PageRenderTime 17ms CodeModel.GetById 6ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/accounting/AccountInfo.asp

http://github.com/khaneh/Orders
ASP | 565 lines | 470 code | 71 blank | 24 comment | 36 complexity | 8162d368b66ba3cf42a8605330071cd8 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2Response.Buffer=false
  3'Accounting (8)
  4PageTitle= "���� ��"
  5SubmenuItem=4
  6if not Auth(8 , 4) then NotAllowdToViewThisPage()
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<%
 12'-----------------------------------------------------------------------------------------------------
 13'----------------------------------------------------------------------------------------- Search Form
 14'------------------------------------------------------------------------------------------		+
 15'--------------------------------------------------------------------------------------------- Scripts
 16'-----------------------------------------------------------------------------------------------------
 17if request.form("act")="" then
 18	DateFrom	=	request("DateFrom")
 19	DateTo		=	request("DateTo")
 20	act			=	request("act")
 21	id			=	request("id")
 22	ShowRemained=	request("ShowRemained")
 23else
 24	DateFrom	=	request.form("DateFrom")
 25	DateTo		=	request.form("DateTo")
 26	act			=	request.form("act")
 27	id			=	request.form("id")
 28	ShowRemained=	request.form("ShowRemained")
 29end if
 30
 31if ShowRemained="on" then
 32	ShowRemained=true
 33else
 34	ShowRemained=false
 35end if
 36
 37if DateFrom		= "" then	DateFrom = fiscalYear & "/01/01"
 38if DateTo		= "" then	DateTo = shamsiToday()
 39
 40%>
 41<input type="hidden" Name='tmpDlgArg' value=''>
 42<input type="hidden" Name='tmpDlgTxt' value=''>
 43<BR>
 44<FORM METHOD=POST ACTION="">
 45<input type="hidden" Name='act' value='<%=act%>'>
 46<input type="hidden" Name='id' value='<%=id%>'>
 47<TABLE style="border:1 solid #330066;" align=center>
 48<TR>
 49	<TD align=left>�� �����</TD>
 50	<TD><INPUT dir="LTR"  TYPE="text" NAME="DateFrom" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=DateFrom%>"></TD>
 51	<TD align=left>�� ����� </TD>
 52	<TD><INPUT dir="LTR"  TYPE="text" NAME="DateTo" maxlength="10" size="10" onblur="acceptDate(this)" onKeyPress="return maskDate(this);" value="<%=DateTo%>"></TD>
 53	<TD align=center>
 54		<INPUT TYPE="submit" NAME="submitt" value="������">
 55		<INPUT TYPE="hidden" Name="Order" Value="">
 56	</TD>
 57	<TD>
 58		<INPUT TYPE="checkbox" NAME="ShowRemained" <%if ShowRemained then response.write "checked"%>> ����� ��� ����� ���� ���.
 59	</TD>
 60</TR>
 61</FORM>
 62</TABLE>
 63<SCRIPT LANGUAGE="JavaScript">
 64<!--
 65function drill(act,id){
 66	document.all.act.value=act;
 67	document.all.id.value=id;
 68	document.forms[0].submit();
 69}
 70//-->
 71</SCRIPT>
 72<%
 73dateStr = "�� ����� <span dir=rtl>" & fiscalYear & "/1/1</span> �� <span dir=rtl>" & shamsiToday() & "</span>"
 74
 75'-----------------------------------------------------------------------------------------------------
 76'-------------------------------------------------------------------------------- List GL Super Groups
 77'-----------------------------------------------------------------------------------------------------
 78if request("act")="" then
 79
 80%>
 81	<br>
 82	<TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
 83	<TR bgcolor="#CCCCEE" height="30">
 84		<TD colspan=6>
 85			<A HREF="?"><%=OpenGLName%></A>
 86		</TD>
 87	</TR>
 88	<TR bgcolor="black" height="2">
 89		<TD colspan="6" style="padding:0;"></TD>
 90	</TR>
 91	<TR bgcolor="eeeeee" >
 92		<TD>��</TD>
 93		<TD>��� �ѐ���</TD>
 94		<TD>���� ������</TD>
 95		<TD>���� ��������</TD>
 96		<TD>����� ������</TD>
 97		<TD>����� ��������</TD>
 98	</TR>
 99	<TR bgcolor="eeeeee" >
100		<TD colspan=6 height=2 bgcolor=0></TD>
101	</TR>
102<%
103	SumCredit=0
104	SumDebit=0
105	SumCreditRemained=0
106	SumDebitRemained=0
107	tmpCounter=0
108
109	'Added By kid 830805
110	if ShowRemained then
111		mySQL="SELECT ISNULL(SUM(IsCredit * Amount),0) AS totalCredit, ISNULL(SUM(- ((IsCredit - 1) * Amount)),0) AS totalDebit FROM EffectiveGLRows WHERE (GLDocDate < N'"& DateFrom & "') AND (GL = "& OpenGL & ")"
112		set RSS2=Conn.Execute (mySQL)
113
114		if RSS2.eof then
115			totalDebit =	0
116			totalCredit =	0
117		else
118			totalDebit =	cdbl(RSS2("totalDebit"))
119			totalCredit =	cdbl(RSS2("totalCredit"))
120		end if
121
122		RSS2.close
123		
124		tmpCounter=1
125
126		if totalCredit > totalDebit then
127			creditRemained =	totalCredit - totalDebit
128			debitRemained  =	0
129		else
130			creditRemained =	0
131			debitRemained  =	totalDebit - totalCredit
132		end if
133
134		SumCredit = SumCredit + totalCredit 
135		SumDebit =	SumDebit + totalDebit
136
137		SumCreditRemained = SumCreditRemained + creditRemained
138		SumDebitRemained =	SumDebitRemained + debitRemained
139%>
140		<TR bgcolor="#FFFFFF">
141			<TD style="border-bottom:1 solid black;" colspan=2 align=left>����� ��� �� ����� <%=replace(DateFrom,"/",".")%></TD>
142			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalDebit)%></TD>
143			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalCredit)%></TD>
144			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(debitRemained)%></TD>
145			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(creditRemained)%></TD>
146		</TR>
147<% 
148	end if
149
150
151	'changed by kid 830805
152	mySQL="SELECT ISNULL(DRV.totalCredit, 0) AS totalCredit, ISNULL(DRV.totalDebit, 0) AS totalDebit, GLAccountSuperGroups.ID, GLAccountSuperGroups.Name FROM (SELECT SUM(EffectiveGLRows.IsCredit * EffectiveGLRows.Amount) AS totalCredit, SUM(- ((EffectiveGLRows.IsCredit - 1)  * EffectiveGLRows.Amount)) AS totalDebit, GLAccountGroups.GLSuperGroup FROM EffectiveGLRows INNER JOIN GLAccounts INNER JOIN GLAccountGroups ON GLAccounts.GLGroup = GLAccountGroups.ID AND GLAccounts.GL = GLAccountGroups.GL ON  EffectiveGLRows.GL = GLAccounts.GL AND EffectiveGLRows.GLAccount = GLAccounts.ID WHERE (GLDocDate >= N'"& DateFrom & "') AND (GLDocDate <= N'"& DateTo & "') AND (EffectiveGLRows.GL = "& OpenGL&") GROUP BY GLAccountGroups.GLSuperGroup) DRV RIGHT OUTER JOIN GLAccountSuperGroups ON DRV.GLSuperGroup = GLAccountSuperGroups.ID WHERE (GLAccountSuperGroups.GL = "& OpenGL&") ORDER BY GLAccountSuperGroups.ID"
153
154	set RSS=Conn.Execute (mySQL)
155
156	Do while not RSS.eof
157		tmpCounter = tmpCounter + 1
158		if tmpCounter mod 2 = 1 then
159			tmpColor="#FFFFFF"
160			tmpColor2="#FFFFBB"
161		Else
162			tmpColor="#DDDDDD"
163			tmpColor2="#EEEEBB"
164		End if 
165
166		totalDebit =	cdbl(RSS("totalDebit"))
167		totalCredit =	cdbl(RSS("totalCredit"))
168
169		if totalCredit > totalDebit then
170			creditRemained =	totalCredit - totalDebit
171			debitRemained  =	0
172		else
173			creditRemained =	0
174			debitRemained  =	totalDebit - totalCredit
175		end if
176
177		SumCredit = SumCredit + totalCredit 
178		SumDebit =	SumDebit + totalDebit
179
180		SumCreditRemained = SumCreditRemained + creditRemained
181		SumDebitRemained =	SumDebitRemained + debitRemained
182
183%>
184		<TR bgcolor="<%=tmpColor%>" height=30>
185			<TD><A HREF="javascript:drill('groups','<%=RSS("ID")%>');"><%=RSS("ID")%></A></TD>
186			<TD><A HREF="javascript:drill('groups','<%=RSS("ID")%>');"><%=RSS("Name")%></A></TD>
187			<TD dir=ltr align=right><span dir=ltr><%=Separate(totalDebit)%></span></TD>
188			<TD dir=ltr align=right><span dir=ltr><%=Separate(totalCredit)%></span></TD>
189			<TD dir=ltr align=right><span dir=ltr><%=Separate(debitRemained)%></span></TD>
190			<TD dir=ltr align=right><span dir=ltr><%=Separate(creditRemained)%></span></TD>
191		</TR>
192		  
193<% 
194	RSS.moveNext
195	Loop
196
197	if SumDebitRemained > SumCreditRemained then
198		TotalSumDebitRemained = SumDebitRemained - SumCreditRemained 
199		TotalSumCreditRemained=0
200	else
201		TotalSumDebitRemained=0
202		TotalSumCreditRemained = SumCreditRemained - SumDebitRemained 
203	end if
204
205%>
206	<TR bgcolor="eeeeee" >
207		<TD colspan=6 height=2 bgcolor=0></TD>
208	</TR>
209	<TR bgcolor="eeeeee" >
210		<TD style="border-bottom:1 solid black;" colspan=2 align=left>���:</TD>
211		<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumDebit)%></TD>
212		<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumCredit)%></TD>
213		<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumDebitRemained)%></TD>
214		<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumCreditRemained)%></TD>
215	</TR>
216	<TR bgcolor="eeeeee" >
217		<TD colspan=4 align=left>����� �� ��:</TD>
218		<TD dir=ltr align=right><%=Separate(TotalSumDebitRemained)%></TD>
219		<TD dir=ltr align=right><%=Separate(TotalSumCreditRemained)%></TD>
220	</TR>
221	</TABLE><br>
222
223	<CENTER>
224	<FORM METHOD=POST ACTION="AccountInfo.asp">
225	<!--INPUT TYPE="button" onclick="window.location='balance.asp'" class="GenButton" value="����" style="width:90px; ">
226	<INPUT TYPE="button" onclick="window.location='sood.asp'" class="GenButton" value="��� � ����" style="width:90px; "--><br><br>
227	<INPUT TYPE="button" onclick="window.location='manageGL.asp?act=select'" class="GenButton" value="�����" style="width:90px; background-color: #FFFFBB ">
228	</FORM>
229	</CENTER>
230<%
231
232'-----------------------------------------------------------------------------------------------------
233'------------------------------------------------------------------ List GL Groups under a super group
234'-----------------------------------------------------------------------------------------------------
235elseif request("act")="groups" then
236	SuperGroupID = clng(id)
237	'changed by kid 830804
238	mySQL="SELECT GLs.ID AS GLID, GLs.Name AS GLname, GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName FROM GLs INNER JOIN GLAccountSuperGroups ON GLs.ID = GLAccountSuperGroups.GL WHERE (GLAccountSuperGroups.GL = "& OpenGL & ") AND (GLAccountSuperGroups.ID = "& SuperGroupID & ")"
239	set rsGLNames=Conn.Execute (mySQL)
240
241	if not rsGLNames.EOF then
242%>
243		<br>
244		<TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
245		<TR bgcolor="#CCCCEE" height="30">
246			<TD colspan=7>
247				<A HREF="javascript:drill('','');"><%=rsGLNames("GLname")%></A>
248				> <A HREF="javascript:drill('groups','<%=rsGLNames("SuperGroupID")%>');"><%=rsGLNames("SuperGroupName")%></A>
249				[<%=rsGLNames("SuperGroupID")%>]
250			</TD>
251		</TR>
252		<TR bgcolor="black" height="2">
253			<TD colspan="7" style="padding:0;"></TD>
254		</TR>
255		<TR bgcolor="eeeeee" >
256			<TD>��</TD>
257			<TD>��� ����</TD>
258			<TD>���� ������</TD>
259			<TD>���� ��������</TD>
260			<TD>����� ������</TD>
261			<TD>����� ��������</TD>
262		</TR>
263		<TR bgcolor="eeeeee" >
264			<TD colspan=7 height=2 bgcolor=0></TD>
265		</TR>
266<%	end if 
267	rsGLNames.close
268
269	SumCredit=0
270	SumDebit=0
271	SumCreditRemained=0
272	SumDebitRemained=0
273	tmpCounter=0
274	'Added By kid 830805
275	if ShowRemained then
276		mySQL="SELECT ISNULL(SUM(IsCredit * Amount),0) AS totalCredit, ISNULL(SUM(- ((IsCredit - 1) * Amount)),0) AS totalDebit FROM GLAccounts INNER JOIN EffectiveGLRows ON GLAccounts.GL = EffectiveGLRows.GL AND GLAccounts.ID = EffectiveGLRows.GLAccount INNER JOIN GLAccountGroups ON GLAccounts.GLGroup = GLAccountGroups.ID AND GLAccounts.GL = GLAccountGroups.GL WHERE (GLDocDate < N'"& DateFrom & "') AND (EffectiveGLRows.GL = "& OpenGL & ") GROUP BY GLAccountGroups.GLSuperGroup HAVING (GLAccountGroups.GLSuperGroup = "& SuperGroupID & ")"
277		set RSS2=Conn.Execute (mySQL)
278
279		if RSS2.eof then
280			totalDebit =	0
281			totalCredit =	0
282		else
283			totalDebit =	cdbl(RSS2("totalDebit"))
284			totalCredit =	cdbl(RSS2("totalCredit"))
285		end if
286
287		RSS2.close
288		
289		tmpCounter=1
290
291		if totalCredit > totalDebit then
292			creditRemained =	totalCredit - totalDebit
293			debitRemained  =	0
294		else
295			creditRemained =	0
296			debitRemained  =	totalDebit - totalCredit
297		end if
298
299		SumCredit = SumCredit + totalCredit 
300		SumDebit =	SumDebit + totalDebit
301
302		SumCreditRemained = SumCreditRemained + creditRemained
303		SumDebitRemained =	SumDebitRemained + debitRemained
304%>
305		<TR bgcolor="#FFFFFF">
306			<TD style="border-bottom:1 solid black;" colspan=2 align=left>����� ��� �� ����� <%=replace(DateFrom,"/",".")%></TD>
307			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalDebit)%></TD>
308			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalCredit)%></TD>
309			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(debitRemained)%></TD>
310			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(creditRemained)%></TD>
311		</TR>
312<% 
313	end if
314
315
316'	mySQL="SELECT SUM(IsCredit * Amount) AS totalCredit, SUM(- ((IsCredit - 1) * Amount)) AS totalDebit, GLAccounts.GLGroup, GLAccountGroups.Name FROM GLAccounts INNER JOIN EffectiveGLRows ON GLAccounts.GL = EffectiveGLRows.GL AND GLAccounts.ID = EffectiveGLRows.GLAccount INNER JOIN GLAccountGroups ON GLAccounts.GLGroup = GLAccountGroups.ID AND GLAccounts.GL = GLAccountGroups.GL WHERE (GLDocDate >= N'"& DateFrom & "') AND (GLDocDate <= N'"& DateTo & "') AND (EffectiveGLRows.GL = "& OpenGL & ") GROUP BY GLAccountGroups.GLSuperGroup, GLAccounts.GLGroup, GLAccountGroups.Name HAVING (GLAccountGroups.GLSuperGroup = "& SuperGroupID & ") ORDER BY GLAccounts.GLGroup"
317	'Changed By Kid 830805
318	mySQL="SELECT ISNULL(DRV.totalCredit, 0) AS totalCredit, ISNULL(DRV.totalDebit, 0) AS totalDebit, GLAccountGroups.ID, GLAccountGroups.Name FROM (SELECT SUM(EffectiveGLRows.IsCredit * EffectiveGLRows.Amount) AS totalCredit, SUM(- ((EffectiveGLRows.IsCredit - 1)  * EffectiveGLRows.Amount)) AS totalDebit, GLAccounts.GLGroup FROM GLAccounts INNER JOIN EffectiveGLRows ON GLAccounts.GL = EffectiveGLRows.GL AND GLAccounts.ID = EffectiveGLRows.GLAccount WHERE (EffectiveGLRows.GLDocDate >= N'"& DateFrom & "') AND (EffectiveGLRows.GLDocDate <= N'"& DateTo & "') AND (EffectiveGLRows.GL = "& OpenGL & ") GROUP BY GLAccounts.GLGroup) DRV RIGHT OUTER JOIN GLAccountGroups ON DRV.GLGroup = GLAccountGroups.ID WHERE (GLAccountGroups.GLSuperGroup = "& SuperGroupID & ") AND (GLAccountGroups.GL = "& OpenGL & ") ORDER BY ID"
319
320
321	set RSS=Conn.Execute (mySQL)
322
323	Do while not RSS.eof
324		tmpCounter = tmpCounter + 1
325		if tmpCounter mod 2 = 1 then
326			tmpColor="#FFFFFF"
327			tmpColor2="#FFFFBB"
328		Else
329			tmpColor="#DDDDDD"
330			tmpColor2="#EEEEBB"
331		End if 
332
333		totalDebit =	cdbl(RSS("totalDebit"))
334		totalCredit =	cdbl(RSS("totalCredit"))
335
336		if totalCredit > totalDebit then
337			creditRemained =	totalCredit - totalDebit
338			debitRemained  =	0
339		else
340			creditRemained =	0
341			debitRemained  =	totalDebit - totalCredit
342		end if
343
344		SumCredit = SumCredit + totalCredit 
345		SumDebit =	SumDebit + totalDebit
346
347		SumCreditRemained = SumCreditRemained + creditRemained
348		SumDebitRemained =	SumDebitRemained + debitRemained
349
350%>
351		<TR bgcolor="<%=tmpColor%>" >
352			<TD><A HREF="javascript:drill('account','<%=RSS("ID")%>');"><%=RSS("ID")%></A></TD>
353			<TD><A HREF="javascript:drill('account','<%=RSS("ID")%>');"><%=RSS("Name")%></A></TD>
354			<TD dir=ltr align=right><span dir=ltr><%=Separate(totalDebit)%></span></TD>
355			<TD dir=ltr align=right><span dir=ltr><%=Separate(totalCredit)%></span></TD>
356			<TD dir=ltr align=right><span dir=ltr><%=Separate(debitRemained)%></span></TD>
357			<TD dir=ltr align=right><span dir=ltr><%=Separate(creditRemained)%></span></TD>
358		</TR>
359		  
360<% 
361	RSS.moveNext
362	Loop
363
364	if SumDebitRemained > SumCreditRemained then
365		TotalSumDebitRemained = SumDebitRemained - SumCreditRemained 
366		TotalSumCreditRemained=0
367	else
368		TotalSumDebitRemained=0
369		TotalSumCreditRemained = SumCreditRemained - SumDebitRemained 
370	end if
371
372%>
373	<TR bgcolor="eeeeee" >
374		<TD colspan=7 height=2 bgcolor=0></TD>
375	</TR>
376	<TR bgcolor="eeeeee" >
377		<TD style="border-bottom:1 solid black;" colspan=2 align=left>���:</TD>
378		<TD style="border-bottom:1 solid black;" align=right><%=Separate(SumDebit)%></TD>
379		<TD style="border-bottom:1 solid black;" align=right><%=Separate(SumCredit)%></TD>
380		<TD style="border-bottom:1 solid black;" align=right><%=Separate(SumDebitRemained)%></TD>
381		<TD style="border-bottom:1 solid black;" align=right><%=Separate(SumCreditRemained)%></TD>
382	</TR>
383	<TR bgcolor="eeeeee" >
384		<TD colspan=4 align=left>����� �� ��:</TD>
385		<TD dir=ltr align=right><%=Separate(TotalSumDebitRemained)%></TD>
386		<TD dir=ltr align=right><%=Separate(TotalSumCreditRemained)%></TD>
387	</TR>
388	</TABLE><br>
389<%
390'-----------------------------------------------------------------------------------------------------
391'---------------------------------------------------------------------- List GL Accounts under a group
392'-----------------------------------------------------------------------------------------------------
393elseif request("act")="account" then
394	GroupID = clng(id)
395
396	mySQL = "SELECT GLs.Name AS GLName, GLs.ID AS GLID, GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName, GLAccountGroups.ID AS GroupID, GLAccountGroups.Name AS GroupName FROM GLAccountGroups INNER JOIN GLAccountSuperGroups ON GLAccountGroups.GLSuperGroup = GLAccountSuperGroups.ID INNER JOIN GLs ON GLAccountSuperGroups.GL = GLs.ID WHERE (GLAccountSuperGroups.GL = "& OpenGL & ") AND (GLAccountGroups.GL = "& OpenGL & ") AND (GLAccountGroups.ID = "& GroupID & ")"
397
398	set rsGLNames=Conn.Execute (mySQL)
399
400	if not rsGLNames.EOF then
401%>
402		<br>
403		<TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
404		<TR bgcolor="#CCCCEE" height="30">
405			<TD colspan=6>
406				<A HREF="javascript:drill('','');"><%=rsGLNames("GLname")%></A>
407				> <A HREF="javascript:drill('groups','<%=rsGLNames("SuperGroupID")%>');"><%=rsGLNames("SuperGroupName")%></A>
408				> <A HREF="javascript:drill('account','<%=rsGLNames("GroupID")%>');"><%=rsGLNames("GroupName")%></A>
409				[<%=rsGLNames("GroupID")%>]
410			</TD>
411		</TR>
412		<TR bgcolor="black" height="2">
413			<TD colspan="6" style="padding:0;"></TD>
414		</TR>
415		<TR bgcolor="eeeeee" >
416			<TD>��</TD>
417			<TD>����� ����</TD>
418			<TD>���� ������</TD>
419			<TD>���� ��������</TD>
420			<TD>����� ������</TD>
421			<TD>����� ��������</TD>
422		</TR>
423		<TR bgcolor="eeeeee" >
424			<TD colspan=6 height=2 bgcolor=0></TD>
425		</TR>
426<%	end if 
427	rsGLNames.close
428
429	SumCredit=0
430	SumDebit=0
431	SumCreditRemained=0
432	SumDebitRemained=0
433	tmpCounter=0
434	'Added By kid 830805
435	if ShowRemained then
436
437		mySQL="SELECT SUM(IsCredit * Amount) AS totalCredit, SUM(- ((IsCredit - 1) * Amount)) AS totalDebit FROM GLAccounts INNER JOIN EffectiveGLRows ON GLAccounts.GL = EffectiveGLRows.GL AND GLAccounts.ID = GLAccount WHERE (GLAccounts.GL = "& OpenGL & ") AND (GLDocDate < N'"& DateFrom & "') GROUP BY GLAccounts.GLGroup HAVING (GLAccounts.GLGroup = "& GroupID & ")"
438
439		set RSS2=Conn.Execute (mySQL)
440
441		if RSS2.eof then
442			totalDebit =	0
443			totalCredit =	0
444		else
445			totalDebit =	cdbl(RSS2("totalDebit"))
446			totalCredit =	cdbl(RSS2("totalCredit"))
447		end if
448
449		RSS2.close
450		
451		tmpCounter=1
452
453		if totalCredit > totalDebit then
454			creditRemained =	totalCredit - totalDebit
455			debitRemained  =	0
456		else
457			creditRemained =	0
458			debitRemained  =	totalDebit - totalCredit
459		end if
460
461		SumCredit = SumCredit + totalCredit 
462		SumDebit =	SumDebit + totalDebit
463
464		SumCreditRemained = SumCreditRemained + creditRemained
465		SumDebitRemained =	SumDebitRemained + debitRemained
466%>
467		<TR bgcolor="#FFFFFF">
468			<TD style="border-bottom:1 solid black;" colspan=2 align=left>����� ��� �� ����� <%=replace(DateFrom,"/",".")%></TD>
469			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalDebit)%></TD>
470			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(totalCredit)%></TD>
471			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(debitRemained)%></TD>
472			<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(creditRemained)%></TD>
473		</TR>
474<% 
475	end if
476
477	'mySQL="SELECT GLAccounts.Name, ISNULL(DERIVEDTBL.totalDebit,0) AS totalDebit, ISNULL(DERIVEDTBL.totalCredit,0) AS totalCredit, GLAccounts.ID FROM (SELECT SUM(GLRows.IsCredit * GLRows.Amount) AS totalCredit, SUM(- ((GLRows.IsCredit - 1) * GLRows.Amount)) AS totalDebit,  GLRows.GLAccount FROM GLDocs INNER JOIN GLRows ON GLDocs.ID = GLRows.GLDoc WHERE (GLDocs.IsTemporary = 1 OR GLDocs.IsChecked = 1 OR GLDocs.IsFinalized = 1) AND (GLDocs.deleted = 0) AND (GLDocs.IsRemoved = 0) AND (GLRows.deleted = 0) GROUP BY GLRows.GLAccount, GLDocs.GL HAVING (GLDocs.GL = "& OpenGL & ")) DERIVEDTBL RIGHT OUTER JOIN GLAccounts ON DERIVEDTBL.GLAccount = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL & ") AND (GLAccounts.GLGroup = "& GroupID & ") ORDER BY GLAccounts.ID"
478	'Changed By Kid 830805
479	mySQL="SELECT GLAccounts.Name, GLAccounts.HasAppendix, ISNULL(DERIVEDTBL.totalDebit, 0) AS totalDebit, ISNULL(DERIVEDTBL.totalCredit, 0) AS totalCredit, GLAccounts.ID FROM (SELECT SUM(IsCredit * Amount) AS totalCredit, SUM(- ((IsCredit - 1) * Amount)) AS totalDebit, GLAccount FROM EffectiveGLRows WHERE (GLDocDate >= N'"& DateFrom & "') AND (GLDocDate <= N'"& DateTo & "') GROUP BY GLAccount, GL HAVING (GL = "& OpenGL & ")) DERIVEDTBL RIGHT OUTER JOIN GLAccounts ON DERIVEDTBL.GLAccount = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL & ") AND (GLAccounts.GLGroup = "& GroupID & ") ORDER BY GLAccounts.ID"
480
481	set RSS2=Conn.Execute (mySQL)
482
483	Do while not RSS2.eof
484		tmpCounter = tmpCounter + 1
485		if tmpCounter mod 2 = 1 then
486			tmpColor="#FFFFFF"
487			tmpColor2="#FFFFBB"
488		Else
489			tmpColor="#DDDDDD"
490			tmpColor2="#EEEEBB"
491		End if 
492
493		HasAppendix = RSS2("HasAppendix")
494
495		totalDebit =	cdbl(RSS2("totalDebit"))
496		totalCredit =	cdbl(RSS2("totalCredit"))
497
498		if totalCredit > totalDebit then
499			creditRemained =	totalCredit - totalDebit
500			debitRemained  =	0
501		else
502			creditRemained =	0
503			debitRemained  =	totalDebit - totalCredit
504		end if
505
506		SumCredit = SumCredit + totalCredit 
507		SumDebit =	SumDebit + totalDebit
508
509		SumCreditRemained = SumCreditRemained + creditRemained
510		SumDebitRemained =	SumDebitRemained + debitRemained
511
512		if ShowRemained then
513			MoeenShowRemained = "on"
514		else
515			MoeenShowRemained = "off"
516		end if
517%>
518		<TR bgcolor="<%=tmpColor%>" >
519			<TD>
520			<%if HasAppendix then%>
521				* <A Target="_blank" HREF="OtherReports.asp?act=MoeenRep&GLAccount=<%=RSS2("id")%>&FromDate=<%=DateFrom%>&ToDate=<%=DateTo%>&FromTafsil=0&ToTafsil=999999"><%=RSS2("id")%></A>
522			<%else%>
523				<A Target="_blank" HREF="moeen.asp?act=Show&accountID=<%=RSS2("id")%>&accountName=<%=Server.URLEncode(RSS2("Name"))%>&FromDate=<%=DateFrom%>&ToDate=<%=DateTo%>&ShowRemained=<%=MoeenShowRemained%>"><%=RSS2("id")%></A>
524			<%end if %>
525			</TD>
526			<TD><A Target="_blank" HREF="moeen.asp?act=Show&accountID=<%=RSS2("id")%>&accountName=<%=Server.URLEncode(RSS2("Name"))%>&FromDate=<%=DateFrom%>&ToDate=<%=DateTo%>&ShowRemained=<%=MoeenShowRemained%>"><%=RSS2("Name")%></A></TD>
527			<TD dir=ltr align=right><%=Separate(totalDebit)%></TD>
528			<TD dir=ltr align=right><%=Separate(totalCredit)%></TD>
529			<TD dir=ltr align=right><%=Separate(debitRemained)%></TD>
530			<TD dir=ltr align=right><%=Separate(creditRemained)%></TD>
531		</TR>
532		  
533<% 
534	RSS2.moveNext
535	Loop
536
537	if SumDebitRemained > SumCreditRemained then
538		TotalSumDebitRemained = SumDebitRemained - SumCreditRemained 
539		TotalSumCreditRemained=0
540	else
541		TotalSumDebitRemained=0
542		TotalSumCreditRemained = SumCreditRemained - SumDebitRemained 
543	end if
544
545%>
546	<TR bgcolor="eeeeee" >
547		<TD colspan=6 height=2 bgcolor=0></TD>
548	</TR>
549	<TR bgcolor="eeeeee" >
550		<TD style="border-bottom:1 solid black;" colspan=2 align=left>��� �� ����� <%=replace(DateTo,"/",".")%></TD>
551		<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumDebit)%></TD>
552		<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumCredit)%></TD>
553		<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumDebitRemained)%></TD>
554		<TD style="border-bottom:1 solid black;" dir=ltr align=right><%=Separate(SumCreditRemained)%></TD>
555	</TR>
556	<TR bgcolor="eeeeee" >
557		<TD colspan=4 align=left>����� �� ��:</TD>
558		<TD dir=ltr align=right><%=Separate(TotalSumDebitRemained)%></TD>
559		<TD dir=ltr align=right><%=Separate(TotalSumCreditRemained)%></TD>
560	</TR>
561	</TABLE><br>
562<%
563end if
564%>
565<!--#include file="tah.asp" -->