forked from perryyan/ubcair
/
reservation.php
164 lines (138 loc) · 4.76 KB
/
reservation.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="UBC Airline Booking Service">
<title>UBC Air</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/pure-min.css">
<link rel="stylesheet" href="css/mainpage.css"
</head>
<body>
<div class="header">
<div class="home-menu pure-menu pure-menu-open pure-menu-horizontal pure-menu-fixed">
<a class="pure-menu-heading" href="">UBC Air</a>
<ul>
<li><a href='index.php'>Home</a></li>
<?php
if(!array_key_exists('loggedin', $_COOKIE) ) {
echo "<li><a href='login.php'>Login</a></li>";
echo "<li><a href='register.php'>Sign Up</a></li>";
header('location: login.php');
}
else {
echo "<li><a href='logout.php'>Logout</a></li>";
echo "<li><a href='support.php'>My Orders</a></li>";
}
if (array_key_exists('flightchoice', $_POST)) {
// test YVR to TPE (country TW) in flights.php it has 1 and 2 transfers
// direct flight I always test with YVR to HKG (country HK) but doesnt matter
$res = unserialize($_POST['flightchoice']);
//print_r($res);
}
?>
<li><a href="flights.php">Find flights</a></li>
</ul>
</div>
</div>
<div class="banner">
<h1 class="banner-head">
Welcome to UBC Air
</h1>
</div>
<div class='content-customer-area'><body>
<?php
// These stuff are needed (for now) to connect Oracle, will figure out how to import from
// main php file
$success = True; //keep track of errors so it redirects the page only if there are no errors
//include "flightdetails.php";
include "oci_functions.php";
if ($db_conn) {
if (array_key_exists('makeres', $_POST)) {
// Insert reservation tuple into make_res
// (resid, cid, pclass, ticket_num)
executePlainSQL("insert into make_res values (
resid_sequence.nextval,"
.$_COOKIE['cid'].","
.$_POST['makeres_classint'].","
.$_POST['makeres_numtickets'].")");
OCICommit($db_conn);
// res_includes(fid, resid, resorder)
$fids = array($_POST['fid1'], $_POST['fid2'], $_POST['fid3']);
foreach($fids as $key=>$value) {
//echo $fids[$key]."<br>";
if( $fids[$key] != "") {
executePlainSQL("insert into res_includes values ("
.$value.",
resid_sequence.currval,"
.number_format($key+1).")");
}
}
OCICommit($db_conn);
executePlainSQL("insert into payment values(
payid_sequence.nextval,"
.$_POST['credit'].","
.$_COOKIE['cid'].")");
OCICommit($db_conn);
executePlainSQL("insert into deter_pay values(
payid_sequence.currval,
resid_sequence.currval,"
.$_POST['makeres_totalcost'].")");
OCICommit($db_conn);
// Confirmation dialog
?>
<script type="text/javascript">
alert("Payment successful. Proceed to adding bags");
location = "baggage.php";
</script>
<?php
}
else {
//print_r($res);
echo "Your flight itinerary:";
printDetails($res, 0, 0);
?>
<br><br>The summary of your ticket order:
<table class="pure-table">
<tr>
<?php
echo "<td>Number of tickets:</td>";
echo "<td>".$res['NUMTICKETS']."</td>";
?>
</tr>
<tr>
<?php
echo "<td>Flight class:</td>";
echo "<td>".$res['CLASS']."</td>";
?>
</tr>
<tr>
<?php
echo "<td>Price per ticket:</td>";
echo "<td>CAD$".number_format($res['TOTALPRICE'],2)."</td>";
?>
</tr>
<tr>
<?php
$tcost = floatval($res['NUMTICKETS']) * floatval($res['TOTALPRICE']);
echo "<td>Total cost:</td>";
echo "<td>CAD$".number_format($tcost,2)."</td>";
?>
</tr>
</table>
<?php
}
}
?>
<form class="pure-form" method="POST" action="reservation.php">
<input type="hidden" name="makeres_totalcost" value="<?php echo $tcost; ?>">
<input type="hidden" name="makeres_classint" value="<?php echo $res['CLASSINT']; ?>">
<input type="hidden" name="makeres_numtickets" value="<?php echo $res['NUMTICKETS']; ?>">
<input type="hidden" name="makeres_resid" value="<?php echo rand(10000000,99999999); ?>">
<input type="hidden" name="makeres_payid" value="<?php echo rand(10000000,99999999); ?>">
<input type="hidden" name="fid1" value="<?php echo $res['FIRSTID']; ?>">
<input type="hidden" name="fid2" value="<?php echo $res['SECONDID']; ?>">
<input type="hidden" name="fid3" value="<?php echo $res['THIRDID']; ?>">
<input type="text" placeholder="Credit Card Number" name="credit" id="credit" pattern="[0-9]{16}" required>
<button type="submit" name="makeres" class="pure-button pure-button-primary">Pay now</button>
</form>
</div></body>