function doEdit() { $rmid = $_GET['id']; if (isset($_POST['save'])) { if ($_POST['rmname'] == "" or $_POST['roomdesc'] == "") { $message = "All field is required!"; redirect('index.php?view=edit&id=' . $rmid); } else { $room = new Room(); $rmid = $_POST['roomid']; $rmname = $_POST['rmname']; $rmdesc = $_POST['roomdesc']; $room->ROOM_ID = $rmid; $room->ROOM_NAME = $rmname; $room->ROOM_DESC = $rmdesc; $room->update($rmid); $message = $rmname . " has updated successfully!"; redirect('index.php'); } } }
public function save_order() { $room_array = $_POST['room_id']; $order_array = $_POST['order']; $room = new Room(); foreach ($room_array as $key => $value) { $room_id = $value; $room_order = $order_array[$key]; $room->update('Room', array('sequence' => $room_order), 'id=' . $room_id); } Flash::set('success', __('This room sequence has been saved.')); redirect(get_url('room')); }
public static function Room($type, $data) { require_once 'room.class.php'; $class = new Room(); $status = false; $class->setData($data); switch ($type) { case 'add': $status = $class->add(); break; case 'update': $status = $class->update(); break; case 'delete': $status = $class->delete(); break; case 'getsingle': $status = $class->getsingle(); break; case 'getpage': $status = $class->getpage(); break; case 'search': $status = $class->search(); break; default: break; } if ($status) { wp_send_json_success($status); } else { wp_send_json_error($class->error); } }
} } break; } } else { switch ($verb) { case 'POST': echo 'Cannot overwrite existing room.'; exit_with_status_code(409); case 'PUT': $room_name = $_REQUEST['name']; if (empty($room_name)) { echo 'Room name cannot be null.'; exit_with_status_code(400); } else { $updated_room = Room::update($room_id, $room_name); if ($updated_room) { echo 'Successfully updated room.'; exit_with_status_code(201); } else { echo 'Error updating room.'; exit_with_status_code(400); } } case 'GET': $room = Room::get($room_id); if ($room) { echo $room->to_json(); exit_with_status_code(200); } else { echo 'Room not found.';
setEventMessage('<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")) . '</div>'); } $res = $obj_room->fetch($roomid); if (!$res) { $error++; setEventMessage('<div class="error">' . $langs->trans("ErrorFailedToLoadRoom", $langs->transnoentities("Id")) . '</div>'); } if (!$error) { $obj_room->ref = $ref; $obj_room->label = GETPOST("label", 'alpha'); $obj_room->fk_floor = GETPOST("fk_floor", 'int'); $obj_room->type_code = GETPOST("fk_type_room", 'alpha'); $obj_room->capacity = GETPOST("capacity", 'int'); $obj_room->note_public = GETPOST("note_public"); $obj_room->note_private = GETPOST("note_private"); $result = $obj_room->update($user); if ($result > 0) { Header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); exit; } else { setEventMessage('<div class="error">' . $obj_room->error . '</div>'); $action = 'editroom'; } } else { $action = 'editroom'; } } else { if ($action == 'confirm_deleteroom' && $confirm == 'yes' && $user->rights->place->write) { $ret = $obj_room->fetch($roomid); if ($ret) { $result = $obj_room->delete($user);