PageRenderTime 42ms CodeModel.GetById 26ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/beta/inventory/ItemIn.asp

http://github.com/khaneh/Orders
ASP | 908 lines | 794 code | 59 blank | 55 comment | 100 complexity | a081a014f0cb50f818b399cbe2bcb6ff MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Inventory (5)
  3PageTitle= " ���� ����"
  4SubmenuItem=3
  5if not Auth(5 , 3) then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_UtilFunctions.asp"-->
 11<link type="text/css" href="/css/cupertino/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
 12<script type="text/javascript" src="/js/jquery-1.7.min.js"></script>
 13<script type="text/javascript" src="/js/jalaliCalendar.js"></script>
 14<script type="text/javascript" src="/js/jquery.dateFormat-1.0.js"></script>
 15<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
 16<script type="text/javascript">
 17$(document).ready(function(){
 18	$.ajaxSetup({
 19		cache: false
 20	});
 21	$("div#invSelect").dialog({ 
 22		autoOpen: false,
 23		title: '��� � ��� ����� �����' ,
 24		width: 460
 25	});
 26	$("input#invCode").blur(function(){
 27		$.getJSON("xml_InventoryItem.asp",
 28			{act:'fromCode',invCode:$("input#invCode").val()},
 29			function(json){
 30				$("input#itemName").val(json.itemName);
 31				$("input#itemID").val(json.itemID);
 32				$("input#err").val(json.err);
 33				if (json.err==1){
 34					$("input[name=Submit]").prop("disabled", true);
 35					$("div#errMsg").html(json.errMsg);
 36				}
 37				else {
 38					$("input[name=Submit]").prop("disabled", false);
 39					$("div#errMsg").html("");
 40				}
 41				$.each(json.store, function(i,st){
 42					$("select#store").children("[value=" + st.storeID + "]").attr("unit",st.unit);
 43				});
 44				$("input#unit").val($("select#store").children(":selected").attr("unit"));
 45			}
 46		);
 47	});
 48	$("input#invCode").keypress(function(event){
 49		if ( event.which == 13 ) {
 50			event.preventDefault();
 51			if ($("input#invCode").val()==''){
 52				$("div#invSelect").dialog('open');
 53			} else {
 54				$("select#store").focus();
 55			}
 56		}
 57	});
 58	$("select#store").change(function(){
 59		$("input#unit").val($(this).children(":selected").attr("unit"));
 60	});
 61	$("input#mySearch").change(function(){
 62		if ($(this).val()=='')
 63			$("div#searchResult").html('����� �� Ȑ���� �� ���� �����!');
 64		else {
 65			
 66			$.getJSON("xml_InventoryItem.asp",
 67				{act:'search',search:$(this).val()},
 68				function(json){
 69					var result='';
 70					$.each(json, function(i,invItem){
 71						result +="<div class='invItem' invID='" + invItem.id + 
 72							"' invName='" + invItem.name + "' invCode='" + invItem.invCode + 
 73							"'>(<span class='red'>" +invItem.invCode +"</span>) <b>" + invItem.name+"</b></div>";
 74					});
 75					if (result=='')
 76						result = '���� ���� �����!';
 77					$("div#searchResult").html(result);
 78					$("div.invItem").click(function(){
 79						$("input#invCode").val($(this).attr("invCode"));
 80						$("input#itemName").val($(this).attr("invName"));
 81						$("input#itemID").val($(this).attr("invID"));
 82						$.getJSON("xml_InventoryItem.asp",
 83							{act:'getStore',itemID:$(this).attr("invID")},
 84							function(json){
 85								$.each(json, function(i,st){
 86									$("select#store").children("[value=" + st.storeID + "]").attr("unit",st.unit);
 87								});
 88								$("input#unit").val($("select#store").children(":selected").attr("unit"));
 89							}
 90						);
 91						$("div#invSelect").dialog('close');
 92						$("select#store").focus();
 93					});
 94				}
 95			);
 96			
 97		}
 98	});
 99	$("input#searchBut").click(function(e){
100		e.preventDefault();
101		if ($("input#itemID").val==''){
102			$("div#errMsg").html("������ ������ ���塝 ���� ������ ������ ����");
103			$("input[name=Submit]").prop("disabled", true);
104		} else if ($("select#store").children(":selected").attr("unit")==''){
105			
106		}
107	});
108	
109});
110
111</script>
112<style>
113	span.red{color: red;}
114	div.errMsg{color: red;}
115	div.invItem{margin: 5px 0 5px 0;cursor: pointer;}
116	div.invItem:hover{margin: 5px 0 5px 0;cursor: pointer;background-color: #F90;}
117</style>
118<BR>
119<%
120catItem1 = request("catItem")
121itemID = request("item")
122owner = request("owner")
123if not isNumeric(itemID) then
124	response.write "<br>" 
125	call showAlert ("���! �� ���� ���� ��� ����",CONST_MSG_ERROR) 
126	response.write "<br>" 
127	response.end
128end if
129purchaseOrderID = request("purchaseOrderID")
130if catItem1="" then 
131	'catItem1="-1"
132	'itemID="-1"
133	'purchaseOrderID="-1"
134elseif itemID="" then 
135	itemID="-1"
136	purchaseOrderID="-1"
137	owner = "-1"
138elseif purchaseOrderID="" then 
139	purchaseOrderID="-1"
140end if
141
142
143'-----------------------------------------------------------------------------------------------------
144'----------------------------------------------------------------------- Show Inventory Log In Reciept
145'-----------------------------------------------------------------------------------------------------
146if request("act")="showReceipt" then
147	response.write "<br><br><br><br><center>"
148	if request("id")<>"" then 
149		LogItem_ID=request("id")
150		set rs=Conn.Execute("select inventoryLog.*,InventoryItems.unit,InventoryItems.name from inventoryLog inner join InventoryItems on inventoryLog.itemID=InventoryItems.id where inventoryLog.id=" & LogItem_ID)
151		response.write "<li> " & rs("qtty") & " " & RS("unit") & " "  & RS("Name") & " " 
152		if cdbl(rs("owner"))>0 then 
153			response.write "���� " & rs("owner") & " "
154		end if
155		response.write " (������ ����: " & rs("sumQtty") & " " & RS("unit") & "� ������ �����: " & rs("sumCusQtty") & " " & rs("unit") &")"
156		rs.close
157		set rs=nothing
158	else
159		item = request("item")
160		qtty = request("qtty")
161		set RSW=Conn.Execute ("SELECT * FROM InventoryItems WHERE (OldItemID = "& item & ")" )
162		ItemID = RSW("id")
163		
164		
165		oldItemQtty = RSW("qtty")
166		newItemQtty = oldItemQtty ' + qtty
167		response.write "<li> " & RSW("Name") & " " & qtty & " " & RSW("unit") & " (������ ����: " & newItemQtty & " " & RSW("unit") & ")"
168
169		set RSW=Conn.Execute ("SELECT * FROM InventoryLog WHERE (ItemID = "& ItemID & " and Qtty="& Qtty & ") order by id DESC" )
170		LogItem_ID = RSW("id")
171	end if
172	response.write "<br><br>����� ��� �� ����� ����� ��."
173	%>
174	<BR>	<BR>
175	<CENTER>
176	<% 	ReportLogRow = PrepareReport ("InventoryLogIn.rpt", "LogItem_ID", LogItem_ID, "/beta/dialog_printManager.asp?act=Fin") %>
177	<INPUT TYPE="button" value=" �ǁ ����" Class="GenButton" style="border:1 solid blue;" onclick="printThisReport(this,<%=ReportLogRow%>);">
178
179	<input type="button" value="���� ����� ����" Class="GenButton" onclick="window.location='itemIn.asp'">
180
181	</CENTER>
182
183	<BR>	
184	<iframe name=f1 id=f1 src="/CRReports/?Id=<%=ReportLogRow%>" align=center style="width:700; height:410; border-style: none" border=0 FRAMEBORDER=0 scrollbars=no></iframe>
185	<%
186
187	response.end
188
189end if
190'-----------------------------------------------------------------------------------------------------
191'---------------------------------------------------------------------- Voroode Piramon Marjooe submit
192'-----------------------------------------------------------------------------------------------------
193if request.form("Submit")="���� ������� ��� ������" then
194
195	invoice_id = trim(request.form("invoice_id"))
196	if not isnumeric(invoice_id) then 
197		response.write "<br><br>"
198		call showAlert( "����� ������ ���� ��� ������ ���." , CONST_MSG_ERROR)
199		response.end
200	end if 
201
202	'vvvvvvv ------------------------------------------ start of check for current ItemOUT
203	set RSS=Conn.Execute ("SELECT InventoryLog.id, InventoryLog.comments, InventoryLog.Voided, InventoryLog.VoidedBy, InventoryLog.VoidedDate, InventoryItems.Unit, InventoryItems.Name, InventoryItems.OldItemID, InventoryLog.logDate, InventoryLog.Qtty, InventoryLog.RelatedID, InventoryLog.ItemID, InventoryLog.type, InventoryLog.ID, InventoryLog.CreatedBy, InventoryLog.owner, Users.RealName FROM InventoryLog INNER JOIN InventoryItems ON InventoryLog.ItemID = InventoryItems.ID INNER JOIN Users ON InventoryLog.CreatedBy = Users.ID WHERE (InventoryLog.RelatedInvoiceID = "& invoice_id & ") AND (InventoryLog.IsInput = 1)")
204	if not RSS.EOF then
205		%>
206		<br><br>
207		<%
208		call showAlert("���� ����� ��� ��� ���� �� �����  ���� ��� ���", CONST_MSG_ALERT)
209		response.write "<br><br>" 
210		%>
211		<TABLE dir=rtl align=center width=600>
212			<TR bgcolor="eeeeee" >
213				<TD><SMALL>�� ����</SMALL></TD>
214				<TD width=200><SMALL>��� ����</SMALL></TD>
215				<TD><SMALL>����� </SMALL></TD>
216				<TD><SMALL>����</SMALL></TD>
217				<TD><SMALL>����� ����</SMALL></TD>
218				<TD align=center><SMALL>����� �����</SMALL></TD>
219				<TD><SMALL>����</SMALL></TD>
220			</TR>
221		<%
222		tmpCounter=0
223		do while not RSS.EOF
224			tmpCounter = tmpCounter + 1
225			if tmpCounter mod 2 = 1 then
226				tmpColor="#FFFFFF"
227				tmpColor2="#FFFFBB"
228			Else
229				tmpColor="#DDDDDD"
230				tmpColor2="#EEEEBB"
231			End if 
232
233			%>
234			<TR bgcolor="<%=tmpColor%>"  style="height:25pt" <% if RSS("voided") then%> disabled title="��� ��� �� ����� <%=RSS("VoidedDate")%>"<% end if %>>
235				<TD  align=right dir=ltr><INPUT TYPE="hidden" name="id" value="<%=RSS("ID")%>"><A HREF="invReport.asp?oldItemID=<%=RSS("oldItemID")%>&logRowID=<%=RSS("ID")%>" target="_blank"><%=RSS("OldItemID")%></A></TD>
236				<TD><% if RSS("voided") then%><div style="position:absolute;width:520;"><hr style="color:red;"></div><% end if %><!A HREF="default.asp?itemDetail=<%=RSS("ID")%>"><span style="font-size:10pt"><%=RSS("Name")%></A></TD>
237				<TD align=right dir=ltr><span style="font-size:10pt"><%=RSS("Qtty")%></span></TD>
238				<TD align=right dir=ltr><%=RSS("Unit")%></TD>
239				<TD dir=ltr><%=RSS("logDate")%></span></TD>
240			<TD align=center><% if RSS("type")= "1" and RSS("RelatedID")<> "-1" then
241					%>
242						����� ���� 
243				     <A HREF="../purchase/outServiceTrace.asp?od=<%=RSS("RelatedID")%>"><%=RSS("RelatedID")%></A>
244				   <%
245				   elseif RSS("type")= "2" then
246					response.write "<font color=red><b>����� ������</b></font>"
247				   elseif RSS("type")= "3" then
248					response.write "<font color=green><b>������</b></font>"
249					elseif RSS("type")= "4" then
250					response.write "<font color=blue><b>����� ����� ���� </b></font>"
251					elseif RSS("type")= "5" then
252					response.write "<font color=orang><b>������</b></font>"
253					elseif RSS("type")= "6" then
254					response.write "<font color=#6699CC><b>���� �� �����</b></font>"
255					elseif RSS("type")= "7" then
256					response.write "<font color=#FF9966><b>���� �� ����� ������</b></font>"
257				   else 
258					response.write " "
259				   end if	%>
260				   
261				<% if RSS("owner")<> "-1" and RSS("owner")<> "-2" then
262					response.write " (������ <a href='../CRM/AccountInfo.asp?act=show&selectedCustomer="& RSS("owner") &"' target='_blank'> " & RSS("owner") & "</a>)"
263				   end if %>
264				<% if RSS("comments")<> "-" and RSS("comments")<> "" then
265					response.write " <br><br><B>�����:</B>  " & RSS("comments") 
266				   end if %>
267				   </TD>
268				<TD><%=RSS("RealName")%></TD>
269			</TR>
270				  
271			<% 
272			RSS.movenext
273		loop
274		response.write "</table><br><br>" 
275		response.end
276
277	end if
278	RSS.close
279	set RSS = nothing
280	'^^^^^^^ ------------------------------------------ end of check for current ItemOUT
281
282
283	set RSS=Conn.Execute ("SELECT dbo.InventoryItems.Name, dbo.InvoiceLines.AppQtty, dbo.InventoryItems.ID as itemID, dbo.InvoiceItems.RelatedInventoryItemID, dbo.InventoryItems.Unit FROM dbo.InvoiceLines INNER JOIN dbo.InvoiceItems ON dbo.InvoiceLines.Item = dbo.InvoiceItems.ID INNER JOIN dbo.InventoryItems ON dbo.InvoiceItems.RelatedInventoryItemID = dbo.InventoryItems.OldItemID WHERE (dbo.InvoiceLines.Invoice = " & invoice_id & ")")
284	st = ""
285	response.write "<BR><BR><CENTER>��� ���� ������� ��� ������ ��� �� ����� �� ����� �� ���Ͽ<BR><BR>"
286
287	do while not RSS.EOF
288		response.write "<li> " & RSS("AppQtty") & " " & RSS("unit") & " " & RSS("name") 
289		RSS.movenext
290	loop
291	%>
292	<FORM METHOD=POST ACTION="">
293		<INPUT TYPE="hidden" name="invoice_id" value="<%=invoice_id%>">
294		<INPUT TYPE="submit" Name="Submit" Value="����� ���� ������� ��� ������" class=inputBut style="width:170px;" >
295		<INPUT TYPE="submit" Name="Submit" Value="������" class=inputBut style="width:70px;" >
296	</FORM>
297	<%
298	response.end
299'-----------------------------------------------------------------------------------------------------
300'---------------------------------------------------------------------- Voroode Piramon Marjooe submit
301'-----------------------------------------------------------------------------------------------------
302elseif request.form("Submit")="����� ���� ������� ��� ������" then
303	'response.write "<br><br>"
304	'call showAlert("��� ���� ���� ����� ����.",CONST_MSG_ERROR)
305	'response.end
306
307	invoice_id = trim(request.form("invoice_id"))
308	if not isnumeric(invoice_id) then 
309		response.write "<br><br>"
310		call showAlert( "����� ������ ���� ��� ������ ���." , CONST_MSG_ERROR)
311		response.end
312	end if 
313
314	set RSS=Conn.Execute ("SELECT dbo.InventoryItems.Name, dbo.InvoiceLines.AppQtty, dbo.InventoryItems.ID as itemID, dbo.InvoiceItems.RelatedInventoryItemID, dbo.InventoryItems.Unit FROM dbo.InvoiceLines INNER JOIN dbo.InvoiceItems ON dbo.InvoiceLines.Item = dbo.InvoiceItems.ID INNER JOIN dbo.InventoryItems ON dbo.InvoiceItems.RelatedInventoryItemID = dbo.InventoryItems.OldItemID WHERE (dbo.InvoiceLines.Invoice = " & invoice_id & ")")
315	st = ""
316	response.write "<BR><BR><CENTER>������� ��� ������ ��� ���� ����� ��:<BR>"
317
318	do while not RSS.EOF
319		mysql = "INSERT INTO dbo.InventoryLog (ItemID, RelatedID, Qtty, logDate, owner, CreatedBy, IsInput, type, RelatedInvoiceID) VALUES (" & RSS("itemID") & ", -3, " & RSS("AppQtty") & ", N'" & shamsiToday() & "', -1, " & session("id") & ", 1, 3, " & invoice_id & ")"
320		response.write "<li> " & RSS("AppQtty") & " " & RSS("unit") & " " & RSS("name") 
321		Conn.Execute (mysql)
322		'response.write "<br>" & mysql
323		RSS.movenext
324	loop
325	response.end
326
327end if
328'-----------------------------------------------------------------------------------------------------
329'-------------------------------------------------------------------- Submit an Inventory Item Input 3
330'-----------------------------------------------------------------------------------------------------
331if request.form("Submit")="���� ���� �� �����" then
332	item = trim(request.form("item"))
333	qtty = CDbl(request.form("qtty"))
334	purchaseOrderID = CDbl(request.form("purchaseOrderID"))
335	ownerAcc = CDbl(request.form("accountID"))
336	comments = request.form("comments")
337	entryDate = request.form("entryDate")
338	price= request.form("price")
339	if price<>"" then 
340		price = CDbl(price)
341	else
342		price = 0
343	end if
344	gl_update = request.form("gl_update")
345
346	if Auth(5 , "C") AND "" & entryDate <> "" then ' ��� ����/���� �� ����� ������
347		logDate=entryDate
348	else
349		logDate=shamsiToday()
350	end if
351	
352	if 	not item = "" then
353
354		if purchaseOrderID="" then
355			purchaseOrderID = "-1"
356		end if
357
358		if item="-1" or qtty=0 then
359			response.write "<br><br><br>"
360			CALL showAlert ("<B>���! </B><BR>��� ������ ������ ����� ���<br><br><A HREF='itemIn.asp'>�ѐ��</A>",CONST_MSG_ALERT) 
361			response.end
362		end if
363
364		if qtty<0 then
365			response.write "<br><br><br>"
366			CALL showAlert ("<B>���! </B><BR>����� ���� ��� ����� ���� ����<br><br><A HREF='itemIn.asp'>�ѐ��</A>",CONST_MSG_ALERT) 
367			response.end
368		end if
369		
370		if price<=0 and ownerAcc=-1 and purchaseOrderID<>-9 then
371			response.write "<br><br><br>"
372			CALL showAlert ("<B>���! </B><BR>���� �� �� ���� ���� ���� ������<br><br><A HREF='itemIn.asp'>�ѐ��</A>",CONST_MSG_ALERT) 
373			response.end
374		end if
375		
376		set RSW=Conn.Execute ("SELECT * FROM InventoryItems WHERE (OldItemID = "& item & ")" )
377		ItemID = RSW("id")
378		if ownerAcc=-1 then 
379			mySQL = "select * from inventoryLog where owner=-1 and itemID=" & itemID & " and isInput=0 and logDate>='" & logDate & "' and pricedQtty is not null order by logDate desc"
380	'		response.write mySQL
381			set rs=conn.Execute(mySQL)
382			if not rs.eof then 
383				response.write "<br><br><br>"
384				CALL showAlert ("<B>���! </B><BR>��� �� ��� ����� ���� ��� ��� ��ʡ ���� ��� �� ����� " & rs("logDate") & " ���� ��� ����<br><br><A HREF='itemIn.asp'>�ѐ��</A>",CONST_MSG_ALERT) 
385				response.end
386			end if
387		end if
388		response.write "<br><br><br><br><center>"
389
390		
391		type1 = 1 
392		if purchaseOrderID < 0 then type1 = -1 * purchaseOrderID
393		if purchaseOrderID = -8 then 
394			type1 = 1
395			purchaseOrderID = request.form("customerItemRequest")
396		end if
397		if CDbl(price)>0 then 
398			pricedQtty = qtty
399		else
400			pricedQtty = "null"
401		end if
402		mySql="SET NOCOUNT ON;INSERT INTO InventoryLog (ItemID, RelatedID, logDate, Qtty, owner, CreatedBy, IsInput, comments, type, price, gl_update, pricedQtty) VALUES ("& ItemID & ", "& purchaseOrderID & ",N'"& logDate & "', "& Qtty & ", "& ownerAcc & ", "& session("id") & ", 1, N'" & comments & "', " & type1 & "," & price & " ,0," & pricedQtty & " );select @@identity as newID;"
403		'response.write mySQL
404		set rs = conn.Execute(mySql)
405		newID = rs.Fields("newID").value
406		RS.close
407		set rs = nothing
408		if ownerAcc = -1 then 
409			Conn.Execute("insert into InventoryPriceLog (logID,logDate,userID,price) values(" & newID & ",'" & logDate & "'," & session("id") &"," & price & ")")
410		end if
411		'response.redirect "ItemIn.asp?act=showReceipt&item=" & item & "&qtty=" & qtty
412		response.redirect "ItemIn.asp?act=showReceipt&id=" & newID
413	end if
414
415'-----------------------------------------------------------------------------------------------------
416'-------------------------------------------------------------------- Submit an Inventory Item Input 2
417'-----------------------------------------------------------------------------------------------------
418elseif request.form("Submit")="������" then
419%>
420<SCRIPT LANGUAGE="JavaScript">
421<!--
422function hideIT()
423{
424//alert(document.all.aaa2.value)
425if(document.all.aaa2.value==2) 
426	{
427		document.all.aaa1.style.visibility= 'visible'
428		document.all.accountID.value = ""
429		document.all.accountID.focus()
430	}
431	else
432	{
433		document.all.aaa1.style.visibility= 'hidden'
434		document.all.accountID.value = "-1"
435	}
436}
437//-->
438</SCRIPT>
439<%
440customerItemRequest = -1
441comment=""
442purchaseOrderID = request.form("purchaseOrderID")
443if purchaseOrderID = "" then purchaseOrderID = -1
444purchaseOrderID = CInt(purchaseOrderID)
445'set RSA=Conn.Execute ("SELECT * FROM purchaseOrders WHERE (Status = 'OUT' and ID="& purchaseOrderID & ")" )
446if purchaseOrderID > 0 then 
447	set RSA=Conn.Execute ("SELECT * FROM purchaseOrders WHERE (ID="& purchaseOrderID & ")" )
448	if not (RSA.eof) then
449		set rs = Conn.Execute("select * from VoucherLines where RelatedPurchaseOrderID = " & purchaseOrderID)
450		if not rs.eof then 
451			qtty = rs("qtty")
452			price = rs("price")
453			msg = "<a href='../AP/AccountReport.asp?act=showVoucher&voucher=" & rs("voucher_ID") & "'>���� ��� ��� �� ������</a>"
454			gl_update=0
455		else
456			Qtty = RSA("Qtty")
457			price = RSA ("price")
458			msg = "<a href='../purchase/outServiceTrace.asp?od=" & purchaseOrderID & "'>���� ������ ��� ��� �� ����� ����</a>"
459			gl_update=-1
460		end if
461		rs.close
462	else
463		call showAlert ("���� ����! ����� ���� ������ ���� ���" , CONST_MSG_ERROR )
464		response.end
465	end if
466	RSA.close
467elseif purchaseOrderID = -1 then 
468	price = request.form("price")
469	msg="��� ���� ���� �� ���� ���� ������"
470elseif purchaseOrderID = -3 then 
471	set rs = Conn.Execute("select * from InventoryLog where id = " & request.form("retID"))
472	price = rs("price")
473	qtty = rs("qtty")
474	gl_update=0
475	rs.close
476elseif purchaseOrderID = -7 then 
477	set rs = Conn.Execute("select * from InventoryLog where id = " & request.form("outID"))
478	price = rs("price")
479	qtty = rs("qtty")
480	gl_update=0
481	rs.close
482elseif purchaseOrderID = -2 then 
483	gl_update=0
484	price = request.form("price")
485	'------------------------------------------------------------------------------------------------
486	' NOT COMPLITED!!!!!!!!!!!!!!!!!!!!!!
487	'------------------------------------------------------------------------------------------------
488elseif purchaseOrderID = -6 then 
489	gl_update=0
490	price = request.form("price")
491	'------------------------------------------------------------------------------------------------
492	' NOT COMPLITED!!!!!!!!!!!!!!!!!!!!!!
493	'------------------------------------------------------------------------------------------------
494elseif purchaseOrderID = -8 then 
495	customerItemRequest = request.form("customerItemRequest")
496	mySQL="select InventoryItemRequests.*, Orders.Customer, Accounts.accountTitle from InventoryItemRequests inner join Orders on InventoryItemRequests.order_id=orders.id inner join Accounts on Orders.customer=Accounts.id where InventoryItemRequests.id=" & customerItemRequest
497	'response.write mySQL
498	set rs = Conn.Execute(mySQL)
499	if rs.eof then 
500		call showAlert ("���� ����! ����� ������ ���� ��� ���� ���" , CONST_MSG_ERROR )
501		response.end
502	end if
503	if rs("comment")<>"" then comment="�����: " & rs("comment")
504	owner=rs("customer")
505	qtty=rs("qtty")
506	accountName = rs("accountTitle")
507	
508	rs.close
509	set rs = Conn.Execute("select * from InventoryLog where owner>0 and voided=0 and IsInput=1 and RelatedId=" & customerItemRequest)
510	if not rs.eof then 
511		call showAlert ("���� ����! ��� ���� ���� ���� ���" , CONST_MSG_ERROR )
512		response.end
513	end if
514elseif purchaseOrderID = -9 then
515	owner=-1
516	price=0
517end if
518
519'response.write purchaseOrderID 
520%>
521<FORM METHOD=POST ACTION="itemin.asp">
522<INPUT TYPE="hidden" name="item" value="<%=request.form("item")%>">
523<INPUT TYPE="hidden" name="customerItemRequest" value="<%=customerItemRequest%>">
524<INPUT TYPE="hidden" name="purchaseOrderID" value="<%=request.form("purchaseOrderID")%>"><BR><BR>
525<TABLE border=0 align=center>
526<TR>
527	<TD align=left valign=top>��� ����</TD>
528	<TD align=right><span disabled><%=request("goodName")%></span><br><br></TD>
529</TR>
530
531<TR>
532	<TD align=left>�����</TD>
533	<TD align=right>
534		<INPUT dir=ltr TYPE="text" NAME="qtty" size=25 value="<%=Qtty%>" ><onKeyPress="return maskNumber(this);" >
535	</TD>
536</TR>
537<%if customerItemRequest=-1 then %>
538<TR>
539	<TD align=left>����</TD>
540	<TD align=right>
541		<INPUT dir=ltr TYPE="text" NAME="price" size=25 value="<%=price%>" ><onKeyPress="return maskNumber(this);" >
542		<small style="color:red;">* ���� ����� ����� �� ��� ���� �� ��� ���� �� ����� ���� ������. �� �� ��� �� ��� ��������</small>
543		<br><%=msg%><small style="color:red;">* ���� �� �� ��� ����</small>
544	</TD>
545</TR>
546<%end if%>
547<TR>
548	<TD align=left valign=top>������</TD>
549	<TD align=right>
550<%if customerItemRequest=-1 then %>
551	<SELECT NAME="aaa2" onchange="hideIT()" >
552		<option value=1 >���� �ǁ � ���</option>
553		<option value=2 <%if owner<>"-1" then response.write " selected" %>>������ (����� ����)</option>
554	</SELECT>
555<%end if%>
556	<BR>
557	<span name="aaa1" id="aaa1" <% if owner="-1" then response.write "style=""visibility:'hidden'"""%>>
558	<input type="hidden" name="gl_update" value="<%=gl_update%>">
559	<input type="hidden" Name='tmpDlgArg' value=''>
560	<input type="hidden" Name='tmpDlgTxt' value=''>
561	<INPUT  dir="LTR"  TYPE="text" NAME="accountID" maxlength="10" size="13"  value="<%=owner%>" onKeyPress='return mask(this);' onBlur='check(this);'> &nbsp;&nbsp; <INPUT TYPE="text" NAME="accountName" size=30 readonly  value="<%=accountName%>" style="background-color:transparent">
562	</span></TD>
563</TR>
564<%
565	if Auth(5 , "C") then ' ��� ����/���� �� ����� ������
566%>
567	<TR>
568		<TD align=left>�����</TD>
569		<TD align=right><INPUT dir=ltr TYPE="text" NAME="entryDate" size=25 value="<%=shamsiToday()%>" onblur="acceptDate(this)"></TD>
570	</TR>
571<%
572	End if
573
574%>
575<TR>
576	<TD align=left>�������</TD>
577	<TD align=right><TEXTAREA NAME="comments" ROWS="" COLS=""><%=comment%></TEXTAREA>
578	<br><br></TD>
579</TR>
580<TR>
581	<TD align=left></TD>
582	<TD align=right></TD>
583</TR>
584<TR>
585	<TD align=center colspan=2>
586	<INPUT TYPE="submit" Name="Submit" Value="���� ���� �� �����" class=inputBut style="width:120px;" tabIndex="14"<%
587	if not itemID<>"-1" then
588		response.write " disabled "
589	end if
590	%>>
591	</TD>
592</TR>
593</TABLE>
594<SCRIPT LANGUAGE="JavaScript">
595<!--
596document.all.qtty.focus()
597
598var dialogActive=false;
599
600function mask(src){ 
601	var theKey=event.keyCode;
602
603	if (theKey==13){
604		event.keyCode=9
605		dialogActive=true
606		document.all.tmpDlgArg.value="#"
607		document.all.tmpDlgTxt.value="����� �� ��� ���� ��� ������:"
608		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;');
609		if (document.all.tmpDlgTxt.value !="") {
610			var myTinyWindow = window.showModalDialog('../ar/dialog_selectAccount.asp?act=select&search='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:500px; dialogWidth:380px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
611			dialogActive=false
612			if (document.all.tmpDlgArg.value!="#"){
613				Arguments=document.all.tmpDlgArg.value.split("#")
614				src.value=Arguments[0];
615				document.all.accountName.value=Arguments[1];
616			}
617		}
618	}
619}
620
621function check(src){ 
622	if (!dialogActive){
623		badCode = false;
624		if (window.XMLHttpRequest) {
625			var objHTTP=new XMLHttpRequest();
626		} else if (window.ActiveXObject) {
627			var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
628		}
629		objHTTP.open('GET','../accounting/xml_CustomerAccount.asp?id='+src.value,false)
630		objHTTP.send()
631		tmpStr = unescape(objHTTP.responseText)
632		document.all.accountName.value=tmpStr;
633		}
634}
635
636
637//-->
638</SCRIPT>
639<%
640'-----------------------------------------------------------------------------------------------------
641'-------------------------------------------------------------------- Submit an Inventory Item Input 1
642'-----------------------------------------------------------------------------------------------------
643elseif request.form("Submit")="�����" then
644%>
645<FORM METHOD=POST ACTION="itemin.asp">
646<INPUT TYPE="hidden" name="item" value="<%=request.form("item")%>">
647<TABLE border=0 align=center>
648<%
649				storeID = request("store")
650				set RSW=Conn.Execute ("SELECT * FROM InventoryItems Left outer join inventoryItemsInStore on inventoryItemsInStore.itemID=inventoryItems.id and inventoryItemsInStore.storeID=" & storeID & "  WHERE (invCode = "& itemID & ")" )
651				if RSW.EOF then
652					call showAlert ("���! �� ���� ����� ����" , CONST_MSG_ERROR )
653					response.end
654				end if 
655				if IsNull(RSW("itemID")) then 
656					
657				end if
658				itemID = RSW("id")
659				goodUnit = RSW("unit")
660				goodName = RSW("name")
661				owner = RSW("owner")
662				RSW.close
663				set RSW = nothing
664				set rs = Conn.Execute("select * from storeHouses where id=" & storeID)
665				if RS.EOF then
666					call showAlert ("���! ����� ���� �����" , CONST_MSG_ERROR )
667					response.end
668				end if
669				storeName = rs("name")
670				rs.close
671				set rs=nothing
672%>
673<TR>
674	<TD align=right>
675	<span disabled><%=goodName%> �� <b><%=storeName%></b></span><BR>
676	<BR>
677	<br>
678	</TD>
679</TR>
680<INPUT TYPE="hidden" name="goodName" value="<%=goodName%>">
681<TR>
682	<TD align=right>
683			
684<%
685				set RSA=Conn.Execute ("SELECT * FROM purchaseOrders WHERE (Status = 'OUT' and TypeID="& itemID& ") order by OrdDate" )
686				'set RSA=Conn.Execute ("SELECT * FROM purchaseOrders WHERE (TypeID="& itemID& ") order by OrdDate" )
687				flg = false
688				if not RSA.eof then 
689					response.write("����� ���� �� ������ ����:<br>")
690					while not (RSA.eof) %>
691						<INPUT TYPE="radio" NAME="purchaseOrderID" value="<%=RSA("ID")%>"<%
692						if trim(purchaseOrderID) = trim(RSA("ID")) then
693							response.write " chcecked "
694							preQtty = RSA("Qtty")
695							flg = true
696						end if
697						%>> ����� <%=RSA("ID")%> (<%=RSA("Qtty")%>&nbsp;<%=goodUnit%>&nbsp;<%=goodName%>) <BR>
698	<%					RSA.MoveNext
699					wend
700					RSA.close
701				end if
702				if Auth(5,"E") then 
703					response.write ("<input type='hidden' NAME='customerItemRequest' id='customerItemRequest'>")
704					set rs=Conn.Execute ("select InventoryItemRequests.*,Accounts.accountTitle from InventoryItemRequests inner join Orders on InventoryItemRequests.order_id=orders.id inner join Accounts on Orders.customer=Accounts.id where InventoryItemRequests.status='new' and CustomerHaveInvItem=1 and InventoryItemRequests.id not in(select RelatedId from InventoryLog where owner>0 and voided=0 and IsInput=1 and ItemID=" & itemID & ") and itemID=" & itemID)
705					if not rs.eof then response.write ("<br>������ʝ��� �����:<br>")
706					while not rs.eof
707						response.write("<INPUT TYPE='radio' name='purchaseOrderID' value='-8' onclick='document.all.customerItemRequest.value=" & rs("id") & "';>")
708						response.write ("<a href='../shopfloor/manageOrder.asp?radif=" & rs("order_id") & "'>������� �� ����� " & rs("order_id") & "</a>���� " & rs("accountTitle") & " <span title='" & rs("comment") & "'>(" & RS("Qtty") &"&nbsp;" & goodUnit &"&nbsp;"& goodName & ")</span> <BR>")
709						rs.moveNext
710					wend
711					rs.close
712					set rs = nothing
713				end if
714				'rs.close
715				if Auth(5,"G") then 
716				'-------------------------------------------------------------------------------------------------
717				'--------------------------------------- NOT IMPLIMENTED!!!!--------------------------------------
718				'-------------------------------------------------------------------------------------------------
719				set rs=Conn.Execute("select [log].*,inventoryItemsInStore.unit from InventoryLog as [log] inner join (select top 1  logDate from InventoryLog where ItemID=" & itemID & " and sumQtty=0 order by logDate desc) as date on [log].logDate>date.logDate inner join inventoryItemsInStore on [log].itemID=inventoryItemsInStore.itemID and [log].storeID=inventoryItemsInStore.storeID where isInput = 0 and [log].ItemID=" & itemID)
720				if not rs.eof then 
721				%>
722				<INPUT TYPE="radio" NAME="purchaseOrderID" value="-3"> ����� ������ <select name="retID">
723					<%
724					while not rs.eof
725					%>
726					<option value="<%=rs("id")%>"><%=rs("Qtty") & rs("unit") & " �� ����� " & rs("logDate")%></option>
727					<%
728						rs.moveNext
729					wend
730					%>
731				</select><br>
732				<%
733				end if
734				rs.close
735				end if
736				if Auth(5,"F") then
737				'-------------------------------------------------------------------------------------------------
738				'--------------------------------------- NOT IMPLIMENTED!!!!--------------------------------------
739				'------------------------------------------------------------------------------------------------- 
740				%>
741				<INPUT TYPE="radio" NAME="purchaseOrderID" value="-6"> ���� �� �����<small> ����� �����:<input name="orderID" type="text" size="6"></small><br>
742				<%
743				end if
744				if Auth(5,"H") then 
745				'-------------------------------------------------------------------------------------------------
746				'---------------------------------------in 91.3.17 by SAM
747				'-------------------------------------------------------------------------------------------------
748				mySQL = "select storeHouses.*, isnull(drv.sumQtty,0) as sumQtty from storeHouses left outer join (select storeID,SUM(IsInput * Qtty) - SUM((1 - IsInput) * Qtty) AS sumQtty from inventoryLog where itemID=" & itemID &  " and owner=-1 and voided=0 group by storeID) drv on drv.storeID=storeHouses.id  where id<>" & storeID
749'				response.write mySQL
750				set rs=Conn.Execute(mySQL)
751				if not rs.eof then 
752				%>
753				<INPUT TYPE="radio" NAME="purchaseOrderID" value="-7"> ���� �� ���� �������<select name="outID">
754				<%
755					while not rs.eof
756					%>
757					<option value="<%=rs("id")%>" <%if cint(rs("sumQtty"))=0 then response.write " disabled='disabled'"%>>
758						<%=rs("name") & " ������ " & rs("sumQtty")%>
759					</option>
760					<%
761						rs.moveNext
762					wend
763					%>
764				</select><br>
765				<%
766				end if
767				rs.close
768				end if
769				if Auth(5 , 7) then %>
770				<INPUT TYPE="radio" NAME="purchaseOrderID" value="-2"> ����� ������<br>
771				<% end if 
772				if Auth(5,"I") then
773				%>
774				<INPUT TYPE="radio" NAME="purchaseOrderID" value="-9">���� ������<br>
775				<%
776				end if
777				%>
778			<br><br></TD>
779</TR>
780<TR>
781	<TD align=center colspan=2>
782	<INPUT TYPE="hidden" name="owner" value="<%=owner%>">
783	<INPUT TYPE="submit" Name="Submit" Value="������" class=inputBut style="width:120px;" tabIndex="14">
784	</TD>
785</TR>
786</Table>	
787</FORM>
788<SCRIPT LANGUAGE="JavaScript">
789<!--
790document.all.purchaseOrderID[0].focus()
791//-->
792</SCRIPT>
793<%
794else
795'-----------------------------------------------------------------------------------------------------
796'-------------------------------------------------------------------------------  Inventory Item Input
797'-----------------------------------------------------------------------------------------------------
798%>
799<FORM METHOD=POST ACTION="itemin.asp" id='searchForm'>
800<TABLE border=0 align=center>
801<TR>
802	<TD colspan=2 align=center><H3>���� ����</H3></TD>
803</TR>
804<TR>
805	<TD align=left>�� ����</TD>
806	<TD align=right>
807		
808		<input type="hidden" Name='tmpDlgArg' value=''>
809		<input type="hidden" Name='tmpDlgTxt' value=''>
810		<INPUT dir="LTR" TYPE="text" NAME="item" id="invCode" maxlength="10" size="13">
811		<!-- onKeyPress='return mask(this);' onBlur='check(this);'--> 
812		&nbsp;&nbsp; 
813		<INPUT TYPE="text" NAME="accountName" id="itemName" size=50 readonly='readonly' style="background-color:transparent">
814	</TD>
815</TR>
816<tr>
817	<td align="left">�����</td>
818	<td align="right">
819		<select name="store" id='store'>
820<%
821		set rs=Conn.Execute("select * from storeHouses")
822		while not rs.eof
823			response.write("<option value='" & rs("id") & "'unit=''>" & rs("name") & "</option>")
824			rs.moveNext
825		wend
826		rs.close
827		set rs=nothing
828%>				
829		</select>
830	</td>
831</tr>
832<TR>
833	<TD align=center colspan=2>
834	<INPUT TYPE="hidden" name="unit" id='unit'>
835	<INPUT TYPE="hidden" name="itemID" id='itemID'>
836	<input type="hidden" name='err' id='err'>
837	<INPUT TYPE="submit" Name="Submit" id="searchBut" Value="�����" class=inputBut style="width:120px;" tabIndex="14" disabled="disabled">
838	</TD>
839</TR>
840</TABLE>
841</FORM>
842<BR><BR>
843<TABLE align=center width=50%>
844<div id='errMsg' class="errMsg"></div>
845<div id='invSelect' dir="rtl">
846	<span>��� ���� �� ���� ����: </span>
847	<input type="text" name="mySearch" id='mySearch'>
848	<div id='searchResult'></div>
849</div>
850<!--TR>
851	<TD align=center style="border:solid 1pt black">
852		<BR>
853		<FORM METHOD=POST ACTION="">
854		<B> ������� ������ <BR></B><BR>
855		����� �ѐ�� �� ����: <INPUT TYPE="text" NAME="invoice_id" dir=ltr ><BR><BR> <INPUT TYPE="submit"  name="submit"  value="���� ������� ��� ������">
856		<BR>
857		</FORM>
858	</TD>
859</TR-->
860</TABLE><BR>
861
862<SCRIPT LANGUAGE="text/javascript">
863document.all.item.focus()
864
865var dialogActive=false;
866
867function mask(src){ 
868	var theKey=event.keyCode;
869
870	if (theKey==13){
871		event.keyCode=9
872		dialogActive=true
873		document.all.tmpDlgArg.value="#"
874		document.all.tmpDlgTxt.value="����� �� ������� �����"
875		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;');
876		if (document.all.tmpDlgTxt.value !="") {
877			var myTinyWindow = window.showModalDialog('dialog_selectInvItem.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;');
878			dialogActive=false
879			if (document.all.tmpDlgArg.value!="#"){
880				Arguments=document.all.tmpDlgArg.value.split("#")
881				src.value=Arguments[0];
882				document.all.accountName.value=Arguments[1];
883			}
884		}
885	}
886}
887
888function check(src){ 
889	
890	if (!dialogActive){
891		badCode = false;
892		if (window.XMLHttpRequest) {
893			var objHTTP=new XMLHttpRequest();
894		} else if (window.ActiveXObject) {
895			var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
896		}
897		objHTTP.open('GET','xml_InventoryItem.asp?id='+src.value,false)
898		objHTTP.send()
899		tmpStr = unescape(objHTTP.responseText)
900		document.all.accountName.value=tmpStr;
901		}
902}
903
904</SCRIPT>
905<%
906end if 
907%>
908<!--#include file="tah.asp" -->