-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.php
2344 lines (2174 loc) · 107 KB
/
add.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
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
if ( !defined( 'E_DEPRECATED' ) ) { define( 'E_DEPRECATED',8192 );} // 11/8/09
error_reporting (E_ALL ^ E_DEPRECATED);
@session_start();
session_write_close();
if (empty($_SESSION)) {
header("Location: index.php");
}
require_once('incs/functions.inc.php'); //7/28/10
do_login(basename(__FILE__));
$in_win = (array_key_exists("mode", $_GET)) ? 1 : 0;
$from_mi = (array_key_exists("mi", $_GET)) ? 1 : 0;
$gmaps = $_SESSION['internet'];
if($istest) {print "_GET"; dump($_GET);}
if($istest) {print "_POST"; dump($_POST);}
$the_level = (isset($_SESSION['level'])) ? $_SESSION['level'] : 0 ;
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]states_translator`";
$result = mysql_query($query);
while ($row = stripslashes_deep(mysql_fetch_assoc($result))){
$states[$row['name']] = $row['code'];
}
/*
10/28/07 added onLoad = "document.add.frm_lat.disabled..
11/38/07 added frame jump prevention
11/98/07 added map under image
5/29/08 added do_kml() call
8/11/08 added problem-start lock/unlock
8/23/08 added usng handling
8/23/08 corrected problem-end hskpng
9/9/08 added lat/lng-to-CG format functions
10/4/08 added function do_inc_name()
10/7/08 set WRAP="virtual"
10/8/08 synopsis made non-mandatory
10/15/08 changed 'Comments' to 'Disposition'
10/16/08 changed ticket_id to frm_ticket_id
10/17/08 removed 10/16/08 change
10/19/08 added insert_id to description
12/6/08 allow user input of NGS values; common icon marker function
1/11/09 TBD as default, auto_route setting option
1/17/09 replaced ajax functions - for consistency
1/18/09 added script-specific CONSTANTS
1/19/09 added geocode function
1/21/09 show/hide butts
1/22/09 - serial no. to ticket description
1/25/09 serial no. pre-set
1/27/09 area code vaiable added
2/4/09 added function get_res_row()
2/10/09 added function sv_win()
2/11/09 added dollar function, streetview functions
3/3/09 cleaned trash as page bottom
3/10/09 intrusive space in ticket_id
4/30/09 $ replaces document.getElementById, USNG text underline
7/7/09 added protocol handling
7/16/09 zero to in_types_id
8/2/09 Added code to get maptype variable and switch to change default maptype based on variable setting
8/3/09 Added code to get locale variable and change USNG/UTM/UTM dependant on variable in tabs and sidebar.
8/13/09 'date' = now added to UPDATE
9/22/09 Added set Incident at a Facility functionality
9/29/09 'frequent fliers' added
10/1/09 added special ticket type - for pre-booked tickets
10/2/09 added locale check for WP lookup
10/6/09 Added Mouseover help text to all field labels.
10/6/09 Added Receiving Facility, added links button
10/12/09 Incident at facility menu is hidden by default - click radio button to show.
10/13/09 Added reverse geocoding - map click now returns address and location to form.
11/01/09 Added use of reverse_geo setting to switch off reverse geocoding if not required - default is off.
11/06/09 Changed "Special" incident type to "Scheduled".
11/06/09 Moved both Facility dropdown menus to the same area
12/16/09 added call-history operation
1/3/10 added '_by' field for multi-user call-taker id
3/13/10 present constituents 'miscellaneous'
3/18/10 corrections to facilities options list
3/24/10 made facilities input conditioned on existence, logging revised
4/21/10 provided for changed NOC/name values - per AF email
4/27/10 try geo-code on failed phone lookup
5/6/10 accommodate embedded quotes
6/20/10 handle negative delta's, NULL forced, 'NULL' un-quoted
6/25/10 guest/member notification changed
6/26/10 911 field handling added
7/5/10 Revised reverse geocoding function - per AH
7/11/10 'NULL' to 0
7/22/10 miscjs, google reverse geocode parse added
7/28/10 Added inclusion of startup.inc.php for checking of network status and setting of file name variables to support no-maps versions of scripts.
8/7/10 protocol reset house-keeping
8/13/10 map.setUIToDefault(), get_text settings
9/30/10 use '_by' as the match identifier, booking button name disambiguated
10/21/10 onload focus(), tabindex added
11/5/10 revised to prepare for callerid handling
11/13/10 incident numbering added
11/23/10 'state' size made locale-dependent
11/29/10 locale 2 handling added
12/1/10 get_text changes
12/18/10 set signals added
1/1/11 Titles array added, scheduled incidents revised
1/19/10 revised to accommodate both maps and no-maps option
1/21/11 corrections to booked-date handling
1/24/11 corrections to locale/grid handling
1/29/11 changed coordinates test to string-length
2/1/11 added table 'hints' as hints source
2/11/11 condition signals on non-empty table
2/12/11 facility names shortened
2/19/11 draggable button bar replaces tr
2/27/11 corrected 'append incident nature to incident name'
3/2/11 added base64_decode to serialize/unserialize
3/15/11 changed default.css to stylesheet.php to cater for day / night capability
3/17/11 Revised form to not use default city if places exist in the places table
4/23/11 revisions for USNG handling
5/22/11 corrected reverse geo-location lookup
6/9/11 action and patient buttons, cancel function added, caller id
6/10/11 added changes required to support regional capability (Ticket region assignment).
6/23/11 revised target for action and patient buttons
11/22/2012 'nearby' capability added
12/1/2012 show 'nearby' only if internet/maps
5/22/2013 added broadcast call
6/2/2013 - reverse geocode added
7/3/2013 - socket2me conditioned on internet and broadcast settings, enforce reverse-geo values size limits
9/10/13 - Added "address about" and "To address" fields. Also Location warnings capability
10/11/2013 - corrected auto incident numbering - relocated else {} closure
3/29/2014 - added buildings operations
4/7/2014 - revised per nm operation
4/27/2014 - correction re bldg per YG email, also do_reset() kml re-arrangement
5/23/2015 - revised to handle new 'addr_source' functions
10/3/2015 - revised to accommodate V3 map functions (AS)
*/
/* $temp = get_variable('_inc_num'); // 3/2/11
$inc_num_ary = (strpos($temp, "{")>0)? unserialize ($temp) : unserialize (base64_decode($temp));
dump($inc_num_ary); */
if (empty($_GET)) {
if (mysql_table_exists("$GLOBALS[mysql_prefix]caller_id")) { // 6/9/11
$cid_calls = $cid_name = $cid_phone = $cid_street = $cid_city = $cid_state = $cid_lat = $cid_lng = "";
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]caller_id` WHERE `status` = 0 LIMIT 1;";
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
if (mysql_num_rows($result)> 0) { // build return string from newest incident data
$row = stripslashes_deep(mysql_fetch_array($result));
$query = "UPDATE `$GLOBALS[mysql_prefix]caller_id` SET `status` = 1 WHERE `id` = " . quote_smart($row['id']);
$result = mysql_query($query);
$lookup_vals = explode (";", $row['lookup_vals']);
$cid_calls = $lookup_vals[0];
$cid_name = $lookup_vals[1];
$cid_phone = $lookup_vals[2];
$cid_street = $lookup_vals[3];
$cid_city = $lookup_vals[4];
$cid_state = $lookup_vals[5];
$cid_lat = $lookup_vals[7];
$cid_lng = $lookup_vals[8];
$cid_id = $row['id']; // id of caller id record
}
} // end if(empty())
}
$current_facilities = array(); // 9/22/09
$query_f = "SELECT * FROM `$GLOBALS[mysql_prefix]facilities` ORDER BY `id`"; // types in use
$result_f = mysql_query($query_f) or do_error($query_f, 'mysql query failed', mysql_error(), basename( __FILE__), __LINE__);
while ($row_f = stripslashes_deep(mysql_fetch_assoc($result_f))) {
$current_facilities [$row_f['id']] = array ($row_f['name'], $row_f['lat'], $row_f['lng']);
}
$facilities = mysql_affected_rows(); // 3/24/10
$protocols = array();
$query_in = "SELECT * FROM `$GLOBALS[mysql_prefix]in_types` ORDER BY `group` ASC, `sort` ASC, `type` ASC";
$result_in = mysql_query($query_in);
while ($row_in = stripslashes_deep(mysql_fetch_assoc($result_in))) {
if($row_in['protocol'] != "") {$protocols[$row_in['id']] = addslashes($row_in['protocol']);}
}
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]major_incidents` WHERE `inc_endtime` IS NULL OR DATE_FORMAT(`inc_endtime`,'%y') = '00'";
$result = mysql_query($query) or do_error('', 'mysql query failed', mysql_error(), basename( __FILE__), __LINE__);
$num_mi = mysql_num_rows($result);
function get_res_row() { // writes empty ticket if none exists - returns a row - 11/5/10
$by = $_SESSION['user_id']; // 5/27/10
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]ticket`
WHERE `status`= '{$GLOBALS['STATUS_RESERVED']}'
AND `_by` = '{$by}' LIMIT 1";
$result = mysql_query($query) or do_error("", 'mysql query failed', mysql_error(), basename( __FILE__), __LINE__);
if (mysql_num_rows($result) == 1) { // any ?
$row = stripslashes_deep(mysql_fetch_array($result)); // yes, return it
}
else { // insert empty STATUS_RESERVED row
$query_insert = "INSERT INTO `$GLOBALS[mysql_prefix]ticket` (
`id` , `in_types_id` , `contact` , `street` , `address_about` , `city` , `state` , `phone` , `to_address` , `lat` , `lng` , `date` ,
`problemstart` , `problemend` , `scope` , `affected` , `description` , `comments` , `status` , `owner` ,
`severity` , `updated`, `booked_date`, `_by`
) VALUES (
NULL , 0, 0, NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL ,
NULL , NULL , '', NULL , '', NULL , '" . $GLOBALS['STATUS_RESERVED'] . "', '0', '0', NULL, NULL, $by
)"; // 9/10/13
$result_insert = mysql_query($query_insert) or do_error($query_insert,'mysql_query() failed', mysql_error(), basename( __FILE__), __LINE__);
}
$result = mysql_query($query) or do_error("", 'mysql query failed', mysql_error(), basename( __FILE__), __LINE__);
$row = stripslashes_deep(mysql_fetch_assoc($result)); // get the reserved row
return $row; // and return it - 11/5/10
} // end function get_res_row()
$get_add = ((empty($_GET) || ((!empty($_GET)) && (empty ($_GET['add'])))) ) ? "" : $_GET['add'] ;
if ($get_add == 'true') {
function updt_ticket($id) { /* 1/25/09 */
global $addrs, $_POST, $NOTIFY_TICKET; // 8/28/13
$ticket_id = $id;
$post_frm_meridiem_problemstart = ((empty($_POST) || ((!empty($_POST)) && (empty ($_POST['frm_meridiem_problemstart'])))) ) ? "" : $_POST['frm_meridiem_problemstart'] ;
$post_frm_meridiem_booked_date = ((empty($_POST) || ((!empty($_POST)) && (empty ($_POST['frm_meridiem_booked_date'])))) ) ? "" : $_POST['frm_meridiem_booked_date'] ; //10/1/09
$post_frm_affected = ((empty($_POST) || ((!empty($_POST)) && (empty ($_POST['frm_affected'])))) ) ? "" : $_POST['frm_affected'] ;
$_POST['frm_description'] = strip_html($_POST['frm_description']); //clean up HTML tags
$post_frm_affected = strip_html($post_frm_affected);
$_POST['frm_scope'] = strip_html($_POST['frm_scope']);
if (!get_variable('military_time')) { //put together date from the dropdown box and textbox values
if ($post_frm_meridiem_problemstart == 'pm'){
$post_frm_meridiem_problemstart = ($post_frm_meridiem_problemstart + 12) % 24;
}
}
if (!get_variable('military_time')) { //put together date from the dropdown box and textbox values
if ($post_frm_meridiem_booked_date == 'pm'){
$post_frm_meridiem_booked_date = ($post_frm_meridiem_booked_date + 12) % 24;
}
}
if(empty($post_frm_owner)) {$post_frm_owner = $_SESSION['user_id'];}
$frm_problemstart = "$_POST[frm_year_problemstart]-$_POST[frm_month_problemstart]-$_POST[frm_day_problemstart] $_POST[frm_hour_problemstart]:$_POST[frm_minute_problemstart]:00$post_frm_meridiem_problemstart";
if (intval($_POST['frm_status']) == 3) { // 1/21/11
$frm_booked_date = "$_POST[frm_year_booked_date]-$_POST[frm_month_booked_date]-$_POST[frm_day_booked_date] $_POST[frm_hour_booked_date]:$_POST[frm_minute_booked_date]:00$post_frm_meridiem_booked_date";
} else {
// $frm_booked_date = "NULL";
$frm_booked_date = ""; // 6/20/10
}
if (!get_variable('military_time')) { //put together date from the dropdown box and textbox values
if ($post_frm_meridiem_problemstart == 'pm'){
$_POST['frm_hour_problemstart'] = ($_POST['frm_hour_problemstart'] + 12) % 24;
}
if (isset($_POST['frm_meridiem_problemend'])) {
if ($_POST['frm_meridiem_problemend'] == 'pm'){
$_POST['frm_hour_problemend'] = ($_POST['frm_hour_problemend'] + 12) % 24;
}
}
if (isset($_POST['frm_meridiem_booked_date'])) { //10/1/09
if ($_POST['frm_meridiem_booked_date'] == 'pm'){
$_POST['frm_hour_booked_date'] = ($_POST['frm_hour_booked_date'] + 12) % 24;
}
}
}
$frm_problemend = (isset($_POST['frm_year_problemend'])) ? quote_smart("$_POST[frm_year_problemend]-$_POST[frm_month_problemend]-$_POST[frm_day_problemend] $_POST[frm_hour_problemend]:$_POST[frm_minute_problemend]:00") : "NULL";
$now = mysql_format_date(time() - (intval(get_variable('delta_mins')*60))); // 6/20/10
if(empty($post_frm_owner)) {$post_frm_owner=0;}
//$inc_num_ary = unserialize (get_variable('_inc_num')); // 11/13/10
$temp = get_variable('_inc_num'); // 3/2/11
$inc_num_ary = (strpos($temp, "{")>0)? unserialize ($temp) : unserialize (base64_decode($temp));
// Show serial and format
switch ((int) $inc_num_ary[0]) {
case 0: // none
$inc_serial=""; // empty
break;
case 1: // number only
$inc_serial = (string) $inc_num_ary[3]. $inc_num_ary[2] . " " ; // number and trailing separator if any
break;
case 2: // labeled
$inc_serial = $inc_num_ary[1]. $inc_num_ary[2] . (string) $inc_num_ary[3] . " " ; // label, separator, number
break;
case 3: // year
$inc_serial = $inc_num_ary[5] . $inc_num_ary[2] . (string) $inc_num_ary[3] . " " ; // year, separator, number
break;
default:
alert("ERROR @ " + "<?php print __LINE__;?>");
}
$inc_nature = get_type($_POST['frm_in_types_id']);
$prepend_nature = (bool)($inc_num_ary[4]==1)? $inc_nature: "" ;
switch (get_variable('serial_no_ap')) { // incident name revise -1/22/09
case 0: /* no serial no. */
$name_rev = $_POST['frm_scope'];
break;
case 1: /* prepend */
$name_rev = $ticket_id . "/" . $_POST['frm_scope'];
break;
case 2: /* append */
$name_rev = $_POST['frm_scope'] . " / " . $ticket_id;
break;
default: /* error???? */
$name_rev = " error error error ";
} // end switch
// 8/23/08, 9/20/08, 8/13/09
$spacer = ($inc_num_ary[2] != "") ? $inc_num_ary[2] : "";
$scope = $inc_serial . $name_rev . $spacer . $prepend_nature; // set final scope to be inserted to ticket_id
// increment the serial if used
$the_year = date("y");
if ((((int) $inc_num_ary[0]) == 3) && (!($inc_num_ary[5] == $the_year))) { // year style and change?
$inc_num_ary[3] = 1; // roll over and start at 1
$inc_num_ary[5] = $the_year;
} else {
if (((int) $inc_num_ary[0])>0) { // step to next no. if scheme in use
$inc_num_ary[3]++; // do the deed for next use
}
} // end if/else - 10/11/2013
$out_str = base64_encode(serialize ($inc_num_ary)); // 3/2/11
$query = "UPDATE`$GLOBALS[mysql_prefix]settings` SET `value` = '$out_str' WHERE `name` = '_inc_num'";
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename( __FILE__), __LINE__);
// end of serial increment
$facility_id = empty($_POST['frm_facility_id'])? 0 : trim($_POST['frm_facility_id']); // 9/28/09
$rec_facility_id = empty($_POST['frm_rec_facility_id'])? 0 : trim($_POST['frm_rec_facility_id']); // 9/28/09
$portal_user = empty($_POST['frm_portal_user'])? 0: trim($_POST['frm_portal_user']); // 9/10/13
$groups = "," . implode(',', $_POST['frm_group']) . ","; // 6/10/11
if ($facility_id > 0) { // 9/22/09
$query_g = "SELECT * FROM $GLOBALS[mysql_prefix]facilities WHERE `id`= $facility_id LIMIT 1";
$result_g = mysql_query($query_g) or do_error($query_g, 'mysql query failed', mysql_error(),basename( __FILE__), __LINE__);
$row_g = stripslashes_deep(mysql_fetch_array($result_g));
$the_lat = $row_g['lat']; // use facility location
$the_lng = $row_g['lng'];
} else {
$the_lat = quote_smart(trim($_POST['frm_lat'])); // use incident location
$the_lng = quote_smart(trim($_POST['frm_lng']));
}
if ((strlen($the_lat) < 3 ) && (strlen($the_lng) < 3)) { // 1/29/11
$the_lat = $the_lng = 0.999999;
}
// perform db update //9/22/09 added facility capability, 10/1/09 added receiving facility
$by = $_SESSION['user_id'];
$booked_date = (intval(trim($_POST['frm_do_scheduled'])==1))? quote_smart($frm_booked_date): "NULL" ; // 1/2/11, 1/19/10
// 6/26/10
$query = "UPDATE `$GLOBALS[mysql_prefix]ticket` SET
`portal_user`= " . quote_smart(trim($portal_user)) . ",
`contact`= " . quote_smart(trim($_POST['frm_contact'])) .",
`street`= " . quote_smart(trim($_POST['frm_street'])) .",
`address_about`= " . quote_smart(trim($_POST['frm_address_about'])) .",
`city`= " . quote_smart(trim($_POST['frm_city'])) .",
`state`= " . quote_smart(trim($_POST['frm_state'])) . ",
`phone`= " . quote_smart(trim($_POST['frm_phone'])) . ",
`to_address`= " . quote_smart(trim($_POST['frm_to_address'])) . ",
`facility`= " . quote_smart($facility_id ) . ",
`rec_facility`= " . quote_smart($rec_facility_id) . ",
`lat`= " . $the_lat . ",
`lng`= " . $the_lng . ",
`scope`= " . quote_smart(trim($scope)) . ",
`owner`= " . quote_smart(trim($post_frm_owner)) . ",
`severity`= " . quote_smart(trim($_POST['frm_severity'])) . ",
`in_types_id`= " . quote_smart(trim($_POST['frm_in_types_id'])) . ",
`status`=" . quote_smart(trim($_POST['frm_status'])) . ",
`problemstart`=". quote_smart(trim($frm_problemstart)) . ",
`problemend`=". $frm_problemend . ",
`description`= " . quote_smart(trim($_POST['frm_description'] . "\n")) .",
`comments`= " . quote_smart(trim($_POST['frm_comments'])) .",
`nine_one_one`= " . quote_smart(trim($_POST['frm_nine_one_one'])) .",
`booked_date`= " . $booked_date .",
`date`='$now',
`updated`='$now',
`_by` = $by
WHERE ID=" . $id; // 9/10/13
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(),basename( __FILE__), __LINE__);
$tick_stat = $_POST['frm_status']; // 6/10/11
$prob_start = quote_smart(trim($frm_problemstart)); // 6/10/11
// If portal user is set, insert an associated request if one does not already exist for this Ticket 9/10/13
$where = $_SERVER['REMOTE_ADDR']; // 9/10/13
if(($portal_user != NULL) && ($portal_user != 0)) { // 9/10/13
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]requests` WHERE `ticket_id` = " . $id; // 9/10/13
$result = mysql_query($query) or do_error('', 'mysql query failed', mysql_error(), basename( __FILE__), __LINE__); // 9/10/13
if(mysql_affected_rows() == 0) { // 9/10/13
$query = "INSERT INTO `$GLOBALS[mysql_prefix]requests` (
`org`,
`contact`,
`street`,
`city`,
`state`,
`the_name`,
`phone`,
`to_address`,
`orig_facility`,
`rec_facility`,
`scope`,
`description`,
`comments`,
`lat`,
`lng`,
`request_date`,
`status`,
`accepted_date`,
`declined_date`,
`resourced_date`,
`completed_date`,
`closed`,
`requester`,
`ticket_id`,
`_by`,
`_on`,
`_from`
) VALUES (
" . 0 . ",
'" . get_owner($_POST['frm_portal_user']) . "',
" . quote_smart(trim($_POST['frm_street'])) . ",
" . quote_smart(trim($_POST['frm_city'])) . ",
" . quote_smart(trim($_POST['frm_state'])) . ",
" . quote_smart(trim($_POST['frm_contact'])) . ",
" . quote_smart(trim($_POST['frm_phone'])) . ",
" . quote_smart(trim($_POST['frm_to_address'])) . ",
" . quote_smart($facility_id ) . ",
" . quote_smart($rec_facility_id ) . ",
" . quote_smart(trim($name_rev)) . ",
" . quote_smart(trim($_POST['frm_description'] + '\n')) . ",
" . quote_smart(trim($_POST['frm_comments'])) . ",
" . $the_lat . ",
" . $the_lng . ",
" . quote_smart(trim($frm_problemstart)) . ",
'Accepted',
'" . $now . "',
NULL,
NULL,
NULL,
NULL,
" . $portal_user . ",
" . $id . ",
" . $_SESSION['user_id'] . ",
'" . $now . "',
'" . $where . "')";
$result = mysql_query($query) or do_error($query,'mysql_query() failed', mysql_error(), basename( __FILE__), __LINE__); // 9/10/13
}
}
// end of insert request associated with Ticket
// 9/10/13 File Upload support
$print = "";
if ((isset($_FILES['frm_file'])) && ($_FILES['frm_file']['name'] != "")){
$nogoodFile = false;
$blacklist = array(".php", ".phtml", ".php3", ".php4", ".js", ".shtml", ".pl" ,".py");
foreach ($blacklist as $file) {
if(preg_match("/$file\$/i", $_FILES['frm_file']['name'])) {
$nogoodFile = true;
}
}
if(!$nogoodFile) {
$exists = false;
$existing_file = "";
$upload_directory = "./files/";
if (!(file_exists($upload_directory))) {
mkdir ($upload_directory, 0770);
}
chmod($upload_directory, 0770);
$filename = rand(1,999999);
$realfilename = $_FILES["frm_file"]["name"];
$file = $upload_directory . $filename;
// Does the file already exist in the files table
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]files` WHERE `orig_filename` = '" . $realfilename . "'";
$result = mysql_query($query) or do_error($query, $query, mysql_error(), basename( __FILE__), __LINE__);
if(mysql_affected_rows() == 0) { // file doesn't exist already
if (move_uploaded_file($_FILES['frm_file']['tmp_name'], $file)) { // If file uploaded OK
if (strlen(filesize($file)) < 20000000) {
$print .= "";
} else {
$print .= "Attached file is too large!";
}
} else {
$print .= "Error uploading file";
}
} else {
$row = stripslashes_deep(mysql_fetch_assoc($result));
$exists = true;
$existing_file = $row['filename']; // get existing file name
}
$from = $_SERVER['REMOTE_ADDR'];
$filename = ($existing_file == "") ? $filename : $existing_file; // if existing file, use this file and write new db entry with it.
$query_insert = "INSERT INTO `$GLOBALS[mysql_prefix]files` (
`title` , `filename` , `orig_filename`, `ticket_id` , `responder_id` , `facility_id`, `type`, `filetype`, `_by`, `_on`, `_from`
) VALUES (
'" . $_POST['frm_file_title'] . "', '" . $filename . "', '" . $realfilename . "', " . $id . ", 0,
0, 0, '" . $_FILES['frm_file']['type'] . "', $by, '" . $now . "', '" . $from . "'
)";
$result_insert = mysql_query($query_insert) or do_error($query_insert,'mysql_query() failed', mysql_error(), basename( __FILE__), __LINE__);
if($result_insert) { // is the database insert successful
$dbUpdated = true;
} else { // problem with the database insert
$dbUpdated = false;
}
}
} else { // Problem with the file upload
$fileUploaded = false;
}
// End of file upload
foreach ($_POST['frm_group'] as $grp_val) { // 6/10/11
if(test_allocates($id, $grp_val, 1)) {
$query_a = "INSERT INTO `$GLOBALS[mysql_prefix]allocates` (`group` , `type`, `al_as_of` , `al_status` , `resource_id` , `sys_comments` , `user_id`) VALUES
($grp_val, 1, '$now', 1, $id, 'Allocated to Group' , $by)";
$result_a = mysql_query($query_a) or do_error($query_a, 'mysql query failed', mysql_error(),basename( __FILE__), __LINE__);
}
}
// If Major Incident Set
if(array_key_exists('frm_maj_inc', $_POST) && $_POST['frm_maj_inc'] != 0) {
// Delete existing entries to avoid dupes
$query = "DELETE FROM `$GLOBALS[mysql_prefix]mi_x` WHERE `ticket_id` = '$id'";
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
// Insert new entry
$maj_inc = intval($_POST['frm_maj_inc']);
$query = "INSERT INTO `$GLOBALS[mysql_prefix]mi_x` (
`mi_id`,
`ticket_id`)
VALUES (
" . $maj_inc . ",
" . $id . ")";
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(),basename( __FILE__), __LINE__);
}
do_log($GLOBALS['LOG_INCIDENT_OPEN'], $id);
if (intval($facility_id) > 0) { //9/22/09, 10/1/09, 3/24/10
do_log($GLOBALS['LOG_FACILITY_INCIDENT_OPEN'], $id, '' ,0 ,$facility_id); // - 7/11/10
}
if (intval($rec_facility_id) > 0) {
do_log($GLOBALS['LOG_CALL_REC_FAC_SET'], $id, 0 ,0 ,0 ,$rec_facility_id); // 6/20/10 - 7/11/10
}
$ret_arr = array();
$ret_arr[0] = $name_rev;
$ret_arr[1] = $scope;
return $ret_arr;
} // end function updt ticket()
$ticket_name_ary = updt_ticket(trim($_POST['ticket_id'])); // 1/25/09
$ticket_name = $ticket_name_ary[0];
$ticket_scope = $ticket_name_ary[1];
$addrs = notify_user($_POST['ticket_id'],$GLOBALS['NOTIFY_TICKET_OPEN']); // returns array of adddr's for notification, or FALSE
if ($addrs) { // any addresses? 8/28/13
$theTo = implode("|", array_unique($addrs));
$theText = "New " . get_text("Incident");
mail_it ($theTo, "", $theText, $_POST['ticket_id'], 1 );
} // end if/else ($addrs)
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD><TITLE>Tickets - Add Module</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" />
<META HTTP-EQUIV="Expires" CONTENT="0" />
<META HTTP-EQUIV="Cache-Control" CONTENT="NO-CACHE" />
<META HTTP-EQUIV="Pragma" CONTENT="NO-CACHE" />
<META HTTP-EQUIV="Content-Script-Type" CONTENT="application/x-javascript" />
<META HTTP-EQUIV="Script-date" CONTENT="<?php print date("n/j/y G:i", filemtime(basename(__FILE__)));?>" /> <!-- 7/7/09 -->
<LINK REL=StyleSheet HREF="stylesheet.php?version=<?php print time();?>" TYPE="text/css"> <!-- 3/15/11 -->
<link rel="stylesheet" href="./js/leaflet/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="./js/leaflet/leaflet.ie.css" />
<![endif]-->
<link rel="stylesheet" href="./js/Control.Geocoder.css" />
<SCRIPT TYPE="application/x-javascript" SRC="./js/jss.js"></SCRIPT>
<SCRIPT SRC="./js/misc_function.js" TYPE="application/x-javascript"></SCRIPT> <!-- 9/14/12 -->
<SCRIPT SRC="./js/jscolor/jscolor.js"></SCRIPT> <!-- 9/14/12 -->
<?php
if ((intval(get_variable('broadcast') == 1)) && ($_SESSION['good_internet'])) {
require_once('./incs/socket2me.inc.php'); // 5/22/2013
}
?>
</HEAD>
<?php
if($in_win) {
if((intval(get_variable('auto_route'))==1) && ($in_win == 0)) {
$onloadStr = "setTimeout(function(){ document.to_routes.submit();}, 8000);";
} else if((intval(get_variable('auto_route'))==0) && ($in_win == 0)) {
// $onloadStr = "setTimeout(function(){ document.to_main.submit();}, 8000);";
$onloadStr = "";
}
} else {
$onloadStr = "";
}
?>
<BODY onLoad = "<?php print $onloadStr;?>">
<?php
$now = time() - (intval(get_variable('delta_mins')*60)); // 6/20/10
print "<BR /><BR /><BR /><CENTER><FONT CLASS='header'>Ticket: '{$ticket_scope} ' ({$ticket_name}) Added by '{$_SESSION['user_id']}' at " . date(get_variable("date_format"),$now) . "</FONT></CENTER><BR /><BR />";
if($in_win == 1 || get_variable("calltaker_mode") == 1) {
?>
<CENTER><SPAN id='cont_but' class='plain text' style='float: none;' onMouseover='do_hover(this.id);' onMouseout='do_plain(this.id);' onClick='window.close();'>FINISH</SPAN></CENTER>
<?php
} else {
?>
<FORM NAME='to_main' METHOD='post' ACTION='main.php'></FORM>
<CENTER>
<SPAN id='sub_but' class='plain text' style='float: none;' onMouseover='do_hover(this.id);' onMouseout='do_plain(this.id);' onClick='document.to_main.submit();'>Main</SPAN><BR />
<BR />
<FORM NAME='to_routes' METHOD='get' ACTION='<?php print $_SESSION['routesfile'];?>'>
<INPUT TYPE='hidden' NAME='ticket_id' VALUE='<?php print $_POST['ticket_id'];?>' />
</FORM>
<SPAN id='sub_but' class='plain text' style='float: none;' onMouseover='do_hover(this.id);' onMouseout='do_plain(this.id);' onClick='document.to_routes.submit();'>Routes</SPAN>
</CENTER>
<?php
}
exit();
} // end if ($_GET['add'] ...
// ==============================================
else {
if (is_guest() && !get_variable('guest_add_ticket')) { // 6/25/10
print '<FONT CLASS="warn">Guest/member users may not add tickets on this system. Contact administrator for further information.</FONT>';
exit();
}
$res_row = get_res_row(); // 11/5/10
$ticket_id = $res_row['id'];
// $hints = get_hints("a");
$nature = get_text("Nature"); // 12/1/10 {$nature}
$disposition = get_text("Disposition"); // {$disposition}
$patient = get_text("Patient"); // {$patient}
$incident = get_text("Incident"); // {$incident}
$incidents = get_text("Incidents"); // {$incidents}
$titles = array(); // 2/1/11
$query = "SELECT `tag`, `hint` FROM `$GLOBALS[mysql_prefix]hints`";
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(),basename( __FILE__), __LINE__);
while ($row =stripslashes_deep(mysql_fetch_assoc($result))) {
$titles[trim($row['tag'])] = trim($row['hint']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD><TITLE>Tickets - Add Module</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" />
<META HTTP-EQUIV="Expires" CONTENT="0" />
<META HTTP-EQUIV="Cache-Control" CONTENT="NO-CACHE" />
<META HTTP-EQUIV="Pragma" CONTENT="NO-CACHE" />
<META HTTP-EQUIV="Content-Script-Type" CONTENT="application/x-javascript" />
<LINK REL=StyleSheet HREF="stylesheet.php?version=<?php print time();?>" TYPE="text/css">
<link rel="stylesheet" href="./js/leaflet/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="./js/leaflet/leaflet.ie.css" />
<![endif]-->
<link rel="stylesheet" href="./js/Control.Geocoder.css" />
<link rel="stylesheet" href="./js/leaflet-openweathermap.css" />
<SCRIPT TYPE="application/x-javascript" SRC="./js/jss.js"></SCRIPT>
<SCRIPT TYPE="application/x-javascript" SRC="./js/misc_function.js"></SCRIPT>
<SCRIPT SRC="./js/suggest.js" TYPE="application/x-javascript"></SCRIPT> <!-- 2/20/11 -->
<SCRIPT TYPE="application/x-javascript" SRC="./js/domready.js"></script>
<SCRIPT SRC="./js/messaging.js" TYPE="application/x-javascript"></SCRIPT>
<script src="./js/proj4js.js"></script>
<script src="./js/proj4-compressed.js"></script>
<script src="./js/leaflet/leaflet.js"></script>
<script src="./js/proj4leaflet.js"></script>
<script src="./js/leaflet/KML.js"></script>
<script src="./js/leaflet-openweathermap.js"></script>
<script src="./js/esri-leaflet.js"></script>
<script src="./js/osopenspace.js"></script>
<script src="./js/Control.Geocoder.js"></script>
<?php
if ($_SESSION['internet']) {
$api_key = get_variable('gmaps_api_key');
$key_str = (strlen($api_key) == 39)? "key={$api_key}&" : false;
if($key_str) {
if($https) {
?>
<script src="https://maps.google.com/maps/api/js?<?php print $key_str;?>"></script>
<script src="./js/Google.js"></script>
<?php
} else {
?>
<script src="http://maps.google.com/maps/api/js?<?php print $key_str;?>"></script>
<script src="./js/Google.js"></script>
<?php
}
}
}
?>
<SCRIPT SRC="./js/usng.js" TYPE="application/x-javascript"></SCRIPT>
<SCRIPT SRC='./js/jscoord.js' TYPE="application/x-javascript"></SCRIPT> <!-- coordinate conversion 12/10/10 -->
<SCRIPT SRC="./js/lat_lng.js" TYPE="application/x-javascript"></SCRIPT> <!-- 11/8/11 -->
<SCRIPT SRC="./js/geotools2.js" TYPE="application/x-javascript"></SCRIPT> <!-- 11/8/11 -->
<SCRIPT SRC="./js/osgb.js" TYPE="application/x-javascript"></SCRIPT> <!-- 11/8/11 -->
<script type="application/x-javascript" src="./js/osm_map_functions.js"></script>
<script type="application/x-javascript" src="./js/L.Graticule.js"></script>
<script type="application/x-javascript" src="./js/leaflet-providers.js"></script>
<SCRIPT>
window.onresize=function(){set_size()};
</SCRIPT>
<?php
require_once('./incs/all_forms_js_variables.inc.php');
?>
<SCRIPT>
var protocols = <?php echo json_encode($protocols); ?>;
var theBounds = <?php echo json_encode(get_tile_bounds("./_osm/tiles")); ?>;
var states_arr = <?php echo json_encode($states); ?>;
var colors = new Array ('odd', 'even');
var viewportwidth;
var viewportheight;
var fieldwidth;
var smallfieldwidth;
var mapwidth;
var mapheight;
var outerwidth;
var outerheight;
var colwidth;
var colheight;
var leftcolwidth;
var winleftcolwidth;
var rightcolwidth
var isinwin = <?php print $in_win;?>;
var fields = ["about",
"street",
"scope",
"toaddress",
"loc_warnings",
"description",
"comments",
"contact",
"filename",
"sel_bldg",
"911",
"frm_phone",
"proto_cell"];
var medfields = ["facy",
"recfacy",
"my_txt",
"sel_in_types_id",
"severity",
"signals",
"signals2",
"portal_user",
"statusSelect",
"sel_status",
"sel_maj_inc"];
var smallfields = ["show_lat", "show_lng", "griddisp"];
function set_size() {
if (typeof window.innerWidth != 'undefined') {
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
viewportwidth = document.documentElement.clientWidth,
viewportheight = document.documentElement.clientHeight
} else {
viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
viewportheight = document.getElementsByTagName('body')[0].clientHeight
}
if(window.isinwin) {set_fontsizes(viewportwidth, "popup");} else {set_fontsizes(viewportwidth, "fullscreen");}
if(window.isinwin) {mapWidth = viewportwidth * .95;} else {mapWidth = viewportwidth * .40;}
mapHeight = viewportheight * .55;
if(window.isinwin) {outerwidth = viewportwidth * .95;} else {outerwidth = viewportwidth * .99;}
outerheight = viewportheight * .95;
if(window.isinwin) {colwidth = outerwidth;} else {colwidth = outerwidth * .40;}
colheight = outerheight * .95;
leftcolwidth = viewportwidth * .45;
winleftcolwidth = viewportwidth * .90;
rightcolwidth = viewportwidth * .35;
fieldwidth = leftcolwidth * .45;
medfieldwidth = colwidth * .20;
smallfieldwidth = colwidth * .10;
if($('outer')) {$('outer').style.width = outerwidth + "px";}
if($('outer')) {$('outer').style.height = outerheight + "px";}
if($('leftcol')) {$('leftcol').style.width = leftcolwidth + "px";}
if($('leftcol_inwin')) {$('leftcol_inwin').style.width = winleftcolwidth + "px";}
if($('leftcol')) {$('leftcol').style.height = colheight + "px";}
if($('rightcol')) {$('rightcol').style.width = colwidth + "px";}
if($('rightcol')) {$('rightcol').style.height = colheight + "px";}
if($('map_canvas')) {$('map_canvas').style.width = mapWidth + "px";}
if($('map_canvas')) {$('map_canvas').style.height = mapHeight + "px";}
if($('map_caption')) {$('map_caption').style.width = mapWidth + "px";}
for (var i = 0; i < fields.length; i++) {
if($(fields[i])) {$(fields[i]).style.width = fieldwidth + "px";}
}
for (var i = 0; i < medfields.length; i++) {
if($(medfields[i])) {$(medfields[i]).style.width = medfieldwidth + "px";}
}
for (var i = 0; i < smallfields.length; i++) {
if($(smallfields[i])) {$(smallfields[i]).style.width = smallfieldwidth + "px";}
}
map.invalidateSize();
}
function get_new_colors() { // 5/4/11
window.location.href = '<?php print basename(__FILE__);?>';
}
<?php
if(!$in_win) {
?>
parent.frames["upper"].$("whom").innerHTML = "<?php print $_SESSION['user'];?>";
parent.frames["upper"].$("level").innerHTML = "<?php print get_level_text($_SESSION['level']);?>";
parent.frames["upper"].$("script").innerHTML = "<?php print LessExtension(basename( __FILE__));?>";
<?php
}
?>
var lat_lng_frmt = <?php print get_variable('lat_lng'); ?>; // 9/9/08
var starting = false;
starting=false; // 12/16/09
function do_hist_win() {
if(starting) {return;}
var goodno = document.add.frm_phone.value.replace(/\D/g, "" ); // strip all non-digits - 1/18/09
<?php
if (get_variable("locale") ==0) { // USA only
?>
if (goodno.length<10) {
alert("10-digit phone no. required - any format");
return;}
<?php
} // end locale check
?>
starting=true;
var url = "call_hist.php?frm_phone=" + goodno;
newwindow_c_h=window.open(url, "Call_hist", "titlebar, resizable=1, scrollbars, height=640,width=760,status=0,toolbar=0,menubar=0,location=0, left=50,top=150,screenX=100,screenY=300");
if (isNullOrEmpty(newwindow_c_h)) {
starting = false;
alert ("Call history operation requires popups to be enabled. Please adjust your browser options.");
return;
}
newwindow_c_h.focus();
starting = false;
} // function do hist_win()
function writeConsole(content) {
top.consoleRef=window.open('','myconsole',
'width=800,height=250' +',menubar=0' +',toolbar=0' +',status=0' +',scrollbars=1' +',resizable=1')
top.consoleRef.document.writeln('<html><head><title>Console</title></head>'
+'<body bgcolor=white onLoad="self.focus()">' +content +'</body></html>'
) // end top.consoleRef.document.writeln()
top.consoleRef.document.close();
} // end function writeConsole(content)
function getRes() {
return window.screen.width + ' x ' + window.screen.height;
}
var request;
var tab1contents // info window contents - first/only tab
var thePoint;
var baseIcon;
var cross;
function do_usng(theForm) { // 8/23/08, 12/5/10
theForm.frm_ngs.value = LLtoUSNG(theForm.frm_lat.value, theForm.frm_lng.value, 5); // US NG
}
function do_utm (theForm) {
var ll_in = new LatLng(parseFloat(theForm.frm_lat.value), parseFloat(theForm.frm_lng.value));
var utm_out = ll_in.toUTMRef().toString();
temp_ary = utm_out.split(" ");
theForm.frm_ngs.value = (temp_ary.length == 3)? temp_ary[0] + " " + parseInt(temp_ary[1]) + " " + parseInt(temp_ary[2]) : "";
}
function do_osgb (theForm) {
theForm.frm_ngs.value = LLtoOSGB(theForm.frm_lat.value, theForm.frm_lng.value);
if(document.wiz_add) {document.wiz_add.wiz_frm_ngs.value = LLtoOSGB(theForm.frm_lat.value, theForm.frm_lng.value);}
}
function do_cancel(the_form) { // 6/9/11
try {
window.opener.frames["upper"].new_signal_off();
}
catch(e) {
}
try {
parent.frames["upper"].new_signal_off();
}
catch(e) {
}
var params = "ticket_id=" + the_form.ticket_id.value;
sendRequest (the_form, 'cancel_add.php',handleResult_can, params); // (my_form, url,callback,postData)) 10/15/08
} // end function do cancel()
function handleResult_can(req) { // the called-back function
<?php
if($istest) {print "\t\t\talert('HTTP error ' + req.status + '" . __LINE__ . "');\n";}
?>
<?php
if ($in_win) {
?>
window.close();
<?php
}
else {
?>
parent.frames['upper'].light_butt('main'); // top frame button
history.back();
<?php
} // end else
?>
} // end function handleResult_can(req)
// *********************************************************************
// "Juan Wzzzzz;(123) 456-9876;1689 Abcd St;Abcdefghi;MD;16701;99.013297;-88.544775;"
// 1 2 3 4 5 6 7 8
function isOKCoord (theVal) { // 10/3/2015
return (
( ! ( isNaN ( parseFloat ( theVal ) ) ) ) &&
( theVal != "<?php echo $GLOBALS['NM_LAT_VAL'];?>" )
);
} // end function
function handleResult(req) { // the called-back phone lookup function
// alert(754);
var result=req.responseText.split(";"); // parse semic-separated return string
$('repeats').innerHTML = "(" + result[0].trim() + ")"; // prior calls this phone no. - 9/29/09
if (!(result.length>2)) {
<?php
if (get_variable("locale") ==0) { // USA only // 10/2/09
?>
alert("lookup failed");
<?php
}
?>
} else { // 10/2/2015
document.add.frm_contact.value=result[1].trim(); // name
document.add.frm_phone.value=result[2].trim(); // phone
document.add.frm_street.value=result[3].trim(); // street
document.add.frm_city.value=result[4].trim(); // city
document.add.frm_state.value=result[5].trim(); // state
// document.add.frm_zip.value=result[6].trim(); // frm_zip - unused
if (result[9].length > 0) { // misc constituents information - 3/13/10
$('td_misc').innerHTML = ' ' + result[9].trim();
$('tr_misc').style.display='';
pt_to_map (document.add, result[7].trim(), result[8].trim()); // 1/19/09
}
// else if ((result[3].length>0) && (result[4].length>0) && (result[5].length>0)) { // 4/27/10
else if ( isOKCoord ( result[7].trim() ) && ( isOKCoord ( result[8].trim() ) ) ) { // 10/3/2015
pt_to_map (document.add, result[7].trim(), result[8].trim()); // (my_form, lat, lng) - 10/2/2015
}
} // end else ...
} // end function handleResult()
function phone_lkup(){
var goodno = document.add.frm_phone.value.replace(/\D/g, "" ); // strip all non-digits - 1/18/09
// alert(goodno);
<?php
if (get_variable("locale") ==0) { // USA only
?>
if (goodno.length<10) {
alert("10-digit phone no. required - any format");
return;}
<?php
} // end locale check
?>
var params = "phone=" + URLEncode(goodno);
// alert(800);
// sendRequest (document.add, 'wp_lkup.php',handleResult, params); //1/17/09 - (url,callback,postData)
sendRequest ( 'wp_lkup.php', handleResult, params); // 10/1/2015 - (url,callback,postData)
}
// *********************************************************************
function contains(array, item) {
for (var i = 0, I = array.length; i < I; ++i) {
if (array[i] == item) return true;
}
return false;
}
function do_lat (lat) { // 9/14/08
document.forms[0].frm_lat.value=lat.toFixed(6); // 9/9/08
document.forms[0].show_lat.disabled=false;
document.forms[0].show_lat.value=do_lat_fmt(document.forms[0].frm_lat.value);
document.forms[0].show_lat.disabled=true;
if(document.wiz_add) {
document.wiz_add.wiz_show_lat.disabled=false;
document.wiz_add.wiz_show_lat.value=do_lat_fmt(document.forms[0].frm_lat.value);
document.wiz_add.wiz_show_lat.disabled=true;
}
}
function do_lng (lng) {