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 : 13.58.232.94
<?php
function getHolidayMaster($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$fyear = $aobj_context->mobj_data["fyear"];
// var_dump($fyear);
$query = "select fyear, DATE_FORMAT(fdate,'%d/%m/%Y') AS fdate, fremarks, fdeleted from holiday where fyear={$fyear} and fdeleted='F'";
$result = $aobj_context->pobj_db->GetAll($query);
if(!$result && gettype($result) == 'boolean')
{
$arr['msg'] = "Error while fetching holidays for year ".$fyear;
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 saveHolidayMaster($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$req = $aobj_context->req_body;
$data = $req['data'];
if(!array_key_exists('holidays', $data) || !array_key_exists('fyear', $data) )
{
$arr['msg'] = 'Invalid Params';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,1,"failure");
return;
}
if(count($data['holidays']) == 0 || $data['fyear'] == '' )
{
$arr['msg'] = 'Invalid Params data';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,1,"failure");
return;
}
$values = '';
foreach( $data['holidays'] as $k => $v )
{
$deleted = $v['fdeleted'] == 'true' ? 'T' : 'F';
$values .= "(DATE_FORMAT(str_to_date('".$v['fdate']."','%d/%m/%Y'),'%Y-%m-%d'), '".$v['fremarks']."', '{$data['fyear']}', '{$deleted}'),";
}
$values = rtrim($values, ',');
$query = "insert into holiday(fdate, fremarks, fyear, fdeleted ) values ".$values."
ON DUPLICATE KEY UPDATE
fdate = VALUES(fdate), fremarks = VALUES(fremarks),fdeleted = VALUES(fdeleted)";
// var_dump($query);
$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;
}
}
|