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

/beta/AP/IsA-VouchersReport.asp

http://github.com/khaneh/Orders
ASP | 223 lines | 194 code | 24 blank | 5 comment | 11 complexity | af7050364d8a5250eae0bc6e9d24f328 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'AP (7)
  3PageTitle= "����� ����"
  4SubmenuItem=5
  5if not Auth(7 , 5) then NotAllowdToViewThisPage()
  6
  7fixSys = "AP"
  8SA_IsVendor = 1
  9%>
 10<!--#include file="top.asp" -->
 11<!--#include File="../include_farsiDateHandling.asp"-->
 12<!--#include File="../include_JS_InputMasks.asp"-->
 13
 14<STYLE>
 15	.RepTable {font-family:tahoma; font-size:9pt; direction: RTL; }
 16	.RepTable td {padding:5;border:1pt solid gray;}
 17	.RepTable a {text-decoration:none; color:#222288;}
 18	.RepTable a:hover {text-decoration:underline;}
 19	.RepTableTitle {background-color: #CCCCFF; text-align: center; font-weight:bold; height:50;}
 20	.RepTableHeader {background-color: #BBBBBB; text-align: center; font-weight:bold;}
 21	.RepTableFooter {background-color: #BBBBBB; direction: LTR; }
 22	.RepTR1 {background-color: #DDDDDD;}
 23	.RepTR2 {background-color: #FFFFFF;}
 24	.RepDescSpan {overflow:auto;border:none; width:250px; height:23px; font-size:7pt;}
 25	.RepGenInput { font-family:tahoma; font-size: 8pt; border: 1 solid black; direction:LTR; width:70px; height:19px;}
 26</STYLE>
 27<style>
 28	.InvTable { font-size: 9pt;}
 29	.InvRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
 30	.InvHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
 31	.InvRowInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0FFF0; text-align:right;}
 32	.InvHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
 33	.InvHeadInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right; direction: RTL;}
 34	.InvGenInput { font-family:tahoma; font-size: 9pt; border: none; }
 35</style>
 36<style>
 37	.RcpTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; }
 38	.RcpMainTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; background-color: #558855; text-align:right; direction: RTL;}
 39	.RcpMainTableTH { background-color: #C3C300;}
 40	.RcpMainTableTR { background-color: #CCCC88; border: 0; }
 41	.RcpRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
 42	.RcpRowInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
 43	.RcpHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
 44	.RcpHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
 45	.RcpHeadInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #D0E0FF; text-align:right; direction: RTL;}
 46	.RcpGenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;}
 47	.GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
 48</style>
 49<style>
 50	.MmoTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; direction: LTR;}
 51	.MmoMainTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; background-color: #558855; text-align:right; direction: RTL;}
 52	.MmoMainTableTH { background-color: #C3C300;}
 53	.MmoMainTableTR { background-color: #CCCC88; border: 0; }
 54	.MmoRowInput { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
 55	.MmoRowInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
 56	.MmoHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
 57	.MmoHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
 58	.MmoHeadInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #D0E0FF; text-align:right; direction: RTL;}
 59	.MmoGenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;}
 60</style>
 61
 62
 63<%
 64	CustomerID=request("selectedCustomer")
 65	'sys = request("sys")
 66	'if sys = "" then sys = "AR"
 67	reason = request("Reason")
 68	if reason = "" then reason = 1
 69
 70	mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")"
 71	Set RS1=Conn.execute(mySQL)
 72	if RS1.eof then
 73		conn.close
 74		response.redirect "top.asp?errMsg=" & Server.URLEncode("���!")
 75	else
 76		Sys=			RS1("Acron")
 77		firstGLAccount=	RS1("GLAccount")
 78	end if
 79	RS1.close
 80
 81	if not fixSys = "-" then sys = fixSys
 82
 83	mySQL="SELECT AccountTitle FROM Accounts WHERE (ID='"& CustomerID & "')"
 84	Set RS1 = conn.Execute(mySQL)
 85	customerName=RS1("AccountTitle")
 86	RS1.close
 87	
 88	EndDate=sqlSafe(request("EndDate"))
 89	StartDate=sqlSafe(request("StartDate"))
 90	if StartDate="" then
 91		StartDate=session("OpenGLStartDate") 'yearBeginnig=left(shamsiToday(),4)&"/01/01"
 92	end if
 93	if EndDate="" then
 94		if session("OpenGLEndDate") > shamsiToday() then
 95			EndDate=shamsiToday()
 96		else
 97			EndDate=session("OpenGLEndDate")
 98		end if
 99	end if
100
101	nextYear=cint(left(StartDate,4)) + 1 
102	prevYear=cint(left(StartDate,4)) - 1 
103
104	nextStartDate=	nextYear & "/01/01" 'right(StartDate,6)
105	nextEndDate=	nextYear & "/12/30" 'right(EndDate,6)
106	 
107	prevStartDate=	prevYear & "/01/01" 'right(StartDate,6)
108	prevEndDate=	prevYear & "/12/30" 'right(EndDate,6)
109
110	nextYear=right(nextYear,2)
111	prevYear=right(prevYear,2)
112%>
113	<br>
114
115	<TABLE class="RepTable" width='90%' align='center'>
116	<TR>
117		<TD colspan=8 dir='rtl' align='center'>
118		</TD>
119	</TR>
120	<TR>
121		<TD class="RepTableTitle" colspan=8 dir='rtl' align='center'>
122			<br>
123			<FORM METHOD=POST ACTION="?act=show&sys=<%=sys%>&selectedCustomer=<%=CustomerID%>" ID="dateForm">
124			����� ���� ��� <A target="_blank" HREF="../CRM/AccountInfo.asp?act=show&selectedCustomer=<%=CustomerID%>"><%=customerName%> [<%=CustomerID%>]</A>
125			<br>
126			<br>
127			�� ����� <INPUT class="RepGenInput" TYPE="text" NAME="StartDate" Value="<%=StartDate%>" OnBlur="return acceptDate(this);"> �� <INPUT class="RepGenInput" TYPE="text" NAME="EndDate" Value="<%=EndDate%>"OnBlur="return acceptDate(this);"> <INPUT Class="GenButton" TYPE="button" Value=" ����� "onclick="if(acceptDate(document.getElementsByName('StartDate')[0]) && acceptDate(document.getElementsByName('EndDate')[0])) document.getElementById('dateForm').submit()">
128			<BR><BR>
129			<INPUT Class="GenButton" TYPE="button" Value=" <- <%=prevYear%> " onclick="window.location='?act=show&reason=<%=reason%>&sys=<%=sys%>&selectedCustomer=<%=CustomerID%>&startDate=<%=prevStartDate%>&endDate=<%=prevEndDate%>';">
130			<INPUT Class="GenButton" TYPE="button" Value=" <%=nextYear%> -> " onclick="window.location='?act=show&reason=<%=reason%>&sys=<%=sys%>&selectedCustomer=<%=CustomerID%>&startDate=<%=nextStartDate%>&endDate=<%=nextEndDate%>';">
131			</FORM>
132
133		</TD>
134	</TR>
135	<TR class="RepTableHeader">
136		<TD>#</TD>
137		<TD>�����</TD>
138		<TD>������ ����</TD>
139		<TD>������ ����</TD>
140		<TD>�������</TD>
141		<TD>����</TD>
142	</TR>
143<%
144
145	'mySQL="SELECT Vouchers.*, Invoices.Number AS InvoiceNumber, Invoices.ID AS InvoiceID FROM VoucherLines INNER JOIN Vouchers ON VoucherLines.Voucher_ID = Vouchers.id INNER JOIN PurchaseOrders ON VoucherLines.RelatedPurchaseOrderID = PurchaseOrders.ID INNER JOIN PurchaseRequestOrderRelations ON PurchaseOrders.ID = PurchaseRequestOrderRelations.Ord_ID INNER JOIN PurchaseRequests ON PurchaseRequestOrderRelations.Req_ID = PurchaseRequests.ID INNER JOIN Orders ON PurchaseRequests.Order_ID = Orders.ID INNER JOIN InvoiceOrderRelations ON Orders.ID = InvoiceOrderRelations.[Order] INNER JOIN Invoices ON InvoiceOrderRelations.Invoice = Invoices.ID WHERE Invoices.isA = 1 and Invoices.Voided = 0 and Vouchers.Verified = 1 and Vouchers.vendorID = " & CustomerID
146	'Changed By Kid 830625
147
148	mySQL="SELECT DISTINCT * FROM Vouchers INNER JOIN (SELECT Invoices.Number AS InvoiceNumber, Invoices.ID AS InvoiceID, VoucherLines.Voucher_ID FROM VoucherLines INNER JOIN PurchaseOrders ON VoucherLines.RelatedPurchaseOrderID = PurchaseOrders.ID INNER JOIN PurchaseRequestOrderRelations ON PurchaseOrders.ID = PurchaseRequestOrderRelations.Ord_ID INNER JOIN PurchaseRequests ON PurchaseRequestOrderRelations.Req_ID = PurchaseRequests.ID INNER JOIN Orders ON PurchaseRequests.OrderID = Orders.ID INNER JOIN InvoiceOrderRelations ON Orders.ID = InvoiceOrderRelations.[Order] INNER JOIN Invoices ON InvoiceOrderRelations.Invoice = Invoices.ID WHERE (Invoices.IsA = 1) AND (Invoices.Voided = 0) AND (Invoices.Issued = 1)) VoucherLine_AInvoice ON  VoucherLine_AInvoice.Voucher_ID = Vouchers.id WHERE (Vouchers.Verified = 1) AND (Vouchers.VendorID = " & CustomerID &") AND (Vouchers.EffectiveDate >= '" & StartDate &"') AND (Vouchers.EffectiveDate <= '" & EndDate &"') ORDER BY Vouchers.EffectiveDate, Vouchers.ID"
149
150	Set RS1 = conn.execute(mySQL)
151	
152	Remained = 0
153	Totalcredit = 0
154	TotalDebit = 0
155	tempCounter = 0
156	if Not (RS1.EOF) then
157		While Not (RS1.EOF)
158			tempCounter=tempCounter+1
159			
160			sourceLink="<a href='AccountReport.asp?act=showVoucher&voucher="& RS1("id") & "' target='_blank'>" & replace(RS1("Title"),"/",".") & "</a>"
161			sourceLink2="<a href='../AR/AccountReport.asp?act=showInvoice&invoice="& RS1("InvoiceID") & "' target='_blank'>" & RS1("InvoiceID") & "</a>"
162
163			if not isnull(RS1("comment")) then 
164				Description = replace(RS1("comment"),chr(13),"<br>") + " - ������ " & RS1("InvoiceNumber")
165				Description = replace(Description,"/",".")
166			else
167				Description = ""
168			end if
169
170			if RS1("Voided") then 
171
172%>			<TR bgcolor=#FFEEEE style='color:#999999'>
173				<td> # <%tempCounter = tempCounter -1 %></td>
174				<td width=60 dir='LTR' align='right'><%=RS1("EffectiveDate")%></td>
175				<td width=140><%=sourceLink%></td>
176				<td width=70><%=sourceLink2%></td>
177				<td width=200><span ><%=Description%></span></td>
178				<td dir='LTR'>
179					<div style="position:absolute;width:650;"><hr style="color:red;"></div>
180					<div align=right><%=Separate(RS1("TotalPrice"))%></div>
181				</td>
182			</TR>
183<%
184			else
185				TotalDebit = TotalDebit + cdbl(Debit)
186				Totalcredit = Totalcredit + cdbl(Credit)
187				Remained = Remained + Cdbl(Credit) - Cdbl(Debit)
188%>			<TR class='<%if tempCounter MOD 2 = 0 then response.write "RepTR1" else response.write "RepTR2"%>'>
189				<td><%=tempCounter %></td>
190				<td width=60 dir='LTR' align='right'><%=RS1("EffectiveDate")%></td>
191				<td width=140><%=sourceLink%></td>
192				<td width=70><%=sourceLink2%></td>
193				<td width=200><span ><%=Description%></span></td>
194				<td dir='LTR' align='right'><%=Separate(RS1("TotalPrice"))%></td>
195			</TR>
196<%
197			end if
198			total = total + Cdbl(RS1("TotalPrice"))
199			RS1.MoveNext
200		Wend
201		if Remained>=0 then
202			remainedColor="green"
203		else
204			remainedColor="red"
205		end if
206
207	else
208		total= " - "
209%>
210		<TR class="RepTR1">
211			<TD colspan=6 align=center>���</TD>
212		</TR>
213<%	
214	end if
215%>
216		<TR>
217			<TD class="RepTableFooter" colspan='5'>&nbsp;&nbsp; : ���</span></td>
218			<TD class="RepTableFooter" align='right'><%=Separate(total)%></td>
219		</TR>
220	</TABLE>
221	<br>
222
223<!--#include file="tah.asp" -->