PageRenderTime 31ms CodeModel.GetById 21ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/AR/Rep_AReceipt.asp

http://github.com/khaneh/Orders
ASP | 316 lines | 271 code | 39 blank | 6 comment | 27 complexity | 912edda6d1e8ec20d22893fe98fd5565 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Order (2)
  3PageTitle="����� ����"
  4SubmenuItem=11
  5if not Auth("C" , 5) 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		isA =			clng(request("isA"))
 31
 32		FromDate =		sqlSafe(request("FromDate"))
 33		ToDate =		sqlSafe(request("ToDate"))
 34
 35		ResultsInPage =	cint(request("ResultsInPage"))
 36		
 37		if FromDate="" AND ToDate="" then
 38			pageTitle="�� ���� ����"
 39		elseif FromDate="" then
 40			pageTitle="�� ����� �� ����� " & replace (ToDate,"/",".")
 41		elseif ToDate="" then
 42			pageTitle="�� ����� "& replace (FromDate,"/",".") & " �� ����� "
 43		else
 44			pageTitle="�� ����� "& replace (FromDate,"/",".") & " �� ����� " & replace (ToDate,"/",".")
 45		end if
 46	
 47		if ToDate = "" then ToDate = "9999/99/99"
 48		
 49		if request("ShowRemained")="on" OR request("ShowRemained")="True" then
 50			ShowRemained=true
 51		else
 52			ShowRemained=false
 53		end if
 54		if Err.Number<>0 then
 55			Err.clear
 56			conn.close
 57			response.redirect "OtherReports.asp?errMsg=" & Server.URLEncode("��� �� �����.")
 58		end if
 59	ON ERROR GOTO 0
 60	Ord=request("Ord")
 61
 62	select case Ord
 63	case "1":
 64		order="Receipts.ID"
 65	case "-1":
 66		order="Receipts.ID DESC"
 67	case "2":
 68		order="AccountTitle"
 69	case "-2":
 70		order="AccountTitle DESC"
 71	case "3":
 72		order="Customer"
 73	case "-3":
 74		order="Customer DESC"
 75	case "4":
 76		order="InvoiceId"
 77	case "-4":
 78		order="InvoiceId DESC"
 79	case "5"
 80		order="Number DESC"
 81	case "-5":
 82		order="Number DESC"
 83	case "6"
 84		order="ReceiptAmount DESC"
 85	case "-6":
 86		order="ReceiptAmount DESC"
 87	case "7"
 88		order="Amount DESC"
 89	case "-7":
 90		order="Amount DESC"
 91	case "8"
 92		order="EffectiveDate DESC"
 93	case "-8":
 94		order="EffectiveDate DESC"
 95	case else:
 96		order="Receipts.ID"
 97		Ord=1
 98	end select
 99	if ord<0 then
100		style="background-color: #33CC99;"
101		arrow="<br><span style='font-family:webdings'>6</span>"
102	else
103		style="background-color: #33CC99;"
104		arrow="<br><span style='font-family:webdings'>5</span>"
105	end if
106
107	otherCriteria=""
108	if isA = 1 then
109		isAName = "�� ��� ���"
110		otherCriteria = " AND (Invoices.IsA = 1) "
111	elseif isA = 2 then
112		isAName = "���� ��� ���"
113		otherCriteria = " AND (Invoices.IsA = 0) "
114	end if
115
116		
117	'mySQL="SELECT * From (SELECT ARItems_1.GL,Receipts.ID AS ReceiptId, Accounts.AccountTitle, Invoices.Customer, Invoices.ID AS InvoiceId, Invoices.Number, ARItems.AmountOriginal AS ReceiptAmount, ARItemsRelations.Amount, Receipts.EffectiveDate FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Receipts.Voided=0) AND (Invoices.IsA = 1) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate<= N'"& ToDate & "') AND (ARItems.Type = 2))drv ORDER BY " & order
118	' Changed By Kid 851026 Adding the option of with/without isA tick
119	mySQL="SELECT ARItems_1.GL,Receipts.ID AS ReceiptId, Accounts.AccountTitle, Invoices.Customer, Invoices.ID AS InvoiceId, Invoices.Number, ARItems.AmountOriginal AS ReceiptAmount, ARItemsRelations.Amount, Receipts.EffectiveDate FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Receipts.Voided=0) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate<= N'"& ToDate & "') AND (ARItems.Type = 2) AND (ARItems_1.Type = 1) " & otherCriteria & " ORDER BY " & order
120
121	'mySQLsum ="SELECT Count(ReceiptId) As ReceiptId,Sum(ReceiptAmount) As ReceiptAmount,Sum(Amount) As Amount From (SELECT ARItems_1.GL,Receipts.ID AS ReceiptId, Accounts.AccountTitle, Invoices.Customer, Invoices.ID AS InvoiceId, Invoices.Number, ARItems.AmountOriginal AS ReceiptAmount, ARItemsRelations.Amount, Receipts.EffectiveDate FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Receipts.Voided=0) AND (Invoices.IsA = 1) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate<= N'"& ToDate & "') AND (ARItems.Type = 2))drv "
122	' Changed By Kid 851026 Adding the option of with/without isA tick
123	'mySQLsum ="SELECT Count(ReceiptId) As ReceiptId,Sum(ReceiptAmount) As ReceiptAmount,Sum(Amount) As Amount From (SELECT ARItems_1.GL,Receipts.ID AS ReceiptId, Accounts.AccountTitle, Invoices.Customer, Invoices.ID AS InvoiceId, Invoices.Number, ARItems.AmountOriginal AS ReceiptAmount, ARItemsRelations.Amount, Receipts.EffectiveDate FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID INNER JOIN Accounts ON Invoices.Customer = Accounts.ID WHERE (Receipts.Voided=0) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate<= N'"& ToDate & "') AND (ARItems.Type = 2) AND (ARItems_1.Type = 1) " & otherCriteria & ")drv "
124	mySQLsum="SELECT COUNT(*) AS ReceiptCNT, SUM(ReceiptAmount) AS SumReceiptAmount, SUM(RelatedAmount) AS SumRelatedAmount FROM (SELECT Receipts.ID, Receipts.TotalAmount AS ReceiptAmount, SUM(ARItemsRelations.Amount) AS RelatedAmount FROM ARItems INNER JOIN Receipts ON ARItems.Link = Receipts.ID INNER JOIN ARItemsRelations ON ARItems.ID = ARItemsRelations.CreditARItem INNER JOIN ARItems ARItems_1 ON ARItemsRelations.DebitARItem = ARItems_1.ID INNER JOIN Invoices ON ARItems_1.Link = Invoices.ID WHERE (Receipts.Voided = 0) AND (Receipts.EffectiveDate >= N'"& FromDate & "') AND (Receipts.EffectiveDate <= N'"& ToDate & "') AND (ARItems.Type = 2) AND (ARItems_1.Type = 1) " & otherCriteria & " GROUP BY Receipts.ID, Receipts.TotalAmount) DRV"
125
126
127	Set Rs2 = Conn.Execute(mySQLsum)
128	if (Not Rs2.EOF) Then
129	ReceiptCNT = Rs2("ReceiptCNT")
130	SumReceitpAmount = Rs2("SumReceiptAmount")
131	SumRelatedAmount = Rs2("SumRelatedAmount")
132
133%>
134	<br><br>
135	<table class="CustTable" cellspacing='1' style='width:90%;' align='center'>
136		<tr>
137			<td colspan="8" class="CusTableHeader" style="text-align:right;height:35;">��� ���� ��� ��� <%=isAName %> &nbsp; <%=GroupName%>  (<%=pageTitle%>)</td>
138		</tr>
139		<tr>
140			<td class="CusTD3" width=100>����� ���� ��</td>
141			<td class="CusTD3">��� ����</td>
142			<td class="CusTD3">��� ��� ���</td>
143		</tr>
144		<tr bgcolor="white">
145			<TD dir=LTR align=center><%=Separate(ReceiptCNT)%></TD>
146			<TD dir=LTR align=center><%=Separate(SumReceitpAmount)%></TD>
147			<TD dir=LTR align=center><%=Separate(SumRelatedAmount)%></TD>
148		</tr>
149	</table>
150	<br><br>
151<%
152	end if 
153	Rs2.Close
154%>
155
156	<table class="CustTable" cellspacing='1' style='width:90%;' align='center'>
157		<tr>
158			<td colspan="10" class="CusTableHeader" style="text-align:right;height:35;">���� ��� ��� (<%=pageTitle%>)</td>
159		</tr>
160<%
161		Set RS1 = Server.CreateObject("ADODB.Recordset")
162
163		PageSize = ResultsInPage
164		RS1.PageSize = PageSize 
165
166		RS1.CursorLocation=3 'in ADOVBS_INC adUseClient=3
167		RS1.Open mySQL ,Conn,3
168		TotalPages = RS1.PageCount
169
170		CurrentPage=1
171
172		if isnumeric(Request.QueryString("p")) then
173			pp=clng(Request.QueryString("p"))
174			if pp <= TotalPages AND pp > 0 then
175				CurrentPage = pp
176			end if
177		end if
178
179		if not RS1.eof then
180			RS1.AbsolutePage=CurrentPage
181		end if
182
183
184		if RS1.eof then
185%>			<tr>
186				<td colspan="10" class="CusTD3" style='direction:RTL;'>��� ������� ���� ���.</td>
187			</tr>
188<%		else
189%>
190			<tr>
191				<td class="CusTD3" >#</td>
192				<td class="CusTD3" onclick='go2Page(1,1);' style="cursor:hand; <%if abs(ord)=1 then response.write style%>" style='direction:RTL;'># ���� <%if abs(ord)=1 then response.write arrow%></td>
193				<td class="CusTD3" onclick='go2Page(1,2);' style="cursor:hand; <%if abs(ord)=2 then response.write style%>">����� ���� <%if abs(ord)=2 then response.write arrow%></td>
194				<td class="CusTD3" onclick='go2Page(1,3);' style="cursor:hand; <%if abs(ord)=3 then response.write style%>">����� ���� <%if abs(ord)=3 then response.write arrow%></td>
195				<td class="CusTD3" onclick='go2Page(1,4);' style="cursor:hand; <%if abs(ord)=4 then response.write style%>" style='direction:RTL;'># ������ <%if abs(ord)=4 then response.write arrow%></td>
196				<td class="CusTD3" onclick='go2Page(1,5);' style="cursor:hand; <%if abs(ord)=5 then response.write style%>" >����� ��� <%if abs(ord)=5 then response.write arrow%></td>
197				<td class="CusTD3" >GL</td>
198				<td class="CusTD3" onclick='go2Page(1,6);' style="cursor:hand; <%if abs(ord)=6 then response.write style%>" >���� <%if abs(ord)=6 then response.write arrow%></td>
199				<td class="CusTD3" onclick='go2Page(1,7);' style="cursor:hand; <%if abs(ord)=7 then response.write style%>" >��� ��� <%if abs(ord)=7 then response.write arrow%></td>
200				<td class="CusTD3" onclick='go2Page(1,8);' style="cursor:hand; <%if abs(ord)=8 then response.write style%>" >����� ���� <%if abs(ord)=8 then response.write arrow%></td>
201			</tr>
202<%			tmpCounter=(CurrentPage - 1) * PageSize
203			SumAmount = 0
204			SumReceiptAmount = 0
205			LastReceipt = 0
206
207			Do while NOT RS1.eof AND (RS1.AbsolutePage = CurrentPage)
208
209				Number=	RS1("Number")
210
211				ReceiptID = RS1("ReceiptID")
212
213				Amount = cdbl(RS1("Amount"))
214
215				if ReceiptID = LastReceipt then
216					ReceiptAmount = 0
217					ReceiptAmountText = ""
218
219				else
220					ReceiptAmount = cdbl(RS1("ReceiptAmount"))
221					ReceiptAmountText = Separate(ReceiptAmount)
222
223					tmpCounter = tmpCounter + 1
224
225				end if
226
227				SumReceiptAmount = SumReceiptAmount + ReceiptAmount
228				SumAmount = SumAmount + Amount
229
230				if tmpCounter mod 2 = 1 then
231					tmpColor="#FFFFFF"
232					tmpColor2="#FFFFBB"
233				Else
234					tmpColor="#DDDDDD"
235					tmpColor2="#EEEEBB"
236				End if 
237
238%>
239				<TR bgcolor="<%=tmpColor%>" style="cursor: hand;" onMouseOver="this.style.backgroundColor='<%=tmpColor2%>'" onMouseOut="this.style.backgroundColor='<%=tmpColor%>'" onclick="window.open('../AR/AccountReport.asp?act=showReceipt&receipt=<%=RS1("ReceiptID")%>');">
240					<TD style="height:30px;"><%=tmpCounter%></TD>
241					<TD style="height:30px;"><%=ReceiptID%></TD>
242					<TD><%=RS1("AccountTitle")%>&nbsp;</TD>
243					<TD><%=RS1("Customer")%>&nbsp;</TD>
244					<TD style="height:30px;"><%=RS1("InvoiceId")%></TD>
245					<TD dir="LTR" align='right' <%=tmpColor3%> ><%=Number%>&nbsp;</TD>
246					<TD dir="LTR" align='right' <%=tmpColor3%> ><%=RS1("GL")%></TD>
247					<TD><%=ReceiptAmountText%>&nbsp;</TD>
248					<TD><%=Separate(Amount)%>&nbsp;</TD>
249					<TD dir="LTR" align='right'><%=RS1("EffectiveDate")%>&nbsp;</TD>
250				</TR>
251<%
252				LastReceipt = ReceiptID 
253				RS1.moveNext
254			Loop
255%>
256			<tr dir=rtl  bgcolor=#CCCCCC >
257				<td  colspan=7 align=left >����� &nbsp;</td>
258				<td ><B><%=Separate(SumReceiptAmount)%></B></td>
259				<td ><B><%=Separate(SumAmount)%></B></td>
260				<td ></td>
261			</tr>
262
263<%
264			if ToDate="9999/99/99" then ToDate="" 
265
266			if TotalPages > 1 then
267				pageCols=20
268%>			
269				<TR class="RepTableTitle">
270					<TD bgcolor='#33AACC' height="30" colspan="10">
271					<table width=100% cellspacing=0 style="cursor:hand;color:#444444">
272					<tr>
273						<td style="height:25;border-bottom:1 solid black;" colspan=<%=pagecols%>>
274							<b>���� <%=CurrentPage%> �� <%=TotalPages%></b>
275							&nbsp;&nbsp;<a href="javascript:go2Page(<%=CurrentPage+1%>,0);">���� ��� &gt;</a>
276						</td>
277					</tr>
278					<tr>
279<%					for i=1 to TotalPages 
280						if i = CurrentPage then 
281%>							<td style="color:black;"><b>[<%=i%>]</b></td>
282<%						else
283%>							<td onclick="go2Page(<%=i%>,0);"><%=i%></td>
284<%						end if 
285						if i mod pageCols = 0 then response.write "</tr><tr>" 
286					next 
287
288%>					</tr>
289					</table>
290
291					<SCRIPT LANGUAGE="JavaScript">
292					<!--
293					function go2Page(p,ord) {
294						if(ord==0){
295						ord=<%=Ord%>;
296						}
297						else if(ord==<%=Ord%>){
298						ord= 0-ord;
299						}
300						window.location="?act=show&ResultsInPage=<%=ResultsInPage%>&p="+p+"&FromDate=<%=FromDate%>&ToDate=<%=ToDate%>&isA=<%=isA%>&ShowRemained=<%=ShowRemained%>&Ord="+escape(ord);
301					}
302					//-->
303					</SCRIPT>
304
305					</TD>
306				</TR>
307<%			end if
308		end if
309		RS1.close
310		Set RS1 = Nothing
311%>
312	</table>
313	<br>
314<%
315end if%>
316<!--#include file="tah.asp" -->