/beta/AP/verify.asp

http://github.com/khaneh/Orders · ASP · 229 lines · 179 code · 32 blank · 18 comment · 20 complexity · 46e9c7640e03d0d14e9bf7294a5c6876 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'AP (7)
  3. PageTitle= " "
  4. SubmenuItem=2
  5. if not Auth(7 , 2) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <%
  11. '-----------------------------------------------------------------------------------------------------
  12. '-------------------------------------------------------------------------------------- Submit Payment
  13. '-----------------------------------------------------------------------------------------------------
  14. if request.form("Submit")="" then
  15. 'Check for permission for APPROVING the Voucher
  16. if NOT Auth(7 , 2) then NotAllowdToViewThisPage()
  17. ON ERROR RESUME NEXT
  18. VouchID = clng(request("VouchID"))
  19. if Err.Number<>0 then
  20. Err.clear
  21. conn.close
  22. response.redirect "top.asp?errMsg=" & Server.URLEncode(" .")
  23. end if
  24. ON ERROR GOTO 0
  25. set RSV=Conn.Execute ("SELECT * FROM Vouchers WHERE (id="& VouchID & ") and Verified = 0" )
  26. if RSV.EOF then
  27. response.redirect "?errMsg=" & Server.URLEncode("!<br> .")
  28. end if
  29. TotalPrice = RSV("TotalPrice")
  30. VendorID = RSV("VendorID")
  31. totalVat = RSV("totalVat")
  32. effectiveDate = RSV("EffectiveDate")
  33. '---- Checking wether EffectiveDate is valid in current open GL
  34. if (effectiveDate < session("OpenGLStartDate")) OR (effectiveDate > session("OpenGLEndDate")) then
  35. Conn.close
  36. response.redirect "?errMsg=" & Server.URLEncode("!<br> .<br><br> .")
  37. end if
  38. '----
  39. '----- Check GL is closed
  40. if (session("IsClosed")="True") then
  41. Conn.close
  42. response.redirect "?errMsg=" & Server.URLEncode("! .")
  43. end if
  44. '----
  45. Conn.Execute ("UPDATE Vouchers SET Verified = 1 WHERE (id = "& VouchID & ")")
  46. Conn.Execute ("UPDATE Accounts SET APBalance=APBalance+"& TotalPrice & " WHERE (ID = "& VendorID & ")")
  47. creationDate= shamsiToday()
  48. creationTime= CurrentTime10()
  49. GLAccount= "89099" 'This must be changed... (Misc. Purchase)
  50. firstGLAccount= "41001" 'This must be changed... (Business Creditors)
  51. '*** Type = 6 means APItem is a Voucher
  52. conn.Execute("INSERT INTO APItems (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, IsCredit, Type, Link, AmountOriginal, createdDate, creationTime, CreatedBy, RemainedAmount, Vat) VALUES (" &_
  53. GLAccount & ", '"& OpenGL & "', '"& firstGLAccount & "', '"& VendorID & "', N'"& EffectiveDate & "', 1, 6, '"& VouchID & "', '"& TotalPrice & "', N'"& creationDate & "', N'"& creationTime & "', '"& session("ID") & "', '"& TotalPrice & "', '" & totalVat & "')" )
  54. Conn.close
  55. response.redirect "AccountReport.asp?act=showVoucher&voucher="& VouchID
  56. end if
  57. '-----------------------------------------------------------------------------------------------------
  58. '-------------------------------------------------------------------------------- Show Voucher Details
  59. '-----------------------------------------------------------------------------------------------------
  60. if request("VouchID") <> "" then
  61. response.write "<br><br>"
  62. call showAlert(" .<br><br> .<br><br> Ȑ. <br><br> .<br><br> <A HREF='AccountReport.asp?act=showVoucher&voucher="& request("VouchID") & "'><B></B></A> ." , CONST_MSG_ALERT)
  63. response.end
  64. end if
  65. '-----------------------------------------------------------------------------------------------------
  66. '------------------------------------------------------------------------------------------------ Main
  67. '-----------------------------------------------------------------------------------------------------
  68. 'mySQL="SELECT DRV.OrdDate AS OrdDate, DRV.RelatedPurchaseOrderID, DRV.LineTitle, DRV.qtty, DRV.price, DRV.Invoice, DRV.status, SUM(InvoiceLines.Price - InvoiceLines.Discount - InvoiceLines.Reverse) AS SalePrice, COUNT(InvoiceLines.Price) AS COUNT FROM (SELECT VoucherLines.*, PurchaseOrders.OrdDate, InvoiceOrderRelations.Invoice AS Invoice, InvoiceItems.ID AS InvoiceItem, PurchaseOrders.status FROM InvoiceItems RIGHT OUTER JOIN InvoiceOrderRelations INNER JOIN PurchaseRequests INNER JOIN PurchaseRequestOrderRelations ON PurchaseRequests.ID = PurchaseRequestOrderRelations.Req_ID ON InvoiceOrderRelations.[Order] = PurchaseRequests.Order_ID RIGHT OUTER JOIN PurchaseOrders ON PurchaseRequestOrderRelations.Ord_ID = PurchaseOrders.ID ON InvoiceItems.RelatedInventoryItemID = PurchaseOrders.TypeID FULL OUTER JOIN Vouchers INNER JOIN VoucherLines ON Vouchers.id = VoucherLines.Voucher_ID ON PurchaseOrders.ID = VoucherLines.RelatedPurchaseOrderID WHERE (PurchaseOrders.Status <> 'CANCEL') AND (Vouchers.Verified=0)) DRV LEFT OUTER JOIN InvoiceLines ON DRV.Invoice = InvoiceLines.Invoice AND DRV.InvoiceItem = InvoiceLines.Item GROUP BY DRV.OrdDate, DRV.RelatedPurchaseOrderID, DRV.LineTitle, DRV.qtty, DRV.price, DRV.Invoice, DRV.status ORDER BY DRV.OrdDate"
  69. ' S A M
  70. mySQL="SELECT DRV.ID, DRV.OrdDate AS OrdDate, DRV.RelatedPurchaseOrderID, DRV.LineTitle, DRV.qtty, DRV.price, DRV.Invoice, DRV.status, SUM(InvoiceLines.Price - InvoiceLines.Discount - InvoiceLines.Reverse + InvoiceLines.Vat) AS SalePrice, COUNT(InvoiceLines.Price) AS COUNT FROM (SELECT Vouchers.ID, Voucherlines.RelatedPurchaseOrderID, Voucherlines.LineTitle, Voucherlines.Qtty, Voucherlines.Price, PurchaseOrders.OrdDate, InvoiceOrderRelations.Invoice AS Invoice, InvoiceItems.ID AS InvoiceItem, PurchaseOrders.status FROM InvoiceItems RIGHT OUTER JOIN InvoiceOrderRelations INNER JOIN PurchaseRequests INNER JOIN PurchaseRequestOrderRelations ON PurchaseRequests.ID = PurchaseRequestOrderRelations.Req_ID ON InvoiceOrderRelations.[Order] = PurchaseRequests.Order_ID RIGHT OUTER JOIN PurchaseOrders ON PurchaseRequestOrderRelations.Ord_ID = PurchaseOrders.ID ON InvoiceItems.RelatedInventoryItemID = PurchaseOrders.TypeID FULL OUTER JOIN Vouchers INNER JOIN VoucherLines ON Vouchers.id = VoucherLines.Voucher_ID ON PurchaseOrders.ID = VoucherLines.RelatedPurchaseOrderID WHERE (PurchaseOrders.Status <> 'CANCEL') AND (Vouchers.Verified = 0)) DRV LEFT OUTER JOIN InvoiceLines ON DRV.Invoice = InvoiceLines.Invoice AND DRV.InvoiceItem = InvoiceLines.Item GROUP BY DRV.ID, DRV.OrdDate, DRV.RelatedPurchaseOrderID, DRV.LineTitle, DRV.qtty, DRV.price, DRV.Invoice, DRV.status ORDER BY DRV.OrdDate DESC, DRV.ID"
  71. set RSS=Conn.Execute (mySQL) '"SELECT * FROM Vouchers WHERE (Verified = 0)" )
  72. %>
  73. <BR><BR><BR>
  74. <style>
  75. .myTbl td {direction: LTR; text-align:right;}
  76. .GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
  77. </style>
  78. <FORM METHOD=POST ACTION="AccountReport.asp?act=showVoucher">
  79. <TABLE dir=rtl style="border:2 solid #333399;" align=center width="90%">
  80. <TR bgcolor="#eeeeee" height=25>
  81. <TD align=center colspan=7><B> </B></TD>
  82. </TR>
  83. <TR bgcolor="#eeeeee" height=25>
  84. <TD width=10> # </TD>
  85. <TD><INPUT TYPE="radio" NAME="" disabled></TD>
  86. <TD width=120> </TD>
  87. <TD> </TD>
  88. <TD> </TD>
  89. <TD width=60> </TD>
  90. <TD>
  91. <input style='width:120pt;border:0pt;background:transpanrent;font-size:7pt' value=' '>
  92. <input style='width:25pt;border:0pt;background:transpanrent;font-size:7pt' value=''>
  93. <input style='width:35pt;border:0pt;background:transpanrent;font-size:7pt' value=''>
  94. <input style='width:35pt;border:0pt;background:transpanrent;font-size:7pt' value=' '>
  95. </TD>
  96. </TR>
  97. <TR bgcolor="#5555BB" height="2">
  98. <TD colspan=7></TD>
  99. </TR>
  100. <%
  101. tmpCounter=0
  102. Do while not RSS.eof
  103. tmpCounter = tmpCounter + 1
  104. if tmpCounter mod 2 = 1 then
  105. tmpColor="#FFFFFF"
  106. tmpColor2="#FFFFBB"
  107. Else
  108. tmpColor="#DDDDDD"
  109. tmpColor2="#EEEEBB"
  110. End if
  111. DisableFlag = ""
  112. vouchLines = "<table class='myTbl' >"
  113. Do
  114. Voucher= RSS("ID")
  115. mySQL="SELECT Vouchers.Title, Vouchers.Number, Vouchers.TotalPrice, Vouchers.comment, Vouchers.CreationDate, Vouchers.VendorID, Accounts.AccountTitle FROM Vouchers INNER JOIN Accounts ON Vouchers.VendorID = Accounts.ID WHERE (Vouchers.ID = "& Voucher & ")"
  116. set RST=Conn.Execute (mySQL)
  117. Comment = RST("Comment")
  118. VoucherTitle = RST("title")
  119. VoucherPrice = RST("totalPrice")
  120. CreationDate = RST("CreationDate")
  121. Vendor = RST("VendorID")
  122. AccountTitle = RST("AccountTitle")
  123. number = RST("Number")
  124. RST.close
  125. vouchLines = vouchLines & "<tr><td><input readonly onclick='window.open(""../purchase/outServiceTrace.asp?od=" & RSS("RelatedPurchaseOrderID") & """,""_blank"","""")' type='' style='width:120pt;border:0pt;background:transpanrent;background:transpanrent;font:7pt blue;cursor:hand' value='" & RSS("LineTitle") & "'></td></a><td style='width:25pt;font-size:7pt;'>" & RSS("qtty") & "</td><td><input readonly type='' style='width:35pt;border:0pt;background:transpanrent;font-size:7pt;cursor:hand' value='" & Separate(RSS("price")) & "'></td><td> "
  126. if trim(" " & RSS("Invoice"))="" then
  127. vouchLines = vouchLines & "<span disabled style='font-size:7pt'> </span>"
  128. else
  129. vouchLines = vouchLines & "<span style='font-size:7pt'><A HREF='../AR/AccountReport.asp?act=showInvoice&invoice="& RSS("Invoice")& "' target='_blank'>" & Separate(RSS("SalePrice"))
  130. if RSS("count") > 1 then
  131. vouchLines = vouchLines & " (" & RSS("count") & " )"
  132. end if
  133. if trim(RSS("SalePrice"))="" or isnull(RSS("SalePrice")) then
  134. vouchLines = vouchLines & " "
  135. end if
  136. vouchLines = vouchLines & "</A></span>"
  137. end if
  138. vouchLines = vouchLines & "</tr>"
  139. if RSS("status") <> "OK" then DisableFlag=" disabled"
  140. RSS.moveNext
  141. if NOT RSS.eof then
  142. nextVoucher=RSS("ID")
  143. else
  144. nextVoucher=-1
  145. end if
  146. Loop While Voucher= nextVoucher AND NOT RSS.eof
  147. vouchLines = vouchLines & "</table>"
  148. %>
  149. <TR bgcolor="<%=tmpColor%>" <%=DisableFlag%> Title="<%
  150. if Comment<>"-" then
  151. response.write ": " & Comment
  152. else
  153. response.write " "
  154. end if
  155. %>">
  156. <TD><INPUT TYPE="hidden" name=color1 value="<%=tmpColor%>"><INPUT TYPE="hidden" name=color2 value="<%=tmpColor2%>"><A target="_blank" HREF="AccountReport.asp?act=showVoucher&voucher=<%=Voucher%>"><%=Voucher%></A></TD>
  157. <TD><INPUT TYPE="radio" NAME="voucher" VALUE="<%=Voucher%>" onfocus="setColorFocus(this)" onblur="setColorBlur(this)" id="<%=tmpCounter-1%>"></TD>
  158. <TD><%=AccountTitle%></TD>
  159. <TD><%=VoucherTitle%></TD>
  160. <TD dir=LTR align=right><%=Separate(VoucherPrice)%></TD>
  161. <TD align=left><span dir=ltr><%=CreationDate%></span></TD>
  162. <TD><%=vouchLines%></TD>
  163. </TR>
  164. <%
  165. Loop
  166. %>
  167. </TABLE>
  168. <br>
  169. <br>
  170. <center><INPUT TYPE="submit" Name="Submit" Value=" " class="inputBut" style="width:150px;" tabIndex="14">
  171. </form>
  172. </center>
  173. <SCRIPT LANGUAGE="JavaScript">
  174. <!--
  175. function setColorFocus(obj){
  176. ii=parseInt(obj.id)
  177. theTR = obj.parentNode.parentNode
  178. theTR.setAttribute("bgColor",document.getElementsByName("color2")[ii].value)
  179. }
  180. function setColorBlur(obj){
  181. ii=parseInt(obj.id)
  182. theTR = obj.parentNode.parentNode
  183. theTR.setAttribute("bgColor",document.getElementsByName("color1")[ii].value)
  184. }
  185. /*function setColor(obj)
  186. {
  187. for(i=0; i<document.all.voucher.length; i++)
  188. {
  189. theTR = document.all.voucher[i].parentNode.parentNode
  190. theTR.setAttribute("bgColor","<%=AppFgColor%>")
  191. }
  192. theTR = obj.parentNode.parentNode
  193. theTR.setAttribute("bgColor","#FFFFFF")
  194. }*/
  195. //-->
  196. </SCRIPT>
  197. <!--#include file="tah.asp" -->