/
processorder.php
83 lines (63 loc) · 1.71 KB
/
processorder.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
<?php
include("system-db.php");
start_db();
$siteid = getLoggedOnSiteID();
$takenbyid = getLoggedOnMemberID();
$sql = "INSERT INTO {$_SESSION['DB_PREFIX']}order
(
siteid, orderdate, status, revision, takenbyid
)
VALUES
(
$siteid, CURDATE(), 0, 1, $takenbyid
)";
$result = mysql_query($sql);
if (! $result) {
logError($sql . " = " . mysql_error());
}
$orderid = mysql_insert_id();
for ($row = 0; $row < count($_POST['productid']); $row++) {
$productid = $_POST['productid'][$row];
$qty = $_POST['qty'][$row];
if ($qty <= 0 || $productid == "" || $productid == "0") {
continue;
}
$sql = "INSERT INTO {$_SESSION['DB_PREFIX']}frequentproducts
(
siteid, productid, frequency
)
VALUES
(
$siteid, $productid, $qty
)";
$result = mysql_query($sql);
if (mysql_errno() == 1062) {
$sql = "UPDATE {$_SESSION['DB_PREFIX']}frequentproducts SET
frequency = frequency + $qty
WHERE siteid = $siteid
AND productid = $productid";
$result = mysql_query($sql);
if (! $result) {
logError($sql . " = " . mysql_error());
}
} else if (! $result) {
logError($sql . " = " . mysql_error());
}
$sql = "INSERT INTO {$_SESSION['DB_PREFIX']}orderitem
(
orderid, productid, quantity
)
VALUES
(
$orderid, $productid, $qty
)";
$result = mysql_query($sql);
if (! $result) {
logError($sql . " = " . mysql_error());
}
}
mysql_query("COMMIT");
sendRoleMessage("JRM", "Confirmed order", "Confirmed order ........");
sendSiteMessage($siteid, "Confirmed customer order", "Confirmed order ........");
header("location: processorderconfirm.php?orderid=$orderid");
?>