forked from mikesanchezdev/nhconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wcontact.php.bak
418 lines (370 loc) · 17.5 KB
/
wcontact.php.bak
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<?php require_once('includes/config.php'); ?>
<?php
include('includes/sc-includes.php');
$pagetitle = FollowUp;
$whois = $row_userinfo['user_id'];
$update = 0;
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
//UPLOAD PICTURE
$picture = $_POST['image_location'];
$time = substr(time(),0,5);
if($_FILES['image'] && $_FILES['image']['size'] > 0){
$ori_name = $_FILES['image']['name'];
$ori_name = $time.$ori_name;
$tmp_name = $_FILES['image']['tmp_name'];
$src = imagecreatefromjpeg($tmp_name);
list($width,$height)=getimagesize($tmp_name);
$newwidth=95;
$newheight=($height/$width)*95;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = "images/". $ori_name;
imagejpeg($tmp,$filename,100);
$picture = $ori_name;
imagedestroy($src);
imagedestroy($tmp);
}
//END UPLOAD PICTURE
//Do Google Geocode
if ($update==0) {
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$street=$_POST['contact_street'];
$city=$_POST['contact_city'];
$zip=$_POST['contact_zip'];
$state=$_POST['contact_state'];
$name=$_POST['contact_first'] . " " . $_POST['contact_last'];
$fulladdress=$_POST['contact_street'] . ", " . $_POST['contact_city'] . ", " . $_POST['contact_state'] . ", " . $_POST['contact_zip'];
$mapaddress = urlencode("$street $city $state $zip");
// Desired address
$address = "http://maps.google.com/maps/geo?q=$mapaddress&output=xml&key=" . GKEY;
//209.85.173.104
//64.233.167.147
// Retrieve the URL contents
// $page = file_get_contents($address); // This code stopped working on godaddy 7/15/2010 ?? Had to go with fopen
// Parse the returned XML file
// $xml = new SimpleXMLElement($page);
//
// // Retrieve the desired XML node
// $coordinates = $xml->Response->Placemark->Point->coordinates;
// $coordinatesSplit = split(",", $coordinates);
// Format: Longitude, Latitude, Altitude
$page = fopen($address, "r");
if($page){
$data = fread($page, 4096);
$xml = new SimpleXMLElement($data);
// Retrieve the desired XML node
$coordinates = $xml->Response->Placemark->Point->coordinates;
$coordinatesSplit = split(",", $coordinates);
}
fclose($page);
$lat = $coordinatesSplit[1];
$lng = $coordinatesSplit[0];
$insertSQL = sprintf("INSERT INTO follows_contacts (address, name, contact_first, contact_last, contact_date, contact_user, contact_image, contact_age, contact_profile, contact_method, contact_mstatus, contact_stime, contact_street, contact_unit, contact_city, contact_state, contact_zip, contact_stage, lat, lng, contact_phone, contact_cell, contact_email, contact_updated, contact_wait, follow_date) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($fulladdress, "text"),
GetSQLValueString($name, "text"),
GetSQLValueString(trim($_POST['contact_first']), "text"),
GetSQLValueString(trim($_POST['contact_last']), "text"),
GetSQLValueString(time(), "date"),
GetSQLValueString(trim($_POST['contact_user']), "text"),
GetSQLValueString($picture, "text"),
GetSQLValueString(trim($_POST['contact_age']), "int"),
GetSQLValueString(trim($_POST['contact_profile']), "text"),
GetSQLValueString(trim($_POST['contact_method']), "text"),
GetSQLValueString(trim($_POST['contact_mstatus']), "text"),
GetSQLValueString(trim($_POST['contact_stime']), "text"),
GetSQLValueString(trim($_POST['contact_street']), "text"),
GetSQLValueString(trim($_POST['contact_street2']), "text"),
GetSQLValueString(trim($_POST['contact_city']), "text"),
GetSQLValueString(trim($_POST['contact_state']), "text"),
GetSQLValueString(trim($_POST['contact_zip']), "text"),
GetSQLValueString(trim($_POST['contact_stage']), "text"),
GetSQLValueString($lat, "text"),
GetSQLValueString($lng, "text"),
GetSQLValueString(trim($_POST['contact_phone']), "text"),
GetSQLValueString(trim($_POST['contact_cell']), "text"),
GetSQLValueString(trim($_POST['contact_email']), "text"),
GetSQLValueString($_POST['contact_updated'], "int"),
GetSQLValueString($_POST['contact_wait'], "int"),
GetSQLValueString($_POST['date3'], "text"));
mysql_select_db($database_follows, $follows);
$Result1 = mysql_query($insertSQL, $follows) or die(mysql_error());
$lastid = mysql_insert_id($follows);
$insertSQL4Wait = sprintf("INSERT INTO follows_wait (group_id, contact_id, wait_updated) VALUES (%s, %s, %s)",
GetSQLValueString(trim($_POST['wait_group']), "text"),
GetSQLValueString($lastid, "text"),
GetSQLValueString(time(), "date"));
$Result2 = mysql_query($insertSQL4Wait, $follows) or die(mysql_error());
set_msg('Follow-Up Waiting');
$redirect = "waitqueue.php";
header(sprintf('Location: %s', $redirect)); die;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo "Add Contact to wait queue"; ?></title>
<script src="includes/lib/prototype.js" type="text/javascript"></script>
<script src="includes/src/effects.js" type="text/javascript"></script>
<script src="includes/validation.js" type="text/javascript"></script>
<script src="includes/src/scriptaculous.js" type="text/javascript"></script>
<script language="javascript">
function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}
</script>
<link rel="alternate stylesheet" type="text/css" media="all" href="calendar-blue.css" id="defaultTheme" title="winter" />
<script type="text/javascript" src="calendar.js"></script>
<link href="includes/style.css" rel="stylesheet" type="text/css" />
<link href="includes/simplecustomer.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include('includes/header.php'); ?>
<div class="container">
<div class="leftcolumn">
<h2>Add FollowUp to Wait Queue</h2>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="28%">First Name<br />
<input name="contact_first" type="text" class="required" title="First name required" id="contact_first" value="<?php echo $row_contact['contact_first']; ?>" size="25" /></td>
<td width="72%">Last Name<br />
<input name="contact_last" type="text" class="required" title="Last name required" id="contact_last" value="<?php echo $row_contact['contact_last']; ?>" size="25" />
</p></td>
</tr>
<tr>
<td>Phone<br /> <input name="contact_phone" type="text" id="contact_phone" value="<?php echo $row_contact['contact_phone']; ?>" size="35" /> </td>
<td>Cell<br /> <input name="contact_cell" type="text" id="contact_cell" value="<?php echo $row_contact['contact_cell']; ?>" size="35" /> </td>
</tr>
<tr>
<td>Email <br />
<input name="contact_email" type="text" class="validate-email" id="contact_email" value="<?php echo $row_contact['contact_email']; ?>" size="35" /></td>
<td>Contacted via<br />
<select name="contact_method" id="contact_method" class="validate-selection">
<option value="">Select</option>
<?php //This is the method in which the user was contacted or met
$link1 = "SELECT * FROM category ORDER BY cat ASC";
$res1 = mysql_query($link1);
$cur = $row_contact['contact_method'];
$x = 0;
while ($row1 = mysql_fetch_row($res1))
{
$cat = $row1[0];
if ($cat == $cur && $x != 1)
{
echo '<option value="' . $cat . '" selected>' . $cat;
$x = 1;
}
else
echo '<option value="' . $cat . '">' . $cat;
}
?>
</select></td>
</tr>
<tr>
<td width="27%" valign="top">Marital Status<br />
<select name="contact_mstatus" id="contact_mstatus" class="validate-selection">
<option value="">Select</option>
<option value="Single" <?php if (!(strcmp("Single", $row_contact['contact_mstatus']))) {echo "selected=\"selected\"";} ?>>Single</option>
<option value="Married" <?php if (!(strcmp("Married", $row_contact['contact_mstatus']))) {echo "selected=\"selected\"";} ?>>Married</option>
<option value="Divorced" <?php if (!(strcmp("Divorced", $row_contact['contact_mstatus']))) {echo "selected=\"selected\"";} ?>>Divorced</option>
<option value="Unknown" <?php if (!(strcmp("Unknown", $row_contact['contact_mstatus']))) {echo "selected=\"selected\"";} ?>>Unknown</option>
</select></td>
<td>Service Attended<br />
<select name="contact_stime" id="contact_stime" class="validate-selection" title="Please select service time">
<option value="">Select</option>
<?php //This is the method in which the user was contacted or met
$link1 = "SELECT * FROM follows_services ORDER BY service_name ASC";
$res1 = mysql_query($link1);
$cur = $row_contact['contact_stime'];
$x = 0;
while ($row1 = mysql_fetch_row($res1))
{
$cat = $row1[3];
$cat2 = $row1[1];
if ($cat == $cur && $x != 1)
{
echo '<option value="' . $cat . '" selected>' . $cat;
$x = 1;
}
else
echo '<option value="' . $cat . '">' . $cat;
}
?>
</select></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Street<br />
<input name="contact_street" type="text" id="contact_street" value="<?php echo $row_contact['contact_street']; ?>" size="35" /></td></tr>
<tr><td>Unit/Apt<br />
<input name="contact_street2" type="text" id="contact_street2" value="<?php echo $row_contact['contact_unit']; ?>" size="17" /></td></tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="39%">City<br />
<input name="contact_city" type="text" id="contact_city" value="<?php echo $row_contact['contact_city']; ?>" size="35" /></td>
<td width="27%" valign="top">State<br />
<select name="contact_state" id="contact_state">
<option value="CA" <?php if (!(strcmp("CA", $row_contact['contact_state']))) {echo "selected=\"selected\"";} ?>>California</option>
<option value="CA" <?php if (!(strcmp("CA", $row_contact['contact_state']))) {echo "selected=\"selected\"";} ?>>California</option>
</select></td>
<td width="34%">Zip<br />
<input name="contact_zip" type="text" id="contact_zip" value="<?php echo $row_contact['contact_zip']; ?>" size="10" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40%">Wait in Group<br />
<select name="wait_group" id="wait_group" class="validate-selection" title="You must select a group">
<option value="<?php if ($update==1) { echo $row_contact['contact_user']; } else { echo $row_userinfo['user_id']; } ?>">
<?php if (($update==1) && ($row_contactJ2['user_name'])) { echo "Currently Assigned to: " . $row_contactJ2['user_name']; } else { echo "Select"; } ?>
</option>
<?php if ($row_userinfo['user_level'] != 2) {
//$query_userassign = "SELECT user_id,user_name,user_email FROM follows_users ORDER BY user_name";
// - $query_userassign = "SELECT * FROM follows_users INNER JOIN follows_group ON member_group_id = group_id WHERE leader_id = $whois ";
$query_userassign = "SELECT group_id, leader_id, group_name FROM follows_group ORDER BY group_name";
$userassign = mysql_query($query_userassign, $follows);
if(mysql_num_rows($userassign)) {
while($row_userassign = mysql_fetch_row($userassign))
{
print("<option value=\"$row_userassign[0]\">$row_userassign[2]</option>");
}
} else {
print("<option value=\"\">No users created yet</option>");
}
}
?>
<?php if (($row_userinfo['user_level']!=1) && ($update == 0) ) { ?>
<option value="<?php echo $row_userinfo['user_id'];?>"><?php echo $row_userinfo['user_name'];?></option>
<?php } ?>
</select>
</td>
</tr>
</table></td>
</tr>
<tr>
<td>Image<br />
<input name="image" type="file" id="image" /><?php if ($row_contact['contact_image']) { ?>
<br />
<img src="images/<?php echo $row_contact['contact_image']; ?>" width="95" />
<?php } ?>
</td>
</tr>
<tr>
<td>Age<br /><input name="contact_age" type="text" class="validate-digits" id="contact_age" value="<?php echo $row_contact['contact_age']; ?>" size="1"/></td>
</tr>
<tr>
<td>Add FollowUp Date<br /><input type="text" name="date3" class="validate-date" id="sel3" size="10" value="<?php echo $row_contact['follow_date'];?>">
<input type="reset" value="Date Select"onclick="return showCalendar('sel3', 'mm/dd/y');"></td></tr>
<tr>
<td>
FollowUp Stage<br />
<select name="contact_stage" id="contact_stage" class="validate-selection">
<option value="">Select</option>
<?php //This is the followups current stage
$link1 = "SELECT * FROM follows_stages ORDER BY stage ASC";
$res1 = mysql_query($link1);
$cur = $row_contact['contact_stage'];
$x = 0;
while ($row1 = mysql_fetch_row($res1))
{
$cat = $row1[0];
$catn = $row1[1];
if ($cat == $cur && $x != 1)
{
echo '<option value="' . $cat . '" selected>' . $catn;
$x = 1;
}
else
echo '<option value="' . $cat . '">' . $catn;
}
?>
</select>
</td>
</tr>
<td>Background/Profile<br />
<textarea name="contact_profile" cols="50" rows="3" id="contact_profile"><?php echo $row_contact['contact_profile']; ?></textarea></td>
</tr>
</table>
</div>
<p> </p></td>
</tr>
<tr>
<td colspan="2"><p>
<input type="submit" name="Submit2" value="Add FollowUp" />
<input name="contact_updated" type="hidden" id="contact_updated" value="<?php echo time(); ?>" />
<input name="contact_wait" type="hidden" id="contact_wait" value=1 />
<input type="hidden" name="MM_insert" value="form1" />
<input name="contact_id" type="hidden" id="contact_id" value="<?php echo $row_contact['contact_id']; ?>" />
<input name="image_location" type="hidden" id="image_location" value="<?php echo $row_contact['contact_image']; ?>" />
</p></td>
</tr>
</table>
<p> </p>
<input type="hidden" name="MM_update" value="form1">
</form><script type="text/javascript">
var valid2 = new Validation('form1', {useTitles:true});
</script>
</div>
<?php include('includes/right-column.php'); ?>
<br clear="all" />
</div>
<?php include('includes/footer.php'); ?>
</body>
</html>