/beta/AO/AOReport.asp

http://github.com/khaneh/Orders · ASP · 187 lines · 159 code · 18 blank · 10 comment · 21 complexity · b5525ab46f5fd14b79f6a58298b75b63 MD5 · raw file

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