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.15.26.231
<?php
function getCentresForUpdation($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$deggrp = $aobj_context->mobj_data["deggrp"];
if ($deggrp == '') {
$arr['msg'] = 'Invalid Params';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 1, "failure");
return;
}
$query = "select fyear, fexamtype from deggrp where fdeggrp = '{$deggrp}' limit 1";
$result = $aobj_context->pobj_db->GetRow($query);
$fyear = $result['fyear'];
$fexamtype = $result['fexamtype'];
$query = "select d.fcollcode, concat(cl.fcollname,', ',cl.ftown) as fcollname,
ifnull(d.fexamcodet,'') as fexamcodet,
ifnull(d.fexamcodep,'') as fexamcodep
from degcntr d inner join college cl on d.fcollcode = cl.fcollcode
where d.fdeggrp = '{$deggrp}' and d.fyear = '{$fyear}' and d.fexamtype = '{$fexamtype}'";
$result = $aobj_context->pobj_db->GetAll($query);
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while fetching Exam Centre Details";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
if (count($result) > 0) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
return;
}
$query= "select distinct fyear, fexamtype from degcntr where fdeggrp = '{$deggrp}'
order by fyear desc, fexamtype desc";
$result = $aobj_context->pobj_db->GetRow($query);
$fpyear = $result['fyear'];
$fpexamtype = $result['fexamtype'];
$query = "select d.fcollcode, concat(cl.fcollname,', ',cl.ftown) as fcollname,
ifnull(d.fexamcodet,'') as fexamcodet,
ifnull(d.fexamcodep,'') as fexamcodep
from degcntr d inner join college cl on d.fcollcode = cl.fcollcode
where d.fdeggrp = '{$deggrp}' and d.fyear = '{$fpyear}' and d.fexamtype = '{$fpexamtype}'
union
select distinct cs.fcollcode, concat(cl.fcollname, ', ', cl.ftown) as fcollname,
ifnull(dc.fexamcodet, cl.fcollcode) as fexamcodet, ifnull(dc.fexamcodep, cl.fcollcode) as fexamcodep
from candsum cs inner join college cl on cs.fcollcode = cl.fcollcode
inner join degree dg on cs.fdegree = dg.fdegree and cs.fexamno = dg.fexamno
and cs.fyear = dg.fmeyear and cs.fexamtype = dg.fmeexamtyp
left join degcntr dc on dc.fcollcode = cl.fcollcode and dg.fdeggrp = dc.fdeggrp
and dc.fyear = dg.fmeyear and dc.fexamtype = dg.fmeexamtyp
where dg.fdeggrp = '{$deggrp}' and cl.fcollcode not in
(select fcollcode from degcntr where fdeggrp = '{$deggrp}' and fyear = '{$fpyear}' and fexamtype = '{$fpexamtype}')";
$result = $aobj_context->pobj_db->GetAll($query);
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while fetching Exam Centre Details";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
if (count($result) > 0) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
return;
}
$query = "select distinct cs.fcollcode, concat(cl.fcollname, ', ', cl.ftown) as fcollname,
ifnull(dc.fexamcodet, cl.fcollcode) as fexamcodet, ifnull(dc.fexamcodep, cl.fcollcode) as fexamcodep
from candsum cs inner join college cl on cs.fcollcode = cl.fcollcode
inner join degree dg on cs.fdegree = dg.fdegree and cs.fexamno = dg.fexamno
and cs.fyear = dg.fmeyear and cs.fexamtype = dg.fmeexamtyp
left join degcntr dc on dc.fcollcode = cl.fcollcode and dg.fdeggrp = dc.fdeggrp
and dc.fyear = dg.fmeyear and dc.fexamtype = dg.fmeexamtyp
where dg.fdeggrp = '{$deggrp}'";
$result = $aobj_context->pobj_db->GetAll($query);
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while fetching Exam Centre Details";
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'] = "Exam Centre Details Not found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
}
function saveUpdatedCentres($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$req = $aobj_context->req_body['data'];
// var_dump($req);
if (!array_key_exists('cntrlist', $req) || !array_key_exists('fdeggrp', $req)) {
$arr['msg'] = 'Invalid Params';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if (count($req['cntrlist']) == 0) {
$arr['msg'] = 'Invalid Params data';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$centreList = $req['cntrlist'];
$deggrp = $req["fdeggrp"];
// var_dump($deggrp);
$query = "select fyear, fexamtype from deggrp where fdeggrp = '{$deggrp}' limit 1";
$result = $aobj_context->pobj_db->GetRow($query);
$fyear = $result['fyear'];
$fexamtype = $result['fexamtype'];
$values = '';
foreach ($centreList as $k => $v) {
$values .= "( '{$deggrp}', '{$v['fcollcode']}', '{$v['fexamcodet']}', '{$v['fexamcodep']}', '{$fyear}', '{$fexamtype}', 'F'),";
}
$values = rtrim($values, ',');
// var_dump($values);
$query = "insert into degcntr(fdeggrp, fcollcode, fexamcodet, fexamcodep, fyear, fexamtype, fdeleted )
values " . $values . "
on duplicate key update
fexamcodet = VALUES(fexamcodet), fexamcodep = VALUES(fexamcodep)";
// var_dump($query);
$result = $aobj_context->pobj_db->Execute($query);
$query = "update candsum c, degcntr d, degree g
set c.fcntrcode = d.fexamcodet where c.fcollcode = d.fcollcode
and c.fdegree = g.fdegree and c.fexamno = g.fexamno and d.fdeggrp = g.fdeggrp
and c.fyear = g.fmeyear and c.fexamtype = g.fmeexamtyp
and d.fyear = g.fmeyear and d.fexamtype = g.fmeexamtyp
and d.fyear = '{$fyear}' and d.fexamtype = '{$fexamtype}'
and d.fdeggrp = '{$deggrp}'";
$result = $aobj_context->pobj_db->Execute($query);
if ($result) {
$arr['msg'] = 'Successfully Updated';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
} else {
$arr['msg'] = 'Insertion / Updation Failed';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
|