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


Current Path : /proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/examCntrdurexm.php

<?php

function getExmCntr($aobj_context)
{

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

 $deggrp = $aobj_context->mobj_data["dgp"];
 $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 != '') {
  $fdegree = "and d.fdeggrp = '{$deggrp}'";
 }
 
 $query = "SELECT s.fcntrcode, cl.fcollname, cl.ftown, 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.fqpcode,a.fdoe, a.fsubname, COUNT(a.fregno) AS pcount FROM
      (SELECT cs.fcntrcode, 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
      WHERE IFNULL(fpresent,'') = 'P' and ifnull(s.fdoe,'0000-00-00') <> '0000-00-00'
      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);
 $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;
 }
}