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.129.24.240
<?php
function getAvailableQp($aobj_context){
$db = $aobj_context->mobj_data["db"];
$data = json_decode($aobj_context->mobj_data["data"], true);
$deggrp = $data['deggrp'];
$board = $data['board'];
$data['sem'] === "All" ? $sem = "" : $sem = "and s.fexamno='{$data['sem']}'";
$data['degree'] === "All" ? $degree = "" : $degree = "and s.fdegree='{$data['degree']}'";
$data['qpcode'] === "All" ? $qpcode = "" : $qpcode = "and s.fqpcode='{$data['qpcode']}'";
$data['avl'] === "" || $data['avl'] === NULL ? $avilQPLess = "" : $avilQPLess = "having available < '{$data['avl']}'";
if($db === 'reva'){
$cnd = "and ifnull(fmodqpupd, '')<>''";
}else{
$cnd = "";
}
$query = "select s.fdegree, s.fexamno, s.fqpcode,
concat(s.fsubshort,' - ',s.fsubname, ' [',s.fqpcode, ']') as fsubname,
ifnull(q.fset, '0') as fset,
ifnull(q.available, '0')as available,
ifnull(q.used, '0')as used,
s.fsubshort,s.FELIGQP
from subject s
inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
inner join deggrp dg on dg.fdeggrp = d.fdeggrp
left join (select fqpcode,count(fset) as fset,
sum(case when ifnull(FFINALPAPER, '') = '' then 1 else 0 end) as available,
sum(case when ifnull(FFINALPAPER, '') = 'T' then 1 else 0 end) as used
from qpseterdet where ifnull(fqpfilepath,'') <> '' {$cnd}
group by fqpcode) q on s.fqpcode = q.fqpcode
where ifnull(s.fdeleted, '') <> 'T'
and dg.fdeggrp='{$deggrp}' {$sem} {$degree} {$qpcode}
and ifnull(s.fqpcode,'') <> ''
group by s.fqpcode
{$avilQPLess}";
// var_dump($query);die();
// $query = "select s.fdegree, s.fexamno, s.fdeggrp, q.fqpcode,
// count(q.fset) as fset,
// concat(s.fsubshort,' - ',s.fsubname) as fsubname,
// sum(case when ifnull(q.FFINALPAPER, '') = '' then 1 else 0 end)as available,
// sum(case when ifnull(q.FFINALPAPER, '') = 'T' then 1 else 0 end)as used,
// s.fsubshort,s.FELIGQP
// from qpseterdet q inner join (select distinct s.fdegree, s.fexamno, s.fqpcode, s.fsubname,
// s.fsubshort, dg.fdeggrp,ifnull(s.FELIGQP,'F')as FELIGQP from subject s
// inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
// inner join deggrp dg on dg.fdeggrp = d.fdeggrp
// where ifnull(fqpcode,'') <> ''
// {$degree} and dg.fdeggrp='{$deggrp}' {$sem}
// group by fqpcode) s on s.fqpcode = q.fqpcode
// where ifnull(fqpfilepath, '')<>'' {$qpcode} and ifnull(fdeleted, '') <> 'T'
// group by fqpcode {$avilQPLess}";
$result = $aobj_context->mobj_db->GetAll($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
}else{
$arr['msg'] = "No data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function saveAvailableQp($aobj_context){
$data = json_decode($aobj_context->mobj_data["data"], true);
foreach($data as $val){
$query = "update subject set FELIGQP = '{$val['FELIGQP']}'
where FDEGREE = '{$val['fdegree']}' and FEXAMNO = '{$val['fexamno']}'
and FSUBSHORT = '{$val['fsubshort']}' and FQPCODE = '{$val['fqpcode']}'";
$result = $aobj_context->mobj_db->Execute($query);
}
if($result){
$arr['msg'] = "Successfully Updated";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}else{
$arr['msg'] = "No data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function viewDetailedAvailableQp($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$data = json_decode($aobj_context->mobj_data["data"], true);
$fdeggrp = $data['fdeggrp'];
$fdegree = $data['fdegree'];
$fexamno = $data['fexamno'];
$fqpcode = $data['fqpcode'];
$query = "select s.fdegree, s.fdeggrp, s.fexamno, q.fteachcode, m.fteachname, concat(s.fsubshort,' - ',s.fsubname, ' [',s.fqpcode, ']') as fsubname,
s.fsubshort, q.fqpcode, fset, fyear, fexamtype,
concat(fyear,' / ',fexamtype) fyears,
if(ifnull(q.fqpfilepath, '')<>'', 'Yes', 'No')as fqpupdstatus,
date_format(q.fqpdtme, '%d/%m/%Y %h:%m:%s')as fqpdtme,
if(ifnull(q.fmodqpupd, '') <> '', 'Yes', 'No')as fmodstatus,
date_format(q.fmodqpdate, '%d/%m/%Y %h:%m:%s')as fmodtme,
if(ifnull(q.ffinalpaper, '') = 'T', 'Used', '')as used,
date_format(q.ffinalpaperdate, '%d/%m/%Y %h:%m:%s')as ffinalpaperdate,
ifnull(q.fteachcode,'') as fteachcode
from qpseterdet q
inner join (
select distinct s.fdegree, s.fexamno, s.fqpcode, s.fsubname, s.fsubshort, dg.fdeggrp from subject s
inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
inner join deggrp dg on dg.fdeggrp = d.fdeggrp
where ifnull(fqpcode,'') <> ''
and s.fdegree='{$fdegree}' and dg.fdeggrp='{$fdeggrp}' and s.fexamno='{$fexamno}'
group by fqpcode)s on s.fqpcode = q.fqpcode
inner join masteach m on m.fteachcode = q.fteachcode
where ifnull(fqpfilepath, '')<>'' and q.fqpcode='{$fqpcode}'
and ifnull(q.fdeleted, '') <> 'T'";
$result = $aobj_context->mobj_db->GetAll($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
}else{
$arr['msg'] = "No data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getAvailableSubjects($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$board = $aobj_context->mobj_data["board"];
$deggrp = $aobj_context->mobj_data["deggrp"];
if($board === "All"){
$cnd = "";
}else{
$cnd = "and s.fboard = '{$board}'";
}
$query = "select s.fqpcode,
concat(group_concat(distinct s.fsubshort),' - ',s.fsubname, ' - ',s.fssubname, ' [',s.fqpcode, ']') as fsubname
from subject s
inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
inner join deggrp dg on dg.fdeggrp = d.fdeggrp
left join (select fqpcode,count(fset) as fset,
sum(case when ifnull(FFINALPAPER, '') = '' then 1 else 0 end) as available,
sum(case when ifnull(FFINALPAPER, '') = 'T' then 1 else 0 end) as used
from qpseterdet where ifnull(fqpfilepath,'') <> ''
group by fqpcode) q on s.fqpcode = q.fqpcode
where ifnull(s.fdeleted, '') <> 'T'
and dg.fdeggrp='{$deggrp}' {$cnd}
and ifnull(s.fqpcode,'') <> ''
group by s.fqpcode";
$result = $aobj_context->mobj_db->GetAll($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
}else{
$arr['msg'] = "No qp data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
?>
|