PageRenderTime 33ms CodeModel.GetById 2ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 1ms

/beta/AO/INCLUDE_ITEMSRELATION.ASP

http://github.com/khaneh/Orders
ASP | 640 lines | 520 code | 58 blank | 62 comment | 54 complexity | a5a5bc3db94af45411bde6c46e8ba5ce MD5 | raw file
  1<%
  2
  3'---------------------------------------------
  4'---------------------------------- Link2Trace
  5'---------------------------------------------
  6function Link2Trace(OrderNo)
  7	Link2Trace="<A HREF='../order/orderEdit.asp?e=n&radif="& OrderNo & "' target='_balnk'>"& OrderNo & "</A>"
  8end function
  9
 10%>
 11<style>
 12	.GenTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; }
 13	.GenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;}
 14	.GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
 15	.GrayOutLine .rowName {border: 1px solid gray; }
 16	.RelInput { font-family:tahoma; font-size: 8pt; border: none; text-align:right; direction: LTR; background: transparent;}
 17	
 18
 19</style>
 20<%
 21'-----------------------------------------------------------------------------------------------------
 22'------------------------------------------------------------------------------------ 2 Select Account
 23'-----------------------------------------------------------------------------------------------------
 24if request("act")="submitsearch" then
 25	if request("CustomerNameSearchBox") <> "" then
 26		SA_TitleOrName=request("CustomerNameSearchBox")
 27		SA_Action="return true;"
 28		SA_SearchAgainURL="ItemsRelation.asp"
 29		SA_StepText="&nbsp;��� ��� : ������ ����"
 30%>
 31		<FORM METHOD=POST ACTION="ItemsRelation.asp?act=relate">
 32		<!--#include File="../AR/include_SelectAccount.asp"-->
 33		</FORM>
 34<%
 35	end if
 36'-----------------------------------------------------------------------------------------------------
 37'------------------------------------------------------------------------------------ Relates to Items
 38'-----------------------------------------------------------------------------------------------------
 39elseif request("act")="relate" then
 40
 41	TopNo = "" '"TOP 20"
 42
 43	dim typeNamesArray(6) 
 44	typeNamesArray(1) = "������"
 45	typeNamesArray(2) = "������"
 46	typeNamesArray(3) = "���"
 47	typeNamesArray(4) = "�ѐ��"
 48	typeNamesArray(5) = "������"
 49	typeNamesArray(6) = "������ ����"
 50
 51
 52	if request("selectedCustomer") <> "" then
 53	Customer = request("selectedCustomer")
 54	sys = request("sys")
 55	if sys = "" then sys = "AR"
 56	if not fixSys = "-"  then sys = fixSys
 57%>
 58	<br>
 59	<CENTER>
 60	<% if fixSys = "-"  then %>
 61	<FORM METHOD="POST" ACTION="ItemsRelation.asp?act=relate">
 62	<INPUT TYPE="hidden" name="selectedCustomer" value="<%=Customer%>">
 63		<INPUT TYPE="radio" NAME="sys" value="AR" <% if sys="AR" then %>checked <% end if %> onclick="submit()"> ����
 64		<INPUT TYPE="radio" NAME="sys" value="AP" <% if sys="AP" then %>checked <% end if %> onclick="submit()"> ����
 65		<INPUT TYPE="radio" NAME="sys" value="AO" <% if sys="AO" then %>checked <% end if %> onclick="submit()"> ����
 66	</FORM>
 67	<% else 
 68		response.write "<br><br>" 
 69		sys = fixSys 
 70	end if
 71	%>
 72	</CENTER>
 73	<FORM METHOD="POST" ACTION="ItemsRelation.asp?act=submitRelation">
 74	<INPUT TYPE="hidden" name="sys" value="<%=sys%>">
 75	<INPUT TYPE="hidden" name="Customer" value="<%=Customer%>">
 76	<TABLE class="GenTable" align="center" cellspacing="2" cellpadding="0" dir="RTL">
 77	<tbody id="MainTable">
 78	<%
 79	
 80	mySQL="SELECT * From Accounts WHERE (ID='"& Customer & "')"
 81	Set RS1 = conn.Execute(mySQL)
 82	if (RS1.eof) then
 83		call showAlert( "���� ���� �����." , CONST_MSG_ERROR)
 84		response.end
 85	else
 86		AccountTitle=RS1("AccountTitle")
 87	end if
 88
 89	noJavaScript=false
 90
 91%>
 92	<tr bgcolor='#DDDDFF' height="50">
 93		<td align='center' colspan="3" style="font-weight:bold; font-size:9pt;border:1 solid black;">����� �� <br><%=AccountTitle%>
 94			<input type="hidden" id="selectedCreditItem" value="">
 95			<input type="hidden" id="selectedDebitItem" value="">		
 96		</td>
 97	</tr>
 98	<tr height="10">
 99		<td align='center' colspan="3"></td>
100	</tr>
101	<tr height="30">
102		<td bgColor="#FFC0C0" style="border:1px solid black;" width="300">&nbsp;&nbsp;&nbsp; <b>�������</b> 
103		<td width="50" rowspan="4" onclick="unselect();">&nbsp;</td>
104		<td bgColor="#C0EEC0" style="border:1px solid black;" width="300">&nbsp;&nbsp;&nbsp; <b>���������</b>
105		</td>
106	</tr>
107	<tr>
108		<td valign="top">
109<%
110	mySQL="SELECT "& TopNo & " * From "& sys & "Items WHERE (Account='"& Customer & "' AND IsCredit=0 AND FullyApplied=0 AND Voided=0) ORDER BY EffectiveDate DESC, ID DESC"
111	Set RS1 = conn.Execute(mySQL)
112
113	if (RS1.eof) then 
114		call showAlert( "���� ���" , CONST_MSG_ALERT)
115		noJavaScript=true
116	else
117	'********************   Debit Items
118
119%>
120		<TABLE class="GenTable" align="center" cellspacing="5" cellpadding="2" dir="RTL" border="0" width="100%">
121		<Tbody ID="DebitsTable" name='DebitsTable'>
122<%		TotalDebit=0
123		while Not (RS1.EOF)
124			description = ""
125			'================================== Type = 1
126			'================================== 
127			if RS1("Type")=1 then
128				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showInvoice&invoice="& RS1("Link") & "' target='_blank'>" & "������ " & RS1("Link") & "</a>"
129			
130			'================================== Type = 2
131			'================================== 
132			elseif RS1("Type")=2 then
133				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showReceipt&receipt="& RS1("Link") & "' target='_blank'>" & "������ " & RS1("Link") & "</a>"
134				Set RST = conn.Execute("select * from ReceivedCash where Receipt=" & RS1("Link"))
135
136				if RST.EOF then
137					description = "��� ! ��� ������ ���� �����"
138				else
139					description = RST("Description")
140				end if
141			
142			'================================== Type = 3
143			'================================== 
144			elseif RS1("Type")=3 then
145				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showMemo&sys="& sys & "&memo="& RS1("Link") & "' target='_blank'>" & "������� "& RS1("Link") & "</a>"
146				Set RST = conn.Execute("select * from "& sys & "memo where ID=" & RS1("Link"))
147
148				if RST.EOF then
149					description = "��� ! ��� ������ ���� �����"
150				else
151					description = RST("Description")
152				end if
153
154			'================================== Type = 4
155			'================================== 
156			elseif RS1("Type")=4 then
157				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showInvoice&invoice="& RS1("Link") & "' target='_blank'>" & "�ѐ�� �� ����" & RS1("Link") & "</a>"
158
159			'================================== Type = 5
160			'================================== 
161			elseif RS1("Type")=5 then
162				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showPayment&payment="& RS1("Link") & "' target='_blank'>" & "������ "& RS1("Link") & "</a>"
163
164				mySQL="SELECT ISNULL(PaidCash.Description,'') AS CashDesc, PaidCheques.Description AS CheqDesc FROM PaidCheques RIGHT OUTER JOIN Payments ON PaidCheques.Payment = Payments.ID LEFT OUTER JOIN PaidCash ON Payments.ID = PaidCash.Payment WHERE (Payments.ID = "& RS1("Link") & ")"
165				Set RST = conn.Execute(mySQL)
166
167				if RST.EOF then
168					description = "��� ! ��� ������ ���� �����"
169				else
170					description = RST("CashDesc")
171					Do Until RST.eof
172						description = description + " " + RST("CheqDesc")
173						RST.moveNext
174					Loop
175				end if
176				RST.close
177
178			'================================== Type = 6
179			'================================== 
180			elseif RS1("Type")=6 then
181				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showVoucher&voucher="& RS1("Link") & "' target='_blank'>" & "������ ���� "& RS1("Link") & "</a>"
182
183				mySQL="SELECT Title FROM Vouchers WHERE (id = "& RS1("Link") & ")"
184
185				Set RST = conn.Execute(mySQL)
186
187				if RST.EOF then
188					description = "��� ! ��� ������ ���� �����"
189				else
190					description = replace(RST("Title"), "/", ".")
191				end if
192				RST.close
193
194			'================================== Unknown
195			'================================== 
196			else
197				sourceLink="<a href='javascript:void(0);'>" & "������" & "</a>"
198			end if
199
200%>			<tr class="unsel" bgcolor="white" height='70' valign='top' onclick="slctDdit(this)"><td  class="GrayOutLine">
201			<input type='hidden' name='DebitItems' value='<%=RS1("ID")%>'>
202			<table class='GenTable' width="300" cellspacing='4' cellpadding='1'>
203				<tr bgcolor='#FFDDDD'>
204					<td class="rowName"><%=sourceLink%></td>
205					<td class="GrayOutLine"><span dir='LTR'><%=RS1("EffectiveDate")%></span></td>
206					<td class="GrayOutLine">���� ��: <INPUT class='RelInput' readonly value='<%=Separate(RS1("AmountOriginal"))%>' size='10'></td>
207				</tr>
208				<tr>
209					<td colspan="3">
210					<a disabled><%=description%></a><BR>
211					<span class="desc">
212					<%
213					mySQL2="SELECT * From "& sys & "ItemsRelations INNER JOIN  "&sys & "Items ON "& sys & "ItemsRelations.Credit"& sys & "Item = "& sys & "Items.ID WHERE ("& sys & "ItemsRelations.Debit"& sys & "Item = "& RS1("id") & ") "
214					Set RS2 = conn.Execute(mySQL2)
215					while Not (RS2.EOF)
216						response.write "<span disabled><input class='RelInput' size='10' readonly value=' " & separate(RS2("Amount")) & " '> " & " �� "& typeNamesArray(cint(RS2("Type"))) & " ����� "& RS2("Link") & "</span><br>"
217
218						RS2.movenext
219					wend
220					if RS1("voided") then response.write "<b>���� ���</b>"
221					%>
222					&nbsp;</span></td>
223				</tr>
224				<tr>
225					<td class="GrayOutLine" colspan="2">�����: <span><INPUT class='RelInput' readonly Name='DebitRemained' value='<%=Separate(RS1("RemainedAmount"))%>' size='10'></span></td>
226					<td align="center"><span class="isPass" style="visibility:hidden;color:red;"><b>��� ��</b></span></td>
227				</tr>
228			</table></td>
229			</tr>
230<%
231			TotalDebit = TotalDebit + cdbl(RS1("RemainedAmount"))
232			RS1.movenext
233		wend
234%>
235		</Tbody>
236		</TABLE>
237<%
238	end if
239%>		
240		</td>
241		<td valign="top">
242<%
243	mySQL="SELECT "& TopNo & " * From "& sys & "Items WHERE (Account='"& Customer & "' AND IsCredit=1 AND FullyApplied=0 AND Voided=0) ORDER BY EffectiveDate DESC, ID DESC"
244
245	Set RS1 = conn.Execute(mySQL)
246
247	if (RS1.eof) then 
248		call showAlert( "���� ���" , CONST_MSG_ALERT)
249		noJavaScript=true
250	else
251	'********************   Credit Items
252%>
253		<TABLE class="GenTable" align="center" cellspacing="5" cellpadding="2" dir="RTL" border="1" width="100%">
254		<Tbody ID="CreditsTAble" name='CreditsTable'>
255<%			TotalCredit=0
256			while Not (RS1.EOF)
257			description = ""
258			'================================== Type = 1
259			'================================== 
260			if RS1("Type")=1 then
261				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showInvoice&invoice="& RS1("Link") & "' target='_blank'>" & "������ " & RS1("Link") & "</a>"
262			
263			'================================== Type = 2
264			'================================== 
265			elseif RS1("Type")=2 then
266				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showReceipt&receipt="& RS1("Link") & "' target='_blank'>" & "������ " & RS1("Link") & "</a>"
267				Set RST = conn.Execute("select * from ReceivedCash where Receipt=" & RS1("Link"))
268
269				if RST.EOF then
270					description = "��� ! ��� ������ ���� �����"
271				else
272					description = RST("Description")
273				end if
274			
275			'================================== Type = 3
276			'================================== 
277			elseif RS1("Type")=3 then
278				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showMemo&sys="& sys & "&memo="& RS1("Link") & "' target='_blank'>" & "������� "& RS1("Link") & "</a>"
279				Set RST = conn.Execute("select * from "& sys & "memo where ID=" & RS1("Link"))
280
281				if RST.EOF then
282					description = "��� ! ��� ������ ���� �����"
283				else
284					description = RST("Description")
285				end if
286
287			'================================== Type = 4
288			'================================== 
289			elseif RS1("Type")=4 then
290				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showInvoice&invoice="& RS1("Link") & "' target='_blank'>" & "�ѐ�� �� ����" & RS1("Link") & "</a>"
291
292			'================================== Type = 5
293			'================================== 
294			elseif RS1("Type")=5 then
295				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showPayment&payment="& RS1("Link") & "' target='_blank'>" & "������ " & RS1("Link") & "</a>"
296
297				mySQL="SELECT ISNULL(PaidCash.Description,'') AS CashDesc, PaidCheques.Description AS CheqDesc FROM PaidCheques RIGHT OUTER JOIN Payments ON PaidCheques.Payment = Payments.ID LEFT OUTER JOIN PaidCash ON Payments.ID = PaidCash.Payment WHERE (Payments.ID = "& RS1("Link") & ")"
298				Set RST = conn.Execute(mySQL)
299
300				if RST.EOF then
301					description = "��� ! ��� ������ ���� �����"
302				else
303					description = RST("CashDesc")
304					Do Until RST.eof
305						description = description + " " + RST("CheqDesc")
306						RST.moveNext
307					Loop
308				end if
309				RST.close
310
311			'================================== Type = 6
312			'================================== 
313			elseif RS1("Type")=6 then
314				sourceLink="<a style='text-decoration:none; color:green;' href='AccountReport.asp?act=showVoucher&voucher="& RS1("Link") & "' target='_blank'>" & "������ ���� "& RS1("Link") & "</a>"
315
316				mySQL="SELECT Title FROM Vouchers WHERE (id = "& RS1("Link") & ")"
317
318				Set RST = conn.Execute(mySQL)
319
320				if RST.EOF then
321					description = "��� ! ��� ������ ���� �����"
322				else
323					description = replace(RST("Title"), "/", ".")
324				end if
325				RST.close
326
327			'================================== Unknown
328			'================================== 
329			else
330				sourceLink="<a href='javascript:void(0);'>" & "������" & "</a>"
331			end if
332
333%>			<tr class="unsel" bgcolor="white" height='70' valign='top' onclick="slctCrdit(this)"><td class="GrayOutLine">
334			<input type='hidden' name='CreditItems' value='<%=RS1("ID")%>'>
335			<table class='GenTable' width="300" cellspacing='4' cellpadding='1'>
336				<tr bgcolor='#CCEECC'>
337					<td class="rowName"><%=sourceLink%></td>
338					<td class="GrayOutLine"><span dir='LTR'><%=RS1("EffectiveDate")%></span></td>
339					<td class="GrayOutLine">���� ��: <INPUT class='RelInput' readonly value='<%=Separate(RS1("AmountOriginal"))%>' size='10'></td>
340				</tr>
341				<tr>
342					<td colspan="3">
343					<a disabled><%=description%></a><BR>
344					<span class="desc">
345					<%
346					mySQL2="SELECT * From "& sys & "ItemsRelations INNER JOIN  "&sys & "Items ON "& sys & "ItemsRelations.Debit"& sys & "Item = "& sys & "Items.ID WHERE ("& sys & "ItemsRelations.Credit"& sys & "Item = "& RS1("id") & ") "
347					Set RS2 = conn.Execute(mySQL2)
348					while Not (RS2.EOF)
349						response.write "<span disabled><input class='RelInput' size='10' readonly value=' " & separate(RS2("Amount")) & " '> " & "�� "& typeNamesArray(cint(RS2("Type"))) & " ����� "& RS2("Link") & "</span><br>"
350
351						RS2.movenext
352					wend
353					if RS1("voided") then response.write "<b>���� ���</b>"
354					%>
355					&nbsp;</span></td>
356				</tr>
357				<tr>
358					<td class="GrayOutLine" colspan="2">�����: <span><INPUT class='RelInput' readonly Name='CreditRemained' value=<%=Separate(RS1("RemainedAmount"))%> size='10'></span></td>
359					<td align="center"><span class="isPass" style="visibility:hidden;color:green;"><b>��� ��</b></span></td>
360				</tr>
361			</table></td>
362			</tr>
363<%
364				TotalCredit= TotalCredit + cdbl(RS1("RemainedAmount"))
365				RS1.movenext
366			wend
367%>
368		</Tbody>
369		</TABLE>
370<%
371	end if
372%>		
373		</td>
374	</tr>
375	<tr height="5">
376		<td dir='LTR' align='left' colspan="3"><span id="Relations"></span></td>
377	</tr>
378	<tr style="padding:4">
379		<td class="GrayOutLine" bgColor="#FFC0C0">��� : <span>&nbsp;&nbsp;<INPUT class='RelInput' readonly Name='TotalDebitRemained' value='<%=Separate(TotalDebit)%>' size='10'></span></td>
380		<td class="GrayOutLine" bgColor="#C0EEC0">��� : <span>&nbsp;&nbsp;<INPUT class='RelInput' readonly Name='TotalCreditRemained' value='<%=Separate(TotalCredit)%>' size='10'></span></td>
381	</tr>
382	<tr height="10">
383		<td align='center' colspan="3"><input name="selectedCustomer" type="hidden" value="<%=Customer%>"></td>
384	</tr>
385	<tr>
386		<td align='left'><input class="GenButton" type="button" style="font-family:Tahoma" value="������" onclick="window.location='ItemsRelation.asp';" >&nbsp;</td>
387		<td align='center'>&nbsp;<input class="GenButton" type="button" style="font-family:Tahoma" value=" ����� " onclick="this.disabled=true;submit();" >&nbsp;</td>
388		<td align='right'><input class="GenButton" type="button" style="font-family:Tahoma" value="��� ����" onclick="window.location='ItemsRelation.asp?act=relate&selectedCustomer=<%=Customer%>'" >&nbsp;</td>
389	</tr>
390	</Tbody>
391	</TABLE><br>
392	</FORM>
393<%
394	end if
395'-----------------------------------------------------------------------------------------------------
396'----------------------------------------------------------------------------------- submits Relations
397'-----------------------------------------------------------------------------------------------------
398elseif request("act")="submitRelation" then
399	sys = request("sys")
400	selectedCustomer = request("selectedCustomer")
401'response.write request.form("CreditItems") 
402'response.write "<br>"
403'response.write request.form("DebitItems")
404'response.write "<br>"
405'response.end
406	if sys = "" then sys = "AR"
407	for i=1 to request.form("CreditItems").count 
408		remained=text2value(request.form("CreditRemained")(i))
409		mySQL="UPDATE "& sys & "Items SET RemainedAmount='"& remained & "' WHERE (ID='"& request.form("CreditItems")(i) & "')"
410		conn.Execute(mySQL)	
411'		response.write mySQL & "<br>"
412	next
413	for i=1 to request.form("DebitItems").count 
414		remained=text2value(request.form("DebitRemained")(i))
415		mySQL="UPDATE "& sys & "Items SET RemainedAmount='"& remained & "' WHERE (ID='"& request.form("DebitItems")(i) & "')"
416		conn.Execute(mySQL)
417'		response.write mySQL & "<br>"
418	next
419
420	mySQL="UPDATE "& sys & "Items SET FullyApplied='1' WHERE (RemainedAmount='0')"	
421	conn.Execute(mySQL)
422'	response.write mySQL & "<br>"
423	
424	for i=1 to request.form("CreditARItem").count 
425		amount = cdbl(request.form("Amount")(i))
426		mySQL="INSERT INTO "& sys & "ItemsRelations (CreatedDate, CreatedBy, Credit"& sys & "Item, Debit"& sys & "Item, Amount) VALUES (N'"& ShamsiToday() & "', '"& session("ID") & "', '"& request.form("CreditARItem")(i) &"', '"& request.form("DebitARItem")(i) &"', '"& amount &"')"
427		conn.Execute(mySQL)
428'		response.write mySQL & "<br>"
429	next
430	conn.Close
431'response.write request.form("CreditARItem").count
432	response.redirect "ItemsRelation.asp?sys=" & sys & "&act=relate&selectedCustomer=" & selectedCustomer
433'response.end
434'-----------------------------------------------------------------------------------------------------
435'---------------------------------------------------------------------------------- Tear a Relation
436'-----------------------------------------------------------------------------------------------------
437elseif request("act")="unrelate" then
438
439	relation=clng(request("relation"))
440	sys= ucase(request("sys"))
441	if NOT (sys = "AR" OR sys = "AP" OR sys = "AO" ) then
442		conn.close
443		response.redirect "top.asp?errMsg="& Server.URLEncode("���!")
444	end if
445
446	mySQL="SELECT * FROM "& sys & "ItemsRelations WHERE (ID = '"& relation & "')"
447	Set RS1=conn.Execute(mySQL)
448	If not RS1.eof then
449		'*********  Adding back the amount in the relation, to the debit Item ...
450		conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=RemainedAmount+ '"& RS1("Amount") & "', FullyApplied=0 WHERE (ID = '"& RS1("Debit"& sys & "Item") & "')")
451
452		'*********  Adding back the amount in the relation, to the credit Item ...
453		conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=RemainedAmount+ '"& RS1("Amount") & "', FullyApplied=0 WHERE (ID = '"& RS1("Credit"& sys & "Item") & "')")
454
455		'*********  Deleting the relation
456		conn.Execute("DELETE FROM "& sys & "ItemsRelations WHERE (ID = '"& relation & "')")
457	End if
458	RS1.close
459
460	conn.close
461	response.redirect Request.ServerVariables("HTTP_REFERER")&"&msg=" &Server.URLEncode("����� ��� ��.")
462'-----------------------------------------------------------------------------------------------------
463'---------------------------------------------------------------------------------- Search for account
464'-----------------------------------------------------------------------------------------------------
465else%>
466<!-- ����� ���� ��� ���� --><BR><BR>
467	<FORM METHOD=POST ACTION="ItemsRelation.asp?act=submitsearch" onsubmit="if (document.all.CustomerNameSearchBox.value=='') return false;">
468	<div dir='rtl'>&nbsp;<B> ��� ��� : ����� ���� ��� ����</B>
469		<INPUT TYPE="text" NAME="CustomerNameSearchBox">&nbsp;
470		<INPUT class="GenButton" TYPE="submit" value="�����"><br>
471	</div>
472	</FORM>
473	<SCRIPT LANGUAGE="JavaScript">
474	<!--
475		document.all.CustomerNameSearchBox.focus();
476	//-->
477	</SCRIPT>
478<%
479end if
480conn.Close
481if not (noJavaScript=true) then %>
482<script language="JavaScript">
483<!--
484//---------------------------------------------
485//---------------------------------------------
486//---------------------------------------------
487var slctRowClr='#FFFF00'
488function slctCrdit(srcRow){
489	var e = $(srcRow);
490	if (getNum(e.find("input[name=CreditRemained]").val())==0)
491		return 0;
492	$("[name=CreditsTable]").css("cursor","auto");
493/* 	$("#selectedCreditItem").val(e.index()); // must check. may be no more needed! */
494	$("[name=CreditItems]").parent().parent().prop("bgColor","#FFFFFF");
495	$("[name=CreditItems]").parent().parent().prop("selected","no");
496	e.prop("bgColor",slctRowClr);
497	e.removeClass("unsel");
498	e.addClass("sel");
499	if ($("[name=DebitsTable] tr.sel").size()!=0){
500		var dstRow = $("[name=DebitsTable] tr.sel");
501		var dstSpan = dstRow.find("span.desc");
502		var dstName = dstRow.find("td.rowName").text();
503		var dstRemained = dstRow.find("input[name=DebitRemained]");
504		var srcSpan = e.find("span.desc");
505		var srcName = e.find("td.rowName").text();
506		var srcRemained = e.find("input[name=CreditRemained]");
507		var suggest = Math.min(getNum(srcRemained.val()),getNum(dstRemained.val()));
508		var amount = getNum(prompt("���� ������� �� ���� ����",suggest));
509		if (amount != 0 && amount <= suggest){
510			srcRemained.val(echoNum(getNum(srcRemained.val()) - parseInt(amount)));
511			dstRemained.val(echoNum(getNum(dstRemained.val()) - parseInt(amount)));
512			srcSpan.append("<input class='RelInput' readonly value='"+echoNum(amount)+"' size='10'>"+"�� "+dstName +"<br>&nbsp;");
513			dstSpan.append("<input class='RelInput' readonly value='"+echoNum(amount)+"' size='10'>"+"�� "+srcName +"<br>&nbsp;");
514			$("#Relations").append("<input type='hidden' name='CreditARItem' value='"+e.find("input[name=CreditItems]").val()+"'>");
515			$("#Relations").append("<input type='hidden' name='DebitARItem' value='"+dstRow.find("input[name=DebitItems]").val()+"'>");
516			$("#Relations").append("<input type='hidden' name='Amount' value='"+amount+"'>");
517			setRemained();
518		}
519		if (getNum(dstRemained.val())==0){
520			dstRow.find("span.isPass").css("visibility","visible");
521			dstRow.removeClass("sel");
522			dstRow.removeClass("unsel");
523			dstRow.addClass("unsel");
524			dstRow.prop("bgColor","#FFFFFF");
525		}
526		if (getNum(srcRemained.val()==0)){
527			e.find("span.isPass").css("visibility","visible");
528			e.removeClass("sel");
529			e.removeClass("unsel");
530			e.addClass("unsel");
531			e.prop("bgColor","#FFFFFF");
532		}
533	} else {
534		$("[name=DebitsTable]").css("cursor","crosshair");
535	}
536
537}
538
539//---------------------------------------------
540//---------------------------------------------
541//---------------------------------------------
542function slctDdit(dstRow){
543	var e = $(dstRow);
544	if (getNum(e.find("input[name=DebitRemained]").val())==0)
545		return 0;
546	$("[name=DebitsTable]").css("cursor","auto");	
547
548/* 	document.all.selectedDebitItem.value=dstRow.rowIndex */
549	$("[name=DebitItems]").parent().parent().prop("bgColor","#FFFFFF");
550	$("[name=DebitItems]").parent().parent().prop("selected","yes");
551	e.prop("bgColor",slctRowClr);
552	e.removeClass("unsel");
553	e.addClass("sel");
554	if ($("[name=CreditsTable] tr.sel").size()!=0){
555		var dstSpan = e.find("span.desc");
556		var dstName = e.find("td.rowName").text();
557		var dstRemained = e.find("input[name=DebitRemained]");
558		var srcRow = $("[name=CreditsTable] tr.sel");
559		var srcSpan = srcRow.find("span.desc");
560		var srcName = srcRow.find("td.rowName").text();
561		var srcRemained = srcRow.find("input[name=CreditRemained]");
562		var suggest = Math.min(getNum(srcRemained.val()),getNum(dstRemained.val()));
563		var amount = getNum(prompt("���� ������� �� ���� ����",suggest));
564		if (amount != 0 && amount <= suggest){
565			srcRemained.val(echoNum(getNum(srcRemained.val()) - parseInt(amount)));
566			dstRemained.val(echoNum(getNum(dstRemained.val()) - parseInt(amount)));
567			srcSpan.append("<input class='RelInput' readonly value='"+echoNum(amount)+"' size='10'>"+"�� "+dstName +"<br>&nbsp;");
568			dstSpan.append("<input class='RelInput' readonly value='"+echoNum(amount)+"' size='10'>"+"�� "+srcName +"<br>&nbsp;");
569			$("#Relations").append("<input type='hidden' name='CreditARItem' value='"+srcRow.find("input[name=CreditItems]").val()+"'>");
570			$("#Relations").append("<input type='hidden' name='DebitARItem' value='"+e.find("input[name=DebitItems]").val()+"'>");
571			$("#Relations").append("<input type='hidden' name='Amount' value='"+amount+"'>");
572			setRemained();
573		}
574		if (getNum(srcRemained.val())==0){
575			srcRow.find("span.isPass").css("visibility","visible");
576			srcRow.removeClass("sel");
577			srcRow.removeClass("unsel");
578			srcRow.addClass("unsel");
579			srcRow.prop("bgColor","#FFFFFF");
580		}
581		if (getNum(dstRemained.val())==0){
582			e.find("span.isPass").css("visibility","visible");
583			e.removeClass("sel");
584			e.removeClass("unsel");
585			e.addClass("unsel");
586			e.prop("bgColor","#FFFFFF");
587		}
588	} else {
589		$("[name=CreditsTable]").css("cursor","crosshair");
590	}
591}
592
593//---------------------------------------------
594//---------------------------------------------
595//---------------------------------------------
596function setRemained(){
597	var totalDebit = 0;
598	var totalCredit = 0
599	$("input[name=DebitRemained]").each(function(i){
600		totalDebit += getNum($(this).val());
601	});
602	$("input[name=CreditRemained]").each(function(i){
603		totalCredit += getNum($(this).val());
604	});
605	$("input[name=TotalDebitRemained]").val(echoNum(totalDebit));
606	$("input[name=TotalCreditRemained]").val(echoNum(totalCredit));
607}
608
609//---------------------------------------------
610//---------------------------------------------
611//---------------------------------------------
612function unselect(){
613	$("[name=DebitsTable]").css("cursor","auto");
614	$("[name=CreditsTable]").css("cursor","auto");
615	$("[name=DebitsTable] tr.sel").prop("bgColor","#fff");
616	$("[name=DebitsTable] tr.sel").addClass("unsel");
617	$("[name=DebitsTable] tr.sel").removeClass("sel");
618	$("[name=CreditsTable] tr.sel").prop("bgColor","#fff");
619	$("[name=CreditsTable] tr.sel").addClass("unsel");
620	$("[name=CreditsTable] tr.sel").removeClass("sel");
621}
622
623//---------------------------------------------
624//---------------------------------------------
625//---------------------------------------------
626function delRelation(src){
627	srcRow=src.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
628	alert(srcRow)
629}
630//-->
631</script>
632<%else%>
633<script language="JavaScript">
634<!--
635function slctCrdit(srcRow){}
636function slctDdit(dstRow){}
637function unselect(){}
638//-->
639</script>
640<%end if%>