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


Current Path : /var/www/html/gcg/adm/admin/src/pg/
Upload File :
Current File : /var/www/html/gcg/adm/admin/src/pg/meritList.php

<?php

$GLOBALS['main_src']=substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-20);
$pdf_writer_class =$GLOBALS['main_src']."/tcpdf/tcpdf.php";
require_once($pdf_writer_class);

class MYPDF extends TCPDF 
{

	public function setData($FUNIVNAME,$s_state,$pdf_logo_path,$FUNIVCODE,$current_date,$folder)
	{
    $this->FUNIVNAME = $FUNIVNAME;
    $this->s_state = $s_state;
    $this->pdf_logo_path = $pdf_logo_path;
    $this->$FUNIVCODE = $FUNIVCODE;
		$this->current_date = $current_date;
		$this->folder = $folder;
	}
	
	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);

    $this->SetFillColor(248, 248 ,255);		
		$img_path = $GLOBALS['main_src']."/img/logo_{$this->folder}.jpg";
		if(file_exists($img_path)) 
			$this->Image($img_path,15,6,20,20);
		$img_path = $GLOBALS['main_src']."/img/logo2.jpg";
	
		if(file_exists($img_path)) 
      $this->Image($img_path,170,6,20,20);
		
		
			$this->SetMargins(10, 20);//l,t,r,true or False

		$this->SetFont('helvetica','B',14);
		$this->Cell(0,4,$this->FUNIVNAME,0,1,'C');
		$this->SetFont('Times','',12);
		$this->Cell(0,4,$this->s_state,0,1,'C');
		
		$cur_year = date("Y");
    $this->SetFont('Times','',10);
    
		$this->SetFont('Times','',12);
		
    $this->SetAutoPageBreak($auto_page_break, $bMargin);
    
  }

	public function Footer() 
	{
		$this->SetMargins(20,45);
		$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 Results 
{

	public $html='';

	function DefaultConstructor()
	{
		include 'database.php';
		include("commandb.php"); 
		
		$this->ip=$_SERVER["REMOTE_ADDR"];
		$get_date="select DATE_FORMAT(now(), '%d/%m/%Y') as now_date";
		$obj=$conn->query($get_date);
        $obj = $obj->fetch_assoc();

		$get_coll_name="select FUNIVNAME,FUNIVCODE,
		FUNIVADD1 as 'state', pdf_logo_path,
		ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control where funivcode='033'";
		$lobj_get_coll_name=$conn->query($get_coll_name);//or die($conn->error)
		$coll_name = $lobj_get_coll_name->fetch_assoc();
		
		$get_univ_shortname ="select ffolder from dbname where funivcode='033'";
		$ffolder = $conndb->query($get_univ_shortname);//or die($conndb->error)
		$res = $ffolder->fetch_assoc();

		$FUNIVNAME=$coll_name['FUNIVNAME'];
		$s_state=$coll_name['state'];
		$pdf_logo_path=$coll_name['pdf_logo_path'];
		$FUNIVCODE=$coll_name['FUNIVCODE']; 
		$current_date = $obj['now_date'];		
		$folder = $res['ffolder'];
 
		$this->pdf= new MYPDF('L');
		$this->pdf->setData($FUNIVNAME,$s_state,$pdf_logo_path,$FUNIVCODE,$current_date,$folder);
		
  }


	function tableHeader($pdf)
	{
	
        $pdf->SetFont('Times','B',10);
		$this->html .='<div align="center"><table cellspacing="0" cellpadding="2" border="1" ><tr>';
        $this->html .='<th align="center" width ="20px"><b>Sl.<br>No.</b></th>';
        $this->html .='<th align="center" width ="55px" ><b>Application <br>No.</b></th>';
        $this->html .='<th align="center" width ="200px" ><b>Name</b></th>';
        $this->html .='<th align="center" width ="33px" ><b>Cat.</b></th>';
        $this->html .='<th align="center" width ="50px" ><b>DOB.</b></th>';
        $this->html .='<th align="center" width ="80px" ><b>Special <br>Category</b></th>';
        $this->html .='<th align="center" width ="35px" ><b>371(J)</b></th>';		
        $this->html .='<th align="center" width ="30px" ><b>Deg. <br> Perc.</b></th>';	
        $this->html .='<th align="center" width ="30px" ><b>Sub. <br> Perc.</b></th>';	
		$this->html .='</tr>';
		
    $pdf->SetFont('Times','',10);
  }

	function writeReport($detailed,$merit,$degree)
	{
		$pdf=$this->pdf;
		$univcode = '033';
        $pdf->startPageGroup();
		$data = json_decode($detailed,true);
		$pdf->AddPage('P','A4');
        $pdf->SetFont('Times','B',12);
    
        if($merit == 'all')
        {
            $meritType = "General";
        }else
        {
            $meritType = $merit;
        }
        
        $pdf->cell(0,6,"Merit List of Candidates",0,1,"C");
        $pdf->cell(0,6,"Merit List Type : ".$meritType,0,1,"C");
        $pdf->cell(0,6,"Degree : ".$degree,0,1,"C");

        $i = 1;
        $this->tableHeader($pdf);
        $pdf->SetFont('Times','',10);
        $this->html .="<tbody>";
        $this->degcode = "";
        // var_dump($data);
        foreach($data as $value)
        {
            
            $this->html .='<tr>';
            $this->html .='<td align="center" >'.$i.'</td>';
            $this->html .='<td align="center" >'.$value['fappno'].'</td>';
            $this->html .='<td align="left" >'.$value['fname'].'</td>';
            $this->html .='<td align="center" >'.$value['caste'].'</td>';
            $this->html .='<td align="center" >'.$value['fdob'].'</td>';
            $this->html .='<td align="center" >'.$value['special_category'].'</td>';
            $this->html .='<td align="center" >'.$value['371j'].'</td>';		
            $this->html .='<td align="center" >'.$value['degree_aggregate_precent'].'</td>';	//
            $this->html .='<td align="center" >'.$value['sub_aggregate_precent'].'</td>';	
            $this->html .='</tr>';
            $this->degcode = $value['fdegree'];

            $i++;
        }		
		
		$this->html .= '</tbody></table></div>';

		$pdf->writeHTML($this->html, true, false, true, false, '');
	
    
  }

  function SendOutput()
    {
		ob_end_clean();
		$this->pdf->Output("Merit_List_{$this->degcode}.pdf","D");
  }	
}


//==========call to api=========//
include 'database.php';

include("commandb.php");
//=======Request for Print Results=======//

	
  $degree = $_GET['degree'];
  $rtype = $_GET['rtype']; 

  $get_data="select fdegree,fdescpn from degree where fdegree = '{$degree}'";

  // var_dump('hii');
  
  $rest=mysqli_query($conn,$get_data);
  foreach($rest as $k=>$v)
  {
      $fdescpn = $v['fdescpn'];
  }
  $order = "order by fdegree, q2.fsubpercent desc,f371j";
  if($degree == 'MCOM1' || $degree == 'MSMB1' || $degree == 'MSCS1')
    $order = "order by  fdegree, q1.fsubpercent desc,f371j";

  
  if($rtype == 'all')
  {
    $cnd = '';
  }else if($rtype == '371J')
  {
    $cnd = " and f371j = 'T'";
  }
  else if($rtype == 'SC-GEN')
  {
    $cnd = " and fcaste = 'SC'";
  }
  else if($rtype == 'ST-GEN')
  {
    $cnd = " and fcaste = 'ST'";
  }
  else if($rtype == 'CAT-I-GEN')
  {
    $cnd = " and fcaste = 'CAT-I'";
  }
  else if($rtype == 'IIA-GEN')
  {
    $cnd = " and fcaste = 'IIA'";
  }
  else if($rtype == 'IIB-GEN')
  {
    $cnd = " and fcaste = 'IIB'";
  }
  else if($rtype == 'IIIA-GEN')
  {
    $cnd = " and fcaste = 'IIIA'";
  }
  else if($rtype == 'IIIB-GEN')
  {
    $cnd = " and fcaste = 'IIIB'";
  }
  else if($rtype == 'IIIB-371J')
  {
    $cnd = " and fcaste = 'IIIB' and f371j = 'T'";
  }
  else if($rtype == 'ST-371J')
  {
    $cnd = " and fcaste = 'ST' and f371j = 'T'";
  }
  else if($rtype == 'SC-371J')
  {
    $cnd = " and fcaste = 'SC' and f371j = 'T'";
  }
  else if($rtype == 'CAT-I-371J')
  {
    $cnd = " and fcaste = 'CAT-I' and f371j = 'T'";
  }
  else if($rtype == 'IIA-371J')
  {
    $cnd = " and fcaste = 'IIA' and f371j = 'T'";
  }
  else if($rtype == 'IIB-371J')
  {
    $cnd = " and fcaste = 'IIB' and f371j = 'T'";
  }
  else if($rtype == 'IIIA-371J')
  {
    $cnd = " and fcaste = 'IIIA' and f371j = 'T'";
  }

    $get_data="select s.fappno,s.fdegree,s.fname, q1.fsubname, q1.fsubpercent as degree_aggregate_precent, q2.fsubname as subject_aggregate,
    q2.fsubpercent as sub_aggregate_precent, if(`f371j` = 'T','Yes','No') as 371j,fcaste as caste,
    fstutype as special_category,if(fpwd = 'T','Yes','No') as pwd,
    date_format(fdob,'%d/%m/%Y') as fdob
    from pgstudadm s left join qualsubdet q1 on s.fappno = q1.fappno 
    and q1.fsubname = 'Aggregate' 
    left join qualsubdet q2 on s.fappno = q2.fappno 
    and q2.fsubname <> 'Aggregate' 
    where ifnull(s.fackdate,'') <> '' 
    and s.fdegree = '{$degree}'
    and s.FAPPSTATUS = 'APPROVED'
    {$cnd}
    {$order}";
    $rest=mysqli_query($conn,$get_data);
    $count =  mysqli_num_rows($rest);

    // var_dump($get_data);
    // die();
    foreach($rest as $k=>$v)
    {
        $data[$k] = $v;
    }
    //$data = mysqli_fetch_assoc($rest);
    if($count)
    {
        $class_obj = new Results();
        $class_obj->DefaultConstructor();
        $class_obj->writeReport(json_encode($data,true),$rtype,$fdescpn);
        $class_obj->SendOutput();
        return;
    }
		
		
?>