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


Current Path : /proc/thread-self/root/var/www/html/pms/Reports/
Upload File :
Current File : //proc/thread-self/root/var/www/html/pms/Reports/pmsreport.php

<?php
ini_set('max_execution_time', 60);
$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);
    
    ob_end_clean();
    // ob_start();
    // 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_end_clean();
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    
    $objWriter->save('php://output');
}


function reportAdmFeeSummary($result, $aobj_context)
{

    $objPHPExcel = new PHPExcel();
    $fileName = 'BatchReport';
    $objPHPExcel->getProperties()->setCreator("Me")
    ->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
    ->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
    ->setKeywords("Excel Sheet")->setCategory("Me");
    // $objPHPExcel->setOutputEncoding('UTF-8');
    // Set active sheet index to the first sheet, so Excel opens this as the first sheet
    $objPHPExcel->setActiveSheetIndex(0);

    $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->mobj_db->GetRow($get_coll_name);

    $objPHPExcel->getActiveSheet()->getHeaderFooter()
    ->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME);

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


    // Add column headers and make them bold
    $styleArray = array(
        'borders' => array(
            'allborders' => array(
                'style' => PHPExcel_Style_Border::BORDER_THIN,
                'color' => array('argb' => '000000'),
            ),
        ),
    );

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

    $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.');
    $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Batch No.');
    $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Supplier Name');
    $objPHPExcel->getActiveSheet()->setCellValue('D1', 'Invoice No.');
    $objPHPExcel->getActiveSheet()->setCellValue('E1', 'Invoice Date');
    $objPHPExcel->getActiveSheet()->setCellValue('F1', 'Total Payable');
    $objPHPExcel->getActiveSheet()->setCellValue('G1', 'Status');
        
    
    
    $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->applyFromArray($styleArray);
    // $objPHPExcel->getActiveSheet()->getColumnDimension('G1')->setAutoSize(true);
    $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);

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


    // $objPHPExcel->getActiveSheet()->freezePane('A1');  
    $objPHPExcel->getActiveSheet()->freezePane('A2');              

    $j = 2;
    $slNo = 1;
    $sum = array();
    $totamt=0;
    $totapp=0;
    // setlocale(LC_ALL, 'hi_IN');
    // var_dump($result);die();

    foreach ($result as $key => $value) {

        $objPHPExcel->getActiveSheet()->setCellValue('A' . $j, $slNo)
        ->getColumnDimension('A')->setwidth(5);

        $objPHPExcel->getActiveSheet()->setCellValue('B' . $j, $value['fbatchno'])
        ->getColumnDimension('B')->setwidth(15);

        $objPHPExcel->getActiveSheet()->setCellValue('C' . $j, $value['fsupname'])
        ->getColumnDimension('C')->setwidth(50);

        $objPHPExcel->getActiveSheet()->setCellValue('D' . $j, $value['finvno'])
        ->getColumnDimension('D')->setwidth(25);

        $objPHPExcel->getActiveSheet()->setCellValue('E' . $j, $value['finvdate'])
        ->getColumnDimension('E')->setwidth(20);
        // $objPHPExcel->getActiveSheet()->setCellValue('E' . $j, moneyFormatIndia($value['FAPAYABLE']))
        // ->getColumnDimension('E')->setwidth(20);

        $objPHPExcel->getActiveSheet()->setCellValue('F' . $j, moneyFormatIndia($value['ftpayable']))
        ->getColumnDimension('F')->setwidth(20);

        $objPHPExcel->getActiveSheet()->setCellValue('G' . $j, $value['fstatus'])
        ->getColumnDimension('G')->setwidth(25);

        // $objPHPExcel->getActiveSheet()->setCellValue('H' . $j, $value['FIFSCCODE'])
        // ->getColumnDimension('H')->setwidth(25);


       

        
        
        $objPHPExcel->getActiveSheet()->getRowDimension($j)->setRowHeight(30);
        $j++;$slNo++;
        $totamt += $value['fee'];
        $totapp += $value['fcnt'];
    }
    // var_dump($totamt);die();


    $objPHPExcel->getActiveSheet()->getStyle('A2' . ':G' . $j)->applyFromArray($styleArray);

    $objPHPExcel->getActiveSheet()->getStyle('A2'.':G' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

    $objPHPExcel->getActiveSheet()->getStyle('A2'.':G' . $j)->getAlignment()
    ->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

    $objPHPExcel->getActiveSheet()->getStyle('C2'.':C' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);

    $objPHPExcel->getActiveSheet()->getStyle('D2'.':D' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER);

    $objPHPExcel->getActiveSheet()->getStyle('G2'.':G' . $j)->getAlignment()
    ->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER);



    $objPHPExcel->getActiveSheet()->getStyle('A3' . ':G' . $j)->getAlignment()
    ->setVertical(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

    // $objPHPExcel->getActiveSheet()->getStyle('A1:X1')->getAlignment()
    // ->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    $objPHPExcel->getActiveSheet()->getRowDimension($j)->setRowHeight(30);
    

    $objPHPExcel->getActiveSheet()->getStyle('A3' . ':G' . $j)->getAlignment()
    ->setWrapText(true);

    // $objPHPExcel->getActiveSheet()->setCellValue('G'.$j, moneyFormatIndia($totamt));
    // $objPHPExcel->getActiveSheet()->setCellValue('F'.$j, moneyFormatIndia($totapp));

    // $objPHPExcel->getActiveSheet()->getStyle('A'.$j.':G'.$j)->getFont()->setBold(true);
    // $objPHPExcel->getActiveSheet()->getStyle('A'.$j.':G'.$j)->getFont()->setSize(12);
    
    // $objPHPExcel->getActiveSheet()->mergeCells('A'.$j.':E'.$j)->setCellValue('A'.$j, 'Total');

    // $objPHPExcel->getActiveSheet()->getStyle('G2:G'.$j)->getNumberFormat()->setFormatCode("#,##0");
    // $objPHPExcel->getActiveSheet()->getStyle('F'.$j)->getNumberFormat()->setFormatCode("#,##0");

    

    

    getheaders($objPHPExcel, $fileName);
}


function pmsreport($aobj_context) {
    $batchno = $aobj_context->mobj_data["batchno"];
    $bankcode = $aobj_context->mobj_data["bankcode"];

    // var_dump($batchno,$bankcode);
    // die();


    $query = "select p.fbatchno,p.fsupcode,s.fsupname,p.finvno,date_format(p.finvdate,'%d/%m/%Y') as finvdate, p.ftpayable,
    IF(b.fpayrefno <> '','Payment Made',IF(p.fappstatus='Approved','Approved', IF(p.fchkstatus='Verified','Verified','NO'))) as fstatus
    from pms_payhead p 
    inner join pms_massup s on s.fsupcode = p.fsupcode
    inner join pms_batchinfo b on b.fbatchno = p.fbatchno and b.fsuppcode = p.fsupcode
    order by p.fbatchno;";
     
     //ifnull(fdeggrp,'') = '{$deggrp}' and -------------(removed )


    $result = $aobj_context->mobj_db->GetAll($query);
    // var_dump($query);die();

    reportAdmFeeSummary($result, $aobj_context);


}


function moneyFormatIndia($num)
{
    $explrestunits = "";
    if (strlen($num) > 3) {
        $lastthree = substr($num, strlen($num) - 3, strlen($num));
        $restunits = substr($num, 0, strlen($num) - 3); // extracts the last three digits
        $restunits = (strlen($restunits) % 2 == 1) ? "0" . $restunits : $restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
        $expunit = str_split($restunits, 2);
        for ($i = 0; $i < sizeof($expunit); $i++) {
            // creates each of the 2's group and adds a comma to the end
            if ($i == 0) {
                $explrestunits .= (int) $expunit[$i] . ","; // if is first value , convert into integer
            } else {
                $explrestunits .= $expunit[$i] . ",";
            }
        }
        $thecash = $explrestunits . $lastthree;
    } else {
        $thecash = $num;
    }
    return $thecash; // writes the final format where $currency is the currency symbol.
}