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

/beta/accounting/manageGL.asp

http://github.com/khaneh/Orders
ASP | 344 lines | 234 code | 42 blank | 68 comment | 21 complexity | 2b6bad8b01939a114cbde2eace21cdef 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<!--#include File="../include_JS_InputMasks.asp"-->
 11
 12<%
 13
 14'-----------------------------------------------------------------------------------------------------
 15'---------------------------------------------------------------------------- Submit Change Default GL
 16'-----------------------------------------------------------------------------------------------------
 17if request("act")="change" then
 18
 19	newOpenGL=request("OpenGL")
 20	forWhom=request("forWhom")
 21
 22	if forWhom = 0 then
 23
 24		conn.Execute("UPDATE GLs SET IsDefault = 0")
 25		conn.Execute("UPDATE GLs SET IsDefault = 1 , LastChangedBy="& session("ID")& " , LastChangedDate=N'"& shamsiToday() & "', LastChange=N'set to default' WHERE (ID = "& newOpenGL & ")")
 26
 27		'Changed 13282/01/09 for using UserDefaults table instead
 28		'Set RS2 = conn.Execute("SELECT FiscalYear, name, ID FROM GLs WHERE (IsDefault = 1) ORDER BY ID DESC")
 29
 30		mySQL="UPDATE UserDefaults SET WorkingGL='"& newOpenGL & "' WHERE ([User]=0)"
 31		conn.Execute(mySQL)
 32		responseRedirectAddress = "AccountInfo.asp?msg=" & Server.URLEncode("��� ���� ����� ���� ��� ������� ����� ���.")
 33	
 34	else
 35		Set RS2 = conn.Execute("SELECT [User] as ID, WorkingGL FROM UserDefaults WHERE ([User] = "& forWhom & ") OR (UserDefaults.[User] = 0) ORDER BY ABS(UserDefaults.[User]) DESC")
 36
 37		if RS2("id")="0" then
 38			mySQL="INSERT INTO UserDefaults ([User], WorkingGL) VALUES ("& forWhom & ","& newOpenGL & ")"
 39			conn.Execute(mySQL)
 40		else
 41			mySQL="UPDATE UserDefaults SET WorkingGL='"& newOpenGL & "' WHERE ([User]="& forWhom & ")"
 42			conn.Execute(mySQL)
 43		end if
 44
 45		responseRedirectAddress = "GLMemoDocShow.asp?msg=" & Server.URLEncode("��� ���� �����  "& session("CSRName") & " ����� ���")
 46	end if
 47
 48	Set RS2 = conn.Execute("SELECT GLs.EndDate, GLs.StartDate, GLs.Name, GLs.ID, GLs.FiscalYear, UserDefaults.[User], GLs.IsClosed, GLs.Vat FROM GLs INNER JOIN UserDefaults ON GLs.ID = UserDefaults.WorkingGL WHERE (UserDefaults.[User] = '"& session("id") & "') OR (UserDefaults.[User] = 0) ORDER BY ABS(UserDefaults.[User]) DESC")
 49	session("OpenGL")=RS2("id")
 50	session("FiscalYear")=RS2("FiscalYear")
 51	session("OpenGLName")=RS2("name")
 52	session("OpenGLStartDate")=RS2("StartDate")
 53	session("OpenGLEndDate")=RS2("EndDate")
 54	session("IsClosed")=RS2("IsClosed")
 55	session("VatRate")=RS2("Vat")
 56	RS2.movenext
 57	session("differentGL") = False
 58	if not RS2.EOF then
 59		temp=RS2("id")
 60		if temp <> session("OpenGL") then
 61			session("differentGL") = True
 62		end if
 63	end if
 64	RS2.close
 65
 66	response.redirect responseRedirectAddress
 67
 68'-----------------------------------------------------------------------------------------------------
 69'-------------------------------------------------------------------------------- Submit Create New GL
 70'-----------------------------------------------------------------------------------------------------
 71elseif request("act")="submitNew" then
 72
 73	name=request.form("name")
 74	FiscalYear=request.form("FiscalYear")
 75	copy = request.form("copy")
 76	OpenGL = request.form("OpenGL")
 77
 78
 79	CurrentDate = shamsiToday()
 80	tempStartDate=left(CurrentDate,4)&"/01/01"
 81	tempEndDate=left(CurrentDate,4)&"/12/30"
 82
 83	conn.Execute("INSERT INTO GLs (Name, FiscalYear, StartDate, EndDate, IsDefault, IsClosed, LastChangedBy, LastChangedDate, LastChange) VALUES ( N'"& name & "', N'"& FiscalYear & "', N'"& tempStartDate & "', N'"& tempEndDate & "', 0, 0, "& session("id") & ", N'"& CurrentDate & "', N'Created')")
 84
 85	if copy="on" then
 86		Set RS2 = conn.Execute("SELECT * from GLs where FiscalYear="& FiscalYear & " order by id DESC")
 87		GLID=RS2("id")
 88		conn.Execute("INSERT INTO GLAccountSuperGroups SELECT ID, Name, "& GLID & " AS GL, Type FROM GLAccountSuperGroups WHERE (GL = "& OpenGL & ")")
 89		conn.Execute("INSERT INTO GLAccountGroups SELECT ID, GLSuperGroup, Name, "& GLID & " AS GL FROM GLAccountGroups WHERE (GL = "& OpenGL & ")")
 90		conn.Execute("INSERT INTO GLAccounts SELECT ID, GLGroup, Name, "& GLID & " AS GL,HasAppendix FROM GLAccounts WHERE (GL = "& OpenGL & ")")
 91	end if
 92
 93
 94
 95	response.write "<BR><BR><BR><CENTER><H2>���� �� ���� ����� ��</H2></CENTER>"
 96
 97
 98'"INSERT INTO GLAccounts SELECT ID, GLGroup, Name, 3 AS GL FROM GLAccounts WHERE (GL = 1)"
 99
100'-----------------------------------------------------------------------------------------------------
101'------------------------------------------------------------------------------- Close an open GL Form
102'-----------------------------------------------------------------------------------------------------
103elseif request("act")="new" then
104%>
105<CENTER>
106<BR><BR><BR><BR>
107<FORM METHOD=POST ACTION="manageGL.asp?act=submitNew">
108<TABLE>
109<TR>
110	<TD colspan=2 align=center><H3>����� ���� �� ����</H3></TD>
111</TR>
112<TR>
113	<TD align=left>����� ����: </TD>
114	<TD><INPUT TYPE="text" NAME="name"></TD>
115</TR>
116<TR>
117	<TD align=left>��� ����: </TD>
118	<TD><INPUT TYPE="text" NAME="FiscalYear" onkeypress="return maskNumber(this)" maxlength=4></TD>
119</TR>
120<TR>
121	<TD colspan=2><BR></TD>
122</TR>
123<TR>
124	<TD align=left><INPUT TYPE="checkbox" NAME="copy" checked> ߁� ���� �� � ���� �� �� </TD>
125	<TD>
126		<%
127		set RSSX=Conn.Execute ("SELECT * from GLs where order by id desc")
128		%>
129		<SELECT NAME="OpenGL" style="font-family:tahoma" class="GenButton">
130		<%
131		Do while not RSSX.eof
132		%>
133		<option <%	if cint(OpenGL)=cint(RSSX("ID")) then 
134						response.write "selected"
135						GLname = RSSX("name")
136					end if %> value="<%=RSSX("ID")%>" ><%=RSSX("name")%> - ��� ���� <%=RSSX("FiscalYear")%></option>
137		<% 
138
139		RSSX.moveNext
140		Loop
141		RSSX.close
142		%>
143		</SELECT>
144	</TD>
145</TR>
146<TR>
147	<TD colspan=2 align=center> 
148		<BR><BR>
149		<INPUT TYPE="submit" value="�����"class="GenButton">
150		<INPUT TYPE="button" value="������"class="GenButton" onclick="window.location='AccountInfo.asp'">
151	</TD>
152</TR>
153</TABLE>
154<%
155'-----------------------------------------------------------------------------------------------------
156'------------------------------------------------------------------------------- Close an open GL Form
157'-----------------------------------------------------------------------------------------------------
158elseif request("act")="close" then
159%>
160<CENTER>
161<BR><BR>
162<% call showAlert ("<B>����: </B><BR>���� �� �� ���� �ѐ�� �ǁ��� ���<BR>� ���� �� ��� �� ��� �� ��� ��� ����<BR>�� �� ����� ���� �����.<BR>",CONST_MSG_INFORM)%>
163
164<BR>
165<% call showAlert ("���� �� ���� �� ��� �� ����� ���� ��� ��� ���� ��� ���� ���",CONST_MSG_INFORM)%>
166
167<BR><BR>
168<%
169set RSSX=Conn.Execute ("SELECT * from GLs where IsClosed=0 and IsDefault=0 order by id desc")
170%>
171<FORM METHOD=POST ACTION="manageGL.asp?act=submitClose">
172
173<B>���� ���� �� </B><SELECT NAME="OpenGL" style="font-family:tahoma" class="GenButton">
174<%
175Do while not RSSX.eof
176%>
177<option <%	if cint(OpenGL)=cint(RSSX("ID")) then 
178				response.write "selected"
179				GLname = RSSX("name")
180			end if %> value="<%=RSSX("ID")%>" ><%=RSSX("name")%> - ��� ���� <%=RSSX("FiscalYear")%></option>
181<% 
182
183RSSX.moveNext
184Loop
185RSSX.close
186%>
187</SELECT><BR><BR>
188<INPUT TYPE="submit" value="����"class="GenButton">
189<INPUT TYPE="button" value="������"class="GenButton" onclick="window.location='AccountInfo.asp'">
190</FORM>
191</CENTER>
192
193<%
194
195'-----------------------------------------------------------------------------------------------------
196'--------------------------------------------------------------------------------- submit Closing a GL
197'-----------------------------------------------------------------------------------------------------
198elseif request("act")="submitClose" then
199	conn.Execute("UPDATE GLs SET IsClosed = 1 , LastChangedBy="& session("ID")& " , LastChangedDate=N'"& shamsiToday() & "', LastChange=N'Closed' WHERE (ID = "& request("OpenGL") & ")")
200
201	response.redirect "AccountInfo.asp"
202
203
204'-----------------------------------------------------------------------------------------------------
205'-------------------------------------------------------------------------------- Show GLs Changes Log
206'-----------------------------------------------------------------------------------------------------
207elseif request("act")="showLog" then
208	set RSSX=Conn.Execute ("SELECT Users.RealName, GLLog.ChangedDate, GLLog.Change, GLs.Name ,GLs.id , GLs.FiscalYear  FROM GLLog INNER JOIN GLs ON GLLog.GLID = GLs.ID INNER JOIN Users ON GLLog.ChangedBy = Users.ID ORDER BY GLLog.id DESC")
209	%>
210	<TABLE dir=rtl align=center width=600>
211	<TR >
212		<TD colspan=6 align=center>
213			<BR><H3>����� ������� ���� ��</H3><BR>
214		</TD>
215	</TR>
216	<TR bgcolor="eeeeee" >
217		<TD><SMALL> # </SMALL></TD>
218		<TD><SMALL> ���� </SMALL></TD>
219		<TD><SMALL> ��� ����</SMALL></TD>
220		<TD><SMALL> ����� ����� </SMALL></TD>
221		<TD><SMALL> ����� ����� </SMALL></TD>
222		<TD><SMALL> ����� </SMALL></TD>
223	</TR>
224	<%
225	tmpCounter=0
226	Do while not RSSX.eof
227		tmpCounter = tmpCounter + 1
228		if tmpCounter mod 2 = 1 then
229			tmpColor="#FFFFFF"
230			tmpColor2="#FFFFBB"
231		Else
232			tmpColor="#DDDDDD"
233			tmpColor2="#EEEEBB"
234		End if 
235		%>
236		<TR bgcolor="<%=tmpColor%>" >
237			<TD><%=RSSX("id")%> </TD>
238			<TD><%=RSSX("Name")%> </TD>
239			<TD><%=RSSX("FiscalYear")%></TD>
240			<TD><span dir=ltr><%=RSSX("ChangedDate")%></span></TD>
241			<TD><%=RSSX("RealName")%></TD>
242			<TD><%=RSSX("Change")%></TD>
243			</TD>
244		</TR>
245		<%
246		RSSX.moveNext
247	Loop
248	%>
249	</TABLE><br>
250	<CENTER><INPUT TYPE="button" value="�ѐ��"class="GenButton" onclick="window.location='AccountInfo.asp'"></CENTER><BR><BR>
251
252	<%
253	set RSSX = nothing
254
255'-----------------------------------------------------------------------------------------------------
256'---------------------------------------------------------------------- Select Another Default GL Form
257'-----------------------------------------------------------------------------------------------------
258elseif request("act")="select" or request("act")="" then
259%>
260<CENTER>
261<BR><BR><BR>
262<% call showAlert ("<B>����: </B><BR>����� ���� �� ��� ��� �� ��� ����<BR> ���� �� ��� �� ��� �� ���� ������ �� <BR> �� ������� ��� ����",CONST_MSG_INFORM)%>
263<BR><BR>
264<%
265set RSSX=Conn.Execute ("SELECT * from GLs order by id desc")
266%>
267<FORM METHOD=POST ACTION="manageGL.asp?act=change">
268
269<B>����� ���� �� �� </B><SELECT NAME="OpenGL" style="font-family:tahoma" class="GenButton">
270<%
271Do while not RSSX.eof
272%>
273<option <%	if cint(OpenGL)=cint(RSSX("ID")) then 
274				response.write "selected"
275				GLname = RSSX("name")
276			end if %> value="<%=RSSX("ID")%>" ><%=RSSX("name")%> - ��� ���� <%=RSSX("FiscalYear")%></option>
277<% 
278
279RSSX.moveNext
280Loop
281RSSX.close
282%>
283</SELECT><BR><BR>
284<% if Auth(8 , "D") then %>
285<INPUT TYPE="radio" NAME="forWhom" value="0">���� �� ��� ��� �����<br>
286<% end if %>
287<INPUT TYPE="radio" NAME="forWhom" checked value="<%=session("id")%>">��� ���� ����� <%=session("CSRName")%>
288<BR><BR>
289<INPUT TYPE="submit" value="�����"class="GenButton">
290<INPUT TYPE="button" value="������"class="GenButton" onclick="window.location='AccountInfo.asp'">
291</FORM>
292</CENTER>
293
294<%
295end if
296%>
297<!--#include file="tah.asp" -->
298
299<%
300	'------------- Related Triggers ----------------
301	'
302	'	CREATE TRIGGER [setDefaultGL] ON [dbo].[GLs] 
303	'	FOR INSERT, UPDATE
304	'	AS 
305	'	DECLARE 
306	'		@IsDefault binary,
307	'		@id int
308	'		SELECT 
309	'			@IsDefault = IsDefault, 
310	'			@id = [id]
311	'		FROM inserted 
312	'	if @IsDefault = 1
313	'	begin
314	'	UPDATE GLs SET 
315	'		IsDefault = 0
316	'	UPDATE GLs SET 
317	'		IsDefault = 1
318	'	WHERE ID = @id
319	'	end
320	'
321	'----------------------------------------------
322	'
323	'	CREATE TRIGGER Trig_GLLOGGER ON [dbo].[GLs] 
324	'	FOR INSERT, UPDATE
325	'	AS 
326	'	DECLARE 
327	'		@GLID int,
328	'		@LastChange nvarchar(100),
329	'		@LastChangedDate nvarchar(10),
330	'		@LastChangedBy int
331	'		SELECT 
332	'			@GLID=[ID], 
333	'			@LastChange = LastChange, 
334	'			@LastChangedDate = LastChangedDate, 
335	'			@LastChangedBy = LastChangedBy
336	'		FROM inserted
337	'	IF UPDATE (LastChange)
338	'	INSERT INTO GLLog (GLID, Change, ChangedDate, ChangedBy)
339	'			VALUES (@GLID, @LastChange, @LastChangedDate, @LastChangedBy)
340	'
341	'
342	'----------------------------------------------
343
344%>