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.16.212.203
<?php
function saveUsertype($aobj_context){
$data = json_decode($aobj_context->mobj_data["data"], true);
$query = "insert into usertype (fusertype, fdescpn)
values('{$data['usertype']}', '{$data['descpn']}')
on duplicate key update fdescpn = '{$data['descpn']}'";
$res = $aobj_context->mobj_db->Execute($query);
if($res){
$arr['msg'] = "updated successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}else{
$arr['msg'] = "Failed to save / update the data";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getUsertypeData($aobj_context){
$query = "select fusertype, ifnull(fdescpn, '')as fdescpn from usertype where ifnull(fusertype, '') <> ''";
$res = $aobj_context->mobj_db->GetAll($query);
if($res){
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
}else{
$arr['msg'] = "No data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function saveCreateUser($aobj_context){
$data = json_decode($aobj_context->mobj_data["data"], true);
$type = $aobj_context->mobj_data["type"];
$query = "select * from qp_masuser
where fmobileno='{$data['mobile']}' and fusertype='{$data['usertype']}'";
$res = $aobj_context->mobj_db->GetRow($query);
if($type == "false" && count($res) > 0){
$arr['msg'] = "User already exist";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if(count($res) > 0){
$query = "update qp_masuser set femail='{$data['email']}',
fdob=date_format(str_to_date('{$data['dob']}', '%d/%m/%Y'),'%Y-%m-%d'),
frealname='{$data['name']}'
where fmobileno='{$data['mobile']}'
and fusertype='{$data['usertype']}'";
$res = $aobj_context->mobj_db->Execute($query);
}else{
$masteachqur = "select * from masteach where fmobile = '{$data['mobile']}'";
$masres = $aobj_context->mobj_db->GetRow($masteachqur);
$fregno = $masres['fregno'];
if(count($masres) > 0){
$query = "insert into qp_masuser(fregno,fmobileno, fpassword, femail, fdob, frealname, fusertype, factive)
values('{$fregno}','{$data['mobile']}', '{$data['mobile']}', '{$data['email']}',
date_format(str_to_date('{$data['dob']}', '%d/%m/%Y'),'%Y-%m-%d'),
'{$data['name']}', '{$data['usertype']}', 'T')";
}else{
$masinstqur = "insert into masteach(fmobile, femail, fdob, fteachname)
values('{$data['mobile']}', '{$data['email']}',date_format(str_to_date('{$data['dob']}', '%d/%m/%Y'),'%Y-%m-%d'),
'{$data['name']}')";
$masinst = $aobj_context->mobj_db->Execute($masinstqur);
$getTeachcode = "select internal_code from masteach where fmobile = '{$data['mobile']}'";
$fregCoderes = $aobj_context->mobj_db->GetRow($getTeachcode);
$fteachcode = $fregCoderes['internal_code'];
$masupdqur = "update masteach set fteachcode = '{$fteachcode}'
where fmobile = '{$data['mobile']}'";
$masupd = $aobj_context->mobj_db->Execute($masupdqur);
$query = "insert into qp_masuser(fregno,fmobileno, fpassword, femail, fdob, frealname, fusertype, factive)
values('{$fteachcode}','{$data['mobile']}', '{$data['mobile']}', '{$data['email']}',
date_format(str_to_date('{$data['dob']}', '%d/%m/%Y'),'%Y-%m-%d'),
'{$data['name']}', '{$data['usertype']}', 'T')";
}
$res = $aobj_context->mobj_db->Execute($query);
}
if($res){
$arr['msg'] = "saved successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}else{
$arr['msg'] = "Failed to save";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getCreateUserData($aobj_context){
$query = "select fmobileno, ifnull(femail, '')as femail, ifnull(frealname, '')as fname, ifnull(date_format(fdob,'%d/%m/%Y'), '')as fdob,
q.fusertype, u.fdescpn from qp_masuser q
inner join usertype u on u.fusertype = q.fusertype where ifnull(fmobileno, '') <> ''";
$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");
return;
}
}
?>
|