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


Current Path : /var/www/html/univadmin/Reports/
Upload File :
Current File : /var/www/html/univadmin/Reports/college_reports_xl.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 college_reports_xl($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    $univcode = $aobj_context->mobj_data["univcode"];
    $rtype = $aobj_context->mobj_data["val"];
    $_deggrp = $aobj_context->mobj_data["deggrp"];
    $deggrp = json_decode($_deggrp,true);

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

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



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

    $collarr = substr_replace($col ,"",-1);

   

    if(strpos($collarr,"All") != ""){
        $cnd = "";
    }else{
      $cnd = "and c.FCOLLCODE in ($collarr)";
    }


    foreach($deggrp as $key => $val){
        $degg .= "'".$val."',";
    }

    $deggrparr = substr_replace($degg ,"",-1);

   

    if(strpos($deggrparr,"All") != ""){
        $cnd1 = "";
    }else{
      $cnd1 = "and d.fdeggrp in ($deggrparr)";
    }



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

    $degreearr = substr_replace($deg ,"",-1);

   

    if(strpos($degreearr,"All") != ""){
        $cnd2 = "";
    }else{
      $cnd2 = "and d.fdegree in ($degreearr)";
    }

    if($rtype == "Active College List" || $rtype == "All College List"){
    $query = "select c.FCOLLCODE as fcollcode, concat(c.fcollname, ',  ', c.ftown) as fcollname,  c.ftown as town, lcase(c.fcolladd1) as fcolladd1 ,lcase(c.fcolladd2) as fcolladd2,
    ifnull(c.fprincipalname,'') as fprincipalname, ifnull(c.fphone,'') as landline, ifnull(c.fmobile,'') as fmobile, ifnull(c.femail,'') as femail,ifnull(c.faltmobile,'') as faltmobile
    from college c
    inner join student s on s.FCOLLCODE = c.FCOLLCODE
    inner join degree d on d.FDEGREE = s.FDEGREE
    where ifnull(c.fdeleted,'') <> 'T' $cnd $cnd1 
    group by c.fcollcode";
    
    }else if($rtype == "degreeWiseCollegeList"){

        $query = "select d.fdegree,d.fdescpn, s.fcollcode, 
        concat(c.fcollname,',  ',c.ftown) as college_name, c.`FPRINCIPALNAME`,  c.fmobile,c.femail 
        from degree d inner join student s on d.fdegree = s.fdegree and d.fexamno = s.fexamno 
        inner join college c on s.fcollcode = c.fcollcode
        where  IFNULL(c.fdeleted,'') <> 'T' 
        $cnd
        $cnd1
        $cnd2
        group by s.fdegree,s.fcollcode
        order by s.fdegree,s.fcollcode"; 

    }else if($rtype == "collwisedeglist"){
        $query = "select d.fdegree,d.fdescpn, s.fcollcode, 
        concat(c.fcollname,',  ',c.ftown) as college_name, c.`FPRINCIPALNAME`,  c.fmobile,c.femail 
        from degree d inner join student s on d.fdegree = s.fdegree and d.fexamno = s.fexamno 
        inner join college c on s.fcollcode = c.fcollcode
        where IFNULL(c.fdeleted,'') <> 'T' 
        $cnd
        $cnd1
        GROUP BY s.fcollcode, s.fdegree
        ORDER BY s.fcollcode, s.fdegree";          
    }

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


    $objPHPExcel = new PHPExcel();
    if($rtype == "Active College List"){
        $fileName = 'Active_College_List';
    }else if($rtype == "All College List"){
        $fileName = 'All_College_List';
    }else if($rtype == "degreeWiseCollegeList"){
        $fileName="Degreewise_College_List";
    }else if($rtype == "collwisedeglist"){
        $fileName = 'Collegewise_Degree_List';
    }
    $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'),
            ),
        ),
    );

    if($rtype == "Active College List" || $rtype == "All College List"){
    $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', 'Principle Name')
        ->setCellValue('E1', 'Mobile No.')
        ->setCellValue('F1', 'Email')
        ->setCellValue('G1', 'Alt. Contact');
    $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->applyFromArray($styleArray);
        
    
    $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(29);
    $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setWrapText(true);
    $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
  
    foreach ($result as $key => $value) {
    $slNo = $key + 2;
    
      $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(6.5);
      $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fcollcode'])->getColumnDimension('B')->setwidth(15);
      $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fcollname'])->getColumnDimension('C')->setwidth(60);
      $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fprincipalname'])->getColumnDimension('D')->setwidth(35);
      $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fmobile'])->getColumnDimension('E')->setwidth(13);
      $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['femail'])->getColumnDimension('F')->setwidth(50);
      $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['faltmobile'])->getColumnDimension('G')->setwidth(14);
      
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':G'. $slNo)->applyFromArray($styleArray);
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo.':B'. $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('E' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('G' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    
        }
    }else if($rtype == "degreeWiseCollegeList"){
    
    $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', 'Degree')
        ->setCellValue('C1', 'Description')
        ->setCellValue('D1', 'College Code')
        ->setCellValue('E1', 'College Name')
        ->setCellValue('F1', 'Prinicipal Name')
        ->setCellValue('G1', 'Email')
        ->setCellValue('H1', 'Mobile No.');
    $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->applyFromArray($styleArray);
        
    
    $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(29);
    $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->getAlignment()->setWrapText(true);
    $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
  
    foreach ($result as $key => $value) {
    $slNo = $key + 2;
    
      $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(6.5);
      $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fdegree'])->getColumnDimension('B')->setwidth(10);
      $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fdescpn'])->getColumnDimension('C')->setwidth(50);
      $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fcollcode'])->getColumnDimension('D')->setwidth(13);
      $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['college_name'])->getColumnDimension('E')->setwidth(60);
      $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['FPRINCIPALNAME'])->getColumnDimension('F')->setwidth(40);
      $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['femail'])->getColumnDimension('G')->setwidth(50);
      $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['fmobile'])->getColumnDimension('H')->setwidth(14);
      
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':H'. $slNo)->applyFromArray($styleArray);
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo.':B'. $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('H' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        }
    }else if($rtype == "collwisedeglist"){
        $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', 'Degree')
            ->setCellValue('C1', 'Description')
            ->setCellValue('D1', 'College Code')
            ->setCellValue('E1', 'College Name')
            ->setCellValue('F1', 'Prinicipal Name')
            ->setCellValue('G1', 'Email')
            ->setCellValue('H1', 'Mobile No.');
        $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->applyFromArray($styleArray);
            
        
        $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(29);
        $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->getAlignment()->setWrapText(true);
        $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    
        foreach ($result as $key => $value) {
        $slNo = $key + 2;
        
        $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(6.5);
        $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fdegree'])->getColumnDimension('B')->setwidth(10);
        $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fdescpn'])->getColumnDimension('C')->setwidth(50);
        $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fcollcode'])->getColumnDimension('D')->setwidth(13);
        $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['college_name'])->getColumnDimension('E')->setwidth(60);
        $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['FPRINCIPALNAME'])->getColumnDimension('F')->setwidth(40);
        $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['femail'])->getColumnDimension('G')->setwidth(50);
        $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['fmobile'])->getColumnDimension('H')->setwidth(14);
        
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':H'. $slNo)->applyFromArray($styleArray);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo.':B'. $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('H' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    }
}
    $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);


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