-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorderEdit.php
More file actions
131 lines (113 loc) · 5.16 KB
/
orderEdit.php
File metadata and controls
131 lines (113 loc) · 5.16 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
<?php include "inc/head.php"; ?>
<!-- ::::: order-Edit Section Start ::::: -->
<section>
<div class="container">
<div class="row">
<div class="col-lg-12 py-5">
<h2 class="text-center py-3">Edit Booking Status</h2>
<!-- Table Start -->
<div>
<table class="table table-striped table-hover table-bordered">
<thead class="table-info">
<tr>
<th scope="col">Book Title</th>
<th scope="col">Order Date</th>
<th scope="col">Receive Date</th>
<th scope="col">Return Date</th>
</tr>
</thead>
<tbody>
<?php
if ( isset($_GET['orderId']) ) {
$order_id = $_GET['orderId'];
$sql = "SELECT * FROM booking_list WHERE id = '$order_id'";
$orderData = mysqli_query($db, $sql);
while ($row = mysqli_fetch_assoc($orderData)) {
$id = $row['id'];
$book_id = $row['book_id'];
$user_id = $row['user_id'];
$rcv_date = $row['rcv_date'];
$rtn_date = $row['rtn_date'];
$booking_date = $row['booking_date'];
$status = $row['status'];
?>
<tr>
<td>
<?php
$sql = "SELECT * FROM book WHERE id = '$book_id'";
$theBook = mysqli_query($db, $sql);
while ($row = mysqli_fetch_assoc($theBook)) {
$title = $row['title'];
echo $title;
}
?>
</td>
<td><?php echo $booking_date; ?></td>
<td><?php echo $rcv_date; ?></td>
<td><?php echo $rtn_date; ?></td>
</tr>
<?php }
}
?>
</tbody>
</table>
</div>
<!-- Table End -->
<!-- Edit Status Part Start -->
<div class="row py-5">
<div class="col-lg-6 offset-lg-3" style="border-top: 4px solid #08c; padding: 29px 62px 39px; box-shadow: 1px 10px 15px #ccc; border-radius: 5px; ">
<h4 class="text-center">Do You Want to Cancel this Booking?</h4>
<form action="" method="POST">
<div class="mb-3">
<select class="form-select" name='status'>
<option selected>Tap Here..</option>
<option value="3">Cancel</option>
</select>
</div>
<div class="mb-3">
<div class="d-grid gap-2">
<input type="hidden" name="order_id" value="<?php echo $id; ?>">
<input type="hidden" name="book_id" value="<?php echo $book_id; ?>">
<input type="submit" name="updateOrder" class="btn btn-success btn-block" value="CONFIRM">
</div>
</div>
</form>
<?php
if (isset($_POST['updateOrder'])) {
$order_id = $_POST['order_id'];
$book_id = $_POST['book_id'];
$rcv_date = date('Y-m-d', strtotime($_POST['rcv_date']));
$rtn_date = date('Y-m-d', strtotime($_POST['rtn_date']));
$status = $_POST['status'];
//Cancel
if ($status == 3) {
$sql = "UPDATE booking_list SET status='$status' WHERE id='$order_id'";
$updateOrderDetails = mysqli_query($db, $sql);
// Update the Quantity of the Order Book
$query = "SELECT * FROM book WHERE id='$book_id'";
$bookData = mysqli_query($db, $query);
while( $row = mysqli_fetch_assoc($bookData) ) {
$quantity = $row['quantity'];
$quantity;
}
$query2 = "UPDATE book SET quantity='$quantity' Where id='$book_id'";
$updateBookData = mysqli_query($db, $query2);
if ($updateBookData) {
header("Location: orderHistory.php");
}
else {
die("mysqli Error" . mysqli_error($db));
}
}
//Cancel
}
?>
</div>
</div>
<!-- Edit Status Part End -->
</div>
</div>
</div>
</section>
<!-- ::::: order-Edit Section End ::::: -->
<?php include "inc/footer.php"; ?>