PageRenderTime 29ms CodeModel.GetById 10ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/Inquiry/Rep_BInvoices.asp

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