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.145.42.140
<?php
function getDateMaster($aobj_context)
{
$deggrp = $aobj_context->mobj_data["deggrp"];
$query = "SELECT m.fdatecode, date_format(m.fdate,'%d/%m/%Y') as fdate,
ifnull(m.fdeleted, 'false') as fdeleted FROM masdate m
INNER JOIN deggrp d ON m.fdeggrp = d.fdeggrp AND m.fyear = d.fyear AND m.fexamtype = d.fexamtype
WHERE d.fdeggrp = '{$deggrp}' and ifnull(m.fdeleted,'') <> 'T'";
$result = $aobj_context->pobj_db->GetAll($query);
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while fetching date codes " . $deggrp . " degree group";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
if (count($result) >= 0) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
return;
}
}
function insertUpdateDateMaster($aobj_context)
{
// $deggrp = $aobj_context->mobj_data["fdeggrp"];
// $newDM = $aobj_context->mobj_data["newDM"];
// $data = json_decode($newDM, true);
$req = $aobj_context->req_body;
// var_dump($req);return;
$data = $req['data'];
$deggrp = $data['fdeggrp'];
$newDM = $data['newDM'];
$user = $data['user'];
$query = "select fyear, fexamtype from deggrp where fdeggrp= '{$deggrp}'";
$result = $aobj_context->pobj_db->GetRow($query);
$values = '';
foreach ($newDM as $k => $v) {
$deleted = $v['fdeleted'] == 'true' ? 'T' : 'F';
$values .= "('" . $v['fdatecode'] . "', '" . $deggrp . "', '" . $result['fyear'] . "', '" . $result['fexamtype'] . "',
DATE_FORMAT(str_to_date('" . $v['fdate'] . "','%d/%m/%Y'),'%Y-%m-%d'), '{$deleted}',
'{$user['fcurtype']}-{$user['fuserid']}', now()),";
}
$values = rtrim($values, ',');
// var_dump($values);
$query = "insert into masdate(fdatecode, fdeggrp, fyear, fexamtype, fdate, fdeleted, fuser, fmoddate ) values " . $values . "
ON DUPLICATE KEY UPDATE
fdate = VALUES(fdate),
fdeleted = VALUES(fdeleted),
fuser=VALUES(fuser),
fmoddate=now()";
$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;
}
}
|