-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirmation.php
More file actions
274 lines (202 loc) · 8.32 KB
/
confirmation.php
File metadata and controls
274 lines (202 loc) · 8.32 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?php
include 'model.php';
session_name("name");
session_start();
if (!isset($_POST['pid']))
header("location:main.php");
?>
<html>
<head>
<link rel="stylesheet" href="css/confirmationStyle.css" type="text/css">
<title>Confirm You order!</title>
</head>
<body>
<div class="container">
<table class="picnic-table">
<thead>
<tr>
<th>Picnic Reference ID</th>
<th>Place</th>
<th>Date</th>
<th>Number of Guests</th>
<th>Cost per one</th>
<th>Departure Time</th>
<th>Departure Location</th>
<th>Arrival Time</th>
<th>Return Time</th>
</tr>
</thead>
<tbody>
<?php
$res = null;
if (isset($_POST['pid'])) {
$res = getPicnicById($_POST['pid']);
}
$keys = ["pid", "place", "date", "description", "cost", "departuretime", "departurelocation", "arrivaltime", "returntime"];
if ($row = $res->fetch()) {
?>
<tr><?php
$time = array();
$cost = 0;
$seats = 0;
$additions = "";
$invoice = 0;
$date = date("Y-m-d");
$pid = 0;
foreach ($keys as $i) {
if ($i == "description") {
if (isset($_POST['numOfSeats'])) {
echo "<td style='padding-left: 40px;font-size: 1.2pc'>" . $_POST['numOfSeats'] . "</td>";
continue;
}
}
if ($i == "pid") {
$pid = $row[$i];
echo "<td class='pid' style='padding-left: 40px;font-size: 1.4pc'><a href='#' style='text-decoration:none;'>" . $row[$i] . "</a></td>";
} else if ($i == "cost") {
$cost = $row[$i];
?>
<td style="padding-left: 25px"><?= $row[$i] ?> ₪</td><?php
} else if (strpos($i, "time")) {
$time = explode(":", $row[$i]);
unset($time[2]);
$row[$i] = implode(":", $time);
?>
<td style="padding-left: 20px">
<time><?= $row[$i] ?></time></td><?php
} else { ?>
<td><?= $row[$i] ?></td><?php
}
}
echo "</tr>";
} ?>
<tr>
<td colspan="2"></td>
<td colspan="1" style="padding-left: 10px;font-size: 16px">
</td>
<td colspan="1">
</td>
<td colspan="5">
</td>
</tr>
</tbody>
</table>
<div class="pricing">
<div class="[ price-option price-option--low ]">
<div class="price-option__detail">
<span class="price-option__cost"> <?php
if (isset($cost) && isset($_POST['Birthday_cake']) && isset($_POST['numOfSeats'])) {
$additions = "Birthday-Cake for " . $_POST['numOfSeats'];
$invoice = ($cost * $_POST['numOfSeats']) + ($_POST['numOfSeats'] * 20);
echo ($cost * $_POST['numOfSeats']) + ($_POST['numOfSeats'] * 20) . "₪";
} else if (isset($cost)) {
$additions = "None";
$invoice = ($cost * $_POST['numOfSeats']);
echo ($cost * $_POST['numOfSeats']) . "₪";
}
$seats = $_POST['numOfSeats']
?></span>
<span class="price-option__type">Total Cost</span>
</div>
<a href="#checkoutModal" class="price-option__purchase">Confirm</a>
</div>
</div>
</div>
<div class="modal-window" id="checkoutModal" tabindex="-1" role="dialog" aria-hidden="true">
<div>
<div class="modal-title"><strong>Picnic-Checkout</strong><a href="#"><span class="modal-close">×</span></a>
</div>
<div class="modal-body">
<form action="checkout-temp.php" method="post" id="checkout-form">
<img src="img/icons/visa.svg" id="visa" class="payment-card" onclick="changePrefixVisa()">
<img src="img/icons/mastercard.svg" id="mastercard" class="payment-card"
onclick="changePrefixMaster()">
<img src="img/icons/american-express.svg" id="american-express" class="payment-card"
onclick="changePrefixAmerican()">
<br/>
<br>
<hr>
<br>
<span class="modal-content" id="content" style="display: none">
<label id="prefix">xxx-</label>
<input type="text" placeholder="xxx-xxx" id="card-num" name="card-num"
pattern="[0-9]{3}-[0-9]{3}|[0-9]{6}">
<br> <sup class="modal-errors" id="card-error">Please Enter 6-digit valid number xxx-xxx or xxxxxx</sup>
<input id="card-name" name="card-name" type="hidden">
<br><br>
<label for="expire-date"
id="expire-date-label">Expire-Date</label>
<input type="date" name="expire-date"
id="expire-date">
<br><sup class="modal-errors" id="date-error">Please Enter Expire Date</sup>
<br><br>
<label id="bank-label">Bank</label>
<input type="text" placeholder="Bank Issued" name="bank" id="bank"
data-tool-tip="Bank issued with the Card">
<input type="hidden" name="invoice" value="<?= $invoice ?>">
<input type="hidden" name="additions" value="<?= $additions ?>">
<input type="hidden" name="date" value="<?= $date ?>">
<input type="hidden" name="seats" value="<?= $seats ?>">
<input type="hidden" name="pid" value="<?= $pid ?>">
<input type="hidden" name="cost" value="<?= $cost ?>">
<br><sup class="modal-errors" id="bank-error">Please Enter Bank issued with card</sup>
<br><br>
<input type="submit" value="Checkout" name="checkout" onclick="return validate()">
</span>
</form>
</div>
</div>
</div>
</body>
<script type="text/javascript">
function checkEnteredDates(expired) {
var CurrentDate = new Date();
var GivenDate = new Date(expired);
if (GivenDate < CurrentDate) {
alert('Card is Expired!');
return false;
}
return true;
}
function validate() {
let cardNum = document.getElementById("card-num");
let expire_date = document.getElementById("expire-date");
let bank = document.getElementById("bank");
if (!checkEnteredDates(expire_date.valueAsDate)) {
return false;
}
let state = true;
if (!cardNum.value) {
document.getElementById("card-error").style.display = "inline";
state = false;
}
if (!expire_date.value) {
document.getElementById("date-error").style.display = "inline";
state = false;
}
if (!bank.value) {
document.getElementById("bank-error").style.display = "inline";
state = false;
}
if (!state) {
return false;
}
return true;
}
function changePrefixVisa() {
document.getElementById("prefix").innerHTML = "4444-";
document.getElementById("card-name").value = "Visa/4444";
document.getElementById("content").style.display = "block";
}
function changePrefixMaster() {
document.getElementById("prefix").innerHTML = "5555-";
document.getElementById("card-name").value = "Master-Card/5555";
document.getElementById("content").style.display = "block";
}
function changePrefixAmerican() {
document.getElementById("prefix").innerHTML = "6666-";
document.getElementById("card-name").value = "American-Express/6666";
document.getElementById("content").style.display = "block";
}
</script>
</html>