PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/accounting/sood.asp

http://github.com/khaneh/Orders
ASP | 246 lines | 207 code | 26 blank | 13 comment | 14 complexity | 02fdf2c22d7d4e6173bb33cebae241ed MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Accounting (8)
  3PageTitle= "����"
  4SubmenuItem=4
  5if not Auth(8 , 4) then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10
 11<%
 12
 13'-----------------------------------------------------------------------------------------------------
 14'-------------------------------------------------------------------------------- List GL Super Groups
 15'-----------------------------------------------------------------------------------------------------
 16if request("act")="" then
 17%><BR><BR>
 18
 19<TABLE dir=rtl align=center width=400 border=0>
 20<TR>
 21	<TD   align=right><A HREF="AccountInfo.asp">���� �� </A>> ��� � ����
 22	</TD>
 23</TR>
 24<TR  bgcolor="eeeeee" >
 25	<TD  align=center>��� � ����
 26	</TD>
 27</TR>
 28<TR>
 29	<TD bgcolor="#FFFFFF" width=50%><!----Right---->
 30	<TABLE width=70% align=center>
 31	<%
 32	set RSS=Conn.Execute ("SELECT GLAccountSuperGroups.Name, ISNULL(DERIVEDTBL.total, 0) AS total, GLAccountSuperGroups.ID, GLAccountSuperGroups.Type FROM (SELECT SUM(DERIVEDTBL.Total) AS total, GLAccountGroups.GLSuperGroup FROM (SELECT SUM(DERIVEDTBL.total) AS Total, GLAccounts.GLGroup FROM (SELECT SUM((CONVERT(tinyint, IsCredit) - .5) * 2 * Amount) AS total, 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)  GROUP BY GLAccount, GL HAVING (GL = "& OpenGL&")) DERIVEDTBL INNER JOIN GLAccounts ON DERIVEDTBL.GLAccount = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL&") GROUP BY GLAccounts.GLGroup) DERIVEDTBL INNER JOIN GLAccountGroups ON DERIVEDTBL.GLGroup = GLAccountGroups.ID WHERE (GLAccountGroups.GL = "& OpenGL&") GROUP BY GLAccountGroups.GLSuperGroup) DERIVEDTBL RIGHT OUTER JOIN GLAccountSuperGroups ON DERIVEDTBL.GLSuperGroup = GLAccountSuperGroups.ID WHERE (GLAccountSuperGroups.GL = "& OpenGL&" and GLAccountSuperGroups.Type=4) ")
 33
 34	Do while not RSS.eof
 35		%>
 36		<TR>
 37		<TD><A HREF="sood.asp?act=groups&SuperGroupID=<%=RSS("ID")%>"><%=RSS("name")%></a></TD>
 38		<TD><span dir=ltr><%=RSS("total")%></span><br></TD>
 39		</TR>
 40		<%
 41		totalRight = totalRight + clng(RSS("total"))
 42		RSS.moveNext
 43	Loop
 44	%>	
 45	</TABLE>
 46	</TD>
 47</TR>
 48<TR>
 49	<TD bgcolor="#DDDDDD" width=50%><!----left---->
 50	<TABLE width=70% align=center>
 51	<%
 52	set RSS=Conn.Execute ("SELECT GLAccountSuperGroups.Name, ISNULL(DERIVEDTBL.total, 0) AS total, GLAccountSuperGroups.ID, GLAccountSuperGroups.Type FROM (SELECT SUM(DERIVEDTBL.Total) AS total, GLAccountGroups.GLSuperGroup FROM (SELECT SUM(DERIVEDTBL.total) AS Total, GLAccounts.GLGroup FROM (SELECT SUM((CONVERT(tinyint, IsCredit) - .5) * 2 * Amount) AS total, 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)  GROUP BY GLAccount, GL HAVING (GL = "& OpenGL&")) DERIVEDTBL INNER JOIN GLAccounts ON DERIVEDTBL.GLAccount = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL&") GROUP BY GLAccounts.GLGroup) DERIVEDTBL INNER JOIN GLAccountGroups ON DERIVEDTBL.GLGroup = GLAccountGroups.ID WHERE (GLAccountGroups.GL = "& OpenGL&") GROUP BY GLAccountGroups.GLSuperGroup) DERIVEDTBL RIGHT OUTER JOIN GLAccountSuperGroups ON DERIVEDTBL.GLSuperGroup = GLAccountSuperGroups.ID WHERE (GLAccountSuperGroups.GL = "& OpenGL&" and GLAccountSuperGroups.Type=5) ")
 53
 54	Do while not RSS.eof
 55		%>
 56		<TR>
 57		<TD><A HREF="sood.asp?act=groups&SuperGroupID=<%=RSS("ID")%>"><%=RSS("name")%></a></TD>
 58		<TD><span dir=ltr><%=RSS("total")%></span><br></TD>
 59		</TR>
 60		<%
 61		totalLeft = totalLeft + clng(RSS("total"))
 62		RSS.moveNext
 63	Loop
 64	%>	
 65		</TABLE>
 66	</TD>
 67</TR>
 68<TR  bgcolor="eeeeee" >
 69	<TD align=center>����� :  <span dir=ltr><%=totalLeft+totalRight%></span> ���� 
 70	</TD>
 71</TR>
 72</TABLE>
 73
 74<% 
 75response.end
 76
 77
 78'-----------------------------------------------------------------------------------------------------
 79'------------------------------------------------------------------ List GL Groups under a super group
 80'-----------------------------------------------------------------------------------------------------
 81elseif request("act")="groups" then
 82SuperGroupID = request("SuperGroupID")
 83
 84set RSS=Conn.Execute ("SELECT SUM(ISNULL(DERIVEDTBL.Total, 0)) AS total, GLAccountGroups.GLSuperGroup, SUM(DERIVEDTBL.accountsCount) AS accountsCount, GLAccountGroups.Name, GLAccountGroups.ID FROM (SELECT SUM(DERIVEDTBL.total) AS Total, GLAccounts.GLGroup, COUNT(GLAccounts.ID) AS accountsCount FROM (SELECT SUM((CONVERT(tinyint, IsCredit) - .5) * 2 * Amount) AS total, 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)  GROUP BY GLAccount, GL HAVING (GL = "& OpenGL & ")) DERIVEDTBL RIGHT OUTER JOIN GLAccounts ON DERIVEDTBL.GLAccount = GLAccounts.ID WHERE (GLAccounts.GL = "& OpenGL & ") GROUP BY GLAccounts.GLGroup) DERIVEDTBL INNER JOIN GLAccountGroups ON DERIVEDTBL.GLGroup = GLAccountGroups.ID WHERE (GLAccountGroups.GL = "& OpenGL & ") AND (GLAccountGroups.GLSuperGroup = "& SuperGroupID & ") GROUP BY GLAccountGroups.GLSuperGroup, GLAccountGroups.Name, GLAccountGroups.ID ")	
 85
 86%><BR><BR>
 87<TABLE dir=rtl align=center width=600>
 88<TR >
 89	<TD colspan=4>
 90		<%
 91		set RSS2=Conn.Execute ("SELECT *, GLs.ID AS GLID ,GLs.Name AS GLname FROM GLs INNER JOIN GLAccountSuperGroups ON GLs.ID = GLAccountSuperGroups.GL WHERE (GLAccountSuperGroups.GL = "& OpenGL & ") AND (GLAccountSuperGroups.ID = "& SuperGroupID & ")")
 92		%><A HREF="AccountInfo.asp">���� �� </A>> <A HREF="sood.asp?OpenGL=<%=RSS2("GLID")%>">��� � ����</A> > <%=RSS2("name")%>
 93		<BR><hR>
 94	</TD>
 95</TR>
 96<TR bgcolor="eeeeee" >
 97	<TD><!A HREF="default.asp?s=1"><SMALL>��</SMALL></A></TD>
 98	<TD><!A HREF="default.asp?s=2"><SMALL>���  ����</SMALL></A></TD>
 99	<TD><!A HREF="default.asp?s=4"><SMALL>����� ������� �����</SMALL></A></TD>
100	<TD><!A HREF="default.asp?s=4"><SMALL>��� ������ (����)</SMALL></A></TD>
101</TR>
102<%
103tmpCounter=0
104Do while not RSS.eof
105	tmpCounter = tmpCounter + 1
106	if tmpCounter mod 2 = 1 then
107		tmpColor="#FFFFFF"
108		tmpColor2="#FFFFBB"
109	Else
110		tmpColor="#DDDDDD"
111		tmpColor2="#EEEEBB"
112	End if 
113
114%>
115<TR bgcolor="<%=tmpColor%>" >
116	<TD><A HREF="sood.asp?act=account&GroupID=<%=RSS("id")%>"><%=RSS("id")%></A></TD>
117	<TD><A HREF="sood.asp?act=account&GroupID=<%=RSS("id")%>"><%=RSS("Name")%></A></TD>
118	<TD><%=RSS("accountsCount")%></TD>
119	<TD><span dir=ltr><%=RSS("total")%></span></TD>
120</TR>
121	  
122<% 
123RSS.moveNext
124Loop
125%>
126</TABLE><br>
127<%
128
129'-----------------------------------------------------------------------------------------------------
130'---------------------------------------------------------------------- List GL Accounts under a group
131'-----------------------------------------------------------------------------------------------------
132elseif request("act")="account" then
133GroupID = request("GroupID")
134
135set RSS=Conn.Execute ("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 & ")")
136%><BR><BR>
137<TABLE dir=rtl align=center width=600>
138<TR >
139	<TD colspan=5>
140		<%
141		set RSS2=Conn.Execute ("SELECT GLAccounts.Name, DERIVEDTBL.totalDebit AS totalDebit, DERIVEDTBL.totalCredit AS totalCredit, GLAccounts.ID FROM (SELECT SUM(CONVERT(tinyint, IsCredit) * Amount) AS totalCredit, SUM((CONVERT(tinyint, IsCredit) - 1) * (- 1) * Amount) AS totalDebit, 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)  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 & ")")
142		
143		%><A HREF="AccountInfo.asp">���� �� </A>> <A HREF="sood.asp?OpenGL=<%=RSS("GLID")%>">��� � ����</A> > <A HREF="sood.asp?act=groups&SuperGroupID=<%=RSS("SuperGroupID")%>"><%=RSS("SuperGroupName")%></a>  > <%=RSS("GroupName")%>
144		<BR><hR>
145	</TD>
146</TR>
147<TR bgcolor="eeeeee" >
148	<TD><!A HREF="default.asp?s=1"><SMALL>��</SMALL></A></TD>
149	<TD><!A HREF="default.asp?s=2"><SMALL>����� ����</SMALL></A></TD>
150	<TD><!A HREF="default.asp?s=2"><SMALL>��� ������</SMALL></A></TD>
151	<TD><!A HREF="default.asp?s=2"><SMALL>��� ��������</SMALL></A></TD>
152</TR>
153<%
154tmpCounter=0
155Do while not RSS2.eof
156	tmpCounter = tmpCounter + 1
157	if tmpCounter mod 2 = 1 then
158		tmpColor="#FFFFFF"
159		tmpColor2="#FFFFBB"
160	Else
161		tmpColor="#DDDDDD"
162		tmpColor2="#EEEEBB"
163	End if 
164
165%>
166<TR bgcolor="<%=tmpColor%>" >
167	<TD><A HREF="sood.asp?act=accountRows&accountID=<%=RSS2("id")%>"><%=RSS2("id")%></A></TD>
168	<TD><A HREF="sood.asp?act=accountRows&accountID=<%=RSS2("id")%>"><%=RSS2("Name")%></A></TD>
169	<TD><span dir=ltr><%=RSS2("totalDebit")%></span></TD>
170	<TD><span dir=ltr><%=RSS2("totalCredit")%></span></TD>
171</TR>
172	  
173<% 
174RSS2.moveNext
175Loop
176%>
177</TABLE><br>
178<%
179
180'-----------------------------------------------------------------------------------------------------
181'-------------------------------------------------------------------------- List Rows of a GL Accounts 
182'-----------------------------------------------------------------------------------------------------
183elseif request("act")="accountRows" then
184account = request("accountID")
185
186set RSS=Conn.Execute ("SELECT * 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 (GL = "& OpenGL & ") AND (GLaccount = "& account & ")")	
187%><BR><BR>
188<TABLE dir=rtl align=center width=600>
189<TR >
190	<TD colspan=6>
191		<%
192		set RSS2=Conn.Execute ("SELECT *, GLAccountGroups.ID AS GroupID, GLAccountGroups.Name AS GroupName, GLAccountSuperGroups.ID AS SuperGroupID, GLAccountSuperGroups.Name AS SuperGroupName, GLs.ID AS GLID, GLs.Name AS GLname, GLAccounts.Name AS name 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 (GLAccounts.GL = "& OpenGL & ") AND (GLAccounts.ID = "& account & ")")
193		
194		%><A HREF="AccountInfo.asp">���� �� </A>> <A HREF="sood.asp?OpenGL=<%=RSS2("GLID")%>">��� � ����</A> > <A HREF="sood.asp?act=groups&SuperGroupID=<%=RSS2("SuperGroupID")%>"><%=RSS2("SuperGroupName")%></a>  > <A HREF="sood.asp?act=account&GroupID=<%=RSS2("GroupID")%>"><%=RSS2("GroupName")%></a>  >  <%=RSS2("Name")%>
195		<BR><hR>
196	</TD>
197</TR>
198<TR bgcolor="eeeeee" >
199	<TD><!A HREF="default.asp?s=1"><SMALL>��</SMALL></A></TD>
200	<TD><!A HREF="default.asp?s=2"><SMALL>���</SMALL></A></TD>
201	<TD><!A HREF="default.asp?s=2"><SMALL>����� ���</SMALL></A></TD>
202	<TD><!A HREF="default.asp?s=2"><SMALL>����� ���</SMALL></A></TD>
203	<TD><!A HREF="default.asp?s=5"><SMALL>������</SMALL></A></TD>
204	<TD><!A HREF="default.asp?s=5"><SMALL>��������</SMALL></A></TD>
205</TR>
206<%
207tmpCounter=0
208Do while not RSS.eof
209	tmpCounter = tmpCounter + 1
210	if tmpCounter mod 2 = 1 then
211		tmpColor="#FFFFFF"
212		tmpColor2="#FFFFBB"
213	Else
214		tmpColor="#DDDDDD"
215		tmpColor2="#EEEEBB"
216	End if 
217	
218	debit = ""
219	credit = ""
220	if RSS("IsCredit") then
221		credit = RSS("Amount")
222	else
223		debit = RSS("Amount")
224	end if
225%>
226<TR bgcolor="<%=tmpColor%>" >
227	<TD><!A HREF="sood.asp?act=accountRows&accountID=<%=RSS("id")%>"><%=RSS("id")%></A></TD>
228	<TD><!A HREF="sood.asp?act=accountRows&accountID=<%=RSS("id")%>"><%=RSS("Description")%></A></TD>
229	<TD><A HREF="javascript:void(0);" onclick="window.open('GLMemoDocShow.asp?id=<%=RSS("GLDoc")%>',null,'menubars=no')"><%=RSS("GLDocID")%></A></TD>
230	<TD><%=RSS("GLDocDate")%></TD>
231	<TD><%=debit%></TD>
232	<TD><%=credit%></TD>
233</TR>
234	  
235<% 
236RSS.moveNext
237Loop
238%>
239</TABLE><br>
240<%
241end if
242
243
244%>
245
246<!--#include file="tah.asp" -->