-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessorders.php
More file actions
97 lines (91 loc) · 3.97 KB
/
Copy pathprocessorders.php
File metadata and controls
97 lines (91 loc) · 3.97 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
<?php
include("db.php");
$pagename="Process Orders"; //Create and populate a variable called $pagename
echo "<link rel=stylesheet type=text/css href=mystylesheet.css>";//Call in stylesheet
echo "<title>".$pagename."</title>";//display name of the page as window title
echo "<body>";
include ("headfile.html");//include headerlayoutfile
include ("detectlogin.php");
echo "<h4>".$pagename."</h4>";//display name of thepageon the web page
if(isset($_POST['status'])){
$ostate = $_POST['status'];
$oid = $_POST['ordId'];
mysqli_query($GLOBALS['conn'],"UPDATE orders SET orderStatus='$ostate'
WHERE orderNo=$oid");
displayTable();
}else{
displayTable();
}
function displayTable(){
echo "<table>";
echo "<tr>";
echo "<th>Order</th>";
echo "<th>Order Date Time</th>";
echo "<th>User Id</th>";
echo "<th>Name</th>";
echo "<th>Surname</th>";
echo "<th>Status</th>";
echo "<th>Product</th>";
echo "<th>Quantity</th>";
echo"</tr>";
$SQL="select * from orders";
$exeSQL=mysqli_query($GLOBALS['conn'], $SQL) or die (mysqli_error());
while($arrayp=mysqli_fetch_array($exeSQL)){
echo"<tr>";
echo "<td><b>No:".$arrayp['orderNo']."</b></td>";
echo "<td>".$arrayp['orderDateTime']."</td>";
echo "<td>".$arrayp['userId']."</td>";
$uId =$arrayp['userId'];
$SQL2="select userFName,userSName from users where userId=$uId";
$exeSQL2=mysqli_query($GLOBALS['conn'], $SQL2) or die (mysqli_error());
$arrayp2=mysqli_fetch_array($exeSQL2);
echo "<td>".$arrayp2['userFName']."</td>";
echo "<td>".$arrayp2['userSName']."</td>";
$status=$arrayp['orderStatus'];
echo "<form action=processorders.php method=POST>";
$ordId=$arrayp['orderNo'];
if($status=="Placed"){
echo "<td><select name=status>";
echo "<option value='Placed'>Placed</option>";
echo "<option value='Ready'>Ready to collect</option>";
echo "</select>";
echo "<input type=hidden name=ordId value=$ordId>";
echo "<input type=submit name=submit value='Update'></td>";
}else if($status=="Ready"){
echo "<td><select name=status>";
echo "<option value='Ready'>Ready to collect</option>";
echo "<option value='Collected'>Collected</option>";
echo "</select>";
echo "<input type=hidden name=ordId value=$ordId>";
echo "<input type=submit name=submit value='Update'></td>";
}else if($status=="Collected"){
echo "<td>".$status."</td>";
}
echo "</form>";
$ordNo = $arrayp['orderNo'];
$SQL3="select prodId,quantityOrdered from order_line where orderNo=$ordNo";
$exeSQL3=mysqli_query($GLOBALS['conn'], $SQL3) or die (mysqli_error());
$count=0;
while($arrayp3=mysqli_fetch_array($exeSQL3)){
$pId=$arrayp3['prodId'];
$SQL4="select prodName from product where prodId=$pId";
$exeSQL4=mysqli_query($GLOBALS['conn'], $SQL4) or die (mysqli_error());
$arrayp4=mysqli_fetch_array($exeSQL4);
if($count>0){
echo "<td colspan='6'></td>";
echo "<td>".$arrayp4['prodName']."</td>";
echo "<td>".$arrayp3['quantityOrdered']."</td>";
}else{
echo "<td>".$arrayp4['prodName']."</td>";
echo "<td>".$arrayp3['quantityOrdered']."</td>";
}
$count=$count+1;
echo"</tr>";
}
echo"</tr>";
}
echo "</table>";
}
include("footfile.html");//include head layout
echo "</body>";
?>