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


Current Path : /var/www/html/admission/src/
Upload File :
Current File : /var/www/html/admission/src/setDGExamTimetableReport.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)
    {
        $this->aobj_context = $aobj_context;
        $this->Deggrp = $this->aobj_context->mobj_data["deggrp"];

        $get_coll_name = "select fdescpn,fexamdate from deggrp where fdeggrp = '{$this->Deggrp}'";
        $lobj_get_coll_name = $this->aobj_context->pobj_db->GetRow($get_coll_name);

        $this->fdescpn = $lobj_get_coll_name['fdescpn'];
        $this->fexamdate = $lobj_get_coll_name['fexamdate'];

        $this->examrng = $this->aobj_context->mobj_data["examrange"];
        $this->univcode = $this->aobj_context->mobj_data["univcode"];

    }
    public function Header()
    {

        $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->SetMargins(6,30,5,true);	
        $this->SetFillColor(248, 248, 255);
        $img_path = $this->aobj_context->main_src . "/img/{$this->univcode}_logo.jpg";
       
        if($this->univcode == '052')
        {
            $this->Ln(1);
            $this->SetFont('Times','B',9);
			$this->Cell(0,4,"JSS MAHAVIDYAPEETHA",0,1,'C');
            
        }

        if($this->univcode == '030'){
            if (file_exists($img_path))
            $this->Image($img_path, 125, 1, 40, 20);
            $this->SetY(20);
        }else{
            if (file_exists($img_path))
            $this->Image($img_path, 10, 6, 40, 20);
            $this->SetY(5);
            $this->SetFont('Times', 'B', 13);
        
            $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->SetFont('Times', '', 12);

        $this->Cell(0, 5, $this->fdescpn . ' - ' . $this->fexamdate . ' Examination', '0', 1, 'C');

        
        if($this->univcode == "052"){
            $det = "";
        }else{
            $det = "- Degreewise";
        }
        $this->Cell(0, 5, 'Exam Time Table '.$det, '0', 1, 'C');
        // $this->Cell(0,6," Degree Group : ".$this->Deggrp,"0",1,"C");
        //$this->Cell(0,6," Exam Range : ".$this->examrng,"0",1,"C");
        //$this->Cell(0,6,"Exam: II Semester" ,"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->SetMargins(20, 40);
        $this->SetY(-15);
        $this->SetFont('helvetica', 'I', 8);
        if($this->univcode == '052')
        {

        }else
        {
            $this->Cell(40, 10, 'IP : ' . $_SERVER["REMOTE_ADDR"], 0, 0, 'L');
            $this->Cell(200, 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 ExamTTReport
{

    function DefaultConstructor($aobj_context, $fexamdate)
    {
        $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;
        $aobj_context->fexamdate = $fexamdate;
        // var_dump($this->Deggrp); 
        $this->current_date = $obj['now_date'];

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

    function tableHeader($pdf)
    {
        if($this->univcode == '030' || $this->univcode == '055'){
            $width = array('30', '50','30','24','102','260');  
            $qpc = 'Q.P.Code';  
            $pdf->SetFont('Times', 'B', 11);

            $pdf->Cell($width[0], 6, "Date", "1", 0, 'C');
            $pdf->Cell($width[1], 6, "Time", "1", 0, "C");
            $pdf->Cell($width[2], 6, "Sem", "1", 0, "C");
            $pdf->Cell($width[3], 6, $qpc, "1", 0, "C");
            $pdf->Cell($width[3], 6, "Course Code", "1", 0, "C");
            $pdf->Cell($width[4], 6, "Subject Name", "1", 1, "C");

        } else if($this->univcode == '052')
        {
            $width = array('20', '45','20','27','82','192');
            $qpc = 'Q.P.Code';
            $pdf->SetFont('Times', 'B', 11);

            $pdf->Cell($width[0], 6, "Date", "1", 0, 'C');
            $pdf->Cell($width[1], 6, "Time", "1", 0, "C");
            $pdf->Cell($width[2], 6, "Sem", "1", 0, "C");
            $pdf->Cell($width[3], 6, "Course Code", "1", 0, "C");
            $pdf->Cell($width[4], 6, "Course Title", "1", 1, "C");
        }
        else{
            $width = array('20', '45','20','27','82','192');
            $qpc = 'Q.P.Code';
            $pdf->SetFont('Times', 'B', 11);

            $pdf->Cell($width[0], 6, "Date", "1", 0, 'C');
            $pdf->Cell($width[1], 6, "Time", "1", 0, "C");
            $pdf->Cell($width[2], 6, "Sem", "1", 0, "C");
            $pdf->Cell($width[3], 6, $qpc, "1", 0, "C");
            $pdf->Cell($width[4], 6, "Subject Name", "1", 1, "C");
        }



        $pdf->SetFont('Times', '', 11);
    }

    function writeReport($detailed,$ind)
    {
        $pdf = $this->pdf;
        $sl_no = 0;

        $olddeg = "";
        $newdeg = "";

        $newdate = "";
        $olddate = "";

        // $target_path = dirname(dirname($_SERVER['SCRIPT_FILENAME']));

        // $target_folder = $target_path.'/'.$this->aobj_context->pdb['ffolder'].'/timetable'.'/';

        $i = 1;
        $sem = array('A' => 'First', 'B' => 'Second', 'C' => 'Third', 'D' => 'Fourth', 'E' => 'Fifth', 'F' => 'Sixth', 'G' => 'Seventh', 'H' => 'Eighth','I' => 'Ninth');
        if($this->univcode == '030' || $this->univcode == '055'){
            $width = array('30', '50','30','24','102','260','170');    
        }else{
            $width = array('20', '45','20','27','82','194','260');
        }


        foreach ($detailed as $key => $value) {
            
            $sl_no++;

            $examname = $sem[$value['fexamno']];

            if($value['oe'] == 'openelective')
            {
                $newdeg = "OE";
                $newdeg1 = "OE";
            }else
            {
                $newdeg = $value['fdegree'];
                $newdeg1 = $value['fdegree'];
            }
            

            if ($newdeg != $olddeg) {
                $pdf->SetMargins(10, 39);
                // $pdf->startPageGroup();
                if ($i != 1)
                {
                    $pdf->Cell($width[5], 1, "", "T", 1, 'C');
                    // ob_end_clean();
                    // ob_clean();
                    // var_dump($target_folder."{$this->aobj_context->pdb['ffolder']}-tt-2019-1-{$olddeg}.pdf");
                    // $this->pdf->Output($target_folder."{$this->aobj_context->pdb['ffolder']}-tt-2019-1-{$olddeg}.pdf", "F");
                    // $this->pdf = new MYPDF('P');
                }
                if($this->univcode == "041x") {
                    $pdf->ln(10);
                    $pdf->SetFont('Times', 'B', 11);
                    $pdf->Cell(0, 7, "NOTE: II sem examination are only for students studying in IV sem and having backlogs in II Semester", "LRTB", "L");
                }
                if($this->univcode == '030'){
                    $pdf->ln(2);
                    $pdf->SetFont('Times', 'B', 11);
                    $pdf->Cell($width[5], 7, "                ", "0", 1, 'R');
                    $pdf->Cell($width[5], 7, "Controller of Examinations", "0", 0, 'R');
                }
                if($this->univcode == '030' || $this->univcode == '055'){
                    $pdf->AddPage("L");    
                }else{
                    $pdf->AddPage("P");
                }
                
                
                $orientation = "P";
                $pdf->SetFont('Times', 'B', 11);
                if($value['oe'] == 'openelective')
                    $pdf->Cell($width[5], 7, 'OE' . ' - ' . 'Open Elective', "1", 1, 'C');
                else
                    $pdf->Cell($width[5], 7, $value['fdegree'] . ' - ' . $value['fdescpn'], "1", 1, 'C');
                $this->tableHeader($pdf);
                $olddeg = $newdeg;
                $newdate = "";
                $olddate = "";
                $i++;
            }

            $newdate = $value['fdate'];

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

            $pdf->SetXY($x, $y);

            if($this->univcode == '030' || $this->univcode == '055')
                $pdf->SetX($x + 158);
            else
                $pdf->SetX($x + 112);
            $pdf->MultiCell($width[4], 7, $value['fsubname'], "LRT", "L");
            $y1 = $pdf->GetY();
            $h1 = $y1 - $y;

            $pdf->SetXY($x, $y);
            
            $newdate = $value['fdate'];
            if ($newdate != $olddate) {
                $pdf->Cell($width[0], $h1, $value['fdate'], "LRT", 0, 'C');
                $olddate = $newdate;
            } else {
                $pdf->Cell($width[0], $h1, "", "LR", 0, 'C');
            }

            $pdf->Cell($width[1], $h1, $value['ftime'], "1", 0, "C");
            $pdf->Cell($width[2], $h1, $examname, "1", 0, "C");
            if($this->univcode == '030' || $this->univcode == '055'){
                $pdf->Cell($width[3], $h1, $value['fqpcode'], "1", 0, "C");
                $pdf->Cell($width[3], $h1, $value['fsubshort'], "1", 1, "C");
            }else{
                
                if($this->univcode == '052'){
                    $pdf->Cell($width[3], $h1, $value['fsubshort'], "1", 1, "C");
                }else{
                    $pdf->Cell($width[3], $h1, $value['fqpcode'], "1", 1, "C");
                }
                // $pdf->Cell($width[3], $h1, $value['fsubshort'], "1", 1, "C");
            }
                
            
            //228
            if ($pdf->getY() > $width[6]) {
                $pdf->Cell($width[5], 1, "", "T", 1, 'C');  
                if($this->univcode == "030") {
                    $pdf->AddPage("L");
                }else{
                    $pdf->AddPage("P");
                }
                if($value['oe'] == 'openelective')
                    $pdf->Cell($width[5], 7, 'OE' . ' - ' . 'Open Elective', "1", 1, 'C');
                else
                    $pdf->Cell($width[5], 7, $value['fdegree'] . ' - ' . $value['fdescpn'], "1", 1, 'C');

                //$pdf->Cell($width[5]+2, 7, $value['fdegree'] . ' - ' . $value['fdescpn'], "1", 1, 'C');
                $this->tableHeader($pdf);
            }
        }
        // var_dump($ind);
        // die();
        
        $pdf->Cell($width[5]+2, 1, "", "T", 1, 'C');
        // if($ind == 'F'){
            if($this->univcode == '030'){

                $pdf->ln(10);
                $pdf->SetFont('Times', 'B', 11);
                $pdf->Cell($width[5], 7, "                  ", "0", 1, 'R');
                $pdf->Cell($width[5], 7, "Controller of Examinations", "0", 0, 'R');
            }
        // }
        if($this->univcode == "041x") {
            $pdf->ln(10);
            $pdf->SetFont('Times', 'B', 11);
            $pdf->MultiCell(0, 7, "NOTE: II sem examination are only for students studying in IV sem and having backlogs in II Semester", "LRTB", "L");
        }



    }

    function SendOutput()
    {
        ob_end_clean();
        $this->pdf->Output("EXAM_TIME_TABLE{$this->reportType}Report_{$this->univcode}.pdf", "I");
    }
}

function GenerateDGExamTimetable($aobj_context)
{

    $univcode = $aobj_context->mobj_data["univcode"];
    $deggrp = $aobj_context->mobj_data["deggrp"];
    $ignore = $aobj_context->mobj_data["ignorett"];
    $examrange = $aobj_context->mobj_data["examrange"];
    $fdegfrom = $aobj_context->mobj_data["fdegfrom"];
    $fdegto = $aobj_context->mobj_data["fdegto"];
    $oe = $aobj_context->mobj_data["eltype"];

    $exam = str_split($examrange);

    $exm = $examrange;

    $examrange = implode("','", $exam);
    $cond = "";
    $cnd4 = "";
    $cnd3 = " group by s.fdegree, s.fexamno, s.fqpcode";

    if($oe =='openelective') {
        $cond = "and ifnull(s.foe,'') = 'T'";
        $cnd3 = "group by  s.fexamno, s.fqpcode";
        $cnd4 = "order by m.fdate,s.fexamno,r.fdescpn";
    }else if($oe =='withoutopenelective')
    {
        $cond = "and ifnull(s.foe,'') <> 'T'";
        $cnd3 = " group by s.fdegree, s.fexamno, s.fqpcode";
        $cnd4 = "order by s.fdegree,m.fdate,s.fexamno,r.fdescpn";
    }else 
    {
        $cond = "";
        $cnd3 = " group by s.fdegree, s.fexamno, s.fqpcode";
        $cnd4 = "order by s.fdegree,m.fdate,s.fexamno,r.fdescpn";
    }

    if($fdegfrom == '0'){
        $ind = 'T';
    }else{
        $ind = 'F';
    }
    $cnd2 = "";
    if($univcode == '052' || $univcode == '041')
        $cnd2 = "inner join canddet cd on cd.fdegree = s.fdegree and cd.fexamno = s.fexamno
        and cd.fsubcode = s.fsubcode and ifnull(cd.fpresent,'F') in('P','Y')
        inner join degree dg1 on cd.fdegree = dg1.fdegree and cd.fexamno = dg1.fexamno
        and dg1.fdeggrp = '{$deggrp}'";

    // $query =  "select s.fqpcode, s.fsubname, d.fdegree,d.fdescpn,d.fexamdate,d.fexamno,
    // ifnull(s.fdatecodet,'') as fdatecode, ifnull(s.fsession,'') as ftimecode,
    // ifnull(date_format(ifnull(md.fdate, ''),'%d/%m/%Y'),'') as fdate, 
    // ifnull(r.fdescpn,'') as ftime
    // from  subject s inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
    // inner join masdate md on s.fdatecodet = md.fdatecode and md.fdeggrp = '{$deggrp}'
    // and md.fyear = d.fmeyear and d.fmeexamtyp = md.fexamtype
    // inner join reason r on s.fsessiont = r.freasoncd
    // where d.fdeggrp = '{$deggrp}' and s.fexamno in('{$examrange}') 
    // and s.ftheory = 'T' and s.fintass <> 'T' and ifnull(s.fqpcode,'') <>''
    // and ifnull(s.fdatecodet,'') <> '' {$cond}
    // order by s.fdegree,md.fdate,s.fqpcode,d.fexamno";
    //$ignore = 'T';
    if($ignore == 'T')
    {
        $query_set = "select '{$oe}' as oe, d.fdegree,d.fdescpn,d.fexamdate,d.fexamno, 
        s.fqpcode,s.fsubshort,
        trim(TRAILING ', ' from  if('{$univcode}' = '052',concat(s.fmarkdesc1 ,s.fmarkdesc2) ,concat(s.fmarkdesc1 ,s.fmarkdesc2,', ', if(s.fssubname <> 'Theory',s.fssubname,'')))) as fsubname,
        ifnull(s.fdatecodet,'') as fdatecode, ifnull(t.fsessiont,'') as ftimecode,
        ifnull(date_format(ifnull(m.fdate, ''),'%d/%m/%Y'),'') as fdate, 
        ifnull(r.fdescpn,'') as ftime
         from subject s inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
         inner join timetable t on s.fqpcode = t.fqpcode inner join deggrp dg
         on dg.fdeggrp = t.fdeggrp
         and dg.fyear = t.fyear and dg.fexamtype = t.fexamtype 
         and s.fqpcode = t.fqpcode
         inner join masdate m on dg.fdeggrp = m.fdeggrp and t.fdatecodep = m.fdatecode 
         and m.fyear = t.fyear and m.fexamtype = t.fexamtype
         {$cnd2}
         left join reason r on t.fsessiont = r.freasoncd
         where t.fdeggrp = '{$deggrp}' {$cond}
         and s.fexamno in('{$examrange}')
         and d.fdegree between '{$fdegfrom}' and '{$fdegto}'
         and m.fdeggrp = '{$deggrp}'
         and d.fdeggrp = '{$deggrp}'
         and ifnull(t.fdatecodet,'') <> '' and s.fsuspend <> 'T'
         group by s.fdegree, s.fexamno, s.fqpcode
         order by s.fdegree,m.fdate,s.fexamno,r.fdescpn";

        

         if (!empty($_SERVER['HTTP_CLIENT_IP']))   
			{
				$ip_address = $_SERVER['HTTP_CLIENT_IP'];
			}
			else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  
			{
				$ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
			}
			else
			{
				$ip_address = $_SERVER['REMOTE_ADDR'];
			}
            $remarks = 'TIG - Time Table Ignored'.'Degree: '.$fdegfrom.'and'.$fdegto.', Examrange: '.$exm.', Deggrp: '.$deggrp;
			
			$query = "INSERT INTO logisys3_logs.daylog (funivcode, fdate, fip, fremarks, fcollcode, fenttype, fuser, fmobileno)
			VALUES ('{$univcode}', now(),'{$ip_address}', '{$remarks}', '{$deggrp}', 'TIG', 'AAA', '888888')";
			$res = $aobj_context->pobj_db->Execute($query);
            

    }else
    {
        // var_dump($deggrp);die();
        $query_set = "select '{$oe}' as oe, d.fdegree,d.fdescpn,d.fexamdate,d.fexamno, 
        s.fqpcode,s.fsubshort,
        trim(TRAILING ', ' from  if('{$univcode}' = '052',concat(s.fmarkdesc1 ,ifnull(s.fmarkdesc2,'')) ,concat(s.fmarkdesc1 ,ifnull(s.fmarkdesc2,''),', ', if(s.fssubname <> 'Theory',s.fssubname,'')))) as fsubname,
        ifnull(s.fdatecodet,'') as fdatecode, ifnull(t.fsessiont,'') as ftimecode,
        ifnull(date_format(ifnull(m.fdate, ''),'%d/%m/%Y'),'') as fdate, 
        ifnull(r.fdescpn,'') as ftime
         from subject s 
         inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
         left join timetable t on s.fqpcode = t.fqpcode and t.fdeggrp = '{$deggrp}'
         inner join deggrp dg
         on dg.fdeggrp = t.fdeggrp
         and dg.fyear = t.fyear and dg.fexamtype = t.fexamtype 
         and s.fqpcode = t.fqpcode
         {$cnd2}
         left join masdate m on dg.fdeggrp = m.fdeggrp and t.fdatecodep = m.fdatecode 
         and m.fdeggrp = '{$deggrp}'
         and m.fyear = t.fyear and m.fexamtype = t.fexamtype
         left join reason r on t.fsessiont = r.freasoncd
         where s.fexamno in('{$examrange}') 
         and d.fdegree between '{$fdegfrom}' and '{$fdegto}'
         {$cond}
         
         and dg.fdeggrp = '{$deggrp}'
        {$cnd3}
        {$cnd4}
         ";
    }
    
    // var_dump($query_set);
    // die();
    $result = $aobj_context->pobj_db->GetAll($query_set);



    $class_obj = new ExamTTReport();
    $class_obj->univcode = $univcode;
    $fexamdate = $result[0]['fexamdate'];

    $class_obj->DefaultConstructor($aobj_context, $fexamdate);
    $class_obj->writeReport($result,$ind);
    $class_obj->SendOutput();
}

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

}