PageRenderTime 52ms CodeModel.GetById 39ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/accounting/CompMemoInput.asp

http://github.com/khaneh/Orders
ASP | 1210 lines | 926 code | 188 blank | 96 comment | 140 complexity | a2afb2a0187dd937d32cc48b379e9c30 MD5 | raw file
   1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
   2'Accounting (8)
   3PageTitle= "��� ����"
   4SubmenuItem=2
   5if not Auth(8 , "F") then NotAllowdToViewThisPage()
   6
   7
   8'---------------------------------------------
   9'---------------------------- ShowErrorMessage
  10'---------------------------------------------
  11function ShowErrorMessage(msg)
  12	response.write "<table align='center' cellpadding='5'><tr><td bgcolor='#FFCCCC' dir='rtl' align='center'> ��� ! <br>"& msg & "<br></td></tr></table><br>"
  13end function
  14
  15Sub MakeSubsystemItem()
  16	'--- variables used:
  17	'	Conn
  18	'	Account 
  19	'	GLAccount
  20	'	GLMemoDate 
  21	'	IsCredit 
  22	'	Amount 
  23	'	theDescription 
  24	'	creationDate
  25	'
  26	'	Sys		(Must have value before)
  27	'	theItem	(Must have value before)
  28
  29	mySQL = "SELECT ItemReason FROM AXItemReasonGLAccountRelations WHERE (GL = "& openGL & ") AND (GLAccount = "& GLAccount & ")"
  30	Set RS1=Conn.execute(mySQL)
  31
  32	if RS1.eof then
  33		'Using default reason (sys: AO, reason: Misc.)
  34		Reason=6
  35	else
  36		Reason=	cint(RS1("ItemReason"))
  37	end if
  38	RS1.close
  39
  40	mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")"
  41	Set RS1=Conn.execute(mySQL)
  42	sys=			RS1("Acron")
  43	ReasonName =	RS1("Name")
  44	RS1.close
  45
  46	' * Note: This is affecting the first line info (Account) so it must be the opposite of isCredit
  47	'*** Memo Type=8 means 'Compound Memo'
  48	mySQL="INSERT INTO "& sys & "Memo (CreatedDate, CreatedBy, Type, Account, IsCredit, Amount, Description) VALUES (N'"&_
  49	GLMemoDate & "' , "& session("ID") & ", 8, "& Account & ", "& IsCredit & ", "& Amount & ", N'"& theDescription & "');SELECT @@Identity AS NewMemo"
  50	set RS1 = Conn.execute(mySQL).NextRecordSet
  51	theMemo = RS1("NewMemo")
  52	RS1.close
  53
  54	' * Note: there is no FirstGLAccount because this is a compound memo
  55	'*** Type = 3 means A*Item is a Memo
  56	mySQL="INSERT INTO "& sys & "Items (GLAccount, GL, Account, EffectiveDate, IsCredit, Type, Link, Reason, AmountOriginal, CreatedDate, CreatedBy, RemainedAmount, GL_Update) VALUES ('" &_
  57	GLAccount & "', "& OpenGL &", '"& Account & "', N'"& GLMemoDate & "', "& IsCredit & ", 3, "& theMemo & ", "& Reason & ", "& Amount & ", N'"& creationDate & "', "& session("ID") & ", "& Amount & ", 0);SELECT @@Identity AS NewItem"
  58	set RS1 = Conn.execute(mySQL).NextRecordSet
  59	theItem = RS1("NewItem")
  60	RS1.close
  61
  62	'*** Updating Accout's balance in the subsystem:
  63	if IsCredit then
  64		mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance + '"& Amount & "' WHERE (ID='"& Account & "')"
  65	else
  66		mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance - '"& Amount & "' WHERE (ID='"& Account & "')"
  67	end if
  68	conn.Execute(mySQL)
  69End Sub
  70%>
  71<!--#include file="top.asp" -->
  72<!--#include File="../include_farsiDateHandling.asp"-->
  73<!--#include File="../include_JS_InputMasks.asp"-->
  74
  75<style>
  76	Table { font-size: 9pt;}
  77	.InvRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; direction:LTR; width:100%;}
  78	.InvHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
  79	.InvRowInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: transparent; text-align:right; width:100%;}
  80	.InvRowInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid gray; background-color: #F0F0F0; text-align:right; width:100%;cursor:hand;}
  81	.InvHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
  82	.InvHeadInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right; direction: right-to-left;}
  83	.InvGenInput  { font-family:tahoma; font-size: 9pt; border: none; }
  84	.InvGenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
  85	.GLInput1 { font-family:tahoma; font-size: 9pt; border: 1px solid black; direction:RTL;}
  86	.GLInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; direction:LTR; text-align:right; }
  87	.GLTable1 { border: none; direction:RTL; border:1px dashed red ; width:685;} 
  88	.GLTable1 tr {height:20; background-color: #CCCC88; }
  89	.GLTable2 { border: none; direction:RTL;} 
  90	.GLTable2 tr {height:20; text-align:center; background-color: #F0F0F0; }
  91	.GLTable2 td {border-bottom: 1px solid black; border-right: 1px solid black;}
  92	.GLTable3 tr {background-color: #F0F0F0}
  93	
  94	.CompMemoEdit td {background-color: #CCCCCC; font-size:10pt;}
  95
  96	.GLTable5 { font-family:tahoma; font-size: 10pt; background-color: #66CCCC; border:2 solid #225555; padding:0; }
  97	.GLTable5 TH { background-color: #66BBCC; border: 0; font-size:16pt;border-bottom: 2 solid #225555;}
  98	.GLTable5TR  td { background-color: #EEEEEE; border: 0; font-size:10pt;}
  99	.GLTable5TR1 td{ background-color: #99DDDD; border: 0; }
 100	.GLTable5TR2 td{ background-color: #66CCCC; border: 0; }
 101
 102	.GLTR1 { font-family:tahoma; font-size: 9pt; height:30; text-align:center; vertical-align:top; background-color: #C3C300; }
 103	.GLTR2 { height:20; text-align:center; background-color: #C3C300; }
 104	.GLTD1 { font-family:tahoma; font-size: 9pt; height:20; text-align:center; }
 105</style>
 106<SCRIPT LANGUAGE="JavaScript">
 107<!--
 108var okToProceed=false;
 109var currentRow=0;
 110var IsTaraz = false
 111//-->
 112</SCRIPT>
 113<%
 114
 115ON ERROR RESUME NEXT
 116	DocID=	clng(request("DocID"))
 117	if Err.Number<>0 then Err.clear:DocID=0
 118	id=		clng(request("id"))
 119	if Err.Number<>0 then Err.clear:id=0
 120ON ERROR GOTO 0
 121
 122'-----------------------------------------------------------------------------------------------------
 123'----------------------------------------------------------------------------- Input a new GL Memo Doc
 124'-----------------------------------------------------------------------------------------------------
 125'xml_GLAccount.asp
 126if request("act")="" then
 127if session("IsClosed")="True" then 
 128	response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.")
 129end if
 130%>
 131<!-- ���� ������� ��� -->
 132	<br>
 133	<input type="hidden" Name='tmpDlgArg' value=''>
 134	<input type="hidden" Name='tmpDlgTxt' value=''>
 135	<BR>
 136		<FORM METHOD=POST ACTION="?act=submitMemo" onsubmit="return checkValidation()">
 137		<table class="GLTable1" align="center" Cellspacing="0" Cellpadding="0">
 138			<tr class="GLTR1" align="center" Cellspacing="1" Cellpadding="0">
 139			<TD colspan="10"><TABLE Border="0" Width="100%" Cellspacing="1" Cellpadding="2" Dir="RTL">
 140				<TR>
 141				<TD align="left">���� :</TD>
 142				<TD>	<%=OpenGLName%>
 143				</TD>
 144				<TD align="left">����� ��� :</TD>
 145				<TD>	
 146					<INPUT class="GLInput2" NAME="GLMemoDate" TYPE="text" maxlength="10" size="10" value="<%=shamsiToday()%>" onblur="acceptDate(this)" >
 147				</TD>
 148				<TD align="left">����� ��� :</TD>
 149				<TD>	
 150<%				mySQL="SELECT ISNULL(MAX(GLDocID),0) AS LastMemo FROM GLDocs WHERE GL='"& OpenGL & "'"
 151				Set RS1=conn.Execute (mySQL)
 152				LastMemo = RS1("LastMemo")
 153%>
 154					<INPUT class="GLInput2" NAME="GLMemoNo" TYPE="text" maxlength="10" size="10" value="<%=LastMemo+1%>">
 155				</TD>
 156				</TR></TABLE></TD>
 157			</tr>
 158			<tr class="GLTR2">
 159				<TD colspan="10" align=right><div>
 160
 161				<TABLE class="GLTable2" Cellspacing="0" Cellpadding="0" >
 162				<tr>
 163					<td style="width:26; border-right:none;"> # </td>
 164					<td style="width:60;">������</td>
 165					<td style="width:40;">����</td>
 166					<td style="width:300;">���</td>
 167					<td style="width:80;">������</td>
 168					<td style="width:80;">��������</td>
 169				</tr>
 170				</TABLE></div></TD>
 171			</tr>
 172			<tr>
 173			<td colspan="10">
 174			<div style="overflow:auto; height:250px; width:*;">
 175				<TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855" class="GLTable3">
 176				<Tbody id="GLrows">
 177				<tr bgcolor='#F0F0F0' onclick="setCurrentRow(this.rowIndex);" >
 178					<td colspan="6">
 179						<INPUT class="InvGenButton" TYPE="button" value="�����" onkeyDown="if(event.keyCode==9) {setCurrentRow(this.parentNode.parentNode.rowIndex); return false;};" onClick="addRow();">
 180					</td>
 181				</tr>
 182				</Tbody></TABLE>
 183			</div>
 184			</td>
 185			</tr>
 186			<tr bgcolor='#CCCC88'>
 187				<td align=left>
 188				<B><span id="tarazDiv"> </span></B>
 189				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 190				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 191				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 192				������  : <input type=text name="totalDebit" style="border:none; background:none;" value=0>
 193				&nbsp;&nbsp;&nbsp;
 194				�������� : <input type=text name="totalCredit" style="border:none; background:none;" value=0>
 195				</td>
 196			</tr>
 197			</table>
 198		<br> 
 199		<TABLE Border="0" Cellspacing="5" Cellpadding="0" Dir="RTL" align='left'>
 200		<tr>
 201			<td align='center'><INPUT class="InvGenButton" TYPE="submit" name="submit" value="�����"></td>
 202			<td align='center'><INPUT class="InvGenButton" TYPE="submit" name="submit" value="����� �� ���� �������" onclick="saveDraft()"> </td>
 203		</tr>
 204		</TABLE>
 205		</FORM>
 206
 207<%
 208'-----------------------------------------------------------------------------------------------------
 209'----------------------------------------------------------------------------- Submit Edit GL Memo Doc
 210'-----------------------------------------------------------------------------------------------------
 211
 212elseif request("act")="submitEditMemo" then
 213		if request.form("submit")="���" then
 214			response.write "asdfasdf"
 215			response.end
 216
 217		end if
 218
 219	ON ERROR RESUME NEXT
 220		if request.form("submit")="���" then
 221			IsTemporary = 0
 222		else
 223			IsTemporary = 1
 224		end if
 225
 226		GLMemoDate=		sqlSafe(request.form("GLMemoDate"))
 227		GLMemoNo=		clng(request.form("GLMemoNo"))
 228		totalDebit =	cdbl(text2value(request.form("totalDebit")))
 229		totalCredit=	cdbl(text2value(request.form("totalCredit")))
 230		GLDoc =			clng(request.form("GLDoc"))
 231
 232		TotalItemCount	=	request.form("GLAccounts").count 
 233
 234		ReDim Accounts(TotalItemCount)
 235		ReDim GLAccounts(TotalItemCount)
 236		ReDim Descriptions(TotalItemCount)
 237		ReDim Amounts(TotalItemCount)
 238		ReDim IsCredits(TotalItemCount)
 239		ReDim Syss(TotalItemCount)
 240		ReDim Links(TotalItemCount)
 241		ReDim Functions(TotalItemCount)
 242
 243		for i=1 to TotalItemCount
 244			Functions(i) =		request.form("Functions")(i)
 245			Accounts(i) =		clng(text2value(request.form("Accounts")(i)))
 246			GLAccounts(i) =		clng(text2value(request.form("GLAccounts")(i)))
 247			Descriptions(i) =	sqlSafe(request.form("Descriptions")(i))
 248			Syss(i) =			sqlSafe(request.form("Syss")(i))
 249			Links(i) =			sqlSafe(request.form("Links")(i))
 250			credit		=		cdbl(text2value(request.form("credits")(i)))	
 251			debit		=		cdbl(text2value(request.form("debits")(i)))	
 252			if credit <> "" and credit <> "0" then 
 253				Amounts(i) = credit 
 254				IsCredits(i)= 1
 255			else
 256				Amounts(i) = debit 
 257				IsCredits(i)= 0
 258			end if
 259		next	
 260
 261		if Err.Number<>0 then
 262			Err.clear
 263			conn.close
 264			response.redirect "top.asp?errMsg=" & Server.URLEncode("���!")
 265		end if
 266	ON ERROR GOTO 0
 267
 268	creationDate = shamsiToday()
 269	voidDate = creationDate 'for voided Memos
 270
 271	'---- Checking wether EffectiveDate is valid in current open GL
 272	if (GLMemoDate < session("OpenGLStartDate")) OR (GLMemoDate > session("OpenGLEndDate")) then
 273		Conn.close
 274		response.redirect "?act=editDoc&id="& GLMemoNo & "&errMsg=" & Server.URLEncode("���! ����� ���� ��� ����� �� ��� ���� ���� ����.")
 275	end if 
 276	'----
 277	'----- Check GL is closed
 278	if (session("IsClosed")="True") then 
 279		Conn.close
 280		response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.")
 281	end if 
 282	'----
 283
 284	'---- Marking old GLDoc and its GLRows as DELETED
 285	conn.Execute("UPDATE GLRows SET deleted = 1 WHERE (GLDoc = "& GLDoc & ")")
 286	conn.Execute("UPDATE GLDocs SET deleted = 1 WHERE (ID = "& GLDoc & ")")
 287	'---- 
 288	
 289	'---- Creating a new GLDoc 
 290	mySQL="INSERT INTO GLDocs (GL, GLDocID, GLDocDate, CreatedDate, createdBy, IsTemporary, IsCompound) VALUES ("& openGL & " , "& GLMemoNo & ", N'"& GLMemoDate & "' , N'"& creationDate & "', "& session("ID") & ", "& IsTemporary & ",1);SELECT @@Identity AS NewGLDoc"
 291	set RS1 = Conn.execute(mySQL).NextRecordSet
 292	GLDoc = RS1 ("NewGLDoc")
 293	RS1.close
 294	'---- 
 295
 296	'---- Inserting new GLRows 
 297	for i=1 to TotalItemCount
 298		if Functions(i)="V" then
 299			if Accounts(i) <> 0 then
 300			' Void Sybsystem Memo
 301
 302			  '***--- Voiding A*Item of Memo (Very Similar to sub voidMemo in ../AO/MemoVoid.asp ) ---
 303			  '*** Type = 3 means the Item is a Memo
 304			  '***
 305			    sys = Syss(i)
 306				voidedItem = Links(i) '** Links(i) contains A*Item id from GLRows
 307				Account = Accounts(i)
 308				Amount = Amounts(i)
 309				IsCredit = IsCredits(i)
 310
 311				'*********  Finding the A*Memo
 312				mySQL="SELECT Link FROM "& sys & "Items WHERE (Type=3) AND (ID='"& voidedItem & "')" 
 313				Set RS1=conn.Execute(mySQL)
 314				MemoID=RS1("Link")
 315
 316				'-------------------SAM
 317				'mySQL = "UPADTE "& sys & "Items SET GL_Update=0 WHERE (Type=3) AND (ID='"& voidedItem & "')" 
 318				'set RS1=conn.Execute(mySQL)
 319				
 320				'*********  Void the A*Memo
 321				mySQL="UPDATE "& sys & "Memo SET Voided=1, VoidedDate=N'"& voidDate & "', VoidedBy='"& session("ID") & "' WHERE (ID='"& MemoID & "')"
 322				conn.Execute(mySQL)
 323				 
 324				'*********  Finding other Items related to this Item
 325				if isCredit then
 326					mySQL="SELECT ID AS RelationID, Debit"& sys & "Item, Amount FROM "& sys & "ItemsRelations WHERE (Credit"& sys & "Item = '"& voidedItem & "')"
 327					Set RS1=conn.Execute(mySQL)
 328					Do While not (RS1.eof)
 329						'*********  Adding back the amount in the relation, to the *DEBIT* Item ...
 330						conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=RemainedAmount+ '"& RS1("Amount") & "', FullyApplied=0 WHERE (ID = '"& RS1("Debit"& sys & "Item") & "')")
 331
 332						'*********  Deleting the relation
 333						conn.Execute("DELETE FROM "& sys & "ItemsRelations WHERE ID='"& RS1("RelationID") & "'")
 334						
 335						RS1.movenext
 336					Loop
 337				else ' (isCredit==false)
 338					mySQL="SELECT ID AS RelationID, Credit"& sys & "Item, Amount FROM "& sys & "ItemsRelations WHERE (Debit"& sys & "Item = '"& voidedItem & "')"
 339					Set RS1=conn.Execute(mySQL)
 340					Do While not (RS1.eof)
 341						'*********  Adding back the amount in the relation, to the *CREDIT* Item ...
 342						conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=RemainedAmount+ '"& RS1("Amount") & "', FullyApplied=0 WHERE (ID = '"& RS1("Credit"& sys & "Item") & "')")
 343
 344						'*********  Deleting the relation
 345						conn.Execute("DELETE FROM "& sys & "ItemsRelations WHERE ID='"& RS1("RelationID") & "'")
 346						
 347						RS1.movenext
 348					Loop
 349				end if
 350
 351				'*********  Voiding A*Item 
 352				'conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=0, FullyApplied=0, Voided=1 WHERE (ID = '"& voidedItem & "')")
 353				' ------------- SAM ---------
 354				conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=0, FullyApplied=0, Voided=1 WHERE (ID = '"& voidedItem & "')")
 355				conn.Execute("UPDATE "& sys & "Items SET GL_Update=0 WHERE ID="&voidedItem)
 356				'----------------------------
 357				'**************************************************************
 358				'*				Affecting Account's A* Balance  
 359				'**************************************************************
 360				if isCredit then
 361					mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance - '"& Amount & "' WHERE (ID='"& Account & "')"
 362				else
 363					mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance + '"& Amount & "' WHERE (ID='"& Account & "')"
 364				end if
 365
 366				conn.Execute(mySQL)
 367				
 368				'***
 369			  '***--- End of Voiding A*Item of Memo --------------------------------------------------
 370			end if
 371		else
 372			if Accounts(i) <> 0 and Functions(i)="I" then
 373			' New Sybsystem Memo
 374				GLAccount = GLAccounts(i)
 375				Account = Accounts(i)
 376				Amount = Amounts(i)
 377				IsCredit = IsCredits(i)
 378				theDescription = Descriptions(i)
 379				Sys = Syss(i)
 380				theItem =Links(i)
 381
 382				' --------------------------------------------------------------
 383				' -----	Creating a Memo and an A*Item for this line
 384				' **************************************************
 385
 386				Call MakeSubsystemItem()
 387
 388				' **************************************************
 389				' ------ End of Creating Memo and A*Item for this line
 390				' --------------------------------------------------------------
 391
 392				Syss(i) = Sys 
 393
 394				Links(i) = theItem
 395			end if
 396			
 397			Syss(i) = "'" & Syss(i) & "'"
 398			if Accounts(i) = 0 then 
 399				Accounts(i) = "NULL"
 400				Syss(i) = "NULL"
 401				Links(i) = "NULL"
 402			end if
 403
 404			mySQL="INSERT INTO GLRows ( GLDoc, GLAccount,  Tafsil, Amount, Description, Sys, Link, IsCredit) VALUES ( "&_
 405			 GLDoc & ", "& GLAccounts(i) & ", "& Accounts(i) & ", "& Amounts(i) & ", N'"& Descriptions(i) & "', "& Syss(i) & ", "& Links(i) & ", "& IsCredits(i) & ")"
 406			 response.write mySQL
 407			 'response.end
 408
 409			conn.Execute(mySQL)
 410			
 411
 412		end if
 413	next	
 414	'---- 
 415	response.redirect "GLMemoDocShow.asp?id="& GLDoc & "&msg=" & Server.URLEncode("������� ��� ��.")
 416
 417'-----------------------------------------------------------------------------------------------------
 418'------------------------------------------------------------------------------ Submit new GL Memo Doc
 419'-----------------------------------------------------------------------------------------------------
 420elseif request("act")="submitMemo" then
 421
 422	GLMemoDate=request.form("GLMemoDate")
 423	GLMemoNo=request.form("GLMemoNo")
 424	totalDebit = text2value(request.form("totalDebit"))
 425	totalCredit = text2value(request.form("totalCredit"))
 426	creationDate = shamsiToday()
 427	if request.form("submit")="����� �� ���� �������" then
 428		IsTemporary = 0
 429	else
 430		IsTemporary = 1
 431	end if
 432
 433	
 434	if GLMemoNo="" or not(isnumeric(GLMemoNo)) then
 435		ShowErrorMessage("���! ����� ��� ���� ���� ���")
 436		response.end
 437	end if
 438
 439	'---- Checking wether EffectiveDate is valid in current open GL
 440	if (GLMemoDate < session("OpenGLStartDate")) OR (GLMemoDate > session("OpenGLEndDate")) then
 441		Conn.close
 442		response.write "<BR><BR><BR><CENTER>���! ��� ���� ��� ����� �� ��� ���� ���� ����.</CENTER>"
 443		response.end
 444	end if 
 445	'----
 446	'----- Check GL is closed
 447	if (session("IsClosed")="True") then
 448		Conn.close
 449		response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.")
 450	end if 
 451	'----
 452
 453	WarningMsg=""
 454	Set RS3=Conn.Execute ("SELECT GLDocID FROM GLDocs WHERE (GLDocID='"& GLMemoNo & "') AND (GL='"& OpenGL & "')")
 455	if not RS3.eof then
 456		Set RS3= Conn.Execute("SELECT Max(GLDocID) AS MaxGLDocID FROM GLDocs WHERE (GL='"& OpenGL & "')")
 457		GLMemoNo=RS3("MaxGLDocID")+1
 458		WarningMsg="����� ��� ������ ���.<br>��� �� ����� <B>"& GLMemoNo & "</B> ��� ��."
 459	end if
 460	RS3.Close
 461
 462	mySQL="INSERT INTO GLDocs (GL, GLDocID, GLDocDate, CreatedDate, createdBy,  IsTemporary, IsCompound) VALUES ("& OpenGL & " , "& GLMemoNo & ", N'"& GLMemoDate & "' , N'"& creationDate & "', "& session("id") & ", "& IsTemporary & ", 1);SELECT @@Identity AS NewGLDoc"
 463	set RS1 = Conn.execute(mySQL).NextRecordSet
 464	GLDoc = RS1 ("NewGLDoc")
 465	RS1.close
 466
 467
 468	for i=1 to request.form("Accounts").count 
 469		Account = text2value(request.form("Accounts")(i))
 470		GLAccount = text2value(request.form("GLAccounts")(i))
 471		theDescription = request.form("Descriptions")(i)
 472		debit = text2value(request.form("debits")(i))
 473		credit = text2value(request.form("credits")(i))
 474		Sys = "NULL"
 475		theItem ="NULL"
 476
 477		if credit <> "" and credit <> "0" then 
 478			Amount = credit 
 479			IsCredit = 1
 480		else
 481			Amount = debit 
 482			IsCredit = 0
 483		end if
 484
 485		if amount = "" then amount = 0
 486
 487		if Account <> 0 then
 488			' --------------------------------------------------------------
 489			' -----	Creating a Memo and an A*Item for this line
 490			' **************************************************
 491
 492			Call MakeSubsystemItem()
 493
 494			' **************************************************
 495			' ------ End of Creating Memo and A*Item for this line
 496			' --------------------------------------------------------------
 497			sys = "'" & sys & "'"
 498
 499		end if
 500
 501
 502		' --------------------------------------------------------------
 503		' ----- Creating the GLRow for this line
 504		if Account=0 then 
 505			Account = "NULL"
 506			Sys = "NULL"
 507			theItem ="NULL"
 508		end if
 509
 510		mySQL="INSERT INTO GLRows (GLDoc, Tafsil, GLAccount, Amount, Description, SYS, Link, IsCredit) VALUES ("&_
 511			GLDoc & ", " & Account & ", " & GLAccount & ", " & Amount & ", N'" & theDescription & "', " & sys & ", " & theItem & ", " & IsCredit & ")"
 512
 513		Conn.Execute(mySQL)
 514		' **************************************************
 515		' ----- End of Creating the GLRow for this line
 516		' --------------------------------------------------------------
 517
 518	next	
 519	conn.close
 520
 521	response.redirect "GLMemoDocShow.asp?id="& GLDoc &"&msg="& Server.URLEncode("��� �� ������ ����� ��.") &"&errmsg="& Server.URLEncode(WarningMsg)
 522
 523'-----------------------------------------------------------------------------------------------------
 524'---------------------------------------------------------------------------------- Edit a Compund Doc
 525'-----------------------------------------------------------------------------------------------------
 526elseif request("act")="editDoc" then
 527
 528
 529	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.Deleted = 0) AND (GLDocs.GLDocID="& id & ") AND (GLDocs.isCompound=1) AND (GLDocs.GL = "& OpenGL & ") AND (GLAccounts.GL = "& OpenGL & ") ORDER BY GLRows.ID"
 530	set RS1=conn.execute(mySQL)
 531
 532	if RS1.eof then
 533		response.write "<BR><BR><BR><CENTER>���! ���� ��� ����� �� ��� ��� ���� ���� �����</CENTER>"
 534		response.end
 535	end if 
 536
 537	GLDocID = RS1("GLDocID")
 538	Creator = RS1("CreatedBy")
 539
 540	classType=1
 541
 542
 543	if RS1("IsRemoved") OR RS1("deleted") then 
 544		response.write "<BR><BR><BR><CENTER>���! ��� ��� ���� ��� ��� ���.</CENTER>"
 545		response.end
 546	elseif RS1("BySubSystem") then 
 547		response.write "<BR><BR><BR><CENTER>���! ��� �� ��� �������� ���.</CENTER>"
 548		response.end
 549	elseif RS1("IsFinalized") then 
 550		response.write "<BR><BR><BR><CENTER>���! ��� ��� ���� ���� ��� ���.</CENTER>"
 551		response.end
 552	elseif RS1("IsChecked") then 
 553		response.write "<BR><BR><BR><CENTER>���! ��� ��� ���� ����� ��� ���.</CENTER>"
 554		response.end
 555	elseif RS1("IsTemporary") then 
 556		if Not (session("ID") = Creator OR Auth( 8 , 7 ) )then
 557			ShowErrorMessage("��� ���� �� ������ ��� ��� ������.")		
 558			conn.close
 559			response.end
 560		end if	
 561		statusString = " ���� "
 562		status = "Temporary"
 563		classType=1
 564
 565	else
 566		if Not (session("ID") = Creator OR Auth( 8 , 8 ) )then
 567			ShowErrorMessage("��� ���� �� ������ ��� ��� ������.")		
 568			conn.close
 569			response.end
 570		end if	
 571		statusString = " ������� "
 572		status = "Draft"
 573		classType=3
 574	end if 
 575	'----- Check GL is closed
 576	if (session("IsClosed")="True") then
 577		Conn.close
 578		response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.")
 579	end if 
 580	'----
 581
 582	isBySubSystem = false
 583
 584	if RS1("BySubSystem") then
 585		isBySubSystem = true
 586		if RS1("IsRemoved") then
 587			classType=2
 588		else
 589			classType=4
 590		end if
 591	end if
 592
 593	isCompound = false
 594
 595	if RS1("IsCompound") then
 596		isCompound = true
 597		if RS1("IsRemoved") then
 598			classType=2
 599		else
 600			classType=5
 601		end if
 602	end if 
 603
 604	%>
 605	<input type="hidden" Name='tmpDlgArg' value=''>
 606	<input type="hidden" Name='tmpDlgTxt' value=''>
 607
 608	<FORM METHOD=POST ACTION="?act=submitEditMemo" onsubmit="return checkValidation()">
 609	<table border="0" cellpadding="0" cellspacing="0" align="center">
 610		<tr height="20">
 611			<td colspan=2></td>
 612		</tr>
 613		<tr height="10">
 614			<td width="250"></td>
 615			<td valign="top"><div style='position:absolute;'><%=stamp%></div></td>
 616		</tr>
 617		<tr height="20">
 618			<td colspan=2></td>
 619		</tr>
 620	</table>
 621
 622	<table id="MemoTable" Border="0" align=center Cellspacing="1" Cellpadding="5" Dir="RTL" class="GLTable5">
 623	<tr>
 624		<th colspan=7>
 625			��� ����� <%=RS1("GLDocID")%> <INPUT TYPE='hidden' name='GLMemoNo' value='<%= RS1("GLDocID")%>'>
 626		</th>
 627	</tr>
 628	<tr>
 629		<th colspan=7 style="padding:0">
 630		<TABLE width="100%" border=0 Cellspacing="1" Cellpadding="10" Dir="RTL">
 631		<TR class="GLTable5TR2">
 632			<TD>����� ���: <%= RS1("id")%><INPUT TYPE='hidden' name='GLDoc' value='<%= RS1("ID")%>'></TD>
 633			<TD align=center>�����: <%=statusString%></TD>
 634			<TD align=left>����� ���: <span dir=ltr><%= RS1("GLDocDate")%><INPUT TYPE='hidden' name='GLMemoDate' value='<%= RS1("GLDocDate")%>'></span></TD>
 635		</TR>
 636		</TABLE>
 637		</th>
 638	</tr>
 639	<tr class="GLTable5TR1">
 640		<td style="width:20;">
 641			<div id="mnuDivHome" style="width:100%;height:100%;position:relative;cursor:hand;">
 642				<div id="mnuDiv" style = 'position:absolute;top:-4;left:-3; width:100; height:20; background-color:#DDDDDD; border: 1px solid red; visibility:hidden;' onmouseout="hideMenu();" onmouseover="keepMenu();"> 
 643					<IMG SRC='../images/s_undo.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT='������' onclick="undoRow();" onmouseover="keepMenu();"> 
 644					<IMG SRC='../images/s_delete.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT='����� ��� ��' onclick="voidRow();" onmouseover="keepMenu();"> 
 645					<IMG SRC='../images/s_insert.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT='��� �� ��' onclick="insertRow();" onmouseover="keepMenu();">
 646					<IMG SRC='../images/s_edit.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT='������ ��� ��' onclick="editRow();" onmouseover="keepMenu();"> 
 647				</div>
 648			</div>
 649		</td>
 650		<td style="width:20;"> # </td>
 651		<td style="width:50;">������</td>
 652		<td style="width:45;">����</td>
 653		<td style="width:300;">���</td>
 654		<td style="width:80;">������</td>
 655		<td style="width:80;">��������</td>
 656	</tr>
 657<%
 658	i=0
 659	Do while not RS1.eof
 660		i = i + 1
 661		GLAccount = RS1("GLAccount")
 662		accTitle = RS1("name")
 663		theDescription = RS1("Description")
 664		Amount = Separate(RS1("Amount"))
 665		IsCredit = RS1("IsCredit")
 666		Tafsil = RS1("Tafsil")
 667		Sys =	RS1("Sys")
 668		ItemLink =	RS1("Link")
 669
 670		if len(sys)>1 then  'if isBySubSystem then
 671			theLink = "ShowItem.asp?sys=" & sys & "&Item=" & ItemLink
 672		else
 673			theLink = "about:blank"
 674		end if
 675
 676		credit = ""
 677		debit = ""
 678		if IsCredit then 
 679			credit = Amount 
 680			totalCredit = totalCredit + cdbl(Amount)
 681		else
 682			debit = Amount 
 683			totalDebit = totalDebit + cdbl(Amount)
 684		end if
 685
 686		%>
 687		<tr class="GLTable5TR">
 688			<td ><div align=center style="width:100%;height:100%;position:relative;cursor:hand;" onmouseover="showMenu(this);">[+]</div></td>
 689			<td > <%=i%> 
 690				<INPUT TYPE='hidden' name='functions' value=''>
 691				<INPUT TYPE='hidden' name='Syss' value='<%=Sys%>'>
 692				<INPUT TYPE='hidden' name='Links' value='<%=ItemLink%>'>
 693			</td>
 694			<!---------------------SAM----------------->
 695			<td dir=ltr><INPUT class='InvRowInput2' TYPE='text' readonly NAME='Accounts'   value='<%=Tafsil%>'    style='width:50;' ></td>
 696			<td dir=ltr><INPUT class='InvRowInput2' TYPE='text' readonly NAME='GLAccounts' value='<%=GLAccount%>' style='width:45;' ></td>
 697			<td dir=rtl><INPUT class='InvRowInput2' TYPE='text' readonly NAME='Descriptions' value='<%=theDescription%>' style='width:300;' ></td>
 698			<td dir=ltr><INPUT class='InvRowInput2' TYPE='text' readonly NAME='debits'		value='<%=debit%>' style='width:80;' ></td>
 699			<td dir=ltr><INPUT class='InvRowInput2' TYPE='text' readonly NAME='credits'	value='<%=credit%>' style='width:80;' ></td>
 700		</tr>
 701		<%
 702	RS1.movenext
 703	loop	
 704%>
 705	<tr class="GLTable5TR1">
 706		<td style="width:20;" ><div align=center style="width:100%;height:100%;position:relative;cursor:hand;" onmouseover="showMenu(this);">[+]</div></td>
 707		<td></td>
 708		<td></td>
 709		<td></td>
 710		<td><DIV style="float:right;font-weight:bold;"><span id="tarazDiv"> </span></DIV><div style="float:left;">���</div></td>
 711		<td><input type="text" name="totalDebit" style="border:none; background:none; width:100%;" value="<%=Separate(totalDebit)%>"></td>
 712		<td><input type="text" name="totalCredit" style="border:none; background:none;width:100%;" value="<%=Separate(totalCredit)%>"></td>
 713	</tr>
 714	</TABLE>
 715	<TABLE Border="0" Cellspacing="5" Cellpadding="0" Dir="RTL" align='left'>
 716	<tr>
 717		<td align='center'><INPUT class="InvGenButton" TYPE="submit" name="submit" value="�����"></td>
 718		<!--td align='center'><INPUT class="InvGenButton" TYPE="submit" name="submit" value="���" style="border-color:red;" onclick="return confirm('��� ����� ����� �� �� ������ ��� ��� �� ��� ���Ͽ')"> </td-->
 719		<td align='center'><INPUT class="InvGenButton" TYPE="button" value="������" onclick="history.back()"></td>
 720	</tr>
 721	</TABLE>
 722	</FORM>
 723
 724<SCRIPT LANGUAGE="JavaScript">
 725<!--
 726var mnuCountr=0;
 727var mnuDiv = document.getElementById("mnuDiv");
 728function showMenu(src){
 729	if (! src.getElementsByTagName('DIV')[0]){
 730		mnuCountr+=2;
 731		mnuDiv.style.visibility="visible";
 732		src.appendChild(mnuDiv);
 733	}
 734}
 735function keepMenu(){
 736	//alert('keep');
 737	if (mnuCountr<4)
 738		mnuCountr+=2;
 739}
 740function hideMenu(){
 741	if (mnuCountr>0){
 742		mnuCountr-=1;
 743		setTimeout('hideMenu()',2000);
 744		return;
 745	}
 746	mnuCountr=0;
 747	mnuDiv.style.visibility='hidden';
 748	document.getElementById("mnuDivHome").appendChild(mnuDiv);
 749}
 750
 751function insertRow(){
 752	theRow = mnuDiv.parentNode.parentNode.parentNode
 753	
 754	mnuCountr=0;
 755	hideMenu();
 756	
 757	newRow=document.createElement("tr");
 758
 759	tempTD=document.createElement("td");
 760	tempTD.innerHTML="<div align=center style='width:100%;height:100%;position:relative;cursor:hand;' onmouseover='showMenu(this);'><IMG SRC='../images/s_insert.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT='��� ��� ���' ></div>"
 761	newRow.appendChild(tempTD);
 762
 763
 764	tempTD=document.createElement("td");
 765	tempTD.innerHTML="<INPUT TYPE='hidden' name='functions' value='I'><INPUT TYPE='hidden' name='Syss' value=''><INPUT TYPE='hidden' name='Links' value=''>";
 766	newRow.appendChild(tempTD);
 767
 768	tempTD=document.createElement("td");
 769	tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='Accounts' maxlength=6 onKeyPress='return mask(this);' onBlur='check(this);' >"
 770	newRow.appendChild(tempTD);
 771
 772	tempTD=document.createElement("td");
 773	tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='GLAccounts' maxlength=5 onKeyPress='return mask(this);' onBlur='check(this);' >"
 774	newRow.appendChild(tempTD);
 775
 776	tempTD=document.createElement("td");
 777	tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='Descriptions'>"
 778	newRow.appendChild(tempTD);
 779
 780	tempTD=document.createElement("td");
 781	tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='debits' onblur='setPrice(this)'  onKeyPress='return onlyNumber(this);'  onfocus='this.value=txt2val(this.value);this.select()' >"
 782	newRow.appendChild(tempTD);
 783
 784	tempTD=document.createElement("td");
 785	tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='credits' onblur='setPrice(this)' onKeyPress='return onlyNumber(this);'   onfocus='this.value=txt2val(this.value);this.select()' >"
 786	newRow.appendChild(tempTD);
 787
 788	newRow.className="CompMemoEdit";
 789
 790	theRow.parentNode.insertBefore(newRow,theRow)
 791
 792	newRow.getElementsByTagName('TD')[2].getElementsByTagName('INPUT')[0].focus();
 793
 794}
 795
 796function undoRow(){
 797	theRow = mnuDiv.parentNode.parentNode.parentNode
 798	tds = theRow.getElementsByTagName('TD')
 799
 800	mnuCountr=0;
 801	hideMenu();
 802
 803	func = tds[1].getElementsByTagName('INPUT')[0];
 804
 805	if (!func ){
 806		return;
 807	}
 808	else if (func.value=='I'){
 809		removeRow(theRow);
 810		memoIsTaraz();
 811		return;
 812	}
 813	else if (func.value!='E' && func.value!='V' ){
 814		alert('��� �� ��� ������ ��� ����.')
 815		return;
 816	}
 817
 818	theRow.className="GLTable5TR";
 819
 820	tds[0].getElementsByTagName('DIV')[0].innerHTML="[+]";
 821
 822	func.value='';
 823	if(tds[1].getElementsByTagName('DIV')[0])
 824		tds[1].removeChild(tds[1].getElementsByTagName('DIV')[0]);
 825
 826	tds[2].innerHTML="<INPUT class='InvRowInput2' TYPE='text' readonly NAME='Accounts'   value='" + tds[2].getElementsByTagName('INPUT')[0].defaultValue + "' >"
 827
 828	tds[3].innerHTML="<INPUT class='InvRowInput2' TYPE='text' readonly NAME='GLAccounts' value='" + tds[3].getElementsByTagName('INPUT')[0].defaultValue + "' >"
 829
 830	tds[4].innerHTML="<INPUT class='InvRowInput2' TYPE='text' readonly NAME='Descriptions' value='" + tds[4].getElementsByTagName('INPUT')[0].defaultValue + "' >"
 831
 832	tds[5].innerHTML= "<INPUT class='InvRowInput2' TYPE='text' readonly NAME='debits'	value='" + tds[5].innerText + tds[5].getElementsByTagName('INPUT')[0].defaultValue + "' >"
 833
 834	tds[6].innerHTML="<INPUT class='InvRowInput2' TYPE='text' readonly NAME='credits'	value='" + tds[6].innerText + tds[6].getElementsByTagName('INPUT')[0].defaultValue + "' >"
 835
 836	memoIsTaraz();
 837
 838}	
 839
 840function editRow(){
 841	theRow = mnuDiv.parentNode.parentNode.parentNode
 842	tds = theRow.getElementsByTagName('TD')
 843
 844	mnuCountr=0;
 845	hideMenu();
 846	
 847	func = tds[1].getElementsByTagName('INPUT')[0];
 848
 849
 850	if (!func || tds[2].getElementsByTagName('INPUT')[0].value){
 851		alert('��� ��� �� ��� ������ ������ ����.')
 852		return;
 853	}
 854
 855	theRow.className="CompMemoEdit";
 856
 857	tds[0].getElementsByTagName('DIV')[0].innerHTML="<IMG SRC='../images/s_edit.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT='��� ������ ���' >";
 858
 859	tds[1].getElementsByTagName('INPUT')[0].value='E';
 860	
 861	tds[3].innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='GLAccounts' maxlength=5 style='width:45;border:1px solid gray;cursor:hand;' onKeyPress='return mask(this);' onBlur='check(this);' Value='" + tds[3].getElementsByTagName('INPUT')[0].value + "'>"
 862
 863	tds[4].innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='Descriptions' maxlength=250 style='100%;border:1px solid gray;' Value='" + tds[4].getElementsByTagName('INPUT')[0].value + "'>"
 864
 865	tds[5].innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='debits'  style='border:1px solid gray;' onblur='setPrice(this)'  onKeyPress='return onlyNumber(this);'  onfocus='this.value=txt2val(this.value);this.select()' Value='" + tds[5].getElementsByTagName('INPUT')[0].value + "' >"
 866
 867	tds[6].innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='credits' style='border:1px solid gray;' onblur='setPrice(this)'  onKeyPress='return onlyNumber(this);'  onfocus='this.value=txt2val(this.value);this.select()' Value='" + tds[6].getElementsByTagName('INPUT')[0].value + "' >"
 868
 869	tds[3].getElementsByTagName('INPUT')[0].focus();
 870
 871}
 872
 873function removeRow(theRow){
 874
 875	//theRow = mnuDiv.parentNode.parentNode.parentNode
 876	tds = theRow.getElementsByTagName('TD')
 877
 878	//mnuCountr=0;
 879	//hideMenu();
 880	
 881	func = tds[1].getElementsByTagName('INPUT')[0];
 882
 883	if (!func ){
 884		alert('��� ��� �� ��� ������ ��� ����.')
 885		return;
 886	}
 887	else if (func.value=='E' || func.value==''){
 888		alert('��� ��� �� ��� ������ ��� ����.')
 889		return;
 890	}
 891	theRow.parentNode.removeChild(theRow);
 892
 893}
 894
 895function voidRow(){
 896	theRow = mnuDiv.parentNode.parentNode.parentNode
 897	tds = theRow.getElementsByTagName('TD')
 898
 899	mnuCountr=0;
 900	hideMenu();
 901
 902	func = tds[1].getElementsByTagName('INPUT')[0];
 903
 904	if (!func || func.value!=''){
 905		alert('��� ��� �� ��� ������ ���� ����.')
 906		return;
 907	}
 908
 909	theRow.className="CompMemoEdit";
 910
 911	tds[0].getElementsByTagName('DIV')[0].innerHTML="<IMG SRC='../images/s_delete.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT='��� ���� ���' >";
 912
 913	func.value="V"
 914	tds[1].innerHTML+="<div style='position:relative;'><div style='position:absolute;left:-610;top:-15;width:610;'><hr style='color:red;'></div></div>";
 915	
 916	tds[5].innerHTML = tds[5].getElementsByTagName('INPUT')[0].value + "<INPUT TYPE='hidden' name='debits' Value='"+tds[5].getElementsByTagName('INPUT')[0].value+"'>"
 917
 918	tds[6].innerHTML = tds[6].getElementsByTagName('INPUT')[0].value + "<INPUT TYPE='hidden' name='credits' Value='"+tds[6].getElementsByTagName('INPUT')[0].value+"'>"
 919
 920	memoIsTaraz()
 921
 922}
 923
 924//-->
 925</SCRIPT>
 926<%
 927end if
 928
 929'-----------------------------------------------------------------------------------------------------
 930'-----------------------------------------------------------------------------------------------------
 931'-----------------------------------------------------------------------------------------------------
 932
 933conn.Close
 934%>
 935</font>
 936<% if request("act")="" OR request("act")="editDoc" then%>
 937
 938<script language="JavaScript">
 939<!--
 940
 941function setCurrentRow(rowNo){
 942	if (rowNo == -1) rowNo=0;
 943	invTable=document.getElementById("GLrows");
 944	theTD=invTable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[0];
 945	theTD.setAttribute("bgColor", '#F0F0F0');
 946
 947	currentRow=rowNo;
 948	invTable=document.getElementById("GLrows");
 949	theTD=invTable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[0];
 950	theTD.setAttribute("bgColor", '#FFB0B0');
 951}
 952function delRow(rowNo){
 953	invTable=document.getElementById("GLrows");
 954	theRow=invTable.getElementsByTagName("tr")[rowNo];
 955	invTable.removeChild(theRow);
 956
 957	rowsCount=document.getElementsByName("Accounts").length;
 958	for (rowNo=0; rowNo < rowsCount ; rowNo++){
 959		tempTD=invTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0]
 960		tempTD.bgColor= '#F0F0F0';
 961		tempTD.innerText= rowNo+1;
 962	}
 963}
 964function addRow(){
 965	rowNo = currentRow
 966	invTable=document.getElementById("GLrows");
 967	theRow=invTable.getElementsByTagName("tr")[rowNo];
 968	newRow=document.createElement("tr");
 969	newRow.setAttribute("bgColor", '#f0f0f0');
 970	newRow.setAttribute("onclick", theRow.getAttribute("onclick"));
 971
 972	tempTD=document.createElement("td");
 973	tempTD.innerHTML=rowNo+1
 974	tempTD.setAttribute("align", 'center');
 975	tempTD.setAttribute("width", '26');
 976	newRow.appendChild(tempTD);
 977
 978	tempTD=document.createElement("td");
 979	tempTD.setAttribute("dir", 'LTR');
 980	tempTD.setAttribute("width", '60');
 981	tempTD.innerHTML="<INPUT class='InvRowInput'  TYPE='text' NAME='Accounts'   maxlength=6 onKeyPress='return mask(this);' onBlur='check(this);' style='width:100%;' >"
 982	newRow.appendChild(tempTD);
 983
 984	tempTD=document.createElement("td");
 985	tempTD.setAttribute("width", '40');
 986	tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='GLAccounts' maxlength=5 onKeyPress='return mask(this);' onBlur='check(this);' style='width:100%;' >"
 987	newRow.appendChild(tempTD);
 988
 989	tempTD=document.createElement("td");
 990	tempTD.setAttribute("width", '300');
 991	tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='Descriptions' style='width:100%;'>"
 992	newRow.appendChild(tempTD);
 993
 994	tempTD=document.createElement("td");
 995	tempTD.setAttribute("dir", 'LTR');
 996	tempTD.setAttribute("width", '80');
 997	tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='debits' style='width:100%;' onblur='setPrice(this)'  onKeyPress='return onlyNumber(this);'  onfocus='this.value=txt2val(this.value);this.select()'>"
 998	newRow.appendChild(tempTD);
 999
1000	tempTD=document.createElement("td");
1001	tempTD.setAttribute("dir", 'LTR');
1002	tempTD.setAttribute("width", '80');
1003	tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='credits' style='width:100%;'  onblur='setPrice(this)' onKeyPress='return onlyNumber(this);'   onfocus='setCurrentRow(this.parentNode.parentNode.rowIndex);this.value=txt2val(this.value);this.select()'>"
1004	newRow.appendChild(tempTD);
1005
1006
1007	invTable.insertBefore(newRow,theRow);
1008	
1009	rowsCount=document.getElementsByName("Accounts").length;
1010	for (rowNo=0; rowNo < rowsCount ; rowNo++){
1011		tempTD=invTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0]
1012		tempTD.bgColor= '#F0F0F0';
1013		tempTD.innerText= rowNo+1;
1014	}
1015
1016	invTable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[1].getElementsByTagName("Input")[0].focus();
1017//	document.all.dddd2.innerText=invTable.innerHTML
1018}
1019
1020function saveDraft(){ 
1021	if (document.all.totalDebit.value != 0 || document.all.totalCredit.value != 0)
1022			IsTaraz = true
1023}
1024
1025function checkValidation(){ 
1026	memoIsTaraz()
1027	if (IsTaraz==true)
1028		return true
1029	else{
1030		alert("���! ��� ���� ����")
1031		return false
1032	}
1033}
1034
1035var dialogActive=false;
1036
1037function mask(src){ 
1038	var theKey=event.keyCode;
1039	if (src.name=="Accounts"){
1040		if (theKey==32){
1041			event.keyCode=0;
1042			dialogActive=true;
1043			document.all.tmpDlgArg.value="#"
1044			document.all.tmpDlgTxt.value="����� �� ��� ���� ��� ������:"
1045			var myTinyWindow = window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
1046			dialogActive=false;
1047			if (document.all.tmpDlgTxt.value !="") {
1048				var myTinyWindow = window.showModalDialog('../ar/dialog_selectAccount.asp?act=select&search='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:300px; dialogWidth:600px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
1049				if (document.all.tmpDlgArg.value!="#"){
1050					Arguments=document.all.tmpDlgArg.value.split("#")
1051					src.value=Arguments[0];
1052					src.title=Arguments[1];
1053				}
1054			}
1055//				src.parentNode.nextSibling.getElementsByTagName("INPUT")[0].focus();
1056		}
1057		else if (theKey >= 48 && theKey <= 57 ) 
1058			return true;
1059		else
1060			return false;
1061	}
1062	else if (src.name=="GLAccounts"){
1063		if (theKey==32){
1064			event.keyCode=0;
1065			dialogActive=true;
1066			document.all.tmpDlgArg.value="#"
1067			document.all.tmpDlgTxt.value="����� �� ��� ���� ��� ���� ��:"
1068			var myTinyWindow = window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
1069			dialogActive=false;
1070			if (document.all.tmpDlgTxt.value !="") {
1071				var myTinyWindow = window.showModalDialog('dialog_selectGL.asp?act=select&name='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:500px; dialogWidth:380px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
1072				if (document.all.tmpDlgArg.value!="#"){
1073					Arguments=document.all.tmpDlgArg.value.split("#")
1074					src.value=Arguments[0];
1075					src.title=Arguments[1];
1076				}
1077			}
1078//				src.parentNode.nextSibling.getElementsByTagName("INPUT")[0].focus();
1079		}
1080		else if (theKey >= 48 && theKey <= 57 ) // [0]-[9] are acceptible
1081			return true;
1082		else
1083			return false;
1084	}
1085	else if (src.name=="debits" || src.name=="credits" || src.name=="Refs1"){
1086		if (theKey < 48 || theKey > 57) { // [0]-[9] are acceptible
1087			return false;
1088		}
1089		return true;
1090	}
1091	else if (src.name=="Descriptions" || src.name=="Refs2"){
1092		if (theKey==13){  // [Enter] 
1093			return false;
1094		}
1095		return true;
1096	}
1097}
1098
1099function onlyNumber(src){ 
1100	var theKey=event.keyCode;
1101	if (theKey==13){  // [Enter] 
1102		return true;
1103	}
1104	else if (theKey < 48 || theKey > 57) { // 0-9 are acceptible
1105		return false;
1106	}
1107}
1108
1109function areYouSureToExit()
1110{
1111	a= confirm("are you sure?")
1112	return a
1113}
1114
1115function setPrice(src){
1116	src.value=val2txt(txt2val(src.value));
1117	//rowNo=src.parentNode.parentNode.rowIndex;
1118	if (src.name=="credits" && src.value!=0) 
1119		src.parentNode.previousSibling.getElementsByTagName('INPUT')[0].value = ""
1120	if (src.name=="debits" && src.value!=0) 
1121		src.parentNode.nextSibling.getElementsByTagName('INPUT')[0].value = ""
1122	if (src.value ==0) src.value=""
1123	if (src.value ==" ") src.value=""
1124
1125	memoIsTaraz();
1126
1127}
1128
1129function check(src){ 
1130	if (src.name=="Accounts"){
1131		if (!dialogActive){
1132			if (window.XMLHttpRequest) {
1133			var objHTTP=new XMLHttpRequest();
1134		} else if (window.ActiveXObject) {
1135			var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
1136		}
1137			objHTTP.open('GET','xml_CustomerAccount.asp?id='+src.value,false)
1138			objHTTP.send()
1139			tmpStr = unescape( objHTTP.responseText)
1140			src.title=tmpStr;
1141			if (tmpStr=="���� ����� ���� �����"){
1142				src.value="";
1143			}
1144		}
1145	}
1146	else if(src.name=="GLAccounts"){
1147		if (!dialogActive){
1148			if (window.XMLHttpRequest) {
1149			var objHTTP=new XMLHttpRequest();
1150		} else if (window.ActiveXObject) {
1151			var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
1152		}
1153			objHTTP.open('GET','xml_GLAccount.asp?id='+src.value,false)
1154			objHTTP.send()
1155			tmpStr = unescape( objHTTP.responseText)
1156
1157			src.title=tmpStr;
1158			if (tmpStr=="���� ����� ���� �����"){
1159				src.value="";
1160			}
1161		}
1162	}
1163	else if(src.name=="debits" || src.name=="credits"){
1164		src.value=val2txt(txt2val(src.value));
1165		if (''+src.value=="NaN" || src.value=="0") src.value = ""
1166		//rowNo=src.parentNode.parentNode.rowIndex;
1167
1168		if (src.value!=""){
1169			if (src.name=="credits") 
1170				src.parentNode.previousSibling.getElementsByTagName('INPUT')[0].value = ""
1171			else
1172				src.parentNode.nextSibling.getElementsByTagName('INPUT')[0].value = ""
1173		}
1174
1175		memoIsTaraz();
1176		
1177	}
1178}
1179function memoIsTaraz(){ 
1180	var totalCredit = 0;
1181	var totalDebit = 0;
1182	rowsCnt=document.getElementsByName("debits").length
1183	for (rowNo=0; rowNo < rowsCnt; rowNo++){
1184		if (document.getElementsByName("credits")[rowNo].type!='hidden')
1185		totalCredit += parseInt(txt2val(document.getElementsByName("credits")[rowNo].value));
1186		if (document.getElementsByName("debits")[rowNo].type!='hidden')
1187		totalDebit += parseInt(txt2val(document.getElementsByName("debits")[rowNo].value));
1188	}
1189	document.all.totalCredit.value = val2txt(totalCredit);
1190	document.all.totalDebit.value = val2txt(totalDebit);
1191	if (totalDebit == totalCredit && totalCredit != 0){
1192		IsTaraz = true
1193		document.all.tarazDiv.innerHTML = "<FONT COLOR='#008833'>��� ���� ���</FONT>"
1194	}
1195	else{
1196		IsTaraz = false
1197		document.all.tarazDiv.innerHTML = "<FONT COLOR='#FF3300'>��� ���� ����</FONT>"
1198	}
1199
1200}
1201
1202setPrice(document.all.totalDebit)
1203setPrice(document.all.totalCredit)
1204if (parseInt(document.all.totalDebit.value)==0) IsTaraz=false;
1205
1206//-->
1207</SCRIPT>
1208
1209<%end if%>
1210<!--#include file="tah.asp" -->