PageRenderTime 19ms CodeModel.GetById 7ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/beta/order/orderInput.asp

http://github.com/khaneh/Orders
ASP | 554 lines | 496 code | 22 blank | 36 comment | 70 complexity | 0593b8153523c8e3b6c8f2b943f5d890 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Order (2)
  3PageTitle="���� �����"
  4SubmenuItem=1
  5if not Auth(2 , 1) then NotAllowdToViewThisPage()
  6
  7'Copy from old trace/orderTraceInput.asp
  8%>
  9<!--#include file="top.asp" -->
 10<!--#include File="../include_farsiDateHandling.asp"-->
 11<!--#include File="../include_JS_InputMasks.asp"-->
 12<style >
 13	.mySection{border: 1px #F90 dashed;margin: 15px 10px 0 15px;}
 14	.myRow{border: 2px #F05 dashed;margin: 10px 0 10px 0;padding: 0 3px 5px 0;}
 15	.exteraArea{border: 1px #33F dotted;margin: 5px 0 0 5px;padding: 0 3px 5px 0;}
 16	.myLabel {margin: 0 3px 0 0;white-space: nowrap;}
 17	.myProp {font-weight: bold;color: #40F; margin: 0 3px 0 3px;}
 18	div.btn label{background-color:yellow;color: blue;padding: 3px 30px 3px 30px;cursor: pointer;}
 19	div.btn{margin: -5px 250px 0px 5px;}
 20	div.btn img{margin: 0px 20px -5px 0;cursor: pointer;}
 21</style>
 22<%
 23if request("act")="submitsearch" then
 24	if isnumeric(request("CustomerNameSearchBox")) then
 25		conn.close
 26		response.redirect "?act=getorder&selectedCustomer=" & request("CustomerNameSearchBox")
 27	elseif request("CustomerNameSearchBox") <> "" then
 28		SA_TitleOrName=request("CustomerNameSearchBox")
 29		mySQL="SELECT * FROM Accounts WHERE (REPLACE(AccountTitle, ' ', '') LIKE REPLACE(N'%"& sqlSafe(SA_TitleOrName) & "%', ' ', '') ) ORDER BY AccountTitle"
 30		Set RS1 = conn.Execute(mySQL)
 31
 32		if (RS1.eof) then 
 33			conn.close
 34			response.redirect "?errmsg=" & Server.URLEncode("���� ����� ���� ���.<br><a href='../CRM/AccountEdit.asp?act=getAccount'>���� ���Ͽ</a>")
 35		end if 
 36
 37		SA_TitleOrName=request("CustomerNameSearchBox")
 38		SA_Action="return true;"
 39		SA_SearchAgainURL="OrderInput.asp"
 40		SA_StepText="��� ��� : ������ ����"
 41%>
 42		<br>
 43		<FORM METHOD=POST ACTION="?act=getType">
 44			<!--#include File="../AR/include_SelectAccount.asp"-->
 45		</FORM>
 46<%
 47	end if
 48elseif Request.QueryString("act")="getType" then 
 49	customerID=request("selectedCustomer")
 50	mySQL="SELECT * FROM Accounts WHERE (ID='"& CustomerID & "')"
 51	Set RS1 = conn.Execute(mySQL)
 52
 53	if (RS1.eof) then 
 54		conn.close
 55		response.redirect "?errmsg=" & Server.URLEncode("���� ����� ���� ���.<br><a href='../CRM/AccountEdit.asp?act=getAccount'>���� ���Ͽ</a>")
 56	end if 
 57	'if (cdbl(rs1("arBalance"))+cdbl(rs1("apBalance"))+cdbl(rs1("aoBalance"))+cdbl(rs1("creditLimit")) < 0) then 
 58	if (cdbl(rs1("arBalance"))+cdbl(rs1("creditLimit")) < 0) then 
 59		conn.close
 60		response.redirect "?errmsg=" & Server.URLEncode("���� ��� ���� �� ����� ������ �� ����� ����<br> ���� �� �� ���� ������ ����.<br><a href='../CRM/AccountInfo.asp?act=show&selectedCustomer=" & CustomerID & "'>����� ����</a>")
 61	end if
 62%>
 63		<br>
 64		<div dir='rtl'>
 65			<B>��� ��� : ����� ��� �����</B>
 66		</div>
 67		<form method="post" action="?act=getorder">
 68			<input name="selectedCustomer" type="hidden" value="<%=customerID%>">
 69			<SELECT NAME="OrderType" style='font-family: tahoma,arial ; font-size: 9pt; font-weight: bold; width: 100px' tabIndex="7">
 70			<OPTION value="-1" style='color:red;'>������ ����</option>
 71<%
 72			Set RS2 = conn.Execute("SELECT [User] as ID, DefaultOrderType FROM UserDefaults WHERE ([User] = "& session("ID") & ") OR (UserDefaults.[User] = 0) ORDER BY ABS(UserDefaults.[User]) DESC")
 73			defaultOrderType=RS2("DefaultOrderType")
 74			RS2.close
 75			Set RS2 = Nothing
 76
 77			set RS_TYPE=Conn.Execute ("SELECT ID, Name FROM OrderTraceTypes WHERE (IsActive=1) ORDER BY ID")
 78			Do while not RS_TYPE.eof	
 79%>
 80				<OPTION value="<%=RS_TYPE("ID")%>" <%if RS_TYPE("ID")=defaultOrderType then response.write "selected"%>><%=RS_TYPE("Name")%></option>
 81<%
 82			RS_TYPE.moveNext
 83			loop
 84			RS_TYPE.close
 85			set RS_TYPE = nothing
 86%>		
 87			</SELECT>
 88			<input type="submit" value="�����">
 89		</form>
 90<%	
 91
 92elseif request("act")="getorder" then
 93	customerID=request("selectedCustomer")
 94	mySQL="SELECT * FROM Accounts WHERE (ID='"& CustomerID & "')"
 95	Set RS1 = conn.Execute(mySQL)
 96
 97	if (RS1.eof) then 
 98		conn.close
 99		response.redirect "?errmsg=" & Server.URLEncode("���� ����� ���� ���.<br><a href='..//CRM/AccountEdit.asp?act=getAccount'>���� ���Ͽ</a>")
100	end if 
101
102	AccountNo=RS1("ID")
103	AccountTitle=RS1("AccountTitle")
104	companyName=RS1("CompanyName")
105	customerName=RS1("Dear1")& " " & RS1("FirstName1")& " " & RS1("LastName1")
106	Tel=RS1("Tel1")
107	set rs=Conn.Execute("select * from OrderTraceTypes where id=" & request("orderType"))
108	if rs.eof then 
109		conn.close
110		response.redirect "?errmsg=" & server.urlEncode("��� ����� �� ����� ����")
111	end if
112	orderTypeID=rs("id")
113	orderTypeName=rs("name")
114	set orderProp = server.createobject("MSXML2.DomDocument")
115	hasProperty=false
116	if rs("property")<>"" then 
117		orderProp.loadXML(rs("property"))
118		hasProperty=true
119	end if
120	rs.close
121	set rs=nothing
122	creationDate=shamsiToday()
123	creationTime=time
124	creationTime=Hour(creationTime)&":"&Minute(creationTime)
125	if instr(creationTime,":")<3 then creationTime="0" & creationTime
126	if len(creationTime)<5 then creationTime=Left(creationTime,3) & "0" & Right(creationTime,1)
127%>
128	<br>
129	<div dir='rtl'><B>��� ����� : ����� �����</B>
130	</div>
131	<br>
132<!-- ����� ����� -->
133	<hr>
134	<TABLE border="0" cellspacing="0" cellpadding="2" dir="RTL" width="700" align="center">
135	<FORM METHOD=POST ACTION="?act=submitorder" onSubmit="return checkValidation();">
136	<TR bgcolor="black">
137		<TD align="left"><FONT COLOR="YELLOW">����:</FONT></TD>
138		<TD align="right" colspan=3 height="25px">
139			<FONT COLOR="YELLOW"><%=customerID & " - "& AccountTitle%></FONT>
140			<INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>">
141		</TD>
142		<td align="left"><font color="yellow">��� �����:</font></td>
143		<td>
144			<font color="red"><b><%=orderTypeName%></b></font>
145			<input type="hidden" name="orderType" value="<%=orderTypeID%>">
146		</td>
147	</TR>
148	<TR bgcolor="black">
149		<TD align="left"><FONT COLOR="YELLOW">����� �����:</FONT></TD>
150		<TD align="right">
151			<!-- Radif -->
152			<INPUT disabled TYPE="text" NAME="Radif" maxlength="6" size="8" tabIndex="1" dir="LTR" value="######">
153		</TD>
154		<TD align="left"><FONT COLOR="YELLOW">�����:</FONT></TD>
155		<TD><TABLE border="0">
156			<TR>
157				<TD dir="LTR">
158					<INPUT disabled TYPE="text" maxlength="10" size="10" value="<%=CreationDate%>">
159					<INPUT TYPE="hidden" NAME="OrderDate" value="<%=CreationDate%>">
160				</TD>
161				<TD dir="RTL"><FONT COLOR="YELLOW"><%=weekdayname(weekday(date))%></FONT></TD>
162			</TR>
163			</TABLE></TD>
164		<TD align="left"><FONT COLOR="YELLOW">����:</FONT></TD>
165		<TD align="right">
166			<INPUT disabled TYPE="text" maxlength="5" size="3" dir="LTR" value="<%=creationTime%>">
167			<INPUT TYPE="hidden" NAME="OrderTime" value="<%=creationTime%>"></TD>
168	</TR>
169	<TR bgcolor="#CCCCCC">
170		<TD align="left">��� ����:</TD>
171		<TD align="right">
172			<!-- CompanyName -->
173			<INPUT TYPE="text" NAME="CompanyName" maxlength="50" size="25" tabIndex="2" value="<%=companyName%>">
174		</TD>
175		<TD></TD>
176		<TD align="left">
177			<span>���� ����� ����!</span>
178			<input name="returnDateNull" type="checkbox">
179		</td>
180		<TD title="���� ������� �� �� ���� �� ��� ��� ����Ρ �� ����� ����� ����� ������� ��� ����� �� � ��� ���� ������ ����� ���!" align="left">����� ����� �������:</TD>
181		<TD>
182			<TABLE border="0">
183				<TR>
184					<TD dir="LTR">
185						<INPUT TYPE="text" NAME="ReturnDate" onblur="acceptDate(this)" maxlength="10" size="10" >
186					</TD>
187					<TD dir="RTL">(?����)</TD>
188				</TR>
189			</TABLE>
190		</TD>
191	</TR>
192	<TR bgcolor="#CCCCCC">
193		<TD align="left">��� �����:</TD>
194		<TD align="right">
195			<!-- CustomerName -->
196			<INPUT TYPE="text" NAME="CustomerName" maxlength="50" size="25" tabIndex="3" value="<%=customerName%>">
197		</TD>
198		<TD align="left">����:</TD>
199		<TD align="right">
200			<!-- Telephone -->
201			<INPUT TYPE="text" NAME="Telephone" maxlength="50" size="25" tabIndex="4" value="<%=Tel%>">
202		</TD>
203		<TD align="left">���� �����:</TD>
204		<TD align="right">
205			<INPUT TYPE="text" NAME="ReturnTime" maxlength="5" size="3" dir="LTR" onKeyPress="return maskTime(this);" >
206		</TD>
207	</TR>
208	<TR bgcolor="#CCCCCC">
209		<td align="left">����:</td>
210		<td>
211			<input type="text" name="paperSize" tabindex="6">
212		</td>
213		<td align="left">���ǎ:</td>
214		<td>
215			<input type="text" name="qtty" tabindex="7">
216		</td>
217		<td align="left">���� ��:</td>
218		<td colspan="3">
219			<input type="text" name="totalPrice" id='totalPrice' style="background-color:#FED;border-width:0;" <%if hasProperty then response.write " readonly='readonly' "%>  tabindex="8">
220		</td>
221	</TR>
222	<TR bgcolor="#CCCCCC">
223		
224		<TD align="left">����� ��� ���� ����:</TD>
225		<TD align="right" colspan="3">
226			<INPUT TYPE="text" NAME="OrderTitle" maxlength="255" size="50" tabIndex="9">
227		</TD>
228		<TD align="left">����� ������:</TD>
229		<TD>
230			<INPUT Type="Text" readonly NAME="SalesPerson" value="<%=CSRName%>" style='font-family: tahoma,arial ; font-size: 9pt; font-weight: bold; width: 100px' tabIndex="888">
231		</TD>
232	</TR>
233	<TR bgcolor="#CCCCCC">
234		<TD colspan="6" height="30px">&nbsp;</TD>
235	</TR>
236	<tr bgcolor="#CCCCCC">
237	<td colspan="6">
238<%
239if hasProperty then 
240sub fetchKeys(key)
241	oldGroup="---first---"
242	oldLabel="---first---"
243	thisRow="<div class='myRow'>"
244	thisRow = thisRow & "<input type='hidden' value='0' id='" & Replace(key,"/","-") & "-maxID'>"
245	thisRow = thisRow & "<div class='exteraArea' id='" & Replace(key,"/","-") & "-0'>"
246' 	thisRow = thisRow & "<img title='��� ��� ��' src='/images/cancelled.gif' onclick='$(""#" & Replace(key,"/","-") & "-0"").remove();'>"
247' 	thisRow = thisRow & "<img title='��� ��� ��' src='/images/cancelled.gif' onclick='$(this).parent().remove();'>" 
248	For Each myKey In orderProp.SelectNodes(key)
249	  thisType = myKey.GetAttribute("type")
250	  thisName = myKey.GetAttribute("name")
251	  thisLabel= myKey.GetAttribute("label")
252	  thisGroup= myKey.GetAttribute("group")
253	  'response.write thisName & ": " & thisLabel &"(" &thisType& ")" & "<br>"
254	  if (oldGroup<>thisGroup and oldGroup <> "---first---") then thisRow = thisRow &  "</div>"
255	  if oldGroup<>thisGroup then 
256	  	thisRow = thisRow & "<div class='mySection' groupName='" & thisGroup & "'>"
257	  	if myKey.GetAttribute("disable")="1" then 
258			thisRow = thisRow &  "<input type='checkbox' value='0' name='" & thisGroup & "-disBtn' onclick='disGroup(this);"
259			if myKey.GetAttribute("blur")="yes" then thisRow = thisRow & " calc_" & myKey.GetAttribute("group") & "(this);"
260			thisRow = thisRow & "'>"
261			disText=" disabled='disabled' "
262		else
263			disText=""
264		end if
265	  end if
266	  if oldLabel<>thisLabel then thisRow = thisRow &  "<label class='myLabel'>" & thisLabel & "</label>"
267		
268	  select case thisType
269	  	case "option"
270	  		thisRow = thisRow &  "<select " & disText & " style='margin:0;padding:0;' name='" & thisName & "'"
271	  		if myKey.GetAttribute("blur")="yes" then thisRow = thisRow & " onchange='calc_" & myKey.GetAttribute("group") & "(this);' "
272	  		thisRow = thisRow & ">"
273	  		for each myOption in myKey.getElementsByTagName("option")
274	  			thisRow = thisRow &  "<option value='" & myOption.text & "'"
275	  			if myOption.GetAttribute("price")<>"" then 
276	  				thisRow = thisRow & " price='" & myOption.GetAttribute("price") & "' "
277	  			end if 
278	  			thisRow = thisRow &">" & myOption.GetAttribute("label") & "</option>"
279		  	next
280		  	thisRow = thisRow &  "</select>"
281		case "option-other"
282			thisRow = thisRow &  "<select " & disText & " style='margin:0;padding:0;' name='" & thisName & "' onchange='checkOther(this);"
283			if myKey.GetAttribute("blur")="yes" then thisRow = thisRow & " calc_" & myKey.GetAttribute("group") & "(this);"
284			thisRow = thisRow & "'>"
285	  		for each myOption in myKey.getElementsByTagName("option")
286	  			thisRow = thisRow &  "<option value='" & myOption.text & "'"
287	  			if myOption.GetAttribute("price")<>"" then 
288	  				thisRow = thisRow & " price='" & myOption.GetAttribute("price") & "' "
289	  			end if
290	  			thisRow = thisRow & ">" & myOption.GetAttribute("label") & "</option>"
291		  	next
292		  	thisRow = thisRow &  "<option value='-1'>����</option></select>"	
293		  	thisRow = thisRow & "<input type='text' name='" &thisName & "-addValue' onblur='addOther(this);'>"	  	
294		case "text"
295			thisRow = thisRow &  "<input " & disText & " type='text' class='myInput' size='" & myKey.text & "' name='" & thisName & "' "
296			if myKey.GetAttribute("readonly")="yes" then thisRow =thisRow & " readonly='readonly' "
297			if myKey.GetAttribute("default")<>"" then thisRow = thisRow & "value='" & myKey.GetAttribute("default") & "'"
298			if myKey.GetAttribute("blur")="yes" then thisRow = thisRow & " onblur='calc_" & myKey.GetAttribute("group") & "(this);' "
299			thisRow = thisRow & ">"
300		case "text area"
301			thisRow = thisRow &  "<textarea name='" & thisName & "' style='width:600px;' cols='" & myKey.text & "'></textarea>"
302		case "check"
303			thisRow = thisRow & "<input type='checkbox' value='on-0' name='" & thisName & "' "
304			if myKey.text="checked" then thisRow = thisRow & "checked='checked'"
305			if myKey.GetAttribute("blur")="yes" then thisRow = thisRow & " onclick='calc_" & myKey.GetAttribute("group") & "(this);' "
306			if IsNumeric(myKey.GetAttribute("price")) then thisRow = thisRow & " price='" & myKey.GetAttribute("price") & "' "
307			thisRow = thisRow & ">"
308		case "radio":
309				thisRow = thisRow & "<input " & disText & " type='radio' value='" & myKey.text & "' name='" & thisName & "'" 
310				if myKey.GetAttribute("default")="yes" then thisRow = thisRow & " checked='checked' "
311				if myKey.GetAttribute("blur")="yes" then thisRow = thisRow & " onchange='calc_" & myKey.GetAttribute("group") & "(this);' "
312				thisRow = thisRow & ">"
313	  end select
314	  if myKey.GetAttribute("force")="yes" then thisRow = thisRow &  "<span style='color:red;margin:0 0 0 2px;padding:0;'>*</span>"
315	  oldGroup=thisGroup
316	  oldLabel=thisLabel
317	  if myKey.GetAttribute("br")="yes" then thisRow = thisRow & "<br>"
318	Next
319	thisRow = thisRow & "</div></div><div id='extreArea" &Replace(key,"/","-")& "'></div>"
320	response.write thisRow 'prependTo 
321	response.write "<div class='btn'><img title='�����' src='/images/Plus-32.png' width='20px' onclick='cloneRow(""" & key & """);'><img title='��� ����� ��' src='/images/cancelled.gif' onclick='removeRow(""" & key & """);'></div></div>"
322end sub
323
324	oldTmp="---first---"
325	for each tmp in orderProp.selectNodes("//key")
326		if oldTmp<>tmp.parentNode.nodeName then 
327			oldTmp=tmp.parentNode.nodeName
328			call fetchKeys("/keys/" & oldTmp & "/key")
329		end if
330	next
331' 	call fetchKeys("/keys/printing/key")
332' 	call fetchKeys("keys/binding/key")
333' 	call fetchKeys("keys/service/key")
334' 	call fetchKeys("keys/delivery/key")
335end if
336%>			
337
338	</td>
339	</tr>
340	<TR bgcolor="#CCCCCC">
341		<TD colspan="6">
342		<TABLE align="center" width="50%" border="0">
343		<TR>
344			<TD><INPUT TYPE="submit" Name="Submit" Value="�����" style="width:100px;" tabIndex="14"></TD>
345			<TD><INPUT TYPE="hidden" NAME="Price" maxlength="10" size="9" dir="LTR" tabIndex="13" value="������">&nbsp;</TD>
346			<TD align="left"><INPUT TYPE="button" Name="Cancel" Value="������" style="width:100px;" onClick="window.location='OrderInput.asp';" tabIndex="15"></TD>
347		</TR>
348		</TABLE>
349		</TD>
350	</TR>
351	</FORM>
352	</TABLE>
353	<script type="text/javascript" src="/js/jquery-1.7.min.js"></script>
354	<script type="text/javascript" src="calcOrder.js"></script>
355	<SCRIPT LANGUAGE="JavaScript">
356		
357	<!--
358		function checkValidation(){
359		//TRIM : str = str.replace(/^\s*|\s*$/g,""); 
360		if(document.all.CustomerName.value.replace(/^\s*|\s*$/g,'') == ''){
361			alert("��� ����� �� ���� ����")
362			document.all.CustomerName.focus();
363			return false;
364		}
365		else if(document.all.SalesPerson.value.replace(/^\s*|\s*$/g,"") == ''){
366			alert("����� ������ �� ���� ����")
367			document.all.SalesPerson.focus();
368			return false;
369		}
370		else if(document.all.ReturnDate.value.replace(/^\s*|\s*$/g,'') == '' && !document.all.returnDateNull.checked){
371			alert("���� ����� �� ���� ����")
372			document.all.ReturnDate.focus();
373			return false;
374		}
375		else if(document.all.ReturnTime.value.replace(/^\s*|\s*$/g,'') == '' && !document.all.returnDateNull.checked){
376			alert("���� (����) ����� �� ���� ����")
377			document.all.ReturnTime.focus();
378			return false;
379		}
380		else if(document.all.OrderTitle.value.replace(/^\s*|\s*$/g,'') == ''){
381			alert("����� ��� ���� ���� �� ���� ����")
382			document.all.OrderTitle.focus();
383			return false;
384		}
385		else if(document.all.paperSize.value.replace(/^\s*|\s*$/g,'') == ''){
386			alert("���� �� ���� ����")
387			document.all.paperSize.focus();
388			return false;
389		}
390		else if(document.all.qtty.value.replace(/^\s*|\s*$/g,'') == ''){
391			alert("���ǎ �� ���� ����")
392			document.all.qtty.focus();
393			return false;
394		}
395		else{
396			document.all.Submit.disabled=true;
397			return true;
398		}
399	}
400
401		document.all.CompanyName.focus();
402	//-->
403	</SCRIPT>
404<%elseif request("act")="submitorder" then
405	CreationDate=shamsiToday()
406	CustomerID=request.form("CustomerID") 
407	if CustomerID="" OR not isNumeric(CustomerID) then
408		conn.close
409		response.redirect "?act=getorder&selectedCustomer=" & CustomerID & "&errMsg=" & Server.URLEncode("��� �� ��� �����<br>������� ���� ���...<BR>")
410	end if
411
412'	TraceID=request.form("radif")
413'
414'	if TraceID="" OR not isNumeric(TraceID) then
415'		conn.close
416'		response.redirect "?act=getorder&selectedCustomer=" & CustomerID & "&errMsg=" & Server.URLEncode("��� �� ����� �����<br>������� ���� ���...<BR>")
417'	end if
418'
419'	set RS1=Conn.Execute ("SELECT * FROM Orders WHERE (ID='"& TraceID & "')")
420'	if not RS1.eof then
421'		conn.close
422'		response.redirect "?act=getorder&selectedCustomer=" & CustomerID & "&errMsg=" & Server.URLEncode("����� ����� ������ ���<br>������� ���� ���...<BR>")
423'	end if
424'	RS1.close
425
426	orderType=request.form("OrderType")
427	if orderType="" OR not isNumeric(OrderType) then
428		conn.close
429		response.redirect "?act=getorder&selectedCustomer=" & CustomerID & "&errMsg=" & Server.URLEncode("��� �� ��� �����<br>������� ���� ���...<BR>")
430	end if
431	set rs=Conn.Execute("select * from OrderTraceTypes where id=" & orderType)
432	if rs.eof then 
433		conn.close
434		response.redirect "?errmsg=" & server.urlEncode("��� ����� �� ����� ����")
435	end if
436	set RS1=Conn.Execute ("SELECT Name FROM OrderTraceTypes WHERE (ID='"& orderType & "') AND (IsActive=1)")
437	if RS1.eof then
438		conn.close
439		response.redirect "?act=getorder&selectedCustomer=" & CustomerID & "&errMsg=" & Server.URLEncode("��� �� ��� �����<br>������� ���� ���...<BR>")
440	else
441		orderTypeName=RS1("Name")
442	end if
443	RS1.close
444	'----------------------------------------------------------------------------
445	'----------------------------------------------------------------------------
446	'----------------------------------------------------------------------------
447	orderTypeID=rs("id")
448	orderTypeName=rs("name")
449	set orderProp = server.createobject("MSXML2.DomDocument")
450	if rs("property")<>"" then 
451		orderProp.loadXML(rs("property"))
452		myXML = fetchKeyValues()
453	end if
454	rs.close
455	set rs=nothing
456	
457function fetchKeyValues()
458	key="---first---"
459	thisRow="<?xml version=""1.0""?><keys>"
460	for each tmp in orderProp.selectNodes("//key")
461		if key<>tmp.parentNode.nodeName then 
462			key=tmp.parentNode.nodeName
463			thisRow = thisRow & "<" & key & ">"
464			hasValue=0
465			For Each myKey In orderProp.SelectNodes("/keys/" & key & "/key")
466				thisName = myKey.GetAttribute("name")
467				thisGroup= myKey.GetAttribute("group")
468				id=0
469'					response.write oldName& "<br>"
470				if thisName<>oldName then 
471					for each value in request.form(thisName)
472						if value <> "" then 
473							thisRow = thisRow & "<key name=""" & thisName & """ id=""" 
474							select case myKey.GetAttribute("type") 
475								case "check"
476									thisRow = thisRow & mid(value,4)
477								case else
478									if request.form(thisGroup & "-disBtn")<>"" then 
479										thisRow = thisRow & trim(split(request.form(thisGroup & "-disBtn"),",")(id))
480									else
481										thisRow = thisRow & id 
482									end if
483							end select
484							thisRow = thisRow & """>" & value & "</key>"
485							hasValue=hasValue +1
486						end if
487						id=id+1
488					next
489				end if
490				oldName = thisName
491			Next
492			
493			if hasValue>0 then 
494				thisRow = thisRow & "</" & key & ">"
495			else
496				thisRow = Replace(thisRow,"<" & key & ">","")
497			end if
498		end if
499	Next
500	thisRow = thisRow & "</keys>"
501	fetchKeyValues = thisRow 
502	'response.write thisRow
503	'response.end
504end function
505
506	mySQL="INSERT INTO Orders (CreatedDate, CreatedBy, Customer) VALUES ('"& CreationDate & "', '"& session("ID") & "', '"& CustomerID & "');SELECT @@Identity AS NewOrder"
507	set RS1 = Conn.execute(mySQL).NextRecordSet
508	OrderID = RS1 ("NewOrder")
509	RS1.close
510	'--------------------------------SAM-----------------------------------------
511	'dim fs,f
512	'set fs = Server.CreateObject("Scripting.FileSystemObject")
513	'set f = fs.CreateFolder("d:\OrdersStorage\" & cstr(OrderID))
514	'set f = nothing
515	'set fs = nothing
516	'----------------------------------------------------------------------------
517	qtty = 0
518	if IsNumeric(request.form("qtty")) then 
519		qtty = cdbl(request.form("qtty"))
520	end if
521
522	ReturnDate = "null"
523	ReturnTime = "null"
524	if request.form("actualReturn_date")<>"" then actualReturn_date = "'" & request.form("actualReturn_date") & "'"
525	if request.form("ReturnDate")<>"" then ReturnDate = "'" & request.form("ReturnDate") & "'"
526	if request.form("ReturnDate")<>"" then ReturnTime = "'" & request.form("ReturnTime") & "'"
527		
528	mySQL="INSERT INTO orders_trace (radif_sefareshat, order_date, order_time, return_date, return_time, company_name, customer_name, telephone, order_title, order_kind, Type, vazyat, marhale, salesperson, status, step, LastUpdatedDate, LastUpdatedTime, LastUpdatedBy,property,qtty,paperSize,price) VALUES ('"&_
529	OrderID & "', N'"& sqlSafe(request.form("OrderDate")) & "', "& ReturnTime & ", "& ReturnDate & ", N'"& sqlSafe(request.form("ReturnTime")) & "', N'"& sqlSafe(request.form("CompanyName")) & "', N'"& sqlSafe(request.form("CustomerName")) & "', N'"& sqlSafe(request.form("Telephone")) & "', N'"& sqlSafe(request.form("OrderTitle")) & "', N'"& orderTypeName & "', '"& orderType & "', N'�� �����', N'�� �� ����', N'"& sqlSafe(request.form("SalesPerson")) & "', 1, 1, N'"& CreationDate & "',  N'"& currentTime10() & "', "& session("ID") & " ,N'" & myXML& "'," & qtty & ",'" & request.form("paperSize") & "','" & request.form("totalPrice") & "')"	
530	response.write mySQL
531	conn.Execute(mySQL)
532
533	conn.close
534	response.redirect "../order/TraceOrder.asp?act=show&order=" & OrderID & "&msg=" & Server.URLEncode("������� ����� ��� ��")
535else%>
536<!-- ����� ���� ��� ���� -->
537	<br>
538	<FORM METHOD=POST ACTION="?act=submitsearch" onsubmit="if (document.all.CustomerNameSearchBox.value=='') return false;">
539	<div dir='rtl'><B>��� ��� : ����� ���� ��� ����</B>
540		<INPUT TYPE="text" NAME="CustomerNameSearchBox">&nbsp;
541		<INPUT TYPE="submit" value="�����"><br>
542	</div>
543	</FORM>
544	<SCRIPT LANGUAGE="JavaScript">
545	<!--
546		document.all.CustomerNameSearchBox.focus();
547	//-->
548	</SCRIPT>
549<%
550end if
551conn.Close
552%>
553</font>
554<!--#include file="tah.asp" -->