-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbooking.php
460 lines (441 loc) · 13.8 KB
/
booking.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
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<?php
error_reporting(E_ALL ^ E_WARNING);
include_once('connect.php');
// $varcheck=0;
session_start();
if(!isset($_SESSION['loggedin']) || $_SESSION['loggedin']!=true){
header("location: account.php");
exit;
}
$hide=0;
if($_SESSION['username']=="admin"){
header("location: admin.php");
}
// $varcheck=0;
if(isset($_POST['lout'])){
$_SESSION[$hide]=0;
// $_SESSION['acc']=false;
session_unset();
session_destroy();
header("location: account.php");
exit;
}
function writeMsg() {
echo '
<span class="alert alert-danger" role="alert">
enteries cannot be null
</span>
';
}
function writeMsg01() {
echo '
<span class="alert alert-danger" role="alert">
eggs and chickens cannot be zero
</span>
';
}
function writeMsg31() {
echo '
<span class="alert alert-danger" role="alert">
city doent exsist
</span>
';
}
function writeMsg41() {
echo '
<span class="alert alert-danger" role="alert">
invalid input
</span>
';
}
function ext() {
echo '
<span class="alert alert-danger" role="alert">
try entering a different order key
</span>
';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $_SESSION['username']?></title>
<!-- swiper css link -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/swiper@8/swiper-bundle.min.css"/>
<!-- linking font -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<!-- custom css file -->
<link rel="stylesheet" href="book.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<!-- linking favicon -->
<link rel="shortcut icon" type="image/png" href="images/mainicon.png">
<script type="text/javascript"src="jquery-3.6.0.min.js"></script>
<script type="text/javascript"></script>
</head>
<body>
<section class="header">
<a href="home.php" class="logo"><img src="images/homelogo.png" alt=""></a>
<nav class="navbar">
<a href="home.php">Home</a>
<a href="about.php">About</a>
<!-- <a href="package.html">Package</a> -->
<a href="package.php">Package</a>
<a href="booking.php">Booking</a>
<?php
if(isset($_SESSION[$hide])) {?>
<a href="account.php" >Account</a>
<?php } ?>
<!-- <a href="account.php">Account</a> -->
</nav>
</section>
<!-- </form> -->
<div class="pto">
<form action="booking.php" method="post" class="aasx" >
<input type="submit" class="btn asx" value="fetch Order" method="post" name="por">
</form>
<table class="styled-table" >
<thead>
<tr>
<th>User Name</th>
<th>Order No</th>
<th>Branch No</th>
<th>Eggs</th>
<th>Chickens</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
<!-- and so on... -->
<?php
include_once('connect.php');
if(isset($_POST['por']) or isset($_POST['order'])){
$tempuname=$_SESSION['username'];
$query444q="SELECT USERNAME,ORDERNO,BRANCHNO,EGG,CHICKEN,PRICE from BOOKING WHERE USERNAME='$tempuname' ";
$temp1444q=oci_parse($connection,$query444q);
oci_execute($temp1444q);
while (( $row24q = oci_fetch_assoc($temp1444q) ) != false)
{
echo "
<tbody>
<tr>
<td >" . $row24q['USERNAME'] ."</td>
<td >" . $row24q['ORDERNO'] ."</td>
<td >" . $row24q['BRANCHNO'] ."</td>
<td >" . $row24q['EGG'] ."</td>
<td >" . $row24q['CHICKEN'] ."</td>
<td >" . $row24q['PRICE'] ."</td>
</tr>
</tbody>";
}
}
?>
</table>
</div>
<form action="booking.php" method="post" class="noo">
<input class="btn no" type="submit" value="logout" name="lout">
</form>
<!-- header sections ends here -->
<!-- booking section start here -->
<div class="cont">
<!-- class="panel-container"
class="panel left-panel" -->
<div class="div1">
<!-- <div class="content">
<h3>Book Now</h3>
<p>Book eggs and chickens now.</p>
</div>
<img src="images/booknow.png" alt="" class="image"> -->
<form action="booking.php" class="p1" method="post">
<div class="input-field p11">
<i class="fas fa-user"></i>
<input type="text" id="ttext" maxlength="15" placeholder="Enter city name" name="ci">
</div>
<!-- onclick="myFunction()" -->
<button type="submit" class="btn d" method="post" name="vi" id="vi" >View Branches</button>
</form>
<table class="styled-table" id="1">
<thead>
<tr>
<th>Branch No</th>
<th>Branch Name</th>
<th>Branch address</th>
</tr>
</thead>
<tbody>
<tr>
<!-- <th></th>
<th></th>
<th></th>
<th></th>
<th></th> -->
</tr>
</tbody>
<!-- and so on... -->
<?php
include_once('connect.php');
if(isset($_POST['vi'])){
$city1=$_POST['ci'];
if($city1 == NULL){
// writeMsg();
}
else{
$sql31="SELECT NAME from CITYNAMES where NAME='$city1' ";
$temp31=oci_parse($connection,$sql31);
oci_execute($temp31);
$ll31=oci_fetch($temp31);
if($ll31 == 1 ){
$query44="SELECT BRACHNO,BRACHNAME,BRANCHADDRESS FROM $city1";
$temp144=oci_parse($connection,$query44);
oci_execute($temp144);
while (( $row2 = oci_fetch_assoc($temp144) ) != false)
{
echo "
<tbody>
<tr>
<td >" . $row2['BRACHNO'] ."</td>
<td>" . $row2['BRACHNAME'] ."</td>
<td>" . $row2['BRANCHADDRESS'] ."</td>
</tr>
</tbody>";
}
}
else{
// writeMsg31();
}
}
}
?>
</table>
</div>
<div class="fcont">
<div class="inup" id="1">
<form action="booking.php" class="in" method="post">
<h2 class="title">BOOK NOW</h2>
<select id="select" class="select v1" name="city" onchange="ddlselect()">
<option value="" disabled selected>Select City</option>
<?php
include_once('connect.php');
$queryk="SELECT NAME FROM CITYNAMES";
$do=oci_parse($connection,$queryk);
oci_execute($do);
while (($rowval = oci_fetch_assoc($do)) != false)
{
echo" <option value=".$rowval['NAME'].">".$rowval['NAME']."</option>";
// echo "<option value='$tempp'>$tempp</option>";
}
?>
</select>
<div class="input-field">
<i class="fas fa-phone""></i>
<input type="text" maxlength="5" placeholder="Enter Branch No" name="i1">
</div>
<div class="input-field">
<i class="fas fa-address-book"></i>
<input type="text" maxlength="40"placeholder="Enter permanent-address" name="i2">
</div>
<div class="radio-container">
<input type="radio" id="windows" name="os" value="on" onclick="text(1)" checked >
<label for="windows">Packages</label>
<input type="radio" id="mac" name="os" value="of" onclick="text(0)">
<label for="mac">Custom</label>
</div>
<select id="mycode" class="select" name="ecp">
<option value="" disabled selected>package : eggs : chickens</option>
<?php
include_once('connect.php');
$queryk="SELECT NAME,EGG,CHICKEN FROM PACKAGES";
$do=oci_parse($connection,$queryk);
oci_execute($do);
while (($rowval = oci_fetch_assoc($do)) != false)
{
echo" <option value=".$rowval['NAME'].">".$rowval['NAME']." : ".$rowval['EGG']." : ".$rowval['CHICKEN']."</option>";
// echo "<option value='$tempp'>$tempp</option>";
}
?>
</select>
<div class="input-field" id="mycode1">
<!-- <i class=""></i> -->
<input type="number" placeholder="total no of eggs" class="dmn" name="i4" maxlength="6" max="999999">
</div>
<div class="input-field" id="mycode2">
<!-- <i class=""></i> -->
<input type="number" placeholder="total no of chickens" class="dmn" name="i5" maxlength="6" max="99999">
</div>
<input type="submit" class="btn nb" value="order" name="order" method="post">
</div>
</form>
</div>
</div>
<?php
include_once("connect.php");
$chr="SELECT orderno FROM BOOKING WHERE ORDERNO=(SELECT max(ORDERNO) FROM BOOKING)";
$ch1=oci_parse($connection,$chr);
oci_execute($ch1);
$xz = oci_fetch_assoc($ch1);
$num=$xz['ORDERNO'];
if($num<=0){
$num=1;
$v9=$num;
}
else{
$num=$num+1;
$v9=$num;
}
if(isset($_POST['order'])){
$vb1=$_POST['i1'];
$v2=$_POST['i2'];
$v4=$_POST['i4'];
$v5=$_POST['i5'];
$vo4=$_POST['os'];
$vname=$_SESSION['username'];
$varr=$_POST['city'];
if($vb1==NULL or $v2==NULL ){
writeMsg();
}
else{
if($vb1<=0){
writeMsg41();
}
else{
$checker="SELECT ORDERNO FROM BOOKING WHERE ORDERNO=$v9";
$CHECK=oci_parse($connection,$checker);
oci_execute($CHECK);
$DDL=oci_fetch($CHECK);
if($DDL==1){
ext();
}
else{
if(!empty($varr)) {
$selected1 = $varr;
$q11="SELECT NAME FROM CITYNAMES WHERE NAME='$selected1'";
$vv1=oci_parse($connection,$q11);
oci_execute($vv1);
$v1 = oci_fetch_assoc($vv1);
$cityname=$v1['NAME'];
if($cityname!=NULL){
$qwe1="SELECT BRACHNO FROM $cityname WHERE BRACHNO=$vb1";
$qwee=oci_parse($connection,$qwe1);
oci_execute($qwee);
$looe=oci_fetch($qwee);
if($looe == 1 ){
$qwe1="SELECT BRACHNO FROM $cityname WHERE BRACHNO=$vb1";
$qwee=oci_parse($connection,$qwe1);
oci_execute($qwee);
$varrr = oci_fetch_assoc($qwee);
$branchnumber=$varrr['BRACHNO'];
}
else{
echo "invalid brach number";
}
}
}
if(!empty($vo4)) {
if($vo4=="on"){
if(empty($_POST['ecp'])){
writeMsg();
}
if(!empty($_POST['ecp'])) {
$selected = $_POST['ecp'];
$q1="SELECT EGG,CHICKEN FROM PACKAGES WHERE NAME='$selected'";
$vv=oci_parse($connection,$q1);
oci_execute($vv);
$v = oci_fetch_assoc($vv);
$eggs=$v['EGG'];
$chickens=$v['CHICKEN'];
$PRICE=((20*$eggs)+(1200*$chickens));
$insertquery="INSERT INTO BOOKING (USERNAME,CITY,BRANCHNO,ADDRESS,EGG,CHICKEN,PRICE,ORDERNO) VALUES('$vname','$cityname',$branchnumber,'$v2',$eggs,$chickens,$PRICE,$v9)";
$ex=oci_parse($connection,$insertquery);
oci_execute($ex);
$qaz="SELECT TOTALORDER FROM $cityname WHERE BRACHNO=$vb1";
$qaz1=oci_parse($connection,$qaz);
oci_execute($qaz1);
$qaz2=oci_fetch_assoc($qaz1);
$qazvar=$qaz2['TOTALORDER'];
$qazvar=$qazvar+1;
$qaz3="UPDATE $cityname SET TOTALORDER=$qazvar WHERE BRACHNO=$vb1";
$qaz33=oci_parse($connection,$qaz3);
oci_execute($qaz33);
}
}
else{
if($v4==NULL or $v5==NULL){
writeMsg();
}
else{
if($v4<=0 or $v5<=0){
writeMsg01();
}
else{
$price=((20*$v4)+(1200*$v5));
$insertquery1="INSERT INTO BOOKING (USERNAME,CITY,BRANCHNO,ADDRESS,EGG,CHICKEN,PRICE,ORDERNO) VALUES('$vname','$cityname',$branchnumber,'$v2',$v4,$v5,$price,$v9)";
$ex1=oci_parse($connection,$insertquery1);
oci_execute($ex1);
$qaz="SELECT TOTALORDER FROM $cityname WHERE BRACHNO=$vb1";
$qaz1=oci_parse($connection,$qaz);
oci_execute($qaz1);
$qaz2=oci_fetch_assoc($qaz1);
$qazvar=$qaz2['TOTALORDER'];
$qazvar=$qazvar+1;
$qaz3="UPDATE $cityname SET TOTALORDER=$qazvar WHERE BRACHNO=$vb1";
$qaz33=oci_parse($connection,$qaz3);
oci_execute($qaz33);
}
}
}
}
}
}
}
}
?>
<!-- booking section ends here -->
<!-- footer -->
<section class="footer">
<div class="box-container">
<div class="box">
<h3>Quick Links</h3>
<a href="home.php"> <i class="fas fa-angle-right"></i> Home</a>
<a href="about.php"> <i class="fas fa-angle-right"></i> About</a>
<a href="account.php"> <i class="fas fa-angle-right"></i> Accounts</a>
<a href="booking.php"> <i class="fas fa-angle-right"></i> Booking</a>
</div>
<div class="box">
<h3>Extra Links</h3>
<a href="#"> <i class="fas fa-angle-right"></i>Ask Questions</a>
<a href="#"> <i class="fas fa-angle-right"></i>About Us</a>
<a href="#"> <i class="fas fa-angle-right"></i>Privacy Policy</a>
<a href="#"> <i class="fas fa-angle-right"></i>Terms of Use</a>
</div>
<div class="box">
<h3>Contact Info</h3>
<a href="#"><i class="fas fa-angle-right fa-angle-phone" ></i>+92-318-7486-849</a>
<a href="#"><i class="fas fa-angle-right fa-angle-phone"></i>+92-304-6628-824</a>
<a href="#"><i class="fas fa-angle-right fa-angle-envelope"></i>f200282@cfd.nu.edu.pk</a>
<a href="#"><i class="fas fa-angle-right fa-angle-maps"></i> punjab, pakistan </a>
</div>
<div class="box">
<h3>Follow Us</h3>
<a href="#"> <i class="fab fa-facebook-f"></i>Facebook</a>
<a href="#"> <i class="fab fa-twitter"></i>Twitter</a>
<a href="#"> <i class="fab fa-instagram"></i>Instagram</a>
<a href="#"> <i class="fab fa-linkedin"></i>linkedin</a>
</div>
</div>
</div>
<div class="credit">created by <span>Muhammad Ahmad & Muhammad Awais</span> | All Rights Reserved! </div>
</section>
<!-- swiper js link -->
<script src="https://unpkg.com/swiper@8/swiper-bundle.min.js"></script>
<!-- custom script -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="book.js"></script>
</section>
</body>
</html>