-
Notifications
You must be signed in to change notification settings - Fork 6
/
add.php
2872 lines (2664 loc) · 122 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
/**
*
* @package add.php
* @author John Doe <[email protected]>
* @since 2007-10-28
* @version 2013-11-29
*/
if ( !defined( 'E_DEPRECATED' ) ) { define( 'E_DEPRECATED',8192 );} // 11/8/09
error_reporting (E_ALL ^ E_DEPRECATED);
@session_start();
if (empty($_SESSION)) {
header("Location: index.php");
}
require_once 'incs/functions.inc.php'; //7/28/10
do_login(basename(__FILE__));
$gmaps = $_SESSION['internet'];
$in_win = array_key_exists ("mode", $_GET); // in
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
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
5/7/2014 - prepend bldg name to location string
5/9/2014 - revised query for consistency with edit.php
5/10/2014 - revised bldg sql to preclude field-name collision
*/
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) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
$lookup_vals = explode (";", $row['lookup_vals']);
// dump($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
/**
* get_res_row
* Insert description here
*
*
* @return
*
* @access
* @static
* @see
* @since
*/
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') {
/**
* updt_ticket
* Insert description here
*
* @param $id
*
* @return
*
* @access
* @static
* @see
* @since
*/
function updt_ticket($id) { /* 1/25/09 */
global $addrs, $NOTIFY_TICKET; // 8/28/13
$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 (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
snap( __LINE__ , $temp );
$inc_num_ary = (strpos($temp, "{")>0)? unserialize ($temp) : unserialize (base64_decode($temp));
$name_rev = $_POST['frm_scope'];
snap( __LINE__ , $inc_num_ary[0] );
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
$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
@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(trim($_POST['frm_do_scheduled'])==1))? quote_smart($frm_booked_date): "NULL" ; // 1/2/11, 1/19/10
// die;
// 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($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"; // 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'])) . ",
" . 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 .= gettext("Attached file is too large!");
}
} else {
$print .= gettext("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', $tick_stat, $id, 'Allocated to Group' , $by)";
$result_a = mysql_query($query_a) or do_error($query_a, '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 = 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__);
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><?php print gettext('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="text/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 -->
<SCRIPT SRC="./js/misc_function.js" TYPE="text/javascript"></SCRIPT> <!-- 9/14/12 -->
<SCRIPT SRC="./js/jscolor/jscolor.js"></SCRIPT> <!-- 9/14/12 -->
<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? 8/28/13
?>
/**
*
* @returns {unresolved}
*/
function do_notify() {
var theAddresses = '<?php print implode("|", array_unique($addrs));?>'; // drop dupes
var theText= ' New <?php print get_text("Incident");?>: ';
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
alert(520);
alert(escape(theAddresses));
sendRequest ('mail_it.php',handleResult, params); // ($to_str, $text, $ticket_id) 10/15/08
} // end function do notify()
/**
*
* @param {type} req
* @returns {undefined}
*/
function handleResult(req) { // the 'called-back' function
<?php
if ($istest) {print "\t\t\talert('HTTP error ' + req.status + '" . __LINE__ . "');\n";}
?>
}
/**
*
* @param {type} my_form
* @param {type} url
* @param {type} callback
* @param {type} postData
* @returns {unresolved}
*/
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);
}
/**
*
* @type Array|Array
*/
var XMLHttpFactories = [
function () {return new XMLHttpRequest(); },
function () {return new ActiveXObject("Msxml2.XMLHTTP"); },
function () {return new ActiveXObject("Msxml3.XMLHTTP"); },
function () {return new ActiveXObject("Microsoft.XMLHTTP"); }
];
/**
*
* @returns {Boolean}
*/
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 {
?>
/**
*
* @returns {unresolved}
*/
function do_notify() { // dummy
return;
}
<?php
} // end if/else ($addrs)
$form_name = (intval(get_variable('auto_route'))==1)? "to_routes" : "to_main";
?>
</SCRIPT>
<?php // 7/3/2013
if ( ( intval ( get_variable ('broadcast')==1 ) ) && ( intval ( get_variable ('internet')==1 ) ) ) {
require_once './incs/socket2me.inc.php'; // 5/22/2013
}
?>
</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='<?php print gettext('Main');?>' />
</FORM>
<FORM NAME='to_routes' METHOD='get' ACTION='<?php print $_SESSION['routesfile'];?>'>
<INPUT TYPE='hidden' NAME='ticket_id' VALUE='<?php print $_POST['ticket_id'];?>' />
<INPUT TYPE='submit' VALUE='<?php print gettext('Routes');?>' /></CENTER>
</FORM>
<?php
} // end if ($_GET['add'] ...
// ==============================================
else {
if (is_guest() && !get_variable('guest_add_ticket')) { // 6/25/10
print '<FONT CLASS="warn">' . gettext('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><?php print gettext('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="text/javascript" />
<LINK REL="StyleSheet" HREF="stylesheet.php?version=<?php print time();?>" TYPE="text/css" /> <!-- 3/15/11 -->
<STYLE TYPE="text/css">
#suggest{background:#fff; width:150px; }
#suggest div{ background:#ddd; color:#000; padding-left:4px; cursor:hand; text-align:left;position:relative; }
#suggest div.over{ color:#000; background:#fff; }
</STYLE>
<?php
if (($gmaps) && (!($in_win))) {
$api_key = get_variable('gmaps_api_key');
$key_str = (strlen($api_key) == 39)? "key={$api_key}&" : "";
if((array_key_exists('HTTPS', $_SERVER)) && ($_SERVER['HTTPS'] == 'on')) {
$gmaps_url = "https://maps.google.com/maps/api/js?" . $key_str . "sensor=false";
} else {
$gmaps_url = "http://maps.google.com/maps/api/js?" . $key_str . "sensor=false";
}
?>
<SCRIPT TYPE="text/javascript" SRC="<?php print $gmaps_url;?>"></SCRIPT>
<script type="text/javascript" src="./js/geoxml_v3.js"></script>
<SCRIPT SRC="./js/graticule_V3.js" type="text/javascript"></SCRIPT>
<SCRIPT SRC="./js/gmaps_v3_init.js" TYPE="text/javascript" ></SCRIPT>
<?php
}
?>
<SCRIPT SRC="./js/usng.js" TYPE="text/javascript"></SCRIPT>
<SCRIPT SRC='./js/jscoord.js' TYPE="text/javascript"></SCRIPT> <!-- coordinate conversion 12/10/10 -->
<SCRIPT SRC="./js/lat_lng.js" TYPE="text/javascript"></SCRIPT> <!-- 11/8/11 -->
<SCRIPT SRC="./js/geotools2.js" TYPE="text/javascript"></SCRIPT> <!-- 11/8/11 -->
<SCRIPT SRC="./js/osgb.js" TYPE="text/javascript"></SCRIPT> <!-- 11/8/11 -->
<SCRIPT SRC="./js/misc_function.js" TYPE="text/javascript"></SCRIPT> <!-- 7/22/10 -->
<SCRIPT SRC="./js/suggest.js" TYPE="text/javascript"></SCRIPT> <!-- 2/20/11 -->
<SCRIPT>
/**
*
* @returns {undefined}
*/
function get_new_colors() { // 5/4/11
window.location.href = '<?php print basename(__FILE__);?>';
}
/**
*
* @returns {undefined}
*/
function ck_frames() { // onLoad = "ck_frames()"
<?php if ($in_win) {echo "\n\t\t return;\n"; }?>
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
/**
*
* @returns {Array}
*/
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;
}
/**
*
* @param {type} str
* @returns {Boolean}
*/
function isNullOrEmpty(str) {
if (null == str || "" == str) {return true;} else { return false;}
}
var starting = false;
/**
*
* @param {type} theForm
* @returns {unresolved}
*/
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 ("<?php print gettext('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()
/**
*
* @returns {unresolved}
*/
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
/**
*
* @param {type} val
* @returns {unresolved}
*/
function chknum(val) {
return ((val.trim().replace(/\D/g, "")==val.trim()) && (val.trim().length>0));}
/**
*
* @param {type} val
* @param {type} lo
* @param {type} hi
* @returns {@exp;@call;chknum}
*/
function chkval(val, lo, hi) {
return (chknum(val) && !((val> hi) || (val < lo)));}
starting=false; // 12/16/09
/**
*
* @returns {unresolved}
*/
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 ("<?php print gettext('Call history operation requires popups to be enabled. Please adjust your browser options.');?>");
return;
}
newwindow_c_h.focus();
starting = false;
} // function do hist_win()
/**
*
* @param {type} inlat
* @param {type} inlng
* @returns {unresolved}
*/
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);
}
/**
*
* @param {type} inval
* @returns {String}
*/
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) + '"';
}
/**
*
* @param {type} inlat
* @returns {String}
*/
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;
}
/**
*
* @param {type} inlng
* @returns {String}
*/
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;
}
/**
*
* @param {type} inlat
* @returns {String}
*/
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 <?php print __LINE__;?>");
}
}
/**
*
* @param {type} inlng
* @returns {String}
*/
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 <?php print __LINE__;?>");
}
}
/**
*
* @param {type} content
* @returns {undefined}
*/
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><?php print gettext('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)
/**
*
* @returns {String}
*/
function getRes() {
return window.screen.width + ' x ' + window.screen.height;
}
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 thePoint;
var baseIcon;
var cross;
var grid_bool = false;
/**
*
* @returns {undefined}
*/