PageRenderTime 19ms CodeModel.GetById 3ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/accounting/OtherReports.asp

http://github.com/khaneh/Orders
ASP | 1064 lines | 974 code | 57 blank | 33 comment | 65 complexity | 43802319e6b091a3b2a50d624293541a MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Accounting (8)
  3PageTitle="���� ����� ��"
  4SubmenuItem=10
  5if not Auth(8 , "E") then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<!--#include File="../include_UtilFunctions.asp"-->
 12<STYLE>
 13	.RepTable {font-family:tahoma; font-size:9pt; direction: RTL; }
 14	.RepTable td {border:1pt solid white;vertical-align:top;}
 15	.RepTable a {text-decoration:none; color:#222288;}
 16	.RepTable a:hover {text-decoration:underline;}
 17	.RepTable2 th {font-size:9pt; background-color:#666699;height:25px;}
 18	.RepTable2 input {font-family:tahoma; font-size:9pt; border:1 solid black;}
 19	.RepTR0 {background-color: #DDDDDD;}
 20	.RepTR1 {background-color: #FFFFFF;}
 21	.RepTableHeader {background-color: #BBBBFF; text-align: center; font-weight:bold;}
 22	.RepTDb {font-weight: bold;}
 23</STYLE>
 24<BR>
 25
 26<%
 27'-----------------------------------------------------------------------------------------------------
 28'----------------------------------------------------------------------------------------- Search Form
 29'-----------------------------------------------------------------------------------------------------
 30if request("act")="" then
 31%>
 32
 33<TABLE class="RepTable" align=center cellspacing=10>
 34<TR>
 35	<TD width="130">
 36		<FORM METHOD=POST ACTION="?act=MoeenRep">
 37		<table class="RepTable2" id="MoeenRep01">
 38			<tr>
 39			<th colspan="2">����� ����</td>
 40		</tr>
 41		<tr>
 42			<td align=left>����</td>
 43			<td><INPUT TYPE="text" NAME="GLAccount" style="width:50px;" maxlength=5></td>
 44		</tr>
 45		<tr>
 46			<td align=left>�� �����</td>
 47			<td><INPUT TYPE="text" NAME="FromDate" style="width:75px;direction:LTR;" maxlength=10 OnBlur="return acceptDate(this);"></td>
 48		</tr>
 49		<tr>
 50			<td align=left>�� �����</td>
 51			<td><INPUT TYPE="text" NAME="ToDate" style="width:75px;direction:LTR;" maxlength=10 OnBlur="return acceptDate(this);"></td>
 52		</tr>
 53		<tr>
 54			<td align=left>�� �����</td>
 55			<td><INPUT TYPE="text" NAME="FromTafsil" style="width:50px;" maxlength=6 value="0"></td>
 56		</tr>
 57		<tr>
 58			<td align=left>�� �����</td>
 59			<td><INPUT TYPE="text" NAME="ToTafsil" style="width:50px;" maxlength=6 value="999999">
 60				<INPUT TYPE="hidden" NAME="GL" value="<%=OpenGL%>">
 61			</td>
 62		</tr>
 63		</table>
 64		<div align=center>
 65		<% 	ReportLogRow = PrepareReport ("Receipt.rpt", "Recept_ID", Receipt, "/beta/dialog_printManager.asp?act=Fin") %>
 66		<INPUT Class="GenButton" TYPE="submit" name="action" value=" ����� ">
 67		<INPUT Class="GenButton" TYPE="submit" name="action" style="border:1 solid green;" value=" �ǁ ">
 68		</div>
 69		</FORM>
 70	</TD>
 71	<TD width="130" align=center>
 72	 &nbsp;
 73	 <A HREF="OtherReports_Tmp4Zamani.asp" style='font-weight:bold;'>����� ���� ��� ������� �� ����� ���� �� ����� ��� 82</A>
 74	</TD>
 75</TR>
 76<TR>
 77	<TD width="130">
 78	<%
 79	if Auth(8 , "G") then
 80	%>
 81		<FORM METHOD=POST ACTION="?act=cash">
 82			<table class="RepTable2">
 83				<tr>
 84					<th colspan="2">������ ����������</td>
 85				</tr>
 86				
 87			</table>		
 88			 <div align="center">
 89			 	
 90				 	<INPUT Class="GenButton" TYPE="submit" name="action" value=" ����� ">
 91				
 92			 </div>
 93	 	</form>
 94	 <%end if%>
 95	</TD>
 96	<TD>
 97	 <%
 98	 if Auth(8,"G") then 
 99	 	set rs=Conn.Execute ("select * from gls where id="&openGL)
100	 	if not rs.eof then 
101	 		startDate=rs("startDate")
102	 		if shamsiToday()>rs("endDate") then 
103	 			endDate=rs("endDate")
104	 		else
105	 			endDate=shamsiToday()
106	 		end if
107	 	end if
108	 %>
109	 	<form method="post" action="?act=finState">
110	 		<table class="RepTable2">
111	 			<tr>
112	 				<th colspan="2">���ʝ��� ����</th>
113	 			<tr>
114					<td align=left>�� �����</td>
115					<td><INPUT TYPE="text" NAME="FromDate" value="<%=startDate%>" style="width:75px;direction:LTR;" maxlength=10 OnBlur="return acceptDate(this);"></td>
116				</tr>
117				<tr>
118					<td align=left>�� �����</td>
119					<td><INPUT TYPE="text" NAME="ToDate" value="<%=endDate%>" style="width:75px;direction:LTR;" maxlength=10 OnBlur="return acceptDate(this);"></td>
120				</tr>
121	 				<td colspan="2">
122	 					<input name="rep" type="submit" value="��� � ����">
123	 					<input name="rep" type="submit" value="���� ����">
124	 					<input name="rep" type="submit" value="���� ���� ���">
125	 				</td>
126	 			</tr>
127	 		</table>
128	 	</form>
129	 <%
130	 end if
131	 %>
132	</TD>
133</TR>
134<TR>
135	<TD width="130">
136	<%
137	if Auth(8,"G") then 
138	%>
139		<table class="RepTable2">
140			<tr>
141				<td colspan="2">����� ����� �����</td>
142			</tr>
143			<tr>
144				<td><a href="otherReports.asp?act=sepPay">����� ��������</a></td>
145				<td><a href="otherReports.asp?act=sepRec">����� ��������</a></td>
146			</tr>
147		</table>
148	<%	
149	end if
150	%>
151	</td>
152	<td></td>
153</TABLE>
154<%
155'-----------------------------------------------------------------------------------------------------
156'-----------------------------------------------------------------------------------------------------
157'-----------------------------------------------------------------------------------------------------
158elseif request("act")="sepPay" or request("act")="sepRec" then 
159	if request("act")="sepPay" then 
160		mySQL="select g42.*, case when g41.glAccount=41001 then N'�����' else N'��� �����' end as state from EffectiveGLRows as g42 inner join EffectiveGLRows as g41 on g41.glDoc=g42.glDoc and g41.sys=g42.sys and g41.link=g42.link where g42.GL=" & openGL & " and g42.glAccount between 42000 and 42999 and g41.glAccount between 41000 and 41999"
161	else
162		mySQL="select g17.*, case when g13.glAccount=13003 then N'�����' else N'��� �����' end as state from EffectiveGLRows as g17 inner join EffectiveGLRows as g13 on g17.glDoc=g13.glDoc and g17.sys=g13.sys and g17.link=g13.link where g17.GL=" & openGL & " and g17.glAccount between 17000 and 17999 and g17.ref1<>'' and not g13.glAccount between 17000 and 17999 "
163	end if
164	set rs=Conn.Execute(mySQL)
165%>
166<table class="RepTable">
167	<tr class="RepTableHeader">
168		<th>����� ���</th>
169		<th>����� ���</th>
170		<th>����</th>
171		<th>����</th>
172		<th>���</th>
173		<th>����� ��</th>
174		<th>����� ��</th>
175		<th>�����</th>
176	</tr>
177<%
178	rowColor="RepTR0"
179	while not rs.eof
180		theLink = "ShowItem.asp?sys=" & rs("sys") & "&Item=" & rs("Link")
181		if rowColor="RepTR0" then 
182			rowColor="RepTR1"
183		else
184			rowColor="RepTR0"
185		end if
186	%>
187	<tr class="<%=rowColor%>">
188		<td style="cursor:hand;" title="���� ����� ��� �������� ������ ���� ����." onclick="window.open('GLMemoDocShow.asp?id=<%=rs("glDoc")%>');"><%=rs("glDocID")%></td>
189		<td><%=rs("glDocDate")%></td>
190		<td><%=rs("glAccount")%></td>
191		<td><%=Separate(rs("amount"))%></td>
192		<td style="cursor:hand;" title="���� ����� ��� ��� ����� ������ ���� ����." onclick="window.open('<%=theLink%>');"><%=rs("description")%></td>
193		<td style="cursor:hand;" title="���� ����� �� ������ ���� ����." onclick="window.open('../bank/CheqBook.asp?act=findCheq&cheque=<%=rs("ref1")%>&amount=<%=rs("amount")%>');"><%=rs("ref1")%></td>
194		<td><%=rs("ref2")%></td>
195		<td><%=rs("state")%></td>
196
197	</tr>
198	<%
199		rs.moveNext
200	wend
201%>
202</table>
203<%
204'-----------------------------------------------------------------------------------------------------
205'-----------------------------------------------------------------------------------------------------
206'-----------------------------------------------------------------------------------------------------
207elseif request("act")="finState" then
208	fromDate=request("fromDate")
209	toDate=request("toDate")
210	function getRem(v,t)
211		if t="group" then 
212			mySQL="select isnull(sum(effectiveGlRows.Amount*2*(cast(effectiveGlRows.IsCredit as int)-.5)),0) as amount from effectiveGlRows inner join glAccounts on effectiveGlRows.glAccount=glAccounts.id and effectiveGlRows.gl=glAccounts.gl where effectiveGlRows.gl=" & OpenGL & " and glAccounts.GLGroup=" & v & " and effectiveGLRows.glDocDate between '" & fromDate & "' and '" & toDate & "'"
213		elseif t="super" then 
214			mySQL="select isnull(sum(effectiveGlRows.Amount*2*(cast(effectiveGlRows.IsCredit as int)-.5)),0) as amount from effectiveGlRows inner join glAccounts on effectiveGlRows.glAccount=glAccounts.id and effectiveGlRows.gl=glAccounts.gl inner join GLAccountGroups on glAccounts.GLGroup=GLAccountGroups.ID and GLAccountGroups.gl=glAccounts.gl where effectiveGlRows.gl=" & OpenGL & " and GLAccountGroups.GLSuperGroup=" & v & " and effectiveGLRows.glDocDate between '" & fromDate & "' and '" & toDate & "'"
215		end if
216		set rs=Conn.Execute(mySQL)
217		if not rs.eof then 
218			getRem = CDbl(rs("amount"))
219		else
220			getRem = "���"
221		end if
222	end function
223	if request("rep")="��� � ����" then
224		sales = getRem(91000,"group")
225		cogs = abs(getRem(30000,"super"))
226		grossProfit = sales - cogs
227		cgA = abs(getRem(62000,"group")+getRem(63000,"group")+getRem(68000,"group")+getRem(69000,"group"))
228		rANDd = 0
229		other = 0
230		Interest = abs(getRem(61000,"group"))
231		netProfit = grossProfit - cgA - rANDd - other - interest
232		tax = 0
233		Depreciation = 0
234		EBITDA = netProfit + interest + tax + depreciation
235%>
236<table class="RepTable">
237	<tr>
238		<th>��������</th>
239		<th>�� <%=fromDate%> ��� <%=toDate%></th>
240	</tr>
241	<tr>
242		<td> ���ԝ ����</td>
243		<td><%=Separate(sales)%></td>
244	</tr>
245	<tr>
246		<td> ����� ��������� ������ ���ԝ�����</td>
247		<td><%=Separate(cogs)%></td>
248	</tr>
249	<tr>
250		<td>��� (�����) ������</td>
251		<td><%=Separate(grossProfit)%></td>
252	</tr>
253	<tr>
254		<td> ���ԝ� ������ � ������</td>
255		<td><%=Separate(cgA)%></td>
256	</tr>
257	<tr>
258		<td>����� � �����</td>
259		<td><%=Separate(rANDd)%></td>
260	</tr>
261	<tr>
262		<td>����� (�����) ����</td>
263		<td><%=Separate(interest)%></td>
264	</tr>
265	<tr>
266		<td>���� (������ ���� ��� ���)</td>
267		<td><%=Separate(other)%></td>
268	</tr>
269	<tr>
270		<td>��� (�����) ���՝</td>
271		<td><%=Separate(netProfit)%></td>
272	</tr>
273	<tr>
274		<td>��������� ����</td>
275		<td><%=Separate(interest)%></td>
276	</tr>
277	<tr>
278		<td>������</td>
279		<td><%=Separate(tax)%></td>
280	</tr>
281	<tr>
282		<td>�������</td>
283		<td><%=Separate(depreciation)%></td>
284	</tr>
285	<tr>
286		<td>������</td>
287		<td><%=Separate(EBITDA)%></td>
288	</tr>
289</table>
290<%	
291	elseif request("rep")="���� ����" then
292		'mySQL="select sum(g42.amount) as amount from EffectiveGLRows as g42 inner join EffectiveGLRows as g41 on g41.glDoc=g42.glDoc and g41.sys=g42.sys and g41.link=g42.link where g42.GL=" & openGL & " and g42.glAccount between 42000 and 42999 and g41.glAccount between 41000 and 41999 and g42.isCredit=1 and g41.glAccount=41001"
293		mySQL="select isnull(sum(amount),0) as amount from (select sum(amount)/count(id) as amount from EffectiveGLRows inner join (select g42.ref1,g42.ref2 from EffectiveGLRows as g42 inner join EffectiveGLRows as g41 on g41.glDoc=g42.glDoc and g41.sys=g42.sys and g41.link=g42.link where g42.GL=" & openGL & " and g42.glAccount between 42000 and 42999 and g41.glAccount between 41000 and 41999 and g42.isCredit=1 and g41.glAccount=41001 and g42.ref1<>'' and g42.glDocDate between '" & fromDate & "' and '" & toDate & "') as drv on EffectiveGLRows.Ref1=drv.ref1 and EffectiveGLRows.ref2=drv.ref2 where EffectiveGLRows.gl=" & openGL & " and glAccount between 42000 and 42999 and glDocDate between '" & fromDate & "' and '" & toDate & "' group by GLAccount, Tafsil, Amount,EffectiveGLRows.ref1,EffectiveGLRows.ref2 having count(EffectiveGLRows.ref1) % 2 =1) as d"
294		rs=conn.Execute(mySQL)
295		accountsPayableTej = cdbl(rs("amount"))
296		'mySQL="select sum(g42.amount) as amount from EffectiveGLRows as g42 inner join EffectiveGLRows as g41 on g41.glDoc=g42.glDoc and g41.sys=g42.sys and g41.link=g42.link where g42.GL=" & openGL & " and g42.glAccount between 42000 and 42999 and g41.glAccount between 41000 and 41999 and g42.isCredit=1 and g41.glAccount<>41001"
297		mySQL="select isnull(sum(amount),0) as amount from (select sum(amount)/count(id) as amount from EffectiveGLRows inner join (select g42.ref1,g42.ref2 from EffectiveGLRows as g42 inner join EffectiveGLRows as g41 on g41.glDoc=g42.glDoc and g41.sys=g42.sys and g41.link=g42.link where g42.GL=" & openGL & " and g42.glAccount between 42000 and 42999 and g41.glAccount between 41000 and 41999 and g42.isCredit=1 and g41.glAccount<>41001 and g42.ref1<>'' and g42.glDocDate between '" & fromDate & "' and '" & toDate & "') as drv on EffectiveGLRows.Ref1=drv.ref1 and EffectiveGLRows.ref2=drv.ref2 where EffectiveGLRows.gl=" & openGL & " and glAccount between 42000 and 42999 and glDocDate between '" & fromDate & "' and '" & toDate & "' group by GLAccount, Tafsil, Amount,EffectiveGLRows.ref1,EffectiveGLRows.ref2 having count(EffectiveGLRows.ref1) % 2 =1) as d"
298		rs=conn.Execute(mySQL)
299		accountsPayableNonTej = cdbl(rs("amount"))
300		'mySQL="select sum(g17.amount) as amount from EffectiveGLRows as g17 inner join EffectiveGLRows as g13 on g17.glDoc=g13.glDoc and g17.sys=g13.sys and g17.link=g13.link where g17.GL=" & openGL & " and g17.glAccount between 17000 and 17999 and g17.ref1<>'' and not g13.glAccount between 17000 and 17999 and g17.isCredit=0 and g13.glAccount <> 13003"
301		mySQL="select isnull(sum(amount),0) as amount from (select sum(amount)/count(id) as amount from EffectiveGLRows inner join (select g17.ref1,g17.ref2 from EffectiveGLRows as g17 inner join EffectiveGLRows as g13 on g17.glDoc=g13.glDoc and g17.sys=g13.sys and g17.link=g13.link where g17.GL=" & openGL & " and g17.glAccount between 17000 and 17999 and g17.ref1<>'' and not g13.glAccount between 17000 and 17999 and g17.isCredit=0 and g13.glAccount <> 13003 and g17.glDocDate between '" & fromDate & "' and '" & toDate & "') as drv on EffectiveGLRows.Ref1=drv.ref1 and EffectiveGLRows.ref2=drv.ref2 where EffectiveGLRows.gl=" & openGL & " and glAccount between 17000 and 17999 and glDocDate between '" & fromDate & "' and '" & toDate & "' group by GLAccount, Tafsil, Amount,EffectiveGLRows.ref1,EffectiveGLRows.ref2 having count(EffectiveGLRows.ref1) % 2 =1) as d"
302		rs=conn.Execute(mySQL) 
303		accountsReceviableNonTej = cdbl(rs("amount"))
304		'mySQL="select sum(g17.amount) as amount from EffectiveGLRows as g17 inner join EffectiveGLRows as g13 on g17.glDoc=g13.glDoc and g17.sys=g13.sys and g17.link=g13.link where g17.GL=" & openGL & " and g17.glAccount between 17000 and 17999 and g17.ref1<>'' and not g13.glAccount=13003 and g17.isCredit=0"
305		mySQL="select isnull(sum(amount),0) as amount from (select sum(amount)/count(id) as amount from EffectiveGLRows inner join (select g17.ref1,g17.ref2 from EffectiveGLRows as g17 inner join EffectiveGLRows as g13 on g17.glDoc=g13.glDoc and g17.sys=g13.sys and g17.link=g13.link where g17.GL=" & openGL & " and g17.glAccount between 17000 and 17999 and g17.ref1<>'' and not g13.glAccount=13003 and g17.isCredit=0 and g17.glDocDate between '" & fromDate & "' and '" & toDate & "') as drv on EffectiveGLRows.Ref1=drv.ref1 and EffectiveGLRows.ref2=drv.ref2 where EffectiveGLRows.gl=" & openGL & " and glAccount between 17000 and 17999 and glDocDate between '" & fromDate & "' and '" & toDate & "' group by GLAccount, Tafsil, Amount,EffectiveGLRows.ref1,EffectiveGLRows.ref2 having count(EffectiveGLRows.ref1) % 2 =1) as d"
306		rs=conn.Execute(mySQL)
307		accountsReceviableTej = cdbl(rs("amount"))
308		
309		cash=abs(getRem(11000,"group")) + abs(getRem(12000,"group"))
310		'accountsReceviable = abs(getRem(13000,"group")) + abs(getRem(15000,"group")) + abs(getRem(17000,"group")) + abs(getRem(18000,"group"))
311		inventory = abs(getRem(14000,"group"))
312		orders = abs(getRem(16000,"group"))
313		plant = abs(getRem(26000,"group"))-abs(getRem(26100,"group"))
314		properties = abs(getRem(27000,"group"))-abs(getRem(27100,"group"))
315		otherAsset = abs(getRem(29000,"group"))
316		totalAsset = cash + accountsReceviableTej + accountsReceviableNonTej + inventory + orders + plant + properties + otherAsset
317		'accountsPayable = abs(getRem(41000,"group"))+abs(getRem(42000,"group"))
318		bankDebit = abs(getRem(46000,"group"))
319		personsDebit = abs(getRem(44000,"group"))
320		otherDebit =  abs(getRem(43000,"group")) + abs(getRem(45000,"group")) + abs(getRem(47000,"group")) + abs(getRem(49000,"group")) + abs(getRem(71000,"group"))
321		totalDebit = accountsPayableTej + accountsPayableNonTej + bankDebit + personsDebit + otherDebit
322		equity = abs(getRem(50100,"group"))
323		retainedEarnings = getRem(51000,"group") + getRem(52000,"group") + getRem(53000,"group") + getRem(54000,"group") + getRem(55000,"group") + getRem(59000,"group")
324		periodEarnings = 0
325		totalLiabilities = totalDebit + equity + retainedEarnings
326%>
327<table class="RepTable">
328	<tr>
329		<th>��������</th>
330		<th><%=toDate%></th>
331	</tr>
332	<tr>
333		<td>������� ���</td>
334		<td><%=Separate(cash)%></td>
335	</tr>
336	<tr>
337		<td>������ � ����� ��������� ������</td>
338		<td><%=Separate(accountsReceviableTej)%></td>
339	</tr>
340	<tr>
341		<td>������ � ����� ��������� ��� �����</td>
342		<td><%=Separate(accountsReceviableNonTej)%></td>
343	</tr>
344	<tr>
345		<td>������ ����� ���� ����� � ����� ����� ���</td>
346		<td><%=Separate(inventory)%></td>
347	</tr>
348	<tr>
349		<td>������� � ��� ��������</td>
350		<td><%=Separate(orders)%></td>
351	</tr>
352	<tr>
353		<td>���������� ���ʝ �����</td>
354		<td><%=Separate(plant)%></td>
355	</tr>
356	<tr>
357		<td>���������� �� �����</td>
358		<td><%=Separate(properties)%></td>
359	</tr>
360	<tr>
361		<td>��� ����� ��� ��� �����</td>
362		<td><%=Separate(otherAsset)%></td>
363	</tr>
364	<tr>
365		<td class="RepTDb">��ڝ ��������</td>
366		<td><%=Separate(totalAsset)%></td>
367	</tr>
368	<tr>
369		<td>������ � ����� ��������� ������</td>
370		<td><%=Separate(accountsPayableTej)%></td>
371	</tr>
372	<tr>
373		<td>������ � ����� ��������� ��� ������</td>
374		<td><%=Separate(accountsPayableNonTej)%></td>
375	</tr>
376	<tr>
377		<td>������ʝ ���� �����</td>
378		<td><%=Separate(bankDebit)%></td>
379	</tr>
380	<tr>
381		<td>������� ���� �����</td>
382		<td><%=Separate(personsDebit)%></td>
383	</tr>
384	<tr>
385		<td>���� ������� (������ ���� ��� ���(</td>
386		<td><%=Separate(otherDebit)%></td>
387	</tr>
388	<tr>
389		<td class="RepTDb">��ڝ ������</td>
390		<td><%=Separate(totalDebit)%></td>
391	</tr>
392	<tr>
393		<td>�������</td>
394		<td><%=Separate(equity)%></td>
395	</tr>
396	<tr>
397		<td>�������� ( ��� (�����</td>
398		<td><%=Separate(retainedEarnings)%></td>
399	</tr>
400	<tr>
401		<td>���� � ���� ���� ����</td>
402		<td></td>
403	</tr>
404	<tr>
405		<td class="RepTDb">���ڝ ������ � ���ޝ ������� �����</td>
406		<td><%=Separate(totalLiabilities)%></td>
407	</tr>
408</table>
409<%
410	elseif request("rep")="���� ���� ���" then 
411		response.write "���� ����� ����"
412	end if
413'-----------------------------------------------------------------------------------------------------
414'-----------------------------------------------------------------------------------------------------
415'-----------------------------------------------------------------------------------------------------
416elseif request("act")="cash" then 
417	myMonth = replace(request("month"),"-","/")
418	dim fmonth(12)
419	fmonth(0)="�������"
420	fmonth(1)="��������"
421	fmonth(2)="�����"
422	fmonth(3)="���"
423	fmonth(4)="�����"
424	fmonth(5)="������"
425	fmonth(6)="���"
426	fmonth(7)="����"
427	fmonth(8)="���"
428	fmonth(9)="��"
429	fmonth(10)="����"
430	fmonth(11)="�����"
431	
432	'----------------------------------------------------------------------------------------
433	
434	function echoTD(num,sys)
435		result="<td style=""direction: ltr;text-align: right;color:"
436		if num<0 then 
437			result = result & "red"
438		else
439			reslt = result & "black"
440		end if
441		result = result & ";"">" 
442		select case sys
443		case "ar" ' ----------- AR Items
444			result = result & "<a target=�_blank� href=""../AR/rep_dailySale.asp?input_date_start="
445			if EffectiveDate<>"old" then 
446				result = result & Server.URLEncode(EffectiveDate&"01")&"&input_date_end=" & Server.URLEncode(EffectiveDate&"31")&"&fullyApplied=on"" >" 
447			else
448				result = result & Server.URLEncode("0000/00/00")&"&input_date_end=" & Server.URLEncode("1388/01/01") &"&fullyApplied=on"">" 
449			end if
450		case "ap" '------------ AP Items
451			result = result & "<a target=�_blank� href=""../AP/report.asp?fromDate="
452			if EffectiveDate<>"old" then 
453				if myMonth<>"" then 
454					result = result & Server.URLEncode(EffectiveDate)&"&toDate=" & Server.URLEncode(EffectiveDate)
455				else
456					result = result & Server.URLEncode(EffectiveDate&"01")&"&toDate=" & Server.URLEncode(EffectiveDate&"31")
457				end if
458			else
459				result = result & Server.URLEncode(shamsiDate(DateAdd("m",-10,Date)))&"&toDate=" & Server.URLEncode(mid(shamsiDate(DateAdd("m",-6,Date)),1,8)) & "31" 
460			end if
461			result = result & "&submit=" & Server.URLEncode("������") & """>"
462		case "ar-full"
463			result = result & "<a target=�_blank� href=""../AR/rep_dailySale.asp?input_date_start="
464			if EffectiveDate<>"old" then 
465				result = result & Server.URLEncode(EffectiveDate&"01")&"&input_date_end=" & Server.URLEncode(EffectiveDate&"31")&"&fullyApplied="" >" 
466			else
467				result = result & Server.URLEncode("0000/00/00")&"&input_date_end=" & Server.URLEncode("1388/01/01") &"&fullyApplied="">" 
468			end if
469		case "ap-full"
470			result = result & "<a target=�_blank� href=""../AP/report.asp?fromDate="
471			if EffectiveDate<>"old" then
472				if myMonth<>"" then 
473					result = result & Server.URLEncode(EffectiveDate)&"&toDate=" & Server.URLEncode(EffectiveDate)
474				else 
475					result = result & Server.URLEncode(EffectiveDate&"01")&"&toDate=" & Server.URLEncode(EffectiveDate&"31") 
476				end if
477			else
478				result = result & Server.URLEncode(shamsiDate(DateAdd("m",-10,Date)))&"&toDate=" & Server.URLEncode(mid(shamsiDate(DateAdd("m",-6,Date)),1,8)) & "31"  
479			end if
480			result = result & "&submit=" & Server.URLEncode("������") & """>"
481		case "cash"
482			if myMonth<>"" then 
483				result = result & "<a target=�_blank� href=""AccountInfo.asp?act=account&id=11000&fromDate=" & Server.URLEncode(ref2) & "&DateTo=" & Server.URLEncode(ref2) & """>"
484			else
485				result = result & "<a target=�_blank� href=""AccountInfo.asp?act=account&id=11000&fromDate=" & Server.URLEncode(ref2&"01") & "&DateTo=" & Server.URLEncode(ref2&"31") & """>"
486			end if
487		case "bnk"
488			if myMonth<>"" then 
489				result = result & "<a target=�_blank� href=""AccountInfo.asp?act=account&id=12000&fromDate=" & Server.URLEncode(ref2) & "&DateTo=" & Server.URLEncode(ref2) & """>"
490			else
491				result = result & "<a target=�_blank� href=""AccountInfo.asp?act=account&id=12000&fromDate=" & Server.URLEncode(ref2&"01") & "&DateTo=" & Server.URLEncode(ref2&"31") & """>"
492			end if
493		case else
494			if mid(sys,1,4)="bank" then 
495				if myMonth<>"" then 
496					result = result & "<a  target=�_blank� href=""../bank/CheqBook.asp?act=showBook&GLAccount=" & mid(sys,5,5) & "&FromDate="
497					result = result & Server.URLEncode(Ref2)&"&ToDate=" & Server.URLEncode(Ref2)&"&ShowRemained=&displayMode=0"">" 		
498				else
499					result = result & "<a target=�_blank� href=""../bank/CheqBook.asp?act=showBook&GLAccount=" & mid(sys,5,5) & "&FromDate="
500					result = result & Server.URLEncode(Ref2&"01")&"&ToDate=" & Server.URLEncode(Ref2&"31")&"&ShowRemained=&displayMode=0"">" 
501				end if
502			end if
503		end select
504		result = result & Separate(num) 
505		if sys="ar" or sys="ar-full" or sys="ap" or sys="ap-full" or sys="cash" or sys="bnk" then result = result & "</a>"
506		result = result & "</td>"
507		echoTD = result
508	end function
509	today = shamsiToday()
510	if myMonth<>"" then 
511		mySQL="select * from (select sum(amount) as amount,ref2,glAccount from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=17003 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv17003 group by Ref2,glAccount union select sum(amount) as amount,ref2,glAccount from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=17004 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv17004 group by Ref2,glAccount union select sum(amount) as amount,ref2,glAccount from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=17016 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv17016 group by Ref2,glAccount union select sum(amount) as amount,ref2,glAccount from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42001 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42001 group by Ref2,glAccount union select sum(amount) as amount,ref2,glAccount from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42002 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42002 group by Ref2,glAccount union select sum(amount) as amount,ref2,glAccount from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42004 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42004 group by Ref2,glAccount union select sum(amount) as amount,ref2,glAccount from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42011 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42011 group by Ref2,glAccount union select sum(Amount) as Amount, GLDocDate collate SQL_Latin1_General_CP1_CI_AS as ref2,11000 as GLAccount from EffectiveGLRows where gl=" & OpenGL & " and SUBSTRING(GLDocDate,1,8)='" & myMonth & "' and isCredit=0 and glAccount in (11004,11005,11006,11007) group by GLDocDate union select sum(2*(.5-cast(isCredit as int))*amount) as amount, d.ref2 collate SQL_Latin1_General_CP1_CI_AS as ref2,12000 as GLAccount from EffectiveGLRows inner join (select GLDocDate as ref2 from EffectiveGLRows where GL=" & OpenGL & " and glAccount between 12000 and 12999 and  SUBSTRING(GLDocDate,1,8)='" & myMonth & "' group by GLDocDate) d on GLDocDate<=d.ref2 where GL=" & OpenGL & " and glAccount between 12000 and 12999 group by d.ref2 union select isnull(d17.amount,0)-isnull(d42.amount,0) as Amount,isnull(d42.ref2,d17.ref2) as ref2, 1742 as glAccount from (select sum(amount) as amount,ref2 from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount in (42001,42002,42004,42011) and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' and Ref2>'" & today & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42 group by Ref2)as d42 full outer join (select sum(amount) as amount,ref2 from (select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount in (17003,17004,17016) and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' and Ref2>'" & today & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv17 group by Ref2) as d17 on d42.ref2=d17.ref2) dev order by Ref2,GLAccount"
512		
513		'"select * from (select Amount,Ref2,ref1,GLAccount,max(description) as description from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=17003 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) union select Amount,Ref2,ref1,GLAccount,max(description) as description from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=17004 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) union select Amount,Ref2,ref1,GLAccount,max(description) as description from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42001 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) union select Amount,Ref2,ref1,GLAccount,max(description) as description from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42004 and Ref1<>'' and SUBSTRING(Ref2,1,8)='" & myMonth & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) dev order by Ref2,GLAccount"
514	else
515		mySQL="select * from (select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2,GLAccount from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=17003 and Ref1<>'' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv17003 group by SUBSTRING(Ref2,1,8),GLAccount union select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2,GLAccount from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=17004 and Ref1<>'' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv17004 group by SUBSTRING(Ref2,1,8),GLAccount union select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2,GLAccount from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=17016 and Ref1<>'' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv17016 group by SUBSTRING(Ref2,1,8),GLAccount union select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2,GLAccount from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42001 and Ref1<>'' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42001 group by SUBSTRING(Ref2,1,8),GLAccount union select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2,GLAccount from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42002 and Ref1<>'' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42002 group by SUBSTRING(Ref2,1,8),GLAccount union select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2,GLAccount from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42004 and Ref1<>'' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42004 group by SUBSTRING(Ref2,1,8),GLAccount union select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2,GLAccount from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount=42011 and Ref1<>'' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42011 group by SUBSTRING(Ref2,1,8),GLAccount union select sum(Amount) as Amount, SUBSTRING(GLDocDate,1,8) collate SQL_Latin1_General_CP1_CI_AS as ref2,11000 as GLAccount from EffectiveGLRows where gl=" & OpenGL & " and isCredit=0 and glAccount in (11004,11005,11006,11007) group by SUBSTRING(GLDocDate,1,8) union select sum(2*(.5-cast(isCredit as int))*amount) as amount, d.ref2,12000 as GLAccount from EffectiveGLRows inner join (select SUBSTRING(GLDocDate,1,8) collate SQL_Latin1_General_CP1_CI_AS as ref2 from EffectiveGLRows where GL=" & OpenGL & " and glAccount between 12000 and 12999 group by SUBSTRING(GLDocDate,1,8)) d on GLDocDate<d.ref2+'32' where GL=" & OpenGL & " and glAccount between 12000 and 12999 group by d.ref2 union select isnull(d17.amount,0)-isnull(d42.amount,0) as Amount,isnull(d42.ref2,d17.ref2) as ref2, 1742 as glAccount from (select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2 from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount in (42001,42002,42004,42011) and Ref1<>'' and Ref2>'" & today & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42011 group by SUBSTRING(Ref2,1,8)) as d42 full outer join (select sum(Amount) as Amount, SUBSTRING(Ref2,1,8) as Ref2 from ( select Amount,Ref2,GLAccount from EffectiveGLRows where GL=" & OpenGL & " and GLAccount in (17003,17004,17016) and Ref1<>'' and Ref2>'" & today & "' group by GLAccount, Tafsil, Amount, Ref1, Ref2, GL HAVING (COUNT(Ref1) % 2 = 1) ) drv42011 group by SUBSTRING(Ref2,1,8)) as d17 on d42.ref2=d17.ref2) drv order by Ref2,GLAccount"
516	end if
517	'response.write mySQL
518	set rs=Conn.Execute(mySQL)
519	amount12000=0
520	amount1742=0
521		'Conn.Close
522		'response.redirect "?errMsg=" & Server.URLEncode("���� ����! ���� ���� ���")
523	
524	sub setValue()
525		select case rs("GLAccount")
526			case "17003":
527				amount17003 = CDbl(rs("Amount"))
528			case "17004":
529				amount17004 = CDbl(rs("Amount"))
530			case "17016":
531				amount17016 = CDbl(rs("Amount"))
532			case "42001":
533				amount42001 = CDbl(rs("Amount"))
534			case "42002":
535				amount42002 = CDbl(rs("Amount"))
536			case "42004":
537				amount42004 = CDbl(rs("Amount"))
538			case "42011":
539				amount42011 = CDbl(rs("Amount"))	
540			case "11000":
541				amount11000 = CDbl(rs("Amount"))
542			case "12000":
543				amount12000 = CDbl(rs("Amount"))	
544			case "1742":
545				amount1742 = amount1742 + CDbl(rs("Amount"))
546		end select
547		
548		rs.MoveNext
549		if not rs.eof then 
550			if ref2=rs("Ref2") then
551				ref2=rs("Ref2")
552				call setValue()
553			end if
554		end if
555	end sub
556	If not rs.EOF then
557	%>
558	<table>
559		<tr class="RepTableHeader">
560			<td rowspan="2" colspan="2">&nbsp;</td>
561			<td colspan="3">�� ����� ����</td>
562			<td rowspan="2">��� �� �����</td>
563			<td colspan="4">����� ��������</td>
564			<td rowspan="2">��� ����� ��������</td>
565			<td rowspan="2">���� ��</td>
566			<td rowspan="2">�����</td>
567			<td rowspan="2">���� ���</td>
568			<td rowspan="2">���� ��ԝ����</td>
569		</tr>
570		<tr class="RepTableHeader">
571			<td>17003</td>
572			<td>17004</td>
573			<td>17016</td>
574			<td>42001</td>
575			<td>42002</td>
576			<td>42004</td>
577			<td>42011</td>
578		</tr>
579		<%
580		rowColor="RepTR0"
581		do while not rs.eof
582			ref2=rs("Ref2")
583			if rowColor="RepTR0" then 
584				rowColor="RepTR1"
585			else
586				rowColor="RepTR0"
587			end if
588		%>
589		<tr class="<%=rowColor%>">
590			<%
591				yyyy=mid(ref2,1,4)
592				if myMonth<>"" then 
593					mm=ref2
594				else
595					mm=fmonth(cint(mid(ref2,6,2))-1)
596				end if
597				amount17003=0
598				amount17004=0
599				amount17016=0
600				amount42001=0
601				amount42002=0
602				amount42004=0
603				amount42011=0
604				amount11000=0
605				
606				call setValue()
607			%>
608			<td title="<%=ref2%>"><%=yyyy%></td>
609				<%if myMonth<>"" then%>
610			<td><%=mm%></td>
611				<%else%>
612			<td title='���� ������ ������ ���� ����'><a href="otherReports.asp?act=cash&month=<%=replace(mid(ref2,1,8),"/","-")%>"><%=mm%></a></td>
613			<%
614				end if
615				response.write echoTD(amount17003,"bank17003")
616				response.write echoTD(amount17004,"bank17004")
617				response.write echoTD(amount17016,"bank17016")
618				response.write echoTD(amount17003+amount17004+amount17016,"")
619				response.write echoTD(amount42001,"bank42001")
620				response.write echoTD(amount42002,"bank42002")
621				response.write echoTD(amount42004,"bank42004")
622				response.write echoTD(amount42011,"bank42011")
623				response.write echoTD(amount42001+amount42002+amount42004+amount42011,"")
624				response.write echoTD(amount17003+amount17004+amount17016-(amount42001+amount42002+amount42004+amount42011),"")
625				response.write echoTD(amount11000,"cash")
626				response.write echoTD(amount12000+amount1742,"bnk")
627				if amount1742<>0 then 
628					response.write echoTD(amount12000+amount1742,"")
629				else
630					response.write echoTD(amount12000+amount17003+amount17004+amount17016-(amount42001+amount42002+amount42004+amount42011),"")
631				end if
632			%>
633			
634		</tr>
635		<%
636		loop
637	%>
638</table>
639<%
640	end if
641	if myMonth<>"" then 
642		mySQL="select * from (select RemainedAmount, EffectiveDate, 'ar' as sys from ARItems where FullyApplied=0 and Voided=0 and ARItems.Type=1 and SUBSTRING(EffectiveDate,1,8)='" & myMonth & "' UNION select RemainedAmount, Vouchers.EffectiveDate, 'ap' as sys from APItems inner join Vouchers on apItems.link=Vouchers.id where FullyApplied=0 and apItems.Voided=0 and APItems.Type=6 and SUBSTRING(Vouchers.EffectiveDate,1,8)='" & myMonth & "' UNION select amountOriginal as RemainedAmount, EffectiveDate, 'ar-full' as sys from ARItems where  Voided=0 and ARItems.Type=1 and SUBSTRING(EffectiveDate,1,8)='" & myMonth & "' UNION select amountOriginal as RemainedAmount, EffectiveDate, 'ap-full' as sys from APItems where Voided=0 and APItems.Type=6 and SUBSTRING(EffectiveDate,1,8)='" & myMonth & "' ) dev order by EffectiveDate,sys"
643	else
644		mySQL="select * from (select sum(RemainedAmount) as RemainedAmount, SUBSTRING(EffectiveDate,1,8) as EffectiveDate, 'ar' as sys from ARItems where FullyApplied=0 and Voided=0 and ARItems.Type=1 and EffectiveDate>='1388/01/01' group by SUBSTRING(EffectiveDate,1,8) UNION select sum(RemainedAmount) as RemainedAmount, SUBSTRING(Vouchers.EffectiveDate,1,8) as EffectiveDate, 'ap' as sys from APItems inner join Vouchers on apItems.link=Vouchers.id where FullyApplied=0 and apItems.Voided=0 and APItems.Type=6 and Vouchers.EffectiveDate>='1388/01/01' group by SUBSTRING(Vouchers.EffectiveDate,1,8) UNION select sum(amountOriginal) as RemainedAmount, SUBSTRING(EffectiveDate,1,8) as EffectiveDate, 'ar-full' as sys from ARItems where  Voided=0 and ARItems.Type=1 and EffectiveDate>='1388/01/01' group by SUBSTRING(EffectiveDate,1,8) UNION select sum(amountOriginal) as RemainedAmount, SUBSTRING(EffectiveDate,1,8) as EffectiveDate, 'ap-full' as sys from APItems where Voided=0 and APItems.Type=6 and EffectiveDate>='1388/01/01' group by SUBSTRING(EffectiveDate,1,8)) dev order by EffectiveDate,sys"
645	end if
646	mySQLold="select sum(RemainedAmount) as RemainedAmount,'old' as EffectiveDate,'ar' as sys from ARItems where FullyApplied=0 and Voided=0 and ARItems.Type=1 and EffectiveDate<'1388/01/01' UNION select sum(RemainedAmount) as RemainedAmount, 'old' as EffectiveDate,'ap' as sys from APItems inner join Vouchers on apItems.link=Vouchers.id where FullyApplied=0 and apItems.Voided=0 and APItems.Type=6 and Vouchers.EffectiveDate<'1388/01/01' UNION select sum(amountOriginal) as RemainedAmount,'old' as EffectiveDate,'ar-full' as sys from ARItems where Voided=0 and ARItems.Type=1 and EffectiveDate<'1388/01/01' UNION select sum(amountOriginal) as RemainedAmount, 'old' as EffectiveDate,'ap-full' as sys from APItems where Voided=0 and APItems.Type=6 and EffectiveDate<'1388/01/01'"
647
648	set rs=Conn.Execute(mySQL)
649	set rsOLD=conn.Execute(mySQLold)
650	
651		'Conn.Close
652		'response.redirect "?errMsg=" & Server.URLEncode("���� ����! ���� ���� ���")
653	
654	sub setAXValue(RSs)
655		select case RSs("sys")
656			case "ap"
657				apRemainedAmount = CDbl(RSs("RemainedAmount"))
658			case "ar"
659				arRemainedAmount = CDbl(RSs("RemainedAmount"))	
660			case "ap-full"
661				apTotal = CDbl(RSs("RemainedAmount"))
662				case "ar-full"
663				arTotal = CDbl(RSs("RemainedAmount"))	
664		end select
665		if not RSs.EOF then RSs.MoveNext
666		if not RSs.eof then 
667			if EffectiveDate = RSs("EffectiveDate") then
668				ref2 = RSs("EffectiveDate")
669				call setAXValue(RSs)
670			end if
671		end if
672	end sub
673	If not rs.EOF and not rsOLD.EOF then
674	%>
675	<table>
676		<tr class="RepTableHeader">
677			<td colspan="2">&nbsp;</td>
678			<td>����� ����</td>
679			<td>�� ����</td>
680			<td>���� �����</td>
681			<td>����� ����</td>
682			<td>�� ����</td>
683			<td>���� �����</td>
684		</tr>
685		
686		<%
687		rowColor="RepTR0"
688		if myMonth="" then 
689			do while not rsOLD.eof
690				EffectiveDate=rsOLD("EffectiveDate")
691				%>
692				<tr class="<%=rowColor%>">
693					<%
694					arRemainedAmount=0
695					apRemainedAmount=0	
696					arTotal=0
697					apTotal=0		
698					call setAXValue(rsOLD)
699					%>
700					<td colspan="2">����� �����</td>
701					<%
702					response.write echoTD(arRemainedAmount, "ar")
703					response.write echoTD(arTotal, "ar-full")
704					response.write echoTD(round(arRemainedAmount/arTotal*100), "")
705					response.write echoTD(apRemainedAmount, "ap")
706					response.write echoTD(apTotal, "ap-full")
707					response.write echoTD(round(apRemainedAmount/apTotal*100), "")
708					%>
709				</tr>
710				<%
711					
712			loop
713		end if
714		arRemainedAmountSum=0
715		apRemainedAmountSum=0
716		arTotalAmountSum=0
717		apTotalAmountSum=0
718		do while not rs.eof
719			EffectiveDate=rs("EffectiveDate")
720			if rowColor="RepTR0" then 
721				rowColor="RepTR1"
722			else
723				rowColor="RepTR0"
724			end if
725			%>
726			<tr class="<%=rowColor%>">
727				<%
728				yyyy=mid(EffectiveDate,1,4)
729				if myMonth<>"" then 
730					mm= mid(EffectiveDate,6,5)
731				else
732					mm=fmonth(cint(mid(EffectiveDate,6,2))-1)
733				end if
734				arRemainedAmount=0
735				apRemainedAmount=0
736				call setAXValue(rs)
737				arRemainedAmountSum=arRemainedAmountSum+arRemainedAmount
738				apRemainedAmountSum=apRemainedAmountSum+apRemainedAmount
739				arTotalAmountSum=arTotalAmountSum+arTotal
740				apTotalAmountSum=apTotalAmountSum+apTotal
741				%>
742				<td title="<%=EffectiveDate%>"><%=yyyy%></td>
743				<%if myMonth<>"" then%>
744				<td><%=mm%></td>
745				<%else%>
746				<td title='���� ������ ������ ���� ����'><a href="otherReports.asp?act=cash&month=<%=replace(mid(effectiveDate,1,8),"/","-")%>"><%=mm%></a></td>
747				<%
748				end if
749				response.write echoTD(arRemainedAmount, "ar")
750				response.write echoTD(arTotal, "ar-full")
751				if arTotal>0 then 
752					response.write echoTD(round(arRemainedAmount/arTotal*100), "")
753				else
754					response.write echoTD(0,"")
755				end if
756				response.write echoTD(apRemainedAmount, "ap")
757				response.write echoTD(apTotal, "ap-full")
758				if apTotal>0 then 
759					response.write echoTD(round(apRemainedAmount/apTotal*100), "")
760				else
761					response.write echoTD(0,"")
762				end if
763				%>
764			</tr>
765			<%
766		loop
767		if rowColor="RepTR0" then 
768			rowColor="RepTR1"
769		else
770			rowColor="RepTR0"
771		end if
772		
773	%>
774			<tr class="<%=rowColor%>">
775				<td colspan="2">��� ���� ��������</td>
776				<td><%=Separate(arRemainedAmountSum)%></td>
777				<td><%=Separate(arTotalAmountSum)%></td>
778				<td><%if arTotalAmountSum>0 then response.write Round(arRemainedAmountSum/arTotalAmountSum*100)%></td>
779				<td><%=Separate(apRemainedAmountSum)%></td>
780				<td><%=Separate(apTotalAmountSum)%></td>
781				<td><%if apTotalAmountSum>0 then response.write Round(apRemainedAmountSum/apTotalAmountSum*100)%></td>
782			</tr>
783	</table>
784<%
785	end if
786'-----------------------------------------------------------------------------------------------------
787'-----------------------------------------------------------------------------------------------------
788'-----------------------------------------------------------------------------------------------------
789
790elseif request("act")="MoeenRep" then
791
792	ON ERROR RESUME NEXT
793		GLAccount =		clng(request("GLAccount"))
794		FromDate =		sqlSafe(request("FromDate"))
795		ToDate = 		sqlSafe(request("ToDate"))
796
797		if FromDate	= "" then FromDate = fiscalYear & "/01/01"
798		if ToDate = "" then ToDate = shamsiToday()
799
800		FromTafsil =	clng(request("FromTafsil"))
801		ToTafsil =		clng(request("ToTafsil"))
802
803
804		if Err.Number<>0 then
805			Err.clear
806			conn.close
807			response.redirect "?errMsg=" & Server.URLEncode("���!")
808		end if
809	ON ERROR GOTO 0
810
811  '-----------------------------------------------------------------------------------------------------
812  if request("action")=" �ǁ " then
813  '----   It's Print ( Crystal Reports )
814  %>
815	<BR>
816	<BR>
817	<CENTER>
818	<% 	ReportLogRow = PrepareReport ("MoeenRep01.rpt", "GLAccountGLFromDateToDateFromTafsilToTafsil", GLAccount & "" & OpenGL & "" & FromDate & "" & ToDate & "" & FromTafsil& "" & ToTafsil, "/beta/dialog_printManager.asp?act=Fin") %>
819	<INPUT TYPE="button" value=" �ǁ " Class="GenButton" style="border:1 solid blue;" onclick="printThisReport(this,<%=ReportLogRow%>);">
820
821	</CENTER>
822
823	<BR><iframe name=f1 id=f1 src="/CRReports/?Id=<%=ReportLogRow%>" align=center style="width:750; height:410; border-style: none" border=0 FRAMEBORDER=0 scrollbars=no ></iframe>
824
825  <%
826  else
827  '----   It's Not Print
828
829	Ord=request("Ord")
830
831	select case Ord
832	case "1":
833		order="Tafsil"
834	case "-1":
835		order="Tafsil DESC"
836	case "2":
837		order="AccountTitle"
838	case "-2":
839		order="AccountTitle DESC"
840	case "3":
841		order="totalDebit"
842	case "-3":
843		order="totalDebit DESC"
844	case "4":
845		order="totalCredit"
846	case "-4":
847		order="totalCredit DESC"
848	case "5","-6":
849		order="(SUM(GLRows.IsCredit * GLRows.Amount) - SUM(- ((GLRows.IsCredit - 1) * GLRows.Amount))) DESC"
850	case "6","-5":
851		order="SUM(GLRows.IsCredit * GLRows.Amount) - SUM(- ((GLRows.IsCredit - 1) * GLRows.Amount))"
852	case else:
853		order="Tafsil"
854		Ord=1
855	end select
856
857	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 = "& GLAccount & ")"
858
859	set rsGLNames=Conn.Execute (mySQL)
860
861	If rsGLNames.EOF then
862		Conn.Close
863		response.redirect "?errMsg=" & Server.URLEncode("���� ���� ��� [" & GLAccount & "] �� ��� ���� ���� (" & OpenGL & ") ���� ����� ")
864	End If
865	AccountInfoParams = "&DateFrom=" & FromDate & "&DateTo=" & ToDate
866%>
867	<SCRIPT LANGUAGE="JavaScript">
868	<!--
869	function showAcc(acc){
870		window.open('tafsili.asp?accountID='+acc+'&FromDate=<%=FromDate%>&ToDate=<%=ToDate%>&moeenFrom=0&moeenTo=99999&act=Show');
871	}
872	//-->
873	</SCRIPT>
874	<TABLE dir=rtl align=center width=640 cellspacing=2 cellpadding=2 style="border:2 solid #330066;">
875	<TR bgcolor="#CCCCEE" height="30">
876		<TD colspan=7>
877			<A HREF="AccountInfo.asp?OpenGL=<%=rsGLNames("GLID")&AccountInfoParams%>" Target="_blank"><%=rsGLNames("GLname")%></A>
878			> <A HREF="AccountInfo.asp?act=groups&id=<%=rsGLNames("SuperGroupID")&AccountInfoParams%>" Target="_blank"><%=rsGLNames("SuperGroupName")%></A>
879			> <A HREF="AccountInfo.asp?act=account&id=<%=rsGLNames("GroupID")&AccountInfoParams%>" Target="_blank"><%=rsGLNames("GroupName")%></A>
880			> <%=rsGLNames("AccountName")%>
881			[<%=GLAccount%>]
882		</TD>
883	</TR>
884<%
885	rsGLNames.close
886	Set rsGLNames = Nothing
887
888	mySQL = "SELECT SUM(SumCred) AS SumCred, SUM(SumDeb) AS SumDeb, SUM(Flow * (Sgn + 1) / 2) AS sumFlowCred, SUM(Flow * (Sgn - 1) / 2) AS sumFlowdeb FROM (SELECT SUM(IsCredit * Amount) AS SumCred, SUM(- ((IsCredit - 1) * Amount)) AS SumDeb, SUM(IsCredit * Amount) - SUM(- ((IsCredit - 1)  * Amount)) AS Flow, SIGN(SUM(IsCredit * Amount) - SUM(- ((IsCredit - 1) * Amount))) AS Sgn FROM EffectiveGLRows WHERE (GLAccount = "& GLAccount & ") AND (GL = "& OpenGL & ") AND (ISNULL(Tafsil, 0) >= "& FromTafsil & ") AND (ISNULL(Tafsil, 0) <= "& ToTafsil & ") AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "') GROUP BY Tafsil) FlowTbl"
889
890	set rs=Conn.Execute (mySQL)
891
892%>
893	<TR bgcolor="#CCCCEE" >
894		<TD colspan=2 rowspan=2>
895			�� ����� <B><%=replace(FromDate,"/",".")%></B> �� ����� <B><%=replace(ToDate,"/",".")%></B><br>
896			�� ������ <B><%=FromTafsil%></B> �� ������ <B><%=ToTafsil%></B>
897		</TD>
898		<TD width=70 >���� ������		</TD>
899		<TD width=70 >���� ��������		</TD>
900		<TD width=70 >����� ������		</TD>
901		<TD width=70 >����� ��������	</TD>
902	</TR>
903	<TR bgcolor="#CCCCEE" >
904		<TD width=70 ><%=Separate(rs("SumDeb"))%></TD>
905		<TD width=70 ><%=Separate(rs("SumCred"))%></TD>
906		<TD width=70 ><%=Separate(rs("SumFlowDeb"))%></TD>
907		<TD width=70 ><%=Separate(rs("SumFlowCred"))%></TD>
908	</TR>
909	<TR bgcolor="black" height="2">
910		<TD colspan="6" style="padding:0;"></TD>
911	</TR>
912<%
913	rs.close
914
915	if ord<0 then
916		style="background-color: #33CC99;"
917		arrow="<br><span style='font-family:webdings'>6 6 6</span>"
918	else
919		style="background-color: #33CC99;"
920		arrow="<br><span style='font-family:webdings'>5 5 5</span>"
921	end if
922%>
923	<TR bgcolor="eeeeee" style="cursor:hand;" title="����� �����">
924		<TD width=50  onclick='go2Page(1,1);' style="<%if abs(ord)=1 then response.write style%>">������			<%if abs(ord)=1 then response.write arrow%></TD>
925		<TD width='*' onclick='go2Page(1,2);' style="<%if abs(ord)=2 then response.write style%>">����� ����		<%if abs(ord)=2 then response.write arrow%></TD>
926		<TD width=70 onclick='go2Page(1,-3);' style="<%if abs(ord)=3 then response.write style%>">���� ������		<%if abs(ord)=3 then response.write arrow%></TD>
927		<TD width=70 onclick='go2Page(1,-4);' style="<%if abs(ord)=4 then response.write style%>">���� ��������		<%if abs(ord)=4 then response.write arrow%></TD>
928		<TD width=70 onclick='go2Page(1,-5);' style="<%if abs(ord)=5 then response.write style%>">����� ������		<%if abs(ord)=5 then response.write arrow%></TD>
929		<TD width=70 onclick='go2Page(1,-6);' style="<%if abs(ord)=6 then response.write style%>">����� ��������	<%if abs(ord)=6 then response.write arrow%></TD>
930	</TR>
931	<TR bgcolor="eeeeee" >
932		<TD colspan=6 height=2 bgcolor=0></TD>
933	</TR>
934<%		
935	SumCredit=0
936	SumDebit=0
937	SumCreditRemained=0
938	SumDebitRemained=0
939	tmpCounter=0
940
941	mySQL="SELECT GLRows.Tafsil, SUM(GLRows.IsCredit * GLRows.Amount) AS totalCredit, SUM(- ((GLRows.IsCredit - 1) * GLRows.Amount)) AS totalDebit, Accounts.AccountTitle AS AccountTitle FROM (SELECT ID AS GLDoc, GLDocDate FROM GLDocs WHERE (GLDocs.IsTemporary = 1 OR GLDocs.IsChecked = 1 OR GLDocs.IsFinalized = 1) AND (GLDocDate >= N'"& FromDate & "') AND (GLDocDate <= N'"& ToDate & "') AND (GL = "& openGL & " ) AND (IsRemoved = 0) AND (deleted = 0)) EffectiveGLDocs INNER JOIN GLRows ON EffectiveGLDocs.GLDoc = GLRows.GLDoc INNER JOIN Accounts ON GLRows.Tafsil = Accounts.ID WHERE (GLRows.GLAccount = "& GLAccount & ") AND (GLRows.deleted = 0) GROUP BY GLRows.Tafsil, Accounts.AccountTitle HAVING (ISNULL(GLRows.Tafsil, 0) >= "& FromTafsil & ") AND (ISNULL(GLRows.Tafsil, 0) <= "& ToTafsil & ") ORDER BY " & order
942
943	Set rs=Server.CreateObject("ADODB.Recordset")'Conn.Execute(mySQL)
944
945	PageSize = 50
946	rs.PageSize = …

Large files files are truncated, but you can click here to view the full file