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


Current Path : /var/www/html/univadmin/Reports/
Upload File :
Current File : /var/www/html/univadmin/Reports/dispmarksreport.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);

        // set bacground image
        $this->SetFillColor(248, 248, 255);
        $img_path = $this->aobj_context->main_src . "/img/".$this->aobj_context->FUNIVCODE."_logo.jpg";
        
        if (file_exists($img_path)) {
            $this->Image($img_path, 15, 6, 20, 20);
        }

        $this->SetFont('Times', 'B', 13);
        $this->SetY(5);
        $this->Cell(0, 7, $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->SetTitle("Dispatch Markscard(Exam section)");          
            
            $this->Cell(0, 7, ' Dispatch Markscard To Exam section (Summary)', '0', 1, 'C');
            $this->SetFont('Times', 'B', 10);
            $this->Ln(1);
    
            // $this->Cell(0, 5, $this->aobj_context->fcollname, '0', 1, 'C');
            // var_dump($this->$aobj_context->fcollname);            
            // $this->Ln(4);

     
        // 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();
        $this->SetX(15);

        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 ReportObj
{

    public function DefaultConstructor($aobj_context,$res)
    {
        $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->pobj_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["fdeggrp"];
        $reportType = $this->aobj_context->mobj_data["reportType"];
        $aobj_context->dateFrom = $aobj_context->mobj_data['dateFrom'];
        $aobj_context->dateTo   = $aobj_context->mobj_data['dateTo'];
        $aobj_context->qpcodeFrom   = $aobj_context->mobj_data['qpcodeFrom'];
        $aobj_context->qpcodeTo =  $aobj_context->mobj_data['qpcodeTo'];
        $aobj_context->regnoFrom = $aobj_context->mobj_data['regnoFrom'];
        $aobj_context->regnoTo = $aobj_context->mobj_data['regnoTo'];
        $aobj_context->correctionType = $aobj_context->mobj_data['correctionType'];

        $aobj_context->fcollname = $res[0]['fcollcode'].'-'.$res[0]['fcollname'];
        
        
        $aobj_context->degfrom = $aobj_context->mobj_data["degfrom"];
        $aobj_context->degto = $aobj_context->mobj_data["degto"];
        $aobj_context->dispno = $aobj_context->mobj_data["dispno"];
        
        $get_coll_name = "select fdeggrp,fdescpn,fexamdate as fexamdate 
        from deggrp where fdeggrp = '{$deggrp}'";
        $lobj_get_degree = $this->aobj_context->pobj_db->GetRow($get_coll_name);
        
        $aobj_context->deggrp = $lobj_get_degree['fdeggrp'];
        $aobj_context->fexamdate = $lobj_get_degree['fexamdate'];
        $aobj_context->fdescpn = $lobj_get_degree['fdescpn'];

        // var_dump($res);

        

        $this->pdf = new MYPDF('L');
        $this->pdf->aobj_context = $aobj_context;
    }

    public function Header($pdf)
    {
        $pdf->SetFont('Times', 'B', 10);
        $pdf->Cell(10, 5, "Sl.", "LRT", 0, "C");
        $pdf->Cell(70, 5, "Degree", "LRT", 0, "C");
        $pdf->Cell(15, 5, "Exam ", "LRT", 0, "C");        
        $pdf->Cell(90, 5, "College Name", "LRT", 0, "C");
        $pdf->Cell(20, 5, "Starting MC", "LRT", 0, "C");
        $pdf->Cell(20, 5, "Ending MC", "LRT", 0, "C");
        $pdf->Cell(20, 5, "Markscard", "LRT", 0, "C");
        $pdf->Cell(30, 5, "Status", "LRT", 1, "C");
        
        $pdf->Cell(10, 5, "No.", "LRB", 0, "C");
        $pdf->Cell(70, 5, "", "LRB", 0, "C");
        $pdf->Cell(15, 5, "No.", "LRB", 0, "C");        
        $pdf->Cell(90, 5, "", "LRB", 0, "C");
        $pdf->Cell(20, 5, " number", "LRB", 0, "C");
        $pdf->Cell(20, 5, " number", "LRB", 0, "C");
        $pdf->Cell(20, 5, " Count", "LRB", 0, "C");
        $pdf->Cell(30, 5, " ", "LRB", 1, "C");
        
    }

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

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


        $oldCode = "";
        $newCode = "";
        $sl_no = 1;
        $first = true;
        $j = 0;
        
        $pdf->SetFont('Times', '', 10);

        $pdf->Cell(22, 6, 'Dispatch No:-', "", 0, "L");
        $pdf->SetFont('Times', 'B', 10);
        $pdf->Cell(15, 6, $result_mcdisp['fdispno'], "", 0, "L");
        $pdf->SetFont('Times', '', 10);
        $pdf->Cell(22, 6, 'Dispatch date:-', "", 0, "L");
        $pdf->SetFont('Times', 'B', 10);
        $pdf->Cell(20, 6, $result_mcdisp['fdispdate'], "", 0, "L");
        $pdf->SetFont('Times', '', 10);
        $pdf->Cell(15, 6, 'Issue To:-', "", 0, "L");
        $pdf->SetFont('Times', 'B', 10);
        $pdf->Cell(20, 6, $result_mcdisp['fissueto'], "", 1, "L");


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

       
        

        
							
		 			
	
        $slno = 1;
        $tot = 0;
        foreach ($data as $key => $value) {

            if($value['fcollsent'] == 'T'){
                $status = 'Received';
            }else{
                $status = '';
            }
            $pdf->SetFont('Times', '', 10);

            $x = $pdf->GetX();
            $y = $pdf->GetY();
            $h = 6;
            

            // $pdf->Cell(65, $h, $value['fdegree'].'-'.$value['fdescpn'], "LRTB", 0, "C");

            $pdf->SetX($x + 95);        
            $pdf->MultiCell(90, $h, $value['fcollcode'].'-'.$value['fcollname'], "LRTB", "L");
            $y1 = $pdf->GetY();
            $h = $y1 - $y;    
            $pdf->SetXY($x, $y);


            $pdf->SetX($x + 10);        
            $pdf->MultiCell(70, $h, $value['fdegree'].'-'.$value['fdescpn'], "LRTB", "L");
            $y1 = $pdf->GetY();
            $h = $y1 - $y;    
            $pdf->SetXY($x, $y);
            
            $pdf->Cell(10, $h, $slno, "LRTB", 0, "C");


            $pdf->SetX($x + 80);
            $pdf->Cell(15, $h, $value['fexamno'], "LRTB", 0, "C");            

            

            $h = $y1 - $y;    
            $pdf->SetXY($x, $y);

            $pdf->SetX($x + 185);
            
            $pdf->Cell(20, $h, $value['first'], "LRTB", 0, "C");
            $pdf->Cell(20, $h, $value['end'], "LRTB", 0, "C");
            $pdf->Cell(20, $h, $value['count'], "LRTB", 0, "C");            
            $pdf->Cell(30, $h, $status, "LRTB", 1, "C");

            $tot += $value['count'];

            
            
            
                $slno ++;

                if($pdf->getY() > 170){
                    $pdf->AddPage();
                    $this->Header($pdf);
                }
            
        }
        $pdf->SetFont('Times', 'B', 10);
        $pdf->Cell(225, 6, 'Total', "LRTB", 0, "R");
        $pdf->Cell(20, 6, $tot, "LRTB", 0, "C");
        $pdf->Cell(30, 6, '', "LRTB", 0, "C");
    
        $table1 .= '</table>';
            // echo $table1;
            // var_dump($table1);die();

            $pdf->SetX(11);
            // $pdf->SetY(42);
            
            $pdf->writeHTML($table1, false, true, false, false, 'L');            
    }

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

function DispMarksReport($aobj_context)
{        
    $univcode = $aobj_context->mobj_data["univcode"];
    $deggrp = $aobj_context->mobj_data["deggrp"];    
    $fcollcode = $aobj_context->mobj_data['fcollcode'];
    $degfrom = $aobj_context->mobj_data['degfrom'];
    $degto = $aobj_context->mobj_data['degto'];
    $examno = $aobj_context->mobj_data['examno'];
    $clgfrom = $aobj_context->mobj_data['clgfrom'];
    $clgto = $aobj_context->mobj_data['clgto'];
    $dispno = $aobj_context->mobj_data['dispno'];

    $exam = str_split($examno);

    $examrange = implode("','", $exam);

    
        $query = "SELECT m.fcollcode,CONCAT(c.fcollname,',', c.ftown) AS fcollname,m.fdegree,d.fdescpn, m.fexamno, 
        GROUP_CONCAT(m.fmcnumber ORDER BY m.fmcnumber ) AS fmcnumber,
        m.fexamsent, m.fexamsentdate, m.fexamsentuser FROM mcdisp m 
        INNER JOIN college c ON c.fcollcode = m.fcollcode
        INNER JOIN degree d ON d.fdegree = m.fdegree AND d.fexamno = m.fexamno
        WHERE m.fexamdispno = '{$dispno}'
        GROUP BY m.fcollcode,m.fdegree, m.fexamno
        ORDER BY m.fcollcode,m.fdegree, m.fexamno";
        
    
        $result = $aobj_context->pobj_db->GetAll($query);

        $query = "SELECT fdispno,DATE_FORMAT(fdispdate,'%d/%m/%Y') AS fdispdate,fissueto,fmccount,fdispuser  
        FROM mcdispsum WHERE fdispno = '{$dispno}'";            
        $result_mcdisp = $aobj_context->pobj_db->GetROW($query);

        $res = [];

  foreach($result as $v){

    $mcnum_arr = explode(',', $v['fmcnumber']);
    $prevnum = (int)substr($mcnum_arr[0],-6);
    $count = 0;
    $v['fmcnumber'] = "";
    $push_arr = $v;
    $first = $mcnum_arr[0];
    // $arr = [30, 31,32, 33, 35, 36];
    $prevmc = "";
    // var_dump("MC arr =", $mcnum_arr);
    foreach($mcnum_arr as $mc){
      $num = (int)substr($mc,-6);
      // var_dump($num);
      if(($prevnum +1) != $num && $count != 0){
        $push_arr['first'] = $first;
        $push_arr['end'] = $prevmc;
        $push_arr['count'] = $count;        
        array_push($res, $push_arr);
        $first = $mc;
        $count = 0;
      }
      $prevnum = $num;
      $prevmc = $mc;
      $count++; 
    }
    $push_arr['first'] = $first;
    $push_arr['end'] = $mc;
    $push_arr['count'] = $count;    
    array_push($res, $push_arr);
  }
        // var_dump($res);

        
        // var_dump($aobj_context->fcollname);

        $class_obj = new ReportObj();
        $class_obj->univcode = $univcode;
        $class_obj->DefaultConstructor($aobj_context,$res);
    
        // If No data found Generate Blank Report
        if (count($res) > 0) {
            $class_obj->Report($res,$result_mcdisp);
        }
        $class_obj->SendOutput();
        
    


}

?>