-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder_track_update.php
134 lines (99 loc) · 5.61 KB
/
order_track_update.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
<?php
include('top_header.php');
echo "<title>Customer Page</title>";
include('header.php');
?>
<?php
if(!isset($_GET['oid'])){
echo "<script language='javascript'>
document.location='admin_orders_panel.php';
</script>";
}
$oid=intval($_GET['oid']);
$sql = "SELECT * FROM `order_track_history` WHERE `id`= $oid ";
$res = mysqli_query($conn,$sql);
if(!$res){
die("error in User Details ".mysqli_error($conn));
}
$row = mysqli_fetch_assoc($res);
?>
<div class="container-fluid " >
<div align="center">
<div class="col-md-8" style="border:3px solid #007bff; margin:50px; border-radius:80px; padding:50px;">
<h1>Order details Update </h1>
<form action="order_track_update.php?oid=<?php echo "".$oid;?>" method="post">
<div class="row" style="padding:0px; margin:20px;" >
<label class="col-5" > <b>Order Id </b></label>
<input class="col-7 form-control" type="text" value="<?php echo $row['id'];?>" name="order_id" readonly>
</div>
<div class="row" style="padding:0px; margin:20px;" >
<label class="col-5" > <b>User Name</b></label>
<input class="col-7 form-control " type="text" value="<?php
$uuid = intval($row['user_id']);
$newsql = "SELECT * FROM `user` WHERE `id`= $uuid ";
$newres = mysqli_query($conn,$newsql);
if(!$newres){
die("Error in the user Id");
}
$newrow = mysqli_fetch_assoc($newres);
echo "".$newrow['first_name']." ".$newrow['last_name'];
?>" name="username" readonly>
</div>
<div class="row" style="padding:0px; margin:20px;" >
<label class="col-5" > <b>Price</b></label>
<input class="col-7 form-control" type="text" value="<?php echo $row['price'];?>" name="price" readonly>
</div>
<div class="row" style="padding:0px; margin:20px;" >
<label class="col-5" > <b>Order Status</b></label>
<select id="inputState" class="form-control col-7" name="status">
<option <?php if($row['status']=="On packing"){ echo "selected"; }?> >On packing</option>
<option <?php if($row['status']=="On Delivery"){ echo "selected"; }?> >On Delivery</option>
<option <?php if($row['status']=="Delivered"){ echo "selected"; }?> >Delivered</option>
<option <?php if($row['status']=="Canceled"){ echo "selected"; }?> >Canceled</option>
</select>
</div>
<div class="row" style="padding:0px; margin:20px;" >
<label class="col-5" > <b>Payment Method</b></label>
<input class="col-7 form-control" type="text" value="<?php echo $row['paymet_method'];?>" name="paymet_method'" readonly>
</div>
<div class="row" style="padding:0px; margin:20px;" >
<label class="col-5" > <b>Ordered Date</b></label>
<input class="col-7 form-control" type="text" value="<?php echo $row['post_date'];?>" name="Ordered_Date" readonly>
</div>
<div class="row" style="padding:0px; margin:20px;" >
<label class="col-5" > <b>Delivery time </b></label>
<input class="col-7 form-control" type="text" placeholder="yyyy-mm-dd hh:mm:ss" value="<?php echo $row['role'];?>" name="Delivery_time" >
</div>
<table>
<tr>
<th><button class="btn btn-primary col-6 " style="float:left; ; width:200px; " type="submit" name="update">Update</button> </th>
<th><button class="btn btn-primary col-6" style=" width:200px; " type="reset" name="clear">Clear</button> </th>
</tr>
</table>
</form>
<?php
if(isset($_POST['update'])){
$oid =intval($_GET['oid']) ;
$status = $_POST['status'];
date_default_timezone_set('Asia/Kolkata');
$updatetime =null;
if($status=="Delivered")
$updatetime=date( 'Y-m-d h:i:s ', time() );
$sql = "UPDATE `order_track_history` SET `status`= '$status',`delivery_time`='$updatetime' WHERE `id` =$oid ";
$res = mysqli_query($conn,$sql);
if(!$res){
die("Error in Update Order Details".mysqli_error($conn));
}
echo "<script language='javascript'>
document.location='admin_orders_panel.php';
</script>";
}
?>
</div>
</div>
</div>
<?php
include("footer.php");
?>
</body>
</html>