PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/accounting/GLMemoDocShow.asp

http://github.com/khaneh/Orders
ASP | 696 lines | 603 code | 75 blank | 18 comment | 94 complexity | 5870afb038154247ec7453055f622fa8 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Accounting (8)
  3PageTitle= "����� �����"
  4SubmenuItem=3
  5if not Auth(8 , 3) 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	a {color:black;}
 14
 15	.GLTable0 { font-family:tahoma; font-size: 9pt; background-color: #006666; border:2 solid #003333; padding:0; }
 16	.GLTable0 TH { background-color: #006666; border: 0; font-size:16pt;border-bottom: 2 solid #003333;}
 17	.GLTable0 TD { background-color: #DDDDDD; border: 0; font-size:10pt;}
 18	.GLTable0TR1 td{ background-color: #008888; border: 0; }
 19	.GLTable0TR2 td{ background-color: #006666; border: 0; }
 20
 21	.GLTable1 { font-family:tahoma; font-size: 9pt; background-color: #3399CC; border:2 solid #330099; padding:0; }
 22	.GLTable1 TH { background-color: #3399CC; border: 0; font-size:16pt;border-bottom: 2 solid #330099;}
 23	.GLTable1 TD { background-color: #EEEEEE; border: 0; font-size:10pt;}
 24	.GLTable1TR1 td{ background-color: #88BBDD; border: 0; }
 25	.GLTable1TR2 td{ background-color: #3399CC; border: 0; }
 26
 27	.GLTable2 { font-family:tahoma; font-size: 9pt; background-color: #CC3399; border:2 solid #993300; padding:0; }
 28	.GLTable2 TH { background-color: #CC3399; border: 0; font-size:16pt;border-bottom: 2 solid #993300;}
 29	.GLTable2 TD { background-color: #EEEEEE; border: 0; font-size:10pt;}
 30	.GLTable2TR1 td{ background-color: #DD88BB; border: 0; }
 31	.GLTable2TR2 td{ background-color: #CC3399; border: 0; }
 32
 33	.GLTable3 { font-family:tahoma; font-size: 9pt; background-color: #AAAA33; border:2 solid #CCCC00; padding:0; }
 34	.GLTable3 TH { background-color: #AAAA33; border: 0; font-size:16pt;border-bottom: 2 solid #BBBB00;}
 35	.GLTable3 TD { background-color: #EEEEEE; border: 0; font-size:10pt;}
 36	.GLTable3TR1 td{ background-color: #CCCC11; border: 0; }
 37	.GLTable3TR2 td{ background-color: #AAAA33; border: 0; }
 38
 39	.GLTable4 { font-family:tahoma; font-size: 9pt; background-color: #33AA99; border:2 solid #005533; padding:0; }
 40	.GLTable4 TH { background-color: #33AA99; border: 0; font-size:16pt;border-bottom: 2 solid #005533;}
 41	.GLTable4 TD { background-color: #EEEEEE; border: 0; font-size:10pt;}
 42	.GLTable4TR1 td{ background-color: #77BBAA; border: 0; }
 43	.GLTable4TR2 td{ background-color: #33AA99; border: 0; }
 44
 45	.GLTable5 { font-family:tahoma; font-size: 9pt; background-color: #66CCCC; border:2 solid #225555; padding:0; }
 46	.GLTable5 TH { background-color: #66BBCC; border: 0; font-size:16pt;border-bottom: 2 solid #225555;}
 47	.GLTable5 TD { background-color: #EEEEEE; border: 0; font-size:10pt;}
 48	.GLTable5TR1 td{ background-color: #99DDDD; border: 0; }
 49	.GLTable5TR2 td{ background-color: #66CCCC; border: 0; }
 50
 51	.GenRow1 TD { background-color: #EEEEEE; border: 0; font-size:10pt;}
 52	.GenRow2 TD { background-color: #DDDDDD; border: 0; font-size:10pt;}
 53
 54
 55</style>
 56<%
 57function ShowErrorMessage(theText)
 58%>
 59	<br>
 60	<TABLE width=70% align='center'>
 61	<TR>
 62		<TD align=center bgcolor=#FFBBBB style='border: dashed 2pt Red'><BR><b><%=theText%></b><BR><BR></TD>
 63	</TR>
 64	</TABLE>
 65<%
 66end function
 67
 68ON ERROR RESUME NEXT
 69	DocID=	clng(request("DocID"))
 70	if Err.Number<>0 then Err.clear:DocID=0
 71	id=		clng(request("id"))
 72	if Err.Number<>0 then Err.clear:id=0
 73ON ERROR GOTO 0
 74
 75'-----------------------------------------------------------------------------------------------------
 76'------------------------------------------------------------------------- Changing status of a GL DOC
 77'-----------------------------------------------------------------------------------------------------
 78if request("act")="changeStatus" then
 79	
 80	'----- Check GL is closed
 81	if (session("IsClosed")="True") then 
 82		Conn.close
 83		response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.")
 84	end if 
 85	'----
 86
 87	submit=request("submit")
 88
 89	if DocID=0 or id=0 then
 90		%>
 91		<BR><BR><CENTER>
 92		���! ����� ��� ���� ���� ���
 93		</CENTER>
 94		<%
 95		response.end
 96	end if
 97
 98	if submit="���" then
 99		mySQL="SELECT min(GLDocID) as MinGLDocID FROM GLDocs where (GL = "& OpenGL & ")"
100		set RS1=conn.execute(mySQL)
101
102		if RS1.eof then
103			response.write "<BR><BR><BR><CENTER>����� ������� �� ����� ������ ���.</CENTER>"
104			response.end
105		else
106			RemovedGLDocID = RS1("MinGLDocID") - 1
107			if RemovedGLDocID=0 then RemovedGLDocID=-1
108		end if 
109
110		Conn.Execute ("UPDATE GLDocs SET IsRemoved=1,RemovedDate=N'"& shamsiToday() & "',RemovedBy='"& session("ID") & "' WHERE (ID = "& id & ") AND (GL = "& OpenGL & ")")
111		Conn.Execute ("UPDATE GLRows SET deleted=1 WHERE (GLDoc = "& id & ")")
112		Conn.Execute ("UPDATE GLDocs SET GLDocID="& RemovedGLDocID & ", OldGLDocID="& DocID & " WHERE (GLDocID = "& DocID & ") AND (GL = "& OpenGL & ")")
113		DocID = RemovedGLDocID
114	elseif submit="������ ��� ��������" then
115		conn.close
116		response.redirect "SubsysDocsEdit.asp?act=show&id=" & id
117	elseif submit="������ ��� ����" then
118		response.redirect "CompMemoInput.asp?act=editDoc&id="& DocID 
119	elseif submit="������" then
120		response.redirect "GLMemoInput.asp?act=editDoc&id="& DocID 
121	elseif submit="��� ��� ����" then ' ------------------ADD BY SAM
122		mySQL="SELECT min(GLDocID) as MinGLDocID FROM GLDocs where (GL = "& OpenGL & ")"
123		set RS1=conn.execute(mySQL)
124
125		if RS1.eof then
126			response.write "<BR><BR><BR><CENTER>����� ������� �� ����� ������ ���.</CENTER>"
127			response.end
128		else
129			RemovedGLDocID = RS1("MinGLDocID") - 1
130			if RemovedGLDocID=0 then RemovedGLDocID=-1
131		end if 
132		set myRSS=Conn.Execute("SELECT * FROM EffectiveGLRows  WHERE GLDoc="&id &" AND SYS>''")
133		do while not myRSS.eof
134			link	= myRSS("Link")
135			sys		= myRSS("SYS")
136			isCredit= myRSS("isCredit")
137			Amount	= myRSS("Amount")
138			Account = myRSS("Tafsil")
139			Conn.Execute ("UPDATE " & sys & "Items SET RemainedAmount=0, FullyApplied=0,Voided=1,GL_Update=1 WHERE ID="& link)
140			conn.Execute ("UPDATE " & sys & "Memo SET Voided=1 WHERE ID in (SELECT Link FROM "&sys&"Items WHERE Type=3 AND ID="&link&")")
141			if isCredit then
142				mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance - '"& Amount & "' WHERE (ID='"& Account & "')"
143			else
144				mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance + '"& Amount & "' WHERE (ID='"& Account & "')"
145			end if
146			myRSS.moveNext
147		loop
148		myRSS.close
149		Conn.Execute ("UPDATE GLDocs SET IsRemoved=1,RemovedDate=N'"& shamsiToday() & "',RemovedBy='"& session("ID") & "' WHERE (ID = "& id & ") AND (GL = "& OpenGL & ")")
150		Conn.Execute ("UPDATE GLRows SET deleted=1 WHERE (GLDoc = "& id & ")")
151
152		Conn.Execute ("UPDATE GLDocs SET GLDocID="& RemovedGLDocID & ", OldGLDocID="& DocID & " WHERE (GLDocID = "& DocID & ") AND (GL = "& OpenGL & ")")
153		DocID = RemovedGLDocID
154		'---------------------------------------------------------
155	else
156		select case submit
157			case "����� �� �������"
158				fieldUpdate = " IsTemporary=0 , IsChecked=0, IsFinalized=0"
159			case "����� �� ����" 
160				fieldUpdate = " IsTemporary=1 , IsChecked=0, IsFinalized=0, CreatedDate=N'" & shamsiToday() & "'"
161			case "����� ��" 
162				fieldUpdate = " IsTemporary=0 , IsChecked=1, IsFinalized=0, CheckedDate=N'" & shamsiToday() & "', CheckedBy="& session("id")
163			case "���� ��" 
164				fieldUpdate = " IsTemporary=0 , IsChecked=0, IsFinalized=1, FinalizedDate=N'" & shamsiToday() & "', FinalizedBy="& session("id")
165			case else
166				response.write "<BR><BR><H1>Very Bad Error!</H1><BR>System Has Been Colapsed!@"
167				response.end
168		end select
169		Conn.Execute ("UPDATE GLDocs SET "& fieldUpdate & " WHERE (ID = "& id & ") AND (GL = "& OpenGL & ")")
170	end if
171	
172end if
173
174itemAmount=""
175
176if DocID <> 0 then
177	mySQL="SELECT * FROM GLDocs WHERE GLDocID="& DocID & " and (GL = "& OpenGL & ") order by id DESC"
178	
179	set RS1=conn.execute(mySQL)
180
181	if RS1.eof then
182		response.write "<BR><BR><BR><CENTER>���! ���� ���� �� ��� ��� ���� ���� �����</CENTER>"
183		response.end
184	else
185		id = clng(RS1("id"))
186	end if 
187end if
188
189'-----------------------------------------------------------------------------------------------------
190'---------------------------------------------------------------------------------- GL Doc Search Form
191'-----------------------------------------------------------------------------------------------------
192if id=0 then
193	showDescription=false
194	itemDesc=sqlSafe(replace(request("itemDesc")," ",""))
195
196	if request("act")="search" and itemDesc<>"" then
197
198		SQL_ST = "SELECT TOP 20 GLDocs.ID, GLDocs.GLDocID, GLDocs.GLDocDate, GLDocs.IsTemporary, GLDocs.IsChecked, GLDocs.IsFinalized, GLDocs.IsRemoved, GLDocs.BySubSystem, GLDocs.IsCompound, GLRows.Description FROM GLDocs INNER JOIN GLRows ON GLDocs.ID = GLRows.GLDoc WHERE (GL = "& OpenGL & ") AND (REPLACE(GLRows.Description,' ','') LIKE N'%" & itemDesc & "%') ORDER BY GLDocDate DESC"
199
200		showDescription=true
201	
202	else
203
204		fromDate =	request("fromDate") 
205		toDate =	request("toDate") 
206		Draft =		request("Draft") 
207		Temporary=	request("Temporary") 
208		Checked=	request("Checked") 
209		Finalized=	request("Finalized") 
210		Removed =	request("Removed")
211		Order1=		request("Order1")
212
213		itemAmount=	request("itemAmount")
214
215		if request("fromSession") = "y" then
216			toDate =	session("toDate")
217			fromDate =	session("fromDate")
218			Draft =		session("Draft") 
219			Temporary=	session("Temporary") 
220			Checked =	session("Checked") 
221			Finalized=	session("Finalized") 
222			Removed =	session("Removed") 
223			Order1 =	session("Order1") 
224		end if
225
226		if not Draft="" then DraftSt = "checked"
227		if not Temporary="" then	TemporarySt = "checked"
228		if not Checked="" then CheckedSt = "checked"
229		if not Finalized="" then FinalizedSt = "checked"
230		if not Removed="" then RemovedSt = "checked"
231
232		if ""&Order1="" then Order1 = "GLDocs.ID DESC"
233
234		if toDate="" or fromDate="" then
235			toDate =		shamsiToday()
236			fromDate =		shamsiDate(Date()-7)
237			DraftSt =		"checked"
238			TemporarySt =	"checked"
239			CheckedSt =		"checked"
240		end if
241
242		session("fromDate") =	fromDate 
243		session("toDate") =		toDate
244		session("Draft") =		Draft
245		session("Temporary") =	Temporary
246		session("Checked") =	Checked
247		session("Finalized") =	Finalized
248		session("Removed") =	Removed
249		session("Order1") =		Order1
250		
251'--
252	
253		if itemAmount<>"" and isnumeric(itemAmount) then
254			itemAmount = cdbl(itemAmount)
255
256			SQL_ST = "SELECT TOP 50 GLDocs.ID, GLDocs.GLDocID, GLDocs.GLDocDate, GLDocs.IsTemporary, GLDocs.IsChecked, GLDocs.IsFinalized, GLDocs.IsRemoved, GLDocs.BySubSystem, GLDocs.IsCompound, GLRows.Description FROM GLDocs INNER JOIN GLRows ON GLDocs.ID = GLRows.GLDoc WHERE (GL = "& OpenGL & ") AND (GLRows.Amount = '" & itemAmount & "') "
257
258			showDescription=true
259		else
260			itemAmount = ""
261			SQL_ST = "SELECT * FROM GLDocs WHERE (GL = "& OpenGL & ") and (GLDocDate >= N'"& fromDate & "') and (GLDocDate <= N'"& toDate & "')"
262		end if
263
264		SQL_ST = SQL_ST & " and ( 1=0 "
265
266		if RemovedSt = "checked" then SQL_ST = SQL_ST & " or (IsRemoved=1) "
267		if FinalizedSt = "checked" then	SQL_ST = SQL_ST & " or ( (IsFinalized=1) and (GLDocs.deleted=0) and (IsRemoved=0) )"
268		if CheckedSt = "checked" then SQL_ST = SQL_ST & " or ( (IsChecked=1) and (GLDocs.deleted=0) and (IsRemoved=0) )"
269		if TemporarySt = "checked" then	SQL_ST = SQL_ST & " or ( (IsTemporary=1) and (GLDocs.deleted=0) and (IsRemoved=0) )"
270		if DraftSt = "checked" then SQL_ST = SQL_ST & " or ( (IsTemporary=0) and (IsChecked=0) and (IsFinalized=0) and (GLDocs.deleted=0) and (IsRemoved=0) )"
271
272	'	SQL_ST = SQL_ST & " ) order by GLDocDate, GLDocID, id"
273		SQL_ST = SQL_ST & " ) ORDER BY "& order1 '& ", id"
274	end if
275
276	%>
277	<BR><BR><CENTER>
278	<FORM METHOD=POST ACTION="GLMemoDocShow.asp?act=">
279	����� ���: <INPUT TYPE="text" NAME="DocID"> &nbsp;&nbsp;<INPUT TYPE="submit" value="������">
280	</FORM>
281	<hr>
282	<FORM METHOD=POST ACTION="GLMemoDocShow.asp?act=search">
283	���: <INPUT TYPE="text" NAME="itemDesc" value="<%=itemDesc%>" > &nbsp;&nbsp;<INPUT TYPE="submit" value="�����">
284	</FORM>
285	<hr>
286	<FORM METHOD=POST ACTION="GLMemoDocShow.asp">
287	<TABLE border=0 align=center>
288	<TR>
289		<TD align=left>�� �����</TD>
290		<TD align=right><INPUT TYPE="text" NAME="fromDate" value="<%=fromDate%>" dir=ltr onKeyPress="return maskDate(this);" onblur="acceptDate(this)" maxlength="10"></TD>
291		<TD align=left width=20></TD>
292		<TD align=left>�� �����</TD>
293		<TD align=right><INPUT TYPE="text" NAME="toDate" value="<%=toDate%>" dir=ltr onKeyPress="return maskDate(this);" onblur="acceptDate(this)" maxlength="10"></TD>
294	</TR>
295	<TR height=10>
296		<TD colspan=5 align=center><hr></TD>
297	</TR>
298	<TR>
299		<TD colspan=5>
300		<INPUT TYPE="checkbox" NAME="Draft" <%=DraftSt%>> ������� 
301		<INPUT TYPE="checkbox" NAME="Temporary" <%=TemporarySt%>> ����
302<%	if Auth( 8 , 6 ) then%>
303		<INPUT TYPE="checkbox" NAME="Checked" <%=CheckedSt%>> ����� ��� 
304<%	end if
305	if Auth( 8 , 5 ) then%>
306		<INPUT TYPE="checkbox" NAME="Finalized" <%=FinalizedSt%>> ���� ��� 
307<%	end if
308	if Auth( 8 , 2 ) then%>
309		<INPUT TYPE="checkbox" NAME="Removed" <%=RemovedSt%>> ��� ���
310<%	end if%>
311	</TR>
312	<TR height=10>
313		<TD colspan=5 align=center><hr></TD>
314	</TR>
315	<TR>
316		<TD align=left>����:</TD>
317		<TD align=right colspan=4>
318			<INPUT TYPE="text" NAME="itemAmount" value="<%=itemAmount%>" >
319		</TD>
320	</TR>
321	<TR height=10>
322		<TD colspan=5 align=center><hr></TD>
323	</TR>
324	<TR>
325		<TD colspan=4 align=center>���� ��� �� ����:
326			<SELECT NAME="Order1" style="font-family:tahoma;font-size:9pt;width:120px;" onchange="document.all.submit.click();">
327				<OPTION Value="GLDocDate" <%if Order1="GLDocDate" then response.write "selected"%>>����� ���</OPTION>
328				<OPTION Value="GLDocID" <%if Order1="GLDocID" then response.write "selected"%>>����� ���</OPTION>
329				<OPTION Value="GLDocs.ID" <%if Order1="GLDocs.ID" then response.write "selected"%>>����� ��� ���</OPTION>
330				<OPTION Value="GLDocs.ID DESC" <%if Order1="GLDocs.ID DESC" then response.write "selected"%>>����� �������</OPTION>
331			</SELECT>
332		</TD>
333		<TD align=center>
334			<INPUT TYPE="submit" NAME="submit" class=inputBut value="�����">
335		</TD>
336	</TR>
337	</TABLE>
338	</FORM>
339	</CENTER>
340	<BR><BR>
341	<div style='padding:10px;'>
342	<%
343'--
344	set rsNote=Conn.Execute("select * from GLDocs where IsTemporary=0 and IsChecked=0 and IsFinalized=0 and IsRemoved=0 and deleted=0 and gl="&OpenGL)
345	if not rsNote.eof then response.write ("<center><h2 style='color:yellow;'>����� ���� ���! ��� ����� ������� �����. ���� �э� ����� ����� ���� �� ���� ����</h2></center>")
346	do while not rsNote.eof 
347		statusString = " ������� "
348		status =""
349		if rsNote("BySubSystem") then
350			statusString = statusString & " - �������� "
351			status = "BySubSystem"
352		elseif rsNote("IsCompound") then
353			statusString = statusString & " - ��� ���� "
354		end if
355		response.write("<li class=alak2> <A style='font-size:8pt; color:red;' HREF='GLMemoDocShow.asp?id=" & rsNote("ID") & "' target='_blank'>")
356		if status = "BySubSystem" then response.write("<b>")
357		response.write(" ��� ����� "& rsNote("GLDocID")& " �� ����� <span dir=ltr>" & rsNote("GLDocDate") & "</span> &nbsp;&nbsp;" & statusString)
358		if status = "BySubSystem" then response.write("</b>")
359		response.write ("</a></li>")
360		rsNote.moveNext
361	loop
362	response.write "<hr>"
363	set RSS=Conn.Execute (SQL_ST)
364	status =""
365	Do while not RSS.eof
366		memoNumberString=" ��� ����� " & RSS("GLDocID")
367		if RSS("IsRemoved") then 
368										statusString = " ��� ��� "
369										memoNumberString= " <U>��� ��� ��� </U>"
370		elseif RSS("IsFinalized") then 		
371										statusString = " ���� ��� "
372		elseif RSS("IsChecked") then	
373										statusString = " ����� ��� "
374		elseif RSS("IsTemporary") then	
375										statusString = " ���� "
376		else							
377										statusString = " ������� "
378		end if 
379
380		if RSS("BySubSystem") then
381			statusString = statusString & " - �������� "
382			status = "BySubSystem"
383		elseif RSS("IsCompound") then
384			statusString = statusString & " - ��� ���� "
385		end if 
386%>
387		<li class=alak2> <A style='font-size:8pt;' HREF='GLMemoDocShow.asp?id=<%=RSS("ID")%>' target='_blank'>
388		<%=memoNumberString%> �� ����� <span dir=ltr><%=RSS("GLDocDate")%></span> &nbsp;&nbsp;(<%=statusString%>)
389<%
390		if showDescription then
391%>			<span style='font-size:7pt;color:gray;'>[<%=RSS("Description")%>]</span>
392<%		end if
393%>		</A>
394<%		
395	RSS.moveNext
396	Loop
397%>
398	</div>
399<%
400else
401'-----------------------------------------------------------------------------------------------------
402'--------------------------------------------------------------------------------------- Show a GL Doc
403'-----------------------------------------------------------------------------------------------------
404
405	'mySQL="SELECT GLDocs.*, GLRows.GLAccount, GLRows.Tafsil, GLRows.Amount, GLRows.Description, GLRows.SYS, GLRows.Link, GLRows.IsCredit, GLAccounts.Name FROM GLDocs INNER JOIN GLRows ON GLDocs.ID = GLRows.GLDoc INNER JOIN GLAccounts ON GLRows.GLAccount = GLAccounts.ID WHERE (GLDocs.id="& id & ") AND (GLDocs.GL = "& OpenGL & ") AND (GLAccounts.GL = "& OpenGL & ") ORDER BY GLRows.ID"
406	' Changed By kid 860728 Adding Accounts.AccountTitle
407	mySQL="SELECT GLDocs.*, GLRows.GLAccount, GLRows.Tafsil, GLRows.Amount, GLRows.Description, GLRows.SYS, GLRows.Link, GLRows.IsCredit, GLAccounts.Name, Accounts.AccountTitle FROM GLDocs INNER JOIN GLRows ON GLDocs.ID = GLRows.GLDoc INNER JOIN GLAccounts ON GLRows.GLAccount = GLAccounts.ID LEFT OUTER JOIN Accounts ON GLRows.Tafsil = Accounts.ID WHERE (GLDocs.id="& id & ") AND (GLDocs.GL = "& OpenGL & ") AND (GLAccounts.GL = "& OpenGL & ") ORDER BY GLRows.ID"
408
409	set RS1=conn.execute(mySQL)
410
411	if RS1.eof then
412	response.write "<BR><BR><BR><CENTER>���! ���� ���� �� ��� ��� ���� ���� �����</CENTER>"
413		response.end
414	end if 
415
416	GLDocID = RS1("GLDocID")
417	Creator = RS1("CreatedBy")
418
419	classType=1
420
421	if RS1("IsRemoved") then 
422		if Not Auth( 8 , 2 ) then
423			ShowErrorMessage("��� ���� �� ���� ��� ��� ������.")		
424			conn.close
425			response.end
426		end if	
427		statusString = " ��� ��� "
428		status = "Removed"
429		classType=2
430
431	elseif RS1("IsFinalized") then 
432		if Not Auth( 8 , 5 ) then
433			ShowErrorMessage("��� ���� �� ���� ��� ��� ������.")		
434			conn.close
435			response.end
436		end if	
437		statusString = " ���� ��� "
438		status = "Finalized"
439
440	elseif RS1("IsChecked") then 
441		if Not Auth( 8 , 6 ) then
442			ShowErrorMessage("��� ���� �� ���� ��� ��� ������.")		
443			conn.close
444			response.end
445		end if	
446		statusString = " ����� ��� "
447		status = "Checked"
448
449	elseif RS1("IsTemporary") then 
450		if Not (session("ID") = Creator OR Auth( 8 , 7 ) )then
451			ShowErrorMessage("��� ���� �� ���� ��� ��� ������.")		
452			conn.close
453			response.end
454		end if	
455		statusString = " ���� "
456		status = "Temporary"
457		classType=1
458
459	else
460		if Not (session("ID") = Creator OR Auth( 8 , 9 ) )then
461			ShowErrorMessage("��� ���� �� ���� ��� ������� ������.")		
462			conn.close
463			response.end
464		end if	
465		statusString = " ������� "
466		status = "Draft"
467		classType=3
468	end if 
469
470	isBySubSystem = false
471
472	if RS1("BySubSystem") then
473		isBySubSystem = true
474		if RS1("IsRemoved") then
475			classType=2
476		else
477			classType=4
478		end if
479	end if
480
481	isCompound = false
482
483	if RS1("IsCompound") then
484		isCompound = true
485		if RS1("IsRemoved") then
486			classType=2
487		else
488			classType=5
489		end if
490	end if 
491
492	if isBySubSystem then
493		stamp="<div style='width:220px; text-align:center; border:2 dashed green;padding:10px;font-size:12pt;font-weight:bold;'>��� �������� ��� ����� <br>("&statusString&")</div>"
494	elseif isCompound then
495		stamp="<div style='width:220px; text-align:center; border:2 dashed #9966CC;padding:10px;font-size:12pt;font-weight:bold;'>��� ����<br>("&statusString&")</div>"
496	else
497		stamp="<div style='width:120px; text-align:center; border:2 dashed red;padding: 10px;color:red;font-size:14pt;font-weight:bold;'>"&statusString&"</div>"
498	end if 
499
500	if RS1("deleted") then 
501		statusString = statusString & " (�����) "
502		stamp="<div style='border:2 dashed red;padding: 10px;color:red;font-size:14pt;font-weight:bold;'>�����</div>"
503		status = "deleted"
504		classType=0
505	end if 
506
507	%>
508	<SCRIPT LANGUAGE="JavaScript">
509	<!--
510	function showAcc(acc,moeen){
511		window.open('tafsili.asp?accountID='+acc+'&FromDate=<%=RS1("GLDocDate")%>&ToDate=<%=RS1("GLDocDate")%>&moeenFrom='+moeen+'&moeenTo='+moeen+'&act=Show');
512	}
513	function showGLAcc(num){
514		window.open('moeen.asp?accountID='+num+'&FromDate=<%=RS1("GLDocDate")%>&ToDate=<%=RS1("GLDocDate")%>&act=Show');
515	}
516	//-->
517	</SCRIPT>
518	<table border="0" cellpadding="0" cellspacing="0" align="center">
519		<tr height="20">
520			<td colspan=2></td>
521		</tr>
522		<tr height="10">
523			<td width="250"></td>
524			<td valign="top"><div style='position:absolute;'><%=stamp%></div></td>
525		</tr>
526		<tr height="20">
527			<td colspan=2></td>
528		</tr>
529	</table>
530
531	<table Border="0" align=center Cellspacing="1" Cellpadding="5" Dir="RTL" class="GLTable<%=classType%>">
532	<tr>
533		<th colspan=6>
534<%		if RS1("GLDocID")>0 then 
535			response.write "��� ����� " & RS1("GLDocID")
536		else 
537			response.write "��� ��� (����� ����: "& RS1("OldGLDocID") & ")"
538		end if 
539%>
540		</th>
541	</tr>
542	<tr>
543		<th colspan=7 style="padding:0">
544		<TABLE width="100%" border=0 Cellspacing="1" Cellpadding="10" Dir="RTL">
545		<TR class="GLTable<%=classType%>TR2">
546			<TD>����� ���: <%= RS1("id")%></TD>
547			<TD align=center>�����: <%=statusString%></TD>
548			<TD align=left>����� ���: <span dir=ltr><%= RS1("GLDocDate")%></span></TD>
549		</TR>
550		</TABLE>
551		</th>
552	</tr>
553	<tr class="GLTable<%=classType%>TR1">
554		<td style="width:20;"> # </td>
555		<td style="width:40;">������</td>
556		<td style="width:30;">����</td>
557		<td style="width:300;">���</td>
558		<td style="width:70;">������</td>
559		<td style="width:70;">��������</td>
560	</tr>
561<%
562	i=0
563	Do while not RS1.eof
564		i = i + 1
565		GLAccount = RS1("GLAccount")
566		AccTitle = RS1("AccountTitle")
567		GLAccTitle = RS1("name")
568		theDescription = RS1("Description")
569		Amount = Separate(RS1("Amount"))
570		IsCredit = RS1("IsCredit")
571		Tafsil = RS1("Tafsil")
572		Sys =	RS1("Sys")
573		ItemLink =	RS1("Link")
574
575		if len(sys)>1 then  'if isBySubSystem then
576			theLink = "ShowItem.asp?sys=" & sys & "&Item=" & ItemLink
577		else
578			theLink = "about:blank"
579		end if
580
581		credit = ""
582		debit = ""
583		if IsCredit then 
584			credit = Amount 
585			totalCredit = totalCredit + cdbl(Amount)
586		else
587			debit = Amount 
588			totalDebit = totalDebit + cdbl(Amount)
589		end if
590
591		%>
592		<tr <%if i mod 2 = 1 then%>class="GenRow1"<%else%>class="GenRow2"<%end if%>>
593			<td style="width:20;"> <%=i%> </td>
594			<td style="width:40;" title="<%=AccTitle%>"><A HREF="javascript:showAcc(<%=Tafsil%>,<%=GLAccount%>);" style="color:black;"><%=Tafsil%></A></td>
595			<td style="width:30;" title="<%=GLAccTitle%>"><A HREF="javascript:showGLAcc(<%=GLAccount%>);"><%=GLAccount%></A></td>
596			<td style="width:300; cursor:hand;" title="���� ����� ��� ������ ���� ����." onclick="window.open('<%=theLink%>');"><%=theDescription%></td>
597			<td style="width:80;"><%=debit%></td>
598			<td style="width:80;"><%=credit%></td>
599		</tr>
600		<%
601	RS1.movenext
602	loop	
603%>
604	<tr class="GLTable<%=classType%>TR1">
605		<td></td>
606		<td></td>
607		<td></td>
608		<td>���</td>
609		<td><%=Separate(totalDebit)%></td>
610		<td><%=Separate(totalCredit)%></td>
611	</tr>
612	</TABLE>
613	<BR><BR>
614	<CENTER>
615	<FORM METHOD=POST ACTION="?act=changeStatus&msg=����� ����� ��� ����� ��">
616		<INPUT TYPE="hidden" name="DocID" value="<%=GLDocID%>">
617		<INPUT TYPE="hidden" name="id" value="<%=id%>">
618	<% if status <> "deleted" then 
619		if status = "Draft" then 
620			if (((session("ID") = Creator) OR ( Auth( 8 , "H" ))) AND totalDebit=totalCredit) OR isBySubSystem then%>
621				<INPUT TYPE="submit" name="submit" value="����� �� ����" class="GenButton" onclick="return confirm('����� ����� ��� ����� ��Ͽ')"><%
622			end if
623
624			if isBySubSystem AND Auth( 8 , 8 ) then %>
625				<INPUT TYPE="submit" name="submit" value="������ ��� ��������" class="GenButton" style="border-color:red;">
626		<%	elseif isCompound then
627				if Auth( 8 , "F" ) then %>
628					<INPUT TYPE="submit" name="submit" value="������ ��� ����" class="GenButton" style="border-color:red;">
629					<INPUT TYPE="submit" name="submit" value="��� ��� ����" class="GenButton" style="border-color:red;" onclick="return confirm('��� ����� ����� �� �� ������ ��� ��� �� ��� ���Ͽ')">
630		<%		end if
631			else %>
632				<INPUT TYPE="submit" name="submit" value="������" class="GenButton" style="border-color:red;">
633				<INPUT TYPE="submit" name="submit" value="���" class="GenButton" style="border-color:red;" onclick="return confirm('��� ����� ����� �� �� ������ ��� ��� �� ��� ���Ͽ')"><%
634			end if 
635
636		elseif status = "Temporary" then 
637			if session("ID") = Creator OR Auth( 8 , 8 ) then%>
638				<INPUT TYPE="submit" name="submit" value="����� �� �������" class="GenButton" onclick="return confirm('����� ����� ��� ����� ��Ͽ')"><%
639			end if
640			if Auth( 8 , 8 ) then%>
641				<INPUT TYPE="submit" name="submit" value="����� ��" class="GenButton" onclick="return confirm('����� ����� ��� ����� ��Ͽ')"><%
642
643				if isBySubSystem AND Auth( 8 , 8 ) then %>
644					<INPUT TYPE="submit" name="submit" value="������ ��� ��������" class="GenButton" style="border-color:red;">
645			<%	elseif isCompound then
646					if Auth( 8 , "F" ) then %>
647						<INPUT TYPE="submit" name="submit" value="������ ��� ����" class="GenButton" style="border-color:red;">
648						<INPUT TYPE="submit" name="submit" value="��� ��� ����" class="GenButton" style="border-color:red;" onclick="return confirm('��� ����� ����� �� �� ������ ��� ��� �� ��� ���Ͽ')">
649			<%		end if
650				else %>
651					<INPUT TYPE="submit" name="submit" value="������" class="GenButton" style="border-color:red;">
652					<INPUT TYPE="submit" name="submit" value="���" class="GenButton" style="border-color:red;" onclick="return confirm('��� ����� ����� �� �� ������ ��� ��� �� ��� ���Ͽ')"><%
653				end if 
654
655			end if
656		elseif status = "Checked" then 	%>
657			<INPUT TYPE="submit" name="submit" value="����� �� ����" class="GenButton" onclick="return confirm('����� ����� ��� ����� ��Ͽ')">
658			<INPUT TYPE="submit" name="submit" value="���� ��" class="GenButton" onclick="return confirm('����� ����� ��� ����� ��Ͽ')">
659	<%	end if 
660	%>
661	<br><br>
662	<% if status <> "Draft" then %>
663		<% 	ReportLogRow = PrepareReport ("GLDoc.rpt", "GLDoc_ID", id, "/beta/dialog_printManager.asp?act=Fin") %>
664		<INPUT TYPE="button" value=" �ǁ " Class="GenButton" style="border:1 solid blue;" onclick="printThisReport(this,<%=ReportLogRow%>);">
665		<!--BR><iframe name=f1 id=f1 src="/CRReports/?Id=<%=ReportLogRow%>" align=center style="width:750; height:210; border-style: none" border=0 FRAMEBORDER=0 scrollbars=no ></iframe-->
666	<% end if %>
667	<INPUT TYPE="button" name="submit" value="������" class="GenButton" onclick="window.location='GLMemoDocShow.asp?fromSession=y'">
668	<% 
669	end if %>
670	</FORM>
671
672	<br>
673	<hr noshade color=white>
674	<%
675	mySQL="SELECT GLDocs.*, Users.RealName FROM GLDocs INNER JOIN Users ON GLDocs.createdBy = Users.ID where GLDocID="& GLDocID & " and GL = "& OpenGL & " ORDER BY GLDocs.ID"
676
677	set RS1=conn.execute(mySQL)
678
679	if not RS1.eof then
680		response.write " ��� ��� �� ����� ��� ��� ������ ��� ���: <br><br>"
681		do while not RS1.EOF
682			response.write "<li class=alak2 "
683			if trim(id) = trim(RS1("id")) then 
684				response.write " disabled "
685			end if
686			response.write "><A HREF='GLMemoDocShow.asp?id="& RS1("id") & "'> <span dir=ltr>"& RS1("CreatedDate") & "</span> ���� "& RS1("RealName") & " </a> <br>"
687			RS1.movenext
688		loop
689	end if 
690
691end if
692%>
693	<hr noshade color=white>
694	<BR>
695</center>
696<!--#include file="tah.asp" -->