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.87.225


Current Path : /var/www/html/univadmin/Reports/
Upload File :
Current File : /var/www/html/univadmin/Reports/degreesemister.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');
// PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
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
    $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 . '.xls"');
    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 degreesemister($aobj_context)
{
    $univcode = $aobj_context->mobj_data["univcode"];  
    $fdeggrp = $aobj_context->mobj_data["deggrp"];  
    $fexamtype = $aobj_context->mobj_data["fexamtype"];
    $fyear = $aobj_context->mobj_data["fyear"];
    $rformat = $aobj_context->mobj_data["rformat"];

    $_degree = $aobj_context->mobj_data['degree'];
    $deg = json_decode($_degree,true);

    foreach($deg as $key => $val){
      $degree .= "'".$val."',";
  }
  $degarr = substr_replace($degree ,"",-1);

    if(strpos($degarr,"All") == ""){
      $cnddeg = "and cs.fdegree in ($degarr)";
  }else{
    $cnddeg = "";
  }


  $_college = $aobj_context->mobj_data['college'];
    $col = json_decode($_college,true);

    foreach($col as $key => $val){
      $college .= "'".$val."',";
  }
  $collarr = substr_replace($college ,"",-1);

  if(strpos($collarr,"All") == ""){
    $cndcoll = "and cs.fcollcode in ($collarr)";
}else{
    $cndcoll = "";
}


    
    ini_set('MAX_EXECUTION_TIME', '300');
    
    $query ="SELECT cs.fcollcode,c.fcollname AS college_name,FTOWN,
    cs.fdegree,d.fdescpn,
        SUM(IF(INSTR(cs.fhtenable,'A') >0 and FEXAMFEEA > 0,1,0)) AS Sem_A,
        SUM(IF(INSTR(cs.fhtenable,'B') >0 and FEXAMFEEB > 0,1,0)) AS Sem_B,
        SUM(IF(INSTR(cs.fhtenable,'C') >0 and  FEXAMFEEC > 0,1,0)) AS Sem_C,
        SUM(IF(INSTR(cs.fhtenable,'D') >0 and  FEXAMFEED > 0,1,0)) AS Sem_D,
        SUM(IF(INSTR(cs.fhtenable,'E') >0 and  FEXAMFEEE > 0,1,0)) AS Sem_E,
        SUM(IF(INSTR(cs.fhtenable,'F') >0 and  FEXAMFEEF > 0,1,0)) AS Sem_F,
        SUM(IF(INSTR(cs.fhtenable,'F') >0 and  FEXAMFEEG > 0,1,0)) AS Sem_G,
        SUM(IF(INSTR(cs.fhtenable,'F') >0 and  FEXAMFEEH > 0,1,0)) AS Sem_H,
        SUM(IF(INSTR(cs.fhtenable,'F') >0 and  FEXAMFEEI> 0,1,0)) AS Sem_I,
        SUM(IF(INSTR(cs.fhtenable,'F') >0 and  FEXAMFEEJ > 0,1,0)) AS Sem_J,
        fyear,fexamtype
        FROM candsum cs INNER JOIN college c ON cs.fcollcode = c.fcollcode
        inner join degree d on d.fdegree = cs.fdegree and d.fexamno ='A'
        WHERE cs.fyear = '{$fyear}' and cs.fexamtype = '{$fexamtype}'
        $cndcoll
        $cnddeg
        and cs.fdegree in(SELECT fdegree FROM degree WHERE fdeggrp = '{$fdeggrp}')
        GROUP BY cs.fdegree
        having (Sem_A+Sem_B+Sem_C+Sem_D+Sem_E+Sem_F+Sem_G+Sem_H+Sem_I+Sem_J) >0
        ORDER BY cs.fdegree";
        
    


    $result = $aobj_context->pobj_db->GetAll($query);  

    

    $objPHPExcel = new PHPExcel();
    
    $fileName = 'DEGREE WISE  SEMESTER WISE STUDENT COUNT(EXCEL)';

    $objPHPExcel->getProperties()->setCreator("Uniclare")
    ->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
    ->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
    ->setKeywords("Excel Sheet")->setCategory("Me");

    // Set active sheet index to the first sheet, so Excel opens this as the first sheet
    $objPHPExcel->setActiveSheetIndex(0);
    
    // Add column headers and make them bold
    $styleArray = array(
        'borders' => array(
            'allborders' => array(
                'style' => PHPExcel_Style_Border::BORDER_THIN,
                'color' => array('argb' => '000000'),
            ),
        ),
    );

    $count = "";

    $alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G','H','I','J','K','L','M','N'];
  $j=4;
  $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
  $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
  $objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
  $objPHPExcel->getActiveSheet()->getColumnDimension('D1')->setwidth(15);
//   $objPHPExcel->getActiveSheet()->freezePane('A2');
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Degree')
  ->setCellValue('C1', 'Degree Description')
  ->setCellValue('D1', 'Year')
  ->setCellValue('E1', 'Exam Type')
  ->setCellValue('F1', 'Sem_A')
  ->setCellValue('G1', 'Sem_B')
  ->setCellValue('H1', 'Sem_C')
  ->setCellValue('I1', 'Sem_D')
  ->setCellValue('J1', 'Sem_E')
  ->setCellValue('K1', 'Sem_F')
  ->setCellValue('L1', 'Sem_G')
  ->setCellValue('M1', 'Sem_H')
  ->setCellValue('N1', 'Sem_I')
  ->setCellValue('O1', 'Sem_J')
  ->setCellValue('P1', 'Total');

 

     
  $objPHPExcel->getActiveSheet()->getStyle('A1:P1')->applyFromArray($styleArray);
   $objPHPExcel->getActiveSheet()->getColumnDimension('1')->setAutoSize(true);
  $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
  //$objPHPExcel->getActiveSheet()->getStyle('A1:AI1')->getAlignment()->setWrapText(true);
  $objPHPExcel->getActiveSheet()->getStyle('A1:S1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('A1:S1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
  
  $count=rtrim($count,", ");


  foreach ($result as $key => $value) {     
    $slNo = $key + 2;
    $j=4;
    
    $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(8);     
    $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fdegree'])->getColumnDimension('B')->setwidth(10);    
    $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fdescpn'])->getColumnDimension('C')->setwidth(60);  
    $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fyear'])->getColumnDimension('D')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fexamtype'])->getColumnDimension('E')->setwidth(15);
    $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['Sem_A'])->getColumnDimension('F')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['Sem_B'])->getColumnDimension('G')->setwidth(10);     
    $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['Sem_C'])->getColumnDimension('H')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['Sem_D'])->getColumnDimension('I')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('J' . $slNo, $value['Sem_E'])->getColumnDimension('J')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('K' . $slNo, $value['Sem_F'])->getColumnDimension('K')->setwidth(10);    
    $objPHPExcel->getActiveSheet()->setCellValue('L' . $slNo, $value['Sem_G'])->getColumnDimension('L')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('M' . $slNo, $value['Sem_H'])->getColumnDimension('M')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('N' . $slNo, $value['Sem_I'])->getColumnDimension('N')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('O' . $slNo, $value['Sem_J'])->getColumnDimension('O')->setwidth(10);
    $objPHPExcel->getActiveSheet()->setCellValue('P' . $slNo, "=sum(F".$slNo.":O".$slNo.")")->getColumnDimension('P')->setwidth(10);

   

   
       $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':P'. $slNo)->applyFromArray($styleArray);
       $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':A' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':A' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('B' . $slNo . ':B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('B' . $slNo . ':B' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    //    $objPHPExcel->getActiveSheet()->getStyle('C' . $slNo . ':C' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('C' . $slNo . ':C' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo . ':D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo . ':D' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('E' . $slNo . ':E' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('E' . $slNo . ':E' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('F' . $slNo . ':F' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('F' . $slNo . ':F' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('G' . $slNo . ':G' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('G' . $slNo . ':G' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('H' . $slNo . ':H' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('H' . $slNo . ':H' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('I' . $slNo . ':I' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('I' . $slNo . ':I' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('J' . $slNo . ':J' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('J' . $slNo . ':J' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

       $objPHPExcel->getActiveSheet()->getStyle('K' . $slNo . ':K' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('K' . $slNo . ':K' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

       $objPHPExcel->getActiveSheet()->getStyle('L' . $slNo . ':L' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('L' . $slNo . ':L' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

       $objPHPExcel->getActiveSheet()->getStyle('M' . $slNo . ':M' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('M' . $slNo . ':M' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('N' . $slNo . ':N' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('N' . $slNo . ':N' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('O' . $slNo . ':O' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('O' . $slNo . ':O' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('P' . $slNo . ':P' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
       $objPHPExcel->getActiveSheet()->getStyle('P' . $slNo . ':P' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
       
    
    }


    getheaders($objPHPExcel, $fileName);
}

?>