/beta/Inquiry/Rep_4col.asp

http://github.com/khaneh/Orders · ASP · 234 lines · 210 code · 20 blank · 4 comment · 34 complexity · 8462eea5c5dda35a44724f9a28650c94 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'Order (2)
  3. PageTitle=" "
  4. SubmenuItem=11
  5. if not Auth("C" , 8) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <!--#include File="../include_UtilFunctions.asp"-->
  11. <STYLE>
  12. .GetCustTbl {font-family:tahoma; background-color: #DDDDDD; width:630; direction: RTL; }
  13. .GetCustTbl td {padding:2; font-size: 9pt; height:25;}
  14. .GetCustInp { font-family:tahoma; font-size: 9pt;}
  15. .CusTableHeader {background-color: #33AACC; text-align: center; font-weight:bold;}
  16. .CustContactTable {font-family:tahoma; width:100%; border:1 solid black; direction: RTL; background-color:#CCCCCC;}
  17. .CustContactTable td {padding:5;}
  18. .CustTable {font-family:tahoma; width:80%; border:1 solid black; direction: RTL; background-color:black;}
  19. .CustTable td {padding:5;}
  20. .CustTable a {text-decoration:none;color:#000088}
  21. .CustTable a:hover {text-decoration:underline;}
  22. .CusTD1 {background-color: #CCCC66; text-align: left; font-weight:bold;}
  23. .CusTD2 {background-color: #DDDDDD; direction: LTR; text-align: right; font-size:9pt;}
  24. .CusTD3 {background-color: #DDDDDD; direction: LTR; text-align: center; font-size:9pt;}
  25. .CusTD4 {background-color: #CCCC66; direction: LTR; text-align: center; font-size:9pt;}
  26. .CustTable4 {font-family:tahoma; direction: RTL; width:100%; height:100%; background-color:#C3DBEB;}
  27. </STYLE>
  28. <%
  29. if request("act")="show" then
  30. 'ON ERROR RESUME Next
  31. FromDate = sqlSafe(request("FromDate"))
  32. ToDate = sqlSafe(request("ToDate"))
  33. Ord = request("Ord")
  34. If Ord="" Then Ord = 0
  35. 'mySQL="SELECT account, accountTitle, sum(case arItems.[type] when 1 then amountOriginal else 0 end) as totalDebit, sum(case arItems.[type] when 2 then amountOriginal else 0 end) as totalCredit, count(account) as Items FROM arItems inner join accounts on arItems.account = accounts.id where voided = 0 and effectiveDate between N'" & FromDate & "' and N'" & ToDate & "' group by account,accountTitle" & order
  36. select case Ord
  37. case "1":
  38. order="account"
  39. case "-1":
  40. order="account DESC"
  41. case "2":
  42. order="AccountTitle"
  43. case "-2":
  44. order="AccountTitle DESC"
  45. case "3":
  46. order="totalDebit"
  47. case "-3":
  48. order="totalDebit DESC"
  49. case "4":
  50. order="totalCredit"
  51. case "-4":
  52. order="totalCredit DESC"
  53. Case "5":
  54. order = "remainDebit"
  55. Case "-5":
  56. order = "remainDebit DESC"
  57. case "6":
  58. order="remainCredit"
  59. case "-6":
  60. order="remainCredit DESC"
  61. case else:
  62. order="account"
  63. Ord=1
  64. end select
  65. %>
  66. <TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
  67. <%
  68. mySQL = "select sum(remDebit) as sumRemDebit, sum(remCredit) as sumRemCredit, sum(totalDebit + remDebit) as sumTotalDebit, sum(totalCredit + remCredit) as sumTotalCredit, sum(case when (totalDebit+remDebit)>(totalCredit+remCredit) then (totalDebit+remDebit)-(totalCredit+remCredit) else 0 end) as remainDebit, sum(case when (totalDebit+remDebit)<(totalCredit+remCredit) then (totalCredit+remCredit)-(totalDebit+remDebit) else 0 end) as remainCredit, sum(Items) as totalItems from (SELECT CASE WHEN remTbl.amount > 0 THEN 0 ELSE - remTbl.amount END AS remDebit, CASE WHEN remTbl.amount > 0 THEN remTbl.amount ELSE 0 END AS remCredit, account, accountTitle, sum(case arItems.IsCredit when 0 then amountOriginal else 0 end) as totalDebit, sum(case arItems.IsCredit when 1 then amountOriginal else 0 end) as totalCredit, count(account) as Items FROM arItems inner join accounts on arItems.account = accounts.id LEFT OUTER JOIN (SELECT account as remAccount, ISNULL(SUM(AmountOriginal *(CONVERT(tinyint, IsCredit) - .5) * 2 ), 0) as amount from arItems WHERE voided = 0 AND EffectiveDate < N'"&FromDate&"' GROUP BY account) remTbl on remTbl.remAccount = arItems.account WHERE voided = 0 and effectiveDate between N'" & FromDate & "' and N'" & ToDate & "' GROUP BY account,accountTitle,remTbl.amount) drvTBL"
  69. 'response.write mySQL
  70. set rs=Conn.Execute (mySQL)
  71. if rs.eof then
  72. %> <tr>
  73. <td bgcolor="#BBBBBB" height="30" colspan="7" align=center><b> .</b></td>
  74. </tr>
  75. <% Else %>
  76. <TR bgcolor="#CCCCEE" >
  77. <TD colspan=2 rowspan=2 title=" <%=rs("totalItems")%> ">
  78. <B><%=replace(FromDate,"/",".")%></B> <B><%=replace(ToDate,"/",".")%></B><br>
  79. <B><%=FromTafsil%></B> <B><%=ToTafsil%></B>
  80. </TD>
  81. <TD width=70 > </TD>
  82. <TD width=70 > </TD>
  83. <TD width=70 > </TD>
  84. <TD width=70 > </TD>
  85. </TR>
  86. <TR bgcolor="#CCCCEE" >
  87. <TD title='<%=Separate(rs("sumRemDebit"))%> ' width=70 ><%=Separate(rs("sumTotalDebit"))%></TD>
  88. <TD title='<%=Separate(rs("sumRemCredit"))%> ' width=70 ><%=Separate(rs("sumTotalCredit"))%></TD>
  89. <TD width=70 ><%=Separate(rs("remainDebit"))%></TD>
  90. <TD width=70 ><%=Separate(rs("remainCredit"))%></TD>
  91. </TR>
  92. <TR bgcolor="black" height="2">
  93. <TD colspan="6" style="padding:0;"></TD>
  94. </TR>
  95. <%
  96. rs.close
  97. if ord<0 then
  98. style="background-color: #33CC99;"
  99. arrow="<br><span style='font-family:webdings'>6 6 6</span>"
  100. else
  101. style="background-color: #33CC99;"
  102. arrow="<br><span style='font-family:webdings'>5 5 5</span>"
  103. end if
  104. %>
  105. <TR bgcolor="eeeeee" style="cursor:hand;" title=" ">
  106. <TD width=50 onclick='go2Page(1,1);' style="<%if abs(ord)=1 then response.write style%>"> <%if abs(ord)=1 then response.write arrow%></TD>
  107. <TD width='*' onclick='go2Page(1,2);' style="<%if abs(ord)=2 then response.write style%>"> <%if abs(ord)=2 then response.write arrow%></TD>
  108. <TD width=70 onclick='go2Page(1,-3);' style="<%if abs(ord)=3 then response.write style%>"> <%if abs(ord)=3 then response.write arrow%></TD>
  109. <TD width=70 onclick='go2Page(1,-4);' style="<%if abs(ord)=4 then response.write style%>"> <%if abs(ord)=4 then response.write arrow%></TD>
  110. <TD width=70 onclick='go2Page(1,-5);' style="<%if abs(ord)=5 then response.write style%>"> <%if abs(ord)=5 then response.write arrow%></TD>
  111. <TD width=70 onclick='go2Page(1,-6);' style="<%if abs(ord)=6 then response.write style%>"> <%if abs(ord)=6 then response.write arrow%></TD>
  112. </TR>
  113. <TR bgcolor="eeeeee" >
  114. <TD colspan=6 height=2 bgcolor=0></TD>
  115. </TR>
  116. <%
  117. SumCredit=0
  118. SumDebit=0
  119. SumCreditRemained=0
  120. SumDebitRemained=0
  121. tmpCounter=0
  122. mySQL="SELECT CASE WHEN remTbl.amount > 0 THEN 0 ELSE - remTbl.amount END AS remDebit, CASE WHEN remTbl.amount > 0 THEN remTbl.amount ELSE 0 END AS remCredit, account, accountTitle, sum(case arItems.IsCredit when 0 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN 0 ELSE - remTbl.amount END as totalDebit, sum(case arItems.IsCredit when 1 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN remTbl.amount ELSE 0 END as totalCredit, case when (sum(case arItems.IsCredit when 0 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN 0 ELSE - remTbl.amount END) > (sum(case arItems.IsCredit when 1 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN remTbl.amount ELSE 0 END) then (sum(case arItems.IsCredit when 0 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN 0 ELSE - remTbl.amount END)-(sum(case arItems.IsCredit when 1 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN remTbl.amount ELSE 0 END) else 0 end as remainDebit, case when (sum(case arItems.IsCredit when 0 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN 0 ELSE - remTbl.amount END) < (sum(case arItems.IsCredit when 1 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN remTbl.amount ELSE 0 END) then -(sum(case arItems.IsCredit when 0 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN 0 ELSE - remTbl.amount END)+(sum(case arItems.IsCredit when 1 then amountOriginal else 0 end) + CASE WHEN remTbl.amount > 0 THEN remTbl.amount ELSE 0 END) else 0 end as remainCredit, count(account) as Items FROM arItems inner join accounts on arItems.account = accounts.id LEFT OUTER JOIN (SELECT account as remAccount, ISNULL(SUM(AmountOriginal *(CONVERT(tinyint, IsCredit) - .5) * 2 ), 0) as amount from arItems WHERE voided = 0 AND EffectiveDate < N'"&FromDate&"' GROUP BY account) remTbl on remTbl.remAccount = arItems.account WHERE voided = 0 and effectiveDate between N'" & FromDate & "' and N'" & ToDate & "' GROUP BY account,accountTitle,remTbl.amount ORDER BY " & order
  123. Set rs=Server.CreateObject("ADODB.Recordset")'Conn.Execute(mySQL)
  124. PageSize = 50
  125. rs.PageSize = PageSize
  126. rs.CursorLocation=3 'in ADOVBS_INC adUseClient=3
  127. rs.Open mySQL ,Conn,3
  128. TotalPages = rs.PageCount
  129. CurrentPage=1
  130. if isnumeric(Request.QueryString("p")) then
  131. pp=clng(Request.QueryString("p"))
  132. if pp <= TotalPages AND pp > 0 then
  133. CurrentPage = pp
  134. end if
  135. end if
  136. if not rs.eof then
  137. rs.AbsolutePage=CurrentPage
  138. end if
  139. if rs.eof then
  140. %> <tr>
  141. <td bgcolor="#BBBBBB" height="30" colspan="7" align=center><b> .</b></td>
  142. </tr>
  143. <% else
  144. Do While NOT rs.eof AND (rs.AbsolutePage = CurrentPage)
  145. tmpCounter = tmpCounter + 1
  146. if tmpCounter mod 2 = 1 then
  147. tmpColor="#FFFFFF"
  148. tmpColor2="#FFFFBB"
  149. Else
  150. tmpColor="#DDDDDD"
  151. tmpColor2="#EEEEBB"
  152. End if
  153. %>
  154. <TR bgcolor="<%=tmpColor%>" >
  155. <TD dir=ltr align=right><A href="AccountReport.asp?act=show&reason=6&sys=AR&selectedCustomer=<%=rs("account")%>&startDate=<%=FromDate%>&endDate=<%=ToDate%>"><%=rs("account")%></A></TD>
  156. <TD title=" <%=rs("Items")%> "><%=rs("accountTitle")%></TD>
  157. <TD title='<%=Separate(rs("remDebit"))%> ' dir=ltr align=right><span dir=ltr><%=Separate(rs("totalDebit"))%></span></TD>
  158. <TD title='<%=Separate(rs("remCredit"))%> ' dir=ltr align=right><span dir=ltr><%=Separate(rs("totalCredit"))%></span></TD>
  159. <TD dir=ltr align=right><span dir=ltr><%=Separate(rs("remainDebit"))%></span></TD>
  160. <TD dir=ltr align=right><span dir=ltr><%=Separate(rs("remainCredit"))%></span></TD>
  161. </TR>
  162. <%
  163. rs.moveNext
  164. Loop
  165. if TotalPages > 1 then
  166. pageCols=20
  167. %>
  168. <TR bgcolor="eeeeee" >
  169. <TD colspan=6 height=2 bgcolor=0></TD>
  170. </TR>
  171. <TR class="RepTableTitle">
  172. <TD bgcolor="#CCCCEE" height="30" colspan="6">
  173. <table width=100% cellspacing=0 style="cursor:hand;color:gray;">
  174. <tr>
  175. <td style="height:25;border-bottom:1 solid black;" colspan=<%=pagecols%>>
  176. <b> <%=CurrentPage%> <%=TotalPages%></b>
  177. &nbsp;&nbsp;<a href="javascript:go2Page(<%=CurrentPage+1%>,0);"> &gt;</a>
  178. </td>
  179. </tr>
  180. <tr>
  181. <% for i=1 to TotalPages
  182. if i = CurrentPage then
  183. %> <td style="color:black;"><b>[<%=i%>]</b></td>
  184. <% else
  185. %> <td onclick="go2Page(<%=i%>,0);"><%=i%></td>
  186. <% end if
  187. if i mod pageCols = 0 then response.write "</tr><tr>"
  188. next
  189. %> </tr>
  190. </table>
  191. </TD>
  192. </TR>
  193. <% end if
  194. %>
  195. </TABLE>
  196. <br>
  197. <SCRIPT LANGUAGE="JavaScript">
  198. function go2Page(p,ord) {
  199. if(ord==0){
  200. ord=<%=Ord%>;
  201. }
  202. else if(ord==<%=Ord%>){
  203. ord= 0-ord;
  204. }
  205. str = '?act=show&FromDate=' + escape('<%=FromDate%>') + '&ToDate=' + escape('<%=ToDate%>') + '&Ord=' + escape(ord) + '&p=' + escape(p);
  206. window.location = str;
  207. }
  208. </SCRIPT>
  209. <%
  210. End if
  211. End If
  212. End If
  213. %>
  214. <!--#include file="tah.asp" -->