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.119.158.110
<?php
function getTimeTables($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$deggrp = $aobj_context->mobj_data["dgp"];
$degrngfrom = $aobj_context->mobj_data["fdegfrm"];
$degrngto = $aobj_context->mobj_data["fdegto"];
$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 = "";
$cnd = "";
if ($fdatefrm != "" && $fdateto != "") {
$cnd = "AND IFNULL(s.fdoe, '0000-00-00') between '{$datefrm}' and '{$dateto}'";
}
//if qpcode not mentioned
$fqpcode = "";
if ($qprngfrom != '' && $qprngto != "") {
$fqpcode = "AND s.fqpcode BETWEEN '{$qprngfrom}' AND '{$qprngto}'";
}else{
$fqpcode = "AND s.fqpcode BETWEEN '0' AND 'zzzzz'";
}
//if Degree group not mentioned
$fdegrng = "";
if ($degrngfrom === '' && $degrngto === ""){
$degrngfrom = '0';
$degrngto = 'zzzzz';
}elseif ($degrngto === "") {
$degrngto = 'zzzzz';
}
$fdegree = "";
if ($deggrp != '') {
$fdegree = "and d.fdeggrp = '{$deggrp}'";
}
//In the query I have assigned as d.fdegree = '{$deggrp}1' 1 is extra because in MBA there are no records, So making it as MBA1
// $query = "select s.fqpcode, s.fsubname, d.fdegree,d.fdescpn,d.fexamdate,d.fexamno,
// ifnull(s.fdatecodet,'') as fdatecode, ifnull(s.fsession,'') as ftimecode,
// ifnull(date_format(ifnull(md.fdate, ''),'%d/%m/%Y'),'') as fdate,
// ifnull(r.fdescpn,'') as ftime
// from subject s inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
// inner join masdate md on s.fdatecodet = md.fdatecode and md.fdeggrp = '{$deggrp}'
// and md.fyear = d.fmeyear and d.fmeexamtyp = md.fexamtype
// inner join reason r on s.fsession = r.freasoncd
// where d.fdegree BETWEEN '{$degrngfrom}' AND '{$degrngto}' {$fqpcode} {$cnd}
// and s.ftheory = 'T' and s.fintass <> 'T' and ifnull(s.fqpcode,'') <>''
// and d.fdeggrp = '{$deggrp}'
// order by s.fdegree,md.fdate,s.fqpcode,d.fexamno";
$query = "select s.fqpcode, s.fsubname, d.fdegree,d.fdescpn,d.fexamdate, d.fexamname as fexamno,
ifnull(s.fdatecodet,'') as fdatecode, ifnull(s.fsession,'') as ftimecode,
ifnull(date_format(ifnull(s.fdoe, ''),'%d/%m/%Y'),'') as fdate,
ifnull(r.fdescpn,'') as ftime
from subject s inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
inner join reason r on s.fsession = r.freasoncd
where d.fdegree BETWEEN '{$degrngfrom}' AND '{$degrngto}' {$fqpcode} {$cnd}
and s.ftheory = 'T' and s.fintass <> 'T' and ifnull(s.fqpcode,'') <>''
and d.fdeggrp = '{$deggrp}'
order by s.fdegree,s.fdoe,s.fqpcode,d.fexamno";
// 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;
}
}
|