-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnew-incident.php
189 lines (162 loc) · 7.2 KB
/
new-incident.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
<?php
$subsys="incidents";
require_once('db-open.php');
require('local-dls.php');
require_once('session.inc');
require_once('functions.php');
SessionErrorIfReadonly();
if (isset($_POST["incident_abort"])) {
header('Location: incidents.php');
exit;
}
elseif (isset($_POST["goto_incident"])) {
$incident_id = (int) MysqlClean($_POST,'goto_incident', 20);
header("Location: edit-incident.php?incident_id=$incident_id");
exit;
}
elseif (isset($_POST["new_incident"])) {
$call_details = MysqlClean($_POST, 'call_details', 80);
$location = MysqlClean($_POST, 'location', 80);
$call_type = MysqlClean($_POST, 'call_type', 40);
MysqlQuery("LOCK TABLES incidents WRITE");
// if this fails ... is another incident being created right now?
MysqlQuery("INSERT INTO incidents (call_details, location, call_type, ts_opened, incident_status, updated) VALUES ('$call_details', '$location', '$call_type', NOW(), 'Open', NOW())");
if (mysql_affected_rows() != 1)
die("Critical error: When inserting incident, mysql_affected_rows(".mysql_affected_rows().") != 1.");
$findlastIDquery = "SELECT LAST_INSERT_ID()";
$findlastIDresult = MysqlQuery($findlastIDquery) or die ("Could not select new incident row LAST_INSERT_ID(): ". mysql_error());
$newIDrow = mysql_fetch_array($findlastIDresult, MYSQL_NUM);
$incident_id = $newIDrow[0];
mysql_free_result($findlastIDresult);
MysqlQuery("UPDATE incidents SET call_number='" .CallNumber($incident_id) . "' WHERE incident_id=$incident_id ");
MysqlQuery("UNLOCK TABLES");
syslog(LOG_INFO, $_SESSION['username'] . " created call [" . CallNumber($incident_id). "] (incident $incident_id) with values: details ($call_details), location ($location), type ($call_type)");
/* print "
<html>
<head>
<script language=JavaScript>
function popup(url, name, height, width)
{
var myWindow = window.open(url,name,'width='+width+',height='+height+',scrollbars')
// FLAG: TODO: modal=yes is a partially ineffective hack, i'd prefer to have truly modeless persistent windows, but Javascript SUCKS.
if (myWindow.focus) {
myWindow.focus()
}
return false;
}
</script>
</head>
<body bgcolor=\"#99cc99\">
New incident has been created (Call #<b>". CallNumber($incident_id)."</b>).
<p>
Next steps:
<li> Request the caller's (reporting party's) ID/name and the following info.
";
if ($call_type == 'INJURY' || $call_type == 'ILLNESS') {
print "<ul><li>Illness/Injury call: <b> Ask questions of the caller to obtain the SEND Protocol information.</ul>";
}
elseif ($call_type == 'FIRE') {
print "<ul><li>Fire call: <b> Request information about fire size and proximity of exposures.</ul>";
}
elseif ($call_type == 'LAW ENFORCEMENT') {
print "<ul><li> Law Enforcement call: <b>Request information about presence or absence of weapons, etc.</ul>";
}
print "
<li> <b>IF THIS IS AN EMERGENCY CALL, REMIND THE CALLER TO STAY ON SCENE AND ON THIS CHANNEL UNTIL HELP ARRIVES.
</b>
<p>
Continue to the incident screen to enter additional details.
<form action=\"new-incident.php\" method=\"post\">
<input type=hidden name=goto_incident value=\"$incident_id\">
<button type=\"submit\" accesskey=\"g\" Value=\"Go To New Incident\"><u>G</u>o To New Incident</button>
<button onClick=\"self.close()\" type=\"submit\" accesskey=\"C\" Value=\"Close\"><u>C</u>lose</button>
</center>
</body>
</html>
";
*/
//<button onClick=\"return popup('edit-incident.php?incident_id=$incident_id','incident-new',width=1000,height=600,scrollbars)\">Go To New Incident</button>
header("Location: edit-incident.php?incident_id=$incident_id");
//print "<a href=\"javascript:return popup('edit-incident.php?incident_id=$incident_id','incident-new',600,1000); self.close();\">Click here to continue to incident</a>";
exit;
}
?>
<body bgcolor="#cccc99" onload="document.myform.call_details.focus();" onBlur="self.focus()">
<font face="tahoma,ariel,sans">
<form name="myform" action="new-incident.php" autocomplete="off" method="post">
<input type="hidden" name="new_incident_form">
<?php
//<!-- <td align=right>
//<input type="text" name="displayClock" readonly disabled STYLE="color: black; background-color: white" size="6">
//</td> --> <!-- todo 1.8: possibly add countdown timer, new incidents should be entered in 30/60 seconds? -->
?>
<table border cellspacing=0 cellpadding=0 width="100%">
<tr><td bgcolor="#cccc99" class="text" width=100% height="100%">
<table cellpadding=3 cellspacing=0 width="100%" height="100%">
<!-- ****************************************** -->
<tr valign=top>
<td width=100% colspan=3 bgcolor="#993333" class="text">
<font color="white" size="+1">
<b> New Incident</b></font>
</td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td align=right class="label"><b><u>W</u>HAT IS THE PROBLEM?</b>
</td>
<td align=left class="text">
<label for="call_details" accesskey="w">
<input type="text" name="call_details" id="call_details" tabindex="1" size="50" maxlength="80">
</lable>
</td>
<td style="font-size: 12px; color:gray"> Ask caller for the general description of incident </td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<!-- ****************************************** -->
<tr>
<td align=right class="label"><b>W<u>H</u>ERE ARE YOU? (Where is the problem?)</b></td>
<td align=left class="text">
<label for="location" accesskey="h">
<input type="text" name="location" id="location" tabindex="2" size="50" maxlength="80">
</label>
</td>
<td style="font-size: 12px; color:gray"> Ask caller for the location of incident </td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<!-- ****************************************** -->
<tr valign=top>
<td width="30" align=right class="label"><b><u>T</u>ype Of Call:</b><br><span style="font-size:12px; color:gray">(Dispatcher's choice)</span></td>
<td width="50" align=left class="text">
<Label for="call_type" accesskey="t">
<select name="call_type" id="call_type" tabindex="5" size=12 onChange="handleIncidentType()" onKeyUp="handleIncidentType()">
<?php
if (!isset($row->call_type) || !$row->call_type || !strcmp("not selected", $row->call_type))
echo "<option selected value=\"not selected\">not selected</option>\n";
$type_result = MysqlQuery("SELECT * from incident_types");
while ($type_row = mysql_fetch_object($type_result)) {
echo "<option ";
if (isset($row->call_type) && !strcmp($type_row->call_type, $row->call_type)) echo "selected ";
echo "value=\"". $type_row->call_type ."\">".$type_row->call_type ."</option>\n";
}
mysql_free_result($type_result);
?>
</select>
</label>
</td>
</tr>
<tr><td colspan=4><br></td></tr>
<tr>
<td class="label"> </td>
<td class="label" align="middle">
<button type="submit" name="new_incident" tabindex="41" accesskey="S"><u>S</u>ave New Incident</button>
<button name="incident_abort" tabindex="43" accesskey="C" onClick='if (window.opener){window.opener.location.reload()} self.close()'><u>C</u>ancel New Incident</button>
</td>
</tr>
</table>
</td></tr></table>
</form>
</body>
</html>