PageRenderTime 30ms CodeModel.GetById 19ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/accounting/moeen.asp

http://github.com/khaneh/Orders
ASP | 436 lines | 378 code | 42 blank | 16 comment | 66 complexity | 4621d8eee2a90f61136ba4659039f377 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2Response.Buffer=false
  3'Accounting (8)
  4PageTitle= "���� ��"
  5SubmenuItem=5
  6if not Auth(8 , "A") then NotAllowdToViewThisPage()
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<style>
 12
 13	.MoeenTR1 { background-color: #eeeeee; }
 14	.MoeenTR1 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'--------------------------------------------------------------------------------------------- Scripts
 22'-----------------------------------------------------------------------------------------------------
 23
 24account		=	request("accountID")
 25if account <> "" then accountName	= request("accountName")
 26ToAccount	=	request("ToAccount")
 27if ToAccount = "" then 
 28	ToAccount	=	account
 29	ToAccountName=	accountName
 30else
 31	ToAccount = request("ToAccount")
 32	ToAccountName=	request("ToAccountName")
 33end if
 34
 35
 36FromDate	=	request("FromDate")
 37ToDate		=	request("ToDate")
 38Order		=	request("Order")
 39
 40if request("ShowRemained")="on" then
 41	ShowRemained=true
 42else
 43	ShowRemained=false
 44end if
 45
 46
 47'if account		= ""	then	account = "11011"
 48'if accountName	= ""	then	accountName = "�����"
 49
 50if FromDate		= ""	then	FromDate = shamsiToday()
 51if ToDate		= ""	then	ToDate = shamsiToday()
 52%>
 53<input type="hidden" Name='tmpDlgArg' value=''>
 54<input type="hidden" Name='tmpDlgTxt' value=''>
 55<BR>
 56<FORM Name="SearchForm" METHOD=POST ACTION="?act=Show" onSubmit="return checkValidation();"> 
 57<TABLE style="border:1 solid #330066;" align=center>
 58<TR>
 59	<TD align=left>����</TD>
 60	<TD><INPUT  dir="LTR"  TYPE="text" NAME="accountID" maxlength="5" size="10"  value="<%=account%>" onKeyPress='return mask(this);' onBlur='check(this);document.all.ToAccount.value=this.value;check(document.all.ToAccount);'></TD>
 61	<TD><INPUT TYPE="text" NAME="accountName" size=30 readonly  value="<%=accountName%>" style="background-color:transparent"></TD>
 62</TR>
 63<TR>
 64	<TD align=left>�� ����</TD>
 65	<TD><INPUT  dir="LTR"  TYPE="text" NAME="ToAccount" maxlength="5" size="10" value="<%=ToAccount%>" onKeyPress='return mask(this);' onBlur='check(this);'></TD>
 66	<TD><INPUT TYPE="text" NAME="ToAccountName" size=30 readonly  value="<%=ToAccountName%>" style="background-color:transparent"></TD>
 67</TR>
 68<TR>
 69	<TD align=left style="cursor:hand" title="���� ���� �� ����� �� ��� �� ��� ����" onclick="subtractOneDay();">�� �����</TD>
 70	<TD><INPUT dir="LTR"  TYPE="text" NAME="FromDate" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=FromDate%>"></TD>
 71	<TD>
 72		<INPUT TYPE="checkbox" NAME="ShowRemained" <%if ShowRemained then response.write "checked"%>> ����� ��� ����� ���� ���.
 73	</TD>
 74</TR>
 75<TR>
 76	<TD align=left style="cursor:hand" title="���� ���� �� ����� �� ��� �� ��� ����" onclick="addOneDay();">�� ����� </TD>
 77	<TD><INPUT dir="LTR" TYPE="text" NAME="ToDate" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=ToDate%>"></TD>
 78	<TD align=center>
 79		<INPUT TYPE="submit" NAME="submit" value="������">
 80		<INPUT TYPE="hidden" Name="Order" Value="">
 81	</TD>
 82</TR>
 83</TABLE>
 84</FORM>
 85
 86<SCRIPT LANGUAGE="JavaScript">
 87<!--
 88var dialogActive=false;
 89function mask(src){ 
 90	var theKey=event.keyCode;
 91
 92	if (theKey==13 || theKey==32){
 93		event.keyCode=9
 94		dialogActive=true
 95		document.all.tmpDlgArg.value="#"
 96		document.all.tmpDlgTxt.value="����� �� ��� ���� ��� ����:"
 97		window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
 98		dialogActive=false
 99		if (document.all.tmpDlgTxt.value !="") {
100			window.showModalDialog('dialog_selectGL.asp?act=select&name='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:500px; dialogWidth:380px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
101			if (document.all.tmpDlgArg.value!="#"){
102				Arguments=document.all.tmpDlgArg.value.split("#")
103				src.value=Arguments[0];
104				document.all.accountName.value=Arguments[1];
105			}
106		}
107	}
108}
109
110function check(src){ 
111	if (!dialogActive){
112		if (window.XMLHttpRequest) {
113			var objHTTP=new XMLHttpRequest();
114		} else if (window.ActiveXObject) {
115			var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
116		}
117		objHTTP.open('GET','xml_GLAccount.asp?id='+src.value,false);
118		objHTTP.send();
119		tmpStr = unescape( objHTTP.responseText);
120		if (tmpStr == '���� ����� ���� �����')
121			src.value='';
122		if (src.name=='accountID'){
123			document.all.accountName.value=tmpStr;
124		}
125		else if (src.name=='ToAccount'){
126			document.all.ToAccountName.value=tmpStr;
127		}
128	}
129}
130
131function checkValidation(){
132  try{
133	box=document.all.accountID;
134	check(box);
135	if (box.value==''){
136		box.style.backgroundColor="red";
137		alert("��� ����� ������ ����");
138		box.style.backgroundColor="";
139		box.focus();
140		return false;
141	}
142	box=document.all.FromDate;
143	if (box.value!='' && box.value!=null){
144		if (!acceptDate(box))
145			return false;
146	}
147	box=document.all.ToDate;
148	if (box.value!='' && box.value!=null){
149		if (!acceptDate(box))
150			return false;
151	}
152  }catch(e){
153		alert("���� ��� ������");
154		return false;
155  }
156}
157
158function addOneDay(){
159  try{
160	box=document.all.FromDate;
161	if (box.value!='' && box.value!=null){
162		if (acceptDate(box)){
163			year=parseInt(box.value.substring(0,4));
164			month=parseInt(box.value.substr(5,2).replace(/^0/g,""));
165			day=parseInt(box.value.substr(8,2).replace(/^0/g,""));
166			day++;
167			if (day>31){
168				day=1;
169				month++;
170			}
171			if (month>12){
172				month=1;
173				year++;
174			}
175			box.value=''+year+'/'+month+'/'+day;
176			acceptDate(box);
177		}
178	}
179	box=document.all.ToDate;
180	if (box.value!='' && box.value!=null){
181		if (acceptDate(box)){
182			year=parseInt(box.value.substring(0,4));
183			month=parseInt(box.value.substr(5,2).replace(/^0/g,""));
184			day=parseInt(box.value.substr(8,2).replace(/^0/g,""));
185			day++;
186			if (day>31){
187				day=1;
188				month++;
189			}
190			if (month>12){
191				month=1;
192				year++;
193			}
194			box.value=''+year+'/'+month+'/'+day;
195			acceptDate(box);
196		}
197	document.SearchForm.submit.click();
198	}
199  }catch(e){
200		alert("���� ��� ������");
201		return false;
202  }
203}
204
205function subtractOneDay(){
206  try{
207	box=document.all.FromDate;
208	if (box.value!='' && box.value!=null){
209		if (acceptDate(box)){
210			year=parseInt(box.value.substring(0,4));
211			month=parseInt(box.value.substr(5,2).replace(/^0/g,""));
212			day=parseInt(box.value.substr(8,2).replace(/^0/g,""));
213			day--;
214			if (day<1){
215				day=31;
216				month--;
217			}
218			if (month<1){
219				month=12;
220				year--;
221			}
222			box.value=''+year+'/'+month+'/'+day;
223			acceptDate(box);
224		}
225	}
226	box=document.all.ToDate;
227	if (box.value!='' && box.value!=null){
228		if (acceptDate(box)){
229			year=parseInt(box.value.substring(0,4));
230			month=parseInt(box.value.substr(5,2).replace(/^0/g,""));
231			day=parseInt(box.value.substr(8,2).replace(/^0/g,""));
232			day--;
233			if (day<1){
234				day=31;
235				month--;
236			}
237			if (month<1){
238				month=12;
239				year--;
240			}
241			box.value=''+year+'/'+month+'/'+day;
242			acceptDate(box);
243		}
244	document.SearchForm.submit.click();
245	}
246  }catch(e){
247		alert("���� ��� ������");
248		return false;
249  }
250}
251//-->
252</SCRIPT>
253
254<SCRIPT LANGUAGE="JavaScript">
255<!--
256function sortSubmit(num){
257	document.SearchForm.Order.value=num;
258	document.SearchForm.submit.click();
259}
260//-->
261</SCRIPT>
262
263<%
264'-----------------------------------------------------------------------------------------------------
265'--------------------------------------------------------------------------------------- Search Action
266'-----------------------------------------------------------------------------------------------------
267
268if request("act")="Show" then
269
270' Major Changes By kid 830820
271
272	Order=request("Order")
273	select case Order
274	case "1":
275		order=", GLDocID "
276	case "-1":
277		order=", GLDocID DESC"
278	case "2":
279		order=", GLDocDate"
280	case "-2":
281		order=", GLDocDate DESC"
282	case else:
283		order=", GLDocDate, IsCredit DESC, Amount"
284	end select
285
286'	if ShowRemained then
287		mySQL="SELECT GLAccounts.ID, GLAccounts.Name AS AccountName, GLAccountGroups.ID AS GroupID, GLAccountGroups.Name AS GroupName,  GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName, GLs.ID AS GLID, GLs.Name AS GLname FROM GLs INNER JOIN GLAccountSuperGroups ON GLs.ID = GLAccountSuperGroups.GL INNER JOIN GLAccountGroups ON GLs.ID = GLAccountGroups.GL AND GLAccountSuperGroups.ID = GLAccountGroups.GLSuperGroup INNER JOIN GLAccounts ON GLs.ID = GLAccounts.GL AND GLAccountGroups.ID = GLAccounts.GLGroup WHERE (GLs.ID = "& OpenGL & ") AND (GLAccounts.ID >= "& account & ") AND (GLAccounts.ID <= "& ToAccount & ") ORDER BY GLAccounts.ID"
288'	else
289		'mySQL="SELECT GLAccounts.ID, GLAccounts.Name AS AccountName, GLAccountGroups.ID AS GroupID, GLAccountGroups.Name AS GroupName,  GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName, GLs.ID AS GLID, GLs.Name AS GLname FROM GLs INNER JOIN GLAccountSuperGroups ON GLs.ID = GLAccountSuperGroups.GL INNER JOIN GLAccountGroups ON GLs.ID = GLAccountGroups.GL AND GLAccountSuperGroups.ID = GLAccountGroups.GLSuperGroup INNER JOIN GLAccounts ON GLs.ID = GLAccounts.GL AND GLAccountGroups.ID = GLAccounts.GLGroup INNER JOIN (SELECT DISTINCT GLAccount AS ID FROM EffectiveGLRows WHERE (GL = "& OpenGL & ") AND (GLAccount >= "& account & ") AND (GLAccount <= "& ToAccount & ") AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "')) UsedAccs ON UsedAccs.ID = GLAccounts.ID WHERE (GLs.ID = "& OpenGL & ") ORDER BY GLAccounts.ID"
290	'end if
291
292	set rsGLAccs=Conn.Execute (mySQL)
293
294	Do While not rsGLAccs.EOF 
295
296		GLAccount=rsGLAccs("ID")
297
298		AccountInfoParams = "&DateFrom=" & FromDate & "&DateTo=" & ToDate
299		if ShowRemained then AccountInfoParams = AccountInfoParams & "&ShowRemained=on"
300%>
301		<TABLE dir=rtl align=center width=640 cellspacing=0 cellpadding=0 style="border:2 solid #330066;">
302		<TR bgcolor="#CCCCEE" height="30">
303			<TD colspan=7>
304				<A HREF="AccountInfo.asp?OpenGL=<%=rsGLAccs("GLID")&AccountInfoParams%>" Target="_blank"><%=rsGLAccs("GLname")%></A>
305				> <A HREF="AccountInfo.asp?act=groups&id=<%=rsGLAccs("SuperGroupID")&AccountInfoParams%>" Target="_blank"><%=rsGLAccs("SuperGroupName")%></A>
306				> <A HREF="AccountInfo.asp?act=account&id=<%=rsGLAccs("GroupID")&AccountInfoParams%>" Target="_blank"><%=rsGLAccs("GroupName")%></A>
307				> <%=rsGLAccs("AccountName")%>
308				[<%=GLAccount%>]
309			</TD>
310		</TR>
311		<TR bgcolor="black" height="2">
312			<TD colspan="7" style="padding:0;"></TD>
313		</TR>
314		<TR class="MoeenTR1">
315				<TD style="width:60px;"><A HREF="javaScript:sortSubmit(1);">v</A>&nbsp;���&nbsp;<A HREF="javaScript:sortSubmit(-1);">^</A></TD>
316				<TD style="width:80px;"><A HREF="javaScript:sortSubmit(2);">v</A>&nbsp;����� ���&nbsp;<A HREF="javaScript:sortSubmit(-2);">^</A></TD>
317				<TD style="width:200px;">���</TD>
318				<TD style="width:100px;">������</TD>
319				<TD style="width:100px;">��������</TD>
320				<TD style="width:10px;">-</TD>
321				<TD style="width:100px;border-left:0;">�����</TD>
322		</TR>
323
324<%		
325		if ShowRemained then
326
327			mySQL="SELECT SUM(IsCredit * Amount) AS totalCredit, SUM(- ((IsCredit - 1) * Amount)) AS totalDebit FROM EffectiveGLRows WHERE (GL = "& OpenGL & ") AND (GLAccount = "& GLAccount & ") AND (GLDocDate < N'"& FromDate & "') GROUP BY GLAccount"
328
329			set RSS=Conn.Execute (mySQL)
330
331			if RSS.eof then
332				debit = 0
333				credit = 0
334			else
335				debit = cdbl(RSS("totalDebit"))
336				credit = cdbl(RSS("totalCredit"))
337			end if
338
339			RSS.close
340
341			remainedAmount = debit - credit
342			SumCredit = credit 
343			SumDebit =	debit 
344
345%>
346			<TR bgcolor="#DDDDDD" height=30>
347				<TD colspan=3 align=left style="border-left:solid 1px black"><INPUT TYPE="text" style="text-align:left;" value="����� ��� �� ����� <%=replace(FromDate,"/",".")%>" style="width=200pt; border:solid 0pt; font-size:8pt; background-color:transparent"></TD>
348				<TD dir=ltr align=right style="border-left:solid 1px black"><%=Separate(debit)%>&nbsp;</TD>
349				<TD dir=ltr align=right style="border-left:solid 1px black"><%=Separate(credit)%>&nbsp;</TD>
350				<TD dir=ltr align=center style="border-left:solid 1px black"><% if remainedAmount > 0 then %>�<% else %>�<% end if %></TD>
351				<TD dir=ltr align=right><%=Separate(remainedAmount)%> &nbsp;</TD>
352			</TR>
353			<TR bgcolor="black" height="2">
354				<TD colspan="7" style="padding:0;"></TD>
355			</TR>
356<% 
357		else
358			remainedAmount = 0
359			SumCredit = 0 
360			SumDebit =	0
361		end if
362
363		mySQL="SELECT * FROM EffectiveGLRows WHERE (GL = "& OpenGL & ") AND (GLAccount = "& GLAccount & ") AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "') ORDER BY GLAccount" & order
364		set RSS=Conn.Execute (mySQL)	
365
366		tmpCounter=0
367
368		Do while not RSS.eof
369			tmpCounter = tmpCounter + 1
370			if tmpCounter mod 2 = 1 then
371				tmpColor="#FFFFFF"
372				tmpColor2="#FFFFBB"
373			Else
374				tmpColor="#DDDDDD"
375				tmpColor2="#EEEEBB"
376			End if 
377			
378			debit = 0
379			credit = 0
380			if RSS("IsCredit") then
381				credit = cdbl(RSS("Amount"))
382			else
383				debit = cdbl(RSS("Amount"))
384			end if
385			remainedAmount = remainedAmount - credit + debit
386
387			SumCredit = SumCredit + credit 
388			SumDebit =	SumDebit + debit 
389
390%>
391			<TR bgcolor="<%=tmpColor%>" height=30>
392				<TD style="border-left:solid 1px black"><A HREF="javascript:void(0);" onclick="window.open('GLMemoDocShow.asp?id=<%=RSS("GLDoc")%>')"><%=RSS("GLDocID")%></A></TD>
393				<TD  align=center dir=ltr style="border-left:solid 1px black"><%=RSS("GLDocDate")%></TD>
394				<TD  width=100 style="border-left:solid 1px black">
395					<INPUt size="70" TYPE="text" value="<%=RSS("Description")%>" style="width=200pt; border:solid 0pt; font-size:8pt; background-color:transparent">
396				</TD>
397				<TD dir=ltr align=right style="border-left:solid 1px black"><% if debit<>"0" then %> <%=Separate(debit)%><% end if %> &nbsp;</TD>
398				<TD dir=ltr align=right style="border-left:solid 1px black"><% if credit<>"0" then %> <%=Separate(credit)%><% end if %> &nbsp;</TD>
399				<TD dir=ltr align=center style="border-left:solid 1px black"><% if remainedAmount > 0 then %>�<% else %>�<% end if %></TD>
400				<TD dir=ltr align=right><%=Separate(remainedAmount)%> &nbsp;</TD>
401			</TR>
402				  
403<% 
404			RSS.moveNext
405		Loop
406		RSS.close
407
408		tmpCounter = tmpCounter + 1
409		if tmpCounter mod 2 = 1 then
410			tmpColor="#FFFFFF"
411			tmpColor2="#FFFFBB"
412		Else
413			tmpColor="#DDDDDD"
414			tmpColor2="#EEEEBB"
415		End if 
416		%>
417		<TR bgcolor="black" height="2">
418			<TD colspan="7" style="padding:0;"></TD>
419		</TR>
420		<TR bgcolor="<%=tmpColor%>" height=30>
421			<TD colspan=3 align=left style="border-left:solid 1px black"><INPUT TYPE="text" style="text-align:left;" value="��� ���� <%=GLAccount%> �� ����� <%=replace(ToDate,"/",".")%>" style="width=200pt; border:solid 0pt; font-size:8pt; background-color:transparent"></TD>
422			<TD dir=ltr align=right style="border-left:solid 1px black"><% if SumDebit<>"0" then response.write Separate(SumDebit)%> &nbsp;</TD>
423			<TD dir=ltr align=right style="border-left:solid 1px black"><% if SumCredit<>"0" then response.write Separate(SumCredit)%> &nbsp;</TD>
424			<TD dir=ltr align=center style="border-left:solid 1px black"><% if remainedAmount > 0 then %>�<% else %>�<% end if %></TD>
425			<TD dir=ltr align=right><%=Separate(remainedAmount)%> &nbsp;</TD>
426		</TR>
427		</TABLE><br><br>
428<% 
429
430		rsGLAccs.moveNext
431	Loop
432	rsGLAccs.close
433	Set rsGLAccs = Nothing
434
435end if %>
436<!--#include file="tah.asp" -->