/beta/AP/APReport.asp

http://github.com/khaneh/Orders · ASP · 213 lines · 186 code · 17 blank · 10 comment · 25 complexity · 108ecb04f317e6b968de8df4b267e06b MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'AP (7)
  3. PageTitle= " "
  4. SubmenuItem=7
  5. if not Auth(7 , 7) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <BR><BR><BR>
  11. <%
  12. selectedCustomer = request("selectedCustomer")
  13. if selectedCustomer="" then selectedCustomer=1000
  14. %>
  15. <%
  16. if not Auth(6 , 9) then
  17. selectedCustomer = session("id")
  18. else
  19. %>
  20. <a href="?act=showRemain"> ȝ </a>
  21. <FORM METHOD=POST ACTION="?act=show">
  22. <CENTER> : <select name="selectedCustomer" class=inputBut ></CENTER>
  23. <option value="1000"> ()</option>
  24. <option value="2000">-------------------</option>
  25. <% set RSV=Conn.Execute ("SELECT * FROM Users WHERE Display=1 ORDER BY RealName")
  26. Do while not RSV.eof
  27. %>
  28. <option value="<%=RSV("ID")%>" <%
  29. if trim(RSV("ID"))=trim(selectedCustomer) then
  30. response.write " selected "
  31. end if
  32. %>><%=RSV("RealName")%></option>
  33. <%
  34. RSV.moveNext
  35. Loop
  36. RSV.close
  37. %>
  38. </select>
  39. <INPUT TYPE="submit" value=""><BR>
  40. <INPUT TYPE="checkbox" <% if request("showZero") = "on" then%>checked <% end if %> NAME="showZero">
  41. </form>
  42. <%
  43. end if
  44. if request("act")="showRemain" then
  45. %>
  46. <table>
  47. <tr>
  48. <td></td>
  49. <td> </td>
  50. <td> </td>
  51. <td></td>
  52. </tr>
  53. <%
  54. set rs=Conn.execute("select * from accounts where apBalance<0")
  55. while not rs.eof
  56. %>
  57. <tr>
  58. <td><a href="../CRM/AccountInfo.asp?act=show&selectedCustomer=<%=rs("id")%>"><%=rs("accountTitle")%></a></td>
  59. <td><%=Separate(abs(CDbl(rs("apBalance"))))%></td>
  60. <td><%=Separate(abs(CDbl(rs("arBalance"))))%></td>
  61. <td><%if CDbl(rs("arBalance"))<0 then response.write " " else if CDbl(rs("arBalance")) >0 then response.write " "%></td>
  62. </tr>
  63. <%
  64. rs.moveNext
  65. wend
  66. %>
  67. </table>
  68. <%
  69. end if
  70. '-----------------------------------------------------------------------------------------------------
  71. '------------------------------------------------------------------------------------ Send New Message
  72. '-----------------------------------------------------------------------------------------------------
  73. if request("act")="show" and selectedCustomer<>"" then
  74. if not request("showZero") = "on" then
  75. extraCond = "and not APBalance=0"
  76. else
  77. extraCond = " "
  78. end if
  79. '=========================================== All CSRs
  80. '====================================================
  81. if selectedCustomer=1000 then '----- brief Report
  82. set RSM = conn.Execute ("SELECT Accounts.CSR, COUNT(Accounts.APBalance) AS AccountsCOUNT, SUM(CONVERT(bigint, Accounts.APBalance)) AS sumAPBalance, Users.RealName FROM Accounts LEFT OUTER JOIN Users ON Accounts.CSR = Users.ID GROUP BY Accounts.CSR, Users.RealName ORDER BY sumAPBalance")
  83. %>
  84. <table style="font-family:tahoma;font-size:9pt; border:1 dashed #888888; direction:RTL;" align="center" Width="90%" Cellspacing="0" Cellpadding="5">
  85. <tbody id="AccountsTable">
  86. <tr bgcolor='#33AACC'>
  87. <td> # </td>
  88. <td> </td>
  89. <td> </td>
  90. <td width='80'> </td>
  91. </tr>
  92. <%
  93. SA_tempCounter= 0
  94. while Not ( RSM.EOF)
  95. AccountsCOUNT=RSM("AccountsCOUNT")
  96. sumAPBalance=cdbl(RSM("sumAPBalance"))
  97. RealName=RSM("RealName")
  98. CSR=RSM("CSR")
  99. if (cdbl(sumAPBalance) >= 0 )then
  100. SA_tempBalanceColor="green"
  101. else
  102. SA_tempBalanceColor="red"
  103. end if
  104. SA_tempCounter=SA_tempCounter+1
  105. if (SA_tempCounter Mod 2 = 1)then
  106. SA_tempColor="#FFFFFF"
  107. else
  108. SA_tempColor="#DDDDDD"
  109. end if
  110. total = total + APBalance
  111. %> <tr >
  112. <td style="border-bottom: solid 1pt black"><%=SA_tempCounter %>&nbsp;</td>
  113. <td style="border-bottom: solid 1pt black" class=alak2><A HREF="?act=show&selectedCustomer=<%=CSR%>"><%=RealName%></A>&nbsp;</td>
  114. <td style="border-bottom: solid 1pt black"><%=AccountsCOUNT%>&nbsp;</td>
  115. <td style="border-bottom: solid 1pt black; direction:LTR; text-align:right;"><FONT COLOR="<%=SA_tempBalanceColor%>"><%=Separate(sumAPBalance)%></FONT>&nbsp;</td>
  116. </tr>
  117. <%
  118. 'total = cdbl(total) + cdbl(sumAPBalance)
  119. RSM.movenext
  120. wend
  121. %>
  122. <tr bgcolor='#33AACC'>
  123. <td align='right' colspan=3> . </td>
  124. <td dir=ltr><! <%=Separate(total)%> ></td>
  125. </td>
  126. </tr>
  127. </table><BR><BR>
  128. <%
  129. response.end
  130. end if
  131. '============================================ One CSR
  132. '====================================================
  133. if selectedCustomer=2000 then '----- no csr Report
  134. mySQL="SELECT * FROM Accounts WHERE (CSR IS NULL)"& extraCond & " ORDER BY APBalance"
  135. else
  136. mySQL="SELECT * FROM Accounts where CSR = " & selectedCustomer & " "& extraCond & " ORDER BY APBalance"
  137. end if
  138. set RSM = conn.Execute (mySQL)
  139. %>
  140. <table style="font-family:tahoma;font-size:9pt; border:1 dashed #888888; direction:RTL;" align="center" Width="90%" Cellspacing="0" Cellpadding="5">
  141. <tbody id="AccountsTable">
  142. <tr bgcolor='#33AACC'>
  143. <td> # </td>
  144. <td> </td>
  145. <td> </td>
  146. <td width='80'> </td>
  147. </tr>
  148. <%
  149. SA_tempCounter= 0
  150. while Not ( RSM.EOF)
  151. AccountNo=RSM("ID")
  152. AccountTitle=RSM("AccountTitle")
  153. APBalance=cdbl(RSM("APBalance"))
  154. CreditLimit=RSM("CreditLimit")
  155. contact1 = RSM("Dear1") & " " & RSM("FirstName1") & " " & RSM("LastName1")
  156. if RSM("Type") = 1 then
  157. AccountTitle = AccountTitle & " () "
  158. end if
  159. if isnull(SA_totalBalance) then
  160. APBalance=0
  161. totalBalanceText="<i>N / A</i>"
  162. tempBalanceColor="gray"
  163. else
  164. if (APBalance>= 0 )then
  165. SA_tempBalanceColor="green"
  166. else
  167. SA_tempBalanceColor="red"
  168. end if
  169. totalBalanceText=Separate(APBalance)
  170. end if
  171. SA_tempCounter=SA_tempCounter+1
  172. if (SA_tempCounter Mod 2 = 1)then
  173. SA_tempColor="#FFFFFF"
  174. else
  175. SA_tempColor="#DDDDDD"
  176. end if
  177. ' total = total + APBalance
  178. %> <tr >
  179. <td style="border-bottom: solid 1pt black"><%=SA_tempCounter %>&nbsp;</td>
  180. <td style="border-bottom: solid 1pt black"><A href="../CRM/AccountInfo.asp?act=show&selectedCustomer=<%=AccountNo%>" target='_blank'><%=AccountTitle%></A>&nbsp;</td>
  181. <td style="border-bottom: solid 1pt black"><%=contact1%>&nbsp;</td>
  182. <td style="border-bottom: solid 1pt black; direction:LTR; text-align:right;"><FONT COLOR="<%=SA_tempBalanceColor%>"><%=totalBalanceText%></FONT>&nbsp;</td>
  183. </tr>
  184. <% RSM.movenext
  185. wend
  186. %>
  187. <tr bgcolor='#33AACC'>
  188. <td align='right' colspan=3> </td>
  189. <td dir=ltr> <%=Separate(total)%> </td>
  190. </td>
  191. </tr>
  192. </table><BR><BR>
  193. <%
  194. end if
  195. %>
  196. <!--#include file="tah.asp" -->