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

/beta/inventory/ItemOut.asp

http://github.com/khaneh/Orders
ASP | 327 lines | 260 code | 40 blank | 27 comment | 33 complexity | 227d5b5712c57385770cd836847472b4 MD5 | raw file
  1<%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2'Inventory (5)
  3PageTitle= " ���� ����"
  4SubmenuItem=2
  5if not Auth(5 , 2) then NotAllowdToViewThisPage()
  6
  7%>
  8<!--#include file="top.asp" -->
  9<!--#include File="../include_farsiDateHandling.asp"-->
 10<!--#include File="../include_JS_InputMasks.asp"-->
 11<!--#include File="../include_UtilFunctions.asp"-->
 12
 13
 14<%
 15'-----------------------------------------------------------------------------------------------------
 16'-------------------------------------------------------------------------------------------- Item Out
 17'-----------------------------------------------------------------------------------------------------
 18if request.form("Submit")="�����" then
 19	PickID		=	request.form("PickID")
 20	comments	=	request.form("comments")
 21	exitDate	=	request.form("exitDate")
 22
 23	if Auth(5 , "C") AND "" & exitDate <> "" then ' ��� ����/���� �� ����� ������
 24		logDate=exitDate
 25	else
 26		logDate=shamsiToday()
 27	end if
 28	
 29	'===================================================
 30	' check status of pick list to be 'New' 
 31	' and change it to 'done'
 32	'===================================================
 33	set RSS=Conn.Execute ("SELECT * FROM InventoryPickuplists WHERE (id = "& PickID & " and status='new') " )
 34	if RSS.eof then 
 35		response.write "<BR><BR><BR><BR><center>���! <BR><BR>��� ����� ���� �� ����� ���� ��� ���. </center>"
 36		'response.write pickID
 37		response.end
 38	end if
 39	mySQL = "update InventoryPickuplists set status='done' where (id = "& PickID & ")"
 40'	response.write mySQL
 41	Conn.Execute (mySQL)
 42
 43
 44	'===================================================
 45	' insert items in InventoryLogOut table and
 46	' change the Qtty of item in InventoryItems table
 47	'===================================================
 48
 49
 50	set RSI=Conn.Execute ("SELECT dbo.InventoryPickuplistItems.*, ISNULL(dbo.Orders.Customer, - 1) AS owner, dbo.InventoryItemRequests.RelatedInvoiceID FROM dbo.InventoryPickuplistItems INNER JOIN dbo.InventoryItemRequests ON dbo.InventoryPickuplistItems.RequestID = dbo.InventoryItemRequests.ID LEFT OUTER JOIN dbo.Orders ON dbo.InventoryPickuplistItems.Order_ID = dbo.Orders.ID WHERE (dbo.InventoryPickuplistItems.pickupListID = "& PickID & ")")
 51	if RSI.eof then 
 52		response.write "<BR><BR><BR><BR><center>���! <BR><BR>����� ���� ���</center>"
 53		response.end
 54	end if
 55
 56	response.write "<BR><BR><BR><BR><center>����� ��� �� ����� ���� ��:"
 57	Do while not RSI.eof
 58		ItemID		=	RSI("ItemID")
 59		ItemName	=	RSI("ItemName")
 60		unit		=	RSI("unit")
 61		qtty		=	RSI("qtty")
 62		order_ID	=	RSI("order_ID")
 63		RequestID	=	RSI("RequestID")
 64		RelatedInvoiceID	=	RSI("RelatedInvoiceID")
 65		if trim(RelatedInvoiceID) = "" or isnull(RelatedInvoiceID) then
 66			RelatedInvoiceID = 0
 67		end if
 68
 69		if RSI("CustomerHaveInvItem") then
 70			owner	=	RSI("owner")
 71		else
 72			owner	= "-1"
 73		end if
 74		mySQL = "SET NOCOUNT ON;INSERT INTO InventoryLog (ItemID, RelatedID, Qtty, logDate, CreatedBy, owner, IsInput, comments, type, RelatedInvoiceID,price,gl_update) VALUES ("& ItemID & ","& PickID& ","& Qtty& ",N'"& logDate& "', "& session("ID") & ", " & owner & " , 0, N'" & comments & "', 1, "& RelatedInvoiceID & ", null,0);select @@identity as newID;SET NOCOUNT OFF;"
 75		'response.write mySQL 
 76		'response.end
 77		set rs = Conn.Execute(mySQL)
 78		newOut = rs.Fields("newID").value
 79		rs.close
 80		set rs= nothing
 81		if RSI("CustomerHaveInvItem") then
 82			set RSW=Conn.Execute ("SELECT SUM((CONVERT(tinyint, dbo.InventoryLog.IsInput) - .5) * 2 * dbo.InventoryLog.Qtty) AS sumQtty, dbo.Accounts.AccountTitle FROM dbo.Orders INNER JOIN dbo.InventoryLog ON dbo.Orders.Customer = dbo.InventoryLog.owner INNER JOIN dbo.Accounts ON dbo.Orders.Customer = dbo.Accounts.ID WHERE (dbo.InventoryLog.ItemID = " & ItemID & " and dbo.InventoryLog.voided=0) GROUP BY dbo.Orders.ID, dbo.Accounts.AccountTitle HAVING (dbo.Orders.ID = " & order_ID  & ")")
 83			newItemQtty = RSW("sumQtty")
 84			RSW.close
 85			set RSW = nothing
 86		else
 87			set RSW=Conn.Execute ("SELECT * FROM InventoryItems WHERE (id = "& ItemID & ")" )
 88			newItemQtty = RSW("qtty")
 89			RSW.close
 90			set RSW = nothing
 91		end if
 92		response.write "<li> " & ItemName & " " & qtty & " " & unit & " (���������: " & newItemQtty & " " & unit & ")"
 93		if clng(newItemQtty)<0 then 
 94			response.write "error!"
 95			response.end
 96		end if
 97'		Conn.Execute ("update InventoryItems set qtty="& newItemQtty & " where (id = "& ItemID & ")")
 98' --------------- TEmPORARY DISABLE
 99'		Conn.Execute("execute dbo.outFIFO")
100		set rs=conn.Execute("select * from InventoryFIFORelations where outID=" & newOut)
101		while not rs.eof
102			response.write("<li> ���� �� ���� <a href='invReport.asp?oldItemID=-1&itemID=" & itemID & "'>" & rs("inID") & "</a> �� ����� " & rs("qtty") & " ����� ��.<br>")
103			rs.moveNext
104		wend
105		RSI.moveNext
106	loop 
107	RSI.close
108	response.write "</center>"
109	
110%>
111	<BR>	
112	<CENTER>
113		<% 	ReportLogRow = PrepareReport ("InvPickupList.rpt", "InvItem_ID", PickID, "/beta/dialog_printManager.asp?act=Fin") %>
114		<INPUT TYPE="button" value=" �ǁ " Class="GenButton" style="border:1 solid blue;" onclick="printThisReport(this,<%=ReportLogRow%>);">
115	</CENTER>
116
117	<BR>
118	<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>
119<%
120response.end
121end if
122
123'-----------------------------------------------------------------------------------------------------
124'------------------------------------------------------------------- Inventory Item Pickup list Submit
125'-----------------------------------------------------------------------------------------------------
126if request.form("Submit")="��� �����" then
127	
128
129	PickID =  request.form("PickID")
130	if PickID = "" then%>
131		<br><br>
132		<%
133		call showAlert("��� ����� �� ���� ��� ������ ���� ���", CONST_MSG_ERROR)
134	else
135			set RSX=Conn.Execute ("update InventoryPickuplists set status='del', LastEditedBy=" & session("id") & ", LastEditDate=N'" & shamsiToday() & "', LastEditTime=N'" & currentTime10() & "' where id=" & PickID)
136			response.write "<br><br>"
137			call showAlert(" ����� ����� " & PickID & " ��� ��. ", CONST_MSG_INFORM)
138				
139			set RSX=Conn.Execute ("SELECT dbo.InventoryPickuplistItems.RequestID FROM         dbo.InventoryPickuplists INNER JOIN dbo.InventoryPickuplistItems ON dbo.InventoryPickuplists.id = dbo.InventoryPickuplistItems.pickupListID where InventoryPickuplists.id=" & PickID)
140
141
142			Do while not RSX.eof
143				Conn.Execute ("UPDATE dbo.InventoryItemRequests SET status='new' WHERE (ID = "& RSX("RequestID") & ")")
144				RSX.moveNext
145			loop
146			RSX.close
147
148			response.write "<br><br>"
149			call showAlert(" ������� ��� ������ �� �� ���� ����� �ѐ����. ", CONST_MSG_INFORM)
150			
151	end if
152
153end if
154'-----------------------------------------------------------------------------------------------------
155'------------------------------------------------------------------- Inventory Item Pickup list Submit
156'-----------------------------------------------------------------------------------------------------
157if request.form("Submit")="������ ���� ����" then
158	 PickID =  request.form("PickID")
159	 if PickID ="" then
160		response.redirect "ItemOut.asp"
161	end if
162
163	set RSS=Conn.Execute ("SELECT * FROM InventoryPickuplists WHERE (id = "& PickID & ") " )
164	if RSS.eof then 
165		response.redirect "ItemOut.asp"
166	end if
167
168	set RSI=Conn.Execute ("SELECT dbo.InventoryPickuplistItems.*, ISNULL(dbo.Orders.Customer, - 1) AS owner FROM dbo.InventoryPickuplistItems LEFT OUTER JOIN dbo.Orders ON dbo.InventoryPickuplistItems.Order_ID = dbo.Orders.ID WHERE (dbo.InventoryPickuplistItems.pickupListID = "& PickID & ") " )
169	if RSI.eof then 
170		response.redirect "ItemOut.asp"
171	end if
172
173	set RST=Conn.Execute ("SELECT RealName FROM Users WHERE (ID = "& RSS("GiveTo") & ")" )
174	GiveToRealName = RST("RealName")
175
176	response.write "<center><br><br><br><BR><BR><BR>��� �� ��� ��� ���� ����� ����� �� ����� ��� �� ����� �����: "
177	response.write "<BR><br><br><BR><TABLE align=center style='border: solid 2pt black; '><TR><TD style='font-size:12pt'>"
178	response.write "<li>����� �����: " & PickID
179	response.write "<li> ����� ����: " &  RSS("CreationDate") & "  (" & RSS("CreationTime") & ")"
180	response.write "<li> ������ �����: " & GiveToRealName
181	response.write "<hr>"
182	Do while not RSI.eof
183		ItemID		=	RSI("ItemID")
184		ItemName	=	RSI("ItemName")
185		unit		=	RSI("unit")
186		qtty		=	RSI("qtty")
187		order_ID	=	RSI("order_ID")
188		RequestID	=	RSI("RequestID")
189		if RSI("CustomerHaveInvItem") then
190			owner	=	RSI("owner")
191		else
192			owner	= "-1"
193		end if
194
195		set RSW=Conn.Execute ("SELECT * FROM InventoryItems WHERE (id = "& ItemID & ")" )
196		OldItemID = RSW("OldItemID")
197		if owner = "-1" then
198			itemQtty = RSW("qtty")
199		else
200			itemQtty = RSW("cusQtty")
201		end if
202
203		if itemQtty < Qtty then 
204			response.write "<span><li  style='background-color: #FF9933'> "& OldItemID & " - " & ItemName & " (��������: " & Qtty & " " &  unit & " - ������: "& itemQtty & " "& unit & ")</span>"
205			notAvailable = "yes"
206		else
207			response.write "<li> "& OldItemID & " - " & ItemName & " (" & Qtty & " " &  unit & ")"
208			if not owner = "-1" then
209				response.write "<b> ������ " & owner & " </b>" 
210			end if
211		end if
212		RSI.moveNext
213	loop
214	RSI.close
215	 
216response.write "</TD></TR></TABLE><br><br><FORM METHOD=POST ACTION='ItemOut.asp'><INPUT TYPE='hidden' name='PickID' value='"& PickID & "'>"
217if notAvailable <> "yes" then
218	
219	if Auth(5 , "C") then ' ��� ����/���� �� ����� ������
220%>
221	����� &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT dir=ltr TYPE="text" NAME="exitDate" style="width:200px;" value="<%=shamsiToday()%>" onblur="acceptDate(this)"><br><br>
222<%
223	End if
224%>
225	������� <TEXTAREA NAME='comments' style="width:200px;" ></TEXTAREA><br><br>
226	<INPUT TYPE='submit' name='submit' class=inputBut value='�����'> &nbsp;&nbsp;
227	<INPUT TYPE='submit' name='submit' class=inputBut value='������'>
228<%
229else
230	response.write "�� ���� ����� ����� ���� �� ����� ��� ����� ���� ���� ����. "
231	response.write "<A HREF='default.asp?ed=" & RSS("id") & "'>(����� �����)</A>"
232end if
233	response.write "<BR><BR></center></FORM>"
234response.end
235
236end if
237if Request("act")="" then 
238set RSS=Conn.Execute ("SELECT InventoryPickuplists.*, Users.RealName AS RealName FROM InventoryPickuplists INNER JOIN Users ON InventoryPickuplists.GiveTo = Users.ID WHERE (InventoryPickuplists.Status = 'new') ORDER BY InventoryPickuplists.ID" )
239 %>
240<BR>
241<FORM METHOD=POST ACTION="">
242<TABLE dir=rtl align=center width=600 cellspacing=0>
243<TR bgcolor="eeeeee" >
244	<TD align=center colspan=6><B>����� ��� ���� ����</B></TD>
245</TR>
246<TR bgcolor="eeeeee" >
247	<TD style="border-bottom: solid 1pt black" ><INPUT TYPE="radio" NAME="" disabled></TD>
248	<TD style="border-bottom: solid 1pt black" ><!A HREF="default.asp?s=1"><SMALL>����� </SMALL></A></TD>
249	<TD style="border-bottom: solid 1pt black" ><!A HREF="default.asp?s=2"><SMALL>����� ����� </SMALL></A></TD>
250	<TD style="border-bottom: solid 1pt black" ><!A HREF="default.asp?s=3"><SMALL>������ �����</SMALL></A></TD>
251	<TD style="border-bottom: solid 1pt black" ><!A HREF="default.asp?s=4"><SMALL>�����</SMALL></A></TD>
252</TR>
253<%
254tmpCounter=0
255Do while not RSS.eof
256	tmpCounter = tmpCounter + 1
257	if tmpCounter mod 2 = 1 then
258		tmpColor="#FFFFFF"
259		tmpColor2="#FFFFBB"
260	Else
261		tmpColor="#FFFFFF"
262		tmpColor2="#FFFFBB"
263		'tmpColor="#DDDDDD"
264		'tmpColor2="#EEEEBB"
265	End if 
266
267set RSF=Conn.Execute ("SELECT * FROM InventoryPickuplistItems WHERE (pickupListID = "& RSS("ID") & ")" )
268%>
269<TR style="cursor:hand" onclick="this.getElementsByTagName('input')[0].click();this.getElementsByTagName('input')[0].focus();">
270	<TD  style="border-bottom: solid 1pt black; border-left: solid 1pt black; border-right: solid 1pt black" ><INPUT TYPE="radio" NAME="PickID" onclick="setColor(this)" VALUE="<%=RSS("id")%>"></TD>
271	<TD style="border-bottom: solid 1pt black; border-left: solid 1pt black" ><A HREF="default.asp?show=<%=RSS("id")%>"><%=RSS("id")%></A></TD>
272	<TD style="border-bottom: solid 1pt black; border-left: solid 1pt black" dir=l><span dir=ltr><%=RSS("CreationDate")%></span><!-- (���� <%=RSS("CreationTime")%>)--></small></TD>
273	<TD style="border-bottom: solid 1pt black; border-left: solid 1pt black" ><%=RSS("RealName")%></TD>
274	<TD style="border-bottom: solid 1pt black; border-left: solid 1pt black" >
275	<%
276	
277	
278	response.write "<TABLE width=100% >"
279
280	Do while not RSF.eof
281		response.write "<TR><TD>" & RSF("ItemName") & " (" & RSF("qtty") & " " & RSF("unit") & ") "
282		if RSF("CustomerHaveInvItem") then
283			response.write "<b style='color:red;background-color:white'> ������ </b>" 
284		end if
285		response.write "</TD><TD align=left dir=ltr>" 
286		if RSF("Order_ID")<>-1 then
287			response.write RSF("Order_ID") & "</TD></TR>"
288		end if
289	RSF.moveNext
290	Loop
291	response.write "</TABLE>"
292	%>
293
294	</TD>
295</TR>
296<% 
297RSS.moveNext
298Loop
299%>
300</TABLE><br>
301<center>
302	<INPUT TYPE="submit" Name="Submit" Value="��� �����" onclick="return confirm('��� ������ �� ������ ��� ������� �� ��� ���Ͽ')" class="btn" style="width:150px;" tabIndex="14"> 
303	<INPUT TYPE="submit" Name="Submit" Value="������ ���� ����" class="btn" style="width:150px;" tabIndex="14">
304</center>
305</form>
306<%
307		
308	end if
309	
310%>
311<SCRIPT LANGUAGE="JavaScript">
312<!--
313
314function setColor(obj)
315{
316	for(i=0; i<document.all.PickID.length; i++)
317		{
318		theTR = document.all.PickID[i].parentNode.parentNode
319		theTR.setAttribute("bgColor","<%=AppFgColor%>")
320		}
321	theTR = obj.parentNode.parentNode
322	theTR.setAttribute("bgColor","#FFFFFF")
323}
324//-->
325</SCRIPT>
326
327<!--#include file="tah.asp" -->