/beta/cashReg/CashRegReport.asp

http://github.com/khaneh/Orders · ASP · 300 lines · 279 code · 17 blank · 4 comment · 16 complexity · 6e8aecbdab5a3c83e2bbae9e1c48cab9 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'CashRegister (9)
  3. PageTitle=" "
  4. SubmenuItem=3
  5. if not Auth(9 , 3) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <STYLE>
  11. .CClosTable {font-family:tahoma; font-size:9pt; direction: RTL; border:2 solid #330099;}
  12. .CClosTable td {padding:5;border:1pt solid gray;}
  13. .CClosTable a {text-decoration:none; color:#222288;}
  14. .CClosTable a:hover {text-decoration:underline;}
  15. .CClosTableTitle {background-color: #CCCCFF; text-align: center; font-weight:bold; height:50;}
  16. .CClosTableHeader {background-color: #BBBBBB; text-align: center; font-weight:bold;}
  17. .CClosTableFooter {background-color: #BBBBBB; direction: LTR; }
  18. .CClosTR1 {background-color: #DDDDDD;}
  19. .CClosTR2 {background-color: #FFFFFF;}
  20. .CClosTR3 {background-color: #EEEEFF;}
  21. .RepTable {font-family:tahoma; font-size:9pt; direction: RTL; }
  22. .RepTable td {padding:5;border:1pt solid gray;}
  23. .RepTable a {text-decoration:none; color:#222288;}
  24. .RepTable a:hover {text-decoration:underline;}
  25. .RepTableTitle {background-color: #CCCCFF; text-align: center; font-weight:bold; height:50;}
  26. .RepTableHeader {background-color: #BBBBBB; text-align: center; font-weight:bold;}
  27. .RepTableFooter {background-color: #BBBBBB; direction: LTR; }
  28. .RepTR1 {background-color: #DDDDDD;}
  29. .RepTR2 {background-color: #FFFFFF;}
  30. </STYLE>
  31. <%
  32. function Link2Trace(OrderNo)
  33. Link2Trace="<A HREF='../order/TraceOrder.asp?act=show&order="& OrderNo & "' target='_balnk'>"& OrderNo & "</A>"
  34. end function
  35. mySQL="SELECT Bankers.Name AS BankerName, CashRegisters.*, Users.RealName FROM CashRegisters INNER JOIN Users ON CashRegisters.Cashier = Users.ID INNER JOIN Bankers ON CashRegisters.Banker = Bankers.ID WHERE (CashRegisters.IsOpen=1) AND (Cashier='"& session("ID") & "')"
  36. Set RS1= conn.Execute(mySQL)
  37. if RS1.eof then
  38. %><br><br>
  39. <TABLE width='70%' align='center'>
  40. <TR>
  41. <TD align=center bgcolor=#FFBBBB style='border: solid 1pt black'><BR><b> <%=CSRName%> ... <br><br> <br>."</b><BR><BR></TD>
  42. </TR>
  43. </TABLE>
  44. <% conn.close
  45. response.end
  46. else
  47. CashRegID= RS1("ID")
  48. BankerName= RS1("BankerName")
  49. CashRegName= RS1("NameDate")
  50. OpenningDate= RS1("OpenDate")
  51. OpenningAmount= cdbl(RS1("OpeningAmount"))
  52. totalCashAmountA= Separate(RS1("cashAmountA"))
  53. totalCashAmountB= Separate(RS1("cashAmountB"))
  54. totalChequeAmount= Separate(RS1("chequeAmount"))
  55. totalChequeQtty= RS1("chequeQtty")
  56. TotalAmount= Separate(cdbl(RS1("cashAmountA")) + cdbl(RS1("cashAmountB")) + cdbl(RS1("chequeAmount")))
  57. Set RS1=nothing
  58. end if
  59. if true then ' this 'if' statement is reserved for further changes. It is not neccesary.
  60. 'response.write cashRegID
  61. mySQL="SELECT CashRegisterLines.ID,CashRegisterLines.isA, CashRegisterLines.CashReg, CashRegisterLines.Date, CashRegisterLines.Time, CashRegisterLines.Type, isnull(case when isnull(drv.isA,0)>0 and CashRegisterLines.type=1 then ISNULL(Receipts.CashAmount,0) end,0) AS CashAmountA, isnull(case when isnull(drv.isA,0)<1 and CashRegisterLines.type=1 then ISNULL(Receipts.CashAmount,0) end,0) AS CashAmountB, CashRegisterLines.Link, CashRegisterLines.Voided, ISNULL(Receipts.CashAmount, 0) AS CashAmount, ISNULL(Receipts.ChequeAmount, 0) AS ChequeAmount, Receipts.ChequeQtty, Payments.CashAmount AS PayAmount, Accounts_1.AccountTitle AS PayAccTitle, Accounts_2.AccountTitle AS RcpAccTitle, Accounts_1.ID AS PayAccID, Accounts_2.ID AS RcpAccID FROM CashRegisterLines LEFT OUTER JOIN Accounts AS Accounts_1 INNER JOIN Payments ON Accounts_1.ID = Payments.Account ON CashRegisterLines.Link = Payments.ID LEFT OUTER JOIN Accounts AS Accounts_2 INNER JOIN Receipts ON Accounts_2.ID = Receipts.Customer ON CashRegisterLines.Link = Receipts.ID left outer join (select Receipts.id, isnull(sum(cast(invoices.IsA as int)),-1) as isA from Receipts inner join ARItems on receipts.id=arItems.link inner join ARItemsRelations on arItems.ID=arItemsRelations.CreditARItem inner join ARItems as arItems_D on arItemsRelations.DebitARItem=arItems_D.id inner join Invoices on arItems_D.link=invoices.ID where receipts.SYS='AR' and arItems_D.type=1 group by Receipts.id) as drv on receipts.id=drv.id WHERE (CashRegisterLines.CashReg = '"& CashRegID & "') ORDER BY CashRegisterLines.ID"
  62. ' response.write mySQL
  63. ' response.end
  64. Set RS1 = conn.execute(mySQL)
  65. Remained = 0
  66. Totalcredit = 0
  67. TotalDebit = 0
  68. tempCounter = 0
  69. if Not (RS1.EOF AND OpenningAmount=0) then
  70. %>
  71. <br>
  72. <TABLE class="RepTable" width='100%' align='center'>
  73. <TR>
  74. <TD class="RepTableTitle" colspan=10 dir='rtl' align='center'><br><B> <span dir='LTR'><%=CashRegName%></span> - <%=CSRName%> </B><BR>(: <%=BankerName%>)<br>
  75. </TD>
  76. </TR>
  77. <TR class="RepTableHeader">
  78. <TD width="15px">#</TD>
  79. <TD width="15px"> x </TD>
  80. <TD width="50px"></TD>
  81. <TD width="10px"></TD>
  82. <TD width="60px"></TD>
  83. <td width="30px">/</td>
  84. <TD></TD>
  85. <TD width="60px"></TD>
  86. <TD width="60px"></TD>
  87. <TD width="60px"></TD>
  88. </TR>
  89. <%
  90. if OpenningAmount<>0 then
  91. Remained = OpenningAmount
  92. Credit = OpenningAmount
  93. Totalcredit = OpenningAmount
  94. tempCounter = 0
  95. %> <TR class='<%if tempCounter MOD 2 = 0 then response.write "RepTR1" else response.write "RepTR2"%>'>
  96. <td><%=tempCounter%></td>
  97. <td align='center'><b>x&nbsp;<b></td>
  98. <td dir='LTR'><%=OpenningDate%></td>
  99. <td colspan='3'> </td>
  100. <td dir='LTR' align='right'><%=Separate(Debit)%>&nbsp;</td>
  101. <td dir='LTR' align='right'><%=Separate(Credit)%>&nbsp;</td>
  102. <td dir='LTR' align='right'><%=Separate(Remained)%>&nbsp;</td>
  103. </TR>
  104. <% end if
  105. While Not (RS1.EOF)
  106. tempCounter=tempCounter+1
  107. if RS1("Type")=1 then
  108. sourceLink="../AR/AccountReport.asp?act=showReceipt&receipt="& RS1("Link")
  109. voidLink="Void.asp?act=voidReceipt&receipt="& RS1("Link")
  110. Description = " "
  111. myAND=""
  112. CashAmount=cdbl(RS1("CashAmount"))
  113. ChequeAmount=cdbl(RS1("ChequeAmount"))
  114. if CashAmount<>0 then
  115. Description=Description & " "
  116. myAND=" "
  117. end if
  118. if RS1("ChequeQtty")<>0 then
  119. Description=Description & myAND & RS1("ChequeQtty") & " "
  120. end if
  121. AccID=RS1("RcpAccID")
  122. AccTitle=RS1("RcpAccTitle")
  123. Credit=CashAmount + ChequeAmount
  124. Debit=0
  125. elseif RS1("Type")=2 then
  126. sourceLink="../AR/AccountReport.asp?act=showPayment&payment="& RS1("Link")
  127. voidLink="Void.asp?act=voidPayment&payment="& RS1("Link")
  128. Description = " "
  129. AccID=RS1("PayAccID")
  130. AccTitle=RS1("PayAccTitle")
  131. Credit=0
  132. Debit=RS1("PayAmount")
  133. else
  134. sourceLink="javascript:void(0);"
  135. voidLink="javascript:void(0);"
  136. Description = ""
  137. AccountInfo=""
  138. Credit=0
  139. Debit=0
  140. end if
  141. TotalDebit = TotalDebit + CLng(Debit)
  142. Totalcredit = Totalcredit + CLng(Credit)
  143. Remained = Remained + CLng(Credit) - CLng(Debit)
  144. %> <TR class='<%if tempCounter MOD 2 = 0 then response.write "RepTR1" else response.write "RepTR2"%>'>
  145. <td><%=tempCounter%></td>
  146. <td align='center'><b><A HREF="<%=voidLink%>" onclick="return setVoid(this);">x</A>&nbsp;<b></td>
  147. <td dir='LTR'><%=RS1("Date")%></td>
  148. <td dir='LTR'><%=RS1("Time")%></td>
  149. <td><A HREF='<%=sourceLink%>' target='_blank'><%=Description%></A></td>
  150. <td align="center"><%
  151. if CBool(rs1("isA")) then
  152. response.write("<b></b>")
  153. else
  154. response.write("")
  155. end if
  156. %></td>
  157. <td><A HREF='../AR/AccountReport.asp?act=show&selectedCustomer=<%=AccID%>' target='_blank'><%=AccTitle%></A></td>
  158. <td dir='LTR' align='right'><%=Separate(Debit)%></td>
  159. <td dir='LTR' align='right' title='<%=": "&RS1("CashAmountA") & " : " & RS1("CashAmountB")%>'><%=Separate(Credit) %></td>
  160. <td dir='LTR' align='right'>
  161. <% if RS1("Voided")=TRUE then
  162. %> <div style="position:absolute;width:700;"><hr style="color:red;"></div>
  163. <% response.write "xx xx xx" '& Separate(remained) & "xx"
  164. TotalDebit = TotalDebit - CLng(Debit)
  165. Totalcredit = Totalcredit - CLng(Credit)
  166. Remained = Remained - CLng(Credit) + CLng(Debit)
  167. else
  168. response.write Separate(remained)
  169. end if
  170. %> </td>
  171. </TR>
  172. <%
  173. RS1.MoveNext
  174. Wend
  175. if Remained>=0 then
  176. remainedColor="green"
  177. else
  178. remainedColor="red"
  179. end if
  180. %>
  181. <TR>
  182. <TD class="RepTableFooter" colspan='7'>&nbsp;&nbsp; : </td>
  183. <TD class="RepTableFooter" align='right'><%=Separate(totaldebit)%></td>
  184. <TD class="RepTableFooter" align='right'><%=Separate(totalcredit)%></td>
  185. <TD class="RepTableFooter" align='right'><FONT COLOR='<%=remainedColor%>'><%=Separate(Remained)%></FONT></td>
  186. </TR>
  187. </TABLE>
  188. <br >
  189. <TABLE class="CClosTable" width='90%' align='center' style="page-break-before:always;">
  190. <%
  191. mySQL="SELECT ReceivedCheques.ChequeNo, ReceivedCheques.ChequeDate, ReceivedCheques.Description, ReceivedCheques.BankOfOrigin, receivedCheques.Amount, CashRegisterLines.* FROM ReceivedCheques INNER JOIN Receipts ON ReceivedCheques.Receipt = Receipts.ID INNER JOIN CashRegisterLines ON Receipts.ID = CashRegisterLines.Link WHERE (CashRegisterLines.CashReg = '"& CashRegID & "') AND (CashRegisterLines.Type = 1) ORDER BY CashRegisterLines.[Date], CashRegisterLines.[Time]"
  192. Set RS1 = conn.execute(mySQL)
  193. Remained = OpenningAmount
  194. Credit = OpenningAmount
  195. Totalcredit = OpenningAmount
  196. TotalDebit = 0
  197. tempCounter = 0
  198. %> <TR class='CClosTR3'>
  199. <td colspan='7' align='center'> <span dir='LTR'><%=CashRegName%></span> (: <%=CSRName%> : <%=BankerName%>)</TD>
  200. </TR>
  201. <TR>
  202. <TD colspan='6' class="CClosTableFooter">: </td>
  203. <TD class="CClosTableFooter" align='right'><span id='cashAmount'><%=Separate(cdbl(totalCashAmountA) + Cdbl(totalCashAmountB))%></span></TD>
  204. </TR>
  205. <TR>
  206. <TD colspan='6' class="CClosTableFooter" style='direction:RTL;text-align=left;'> (<span id='chequeQtty'><%=totalChequeQtty%></span> ) :</td>
  207. <TD class="CClosTableFooter" align='right'><%=totalChequeAmount%></TD>
  208. </TR>
  209. <TR>
  210. <TD colspan='6' class="CClosTableFooter">: </td>
  211. <TD class="CClosTableFooter" align='right'><%=TotalAmount%></td>
  212. </TR>
  213. <TR class='CClosTR3'>
  214. <td colspan='7' align='right'> :</td>
  215. </TR>
  216. <TR class="CClosTableHeader">
  217. <TD width="10px">#</TD>
  218. <TD width="100px"> </TD>
  219. <TD width="50px"></TD>
  220. <TD width="50px"></TD>
  221. <TD width="70px"> </TD>
  222. <TD width="220px"></TD>
  223. <TD width="70px"></TD>
  224. </TR>
  225. <%
  226. While Not (RS1.EOF)
  227. tempCounter=tempCounter+1
  228. sourceLink="../AR/AccountReport.asp?act=showReceipt&receipt="& RS1("Link")
  229. Description = " "
  230. myAND=""
  231. Amount=Separate(RS1("Amount"))
  232. if RS1("Voided") then
  233. tempCounter=tempCounter-1%>
  234. <TR class='CClosTR4'>
  235. <td>-</td>
  236. <td dir='LTR'><A HREF='<%=sourceLink%>' target='_blank'><%=RS1("Date") & " @ " & RS1("Time")%></A></td>
  237. <td><%=RS1("ChequeNo")%></td>
  238. <td><%=RS1("BankOfOrigin")%></td>
  239. <td dir='LTR'><%=RS1("ChequeDate")%></td>
  240. <td><%=RS1("Description")%></td>
  241. <td dir='LTR'>
  242. <div style="position:absolute;width:600;"><hr style="color:red;"></div><div align='right'><%=Amount%></div>
  243. <% else%>
  244. <TR class='<%if tempCounter MOD 2 = 0 then response.write "CClosTR1" else response.write "CClosTR2"%>'>
  245. <td><%=tempCounter%></td>
  246. <td dir='LTR'><A HREF='<%=sourceLink%>' target='_blank'><%=RS1("Date") & " @ " & RS1("Time")%></A></td>
  247. <td><%=RS1("ChequeNo")%></td>
  248. <td><%=RS1("BankOfOrigin")%></td>
  249. <td dir='LTR'><%=RS1("ChequeDate")%></td>
  250. <td><%=RS1("Description")%></td>
  251. <td dir='LTR' align='right'>
  252. <%=Amount%>
  253. <% end if
  254. %> </td>
  255. </TR>
  256. <%
  257. RS1.MoveNext
  258. Wend
  259. %>
  260. </TABLE>
  261. <br>
  262. <% end if
  263. end if
  264. conn.Close
  265. %>
  266. </font>
  267. <script language="JavaScript">
  268. <!--
  269. function setVoid(obj)
  270. {
  271. theTR = obj.parentNode.parentNode.parentNode;
  272. for(i=0; i<theTR.getElementsByTagName("TD").length; i++){
  273. theTR.getElementsByTagName("TD")[i].setAttribute("bgColor","yellow")
  274. }
  275. confirmResult = confirm('! / \n\n Ͽ');
  276. for(i=0; i<theTR.getElementsByTagName("TD").length; i++){
  277. theTR.getElementsByTagName("TD")[i].setAttribute("bgColor","")
  278. }
  279. return confirmResult;
  280. }
  281. //-->
  282. </script>
  283. <!--#include file="tah.asp" -->