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.139.233.121
<?php
function getQpTemplateDet($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$query = "select ftempcode, ftempname, ftempdesc
from tdvs_qptemphead
where ifnull(fdeleted,'') <> 'T'
group by ftempcode";
$result = $aobj_context->mobj_db->GetAll($query);
if(count($result) > 0)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}
else
{
$arr['msg'] = 'No data Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function deleteTemplateCode($aobj_context){
$univcode = $aobj_context->mobj_data["univcode"];
$tempcode = $aobj_context->mobj_data["tempcode"];
$sltQry = "select ftempcode from tdvs_masqp where ftempcode='{$tempcode}'";
$res = $aobj_context->mobj_db->GetAll($sltQry);
if(count($res) === 0){
$query = "delete from tdvs_qptempdetl where ftempcode='{$tempcode}'";
$result = $aobj_context->mobj_db->Execute($query);
$query = "delete from tdvs_qptemphead where ftempcode='{$tempcode}'";
$result = $aobj_context->mobj_db->Execute($query);
}
if($result){
$arr['msg'] = 'Deleted Successfully';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg'] = 'Something Went wrong';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function tempCodeDet($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$ftempcode = $aobj_context->mobj_data["ftempcode"];
$query = "select ifnull(ftempcode,'') as ftempcode,
ifnull(ftempname,'') as ftempname,
ifnull(ftempdesc,'') as ftempdesc,
ifnull(ftempmax,'') as ftempmax,
ifnull(ftotmandqn,'') as ftotmandqn,
ifnull(fpartcode,'') as fpartcode,
ifnull(fpartdesc,'') as fpartdesc,
ifnull(fmaxqn,'') as fmaxqn,
ifnull(fmandqn,'') as fmandqn,
ifnull(fmaxmarks,'') as fmaxmarks,
ifnull(fminqn,'') as fminqn
from tdvs_qptemphead where ftempcode = '{$ftempcode}'";
$result = $aobj_context->mobj_db->GetAll($query);
$que = "select ifnull(ftempcode, '') as ftempcode,
ifnull(fpartcode, '') as fpartcode,
ifnull(fqncode, '') as fqncode,
ifnull(fqnno, '') as fqnno,
ifnull(fqndesc, '') as fqndesc,
ifnull(fqnlevel, '') as fqnlevel,
ifnull(fqnparent, '') as fqnparent,
ifnull(fmaxmarks, '') as fmaxmarks,
ifnull(fsubqp, '') as fsubqp,
ifnull(fsubmaxqn, '') as fsubmaxqn,
ifnull(fsubmandqn, '') as fsubmandqn,
ifnull(fqnord, '') as fqnord
from tdvs_qptempdetl where ftempcode = '{$ftempcode}'
order by fqnord";
$res = $aobj_context->mobj_db->GetAll($que);
$sumarr = array_map('transform', $result);
$arr["ftempcode"] = $result[0]['ftempcode'];
$arr["ftempname"] = $result[0]['ftempname'];
$arr["ftempdesc"] = $result[0]['ftempdesc'];
$arr["ftempmax"] = $result[0]['ftempmax'];
$arr["ftotmandqn"] = $result[0]['ftotmandqn'];
$arr["detlength"] = count($res) > 0 ? "T" : "F";
$arr['sumarr'] = $sumarr;
$arr['sumarrdet']=$res;
if(count($result) > 0)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}
else
{
$arr['msg'] = 'No data Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function transform($el) {
return [
'partcode' => $el['fpartcode'],
'partdescp' => $el['fpartdesc'],
'maxqns' => $el['fmaxqn'],
'mandqns' => $el['fmandqn'],
'maxmarks' => $el['fmaxmarks'],
'minqns' => $el['fminqn']
];
}
function checkTempCode($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$ftempcode = $aobj_context->mobj_data["ftempcode"];
$query = "select * from tdvs_qptemphead where ftempcode = '{$ftempcode}'";
$result = $aobj_context->mobj_db->GetAll($query);
if(count($result) > 0)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}
else
{
$arr['msg'] = 'No data Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function save_tempcode($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$tempcode = $aobj_context->mobj_data["tempcode"];
$sumdata = json_decode($aobj_context->mobj_data["sumdata"], true);
$delrows = json_decode($aobj_context->mobj_data["delrows"], true);
$tempname = $aobj_context->mobj_data["tempname"];
$tempdesc = $aobj_context->mobj_data["tempdesc"];
$tempmaxmarks = $aobj_context->mobj_data["tempmaxmarks"];
$tempmandqns = $aobj_context->mobj_data["tempmandqns"];
$template_obj = '';
foreach($delrows as $data){
$deleteData = "delete from tdvs_qptemphead
where ftempcode = '${tempcode}' and fpartcode='{$data['partcode']}'";
$res1 = $aobj_context->mobj_db->Execute($deleteData);
}
foreach($sumdata as $val){
$template_obj .= "('{$tempcode}', '{$tempname}', '{$tempdesc}', '{$val['partcode']}', '{$val['partdescp']}', '{$val['maxqns']}', '{$val['mandqns']}',
'{$val['maxmarks']}', '{$tempmaxmarks}', '{$tempmandqns}', '{$val['minqns']}'),";
}
$template_obj = rtrim($template_obj, ',');
$sltQry = "insert into tdvs_qptemphead (ftempcode, ftempname,
ftempdesc, fpartcode, fpartdesc,fmaxqn,fmandqn,
fmaxmarks,ftempmax,ftotmandqn,fminqn) values
{$template_obj}
ON DUPLICATE KEY UPDATE
fpartcode = VALUES(fpartcode),
fpartdesc = VALUES(fpartdesc),
fmaxqn = VALUES(fmaxqn),
fmandqn = VALUES(fmandqn),
fmaxmarks = VALUES(fmaxmarks)";
$res = $aobj_context->mobj_db->Execute($sltQry);
if($res){
$arr['msg'] = 'Successfully Updated';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg'] = 'Something Went wrong';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function saveTempPartDet($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$tempcode = $aobj_context->mobj_data["tempcode"];
$sumdata = json_decode($aobj_context->mobj_data["sumdata"], true);
$delrows = json_decode($aobj_context->mobj_data["delrows"], true);
$template_obj = '';
foreach($delrows as $data){
$deleteData = "delete from tdvs_qptempdetl
where ftempcode = '{$tempcode}' and fpartcode='{$data['partcode']}'
and fqncode = '{$data['qpcode']}'";
$res1 = $aobj_context->mobj_db->Execute($deleteData);
}
foreach ($sumdata as $key => $subArrays) {
foreach ($subArrays as $item) {
$id = $item["id"];
$qpcode = $item["qpcode"];
$qpno = $item["qpno"];
$level = $item["level"];
$parent = $item["parent"];
$maxmarks = $item["maxmarks"];
$subqn = $item["subqn"];
$maxqn = $item["maxqn"];
$mandqp = $item["mandqp"];
$order = $item["order"];
$template_obj .="('{$tempcode}','$key','$qpcode', '$qpno', '$level', '$parent', '$maxmarks', '$subqn', '$maxqn', '$mandqp', '$order'),";
}
}
$template_obj = rtrim($template_obj, ',');
$sltQry = "INSERT INTO tdvs_qptempdetl (ftempcode, fpartcode, fqncode, fqnno, fqnlevel, fqnparent, fmaxmarks, fsubqp, fsubmaxqn, fsubmandqn, fqnord)
values
${template_obj}
ON DUPLICATE KEY UPDATE
fqnno = VALUES(fqnno),
fqndesc = VALUES(fqndesc),
fqnlevel = VALUES(fqnlevel),
fqnparent = VALUES(fqnparent),
fmaxmarks = VALUES(fmaxmarks),
fsubqp = VALUES(fsubqp),
fsubmaxqn = VALUES(fsubmaxqn),
fsubmandqn = VALUES(fsubmandqn),
fqnord = VALUES(fqnord)";
$res = $aobj_context->mobj_db->Execute($sltQry);
if($res){
$arr['msg'] = 'Successfully Updated';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg'] = 'Something Went wrong';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
?>
|