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


Current Path : /var/www/html/rcub/Report_details/
Upload File :
Current File : /var/www/html/rcub/Report_details/report_daliy_report_qp.php

<?php
$main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
$pdf_writer_class = $main_src . "/tarka_pdf_latest/fpdf.php";
require_once($pdf_writer_class);

class DownloadExamAppFormApplications  extends FPDF
{

    function DefaultConstructor($aobj_context)
    {
        include_once($aobj_context->main_src . "/src/format.php");
        $this->aobj_context = $aobj_context;
        $this->pdf =  new FPDF();
        $this->pdf = $this;
        session_start();
        $this->ip = $_SERVER["REMOTE_ADDR"];
        $this->collcode = $_SESSION['collcode'];
        $this->college_code = $_SESSION['collcode'];
        $get_date = "select date_add(date_add(now(),INTERVAL 13 hour),interval 30 minute) as now_date";
        $obj = $this->aobj_context->mobj_db->GetRow($get_date);
        $this->current_date = $obj[now_date];
        $this->qp_code_start =  substr("0000000000" . $aobj_context->mobj_data["qp_code_start"], -5);
        $this->qp_code_end =  substr("ZZZZZZZZZZ" . $aobj_context->mobj_data["qp_code_end"], -5);

        $this->date_start = substr("0000000000" . db_date_Format($aobj_context->mobj_data["Date_start"]), -10);
        $this->date_end   = substr("ZZZZZZZZZZ" . db_date_Format($aobj_context->mobj_data["Date_end"]), -10);

        $this->session     = stripslashes($aobj_context->mobj_data["session"]);
        if ($this->session == "PM")
            $this->session = "'PM'";
        if ($this->session == "AM")
            $this->session = "'AM'";
    }

    function Header()
    {
        $this->pdf->SetMargins(10, 12, 10);

        $img_path = $this->aobj_context->main_src . $this->pdf_logo_path;

        if (!empty($this->pdf_logo_path) && file_exists($img_path)) {

            $this->pdf->Image($img_path, 10, 10, 20);
        }
        $this->pdf->SetFont('Times', 'B', 15);
        $this->pdf->cell(180, 4, "" . $this->FUNIVNAME, "0", 1, "C");
        $this->pdf->SetFont('Times', '', 8);
        $this->pdf->cell(180, 4, $this->s_state, "0", 0, "C");
        $this->pdf->SetFont('Times', '', 10);
        $this->pdf->Cell(-20, 4, "Page {$this->pdf->PageNo()}/{nb}", 0, 1, 'C');
        $this->pdf->SetFont('Times', 'B', 10);
        $this->pdf->cell(180, 5, "College : " . $this->FCOLLCODE . " - " . $this->FCOLLNAME, "0", 1, "C");
        $this->pdf->SetFont('Times', 'B', 10);
    }

    function Footer()
    {

        $this->SetY(-15);
        $this->pdf->SetFont('Times', '', 9);
        //$this->Cell(140,6,'Entered  : IP Address : '.$this->ip_address." Date ".$this->created_date,'0',0,'L');
        $new_y = $this->pdf->GetY();
        //$this->pdf->SetDash(1,3);
        $this->pdf->Line(5, $new_y, 203, $new_y);
        // $this->pdf->Line(5, $new_y + .5, 203, $new_y + .5);
        $this->pdf->Ln(2);
        $this->Cell(150, 6, 'Printed - IP Address : ' . $this->ip . ", Date : " . date('d/m/Y h:i:s A'), '0', 0, 'L');
        //$this->Cell(50,6,'Page '.$this->PageNo().' of {nb}',0,1,'R');
    }

    function formcolldata()
    {
        $get_coll_name = "select FUNIVNAME as 'FUNIVNAME',
		FUNIVADD1 as 'state', pdf_logo_path From control";
        $lobj_get_coll_name = $this->aobj_context->mobj_db->GetRow($get_coll_name);
        $this->FUNIVNAME = $lobj_get_coll_name['FUNIVNAME'];
        $this->s_state = $lobj_get_coll_name['state'];
        $this->f_year = $lobj_get_coll_name['f_year'];
        $this->pdf_logo_path = $lobj_get_coll_name['pdf_logo_path'];

        $get_coll_name = "SELECT FCOLLCODE,FCOLLNAME
		FROM college where FCOLLCODE='{$this->collcode}'";
        $lobj_get_coll_name = $this->aobj_context->mobj_db->GetRow($get_coll_name);
        $this->FCOLLCODE = $lobj_get_coll_name['FCOLLCODE'];

        $this->FCOLLNAME = $lobj_get_coll_name['FCOLLNAME'];
    }

    function GetAllSubjects()
    {

        $get_daliy_data = " select  date_format(cd.FDOE,'%d/%m/%Y') as doe_name,cd.FQPCODE as FQPCODE,CASE WHEN LEFT(cd.fsession,1)='M' OR LEFT(cd.fsession,1)='A' THEN 'AM' ELSE 'PM' END as FSESSION, 
									concat(sub.FSUBNAME, space(2), '( ',sub.FSSUBNAME,' )') as subject_desp,
									GROUP_CONCAT(distinct concat(cd.ftotscript,'/',cd.fbuno) order by cd.fbuno SEPARATOR '  ' ) as fbun,
									FNOBUNDLE,FTOTSCRIPT 
									from colldesp cd inner join subject sub on
									sub.FQPCODE=cd.FQPCODE							 
									where  
									cd.FCOLLCODE='{$this->college_code}' and
									cd.FQPCODE>='{$this->qp_code_start}' and cd.FQPCODE<='{$this->qp_code_end}' and 
									cd.FDOE>='{$this->date_start}' and cd.FDOE<='{$this->date_end}'   
									and CASE WHEN LEFT(cd.fsession,1)='M' OR LEFT(cd.fsession,1)='A' THEN 'AM' ELSE 'PM' END in({$this->session}) 
									and	IFNULL(cd.FDELETED,'') <> 'T' group by cd.FDOE,cd.FQPCODE,cd.FSESSION 
									order by date_format(cd.FDOE,'%d/%m/%Y'), cd.FSESSION, cd.fqpcode";
        //var_dump($get_daliy_data);
        $lobj_get_daliy_data = $this->aobj_context->mobj_db->GetAll($get_daliy_data);


        $get_daliy_absent_data = " select a.FQPCODE,date_format(a.FDOE,'%d/%m/%Y') as doe_name, 
										CASE WHEN LEFT(a.fsession,1)='M' OR LEFT(a.fsession,1)='A' THEN 'AM' ELSE 'PM' END as FSESSION,
										upper(a.FABSTYPE) as type,concat(sub.FSUBNAME, space(2), '( ',sub.FSSUBNAME,' )') as subject_desp,
										GROUP_CONCAT(distinct a.FREGNO SEPARATOR '  ') as FREGNO,COUNT(DISTINCT FREGNO) AS reg_cnt 
										from absent a 
										inner join subject sub on
										 sub.FQPCODE=a.FQPCODE	 and left(a.FABSTYPE,2)='QP'	
										where 
										a.FDOE>='{$this->date_start}' and a.FDOE<='{$this->date_end}'
										and a.FQPCODE>='{$this->qp_code_start}' and a.FQPCODE<='{$this->qp_code_end}'    
										and CASE WHEN LEFT(a.fsession,1)='M' OR LEFT(a.fsession,1)='A' THEN 'AM' ELSE 'PM' END in({$this->session})
										and a.FCOLLCODE='{$this->college_code}'
										and a.FDELETED='F' and  a.FCOLLCODE='{$this->college_code}'
										group by a.FDOE,a.FQPCODE,a.FABSTYPE,a.FSESSION 
										order by date_format(a.FDOE,'%d/%m/%Y'), a.FSESSION, a.fqpcode, a.FABSTYPE";
        $lobj_get_daliy_absent_data = $this->aobj_context->mobj_db->GetAll($get_daliy_absent_data);

        $this->unique_page_arr = array();
        $this->qp_code_arr = array();
        foreach ($lobj_get_daliy_absent_data as $ak => $av) {
            if ($av['type'] == 'QPA') {
                $this->unique_page_arr[$av['doe_name']][$av['FQPCODE']][$av['FSESSION']]['det']['QPA']['cnt'] = $av['reg_cnt'];
                $this->unique_page_arr[$av['doe_name']][$av['FQPCODE']][$av['FSESSION']]['det']['QPA']['FREGNO'] = $av['FREGNO'];
            }
            if ($av['type'] == 'QPM') {
                $this->unique_page_arr[$av['doe_name']][$av['FQPCODE']][$av['FSESSION']]['det']['QPM']['cnt'] = $av['reg_cnt'];
                $this->unique_page_arr[$av['doe_name']][$av['FQPCODE']][$av['FSESSION']]['det']['QPM']['FREGNO'] = $av['FREGNO'];
            }
            $this->qp_code_arr[$av['FQPCODE']] = $av['subject_desp'];
        }
        foreach ($lobj_get_daliy_data as $ak => $av) {

            $this->unique_page_arr[$av['doe_name']][$av['FQPCODE']][$av['FSESSION']]['bund']['FNOBUNDLE'] = $av['FNOBUNDLE'];
            $this->unique_page_arr[$av['doe_name']][$av['FQPCODE']][$av['FSESSION']]['bund']['FTOTSCRIPT'] = $av['FTOTSCRIPT'];
            $this->unique_page_arr[$av['doe_name']][$av['FQPCODE']][$av['FSESSION']]['bund']['FBUN'] = $av['fbun'];

            $this->qp_code_arr[$av['FQPCODE']] = $av['subject_desp'];
        }
        // echo "<pre>";
        // print_r($this->unique_page_arr);die();

    }

    function formData()
    {
        foreach ($this->unique_page_arr as $date_k => $date_v) {
            $this->doe = $date_k;
            foreach ($date_v as $qp_codek => $qp_code_v) {
                $this->qp_code = $qp_codek;
                $this->qp_name = $this->qp_code_arr[$this->qp_code];

                foreach ($qp_code_v as $sessk => $sessv) {
                    $this->session_name = $sessk;
                    if ($this->session_name == "AM")
                        $this->session_name = "Morning";
                    else
                        $this->session_name = "After Noon";
                    $this->FDOE = $sessv['FDOE'];
                    $this->pdf->AddPage();
                    $this->pdf->SetFont('Times', '', 10);
                    $this->pdf->Cell(180, 5, "QP Code : {$this->qp_code} - {$this->qp_name}", "0", 1, "C");
                    $this->pdf->Cell(180, 5, "Date of Examination : {$this->doe}", "0", 1, "C");
                    $this->pdf->Cell(180, 5, "Session : {$this->session_name}", "0", 1, "C");
                    $this->pdf->ln(1);
                    $new_y = $this->pdf->GetY();
                    //$this->pdf->SetDash(1, .3);
                    $this->pdf->Line(5, $new_y, 203, $new_y);
                    $this->pdf->Line(5, $new_y + .5, 203, $new_y + .5);
                    $this->pdf->ln(4);
                    $this->pdf->SetFont('Times', 'B', 10);
                    $this->pdf->Cell(15, 6, '', '0', 0, 'L');
                    $this->pdf->Cell(160, 6, 'Total Scripts / Bundle No.', '1', 1, 'L');
                    $this->pdf->Cell(15, 6, '', 'R', 0, 'L');
                    $this->pdf->SetFont('Times', '', 10);
                    //$this->pdf->Cell(160,6,$sessv['bund']['FBUN'],'1',1,'L');	
                    $this->pdf->MultiCell(160, 6, $sessv['bund']['FBUN'], 1, "L");
                    //total_abs
                    $this->pdf->ln(10);
                    $cnt = $sessv['det']['QPA']['cnt'];
                    $FREGNO = $sessv['det']['QPA']['FREGNO'];
                    $explode_arr = explode("  ", $FREGNO);
                    $chnk_cnt = count(array_chunk($explode_arr, 8)) * 1;
                    if ($chnk_cnt < 6)
                        $chnk_cnt = 6;
                    $this->pdf->Cell(15, 6, '', '0', 0, 'L');
                    $this->pdf->SetFont('Times', 'B', 10);
                    $this->pdf->Cell(70, 6, 'Total Absent', '1', 0, 'L');
                    $this->pdf->Cell(90, 6, $cnt, '1', 1, 'C');
                    $this->pdf->Cell(15, 6, '', 'R', 0, 'L');
                    $this->pdf->SetFont('Times', '', 10);
                    $this->pdf->MultiCell(160, $chnk_cnt, $FREGNO, 1, "L");

                    //total_abs
                    $this->pdf->ln(10);
                    $cnt = $sessv['det']['QPM']['cnt'];
                    $FREGNO = $sessv['det']['QPM']['FREGNO'];
                    $explode_arr = explode("  ", $FREGNO);
                    $chnk_cnt = count(array_chunk($explode_arr, 8)) * 1;
                    if ($chnk_cnt < 6)
                        $chnk_cnt = 6;
                    $this->pdf->Cell(15, 6, '', '0', 0, 'L');
                    $this->pdf->SetFont('Times', 'B', 10);
                    $this->pdf->Cell(70, 6, 'Total Mal-practice', '1', 0, 'L');
                    $this->pdf->Cell(90, 6, $cnt, '1', 1, 'C');
                    $this->pdf->Cell(15, 6, '', 'R', 0, 'L');
                    $this->pdf->SetFont('Times', '', 10);
                    $this->pdf->MultiCell(160, $chnk_cnt, $FREGNO, 1, "L");

                    $this->SetY(-65);
                    $this->pdf->Ln(5);
                    $this->pdf->Cell(180, 6, 'Signature of the Principal', '', 0, 'R');
                }
            }
        }
    }


    function SendOutput()
    {
        $this->pdf->Output("daily_report.pdf", "D");
    }
}
function generateDaliyReportQp($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    $class_obj = new DownloadExamAppFormApplications();
    $class_obj->AliasNbPages();
    $class_obj->DefaultConstructor($aobj_context);
    $class_obj->formcolldata();
    $class_obj->GetAllSubjects();
    $class_obj->formData();

    $class_obj->SendOutput();
}