-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker-common.php
More file actions
44 lines (44 loc) · 1.53 KB
/
Copy pathworker-common.php
File metadata and controls
44 lines (44 loc) · 1.53 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
<?php
function commonWorkerSearch($sql,$ship=0){
require 'db.php';
$sth = $db->prepare ($sql);
$sth->bindParam (':id', $_SESSION['id']);
$sth->execute ();
while($row = $sth->fetch()){
$orderID = $row['id'];
echo "<div id=order>";
echo "<p>Order: ".$orderID."</br>";
$sql = 'SELECT * FROM orderdetail WHERE orderID=:id';
$sth2 = $db->prepare ($sql);
$sth2->bindParam (':id', $orderID);
$sth2->execute ();
$gotWhatWeNeed = 1;
while($row2 = $sth2->fetch()){
$sql = 'SELECT * FROM products WHERE id=:id';
$sthPro = $db->prepare ($sql);
$sthPro->bindParam (':id', $row2['productID']);
$sthPro->execute ();
$row3 = $sthPro->fetch();
echo "</br>";
echo "Product ID: ".$row2['productID']."</br>Name: ".$row3['name']."</br>";
echo "Qty: ".$row2['qty']." In stock: ".$row3['onStock'];
echo "</br>";
// Any of the products that there is not enough of
if(intval($row2['qty']) > intval($row3['onStock'])){
$gotWhatWeNeed = 0;
}
}
// Only allow to take an order if there is enough on stock
if($gotWhatWeNeed != 0 && $ship != 1){
echo '<form action="worker.php" method="post">';
echo "<input type=\"hidden\" name=\"order\" value=".$orderID."/>";
echo '<input type="submit" name="submit" value="Take order"></form>';
}else if($gotWhatWeNeed != 0 && $ship ===1){
echo '<form action="worker-myorders.php" method="post">';
echo "<input type=\"hidden\" name=\"order\" value=".$orderID."/>";
echo '<input type="submit" name="submit" value="Ship order"></form>';
}
echo "</div>";
}
}
?>