/beta/accounting/OtherReports_Tmp4Zamani.asp

http://github.com/khaneh/Orders · ASP · 252 lines · 214 code · 27 blank · 11 comment · 18 complexity · bbe7c9e24ad7259b558cc18a42207900 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'Accounting (8)
  3. PageTitle=" "
  4. SubmenuItem=10
  5. if not Auth(8 , "E") then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <STYLE>
  11. .RepTable {font-family:tahoma; font-size:9pt; direction: RTL; }
  12. .RepTable td {border:1pt solid white;vertical-align:top;}
  13. .RepTable a {text-decoration:none; color:#222288;}
  14. .RepTable a:hover {text-decoration:underline;}
  15. .RepTable2 th {font-size:9pt; background-color:#666699;height:25px;}
  16. .RepTable2 input {font-family:tahoma; font-size:9pt; border:1 solid black;}
  17. </STYLE>
  18. <BR>
  19. <%
  20. '-----------------------------------------------------------------------------------------------------
  21. '----------------------------------------------------------------------------------------- Search Form
  22. '-----------------------------------------------------------------------------------------------------
  23. if request("act")="MoeenRep" OR request("act")="" then
  24. Ord=request("Ord")
  25. select case Ord
  26. case "1":
  27. order="Tafsil"
  28. case "-1":
  29. order="Tafsil DESC"
  30. case "2":
  31. order="AccountTitle"
  32. case "-2":
  33. order="AccountTitle DESC"
  34. case "3":
  35. order="totalDebit"
  36. case "-3":
  37. order="totalDebit DESC"
  38. case "4":
  39. order="totalCredit"
  40. case "-4":
  41. order="totalCredit DESC"
  42. case "5","-6":
  43. order="ISNULL(SUM(ARItems.AmountOriginal * ARItems.IsCredit), 0) - ISNULL(SUM(ARItems.AmountOriginal * (1 - ARItems.IsCredit)), 0) DESC"
  44. case "6","-5":
  45. order="ISNULL(SUM(ARItems.AmountOriginal * ARItems.IsCredit), 0) - ISNULL(SUM(ARItems.AmountOriginal * (1 - ARItems.IsCredit)), 0)"
  46. case else:
  47. order="Tafsil"
  48. Ord=1
  49. end select
  50. %>
  51. <SCRIPT LANGUAGE="JavaScript">
  52. <!--
  53. function showAcc(acc){
  54. window.open('tafsili.asp?accountID='+acc+'&FromDate=<%=FromDate%>&ToDate=<%=ToDate%>&moeenFrom=0&moeenTo=99999&act=Show');
  55. }
  56. //-->
  57. </SCRIPT>
  58. <TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
  59. <TR bgcolor="#EEEECC" height="30">
  60. <TD colspan=7>
  61. 82
  62. </TD>
  63. </TR>
  64. <%
  65. 'mySQL = "SELECT SUM(SumCred) AS SumCred, SUM(SumDeb) AS SumDeb, SUM(Flow * (Sgn + 1) / 2) AS sumFlowCred, SUM(Flow * (Sgn - 1) / 2) AS sumFlowdeb FROM (SELECT SUM(IsCredit * Amount) AS SumCred, SUM(- ((IsCredit - 1) * Amount)) AS SumDeb, SUM(IsCredit * Amount) - SUM(- ((IsCredit - 1) * Amount)) AS Flow, SIGN(SUM(IsCredit * Amount) - SUM(- ((IsCredit - 1) * Amount))) AS Sgn FROM EffectiveGLRows WHERE (GLAccount = "& GLAccount & ") AND (GL = "& OpenGL & ") AND (ISNULL(Tafsil, 0) >= "& FromTafsil & ") AND (ISNULL(Tafsil, 0) <= "& ToTafsil & ") AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "') GROUP BY Tafsil) FlowTbl"
  66. mySQL="SELECT SUM(totalCredit) AS sumCred, SUM(totalDebit) AS sumDeb, SUM(Flow * (Sgn + 1) / 2) AS sumFlowCred, SUM(Flow * (Sgn - 1) / 2) AS sumFlowdeb FROM (SELECT Account AS Tafsil, ISNULL(SUM(AmountOriginal * IsCredit), 0) AS totalCredit, ISNULL(SUM(AmountOriginal * (1 - IsCredit)), 0) AS totalDebit, ISNULL(SUM(AmountOriginal * (CONVERT(tinyint, IsCredit) - .5) * 2), 0) AS Flow, ISNULL(SIGN(SUM(AmountOriginal * (CONVERT(tinyint, IsCredit) - .5) * 2)), 0) AS Sgn FROM ARItems WHERE (Voided = 0) AND (EffectiveDate < '1383/01/01') GROUP BY Account) FlowTbl"
  67. set rs=Conn.Execute (mySQL)
  68. %>
  69. <TR bgcolor="#EEEECC" >
  70. <TD colspan=2 rowspan=2>
  71. </TD>
  72. <TD width=70 > </TD>
  73. <TD width=70 > </TD>
  74. <TD width=70 > </TD>
  75. <TD width=70 > </TD>
  76. </TR>
  77. <TR bgcolor="#EEEECC" >
  78. <TD width=70 ><%=Separate(rs("SumDeb"))%></TD>
  79. <TD width=70 ><%=Separate(rs("SumCred"))%></TD>
  80. <TD width=70 ><%=Separate(rs("SumFlowDeb"))%></TD>
  81. <TD width=70 ><%=Separate(rs("SumFlowCred"))%></TD>
  82. </TR>
  83. <TR bgcolor="black" height="2">
  84. <TD colspan="6" style="padding:0;"></TD>
  85. </TR>
  86. <%
  87. rs.close
  88. if ord<0 then
  89. style="background-color: #33CC99;"
  90. arrow="<br><span style='font-family:webdings'>6 6 6</span>"
  91. else
  92. style="background-color: #33CC99;"
  93. arrow="<br><span style='font-family:webdings'>5 5 5</span>"
  94. end if
  95. %>
  96. <TR bgcolor="eeeeee" style="cursor:hand;" title=" ">
  97. <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>
  98. <TD width='*' onclick='go2Page(1,2);' style="<%if abs(ord)=2 then response.write style%>"> <%if abs(ord)=2 then response.write arrow%></TD>
  99. <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>
  100. <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>
  101. <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>
  102. <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>
  103. </TR>
  104. <TR bgcolor="eeeeee" >
  105. <TD colspan=6 height=2 bgcolor=0></TD>
  106. </TR>
  107. <%
  108. SumCredit=0
  109. SumDebit=0
  110. SumCreditRemained=0
  111. SumDebitRemained=0
  112. tmpCounter=0
  113. 'mySQL="SELECT GLRows.Tafsil, SUM(GLRows.IsCredit * GLRows.Amount) AS totalCredit, SUM(- ((GLRows.IsCredit - 1) * GLRows.Amount)) AS totalDebit, Accounts.AccountTitle AS AccountTitle FROM (SELECT ID AS GLDoc, GLDocDate FROM GLDocs WHERE (GLDocs.IsTemporary = 1 OR GLDocs.IsChecked = 1 OR GLDocs.IsFinalized = 1) AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "') AND (GL = "& openGL & " ) AND (IsRemoved = 0) AND (deleted = 0)) EffectiveGLDocs INNER JOIN GLRows ON EffectiveGLDocs.GLDoc = GLRows.GLDoc INNER JOIN Accounts ON GLRows.Tafsil = Accounts.ID WHERE (GLRows.GLAccount = "& GLAccount & ") AND (GLRows.deleted = 0) GROUP BY GLRows.Tafsil, Accounts.AccountTitle HAVING (ISNULL(GLRows.Tafsil, 0) >= "& FromTafsil & ") AND (ISNULL(GLRows.Tafsil, 0) <= "& ToTafsil & ") ORDER BY " & order
  114. mySQL="SELECT ARItems.Account AS Tafsil, ISNULL(SUM(ARItems.AmountOriginal * ARItems.IsCredit), 0) AS totalCredit, ISNULL(SUM(ARItems.AmountOriginal * (1 - ARItems.IsCredit)), 0) AS totalDebit, Accounts.AccountTitle FROM ARItems INNER JOIN Accounts ON ARItems.Account = Accounts.ID WHERE (ARItems.Voided = 0) AND (ARItems.EffectiveDate < '1383/01/01') GROUP BY ARItems.Account, Accounts.AccountTitle ORDER BY "& order
  115. '
  116. ' The Differences:
  117. ' mySQL="SELECT FromHan.Tafsil, FromHan.totalCredit AS HanCredit, FromHan.totalDebit AS HanDebit, DRV.totalCredit AS sysCred, DRV.totalDebit AS sysDeb FROM (SELECT GLRows.Tafsil, SUM(GLRows.IsCredit * GLRows.Amount) AS totalCredit, SUM(- ((GLRows.IsCredit - 1) * GLRows.Amount)) AS totalDebit FROM (SELECT ID AS GLDoc, GLDocDate FROM GLDocs WHERE (GLDocs.IsTemporary = 1 OR GLDocs.IsChecked = 1 OR GLDocs.IsFinalized = 1) AND (GLDocDate >= N'1383/01/01') AND (GLDocDate <= N'1383/01/01') AND (GL = 83) AND (IsRemoved = 0) AND (deleted = 0)) EffectiveGLDocs INNER JOIN GLRows ON EffectiveGLDocs.GLDoc = GLRows.GLDoc WHERE (GLRows.deleted = 0) AND (LEFT(GLRows.GLAccount, 2) = 13) AND (GLRows.Tafsil IS NOT NULL) GROUP BY GLRows.Tafsil) FromHan INNER JOIN (SELECT Account AS Tafsil, ISNULL(SUM(AmountOriginal * IsCredit), 0) AS totalCredit, ISNULL(SUM(AmountOriginal * (1 - IsCredit)), 0) AS totalDebit FROM ARItems WHERE (Voided = 0) AND (EffectiveDate < '1383/01/01') GROUP BY Account) DRV ON FromHan.Tafsil = DRV.Tafsil AND FromHan.totalCredit - FromHan.totalDebit <> DRV.totalCredit - DRV.totalDebit"
  118. '
  119. '
  120. Set rs=Server.CreateObject("ADODB.Recordset")'Conn.Execute(mySQL)
  121. PageSize = 25
  122. rs.PageSize = PageSize
  123. rs.CursorLocation=3 'in ADOVBS_INC adUseClient=3
  124. rs.Open mySQL ,Conn,3
  125. TotalPages = rs.PageCount
  126. CurrentPage=1
  127. if isnumeric(Request.QueryString("p")) then
  128. pp=clng(Request.QueryString("p"))
  129. if pp <= TotalPages AND pp > 0 then
  130. CurrentPage = pp
  131. end if
  132. end if
  133. if not rs.eof then
  134. rs.AbsolutePage=CurrentPage
  135. end if
  136. if rs.eof then
  137. %> <tr>
  138. <td bgcolor="#BBBBBB" height="30" colspan="7" align=center><b> .</b></td>
  139. </tr>
  140. <% else
  141. Do While NOT rs.eof AND (rs.AbsolutePage = CurrentPage)
  142. tmpCounter = tmpCounter + 1
  143. if tmpCounter mod 2 = 1 then
  144. tmpColor="#FFFFFF"
  145. tmpColor2="#FFFFBB"
  146. Else
  147. tmpColor="#DDDDDD"
  148. tmpColor2="#EEEEBB"
  149. End if
  150. totalDebit = cdbl(rs("totalDebit"))
  151. totalCredit = cdbl(rs("totalCredit"))
  152. if totalCredit > totalDebit then
  153. creditRemained = totalCredit - totalDebit
  154. debitRemained = 0
  155. else
  156. creditRemained = 0
  157. debitRemained = totalDebit - totalCredit
  158. end if
  159. SumCredit = SumCredit + totalCredit
  160. SumDebit = SumDebit + totalDebit
  161. SumCreditRemained = SumCreditRemained + creditRemained
  162. SumDebitRemained = SumDebitRemained + debitRemained
  163. %>
  164. <TR bgcolor="<%=tmpColor%>" >
  165. <TD dir=ltr align=right><A HREF="javascript:showAcc(<%=rs("Tafsil")%>);"><%=rs("Tafsil")%></A></TD>
  166. <TD><%=rs("AccountTitle")%></TD>
  167. <TD dir=ltr align=right><span dir=ltr><%=Separate(totalDebit)%></span></TD>
  168. <TD dir=ltr align=right><span dir=ltr><%=Separate(totalCredit)%></span></TD>
  169. <TD dir=ltr align=right><span dir=ltr><%=Separate(debitRemained)%></span></TD>
  170. <TD dir=ltr align=right><span dir=ltr><%=Separate(creditRemained)%></span></TD>
  171. </TR>
  172. <%
  173. rs.moveNext
  174. Loop
  175. if TotalPages > 1 then
  176. pageCols=20
  177. %>
  178. <TR bgcolor="eeeeee" >
  179. <TD colspan=6 height=2 bgcolor=0></TD>
  180. </TR>
  181. <TR class="RepTableTitle">
  182. <TD bgcolor="#CCCCEE" height="30" colspan="6">
  183. <table width=100% cellspacing=0 style="cursor:hand;color:gray;">
  184. <tr>
  185. <td style="height:25;border-bottom:1 solid black;" colspan=<%=pagecols%>>
  186. <b> <%=CurrentPage%> <%=TotalPages%></b>
  187. &nbsp;&nbsp;<a href="javascript:go2Page(<%=CurrentPage+1%>,0);"> &gt;</a>
  188. </td>
  189. </tr>
  190. <tr>
  191. <% for i=1 to TotalPages
  192. if i = CurrentPage then
  193. %> <td style="color:black;"><b>[<%=i%>]</b></td>
  194. <% else
  195. %> <td onclick="go2Page(<%=i%>,0);"><%=i%></td>
  196. <% end if
  197. if i mod pageCols = 0 then response.write "</tr><tr>"
  198. next
  199. %> </tr>
  200. </table>
  201. </TD>
  202. </TR>
  203. <% end if
  204. %>
  205. </TABLE><br>
  206. <SCRIPT LANGUAGE="JavaScript">
  207. <!--
  208. function go2Page(p,ord) {
  209. if(ord==0){
  210. ord=<%=Ord%>;
  211. }
  212. else if(ord==<%=Ord%>){
  213. ord= 0-ord;
  214. }
  215. str='?act=MoeenRep&GLAccount='+escape('<%=GLAccount%>')+'&FromDate='+escape('<%=FromDate%>')+'&ToDate='+escape('<%=ToDate%>')+'&FromTafsil='+escape('<%=FromTafsil%>')+'&ToTafsil='+escape('<%=ToTafsil%>')+'&Ord='+escape(ord)+'&p='+escape(p) //+'& ='+escape(' ')+'& ='+escape(' ')+'& ='+escape(' ')
  216. window.location=str;
  217. }
  218. //-->
  219. </SCRIPT>
  220. <%
  221. end if
  222. end if
  223. %>
  224. <!--#include file="tah.asp" -->