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


Current Path : /var/www/html/univadmin/Reports/
Upload File :
Current File : /var/www/html/univadmin/Reports/valuationstatsReport.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;

ini_set('memory_limit', '-1');
ini_set('max_execution_time', '300');

class MYPDF extends TCPDF
{

    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->SetTitle(" Valuation Statistics Report");

        // set bacground image
        $this->SetFillColor(248, 248, 255);
        $img_path = $this->aobj_context->main_src . "/img/".$this->aobj_context->FUNIVCODE."_logo.jpg";

        if (file_exists($img_path)) {
            $this->Image($img_path, 40, 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->Cell(0, 5, ' Valuation Statistics', '0', 1, 'C');
        $this->SetFont('Times', 'B', 10);
        $exmrange = $this->aobj_context->mobj_data["fexamno"];
        $examnoStr = strtoupper($exmrange);
        $splitexamno = str_split($examnoStr);
        $examno = implode(",", $splitexamno);
        // var_dump($examno);
        
        // $this->Cell(0, 5, 'Degree Group : ' . $this->aobj_context->deggrp, '0', 1, 'C');
        $this->Cell(0, 5, " Degree Group: " . $this->aobj_context->mobj_data["deggrp"], "0", 1, "C");
        $this->Cell(0, 5, " Exam No. Range: " . $examno, "0", 0, "C");
        // $this->Cell(0, 5, " College Range: " . $this->aobj_context->mobj_data["fcollfrom"] . ' - ' . $this->aobj_context->mobj_data["fcollto"], "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->SetY(-15);
        $this->SetFont('helvetica', 'I', 8);
        // var_dump();
        if($this->CurOrientation == 'P')
        {
            $this->Cell(60, 10, 'IP : ' . $_SERVER["REMOTE_ADDR"], 0, 0, 'L');
            $this->Cell(60, 10, 'Date : ' . date("d-m-Y h:i:s A"), 0, 0, 'C');
            $this->Cell(60, 10, 'Page ' . $this->getPageNumGroupAlias() . '/' . $this->getPageGroupAlias(), 0, 1, 'R');
        }
        else {
            $this->Cell(90, 10, 'IP : ' . $_SERVER["REMOTE_ADDR"], 0, 0, 'L');
            $this->Cell(90, 10, 'Date : ' . date("d-m-Y h:i:s A"), 0, 0, 'C');
            $this->Cell(90, 10, 'Page ' . $this->getPageNumGroupAlias() . '/' . $this->getPageGroupAlias(), 0, 1, 'R');
        }
    }
}

class Report{
  public function DefaultConstructor($aobj_context)
  {
    $this->count ="";
    $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);
    
    $collQry ="select concat(FCOLLCODE,' ',FCOLLNAME,', ',FTOWN) as college_name
    from college where FCOLLCODE='{$this->fcollcode}'";
    $collRes = $this->aobj_context->pobj_db->GetRow($collQry);

    $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->FUNIVCODE = $lobj_get_coll_name['FUNIVCODE'];
    $aobj_context->FCOLLNAME = $collRes['college_name'];

    $this->current_date = $obj['now_date'];
    $deggrp = $this->aobj_context->mobj_data["deggrp"];

    $getDeggrp = "select concat(fdeggrp, ' - ', fdescpn) as fdeggrp 
    from deggrp where fdeggrp = '{$deggrp}'";
    $lobj_get_degree = $this->aobj_context->pobj_db->GetRow($getDeggrp);
    
    $aobj_context->deggrp = $lobj_get_degree['fdeggrp'];
    $this->pdf = new MYPDF('L');
    $this->pdf->aobj_context = $aobj_context;    
  }

  public function TblHeaderPG($pdf)
  {

    $pdf->SetFont('Times', 'B', 10);
        $pdf->Cell(8, 6, "Sl.", "LRT", 0, "C");
        $pdf->Cell(13, 6, "Board ", "LRT", 0, "C");
        $pdf->Cell(13, 6, "Qp ", "LRT", 0, "C");
        $pdf->Cell(70, 6, "Subject Name", "LRT", 0, "C");
        $pdf->Cell(57, 6, "Preparation", "LRT", 0, "C");        
        $pdf->Cell(57, 6, "First Valuation", "LRT", 0, "C");
        $pdf->Cell(57, 6, "Second Valuation", "LRT", 1, "C");       
        
        

        $pdf->Cell(8, 6, "No", "LRB", 0, "C");
        $pdf->Cell(13, 6, "", "LRB", 0, "C");
        $pdf->Cell(13, 6, "Code", "LRB", 0, "C"); //w h txt brd pos align
        $pdf->Cell(70, 6, "", "LBR", 0, "C");

        $pdf->SetFont('Times', 'B', 7);

        $pdf->Cell(19, 6, "Script Recd.", "LBRT", 0, "C");            
        $pdf->Cell(19, 6, "Script Coded", "LBRT", 0, "C");
        $pdf->Cell(19, 6, "Coding Pending", "LBRT", 0, "C");
        $pdf->SetFont('Times', 'B', 8);
        $pdf->Cell(19, 6, "Pkt. Count", "LBRT", 0, "C");        
        $pdf->Cell(19, 6, "Pkt. Valued", "LBRT", 0, "C");
        $pdf->Cell(19, 6, "Pkt. Pending", "LBRT", 0, "C");
        $pdf->Cell(19, 6, "Pkt. Count", "LBRT", 0, "C");        
        $pdf->Cell(19, 6, "Pkt. Valued", "LBRT", 0, "C");
        $pdf->Cell(19, 6, "Pkt. Pending", "LBRT", 1, "C");                      
        $pdf->SetFont('Times', '', 10);
  }

  public function TblHeader($pdf)
  {

        // $pdf->SetMargins(15, 32);    
        $pdf->SetFont('Times', 'B', 10);
        $pdf->Cell(8, 6, "Sl.", "LRT", 0, "C");
        $pdf->Cell(15, 6, "Board ", "LRT", 0, "C");
        $pdf->Cell(15, 6, "Qp ", "LRT", 0, "C");
        $pdf->Cell(70, 6, "Subject Name", "LRT", 0, "C");
        $pdf->Cell(75, 6, "Preparation", "LRT", 0, "C");                      
        $pdf->Cell(75, 6, "Valuation", "LRT", 1, "C");        
        
        

        $pdf->Cell(8, 6, "No", "LRB", 0, "C");
        $pdf->Cell(15, 6, "", "LRB", 0, "C");
        $pdf->Cell(15, 6, "Code", "LRB", 0, "C"); //w h txt brd pos align
        $pdf->Cell(70, 6, "", "LBR", 0, "C");

        $pdf->SetFont('Times', 'B', 9);

        $pdf->Cell(25, 6, "Script Recd.", "LBRT", 0, "C");        
        // $pdf->Cell(25, 6, "Script Counted", "LBRT", 0, "C");
        $pdf->Cell(25, 6, "Script Coded", "LBRT", 0, "C");
        $pdf->Cell(25, 6, "Coding Pending", "LBRT", 0, "C");
        $pdf->SetFont('Times', 'B', 9);
        $pdf->Cell(25, 6, "Pkt. Count", "LBRT", 0, "C");        
        $pdf->Cell(25, 6, "Pkt. Valued", "LBRT", 0, "C");
        $pdf->Cell(25, 6, "Pkt. Pending", "LBRT", 1, "C");        
        $pdf->SetFont('Times', '', 10);
  }


  function writeReport($det,$deggrp){
    
    $pdf = $this->pdf;
   
    
    if($deggrp == 'PG'){

      $pdf->SetMargins(10, 32);
      $pdf->startPageGroup();
      $pdf->AddPage("L");
      $sl_no = 1;
      $pdf->SetFont('Times', '', 10);
      $w=array(10,35,155);

    
    $this->TblHeaderPG($pdf);
    // var_dump($det);
    $B1 = 0;
    $B2 = 0;
    $B3 = 0;
    $B4 = 0;
    $B5 = 0;
    $B6 = 0;
    $B7 = 0;
    $B8 = 0;
    $B9 = 0;
    $B10 = 0;
    $B11 = 0;
    $B12 = 0;
    $B13 = 0;

    foreach($det as $k => $v)
		{	
      if($pdf->GetY()>= 180)
      {
        $pdf->AddPage();        
        $this->TblHeaderPG($pdf);
      }

        $x = $pdf->GetX();
        $y = $pdf->GetY();
        $h = 6;
        
      $pdf->SetX($x + 34);        
      $pdf->MultiCell(70, $h, $v['fsubname'], "LRTB", "L");
      $y1 = $pdf->GetY();
      $h = $y1 - $y;    
      $pdf->SetXY($x, $y);

      $pdf->Cell(8, $h, $sl_no, "1", 0, "C");
      $pdf->Cell(13, $h, $v['fboard'], "1", 0, "C");
      $pdf->Cell(13, $h, $v['fqpcode'], "1", 0, "C");
    //   $pdf->Cell(49, $h, ucwords($v['fsubname']), "1", 0, "L");
      $pdf->SetX($x + 104);
      $pdf->Cell(19, $h, $v['fspresent'], "1", 0, "R");
      // $pdf->Cell(19, $h, $v['fapresent'], "1", 0, "R");
      $pdf->Cell(19, $h, $v['fcodecount'], "1", 0, "R");  
      $pdf->Cell(19, $h, $v['fapresent'] - $v['fcodecount'] < 0 ? 0 : $v['fapresent'] - $v['fcodecount'], "1", 0, "R");
    //   (el.fapresent - el.fcodecount < 0 ? 0 : el.fapresent - el.fcodecount)
      $pdf->Cell(19, $h, $v['ftotpkt1'], "1", 0, "R");
      $pdf->Cell(19, $h, $v['fvalpkt1'], "1", 0, "R");  
      $pdf->Cell(19, $h, $v['ftotpkt1'] - $v['fvalpkt1'] < 0 ? 0 : $v['ftotpkt1'] - $v['fvalpkt1'], "1", 0, "R");
      $pdf->Cell(19, $h, $v['ftotpkt2'], "1", 0, "R");
      $pdf->Cell(19, $h, $v['fvalpkt2'], "1", 0, "R");  
      $pdf->Cell(19, $h, $v['ftotpkt1'] - $v['fvalpkt2'] < 0 ? 0 : $v['ftotpkt1'] - $v['fvalpkt2'], "1", 1, "R");      

      $sl_no++;
      $B1  += $v['fspresent'] ;
      // $B2  += $v['fapresent'] ;
      $B3  += $v['fcodecount'] ;
      $B4  += $v['fapresent'] - $v['fcodecount'] < 0 ? 0 : $v['fapresent'] - $v['fcodecount'] ;
      $B5  += $v['ftotpkt1'];
      $B6  += $v['fvalpkt1'];
      $B7  +=  $v['ftotpkt1'] - $v['fvalpkt1'] < 0 ? 0 : $v['ftotpkt1'] - $v['fvalpkt1'];
      $B8  +=  $v['ftotpkt2'];
      $B9  +=  $v['fvalpkt2'];
      $B10 +=  $v['ftotpkt1'] - $v['fvalpkt2'] < 0 ? 0 : $v['ftotpkt1'] - $v['fvalpkt2'];
      $B11 +=  $v['ftotpkt3'];
      $B12 +=  $v['fvalpkt3'];
      $B13 +=  $v['ftotpkt2'] - $v['fvalpkt3'] < 0 ? 0 : $v['ftotpkt2'] - $v['fvalpkt3'];
    }	
    $pdf->SetFont('Times', 'B', 10);
    $pdf->Cell(104, $h, "Total", "1", 0, "C");
    $pdf->Cell(19, $h, $B1 , "1", 0, "R");
    // $pdf->Cell(19, $h, $B2 , "1", 0, "R");
    $pdf->Cell(19, $h, $B3 , "1", 0, "R");  
    $pdf->Cell(19, $h, $B4 , "1", 0, "R");
  //   (el.fapresent - el.fcodecount < 0 ? 0 : el.fapresent - el.fcodecount)
    $pdf->Cell(19, $h, $B5 , "1", 0, "R");
    $pdf->Cell(19, $h, $B6 , "1", 0, "R");  
    $pdf->Cell(19, $h, $B7 , "1", 0, "R");
    $pdf->Cell(19, $h, $B8 , "1", 0, "R");
    $pdf->Cell(19, $h, $B9 , "1", 0, "R");  
    $pdf->Cell(19, $h, $B10 , "1", 1, "R");    
    
  }else{

    $pdf->SetMargins(17, 32);
    $pdf->startPageGroup();
    $pdf->AddPage("L");
    $sl_no = 1;
    $pdf->SetFont('Times', '', 10);
    $w=array(10,35,155);

    

    // $pdf->SetX(15);

    $this->TblHeader($pdf);
    // var_dump($det);

    $A1 = 0;
    $A2 = 0;
    $A3 = 0;
    $A4 = 0;
    $A5 = 0;
    $A6 = 0;
    $A7 = 0;

    foreach($det as $k => $v)
		{	
      if($pdf->GetY()>= 180)
      {
        $pdf->AddPage();        
        $this->TblHeader($pdf);
      }

        $x = $pdf->GetX();
        $y = $pdf->GetY();
        $h = 6;
        
      $pdf->SetX($x + 38);        
      $pdf->MultiCell(70, $h, $v['fsubname'], "LRTB", "L");
      $y1 = $pdf->GetY();
      $h = $y1 - $y;    
      $pdf->SetXY($x, $y);

      $pdf->Cell(8, $h, $sl_no, "1", 0, "C");
      $pdf->Cell(15, $h, $v['fboard'], "1", 0, "C");
      $pdf->Cell(15, $h, $v['fqpcode'], "1", 0, "C");
    //   $pdf->Cell(49, $h, ucwords($v['fsubname']), "1", 0, "L");
      $pdf->SetX($x + 108);
      $pdf->Cell(25, $h, $v['fspresent'], "1", 0, "R");
      // $pdf->Cell(25, $h, $v['fapresent'], "1", 0, "R");
      $pdf->Cell(25, $h, $v['fcodecount'], "1", 0, "R");  
      $pdf->Cell(25, $h, $v['fapresent'] - $v['fcodecount'] < 0 ? 0 : $v['fapresent'] - $v['fcodecount'], "1", 0, "R");
    
      $pdf->Cell(25, $h, $v['ftotpkt1'], "1", 0, "R");
      $pdf->Cell(25, $h, $v['fvalpkt1'], "1", 0, "R");  
      $pdf->Cell(25, $h, $v['ftotpkt1'] - $v['fvalpkt1'] < 0 ? 0 : $v['ftotpkt1'] - $v['fvalpkt1'], "1", 1, "R");

      $sl_no++;
      $A1 += $v['fspresent'];
      $A2 += $v['fapresent'];
      $A3 += $v['fcodecount'];
      $A4 += $v['fapresent'] - $v['fcodecount'] < 0 ? 0 : $v['fapresent'] - $v['fcodecount'];
      $A5 += $v['ftotpkt1'];
      $A6 += $v['fvalpkt1'];
      $A7 += $v['ftotpkt1'] - $v['fvalpkt1'] < 0 ? 0 : $v['ftotpkt1'] - $v['fvalpkt1'];
    }
    $pdf->SetFont('Times', 'B', 10);
    $pdf->Cell(108, $h, 'Total', "1", 0, "C");
    $pdf->Cell(25, $h, $A1, "1", 0, "R");
    // $pdf->Cell(25, $h, $A2, "1", 0, "R");
    $pdf->Cell(25, $h, $A3, "1", 0, "R");  
    $pdf->Cell(25, $h, $A4, "1", 0, "R");
  
    $pdf->Cell(25, $h, $A5, "1", 0, "R");
    $pdf->Cell(25, $h, $A6, "1", 0, "R");  
    $pdf->Cell(25, $h, $A7, "1", 1, "R");
    
    

  }

  }

  public function SendOutput()
  {
      // ob_end_clean();
      $this->pdf->Output("ValuationStatisticsReport.pdf", "I");
  }
}
function valuationstatsReport($aobj_context){

  

  //http://localhost/univadmin/app.php?a=studentwiseCollList&univcode=041&fcollcode=1001&fdeggrp=UG
  $univcode = $aobj_context->mobj_data["univcode"];    
    $Degree = $aobj_context->mobj_data["deggrp"];
    $fboard = $aobj_context->mobj_data["fboard"];
    $fexamno = $aobj_context->mobj_data["fexamno"];
    $status = $aobj_context->mobj_data["status"];

    if($fboard == 'All'){
        $cnd1 = "";
    }else{
        $cnd1 = "and m.fboard = '{$fboard}'";
    }

    if ($status == "All") {
        $cnd2 = "";
    } else if ($status == "completed") {
        $cnd2 = "and (ifnull(ftotpkt1,0) - ifnull(fvalpkt1,0)) = 0";
    } else if ($status == "pending") {
        $cnd2 = "and (ifnull(ftotpkt1,0) - ifnull(fvalpkt1,0)) <> 0";
    }

    if ($status == "All") {
      $cnd2 = "";
  } else if ($status == "completed") {
      if($Degree == 'PG')
      {
          $cnd2 = "and (ifnull(ftotpkt1,0) - ifnull(fvalpkt1,0)) = 0
          and (ifnull(ftotpkt2,0) - ifnull(fvalpkt2,0)) = 0";
      }else
      {
          $cnd2 = "and (ifnull(ftotpkt1,0) - ifnull(fvalpkt1,0)) = 0";
          
      }
      //$cnd2 = "and (ifnull(ftotpkt1,0) - ifnull(fvalpkt1,0)) = 0";
  } else if ($status == "pending") {

      if($Degree == 'PG')
      {
          $cnd2 = "and ((ifnull(ftotpkt1,0) - ifnull(fvalpkt1,0)) <> 0
          or  (ifnull(ftotpkt2,0) - ifnull(fvalpkt2,0)) <> 0)";
      }else
      {
          $cnd2 = "and (ifnull(ftotpkt1,0) - ifnull(fvalpkt1,0)) <> 0";    
      }

      
  }

    $examnoStr = strtoupper($fexamno);
    $splitexamno = str_split($examnoStr);
    $examno = implode("','", $splitexamno);

    $query = "SELECT fqpcode, m.fboard, b.fboardname, fsubname, IFNULL(fspresent,0) AS fspresent,
    IFNULL(fapresent,0) AS fapresent, IFNULL(fcodecount,0) AS fcodecount,
    IFNULL(ftotpkt1,0) AS ftotpkt1, IFNULL(fvalpkt1,0) AS fvalpkt1,
    ifnull(ftotpkt2,0) as ftotpkt2, ifnull(fvalpkt2,0) as fvalpkt2,
    ifnull(ftotpkt3,0) as ftotpkt3, ifnull(fvalpkt3,0) as fvalpkt3
    FROM masqp m, control c, masboard b WHERE m.fboard=b.fboardcode AND m.fdeggrp = '{$Degree}' {$cnd1} 
    and fexamno in ('{$examno}')
    {$cnd2}
    HAVING fcodecount>0
    ORDER BY m.fboard,fqpcode";

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

  
  $class_obj = new Report();
  $class_obj->univcode=$univcode;
  $class_obj->fcollcode = $fcollcode;
  $class_obj->DefaultConstructor($aobj_context);
  
  if(count($result)>0)
    $class_obj->writeReport($result,$Degree);
  
  $class_obj->SendOutput();
}


?>