PageRenderTime 13ms CodeModel.GetById 9ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/Inquiry/CSRreport.asp

http://github.com/khaneh/Orders
ASP | 192 lines | 163 code | 18 blank | 11 comment | 21 complexity | be6fc462acb7913bd6630ad5b0da2ae4 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'AR (6)
  3PageTitle="����� ����"
  4SubmenuItem=8
  5if not Auth(6 , 8) 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
 15CSR = request("CSR")
 16if CSR="" then CSR=1000
 17
 18%>
 19<% 
 20if not Auth(6 , 9) then 
 21	CSR = session("id")
 22else
 23%>
 24<FORM METHOD=POST ACTION="?act=show">
 25<CENTER>����� ������: <select name="CSR" 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(CSR) 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 CSR<>"" then
 52
 53	if not request("showZero") = "on" then
 54		extraCond = "and not ARBalance=0"
 55	else
 56		extraCond = " "
 57	end if 
 58
 59	'=========================================== All CSRs
 60	'====================================================
 61	if CSR=1000 then '----- brief Report 
 62'	mySQL="SELECT Accounts.CSR, COUNT(Accounts.APBalance) AS AccountsCOUNT, SUM(CONVERT(bigint, Accounts.ARBalance)) AS sumARBalance, Users.RealName FROM Accounts LEFT OUTER JOIN Users ON Accounts.CSR = Users.ID GROUP BY Accounts.CSR, Users.RealName ORDER BY sumARBalance"
 63'	Changed By Kid 840128
 64	mySQL="SELECT Accounts.CSR, RealName, COUNT(Accounts.APBalance) AS AccountsCOUNT, SUM((SIGN(Accounts.ARBalance) + 1) * .5 * CONVERT(bigint, Accounts.ARBalance)) AS sumPosBalance, SUM((SIGN(Accounts.ARBalance) - 1) * .5 * CONVERT(bigint, Accounts.ARBalance)) AS sumNegBalance FROM Accounts LEFT OUTER JOIN Users ON Accounts.CSR = Users.ID GROUP BY Accounts.CSR, Users.RealName ORDER BY sumNegBalance DESC"
 65
 66	set RSM = conn.Execute (mySQL)
 67	%>
 68	<table style="font-family:tahoma;font-size:9pt; border:1 dashed #888888; direction:RTL;" align="center" Width="90%" Cellspacing="0" Cellpadding="5">
 69	<tbody id="AccountsTable">
 70			<tr bgcolor='#33AACC'>
 71				<td> # </td>
 72				<td> ����� ������</td>
 73				<td> ����� ������</td>
 74				<td width='80'> ����� ��������</td>
 75				<td width='80'> ����� ������</td>
 76			</tr>
 77			<%
 78			SA_tempCounter= 0
 79			while Not ( RSM.EOF) 
 80				AccountsCOUNT=cint(RSM("AccountsCOUNT"))
 81				sumPosBalance=cdbl(RSM("sumPosBalance"))
 82				sumNegBalance=cdbl(RSM("sumNegBalance"))
 83				RealName=RSM("RealName")
 84				CSR=cint(RSM("CSR"))
 85
 86				if (cdbl(sumARBalance) >= 0 )then
 87					SA_tempBalanceColor="green"
 88				else
 89					SA_tempBalanceColor="red"
 90				end if
 91				
 92				SA_tempCounter=SA_tempCounter+1
 93				if (SA_tempCounter Mod 2 = 1)then
 94					SA_tempColor="#FFFFFF"
 95				else
 96					SA_tempColor="#DDDDDD"
 97				end if
 98
 99	%>				<tr >
100						<td style="border-bottom: solid 1pt black"><%=SA_tempCounter %>&nbsp;</td>
101						<td style="border-bottom: solid 1pt black" class=alak2><A HREF="CSRreport.asp?act=show&CSR=<%=CSR%>"><%=RealName%></A>&nbsp;</td>
102						<td style="border-bottom: solid 1pt black"><%=AccountsCOUNT%>&nbsp;</td>
103						<td style="border-bottom: solid 1pt black; direction:LTR; text-align:right;"><FONT COLOR="green"><%=Separate(sumPosBalance)%></FONT>&nbsp;</td>
104						<td style="border-bottom: solid 1pt black; direction:LTR; text-align:right;"><FONT COLOR="red"><%=Separate(sumNegBalance)%></FONT>&nbsp;</td>
105					</tr>
106	<%			
107				'total = cdbl(total) + cdbl(sumARBalance)
108				RSM.movenext
109			wend
110	%>
111			<tr bgcolor='#33AACC'>
112				<td align='right' colspan=4> ���� �� ���� ��� ��� ����� ���� ������ �� �����. </td>
113				<td dir=ltr><! <%=Separate(total)%> ></td>
114
115				</td>
116			</tr>
117		</table><BR><BR>
118<%
119		response.end
120	end if
121	'============================================ One CSR
122	'====================================================
123	if CSR=2000 then '----- no csr Report 
124		
125		mySQL="SELECT * FROM Accounts WHERE (CSR IS NULL)"& extraCond & " ORDER BY ARBalance"
126	else
127		mySQL="SELECT * FROM Accounts where CSR = " & CSR & " "& extraCond & " ORDER BY ARBalance"
128	end if
129
130	set RSM = conn.Execute (mySQL)
131	%>
132	<table style="font-family:tahoma;font-size:9pt; border:1 dashed #888888; direction:RTL;" align="center" Width="90%" Cellspacing="0" Cellpadding="5">
133	<tbody id="AccountsTable">
134			<tr bgcolor='#33AACC'>
135				<td> # </td>
136				<td> ����� ���� </td>
137				<td> ��� ���� ��� </td>
138				<td width='80'> ����� ����</td>
139			</tr>
140			<%
141			SA_tempCounter= 0
142			while Not ( RSM.EOF) 
143				AccountNo=RSM("ID")
144				AccountTitle=RSM("AccountTitle")
145				ARBalance=cdbl(RSM("ARBalance"))
146				CreditLimit=RSM("CreditLimit")
147				contact1 = RSM("Dear1") & " " & RSM("FirstName1") & " " & RSM("LastName1")
148				if RSM("Type") = 1 then 
149					AccountTitle = AccountTitle & " (�������) "
150				end if
151				if isnull(SA_totalBalance) then
152					ARBalance=0
153					totalBalanceText="<i>N / A</i>"
154					tempBalanceColor="gray"
155				else
156					totalBalanceText=Separate(ARBalance)
157					if (ARBalance >= 0 )then
158						SA_tempBalanceColor="green"
159					else
160						SA_tempBalanceColor="red"
161					end if
162				end if
163				SA_tempCounter=SA_tempCounter+1
164				if (SA_tempCounter Mod 2 = 1)then
165					SA_tempColor="#FFFFFF"
166				else
167					SA_tempColor="#DDDDDD"
168				end if
169
170				total = total + ARBalance
171
172	%>				<tr >
173						<td style="border-bottom: solid 1pt black"><%=SA_tempCounter %>&nbsp;</td>
174						<td style="border-bottom: solid 1pt black"><A href="../CRM/AccountInfo.asp?act=show&selectedCustomer=<%=AccountNo%>" target='_blank'><%=AccountTitle%></A>&nbsp;</td>
175						<td style="border-bottom: solid 1pt black"><%=contact1%>&nbsp;</td>
176						<td style="border-bottom: solid 1pt black; direction:LTR; text-align:right;"><FONT COLOR="<%=SA_tempBalanceColor%>"><%=totalBalanceText%></FONT>&nbsp;</td>
177					</tr>
178	<%			RSM.movenext
179			wend
180	%>
181			<tr bgcolor='#33AACC'>
182				<td align='right' colspan=3> ���</td>
183				<td dir=ltr align='right' > <%=Separate(total)%>&nbsp;</td>
184
185				</td>
186			</tr>
187		</table><BR><BR>
188<%
189end if
190%>
191
192<!--#include file="tah.asp" -->