/beta/AP/IsA-VouchersReport.asp

http://github.com/khaneh/Orders · ASP · 223 lines · 194 code · 24 blank · 5 comment · 11 complexity · af7050364d8a5250eae0bc6e9d24f328 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'AP (7)
  3. PageTitle= " "
  4. SubmenuItem=5
  5. if not Auth(7 , 5) then NotAllowdToViewThisPage()
  6. fixSys = "AP"
  7. SA_IsVendor = 1
  8. %>
  9. <!--#include file="top.asp" -->
  10. <!--#include File="../include_farsiDateHandling.asp"-->
  11. <!--#include File="../include_JS_InputMasks.asp"-->
  12. <STYLE>
  13. .RepTable {font-family:tahoma; font-size:9pt; direction: RTL; }
  14. .RepTable td {padding:5;border:1pt solid gray;}
  15. .RepTable a {text-decoration:none; color:#222288;}
  16. .RepTable a:hover {text-decoration:underline;}
  17. .RepTableTitle {background-color: #CCCCFF; text-align: center; font-weight:bold; height:50;}
  18. .RepTableHeader {background-color: #BBBBBB; text-align: center; font-weight:bold;}
  19. .RepTableFooter {background-color: #BBBBBB; direction: LTR; }
  20. .RepTR1 {background-color: #DDDDDD;}
  21. .RepTR2 {background-color: #FFFFFF;}
  22. .RepDescSpan {overflow:auto;border:none; width:250px; height:23px; font-size:7pt;}
  23. .RepGenInput { font-family:tahoma; font-size: 8pt; border: 1 solid black; direction:LTR; width:70px; height:19px;}
  24. </STYLE>
  25. <style>
  26. .InvTable { font-size: 9pt;}
  27. .InvRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
  28. .InvHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
  29. .InvRowInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0FFF0; text-align:right;}
  30. .InvHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
  31. .InvHeadInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right; direction: RTL;}
  32. .InvGenInput { font-family:tahoma; font-size: 9pt; border: none; }
  33. </style>
  34. <style>
  35. .RcpTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; }
  36. .RcpMainTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; background-color: #558855; text-align:right; direction: RTL;}
  37. .RcpMainTableTH { background-color: #C3C300;}
  38. .RcpMainTableTR { background-color: #CCCC88; border: 0; }
  39. .RcpRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
  40. .RcpRowInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
  41. .RcpHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
  42. .RcpHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
  43. .RcpHeadInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #D0E0FF; text-align:right; direction: RTL;}
  44. .RcpGenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;}
  45. .GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
  46. </style>
  47. <style>
  48. .MmoTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; direction: LTR;}
  49. .MmoMainTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; background-color: #558855; text-align:right; direction: RTL;}
  50. .MmoMainTableTH { background-color: #C3C300;}
  51. .MmoMainTableTR { background-color: #CCCC88; border: 0; }
  52. .MmoRowInput { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
  53. .MmoRowInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
  54. .MmoHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
  55. .MmoHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
  56. .MmoHeadInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #D0E0FF; text-align:right; direction: RTL;}
  57. .MmoGenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;}
  58. </style>
  59. <%
  60. CustomerID=request("selectedCustomer")
  61. 'sys = request("sys")
  62. 'if sys = "" then sys = "AR"
  63. reason = request("Reason")
  64. if reason = "" then reason = 1
  65. mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")"
  66. Set RS1=Conn.execute(mySQL)
  67. if RS1.eof then
  68. conn.close
  69. response.redirect "top.asp?errMsg=" & Server.URLEncode("!")
  70. else
  71. Sys= RS1("Acron")
  72. firstGLAccount= RS1("GLAccount")
  73. end if
  74. RS1.close
  75. if not fixSys = "-" then sys = fixSys
  76. mySQL="SELECT AccountTitle FROM Accounts WHERE (ID='"& CustomerID & "')"
  77. Set RS1 = conn.Execute(mySQL)
  78. customerName=RS1("AccountTitle")
  79. RS1.close
  80. EndDate=sqlSafe(request("EndDate"))
  81. StartDate=sqlSafe(request("StartDate"))
  82. if StartDate="" then
  83. StartDate=session("OpenGLStartDate") 'yearBeginnig=left(shamsiToday(),4)&"/01/01"
  84. end if
  85. if EndDate="" then
  86. if session("OpenGLEndDate") > shamsiToday() then
  87. EndDate=shamsiToday()
  88. else
  89. EndDate=session("OpenGLEndDate")
  90. end if
  91. end if
  92. nextYear=cint(left(StartDate,4)) + 1
  93. prevYear=cint(left(StartDate,4)) - 1
  94. nextStartDate= nextYear & "/01/01" 'right(StartDate,6)
  95. nextEndDate= nextYear & "/12/30" 'right(EndDate,6)
  96. prevStartDate= prevYear & "/01/01" 'right(StartDate,6)
  97. prevEndDate= prevYear & "/12/30" 'right(EndDate,6)
  98. nextYear=right(nextYear,2)
  99. prevYear=right(prevYear,2)
  100. %>
  101. <br>
  102. <TABLE class="RepTable" width='90%' align='center'>
  103. <TR>
  104. <TD colspan=8 dir='rtl' align='center'>
  105. </TD>
  106. </TR>
  107. <TR>
  108. <TD class="RepTableTitle" colspan=8 dir='rtl' align='center'>
  109. <br>
  110. <FORM METHOD=POST ACTION="?act=show&sys=<%=sys%>&selectedCustomer=<%=CustomerID%>" ID="dateForm">
  111. <A target="_blank" HREF="../CRM/AccountInfo.asp?act=show&selectedCustomer=<%=CustomerID%>"><%=customerName%> [<%=CustomerID%>]</A>
  112. <br>
  113. <br>
  114. <INPUT class="RepGenInput" TYPE="text" NAME="StartDate" Value="<%=StartDate%>" OnBlur="return acceptDate(this);"> <INPUT class="RepGenInput" TYPE="text" NAME="EndDate" Value="<%=EndDate%>"OnBlur="return acceptDate(this);"> <INPUT Class="GenButton" TYPE="button" Value=" "onclick="if(acceptDate(document.getElementsByName('StartDate')[0]) && acceptDate(document.getElementsByName('EndDate')[0])) document.getElementById('dateForm').submit()">
  115. <BR><BR>
  116. <INPUT Class="GenButton" TYPE="button" Value=" <- <%=prevYear%> " onclick="window.location='?act=show&reason=<%=reason%>&sys=<%=sys%>&selectedCustomer=<%=CustomerID%>&startDate=<%=prevStartDate%>&endDate=<%=prevEndDate%>';">
  117. <INPUT Class="GenButton" TYPE="button" Value=" <%=nextYear%> -> " onclick="window.location='?act=show&reason=<%=reason%>&sys=<%=sys%>&selectedCustomer=<%=CustomerID%>&startDate=<%=nextStartDate%>&endDate=<%=nextEndDate%>';">
  118. </FORM>
  119. </TD>
  120. </TR>
  121. <TR class="RepTableHeader">
  122. <TD>#</TD>
  123. <TD></TD>
  124. <TD> </TD>
  125. <TD> </TD>
  126. <TD></TD>
  127. <TD></TD>
  128. </TR>
  129. <%
  130. 'mySQL="SELECT Vouchers.*, Invoices.Number AS InvoiceNumber, Invoices.ID AS InvoiceID FROM VoucherLines INNER JOIN Vouchers ON VoucherLines.Voucher_ID = Vouchers.id INNER JOIN PurchaseOrders ON VoucherLines.RelatedPurchaseOrderID = PurchaseOrders.ID INNER JOIN PurchaseRequestOrderRelations ON PurchaseOrders.ID = PurchaseRequestOrderRelations.Ord_ID INNER JOIN PurchaseRequests ON PurchaseRequestOrderRelations.Req_ID = PurchaseRequests.ID INNER JOIN Orders ON PurchaseRequests.Order_ID = Orders.ID INNER JOIN InvoiceOrderRelations ON Orders.ID = InvoiceOrderRelations.[Order] INNER JOIN Invoices ON InvoiceOrderRelations.Invoice = Invoices.ID WHERE Invoices.isA = 1 and Invoices.Voided = 0 and Vouchers.Verified = 1 and Vouchers.vendorID = " & CustomerID
  131. 'Changed By Kid 830625
  132. mySQL="SELECT DISTINCT * FROM Vouchers INNER JOIN (SELECT Invoices.Number AS InvoiceNumber, Invoices.ID AS InvoiceID, VoucherLines.Voucher_ID FROM VoucherLines INNER JOIN PurchaseOrders ON VoucherLines.RelatedPurchaseOrderID = PurchaseOrders.ID INNER JOIN PurchaseRequestOrderRelations ON PurchaseOrders.ID = PurchaseRequestOrderRelations.Ord_ID INNER JOIN PurchaseRequests ON PurchaseRequestOrderRelations.Req_ID = PurchaseRequests.ID INNER JOIN Orders ON PurchaseRequests.OrderID = Orders.ID INNER JOIN InvoiceOrderRelations ON Orders.ID = InvoiceOrderRelations.[Order] INNER JOIN Invoices ON InvoiceOrderRelations.Invoice = Invoices.ID WHERE (Invoices.IsA = 1) AND (Invoices.Voided = 0) AND (Invoices.Issued = 1)) VoucherLine_AInvoice ON VoucherLine_AInvoice.Voucher_ID = Vouchers.id WHERE (Vouchers.Verified = 1) AND (Vouchers.VendorID = " & CustomerID &") AND (Vouchers.EffectiveDate >= '" & StartDate &"') AND (Vouchers.EffectiveDate <= '" & EndDate &"') ORDER BY Vouchers.EffectiveDate, Vouchers.ID"
  133. Set RS1 = conn.execute(mySQL)
  134. Remained = 0
  135. Totalcredit = 0
  136. TotalDebit = 0
  137. tempCounter = 0
  138. if Not (RS1.EOF) then
  139. While Not (RS1.EOF)
  140. tempCounter=tempCounter+1
  141. sourceLink="<a href='AccountReport.asp?act=showVoucher&voucher="& RS1("id") & "' target='_blank'>" & replace(RS1("Title"),"/",".") & "</a>"
  142. sourceLink2="<a href='../AR/AccountReport.asp?act=showInvoice&invoice="& RS1("InvoiceID") & "' target='_blank'>" & RS1("InvoiceID") & "</a>"
  143. if not isnull(RS1("comment")) then
  144. Description = replace(RS1("comment"),chr(13),"<br>") + " - " & RS1("InvoiceNumber")
  145. Description = replace(Description,"/",".")
  146. else
  147. Description = ""
  148. end if
  149. if RS1("Voided") then
  150. %> <TR bgcolor=#FFEEEE style='color:#999999'>
  151. <td> # <%tempCounter = tempCounter -1 %></td>
  152. <td width=60 dir='LTR' align='right'><%=RS1("EffectiveDate")%></td>
  153. <td width=140><%=sourceLink%></td>
  154. <td width=70><%=sourceLink2%></td>
  155. <td width=200><span ><%=Description%></span></td>
  156. <td dir='LTR'>
  157. <div style="position:absolute;width:650;"><hr style="color:red;"></div>
  158. <div align=right><%=Separate(RS1("TotalPrice"))%></div>
  159. </td>
  160. </TR>
  161. <%
  162. else
  163. TotalDebit = TotalDebit + cdbl(Debit)
  164. Totalcredit = Totalcredit + cdbl(Credit)
  165. Remained = Remained + Cdbl(Credit) - Cdbl(Debit)
  166. %> <TR class='<%if tempCounter MOD 2 = 0 then response.write "RepTR1" else response.write "RepTR2"%>'>
  167. <td><%=tempCounter %></td>
  168. <td width=60 dir='LTR' align='right'><%=RS1("EffectiveDate")%></td>
  169. <td width=140><%=sourceLink%></td>
  170. <td width=70><%=sourceLink2%></td>
  171. <td width=200><span ><%=Description%></span></td>
  172. <td dir='LTR' align='right'><%=Separate(RS1("TotalPrice"))%></td>
  173. </TR>
  174. <%
  175. end if
  176. total = total + Cdbl(RS1("TotalPrice"))
  177. RS1.MoveNext
  178. Wend
  179. if Remained>=0 then
  180. remainedColor="green"
  181. else
  182. remainedColor="red"
  183. end if
  184. else
  185. total= " - "
  186. %>
  187. <TR class="RepTR1">
  188. <TD colspan=6 align=center></TD>
  189. </TR>
  190. <%
  191. end if
  192. %>
  193. <TR>
  194. <TD class="RepTableFooter" colspan='5'>&nbsp;&nbsp; : </span></td>
  195. <TD class="RepTableFooter" align='right'><%=Separate(total)%></td>
  196. </TR>
  197. </TABLE>
  198. <br>
  199. <!--#include file="tah.asp" -->