PageRenderTime 21ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/AR/Rep_AInvoices.asp

http://github.com/khaneh/Orders
ASP | 395 lines | 347 code | 44 blank | 4 comment | 38 complexity | c8ddba09e60c4ef283b8ae9627b09615 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Order (2)
  3PageTitle="����� ����"
  4SubmenuItem=11
  5if not Auth("C" , 4) then NotAllowdToViewThisPage()
  6%>
  7<!--#include file="top.asp" -->
  8<STYLE>
  9	.GetCustTbl {font-family:tahoma; background-color: #DDDDDD; width:630; direction: RTL; }
 10	.GetCustTbl td {padding:2; font-size: 9pt; height:25;}
 11	.GetCustInp { font-family:tahoma; font-size: 9pt;}
 12	.CusTableHeader {background-color: #33AACC; text-align: center; font-weight:bold;}
 13	.CustContactTable {font-family:tahoma; width:100%; border:1 solid black; direction: RTL; background-color:#CCCCCC;}
 14	.CustContactTable td {padding:5;}
 15	.CustTable {font-family:tahoma; width:80%; border:1 solid black; direction: RTL; background-color:black;}
 16	.CustTable td {padding:5;}
 17	.CustTable a {text-decoration:none;color:#000088}
 18	.CustTable a:hover {text-decoration:underline;}
 19	.CusTD1 {background-color: #CCCC66; text-align: left; font-weight:bold;}
 20	.CusTD2 {background-color: #DDDDDD; direction: LTR; text-align: right; font-size:9pt;}
 21	.CusTD3 {background-color: #DDDDDD; direction: LTR; text-align: center; font-size:9pt;}
 22	.CusTD4 {background-color: #CCCC66; direction: LTR; text-align: center; font-size:9pt;}
 23	.CustTable4 {font-family:tahoma; direction: RTL; width:100%; height:100%; background-color:#C3DBEB;}
 24</STYLE>
 25<%
 26if request("act")="show" then
 27
 28	ON ERROR RESUME NEXT
 29
 30		ResultsInPage =	cint(request("ResultsInPage"))
 31
 32		FromDate =		sqlSafe(request("FromDate"))
 33		ToDate =		sqlSafe(request("ToDate"))
 34		
 35		if FromDate="" AND ToDate="" then
 36			pageTitle="�� ���� ����"
 37		elseif FromDate="" then
 38			pageTitle="�� ����� �� ����� " & replace (ToDate,"/",".")
 39		elseif ToDate="" then
 40			pageTitle="�� ����� "& replace (FromDate,"/",".") & " �� ����� "
 41		else
 42			pageTitle="�� ����� "& replace (FromDate,"/",".") & " �� ����� " & replace (ToDate,"/",".")
 43		end if
 44	
 45		if ToDate = "" then ToDate = "9999/99/99"
 46		
 47		if Err.Number<>0 then
 48			Err.clear
 49			conn.close
 50			response.redirect "OtherReports.asp?errMsg=" & Server.URLEncode("��� �� �����.")
 51		end if
 52	ON ERROR GOTO 0
 53%>
 54<br>
 55<br>
 56	<table class="CustTable" cellspacing='1' style='width:680;' align='center'>
 57<%
 58	mySumSQL="SELECT SUM(CONVERT(bigint, Invoices.TotalReceivable)) AS SumAmount FROM Invoices INNER JOIN ARItems ON Invoices.ID = ARItems.Link WHERE (Invoices.Voided = 0) AND (Invoices.Issued = 1) AND (Invoices.IsA = 1) AND (ARItems.GL = "& openGL & ") AND (ARItems.Type = 1) AND (Invoices.IssuedDate >= N'"& FromDate & "') AND (Invoices.IssuedDate <= N'"& ToDate & "') "
 59	Set RS1=Conn.Execute(mySumSQL)
 60	if NOT RS1.eof then
 61		SumAmount=RS1("SumAmount")
 62%>	
 63			<tr>
 64				<td colspan="2" class="CusTableHeader" style="text-align:right;height:35;">������ ��� ��� (<%=pageTitle%>)</td>
 65			</tr>
 66			<tr>
 67				<td width="580px" class="CusTD3" style="text-align:left">��� ����</td>
 68				<td width="100px" bgcolor="white" dir=LTR align=center><%=Separate(SumAmount)%></TD>
 69			</tr>		
 70		<br><br>
 71
 72<%		
 73	end if
 74	RS1.close
 75	Set RS1= Nothing
 76
 77	mySumSQL="SELECT SUM(CONVERT(bigint, ARItems.RemainedAmount)) AS SumRemainedAmount FROM Invoices INNER JOIN ARItems ON Invoices.ID = ARItems.Link WHERE (Invoices.Voided = 0) AND (Invoices.Issued = 1) AND (Invoices.IsA = 1) AND (ARItems.GL = "& openGL & ") AND (ARItems.Type = 1) AND (Invoices.IssuedDate >= N'"& FromDate & "') AND (Invoices.IssuedDate <= N'"& ToDate & "') "
 78	Set RS1=Conn.Execute(mySumSQL)
 79	if NOT RS1.eof then
 80		SumRemainedAmount = RS1("SumRemainedAmount")
 81%>
 82			<tr>
 83				<td width="580px" class="CusTD3" style="text-align:left">��� ����� ��</td>
 84				<td width="100px" bgcolor="white" dir=LTR align=center><%=Separate(SumRemainedAmount)%></TD>
 85			</tr>
 86		<br><br>
 87<%		
 88	end if
 89	RS1.close
 90	Set RS1= Nothing
 91%>
 92	</table>
 93	<br>
 94	<table class="CustTable" cellspacing='1' style='width:90%;' align='center'>
 95		<tr>
 96			<td colspan="8" class="CusTableHeader" style="text-align:right;height:35;">������ ��� ��� (<%=pageTitle%>)</td>
 97		</tr>
 98<%
 99		mySQL="SELECT Invoices.ID, Invoices.IssuedDate, Invoices.Number, Invoices.TotalReceivable, Invoices.Customer, Accounts.AccountTitle, ARItems.RemainedAmount FROM Invoices INNER JOIN ARItems ON Invoices.ID = ARItems.Link INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Invoices.Voided = 0) AND (Invoices.Issued = 1) AND (Invoices.IsA = 1) AND (Invoices.IssuedDate >= N'"& FromDate & "') AND (Invoices.IssuedDate <= N'"& ToDate & "') AND (ARItems.GL = "& openGL & ") AND (ARItems.Type = 1) ORDER BY CONVERT(int, Invoices.Number)"
100
101
102		Set RS1 = Server.CreateObject("ADODB.Recordset")
103
104		PageSize = ResultsInPage
105		RS1.PageSize = PageSize 
106
107		RS1.CursorLocation=3 'in ADOVBS_INC adUseClient=3
108		RS1.Open mySQL ,Conn,3
109		TotalPages = RS1.PageCount
110
111		CurrentPage=1
112
113		if isnumeric(Request.QueryString("p")) then
114			pp=clng(Request.QueryString("p"))
115			if pp <= TotalPages AND pp > 0 then
116				CurrentPage = pp
117			end if
118		end if
119
120		if not RS1.eof then
121			RS1.AbsolutePage=CurrentPage
122		end if
123
124
125		if RS1.eof then
126%>			<tr>
127				<td colspan="8" class="CusTD3" style='direction:RTL;'>��� ������� ���� ���.</td>
128			</tr>
129<%		else
130%>			<tr>
131				<td class="CusTD3">#</td>
132				<td class="CusTD3" style='direction:RTL;'># ������</td>
133				<td class="CusTD3">����� ����</td>
134				<td class="CusTD3">����� ����</td>
135				<td class="CusTD3">����� ���</td>
136				<td class="CusTD3">����� ����</td>
137				<td class="CusTD3">����</td>
138				<td class="CusTD3">�����</td>
139			</tr>
140<%			tmpCounter=(CurrentPage - 1) * PageSize
141			LastNumber=RS1("Number")
142			Do while NOT RS1.eof AND (RS1.AbsolutePage = CurrentPage)
143				tmpCounter = tmpCounter + 1
144				if tmpCounter mod 2 = 1 then
145					tmpColor="#FFFFFF"
146					tmpColor2="#FFFFBB"
147				Else
148					tmpColor="#DDDDDD"
149					tmpColor2="#EEEEBB"
150				End if 
151				Number=	RS1("Number")
152				if trim("" & Number) = "" then
153					tmpColor3="BGcolor='#FFBBBB'"
154					LastNumber=0
155				elseif clng(Number) > clng(LastNumber+1) then
156					tmpColor3="BGcolor='#FFBBBB'"
157					LastNumber=Number
158				else
159					tmpColor3=""
160					LastNumber=Number
161				end if
162%>
163				<TR bgcolor="<%=tmpColor%>" style="cursor: pointer;" onMouseOver="this.style.backgroundColor='<%=tmpColor2%>'" onMouseOut="this.style.backgroundColor='<%=tmpColor%>'" onclick="window.open('../AR/AccountReport.asp?act=showInvoice&invoice=<%=RS1("ID")%>');">
164					<TD style="height:30px;"><%=tmpCounter%></TD>
165					<TD style="height:30px;"><%=RS1("ID")%></TD>
166					<TD><%=RS1("AccountTitle")%>&nbsp;</TD>
167					<TD><%=RS1("Customer")%>&nbsp;</TD>
168					<TD dir="LTR" align='right' <%=tmpColor3%> ><%=Number%>&nbsp;</TD>
169					<TD dir="LTR" align='right'><%=RS1("IssuedDate")%>&nbsp;</TD>
170					<TD><%=Separate(RS1("TotalReceivable"))%>&nbsp;</TD>
171					<TD><%=Separate(RS1("RemainedAmount"))%>&nbsp;</TD>
172				</TR>
173<%				RS1.moveNext
174			Loop
175
176			if ToDate="9999/99/99" then ToDate="" 
177
178			if TotalPages > 1 then
179				pageCols=20
180%>			
181				<TR class="RepTableTitle">
182					<TD bgcolor='#33AACC' height="30" colspan="8">
183					<table width=100% cellspacing=0 style="cursor:hand;color:#444444">
184					<tr>
185						<td style="height:25;border-bottom:1 solid black;" colspan=<%=pagecols%>>
186							<b>���� <%=CurrentPage%> �� <%=TotalPages%></b>
187							&nbsp;&nbsp;<a href="javascript:go2Page(<%=CurrentPage+1%>);">���� ��� &gt;</a>
188						</td>
189					</tr>
190					<tr>
191<%					for i=1 to TotalPages 
192						if i = CurrentPage then 
193%>							<td style="color:black;"><b>[<%=i%>]</b></td>
194<%						else
195%>							<td onclick="go2Page(<%=i%>);"><%=i%></td>
196<%						end if 
197						if i mod pageCols = 0 then response.write "</tr><tr>" 
198					next 
199
200%>					</tr>
201					</table>
202
203					<SCRIPT LANGUAGE="JavaScript">
204					<!--
205					function go2Page(p) {
206						window.location="?act=show&ResultsInPage=<%=ResultsInPage%>&p="+p+"&FromDate=<%=FromDate%>&ToDate=<%=ToDate%>";
207					}
208					//-->
209					</SCRIPT>
210
211					</TD>
212				</TR>
213<%			end if
214		end if
215		RS1.close
216		Set RS1 = Nothing
217%>
218	</table>
219	<br>
220<%
221elseif request("act")="showByDay" then
222
223	ON ERROR RESUME NEXT
224
225		ResultsInPage =	cint(request("ResultsInPage"))
226
227		FromDate =		sqlSafe(request("FromDate"))
228		ToDate =		sqlSafe(request("ToDate"))
229		
230		if FromDate="" AND ToDate="" then
231			pageTitle="�� ���� ����"
232		elseif FromDate="" then
233			pageTitle="�� ����� �� ����� " & replace (ToDate,"/",".")
234		elseif ToDate="" then
235			pageTitle="�� ����� "& replace (FromDate,"/",".") & " �� ����� "
236		else
237			pageTitle="�� ����� "& replace (FromDate,"/",".") & " �� ����� " & replace (ToDate,"/",".")
238		end if
239	
240		if ToDate = "" then ToDate = "9999/99/99"
241		
242		if Err.Number<>0 then
243			Err.clear
244			conn.close
245			response.redirect "OtherReports.asp?errMsg=" & Server.URLEncode("��� �� �����.")
246		end if
247	ON ERROR GOTO 0
248%>
249<br>
250<br>
251
252<%
253	mySumSQL="SELECT SUM(CONVERT(bigint, Invoices.TotalReceivable)) AS SumAmount FROM Invoices INNER JOIN ARItems ON Invoices.ID = ARItems.Link WHERE (Invoices.Voided = 0) AND (Invoices.Issued = 1) AND (Invoices.IsA = 1) AND (ARItems.GL = "& openGL & ") AND (ARItems.Type = 1) AND (Invoices.IssuedDate >= N'"& FromDate & "') AND (Invoices.IssuedDate <= N'"& ToDate & "') "
254	Set RS1=Conn.Execute(mySumSQL)
255	if NOT RS1.eof then
256		SumAmount=RS1("SumAmount")
257%>
258		<table class="CustTable" cellspacing='1' style='width:680;' align='center'>
259			<tr>
260				<td colspan="2" class="CusTableHeader" style="text-align:right;height:35;">������ ��� ��� (<%=pageTitle%>)</td>
261			</tr>
262			<tr>
263				<td width="580px" class="CusTD3" style="text-align:left">��� ����</td>
264				<td width="100px" bgcolor="white" dir=LTR align=center><%=Separate(SumAmount)%></TD>
265			</tr>
266		</table>
267		<br><br>
268
269<%		
270	end if
271	RS1.close
272	Set RS1= Nothing
273%>
274	<br>
275	<table class="CustTable" cellspacing='1' style='width:90%;' align='center'>
276		<tr>
277			<td colspan="7" class="CusTableHeader" style="text-align:right;height:35;">������ ��� ��� (<%=pageTitle%>)</td>
278		</tr>
279<%
280		mySQL="SELECT Invoices.IssuedDate, COUNT(Invoices.ID) AS CNT_Invoices, SUM(Invoices.TotalReceivable) AS SumPrice, COUNT(DISTINCT Invoices.Customer) AS CNT_Customers FROM Invoices INNER JOIN ARItems ON Invoices.ID = ARItems.Link WHERE (ARItems.GL = '"& openGL & "') AND (ARItems.Type = 1) AND (Invoices.Voided = 0) AND (Invoices.Issued = 1) AND (Invoices.IsA = 1) GROUP BY Invoices.IssuedDate HAVING (Invoices.IssuedDate >= N'"& FromDate & "') AND (Invoices.IssuedDate <= N'"& ToDate & "') ORDER BY Invoices.IssuedDate"
281
282'response.write mySQL
283'response.end
284
285		Set RS1 = Server.CreateObject("ADODB.Recordset")
286
287		PageSize = ResultsInPage
288		RS1.PageSize = PageSize 
289
290		RS1.CursorLocation=3 'in ADOVBS_INC adUseClient=3
291		RS1.Open mySQL ,Conn,3
292		TotalPages = RS1.PageCount
293
294		CurrentPage=1
295
296		if isnumeric(Request.QueryString("p")) then
297			pp=clng(Request.QueryString("p"))
298			if pp <= TotalPages AND pp > 0 then
299				CurrentPage = pp
300			end if
301		end if
302
303		if not RS1.eof then
304			RS1.AbsolutePage=CurrentPage
305		end if
306
307
308		if RS1.eof then
309%>			<tr>
310				<td colspan="7" class="CusTD3" style='direction:RTL;'>��� ������� ���� ���.</td>
311			</tr>
312<%		else
313%>			<tr>
314				<td class="CusTD3">#</td>
315				<td class="CusTD3">���</td>
316				<td class="CusTD3">����� ������ ���</td>
317				<td class="CusTD3">����� �������</td>
318				<td class="CusTD3">��� ����</td>
319			</tr>
320<%			tmpCounter=(CurrentPage - 1) * PageSize
321			Do while NOT RS1.eof AND (RS1.AbsolutePage = CurrentPage)
322				tmpCounter = tmpCounter + 1
323				if tmpCounter mod 2 = 1 then
324					tmpColor="#FFFFFF"
325					tmpColor2="#FFFFBB"
326				Else
327					tmpColor="#DDDDDD"
328					tmpColor2="#EEEEBB"
329				End if 
330%>
331				<TR bgcolor="<%=tmpColor%>" style="cursor: pointer;" onMouseOver="this.style.backgroundColor='<%=tmpColor2%>'" onMouseOut="this.style.backgroundColor='<%=tmpColor%>'" onclick="drill2date('<%=RS1("IssuedDate")%>');">
332					<TD style="height:30px;"><%=tmpCounter%></TD>
333					<TD dir="LTR" align='center'><%=RS1("IssuedDate")%>&nbsp;</TD>
334					<TD align='center'><%=RS1("CNT_Invoices")%>&nbsp;</TD>
335					<TD align='center'><%=RS1("CNT_Customers")%>&nbsp;</TD>
336					<TD><%=Separate(RS1("SumPrice"))%>&nbsp;</TD>
337				</TR>
338<%				RS1.moveNext
339			Loop
340
341			if ToDate="9999/99/99" then ToDate="" 
342
343			if TotalPages > 1 then
344				pageCols=20
345%>			
346				<TR class="RepTableTitle">
347					<TD bgcolor='#33AACC' height="30" colspan="7">
348					<table width=100% cellspacing=0 style="cursor:hand;color:#444444">
349					<tr>
350						<td style="height:25;border-bottom:1 solid black;" colspan=<%=pagecols%>>
351							<b>���� <%=CurrentPage%> �� <%=TotalPages%></b>
352							&nbsp;&nbsp;<a href="javascript:go2Page(<%=CurrentPage+1%>);">���� ��� &gt;</a>
353						</td>
354					</tr>
355					<tr>
356<%					for i=1 to TotalPages 
357						if i = CurrentPage then 
358%>							<td style="color:black;"><b>[<%=i%>]</b></td>
359<%						else
360%>							<td onclick="go2Page(<%=i%>);"><%=i%></td>
361<%						end if 
362						if i mod pageCols = 0 then response.write "</tr><tr>" 
363					next 
364
365%>					</tr>
366					</table>
367
368					<SCRIPT LANGUAGE="JavaScript">
369					<!--
370					function go2Page(p) {
371						window.location="?act=showByDay&ResultsInPage=<%=ResultsInPage%>&p="+p+"&FromDate=<%=FromDate%>&ToDate=<%=ToDate%>";
372					}
373					//-->
374					</SCRIPT>
375
376					</TD>
377				</TR>
378<%			end if
379		end if
380		RS1.close
381		Set RS1 = Nothing
382'Rep_AInvoices.asp?act=show&ResultsInPage=50&p=2&FromDate=1384/01/01&ToDate=
383%>
384	</table>
385	<br>
386	<SCRIPT LANGUAGE="JavaScript">
387	<!--
388	function drill2date(date) {
389		window.open('?act=show&ResultsInPage=50&p=1&FromDate='+date+'&ToDate='+date);
390	}
391	//-->
392	</SCRIPT>
393<%
394end if%>
395<!--#include file="tah.asp" -->