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

/beta/accounting/GLMemoInput.asp

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