/beta/bank/submitDraft.asp

http://github.com/khaneh/Orders · ASP · 327 lines · 263 code · 35 blank · 29 comment · 28 complexity · 9901a45bc1accce3ed0730b8c59fa99f MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'Bank (10 [=A])
  3. PageTitle= " "
  4. SubmenuItem=4
  5. if not Auth("A" , 4) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <style>
  11. .GenInput { font-family:tahoma; font-size: 9pt; border: 1px solid black; text-align:right; }
  12. .GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
  13. </style>
  14. <BR><BR>
  15. <%
  16. '-----------------------------------------------------------------------------------------------------
  17. '---------------------------------------------------------------------------------- Submit Transaction
  18. '-----------------------------------------------------------------------------------------------------
  19. if request("act")="submit" then
  20. ON ERROR RESUME NEXT
  21. errorFound= false
  22. CustomerID= clng(request.form("CustomerID"))
  23. Amount= cdbl(text2value(request.form("Amount")))
  24. bank = cint(request.form("Bank"))
  25. ReceiptNo = clng(request.form("ReceiptNo"))
  26. Reason= cint(request.form("Reason"))
  27. if Err.Number<>0 then
  28. Err.clear
  29. errorFound= true
  30. errorMsg= Server.URLEncode("!")
  31. end if
  32. if NOT errorFound then
  33. effectiveDate= sqlSafe(request.form("ReceiptDate"))
  34. '---- Checking wether CustomerID is valid
  35. mySQL="SELECT ID FROM Accounts WHERE (ID="& CustomerID & ")"
  36. Set RS1=Conn.execute(mySQL)
  37. if RS1.eof then
  38. conn.close
  39. response.redirect "?errMsg=" & Server.URLEncode("!<br> ["& CustomerID & "] .")
  40. end if
  41. RS1.close
  42. '----
  43. '---- Checking wether EffectiveDate is valid in current open GL
  44. if (effectiveDate < session("OpenGLStartDate")) OR (effectiveDate > session("OpenGLEndDate")) then
  45. errorFound= true
  46. errorMsg= Server.URLEncode("!<br> .")
  47. end if
  48. '----
  49. '----- Check GL is closed
  50. if (session("IsClosed")="True") then
  51. 'Conn.close
  52. errorFound=true
  53. errorMsg=Server.URLEncode("! .")
  54. end if
  55. '----
  56. '-------- Finding SYS and firstGLAccount for the selected Reason
  57. mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")"
  58. Set RS1=Conn.execute(mySQL)
  59. if RS1.eof then
  60. errorFound= true
  61. errorMsg= Server.URLEncode("!")
  62. else
  63. Sys= RS1("Acron")
  64. firstGLAccount= RS1("GLAccount")
  65. end if
  66. RS1.close
  67. '-------- Finding GLAccount for the selected bank
  68. '---- CheqStatus = 2 means 'vosool shode'
  69. mySQL = "SELECT BankerCheqStatusGLAccountRelation.GLAccount, Bankers.Name FROM BankerCheqStatusGLAccountRelation INNER JOIN Bankers ON BankerCheqStatusGLAccountRelation.Banker = Bankers.ID WHERE (Bankers.ID="& bank & ") AND (Bankers.IsBankAccount = 1) AND (BankerCheqStatusGLAccountRelation.GL = '"& openGL & "') AND (BankerCheqStatusGLAccountRelation.CheqStatus = 2)"
  70. Set RS1 = Conn.Execute(mySQL)
  71. if RS1.eof then
  72. conn.close
  73. response.redirect "?errMsg=" & Server.URLEncode("!<br> .")
  74. else
  75. BankName= RS1("Name")
  76. GLAccount= RS1("GLAccount")
  77. end if
  78. RS1.close
  79. '--------
  80. end if
  81. if Err.Number<>0 then
  82. Err.clear
  83. errorFound= true
  84. errorMsg= Server.URLEncode("!")
  85. end if
  86. ON ERROR GOTO 0
  87. if errorFound then
  88. conn.close
  89. response.redirect "?errMsg=" & Server.URLEncode("!")
  90. end if
  91. creationDate= shamsiToday()
  92. comment= sqlSafe(request.form("comment"))
  93. if comment <> "" then comment = " (" & comment & ")"
  94. if instr(BankName,"(")>0 then
  95. BankName=left(BankName,instr(BankName,"(")-1)
  96. end if
  97. theDescription = " "& ReceiptNo & " "& BankName & " "& customerID & comment
  98. ' #########################################################
  99. ' INSERTING RECEIPT ...
  100. ' #########################################################
  101. ' CHQAMOUNT ...
  102. CHQAMOUNT =0
  103. ' CHQQTTY must be Receipt Qtty of Cheques
  104. CHQQTTY =0
  105. DepositAmount = 0
  106. mySQL="INSERT INTO Receipts (CreatedDate, sys, CreatedBy, EffectiveDate, Number, Customer, CashAmount, DepositAmount, ChequeAmount, ChequeQtty, TotalAmount) VALUES (N'" &_
  107. creationDate & "', '"& sys & "' , '"& session("ID") & "', N'" & effectiveDate & "', '"& ReceiptNo & "', '"& CustomerID & "', '"& amount & "', '"& DepositAmount & "', '"& CHQAMOUNT & "', '"& CHQQTTY & "', '"& amount & "');SELECT @@Identity AS NewReceipt"
  108. set RS1 = Conn.execute(mySQL).NextRecordSet
  109. ReceiptID=RS1("NewReceipt")
  110. RS1.close
  111. ' #########################################################
  112. ' INSERTING CASH ...
  113. ' #########################################################
  114. mySQL="INSERT INTO ReceivedCash (Receipt, Amount, Banker, Description) VALUES ('"&_
  115. ReceiptID & "', '" & amount & "', '" & bank & "', N'"& theDescription & "')"
  116. conn.Execute(mySQL)
  117. chequeCount=0
  118. totalChequeAmount=0
  119. '**************************** Creating Item for Receipt ****************
  120. '*** Type = 2 means Item is a Receipt
  121. ItemType = 2
  122. mySQL="INSERT INTO "& sys & "Items (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, Link, Reason, CreatedDate, CreatedBy, Type, IsCredit, AmountOriginal, RemainedAmount) VALUES ('"&_
  123. GLAccount & "', '"& OpenGL & "', "& firstGLAccount & ", "& customerID & ", N'"& effectiveDate & "', "& ReceiptID & ", "& Reason & ", N'"& creationDate & "' , "& session("id") & ", "& ItemType & ", 1, "& Amount & ","& Amount & ")"
  124. conn.Execute(mySQL)
  125. '***------------------------- Creating Item for Receipt ----------------
  126. Conn.Execute ("UPDATE Accounts SET "& sys & "Balance="& sys & "Balance+"& Amount & " WHERE (ID = "& customerID & ")")
  127. Conn.Execute ("UPDATE Bankers SET CurrentBalance=CurrentBalance+"& amount & " WHERE ID="& bank )
  128. response.redirect "../"& sys & "/AccountReport.asp?act=showReceipt&sys="& sys & "&receipt=" & ReceiptID &"&msg="& Server.URLEncode(" .<br><a href='../bank/submitDraft.asp'>Ґ </a>")
  129. '-----------------------------------------------------------------------------------------------------
  130. '----------------------------------------------------------------------------- Input a new GL Memo Doc
  131. '-----------------------------------------------------------------------------------------------------
  132. elseif request("act")="" then
  133. %>
  134. <input type="hidden" Name='tmpDlgArg' value=''>
  135. <input type="hidden" Name='tmpDlgTxt' value=''>
  136. <FORM METHOD=POST ACTION="?act=submit" onsubmit="return isEmpty()">
  137. <TABLE align=center style="border:1pt solid white">
  138. <TR>
  139. <TD colspan='2'>
  140. <TABLE width='100%' cellpadding='5'>
  141. <TR>
  142. <TD bgcolor=white>: </TD>
  143. <%
  144. mySQL="SELECT * FROM AXItemReasons WHERE Display=1 ORDER BY ID"
  145. set RS1=conn.execute(mySQL)
  146. while not RS1.eof
  147. %> <TD bgcolor=white><INPUT TYPE="radio" NAME="Reason" value="<%=RS1("ID")%>" <% if reason=RS1("ID") then response.write "checked "%>><%=RS1("Name")%><br><span style='font-size:7pt;width:100%;text-align:left;'> <%="[" & RS1("GLAccount") & "]"%> </span></TD>
  148. <% RS1.movenext
  149. wend
  150. %>
  151. </TR>
  152. </TABLE>
  153. </TD>
  154. </TR>
  155. <TR>
  156. <TD>
  157. :
  158. </TD>
  159. <TD>
  160. <INPUT class="GenInput" style='direction:LTR;text-align:left;' NAME="ReceiptDate" TYPE="text" maxlength="10" size="10" value="" onblur="acceptDate(this)">
  161. </TD>
  162. </TR>
  163. <TR>
  164. <TD>
  165. :
  166. </TD>
  167. <TD>
  168. <INPUT class="GenInput" style='direction:LTR;text-align:left;' NAME="ReceiptNo" TYPE="text" size="10" >
  169. </TD>
  170. </TR>
  171. <TR>
  172. <TD>
  173. :
  174. </TD>
  175. <TD>
  176. <INPUT TYPE="text" NAME="amount" class='GenInput' style='width:170px;direction:LTR;text-align:left;' onKeyPress="return maskNumber(this);" onBlur="$(this).val(echoNum($(this).val()));">
  177. </TD>
  178. </TR>
  179. <TR>
  180. <TD>
  181. :
  182. </TD>
  183. <TD>
  184. <table width='100%' border=0>
  185. <tr>
  186. <td width=75><INPUT TYPE="text" NAME="customerID" class='GenInput' style='width:70px;direction:LTR;text-align:left;' maxlength="10" onKeyPress='return mask(this);' onBlur='check(this);'></td>
  187. <td><INPUT TYPE="text" NAME="accountName" size=28 readonly value="<%=accountName%>" style="background-color:transparent"></td>
  188. </tr>
  189. </table>
  190. </TD>
  191. </TR>
  192. <TR>
  193. <TD>
  194. :
  195. </TD>
  196. <TD>
  197. <select name="Bank" class=inputBut style="width:250; ">
  198. <option value="-1"> </option>
  199. <option value="-1">---------------------------------</option>
  200. <% set RSV=Conn.Execute ("SELECT * FROM Bankers WHERE (IsBankAccount = 1 AND isActive=1)")
  201. Do while not RSV.eof
  202. %>
  203. <option value="<%=RSV("id")%>"><%=RSV("Name")%> </option>
  204. <%
  205. RSV.moveNext
  206. Loop
  207. RSV.close
  208. %>
  209. </select>
  210. </TD>
  211. </TR>
  212. <TR>
  213. <TD>
  214. :
  215. </TD>
  216. <TD>
  217. <textarea NAME='comment' cols='30' class='GenInput' style='width:250px;'></textarea>
  218. </TD>
  219. </TR>
  220. <TR>
  221. <TD colspan='2' height='2' ><hr></TD>
  222. </TR>
  223. <TR>
  224. <TD colspan='2' align='center'>
  225. <INPUT TYPE="submit" value=" " class='GenButton'><br><br>
  226. </TD>
  227. </TR>
  228. </TABLE>
  229. </FORM>
  230. <BR><BR>
  231. <SCRIPT LANGUAGE="JavaScript">
  232. <!--
  233. var dialogActive=false;
  234. function mask(src){
  235. var theKey=event.keyCode;
  236. if (theKey==32){
  237. event.keyCode=9
  238. dialogActive=true
  239. document.all.tmpDlgArg.value="#"
  240. document.all.tmpDlgTxt.value=" :"
  241. window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
  242. if (document.all.tmpDlgTxt.value !="") {
  243. window.showModalDialog('../AR/dialog_SelectAccount.asp?act=select&search='+escape(document.all.tmpDlgTxt.value), document.all.tmpDlgArg, 'dialogHeight:400px; dialogWidth:700px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
  244. dialogActive=false
  245. if (document.all.tmpDlgArg.value!="#"){
  246. Arguments=document.all.tmpDlgArg.value.split("#")
  247. src.value=Arguments[0];
  248. document.all.accountName.value=Arguments[1];
  249. }
  250. }
  251. }
  252. }
  253. function check(src){
  254. if (!dialogActive){
  255. badCode = false;
  256. if (window.XMLHttpRequest) {
  257. var objHTTP=new XMLHttpRequest();
  258. } else if (window.ActiveXObject) {
  259. var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
  260. }
  261. objHTTP.open('GET','../accounting/xml_CustomerAccount.asp?id='+src.value,false)
  262. objHTTP.send()
  263. tmpStr = unescape(objHTTP.responseText)
  264. //document.all['A1'].innerText= objHTTP.status
  265. //document.all['A2'].innerText= objHTTP.statusText
  266. //document.all['A3'].innerText= objHTTP.responseText
  267. document.all.accountName.value=tmpStr;
  268. }
  269. }
  270. function isEmpty()
  271. {
  272. ReceiptNo = document.all.ReceiptNo.value
  273. CusID = document.all.customerID.value
  274. amount = document.all.amount.value
  275. Bank = document.all.Bank.value
  276. if(CusID=="" || amount=="" || Bank==-1)
  277. {
  278. alert("! ")
  279. return false
  280. }
  281. else
  282. {
  283. str = " "
  284. return confirm(str)
  285. }
  286. }
  287. //-->
  288. </SCRIPT>
  289. <%
  290. end if
  291. %>
  292. <!--#include file="tah.asp" -->