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


Current Path : /var/www/html/univadmin/Reports/
Upload File :
Current File : /var/www/html/univadmin/Reports/centerwisedegreewiseqpwise.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');
// 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 centerwisedegreewiseqpwise($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);

  
    
    ini_set('MAX_EXECUTION_TIME', '300');
    if($rformat == "centerwisedegreewiseqpwise"){
        if(strpos($collarr,"All") == ""){
            $cndcoll = "and cs.fcntrcode in ($collarr)";
        }else{
            $cndcoll = "";
        }
    $query = "SELECT cs.fcntrcode,c.fcollname,c.ftown,DATE_FORMAT(s.fdoe,'%d/%m/%Y') AS fdoe,r.fdescpn AS fsession,
    cs.fdegree as degree,d.fdescpn, s.fqpcode,s.fsubname,
    COUNT(DISTINCT cd.fregno) AS fcount
    FROM candsum cs INNER JOIN canddet cd ON cs.fregno = cd.fregno 
    AND cd.fcollcode = cs.fcollcode AND cd.fdegree = cs.fdegree
    INNER JOIN subject s ON cd.fdegree = s.fdegree 
    AND cd.fexamno = s.fexamno AND cd.fsubcode = s.fsubcode
    INNER JOIN degree d ON cs.fdegree = d.fdegree AND cd.fexamno = d.fexamno
    inner join college c on cs.fcntrcode = c.fcollcode
    INNER JOIN reason r ON s.fsession = r.freasoncd
    WHERE IFNULL(frecptdate,'') <> ''
    AND cd.fpresent = 'P'
    $cnddeg $cndcoll
    AND IFNULL(cd.fpassmth,'') = ''
    AND cs.fyear = '{$fyear}'
    AND cs.fexamtype = '{$fexamtype}'
    AND IFNULL(s.fqpcode,'') <> ''
    AND d.fdeggrp = '{$fdeggrp}'
    and INSTR(cs.fhtenable,cd.fexamno) >0 
    GROUP BY cs.fcntrcode,cs.fdegree,s.fqpcode
    ORDER BY cs.fcntrcode,s.fqpcode";

}else{
    if(strpos($collarr,"All") == ""){
        $cndcoll = "and cs.fcollcode in ($collarr)";
      }else{
        $cndcoll = "";
      }
    $query ="SELECT cs.fcollcode,c.fcollname,c.ftown,DATE_FORMAT(s.fdoe,'%d/%m/%Y') AS fdoe,r.fdescpn AS fsession,
    cs.fdegree as degree,d.fdescpn, s.fqpcode,s.fsubname,
    COUNT(DISTINCT cd.fregno) AS fcount
    FROM candsum cs INNER JOIN canddet cd ON cs.fregno = cd.fregno 
    AND cd.fcollcode = cs.fcollcode AND cd.fdegree = cs.fdegree
    INNER JOIN subject s ON cd.fdegree = s.fdegree 
    AND cd.fexamno = s.fexamno AND cd.fsubcode = s.fsubcode
    INNER JOIN degree d ON cs.fdegree = d.fdegree AND cd.fexamno = d.fexamno
    inner join college c on cs.fcollcode = c.fcollcode
    INNER JOIN reason r ON s.fsession = r.freasoncd
    WHERE IFNULL(frecptdate,'') <> ''
    AND cd.fpresent = 'P'
    $cnddeg $cndcoll
    AND IFNULL(cd.fpassmth,'') = ''
    AND cs.fyear = '{$fyear}'
    AND cs.fexamtype = '{$fexamtype}'
    AND IFNULL(s.fqpcode,'') <> ''
    AND d.fdeggrp = '{$fdeggrp}'
    and INSTR(cs.fhtenable,cd.fexamno) >0 
    GROUP BY cs.fcollcode,cs.fdegree,s.fqpcode
    ORDER BY cs.fcollcode,s.fqpcode";
    }



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

    

    $objPHPExcel = new PHPExcel();
    if($rformat == "centerwisedegreewiseqpwise"){
    $fileName = 'CENTER WISE DEGREE WISE QP WISE STUDENT COUNT(EXCEL)';
}else{
    $fileName = 'COLLEGE WISE DEGREE WISE QP 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'];
  $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.');
if($rformat == "centerwisedegreewiseqpwise"){
    $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Center Code');
    $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Center Name');
}else{
    $objPHPExcel->getActiveSheet()->setCellValue('B1', 'College Code');
    $objPHPExcel->getActiveSheet()->setCellValue('C1', 'College Name');
}
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'Town');
$objPHPExcel->getActiveSheet()->setCellValue('E1', 'Degree')
  ->setCellValue('F1', 'Degree Description')
  ->setCellValue('G1', 'QP code')
  ->setCellValue('H1', 'Subject Name')
  ->setCellValue('I1', 'Date of Exam')
  ->setCellValue('J1', 'Session')
  ->setCellValue('K1', 'Count');


     
  $objPHPExcel->getActiveSheet()->getStyle('A1:K1')->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:K1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('A1:K1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
  
  $count=rtrim($count,", ");


  foreach ($result as $key => $value) {     
    $slNo = $key + 2;
    $j=4;
    
    if($rformat == "centerwisedegreewiseqpwise"){
        $x = $value['fcntrcode'];
    }else{
     $x = $value['fcollcode'];
    }

      $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(8);
      $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $x)->getColumnDimension('B')->setwidth(20);
      $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fcollname'])->getColumnDimension('C')->setwidth(40);
      $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['ftown'])->getColumnDimension('D')->setwidth(10);
      $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['degree'])->getColumnDimension('E')->setwidth(50);
      $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['fdescpn'])->getColumnDimension('F')->setwidth(20);
      $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fqpcode'])->getColumnDimension('G')->setwidth(15);
      $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['fsubname'])->getColumnDimension('H')->setwidth(40);    
      $objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['fdoe'])->getColumnDimension('I')->setwidth(15);    
      $objPHPExcel->getActiveSheet()->setCellValue('J' . $slNo, $value['fsession'])->getColumnDimension('J')->setwidth(25);
      $objPHPExcel->getActiveSheet()->setCellValue('K' . $slNo, $value['fcount'])->getColumnDimension('K')->setwidth(10);

   

   
       $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':K'. $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('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('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('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('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);
     
      
       $count += $value['fcount'];


    }


    $SL = $slNo+1;
    $objPHPExcel->getActiveSheet()->getStyle('A'.$SL.':K'.$SL)->applyFromArray($styleArray);

    $objPHPExcel->getActiveSheet()->mergeCells('A' . $SL . ':J' . $SL);


    $objPHPExcel->getActiveSheet()->setCellValue('A' . $SL, "TOTAL")->getColumnDimension('A')->setwidth(8);
    $objPHPExcel->getActiveSheet()->setCellValue('K' . $SL, $count)->getColumnDimension('G')->setwidth(10);

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

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


    getheaders($objPHPExcel, $fileName);
}

?>