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 : 3.147.51.72


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/attiacombinedReportnewexcel_sjbit.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 attiacombinedReportnewexcel_sjbit($aobj_context)
{
    session_start();
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
   
    $collcode=$_SESSION['collcode'];
   
    $teachcode = $aobj_context->mobj_data["teachcode"];
    $degcode=trim($aobj_context->mobj_data["degcode"]);
    $section=trim($aobj_context->mobj_data["section"]);
    $sem=trim($aobj_context->mobj_data["sem"]);

    $classid = $aobj_context->mobj_data["classid"];
    $subelement = $aobj_context->mobj_data["subelement"];
    $txtmarks = $aobj_context->mobj_data["txtmarks"];
    $txtunits = $aobj_context->mobj_data["txtunits"];
    $testName = $aobj_context->mobj_data["testName"];
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

 $split = explode("*", $subelement);
    $subelement = $split[0];
    $subdet = $split[1];
	

	$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);		



	$page_header_university = "select concat(FUNIVNAME,', ',FTOWN) as FUNIVNAME, '' as FTOWN, date_format(now(),'%d/%m/%Y') as date from control";
	$lobj_page_header_university = $aobj_context->mobj_db->GetRow($page_header_university);
	
  $collcode=$_SESSION['collcode'];
	$page_header_college ="select concat('[ ',FCOLLCODE,' ]  ',FCOLLNAME,', ',FTOWN) as college_name
							from college where FCOLLCODE='{$collcode}'";
       $lobj_page_header_college = $aobj_context->mobj_db->GetRow($page_header_college); 


	$page_header_degree = "select concat('[ ',FDEGREE,' ] - ', FDESCPN) as Degree_name, 
							concat('( ', FEXAMNAME ,' Examination ',FEXAMDATE,')') as Exam ,FADYEAR
							from degree where FDEGREE = '{$degcode}' and FEXAMNO='{$sem}' ";
             
	$lobj_page_header_degree = $aobj_context->mobj_db->GetRow($page_header_degree);
	
	$page_header_REGROLL = "select FREGROLL from control";
		$lobj_page_header_REGROLL = $aobj_context->mobj_db->GetRow($page_header_REGROLL);

    $headerQry = "select a.fclassname, s.fsubname, m.fdegree, m.ftest from marksint m 
                inner join subject s on left(s.fcsubcode, 4) = left(m.fsubcode, 4) 
                and m.fdegree = s.fdegree and m.fexamno = s.fexamno
                inner join attendsum sum on sum.fdegree = m.fdegree and 
                left(sum.fsubcode, 4) = left(m.fsubcode, 4)
                inner join attclass a on a.fclassid = sum.fclassid 
                where sum.fclassid='{$classid}'
                and m.fcollcode = '{$collcode}' 
                and m.fsubcode='{$subelement}' 
                and m.ftest='{$testName}' group by m.fsubcode, a.fclassid";

    $lobj_page_header = $aobj_context->mobj_db->GetRow($headerQry);
	
   		
	$get_student_data = ""; 
		  
	$lobj_get_student_data = $aobj_context->mobj_db->GetAll($get_student_data);	
	$page_header_FEEZEDorNOT = "select if(FCMESTATUS is null,'NOT CONFIRMED',concat('CONFIRMED(',FCMESTATUS,')')) as MESTATUS								
								from colldeg where fcollcode='{$collcode}'
								and fdegree='{$degcode}'";
	$lobj_page_header_FEEZEDorNOT = $aobj_context->mobj_db->GetRow($page_header_FEEZEDorNOT);
	$pdf->REPORT_STATUS=$lobj_page_header_FEEZEDorNOT['MESTATUS'];
	
	// $pdf->AddPage('L');
	// $pdf->SetFont('Courier','',9);
    $query = "select distinct fcollcode,fdegree,fexamno from attendsum where fclassid = '{$classid}'";
    $res=$aobj_context->mobj_db->GetRow($query);
	$collcode = $res['fcollcode'];
	$degree = $res['fdegree'];
	$exam = $res['fexamno'];


    $get_coll_name="select FUNIVNAME as 'FUNIVNAME',FUNIVCODE,
    FUNIVADD1 as 'state', pdf_logo_path From control";
$lobj_get_coll_name=$aobj_context->mobj_db->GetRow($get_coll_name);

$FUNIVNAME=$lobj_get_coll_name['FUNIVNAME'];
$s_state=$lobj_get_coll_name['state'];
$f_year=$lobj_get_coll_name['f_year'];
$pdf_logo_path=$lobj_get_coll_name['pdf_logo_path'];
$funivcode=$lobj_get_coll_name['FUNIVCODE'];



$get_data="SELECT c.FCOLLCODE,
CONCAT(c.FCOLLCODE, ' - ', c.FCOLLNAME,', ',c.FTOWN) AS FCOLLNAME FROM college c
where c.FCOLLCODE='{$collcode}'";	


$obj_student=$aobj_context->mobj_db->GetRow($get_data); 

$college_details = $obj_student['FCOLLNAME'];
$FCOLLCODE = $obj_student['FCOLLCODE'];
$degree_details  = " College : {$FCOLLNAME}";

$get_data="SELECT d.fdegree,d.fdescpn,d.fexamname,d.fexamdate
from degree d
where d.fdegree='{$degcode}'
and d.fexamno = '{$sem}'";					
$degdata=$aobj_context->mobj_db->GetRow($get_data); 
$degree_name = $degdata['fdegree'].' - '.$degdata['fdescpn'].' '.$degdata['fexamname'].' '.$degdata['fexamdate'];

$collcode=$_SESSION['collcode'];
    $query = "select distinct fsubshort from subject s 
    inner join marks m on s.fdegree= m.fdegree
    and s.fexamno = m.fexamno 
    and s.fcsubcode = m.fsubcode
    inner join student st on m.fregno = st.fregno
    and m.fdegree = st.fdegree
    where m.fdegree = '{$degcode}'
    and st.fsection ='{$section}'
    and m.fexamno = '{$sem}'
    and m.fcollcode = '{$collcode}'
    order by fsubcode";
    // var_dump($query);
    // die();
    $subhead = $aobj_context->mobj_db->GetAll($query);

    $query = "select m.fregno,st.fname,
    ifnull(s.fattent,'') as fattent,
    group_concat(s.fvalmax, '|','','|',ifnull(m.fmarks,'-'),'|',s.fsubshort,'|',ifnull(s.fattent,'') order by s.fsubcode SEPARATOR '*' ) as subdet 
    from marks m 
    inner join student st on m.fregno = st.fregno and m.fcollcode = st.fcollcode
    and m.fdegree = st.fdegree
    inner join subject s on m.fdegree = s.fdegree and m.fexamno = s.fexamno 
    and m.fsubcode = s.fcsubcode
    where m.fdegree = '{$degcode}'
    and st.fsection ='{$section}'
    and m.fexamno = '{$sem}'

    and m.fcollcode = '{$collcode}'
    group by m.fregno";

    // var_dump($query);
    // die();

    $res = $aobj_context->mobj_db->GetAll($query);

   $subcount = 0;
		foreach($res as $val){
			if(count(explode('*',$val['subdet'])) > $subcount){
				$subcount = count(explode('*',$val['subdet']));
			}
		}
   $objPHPExcel = new PHPExcel();
    
   $fileName = 'student_ia_marks_det.xls';
   // var_dump($subdet);die();
    
   $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'),
            ),
        ),
    );

    $attArr=['D', 'G', 'J', 'M', 'P', 'S', 'V', 'Y', 'AB', 'AE'];
    $cieArr=['E', 'H', 'K', 'N', 'Q', 'T', 'W', 'Z', 'AC', 'AF'];
    $eligArr=['F', 'I', 'L', 'O', 'R', 'U', 'X', 'AA', 'AD', 'AG'];

    $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
    $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
    $objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
    $objPHPExcel->getActiveSheet()->freezePane('A2');


    $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl No.');
    $objPHPExcel->getActiveSheet()->setCellValue('B1', 'USN');
    $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Name');

    for($i=0; $i<$subcount; $i++){
      $objPHPExcel->getActiveSheet()->setCellValue($attArr[$i].'1', 'Att.');
      $objPHPExcel->getActiveSheet()->setCellValue($cieArr[$i].'1', 'CIE');
      $objPHPExcel->getActiveSheet()->setCellValue($eligArr[$i].'1', 'Elig.');

      
      $objPHPExcel->getActiveSheet()->getStyle('A1:'.$eligArr[$i].'1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('A1:'.$eligArr[$i].'1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    }
   
    $merge=2;
    $sl = 1;
    $z=3;
    foreach ($res as $key => $value) {     
      $slNo = $key + 2;
    
      $split = explode("*", $value['subdet']);
     

        // $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
    
        $objPHPExcel->getActiveSheet()->setCellValue('A' . $merge, $sl)->getColumnDimension('A')->setwidth(8);
        $objPHPExcel->getActiveSheet()->setCellValue('B' . $merge, $value['fregno'])->getColumnDimension('B')->setwidth(15);
        $objPHPExcel->getActiveSheet()->setCellValue('C' . $merge, $value['fname'])->getColumnDimension('C')->setwidth(35);
        
        $merge1 = $merge;
        $merge2 = $merge + 1;
        $objPHPExcel->getActiveSheet()->mergeCells('A'.$merge1.':A'.$merge2);
        $objPHPExcel->getActiveSheet()->mergeCells('B'.$merge1.':B'.$merge2);
        $objPHPExcel->getActiveSheet()->mergeCells('C'.$merge1.':C'.$merge2);
     


        for($i=0; $i<count($split); $i++){
          $split_again = explode("|", $split[$i]);

          $att = $split_again[0];
          $cie = $split_again[1];
          $eli = $split_again[2];
          $subshort = $split_again[3];
    

          $objPHPExcel->getActiveSheet()->setCellValue($attArr[$i].$merge, $subshort);
          $objPHPExcel->getActiveSheet()->mergeCells($attArr[$i].$merge.':'.$eligArr[$i].$merge);

          $objPHPExcel->getActiveSheet()->setCellValue($attArr[$i].$z, $att);
          $objPHPExcel->getActiveSheet()->getStyle($attArr[$i].$z, $att)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
          
          $objPHPExcel->getActiveSheet()->setCellValue($cieArr[$i].$z, $cie);
          $objPHPExcel->getActiveSheet()->getStyle($cieArr[$i].$z, $cie)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

          $objPHPExcel->getActiveSheet()->setCellValue($eligArr[$i].$z, $eli);
          $objPHPExcel->getActiveSheet()->getStyle($eligArr[$i].$z, $eli)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

          $objPHPExcel->getActiveSheet()->getStyle($attArr[$i].$merge.':'.$eligArr[$i].$merge)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
          $objPHPExcel->getActiveSheet()->getStyle($attArr[$i].$merge.':'.$eligArr[$i].$merge)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
          $objPHPExcel->getActiveSheet()->getStyle('A1'.':'.$eligArr[$i].$merge)->applyFromArray($styleArray);

          // $objPHPExcel->getActiveSheet()->mergeCells($attArr[$i].$merge1.':'.$eligArr[$i].$merge2);

          // $objPHPExcel->getActiveSheet()->setCellValue($cieArr[$i].$slNo, $cie);
          // $objPHPExcel->getActiveSheet()->mergeCells($attArr[$i].$merge1.':'.$eligArr[$i].$merge2);
          
          // $objPHPExcel->getActiveSheet()->setCellValue($eligArr[$i].$slNo, $eli);
          // $objPHPExcel->getActiveSheet()->mergeCells($attArr[$i].$merge1.':'.$eligArr[$i].$merge2);



        }
        $merge += 2;
        $sl++;
        $z+=2;
   }
    getheaders($objPHPExcel, $fileName);
}

?>