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

/beta/AO/Payroll.asp.tmp

http://github.com/khaneh/Orders
Unknown | 677 lines | 610 code | 67 blank | 0 comment | 0 complexity | bb2067b1e6c37528b696d9255336528f MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'A0 (11 [=B])
  3PageTitle= "ÍŢćŢ - ćÇă ć ŰíŃĺ"
  4SubmenuItem=6
  5if not Auth("B" , 8) 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'---------------------------- ShowErrorMessage
 15'---------------------------------------------
 16function ShowErrorMessage(msg)
 17	response.write "<table align='center' cellpadding='5'><tr><td bgcolor='#FFCCCC' dir='rtl' align='center'> ÎŘÇ ! <br>"& msg & "<br></td></tr></table><br>"
 18end function
 19
 20%>
 21<style>
 22	Table { font-size: 9pt;}
 23	.InvHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
 24	.InvRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right; width:100%;}
 25	.InvRowInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; direction:RTL; width:100%;}
 26	.InvHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
 27	.InvHeadInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right; direction: right-to-left;}
 28	.InvGenInput  { font-family:tahoma; font-size: 9pt; border: none; }
 29	.InvGenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
 30	.GLInput1 { font-family:tahoma; font-size: 9pt; border: 1px solid black; direction:RTL;}
 31	.GLInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; direction:LTR;}
 32	.GLTable1 { border: none; direction:RTL; border:1px dashed red ;} 
 33	.GLTable1 tr {height:20; background-color: #CCCC88; }
 34	.GLTable2 { border: none; direction:RTL;} 
 35	.GLTable2 tr {height:20; text-align:center; background-color: #C3C300; }
 36	.GLTable2 td {border-bottom: 1px solid black; border-right: 1px solid black;}
 37	.GLTable3 tr {background-color: #F0F0F0}
 38	.GLTR1 { font-family:tahoma; font-size: 9pt; height:30; text-align:center; vertical-align:top; background-color: #C3C300; }
 39'	.GLTR2 { height:20; text-align:center; background-color: #C3C300; }
 40	.GLTD1 { font-family:tahoma; font-size: 9pt; height:20; text-align:center; }
 41</style>
 42<SCRIPT LANGUAGE="JavaScript">
 43<!--
 44var okToProceed=false;
 45var currentRow=0;
 46var IsTaraz = false
 47//-->
 48</SCRIPT>
 49<%
 50'-----------------------------------------------------------------------------------------------------
 51'--------------------------------------------------------------------------------- Input a new AO MEMO
 52'-----------------------------------------------------------------------------------------------------
 53if request("act")="" then
 54
 55	mySQL="SELECT GLRows.*, Accounts.AccountTitle, GLAccounts.Name AS GLAccountTitle FROM GLRows INNER JOIN GLAccounts ON GLRows.GLAccount = GLAccounts.ID LEFT OUTER JOIN Accounts ON GLRows.Tafsil = Accounts.ID WHERE (GLRows.deleted = 0) AND (GLRows.GLDoc = 30 ) AND (GLAccounts.GL = 84 )"
 56	set RS2=conn.execute(mySQL)
 57
 58%>
 59<!-- ćŃćĎ ÇŘáÇÚÇĘ ÓäĎ -->
 60	<br>
 61	<input type="hidden" Name='tmpDlgArg' value=''>
 62	<input type="hidden" Name='tmpDlgTxt' value=''>
 63		<FORM METHOD=POST ACTION="GLMemoInput.asp?act=submitEditMemo" onsubmit="return checkValidation()">
 64		<table class="GLTable1" align="center" Cellspacing="0" Cellpadding="0">
 65			<tr class="GLTR1" align="center" Cellspacing="1" Cellpadding="0">
 66			<TD colspan="10"><TABLE Border="0" Width="100%" Cellspacing="1" Cellpadding="2" Dir="RTL">
 67				<TR>
 68				<TD align="left" >ĎÝĘŃ :</TD>
 69				<TD> <%=OpenGLName%>
 70				</TD>
 71				<TD align="left">ĘÇŃíÎ ÓäĎ :</TD>
 72				<TD>	
 73					<INPUT class="GLInput2" style="text-align:left;" NAME="GLMemoDate" TYPE="text" maxlength="10" size="10" value="<%=GLDocDate%>" onblur="acceptDate(this)">
 74				</TD>
 75				<TD align="left">ÔăÇŃĺ ÓäĎ :</TD>
 76				<TD>	
 77					<INPUT class="GLInput2" NAME="GLMemoNo" TYPE="text" maxlength="10" size="10" value="<%=id%>" readonly>
 78				</TD>
 79				</TR></TABLE></TD>
 80			</tr>
 81			<tr class="GLTR2">
 82				<TD colspan="10"><div>
 83				<TABLE class="GLTable2" Cellspacing="0" Cellpadding="0" >
 84				<tbody id="GLcols">
 85				<tr>
 86					<td style="width:26; border-right:none;"> # </td>
 87					<td style="width:60;">ĘÝŐíáí</td>
 88					<td style="width:40;">ăÚíä</td>
 89					<td style="width:250;">ÔŃÍ</td>
 90					<td style="width:80;">ČĎĺßÇŃ</td>
 91					<td style="width:80;">ČÓĘÇäßÇŃ</td>
 92					<td style="width:50;">ÔăÇŃĺ ß</td>
 93					<td style="width:70;">ĘÇŃíÎ ß</td>
 94				</tr>
 95				</tbody>
 96				</TABLE></div></TD>
 97			</tr>
 98			<tr>
 99			<TD colspan="10"><div style="overflow:auto; height:250px; width:*;">
100			<TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855" class="GLTable3" onclick='setCurrentCell()'>
101			<Tbody id="GLrows">
102<%
103			i = 0
104			Do while not RS2.eof
105				i = i + 1
106				GLAccount =		RS2("GLAccount")
107				GLAccTitle =	RS2("GLAccountTitle")
108				Tafsil =		RS2("Tafsil")
109				AccTitle =		RS2("AccountTitle")
110				Description =	RS2("Description")
111				Ref1 =			RS2("Ref1")
112				Ref2 =			RS2("Ref2")
113				Amount =		RS2("Amount")
114				IsCredit =		RS2("IsCredit")
115
116				credit = ""
117				debit = ""
118				if IsCredit  then 
119					credit = Amount 
120					totalCredit = totalCredit + cdbl(Amount)
121				else
122					debit = Amount 
123					totalDebit = totalDebit + cdbl(Amount)
124				end if
125%>
126			<tr bgcolor='#F0F0F0'>
127				<td style="width:25; border-right:none;" align=center> <%=i%> </td>
128				<td width="60">
129					<INPUT  class='InvRowInput' TYPE='text' NAME='Accounts' maxlength=6 value="<%=Tafsil%>" title="<%=AccTitle%>" onKeyPress='return mask(this);' onBlur='check(this);'></td>
130				<td width="40">
131					<INPUT class='InvRowInput2' TYPE='text' NAME='GLAccounts' maxlength=5 value="<%=GLAccount%>" title="<%=GLAccTitle%>" onKeyPress='return mask(this);' onBlur='check(this);'></td>
132				<td width="250">
133					<INPUT class='InvRowInput2' TYPE='text' NAME='Descriptions' value="<%=Description%>" onKeyPress='return mask(this);'></td>
134				<td width="80">
135					<INPUT class='InvRowInput2' TYPE='text' NAME='debits' value="<%=Separate(debit)%>" onKeyPress='return mask(this);' onBlur='check(this);'></td>
136				<td width="80">
137					<INPUT class='InvRowInput2' TYPE='text' NAME='credits' value="<%=Separate(credit)%>" onKeyPress='return mask(this);' onBlur='check(this);'></td>
138				<td width="50">
139					<INPUT class='InvRowInput2' TYPE='text' NAME='Refs1' maxlength=20 value="<%=Ref1%>" onKeyPress='return mask(this);'> </td>
140				<td width="70">
141					<INPUT  class='InvRowInput' TYPE='text' NAME='Refs2' maxlength=20 value="<%=Ref2%>" onKeyPress='return mask(this);' onBlur='acceptDate(this);'> </td>
142			</tr>
143				
144<%
145				RS2.movenext
146			Loop
147%>
148			<tr bgcolor='#F0F0F0'>
149				<td colspan="15">
150					<INPUT class="InvGenButton" TYPE="button" value="ÇÖÇÝĺ" onClick="addRow();">
151				</td>
152			</tr>
153			</Tbody>
154			</TABLE></div>
155			</TD>
156			</tr>
157			<tr class="GLTR2">
158				<TD colspan="10"><div>
159				<TABLE class="GLTable2" Cellspacing="0" Cellpadding="0" style="border-top:1 solid red;">
160				<tr>
161					<td colspan=3 style="width:256;">
162						<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>
163					<td style="width:122; text-align:left;">ĚăÚ ČĎĺßÇŃ:</td>
164					<td style="width:80;"><input type=text name="totalDebit" id="totalDebit" style="width:80;border:none; background:none;" value=<%=Separate(totalCredit)%>></td>
165					<td style="width:80;"><input type=text name="totalCredit" id="totalCredit" style="width:80;border:none; background:none;" value=<%=Separate(totalDebit)%>></td>
166					<td colspan=2 style="width:122; text-align:right;">:ĚăÚ ČÓĘÇäßÇŃ</td>
167				</tr>
168				</TABLE></div></TD>
169			</tr>
170		</table><br> 
171		<TABLE Border="0" Cellspacing="5" Cellpadding="0" Dir="RTL" align='left'>
172		<tr>
173			<td align='center'>
174			<INPUT TYPE="hidden" name="GLDoc" value="<%=GLDoc%>">
175			<INPUT class="InvGenButton" TYPE="submit" name="submit" value="ĐÎíŃĺ Čĺ ŐćŃĘ íÇĎĎÇÔĘ" onclick="saveDraft()">
176			<INPUT class="InvGenButton" TYPE="submit" value="ĐÎíŃĺ "></td>
177			<td align='center'><INPUT class="InvGenButton" TYPE="button" value="ÇäŐŃÇÝ" onclick="history.back()"></td>
178		</tr>
179		</TABLE>
180		</FORM>
181	<script language="JavaScript">
182	<!--
183	var dialogActive=false;
184
185	function mask(src){ 
186		var theKey=event.keyCode;
187/*
188		rowNo=src.parentNode.parentNode.rowIndex;
189		RTable=document.getElementById("GLrows");
190		theRow=RTable.getElementsByTagName("tr")[rowNo];
191*/
192		
193		if (src.name=="Accounts"){
194			if (theKey==13){
195				event.keyCode=0;
196				dialogActive=true;
197				document.all.tmpDlgArg.value="#"
198				document.all.tmpDlgTxt.value="ĚÓĘĚć ĎŃ äÇă ÍÓÇČ ĺÇí ĘÝŐíáí:"
199				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;');
200				dialogActive=false;
201				if (document.all.tmpDlgTxt.value !="") {
202					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;');
203					if (document.all.tmpDlgArg.value!="#"){
204						Arguments=document.all.tmpDlgArg.value.split("#")
205						src.value=Arguments[0];
206						src.title=Arguments[1];
207					}
208				}
209//				src.parentNode.nextSibling.getElementsByTagName("INPUT")[0].focus();
210			}
211			else if (theKey >= 48 && theKey <= 57 ) 
212				return true;
213			else
214				return false;
215		}
216		else if (src.name=="GLAccounts"){
217			if (theKey==13){
218				event.keyCode=0;
219				dialogActive=true;
220				document.all.tmpDlgArg.value="#"
221				document.all.tmpDlgTxt.value="ĚÓĘĚć ĎŃ äÇă ÍÓÇČ ĺÇí ĎÝĘŃ ßá:"
222				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;');
223				dialogActive=false;
224				if (document.all.tmpDlgTxt.value !="") {
225					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;');
226					if (document.all.tmpDlgArg.value!="#"){
227						Arguments=document.all.tmpDlgArg.value.split("#")
228						src.value=Arguments[0];
229						src.title=Arguments[1];
230					}
231				}
232//				src.parentNode.nextSibling.getElementsByTagName("INPUT")[0].focus();
233			}
234			else if (theKey >= 48 && theKey <= 57 ) // [0]-[9] are acceptible
235				return true;
236			else
237				return false;
238		}
239		else if (src.name=="debits" || src.name=="credits" || src.name=="Refs1"){
240			if (theKey < 48 || theKey > 57) { // [0]-[9] are acceptible
241				return false;
242			}
243			return true;
244		}
245		else if (src.name=="Descriptions" || src.name=="Refs2"){
246			if (theKey==13){  // [Enter] 
247				return false;
248			}
249			return true;
250		}
251	}
252
253	function check(src){ 
254		if (src.name=="Accounts"){
255			if (!dialogActive){
256				var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
257				objHTTP.Open('GET','xml_CustomerAccount.asp?id='+src.value,false)
258				objHTTP.Send()
259				tmpStr = unescape( objHTTP.responseText)
260				src.title=tmpStr;
261				if (tmpStr=="äíä ÍÓÇČí ćĚćĎ äĎÇŃĎ"){
262					src.value="";
263				}
264			}
265		}
266		else if(src.name=="GLAccounts"){
267			if (!dialogActive){
268				var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
269				objHTTP.Open('GET','xml_GLAccount.asp?id='+src.value,false)
270				objHTTP.Send()
271				tmpStr = unescape( objHTTP.responseText)
272				src.title=tmpStr;
273				if (tmpStr=="äíä ÍÓÇČí ćĚćĎ äĎÇŃĎ"){
274					src.value="";
275				}
276			}
277		}
278		else if(src.name=="debits" || src.name=="credits"){
279			src.value=val2txt(txt2val(src.value));
280			if (''+src.value=="NaN" || src.value=="0") src.value = ""
281			rowNo=src.parentNode.parentNode.rowIndex;
282
283			if (src.value!=""){
284				if (src.name=="credits") 
285					document.getElementsByName("debits")[rowNo].value = "";
286				else
287					document.getElementsByName("credits")[rowNo].value = "";
288			}
289
290			memoIsTaraz();
291			
292		}
293	}
294
295	function checkValidation(){ 
296		emptySlot=-1;
297		for (rowNo=0; rowNo < lastRow; rowNo++){
298			if(document.getElementsByName("GLAccounts")[rowNo].value==''){
299				emptySlot=rowNo;
300			}
301		}
302		if (emptySlot != -1){
303			errObj=document.getElementsByName("GLAccounts")[emptySlot];
304			errObj.style.backgroundColor="red";
305			document.getElementsByName("GLAccounts")[emptySlot].focus();
306			alert('Çíä ÓŘŃ Čí ăÚäí ÇÓĘ\n\nÇŃ ăí ÎćÇĺíĎ Âä ŃÇ ÍĐÝ ßäíĎ\n[Ctrl]+[Del]\nČŇäíĎ.');
307			errObj.style.backgroundColor="";
308			return false;
309		}
310
311		if (IsTaraz==true)
312			return true
313		else{
314			alert("ÎŘÇ! ÓäĎ ĘŃÇŇ äíÓĘ")
315			return false
316		}
317	}
318
319	function saveDraft(){ 
320		if (document.all.totalDebit.value != 0 || document.all.totalCredit.value != 0)
321				IsTaraz = true
322	}
323
324	function memoIsTaraz(){ 
325		var totalCredit = 0;
326		var totalDebit = 0;
327		for (rowNo=0; rowNo < lastRow; rowNo++){
328			totalCredit += parseInt(txt2val(document.getElementsByName("credits")[rowNo].value));
329			totalDebit += parseInt(txt2val(document.getElementsByName("debits")[rowNo].value));
330		}
331		document.all.totalCredit.value = val2txt(totalCredit);
332		document.all.totalDebit.value = val2txt(totalDebit);
333		if (totalDebit == totalCredit && totalCredit != 0){
334			IsTaraz = true
335			document.all.tarazDiv.innerHTML = "<FONT COLOR='#008833'>ÓäĎ ĘŃÇŇ ÇÓĘ</FONT>"
336		}
337		else{
338			IsTaraz = false
339			document.all.tarazDiv.innerHTML = "<FONT COLOR='#FF3300'>ÓäĎ ĘŃÇŇ äíÓĘ</FONT>"
340		}
341	}
342
343	var currentRow=0;
344	var lastRow=<%=i%>;
345	var currentCol=1;
346	var lastCol=7;
347
348	function documentKeyDown() {
349		var theKey = event.keyCode;
350		/*	
351			Arrow Keys' Codes:
352			<	37	(Left)
353			^	38	(Up)
354			>	39	(Right)
355			v	40	(Down)
356		*/
357		if (event.ctrlKey && !event.shiftKey)
358			Ctrl=true;
359		else
360			Ctrl=false;
361
362		if (theKey==9){
363			Ctrl=true;
364			if (event.shiftKey){
365				theKey = 39;
366			}
367			else
368				theKey = 37;
369		}
370		else if ((theKey == 45) && Ctrl){			// [Ins] Key + [ctrl]
371			event.keyCode=36; // [Home] Key
372			addRow();
373		}
374		else if ((theKey == 46) && Ctrl){			// [Del] Key + [ctrl]
375			event.keyCode=36; // [Home] Key
376			delRow()
377		}
378
379		if (((theKey == 37 || theKey == 39) && Ctrl) || theKey == 38 || theKey == 40){
380			
381			deactivateCurrentCell();
382
383			switch (theKey){
384			case 37:
385				if (currentCol < lastCol) 
386					currentCol++;
387				else{
388					currentCol=1;
389					if(currentRow<lastRow)
390						currentRow++;
391				}
392				break;
393			case 38:
394				if (currentRow > 0) 
395					currentRow--;
396				else
397					currentRow=lastRow;
398				break;
399			case 39:
400				if (currentCol > 1) 
401					currentCol--;
402				else{
403					currentCol=lastCol;
404					if(currentRow>0)
405						currentRow--;
406				}
407				break;
408			case 40:
409				if (currentRow < lastRow) 
410					currentRow++;
411				else
412					currentRow=0;
413				break;
414			default:
415				break;
416			}
417
418			activateCurrentCell();
419
420			event.keyCode=36; // [Home] Key
421		}
422	}
423
424	function deactivateCurrentCell(){
425		Rtable=document.getElementById("GLrows");
426		Ctable=document.getElementById("GLcols");
427		
428		Rtable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[0].setAttribute("bgColor", '#F0F0F0');
429		Ctable.getElementsByTagName("tr")[0].getElementsByTagName("td")[currentCol].setAttribute("bgColor", '#F0F0F0');
430
431		tmpCell=Rtable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[currentCol];
432		if (tmpCell){
433			tmpCell.setAttribute("bgColor", '');
434		}
435	}
436
437	function activateCurrentCell(){
438		Rtable=document.getElementById("GLrows");
439		Ctable=document.getElementById("GLcols");
440		
441		Rtable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[0].setAttribute("bgColor", '#FFB0B0');
442		Ctable.getElementsByTagName("tr")[0].getElementsByTagName("td")[currentCol].setAttribute("bgColor", '#FFB0B0');
443
444		tmpCell=Rtable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[currentCol];
445		if (tmpCell){
446			tmpCell.setAttribute("bgColor", '#FF0000');
447			tmpCell.getElementsByTagName("input")[0].focus();
448		}
449		if(currentRow==lastRow){
450			document.getElementById("GLrows").getElementsByTagName("tr")[currentRow].getElementsByTagName("INPUT")[0].focus();
451		}
452	}
453
454	function setCurrentCell(){
455		tmpRow=event.srcElement.parentNode.parentNode.rowIndex;
456		tmpCol=event.srcElement.parentNode.cellIndex;
457		if(tmpCol>0 && tmpRow>=0){
458			deactivateCurrentCell();
459
460			currentRow =tmpRow;
461			currentCol=tmpCol;
462
463			activateCurrentCell();
464		}
465		else if(event.srcElement.parentNode.rowIndex){
466			deactivateCurrentCell();
467
468			currentRow =event.srcElement.parentNode.rowIndex;
469			currentCol=1;
470
471			activateCurrentCell();
472		}
473	}
474
475	function delRow(){
476		if (currentRow==lastRow)
477			return;
478		deactivateCurrentCell();
479		rowNo = currentRow
480		Rtable=document.getElementById("GLrows");
481		theRow=Rtable.getElementsByTagName("tr")[rowNo];
482		Rtable.removeChild(theRow);
483
484		lastRow--;
485
486		for (rowNo=0; rowNo < lastRow ; rowNo++){
487			tempTD=Rtable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0]
488			tempTD.bgColor= '#F0F0F0';
489			tempTD.innerText= rowNo+1;
490		}
491		activateCurrentCell();
492	}
493	function addRow(){
494
495		deactivateCurrentCell();
496		rowNo = currentRow
497		Rtable=document.getElementById("GLrows");
498		theRow=Rtable.getElementsByTagName("tr")[rowNo];
499		newRow=document.createElement("tr");
500		newRow.setAttribute("bgColor", '#f0f0f0');
501
502		tempTD=document.createElement("td");
503		tempTD.innerHTML=rowNo+1
504		tempTD.setAttribute("align", 'center');
505		tempTD.setAttribute("width", '25');
506		newRow.appendChild(tempTD);
507
508		tempTD=document.createElement("td");
509		tempTD.setAttribute("width", '60');
510		tempTD.innerHTML="<INPUT class='InvRowInput'  TYPE='text' NAME='Accounts' maxlength=6 onKeyPress='return mask(this);' onBlur='check(this);'>"
511		newRow.appendChild(tempTD);
512
513		tempTD=document.createElement("td");
514		tempTD.setAttribute("width", '40');
515		tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='GLAccounts' maxlength=5 onKeyPress='return mask(this);' onBlur='check(this);'>"
516		newRow.appendChild(tempTD);
517
518		tempTD=document.createElement("td");
519		tempTD.setAttribute("width", '250');
520		tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='Descriptions' onKeyPress='return mask(this);'>"
521		newRow.appendChild(tempTD);
522
523		tempTD=document.createElement("td");
524		tempTD.setAttribute("width", '80');
525		tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='debits' onKeyPress='return mask(this);' onBlur='check(this);'>"
526		newRow.appendChild(tempTD);
527
528		tempTD=document.createElement("td");
529		tempTD.setAttribute("width", '80');
530		tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='credits' onKeyPress='return mask(this);' onBlur='check(this);'>"
531		newRow.appendChild(tempTD);
532
533		tempTD=document.createElement("td");
534		tempTD.setAttribute("width", '50');
535		tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='Refs1' maxlength=20 onKeyPress='return mask(this);'>"
536		newRow.appendChild(tempTD);
537
538		tempTD=document.createElement("td");
539		tempTD.setAttribute("width", '70');
540		tempTD.innerHTML="<INPUT class='InvRowInput' TYPE='text' NAME='Refs2' maxlength=20 onKeyPress='return mask(this);' onBlur='acceptDate(this);'>"
541		newRow.appendChild(tempTD);
542
543
544		Rtable.insertBefore(newRow,theRow);
545		
546		lastRow++;
547
548		for (rowNo=0; rowNo < lastRow ; rowNo++){
549			tempTD=Rtable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0]
550			tempTD.bgColor= '#F0F0F0';
551			tempTD.innerText= rowNo+1;
552		}
553
554		activateCurrentCell();
555
556	}
557
558	document.onkeydown = documentKeyDown;
559	activateCurrentCell();
560	memoIsTaraz();
561	//-->
562	</script>
563
564<%
565'-----------------------------------------------------------------------------------------------------
566'---------------------------------------------------------------------------------- Submit new AO MEMO
567'-----------------------------------------------------------------------------------------------------
568elseif request("act")="submit" then
569
570response.write "ok"
571response.end
572
573	creationDate=shamsiToday()
574
575	successCount=0
576	for i=1 to request.form("Accounts").count 
577		errorFound=false
578		ON ERROR RESUME NEXT
579			Account =		clng(text2value(request.form("Accounts")(i)))
580			firstGLAccount=	clng(text2value(request.form("firstGLAccounts")(i)))
581			GLAccount =		clng(text2value(request.form("GLAccounts")(i)))
582			Amount =		cdbl(text2value(request.form("Amounts")(i)))
583			Description=	sqlSafe(request.form("Descriptions")(i))
584			EffectiveDate =	sqlSafe(request.form("EffectiveDates")(i))
585
586			if request.form("isCredits")(i) then
587				isCredit = 1
588			else
589				isCredit = 0
590			end if
591			if Err.Number<>0 then
592				Err.clear
593				errorFound=True
594			end if
595			if NOT errorFound then
596			' checking firstGLAccount is valid
597				mySQL = "SELECT ID FROM GLAccounts WHERE (HasAppendix = 1) AND (GL = "& openGL & ") AND (ID = "& firstGLAccount & ")"
598				Set RS1=Conn.execute(mySQL)
599				if RS1.eof then
600					errorFound=True
601				end if
602				RS1.close
603
604				mySQL = "SELECT ItemReason FROM AXItemReasonGLAccountRelations WHERE (GL = "& openGL & ") AND (GLAccount = "& firstGLAccount & ")"
605				Set RS1=Conn.execute(mySQL)
606				if RS1.eof then
607					'Using default reason (sys: AO, reason: Misc.)
608					Reason=6
609				else
610					Reason=	cint(RS1("ItemReason"))
611				end if
612				RS1.close
613
614				mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")"
615				Set RS1=Conn.execute(mySQL)
616				sys=			RS1("Acron")
617				ReasonName =	RS1("Name")
618				RS1.close
619			' ---------
620
621			'---- Checking wether EffectiveDate is valid in current open GL
622				if (effectiveDate < session("OpenGLStartDate")) OR (effectiveDate > session("OpenGLEndDate")) then
623					errorFound=True
624				end if 
625			'----
626			end if
627		ON ERROR GOTO 0
628
629		if errorFound then
630			response.write "<br>" 
631			errMsg="ÎŘÇ!<br>ÎŘ ČÇ ăÔÎŐÇĘ ŃíŇ ÇÖÇÝĺ äÔĎ:<br>"
632			errMsg=errMsg& "ÍÓÇČ:" & firstGLAccount & "-" & Account & "<br>"
633			errMsg=errMsg& "ăČáŰ:" & Amount & "<br>"
634			errMsg=errMsg& "ÔŃÍ:" & Description & "<br>"
635			errMsg=errMsg& "ŘŃÝ ăÚíä:" & GLAccount & "<br>"
636			errMsg=errMsg& "ĘÇŃíÎ :" & effectiveDate & "<br>"
637			call showAlert (errMsg,CONST_MSG_ERROR) 
638		else
639			'**************************** Creating Memo ****************
640			'MemoType = 1 means Misc. Memo
641			mySQL="INSERT INTO "& sys & "Memo (CreatedDate, CreatedBy, Type, Account, IsCredit, Amount, Description) VALUES (N'"& effectiveDate & "' , "& session("id") & ", 1, "& Account & ", "& IsCredit & ", "& Amount & ", N'"& Description & "');SELECT @@Identity AS NewMemo"
642			Set RS1 = conn.Execute(mySQL).NextRecordSet
643			MemoID=RS1("NewMemo")
644			RS1.close
645
646			'**************************** Creating an Item for Memo ****************
647			'*** Type = 3 means Item is a Memo
648
649			mySQL="INSERT INTO "& sys & "Items (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, Link, Reason, CreatedDate, CreatedBy, Type, IsCredit,  AmountOriginal, RemainedAmount) VALUES ("&_
650			GLAccount & ", "& OpenGL & ", "& firstGLAccount & ", "& Account & ", N'"& effectiveDate & "', "& MemoID & ", "& Reason & ", N'"& creationDate & "' , "& session("id") & ", 3, "& IsCredit & ",  "& Amount & ","& Amount & ")"
651			conn.Execute(mySQL)
652		
653			if IsCredit then
654				mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance + '"& Amount & "' WHERE (ID='"& Account & "')"
655			else
656				mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance - '"& Amount & "' WHERE (ID='"& Account & "')"
657			end if
658			conn.Execute(mySQL)
659			'***------------------------- Creating an Item for Memo ----------------
660			successCount = successCount + 1
661			msg="ÇÚáÇăíĺ <A Href='../"& sys & "/AccountReport.asp?act=showMemo&sys="& sys & "&memo=" & MemoID &"' target='_blank'>"& MemoID & "</a> ËČĘ ÔĎ."
662			response.write "<br>" 
663			call showAlert (msg,CONST_MSG_INFORM) 
664		end if
665	next	
666	response.write "<br>" 
667	response.write "<hr width='70%'>" 
668	response.write "<br>" 
669	call showAlert (successCount & " ÇÚáÇăíĺ ČÇ ăćÝŢíĘ ÇíĚÇĎ ÔĎ.",CONST_MSG_INFORM) 
670'-----------------------------------------------------------------------------------------------------
671'-----------------------------------------------------------------------------------------------------
672'-----------------------------------------------------------------------------------------------------
673end if
674conn.Close
675%>
676</font>
677<!--#include file="tah.asp" -->