-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax_updatebooking.php
148 lines (125 loc) · 5.9 KB
/
ajax_updatebooking.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
require_once("shared.php");
global $gConfig;
$rc = -1;
$msg = "";
$bookingcode = "";
$bookingid = 0;
try
{
if (isset($_POST['bookingcode']) && isset($_POST['uuid']))
{
$bookingcode = $_POST['bookingcode'];
$uuid = $_POST['uuid'];
$custfirstname = $_POST['custfirstname'];
$custlastname = $_POST['custlastname'];
$custemail = $_POST['custemail'];
$custmobile = $_POST['custmobile'];
$custphone = $_POST['custphone'];
$custaddress1 = $_POST['custaddress1'];
$custaddress2 = $_POST['custaddress2'];
$custcity = $_POST['custcity'];
$custpostcode = $_POST['custpostcode'];
$custstate = $_POST['custstate'];
$hasbudget = false;
$hascommission = false;
$hastravel = false;
$hasspotter = false;
$budget = null;
$commission = null;
$travel = null;
$spotter = null;
$vars1 = "";
$vars2 = "";
$vars3 = "";
$vars4 = "";
if (isset($_POST['budget']))
$vars1 = "budget=" . SharedNullOrQuoted($_POST['budget'], 50, $dblink) . ",";
if (isset($_POST['commission']))
$vars2 = "commission=" . SharedNullOrQuoted($_POST['commission'], 50, $dblink) . ",";
if (isset($_POST['travel']))
$vars3 = "travel=" . SharedNullOrQuoted($_POST['travel'], 50, $dblink) . ",";
if (isset($_POST['spotter']))
$vars4 = "spotter=" . SharedNullOrQuoted($_POST['spotter'], 50, $dblink) . ",";
$reportid = $_POST['reportid'];
$notes = $_POST['notes'];
$numstories = $_POST['numstories'];
$numbedrooms = $_POST['numbedrooms'];
$numbathrooms = $_POST['numbathrooms'];
$numrooms = $_POST['numrooms'];
$numbuildings = $_POST['numbuildings'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$postcode = $_POST['postcode'];
$state = $_POST['state'];
$construction = $_POST['construction'];
$age = $_POST['age'];
$meetingonsite = $_POST['meetingonsite'];
$renoadvice = $_POST['renoadvice'];
$pestinspection = $_POST['pestinspection'];
$estateagentcompany = $_POST['estateagentcompany'];
$estateagentcontact = $_POST['estateagentcontact'];
$estateagentmobile = $_POST['estateagentmobile'];
$estateagentphone = $_POST['estateagentphone'];
$userid = SharedGetUserIdFromUuid($uuid, $dblink);
$dbinsert = "update bookings set " .
"custfirstname=" . SharedNullOrQuoted($custfirstname, 50, $dblink) . "," .
"custlastname=" . SharedNullOrQuoted($custlastname, 50, $dblink) . "," .
"custemail=" . SharedNullOrQuoted($custemail, 50, $dblink) . "," .
"custmobile=" . SharedNullOrQuoted($custmobile, 50, $dblink) . "," .
"custphone=" . SharedNullOrQuoted($custphone, 50, $dblink) . "," .
"custaddress1=" . SharedNullOrQuoted($custaddress1, 50, $dblink) . "," .
"custaddress2=" . SharedNullOrQuoted($custaddress2, 50, $dblink) . "," .
"custcity=" . SharedNullOrQuoted($custcity, 50, $dblink) . "," .
"custpostcode=" . SharedNullOrQuoted($custpostcode, 50, $dblink) . "," .
"custstate=" . SharedNullOrQuoted($custstate, 50, $dblink) . "," .
"itype=" . SharedNullOrQuoted($reportid, 50, $dblink) . "," .
$vars1 .
$vars2 .
$vars3 .
$vars4 .
"notes=" . SharedNullOrQuoted($notes, 50, $dblink) . "," .
"numstories=" . SharedNullOrNum($numstories, $dblink) . "," .
"numbedrooms=" . SharedNullOrNum($numbedrooms, $dblink) . "," .
"numbathrooms=" . SharedNullOrNum($numbathrooms, $dblink) . "," .
"numrooms=" . SharedNullOrNum($numrooms, $dblink) . "," .
"numoutbuildings=" . SharedNullOrNum($numbuildings, $dblink) . "," .
"address1=" . SharedNullOrQuoted($address1, 50, $dblink) . "," .
"address2=" . SharedNullOrQuoted($address2, 50, $dblink) . "," .
"city=" . SharedNullOrQuoted($city, 50, $dblink) . "," .
"state=" . SharedNullOrQuoted($state, 50, $dblink) . "," .
"postcode=" . SharedNullOrQuoted($postcode, 50, $dblink) . "," .
"construction=" . SharedNullOrQuoted($construction, 100, $dblink) . "," .
"age=" . SharedNullOrQuoted($age, 50, $dblink) . "," .
"meetingonsite=" . SharedNullOrNum($meetingonsite, $dblink) . "," .
"renoadvice=" . SharedNullOrNum($renoadvice, $dblink) . "," .
"pestinspection=" . SharedNullOrNum($pestinspection, $dblink) . "," .
"estateagentcompany=" . SharedNullOrQuoted($estateagentcompany, 50, $dblink) . "," .
"estateagentcontact=" . SharedNullOrQuoted($estateagentcontact, 50, $dblink) . "," .
"estateagentmobile=" . SharedNullOrQuoted($estateagentmobile, 20, $dblink) . "," .
"estateagentphone=" . SharedNullOrQuoted($estateagentphone, 20, $dblink) . "," .
"datemodified=CURRENT_TIMESTAMP," .
"usersmodified_id=$userid " .
"where " .
"id=$bookingcode";
error_log($dbinsert);
if ($dbresult = SharedQuery($dbinsert, $dblink))
{
$msg = "Successfully updated booking [$bookingid]";
$rc = 0;
}
else
$msg = "Error updating booking please try again...";
}
else
$msg = "Missing parameters...";
}
catch (Exception $e)
{
$msg = "Unable to update booking...";
}
$response = array("rc" => $rc, "msg" => $msg);
$json = json_encode($response);
echo $json;
?>