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