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 : 13.58.84.207


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/exam_attendance_summary.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);
include_once("stringspliter.php");
	
class ExamAttendanceSummary extends TCPDF
{
		 
	function DefaultConstructor($aobj_context)
	{
		session_start();
		$this->aobj_context=$aobj_context;
		$this->pdf = new TCPDF();
		$this->pdf = $this;
		$this->exdate  = trim($this->aobj_context->mobj_data["exdate"]);
		$this->session = trim($this->aobj_context->mobj_data["session"]);
		//var_dump($this->session);
		$this->ip=$_SERVER["REMOTE_ADDR"];
		$get_date="select date_format(now(),'%d/%m/%Y %h:%i %p') as now_date";
		// $get_date="select current_timestamp as now_date";
		$obj=$this->aobj_context->mobj_db->GetRow($get_date);
		$this->current_date=$obj['now_date'];	
		$this->collcode=$_SESSION['collcode'];
		
	}
	 
	function Header()
	{
		session_start();
		$FUNIVCODE = $_SESSION['FUNIVCODE'];
		$this->pdf->Ln(5);
		$img_path=$this->aobj_context->main_src.$this->photo_path;
		if(!empty($this->photo_path) && file_exists($img_path)) 
		{			
			$this->pdf->Image($img_path,166,50,50);
		}	
		$img_logo_path=$this->aobj_context->main_src."/".$this->aobj_context->mobj_data["db"]."/".$this->pdf_logo_path;
		if(!empty($this->pdf_logo_path) && file_exists($img_logo_path))
		{	
			$this->pdf->Image($img_logo_path,10,10,23,22);
		}
		$img_path2 = $this->aobj_context->main_src."/img/logo2.jpg";
		if(file_exists($img_path2))
		{
			$this->pdf->Image($img_path2,170,6,23,23);
		}
		
		$this->pdf->SetFont('Times','B',16);
		$this->pdf->cell(190,3,$this->FUNIVNAME."","0",1,"C");
		$this->pdf->SetFont('Times','B',10);
		$this->pdf->cell(190,7, $this->s_state,"0",1,"C");
		$this->pdf->SetFont('Times','B',14);
		$this->pdf->cell(190,7, $this->college_details,"0",'1',"C");
		
		$this->pdf->Cell(190,7,"Exam Attendance Summary ".$this->FEXAMDATE." Examination","0",1,"C");
		$this->pdf->SetFont('Times','B',14);
		$this->pdf->Ln(2);
		$this->pdf->Cell(65,7,"Exam Date : ".$this->exdate,"0",0,"L");
		$session = "";
		//var_dump(str_replace($this->session,"'"));//
		if($this->session== 'M')
		{
			$session = "Morning Session";
		}
		
		if($this->session == 'N')
		{
			$session = "After Noon Session";
		}
		$this->pdf->Cell(0,7,"Session : ".$session,"0",1,"R");
		$this->pdf->Ln(2);
		$this->pdf->SetFont('Times','',13);
		
	}
	
	function Footer()
	{
		 
		$this->SetY(-15);
		$this->pdf->SetFont('Times','B',8);
		$this->Cell(140,6,'Printed   : IP Address : '.$this->ip."           Date ".$this->current_date,'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_data="SELECT c.FCOLLCODE,
			CONCAT(c.FCOLLCODE, ' - ', c.FCOLLNAME,', ',c.FTOWN) AS FCOLLNAME FROM college c
			where c.FCOLLCODE='{$this->collcode}'";
		 
		$obj_student=$this->aobj_context->mobj_db->GetRow($get_data); 

		$this->college_details=$obj_student['FCOLLNAME'];

		$this->degree_details=" College : {$this->FCOLLNAME}";		

	}

	function GetFullQry()
	{
		$reporttype = "";

		$canddettmp = "canddet";
		$candsumttmp = "candsum"; 
		$degreetmp = "degree";
		$subjecttmp = "subject";

		if($this->session == 'M')
		{
			$sess = 'AM';
		}
		else
		{
			$sess = 'PM'; 
		}

		
		$get_data = "select a.fqpcode, m.fsubname, a.froomno, r.froomname, count(*) as falloted, 
		sum(if(ifnull(fansbookno,'') <> '', 1,0)) as fpresent,
		sum(if(ifnull(fansbookno,'') = '', 1,0)) as fabsent
		from anscapt a inner join (select fqpcode, fsubname from {$subjecttmp} 
		where ifnull(fqpcode,'') <> ''
		group by fqpcode) m on a.fqpcode = m.fqpcode 
		inner join masroom r on a.fcntrcode = r.fcollcode 
		and a.froomno = r.froomno
		where a.fdoe = date_format(str_to_date('{$this->exdate}','%d/%m/%Y'),'%Y-%m-%d') and a.fcntrcode = '{$this->collcode}'
		group by a.fqpcode, a.froomno
		order by a.fqpcode, a.froomno";
		$this->lobj_get_data = $this->aobj_context->mobj_db->GetAll($get_data);
		//var_dump($get_data);
		$query = "select d.fexamdate from {$degreetmp} d inner join {$subjecttmp} s on d.fdegree = s.fdegree 
		and s.fexamno = d.fexamno where s.fqpcode = '{$this->lobj_get_data[0]['fqpcode']}'";
		$res = $this->aobj_context->mobj_db->GetRow($query);
		$this->FEXAMDATE =  $res['fexamdate'];
	}
	
	function formData()
	{
		$this->pdf->SetMargins(7,12,10);		
        $this->pdf->AddPage();
      	$this->pdf->SetMargins(7,20,10);		
      //$this->pdf->SetMargins(5,12,10);	
        
		$empty_cell_width=2;
		$sl_no=1;
		$k2 = 1;
		$first = true;
		
		foreach($this->lobj_get_data as $dk => $dv)
		{
			if($this->pdf->GetY() >= 250)
			{
				$this->pdf->cell($empty_cell_width,7, "","",0,"C");
				$this->pdf->cell(190,1, "","T",1,"C");
				$this->pdf->AddPage();
				$k2 = 1;
			}
			
			if($first == true || $k2 == 1)
			{
				$this->pdf->Ln(25);
				$this->pdf->SetFont('Times','B',12);
				$this->pdf->Cell(190,7,"","0",1,"C");
				

				$this->pdf->cell($empty_cell_width,5, ""," ",0,"C");
				$this->pdf->cell(12,5, "Sl.","LTR",0,"C");
				$this->pdf->cell(18,5, "QP","LTR",0,"C");
                $this->pdf->cell(60,5, "Subject Name","LTR",0,"C");
                $this->pdf->cell(50,5, "Room Name","LTR",0,"C");
                $this->pdf->cell(18,5, "Alloted","LTR",0,"C");
				$this->pdf->cell(18,5, "Present","LTR",0,"C");
				$this->pdf->cell(18,5, "Absent","LTR",1,"C");
				
                $this->pdf->cell($empty_cell_width,7, ""," ",0,"C");
				$this->pdf->cell(12,5, "No.","LBR",0,"C");
				$this->pdf->cell(18,5, "Code","LBR",0,"C");
                $this->pdf->cell(60,5, "","LBR",0,"C");
                $this->pdf->cell(50,5, "","LBR",0,"C");
				$this->pdf->cell(18,5, "","LBR",0,"C");
				$this->pdf->cell(18,5, "","LBR",0,"C");
                $this->pdf->cell(18,5, "","LBR",1,"C");
				$this->pdf->SetFont('Times','',12);
				$first = false;
			}
			
			$froomname = trim($dv['froomname']);
			$froomnamearr = str_splitf($froomname,30);
			
            $nb = 0;
            $nb=max($nb,NbLines(60,$dv['fsubname'],''));
           
			$yH = 0;
			$this->pdf->cell($empty_cell_width,$yH, ""," ",0,"C");
			$x = $this->pdf->GetX();
			$y =  $this->pdf->GetY();
			$this->pdf->SetXY($x+30, $y);
			$this->pdf->Multicell(60,$yH, $dv['fsubname'].'['.$dv['fqpcode'].']','LRT','L');
			
			$y1 =  $this->pdf->GetY();
			$yH = $y1 - $y + 2;
			$this->pdf->SetXY($x, $y);
			
			$this->pdf->cell(12,$yH, $sl_no,"LRT",0,"C");
			$this->pdf->cell(18,$yH, $dv['fqpcode'],"LRT",0,"C");
			$this->pdf->SetFont('Times','',12);
			$this->pdf->SetXY($x+90, $y);
            $this->pdf->cell(50,$yH, $froomnamearr[0],"LRT",0,"L");
            $x=$this->pdf->GetX();
			$y=$this->pdf->GetY();
			   
			$this->pdf->cell(18,$yH, $dv['falloted'],"LRT",0,"C");
			$this->pdf->cell(18,$yH, $dv['fpresent'],"LRT",0,"C");
            $this->pdf->cell(18,$yH,$dv['fabsent'],"LRT",1,"C");
			$this->pdf->SetFont('Times','',12);

			if($k2 == 29)
			{	
				$this->pdf->cell($empty_cell_width,7, "","",0,"C");
				$this->pdf->cell(194,1, "","T",0,"C");
			}

			if($subnamearr[1] != '')
			{
				$this->pdf->cell($empty_cell_width,7, ""," ",0,"C");
				$this->pdf->cell(12,4,'',"LRB",0,"C");
				$this->pdf->cell(18,4,'',"LRB",0,"C");
				
				// $this->pdf->SetFont('Times','',10);
				$this->pdf->cell(50,4, $froomnamearr[1],"LRB",0,"L");
                // $this->pdf->SetFont('Times','',10);
                $this->pdf->cell(50,4,'',"LRB",0,"C");
				$this->pdf->cell(18,4,'',"LRB",0,"C");
				$this->pdf->cell(18,4,'',"LRB",0,"C");
                $this->pdf->cell(18,4,'',"LRB",1,"C");
                
				if($k2 == 30)
				{	
					$this->pdf->cell($empty_cell_width,7, "","",0,"C");
					$this->pdf->cell(194,1, "","T",0,"C");
				}	
			}
			$sl_no++;
			$k2++;
		}
		$this->pdf->cell($empty_cell_width,7, "","",0,"C");
		$this->pdf->cell(194,1, "","T",1,"C");
		$this->pdf->SetFont('Times','',12);
	}
			 
	function SendOutput()
	{
		$this->pdf->Output("ExamAttendanceSummary.pdf","D");
	}
	
}

function ExamAttendanceSummary($aobj_context)
{
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

	$class_obj=new ExamAttendanceSummary();
	//$class_obj->AliasNbPages();
	$class_obj->DefaultConstructor($aobj_context);


	$class_obj->GetFullQry();
	$class_obj->formcolldata();
	$class_obj->formData();  
	$class_obj->SendOutput();
}


function NbLines($w,$txt,$pdf)
{
    //Computes the number of lines a MultiCell of width w will take
    $cw=&$pdf->CurrentFont['cw'];
    if($w==0)
        $w=$pdf->w-$pdf->rMargin-$pdf->x;
    $wmax=($w-2*$pdf->cMargin)*1000/$pdf->FontSize;
    $s=str_replace("\r",'',$txt);
    $nb=strlen($s);
    if($nb>0 and $s[$nb-1]=="\n")
        $nb--;
    $sep=-1;
    $i=0;
    $j=0;
    $l=0;
    $nl=1;
    while($i<$nb){
        $c=$s[$i];
        if($c=="\n"){
            $i++;
            $sep=-1;
            $j=$i;
            $l=0;
            $nl++;
            continue;
        }
        if($c==' ')
            $sep=$i;
        $l+=$cw[$c];
        if($l>$wmax)
		{
            if($sep==-1){
                if($i==$j)
                    $i++;
            } else
                $i=$sep+1;
            $sep=-1;
            $j=$i;
            $l=0;
            $nl++;
        } 
		else
            $i++;
    }
    return $nl;
 }


?>