PageRenderTime 16ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/bank/cheq.asp

http://github.com/khaneh/Orders
ASP | 701 lines | 597 code | 66 blank | 38 comment | 81 complexity | 61989798c9f88001aaec63023af00b75 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Bank (10 [=A])
  3PageTitle= "���� ��"
  4SubmenuItem=1
  5if not Auth("A" , 1) then NotAllowdToViewThisPage()
  6
  7sendTo = session("id")
  8editFlag = 0
  9
 10%>
 11<!--#include file="top.asp" -->
 12<!--#include File="../include_farsiDateHandling.asp"-->
 13<!--#include File="../include_JS_InputMasks.asp"-->
 14<style>
 15	.RcpTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; }
 16	.RcpMainTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; background-color: #558855; text-align:right; direction: RTL;}
 17	.RcpMainTableTH { background-color: #C3C300;}
 18	.RcpMainTableTR { background-color: #CCCC88; border: 0; }
 19	.RcpRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
 20	.RcpRowInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
 21	.RcpHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
 22	.RcpHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
 23	.RcpHeadInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #D0E0FF; text-align:right; direction: right-to-left;}
 24	.RcpGenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;}
 25	.GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
 26	.CustGenTable  { font-family:tahoma; font-size: 9pt;}
 27	.CustGenInput { font-family:tahoma; font-size: 9pt;}
 28</STYLE>
 29<SCRIPT LANGUAGE="JavaScript">
 30<!--
 31var okToProceed=false;
 32var currentRow=null;
 33
 34var tempKeyBuffer;
 35function myKeyDownHandler(){
 36	tempKeyBuffer=window.event.keyCode;
 37}
 38function myKeyPressHandler(){
 39//	alert (tempKeyBuffer)
 40	if (tempKeyBuffer>=65 && tempKeyBuffer<=90){
 41		window.event.keyCode=tempKeyBuffer+32;
 42	}
 43	else if(tempKeyBuffer==186){
 44		window.event.keyCode=59;
 45	}
 46	else if(tempKeyBuffer==188){
 47		window.event.keyCode=44;
 48	}
 49	else if(tempKeyBuffer==190){
 50		window.event.keyCode=46;
 51	}
 52	else if(tempKeyBuffer==191){
 53		window.event.keyCode=47;
 54	}
 55	else if(tempKeyBuffer==192){
 56		window.event.keyCode=96;
 57	}
 58	else if(tempKeyBuffer>=219 && tempKeyBuffer<=221){
 59		window.event.keyCode=tempKeyBuffer-128;
 60	}
 61	else if(tempKeyBuffer==222){
 62		window.event.keyCode=39;
 63	}
 64}
 65//-->
 66</SCRIPT>
 67<font face="tahoma">
 68<!-- <div dir='rtl'><B>���� ����� </B>
 69</div> -->
 70<%
 71'-----------------------------------------------------------------------------------------------------
 72'--------------------------------------------------------------------------------------- Submit Search
 73'-----------------------------------------------------------------------------------------------------
 74if request("act")="submit search" then
 75	if request("CustomerNameSearchBox") <> "" then
 76		SA_TitleOrName=sqlSafe(request("CustomerNameSearchBox"))
 77		mySQL="SELECT * FROM Accounts WHERE (REPLACE(AccountTitle, ' ', '') LIKE REPLACE(N'%"& SA_TitleOrName & "%', ' ', '') ) ORDER BY AccountTitle"
 78		Set RS1 = conn.Execute(mySQL)
 79
 80		if (RS1.eof) then 
 81			response.redirect "?errmsg=" & Server.URLEncode("���� ����� ���� ���.<br><a href='../CRM/AccountEdit.asp?act=getAccount'>���� ���Ͽ</a>")
 82
 83		' Not Found	%>
 84		<div dir='rtl'><B>���� ����� ���� ���</B> &nbsp; <A HREF="cheq.asp" style='font-size:7pt;'>������ ����</A>
 85		</div><br>
 86	<%	else 
 87			SA_TitleOrName=request("CustomerNameSearchBox")
 88			SA_Action="return true;"
 89			SA_SearchAgainURL="cheq.asp"
 90			SA_StepText="��� ��� : ������ ����"
 91%>
 92		<FORM METHOD=POST ACTION="cheq.asp?act=enterCheque">
 93			<!--#include File="../AR/include_SelectAccount.asp"-->
 94		</FORM>
 95<%
 96		end if
 97	end if
 98
 99'-----------------------------------------------------------------------------------------------------
100'-------------------------------------------------------------------------------------- Submit Payment
101'-----------------------------------------------------------------------------------------------------
102elseif request("act")="submitPayment" or editFlag = 1 then
103
104	ON ERROR RESUME NEXT
105
106		errorFound=false
107		CustomerID=			clng(request.form("CustomerID"))
108		accountID=			clng(request.form("accountID"))
109		TotalAmount=		cdbl(text2value(request.form("TotalAmount")))
110		VouchIDS=			request.form("VouchID")
111		VoucherTotalPrices= request.form("VoucherTotalPrice")
112		SumVoucherTotalPrice= cdbl(request.form("SumVoucherTotalPrice"))
113		Reason=				cint(request.form("Reason"))
114
115		if Err.Number<>0 then
116			'Err.clear
117			errorFound=	true
118			'errorMsg=	Server.URLEncode("���!")
119			errorMsg=	Err.Description
120			response.write errorMsg
121			response.end
122
123		end if
124
125		if NOT errorFound then
126			effectiveDate=	sqlSafe(request.form("PaymentDate"))
127			'---- Checking wether EffectiveDate is valid in current open GL
128			if (effectiveDate < session("OpenGLStartDate")) OR (effectiveDate > session("OpenGLEndDate")) then
129				errorFound=	true
130				errorMsg=	Server.URLEncode("���!<br>����� ���� ��� ����� ����.")
131			end if 
132			'----
133			'----- Check GL is closed
134			if (session("IsClosed")="True") then
135				'Conn.close
136				errorFound=true
137				errorMsg= Server.URLEncode("���! ��� ���� ���� ���� ��� � ��� ���� �� ����� �� �� ������.")
138			end if 
139			'----			
140			if TotalAmount=0 then 
141				errorFound=	true
142				errorMsg=	Server.URLEncode("<B>���!  </B><BR>����� ������ ��� ���<BR>")
143			end if 
144			CheqsCount=request.form("ChequeNos").count 
145			for i = 1 to CheqsCount
146				ChequeNo	= clng(request.form("ChequeNos")(i))
147				ChequeDate	= sqlSafe(request.form("ChequeDates")(i))
148				Banker		= cint(request.form("Banks")(i))
149				Description = sqlSafe(request.form("Description")(i))
150				Amount		= cdbl(text2value(request.form("Amounts")(i)))
151
152				if ChequeNo=0 or Banker=-1 or Amount=0 then  ' -- or ChequeDate="" 
153					errorFound=	true
154					errorMsg=	Server.URLEncode("<B>���!  </B><BR>������� �� ���� ���<BR>")
155				end if 
156				'---------------------SAM---------------------------------------------------------------
157				 
158				set che = conn.execute("Select COUNT(*) AS cheque From PaidCheques inner join Payments on PaidCheques.payment = Payments.ID Where PaidCheques.ChequeNo = " & ChequeNo & " AND PaidCheques.ChequeDate = N'" & ChequeDate & "' AND Payments.Voided = 0")
159				if cdbl(che("cheque")) > 0 then
160					errorFound = true
161					errorMsg = Server.URLEncode("<B>���! </B><br> ������� ��� �� ���� ���� ��� ���<br>")
162					call showAlert ("<B>���! </B><br> ������� ��� �� ���� ���� ��� ���<b>",CONST_MSG_ERROR)
163				end if
164				che.close
165			next
166		end if
167		if Err.Number<>0 then
168			'Err.clear
169			errorFound=	true
170			'errorMsg=	Server.URLEncode("���!")
171			errorMsg=	Err.Description
172		end if
173	ON ERROR GOTO 0
174
175	if errorFound then
176		conn.close
177		response.redirect "?act=getPayment&selectedCustomer="& CustomerID & "&Reason="& Reason & "&errMsg=" & errorMsg
178	end if
179
180	mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")"
181	Set RS1=Conn.execute(mySQL)
182	if RS1.eof then
183		conn.close
184		response.redirect "top.asp?errMsg=" & Server.URLEncode("���!")
185	else
186		Sys=			RS1("Acron")
187		firstGLAccount = accountID
188	end if
189	RS1.close
190
191	RemainedTotalAmount = TotalAmount
192
193	creationDate=	shamsiToday()
194	creationTime=	currentTime10()
195	GLAccount=		"NULL"
196
197	'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''	
198	dim APRemainedAmount(10)
199	dim APCreditID(10)
200	dim relationAmount(10)
201	dim n
202
203	if SumVoucherTotalPrice <> 0 and VouchIDS<>"" then		'Balance this payment with a previous APItem.
204
205		VouchID = split(VouchIDS, ",")
206		VoucherTotalPrice = split(VoucherTotalPrices, ",")
207		n = ubound(VouchID)
208
209		for vch = 0 to n  
210			set RSB=Conn.Execute ("SELECT * FROM  APItems WHERE (Type=6 and Link="& VouchID(vch) & ")" )
211			if RSB.EOF then
212				response.write "<br><BR>"
213				call showAlert ("<B>���!  </B><BR>������ �� ������ ��� ������ ���� ����. <br>��� ������ �� ��� ��� ������.<BR>",CONST_MSG_ERROR)
214				response.end
215			end if
216			if not trim(VoucherTotalPrice(vch)) = trim(RSB("AmountOriginal")) then
217				response.write "<br><BR>"
218				call showAlert ("<B>���!  </B><BR>������ �� ������ ��� ������ ���� ����. <br>��� ������ �� ��� ��� ������.<BR>",CONST_MSG_ERROR)
219				response.end
220			end if
221			APRemainedAmount(vch) = cdbl(RSB("RemainedAmount"))
222			APCreditID(vch) = RSB("ID")
223		next
224
225		for vch = 0 to n  
226			if RemainedTotalAmount = 0 then
227				relationAmount(vch) = 0
228			else
229				if APRemainedAmount(vch) > RemainedTotalAmount then
230					mySQL="UPDATE "& sys & "Items SET RemainedAmount='"& APRemainedAmount(vch) - RemainedTotalAmount & "' WHERE (ID='"& APCreditID(vch) & "')"
231					conn.Execute(mySQL)	
232					relationAmount(vch) = RemainedTotalAmount
233					RemainedTotalAmount = 0 
234				else
235					mySQL="UPDATE "& sys & "Items SET RemainedAmount='"& 0 & "' WHERE (ID='"& APCreditID(vch) & "')"
236					conn.Execute(mySQL)	
237					RemainedTotalAmount   = RemainedTotalAmount - APRemainedAmount(vch)
238					Conn.Execute ("UPDATE Vouchers SET paid = 1 WHERE (id = "& VouchID(vch) & ")")
239					relationAmount(vch) = APRemainedAmount(vch)
240				end if
241			end if 
242		next
243	end if
244
245	'************* Inserting the Payment
246	mySQL="INSERT INTO Payments (SYS, Account, CashAmount, ChequeAmount, CreatedBy, CreationDate, CreationTime, EffectiveDate) VALUES ('"& sys & "', "& customerID & ", 0, " & TotalAmount & ","& session("id") & ", N'"& creationDate & "', N'"& creationTime & "', N'"& effectiveDate & "');SELECT @@Identity AS NewPayment"
247	set RSE = Conn.execute(mySQL).NextRecordSet
248	paymentID = RSE ("NewPayment")
249	RSE.close
250	set RSE = Nothing
251
252	'************* Inserting Cheques
253	for i = 1 to CheqsCount
254		ChequeNo	= clng(request.form("ChequeNos")(i))
255		ChequeDate	= sqlSafe(request.form("ChequeDates")(i))
256		Banker		= cint(request.form("Banks")(i))
257		Description = sqlSafe(request.form("Description")(i))
258		Amount		= cdbl(text2value(request.form("Amounts")(i)))
259
260		conn.Execute("INSERT INTO PaidCheques (Payment, CreatedDate, CreatedBy, ChequeNo, ChequeDate, Amount, Banker, Status, StatusSetBy, StatusSetDate, Description) VALUES  ("& paymentID & ",N'"& creationDate & "','"& session("ID") & "',"& ChequeNo& ",N'"& ChequeDate& "',"& Amount& ","& Banker& ", 0, "& session("ID")& ", N'"& creationDate & "', N'"& Description & "')")
261
262	next
263
264	'*************	Creating an Item for the Payment �
265	'*** Type = 5 means Item is a Payment
266	'*** GLAccount = NULL because it can't be identified right now, it depends on where the cheques are�
267	mySQL="INSERT INTO "& sys & "Items (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, Reason, IsCredit, Type, Link, AmountOriginal, CreatedDate, CreatedBy, RemainedAmount) VALUES ("&_
268		GLAccount & ", '"& OpenGL & "', '"& firstGLAccount & "', '"& customerID & "', N'"& effectiveDate & "', '"& reason & "', 0, 5, '"& paymentID & "', '"& TotalAmount & "', N'"& creationDate & "', '"& session("ID") & "', '"& RemainedTotalAmount & "');SELECT @@Identity AS NewItem"
269	set RSF = Conn.execute(mySQL).NextRecordSet
270	APDebitID = RSF ("NewItem")
271	RSF.close 
272	Set RSF = Nothing
273
274	mySQL="UPDATE Accounts SET "& sys & "Balance="& sys & "Balance-"& TotalAmount & "  WHERE (ID = "& customerID & ")"
275	conn.Execute(mySQL)
276
277	'*************	Create the relations between 
278	'				the Payment and Selected Vouvhers 
279	if SumVoucherTotalPrice<> 0 and VouchIDS<>"" then
280		for vch = 0 to n  
281			if relationAmount(vch) = 0 then exit for
282			mySQL="INSERT INTO "& sys & "ItemsRelations (CreatedDate, CreatedBy, Credit"& sys & "Item, Debit"& sys & "Item, Amount) VALUES (N'"& creationDate & "', '"& session("ID") & "', '"& APCreditID(vch) &"', '"& APDebitID &"', '"& relationAmount(vch) &"')"
283			conn.Execute(mySQL)
284		next
285	end if
286	''''------------------------------------------------
287
288	Conn.close
289	response.redirect "../"& sys & "/AccountReport.asp?act=showPayment&payment="& paymentID & "&msg=" & Server.URLEncode("������ ����� ��.")
290
291'-----------------------------------------------------------------------------------------------------
292'--------------------------------------------------------------------------------------- Input cheques
293'-----------------------------------------------------------------------------------------------------
294elseif request("act")="enterCheque" then 
295	customerID=request("selectedCustomer")
296	VouchIDS = request("VouchID")
297	lastCustomerID = -1
298	SumAPAmountOriginal=0
299	SumAPRemainedAmount=0
300	SumVoucherTotalPrice=0
301	VoucherTotalPrice = -1
302	Reason = 0 ' Old Code: Reason = 2 ' Sys: AP
303	if request("Reason")<>"" then Reason=request("Reason")
304
305	if VouchIDS<>"" then
306		VouchIDarray = split(VouchIDS,",")
307		for i=0 to ubound(VouchIDarray) 
308			VouchID = VouchIDarray(i)
309
310			set RSV=Conn.Execute ("SELECT * FROM  Vouchers WHERE (id="& VouchID & ")" )
311			if not RSV.eof then
312				set RSB=Conn.Execute ("SELECT * FROM  APItems WHERE (Type=6 and Link="& VouchID & ")" )
313				if RSB.EOF then
314					response.write "<br><BR>"
315					call showAlert ("<B>���!  </B><BR>����� ������ ��� ������ ���� �����",CONST_MSG_ERROR)
316					response.end
317				end if
318				customerID = RSV("VendorID")
319				if lastCustomerID <> -1 and customerID<>lastCustomerID then
320					response.write "<br><BR>"
321					call showAlert ("<B>���!  </B><BR>��� �������� ����� �� �� ���� ���� 					<BR><BR><A HREF='payment.asp'>�ѐ��</A>",CONST_MSG_ERROR)
322					response.end
323				end if
324				LastCustomerID = customerID 
325			else
326				response.write "<br><BR>"
327				call showAlert ("<B>���!  </B><BR>���� ������� ���� �����",CONST_MSG_ERROR)
328				response.end
329			end if
330		next
331	else
332		if customerID = "" then
333			response.redirect "cheq.asp"
334		end if
335	end if
336
337
338	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
339	mySQL="SELECT * FROM Accounts WHERE (ID='"& CustomerID & "')"
340	Set RS1 = conn.Execute(mySQL)
341	customerName=RS1("AccountTitle")
342
343	creationDate=	shamsiToday()
344	creationTime=	currentTime10()
345%>	
346	<br>
347	<div dir='rtl'>&nbsp;&nbsp;<B>��� ���: ���� ������� �� ��</B>
348	</div>
349<!--#include File="../include_JS_InputMasks.asp"-->
350
351<!-- ���� ������� ������ ��� -->
352	<hr>
353	<SCRIPT LANGUAGE="JavaScript">
354	<!--
355		function checkValidation(){
356		  try{
357
358			tmpBox=document.getElementsByName('PaymentDate')[0];
359			if (tmpBox.value!='' && tmpBox.value!=null){
360				if (!acceptDate(tmpBox))
361					return false;
362			}
363			else{
364				tmpBox.focus();
365				alert("����� ���� ����")
366				return false;
367			}
368
369			tmpBox=document.getElementsByName('TotalAmount')[0];
370			if (txt2val(tmpBox.value)==0){
371				alert("����� ������ ��� ���")
372				return false;
373			}
374
375		  }catch(e){
376				alert("���� ��� ������");
377				return false;
378		  }
379
380		}
381
382	//-->
383
384	var dialogActive=false;
385
386	function maskReason(src){ 
387		var theKey=event.keyCode;
388
389		if (theKey==13){
390			event.keyCode=9
391			dialogActive=true
392			document.all.tmpDlgArg.value="#"
393			document.all.tmpDlgTxt.value="����� �� ��� ���� ��� ����:"
394			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;');
395			dialogActive=false
396			if (document.all.tmpDlgTxt.value !="") {
397				var myTinyWindow = window.showModalDialog('../accounting/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;');
398	//			dialogActive=false
399				if (document.all.tmpDlgArg.value!="#"){
400					Arguments=document.all.tmpDlgArg.value.split("#")
401					src.value=Arguments[0];
402					document.all.accountName.value=Arguments[1];
403				}
404			}
405		}
406	}
407
408	//-->
409	</SCRIPT>
410<input type="hidden" Name='tmpDlgArg' value=''>
411<input type="hidden" Name='tmpDlgTxt' value=''>
412
413	<FORM METHOD=POST ACTION="?act=submitPayment" onsubmit="return checkValidation();">
414		<input type="hidden" Name='tmpDlgArg' value=''>
415		<table class="RcpMainTable" Cellspacing="1" Cellpadding="0" Width="500" align="center">
416		<tr class="RcpMainTableTH">
417			<td colspan="10"><TABLE width='550' align='center' cellpadding='5'>
418			<TR>
419				<TD bgcolor=white>�����: </TD>
420<%
421				mySQL="SELECT * FROM AXItemReasons WHERE Display=1 ORDER BY ID"
422				set RS1=conn.execute(mySQL)
423				while not RS1.eof
424%>					<TD bgcolor=white>
425						<INPUT TYPE="radio" NAME="Reason" value="<%=RS1("ID")%>" <% if reason=RS1("ID") then response.write "checked "%>><%=RS1("Name")%>
426					</TD>
427<%					RS1.movenext
428				wend
429%>		
430			</TR></TABLE></td>
431		</tr>
432		<tr class="RcpMainTableTH">
433			<td colspan="10"><TABLE class="RcpTable" Width="100%" Cellspacing="1" Cellpadding="0" Dir="RTL"><TR>
434				<TD align="left">����:</TD>
435				<TD align="right" width="5">
436					<INPUT class="RcpGenInput" disabled TYPE="text" value="<%=customerID%>" maxlength="5" size="5" tabIndex="1" dir="LTR">
437				</TD>
438				<TD align="right" width="200">
439					<INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>"><%=CustomerName%>.
440				</TD>
441				<TD align="left">�����:</TD>
442				<TD>
443					<table class="RcpTable">
444					<tr>    
445						<td dir="LTR">
446							<input class="RcpGenInput" style="text-align:left;direction:LTR;" NAME="PaymentDate" TYPE="text" maxlength="10" size="10" value="" onblur="acceptDate(this)">
447						</td>
448						<td dir="RTL">�����: <font color=white><%=weekdayname(weekday(date))%> <span dir=rtl><%=shamsiToday()%></span></font></TD>
449					</tr>   
450					</table></TD>
451			</TR></TABLE></td>
452		</tr>
453		<tr class="RcpMainTableTR">
454			<td colspan="10"><div>
455			<TABLE class="RcpTable" Cellspacing="1" Cellpadding="0" Dir="RTL">
456			<TR height="20">
457				<TD colspan="15">
458					<%
459					if VouchIDS<>"" then
460						response.write "����� �� ���������:"
461						VouchIDarray = split(VouchIDS,",")
462						for i=o to ubound(VouchIDarray) 
463							VouchID = VouchIDarray(i)
464
465							set RSV=Conn.Execute ("SELECT * FROM  Vouchers WHERE (id="& VouchID & ")" )
466							set RSB=Conn.Execute ("SELECT * FROM  APItems WHERE (Type=6 and Link="& VouchID & ")" )
467							APAmountOriginal = RSB("AmountOriginal")
468							APRemainedAmount = RSB("RemainedAmount")
469							VoucherTotalPrice = RSV("TotalPrice")
470							SumAPAmountOriginal = cdbl(SumAPAmountOriginal) + cdbl(APAmountOriginal)
471							SumAPRemainedAmount = cdbl(SumAPRemainedAmount) + cdbl(APRemainedAmount)
472							SumVoucherTotalPrice = cdbl(SumVoucherTotalPrice) + cdbl(VoucherTotalPrice)
473							customerID = RSV("VendorID")
474							VoucherTitle = RSV("Title")
475							%>
476							<INPUT TYPE="hidden" name="VouchID" value="<%=VouchID%>">
477							<INPUT TYPE="hidden" name="VoucherTotalPrice" value="<%=VoucherTotalPrice%>">
478							<INPUT TYPE="hidden" name="APRemainedAmount" value="<%=APRemainedAmount%>">
479							<li><B><%=VoucherTitle%></B>   �� ����� <A HREF="../AP/payment.asp?VouchID=<%=VouchID%>"><%=VouchID%></A>  (��� ������: <%=Separate(VoucherTotalPrice)%> ���� - ���������: <%=Separate(APRemainedAmount)%> ����)
480							<%
481						next
482					end if
483					''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
484					%>
485					<INPUT TYPE="hidden" name="SumAPAmountOriginal" value="<%=SumAPAmountOriginal%>">
486					<INPUT TYPE="hidden" name="SumVoucherTotalPrice" value="<%=SumVoucherTotalPrice%>">
487				</TD>
488			</TR>
489			</TABLE></div></td>
490		</tr>
491		<tr class="RcpMainTableTR">
492			<td colspan="10"><div style="width:540;">
493			<TABLE class="RcpTable" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
494			<TR height=20px>
495				<TD class="RcpHeadInput" style="width:25;"> # </td>
496				<TD class="RcpHeadInput" style="width:70;">����� ��</td>
497				<TD class="RcpHeadInput" style="width:70;">�����</td>
498				<TD class="RcpHeadInput" style="width:150;">����</td>
499				<TD class="RcpHeadInput" style="width:95;">����</td>
500				<TD class="RcpHeadInput" style="width:110;">�����</td>
501			</TR>   
502			</TABLE></div></td>
503		</tr>
504		<tr class="RcpMainTableTR">
505			<td colspan="10" dir="RTL"><div style="overflow:auto; height:150px;width:100%;">
506			<TABLE class="RcpTable" Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
507			<Tbody id="ChequeLines">
508			<TR bgcolor='#F0F0F0' onclick="currentRow=this.rowIndex;" >
509				<TD align='center' width="25px">1</td>
510				<TD dir="LTR"><INPUT class="RcpRowInput" TYPE="text" NAME="ChequeNos" size="10" maxLength="6" onKeyPress="return mask(this);"	onblur="check(this);"></td>
511				<TD dir="LTR" ><INPUT class="RcpRowInput" TYPE="text" NAME="ChequeDates" maxlength="10" size="10"  onKeyPress="return maskDate(this);" onblur="acceptDate(this);"></td>
512				<TD dir="RTL">
513					<select name="Banks" class=inputBut style="width:150;">
514					<option value="-1">������ ����</option>
515					<option value="-1">---------------------------------</option>
516					<% set RSV=Conn.Execute ("SELECT * FROM Bankers WHERE (IsBankAccount = 1)") 
517					Do while not RSV.eof
518					%>
519						<option value="<%=RSV("id")%>"><%=RSV("Name")%> </option>
520					<%
521					RSV.moveNext
522					Loop
523					RSV.close
524					%>
525					</select>
526				
527				</TD>
528				<TD dir="LTR"><INPUT class="RcpRowInput" TYPE="text" NAME="Amounts" size="15" onKeyPress="return mask(this);" onBlur="setPrice(this);" ></td>
529				<TD dir="RTL"><INPUT class="RcpRowInput" TYPE="text" NAME="Description" size="18" ></td>
530			</TR>
531			<TR bgcolor='#F0F0F0' onclick="currentRow=this.rowIndex;" >
532				<TD colspan="15">
533					<INPUT class="RcpGenInput" TYPE="button" value="�����" onkeyDown="if(event.keyCode==9) return false;" onClick="addRow(this.parentNode.parentNode.rowIndex);">
534				</TD>
535			</TR>
536			</Tbody></TABLE></div></td>
537		</tr>
538		<tr class="RcpMainTableTR">
539			<td colspan="10"><div>
540			<TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL">
541			<TR>
542				<TD  class="RcpHeadInput" align='center' > 
543				<% if CDbl(VoucherTotalPrice) <> -1 then %>��� ����� ��������:
544				<%=Separate(SumAPRemainedAmount)%>
545				<% end if %></td>
546				<TD class="RcpHeadInput" align='center' width="25px"> </td>
547				<TD class="RcpHeadInput"><INPUT class="RcpHeadInput" readonly TYPE="text" Value="���:" size="10" tabindex="9999"></td>
548				<TD class="RcpHeadInput"><INPUT class="RcpHeadInput3" readonly dir="LTR" TYPE="text" Name="TotalAmount"  size="15" tabindex="9999"></td>
549			</TR>
550			</TABLE></div></td>
551		</tr>
552		</table>
553		<br>
554		<TABLE class="RcpTable" Border="0" Cellspacing="5" Cellpadding="1" Dir="RTL">
555		<TR>
556			<TD align='center' bgcolor="#000000"><INPUT class="RcpGenInput" style="text-align:center" TYPE="submit" value="�����"></td>
557			<TD align='center' bgcolor="#000000"><INPUT class="RcpGenInput" style="text-align:center" TYPE="button" value="������" onclick="window.location='?';"></td>
558		</TR>
559		</TABLE>
560		</FORM>
561		<SCRIPT LANGUAGE="JavaScript">
562		<!--
563			document.all.ChequeNos.focus();
564		//-->
565		</SCRIPT>
566	<SCRIPT language="JavaScript">
567	<!--
568	//===================================================
569	function delRow(rowNo){
570		rowsCount=document.getElementsByName("ChequeNos").length
571		if (rowsCount==1){
572			alert("��� ��� �� ����� ���� ����");
573			return false;
574		}
575		
576		chqTable=document.getElementById("ChequeLines");
577		theRow=chqTable.getElementsByTagName("tr")[rowNo];
578		chqTable.removeChild(theRow);
579
580		rowsCount--;
581		for (rowNo=0; rowNo < rowsCount; rowNo++){
582			chqTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0].innerText= rowNo+1;
583		}
584	}
585
586	//===================================================
587	function addRow(rowNo){
588		chqTable=document.getElementById("ChequeLines");
589		theRow=chqTable.getElementsByTagName("tr")[rowNo];
590		newRow=document.createElement("tr");
591		newRow.setAttribute("bgColor", '#f0f0f0');
592
593		tempTD=document.createElement("td");
594		tempTD.innerHTML=rowNo+1
595		tempTD.setAttribute("align", 'center');
596		tempTD.setAttribute("width", '25');
597		newRow.appendChild(tempTD);
598
599		tempTD=document.createElement("td");
600		tempTD.setAttribute("dir", 'LTR');
601		tempTD.innerHTML='<INPUT class="RcpRowInput" TYPE="text" NAME="ChequeNos" size="10" maxLength="6" onKeyPress="return mask(this);" onblur="check(this);">'
602	//	tempTD.innerHTML=chqTable.getElementsByTagName("tr")[0].getElementsByTagName("td")[1].innerHTML
603		newRow.appendChild(tempTD);
604
605		tempTD=document.createElement("td");
606		tempTD.setAttribute("dir", 'LTR');
607		tempTD.innerHTML='<INPUT class="RcpRowInput" TYPE="text" NAME="ChequeDates" maxlength="10" size="10"  onKeyPress="return maskDate(this);" onblur="acceptDate(this);">'
608	//	tempTD.innerHTML=chqTable.getElementsByTagName("tr")[0].getElementsByTagName("td")[2].innerHTML
609		newRow.appendChild(tempTD);
610
611		tempTD=document.createElement("td");
612		tempTD.innerHTML=chqTable.getElementsByTagName("tr")[0].getElementsByTagName("td")[3].innerHTML
613		newRow.appendChild(tempTD);
614
615		tempTD=document.createElement("td");
616		tempTD.setAttribute("dir", 'LTR');
617		tempTD.innerHTML='<INPUT class="RcpRowInput" TYPE="text" NAME="Amounts" size="15" onKeyPress="return mask(this);" onBlur="setPrice(this);">'
618		newRow.appendChild(tempTD);
619
620		tempTD=document.createElement("td");
621		tempTD.setAttribute("dir", 'RTL');
622		tempTD.innerHTML='<INPUT class="RcpRowInput" TYPE="text" NAME="Description" size="18" >'
623		newRow.appendChild(tempTD);
624					
625
626		chqTable.insertBefore(newRow,theRow);
627
628		chqTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[1].getElementsByTagName("Input")[0].focus();
629	}
630
631	//===================================================
632	function setPrice(src){
633		myRow=src.parentNode.parentNode.rowIndex
634
635		if (src.name=="Amounts" && document.getElementsByName("ChequeNos")[myRow].value==''){
636			src.value=0;
637		}
638		else{
639			src.value=val2txt(txt2val(src.value));
640		}
641		//cashAmount=parseInt(txt2val(document.getElementsByName("CashAmount")[0].value));
642		//totalAmount = cashAmount;
643		totalAmount = 0;
644
645		for (rowNo=0; rowNo < document.getElementsByName("Amounts").length; rowNo++){
646			totalAmount += parseInt(txt2val(document.getElementsByName("Amounts")[rowNo].value));
647		}
648		document.all.TotalAmount.value = val2txt(totalAmount);
649	}
650
651	var dialogActive=false;
652
653	//===================================================
654	function check(src){ 
655		if (src.name=='ChequeNos'){
656			if (src.value=='0'){
657			if (confirm("��� ����� ����� �� �� ������ ��� �� �� �� ��� ���Ͽ\n\n"))
658				delRow(src.parentNode.parentNode.rowIndex);
659			}
660		}
661	}
662	//===================================================
663	function mask(src){ 
664		var theKey=event.keyCode;
665		if (theKey==13){
666			return true;
667		}
668		else if (theKey < 48 || theKey > 57) { // 0-9 are acceptable
669			return false;
670		}
671	}
672	//-->
673	</SCRIPT>
674<%
675'-----------------------------------------------------------------------------------------------------
676'--------------------------------------------------------------------------------------------- Default
677'-----------------------------------------------------------------------------------------------------
678elseif request("act")="" then %>
679<!-- ����� ���� ��� ���� -->
680	<BR><BR>
681	<FORM METHOD=POST ACTION="cheq.asp?act=submitsearch" onsubmit="if (document.all.CustomerNameSearchBox.value=='') return false;">
682	<div dir='rtl'>&nbsp;&nbsp;<B>��� ��� : ����� ���� ��� ����</B>
683		<INPUT TYPE="text" NAME="CustomerNameSearchBox">&nbsp;
684		<INPUT TYPE="submit" value="�����"><br>
685	</div>
686	</FORM>
687	<BR>
688	<SCRIPT LANGUAGE="JavaScript">
689	<!--
690		document.all.CustomerNameSearchBox.focus();
691	//-->
692	</SCRIPT>
693<%
694end if
695conn.Close
696'-----------------------------------------------------------------------------------------------------
697'-----------------------------------------------------------------------------------------------------
698'-----------------------------------------------------------------------------------------------------
699%>
700</font>
701<!--#include file="tah.asp" -->