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