-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
44 lines (39 loc) · 1.6 KB
/
checkout.php
File metadata and controls
44 lines (39 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
try{
include 'basic.php';
$code = $_POST['code'];
$id = $_POST['id'];
$cname = $_POST['cname'];
$rnumber = $_POST['rnumber'];
$phone = $_POST['phone'];
$checkIn = $_POST['checkIn'];
$checkOut = $_POST['checkOut'];
$staff_id = $_SESSION['staff_id'];
$q_code = $db->quote($code);
$q_id = $db->quote($id);
$q_cname = $db->quote($cname);
$q_rnumber = $db->quote($rnumber);
$q_phone = $db->quote($phone);
$q_checkIn = $db->quote($checkIn);
$q_checkOut = $db->quote($checkOut);
$q_staff_id = $db->quote($staff_id);
$str_CHECKOUT = $db->quote("CHECKOUT");
$str = "UPDATE room SET isEmpty = 1, clean = 0 WHERE rnumber = ".$q_rnumber;
$str2 = "INSERT INTO task_log (ttime, rnumber, staff_id, tstatus)
VALUE (NOW()," .$q_rnumber. "," .$q_staff_id. "," .$str_CHECKOUT.")";
$str3 = "INSERT INTO customer_log (code, id, cname, rnumber, phone, checkIn, checkOut)
VALUE (" .$q_code. "," .$q_id. "," .$q_cname. "," .$q_rnumber. "," .$q_phone. "," .$q_checkIn. "," .$q_checkOut.")";
$str4 = "DELETE FROM reservation WHERE code =" .$q_code;
$db->exec($str);
$db->exec($str2);
$db->exec($str3);
$db->exec($str4);
print "<script language=javascript> alert('Check-out complete.'); history.back(); </script>";
exit;
} catch (PDOException $ex) {
?>
<p>Sorry, a database error occurred. Please try again later.</p>
<p>(Error details: <?= $ex->getMessage() ?>)</p>
<?php
}
?>