-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_orders.php
93 lines (78 loc) · 1.79 KB
/
update_orders.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
<?php
require 'core_login.php';
require 'database_connect.php';
if(loggedin() && isset($_GET['req']) && $_GET['req'] == '1')
{
$query = "SELECT order_id, status FROM `orders` WHERE user_id=".$_SESSION['user_id']." ORDER BY order_id DESC";
$query_run = mysqli_query($connect,$query);
$list = array();
while($row = mysqli_fetch_assoc($query_run))
{
if($row['status']=='0')
{
$status = 'Order Received';
}
else if($row['status']=='1')
{
$status = 'Preparing';
}
else if($row['status']=='2')
{
$status = 'Awaiting Delivery';
}
else if($row['status']=='3')
{
$status = 'Out for Delivery';
}
else if($row['status']=='4')
{
$status = 'Delivered';
}
else if($row['status']=='5' || $row['status']=='6')
{
$status = 'Cancelled';
}
$order_detail = new stdClass;
@$order_detail->id = $row['order_id'];
@$order_detail->status = $status;
array_push($list, $order_detail);
}
echo json_encode($list);
}
else if(loggedin() && isset($_GET['req']) && $_GET['req'] == '2' && isset($_SESSION['order_id']))
{
$query = "SELECT status, order_id FROM `orders` WHERE order_id=".$_SESSION['order_id'];
$query_run = mysqli_query($connect,$query);
while($row = mysqli_fetch_assoc($query_run))
{
if($row['status']=='0')
{
$status = 'Order Received';
}
else if($row['status']=='1')
{
$status = 'Preparing';
}
else if($row['status']=='2')
{
$status = 'Awaiting Delivery';
}
else if($row['status']=='3')
{
$status = 'Out for Delivery';
}
else if($row['status']=='4')
{
$status = 'Delivered';
}
else if($row['status']=='5' || $row['status']=='6')
{
$status = 'Cancelled';
}
$order_detail = new stdClass;
@$order_detail->id = $row['order_id'];
@$order_detail->status = $status;
}
echo json_encode($order_detail);
}
?>