-
Notifications
You must be signed in to change notification settings - Fork 0
/
removequoteitem.php
53 lines (41 loc) · 1.4 KB
/
removequoteitem.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
<?php
//Include database connection details
require_once('system-db.php');
require_once("sqlprocesstoarray.php");
start_db();
$quoteid = $_POST['quoteid'];
$id = $_POST['id'];
$qry = "SELECT caseid " .
"FROM {$_SESSION['DB_PREFIX']}quotes B " .
"WHERE B.id = $quoteid";
$result = mysql_query($qry);
if($result) {
while (($member = mysql_fetch_assoc($result))) {
$caseid = $member['caseid'];
addAuditLog("Q", "U", $caseid);
}
}
$qry = "DELETE FROM {$_SESSION['DB_PREFIX']}quoteitems " .
"WHERE id = $id";
$result = mysql_query($qry);
if (! $result) {
logError($qry . " - " . mysql_error());
}
$qry = "UPDATE {$_SESSION['DB_PREFIX']}quotes SET " .
"total = (SELECT SUM(B.total) FROM {$_SESSION['DB_PREFIX']}quoteitems B WHERE B.quoteid = $quoteid), metamodifieddate = NOW(), metamodifieduserid = " . getLoggedOnMemberID() . " " .
"WHERE id = $quoteid";
$result = mysql_query($qry);
if (! $result) {
logError($qry . " - " . mysql_error());
}
$qry = "SELECT A.*, C.total AS headertotal, B.name " .
"FROM {$_SESSION['DB_PREFIX']}quoteitems A " .
"INNER JOIN {$_SESSION['DB_PREFIX']}quotes C " .
"ON C.id = A.quoteid " .
"LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}invoiceitemtemplates B " .
"ON B.id = A.templateid " .
"WHERE A.quoteid = $quoteid " .
"ORDER BY A.id";
$json = new SQLProcessToArray();
echo json_encode($json->fetch($qry));
?>