/beta/accounting/AccountInfo.asp

http://github.com/khaneh/Orders · ASP · 565 lines · 470 code · 71 blank · 24 comment · 36 complexity · 8162d368b66ba3cf42a8605330071cd8 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. Response.Buffer=false
  3. 'Accounting (8)
  4. PageTitle= " "
  5. SubmenuItem=4
  6. if not Auth(8 , 4) then NotAllowdToViewThisPage()
  7. %>
  8. <!--#include file="top.asp" -->
  9. <!--#include File="../include_farsiDateHandling.asp"-->
  10. <!--#include File="../include_JS_InputMasks.asp"-->
  11. <%
  12. '-----------------------------------------------------------------------------------------------------
  13. '----------------------------------------------------------------------------------------- Search Form
  14. '------------------------------------------------------------------------------------------ +
  15. '--------------------------------------------------------------------------------------------- Scripts
  16. '-----------------------------------------------------------------------------------------------------
  17. if request.form("act")="" then
  18. DateFrom = request("DateFrom")
  19. DateTo = request("DateTo")
  20. act = request("act")
  21. id = request("id")
  22. ShowRemained= request("ShowRemained")
  23. else
  24. DateFrom = request.form("DateFrom")
  25. DateTo = request.form("DateTo")
  26. act = request.form("act")
  27. id = request.form("id")
  28. ShowRemained= request.form("ShowRemained")
  29. end if
  30. if ShowRemained="on" then
  31. ShowRemained=true
  32. else
  33. ShowRemained=false
  34. end if
  35. if DateFrom = "" then DateFrom = fiscalYear & "/01/01"
  36. if DateTo = "" then DateTo = shamsiToday()
  37. %>
  38. <input type="hidden" Name='tmpDlgArg' value=''>
  39. <input type="hidden" Name='tmpDlgTxt' value=''>
  40. <BR>
  41. <FORM METHOD=POST ACTION="">
  42. <input type="hidden" Name='act' value='<%=act%>'>
  43. <input type="hidden" Name='id' value='<%=id%>'>
  44. <TABLE style="border:1 solid #330066;" align=center>
  45. <TR>
  46. <TD align=left> </TD>
  47. <TD><INPUT dir="LTR" TYPE="text" NAME="DateFrom" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=DateFrom%>"></TD>
  48. <TD align=left> </TD>
  49. <TD><INPUT dir="LTR" TYPE="text" NAME="DateTo" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=DateTo%>"></TD>
  50. <TD align=center>
  51. <INPUT TYPE="submit" NAME="submitt" value="">
  52. <INPUT TYPE="hidden" Name="Order" Value="">
  53. </TD>
  54. <TD>
  55. <INPUT TYPE="checkbox" NAME="ShowRemained" <%if ShowRemained then response.write "checked"%>> .
  56. </TD>
  57. </TR>
  58. </FORM>
  59. </TABLE>
  60. <SCRIPT LANGUAGE="JavaScript">
  61. <!--
  62. function drill(act,id){
  63. document.all.act.value=act;
  64. document.all.id.value=id;
  65. document.forms[0].submit();
  66. }
  67. //-->
  68. </SCRIPT>
  69. <%
  70. dateStr = " <span dir=rtl>" & fiscalYear & "/1/1</span> <span dir=rtl>" & shamsiToday() & "</span>"
  71. '-----------------------------------------------------------------------------------------------------
  72. '-------------------------------------------------------------------------------- List GL Super Groups
  73. '-----------------------------------------------------------------------------------------------------
  74. if request("act")="" then
  75. %>
  76. <br>
  77. <TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
  78. <TR bgcolor="#CCCCEE" height="30">
  79. <TD colspan=6>
  80. <A HREF="?"><%=OpenGLName%></A>
  81. </TD>
  82. </TR>
  83. <TR bgcolor="black" height="2">
  84. <TD colspan="6" style="padding:0;"></TD>
  85. </TR>
  86. <TR bgcolor="eeeeee" >
  87. <TD></TD>
  88. <TD> ѐ</TD>
  89. <TD> </TD>
  90. <TD> </TD>
  91. <TD> </TD>
  92. <TD> </TD>
  93. </TR>
  94. <TR bgcolor="eeeeee" >
  95. <TD colspan=6 height=2 bgcolor=0></TD>
  96. </TR>
  97. <%
  98. SumCredit=0
  99. SumDebit=0
  100. SumCreditRemained=0
  101. SumDebitRemained=0
  102. tmpCounter=0
  103. 'Added By kid 830805
  104. if ShowRemained then
  105. mySQL="SELECT ISNULL(SUM(IsCredit * Amount),0) AS totalCredit, ISNULL(SUM(- ((IsCredit - 1) * Amount)),0) AS totalDebit FROM EffectiveGLRows WHERE (GLDocDate < N'"& DateFrom & "') AND (GL = "& OpenGL & ")"
  106. set RSS2=Conn.Execute (mySQL)
  107. if RSS2.eof then
  108. totalDebit = 0
  109. totalCredit = 0
  110. else
  111. totalDebit = cdbl(RSS2("totalDebit"))
  112. totalCredit = cdbl(RSS2("totalCredit"))
  113. end if
  114. RSS2.close
  115. tmpCounter=1
  116. if totalCredit > totalDebit then
  117. creditRemained = totalCredit - totalDebit
  118. debitRemained = 0
  119. else
  120. creditRemained = 0
  121. debitRemained = totalDebit - totalCredit
  122. end if
  123. SumCredit = SumCredit + totalCredit
  124. SumDebit = SumDebit + totalDebit
  125. SumCreditRemained = SumCreditRemained + creditRemained
  126. SumDebitRemained = SumDebitRemained + debitRemained
  127. %>
  128. <TR bgcolor="#FFFFFF">
  129. <TD style="border-bottom:1 solid black;" colspan=2 align=left> <%=replace(DateFrom,"/",".")%></TD>
  130. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalDebit)%></TD>
  131. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalCredit)%></TD>
  132. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(debitRemained)%></TD>
  133. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(creditRemained)%></TD>
  134. </TR>
  135. <%
  136. end if
  137. 'changed by kid 830805
  138. mySQL="SELECT ISNULL(DRV.totalCredit, 0) AS totalCredit, ISNULL(DRV.totalDebit, 0) AS totalDebit, GLAccountSuperGroups.ID, GLAccountSuperGroups.Name FROM (SELECT SUM(EffectiveGLRows.IsCredit * EffectiveGLRows.Amount) AS totalCredit, SUM(- ((EffectiveGLRows.IsCredit - 1) * EffectiveGLRows.Amount)) AS totalDebit, GLAccountGroups.GLSuperGroup FROM EffectiveGLRows INNER JOIN GLAccounts INNER JOIN GLAccountGroups ON GLAccounts.GLGroup = GLAccountGroups.ID AND GLAccounts.GL = GLAccountGroups.GL ON EffectiveGLRows.GL = GLAccounts.GL AND EffectiveGLRows.GLAccount = GLAccounts.ID WHERE (GLDocDate >= N'"& DateFrom & "') AND (GLDocDate <= N'"& DateTo & "') AND (EffectiveGLRows.GL = "& OpenGL&") GROUP BY GLAccountGroups.GLSuperGroup) DRV RIGHT OUTER JOIN GLAccountSuperGroups ON DRV.GLSuperGroup = GLAccountSuperGroups.ID WHERE (GLAccountSuperGroups.GL = "& OpenGL&") ORDER BY GLAccountSuperGroups.ID"
  139. set RSS=Conn.Execute (mySQL)
  140. Do while not RSS.eof
  141. tmpCounter = tmpCounter + 1
  142. if tmpCounter mod 2 = 1 then
  143. tmpColor="#FFFFFF"
  144. tmpColor2="#FFFFBB"
  145. Else
  146. tmpColor="#DDDDDD"
  147. tmpColor2="#EEEEBB"
  148. End if
  149. totalDebit = cdbl(RSS("totalDebit"))
  150. totalCredit = cdbl(RSS("totalCredit"))
  151. if totalCredit > totalDebit then
  152. creditRemained = totalCredit - totalDebit
  153. debitRemained = 0
  154. else
  155. creditRemained = 0
  156. debitRemained = totalDebit - totalCredit
  157. end if
  158. SumCredit = SumCredit + totalCredit
  159. SumDebit = SumDebit + totalDebit
  160. SumCreditRemained = SumCreditRemained + creditRemained
  161. SumDebitRemained = SumDebitRemained + debitRemained
  162. %>
  163. <TR bgcolor="<%=tmpColor%>" height=30>
  164. <TD><A HREF="javascript:drill('groups','<%=RSS("ID")%>');"><%=RSS("ID")%></A></TD>
  165. <TD><A HREF="javascript:drill('groups','<%=RSS("ID")%>');"><%=RSS("Name")%></A></TD>
  166. <TD dir=ltr align=right><span dir=ltr><%=Separate(totalDebit)%></span></TD>
  167. <TD dir=ltr align=right><span dir=ltr><%=Separate(totalCredit)%></span></TD>
  168. <TD dir=ltr align=right><span dir=ltr><%=Separate(debitRemained)%></span></TD>
  169. <TD dir=ltr align=right><span dir=ltr><%=Separate(creditRemained)%></span></TD>
  170. </TR>
  171. <%
  172. RSS.moveNext
  173. Loop
  174. if SumDebitRemained > SumCreditRemained then
  175. TotalSumDebitRemained = SumDebitRemained - SumCreditRemained
  176. TotalSumCreditRemained=0
  177. else
  178. TotalSumDebitRemained=0
  179. TotalSumCreditRemained = SumCreditRemained - SumDebitRemained
  180. end if
  181. %>
  182. <TR bgcolor="eeeeee" >
  183. <TD colspan=6 height=2 bgcolor=0></TD>
  184. </TR>
  185. <TR bgcolor="eeeeee" >
  186. <TD style="border-bottom:1 solid black;" colspan=2 align=left>:</TD>
  187. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumDebit)%></TD>
  188. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumCredit)%></TD>
  189. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumDebitRemained)%></TD>
  190. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumCreditRemained)%></TD>
  191. </TR>
  192. <TR bgcolor="eeeeee" >
  193. <TD colspan=4 align=left> :</TD>
  194. <TD dir=ltr align=right><%=Separate(TotalSumDebitRemained)%></TD>
  195. <TD dir=ltr align=right><%=Separate(TotalSumCreditRemained)%></TD>
  196. </TR>
  197. </TABLE><br>
  198. <CENTER>
  199. <FORM METHOD=POST ACTION="AccountInfo.asp">
  200. <!--INPUT TYPE="button" onclick="window.location='balance.asp'" class="GenButton" value="" style="width:90px; ">
  201. <INPUT TYPE="button" onclick="window.location='sood.asp'" class="GenButton" value=" " style="width:90px; "--><br><br>
  202. <INPUT TYPE="button" onclick="window.location='manageGL.asp?act=select'" class="GenButton" value="" style="width:90px; background-color: #FFFFBB ">
  203. </FORM>
  204. </CENTER>
  205. <%
  206. '-----------------------------------------------------------------------------------------------------
  207. '------------------------------------------------------------------ List GL Groups under a super group
  208. '-----------------------------------------------------------------------------------------------------
  209. elseif request("act")="groups" then
  210. SuperGroupID = clng(id)
  211. 'changed by kid 830804
  212. mySQL="SELECT GLs.ID AS GLID, GLs.Name AS GLname, GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName FROM GLs INNER JOIN GLAccountSuperGroups ON GLs.ID = GLAccountSuperGroups.GL WHERE (GLAccountSuperGroups.GL = "& OpenGL & ") AND (GLAccountSuperGroups.ID = "& SuperGroupID & ")"
  213. set rsGLNames=Conn.Execute (mySQL)
  214. if not rsGLNames.EOF then
  215. %>
  216. <br>
  217. <TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
  218. <TR bgcolor="#CCCCEE" height="30">
  219. <TD colspan=7>
  220. <A HREF="javascript:drill('','');"><%=rsGLNames("GLname")%></A>
  221. > <A HREF="javascript:drill('groups','<%=rsGLNames("SuperGroupID")%>');"><%=rsGLNames("SuperGroupName")%></A>
  222. [<%=rsGLNames("SuperGroupID")%>]
  223. </TD>
  224. </TR>
  225. <TR bgcolor="black" height="2">
  226. <TD colspan="7" style="padding:0;"></TD>
  227. </TR>
  228. <TR bgcolor="eeeeee" >
  229. <TD></TD>
  230. <TD> </TD>
  231. <TD> </TD>
  232. <TD> </TD>
  233. <TD> </TD>
  234. <TD> </TD>
  235. </TR>
  236. <TR bgcolor="eeeeee" >
  237. <TD colspan=7 height=2 bgcolor=0></TD>
  238. </TR>
  239. <% end if
  240. rsGLNames.close
  241. SumCredit=0
  242. SumDebit=0
  243. SumCreditRemained=0
  244. SumDebitRemained=0
  245. tmpCounter=0
  246. 'Added By kid 830805
  247. if ShowRemained then
  248. mySQL="SELECT ISNULL(SUM(IsCredit * Amount),0) AS totalCredit, ISNULL(SUM(- ((IsCredit - 1) * Amount)),0) AS totalDebit FROM GLAccounts INNER JOIN EffectiveGLRows ON GLAccounts.GL = EffectiveGLRows.GL AND GLAccounts.ID = EffectiveGLRows.GLAccount INNER JOIN GLAccountGroups ON GLAccounts.GLGroup = GLAccountGroups.ID AND GLAccounts.GL = GLAccountGroups.GL WHERE (GLDocDate < N'"& DateFrom & "') AND (EffectiveGLRows.GL = "& OpenGL & ") GROUP BY GLAccountGroups.GLSuperGroup HAVING (GLAccountGroups.GLSuperGroup = "& SuperGroupID & ")"
  249. set RSS2=Conn.Execute (mySQL)
  250. if RSS2.eof then
  251. totalDebit = 0
  252. totalCredit = 0
  253. else
  254. totalDebit = cdbl(RSS2("totalDebit"))
  255. totalCredit = cdbl(RSS2("totalCredit"))
  256. end if
  257. RSS2.close
  258. tmpCounter=1
  259. if totalCredit > totalDebit then
  260. creditRemained = totalCredit - totalDebit
  261. debitRemained = 0
  262. else
  263. creditRemained = 0
  264. debitRemained = totalDebit - totalCredit
  265. end if
  266. SumCredit = SumCredit + totalCredit
  267. SumDebit = SumDebit + totalDebit
  268. SumCreditRemained = SumCreditRemained + creditRemained
  269. SumDebitRemained = SumDebitRemained + debitRemained
  270. %>
  271. <TR bgcolor="#FFFFFF">
  272. <TD style="border-bottom:1 solid black;" colspan=2 align=left> <%=replace(DateFrom,"/",".")%></TD>
  273. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalDebit)%></TD>
  274. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalCredit)%></TD>
  275. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(debitRemained)%></TD>
  276. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(creditRemained)%></TD>
  277. </TR>
  278. <%
  279. end if
  280. ' mySQL="SELECT SUM(IsCredit * Amount) AS totalCredit, SUM(- ((IsCredit - 1) * Amount)) AS totalDebit, GLAccounts.GLGroup, GLAccountGroups.Name FROM GLAccounts INNER JOIN EffectiveGLRows ON GLAccounts.GL = EffectiveGLRows.GL AND GLAccounts.ID = EffectiveGLRows.GLAccount INNER JOIN GLAccountGroups ON GLAccounts.GLGroup = GLAccountGroups.ID AND GLAccounts.GL = GLAccountGroups.GL WHERE (GLDocDate >= N'"& DateFrom & "') AND (GLDocDate <= N'"& DateTo & "') AND (EffectiveGLRows.GL = "& OpenGL & ") GROUP BY GLAccountGroups.GLSuperGroup, GLAccounts.GLGroup, GLAccountGroups.Name HAVING (GLAccountGroups.GLSuperGroup = "& SuperGroupID & ") ORDER BY GLAccounts.GLGroup"
  281. 'Changed By Kid 830805
  282. mySQL="SELECT ISNULL(DRV.totalCredit, 0) AS totalCredit, ISNULL(DRV.totalDebit, 0) AS totalDebit, GLAccountGroups.ID, GLAccountGroups.Name FROM (SELECT SUM(EffectiveGLRows.IsCredit * EffectiveGLRows.Amount) AS totalCredit, SUM(- ((EffectiveGLRows.IsCredit - 1) * EffectiveGLRows.Amount)) AS totalDebit, GLAccounts.GLGroup FROM GLAccounts INNER JOIN EffectiveGLRows ON GLAccounts.GL = EffectiveGLRows.GL AND GLAccounts.ID = EffectiveGLRows.GLAccount WHERE (EffectiveGLRows.GLDocDate >= N'"& DateFrom & "') AND (EffectiveGLRows.GLDocDate <= N'"& DateTo & "') AND (EffectiveGLRows.GL = "& OpenGL & ") GROUP BY GLAccounts.GLGroup) DRV RIGHT OUTER JOIN GLAccountGroups ON DRV.GLGroup = GLAccountGroups.ID WHERE (GLAccountGroups.GLSuperGroup = "& SuperGroupID & ") AND (GLAccountGroups.GL = "& OpenGL & ") ORDER BY ID"
  283. set RSS=Conn.Execute (mySQL)
  284. Do while not RSS.eof
  285. tmpCounter = tmpCounter + 1
  286. if tmpCounter mod 2 = 1 then
  287. tmpColor="#FFFFFF"
  288. tmpColor2="#FFFFBB"
  289. Else
  290. tmpColor="#DDDDDD"
  291. tmpColor2="#EEEEBB"
  292. End if
  293. totalDebit = cdbl(RSS("totalDebit"))
  294. totalCredit = cdbl(RSS("totalCredit"))
  295. if totalCredit > totalDebit then
  296. creditRemained = totalCredit - totalDebit
  297. debitRemained = 0
  298. else
  299. creditRemained = 0
  300. debitRemained = totalDebit - totalCredit
  301. end if
  302. SumCredit = SumCredit + totalCredit
  303. SumDebit = SumDebit + totalDebit
  304. SumCreditRemained = SumCreditRemained + creditRemained
  305. SumDebitRemained = SumDebitRemained + debitRemained
  306. %>
  307. <TR bgcolor="<%=tmpColor%>" >
  308. <TD><A HREF="javascript:drill('account','<%=RSS("ID")%>');"><%=RSS("ID")%></A></TD>
  309. <TD><A HREF="javascript:drill('account','<%=RSS("ID")%>');"><%=RSS("Name")%></A></TD>
  310. <TD dir=ltr align=right><span dir=ltr><%=Separate(totalDebit)%></span></TD>
  311. <TD dir=ltr align=right><span dir=ltr><%=Separate(totalCredit)%></span></TD>
  312. <TD dir=ltr align=right><span dir=ltr><%=Separate(debitRemained)%></span></TD>
  313. <TD dir=ltr align=right><span dir=ltr><%=Separate(creditRemained)%></span></TD>
  314. </TR>
  315. <%
  316. RSS.moveNext
  317. Loop
  318. if SumDebitRemained > SumCreditRemained then
  319. TotalSumDebitRemained = SumDebitRemained - SumCreditRemained
  320. TotalSumCreditRemained=0
  321. else
  322. TotalSumDebitRemained=0
  323. TotalSumCreditRemained = SumCreditRemained - SumDebitRemained
  324. end if
  325. %>
  326. <TR bgcolor="eeeeee" >
  327. <TD colspan=7 height=2 bgcolor=0></TD>
  328. </TR>
  329. <TR bgcolor="eeeeee" >
  330. <TD style="border-bottom:1 solid black;" colspan=2 align=left>:</TD>
  331. <TD style="border-bottom:1 solid black;" align=right><%=Separate(SumDebit)%></TD>
  332. <TD style="border-bottom:1 solid black;" align=right><%=Separate(SumCredit)%></TD>
  333. <TD style="border-bottom:1 solid black;" align=right><%=Separate(SumDebitRemained)%></TD>
  334. <TD style="border-bottom:1 solid black;" align=right><%=Separate(SumCreditRemained)%></TD>
  335. </TR>
  336. <TR bgcolor="eeeeee" >
  337. <TD colspan=4 align=left> :</TD>
  338. <TD dir=ltr align=right><%=Separate(TotalSumDebitRemained)%></TD>
  339. <TD dir=ltr align=right><%=Separate(TotalSumCreditRemained)%></TD>
  340. </TR>
  341. </TABLE><br>
  342. <%
  343. '-----------------------------------------------------------------------------------------------------
  344. '---------------------------------------------------------------------- List GL Accounts under a group
  345. '-----------------------------------------------------------------------------------------------------
  346. elseif request("act")="account" then
  347. GroupID = clng(id)
  348. mySQL = "SELECT GLs.Name AS GLName, GLs.ID AS GLID, GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName, GLAccountGroups.ID AS GroupID, GLAccountGroups.Name AS GroupName FROM GLAccountGroups INNER JOIN GLAccountSuperGroups ON GLAccountGroups.GLSuperGroup = GLAccountSuperGroups.ID INNER JOIN GLs ON GLAccountSuperGroups.GL = GLs.ID WHERE (GLAccountSuperGroups.GL = "& OpenGL & ") AND (GLAccountGroups.GL = "& OpenGL & ") AND (GLAccountGroups.ID = "& GroupID & ")"
  349. set rsGLNames=Conn.Execute (mySQL)
  350. if not rsGLNames.EOF then
  351. %>
  352. <br>
  353. <TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
  354. <TR bgcolor="#CCCCEE" height="30">
  355. <TD colspan=6>
  356. <A HREF="javascript:drill('','');"><%=rsGLNames("GLname")%></A>
  357. > <A HREF="javascript:drill('groups','<%=rsGLNames("SuperGroupID")%>');"><%=rsGLNames("SuperGroupName")%></A>
  358. > <A HREF="javascript:drill('account','<%=rsGLNames("GroupID")%>');"><%=rsGLNames("GroupName")%></A>
  359. [<%=rsGLNames("GroupID")%>]
  360. </TD>
  361. </TR>
  362. <TR bgcolor="black" height="2">
  363. <TD colspan="6" style="padding:0;"></TD>
  364. </TR>
  365. <TR bgcolor="eeeeee" >
  366. <TD></TD>
  367. <TD> </TD>
  368. <TD> </TD>
  369. <TD> </TD>
  370. <TD> </TD>
  371. <TD> </TD>
  372. </TR>
  373. <TR bgcolor="eeeeee" >
  374. <TD colspan=6 height=2 bgcolor=0></TD>
  375. </TR>
  376. <% end if
  377. rsGLNames.close
  378. SumCredit=0
  379. SumDebit=0
  380. SumCreditRemained=0
  381. SumDebitRemained=0
  382. tmpCounter=0
  383. 'Added By kid 830805
  384. if ShowRemained then
  385. mySQL="SELECT SUM(IsCredit * Amount) AS totalCredit, SUM(- ((IsCredit - 1) * Amount)) AS totalDebit FROM GLAccounts INNER JOIN EffectiveGLRows ON GLAccounts.GL = EffectiveGLRows.GL AND GLAccounts.ID = GLAccount WHERE (GLAccounts.GL = "& OpenGL & ") AND (GLDocDate < N'"& DateFrom & "') GROUP BY GLAccounts.GLGroup HAVING (GLAccounts.GLGroup = "& GroupID & ")"
  386. set RSS2=Conn.Execute (mySQL)
  387. if RSS2.eof then
  388. totalDebit = 0
  389. totalCredit = 0
  390. else
  391. totalDebit = cdbl(RSS2("totalDebit"))
  392. totalCredit = cdbl(RSS2("totalCredit"))
  393. end if
  394. RSS2.close
  395. tmpCounter=1
  396. if totalCredit > totalDebit then
  397. creditRemained = totalCredit - totalDebit
  398. debitRemained = 0
  399. else
  400. creditRemained = 0
  401. debitRemained = totalDebit - totalCredit
  402. end if
  403. SumCredit = SumCredit + totalCredit
  404. SumDebit = SumDebit + totalDebit
  405. SumCreditRemained = SumCreditRemained + creditRemained
  406. SumDebitRemained = SumDebitRemained + debitRemained
  407. %>
  408. <TR bgcolor="#FFFFFF">
  409. <TD style="border-bottom:1 solid black;" colspan=2 align=left> <%=replace(DateFrom,"/",".")%></TD>
  410. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalDebit)%></TD>
  411. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalCredit)%></TD>
  412. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(debitRemained)%></TD>
  413. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(creditRemained)%></TD>
  414. </TR>
  415. <%
  416. end if
  417. 'mySQL="SELECT GLAccounts.Name, ISNULL(DERIVEDTBL.totalDebit,0) AS totalDebit, ISNULL(DERIVEDTBL.totalCredit,0) AS totalCredit, GLAccounts.ID FROM (SELECT SUM(GLRows.IsCredit * GLRows.Amount) AS totalCredit, SUM(- ((GLRows.IsCredit - 1) * GLRows.Amount)) AS totalDebit, GLRows.GLAccount FROM GLDocs INNER JOIN GLRows ON GLDocs.ID = GLRows.GLDoc WHERE (GLDocs.IsTemporary = 1 OR GLDocs.IsChecked = 1 OR GLDocs.IsFinalized = 1) AND (GLDocs.deleted = 0) AND (GLDocs.IsRemoved = 0) AND (GLRows.deleted = 0) GROUP BY GLRows.GLAccount, GLDocs.GL HAVING (GLDocs.GL = "& OpenGL & ")) DERIVEDTBL RIGHT OUTER JOIN GLAccounts ON DERIVEDTBL.GLAccount = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL & ") AND (GLAccounts.GLGroup = "& GroupID & ") ORDER BY GLAccounts.ID"
  418. 'Changed By Kid 830805
  419. mySQL="SELECT GLAccounts.Name, GLAccounts.HasAppendix, ISNULL(DERIVEDTBL.totalDebit, 0) AS totalDebit, ISNULL(DERIVEDTBL.totalCredit, 0) AS totalCredit, GLAccounts.ID FROM (SELECT SUM(IsCredit * Amount) AS totalCredit, SUM(- ((IsCredit - 1) * Amount)) AS totalDebit, GLAccount FROM EffectiveGLRows WHERE (GLDocDate >= N'"& DateFrom & "') AND (GLDocDate <= N'"& DateTo & "') GROUP BY GLAccount, GL HAVING (GL = "& OpenGL & ")) DERIVEDTBL RIGHT OUTER JOIN GLAccounts ON DERIVEDTBL.GLAccount = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL & ") AND (GLAccounts.GLGroup = "& GroupID & ") ORDER BY GLAccounts.ID"
  420. set RSS2=Conn.Execute (mySQL)
  421. Do while not RSS2.eof
  422. tmpCounter = tmpCounter + 1
  423. if tmpCounter mod 2 = 1 then
  424. tmpColor="#FFFFFF"
  425. tmpColor2="#FFFFBB"
  426. Else
  427. tmpColor="#DDDDDD"
  428. tmpColor2="#EEEEBB"
  429. End if
  430. HasAppendix = RSS2("HasAppendix")
  431. totalDebit = cdbl(RSS2("totalDebit"))
  432. totalCredit = cdbl(RSS2("totalCredit"))
  433. if totalCredit > totalDebit then
  434. creditRemained = totalCredit - totalDebit
  435. debitRemained = 0
  436. else
  437. creditRemained = 0
  438. debitRemained = totalDebit - totalCredit
  439. end if
  440. SumCredit = SumCredit + totalCredit
  441. SumDebit = SumDebit + totalDebit
  442. SumCreditRemained = SumCreditRemained + creditRemained
  443. SumDebitRemained = SumDebitRemained + debitRemained
  444. if ShowRemained then
  445. MoeenShowRemained = "on"
  446. else
  447. MoeenShowRemained = "off"
  448. end if
  449. %>
  450. <TR bgcolor="<%=tmpColor%>" >
  451. <TD>
  452. <%if HasAppendix then%>
  453. * <A Target="_blank" HREF="OtherReports.asp?act=MoeenRep&GLAccount=<%=RSS2("id")%>&FromDate=<%=DateFrom%>&ToDate=<%=DateTo%>&FromTafsil=0&ToTafsil=999999"><%=RSS2("id")%></A>
  454. <%else%>
  455. <A Target="_blank" HREF="moeen.asp?act=Show&accountID=<%=RSS2("id")%>&accountName=<%=Server.URLEncode(RSS2("Name"))%>&FromDate=<%=DateFrom%>&ToDate=<%=DateTo%>&ShowRemained=<%=MoeenShowRemained%>"><%=RSS2("id")%></A>
  456. <%end if %>
  457. </TD>
  458. <TD><A Target="_blank" HREF="moeen.asp?act=Show&accountID=<%=RSS2("id")%>&accountName=<%=Server.URLEncode(RSS2("Name"))%>&FromDate=<%=DateFrom%>&ToDate=<%=DateTo%>&ShowRemained=<%=MoeenShowRemained%>"><%=RSS2("Name")%></A></TD>
  459. <TD dir=ltr align=right><%=Separate(totalDebit)%></TD>
  460. <TD dir=ltr align=right><%=Separate(totalCredit)%></TD>
  461. <TD dir=ltr align=right><%=Separate(debitRemained)%></TD>
  462. <TD dir=ltr align=right><%=Separate(creditRemained)%></TD>
  463. </TR>
  464. <%
  465. RSS2.moveNext
  466. Loop
  467. if SumDebitRemained > SumCreditRemained then
  468. TotalSumDebitRemained = SumDebitRemained - SumCreditRemained
  469. TotalSumCreditRemained=0
  470. else
  471. TotalSumDebitRemained=0
  472. TotalSumCreditRemained = SumCreditRemained - SumDebitRemained
  473. end if
  474. %>
  475. <TR bgcolor="eeeeee" >
  476. <TD colspan=6 height=2 bgcolor=0></TD>
  477. </TR>
  478. <TR bgcolor="eeeeee" >
  479. <TD style="border-bottom:1 solid black;" colspan=2 align=left> <%=replace(DateTo,"/",".")%></TD>
  480. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumDebit)%></TD>
  481. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumCredit)%></TD>
  482. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumDebitRemained)%></TD>
  483. <TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumCreditRemained)%></TD>
  484. </TR>
  485. <TR bgcolor="eeeeee" >
  486. <TD colspan=4 align=left> :</TD>
  487. <TD dir=ltr align=right><%=Separate(TotalSumDebitRemained)%></TD>
  488. <TD dir=ltr align=right><%=Separate(TotalSumCreditRemained)%></TD>
  489. </TR>
  490. </TABLE><br>
  491. <%
  492. end if
  493. %>
  494. <!--#include file="tah.asp" -->