0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.116.28.79


Current Path : /proc/thread-self/root/var/www/oasis/src/
Upload File :
Current File : //proc/thread-self/root/var/www/oasis/src/roomallotmentExcel.php

<?php
$main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('GMT+5:30');
ini_set('max_execution_time', 300);
ini_set('memory_limit', '2G');

if (PHP_SAPI == 'cli')
    die('This example should only be run from a Web Browser');

/** Include PHPExcel */
$pdf_writer_class = $main_src . '/PHPExcel/Classes/PHPExcel.php';
require_once($pdf_writer_class);

function getheaders($objPHPExcel, $fileName)
{
    // To Fit To Page while printing
    ini_set('max_execution_time', '300');
    $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);

    // Redirect output to a client’s web browser (Excel5)
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename=' . $fileName);
    header('Cache-Control: max-age=0');
    // If you're serving to IE 9, then the following may be needed
    header('Cache-Control: max-age=1');

    // If you're serving to IE over SSL, then the following may be needed
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
    header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
    header('Pragma: public'); // HTTP/1.0
    ob_clean();
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    $objWriter->save('php://output');
}

function roomallotmentExcel($aobj_context)
{
    session_start();
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
   
    $collcode=$aobj_context->mobj_data['collocde'];
    $funivcode = $aobj_context->mobj_data['univcode'];
	$fromdate = trim($aobj_context->mobj_data["fromdate"]);
	$session = trim($aobj_context->mobj_data["session"]);
	$rtype = trim($aobj_context->mobj_data["rtype"]);

	if($_SESSION['fexamseparate'] == 'T')
	{
		$candsum = "examcandsum"; 
		$canddet = "examcanddet"; 

	}else
	{
		$candsum = "candsum"; 
		$canddet = "canddet"; 
	}	

	$order = "ORDER BY s.fdoe, d.fhallno, orderby desc, s.fqpcode, s.fsession, d.fregno";
	if($funivcode == '055')
		$order = "ORDER BY s.fdoe, d.fhallno,d.fslno";




	$query = "SELECT DATE_FORMAT(s.fdoe,'%d/%m/%Y') AS fdoe, re.fdescpn AS fsession, d.fhallno, r.froomname, s.fqpcode,
	s.fsubshort, 
	CONCAT(LEFT (s.fsubname, 30)) AS fsubname, d.fregno, 
	(select count(*) from $canddet s1
	where s1.fdegree = s.fdegree and s1.fexamno = s.fexamno and s1.fsubcode = s.fsubcode and s1.fpresent = 'P'
	and s1.fcollcode = '{$collcode}' and s.fdoe =date_format(str_to_date('{$fromdate}','%d/%m/%Y'),'%Y-%m-%d')
	AND s.fsession ='{$session}'
	group by s1.fdegree, s1.fexamno, s1.fsubcode) as orderby	
	FROM $candsum c, $canddet d, subject s, masroom r, reason re 
	WHERE c.fcollcode = d.fcollcode and c.fdegree = d.fdegree
    AND c.fregno = d.fregno AND d.fdegree = s.fdegree
	AND d.fexamno = s.fexamno AND d.fsubcode = s.fsubcode
    AND s.ftheory = 'T'
	AND d.fpresent = 'P' AND IFNULL(s.fqpcode,'') <> ''
    AND re.FREASONCD = s.fsession
	AND c.fcntrcode = r.fcollcode and d.fhallno = r.froomno
    and c.fcntrcode = '{$collcode}'
	and INSTR(c.fhtenable,d.fexamno) >0
	AND s.fdoe = date_format(str_to_date('{$fromdate}','%d/%m/%Y'),'%Y-%m-%d')
	AND IFNULL(c.frecptdate,'') <> '' AND IFNULL(d.fhallno,'') <> '' 
	AND s.fsession ='{$session}'  AND lpad(d.FHALLNO,3,'0') 
	{$order}
	";


	// $query="SELECT DATE_FORMAT(s.fdoe,'%d/%m/%Y') AS fdoe, re.fdescpn AS fsession, d.fhallno, r.froomname, s.fqpcode,s.fsubshort, 
	// 		CONCAT(LEFT (s.fsubname, 30)) AS fsubname, d.fregno, (SELECT COUNT(*) FROM canddet s1
	// 		WHERE s1.fdegree = s.fdegree AND s1.fexamno = s.fexamno AND s1.fsubcode = s.fsubcode AND s1.fpresent = 'P'
	// 		AND s1.fcollcode = '1827' AND s.fdoe = '2024-05-21'
	// 		AND s.fsession LIKE 'M4'GROUP BY s1.fdegree, s1.fexamno, s1.fsubcode) AS orderby	
	// 		FROM candsum c, canddet d, subject s, masroom r, reason re 
	// 		WHERE c.fcollcode = d.fcollcode AND c.fdegree = d.fdegree
	// 		AND c.fregno = d.fregno AND d.fdegree = s.fdegree 
	// 		AND d.fexamno = s.fexamno AND d.fsubcode = s.fsubcode
	// 		AND s.ftheory = 'T' AND d.fpresent = 'P' AND IFNULL(s.fqpcode,'') <> ''
	// 		AND re.FREASONCD = s.fsession AND c.fcntrcode = r.fcollcode AND d.fhallno = r.froomno
	// 		AND c.fcntrcode = '1827' AND INSTR(c.fhtenable,d.fexamno) >0 AND s.fdoe = '2024-05-21'
	// 		AND IFNULL(c.frecptdate,'') <> '' AND IFNULL(d.fhallno,'') <> '' AND s.fsession LIKE 'M4'  AND LPAD(d.FHALLNO,3,'0') 
	// 		ORDER BY s.fdoe, d.fhallno, orderby DESC, s.fqpcode, s.fsession, d.fregno";
	
	$lobj_get_data = $aobj_context->mobj_db->GetAll($query);

   

    $main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
    $main_src=$main_src_obj[1];
    $pdf_writer_class=$aobj_context->main_src."/maya-pdf/fpdf.php";
    $root_pdf_file_download=$aobj_context->main_src."/Report_details/output/report_me_student_list.pdf";
	
	include($pdf_writer_class);		

    $objPHPExcel = new PHPExcel();
    
    $fileName ="Candidates Applied List.xls";
  
    $objPHPExcel->getProperties()->setCreator("Uniclare")
    ->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
    ->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
    ->setKeywords("Excel Sheet")->setCategory("Me");
    
    $objPHPExcel->setActiveSheetIndex(0);
  
    $styleArray = array(
        'borders' => array(
            'allborders' => array(
                'style' => PHPExcel_Style_Border::BORDER_THIN,
                'color' => array('argb' => '000000'),
            ),
        ),
    );

	$alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
           'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ',
           'BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW','BX','BY','BZ',
           'CA','CB','CC','CD','CE','CF','CG','CH','CI','CJ','CK','CL','CM','CN','CO','CP','CQ','CR','CS','CT','CU','CV','CW','CX','CY','CZ'];
 
  	$i=0;
	$roomname='';
	$date='';
	$slno=1;
	$index=6;
	
	foreach($lobj_get_data as $value){
		// var_dump($value);die();
		if($roomname !== $value['froomname']){
			$objPHPExcel->getActiveSheet()->getStyle('1:5')->getFont()->setBold(true);
		
			$objPHPExcel->getActiveSheet()->getStyle('1:5')->getFont()->setSize(12);

			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'1', $value['froomname']);
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'2', $value['fdoe']);
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'3', $value['fsession']);
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'4','QPCODE:'. $value['fqpcode']);
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'5', $value['fsubname']);
		
			$i++;
			$roomname = $value['froomname'];
			$slno=1;
			$index=6;
			
		}
	
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i-1].$index, $slno.'  -  '.$value['fregno']);
			$roomname = $value['froomname'];
			$slno++;
			$index++;

		
			
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i-1].$index , '');
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i-1].($index + 1), '');
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i-1].($index + 2), 'TOTAL PR:');
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i-1].($index + 3), 'Total AB:');
			$objPHPExcel->getActiveSheet()->setCellValue($alpha[$i-1].($index + 4), 'Signature:');

			// $objPHPExcel->getActiveSheet()->getStyle($alpha[$i-1] . ($index + 2))->getFont()->setBold(true);
			// $objPHPExcel->getActiveSheet()->getStyle($alpha[$i-1] . ($index + 3))->getFont()->setBold(true);
			// $objPHPExcel->getActiveSheet()->getStyle($alpha[$i-1] . ($index + 4))->getFont()->setBold(true);
	}

	
   $objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  getheaders($objPHPExcel, $fileName);

}

?>