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


Current Path : /var/www/html/gach/Report_details/
Upload File :
Current File : /var/www/html/gach/Report_details/report_adm_combination.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);
ini_set('memory_limit','900M');
ini_set('max_execution_time',0);

class MYPDF extends TCPDF {
    public $aobj_context;
     
    public function setData($aobj_context){
    	$this->aobj_context = $aobj_context;
    }
    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->SetMargins(10,51,20,true);	
		$this->SetFillColor(248, 248 ,255);		
		$img_path = $this->aobj_context->main_src."/img/logo.jpg";
		
		if(file_exists($img_path)) 
			$this->Image($img_path,10,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','B',12);
		$this->Cell(0,4,'College : '.$this->aobj_context->col_name,0,1,'C');
				 
		$this->SetFont('Times','B',12);
		$this->Cell(0,4,'Combination Summary Report',0,1,'C');
		$this->Ln(1);
		$this->Cell(0,5,'Degree : '.$this->aobj_context->degree,'0',1,'C');
		$this->Cell(0,5,'Application Range : '.$this->aobj_context->appfrom.' - '.$this->aobj_context->appto,'0',1,'C');
		$this->Ln(1);
		$this->Cell(10, 6,'Sl.', 'LRT', 0, 'C');
		$this->Cell(50, 6,'Combination', 'LRT', 0, 'C');
		foreach($this->aobj_context->category as $key => $value)
		{
			//$row1 .= '<th width="72" align="center"><b>'.$value['fcategory'].'</b></th>';
			$this->Cell(25, 6,' '.$value['fcategory'], 'LRT', 0, 'C');
			
		}
		$this->Cell(15, 6,'Total', 'LRT', 1, 'C');


		$this->Cell(10, 6,'No.', 'LRB', 0, 'C');
		$this->Cell(50, 6,'', 'LRB', 0, 'C');
		foreach($this->aobj_context->category as $key => $value)
		{
			//$row1 .= '<th width="72" align="center"><b>'.$value['fcategory'].'</b></th>';
			$this->Cell(8, 6,'M', 1, 0, 'C');
			$this->Cell(8, 6,'F', 1, 0, 'C');
			$this->Cell(9, 6,'Tot', 1, 0, 'C');
			
		}
		$this->Cell(15, 6,'', 'LRB', 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->SetY(-15);
        $this->SetFont('helvetica', 'I', 8);
        $this->Cell(50, 10,'IP : '.$_SERVER["REMOTE_ADDR"], 0, 0, 'L');
        $this->Cell(100, 10,'Date : ' .$this->aobj_context->current_date, 0, 0, 'C');

        $this->Cell(50, 10,'Page ' .$this->getPageNumGroupAlias().'/'.$this->getPageGroupAlias(), 0, 1, 'R');
    }
}

class AddmissionApplication
{	
	function DefaultConstructor($aobj_context)
	{
		$this->aobj_context=$aobj_context;
		//$this->pdf=  new FPDF();
		$this->collcode=$_SESSION['collcode'];
		$this->ip=$_SERVER["REMOTE_ADDR"];

		$aobj_context->degree_code = trim($aobj_context->mobj_data["degree_code"]);
		$aobj_context->appfrom = trim($aobj_context->mobj_data["appfrom"]);
		$aobj_context->appto = trim($aobj_context->mobj_data["appto"]);
		$aobj_context->status = trim($aobj_context->mobj_data["status"]);


		$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->mobj_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->FEXAMAPPREQ=$lobj_get_coll_name['FEXAMAPPREQ'];
		$aobj_context->FUNIVCODE=$lobj_get_coll_name['FUNIVCODE']; 

		$get_college_name="select concat(FCOLLNAME,', ',FTOWN) as col_name from college where FCOLLCODE='{$this->collcode}'";
		$lobj_get_college_name = $this->aobj_context->mobj_db->GetRow($get_college_name);
		$aobj_context->col_name = $lobj_get_college_name['col_name'];
		$this->aobj_context->current_date =  $obj[now_date];

		$query = "select d.fdescpn as degree from studadm s inner join degree d on s.fdegree = d.fdegree and d.fexamno = 'a'";
		$result = $this->aobj_context->mobj_db->GetRow($query);
		$aobj_context->degree = $result['degree'];
		$this->aobj_context->current_date =  $obj[now_date];
		$this->current_date = $obj[now_date];
		
		$query = "select fcategory from category order by fcategory";
		$category = $this->aobj_context->mobj_db->GetAll($query);

		$this->aobj_context->category =  $category;

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

		$pdf=$this->pdf;
		$this->aobj_context=$aobj_context;
		$pdf->SetMargins(10,51,20,false);
		$pdf->startPageGroup();
		$pdf->AddPage("L");

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

		$query = "SELECT DISTINCT s.fcombcode,m.fcombdesc FROM studadm s INNER JOIN mascomb m ON
		s.fdegree = s.fdegree AND s.fcombcode = m.fcombcode
		WHERE s.fcollcode = '{$this->collcode}' AND s.fdegree = '{$aobj_context->degree_code}'";
		
		$results = $this->aobj_context->mobj_db->GetAll($query);
		$i = 1;
		foreach ($results as $key => $value) 
		{
			
			$fcombcode = $value['fcombcode']; 

			
			$nb=max($nb,NbLines(10,$value["fcombdesc"],''));
			$n = 10;

			$get_x1=$pdf->GetX();
			$get_y1=$pdf->GetY();
			$width = 50;
			//$pdf->SetXY($x + $width, $y);
			//$pdf->Cell(10, $n,$i, '1', 0, 'C');
			$pdf->SetXY($get_x1+10,$get_y1);
			$pdf->MultiCell(50, 10,$value["fcombdesc"], 1 , 'L');
			
			$get_x2=$pdf->GetX();
			$get_y2=$pdf->GetY();
			$n=$get_y2-$get_y1;
			//$pdf->SetXY($x, $y);
			$pdf->SetXY($get_x1,$get_y1);
			$pdf->Cell(10, $n,$i, '1', 0, 'C');
			$query = "SELECT s.fcombcode,c.`FCATEGORY`, 
			SUM(CASE WHEN fgender = 'M' THEN 1 ELSE 0 END) AS malecnt,
			SUM(CASE WHEN fgender = 'F' THEN 1 ELSE 0 END) AS femalecnt
			FROM category c LEFT JOIN studadm s ON s.`FCASTE` = c.`FCATEGORY`  
			AND  s.fcollcode = '{$this->collcode}' 
			AND s.fdegree = '{$aobj_context->degree_code}' AND s.fcombcode = '{$fcombcode}'
			GROUP BY c.`FCATEGORY`
			order BY c.`FCATEGORY`";
			//var_dump($query);
			$tmpresults = $this->aobj_context->mobj_db->GetAll($query);
			$sum = 0;
			//$x = $pdf->GetX();
			//$pdf->SetXY($x+60, $y);
			$pdf->SetXY($get_x1+60,$get_y1);
 			foreach ($tmpresults as $key => $value) 
			{
			
				$total = $value['malecnt']+$value['femalecnt'];
				$pdf->Cell(8, $n,$value["malecnt"], 1, 0, 'R');
				
				$pdf->Cell(8, $n,$value["femalecnt"], 1, 0, 'R');

				$pdf->Cell(9, $n,$total, 1, 0, 'R');
				$sum += $total;
			}
			$pdf->Cell(15, $n,$sum, 1, 1, 'R');
			$i++;

		}
			/*$pdf->Cell(10, 6,'', 'LRT', 0, 'C');
			$pdf->Cell(50, 6,'', 'LRT', 0, 'C');

			$query ="SELECT fcategory, 
			SUM(CASE WHEN fgender = 'M' THEN 1 ELSE 0 END) AS MaleCount,
			SUM(CASE WHEN fgender = 'F' THEN 1 ELSE 0 END) AS FemaleCount,
			SUM(CASE WHEN fgender = 'Transgende' THEN 1 ELSE 0 END) AS TransCount
			FROM category c LEFT JOIN  studadm s ON  c.fcategory = s.FCASTE
			WHERE s.fcollcode = '{$aobj_context->degree_code}',
			AND s.fdegree = '{$aobj_context->degree_code}'
			GROUP BY c.fcategory
			ORDER BY c.fcategory";
			$sumresults = $this->aobj_context->mobj_db->GetAll($query);

			foreach ($sumresults as $key => $value) 
			{
			
				$total = $value['MaleCount']+$value['FemaleCount'];
				$pdf->Cell(8, $n,$value["MaleCount"], 1, 0, 'R');
				
				$pdf->Cell(8, $n,$value["FemaleCount"], 1, 0, 'R');

				$pdf->Cell(9, $n,$total, 1, 0, 'R');
				$sum += $total;
			}
			$pdf->Cell(15, $n,$sum, 1, 1, 'R');*/
		//$table5 .='</table>';
		//$pdf->SetX(12);
		
		//$pdf->writeHTML($table5, true, false, true, false, 'L');

	}

	function SendOutput()
	{
		$this->pdf->Output("Application_letter{$this->current_date}.pdf","D");
	}	 
}

function PrintCombinationDeatils($aobj_context)
{
	
	$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	
	$degree_code = trim($aobj_context->mobj_data["degree_code"]);
	$appfrom = trim($aobj_context->mobj_data["appfrom"]);
	$appto = trim($aobj_context->mobj_data["appto"]);
	$status = trim($aobj_context->mobj_data["status"]);



	$per_details_query = "SELECT m.fcombcode,m.fcombdesc,s.FCASTE, 
	SUM(CASE WHEN fgender = 'Male' THEN 1 ELSE 0 END) AS malecnt,
	SUM(CASE WHEN fgender = 'Female' THEN 1 ELSE 0 END) AS femalecnt, COUNT(*)
	FROM studadm s INNER JOIN mascomb m ON s.fcombcode = m.fcombcode AND s.fdegree = m.fdegree
	WHERE s.fcollcode = '{$_SESSION['FCOLLCODE']}' AND s.fdegree = '{$degree_code}' 
	AND s.fappno BETWEEN '{$appfrom}' AND '{$appto}'
	GROUP BY s.fcombcode,s.FCASTE
	ORDER BY s.fcombcode,s.FCASTE";
//FINSTLOCAT
	//var_dump($per_details_query);
	//$per_details = $aobj_context->mobj_db->GetAll($per_details_query);
	$per_details = '';
	$query = "select fcategory from category order by fcategory";
	$category = $aobj_context->mobj_db->GetAll($query);

	$class_obj = new AddmissionApplication();
	
	$class_obj->DefaultConstructor($aobj_context);

	
	$class_obj->writeApplication($aobj_context);
	
	$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;
 }

?>