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


Current Path : /proc/thread-self/root/var/www/html/admission/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/admission/src/qpIndent_04032019.php

<?php

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

class MYPDF extends TCPDF {
    public $aobj_context;
     
    public function setData($aobj_context,$Degree,$reportType){
        $this->aobj_context = $aobj_context;
        $this->Degree = $Degree;
        $this->reportType = $reportType;
    }
    public function Header(){
        // var_dump($Degree);
        // 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);
        // set bacground image
        $Degree = $aobj_context->mobj_data["deggrp"];
        $reportType = $aobj_context->mobj_data["rt"];
        // $this->SetMargins(6,30,5,true);	
		$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',12);
		$this->Ln(1);
		
		$cur_year = date("Y");
        $this->Cell(0,5,'QP Indent - '.$this->reportType.' List ','0',1,'C');
        $this->SetFont('Times','',12);

        $this->Cell(0,6," Degree Group: ".$this->Degree,"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);
        $this->Cell(50, 10,'IP : '.$_SERVER["REMOTE_ADDR"], 0, 0, 'L');
        $this->Cell(80, 10,'Date : '.date("d-m-Y H:i:s"), 0, 0, 'C');

        $this->Cell(70, 10,'Page ' .$this->getPageNumGroupAlias().'/'.$this->getPageGroupAlias(), 0, 1, 'R');
    }
}

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);
		
		$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->Degree= $Deggrp;
        // var_dump($this->Deggrp); 
		$this->current_date = $obj['now_date'];
 
		$this->pdf= new MYPDF('L');
        $this->pdf->setData($aobj_context,$Deggrp,$reportType);
    }

    function tableHeader($pdf)
    {

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

        $pdf->Cell(8,6,"Sl.","LRT",0);
		$pdf->Cell(10,6,"Center","LRT",0,"C");
		$pdf->Cell(79,6,"Center Name","LRT",0,"C");
        $pdf->Cell(10,6,"QP","LRT",0,"C");
		$pdf->Cell(45,6,"Subject Name","LRT",0,"C");
		$pdf->Cell(20,6,"Date","LRT",0,"C");
		$pdf->Cell(15,6,"Session","LRT",0,"C");
		$pdf->Cell(10,6,"QP","LRT",1,"C");
 
		$pdf->Cell(8,6,"No","LRB",0,"C");
		$pdf->Cell(10,6,"Code","LRB",0,"C"); //w h txt brd pos align
		$pdf->Cell(79,6,"","LBR",0,"C");
		$pdf->Cell(10,6,"Code","LBR",0,"C");
		$pdf->Cell(45,6,"","LBR",0,"C");
        $pdf->Cell(20,6,"","LBR",0,"C");
        $pdf->Cell(15,6,"","LBR",0,"C");
        $pdf->Cell(10,6,"Indent","LBR",1,"C");
        $pdf->SetFont('Times','',10);
    }

    function headerQPWise($pdf){

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

        $pdf->Cell(8,6,"Sl.","LRT",0);
		$pdf->Cell(15,6,"Center","LRT",0,"C");
		$pdf->Cell(80,6,"Center Name","LRT",0,"C");
		$pdf->Cell(15,6,"Total","LRT",1,"C");
 
		$pdf->Cell(8,6,"No.","LRB",0,"C");
		$pdf->Cell(15,6,"Code","LRB",0,"C"); //w h txt brd pos align
        $pdf->Cell(80,6,"","LBR",0,"C");
        $pdf->Cell(15,6,"Count","LBR",1,"C");
        $pdf->SetFont('Times','',10);
    }

    function headerDateWise($pdf){

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

        $pdf->Cell(8,6,"Sl.","LRT",0);
		$pdf->Cell(20,6,"Date","LRT",0,"C");
		$pdf->Cell(16,6,"Session","LRT",0,"C");
        $pdf->Cell(10,6,"QP","LRT",0,"C");
		$pdf->Cell(60,6,"Subject Name","LRT",0,"C");
		$pdf->Cell(60,6,"Degree","LRT",0,"C");
		$pdf->Cell(15,6,"For","LRT",1,"C");
 
		$pdf->Cell(8,6,"No","LRB",0,"C");
		$pdf->Cell(20,6,"","LRB",0,"C"); //w h txt brd pos align
		$pdf->Cell(16,6,"","LBR",0,"C");
		$pdf->Cell(10,6,"Code","LBR",0,"C");
		$pdf->Cell(60,6,"","LBR",0,"C");
        $pdf->Cell(60,6,"","LBR",0,"C");
        $pdf->Cell(15,6,"College","LBR",1,"C");
        $pdf->SetFont('Times','',10);
    }

	function writeReport($cntrlist)
	{
		$pdf=$this->pdf;

		$pdf->SetMargins(6,35);
		$pdf->startPageGroup();
		$pdf->AddPage("P");

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

        $this->tableHeader($pdf);

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

            $colname1 = strtolower(substr($value['fcntrname'],0,42));
            $colname2 = strtolower(substr($value['fcntrname'],42));
    
            $sub1 = substr($value['fsubname'],0,21);
            $sub2 = substr($value['fsubname'],21);
            $doe =  $value['fdoe'];
            $date = date("Y-m-d",strtotime(str_replace('/', '-',$doe)));

            if($value['fsession']== 'M1')
                $session = "Morning";
            else $session = "Afternoon";
            // var_dump($date);
            $sl_no++;
            $pdf->Cell(8,6,$sl_no,"LRT",0);
            $pdf->cell(10,6,$value['fcntrcode'],"LRT",0,"C");
            $pdf->cell(79,6,ucwords($colname1),"LRT",0,"L");
            $pdf->cell(10,6,$value['fqpcode'],"LRT",0,"L");
            $pdf->cell(45,6,$sub1,"LRT",0,"L");
            $pdf->cell(20,6,$date,"LRT",0,"R");
            $pdf->cell(15,6,$session,"LRT",0,"R");
            $pdf->cell(10,6,$value['frounded'],"LRT",1,"R");
            if($pdf->getY() > 270){
                // $pdf->cell(268,"","","T",1);
                $this->tableHeader($pdf);
            }
            if($colname2 || $sub2){

                if($colname2){

                    $pdf->Cell(8,6,"","LBR",0);
                    $pdf->cell(10,6,"","LBR",0,"C");
                    $pdf->cell(79,6,$colname2,"LBR",0,"L");
                    $pdf->cell(10,6,"","LBR",0,"L");
                    $pdf->cell(45,6,"","LBR",0,"L");
                    $pdf->cell(20,6,"","LBR",0,"R");
                    $pdf->cell(15,6,"","LBR",0,"R");
                    $pdf->cell(10,6,"","LBR",1,"R");
                }
                if($sub2){

                    $pdf->Cell(8,6,"","LBR",0);
                    $pdf->cell(10,6,"","LBR",0,"C");
                    $pdf->cell(79,6,"","LBR",0,"L");
                    $pdf->cell(10,6,"","LBR",0,"C");
                    $pdf->cell(45,6,$sub2,"LBR",0,"L");
                    $pdf->cell(20,6,"","LBR",0,"R");
                    $pdf->cell(15,6,"","LBR",0,"R");
                    $pdf->cell(10,6,"","LBR",1,"R");
                }
                if($pdf->getY() > 270){
                    // $pdf->cell(268,"","","T",1);
                    $this->tableHeader($pdf);
                }
            }
        }
    }
    
    function writeQPReport($qpList){

        $pdf=$this->pdf;

		$pdf->SetMargins(15,35);
		$pdf->startPageGroup();
		$pdf->AddPage("P");

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

        $this->headerQPWise($pdf);
        $sl_no = 0;
        foreach ($qpList as $key => $value){

            $colname1 = strtolower(substr($value['fcntrname'],0,42));
            $colname2 = strtolower(substr($value['fcntrname'],42));

            $sl_no++;

            $pdf->Cell(8,6,$sl_no,"LRT",0);
            $pdf->Cell(15,6,$value['fcntrcode'],"LRT",0,"C");
            $pdf->Cell(80,6,$colname1,"LRT",0,"L");
            $pdf->Cell(15,6,$value['fcount'],"LRT",1,"R");

            if($colname2){
                $pdf->Cell(8,6,"","LBR",0);
                $pdf->Cell(15,6,"","LBR",0,"C");
                $pdf->Cell(80,6,$colname2,"LBR",0,"L");
                $pdf->Cell(15,6,"","LBR",1,"R");
            }
            
            if($pdf->getY() > 270){
                $this->headerQPWise($pdf);
            }
        }
    }

    function writedoeReport($doelist){

		$pdf=$this->pdf;

		$pdf->SetMargins(10,35);
		$pdf->startPageGroup();
		$pdf->AddPage("P");

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

        $this->headerDateWise($pdf);
        $sl_no = 0;
    foreach ($doelist as $key => $value){
        
        if($value['fsession']== 'M1')
            $session = "Morning";
        else $session = "Afternoon";

        $sub = explode(',', $value['fdegree']);
        $lastEle = end($sub);
                // var_dump($lastEle);

        $str1 = implode(',',array_splice($sub,0,5));
        $str2 = implode(',',array_splice($sub,-5));
        $str3 = implode(',',array_splice($sub,-5));

        $sub1 = substr($value['fsubname'],0,31);
        $sub2 = substr($value['fsubname'],31);

        $sl_no++;
        $pdf->Cell(8,6,$sl_no,"LRT",0);
		$pdf->Cell(20,6,$value['fdoe'],"LRT",0,"C");
		$pdf->Cell(16,6,$session,"LRT",0,"C");
        $pdf->Cell(10,6,$value['fqpcode'],"LRT",0,"C");
		$pdf->Cell(60,6,$sub1,"LRT",0,"L");
		$pdf->Cell(60,6,$str1,"LRT",0,"L");
        $pdf->Cell(15,6,$value['fforcoll'],"LRT",1,"R");
        if($pdf->getY() > 270){
            $this->headerDateWise($pdf);
        }
        if($sub2 || $str2 || $str3){
            if($sub2){
                $pdf->Cell(8,6,"","LBR",0);
                $pdf->Cell(20,6,"","LBR",0,"C");
                $pdf->Cell(16,6,"","LBR",0,"C");
                $pdf->Cell(10,6,"","LBR",0,"C");
                $pdf->Cell(60,6,$sub2,"LBR",0,"L");
                $pdf->Cell(60,6,"","LBR",0,"L");
                $pdf->Cell(15,6,"","LBR",1,"R");
            }
            if($str2){
                $pdf->Cell(8,6,"","LR",0);
                $pdf->Cell(20,6,"","LR",0,"C");
                $pdf->Cell(16,6,"","LR",0,"C");
                $pdf->Cell(10,6,"","LR",0,"C");
                $pdf->Cell(60,6,"","LR",0,"L");
                $pdf->Cell(60,6,$str2,"LR",0,"L");
                $pdf->Cell(15,6,"","LR",1,"R");
            }
            if($str3){
                $pdf->Cell(8,6,"","LBR",0);
                $pdf->Cell(20,6,"","LBR",0,"C");
                $pdf->Cell(16,6,"","LBR",0,"C");
                $pdf->Cell(10,6,"","LBR",0,"C");
                $pdf->Cell(60,6,"","LBR",0,"L");
                $pdf->Cell(60,6,$str3,"LBR",0,"L");
                $pdf->Cell(15,6,"","LBR",1,"R"); 
            }
        }
   
    }
    }
    function SendOutput()
	{
		ob_end_clean();
		$this->pdf->Output("CenterWiseList_QPIndent{$this->univcode}.pdf","D");
    }	
    function SendOutputForQPList() {
        ob_end_clean();
		$this->pdf->Output("QPCodeWiseList_QPIndent{$this->univcode}.pdf","D");
    }
        function SendOutputDOE()
	{
		ob_end_clean();
		$this->pdf->Output("DateWiseList__QPIndent{$this->univcode}.pdf","D");
	}
}
function getqpIndentReport($aobj_context){

    $univcode = $aobj_context->mobj_data["univcode"];
    $deggrp = $aobj_context->mobj_data["dgp"];
    $reportType = $aobj_context->mobj_data["rt"];
    // echo $univcode,$deggrp,$reportType;
    $query = "DROP TABLE IF EXISTS qpmaster, tmpqpindsum,tmpqpindtot,tmpqpinddeg";
    $result = $aobj_context->pobj_db->Execute($query);

    $query = "CREATE TABLE IF NOT EXISTS qpmaster
    SELECT DISTINCT fdegree, fexamno, fsubcode, fqpcode, fsubname, fdoe AS fdoe, fsession AS fsession FROM SUBJECT
    WHERE IFNULL(fqpcode,'') <> '' AND ftheory = 'T' AND IFNULL(fintass,'') <> 'T'
    AND fdegree LIKE 'b%'";
    $result = $aobj_context->pobj_db->Execute($query);

    $query = "CREATE TABLE IF NOT EXISTS tmpqpindsum
    SELECT m.fcntrcode, CONCAT(TRIM(g.fcollname), ', ', g.ftown) AS fcntrname, s.fqpcode, 
    s.fsubname, s.fdoe, s.fsession, COUNT(c.fregno) AS fcnt, 
    (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS fextra,
    COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5) AS ftotal,
    (FLOOR((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) / 10) * 10) + 
    IF((COUNT(c.fregno) + (FLOOR((COUNT(c.fregno) * (10/100)) / 5) * 5) + 
    IF((COUNT(c.fregno) * (10/100)) MOD 5 = 0, 0, 5)) MOD 10 = 0, 0, 10) AS frounded,
    GROUP_CONCAT(DISTINCT s.fdegree ORDER BY s.fdegree) AS fdegree
    FROM qpmaster s, canddet c, candsum m, college g
    WHERE s.fdegree = c.fdegree 
    AND s.fexamno = c.fexamno
    AND s.fsubcode = c.fsubcode
    AND c.fdegree = m.fdegree AND c.fregno = m.fregno
    AND m.fcntrcode = g.fcollcode
    GROUP BY s.fqpcode, s.fsubname, m.fcntrcode, g.fcollname, g.ftown
    ORDER BY m.fcntrcode, s.fqpcode";
    $result = $aobj_context->pobj_db->Execute($query);

    $query = "CREATE TABLE IF NOT EXISTS tmpqpindtot
    SELECT q.fdoe, q.fsession, q.fqpcode, q.fsubname, '' AS fdeg,
    SUM(q.frounded) AS fforcoll
    FROM tmpqpindsum q
    GROUP BY q.fdoe, q.fsession, q.fqpcode, q.fsubname
    ORDER BY q.fdoe, q.fsession, q.fqpcode";
    $result = $aobj_context->pobj_db->Execute($query);

    $query = "CREATE TABLE IF NOT EXISTS tmpqpinddeg
    SELECT fqpcode, GROUP_CONCAT(DISTINCT fdegree ORDER BY fdegree) AS fdegree
    FROM tmpqpindsum
    GROUP BY fqpcode
    ORDER BY fqpcode";
    $result = $aobj_context->pobj_db->Execute($query);


    if($reportType == 'Center Wise'){

        $query = "SELECT * FROM tmpqpindsum ORDER BY fcntrcode, fqpcode";
        $result = $aobj_context->pobj_db->GetAll($query);
        // var_dump($query);
        // var_dump($result);
        $class_obj = new QPIndentReport();
  
        $class_obj->DefaultConstructor($aobj_context,$deggrp,$reportType);
        
        if(count($result) > 0)
            $class_obj->writeReport($result);
    
        $class_obj->SendOutput();
    }
    if($reportType == 'QP code Wise'){

        $query="SELECT q.fcntrcode, q.fcntrname, 
        SUM(q.frounded) AS fcount
        FROM tmpqpindsum q
        GROUP BY q.fcntrcode, q.fcntrname
        ORDER BY q.fcntrcode, q.fcntrname";
        $result = $aobj_context->pobj_db->GetAll($query);

        $class_obj = new QPIndentReport();
        $class_obj->DefaultConstructor($aobj_context,$deggrp,$reportType);
        
        if(count($result) > 0)
            $class_obj->writeQPReport($result);
    
        $class_obj->SendOutputForQPList();

    }
    if($reportType == 'Date of Exam Wise'){
        $query = "SELECT q.fdoe, q.fsession, q.fqpcode, q.fsubname, r.fdegree,
        q.fforcoll
        FROM tmpqpindtot q, tmpqpinddeg r WHERE q.fqpcode = r.fqpcode
        GROUP BY q.fdoe, q.fsession, q.fqpcode, q.fsubname
        ORDER BY q.fdoe, q.fsession, q.fqpcode";
        $result = $aobj_context->pobj_db->GetAll($query);

        $class_obj = new QPIndentReport();
        $class_obj->DefaultConstructor($aobj_context,$deggrp,$reportType);
        
        if(count($result) > 0)
            $class_obj->writedoeReport($result);
    
        $class_obj->SendOutputDOE();
    }
}
?>