/beta/admin/BankerMng.asp

http://github.com/khaneh/Orders · ASP · 255 lines · 226 code · 20 blank · 9 comment · 39 complexity · 91acd2e97920696e5d283a6b68b64401 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. ' Admin
  3. PageTitle=" "
  4. SubmenuItem=7
  5. %>
  6. <!--#include file="top.asp" -->
  7. <BR><BR><BR><CENTER>
  8. <%
  9. function sqlSafeNoEnter (s)
  10. st=s
  11. st=replace(St,"'","`")
  12. st=replace(St,chr(34),"`")
  13. st=replace(St,vbCrLf," ")
  14. sqlSafeNoEnter=st
  15. end function
  16. '-----------------------------------------------------------------------------------------------------
  17. '---------------------------------------------------------------------------------- Submit New or Edit
  18. '-----------------------------------------------------------------------------------------------------
  19. if request("act")="submitBanker" then
  20. id = sqlSafeNoEnter(request.form("id"))
  21. bname = sqlSafeNoEnter(request.form("bname"))
  22. Responsible = sqlSafeNoEnter(request.form("Responsible"))
  23. if request.form("IsBankAccount")="on" then
  24. IsBankAccount=1
  25. else
  26. IsBankAccount=0
  27. end if
  28. if request.form("id") = "" then
  29. Conn.Execute ("INSERT INTO Bankers ([Name], IsBankAccount, Responsible, LastCheckedDate, LastCheckedBy) VALUES ("&_
  30. "N'"& bname & "', '"& IsBankAccount & "','"& Responsible & "' , N'0', 0) ")
  31. 'response.write "<B> </B><BR>"
  32. set rsv=conn.execute ("select max(id) as maxID from Bankers where [Name]=N'" & bname & "'")
  33. id = rsv("maxID")
  34. else
  35. Conn.Execute ("UPDATE Bankers SET [name]=N'"& sqlSafeNoEnter(request.form("bname"))& "', [IsBankAccount]='"& IsBankAccount & "', [Responsible]='"& Responsible & "' WHERE ([ID]='"& id & "')")
  36. 'response.write "<B> </B><BR>"
  37. Conn.Execute ("DELETE FROM BankerCheqStatusGLAccountRelation where (Banker = " & id & ") and GL = " & OpenGL)
  38. end if
  39. for i=1 to request.form("GLaccounts").count
  40. if not request.form("GLaccounts")(i) = "" then
  41. Conn.Execute ("INSERT INTO BankerCheqStatusGLAccountRelation (Banker, CheqStatus, GLAccount, GL) VALUES (" & id & ", " & request.form("GLaccountsID")(i) & "," & request.form("GLaccounts")(i) & "," & OpenGL & ")")
  42. end if
  43. next
  44. end if
  45. '-----------------------------------------------------------------------------------------------------
  46. '--------------------------------------------------------------------- Add a new banker & Bankers List
  47. '-----------------------------------------------------------------------------------------------------
  48. EDITFLAG = false
  49. if request("id") <> "" and isnumeric(request("id")) then
  50. id = request("id")
  51. EDITFLAG = true
  52. set rsv=conn.execute ("SELECT Bankers.ID, Bankers.Name, Bankers.IsBankAccount, Bankers.CurrentBalance, Users.ID, Bankers.Responsible, Users.RealName FROM Bankers INNER JOIN Users ON Bankers.Responsible = Users.ID WHERE Bankers.ID=" & id )
  53. if rsv.eof then
  54. EDITFLAG = false
  55. else
  56. BankerName = rsv("Name")
  57. ID = rsv("ID")
  58. IsBankAccount = rsv("IsBankAccount")
  59. end if
  60. rsv.close
  61. end if
  62. %>
  63. <TABLE width=80%>
  64. <TR>
  65. <TD valign=top style="border:solid 1pt white">
  66. <TABLE border=0 width=100%>
  67. <form method=post action="?act=submitBanker">
  68. <TR bgcolor=white><TD align=center ><SPAN name="setGLsSpan" id="setGLsSpan">
  69. <% if EDITFLAG then%>
  70. <% else %>
  71. <% end if %>
  72. </SPAN></TD></TR>
  73. <TR>
  74. <TD align=center>
  75. <BR>
  76. : <INPUT TYPE="hidden" name="id" value="<%=id%>"><input type="text" name="bname" value="<%=BankerName%>" size=35>&nbsp;&nbsp;&nbsp;
  77. :
  78. <select name="Responsible" class="custgeninput" style="width:90; font-family:tahoma; width:123;">
  79. <option value=""> </option>
  80. <option value="">---------------------</option>
  81. <% set rsv=conn.execute ("SELECT * FROM Users WHERE Display=1 ORDER BY RealName")
  82. do while not rsv.eof
  83. %>
  84. <option value="<%=rsv("ID")%>" <%
  85. if ID = rsv("ID") and not ID="" then
  86. response.write "selected"
  87. end if
  88. %>><%=rsv("realname")%></option>
  89. <%
  90. rsv.movenext
  91. loop
  92. rsv.close
  93. %>
  94. </select> &nbsp;&nbsp;&nbsp;
  95. <INPUT TYPE="checkbox" NAME="IsBankAccount" onclick="changeGLsTD()" <%
  96. if IsBankAccount then response.write "checked"
  97. %>>
  98. <BR><BR>
  99. </TD>
  100. </TR>
  101. <TR>
  102. <TD id="setGLsTD" name="setGLsTD">
  103. <% if EDITFLAG then %>
  104. <% if IsBankAccount then %>
  105. <table width=100%>
  106. <tr>
  107. <% set rsv=conn.execute ("select * from RcvPayChqStatus where IsBankAccount=1")
  108. do while not rsv.eof
  109. set rsw=conn.execute ("select * from BankerCheqStatusGLAccountRelation WHERE (CheqStatus = " & rsv("id") & ") AND (Banker = " & id & ") and GL=" & openGL)
  110. %>
  111. <td align=center><%=rsv("Name")%>
  112. <br><INPUT TYPE='text' NAME='GLaccounts' size=7 value='<% if not rsw.eof then response.write rsw("GLAccount")%>'>
  113. <INPUT TYPE='hidden' NAME='GLaccountsID' value='<%=rsv("id")%>'><br>
  114. <% if rsv("IsRcvdChqStatus") then %> () <% else %> ()<% end if %>
  115. </td><%
  116. rsv.movenext
  117. loop
  118. rsv.close %>
  119. </tr></table>
  120. <% else %>
  121. <table width=100%>
  122. <tr>
  123. <% set rsv=conn.execute ("select * from RcvPayChqStatus where IsBankAccount=0 and IsRcvdChqStatus = 0")
  124. do while not rsv.eof
  125. set rsw=conn.execute ("select * from BankerCheqStatusGLAccountRelation WHERE (CheqStatus = " & rsv("id") & ") AND (Banker = " & id & ") and GL=" & openGL)
  126. %>
  127. <td align=center><%=rsv("Name")%><br><INPUT TYPE='text' NAME='GLaccounts' size=7 value='<% if not rsw.eof then response.write rsw("GLAccount")%>'>
  128. <INPUT TYPE='hidden' NAME='GLaccountsID' value='<%=rsv("id")%>'>
  129. </td><%
  130. rsv.movenext
  131. loop
  132. rsv.close %>
  133. </tr></table>
  134. <% end if %>
  135. <% end if %>
  136. </TD>
  137. </TR>
  138. </TABLE>
  139. <BR>
  140. <CENTER>
  141. <% if EDITFLAG then %>
  142. <INPUT TYPE="button" value="" onclick="window.location='BankerMng.asp'">
  143. <% end if %>
  144. <INPUT TYPE="submit" name="dokme" <% if EDITFLAG then %>value=" "<% else %> value=""<% end if %>></CENTER>
  145. <BR>
  146. </TD>
  147. </form>
  148. </TR>
  149. <TR>
  150. <TD><BR><BR>
  151. <table id="result" width=100%>
  152. <tr style="background-color:white">
  153. <td></td>
  154. <td align=center> </td>
  155. <td align=center> </td>
  156. <td align=center> ʿ</td>
  157. </tr>
  158. <%
  159. set rsv=conn.execute ("SELECT Bankers.ID as BID, Bankers.Name, Bankers.IsBankAccount, Bankers.CurrentBalance, Users.ID, Bankers.Responsible, Users.RealName FROM Bankers INNER JOIN Users ON Bankers.Responsible = Users.ID ORDER BY Bankers.ID")
  160. tmpColor2 = "#cccccc"
  161. tmpColor = ""
  162. do while not rsv.eof
  163. %>
  164. <a href="?id=<%=rsv("bid")%>">
  165. <tr style="cursor:hand" onMouseOver="this.style.backgroundColor='<%=tmpColor2%>'" onMouseOut="this.style.backgroundColor='<%=tmpColor%>'" onclick="copyInfo(this.rowIndex);">
  166. <td><INPUT TYPE="hidden" name="idList" value="<%=rsv("id")%>"><%=rsv("Name")%></td>
  167. <td><%=rsv("RealName")%> <INPUT TYPE="hidden" name=IDLIST value="<%=rsv("ID")%>"></td>
  168. <td><%=rsv("CurrentBalance")%></td>
  169. <td align=center><% if rsv("IsBankAccount") then %><INPUT TYPE="checkbox" NAME="isBank" disabled checked><% else %><INPUT TYPE="checkbox" NAME="isBank" disabled><% end if %></td>
  170. </tr>
  171. <%
  172. rsv.movenext
  173. loop
  174. rsv.close
  175. %>
  176. </table>
  177. <BR>
  178. </TD>
  179. </TR>
  180. </TABLE>
  181. </CENTER>
  182. <SCRIPT LANGUAGE="JavaScript">
  183. <!--
  184. s1 = "<table width=100%><tr><% set rsv=conn.execute ("select * from RcvPayChqStatus where IsBankAccount=1")
  185. do while not rsv.eof
  186. %><td align=center><%=rsv("Name")%><br><INPUT TYPE='text' NAME='GLaccounts' size=7><INPUT TYPE='hidden' NAME='GLaccountsID' value='<%=rsv("id")%>'><BR><% if rsv("IsRcvdChqStatus") then %> () <% else %> ()<% end if %></td><%
  187. rsv.movenext
  188. loop
  189. rsv.close
  190. %></tr></table>"
  191. s2 = "<table width=100%><tr><% set rsv=conn.execute ("select * from RcvPayChqStatus where IsBankAccount=0 and IsRcvdChqStatus = 0")
  192. do while not rsv.eof
  193. %><td align=center><%=rsv("Name")%><br><INPUT TYPE='text' NAME='GLaccounts' size=7><INPUT TYPE='hidden' NAME='GLaccountsID' value='<%=rsv("id")%>'></td><%
  194. rsv.movenext
  195. loop
  196. rsv.close
  197. %></tr></table>"
  198. function copyInfo(index){
  199. var myObj=document.getElementsByTagName("table").item('result').getElementsByTagName("tr").item(index);
  200. document.all.bname.value =myObj.getElementsByTagName("td").item(0).innerText;
  201. document.all.IsBankAccount.checked =document.getElementsByName("isBank")[index-1].checked;
  202. document.all.id.value =document.getElementsByName("idList")[index-1].value;
  203. document.all.Responsible.value =document.getElementsByName("IDLIST")[index-1].value;
  204. document.all.dokme.value = " "
  205. document.all.setGLsSpan.innerText = " " + myObj.getElementsByTagName("td").item(0).innerText;
  206. if (document.getElementsByName("isBank")[index-1].checked)
  207. document.all.setGLsTD.innerHTML = s1;
  208. else
  209. document.all.setGLsTD.innerHTML = s2;
  210. document.all.bname.select();
  211. document.all.bname.focus();
  212. }
  213. function changeGLsTD(){
  214. if (document.all.IsBankAccount.checked)
  215. {
  216. s2 = document.all.setGLsTD.innerHTML;
  217. document.all.setGLsTD.innerHTML = s1;
  218. }
  219. else
  220. {
  221. s1 = document.all.setGLsTD.innerHTML;
  222. document.all.setGLsTD.innerHTML = s2;
  223. }
  224. }
  225. document.all.bname.focus();
  226. <% if not EDITFLAG then %>
  227. // by default, new bankers are BankAccount
  228. document.all.setGLsTD.innerHTML = s1;
  229. document.all.IsBankAccount.checked = true ;
  230. <% end if %>
  231. //-->
  232. </SCRIPT>
  233. <!--#include file="tah.asp" -->