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


Current Path : /proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/Reports/
Upload File :
Current File : //proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/Reports/ExamFeeDetailsExcel.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 ExamFeeDetailsExcel($aobj_context)
{
    $univcode = $aobj_context->mobj_data["univcode"]; 
    $fdeggrp = $aobj_context->mobj_data["deggrp"];
    $fdegfrom = $aobj_context->mobj_data["fdegfrom"];
    $fdegto = $aobj_context->mobj_data["fdegto"];
    $fcollfrom = $aobj_context->mobj_data["fcollfrom"];
    $fcollto = $aobj_context->mobj_data["fcollto"];


  
    $query = "select  d.fdegree, d.fdescpn, c.fcollcode, c.fcollname, 'A' as examno, 
    SUM(case when ffreshexam='a' then 1 else 0 end) as reg_app, 
    SUM(case when ffreshexam='a' then fexamfeea else 0 end) as reg_fee, 
    SUM(case when ffreshexam<>'a' then 1 else 0 end) as rep_app, 
    SUM(case when ffreshexam<>'a' then fexamfeea else 0 end) as rep_fee
    from candsum cd inner join degree d on cd.fdegree=d.fdegree and  cd.fexamno=d.fexamno
    inner join college c on cd.fcollcode = c.fcollcode
    where d.fdeggrp ='{$fdeggrp}' and d.fdegree between '{$fdegfrom}' and '{$fdegto}' 
    and c.fcollcode between '{$fcollfrom}' and '{$fcollto}'
    and fexamfeea>0  group by c.fcollcode, d.fdegree
    union
    select  d.fdegree, d.fdescpn, c.fcollcode, c.fcollname,'B' as examno, 
    SUM(case when ffreshexam='b' then 1 else 0 end) as reg_app, 
    SUM(case when ffreshexam='b' then fexamfeeb else 0 end) as reg_fee, 
    SUM(case when ffreshexam<>'b' then 1 else 0 end) as rep_app, 
    SUM(case when ffreshexam<>'b' then fexamfeeb else 0 end) as rep_fee 
    from candsum cd inner join degree d on cd.fdegree=d.fdegree and  cd.fexamno=d.fexamno
    inner join college c on cd.fcollcode = c.fcollcode
    where d.fdeggrp ='{$fdeggrp}' and d.fdegree between '{$fdegfrom}' and '{$fdegto}' 
    and c.fcollcode between '{$fcollfrom}' and '{$fcollto}'
    and fexamfeeb>0 group by c.fcollcode, d.fdegree
    union
    select d.fdegree, d.fdescpn, c.fcollcode, c.fcollname,'C' as examno, 
    SUM(case when ffreshexam='c' then 1 else 0 end) as reg_app, 
    SUM(case when ffreshexam='c' then fexamfeec else 0 end) as reg_fee, 
    SUM(case when ffreshexam<>'c' then 1 else 0 end) as rep_app, 
    SUM(case when ffreshexam<>'c' then fexamfeec else 0 end) as rep_fee
    from candsum cd inner join degree d on cd.fdegree=d.fdegree and  cd.fexamno=d.fexamno
    inner join college c on cd.fcollcode = c.fcollcode 
    where d.fdeggrp ='{$fdeggrp}' and d.fdegree between '{$fdegfrom}' and '{$fdegto}' 
    and c.fcollcode between '{$fcollfrom}' and '{$fcollto}'
    and fexamfeec>0  group by c.fcollcode, fdegree
    union
    select d.fdegree, d.fdescpn, c.fcollcode, c.fcollname,'D' as examno, 
    SUM(case when ffreshexam='d' then 1 else 0 end) as reg_app, 
    SUM(case when ffreshexam='d' then fexamfeed else 0 end) as reg_fee, 
    SUM(case when ffreshexam<>'d' then 1 else 0 end) as rep_app, 
    SUM(case when ffreshexam<>'d' then fexamfeed else 0 end) as rep_fee 
    from candsum cd inner join degree d on cd.fdegree=d.fdegree and  cd.fexamno=d.fexamno
    inner join college c on cd.fcollcode = c.fcollcode
    where d.fdeggrp ='{$fdeggrp}' and d.fdegree between '{$fdegfrom}' and '{$fdegto}' 
    and c.fcollcode between '{$fcollfrom}' and '{$fcollto}'
    and fexamfeed>0  group by c.fcollcode, fdegree
    union
    select d.fdegree, d.fdescpn,  c.fcollcode, c.fcollname,'E' as examno, 
    SUM(case when ffreshexam='e' then 1 else 0 end) as reg_app, 
    SUM(case when ffreshexam='e' then fexamfeee else 0 end) as reg_fee, 
    SUM(case when ffreshexam<>'e' then 1 else 0 end) as rep_app, 
    SUM(case when ffreshexam<>'e' then fexamfeee else 0 end) as rep_fee
    from candsum cd inner join degree d on cd.fdegree=d.fdegree and  cd.fexamno=d.fexamno
    inner join college c on cd.fcollcode = c.fcollcode
    where d.fdeggrp ='{$fdeggrp}' and d.fdegree between '{$fdegfrom}' and '{$fdegto}' 
    and c.fcollcode between '{$fcollfrom}' and '{$fcollto}'
    and fexamfeee>0    group by c.fcollcode, fdegree
    union
    select d.fdegree, d.fdescpn, c.fcollcode, c.fcollname, 'F' as examno, 
    SUM(case when ffreshexam='f' then 1 else 0 end) as reg_app, 
    SUM(case when ffreshexam='f' then fexamfeef else 0 end) as reg_fee, 
    SUM(case when ffreshexam<>'f' then 1 else 0 end) as rep_app, 
    SUM(case when ffreshexam<>'f' then fexamfeef else 0 end) as rep_fee
    from candsum cd inner join degree d on cd.fdegree=d.fdegree and  cd.fexamno=d.fexamno
    inner join college c on cd.fcollcode = c.fcollcode
    where d.fdeggrp ='{$fdeggrp}' and d.fdegree between '{$fdegfrom}' and '{$fdegto}' 
    and c.fcollcode between '{$fcollfrom}' and '{$fcollto}'
    and fexamfeef>0   group by cd.fyear, cd.fexamtype, c.fcollcode, d.fdegree";
   
       $result = $aobj_context->pobj_db->GetAll($query);  
       /*var_dump($result);
       var_dump($query);
       die();*/
    

    $objPHPExcel = new PHPExcel();
    $fileName = 'ExamFeeDetailsExcel';
    $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', 
    'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC',
    'AD', 'AF', 'AE', 'AF', 'AG', 'AH'
  ];
  $j=4;
  $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
  $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
  $objPHPExcel->getActiveSheet()->freezePane('A1');
  $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.')
  ->setCellValue('B1', 'College Code')
  ->setCellValue('C1', 'College Name')
  ->setCellValue('D1', 'Degree Code')
  ->setCellValue('E1', 'Degree Name')
  ->setCellValue('F1', 'Semester')
  ->setCellValue('G1', 'Reg.App')
  ->setCellValue('H1', 'Reg.Fee')
  ->setCellValue('I1', 'Rep.App')
  ->setCellValue('J1', 'Rep.Fee');
      
  $objPHPExcel->getActiveSheet()->getStyle('A1:J1')->applyFromArray($styleArray);
  
  // $objPHPExcel->getActiveSheet()->getColumnDimension('I1')->setAutoSize(true);
  $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(29);
  $objPHPExcel->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setWrapText(true);
  $objPHPExcel->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('A1:J1')->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(6.5);
      $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fcollcode'])->getColumnDimension('B')->setwidth(9);
      $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fcollname'])->getColumnDimension('C')->setwidth(50);
      $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fdegree'])->getColumnDimension('D')->setwidth(9);
      $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fdescpn'])->getColumnDimension('E')->setwidth(45);
      $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['examno'])->getColumnDimension('F')->setwidth(12);
      $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['reg_app'])->getColumnDimension('G')->setwidth(12);
      $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['reg_fee'])->getColumnDimension('H')->setwidth(14);
      $objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['rep_app'])->getColumnDimension('I')->setwidth(12);
      $objPHPExcel->getActiveSheet()->setCellValue('J' . $slNo, $value['rep_fee'])->getColumnDimension('J')->setwidth(14);
      $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setwidth(12);
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':J'. $slNo)->applyFromArray($styleArray);
      
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_JUSTIFY);
      $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_JUSTIFY);
      $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

      $objPHPExcel->getActiveSheet()->getStyle('E' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('E' . $slNo )->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
      $objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
      $objPHPExcel->getActiveSheet()->getStyle('F' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('G' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); 
      $objPHPExcel->getActiveSheet()->getStyle('H' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('I' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('J' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setWrapText(true);
      $objPHPExcel->getActiveSheet()->getStyle('E' . $slNo)->getAlignment()->setWrapText(true);
   
     
    }

    $objPHPExcel->getActiveSheet()->setTitle($fileName);
    $objPHPExcel->getActiveSheet()->getPageSetup()
    ->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
    
    $get_coll_name = "select FUNIVNAME as 'FUNIVNAME',FUNIVCODE,
    FUNIVADD1 as 'state', pdf_logo_path,
    ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control";

    $lobj_get_coll_name = $aobj_context->pobj_db->GetRow($get_coll_name);

    // $deggrp = $aobj_context->mobj_data["dgp"];
    // $query = "select distinct concat(fexamdate,' ',' Examination') as fexamdate 
    // from deggrp where fdeggrp = '{$deggrp}'";
    // $results = $aobj_context->pobj_db->GetRow($query);

    $aobj_context->FUNIVNAME = $lobj_get_coll_name['FUNIVNAME'];
    $aobj_context->s_state = $lobj_get_coll_name['state'];
    $aobj_context->pdf_logo_path = $lobj_get_coll_name['pdf_logo_path'];
    $aobj_context->FUNIVCODE = $lobj_get_coll_name['FUNIVCODE'];    
    // die();

    // $objPHPExcel->getActiveSheet()->getHeaderFooter()->addImage($aobj_context->main_src.'img/'.$aobj_context->FUNIVCODE.'_logo.jpg', PHPExcel_Worksheet_HeaderFooter::IMAGE_HEADER_LEFT);
    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME . "\n" . '&12' . $rtype);
    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H'.$deggrp);

    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&RPage &P of &N');

    getheaders($objPHPExcel, $fileName);
}

?>