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.223.241.235
<?php
function getRoomAllotmentdate($aobj_context){
$date = $aobj_context->mobj_data["date"];
$query = "select distinct s.fsession, r.fdescpn from subject s inner join reason r on s.fsession=r.freasoncd
where s.fdoe='{$date}'";
$res = $aobj_context->mobj_db->GetAll($query);
if($res){
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
} else{
$arr['msg']="Failed to Load";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getQpRoomAllotmentData($aobj_context){
$date = $aobj_context->mobj_data["date"];
$session = $aobj_context->mobj_data["session"];
$collcode = $_SESSION['collcode'];
$query = "select s.fdoe, s.fsession, s.fdegree, s.fsubcode, s.fcsubcode, s.fqpcode,
s.fsubname, c.fregno, count(c.fregno)as counts, sum(if(ifnull(c.fhallno,'')='', 0, 1))as qpcount,
(count(c.fregno) - sum(if(ifnull(c.fhallno,'')='', 0, 1))) as fremaingcount
from subject s inner join
canddet c on s.fdegree = c.fdegree and s.fexamno = c.fexamno
and s.fsubcode = c.fsubcode inner join candsum d on c.fregno = d.fregno
and c.fcollcode = d.fcollcode
inner join reason r on s.fsession=r.freasoncd
where s.ftheory='t' and s.fintass='f'
and ifnull(s.fqpcode,'')<>'' and ifnull(c.fpassmth,'')='' and
ifnull(c.fpresent,'')='P'
and ifnull(d.frecptdate,'')<>''
and s.fdoe='{$date}' and s.fsession like '{$session}%'
and d.fcntrcode='{$collcode}'
group by s.fdoe,s.fsession,s.fqpcode
order by s.fdoe,s.fsession,s.fcsubcode,s.fqpcode,s.fsubname";
$res = $aobj_context->mobj_db->GetAll($query);
if($res){
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
} else{
$arr['msg']="Failed to Load";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getQpRoomAllotment($aobj_context){
$qpcode = $aobj_context->mobj_data["qpcode"];
$collcode = $_SESSION['collcode'];
$query0 = "select froomname, fcapacity, froomno from masroom where fcollcode='{$collcode}'";
$res0 = $aobj_context->mobj_db->GetAll($query0);
// $query1 = "SELECT fhallno,COUNT(fregno)AS alloted,m.fbalance,m.fcapacity FROM canddet c INNER JOIN subject s
// ON c.fdegree=s.fdegree AND c.fsubcode=s.fsubcode
// INNER JOIN masroom m ON m.froomno=c.fhallno
// WHERE IFNULL(fhallno,'')<>'' AND IFNULL(fqpcode1,'')<>''
// AND s.fdoe='2024-05-21' AND s.fsession='M4' AND m.fcollcode='1827'
// AND c.fqpcode1='13101' GROUP BY fhallno";
// $res1 = $aobj_context->mobj_db->GetAll($query1);
// if($res1){
// $arr['data'] = $res1;
// echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
// } else{
// echo $aobj_context->mobj_output->ToJSONEnvelope($res1, -1, "success");
// }
$query = "select m.froomname, m.fcapacity, m.froomno, if(ifnull(fbalance, '')='', fcapacity, fbalance)as fbalance ,
count(d.fregno) as fallot, count(d.fqpcode1)as qpcount from masroom m inner join candsum cs
on m.fcollcode = cs.fcntrcode inner join canddet d
on m.froomno = d.fhallno and cs.fcollcode = d.fcollcode
and cs.fregno = d.fregno inner join subject s
on d.fqpcode1 = s.fqpcode
and d.fdegree = s.fdegree and d.fexamno = s.fexamno
and d.fsubcode = s.fsubcode
where d.fqpcode1='{$qpcode}' and cs.fcntrcode='{$collcode}'
group by d.fhallno";
$res = $aobj_context->mobj_db->GetAll($query);
if($res0){
$arr['options'] = $res0;
$arr['data'] = $res;
$arr['saved']=$res1;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else{
$arr['msg']="Failed to Load";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getQPRoomCapacity($aobj_context){
$roomno = $aobj_context->mobj_data["roomno"];
$capacity = $aobj_context->mobj_data["capacity"];
$collcode = $_SESSION['collcode'];
$query = "select if(ifnull(fbalance, '')='', fcapacity, fbalance)as fbalance,
if(ifnull(fallot, '')='','0', fallot)as fallotted from masroom
where fcollcode='{$collcode}' and froomno='{$roomno}' and fcapacity='{$capacity}'";
$res = $aobj_context->mobj_db->GetRow($query);
if ($res) {
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
} else {
$arr['msg'] = "Failed To Insert";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function saveQpRoomAllotment($aobj_context){
$data = json_decode($aobj_context->mobj_data["data"], true);
$date = $aobj_context->mobj_data["date"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$collcode = $_SESSION['collcode'];
foreach ($data as $key => $value) {
$query6 = "drop table if exists temp_fregno";
$res6 = $aobj_context->mobj_db->Execute($query6);
$query3 = "create table temp_fregno as
select distinct cd.fregno from canddet cd inner join subject s on
s.fdegree = cd.fdegree and s.fexamno = cd.fexamno and s.fsubcode = cd.fsubcode
inner join candsum cs on cd.fregno = cs.fregno
and cd.fcollcode = cs.fcollcode
left join absent ab on ab.fregno = cd.fregno where
s.fdoe = '{$date}' and ifnull(cd.fpassmth, '') = ''
and cd.fpresent='P' and cs.fcntrcode = '{$collcode}'
and s.fqpcode = '{$qpcode}' and ifnull(cd.fhallno, '') = ''
and ifnull(s.fqpcode,'')<>'' and s.fintass='F'
and ifnull(frecptdate, '') <> '' order by cd.fregno asc
limit {$value['fallot']}";
$res3 = $aobj_context->mobj_db->Execute($query3);
$query4 = "update canddet join temp_fregno on canddet.fregno = temp_fregno.fregno
inner join subject sub on sub.fdegree = canddet.fdegree
and sub.fexamno = canddet.fexamno and sub.fsubcode = canddet.fsubcode
set canddet.fhallno = '{$value['froomno']}', canddet.fqpcode1 = '{$qpcode}'
where sub.fqpcode='{$qpcode}'
and ifnull(fhallno, '') = ''";
$res4 = $aobj_context->mobj_db->Execute($query4);
$query6 = "update canddet x, (select right(concat('000',@a:=@a+1),3) as fslno,
fregno, fqpcode1, fhallno
from (select cd.fdegree, cd.fcollcode,
cd.fregno, cd.fqpcode1, cd.fhallno from canddet cd, subject s, candsum cs
where s.fdegree = cd.fdegree
and s.fexamno = cd.fexamno and s.fsubcode = cd.fsubcode
and cd.fqpcode1 = s.fqpcode and cs.fregno = cd.fregno
and cd.fcollcode = cs.fcollcode
and s.fdoe = '{$date}'
and ifnull(cd.fpassmth,'') = '' and cd.fpresent='P'
and ifnull(cs.frecptdate,'0000-00-00')<>'0000-00-00'
and cd.fhallno = '{$value['froomno']}'
and cs.fcntrcode = '{$collcode}'
and ifnull(s.fqpcode,'') <> ''
order by cd.fqpcode1,fregno) b, (select @a:= '000') as a) y
set x.fslno = y.fslno
where x.fqpcode1 = y.fqpcode1
and x.fhallno = y.fhallno
and x.fregno = y.fregno";
$res6 = $aobj_context->mobj_db->Execute($query6);
if($res6){
$query0 = "select if(ifnull(fbalance, '')='', fcapacity, fbalance)as fbal,
ifnull(fallot, '')as fallotted, ifnull(fcapacity, '')as fcapacity
from masroom where fcollcode = '{$collcode}' and froomno='{$value['froomno']}'";
$res0 = $aobj_context->mobj_db->GetRow($query0);
$remaining = intval($res0['fcapacity']) - (intval($res0['fallotted']) + intval($value['fallot']));
$allotted = intval($res0['fallotted']) + intval($value['fallot']);
$query1 = "update masroom set fallot='{$allotted}', fbalance='{$remaining}'
where froomno='{$value['froomno']}' and fcollcode = '{$collcode}'";
$res1 = $aobj_context->mobj_db->Execute($query1);
}
}
if ($res1) {
$arr['msg'] = "Updated successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function viewAllotedData($aobj_context){
$collcode = $_SESSION['collcode'];
$date = $aobj_context->mobj_data["date"];
$session = $aobj_context->mobj_data["session"];
$qpcode = $aobj_context->mobj_data["code"];
$subcode = $aobj_context->mobj_data["subcode"];
$count = $aobj_context->mobj_data["count"];
$query = "SELECT fhallno,COUNT(fhallno)AS cnt FROM canddet WHERE fqpcode1='{$qpcode}' GROUP BY fhallno";
$res = $aobj_context->mobj_db->GetAll($query);
foreach ($res as $value) {
$query="select ifnull(fbalance,0) as fbalance, ifnull(fallot,0) as fallot from masroom where froomno='{$value['fhallno']}' and fcollcode='{$collcode}'";
$res = $aobj_context->mobj_db->GetRow($query);
$remainAllot = intval($res['fallot']) - intval($value['cnt']);
$addBalance = intval($res['fbalance']) + intval($value['cnt']);
$query=" UPDATE masroom
SET fallot = '{$remainAllot}', fbalance = '{$addBalance}'
WHERE froomno='{$value['fhallno']}' AND fcollcode='{$collcode}'";
$res = $aobj_context->mobj_db->Execute($query);
if($res){
$qry = "update canddet set fhallno = '',fslno = '' where fqpcode1='{$qpcode}' and fhallno='{$value['fhallno']}'";
$result = $aobj_context->mobj_db->Execute($qry);
}
}
if ($res) {
$arr['msg']='Reset Successfully';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg']='Reset Failed';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
?>
|