PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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