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

/beta/cashReg/CashRegReport.asp

http://github.com/khaneh/Orders
ASP | 300 lines | 279 code | 17 blank | 4 comment | 16 complexity | 6e8aecbdab5a3c83e2bbae9e1c48cab9 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'CashRegister (9)
  3PageTitle="����� �����"
  4SubmenuItem=3
  5if not Auth(9 , 3) then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<STYLE>
 12	.CClosTable {font-family:tahoma; font-size:9pt; direction: RTL; border:2 solid #330099;}
 13	.CClosTable td {padding:5;border:1pt solid gray;}
 14	.CClosTable a {text-decoration:none; color:#222288;}
 15	.CClosTable a:hover {text-decoration:underline;}
 16	.CClosTableTitle {background-color: #CCCCFF; text-align: center; font-weight:bold; height:50;}
 17	.CClosTableHeader {background-color: #BBBBBB; text-align: center; font-weight:bold;}
 18	.CClosTableFooter {background-color: #BBBBBB; direction: LTR; }
 19	.CClosTR1 {background-color: #DDDDDD;}
 20	.CClosTR2 {background-color: #FFFFFF;}
 21	.CClosTR3 {background-color: #EEEEFF;}
 22
 23	.RepTable {font-family:tahoma; font-size:9pt; direction: RTL; }
 24	.RepTable td {padding:5;border:1pt solid gray;}
 25	.RepTable a {text-decoration:none; color:#222288;}
 26	.RepTable a:hover {text-decoration:underline;}
 27	.RepTableTitle {background-color: #CCCCFF; text-align: center; font-weight:bold; height:50;}
 28	.RepTableHeader {background-color: #BBBBBB; text-align: center; font-weight:bold;}
 29	.RepTableFooter {background-color: #BBBBBB; direction: LTR; }
 30	.RepTR1 {background-color: #DDDDDD;}
 31	.RepTR2 {background-color: #FFFFFF;}
 32</STYLE>
 33<%
 34function Link2Trace(OrderNo)
 35	Link2Trace="<A HREF='../order/TraceOrder.asp?act=show&order="& OrderNo & "' target='_balnk'>"& OrderNo & "</A>"
 36end function
 37
 38
 39mySQL="SELECT Bankers.Name AS BankerName, CashRegisters.*, Users.RealName FROM CashRegisters INNER JOIN Users ON CashRegisters.Cashier = Users.ID INNER JOIN Bankers ON CashRegisters.Banker = Bankers.ID WHERE (CashRegisters.IsOpen=1) AND (Cashier='"& session("ID") & "')"
 40Set RS1= conn.Execute(mySQL)
 41if RS1.eof then 
 42%><br><br>
 43	<TABLE width='70%' align='center'>
 44	<TR>
 45		<TD align=center bgcolor=#FFBBBB style='border: solid 1pt black'><BR><b>���� <%=CSRName%> ��� ����� ��� ������ ... <br><br>�� ��� �� ���� ���� ��� �� ��� ��� <br>������."</b><BR><BR></TD>
 46	</TR>
 47	</TABLE>
 48<%	conn.close
 49	response.end
 50else
 51	CashRegID=			RS1("ID")
 52	BankerName=			RS1("BankerName")
 53	CashRegName=		RS1("NameDate")
 54	OpenningDate=		RS1("OpenDate")
 55	OpenningAmount=		cdbl(RS1("OpeningAmount"))
 56	totalCashAmountA=	Separate(RS1("cashAmountA"))
 57	totalCashAmountB=	Separate(RS1("cashAmountB"))
 58	totalChequeAmount=	Separate(RS1("chequeAmount"))
 59	totalChequeQtty=	RS1("chequeQtty")
 60	TotalAmount=		Separate(cdbl(RS1("cashAmountA")) + cdbl(RS1("cashAmountB")) + cdbl(RS1("chequeAmount")))
 61
 62	Set RS1=nothing
 63end if
 64
 65if true then ' this 'if' statement is reserved for further changes. It is not neccesary.
 66'response.write cashRegID
 67	mySQL="SELECT CashRegisterLines.ID,CashRegisterLines.isA, CashRegisterLines.CashReg, CashRegisterLines.Date, CashRegisterLines.Time, CashRegisterLines.Type, isnull(case when isnull(drv.isA,0)>0 and CashRegisterLines.type=1 then ISNULL(Receipts.CashAmount,0) end,0) AS CashAmountA, isnull(case when isnull(drv.isA,0)<1 and CashRegisterLines.type=1 then ISNULL(Receipts.CashAmount,0) end,0) AS CashAmountB, CashRegisterLines.Link, CashRegisterLines.Voided, ISNULL(Receipts.CashAmount, 0) AS CashAmount, ISNULL(Receipts.ChequeAmount, 0) AS ChequeAmount, Receipts.ChequeQtty, Payments.CashAmount AS PayAmount, Accounts_1.AccountTitle AS PayAccTitle, Accounts_2.AccountTitle AS RcpAccTitle, Accounts_1.ID AS PayAccID, Accounts_2.ID AS RcpAccID FROM CashRegisterLines LEFT OUTER JOIN Accounts AS Accounts_1 INNER JOIN Payments ON Accounts_1.ID = Payments.Account ON CashRegisterLines.Link = Payments.ID LEFT OUTER JOIN Accounts AS Accounts_2 INNER JOIN Receipts ON Accounts_2.ID = Receipts.Customer ON CashRegisterLines.Link = Receipts.ID left outer join (select Receipts.id, isnull(sum(cast(invoices.IsA as int)),-1) as isA from Receipts inner join ARItems on receipts.id=arItems.link inner join ARItemsRelations on arItems.ID=arItemsRelations.CreditARItem inner join ARItems as arItems_D on arItemsRelations.DebitARItem=arItems_D.id inner join Invoices on arItems_D.link=invoices.ID where receipts.SYS='AR' and arItems_D.type=1 group by Receipts.id) as drv on receipts.id=drv.id WHERE (CashRegisterLines.CashReg = '"& CashRegID & "') ORDER BY CashRegisterLines.ID"
 68'	response.write mySQL
 69'	response.end
 70	Set RS1 = conn.execute(mySQL)
 71
 72	
 73	Remained = 0
 74    Totalcredit = 0
 75    TotalDebit = 0
 76	tempCounter = 0
 77
 78	if Not (RS1.EOF AND OpenningAmount=0) then
 79%>
 80		<br>
 81		<TABLE class="RepTable" width='100%' align='center'>
 82		<TR>
 83			<TD class="RepTableTitle" colspan=10 dir='rtl' align='center'><br><B>����� ����� <span dir='LTR'><%=CashRegName%></span> - <%=CSRName%> </B><BR>(���: <%=BankerName%>)<br>
 84			</TD>
 85		</TR>
 86		<TR class="RepTableHeader">
 87			<TD width="15px">#</TD>
 88			<TD width="15px"> x </TD>
 89			<TD width="50px">�����</TD>
 90			<TD width="10px">����</TD>
 91			<TD width="60px">�������</TD>
 92			<td width="30px">���/�</td>
 93			<TD>����</TD>
 94			<TD width="60px">������</TD>
 95			<TD width="60px">��������</TD>
 96			<TD width="60px">�����</TD>
 97		</TR>
 98<%		
 99		if OpenningAmount<>0 then
100			Remained = OpenningAmount
101			Credit = OpenningAmount
102			Totalcredit = OpenningAmount
103			tempCounter = 0
104%>			<TR class='<%if tempCounter MOD 2 = 0 then response.write "RepTR1" else response.write "RepTR2"%>'>
105				<td><%=tempCounter%></td>
106				<td align='center'><b>x&nbsp;<b></td>
107				<td dir='LTR'><%=OpenningDate%></td>
108				<td colspan='3'>����� ����� �����</td>
109				<td dir='LTR' align='right'><%=Separate(Debit)%>&nbsp;</td>
110				<td dir='LTR' align='right'><%=Separate(Credit)%>&nbsp;</td>
111				<td dir='LTR' align='right'><%=Separate(Remained)%>&nbsp;</td>
112			</TR>
113<%		end if
114
115		While Not (RS1.EOF)
116			tempCounter=tempCounter+1
117			if RS1("Type")=1 then
118				sourceLink="../AR/AccountReport.asp?act=showReceipt&receipt="& RS1("Link")
119				voidLink="Void.asp?act=voidReceipt&receipt="& RS1("Link")
120				Description = "������ "
121				myAND=""
122
123				CashAmount=cdbl(RS1("CashAmount"))
124				ChequeAmount=cdbl(RS1("ChequeAmount"))
125				if CashAmount<>0 then
126					Description=Description & "��� "
127					myAND="� "
128				end if 
129				if RS1("ChequeQtty")<>0 then
130					Description=Description & myAND & RS1("ChequeQtty") & " ���� �� "
131				end if 
132				AccID=RS1("RcpAccID")
133				AccTitle=RS1("RcpAccTitle")
134				Credit=CashAmount + ChequeAmount
135				Debit=0
136
137			elseif RS1("Type")=2 then
138				sourceLink="../AR/AccountReport.asp?act=showPayment&payment="& RS1("Link")
139				voidLink="Void.asp?act=voidPayment&payment="& RS1("Link")
140				Description = "������ ���"
141				AccID=RS1("PayAccID")
142				AccTitle=RS1("PayAccTitle")
143				Credit=0
144				Debit=RS1("PayAmount")
145			else
146				sourceLink="javascript:void(0);"
147				voidLink="javascript:void(0);"
148				Description = ""
149				AccountInfo=""
150				Credit=0
151				Debit=0 
152			end if
153
154			TotalDebit = TotalDebit + CLng(Debit)
155			Totalcredit = Totalcredit + CLng(Credit)
156			Remained = Remained + CLng(Credit) - CLng(Debit)
157%>			<TR class='<%if tempCounter MOD 2 = 0 then response.write "RepTR1" else response.write "RepTR2"%>'>
158				<td><%=tempCounter%></td>
159				<td align='center'><b><A HREF="<%=voidLink%>" onclick="return setVoid(this);">x</A>&nbsp;<b></td>
160				<td dir='LTR'><%=RS1("Date")%></td>
161				<td dir='LTR'><%=RS1("Time")%></td>
162				<td><A HREF='<%=sourceLink%>' target='_blank'><%=Description%></A></td>
163				<td align="center"><%
164				if CBool(rs1("isA")) then 
165					response.write("<b>���</b>")
166				else
167					response.write("�")
168				end if
169				%></td>
170				<td><A HREF='../AR/AccountReport.asp?act=show&selectedCustomer=<%=AccID%>' target='_blank'><%=AccTitle%></A></td>
171				<td dir='LTR' align='right'><%=Separate(Debit)%></td>
172				<td dir='LTR' align='right' title='<%="���: "&RS1("CashAmountA") & "� �: " & RS1("CashAmountB")%>'><%=Separate(Credit) %></td>
173				<td dir='LTR' align='right'>
174<%					if RS1("Voided")=TRUE then
175%>						<div style="position:absolute;width:700;"><hr style="color:red;"></div>
176<%						response.write "xx xx xx" '& Separate(remained) & "xx"  
177						TotalDebit = TotalDebit - CLng(Debit)
178						Totalcredit = Totalcredit - CLng(Credit)
179						Remained = Remained - CLng(Credit) + CLng(Debit)
180					else
181						response.write Separate(remained)
182					end if
183%>				</td>
184			</TR>
185<%
186			RS1.MoveNext
187		Wend
188		if Remained>=0 then
189			remainedColor="green"
190		else
191			remainedColor="red"
192		end if
193%>
194			<TR>
195				<TD class="RepTableFooter" colspan='7'>&nbsp;&nbsp; : ���</td>
196				<TD class="RepTableFooter" align='right'><%=Separate(totaldebit)%></td>
197				<TD class="RepTableFooter" align='right'><%=Separate(totalcredit)%></td>
198				<TD class="RepTableFooter" align='right'><FONT COLOR='<%=remainedColor%>'><%=Separate(Remained)%></FONT></td>
199			</TR>
200		</TABLE>
201		<br >
202		<TABLE class="CClosTable" width='90%' align='center' style="page-break-before:always;">
203<%	
204		mySQL="SELECT ReceivedCheques.ChequeNo, ReceivedCheques.ChequeDate, ReceivedCheques.Description, ReceivedCheques.BankOfOrigin,  receivedCheques.Amount, CashRegisterLines.* FROM ReceivedCheques INNER JOIN Receipts ON ReceivedCheques.Receipt = Receipts.ID INNER JOIN CashRegisterLines ON Receipts.ID = CashRegisterLines.Link WHERE (CashRegisterLines.CashReg = '"& CashRegID & "') AND (CashRegisterLines.Type = 1) ORDER BY CashRegisterLines.[Date], CashRegisterLines.[Time]"
205		Set RS1 = conn.execute(mySQL)
206
207		Remained = OpenningAmount
208		Credit = OpenningAmount
209		Totalcredit = OpenningAmount
210		TotalDebit = 0
211		tempCounter = 0
212%>		<TR class='CClosTR3'>
213			<td colspan='7' align='center'>����� ����� ����� <span dir='LTR'><%=CashRegName%></span> (��������: <%=CSRName%>� ���: <%=BankerName%>)</TD>
214		</TR>
215		<TR>
216			<TD colspan='6' class="CClosTableFooter">:����� ���</td>
217			<TD class="CClosTableFooter" align='right'><span id='cashAmount'><%=Separate(cdbl(totalCashAmountA) + Cdbl(totalCashAmountB))%></span></TD>
218		</TR>
219		<TR>
220			<TD colspan='6' class="CClosTableFooter" style='direction:RTL;text-align=left;'>����� �� (<span id='chequeQtty'><%=totalChequeQtty%></span> ����) :</td>
221			<TD class="CClosTableFooter" align='right'><%=totalChequeAmount%></TD>
222		</TR>
223		<TR>
224			<TD colspan='6' class="CClosTableFooter">: ���</td>
225			<TD class="CClosTableFooter" align='right'><%=TotalAmount%></td>
226		</TR>
227		<TR class='CClosTR3'>
228			<td colspan='7' align='right'>���� �� ��:</td>
229		</TR>
230		<TR class="CClosTableHeader">
231			<TD width="10px">#</TD>
232			<TD width="100px">����� ������</TD>
233			<TD width="50px">�����</TD>
234			<TD width="50px">����</TD>
235			<TD width="70px">����� ��</TD>
236			<TD width="220px">�������</TD>
237			<TD width="70px">����</TD>
238		</TR>
239<%
240		While Not (RS1.EOF)
241			tempCounter=tempCounter+1
242
243			sourceLink="../AR/AccountReport.asp?act=showReceipt&receipt="& RS1("Link")
244			Description = "������ "
245			myAND=""
246
247			Amount=Separate(RS1("Amount"))
248
249			if RS1("Voided") then
250				tempCounter=tempCounter-1%>
251				<TR class='CClosTR4'>
252					<td>-</td>
253					<td dir='LTR'><A HREF='<%=sourceLink%>' target='_blank'><%=RS1("Date") & " @ " & RS1("Time")%></A></td>
254					<td><%=RS1("ChequeNo")%></td>
255					<td><%=RS1("BankOfOrigin")%></td>
256					<td dir='LTR'><%=RS1("ChequeDate")%></td>
257					<td><%=RS1("Description")%></td>
258					<td dir='LTR'>
259						<div style="position:absolute;width:600;"><hr style="color:red;"></div><div align='right'><%=Amount%></div>
260<%			else%>						
261				<TR class='<%if tempCounter MOD 2 = 0 then response.write "CClosTR1" else response.write "CClosTR2"%>'>
262					<td><%=tempCounter%></td>
263					<td dir='LTR'><A HREF='<%=sourceLink%>' target='_blank'><%=RS1("Date") & " @ " & RS1("Time")%></A></td>
264					<td><%=RS1("ChequeNo")%></td>
265					<td><%=RS1("BankOfOrigin")%></td>
266					<td dir='LTR'><%=RS1("ChequeDate")%></td>
267					<td><%=RS1("Description")%></td>
268					<td dir='LTR' align='right'>
269						<%=Amount%>
270<%			end if
271%>					</td>
272				</TR>
273<%
274			RS1.MoveNext
275		Wend
276%>
277		</TABLE>
278		<br>
279<%	end if
280end if
281conn.Close
282%>
283</font>
284<script language="JavaScript">
285<!--
286function setVoid(obj)
287{
288	theTR = obj.parentNode.parentNode.parentNode;
289	for(i=0; i<theTR.getElementsByTagName("TD").length; i++){
290		theTR.getElementsByTagName("TD")[i].setAttribute("bgColor","yellow")
291	}
292	confirmResult = confirm('����! ��� �� ���� ���� ������ / ������ ���� ���� ����� ������ �� ����� �� ����� ���\n\n ����� �� ���Ͽ');
293	for(i=0; i<theTR.getElementsByTagName("TD").length; i++){
294		theTR.getElementsByTagName("TD")[i].setAttribute("bgColor","")
295	}
296	return confirmResult;
297}
298//-->
299</script>
300<!--#include file="tah.asp" -->