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.217.104.36
<?php
function viewRoomsToCreate($aobj_context)
{
session_start();
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$collcode = $aobj_context->mobj_data['collcode'];
$query = "SELECT froomno as roomno, froomname AS roomname, fcapacity AS capacity,IFNULL(forder,'') AS forder,
IFNULL(fmaxqpcnt,'') AS fmaxqpcnt,IFNULL(fprefix,'') AS fprefix FROM masroom
WHERE fcollcode = '{$collcode}' ORDER BY froomno";
// var_dump($query);die();
$result = $aobj_context->mobj_db->GetAll($query);
if ($result) {
$data['data'] = $result;
echo $aobj_context->mobj_output->ToJSONEnvelope($data, 0,"success");
} else {
$data['data'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($data, -1,"fail");
}
}
function todeleteRoomFromMasroom($aobj_context){
$collcode = $aobj_context->mobj_data['collcode'];
$roomname=$aobj_context->mobj_data['roomname'];
$capacity=$aobj_context->mobj_data['capacity'];
$query="delete from masroom where fcollcode='{$collcode}' AND froomname='{$roomname}' AND fcapacity='{$capacity}'";
$result = $aobj_context->mobj_db->Execute($query);
if ($result) {
$data['data'] = "Successfully Deleted";
echo $aobj_context->mobj_output->ToJSONEnvelope($data, 0,"success");
} else {
$data['data'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($data, -1,"fail");
}
}
function editRoomDataFromMasroom($aobj_context){
$collcode = $aobj_context->mobj_data['collcode'];
$roomname=$aobj_context->mobj_data['roomname'];
$capacity=$aobj_context->mobj_data['capacity'];
$query="SELECT *FROM masroom WHERE fcollcode='{$collcode}' AND froomname='{$roomname}' AND fcapacity='{$capacity}'";
$result = $aobj_context->mobj_db->GetAll($query);
if ($result) {
$data['data'] = $result;
echo $aobj_context->mobj_output->ToJSONEnvelope($data, 0,"success");
} else {
$data['data'] = "Failed to update";
echo $aobj_context->mobj_output->ToJSONEnvelope($data, -1,"fail");
}
}
// function saveRoomCreationData($aobj_context){
// $data = $aobj_context->mobj_data["data"];
// $arr = json_decode($data,true);
// $collcode=$aobj_context->mobj_data['collcode'];
// // var_dump($array);die();
// $query="SELECT *FROM masroom where fcollcode='{$collcode}'";
// $result = $aobj_context->mobj_db->GetAll($query);
// $i=0;
// foreach($arr as $array){
// if($array["roomno"] == $result[$i]["froomno"]){
// $qry = "UPDATE masroom
// SET froomname='{$array["roomname"]}',fcapacity='{$array["capacity"]}',forder='{$array["forder"]}',
// fmaxqpcnt='{$array["fmaxqpcnt"]}',fprefix='{$array["fprefix"]}'
// WHERE froomno='{$array["roomno"]}' AND fcollcode='{$collcode}'";
// $res = $aobj_context->mobj_db->Execute($qry);
// }else{
// $qry = "INSERT INTO masroom(fcollcode,froomno,froomname,fcapacity,forder,fmaxqpcnt,fprefix)
// VALUES('{$collcode}','{$array["roomno"]}','{$array["roomname"]}','{$array["capacity"]}',
// '{$array["forder"]}','{$array["fmaxqpcnt"]}','{$array["fprefix"]}')";
// $res = $aobj_context->mobj_db->Execute($qry);
// }
// $i++;
// if ($res){
// $data['msg'] = "Updated Successfully";
// echo $aobj_context->mobj_output->ToJSONEnvelope($data, 0,"success");
// } else {
// $data['data'] = "Failed to update";
// echo $aobj_context->mobj_output->ToJSONEnvelope($data, -1,"fail");
// }
// }
// }
function saveRoomCreationData($aobj_context) {
$data = $aobj_context->mobj_data["data"];
$arr = json_decode($data, true);
$collcode = $aobj_context->mobj_data['collcode'];
$query = "SELECT * FROM masroom WHERE fcollcode = '{$collcode}'";
$result = $aobj_context->mobj_db->GetAll($query);
$i = 0;
$response = []; // Array to store results for the frontend
foreach ($arr as $array) {
if ($array["roomno"] == $result[$i]["froomno"]) {
$qry = "UPDATE masroom
SET froomname = '{$array["roomname"]}', fcapacity = '{$array["capacity"]}', forder = '{$array["forder"]}',
fmaxqpcnt = '{$array["fmaxqpcnt"]}', fprefix = '{$array["fprefix"]}'
WHERE froomno = '{$array["roomno"]}' AND fcollcode = '{$collcode}'";
} else {
$qry = "INSERT INTO masroom (fcollcode, froomno, froomname, fcapacity, forder, fmaxqpcnt, fprefix)
VALUES ('{$collcode}', '{$array["roomno"]}', '{$array["roomname"]}', '{$array["capacity"]}',
'{$array["forder"]}', '{$array["fmaxqpcnt"]}', '{$array["fprefix"]}')";
}
// Execute the query and store the result in the response array
$res = $aobj_context->mobj_db->Execute($qry);
$response[] = [
"roomno" => $array["roomno"],
"status" => $res ? "success" : "fail",
"message" => $res ? "Updated Successfully" : "Failed to update"
];
$i++;
}
// Return the response as a JSON array instead of an object
echo $aobj_context->mobj_output->ToJSONEnvelope($response, 0, "success");
}
// function saveroomdeclarationdetails($aobj_context)
// {
// session_start();
// include_once("/JSON.php");
// $json = new Services_JSON();
// $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
// $collcode = $_SESSION['collcode'];
// $roomdet = stripslashes($aobj_context->mobj_data["room_arr"]);
// $roomdetarr = $json->decode($roomdet);
// $roomarr = get_object_vars($roomdetarr);
// for($k=1;$k<=count($roomarr);$k++)
// {
// $query = "select * from masroom
// where fcollcode = '{$collcode}' and froomno = '{$roomarr[$k]->roomno}'";
// //var_dump($query);
// $rst = $aobj_context->mobj_db->GetRow($query);
// if($rst)
// {
// $query2 = "update masroom set froomname = '{$roomarr[$k]->roomname}' , fcapacity = '{$roomarr[$k]->capacity}',forder = '{$roomarr[$k]->order}'
// where fcollcode = '{$collcode}' and froomno = '{$roomarr[$k]->roomno}'";
// //var_dump($query2);
// $rst = $aobj_context->mobj_db->Execute($query2);
// }
// else
// {
// $query3 = "insert into masroom(fcollcode,froomno, froomname, fcapacity) value('{$collcode}', '{$roomarr[$k]->roomno}', '{$roomarr[$k]->roomname}', '{$roomarr[$k]->capacity}')";
// //var_dump($query3);
// $rst = $aobj_context->mobj_db->Execute($query3);
// }
// }
// if($rst)
// {
// $success_msg = "Updated Successfully";
// echo $aobj_context->mobj_output->ToJSONEnvelope($success_msg,0,"success");
// }
// else
// {
// $error_msg = "Updation Failed";
// echo $aobj_context->mobj_output->ToJSONEnvelope($error_msg,0,"success");
// }
// }
// function totalroomcount($aobj_context){
// $collcode = $_SESSION['collcode'];
// $query="SELECT COUNT(froomname) AS croomname FROM masroom WHERE fcollcode = '{$collcode}'";
// $rst = $aobj_context->mobj_db->GetRow($query);
// if($rst){
// echo $aobj_context->mobj_output->ToJSONEnvelope($rst,0,"success");
// }
// }
?>
|