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 : 18.220.227.250
<?php
function saveTeacherDetails($aobj_context){
$data = json_decode($aobj_context->mobj_data["data"], true);
$type = $aobj_context->mobj_data["type"];
$teachcode = $data['teachcode'];
$name = $data['name'];
$dob = $data['dob'];
$email = $data['email'];
$mobile = $data['mobile'];
$college = $data['college'];
$examiner = $data['examiner'];
$fcollname = $data['fcollname'];
$mascolcond = "";
$tdvscolcond = "";
$mascolcond1 = "";
$mascolcond2 = "";
$tdvscolcond1 = "";
$tdvscolcond2 = "";
if($college == 'OTHR'){
$mascolcond = ",fcollname = '{$fcollname}'";
$tdvscolcond = ",fcollege = '{$fcollname}'";
$mascolcond1 = ",fcollname";
$mascolcond2 = ",'{$fcollname}'";
$tdvscolcond1 = ",fcollege";
$tdvscolcond2 = ",'{$fcollname}'";
}
if($type === "update"){
$query1 = "update masteach set fteachname='{$name}',
fdob=date_format(str_to_date('{$dob}', '%d/%m/%Y'),'%Y-%m-%d'),
fmobile='{$mobile}', femail='{$email}', fcollcode='{$college}',
fexaminer='{$examiner}' $mascolcond
where fteachcode='{$teachcode}'";
$res1 = $aobj_context->mobj_db->Execute($query1);
$query2 = "update tdvs_masteach set fteachname='{$name}',
fdob=date_format(str_to_date('{$dob}', '%d/%m/%Y'),'%Y-%m-%d'),
fmobile='{$mobile}', femail='{$email}', fcollcode='{$college}',
fexaminer='{$examiner}' $tdvscolcond
where fteachcode='{$teachcode}'";
$res2 = $aobj_context->mobj_db->Execute($query2);
if($res1 && $res2){
$arr['msg'] = "Updated successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else{
$arr['msg'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}else if($type === "insert"){
$query = "select * from masteach where fteachcode='{$teachcode}'
and ifnull(fteachcode,'') <> '' and ifnull(FDELETED,'F') <> 'T'";
$res = $aobj_context->mobj_db->GetAll($query);
if(count($res) > 0){
$arr['msg'] = "Teacher code already exist";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$query0 = "select * from masteach where fmobile='{$mobile}'
and ifnull(FDELETED,'F') <> 'T'";
$res0 = $aobj_context->mobj_db->GetAll($query0);
if(count($res0) > 0){
$arr['msg'] = "Mobile number already exist";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
$code = "";
if($teachcode === ""){
$code = $mobile;
}else{
$code = $teachcode;
}
$query1 = "insert into masteach(fteachcode, fteachname, fdob, fmobile,
femail, fcollcode, fexaminer $mascolcond1)
values('{$code}', '{$name}', date_format(str_to_date('{$dob}', '%d/%m/%Y'),'%Y-%m-%d'),
'{$mobile}', '{$email}', '{$college}', '{$examiner}' $mascolcond2)";
// var_dump($query1);die();
$res1 = $aobj_context->mobj_db->Execute($query1);
$fteachCode = $aobj_context->mobj_db->Insert_id();
$query2 = "insert into tdvs_masteach(fteachcode, fteachname, fdob, fmobile, femail,
fcollcode, fexaminer $tdvscolcond1)
values('{$code}', '{$name}', date_format(str_to_date('{$dob}', '%d/%m/%Y'),'%Y-%m-%d'),
'{$mobile}', '{$email}', '{$college}', '{$examiner}' $tdvscolcond2)";
$res2 = $aobj_context->mobj_db->Execute($query2);
if($teachcode === ""){
$query4 = "update masteach set fteachcode='{$fteachCode}'
where fteachcode = '{$code}'";
$res4 = $aobj_context->mobj_db->Execute($query4);
$query5 = "update tdvs_masteach set fteachcode='{$fteachCode}'
where fteachcode = '{$code}'";
$res5 = $aobj_context->mobj_db->Execute($query5);
if($res5){
$arr['msg'] = "Teacher code {$fteachCode} created successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else{
$arr['msg'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}else{
if($res1 && $res2){
$arr['msg'] = "Updated successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
return;
}else{
$arr['msg'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
}
}
function getCollegeDetails($aobj_context){
$query = "select fcollcode, concat(fcollname, ' [',fcollcode,']')as fcollname from college where ifnull(fcollcode, '')<>'';";
$res = $aobj_context->mobj_db->GetAll($query);
if($res){
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
}else{
$arr['msg'] = "No college data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($result, -1, "failure");
return;
}
}
function getTeacherDetails($aobj_context){
$query = "select fteachcode, ifnull(fteachname, '')as fteachname,
ifnull(date_format(fdob,'%d/%m/%Y'), '')as fdob,
ifnull(m.fmobile, '')as fmobile, ifnull(m.femail, '')as femail,
(case when(m.fcollcode = 'OTHR')then m.fcollname
else concat(c.fcollname, ' [',c.fcollcode,']') end)as fcollname, ifnull(fexaminer, ''),
ifnull(fexaminer, '')as fexaminer
from masteach m
left join college c on c.fcollcode = m.fcollcode
where ifnull(fteachcode, '')<>''
and ifnull(m.FDELETED,'F') = 'F' order by fteachname";
$res = $aobj_context->mobj_db->GetAll($query);
if($res){
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
}else{
$arr['msg'] = "No college data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($result, -1, "failure");
return;
}
}
function getTeachDet($aobj_context){
$teachcode = $aobj_context->mobj_data["teachcode"];
$query = "select fteachcode, ifnull(fteachname, '')as fteachname,
ifnull(date_format(fdob,'%d/%m/%Y'), '')as fdob,
ifnull(m.fmobile, '')as fmobile, ifnull(m.femail, '')as femail,
c.fcollcode,
concat(c.fcollname, ' [',c.fcollcode,']')as fcollname, ifnull(fexaminer, '')as fexaminer
from masteach m inner join college c on c.fcollcode = m.fcollcode
where ifnull(fteachcode, '')<>''
and fteachcode='{$teachcode}'";
$res = $aobj_context->mobj_db->GetRow($query);
if($res){
echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
}else{
$arr['msg'] = "No college data found";
echo $aobj_context->mobj_output->ToJSONEnvelope($result, -1, "failure");
return;
}
}
function checkTeachcode($aobj_context){
$teachcode = $aobj_context->mobj_data["teachcode"];
$field = $aobj_context->mobj_data["field"];
$code = "";
if($field === "teachcode"){
$query = "select * from masteach
where ifnull(fteachcode, '')<>'' and fteachcode='{$teachcode}'
and ifnull(FDELETED,'F') <> 'T'";
$code = "Teacher code";
}else if($field === "mobile"){
$query = "select * from masteach
where ifnull(fteachcode, '')<>'' and fmobile='{$teachcode}'
and ifnull(FDELETED,'F') <> 'T'";
$code = "Mobile Number";
}
$res = $aobj_context->mobj_db->GetAll($query);
if(count($res) > 0){
$arr['msg'] = "$code already exists";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function deleteTeachData($aobj_context){
$teachcode = $aobj_context->mobj_data["teachcode"];
$usertype = $aobj_context->mobj_data["usertype"];
$fusercode = $aobj_context->mobj_data["fusercode"];
$fmobile = $aobj_context->mobj_data["fmobile"];
$query = "select * from masteach
where fteachcode='{$teachcode}'";
$res = $aobj_context->mobj_db->GetRow($query);
if(count($res) != 0){
$delquery = "update masteach set FDELETED ='T'
where fteachcode='{$teachcode}'";
$delres = $aobj_context->mobj_db->Execute($delquery);
}
$que = "select * from qp_masteach where fregno = '{$teachcode}'";
$qpres = $aobj_context->mobj_db->GetRow($que);
if(count($qpres) != 0){
$delqp = "delete from qp_masuser
where fregno='{$teachcode}' and fmobileno = '{$fmobile}'";
$delqp = $aobj_context->mobj_db->Execute($delqp);
}
if($delqp || $delres){
$arr['msg'] = "Successfully Deleted";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
}else{
$arr['msg'] = "Something went wrong try later";
echo $aobj_context->mobj_output->ToJSONEnvelope($result, -1, "failure");
return;
}
}
?>
|