-
Notifications
You must be signed in to change notification settings - Fork 6
/
auto_disp_status.php
267 lines (249 loc) · 10.4 KB
/
auto_disp_status.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
<?php
/**
*
*
* @package auto_disp_status.php
* @author John Doe <[email protected]>
* @since 2013-09-10
* @version 2013-09-10
*/
/* Change log - auto_status.php
9/10/13 - Config file to configure automatic status updates when dispatch status changes
*/
error_reporting(E_ALL);
@session_start();
require_once './incs/functions.inc.php';
// Declare arrays for all resource ids
$status_ids = array();
$disp_status = array();
$current = array();
// end of array declaration
// get status ids
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]un_status`;";
$result = mysql_query($query);
while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
$i = $row['id'];
$status_ids[$i][0] = $row['id'];
$status_ids[$i][1] = $row['status_val'];
$status_ids[$i][2] = $row['group'];
}
// end of status ids
// Dispatch Status Values
$disp_status[1] = "Dispatched";
$disp_status[2] = "Responding";
$disp_status[3] = "On Scene";
$disp_status[4] = "Facility en-route";
$disp_status[5] = "Facility arrived";
$disp_status[6] = "Clear";
// end of dispatch status values
// get current settings
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]auto_disp_status` ORDER BY `id` ASC;";
$result = mysql_query($query);
$z=1;
while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
$current[$z][0] = $row['id'];
$current[$z][1] = $row['name'];
$current[$z][2] = intval($row['status_val']);
$z++;
}
// end of Current Settings
if (!empty($_POST)) {
$the_data = array();
$i=1;
foreach ($_POST['frm_status'] as $val) {
$the_data[$i][] = $i;
$the_data[$i][] = $val;
$the_data[$i][] = $disp_status[$i];
$i++;
}
foreach ($the_data as $val) {
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]auto_disp_status` WHERE `id` = '" . $val[0] . "'";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) { // Entry exists for the status value
$query = "UPDATE `$GLOBALS[mysql_prefix]auto_disp_status` SET `name` = '" . $val[2] . "', `status_val` = " . $val[1] . " WHERE `id`=" . $val[0];
$result = mysql_query($query);
} else { // entry doesn't exist for the status value - insert a new one
$query = "INSERT INTO `$GLOBALS[mysql_prefix]auto_disp_status` (`id`, `name`, `status_val`) VALUES ('" . $val[0] . "', '" . $val[2] . "', '" . $val[1] . "')";
$result = mysql_query($query);
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HEAD>
<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="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" />
<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__)));?>" />
<TITLE>Tickets</TITLE>
<LINK REL=StyleSheet HREF="stylesheet.php?version=<?php print time();?>" TYPE="text/css">
<link rel="shortcut icon" href="favicon.ico" />
<SCRIPT>
/**
*
* @returns {undefined}
*/
function ck_frames() {
if (self.location.href==parent.location.href) {
self.location.href = 'index.php';
}
else {
parent.upper.show_butts();
}
} // end function ck_frames()
</SCRIPT>
</HEAD>
<BODY onLoad='ck_frames();'>
<DIV style='font-size: 14px; position: fixed; top: 150px; left: 100px;'>
Settings Saved<br /><br />
<A style='font-size: 14px;' href="config.php">Return to Config</A>
</DIV>
</BODY>
</HTML>
<?php
} else {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HEAD>
<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="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" />
<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__)));?>" />
<TITLE>Tickets</TITLE>
<LINK REL="StyleSheet" HREF="stylesheet.php?version=<?php print time();?>" TYPE="text/css" />
<link rel="shortcut icon" href="favicon.ico" />
<STYLE>
.table_header { color: #FFFFFF; text-align: left; height: 20px; border: 1px solid #000000; background: #707070;}
.table_hdr_cell { color: #FFFFFF; width: 20%; font-weight: bold; font-size: 16px; border: 1px solid #000000;}
.table_row { color: #000000; text-align: left; height: 15px; border: 1px solid #000000;}
.table_cell { width: 20%; font-size: 14px; border: 1px solid #000000; word-wrap: break-word;}
.header { display: table-cell; color: #000000; width: 5%;}
.page_heading { font-size: 20px; font-weight: bold; text-align: left; background: #707070; color: #FFFFFF;}
.page_heading_text { font-size: 20px; font-weight: bold; text-align: left; background: #707070; color: #FFFFFF; width: 50%; display: inline;}
.button_bar { font-size: 1.2em; text-align: center; display: inline; width: 30%; position: fixed; right:30%; top: 0px;}
.buttons { border: 2px outset #FFFFFF; padding: 2px; background-color: #EFEFEF; font-weight: bold; display: inline; cursor: pointer;}
.flag { border: 2px outset #707070; background: #CECECE; font-size: 20px; font-weight: bold; display: inline; position: fixed; right:30%; top: 5%;}
</STYLE>
<SCRIPT>
/**
*
* @returns {undefined}
*/
function ck_frames() {
if (self.location.href==parent.location.href) {
self.location.href = 'index.php';
}
else {
parent.upper.show_butts();
}
} // end function ck_frames()
/**
*
* @returns {Array}
*/
function $() {
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} the_id
* @returns {Boolean}
*/
function do_hover(the_id) {
CngClass(the_id, 'hover');
return true;
}
/**
*
* @param {type} the_id
* @returns {Boolean}
*/
function do_plain(the_id) { // 8/21/10
CngClass(the_id, 'plain');
return true;
}
/**
*
* @param {type} obj
* @param {type} the_class
* @returns {Boolean}
*/
function CngClass(obj, the_class) {
$(obj).className=the_class;
return true;
}
</SCRIPT>
</HEAD>
<BODY onLoad='ck_frames();'>
<DIV id='outer' style='position: absolute; top: 5%; width: 100%; height: 75%; border: 1px solid #FFFFFF;'>
<DIV class='heading' style='width: 100%; position: absolute; text-align: center;'><?php print gettext('AUTOMATIC STATUS UPDATES WITH DISPATCH STATUS CHANGES');?></DIV>
<DIV id='left_col' style='width: 45%; position: absolute; top: 60px; left: 2%; border: 3px outset #CECECE;'>
<FORM NAME='auto_stat_edit' METHOD="post" ACTION="<?php print basename(__FILE__);?>">
<TABLE style='width: 100%;'>
<TR class='heading'>
<TH COLSPAN=99><?php print gettext('SETTINGS');?></TH>
</TR>
<TR class='spacer'>
<TD class='spacer' COLSPAN=99> </TH>
</TR>
<?php
$class='even';
$i=1;
foreach ($disp_status as $the_id) {
?>
<TR class='<?php print $class;?>'>
<TD class='td_label'><?php print $the_id;?></TD>
<TD class='td_data'>
<select name="frm_status[<?php print $i;?>]" size="1">
<option value="0" selected="selected"><?php print gettext('Select Status Value');?></option>
<?php
foreach ($status_ids AS $val) {
$sel = ($val[0] == $current[$i][2]) ? " SELECTED" : "";
?>
<option value="<?php print $val[0];?>"<?php print $sel;?>><?php print $val[2] . "->" . $val[1];?></option>
<?php
}
?>
</select>
</TD>
</TR>
<?php
$class = ($class == 'even') ? 'odd' : 'even';
$i++;
}
?>
</TABLE>
</DIV>
<DIV id='right_col' style='width: 40%; height: 500px; position: absolute; top: 60px; right: 2%; border: 3px outset #DEDEDE; background-color: #F0F0F0;'>
<DIV class='heading' style='width: 100%;'><?php print gettext('HELP');?></DIV>
<DIV style='width: 100%; word-wrap: break-word;'>
<?php print gettext('This page is to set the Auto Dispatch Status values and their associated status values.') . "<BR /><BR />"
. gettext('On the left side are the Dispatch status values and on the right are select controls with the status values currently configured on the Tickets CAD system.') . '\n'
. gettext('These can be changed through Config / Units Status.') . "<BR /><BR />"
. gettext('To configure the auto status values, for each Dispatch status value that you want a specific unit status to be set, select the unit status next to that dispatch status and then click submit.');?><BR />
</DIV>
</DIV>
<DIV style='width: 100%; text-align: center; position: absolute; bottom: 10%;'>
<INPUT TYPE='SUBMIT' NAME='SUBMIT' VALUE='<?php print gettext('Submit');?>'/>
</DIV>
</FORM>
</DIV>
<?php
}
?>
</BODY>
</HTML>