forked from khoegenauer/tickets-cad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.php
3201 lines (2850 loc) · 157 KB
/
board.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 board.php
* @author John Doe <[email protected]>
* @since
* @version
*/
error_reporting(E_ALL);
// ========== Beginning of user-reviseable values ==========================================================================
//
// The following three arrays are threshold values for the List function, and control its highlighting.
// Each array is a comma-separated list of minute values, for, respectively:
//
// Dispatched, Responding, On_scene, Facility en-route, Facility arrive, Clear, Problemend
//
// Elapsed times exceeding these values will appear in the list highlighted in red Note that different
// values apply to incidents as a function of the three incident severities.
//
// These may be revised to suit your operation's needs. Please do so with care - no edits are applied!
//
// ===== Dispatched, Responding, On_scene, Facility en-route, Facility arrive, Clear, Problemend ======
$thresh_n = array(3, 20, 30, 40, 50, 60, 120); // threshold times in minutes - normal incidents
$thresh_m = array(2, 5, 15, 15, 15, 15, 60); // threshold times in minutes - medium-severity incidents
$thresh_h = array(1, 5, 30, 40, 50, 60, 30); // threshold times in minutes - high-severity incidents
// ========================================================================================================
//
// Call board layout values - group percentages followed by individual columnn widths - 11/27/09
//
// ========================================================================================================
$TBL_INC_PERC = 50; // incident group - four columns - 50 percent as default
$TBL_UNIT_PERC = 35; // unit group, includes checkboxes - 35 percent as default
$TBL_CALL_PERC = 10; // call group - three columns - 10 percent as default
// total shd be ~ 100
// column width in characters - use zero to suppress display
$COLS_INCID = 18; // incident name - 18 characters as default
$COLS_OPENED = 0; // date/time opened - 0 characters as default
$COLS_DESCR = 32; // incident description - 32 characters as default
$COLS_ADDR = 32; // address - 32 characters as default
$COLS_UNIT = 15; // unit name
$COLS_ASOF = 9; // call as-of date/time - 9 characters as default
$COLS_USER = 3; // last update by user xxx - 3 characters as default
$COLS_COMMENTS = 8; // run comments - 8 characters as default
// ======== End of user-reviseable values ======================================================================
/*
alert(<?php print __LINE__;?>);
5/23/08 fix to status_val field name
6/4/08 Deletion logic revised to remove timed-based inactive and add explicit deletions
6/26/08 added $doTick to assign view/edit ticket functions by priv level
8/24/08 added htmlentities function to TITLE strings
9/17/08 disallow guest edit to unit status
9/27/08 removed dead code relating to $unit_scr
9/28/08 converted TD hide/show to SPAN, to improve col alignment
10/9/08 show unit status dropdown only one time
11/7/08 incident strikethrough corrections
11/8/08 added checkboxes; correction to unit status update
1/12/09 center added for call frame, accomodate frame operation, do status update in-frame, dollar function added
1/15/09 update assigns with unit_id, added ajax functions, added script-specific CONSTANTs
1/16/08 removed 'delta' in favor of INTERVAL-based SQL, added mailit() for new dispatches
1/17/09 incident strike-through corrections
1/29/09 fixed sql stmt, TBD default comment added
2/12/09 fix select list order
2/18/09 added persistence to 'hide cleared'
2/19/09 'do all clicked buttons' added
2/20/09 show/hide changed to radio button
2/28/09 fixes to CB update
3/1/09 restrict guest updates
3/9/09 bypass email if no addr, set 'dispatched' time
3/25/09 'mailed', 'fetch_assoc' for performance, 'mailed' removed
4/11/09 apply guest checkbox restrictions
4/26/09 changes to list layout per AF, addslashes replaces htmlentities
5/11/09 added $theClass to unit name display, 'available' SELECTED if exists
5/17/09 moved buttons to floating div, with user location adjustment
5/20/09 simplified Reset button handling, hide/show cleared dispatches
5/23/09 fix to table alignment, edit 'select status' handling, bold units, relocate and visible 'times reset'
5/24/09 width fix per AH email
5/28/09 dispatch deletion added, per AF request.
5/25/09 change to sort order
6/6/09 page refresh link added
6/16/09 show_top() added, mail win added
6/19/09 d/r case-independence added
7/27/09 synchronous AJAX call to avoid collisions
9/12/09 table cleanup, ticket descr added
10/6/09 Changed comments form field to textarea and comments field in table to text from varchar
10/6/09 Added Unit to Facility enroute and arrived status, added links button
10/20/09 strip newlines
10/29/09 $_REQUEST to $_POST (original reason unknown)
10/31/09 window height syntax, list window open corrections, is_guest() -> $guest
11/2/09 correction to insert param count
11/4/09 mileage added to add form
11/6/09 removed quote - source ???, removed old id manipulation in function our_reset()
11/27/09 revised default column widths - per AF; removed redundant form
12/13/09 applied filter to 'open assigns' list
3/18/10 added log 'dispatch' entry
4/4/10 status alignment fixed
4/27/10 unit_name correction
4/29/10 added 'Cancel' button
5/7/10 query name changes
6/21/10 - user select board sort order added
Sequence numbering: SELECT a.id, @num := @num + 1 seqno from ticket a, (SELECT @num := 0) d;
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/10/10 address column names disambiguated, path correction
8/29/10 use dispatch status tags per 'disp_stat' setting
9/29/10 use revised mysql2timestamp($m), per JB, do_diff moved to FIP
11/16/10 assign 'as of' correction
12/9/10 in_strike corrections, table width corrections for missing unit data
2/8/11 Revised query line 712 to correct multiple showings of same responder in add assignmenet from callboard .
2/8/11 added multi to line 712 sql
3/15/11 Revisions to support user editable color schemes and day/night mode
4/28/11 handle replaces unit name
5/9/11 add test for existence of dform element
6/10/11 changes for regional capability
4/24/12 Revised SQL station to correct incorrect GROUP BY clause.
6/20/12 applied get_text() to "Units", don't reset 'dispatch' time on reset
10/19/12 mysql setting set, form end moved outside table row
10/20/12 button label correction, generate log entry for each changed assigns event
1/8/2013 function get_disp_cell() added, reload() set true
1/10/2013 function my_gregoriantojd added, gregoriantojd being absent from some config's
7/12/2013 revised for zero frame height in case of frames and no assigns
7/16/2013 corrections applied to do_assgn_reset()
11/21/2013 correction per BI email; intrusive close-parens
*/
@session_start();
require_once './incs/functions.inc.php'; //7/28/10
$query = "SET @@global.sql_mode= '';"; //10/19/12
$result = mysql_query($query) ;
//dump($_SESSION);
//dump($_REQUEST);
$from_top = 0; // position of floating div, pixels from top of frame
if ($istest) {
dump($_POST);
}
if(($_SESSION['level'] == $GLOBALS['LEVEL_UNIT']) && (intval(get_variable('restrict_units')) == 1)) {
print "Not Authorized";
exit();
}
/**
* show_top
* Insert description here
*
*
* @return
*
* @access
* @static
* @see
* @since
*/
function show_top() { // generates the document introduction
?>
<!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 - Call Board 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 -->
<STYLE>
span.even { background-color: #DEE3E7;}
.odd { background-color: #EFEFEF;}
.plain { background-color: #FFFFFF;}
input.btn { color:#050; font: bold 84% 'trebuchet ms',helvetica,sans-serif; background-color:#DEE3E7; border:1px solid; border-color: #696 #363 #363 #696; }
#BGCOLOR {BACKGROUND-COLOR: #EFEFEF;}
.emph { background-color: #99b2cc;FONT-SIZE: 12px; COLOR: #ffffff; FONT-STYLE: normal; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none }
.emphb { background-color: #99b2cc;FONT-SIZE: 12px; COLOR: #ffffff; FONT-STYLE: normal; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none }
tr.bigeven { background-color: #DEE3E7;line-height: 200% }
td {cursor: pointer; cursor: hand;}
/* Apply mousedown effect only to NON IE browsers */
html>body .hovermenu ul li a:active{ border-style: inset;}
checkbox {border-width: 0px;}
span.ok{font-weight: light; color: gray;}
span.over {font-weight: light; color: red;}
#bar { width: auto; height: auto; background:transparent; z-index: 100; }
* html #bar { /*\*/position: absolute; top: expression((4 + (ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop)) + 'px'); right: expression((30 + (ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft)) + 'px');/**/ }
#foo > #bar { position: fixed; top: 4px; right: 30px; }
td.my_plain {background-color: white; white-space:nowrap;}
tr td {white-space:nowrap;}
</STYLE>
<SCRIPT>
/**
*
* @param {type} strURL
* @returns {@exp;AJAX@pro;responseText|Boolean}
*/
function syncAjax(strURL) { // synchronous ajax function
if (window.XMLHttpRequest) {
AJAX=new XMLHttpRequest();
}
else {
AJAX=new ActiveXObject("Microsoft.XMLHTTP");
}
if (AJAX) {
AJAX.open("GET", strURL, false);
AJAX.send(null); // form name
return AJAX.responseText;
}
else {
alert ("926: failed");
return false;
}
} // end function sync Ajax(strURL)
/**
*
* @returns {undefined}
*/
function do_refresh() { // 7/10/10
<?php
if (get_variable('call_board')==2) { // window vs. frame behavior
print "\t\t do_frm_refresh();\n"; // re-size cb frame
}
?>
document.can_Form.submit(); // reload frame or window
} // end function do_refresh()
/**
*
* @returns {undefined}
*/
function do_frm_refresh() { // frame refresh - call board option 2
var temp = parent.document.getElementById('the_frames').getAttribute('rows'); // e.g., '63, 126,*'
var rows = temp.split(",", 4);
var height_in_pix = get_lines().trim();
rows[1] = height_in_pix;
temp = rows.join(",");
parent.document.getElementById('the_frames').setAttribute('rows', temp); // set revised cb frame height
document.nav_form.func.value='board';
document.nav_form.submit(); // refresh it
}
/**
*
* @returns {Boolean}
*/
function get_lines() { // returns pixel count
lines = syncAjax("lines_a.php"); // note synch call - 8/10/10
return lines;
} // end function get_lines()
/**
*
* @param {type} in_val
* @param {type} min_val
* @param {type} max_val
* @returns {unresolved}
*/
function tween(in_val, min_val, max_val) { // min and max inclusive
if ((in_val >= min_val) && (in_val<= max_val)) return in_val;
else {
// alert(190);
if (in_val >= max_val) return max_val;
if (in_val <= min_val) return min_val;
alert ("err 192");
}
}
/**
*
* @param {type} lines
* @returns {undefined}
*/
function reSizeScr_add(lines) { // 196 -- 5/23/09
var the_height = ((lines * 25)+280);
window.resizeTo(800, tween(the_height, 200, (window.screen.height - 200))); // 10/31/09 - derived via trial/error (more of the latter, mostly)
} // end function re SizeScr()
/**
*
* @param {type} lines
* @returns {undefined}
*/
function reSizeScr(lines) { // 196 -- 5/23/09
// var the_height = ((lines * 25)+80); // 4/27/10
var the_height = ((lines * 30)+120); // 4/27/10
window.resizeTo((0.98)* screen.width, tween(the_height, 200, (window.screen.height - 200))); // 10/31/09 - derived via trial/error (more of the latter, mostly)
// alert(tween(the_height, 200, (window.screen.height - 200)));
} // end function re SizeScr()
/**
*
* @returns {unresolved}
*/
function do_add_btn() { // 11/4/09
<?php
if (intval(get_variable('call_board'))==1) {
?>
document.nav_form.func.value='add';
document.nav_form.submit(); // 11/6/09
<?php
}
else {
$url = basename(__FILE__) . "?func=add";
?>
newwindow_add = window.open("<?php print $url; ?>", "Email", "titlebar, resizable=1, scrollbars=yes, height=480,width=800,status=no,toolbar=no,menubar=no,location=no, left=50,top=150,screenX=100,screenY=300");
if (isNull(newwindow_add)) {
alert ("<?php print gettext('This requires popups to be enabled. Please adjust your browser options.');?>");
return;
}
newwindow_add.focus();
<?php
} // end if/else
?>
}
</SCRIPT>
<?php
} // end function show_top()
/**
* my_to_date
* Insert description here
*
* @param $in_date
*
* @return
*
* @access
* @static
* @see
* @since
*/
function my_to_date($in_date) { // date_time format to user's spec
$temp = mysql2timestamp($in_date); // 9/29/10
return (good_date_time($in_date)) ? date(get_variable("date_format"), $temp): ""; //
}
/**
* my_to_date_sh
* Insert description here
*
* @param $in_date
*
* @return
*
* @access
* @static
* @see
* @since
*/
function my_to_date_sh($in_date) { // short date_time string
$temp = mysql2timestamp($in_date); // 9/29/10
return (good_date_time($in_date)) ? date("H:i", $temp): ""; //
}
/**
* my_gregoriantojd
* Insert description here
*
* @param $da
* @param $mo
* @param $yr
*
* @return
*
* @access
* @static
* @see
* @since
*/
function my_gregoriantojd($da, $mo, $yr) { // 1/10/2013
return strtotime ("{$da} {$mo} {$yr}");
}
$jd_today = my_gregoriantojd (date ("M"), date ("j"), date ("Y")); // julian today - see get_disp_cell() - 1/7/2013
/**
* get_disp_cell
* Insert description here
*
* @param $row_element
* @param $form_element
* @param $theClass
*
* @return
*
* @access
* @static
* @see
* @since
*/
function get_disp_cell($row_element, $form_element, $theClass) { // returns td cell with disp times or checkbox - 1/8/2013
$can_update = (array_key_exists ('level', $_SESSION) )? ( is_administrator() || is_user()): FALSE; // 1/8/2013
global $jd_today;
if (is_date($row_element)) {
$ttip_str = " onmouseover=\"Tip(' " . my_to_date($row_element) . "');\" onmouseout=\"UnTip();\" ";
$then = strtotime($row_element);
$jd_then = my_gregoriantojd (date ("M", $then), date ("j", $then), date ("Y", $then));
$this_class = ($jd_then == $jd_today )? $theClass: "my_plain";
return "\n\t<TD CLASS='{$this_class}' {$ttip_str}>" . my_to_date_sh($row_element) . "</TD>\n"; // identify as not-today
}
else {
$is_dis = ($can_update)? "" : "DISABLED"; // limit to admins, operators
return "\n\t<TD CLASS='{$theClass}'><INPUT TYPE='checkbox' NAME='{$form_element}' {$is_dis} onClick = 'checkbox_clicked();' /></TD>\n";
}
} // end function get_disp_cell()
sleep(1); // wait for possible logout to complete
@session_start();
if (empty($_SESSION)) { // expired?
show_top() ;
?>
</HEAD>
<BODY> <!-- <?php print __LINE__; ?> -->
<?php
require_once './incs/links.inc.php';
$evenodd = array ("even", "odd"); // CLASS names for alternating table row colors
?>
<CENTER><BR><SPAN ID='zzstart' onClick = "Javascript: self.location.href = '<?php print basename(__FILE__); ?>';"><H3><?php print gettext('Call board loading.');?> ...</H3></span>
</BODY><!-- <?php echo __LINE__;?> -->
</HTML>
<?php
} // end if (!mysql_affected_rows())
else {
set_sess_exp(); // update session time
extract($_POST);
// $func = (!(array_key_exists('func', $_POST)))? "board" : $_POST['func']; // array_key_exists ( mixed key, array search )
$func = (!(array_key_exists('func', $_REQUEST)))? "board" : $_REQUEST['func']; // array_key_exists ( mixed key, array search )
show_top();
$guest = is_guest(); // 10/31/09
$user = is_user(); // 5/11/10
?>
<SCRIPT>
var myuser = "<?php print $_SESSION['user']?$_SESSION['user']: "not";?>";
var mylevel = "<?php print isset($_SESSION['level'])?get_level_text($_SESSION['level']): "na";?>";
var myscript = "<?php print isset($_SESSION['user'])? LessExtension(basename( __FILE__)): "login";?>";
if (!(window.opener==null)) { // 1/12/09
try {
window.opener.parent.frames["upper"].$("whom").innerHTML = myuser;
window.opener.parent.frames["upper"].$("level").innerHTML = mylevel;
window.opener.parent.frames["upper"].$("script").innerHTML = myscript;
}
catch(e) {
}
}
/**
*
* @returns {Array}
*/
function $() { // 1/12/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;
}
/**
*
* @returns {unresolved}
*/
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
/**
*
* @param {type} val
* @returns {Boolean}
*/
function isNull(val) { // checks var stuff = null;
return val === null;
}
/**
*
* @param {type} url
* @param {type} callback
* @param {type} postData
* @returns {unresolved}
*/
function sendRequest(url,callback,postData) { // ajax function set - 1/15/09
var req = createXMLHTTPObject();
if (!req) return;
var method = (postData) ? "POST" : "GET";
// req.open(method,url,true);
req.open(method,url,false); // synchronous, 7/27/09
//// req.setRequestHeader('User-Agent','XMLHTTP/1.0');
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
*/
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;
}
/**
*
* @param {type} id
* @returns {undefined}
*/
function editA(id) { // edit assigns
document.nav_form.frm_id.value=id;
<?php
print "\t\tdocument.nav_form.func.value="; // guest priv's = 'read-only'
print ($guest||($user))? "'view';" : "'edit';"; // 5/11/10
?>
document.nav_form.submit();
}
/**
*
* @returns {unresolved}
*/
function do_mail_all_win() { // 6/16/09
if (starting) {return;}
starting=true;
newwindow_um=window.open("do_unit_mail.php?name=0", "Email", "titlebar, resizable=1, scrollbars, height=640,width=600,status=0,toolbar=0,menubar=0,location=0, left=50,top=150,screenX=100,screenY=300");
if (isNull(newwindow_um)) {
alert ("<?php print gettext('This requires popups to be enabled. Please adjust your browser options.');?>");
return;
}
newwindow_um.focus();
starting = false;
}
/**
*
* @param {type} id
* @returns {undefined}
*/
function viewT(id) { // view ticket
document.T_nav_form.id.value=id;
document.T_nav_form.action='main.php';
document.T_nav_form.submit();
if (!(window.opener==null)) {window.opener.focus();}
}
/**
*
* @param {type} id
* @returns {undefined}
*/
function editT(id) { // edit ticket
document.T_nav_form.id.value=id;
document.T_nav_form.action='edit.php';
document.T_nav_form.submit();
if (!(window.opener==null)) {window.opener.focus();}
}
/**
*
* @param {type} id
* @returns {undefined}
*/
function viewU(id) { // view unit
document.U_nav_form.id.value=id;
document.U_nav_form.submit();
if (!(window.opener==null)) {window.opener.focus();}
}
/**
*
* @param {type} id
* @returns {undefined}
*/
function editU(id) { // edit unit
document.U_edit_form.id.value=id;
document.U_edit_form.submit();
if (!(window.opener==null)) {window.opener.focus();}
}
/**
*
* @param {type} id
* @param {type} the_form
* @returns {unresolved}
*/
function do_assgn_reset(id, the_form) { // 4/26/09 - 7/16/2013
/**
*
* @param {type} id
* @param {type} the_form
* @returns {undefined}
*/
function our_reset(id, the_form) { // reset dispatch checks
var dis = <?php print ($guest)? "true": "false"; ?>; // disallow guest actions
the_form.res_times.checked = false; // 6/20/12
// the_form.frm_dispatched.disabled = false;
// the_form.frm_dispatched.checked = false;
// the_form.frm_dispatched.disabled = dis;
if (the_form.frm_responding) {
the_form.frm_responding.disabled = false;
the_form.frm_responding.checked = false;
the_form.frm_responding.disabled = dis;
}
if (the_form.frm_on_scene) {
the_form.frm_on_scene.disabled = false;
the_form.frm_on_scene.checked = false;
the_form.frm_on_scene.disabled = dis;
}
if (the_form.frm_u2fenr) {
the_form.frm_u2fenr.disabled = false; //10/6/09 Unit to Facility
the_form.frm_u2fenr.checked = false;
the_form.frm_u2fenr.disabled = dis;
}
if (the_form.frm_u2farr) {
the_form.frm_u2farr.disabled = false; //10/6/09 Unit to Facility
the_form.frm_u2farr.checked = false;
the_form.frm_u2farr.disabled = dis;
}
if (the_form.frm_clear) {
the_form.frm_clear.disabled = false;
the_form.frm_clear.checked = false;
the_form.frm_clear.disabled = dis;
}
var url = "assign_res.php";
var postData = "frm_id=" + id; // the post string
sendRequest(url,handleResult,postData) ;
do_refresh();
} // end function do_assgn_reset()
/**
*
* @param {type} id
* @param {type} the_form
* @returns {undefined}
*/
function our_delete(id, the_form) { // delete this dispatch record
$('del_id').style.display='block';
var url = "assign_del.php";
var postData = "frm_id=" + id; // the post string
sendRequest(url,our_wrapup,postData) ;
setTimeout('$(\'del_id\').style.display=\'none\';document.can_Form.submit();', 2000); // show for 2 seconds
} // end function our delete()
/**
*
* @returns {undefined}
*/
function our_wrapup() {
setTimeout('$(\'del_id\').style.display=\'none\';', 2000); // show for 2 seconds
// window.location.reload();
document.can_Form.submit(); // screen refresh/re-size
}
var resp = ""; // 5/28/09
while ((resp.toLowerCase() !="r") && (resp !="d")) { // 6/19/09
resp = prompt("<?php print gettext("Enter 'r' to Reset dispatch times\nEnter 'd' to Delete this dispatch, or press Cancel.\n");?>", "");
if (isNull(resp)) {the_form.res_times.checked = false; return;} // 5/6/10
else {
switch (resp.toLowerCase()) { // process the input
case "r":
our_reset(id, the_form);
break;
case "d":
if ( confirm ( "<?php print gettext('Delete this dispatch record?');?>" ) ) { // 7/16/2013
our_delete(id, the_form);
}
break;
default: // user cancelled
the_form.res_times.checked = false;
return;
} // end switch(resp)
} // end while ( ... )
the_form.res_times.checked = false;
}
} // end function do_assgn_reset()
</SCRIPT>
<?php
$guest = is_guest(); // 10/31/09
$user = is_user(); // 10/31/09
switch ($func) {
case 'add': // ==== { ==== first build JS array of existing assigns for dupe prevention
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]allocates` WHERE `type`= 4 AND `resource_id` = '$_SESSION[user_id]';"; // 6/10/11
$result = mysql_query($query); // 4/18/11
$al_groups = array();
while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { // 4/18/11
$al_groups[] = $row['group'];
}
if (count($al_groups == 0)) { // catch for errors - no entries in allocates for the user. // 5/30/13
$where2 = "";
} else {
if (isset($_SESSION['viewed_groups'])) { // 6/10/11
$curr_viewed= explode(",",$_SESSION['viewed_groups']);
}
if (!isset($curr_viewed)) { // 6/10/11
$x=0;
$where2 = "AND (";
foreach ($al_groups as $grp) {
$where3 = (count($al_groups) > ($x+1)) ? " OR " : ")";
$where2 .= "`$GLOBALS[mysql_prefix]allocates`.`group` = '{$grp}'";
$where2 .= $where3;
$x++;
}
} else {
$x=0;
$where2 = "AND (";
foreach ($curr_viewed as $grp) {
$where3 = (count($curr_viewed) > ($x+1)) ? " OR " : ")";
$where2 .= "`$GLOBALS[mysql_prefix]allocates`.`group` = '{$grp}'";
$where2 .= $where3;
$x++;
}
}
}
$query = "SELECT *, `$GLOBALS[mysql_prefix]ticket`.`id` AS `tick_id`
FROM `$GLOBALS[mysql_prefix]ticket`
LEFT JOIN `$GLOBALS[mysql_prefix]allocates` ON `$GLOBALS[mysql_prefix]ticket`.`id`=`$GLOBALS[mysql_prefix]allocates`.`resource_id`
WHERE `status` = {$GLOBALS['STATUS_OPEN']} {$where2}
GROUP BY `tick_id` ORDER BY `severity` DESC, `problemstart` ASC "; // highest severity, oldest open
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
if (mysql_affected_rows()==1) { // if a single, do it
$row = mysql_fetch_assoc($result);
?>
<SCRIPT>
/**
*
* @returns {undefined}
*/
function do_post() {
document.temp_Form.frm_ticket_id.value=<?php print $row['tick_id'];?>;
document.temp_Form.submit();
}
setTimeout('do_post()', 1000);
</SCRIPT>
<?php
} // end if (mysql_affected_rows()==1)
else { // build <SELECT> list
$lines = mysql_affected_rows();
?>
</HEAD>
<BODY onLoad = "reSizeScr_add(<?php print $lines;?>);"><!-- <?php echo __LINE__ ;?> --><BR /><BR />
<TABLE BORDER=0 ALIGN='center'>
<FORM NAME="add_nav_form" ACTION = "<?php print basename(__FILE__); ?>" METHOD = "post">
<TR CLASS="even"><TH colspan=4 ALIGN="center"><?php print gettext('Select Incident for Dispatch');?></TH></TR>
<TR CLASS="odd" VALIGN="baseline">
<TD CLASS="td_label" ALIGN="right"><?php print gettext('Incident');?>: </TD>
<TD ALIGN='left' COLSPAN=3>
<SELECT NAME="frm_ticket_sel" onChange = "if (!(this.value=='')) {this.form.frm_ticket_id.value=this.value;this.form.submit();}">
<OPTION VALUE= '' SELECTED><?php print gettext('Select');?></OPTION>
<?php
$inc_ctr = mysql_affected_rows();
while ($row = mysql_fetch_array($result)) {
$addr = substr($row['street'] . " " . $row['city'] . " " . $row['state'], 0, 24);
$descr = substr($row['scope'] , 0, 24) . " - " . $addr ;
print "\t\t\t<OPTION value='{$row['tick_id']}'> {$descr}</OPTION>\n";
// $the_ticket_id = $row['id'];
}
?>
</SELECT>
</TD></TR>
<?php // 4/29/10
$the_onclick = (get_variable('call_board')==1)? "history.back()": "window.close()";
?>
<TR><TD COLSPAN = 4 ALIGN = 'center'><BR /><BR /><INPUT TYPE = 'button' value = '<?php print gettext('Cancel');?>' onClick = '<?php print $the_onclick; ?>' /></TD></TR>
</TABLE>
<?php
} // end if/else (mysql_affected_rows()==1)
?>
<INPUT TYPE='hidden' NAME='frm_ticket_id' VALUE='' />
<INPUT TYPE='hidden' NAME='func' VALUE='add_b' />
</FORM>
<?php
break; // end case 'add' ==== } ===
case 'add_b': // ==== { ====
extract ($_POST);
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]allocates` WHERE `type`= 4 AND `resource_id` = '$_SESSION[user_id]';"; // 6/10/11
$result = mysql_query($query); // 4/18/11
$al_groups = array();
while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { // 4/18/11
$al_groups[] = $row['group'];
}
if (count($al_groups == 0)) { // catch for errors - no entries in allocates for the user. // 5/30/13
$where2 = "WHERE `$GLOBALS[mysql_prefix]allocates`.`type` = 2";
} else {
if (isset($_SESSION['viewed_groups'])) { // 6/10/11
$curr_viewed= explode(",",$_SESSION['viewed_groups']);
}
if (!isset($curr_viewed)) { // 6/10/11
$x=0;
$where2 = "WHERE (";
foreach ($al_groups as $grp) {
$where3 = (count($al_groups) > ($x+1)) ? " OR " : ")";
$where2 .= "`$GLOBALS[mysql_prefix]allocates`.`group` = '{$grp}'";
$where2 .= $where3;
$x++;
}
} else {
$x=0;
$where2 = "WHERE (";
foreach ($curr_viewed as $grp) {
$where3 = (count($curr_viewed) > ($x+1)) ? " OR " : ")";
$where2 .= "`$GLOBALS[mysql_prefix]allocates`.`group` = '{$grp}'";
$where2 .= $where3;
$x++;
}
}
$where2 .= "AND `$GLOBALS[mysql_prefix]allocates`.`type` = 2"; // 6/10/11
}
$assigns = array(); // map unit id to ticket id
/**
* get_cd_str
* Insert description here
*
* @param $unit_row
* @param $ticket_id
*
* @return
*
* @access
* @static
* @see
* @since
*/
function get_cd_str($unit_row, $ticket_id) {
global $assigns;
// dump($assigns);
if ((array_key_exists($unit_row['id'], $assigns))
&& ($assigns[$unit_row['id']] == $ticket_id )) { return " CHECKED DISABLED ";} // this unit, this ticket
if ($unit_row['multi'] == 1) { return "";} // multiple assign allowed
if (array_key_exists($unit_row['id'], $assigns)) { return " DISABLED ";}
else { return "";}
} // end function get_cd_str ()
?>
<SCRIPT>
<?php
print "\t\tassigns = new Array();\n";
$query = "SELECT *,`as_of` AS `as_of` FROM `$GLOBALS[mysql_prefix]assigns` WHERE `clear` IS NULL OR DATE_FORMAT(`clear`,'%y') = '00' ORDER BY `as_of` DESC"; // 12/13/09
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
while ($row = stripslashes_deep(mysql_fetch_array($result))) {
print "\t\tassigns['" .$row['ticket_id'] .":" . $row['responder_id'] . "']=true;\n"; // build assoc array of ticket:unit pairs
}
?>
/**
*
* @param {type} theForm
* @returns {Boolean}
*/
function validate_ad(theForm) {
var errmsg="";
if (theForm.frm_unit_id_str.value == "") {errmsg+= "\t<?php print gettext('Select one or more units');?>\n";}
if (theForm.frm_comments.value == "") {errmsg+= "\t<?php print gettext('Comments required');?>\n";}
if (!(theForm.frm_miles_strt.value.trim()) =="") { // 11/4/09
if (!(parseInt(theForm.frm_miles_strt.value.trim()) == theForm.frm_miles_strt.value.trim()))
{errmsg+= "\t<?php print gettext('Start mileage error');?>\n";}
}
if (!(theForm.frm_miles_onsc.value.trim()) =="") { // 11/4/09
if (!(parseInt(theForm.frm_miles_onsc.value.trim()) == theForm.frm_miles_onsc.value.trim()))
{errmsg+= "\t<?php print gettext('On scene mileage error');?>\n";}
}
if (!(theForm.frm_miles_end.value.trim()) =="") {
if (!(parseInt(theForm.frm_miles_end.value.trim()) == theForm.frm_miles_end.value.trim()))
{errmsg+= "\t<?php print gettext('End mileage error');?>\n";}
}
if (!(theForm.frm_miles_tot.value.trim()) =="") { // 10/23/12
if (!(parseInt(theForm.frm_miles_tot.value.trim()) == theForm.frm_miles_tot.value.trim()))
{errmsg+= "\t<?php print gettext('Total mileage error');?>\n";}
}
if (errmsg!="") {
alert ("<?php print gettext('Please correct the following and re-submit');?>:\n\n" + errmsg);
return false;
}
else {
theForm.submit();
}
} // end function vali date(theForm)
</SCRIPT>
<SCRIPT SRC='./js/misc_function.js' type='text/javascript'></SCRIPT>
</HEAD>
<?php
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]responder`
LEFT JOIN `$GLOBALS[mysql_prefix]allocates` ON `$GLOBALS[mysql_prefix]responder`.id=`$GLOBALS[mysql_prefix]allocates`.`resource_id`
{$where2} GROUP BY `$GLOBALS[mysql_prefix]responder`.`id`"; // 2/12/09
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
$lines = mysql_affected_rows();
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]ticket` WHERE `$GLOBALS[mysql_prefix]ticket`.`id` = {$frm_ticket_id}
LIMIT 1"; // see case $func = 'add_b'
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), basename(__FILE__), __LINE__);
$row = mysql_fetch_array($result);
$latitude = $row['lat'];
$longitude = $row['lng'];
?>
<BODY onLoad = "reSizeScr_add(<?php print $lines;?>);"><!-- <?php echo __LINE__; ?> --><LEFT>
<A NAME='page_top'>
<DIV ID='buttons' style="position:fixed; top:10px; right:2px; height: 150px; width: 150px; overflow-y: auto; overflow-x: auto;">
<TABLE>
<TR><TD ALIGN='left'><A HREF="#page_top"><?php print gettext('to top');?></A></TD></TR>
<TR><TD ALIGN='left'><A HREF="#page_bottom"><?php print gettext('to bottom');?></A></TD></TR>
<TR><TD> </TD></TR>
<?php
if (get_variable('call_board')==1) {
print "\t<TR><TD ALIGN='left'><INPUT TYPE='button' VALUE='" . gettext('Cancel') . "' CLASS = 'btn' onClick='do_refresh();' STYLE = 'left: 0;' />\n";
}
else {
print "\t<TR><TD ALIGN='left'><INPUT TYPE='button' VALUE='" . gettext('Cancel') . "' CLASS = 'btn' onClick='window.close();' STYLE = 'left: 0;' />\n";
}
?>
<INPUT TYPE="button" VALUE="<?php print gettext('Reset');?>" onclick="Javascript: document.add_Form.frm_unit_id_str.value = ''; document.add_Form.reset();" CLASS = 'btn' STYLE = 'left: 0;' /></TD></TR>
<TR><TD ALIGN='left'><INPUT TYPE="button" VALUE=" <?php print gettext('Next');?> " name="sub_but" onClick="validate_ad(document.add_Form);" CLASS = 'btn' STYLE = 'left: 0;' /></TD></TR>
</TABLE>
</DIV> <!-- 3/30/10 -->
<TABLE BORDER=0 STYLE = "border-collapse:collapse; margin-left:32px" CELLSPACING=0 CELLPADDING=0 >
<FORM NAME="add_Form" ACTION = "<?php print basename(__FILE__); ?>" METHOD = "post">