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


Current Path : /var/www/html/admission/src/
Upload File :
Current File : /var/www/html/admission/src/setExamTimetableReport.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"];
        $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 (file_exists($img_path))
            $this->Image($img_path, 30, 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->SetFont('Times', '', 12);

        $this->Cell(0, 5, $this->Deggrp . ' - ' . $this->aobj_context->fexamdate . ' Examination', '0', 1, 'C');
        $this->Cell(0, 5, 'Exam Time Table - QP Code Wise', '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);
        $this->Cell(40, 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 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->fexamdate = $fexamdate;
        $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);
    }

    function tableHeader($pdf)
    {
        $pdf->SetFont('Times', 'B', 11);

        $pdf->Cell(12, 6, "Sl. No.", "1", 0);
        $pdf->Cell(20, 6, "Date", "1", 0, "C");
        $pdf->Cell(40, 6, "Time", "1", 0, "C");
        $pdf->Cell(20, 6, "QP Code", "1", 0, "C");
        $pdf->Cell(25, 6, "Sub. Short", "1", 0, "C");
        $pdf->Cell(80, 6, "Subject Name", "1", 1, "C");

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

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

        $pdf->SetMargins(5, 39);
        $pdf->startPageGroup();
        $pdf->AddPage("P");
        $orientation = "P";
        $pdf->SetFont('Times', '', 10);

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

            $fname = strtolower($value['fname']);
            $sub1 = substr($value['fsubname'], 0, 50);
            $sub2 = substr($value['fsubname'], 50);
            $sl_no++;

            if ($sub2) {
                if ($pdf->getY() > 260) {
                    $pdf->AddPage("P");
                    $this->tableHeader($pdf);
                }
                $pdf->Cell(12, 6, $sl_no, "LRT", 0, 'C');
                $pdf->Cell(20, 6, $value['fdate'], "LRT", 0, "C");
                $pdf->Cell(40, 6, $value['ftime'], "LRT", 0, "L");
                $pdf->Cell(20, 6, $value['fqpcode'], "LRT", 0, "C");
                $pdf->Cell(25, 6, $value['fsubshort'], "LRT", 0, "L");
                $pdf->Cell(80, 6, $sub1, "LRT", 1, "L");


                $pdf->Cell(12, 6, "", "LRB", 0, "C");
                $pdf->Cell(20, 6, "", "LBR", 0, "C");
                $pdf->Cell(40, 6, "", "LBR", 0, "L");
                $pdf->Cell(20, 6, "", "LRB", 0, "L");
                $pdf->Cell(25, 6, "", "LRB", 0, "L");
                $pdf->Cell(80, 6, $sub2, "LBR", 1, "L");
            } else {
                $pdf->Cell(12, 6, $sl_no, "1", 0, 'C');
                $pdf->Cell(20, 6, $value['fdate'], "1", 0, "C");
                $pdf->Cell(40, 6, $value['ftime'], "1", 0, "L");
                $pdf->Cell(20, 6, $value['fqpcode'], "1", 0, "C");
                $pdf->Cell(25, 6, $value['fsubshort'], "1", 0, "L");
                $pdf->Cell(80, 6, $sub1, "1", 1, "L");
            }

            if ($pdf->getY() > 260) {
                $pdf->AddPage("P");
                $this->tableHeader($pdf);
            }
        }
    }



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

function GenerateExamTimetable($aobj_context)
{

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

    $exam = str_split($examrange);

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


    $query = "select fyear,fexamtype from deggrp where fdeggrp = '{$deggrp}'";
    $res = $aobj_context->pobj_db->GetRow($query);
    $fexamtype = $res['fexamtype'];
    $fyear = $res['fyear'];

    $query = "select s.fqpcode,s.fsubshort, s.fsubname, group_concat(distinct s.fdegree SEPARATOR ', ')  as fdegree,
    ifnull(t.fdatecodet,'') as fdatecode, ifnull(r.freasoncd,'') as ftimecode,d.fexamdate, 
    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 timetable t on s.fqpcode = t.fqpcode 
    and t.fyear = d.fmeyear and d.fmeexamtyp = t.fexamtype
    inner join masdate md on t.fdatecodet = md.fdatecode 
   	and md.fyear = d.fmeyear and d.fmeexamtyp = md.fexamtype
   	and md.fyear = t.fyear and t.fexamtype = md.fexamtype
   	and md.fdeggrp = t.fdeggrp
    left join reason r on t.fsessiont = r.freasoncd
    where d.fdeggrp = '{$deggrp}' 
	and	t.fdeggrp = '{$deggrp}'
    and md.fdeggrp ='{$deggrp}'
    and s.fexamno in('{$examrange}')
    and t.fyear = '{$fyear}' and t.fexamtype = '{$fexamtype}'
    and s.ftheory = 'T' and s.fintass <> 'T' and ifnull(s.fqpcode,'') <>''
    and ifnull(t.fdatecodet,'') <> ''
    group by s.fqpcode
    order by s.fdatecodet, s.fqpcode";
// var_dump($query);die();
    // $query =  "select s.fqpcode, s.fsubname, group_concat(distinct s.fdegree SEPARATOR ', ')  as fdegree,
    // ifnull(s.fdatecodet,'') as fdatecode, ifnull(r.freasoncd,'') as ftimecode,d.fexamdate, 
    // 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,'') <>''
    // group by s.fqpcode
    // order by s.fdatecodet, s.fqpcode";

    $result = $aobj_context->pobj_db->GetAll($query);

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

    $class_obj->writeReport($result);
    $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.
}