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


Current Path : /proc/thread-self/root/var/www/html/pgadm/admin-src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/pgadm/admin-src/SeatMatrixReport.php

<?php
$main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
$pdf_writer_class = $main_src . "/tcpdf/tcpdf.php";
require_once $pdf_writer_class;
// ini_set('memory_limit','900M');
// ini_set('max_execution_time',0);

class MYPDF extends TCPDF
{
    public function Header()
    {
        // get the current page break margin
        $bMargin = $this->getBreakMargin();
        // get current auto-page-break mode
        $auto_page_break = $this->AutoPageBreak;
        // disable auto-page-break
        $this->SetAutoPageBreak(false, 0);
        $this->SetTitle("SeatMatrixReport");

        // set bacground image
        $this->SetFillColor(248, 248, 255);
        $img_path = $this->aobj_context->main_src . "/img/logo.jpg";

        if (file_exists($img_path)) {
            $this->Image($img_path, 6, 6, 20, 20);
        }

        $this->SetFont('Times', 'B', 13);
        $this->SetY(5);
        $this->Cell(0, 4, $this->aobj_context->FUNIVNAME, 0, 1, 'C');
        //state
        $this->SetFont('Times', '', 11);
        $this->Cell(0, 4, $this->aobj_context->s_state, 0, 1, 'C');

        $this->SetFont('Times', 'BU', 14);
        $this->Ln(1);

        $cur_year = date("Y");
        $this->Cell(0, 5, 'SeatMatrixReport', '0', 1, 'C');
        $this->SetFont('Times', 'B', 12);
        // var_dump($this->doe);
       // $this->Cell(0, 6, " Degree Group: " . $this->aobj_context->mobj_data["deggrp"], "0", 1, "C");
      //  $this->Cell(0, 6, " Degree Range: " . $this->aobj_context->mobj_data["fdegfrom"] . ' - ' . $this->aobj_context->mobj_data["fdegto"], "0", 1, "C");
        // restore auto-page-break status
        $this->SetAutoPageBreak($auto_page_break, $bMargin);
        // set the starting point for the page content
    }

    public function Footer()
    {
        $this->SetY(-15);
        $this->SetFont('helvetica', 'I', 8);
        // var_dump();
        if($this->CurOrientation == 'P')
        {
            $this->Cell(60, 10, 'IP : ' . $_SERVER["REMOTE_ADDR"], 0, 0, 'L');
            $this->Cell(60, 10, 'Date : ' . date("d-m-Y h:i:s A"), 0, 0, 'C');
            $this->Cell(60, 10, 'Page ' . $this->getPageNumGroupAlias() . '/' . $this->getPageGroupAlias(), 0, 1, 'R');
        }
        else {
            $this->Cell(90, 10, 'IP : ' . $_SERVER["REMOTE_ADDR"], 0, 0, 'L');
            $this->Cell(90, 10, 'Date : ' . date("d-m-Y h:i:s A"), 0, 0, 'C');
            $this->Cell(90, 10, 'Page ' . $this->getPageNumGroupAlias() . '/' . $this->getPageGroupAlias(), 0, 1, 'R');
        }
    }
}

class ReprtObject
{

    public function DefaultConstructor($aobj_context)
    {
        $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);
        $this->reportType = $aobj_context->mobj_data["rtype"];

        $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->mobj_db->GetRow($get_coll_name);
// var_dump($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'];

        $this->current_date = $obj['now_date'];
        $deggrp = $this->aobj_context->mobj_data["deggrp"];

       $get_coll_name = "select concat(fdeggrp, ' - ', fdescpn) as fdeggrp 
        from deggrp where fdeggrp = '{$deggrp}'";
        $lobj_get_degree = $this->aobj_context->mobj_db->GetRow($get_coll_name);
        
        $aobj_context->deggrp = $lobj_get_degree['fdeggrp'];
        $this->pdf = new MYPDF('P');
        $this->pdf->aobj_context = $aobj_context;
    }

    public function Header($pdf)
    {

        $pdf->SetFont('Times', 'B', 10);
        $pdf->Cell(12, 7, "Sl.No", "LTR", 0, "C");
        $pdf->Cell(26, 7, "Degree", "LTR", 0, "C");
        $pdf->Cell(22, 7, "College Code", "LTR", 0, "C");
        $pdf->Cell(62, 7, "HKGMTOT", "LTR", 0, "C");
        $pdf->Cell(22, 7, "HKGMALLOT", "LRT", 0, "C");
        $pdf->Cell(18, 7, "HKGMPEND", "LRT", 0, "C");
        $pdf->Cell(18, 7, "HKGMCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKCATITOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKCATIALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKCATIPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKCATICAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIATOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIAALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIAPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIACAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIBTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIBALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIBPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIBCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIIATOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIIAALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIIAPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIIACAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIIBTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIIBALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIIBPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKIIIBCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKSCTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKSCALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKSCPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKSCCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKSTTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKSTALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKSTPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "HKSTCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKGMTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKGMALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKGMPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKGMCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKCATITOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKCATIALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKCATIPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKCATICAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIATOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIAALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIAPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIACAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIBTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIBALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIBPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIBCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIIATOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIIAALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIIAPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIIACAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIIBTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIIBALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIIBPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKIIIBCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKSCTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKSCALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKSCPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKSCCAN", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKSTTOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKSTALLOT", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKSTPEND", "LRT", 0, "C");
        $pdf->Cell(16, 7, "NHKSTCAN", "LRT", 1, "C");
          

       
        /*$pdf->Cell(12, 7, "", "LRB", 0, "C");
        $pdf->Cell(26, 7, "", "LRB", 0, "C");
        $pdf->Cell(22, 7, "", "LRB", 0, "C");
        $pdf->Cell(60, 7, "", "LRB", 0, "C");
        $pdf->Cell(22, 7, "", "LRB", 0, "C");
        $pdf->Cell(18, 7, "", "LRB", 0, "C");
        $pdf->Cell(18, 7, "", "LRB", 0, "C");
        $pdf->Cell(21, 7, "Karnataka", "LRB", 1, "C");
        $pdf->SetFont('Times', '', 12);*/
       
    }

    public function Report($data)
    {
        $pdf = $this->pdf;

        $pdf->SetMargins(07, 35);
        $pdf->startPageGroup();
        $pdf->AddPage('P','A3');

        $pdf->SetFont('Times', '', 10);

        $oldCode = "";
        $newCode = "";
        $sl_no = 1;
        $first = true;
        $j = 0;
        // var_dump($exattendancelist);
        $this->Header($pdf);
        foreach ($data as $key => $value) {
      
         $newCode = $value['fappno'];
        

            if ($pdf->getY() > 250) {
               $pdf->AddPage('P','A3');
                $pdf->SetFont('Times', ' ', 12);
               // $pdf->cell(267, 8, $j. '. ' . $value['fdegree'] . ' - ' . $value['fdescpn'], 1, 1, "C");
                $this->Header($pdf);
                $pdf->SetFont('Times', '', 10);
            }
            if ($pdf->getY() > 260) 
            {
                $pdf->AddPage('P','A3');
                $pdf->SetFont('Times', 'B', 12);
                //$pdf->cell(262, 8, $j. '. ' . $value['fappno'] , 1, 1, "C");
                $this->Header($pdf);
                $pdf->SetFont('Times', '', 10);
            }
             
            $pdf->SetFont('Times', '', 10);
           
            $pdf->Cell(12, 7, $sl_no, "1", 0, "C");
            $pdf->Cell(26, 7, $value['Degree'], "1", 0, "C");
            $pdf->Cell(22, 7, $value["College Code"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKGMTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKGMALLOT"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKGMPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKGMCAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKCATITOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKCATIALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKCATIPEND"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKCATICAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIATOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIAALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIAPEND"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIACAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIBTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIBALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIBPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIBCAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIIATOT"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIIAALLOT"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIIAPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIIACAN"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIIBTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIIBALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIIBPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKIIIBCAN"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKSCTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKSCALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKSCPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKSCCAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKSTTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKSTALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKSTPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["HKSTCAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKGMTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKGMALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKGMPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKGMCAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKCATITOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKCATIALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKCATIPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKCATICAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIATOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIAALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIAPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIACAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIBTOT"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIBALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIBPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIBCAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIIATOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIIAALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIIAPEND"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIIACAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIIBTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIIBALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIIBPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKIIIBCAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKSCTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKSCALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKSCPEND"], "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKSCCAN"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKSTTOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKSTALLOT"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKSTPEND"],  "1", 0, "C");
            $pdf->Cell(22, 7, $value["NHKSTCAN"],  "1", 1, "C");
            $sl_no++;
        }
                        $oldCode = $value['fappno'];
          /*  $this->pdf->SetFont('Times', 'B', 10);
            //$this->pdf->Cell(10, 6, "", "1", 0, "C");
            $this->pdf->Cell(130, 6, "Grand Total", "1", 0, "C");
            $this->pdf->Cell(21, 6, moneyFormatIndia($a), "1", 0, "C");
            $this->pdf->Cell(21, 6, moneyFormatIndia($b), "1", 0, "C");
            $this->pdf->Cell(21, 6, moneyFormatIndia($c), "1", 0, "C");
            $this->pdf->Cell(21, 6, moneyFormatIndia($d), "1", 0, "C");
            $this->pdf->Cell(21, 6, moneyFormatIndia($e), "1", 0, "C");
            $this->pdf->Cell(21, 6, moneyFormatIndia($f), "1", 0, "C");
            $this->pdf->Cell(20, 6, moneyFormatIndia($g), "1", 0, "C");*/

    }       



    public function SendOutput()
    {
        // ob_end_clean();
        $this->pdf->Output("SeatMatrixReport", "I");
    }
}

/*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.
}
*/
function SeatMatrixReport($aobj_context)
{
   // $univcode = $aobj_context->mobj_data["univcode"];  

   // $fdeggrp = $aobj_context->mobj_data["deggrp"];
    
   // $fdeggrpfrm = $aobj_context->mobj_data["deggrpfrm"];
  //  $fdeggrpto = $aobj_context->mobj_data["deggrpto"];
    //$fdegfrom = $aobj_context->mobj_data["fdegfrom"];
    //$fdegto = $aobj_context->mobj_data["fdegto"];

    $query = "select a.fdegree, a.fcollcode, SUM(IFNULL(a.HKGMTOT,0)) as HKGMTOT, SUM(IFNULL(a.HKGMALLOT,0)) as HKGMALLOT, SUM(IFNULL(a.HKGMPEND,0)) as HKGMPEND, SUM(IFNULL(a.HKGMCAN,0)) as HKGMCAN, 
SUM(IFNULL(a.HKCATITOT,0)) as HKCATITOT, SUM(IFNULL(a.HKCATIALLOT,0)) as HKCATIALLOT, SUM(IFNULL(a.HKCATIPEND,0)) as HKCATIPEND, SUM(IFNULL(a.HKCATICAN,0)) as HKCATICAN,
SUM(IFNULL(a.HKIIATOT,0)) as HKIIATOT,  SUM(IFNULL(a.HKIIAALLOT,0)) as HKIIAALLOT, SUM(IFNULL(a.HKIIAPEND,0)) as HKIIAPEND, SUM(IFNULL(a.HKIIACAN,0)) as HKIIACAN,
SUM(IFNULL(a.HKIIBTOT,0)) as HKIIBTOT, SUM(IFNULL(a.HKIIBALLOT,0)) as HKIIBALLOT, SUM(IFNULL(a.HKIIBPEND,0)) as HKIIBPEND, SUM(IFNULL(a.HKIIBCAN,0)) as HKIIBCAN,
SUM(IFNULL(a.HKIIIATOT,0)) as HKIIIATOT, SUM(IFNULL(a.HKIIIAALLOT,0)) as HKIIIAALLOT, SUM(IFNULL(a.HKIIIAPEND,0)) as HKIIIAPEND, SUM(IFNULL(a.HKIIIACAN,0)) as HKIIIACAN,
SUM(IFNULL(a.HKIIIBTOT,0)) as HKIIIBTOT, SUM(IFNULL(a.HKIIIBALLOT,0)) as HKIIIBALLOT, SUM(IFNULL(a.HKIIIBPEND,0)) as HKIIIBPEND, SUM(IFNULL(a.HKIIIBCAN,0)) as HKIIIBCAN,
SUM(IFNULL(a.HKSCTOT,0)) as HKSCTOT, SUM(IFNULL(a.HKSCALLOT,0)) as HKSCALLOT, SUM(IFNULL(a.HKSCPEND,0)) as HKSCPEND, SUM(IFNULL(a.HKSCCAN,0)) as HKSCCAN,
SUM(IFNULL(a.HKSTTOT,0)) as HKSTTOT, SUM(IFNULL(a.HKSTALLOT,0)) as HKSTALLOT, SUM(IFNULL(a.HKSTPEND,0)) as HKSTPEND, SUM(IFNULL(a.HKSTCAN,0)) as HKSTCAN,
SUM(IFNULL(a.NHKGMTOT,0)) as NHKGMTOT, SUM(IFNULL(a.NHKGMALLOT,0)) as NHKGMALLOT, SUM(IFNULL(a.NHKGMPEND,0)) as NHKGMPEND, SUM(IFNULL(a.NHKGMCAN,0)) as NHKGMCAN, 
SUM(IFNULL(a.NHKCATITOT,0)) as NHKCATITOT, SUM(IFNULL(a.NHKCATIALLOT,0)) as NHKCATIALLOT, SUM(IFNULL(a.NHKCATIPEND,0)) as NHKCATIPEND, SUM(IFNULL(a.NHKCATICAN,0)) as NHKCATICAN,
SUM(IFNULL(a.NHKIIATOT,0)) as NHKIIATOT, SUM(IFNULL(a.NHKIIAALLOT,0)) as NHKIIAALLOT, SUM(IFNULL(a.NHKIIAPEND,0)) as NHKIIAPEND, SUM(IFNULL(a.NHKIIACAN,0)) as NHKIIACAN,
SUM(IFNULL(a.NHKIIBTOT,0)) as NHKIIBTOT, SUM(IFNULL(a.NHKIIBALLOT,0)) as NHKIIBALLOT, SUM(IFNULL(a.NHKIIBPEND,0)) as NHKIIBPEND, SUM(IFNULL(a.NHKIIBCAN,0)) as NHKIIBCAN,
SUM(IFNULL(a.NHKIIIATOT,0)) as NHKIIIATOT, SUM(IFNULL(a.NHKIIIAALLOT,0)) as NHKIIIAALLOT, SUM(IFNULL(a.NHKIIIAPEND,0)) as NHKIIIAPEND, SUM(IFNULL(a.NHKIIIACAN,0)) as NHKIIIACAN,
SUM(IFNULL(a.NHKIIIBTOT,0)) as NHKIIIBTOT, SUM(IFNULL(a.NHKIIIBALLOT,0)) as NHKIIIBALLOT, SUM(IFNULL(a.NHKIIIBPEND,0)) as NHKIIIBPEND, SUM(IFNULL(a.NHKIIIBCAN,0)) as NHKIIIBCAN,
SUM(IFNULL(a.NHKSCTOT,0)) as NHKSCTOT, SUM(IFNULL(a.NHKSCALLOT,0)) as NHKSCALLOT, SUM(IFNULL(a.NHKSCPEND,0)) as NHKSCPEND, SUM(IFNULL(a.NHKSCCAN,0)) as NHKSCCAN,
SUM(IFNULL(a.NHKSTTOT,0)) as NHKSTTOT, SUM(IFNULL(a.NHKSTALLOT,0)) as NHKSTALLOT, SUM(IFNULL(a.NHKSTPEND,0)) as NHKSTPEND, SUM(IFNULL(a.NHKSTCAN,0)) as NHKSTCAN
from (select fcollcode, fdegree, 
case when freserve = 'HK' and fcatcode = 'GM' then ftotseats end as HKGMTOT,
case when freserve = 'HK' and fcatcode = 'GM' then fallotseats end as HKGMALLOT, 
case when freserve = 'HK' and fcatcode = 'GM' then fpendseats end as HKGMPEND,
case when freserve = 'HK' and fcatcode = 'GM' then fcanseats end as HKGMCAN,
case when freserve = 'HK' and fcatcode = 'CAT-I' then ftotseats end as HKCATITOT,
case when freserve = 'HK' and fcatcode = 'CAT-I' then fallotseats end as HKCATIALLOT, 
case when freserve = 'HK' and fcatcode = 'CAT-I' then fpendseats end as HKCATIPEND,
case when freserve = 'HK' and fcatcode = 'CAT-I' then fcanseats end as HKCATICAN, 
case when freserve = 'HK' and fcatcode = 'IIA' then ftotseats end as HKIIATOT, 
case when freserve = 'HK' and fcatcode = 'IIA' then fallotseats end as HKIIAALLOT,
case when freserve = 'HK' and fcatcode = 'IIA' then fpendseats end as HKIIAPEND,
case when freserve = 'HK' and fcatcode = 'IIA' then fcanseats end as HKIIACAN, 
case when freserve = 'HK' and fcatcode = 'IIB' then ftotseats end as HKIIBTOT, 
case when freserve = 'HK' and fcatcode = 'IIB' then fallotseats end as HKIIBALLOT,
case when freserve = 'HK' and fcatcode = 'IIB' then fpendseats end as HKIIBPEND,
case when freserve = 'HK' and fcatcode = 'IIB' then fcanseats end as HKIIBCAN,
case when freserve = 'HK' and fcatcode = 'IIIA' then ftotseats end as HKIIIATOT, 
case when freserve = 'HK' and fcatcode = 'IIIA' then fallotseats end as HKIIIAALLOT,
case when freserve = 'HK' and fcatcode = 'IIIA' then fpendseats end as HKIIIAPEND,
case when freserve = 'HK' and fcatcode = 'IIIA' then fcanseats end as HKIIIACAN,
case when freserve = 'HK' and fcatcode = 'IIIB' then ftotseats end as HKIIIBTOT, 
case when freserve = 'HK' and fcatcode = 'IIIB' then fallotseats end as HKIIIBALLOT,
case when freserve = 'HK' and fcatcode = 'IIIB' then fpendseats end as HKIIIBPEND,
case when freserve = 'HK' and fcatcode = 'IIIB' then fcanseats end as HKIIIBCAN, 
case when freserve = 'HK' and fcatcode = 'SC' then ftotseats end as HKSCTOT, 
case when freserve = 'HK' and fcatcode = 'SC' then fallotseats end as HKSCALLOT,
case when freserve = 'HK' and fcatcode = 'SC' then fpendseats end as HKSCPEND,
case when freserve = 'HK' and fcatcode = 'SC' then fcanseats end as HKSCCAN, 
case when freserve = 'HK' and fcatcode = 'ST' then ftotseats end as HKSTTOT, 
case when freserve = 'HK' and fcatcode = 'ST' then fallotseats end as HKSTALLOT,
case when freserve = 'HK' and fcatcode = 'ST' then fpendseats end as HKSTPEND,
case when freserve = 'HK' and fcatcode = 'ST' then fcanseats end as HKSTCAN, 
case when freserve = 'NHK' and fcatcode = 'GM' then ftotseats end as NHKGMTOT, 
case when freserve = 'NHK' and fcatcode = 'GM' then fallotseats end as NHKGMALLOT,
case when freserve = 'NHK' and fcatcode = 'GM' then fpendseats end as NHKGMPEND,
case when freserve = 'NHK' and fcatcode = 'GM' then fcanseats end as NHKGMCAN,
case when freserve = 'NHK' and fcatcode = 'CAT-I' then ftotseats end as NHKCATITOT,
case when freserve = 'NHK' and fcatcode = 'CAT-I' then fallotseats end as NHKCATIALLOT, 
case when freserve = 'NHK' and fcatcode = 'CAT-I' then fpendseats end as NHKCATIPEND,
case when freserve = 'NHK' and fcatcode = 'CAT-I' then fcanseats end as NHKCATICAN, 
case when freserve = 'NHK' and fcatcode = 'IIA' then ftotseats end as NHKIIATOT, 
case when freserve = 'NHK' and fcatcode = 'IIA' then fallotseats end as NHKIIAALLOT,
case when freserve = 'NHK' and fcatcode = 'IIA' then fpendseats end as NHKIIAPEND,
case when freserve = 'NHK' and fcatcode = 'IIA' then fcanseats end as NHKIIACAN, 
case when freserve = 'NHK' and fcatcode = 'IIB' then ftotseats end as NHKIIBTOT, 
case when freserve = 'NHK' and fcatcode = 'IIB' then fallotseats end as NHKIIBALLOT,
case when freserve = 'NHK' and fcatcode = 'IIB' then fpendseats end as NHKIIBPEND,
case when freserve = 'NHK' and fcatcode = 'IIB' then fcanseats end as NHKIIBCAN,
case when freserve = 'NHK' and fcatcode = 'IIIA' then ftotseats end as NHKIIIATOT,
case when freserve = 'NHK' and fcatcode = 'IIIA' then fallotseats end as NHKIIIAALLOT, 
case when freserve = 'NHK' and fcatcode = 'IIIA' then fpendseats end as NHKIIIAPEND,
case when freserve = 'NHK' and fcatcode = 'IIIA' then fcanseats end as NHKIIIACAN,
case when freserve = 'NHK' and fcatcode = 'IIIB' then ftotseats end as NHKIIIBTOT, 
case when freserve = 'NHK' and fcatcode = 'IIIB' then fallotseats end as NHKIIIBALLOT,
case when freserve = 'NHK' and fcatcode = 'IIIB' then fpendseats end as NHKIIIBPEND,
case when freserve = 'NHK' and fcatcode = 'IIIB' then fcanseats end as NHKIIIBCAN, 
case when freserve = 'NHK' and fcatcode = 'SC' then ftotseats end as NHKSCTOT, 
case when freserve = 'NHK' and fcatcode = 'SC' then fallotseats end as NHKSCALLOT,
case when freserve = 'NHK' and fcatcode = 'SC' then fpendseats end as NHKSCPEND,
case when freserve = 'NHK' and fcatcode = 'SC' then fcanseats end as NHKSCCAN, 
case when freserve = 'NHK' and fcatcode = 'ST' then ftotseats end as NHKSTTOT, 
case when freserve = 'NHK' and fcatcode = 'ST' then fallotseats end as NHKSTALLOT,
case when freserve = 'NHK' and fcatcode = 'ST' then fpendseats end as NHKSTPEND,
case when freserve = 'NHK' and fcatcode = 'ST' then fcanseats end as NHKSTCAN 
from entseatmatrix) a group by a.fdegree, a.fcollcode";
    $result = $aobj_context->mobj_db->GetAll($query);
    
    $class_obj = new ReprtObject();
    $class_obj->univcode = $univcode;
    $class_obj->DefaultConstructor($aobj_context);

    // If No data found Generate Blank Report
    if (count($result) > 0) {
        $class_obj->Report($result);
    }

    $class_obj->SendOutput();

}