/beta/admin/costs.asp

http://github.com/khaneh/Orders · ASP · 238 lines · 229 code · 3 blank · 6 comment · 27 complexity · efb944a3c85a89af70ebad097649e377 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. ' Admin
  3. PageTitle=" "
  4. SubmenuItem=11
  5. %>
  6. <!--#include file="top.asp" -->
  7. <%
  8. function echoOperationType(operationID, driverID)
  9. result="<select name='operationType'>"
  10. set rss = Conn.Execute("select * from cost_operation_type where driver_id=" & driverID)
  11. while not rss.eof
  12. result = result & "<option value='" & rss("id") & "'"
  13. if cint(rss("id")) = operationID then result = result & " selected='selected'"
  14. result = result & ">" & rss("name") & "</option>"
  15. rss.moveNext
  16. wend
  17. result = result & "</select>"
  18. echoOperationType = result
  19. rss.close
  20. end function
  21. if request("act")="" or request("act")="" then
  22. %>
  23. <form method=post action='?act=add&step=costCenters'>
  24. <span> :</span>
  25. <input type=text name='costCenterName'>
  26. <input type=submit value=' '>
  27. </form>
  28. <%
  29. set rs=Conn.Execute("SELECT cost_centers.id,cost_centers.name, count(cost_drivers.id) as driverCount FROM cost_centers left outer join cost_drivers on cost_centers.id=cost_drivers.cost_center_id group by cost_centers.id,cost_centers.name")
  30. while not rs.eof
  31. response.write("<a title=' ' href='?act=show&step=driver&id="&rs("id")&"'>"&rs("Name")&"( "&rs("driverCount")&" )</a>")
  32. if CInt(rs("driverCount"))=0 then response.write("<a style='margin:0 10 0 0;' title=' ' href='?act=del&step=center&id="&rs("id")&"'> !</a>")
  33. response.write("<br>")
  34. rs.moveNext
  35. wend
  36. rs.close
  37. elseif request("act")="add" then '------------------ ADD ACTION ----------------
  38. if request("step")="costCenters" and request.form("costCenterName")<>"" then
  39. '--------------- add cost center ------------------
  40. Conn.Execute("Insert into cost_centers ([Name]) VALUES (N'"&request.form("costCenterName")&"')")
  41. msg=" " & "<b><i>" & request.form("costCenterName") & "</i></b>" & " ."
  42. response.redirect "?msg=" & Server.URLEncode(msg)
  43. elseif request("step")="operationType" and request("opName")<>"" then
  44. '-------------- add operation type -----------------
  45. Conn.Execute("INSERT INTO cost_operation_type (driver_id,name) VALUES ("&request("driverID")&",N'"&request("opName")&"')")
  46. msg=" " & "<b><i>" & request.form("opName") & "</i></b>" & " ."
  47. response.redirect "?act=show&step=driver&id="&request("centerID")&"&msg=" & Server.URLEncode(msg)
  48. elseif request("step")="driver" then
  49. '------------------ add driver ---------------------
  50. isTime="0"
  51. isCount="0"
  52. isDirect="0"
  53. isContinuous="0"
  54. if request.form("isTime")="on" then isTime="1"
  55. if request.form("isCount")="on" then isCount="1"
  56. if request.form("isDirect")="on" then isDirect="1"
  57. if request.form("isContinuous")="on" then isContinuous="1"
  58. driverName=sqlsafe(request.form("driverName"))
  59. id=cint(request("centerID"))
  60. rate=cdbl(request("rate"))
  61. sql="INSERT INTO cost_drivers ([name],[cost_center_id],[rate],[is_direct],is_countinuous,is_time,is_count) VALUES (N'"& driverName & "'," & id & "," & rate & "," & isDirect & ","&isContinuous&", " & isTime & "," & isCount & ")"
  62. response.write(sql)
  63. Conn.Execute(sql)
  64. msg=" "
  65. response.redirect "?step=driver&act=show&id="&id&"&msg=" & Server.URLEncode(msg)
  66. end if
  67. elseif request("act")="del" then '----------------------- DELETE -------------------------------
  68. if request("step")="center" then
  69. if cint(request("id"))>0 then
  70. Conn.Execute("delete cost_centers where id="&request("id"))
  71. msg=" ."
  72. response.redirect "?msg=" & Server.URLEncode(msg)
  73. end if
  74. elseif request("step")="diver" then
  75. if isNumeric(request("rowID")) then
  76. set rs=Conn.Execute("SELECT * from costs where driver_id=" & cint(request("rowID")))
  77. if rs.eof then
  78. Conn.Execute("DELETE cost_operation_type WHERE driver_id=" & cint(request("rowID")))
  79. Conn.Execute("DELETE cost_drivers WHERE id=" & cint(request("rowID")))
  80. msg=" ʝ "
  81. else
  82. msg=" "
  83. end if
  84. rs.close
  85. response.redirect "?step=driver&act=show&id="&request("id")&"&msg=" & Server.URLEncode(msg)
  86. end if
  87. elseif request("step")="operationType" then
  88. if isNumeric(request("rowID")) then
  89. set rs=Conn.Execute("SELECT * from costs where operation_type=" & cint(request("rowID")))
  90. if rs.eof then
  91. Conn.Execute("DELETE cost_operation_type WHERE id=" & cint(request("rowID")))
  92. msg=" "
  93. else
  94. msg=" "
  95. end if
  96. response.redirect "?step=driver&act=show&id="&request("id")&"&msg=" & Server.URLEncode(msg)
  97. end if
  98. end if
  99. elseif request("act")="edit" then '------------------- EDIT -----------------------
  100. if request("step")="driver" then
  101. isTime="0"
  102. isCount="0"
  103. isDirect="0"
  104. isContinuous="0"
  105. if request.form("isTime")="on" then isTime="1"
  106. if request.form("isCount")="on" then isCount="1"
  107. if request.form("isDirect")="on" then isDirect="1"
  108. if request.form("isContinuous")="on" then isContinuous="1"
  109. driverName=sqlsafe(request.form("driverName"))
  110. id=cint(request("centerID"))
  111. rate=cdbl(request("rate"))
  112. unitSize=sqlsafe(request.form("unitSize"))
  113. rowID=request.form("rowID")
  114. sql="update cost_drivers SET [name]=N'"& driverName & "',[rate]=" & rate & ", [is_direct]=" & isDirect & ", is_countinuous="&isContinuous &",is_time=" & isTime & ", is_count=" & isCount & " WHERE id="&rowID
  115. 'response.write(sql)
  116. Conn.Execute(sql)
  117. msg=" "
  118. response.redirect "?step=driver&act=show&id="&id&"&msg=" & Server.URLEncode(msg)
  119. elseif request("step")="operationType" then
  120. sql="UPDATE cost_operation_type set [name]=N'"&request("opName")&"' WHERE id=" & request("id")
  121. Conn.Execute(sql)
  122. msg=" "
  123. response.redirect "?step=driver&act=show&id="&request("centerID")&"&msg=" & Server.URLEncode(msg)
  124. end if
  125. elseif request("act")="show" then '---------------------- SHOW ------------------------------------
  126. if request("step")="driver" then
  127. if isNumeric(request("id")) then
  128. id=request("id")
  129. set rsCost= Conn.Execute("SELECT * FROM cost_centers where id="&id)
  130. if rsCost.eof then
  131. response.write("! !!!!!!!")
  132. response.end
  133. end if
  134. costCenterName=rsCost("name")
  135. rsCost.close
  136. sql = "SELECT * FROM cost_drivers WHERE cost_center_id="&id
  137. 'response.write sql
  138. set rs=Conn.Execute(sql)
  139. %>
  140. <a title="Ґ " href="costs.asp"> <%=costCenterName%></a>
  141. <br><br>
  142. <table border="0" cellpadding="0" cellspacing="0">
  143. <tr>
  144. <td align="center"><b></b></td>
  145. <td align="center"><b></b></td>
  146. <td align="center"><b></b></td>
  147. <td align="center"><b></b></td>
  148. <td align="center"><b></b></td>
  149. <td align="center"><b>ʐ</b></td>
  150. <td colspan=2></td>
  151. </tr>
  152. <%
  153. while not rs.eof
  154. %>
  155. <tr>
  156. <form method=post action='?act=edit&step=driver&centerID=<%=id%>'>
  157. <td><input type="text" name="driverName" value="<%=rs("name")%>"></td>
  158. <td>
  159. <input type=hidden name='rowID' value='<%=rs("id")%>'>
  160. <input type="checkbox" name="isTime" <%if rs("is_time") then response.write "checked='checked'"%>>
  161. </td>
  162. <td>
  163. <input type="checkbox" name="isCount" <%if rs("is_count") then response.write "checked='checked'"%>>
  164. </td>
  165. <td><input type=text name='rate' value='<%=rs("rate")%>' style='direction:LTR;'></td>
  166. <td><input type=checkbox name='isDirect' <% if rs("is_direct")="True" then response.write "checked" %>></td>
  167. <td><input type=checkbox name='isContinuous' <% if rs("is_countinuous")="True" then response.write "checked"%>></td>
  168. <td><input type=submit value=' ' ></td>
  169. <td><input type=button value=' ' onclick='if (confirm(" ʝ Ͽ\n\n")) window.location="costs.asp?act=del&step=driver&rowID=<%=rs("id")%>&id=<%=id%>";'></td>
  170. </form>
  171. </tr>
  172. <tr bgcolor="#AAFFFF">
  173. <td colspan="8" align="center"><b>ʝ</b></td>
  174. </tr>
  175. <%
  176. set rsop=Conn.Execute("select * from cost_operation_type where driver_id=" & rs("id"))
  177. if rsop.eof then
  178. %>
  179. <tr bgcolor="#AAFFFF">
  180. <td colspan="8" align="center"><font color="red"> ! </font></td>
  181. </tr>
  182. <%
  183. end if
  184. while not rsop.eof
  185. %>
  186. <tr bgcolor="#AAFFFF">
  187. <form method="post" action="?act=edit&step=operationType&centerID=<%=id%>">
  188. <td colspan="6">
  189. <input type="hidden" name="id" value="<%=rsop("id")%>">
  190. <input name="opName" type="text" value="<%=rsop("name")%>">
  191. </td>
  192. <td><input type=submit value=' ' ></td>
  193. <td><input type=button value=' ' onclick='if (confirm(" Ͽ\n\n")) window.location="costs.asp?act=del&step=operationType&rowID=<%=rsop("id")%>&id=<%=id%>";'></td>
  194. </form
  195. </tr>
  196. <%
  197. rsop.moveNext
  198. wend
  199. rsop.close
  200. %>
  201. <tr bgcolor="#AAAAFF">
  202. <form method="post" action="?act=add&step=operationType&centerID=<%=id%>">
  203. <td colspan="1" align="center"> </td>
  204. <td colspan="5">
  205. <input type="text" name="opName">
  206. <input type="hidden" name="driverID" value="<%=rs("id")%>">
  207. </td>
  208. <td colspan="2" align="center">
  209. <input type="submit" name="action" value=" ">
  210. </td>
  211. </form>
  212. </tr>
  213. <%
  214. rs.moveNext
  215. wend
  216. rs.close
  217. %>
  218. <tr>
  219. <form method=post action='?act=add&step=driver&centerID=<%=id%>'>
  220. <td><input type="text" name="driverName"></td>
  221. <td><input type="checkbox" name="isTime" checked='checked'></td>
  222. <td><input type="checkbox" name="isCount" checked='checked'></td>
  223. <td><input type=text name='rate' style='direction:LTR;'></td>
  224. <td><input type=checkbox name='isDirect'></td>
  225. <td><input type=checkbox name='isContinuous'></td>
  226. <td colspan=2 align=center><input type=submit name='action' value=' '></td>
  227. </form>
  228. </tr>
  229. </table>
  230. <%
  231. end if
  232. end if
  233. end if
  234. %>
  235. <!--#include file="tah.asp" -->