-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_nm.php
1801 lines (1588 loc) · 72.2 KB
/
add_nm.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");
}
/*
if (!($_SESSION['internet'])) { // 8/22/10
header("Location: add_nm.php");
}
*/
require_once('incs/functions.inc.php'); //7/28/10
do_login(basename(__FILE__));
$gmaps = $_SESSION['internet'];
if($istest) {print "_GET"; dump($_GET);}
if($istest) {print "_POST"; dump($_POST);}
/*
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
5/5/11 added get_new_colors()
6/4/2013 added broadcast()
10/11/2013 - corrected auto incident numbering - relocated else {} closure
*/
$api_key = get_variable('gmaps_api_key');
$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
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` , `city` , `state` , `phone` , `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 , '" . $GLOBALS['STATUS_RESERVED'] . "', '0', '0', NULL, NULL, $by
)";
$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, $NOTIFY_TICKET;
$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=0;}
$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 ($_POST['frm_status'] == 3) {
$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
$name_rev = $_POST['frm_scope'];
if ($inc_num_ary[0] == 0 ) { // no auto numbering scheme
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 = $id . "/" . $_POST['frm_scope'];
break;
case 2: /* append */
$name_rev = $_POST['frm_scope'] . "/" . $id;
break;
default: /* error???? */
$name_rev = " error error error ";
} // end switch
// 8/23/08, 9/20/08, 8/13/09
} // end if()
$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
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 ((($the_lat == 0) && ($the_lng == 0)) || (($the_lat == "") && ($the_lng == ""))) {
$the_lat = 0.999999;
$the_lng = 0.999999;
}
// perform db update //9/22/09 added facility capability, 10/1/09 added receiving facility
@session_start();
$by = $_SESSION['user_id'];
// $booked_date = empty($frm_booked_date)? "NULL" : quote_smart(trim($frm_booked_date)) ; // 6/20/10
$booked_date = (intval($frm_do_scheduled)==1)? quote_smart(trim($frm_booked_date)): "NULL" ; // 1/1/11
// 6/26/10
$query = "UPDATE `$GLOBALS[mysql_prefix]ticket` SET
`contact`= " . quote_smart(trim($_POST['frm_contact'])) .",
`street`= " . quote_smart(trim($_POST['frm_street'])) .",
`city`= " . quote_smart(trim($_POST['frm_city'])) .",
`state`= " . quote_smart(trim($_POST['frm_state'])) . ",
`phone`= " . quote_smart(trim($_POST['frm_phone'])) . ",
`facility`= " . quote_smart($facility_id ) . ",
`rec_facility`= " . quote_smart($rec_facility_id) . ",
`lat`= " . $the_lat . ",
`lng`= " . $the_lng . ",
`scope`= " . quote_smart(trim($name_rev)) . ",
`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'])) .",
`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";
$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
}
$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 = serialize ($inc_num_ary);
$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__);
return $name_rev;
} // end function updt ticket()
$ticket_name = updt_ticket(trim($_POST['ticket_id'])); // 1/25/09
?>
<!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="default.css" TYPE="text/css" />
<SCRIPT>
<?php
$addrs = notify_user($_POST['ticket_id'],$GLOBALS['NOTIFY_TICKET_CHG']); // returns array of adddr's for notification, or FALSE
if ($addrs) { // any addresses?
// snap(basename( __FILE__) . __LINE__, count($addrs));
?>
function get_new_colors() { // 5/5/11
window.location.href = '<?php print basename(__FILE__);?>';
}
function do_notify() {
var theAddresses = '<?php print implode("|", array_unique($addrs));?>'; // drop dupes
var theText= "TICKET - New: ";
var theId = '<?php print $_POST['ticket_id'];?>';
// mail_it ($to_str, $text, $theId, $text_sel=1;, $txt_only = FALSE)
var params = "frm_to="+ escape(theAddresses) + "&frm_text=" + escape(theText) + "&frm_ticket_id=" + theId + "&text_sel=1"; // ($to_str, $text, $ticket_id) 10/15/08
sendRequest ('mail_it.php',handleResult, params); // ($to_str, $text, $ticket_id) 10/15/08
} // end function do notify()
function handleResult(req) { // the 'called-back' function
<?php
if($istest) {print "\t\t\talert('HTTP error ' + req.status + '" . __LINE__ . "');\n";}
?>
}
function sendRequest(url,callback,postData) {
var req = createXMLHTTPObject();
if (!req) return;
var method = (postData) ? "POST" : "GET";
req.open(method,url,true);
if (postData)
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
req.onreadystatechange = function () {
if (req.readyState != 4) return;
if (req.status != 200 && req.status != 304) {
<?php
if($istest) {print "\t\t\talert('HTTP error ' + req.status + '" . __LINE__ . "');\n";}
?>
return;
}
callback(req);
}
if (req.readyState == 4) return;
req.send(postData);
}
var XMLHttpFactories = [
function () {return new XMLHttpRequest() },
function () {return new ActiveXObject("Msxml2.XMLHTTP") },
function () {return new ActiveXObject("Msxml3.XMLHTTP") },
function () {return new ActiveXObject("Microsoft.XMLHTTP") }
];
function createXMLHTTPObject() {
var xmlhttp = false;
for (var i=0;i<XMLHttpFactories.length;i++) {
try { xmlhttp = XMLHttpFactories[i](); }
catch (e) { continue; }
break;
}
return xmlhttp;
}
<?php
} // end if ($addrs)
else {
?>
function do_notify() { // dummy
return;
}
<?php
} // end if/else ($addrs)
$form_name = (intval(get_variable('auto_route'))==1)? "to_routes" : "to_main";
?>
</SCRIPT>
</HEAD>
<BODY onLoad = "do_notify();document.<?php print $form_name;?>.submit();">
<?php
$now = time() - (intval(get_variable('delta_mins')*60)); // 6/20/10
print "<BR /><BR /><BR /><CENTER><FONT CLASS='header'>Ticket: '{$ticket_name} ' Added by '{$_SESSION['user_id']}' at " . date(get_variable("date_format"),$now) . "</FONT></CENTER><BR /><BR />";
?>
<FORM NAME='to_main' METHOD='post' ACTION='main.php'>
<CENTER><INPUT TYPE='submit' VALUE='Main' />
</FORM>
<FORM NAME='to_routes' METHOD='get' ACTION='routes.php'>
<INPUT TYPE='hidden' NAME='ticket_id' VALUE='<?php print $_POST['ticket_id'];?>' />
<INPUT TYPE='submit' VALUE='Routes' /></CENTER>
</FORM>
<?php
} // 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(); // 1/1/11
$titles["a1"] = "Location - type in location in fields, click location on map or use *Located at Facility* menu below ";
$titles["a2"] = "City - defaults to default city set in configuration. Type in City if required";
$titles["a3"] = "State - US State or non-US Country code e.g. UK for United Kingdom";
$titles["a4"] = "Phone number - for US only, you can use the lookup button to get the callers name and location using the White Pages";
$titles["a5"] = "{$incident} {$nature} or Type - Available types are set in in_types table in the configuration";
$titles["a6"] = "{$incident} Priority - Normal, Medium or High. Affects order and coloring of {$incidents} on Situation display";
$titles["a7"] = "{$incident} Protocol - this will show automatically if a protocol is set for the {$incident} Type in the configuration";
$titles["a8"] = "Synopsis - Details about the {$incident}, ensure as much detail as possible is completed";
$titles["a9"] = "911 contact information";
$titles["a10"] = "Caller reporting the {$incident}";
$titles["a11"] = "{$incident} Name - Partially completed and prepend or append incident ID depending on setting. Type in an easily identifiable name.";
$titles["a12"] = "Scheduled Date. Must be set if {$incident} Status is *Scheduled*. Sets date and time for a future booked {$incident}, mainly used for non immediate {$patient} transport. Click on Radio button to show date fields.";
$titles["a13"] = "Use the first dropdown menu to select the Facility where the {$incident} is located at, use the second dropdown menu to select the facility where persons from the {$incident} will be received";
$titles["a14"] = "Run-start, {$incident} start time. Defaults to current date and time or edit by clicking padlock icon to enable date & time fields";
$titles["a15"] = "{$incident} Status - Open or Closed or set to Scheduled for future booked calls";
$titles["a16"] = "Run-end, {$incident} end time. When {$incident} is closed, click on radio button which will enable date & time fields";
$titles["a17"] = "Disposition - additional comments about {$incident} ";
$titles["a18"] = "{$incident} Lat/Lng - set by clicking on the map for the location or by selecting location with the address fields.";
?>
<!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="default.css" TYPE="text/css" />
<?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/misc_function.js" TYPE="application/x-javascript"></SCRIPT> <!-- 7/22/10 -->
<SCRIPT>
var colors = new Array ('odd', 'even');
function ck_frames() { // onLoad = "ck_frames()"
return;
if(self.location.href==parent.location.href) {
self.location.href = 'index.php';
}
/* document.onkeypress=function(e){
var e=window.event || e
alert("CharCode value: "+e.charCode)
alert("Character: "+String.fromCharCode(e.charCode))
}
*/
} // end function ck_frames()
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__));?>";
var lat_lng_frmt = <?php print get_variable('lat_lng'); ?>; // 9/9/08
function $() { // 2/11/09
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {
var element = arguments[i];
if (typeof element == 'string')
element = document.getElementById(element);
if (arguments.length == 1)
return element;
elements.push(element);
}
return elements;
}
function isNullOrEmpty(str) {
if (null == str || "" == str) {return true;} else { return false;}
}
var starting = false;
function sv_win(theForm) { // 2/11/09
if(starting) {return;} // dbl-click proof
starting = true;
var thelat = theForm.frm_lat.value;
var thelng = theForm.frm_lng.value;
var url = "street_view.php?thelat=" + thelat + "&thelng=" + thelng;
newwindow_sl=window.open(url, "sta_log", "titlebar=no, location=0, resizable=1, scrollbars, height=450,width=640,status=0,toolbar=0,menubar=0,location=0, left=100,top=300,screenX=100,screenY=300");
if (!(newwindow_sl)) {
alert ("Street view operation requires popups to be enabled. Please adjust your browser options - or else turn off the Call Board option.");
return;
}
newwindow_sl.focus();
starting = false;
} // end function sv win()
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
function chknum(val) {
return ((val.trim().replace(/\D/g, "")==val.trim()) && (val.trim().length>0));}
function chkval(val, lo, hi) {
return (chknum(val) && !((val> hi) || (val < lo)));}
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 do_coords(inlat, inlng) { //9/14/08
if((inlat.length==0)||(inlng.length==0)) {return;}
var str = inlat + ", " + inlng + "\n";
str += ll2dms(inlat) + ", " +ll2dms(inlng) + "\n";
str += lat2ddm(inlat) + ", " +lng2ddm(inlng);
alert(str);
}
function ll2dms(inval) { // lat/lng to degr, mins, sec's - 9/9/08
var d = new Number(Math.abs(inval));
d = Math.floor(d);
var mi = (Math.abs(inval)-d)*60; // fraction * 60
var m = Math.floor(mi) // min's as fraction
var si = (mi-m)*60; // to sec's
var s = si.toFixed(1);
return d + '\260 ' + Math.abs(m) +"' " + Math.abs(s) + '"';
}
function lat2ddm(inlat) { // lat to degr, dec.min's - 9/9/089/7/08
var x = new Number(Math.abs(inlat));
var degs = Math.floor(x); // degrees
var mins = ((Math.abs(x-degs)*60).toFixed(1));
var nors = (inlat>0.0)? " N":" S";
return degs + '\260' + mins +"'" + nors;
}
function lng2ddm(inlng) { // lng to degr, dec.min's - 9/9/089/7/08
var x = new Number(Math.abs(inlng));
var degs = Math.floor(x); // degrees
var mins = ((Math.abs(x-degs)*60).toFixed(1));
var eorw = (inlng>0.0)? " E":" W";
return degs + '\260' + mins +"'" + eorw;
}
function do_lat_fmt(inlat) { // 9/9/08
switch(lat_lng_frmt) {
case 0:
return inlat;
break;
case 1:
return ll2dms(inlat);
break;
case 2:
return lat2ddm(inlat);
break;
default:
alert ( "error 518");
}
}
function do_lng_fmt(inlng) {
switch(lat_lng_frmt) {
case 0:
return inlng;
break;
case 1:
return ll2dms(inlng);
break;
case 2:
return lng2ddm(inlng);
break;
default:
alert ("error 534");
}
}
var map; // note globals
var geocoder = null;
var rev_coding_on; // 11/01/09
// geocoder = new GClientGeocoder();
var request;
var querySting; // will hold the POSTed data
var tab1contents // info window contents - first/only tab
var grid = false; // toggle
var thePoint;
var baseIcon;
var cross;
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;
}
function toglGrid() { // toggle
grid = !grid;
if (!grid) { // check prior value
map.clearOverlays();
}
else {
map.closeInfoWindow();
map.addOverlay(new LatLonGraticule());
}
if (thePoint) {map.addOverlay(new GMarker(thePoint));} // restore it
} // end function toglGrid()
function clearmap(){
<?php
if (!($gmaps)) {
print"\n\t return;\n";
}
?>
map.clearOverlays();
load(<?php echo get_variable('def_lat'); ?>, <?php echo get_variable('def_lng'); ?>, <?php echo get_variable('def_zoom'); ?>);
if (grid) {map.addOverlay(new LatLonGraticule());}
}
function do_marker(lat, lng, zoom) { // 9/16/08 - 12/6/08
map.clearOverlays();
var center = isNullOrEmpty(lat)? GLatLng(map.getCenter()) : new GLatLng(lat, lng);
var myzoom = isNullOrEmpty(zoom)? map.getZoom(): zoom;
map.setCenter(center, myzoom);
thisMarker = new GMarker(center, {icon: cross}); // 9/16/08
map.addOverlay(thisMarker);
}
function domap() { // called from phone, addr lookups
map = new GMap2($('map'));
<?php
$maptype = get_variable('maptype'); // 08/02/09
switch($maptype) {
case "1":
break;
case "2":?>
map.setMapType(G_SATELLITE_MAP);<?php
break;
case "3":?>
map.setMapType(G_PHYSICAL_MAP);<?php
break;
case "4":?>
map.setMapType(G_HYBRID_MAP);<?php
break;
default:
print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />";
}
?>
$("map").style.backgroundImage = "url(./markers/loading.jpg)";
// map.addControl(new GSmallMapControl());
map.setUIToDefault(); // 8/13/10
map.addControl(new GMapTypeControl());
<?php print (get_variable('terrain') == 1)? "\t\tmap.addMapType(G_PHYSICAL_MAP);\n" : "";?>
// map.addMapType(G_SATELLITE_3D_MAP);
map.setCenter(new GLatLng(document.add.frm_lat.value, document.add.frm_lng.value), <?php echo get_variable('def_zoom'); ?>); // larger # => tighter zoom
map.addControl(new GOverviewMapControl());
map.enableScrollWheelZoom();
do_marker(null, null, null) ; // 12/6/08
var sep = (document.add.frm_street.value=="")? "": ", ";
var tab1contents = "<B>" + document.add.frm_contact.value + "</B>" +
"<BR/>"+document.add.frm_street.value + sep +
document.add.frm_city.value +" " +
document.add.frm_state.value;
GEvent.addListener(map, "click", function(marker, point) { // lookup
if (marker) {
map.removeOverlay(marker);
// document.add.frm_lat.disabled=document.add.frm_lat.disabled=false;
document.add.frm_lat.value=document.add.frm_lng.value="";
// document.add.frm_lat.disabled=document.add.frm_lat.disabled=true;
if (grid) {map.addOverlay(new LatLonGraticule());}
}
if (point) {
map.clearOverlays();
do_lat (point.lat()) // display
do_lng (point.lng())
do_grids(document.add);
map.addOverlay(new GMarker(point)); // GLatLng.
map.openInfoWindowHtml(point,tab1contents);
if (grid) {map.addOverlay(new LatLonGraticule());}
}
getAddress(marker, point); // 10/13/09
}); // end GEvent.addListener()
if (grid) {map.addOverlay(new LatLonGraticule());}
$("lock_p").style.visibility = "visible";
} // end function do map()
function load(the_lat, the_lng, the_zoom) { // onLoad function - 4/28/09
<?php
if(!($gmaps)) {
print "\n\t return;\n";
}
?>
if (GBrowserIsCompatible()) {
function drawCircle(lng,lat,radius) { // drawCircle(-87.628092,41.881906,2);
var cColor = "#3366ff";
var cWidth = 2;
var Cradius = radius;
var d2r = Math.PI/180;
var r2d = 180/Math.PI;
var Clat = (Cradius/3963)*r2d;
var Clng = Clat/Math.cos(lat*d2r);
var Cpoints = [];
for (var i=0; i < 33; i++) {
var theta = Math.PI * (i/16);
Cx = lng + (Clng * Math.cos(theta));
Cy = lat + (Clat * Math.sin(theta));
var P = new GPoint(Cx,Cy); // note long, lat order
Cpoints.push(P);
};
map.addOverlay(new GPolyline(Cpoints,cColor,cWidth));
}
map = new GMap2($('map'));
<?php
$maptype = get_variable('maptype'); // 08/02/09
switch($maptype) {
case "1":
break;
case "2":?>
map.setMapType(G_SATELLITE_MAP);<?php
break;
case "3":?>
map.setMapType(G_PHYSICAL_MAP);<?php
break;
case "4":?>
map.setMapType(G_HYBRID_MAP);<?php
break;
default:
print "ERROR in " . basename(__FILE__) . " " . __LINE__ . "<BR />";
}
?>
// map.addControl(new GSmallMapControl());
map.setUIToDefault(); // 8/13/10
map.addControl(new GMapTypeControl());
<?php print (get_variable('terrain') == 1)? "\t\tmap.addMapType(G_PHYSICAL_MAP);\n" : "";?>
baseIcon = new GIcon(); //
baseIcon.iconSize=new GSize(32,32);
baseIcon.iconAnchor=new GPoint(16,16);
cross = new GIcon(baseIcon, "./markers/crosshair.png", null);
do_marker(the_lat, the_lng, the_zoom); // 12/6/08
GEvent.addListener(map, "click", function(marker, point) {
if (marker) { // undo it
map.removeOverlay(marker);
thePoint = "";
document.add.frm_lat.value=document.add.frm_lng.value="";
if (grid) {map.addOverlay(new LatLonGraticule());}
}
if (point) {
$("do_sv").style.display = "block";
map.clearOverlays();
do_lat (point.lat().toFixed(6)) // display
do_lng (point.lng().toFixed(6))
do_grids(document.add);
do_marker(point.lat(), point.lng(), null); // 12/6/08
thePoint = point;
if (grid) {map.addOverlay(new LatLonGraticule());}
}
getAddress(marker, point);
});
document.add.show_lat.disabled=document.add.show_lng.disabled=true;
<?php
do_kml();
?>
} // end if (GBrowserIsCompatible())
} // end function load()
function URLEncode(plaintext ) { // The Javascript escape and unescape functions do
// NOT correspond with what browsers actually do...
var SAFECHARS = "0123456789" + // Numeric
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
"abcdefghijklmnopqrstuvwxyz" + // guess
"-_.!~*'()"; // RFC2396 Mark characters
var HEX = "0123456789ABCDEF";
var encoded = "";
for (var i = 0; i < plaintext.length; i++ ) {
var ch = plaintext.charAt(i);
if (ch == " ") {
encoded += "+"; // x-www-urlencoded, rather than %20
} else if (SAFECHARS.indexOf(ch) != -1) {
encoded += ch;
} else {
var charCode = ch.charCodeAt(0);
if (charCode > 255) {
alert( "Unicode Character '"
+ ch
+ "' cannot be encoded using standard URL encoding.\n" +
"(URL encoding only supports 8-bit characters.)\n" +
"A space (+) will be substituted." );
encoded += "+";
} else {
encoded += "%";
encoded += HEX.charAt((charCode >> 4) & 0xF);
encoded += HEX.charAt(charCode & 0xF);
}
}
} // end for(...)
return encoded;
}; // end function
function URLDecode(encoded ){ // Replace + with ' '
var HEXCHARS = "0123456789ABCDEFabcdef"; // Replace %xx with equivalent character
var plaintext = ""; // Place [ERROR] in output if %xx is invalid.
var i = 0;
while (i < encoded.length) {
var ch = encoded.charAt(i);
if (ch == "+") {
plaintext += " ";
i++;
} else if (ch == "%") {
if (i < (encoded.length-2)
&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
plaintext += unescape( encoded.substr(i,3) );
i += 3;
} else {
alert( '-- invalid escape combination near ...' + encoded.substr(i) );
plaintext += "%[ERROR]";
i++;
}
} else {
plaintext += ch;
i++;
}
} // end while (...)
return plaintext;
}; // end function URLDecode()
function do_lat (lat) {
document.add.frm_lat.value=lat; // 9/9/08
document.add.show_lat.disabled=false; // permit read/write
document.add.show_lat.value=do_lat_fmt(document.add.frm_lat.value);
document.add.show_lat.disabled=true;
}
function do_lng (lng) {
document.add.frm_lng.value=lng;
document.add.show_lng.disabled=false;
document.add.show_lng.value=do_lng_fmt(document.add.frm_lng.value);
document.add.show_lng.disabled=true;
}
function do_grids(theForm) { //12/13/10
if (theForm.frm_ngs.value) {do_usng(theForm) ;}
if (theForm.frm_utm) {do_utm (theForm);}
if (theForm.frm_osgb) {do_osgb (theForm);}
}
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_utm.value = (temp_ary.length == 3)? temp_ary[0] + " " + parseInt(temp_ary[1]) + " " + parseInt(temp_ary[2]) : "";
}
function do_osgb (theForm) {
var ll_in = new LatLng(parseFloat(theForm.frm_lat.value), parseFloat(theForm.frm_lng.value));
var osgb_out = ll_in.toOSRef();
theForm.frm_osgb.value = osgb_out.toSixFigureString();
}
// *********************************************************************
var the_form;
function sendRequest(my_form, url,callback,postData) { // ajax function set - 1/17/09
the_form = my_form;
var req = createXMLHTTPObject();
if (!req) return;
var method = (postData) ? "POST" : "GET";
req.open(method,url,true);
if (postData)
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
req.onreadystatechange = function () {
if (req.readyState != 4) return;
if (req.status != 200 && req.status != 304) {
alert('813: HTTP error ' + req.status);
return;
}
callback(req);
}
if (req.readyState == 4) return;
req.send(postData);
}
var XMLHttpFactories = [
function () {return new XMLHttpRequest() },
function () {return new ActiveXObject("Msxml2.XMLHTTP") },
function () {return new ActiveXObject("Msxml3.XMLHTTP") },
function () {return new ActiveXObject("Microsoft.XMLHTTP") }
];
function createXMLHTTPObject() {
var xmlhttp = false;
for (var i=0;i<XMLHttpFactories.length;i++) {
try {
xmlhttp = XMLHttpFactories[i]();
}
catch (e) {
continue;
}
break;
}
return xmlhttp;
}
// "Juan Wzzzzz;(123) 456-9876;1689 Abcd St;Abcdefghi;MD;16701;99.013297;-88.544775;"
// 1 2 3 4 5 6 7 8
function handleResult(req) { // the called-back phone lookup function
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