/beta/AR/Rep_AReceipt.asp

http://github.com/khaneh/Orders · ASP · 316 lines · 271 code · 39 blank · 6 comment · 27 complexity · 912edda6d1e8ec20d22893fe98fd5565 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'Order (2)
  3. PageTitle=" "
  4. SubmenuItem=11
  5. if not Auth("C" , 5) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <STYLE>
  9. .GetCustTbl {font-family:tahoma; background-color: #DDDDDD; width:630; direction: RTL; }
  10. .GetCustTbl td {padding:2; font-size: 9pt; height:25;}
  11. .GetCustInp { font-family:tahoma; font-size: 9pt;}
  12. .CusTableHeader {background-color: #33AACC; text-align: center; font-weight:bold;}
  13. .CustContactTable {font-family:tahoma; width:100%; border:1 solid black; direction: RTL; background-color:#CCCCCC;}
  14. .CustContactTable td {padding:5;}
  15. .CustTable {font-family:tahoma; width:80%; border:1 solid black; direction: RTL; background-color:black;}
  16. .CustTable td {padding:5;}
  17. .CustTable a {text-decoration:none;color:#000088}
  18. .CustTable a:hover {text-decoration:underline;}
  19. .CusTD1 {background-color: #CCCC66; text-align: left; font-weight:bold;}
  20. .CusTD2 {background-color: #DDDDDD; direction: LTR; text-align: right; font-size:9pt;}
  21. .CusTD3 {background-color: #DDDDDD; direction: LTR; text-align: center; font-size:9pt;}
  22. .CusTD4 {background-color: #CCCC66; direction: LTR; text-align: center; font-size:9pt;}
  23. .CustTable4 {font-family:tahoma; direction: RTL; width:100%; height:100%; background-color:#C3DBEB;}
  24. </STYLE>
  25. <%
  26. if request("act")="show" then
  27. ON ERROR RESUME NEXT
  28. isA = clng(request("isA"))
  29. FromDate = sqlSafe(request("FromDate"))
  30. ToDate = sqlSafe(request("ToDate"))
  31. ResultsInPage = cint(request("ResultsInPage"))
  32. if FromDate="" AND ToDate="" then
  33. pageTitle=" "
  34. elseif FromDate="" then
  35. pageTitle=" " & replace (ToDate,"/",".")
  36. elseif ToDate="" then
  37. pageTitle=" "& replace (FromDate,"/",".") & " "
  38. else
  39. pageTitle=" "& replace (FromDate,"/",".") & " " & replace (ToDate,"/",".")
  40. end if
  41. if ToDate = "" then ToDate = "9999/99/99"
  42. if request("ShowRemained")="on" OR request("ShowRemained")="True" then
  43. ShowRemained=true
  44. else
  45. ShowRemained=false
  46. end if
  47. if Err.Number<>0 then
  48. Err.clear
  49. conn.close
  50. response.redirect "OtherReports.asp?errMsg=" & Server.URLEncode(" .")
  51. end if
  52. ON ERROR GOTO 0
  53. Ord=request("Ord")
  54. select case Ord
  55. case "1":
  56. order="Receipts.ID"
  57. case "-1":
  58. order="Receipts.ID DESC"
  59. case "2":
  60. order="AccountTitle"
  61. case "-2":
  62. order="AccountTitle DESC"
  63. case "3":
  64. order="Customer"
  65. case "-3":
  66. order="Customer DESC"
  67. case "4":
  68. order="InvoiceId"
  69. case "-4":
  70. order="InvoiceId DESC"
  71. case "5"
  72. order="Number DESC"
  73. case "-5":
  74. order="Number DESC"
  75. case "6"
  76. order="ReceiptAmount DESC"
  77. case "-6":
  78. order="ReceiptAmount DESC"
  79. case "7"
  80. order="Amount DESC"
  81. case "-7":
  82. order="Amount DESC"
  83. case "8"
  84. order="EffectiveDate DESC"
  85. case "-8":
  86. order="EffectiveDate DESC"
  87. case else:
  88. order="Receipts.ID"
  89. Ord=1
  90. end select
  91. if ord<0 then
  92. style="background-color: #33CC99;"
  93. arrow="<br><span style='font-family:webdings'>6</span>"
  94. else
  95. style="background-color: #33CC99;"
  96. arrow="<br><span style='font-family:webdings'>5</span>"
  97. end if
  98. otherCriteria=""
  99. if isA = 1 then
  100. isAName = " "
  101. otherCriteria = " AND (Invoices.IsA = 1) "
  102. elseif isA = 2 then
  103. isAName = " "
  104. otherCriteria = " AND (Invoices.IsA = 0) "
  105. end if
  106. 'mySQL="SELECT * From (SELECT ARItems_1.GL,Receipts.ID AS ReceiptId, Accounts.AccountTitle, Invoices.Customer, Invoices.ID AS InvoiceId, Invoices.Number, ARItems.AmountOriginal AS ReceiptAmount, ARItemsRelations.Amount, Receipts.EffectiveDate FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Receipts.Voided=0) AND (Invoices.IsA = 1) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate<= N'"& ToDate & "') AND (ARItems.Type = 2))drv ORDER BY " & order
  107. ' Changed By Kid 851026 Adding the option of with/without isA tick
  108. mySQL="SELECT ARItems_1.GL,Receipts.ID AS ReceiptId, Accounts.AccountTitle, Invoices.Customer, Invoices.ID AS InvoiceId, Invoices.Number, ARItems.AmountOriginal AS ReceiptAmount, ARItemsRelations.Amount, Receipts.EffectiveDate FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Receipts.Voided=0) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate<= N'"& ToDate & "') AND (ARItems.Type = 2) AND (ARItems_1.Type = 1) " & otherCriteria & " ORDER BY " & order
  109. 'mySQLsum ="SELECT Count(ReceiptId) As ReceiptId,Sum(ReceiptAmount) As ReceiptAmount,Sum(Amount) As Amount From (SELECT ARItems_1.GL,Receipts.ID AS ReceiptId, Accounts.AccountTitle, Invoices.Customer, Invoices.ID AS InvoiceId, Invoices.Number, ARItems.AmountOriginal AS ReceiptAmount, ARItemsRelations.Amount, Receipts.EffectiveDate FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Receipts.Voided=0) AND (Invoices.IsA = 1) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate<= N'"& ToDate & "') AND (ARItems.Type = 2))drv "
  110. ' Changed By Kid 851026 Adding the option of with/without isA tick
  111. 'mySQLsum ="SELECT Count(ReceiptId) As ReceiptId,Sum(ReceiptAmount) As ReceiptAmount,Sum(Amount) As Amount From (SELECT ARItems_1.GL,Receipts.ID AS ReceiptId, Accounts.AccountTitle, Invoices.Customer, Invoices.ID AS InvoiceId, Invoices.Number, ARItems.AmountOriginal AS ReceiptAmount, ARItemsRelations.Amount, Receipts.EffectiveDate FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Receipts.Voided=0) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate<= N'"& ToDate & "') AND (ARItems.Type = 2) AND (ARItems_1.Type = 1) " & otherCriteria & ")drv "
  112. mySQLsum="SELECT COUNT(*) AS ReceiptCNT, SUM(ReceiptAmount) AS SumReceiptAmount, SUM(RelatedAmount) AS SumRelatedAmount FROM (SELECT Receipts.ID, Receipts.TotalAmount AS ReceiptAmount, SUM(ARItemsRelations.Amount) AS RelatedAmount FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID WHERE (Receipts.Voided = 0) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate <= N'"& ToDate & "') AND (ARItems.Type = 2) AND (ARItems_1.Type = 1) " & otherCriteria & " GROUP BY Receipts.ID, Receipts.TotalAmount) DRV"
  113. Set Rs2 = Conn.Execute(mySQLsum)
  114. if (Not Rs2.EOF) Then
  115. ReceiptCNT = Rs2("ReceiptCNT")
  116. SumReceitpAmount = Rs2("SumReceiptAmount")
  117. SumRelatedAmount = Rs2("SumRelatedAmount")
  118. %>
  119. <br><br>
  120. <table class="CustTable" cellspacing='1' style='width:90%;' align='center'>
  121. <tr>
  122. <td colspan="8" class="CusTableHeader" style="text-align:right;height:35;"> <%=isAName %> &nbsp; <%=GroupName%> (<%=pageTitle%>)</td>
  123. </tr>
  124. <tr>
  125. <td class="CusTD3" width=100> </td>
  126. <td class="CusTD3"> </td>
  127. <td class="CusTD3"> </td>
  128. </tr>
  129. <tr bgcolor="white">
  130. <TD dir=LTR align=center><%=Separate(ReceiptCNT)%></TD>
  131. <TD dir=LTR align=center><%=Separate(SumReceitpAmount)%></TD>
  132. <TD dir=LTR align=center><%=Separate(SumRelatedAmount)%></TD>
  133. </tr>
  134. </table>
  135. <br><br>
  136. <%
  137. end if
  138. Rs2.Close
  139. %>
  140. <table class="CustTable" cellspacing='1' style='width:90%;' align='center'>
  141. <tr>
  142. <td colspan="10" class="CusTableHeader" style="text-align:right;height:35;"> (<%=pageTitle%>)</td>
  143. </tr>
  144. <%
  145. Set RS1 = Server.CreateObject("ADODB.Recordset")
  146. PageSize = ResultsInPage
  147. RS1.PageSize = PageSize
  148. RS1.CursorLocation=3 'in ADOVBS_INC adUseClient=3
  149. RS1.Open mySQL ,Conn,3
  150. TotalPages = RS1.PageCount
  151. CurrentPage=1
  152. if isnumeric(Request.QueryString("p")) then
  153. pp=clng(Request.QueryString("p"))
  154. if pp <= TotalPages AND pp > 0 then
  155. CurrentPage = pp
  156. end if
  157. end if
  158. if not RS1.eof then
  159. RS1.AbsolutePage=CurrentPage
  160. end if
  161. if RS1.eof then
  162. %> <tr>
  163. <td colspan="10" class="CusTD3" style='direction:RTL;'> .</td>
  164. </tr>
  165. <% else
  166. %>
  167. <tr>
  168. <td class="CusTD3" >#</td>
  169. <td class="CusTD3" onclick='go2Page(1,1);' style="cursor:hand; <%if abs(ord)=1 then response.write style%>" style='direction:RTL;'># <%if abs(ord)=1 then response.write arrow%></td>
  170. <td class="CusTD3" onclick='go2Page(1,2);' style="cursor:hand; <%if abs(ord)=2 then response.write style%>"> <%if abs(ord)=2 then response.write arrow%></td>
  171. <td class="CusTD3" onclick='go2Page(1,3);' style="cursor:hand; <%if abs(ord)=3 then response.write style%>"> <%if abs(ord)=3 then response.write arrow%></td>
  172. <td class="CusTD3" onclick='go2Page(1,4);' style="cursor:hand; <%if abs(ord)=4 then response.write style%>" style='direction:RTL;'># <%if abs(ord)=4 then response.write arrow%></td>
  173. <td class="CusTD3" onclick='go2Page(1,5);' style="cursor:hand; <%if abs(ord)=5 then response.write style%>" > <%if abs(ord)=5 then response.write arrow%></td>
  174. <td class="CusTD3" >GL</td>
  175. <td class="CusTD3" onclick='go2Page(1,6);' style="cursor:hand; <%if abs(ord)=6 then response.write style%>" > <%if abs(ord)=6 then response.write arrow%></td>
  176. <td class="CusTD3" onclick='go2Page(1,7);' style="cursor:hand; <%if abs(ord)=7 then response.write style%>" > <%if abs(ord)=7 then response.write arrow%></td>
  177. <td class="CusTD3" onclick='go2Page(1,8);' style="cursor:hand; <%if abs(ord)=8 then response.write style%>" > <%if abs(ord)=8 then response.write arrow%></td>
  178. </tr>
  179. <% tmpCounter=(CurrentPage - 1) * PageSize
  180. SumAmount = 0
  181. SumReceiptAmount = 0
  182. LastReceipt = 0
  183. Do while NOT RS1.eof AND (RS1.AbsolutePage = CurrentPage)
  184. Number= RS1("Number")
  185. ReceiptID = RS1("ReceiptID")
  186. Amount = cdbl(RS1("Amount"))
  187. if ReceiptID = LastReceipt then
  188. ReceiptAmount = 0
  189. ReceiptAmountText = ""
  190. else
  191. ReceiptAmount = cdbl(RS1("ReceiptAmount"))
  192. ReceiptAmountText = Separate(ReceiptAmount)
  193. tmpCounter = tmpCounter + 1
  194. end if
  195. SumReceiptAmount = SumReceiptAmount + ReceiptAmount
  196. SumAmount = SumAmount + Amount
  197. if tmpCounter mod 2 = 1 then
  198. tmpColor="#FFFFFF"
  199. tmpColor2="#FFFFBB"
  200. Else
  201. tmpColor="#DDDDDD"
  202. tmpColor2="#EEEEBB"
  203. End if
  204. %>
  205. <TR bgcolor="<%=tmpColor%>" style="cursor: hand;" onMouseOver="this.style.backgroundColor='<%=tmpColor2%>'" onMouseOut="this.style.backgroundColor='<%=tmpColor%>'" onclick="window.open('../AR/AccountReport.asp?act=showReceipt&receipt=<%=RS1("ReceiptID")%>');">
  206. <TD style="height:30px;"><%=tmpCounter%></TD>
  207. <TD style="height:30px;"><%=ReceiptID%></TD>
  208. <TD><%=RS1("AccountTitle")%>&nbsp;</TD>
  209. <TD><%=RS1("Customer")%>&nbsp;</TD>
  210. <TD style="height:30px;"><%=RS1("InvoiceId")%></TD>
  211. <TD dir="LTR" align='right' <%=tmpColor3%> ><%=Number%>&nbsp;</TD>
  212. <TD dir="LTR" align='right' <%=tmpColor3%> ><%=RS1("GL")%></TD>
  213. <TD><%=ReceiptAmountText%>&nbsp;</TD>
  214. <TD><%=Separate(Amount)%>&nbsp;</TD>
  215. <TD dir="LTR" align='right'><%=RS1("EffectiveDate")%>&nbsp;</TD>
  216. </TR>
  217. <%
  218. LastReceipt = ReceiptID
  219. RS1.moveNext
  220. Loop
  221. %>
  222. <tr dir=rtl bgcolor=#CCCCCC >
  223. <td colspan=7 align=left > &nbsp;</td>
  224. <td ><B><%=Separate(SumReceiptAmount)%></B></td>
  225. <td ><B><%=Separate(SumAmount)%></B></td>
  226. <td ></td>
  227. </tr>
  228. <%
  229. if ToDate="9999/99/99" then ToDate=""
  230. if TotalPages > 1 then
  231. pageCols=20
  232. %>
  233. <TR class="RepTableTitle">
  234. <TD bgcolor='#33AACC' height="30" colspan="10">
  235. <table width=100% cellspacing=0 style="cursor:hand;color:#444444">
  236. <tr>
  237. <td style="height:25;border-bottom:1 solid black;" colspan=<%=pagecols%>>
  238. <b> <%=CurrentPage%> <%=TotalPages%></b>
  239. &nbsp;&nbsp;<a href="javascript:go2Page(<%=CurrentPage+1%>,0);"> &gt;</a>
  240. </td>
  241. </tr>
  242. <tr>
  243. <% for i=1 to TotalPages
  244. if i = CurrentPage then
  245. %> <td style="color:black;"><b>[<%=i%>]</b></td>
  246. <% else
  247. %> <td onclick="go2Page(<%=i%>,0);"><%=i%></td>
  248. <% end if
  249. if i mod pageCols = 0 then response.write "</tr><tr>"
  250. next
  251. %> </tr>
  252. </table>
  253. <SCRIPT LANGUAGE="JavaScript">
  254. <!--
  255. function go2Page(p,ord) {
  256. if(ord==0){
  257. ord=<%=Ord%>;
  258. }
  259. else if(ord==<%=Ord%>){
  260. ord= 0-ord;
  261. }
  262. window.location="?act=show&ResultsInPage=<%=ResultsInPage%>&p="+p+"&FromDate=<%=FromDate%>&ToDate=<%=ToDate%>&isA=<%=isA%>&ShowRemained=<%=ShowRemained%>&Ord="+escape(ord);
  263. }
  264. //-->
  265. </SCRIPT>
  266. </TD>
  267. </TR>
  268. <% end if
  269. end if
  270. RS1.close
  271. Set RS1 = Nothing
  272. %>
  273. </table>
  274. <br>
  275. <%
  276. end if%>
  277. <!--#include file="tah.asp" -->