/beta/inventory/report.asp

http://github.com/khaneh/Orders · ASP · 320 lines · 274 code · 33 blank · 13 comment · 50 complexity · e643d05a746e91e4dd64be957a82650c MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'Inventory (5)
  3. PageTitle= " "
  4. SubmenuItem=5
  5. if not Auth(5 , 5) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <%
  11. fromDate = request("fromDate")
  12. toDate = request("toDate")
  13. InRep = request("InRep")
  14. outRep = request("outRep")
  15. if inRep="" then
  16. InRepSt = " "
  17. else
  18. InRepSt = "checked"
  19. end if
  20. if outRep="" then
  21. outRepSt = " "
  22. else
  23. outRepSt = "checked"
  24. end if
  25. if toDate="" or fromDate="" then
  26. toDate = shamsiToday()
  27. fromDate = shamsiDate(Date())
  28. InRepSt = "checked"
  29. outRepSt = "checked"
  30. flag = "first"
  31. end if
  32. '-----------------------------------------------------------------------------------------------------
  33. '------------------------------------------------------------------------------------- Delete Log Line
  34. '-----------------------------------------------------------------------------------------------------
  35. if request("act") = "del" and isNumeric(request("rowID")) then
  36. rowID = clng(request("rowID"))
  37. desc = request("desc") ' Description : Deletion Reason
  38. if "" & desc = "" then
  39. desc = "-"
  40. else
  41. desc = sqlSafe(desc)
  42. end if
  43. set RSS=Conn.Execute ("SELECT * from InventoryLog where (ID = " & rowID & ") and voided = 0")
  44. if RSS.EOF then
  45. response.write "<br><br>"
  46. call showAlert ("! ." , CONST_MSG_ERROR)
  47. else
  48. if rss("gl_update")="1" then
  49. response.write "<br><br>"
  50. call showAlert ("! !." , CONST_MSG_ERROR)
  51. else
  52. type1 = RSS("type")
  53. RelatedID = RSS("RelatedID")
  54. isInput = RSS("isInput")
  55. if type1 = 1 and not isInput then
  56. Conn.Execute ("UPDATE InventoryPickuplists SET Status = 'new' WHERE (id = " & RelatedID & ")")
  57. response.write "<br><br>"
  58. call showAlert (" Ґ." , CONST_MSG_INFORM)
  59. end if
  60. if (not isInput) and (RelatedID > 0) then
  61. set RSB=Conn.Execute ("SELECT id from InventoryLog where (RelatedID = " & RelatedID & " and isInput=0) and voided = 0 ")
  62. Do while not RSB.eof
  63. Conn.Execute ("UPDATE InventoryLog SET Voided =1, VoidedBy =" & session("id") & ", VoidedDate =N'" & shamsiToday() & "', comments = LEFT(comments + '<br>[ : " & desc & "]', 250) WHERE (ID = " & RSB("id") & ")")
  64. RSB.movenext
  65. loop
  66. else
  67. Conn.Execute ("UPDATE InventoryLog SET Voided =1, VoidedBy =" & session("id") & ", VoidedDate =N'" & shamsiToday() & "', comments = LEFT(comments + '<br>[ : " & desc & "]', 250) WHERE (ID = " & rowID & ") AND (voided = 0)")
  68. end if
  69. response.write "<br><br>"
  70. call showAlert (" ." , CONST_MSG_INFORM)
  71. Conn.Execute("update InventoryLog set price=null, pricedQtty=null where isInput=0 and owner=-1 and voided=0 and itemID=" & rss("itemID"))
  72. Conn.Execute("update InventoryLog set pricedQtty = qtty where isInput=1 and owner=-1 and voided=0 and itemID=" & rss("itemID"))
  73. Conn.Execute("delete from InventoryFIFORelations where inID in (select id from InventoryLog where isInput=1 and owner=-1 and voided=0 and itemID=" & rss("itemID")) &")"
  74. Conn.Execute("delete from InventoryFIFORelations where outID in (select id from InventoryLog where isInput=0 and owner=-1 and voided=0 and itemID=" & rss("itemID")) &")"
  75. 'Conn.Execute("execute dbo.outFIFO")
  76. end if
  77. end if
  78. end if
  79. '-----------------------------------------------------------------------------------------------------
  80. '---------------------------------------------------------------------- Inventory Transaction Log Form
  81. '-----------------------------------------------------------------------------------------------------
  82. %>
  83. <BR><BR>
  84. <FORM METHOD=POST ACTION="report.asp">
  85. <TABLE border=0 align=center>
  86. <TR>
  87. <TD colspan=5 align=center><H3> </H3></TD>
  88. </TR>
  89. <TR>
  90. <TD align=left> </TD>
  91. <TD align=right><INPUT TYPE="text" NAME="fromDate" value="<%=fromDate%>" dir=ltr onKeyPress="return maskDate(this);" onblur="acceptDate(this)" maxlength="10"></TD>
  92. <TD align=left width=20></TD>
  93. <TD align=left> </TD>
  94. <TD align=right><INPUT TYPE="text" NAME="toDate" value="<%=toDate%>" dir=ltr onKeyPress="return maskDate(this);" onblur="acceptDate(this)" maxlength="10"></TD>
  95. </TR>
  96. <TR height=10>
  97. <TD colspan=5 align=center></TD>
  98. </TR>
  99. <TR>
  100. <TD align=left></TD>
  101. <TD align=right><INPUT TYPE="checkbox" NAME="outRep" <%=outRepSt%>> </TD>
  102. <TD align=left width=20><INPUT TYPE="checkbox" NAME="InRep" <%=inRepSt%>></TD>
  103. <TD align=left> </TD>
  104. <TD align=left><INPUT TYPE="submit" NAME="submit" class=inputBut value=""></TD>
  105. </TR>
  106. </TABLE>
  107. </FORM>
  108. <%
  109. if flag = "first" then
  110. response.end
  111. end if
  112. '-----------------------------------------------------------------------------------------------------
  113. '------------------------------------------------------------------------------------- Transaction Log
  114. '-----------------------------------------------------------------------------------------------------
  115. if request("submit")=""then
  116. %>
  117. <TABLE dir=rtl align=center width=95%>
  118. <%
  119. if outRep = "on" then
  120. ' mySQL="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.CreatedBy, InventoryLog.owner, Users.RealName, Users_1.RealName AS GiveTo FROM InventoryLog INNER JOIN InventoryItems ON InventoryLog.ItemID = InventoryItems.ID INNER JOIN Users ON InventoryLog.CreatedBy = Users.ID INNER JOIN InventoryPickuplists ON InventoryLog.RelatedID = InventoryPickuplists.id INNER JOIN Users Users_1 ON InventoryPickuplists.GiveTo = Users_1.ID WHERE (InventoryLog.logDate >= N'"& fromDate & "' and InventoryLog.logDate <= N'"& toDate & "' and IsInput=0) ORDER BY InventoryLog.ID DESC"
  121. mySQL="SELECT InventoryLog.ID, InventoryLog.comments, InventoryLog.Voided, InventoryLog.VoidedDate, InventoryItems.Unit, InventoryItems.Name, InventoryItems.OldItemID, InventoryLog.logDate, InventoryLog.Qtty, InventoryLog.RelatedID, InventoryLog.ItemID, InventoryLog.type, InventoryLog.CreatedBy, InventoryLog.owner, Users.RealName, Users_1.RealName AS GiveTo, Users_2.RealName AS VoidedBy, InventoryFIFORelations.inID,InventoryFIFORelations.qtty as inQtty FROM InventoryLog INNER JOIN InventoryItems ON InventoryLog.ItemID = InventoryItems.ID INNER JOIN Users ON InventoryLog.CreatedBy = Users.ID left outer JOIN InventoryPickuplists ON InventoryLog.RelatedID = InventoryPickuplists.id and InventoryLog.RelatedID>0 left outer JOIN Users Users_1 ON InventoryPickuplists.GiveTo = Users_1.ID LEFT OUTER JOIN Users Users_2 ON InventoryLog.VoidedBy = Users_2.ID left outer join InventoryFIFORelations on inventoryLog.id = InventoryFIFORelations.outID WHERE (InventoryLog.logDate >= N'"& fromDate & "') AND (InventoryLog.logDate <= N'"& toDate & "') AND (InventoryLog.IsInput = 0) ORDER BY InventoryLog.ID DESC"
  122. 'response.write mySQL
  123. set RSS=Conn.Execute (mySQL)
  124. %>
  125. <TR bgcolor="eeeeee" >
  126. <TD colspan=9><H4> </H4></TD>
  127. </TR>
  128. <TR bgcolor="eeeeee" >
  129. <TD></TD>
  130. <TD></TD>
  131. <TD width=200> </TD>
  132. <TD> </TD>
  133. <TD></TD>
  134. <TD> </TD>
  135. <TD></TD>
  136. <TD align=center> </TD>
  137. <TD></TD>
  138. </TR>
  139. <%
  140. tmpCounter=0
  141. Do while not RSS.eof
  142. tmpCounter = tmpCounter + 1
  143. if tmpCounter mod 2 = 1 then
  144. tmpColor="#FFFFFF"
  145. tmpColor2="#FFFFBB"
  146. Else
  147. tmpColor="#DDDDDD"
  148. tmpColor2="#EEEEBB"
  149. End if
  150. %>
  151. <TR bgcolor="<%=tmpColor%>" style="height:25pt" <% if RSS("voided") then%> disabled title=" <%=RSS("VoidedDate")%> <%=RSS("VoidedBy")%>"<% end if %>>
  152. <TD align=center dir=ltr><small disabled><%=RSS("id")%></small><% if not RSS("voided") then%><A HREF="javascript:confirmDelete(<%=RSS("ID")%>);">X</A> <% end if %></TD>
  153. <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>
  154. <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>
  155. <TD align=right dir=ltr><span style="font-size:10pt"><%=RSS("Qtty")%></span></TD>
  156. <TD align=right dir=ltr><%=RSS("Unit")%></TD>
  157. <TD dir=ltr><%=RSS("logDate")%></span></TD>
  158. <TD><%=RSS("GiveTo")%></TD>
  159. <TD align=center><%
  160. if RSS("type")= "2" then
  161. response.write "<font color=red><b> </b></font>"
  162. elseif RSS("type")= "5" then
  163. response.write "<font color=orang><b></b></font>"
  164. else %>
  165. <A HREF="default.asp?ed=<%=RSS("RelatedID")%>"><%=RSS("RelatedID")%></A>
  166. <% end if %>
  167. <% if RSS("owner")<> "-1" and RSS("owner")<> "-2" then
  168. response.write " ( <a href='../CRM/AccountInfo.asp?act=show&selectedCustomer="& RSS("owner") &"' target='_blank'> " & RSS("owner") & "</a>)"
  169. end if %>
  170. <% if RSS("comments")<> "-" and RSS("comments")<> "" then
  171. response.write " <br><br><B>:</B> " & RSS("comments")
  172. end if
  173. if not isNull(rss("inID")) then
  174. response.write("<br> " & rss("inQtty") & " <b>" & rss("inID") & "</b>")
  175. else
  176. response.write("<br><b> !</b>")
  177. end if
  178. %>
  179. </TD>
  180. <TD><%=RSS("RealName")%></TD>
  181. </TR>
  182. <%
  183. RSS.moveNext
  184. Loop
  185. end if
  186. if inRep = "on" then
  187. mySQL="SELECT InventoryLog.RelatedInvoiceID, InventoryLog.ID, InventoryLog.comments, InventoryLog.Voided, InventoryLog.VoidedDate, InventoryLog.CreatedBy, InventoryLog.owner, InventoryLog.logDate, InventoryLog.type, InventoryLog.Qtty, InventoryLog.RelatedID, InventoryLog.ItemID, InventoryItems.OldItemID, InventoryItems.Name, InventoryItems.Unit, Users.RealName, Users_1.RealName AS VoidedBy, InventoryFIFORelations.outID, InventoryFIFORelations.qtty as outQtty FROM InventoryLog INNER JOIN InventoryItems ON InventoryLog.ItemID = InventoryItems.ID INNER JOIN Users ON InventoryLog.CreatedBy = Users.ID LEFT OUTER JOIN Users Users_1 ON InventoryLog.VoidedBy = Users_1.ID left outer join InventoryFIFORelations on inventoryLog.id = InventoryFIFORelations.inID WHERE (InventoryLog.logDate >= N'"& fromDate & "') AND (InventoryLog.logDate <= N'"& toDate & "') AND (InventoryLog.IsInput = 1) ORDER BY InventoryLog.ID DESC"
  188. set RSS=Conn.Execute (mySQL)
  189. %>
  190. <TR height=50>
  191. <TD colspan=9></TD>
  192. </TR>
  193. <TR bgcolor="eeeeee" >
  194. <TD colspan=9><H4> </H4></TD>
  195. </TR>
  196. <TR bgcolor="eeeeee" >
  197. <TD> </TD>
  198. <TD></TD>
  199. <TD width=200> </TD>
  200. <TD> </TD>
  201. <TD></TD>
  202. <TD> </TD>
  203. <TD colspan=2 align=center></TD>
  204. <TD></TD>
  205. </TR>
  206. <%
  207. tmpCounter=0
  208. Do while not RSS.eof
  209. tmpCounter = tmpCounter + 1
  210. if tmpCounter mod 2 = 1 then
  211. tmpColor="#FFFFFF"
  212. tmpColor2="#FFFFBB"
  213. Else
  214. tmpColor="#DDDDDD"
  215. tmpColor2="#EEEEBB"
  216. End if
  217. %>
  218. <TR bgcolor="<%=tmpColor%>" style="height:25pt" <% if RSS("voided") then%> disabled title=" <%=RSS("VoidedDate")%> <%=RSS("VoidedBy")%>"<% end if %>>
  219. <TD align=center dir=ltr><% if not RSS("voided") then%><A HREF="javascript:confirmDelete(<%=RSS("ID")%>);">X</A> <small disabled><%=RSS("id")%></small><% end if %></TD>
  220. <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>
  221. <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>
  222. <TD align=right dir=ltr><span style="font-size:10pt"><%=RSS("Qtty")%></span></TD>
  223. <TD align=right dir=ltr><%=RSS("Unit")%></TD>
  224. <TD dir=ltr><%=RSS("logDate")%></span></TD>
  225. <TD colspan=2 align=center><% if RSS("type")= "1" and RSS("RelatedID")<> "-1" then
  226. %>
  227. <A HREF="../purchase/outServiceTrace.asp?od=<%=RSS("RelatedID")%>"><%=RSS("RelatedID")%></A>
  228. <%
  229. elseif RSS("type")= "2" then
  230. response.write "<font color=red><b> </b></font>"
  231. elseif RSS("type")= "3" then
  232. response.write "<font color=green><b></b></font> ( :<font color=green> "& RSS("RelatedInvoiceID") & "</font>)"
  233. elseif RSS("type")= "4" then
  234. response.write "<font color=blue><b> </b></font>"
  235. elseif RSS("type")= "5" then
  236. response.write "<font color=orang><b></b></font>"
  237. elseif RSS("type")= "6" then
  238. response.write "<font color=#6699CC><b> </b></font>"
  239. elseif RSS("type")= "7" then
  240. response.write "<font color=#FF9966><b> </b></font>"
  241. elseif RSS("type")="9" then
  242. response.write "<font color=#AAAA00><b> </b></font>"
  243. else
  244. response.write " "
  245. end if %>
  246. <% if RSS("owner")<> "-1" and RSS("owner")<> "-2" then
  247. response.write " ( <a href='../CRM/AccountInfo.asp?act=show&selectedCustomer="& RSS("owner") &"' target='_blank'> " & RSS("owner") & "</a>)"
  248. end if %>
  249. <% if RSS("comments")<> "-" and RSS("comments")<> "" then
  250. response.write " <br><br><B>:</B> " & RSS("comments")
  251. end if
  252. if not isNull(rss("outID")) then
  253. response.write("<br> " & rss("outQtty") & " <b> " & rss("outID") & "</b>")
  254. else
  255. response.write("<br><b> !</b>")
  256. end if
  257. %>
  258. </TD>
  259. <TD dir='LTR' align='right'><%=RSS("RealName")%></TD>
  260. </TR>
  261. <%
  262. RSS.moveNext
  263. Loop
  264. end if
  265. %>
  266. </TABLE><br>
  267. <SCRIPT LANGUAGE="JavaScript">
  268. <!--
  269. function confirmDelete(rowID){
  270. if (confirm(' Ͽ')){
  271. var desc='';
  272. var tmpDlgTxt= new Object();
  273. tmpDlgTxt.value = ' : ';
  274. dialogActive=true
  275. window.showModalDialog('../dialog_GenInput.asp',tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
  276. dialogActive=false
  277. desc=tmpDlgTxt.value
  278. window.location = "?act=del&rowID=" + rowID + "&desc=" + escape(desc);
  279. }
  280. }
  281. //-->
  282. </SCRIPT>
  283. <%
  284. end if
  285. %>
  286. <!--#include file="tah.asp" -->