-
Notifications
You must be signed in to change notification settings - Fork 0
/
addquotationdocument.php
49 lines (38 loc) · 1.42 KB
/
addquotationdocument.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
<?php
//Include database connection details
require_once('system-db.php');
start_db();
initialise_db();
$quotationid = $_GET['id'];
$memberid = getLoggedOnMemberID();
$qry = "SELECT A.id FROM {$_SESSION['DB_PREFIX']}documents A " .
"WHERE A.sessionid = '" . session_id() . "' " .
"AND A.id NOT IN (SELECT documentid FROM {$_SESSION['DB_PREFIX']}quotationdocs WHERE documentid = A.id) " .
"ORDER BY A.id";
$result = mysql_query($qry);
if (! $result) {
logError($qry . " = " . mysql_error());
}
while (($member = mysql_fetch_assoc($result))) {
$qry = "INSERT INTO {$_SESSION['DB_PREFIX']}quotationdocs " .
"(quoteid, documentid, createddate, metacreateddate, metacreateduserid, metamodifieddate, metamodifieduserid) " .
"VALUES " .
"($quotationid, " . $member['id'] . ", NOW(), NOW(), $memberid, NOW(), $memberid)";
$itemresult = mysql_query($qry);
if (! $itemresult) {
logError($qry . " = " . mysql_error());
}
}
$qry = "UPDATE {$_SESSION['DB_PREFIX']}documents " .
"SET sessionid = NULL, metamodifieddate = NOW(), metamodifieduserid = " . getLoggedOnMemberID() . " " .
"WHERE sessionid = '" . session_id() . "'";
$result = mysql_query($qry);
if (! $result) {
logError($qry . " = " . mysql_error());
}
if (isset($_GET['refer'])) {
header("location: " . base64_decode($_GET['refer']));
} else {
header("location: " . $_SERVER['HTTP_REFERER']);
}
?>