PageRenderTime 32ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/members_only/incident_reporting/index.asp

https://github.com/evizitei/bcfpd_asp
ASP | 242 lines | 214 code | 16 blank | 12 comment | 10 complexity | e92da79e80dc753d04756b9794d5f3f5 MD5 | raw file
  1. <!-- #include virtual="/members_only/include/functions.asa"-->
  2. <%
  3. If Not Session("Authorized")(12) Then
  4. Response.Redirect "/members_only/index.asp"
  5. End If
  6. Dim Incident_ID
  7. Dim Time
  8. Dim AMPMVal
  9. Incident_ID = killChars(GetVal("Incident_ID", ""))
  10. AMPVal = GetVal("AMPM", "")
  11. Time = GetVal("Timereq", "") & AMPVal
  12. ' 2. Create a Recordset Object
  13. Set rsIncident = Server.CreateObject("ADODB.Recordset")
  14. Set rsIncTypes = Server.CreateObject("ADODB.Recordset")
  15. Set rsStations = Server.CreateObject("ADODB.Recordset")
  16. ' 4. If there is a request to update the new record, update the new record
  17. If Request.Form("Submit") = "Update Incident" Then
  18. rsIncident.Open "Incidents", cnnBCFPD,3,3
  19. rsIncident.AddNew
  20. For Each Item in Request.Form
  21. if trim(Request.Form(Item)) <> "" AND Item <> "Submit" AND Item <> "AMPM" then
  22. if item <> "Timereq" then
  23. rsIncident(Item) = killChars(Request.Form(Item))
  24. else
  25. 'Response.Write(Item & " = " & Time)
  26. rsIncident(Item) = Time
  27. end if
  28. end if
  29. Next
  30. rsIncident.Update
  31. rsIncident.Close
  32. End If
  33. ' If there is a request to update an existing record, update the existing record.
  34. If Request.Form("Submit") = "Update Existing Incident" Then
  35. rsIncident.Open "SELECT * FROM Incidents WHERE Incident_ID =" & Incident_ID, cnnBCFPD,3,3
  36. For Each Item in Request.Form
  37. if trim(Request.Form(Item)) <> "" AND Item <> "Submit" AND Item <> "Incident_ID" then
  38. 'if trim(Request.Form(Item)) <> "" AND Item <> "Submit" AND right(Item, 3) <> "req" AND Item <> "Incident_ID" then
  39. 'Response.Write(item)
  40. rsIncident(Item) = killChars(Request.Form(Item))
  41. 'elseif right(Item, 3) = "req" then
  42. ' Response.Write(item)
  43. ' rsIncident(Item) = Request.Form(Item)
  44. 'rsIncident(replace(Item, "req", "")) = Request.Form(Item)
  45. end if
  46. Next
  47. rsIncident.Update
  48. rsIncident.Close
  49. End If
  50. %>
  51. <!--#include virtual="/members_only/include/templates/top.asa"-->
  52. <!--#include virtual="/members_only/include/templates/members.asa"-->
  53. <table border="0" width="98%" cellspacing="0" cellpadding="5">
  54. <tr>
  55. <td class="PageTitle">Incident Reporting</td>
  56. </tr>
  57. <tr>
  58. <td width="100%" valign="bottom">
  59. <% If Request.Form("Submit") = "Add New Incident" OR Request.QueryString("Incident_ID") <> "" Then
  60. ' 6. If there is a request to add new record, add new record
  61. If Request.Form("Submit") = "Add New Incident" Then
  62. rsIncident.Open "Incidents", cnnBCFPD, 3, 3
  63. rsIncident.AddNew
  64. End If
  65. ' 7. If there is a request by clicking a hyper link, open the recordset and grab the selected record
  66. If Request.QueryString <> "" Then
  67. rsIncident.Open "SELECT * FROM Incidents WHERE Incident_ID = " & killChars(Request.QueryString("Incident_ID")), cnnBCFPD, 3, 3
  68. End If
  69. %>
  70. <!-- 8. A form is created that contains a table with update fields.-->
  71. <br>
  72. <font size="1"><strong>Items in bold are required.</strong></font>
  73. <form method="post" action="index.asp" id="form1" name="form1" onsubmit="return ValidateApp(document.form1.elements, 'You must enter a ');">
  74. <!-- 8a. A table is created that contains the requested information.-->
  75. <table border="1" cellpadding="3" cellspacing="0" bordercolor="#f2f2f2">
  76. <tr>
  77. <td class="AppLabel"><b>Incident #:</b></td>
  78. <td><input type="text" name="Incident_Numreq" value="<%=rsIncident("Incident_Numreq")%>" size="9" maxlength="9"></td>
  79. </tr>
  80. <tr>
  81. <td class="AppLabel"><b>Date:</b></td>
  82. <td><input type="text" name="Datereq" value="<%=rsIncident("Datereq")%>" size="9" maxlength="15"></td>
  83. </tr>
  84. <tr>
  85. <td class="AppLabel"><b>Time:</b></td>
  86. <td><input type="text" name="Timereq" value="<%=rsIncident("Timereq")%>" size="9" maxlength="15">&nbsp;
  87. <%if Incident_ID = "" then%>
  88. <select id="select1" name="AMPM">
  89. <option value="AM">A.M.</option>
  90. <option value="PM">P.M.</option>
  91. </select>
  92. <%end if%>
  93. </td>
  94. </tr>
  95. <tr>
  96. <td class="AppLabel"><b>Address 1:</b></td>
  97. <td><input type="text" name="Address1req" value="<%=rsIncident("Address1req")%>" size="60" maxlength="200"></td>
  98. <!-- <td align="right"><a href="image_list.asp?Edit=<%=Request.QueryString("Incident_ID")%>&FullPath=<%=server.URLEncode("c:\Websites\bcfdmo\images\Incident\")%>&Virtual=<%=server.URLEncode("/images/Incident")%>">Image Management</a></td> -->
  99. </tr>
  100. <tr>
  101. <td class="AppLabel">Address 2:</td>
  102. <td><input type="text" name="Address2" value="<%=rsIncident("Address2")%>" size="60" maxlength="200"></td>
  103. </tr>
  104. <tr>
  105. <td class="AppLabel"><b>City:</b></td>
  106. <td><input type="text" name="Cityreq" value="<%=rsIncident("Cityreq")%>" size="50" maxlength="100"></td>
  107. </tr>
  108. <tr>
  109. <td class="AppLabel"><b>State:</b></td>
  110. <td><input type="text" name="State" value="MO" size="2" Maxlength="2"></td>
  111. </tr>
  112. <tr>
  113. <td class="AppLabel">Zip:</td>
  114. <td><input type="text" name="Zip" value="<%=rsIncident("Zip")%>" size="5" maxlength="5"></td>
  115. </tr>
  116. <tr>
  117. <td class="AppLabel">Description:</td>
  118. <td><textarea rows="5" cols="50" id="textarea1" name="Description"><%=rsIncident("Description")%></textarea></td>
  119. </tr>
  120. <tr>
  121. <td class="AppLabel"><b>Incident Type:</b> </td>
  122. <td><select size="1" name="Type_IDreq">
  123. <option value>Choose Type...</option>
  124. <% rsIncTypes.Open "SELECT * FROM Incident_Types ORDER BY Number", cnnBCFPD, 3
  125. Do while not rsIncTypes.EOF %>
  126. <option <%if rsIncident("Type_IDreq") = rsIncTypes("Type_ID") then%> selected <%end if%> value="<%=rsIncTypes("Type_ID")%>"><%=rsIncTypes("Number") & " -- " & rsIncTypes("Name")%></option>
  127. <% rsIncTypes.MoveNext
  128. loop
  129. rsIncTypes.Close
  130. set rsIncTypes = Nothing
  131. %>
  132. </td>
  133. </tr>
  134. <tr>
  135. <td class="AppLabel"><b>Station:</b> </td>
  136. <td><select size="1" name="Station_Numberreq">
  137. <option value>Choose Station...</option>
  138. <% rsStations.Open "SELECT * from Stations", cnnBCFPD, 3
  139. Do while not rsStations.EOF %>
  140. <option <%if rsIncident("Station_Numberreq") = rsStations("Station_Number") then%> selected <%end if%> value="<%=rsStations("Station_Number")%>"><%=rsStations("Name")%></option>
  141. <% rsStations.MoveNext
  142. loop
  143. rsStations.Close
  144. set rsStations = Nothing
  145. %>
  146. </td>
  147. </tr>
  148. <tr>
  149. <td align="right" colspan="3">
  150. <!-- 8b. If Then Else statement to check if updating new record or existing.-->
  151. <% If Request.QueryString <> "" Then %>
  152. <a href="javascript:submitPlus(document.form1, 'Update Existing Incident');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  153. <img src="/images/spacer.gif" border="0" height="1" width="35">
  154. <a style="cursor: hand" OnClick="window.history.back();"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  155. <input type="hidden" name="Submit">
  156. <input type="hidden" name="Incident_ID" value="<%=rsIncident("Incident_ID")%>">
  157. <% Else %>
  158. <a href="javascript:submitPlus(document.form1, 'Update Incident');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  159. <img src="/images/spacer.gif" border="0" height="1" width="35">
  160. <a style="cursor: hand" OnClick="window.history.back();"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  161. <input type="Hidden" name="Submit">
  162. <% End If %>
  163. </td>
  164. </tr>
  165. </table>
  166. </form>
  167. <% Else %>
  168. <%rsIncident.Open "Select * From Incidents where datereq > DATEADD(day, - 14, GETDATE()) AND datereq < getdate() Order By Datereq ASC, Timereq ASC ", cnnBCFPD, 3%>
  169. <!-- 9. A form is created that contains a table with delete capability, Headline hyper links, and date info.-->
  170. <form method="post" action="index.asp" id="form2" name="form2">
  171. <!-- 10. A table is created that will contain a delete check box, Headline links, and date info.-->
  172. <table border="0" cellpadding="5" cellspacing="5" bordercolor="#f2f2f2">
  173. <tr>
  174. <td class="subheadercenter">Date</td>
  175. <td class="subheadercenter">Time</td>
  176. <td class="subheadercenter">Location</td>
  177. <td class="subheadercenter">Incident Type</td>
  178. <td class="subheadercenter">Description</td>
  179. <td class="subheadercenter">Edit</td>
  180. </tr>
  181. <!-- 11. Do While Loop to populate the table with database information.-->
  182. <% Do while not rsIncident.EOF %>
  183. <tr>
  184. <td class="contactinfo" valign="top"><%=rsIncident("Datereq")%></td>
  185. <td class="contactinfo" valign="top"><%=rsIncident("Timereq")%></td>
  186. <td align="left" class="contactinfo" valign="top"><%=rsIncident("Address1req")%>
  187. <%if rsIncident("Address2") <> "" then%>
  188. <%="<br>" & rsIncident("Address2")%>
  189. <%end if %>
  190. <%if rsIncident("Cityreq") <> "" then%>
  191. <%="<br>" & rsIncident("Cityreq") & ", " & rsIncident("State")%>
  192. <%end if %>
  193. <%if rsIncident("Zip") <> "" then%>
  194. <%="<br>" & rsIncident("Zip")%>
  195. <%end if %>
  196. </td>
  197. <td class="contactinfo" valign="top"><%rsIncTypes.Open "Select * from Incident_Types where Type_ID = " & rsIncident("Type_IDreq"), cnnBCFPD, 3%>
  198. <%=rsIncTypes("Name")%>
  199. <%rsIncTypes.Close %>
  200. </td>
  201. <td class="contactinfo" valign="top"><%=rsIncident("Description")%></td>
  202. <td valign="top"><a class="update" href="index.asp?Incident_ID=<%=rsIncident("Incident_ID")%>">edit incident</a></td>
  203. </tr>
  204. <% rsIncident.MoveNext
  205. Loop
  206. set rsIncTypes = Nothing
  207. rsIncident.Close
  208. %>
  209. <tr>
  210. <td align="right" colspan="6">
  211. <a href="javascript:submit(document.form2, 'Add New Incident');"><img SRC="/images/members/buttons/add.gif" border="0"></a>
  212. <img src="/images/spacer.gif" border="0" height="1" width="35">
  213. <a style="cursor: hand" OnClick="window.history.back();"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  214. <input type="hidden" name="Submit">
  215. </td>
  216. </tr>
  217. </table>
  218. </form>
  219. <%
  220. End If
  221. set rsIncident = Nothing
  222. %>
  223. </td>
  224. </tr>
  225. </table>
  226. <!--#include virtual="/members_only/include/templates/bottom.asa"-->