PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/beta/accounting/tafsili.asp

http://github.com/khaneh/Orders
ASP | 318 lines | 272 code | 34 blank | 12 comment | 46 complexity | 22340f9c05e4ad4eb14ffbe492ed1634 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Accounting (8)
  3PageTitle= "����� ������"
  4SubmenuItem=6
  5if not Auth(8 , "B") 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
 13	.TafsilTR1 { background-color: #eeeeee; }
 14	.TafsilTR1 td{ width:20pt;border-left:solid 1px black; border-bottom:solid 2 black; font-size:8pt; padding:2px; text-align:center;}
 15
 16</style>
 17<%
 18'-----------------------------------------------------------------------------------------------------
 19'----------------------------------------------------------------------------------------- Search Form
 20'-----------------------------------------------------------------------------------------------------
 21
 22account		=	sqlSafe(request("accountID"))
 23accountName	=	sqlSafe(request("accountName"))
 24FromDate	=	sqlSafe(request("FromDate"))
 25ToDate		=	sqlSafe(request("ToDate"))
 26moeenFrom	=	sqlSafe(request("moeenFrom"))
 27moeenTo		=	sqlSafe(request("moeenTo"))
 28Order		=	sqlSafe(request("Order"))
 29
 30if request("ShowRemained")="on" then
 31	ShowRemained=true
 32else
 33	ShowRemained=false
 34end if
 35
 36if account		= "" OR NOT IsNumeric(account)	then	account = "0"
 37if FromDate		= ""	then	FromDate = fiscalYear & "/01/01"
 38if ToDate		= ""	then	ToDate = shamsiToday()
 39if moeenFrom	= ""	then	moeenFrom = "00000"
 40if moeenTo		= ""	then	moeenTo = "99999"
 41
 42%>
 43<BR><BR>
 44<input type="hidden" Name='tmpDlgArg' value=''>
 45<input type="hidden" Name='tmpDlgTxt' value=''>
 46
 47<FORM Name="SearchForm" METHOD=POST ACTION="?act=Show">
 48<TABLE style="border:1 solid #330066;" align=center cellpadding=3>
 49<TR>
 50	<TD align=left>������ </TD>
 51	<TD><INPUT dir="LTR" TYPE="text" NAME="accountID" maxlength="10" size="10"  value="<%=account%>" onKeyPress='return mask(this);' onBlur='check(this);'></TD>
 52	<TD colspan=2><INPUT TYPE="text" NAME="accountName" size=30 readonly  value="<%=accountName%>" style="background-color:transparent;"></TD>
 53</TR>
 54<TR>
 55	<TD align=left>�� ����� </TD>
 56	<TD><INPUT dir="LTR"  TYPE="text" NAME="FromDate" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=FromDate%>"></TD>
 57	<TD align=left>�� ����� </TD>
 58	<TD><INPUT dir="LTR"  TYPE="text" NAME="ToDate" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=ToDate%>"></TD>
 59</TR>
 60<TR>
 61	<TD align=left>�� ����</TD>
 62	<TD><INPUT  dir="LTR"  TYPE="text" NAME="moeenFrom" maxlength="5" size="10" value="<%=moeenFrom%>"></TD>
 63	<TD align=left>�� ����</TD>
 64	<TD><INPUT  dir="LTR"  TYPE="text" NAME="moeenTo" maxlength="5" size="10" value="<%=moeenTo%>"></TD>
 65</TR>
 66<TR bgcolor="black" height="2">
 67	<TD colspan="4" style="padding:0;"></TD>
 68</TR>
 69<TR>
 70	<TD colspan=4><INPUT TYPE="checkbox" NAME="ShowRemained" <%if ShowRemained then response.write "checked"%>> ����� ��� ����� ���� ���.</TD>
 71</TR>
 72<TR>
 73	<TD colspan=4 align=center>
 74		<INPUT TYPE="submit" NAME="submit" value="������">
 75		<INPUT TYPE="hidden" Name="Order" Value="<%=request("Order")%>">
 76	</TD>
 77</TR>
 78</TABLE>
 79</FORM>
 80
 81<%
 82'-----------------------------------------------------------------------------------------------------
 83'--------------------------------------------------------------------------------------- Search Action
 84'-----------------------------------------------------------------------------------------------------
 85
 86if request("act")="Show" then
 87	Order=request("Order")
 88	select case Order
 89	case "1":
 90		order=" ORDER BY GLDocID "
 91	case "-1":
 92		order=" ORDER BY GLDocID DESC"
 93	case "2":
 94		order=" ORDER BY GLDocDate"
 95	case "-2":
 96		order=" ORDER BY GLDocDate DESC"
 97	case else:
 98		order=" ORDER BY GLAccount, GLDocDate"
 99	end select
100
101
102	'mySQL="SELECT GLAccounts.Name AS Name, GLDocs.ID AS GLDoc, GLDocs.GLDocID, GLDocs.GLDocDate, GLRows.ID AS GLRowsID, GLRows.GLAccount AS GLAccount, GLRows.Amount, GLRows.IsCredit, GLRows.Description FROM GLRows INNER JOIN GLDocs ON GLDocs.ID = GLRows.GLDoc INNER JOIN GLAccounts ON GLRows.GLAccount = GLAccounts.ID WHERE ((GLDocs.IsTemporary=1 OR GLDocs.IsChecked=1 OR GLDocs.IsFinalized=1) AND GLDocs.deleted=0 AND GLRows.deleted=0 AND GLDocs.IsRemoved=0) AND ((GLAccounts.GL = "& OpenGL & ") AND (GLDocs.GL = "& OpenGL & ") AND (GLRows.GLAccount >= "& moeenFrom & ") AND (GLRows.GLAccount <= "& moeenTo & ") AND (GLRows.Tafsil = "& account & ") AND (GLDocs.GLDocDate <= N'"& ToDate & "') AND (GLDocs.GLDocDate >= N'"& FromDate & "')) "& Order
103	'changed by kid 830809
104	if ShowRemained then
105		mySQL="SELECT DRV.GLAcc AS GLAccount, GLAccounts.Name, DRV.GLDoc, DRV.GLDocID, DRV.GLDocDate, DRV.Amount, DRV.IsCredit, DRV.Description, DRV.remainedCredit, DRV.remainedDebit FROM (SELECT ISNULL(Remains.GLAccount, EffGLRows.GLAccount) AS GLAcc, ISNULL(Remains.remCred, 0) AS remainedCredit, ISNULL(Remains.remDeb, 0) AS remainedDebit, EffGLRows.* FROM (SELECT isnull(SUM(IsCredit * Amount), 0) AS remCred, isnull(SUM(- ((IsCredit - 1) * Amount)), 0) AS remDeb, GLAccount FROM EffectiveGLRows WHERE (GL = "& OpenGL & ") AND (GLDocDate < N'"& FromDate & "') AND (Tafsil = "& account & ") GROUP BY GLAccount) Remains FULL OUTER JOIN (SELECT GLDoc, GLDocID, GLDocDate, Amount, IsCredit, Description, GLAccount FROM EffectiveGLRows WHERE (Tafsil = '"& account & "') AND (GL = "& OpenGL & ") AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "')) EffGLRows ON  Remains.GLAccount = EffGLRows.GLAccount) DRV INNER JOIN GLAccounts ON DRV.GLAcc = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL & ") AND (GLAccounts.ID >= "& moeenFrom & ") AND (GLAccounts.ID <= "& moeenTo & ")" & Order 
106	else
107		mySQL="SELECT EffGLRows.*, GLAccounts.Name FROM (SELECT GLDoc, GLDocID, GLDocDate, Amount, IsCredit, Description, GLAccount FROM EffectiveGLRows WHERE (Tafsil = '"& account & "') AND (GL = "& OpenGL & ") AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "')) EffGLRows INNER JOIN GLAccounts ON EffGLRows.GLAccount = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL & ") AND (GLAccounts.ID >= "& moeenFrom & ") AND (GLAccounts.ID <= "& moeenTo & ")" & Order 
108	end if
109
110	set RSS=Conn.Execute (mySQL)
111
112	if RSS.eof then
113		response.write "<br>" 
114		call showAlert ("���� ���.", CONST_MSG_ERROR) 
115		response.end
116	end if
117%>
118	<SCRIPT LANGUAGE="JavaScript">
119	<!--
120	function sortSubmit(num){
121		document.SearchForm.Order.value=num;
122		document.SearchForm.submit.click();
123	}
124	//-->
125	</SCRIPT>
126	<TABLE dir=rtl align=center width=640 cellspacing=0 cellpadding=2 style="border:1 solid black;">
127	<%
128	tmpCounter=0
129	remainedAmount = 0
130	totalRemainedAmount = 0
131	LastGLAccount= ""
132
133	remainedAmount = 0
134	SumCredit = 0 
135	SumDebit =	0
136
137	tmpCounter =0
138	remainedAmount = 0
139	Do while not RSS.eof
140		GLAccount=RSS("GLAccount")
141
142		if LastGLAccount <> GLAccount then
143			if tmpCounter > 0 then
144				remainedAmount = SumDebit - SumCredit
145%>
146				<TR>
147					<TD colspan=3 align=left style="border: 1 solid black; border-right:none;">��� ���� ���� <%=LastGLAccount%>&nbsp;</TD>
148					<TD dir=ltr align=right style="border: 1 solid black; border-right:none;"><%=Separate(SumDebit)%>&nbsp;</TD> 
149					<TD dir=ltr align=right style="border: 1 solid black; border-right:none;"><%=Separate(SumCredit)%>&nbsp;</TD>
150					<TD align=right style="border: 1 solid black; border-right:none;">&nbsp;<% if remainedAmount > 0 then response.write "�" else if remainedAmount < 0 then response.write "�"%></TD>
151					<TD align=right dir=ltr style="border-top: 1 solid black;border-bottom: 1 solid black;" ><%=Separate(abs(remainedAmount))%></TD>
152				</TR>
153<% 
154			end if
155%>
156			<TR>
157			<td colspan=7 style="height:25px;background-color: #88AADD;">���� <%=GLAccount%> - <%=RSS("Name")%></td>
158			</TR>
159			<TR class="TafsilTR1">
160				<TD style="width:60px;"><A HREF="javaScript:sortSubmit(1);">v</A>&nbsp;���&nbsp;<A HREF="javaScript:sortSubmit(-1);">^</A></TD>
161				<TD style="width:80px;"><A HREF="javaScript:sortSubmit(2);">v</A>&nbsp;����� ���&nbsp;<A HREF="javaScript:sortSubmit(-2);">^</A></TD>
162				<TD style="width:200px;">���</TD>
163				<TD style="width:100px;">������</TD>
164				<TD style="width:100px;">��������</TD>
165				<TD colspan=2 style="width:100px;border-left:0;">�����</TD>
166			</TR>
167<%
168			tmpCounter =1
169			remainedAmount = 0
170			SumCredit = 0 
171			SumDebit =	0
172		else
173			tmpCounter = tmpCounter + 1
174		end if
175
176		if ShowRemained AND LastGLAccount <> GLAccount then
177			credit = cdbl(RSS("remainedCredit"))
178			debit =	 cdbl(RSS("remainedDebit"))
179
180			remainedAmount =  debit - credit
181			totalRemainedAmount = totalRemainedAmount + debit - credit
182			SumCredit = SumCredit + credit
183			SumDebit = SumDebit + debit
184			totalCredit=totalCredit + credit
185			totalDebit=totalDebit + debit
186%>
187			<TR bgcolor="#FFFFFF">
188				<TD style="border-left:solid 1px black">&nbsp;</TD>
189				<TD style="border-left:solid 1px black">&nbsp;</TD>
190				<TD style="border-left:solid 1px black"><INPUT TYPE="text" value="<%="����� ��� �� " & replace(FromDate,"/",".")%>" style="width=200pt; border:solid 0pt; font-size:8pt; background-color:transparent"></TD>
191				<TD dir=ltr align=right style="border-left:solid 1px black"><%=Separate(debit)%>&nbsp;</TD>
192				<TD dir=ltr align=right style="border-left:solid 1px black"><%=Separate(credit)%>&nbsp;</TD>
193				<TD align=right style="border-left:solid 1px black">&nbsp;<% if remainedAmount > 0 then response.write "�" else if remainedAmount < 0 then response.write "�"%></TD>
194				<TD dir=ltr align=right><%=Separate(abs(remainedAmount))%></TD>
195			</TR>
196<%
197			tmpCounter = tmpCounter + 1
198		end if
199		
200		LastGLAccount = GLAccount
201
202		if NOT isnull(RSS("Amount")) then
203			if tmpCounter mod 2 = 1 then
204				tmpColor="#FFFFFF"
205			Else
206				tmpColor="#DDDDDD"
207			End if 
208			
209			if RSS("IsCredit") then
210				credit = cdbl(RSS("Amount"))
211				debit = 0
212			else
213				credit = 0
214				debit = cdbl(RSS("Amount"))
215			end if
216
217			remainedAmount = remainedAmount + debit - credit 
218			totalRemainedAmount = totalRemainedAmount + debit - credit
219			SumCredit = SumCredit + credit
220			SumDebit = SumDebit + debit
221			totalCredit=totalCredit + credit
222			totalDebit=totalDebit + debit
223
224%>
225			<TR bgcolor="<%=tmpColor%>" >
226				<TD style="border-left:solid 1px black"><A HREF="GLMemoDocShow.asp?id=<%=RSS("GLDoc")%>" target="_blank"><%=RSS("GLDocID")%></A></TD>
227				<TD  align=center dir=ltr style="border-left:solid 1px black"><%=RSS("GLDocDate")%></TD>
228				<TD  width=100 style="border-left:solid 1px black"><INPUT size="60" TYPE="text" value="<%=RSS("Description")%>" style="width=200pt; border:solid 0pt; font-size:8pt; background-color:transparent"></TD>
229				<TD dir=ltr align=right style="border-left:solid 1px black"><% if debit<>"0" then %> <%=Separate(debit)%><% end if %>&nbsp;</TD>
230				<TD dir=ltr align=right style="border-left:solid 1px black"><% if credit<>"0" then %> <%=Separate(credit)%><% end if %>&nbsp;</TD>
231				<TD align=right style="border-left:solid 1px black">&nbsp;<% if remainedAmount > 0 then response.write "�" else if remainedAmount < 0 then response.write "�"%></TD>
232				<TD dir=ltr align=right><%=Separate(abs(remainedAmount))%></TD>
233			</TR>
234				  
235<% 
236		end if
237		RSS.moveNext
238	Loop
239	remainedAmount = SumDebit - SumCredit
240%>
241	<TR>
242		<TD colspan=3 align=left style="border: 1 solid black; border-right:none;">��� ���� ���� <%=LastGLAccount%>&nbsp;</TD>
243		<TD dir=ltr align=right style="border: 1 solid black; border-right:none;"><%=Separate(SumDebit)%>&nbsp;</TD> 
244		<TD dir=ltr align=right style="border: 1 solid black; border-right:none;"><%=Separate(SumCredit)%>&nbsp;</TD>
245		<TD align=right style="border: 1 solid black; border-right:none;">&nbsp;<% if remainedAmount > 0 then response.write "�" else if remainedAmount < 0 then response.write "�"%></TD>
246		<TD align=right dir=ltr style="border-top: 1 solid black;border-bottom: 1 solid black;" ><%=Separate(abs(remainedAmount))%></TD>
247	</TR>
248	<TR bgcolor="black" height=1>
249		<TD colspan=7></TD>
250	</TR>
251	<TR bgcolor="#88AADD">
252		<TD colspan=3 align=left style="border-left:solid 1px black;">��� ���� ������ <%=account%>&nbsp;</TD>
253		<TD dir=ltr align=right style="border-left:solid 1px black;"><%=Separate(totalDebit)%>&nbsp;</TD> 
254		<TD dir=ltr align=right style="border-left:solid 1px black;"><%=Separate(totalCredit)%>&nbsp;</TD>
255		<TD align=right style="border-left:solid 1px black;">&nbsp;<% if totalRemainedAmount > 0 then response.write "�" else if totalRemainedAmount < 0 then response.write "�"%></TD>
256		<TD align=right dir=ltr><%=Separate(abs(totalRemainedAmount))%></TD>
257	</TR>
258
259	</TABLE><br>
260<% end if %>
261<%
262
263'-----------------------------------------------------------------------------------------------------
264'--------------------------------------------------------------------------------------------- Scripts
265'-----------------------------------------------------------------------------------------------------
266
267%>
268<SCRIPT LANGUAGE="JavaScript">
269<!--
270
271var dialogActive=false;
272
273function mask(src){ 
274	var theKey=event.keyCode;
275
276	if (theKey==13){
277		event.keyCode=9
278		dialogActive=true
279		document.all.tmpDlgArg.value="#"
280		document.all.tmpDlgTxt.value="����� �� ��� ���� ��� ������:"
281		var myTinyWindow = window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
282		if (document.all.tmpDlgTxt.value !="") {
283			var myTinyWindow = window.showModalDialog('../ar/dialog_selectAccount.asp?act=select&search='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:500px; dialogWidth:380px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
284			dialogActive=false
285			if (document.all.tmpDlgArg.value!="#"){
286				Arguments=document.all.tmpDlgArg.value.split("#")
287				src.value=Arguments[0];
288				document.all.accountName.value=Arguments[1];
289			}
290		}
291	}
292}
293
294function check(src){ 
295	if (!dialogActive){
296		badCode = false;
297		if (window.XMLHttpRequest) {
298			var objHTTP=new XMLHttpRequest();
299		} else if (window.ActiveXObject) {
300			var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
301		}
302		objHTTP.open('GET','xml_CustomerAccount.asp?id='+src.value,false);
303		objHTTP.send();
304		tmpStr = unescape(objHTTP.responseText);
305		//document.all['A1'].innerText= objHTTP.status
306		//document.all['A2'].innerText= objHTTP.statusText
307		//document.all['A3'].innerText= objHTTP.responseText
308		document.all.accountName.value=tmpStr;
309		}
310}
311
312// On page load :
313if (document.all.accountID) 
314	check(document.all.accountID);
315
316//-->
317</SCRIPT>
318<!--#include file="tah.asp" -->