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.216.167.229
Current Path : /var/www/oasis/src/ |
| Current File : /var/www/oasis/src/roomallotmentqpwise.php |
<?php
function getsession($aobj_context){
session_start();
$collcode = $_SESSION['collcode'];
$examdate = $aobj_context->mobj_data["rdate"];
$date = DateTime::createFromFormat('d-m-Y', $examdate);
$formatted_date = $date->format('Y-m-d');
$query="SELECT distinct s.fsession, r.fdescpn FROM subject s INNER JOIN reason r ON s.fsession=r.freasoncd
WHERE s.fdoe='{$formatted_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");
}
}
function toDisplayQPcode($aobj_context){
$date = $aobj_context->mobj_data["rdate"];
$date = DateTime::createFromFormat('d-m-Y', $date);
$formatted_date = $date->format('Y-m-d');
$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
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(fqpcode,'')<>'' AND IFNULL(c.fpassmth,'')='' AND
IFNULL(c.fpresent,'')='P'
AND IFNULL(d.frecptdate,'')<>''
AND s.fdoe='{$formatted_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");
}
}
function getRoomdetailQpwise($aobj_context){
session_start();
$collcode = $_SESSION['collcode'];
$code=$aobj_context->mobj_data["qpcode"];
$gcount=$aobj_context->mobj_data["grandcount"];
$query = "SELECT froomname, fcapacity, froomno FROM masroom WHERE fcollcode='{$collcode}'";
$res = $aobj_context->mobj_db->GetAll($query);
// $query1="select froomname, fcapacity, fallot from masroom where fcollcode='$collcode' and ifnull(fallot,'')<>'' ";
$query1 = "SELECT m.froomname, m.fcapacity, m.froomno, IF(IFNULL(fbalance, '')='', fcapacity, fbalance)AS fbalance ,
COUNT(d.fregno) AS fallot 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='{$code}' AND cs.fcntrcode='{$collcode}'
group by d.fhallno";
$result = $aobj_context->mobj_db->GetAll($query1);
// $totalAllotmentCount = 0;
// foreach ($result as $val) {
// $totalAllotmentCount += $val['fallot'];
// }
// $remainingCount = $gcount - $totalAllotmentCount;
if($res){
$arr['opt']=$res;
$arr['data']=$result;
// $arr['grcount']=$remainingCount;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}
else{
$arr['msg']="Failed to Load";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function getTotalRemaining($aobj_context){
$collcode = $_SESSION['collcode'];
$allot = $aobj_context->mobj_data["allot"];
$qpcount = $aobj_context->mobj_data["qpcount"];
$code = $aobj_context->mobj_data["qpcode"];
$roomno = $aobj_context->mobj_data["roomno"];
$query="SELECT froomname,froomno FROM masroom WHERE froomno='{$roomno}' AND fcollcode='{$collcode}'";
$result=$aobj_context->mobj_db->GetRow($query);
$totalAllotmentCount = 0;
$totalAllotmentCount += $allot;
$remainingCount = $qpcount - $totalAllotmentCount;
if($remainingCount){
$arr['grcount']=$remainingCount;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}
}
function postToTable($aobj_context){
$examdate = $aobj_context->mobj_data["rdate"];
$date = DateTime::createFromFormat('d-m-Y', $examdate);
$formatted_date = $date->format('Y-m-d');
$qpcode = $aobj_context->mobj_data["qpcode"];
session_start();
$collcode = $_SESSION['collcode'];
$roomdata = json_decode($aobj_context->mobj_data["data"], true);
foreach ($roomdata as $data) {
$room = $data['froomname'];
$allot = $data['fallot'];
$balance = $data['fbalance'];
$roomno = $data['froomno'];
// $subcode = $data['fsubcode'];
// $degree = $data['fdegree'];
$room1 = explode("-", $room);
$roomname = $room1[0];
if ($data['fdeleted'] == true) {
$query = "update masroom
set fallot='',fbalance=''
where froomno='{$roomno}' AND fcapacity='{$data['fcapacity']}' AND fcollcode='$collcode'";
// "UPDATE canddet
// SET fhallno=''
// WHERE fcollcode='1827' AND fsubcode='A024' AND fdegree='Bcom1'"
$res = $aobj_context->mobj_db->Execute($query);
} else {
$query = "UPDATE masroom
SET fallot='{$allot}',fbalance='{$balance}'
WHERE froomno='{$roomno}' AND fcapacity='{$data['fcapacity']}'
and fcollcode = '{$collcode}'";
$res = $aobj_context->mobj_db->Execute($query);
}
$upd = "update canddet cd, candsum cs set cd.fhallno = NULL, cd.fslno = NULL
where cd.fregno = cs.fregno
and cd.fcollcode = cs.fcollcode
and cd.fqpcode1 = '{$qpcode}'
and cs.fcntrcode = '{$collcode}'";
$res = $aobj_context->mobj_db->Execute($upd);
// in this equal with fqpcode not fsubcode
$query = "CREATE TEMPORARY 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 = '{$formatted_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'
ORDER BY cd.fregno ASC
LIMIT {$allot}";
$res = $aobj_context->mobj_db->Execute($query);
// equal with fqpcode
$query = "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 = '{$roomno}',canddet.fqpcode1 = '{$qpcode}'
WHERE sub.fqpcode='{$qpcode}'
AND IFNULL(fhallno, '') = ''";
$res = $aobj_context->mobj_db->Execute($query);
$query = "DROP TEMPORARY TABLE temp_fregno";
$res = $aobj_context->mobj_db->Execute($query);
$query = "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_format(STR_TO_DATE('{$examdate}', '%d-%m-%Y'),'%Y-%m-%d')
AND IFNULL(cd.fpassmth,'') = '' AND cd.FPRESENT='P'
AND IFNULL(cs.FRECPTDATE,'0000-00-00')<>'0000-00-00'
and cd.fhallno = '{$roomno}'
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";
$lobj_insert = $aobj_context->mobj_db->Execute($query);
}
if ($res) {
$arr['msg'] = "Successfully Inserted";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg'] = "Failed To Insert";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function getRemainingCapacity($aobj_context){
$roomname = $aobj_context->mobj_data["roomname"];
$capacity = $aobj_context->mobj_data["capacity"];
$roomno = $aobj_context->mobj_data["roomno"];
$collcode = $_SESSION['collcode'];
$query = "select if(ifnull(fbalance, '')='', fcapacity, fbalance)as fbalance 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");
}
}
?>
|