/beta/Inquiry/InquiryEdit.asp

http://github.com/khaneh/Orders · ASP · 971 lines · 756 code · 119 blank · 96 comment · 86 complexity · 1679f95e03ad56dadb5c837ce02468e1 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'AR (6)
  3. PageTitle=" "
  4. SubmenuItem=1
  5. 'if not Auth(6 , 1) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <%
  11. function ShowErrorMessage(msg)
  12. response.write "<table align='center' cellpadding='5'><tr><td bgcolor='#FFCCCC' dir='rtl' align='center'> ! <br>"& msg & "<br></td></tr></table><br>"
  13. end function
  14. function Link2Trace(OrderNo)
  15. Link2Trace="<A HREF='../order/TraceOrder.asp?act=show&order="& OrderNo & "' target='_balnk'>"& OrderNo & "</A>"
  16. end function
  17. %>
  18. <style>
  19. Table { font-size: 9pt;}
  20. .InvRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
  21. .InvHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
  22. .InvRowInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0FFF0; text-align:right;}
  23. .InvRowInput4 { font-family:tahoma; font-size: 9pt; border: none; background-color: #FFD3A8; direction:LTR; text-align:right;}
  24. .InvHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
  25. .InvHeadInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right;}
  26. .InvHeadInput4 { font-family:tahoma; font-size: 9pt; border: none; background-color: #FF9900; text-align:center;}
  27. .InvGenInput { font-family:tahoma; font-size: 9pt; border: none; }
  28. .InvGenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
  29. </style>
  30. <SCRIPT LANGUAGE="JavaScript">
  31. <!--
  32. var okToProceed=false;
  33. var currentRow=0;
  34. //-->
  35. </SCRIPT>
  36. <%
  37. if request("act")="search" then
  38. if isnumeric(request("order")) then
  39. OrderID = clng(request("order"))
  40. mySQL="SELECT InquiryOrderRelations.Inquiry FROM InquiryOrderRelations INNER JOIN Inquiries ON InquiryOrderRelations.Inquiry = Inquiries.ID WHERE (InquiryOrderRelations.[Order] = '"& OrderID & "') AND (Inquiries.IsReverse = 0) AND (Inquiries.Voided = 0)"
  41. Set RS1=Conn.Execute(mySQL)
  42. if RS1.eof then
  43. Conn.close
  44. response.redirect "?errmsg=" & Server.URLEncode(" .")
  45. else
  46. theInquiry=RS1("Inquiry")
  47. Conn.close
  48. response.redirect "?act=editInquiry&inquiry=" & theInquiry
  49. end if
  50. elseif isnumeric(request("inquiry")) then
  51. response.redirect "?act=editInquiry&inquiry=" & request("inquiry")
  52. else
  53. response.redirect "?errmsg=" & Server.URLEncode(" .")
  54. end if
  55. '-----------------------------------------------------------------------------------------------------
  56. '---------------------------------------------------------------------------------------- Edit Inquiry
  57. '-----------------------------------------------------------------------------------------------------
  58. elseif request("act")="editInquiry" then
  59. if isnumeric(request("inquiry")) then
  60. InquiryID=clng(request("inquiry"))
  61. mySQL="SELECT * FROM Inquiries WHERE (ID='"& InquiryID & "')"
  62. Set RS1 = conn.Execute(mySQL)
  63. if RS1.eof then
  64. conn.close
  65. response.redirect "?errmsg=" & Server.URLEncode(" .")
  66. end if
  67. else
  68. response.redirect "?errmsg=" & Server.URLEncode(" .")
  69. end if
  70. customerID= RS1("Customer")
  71. creationDate= RS1("CreatedDate")
  72. IssuedDate= RS1("IssuedDate")
  73. totalPrice= cdbl(RS1("totalPrice"))
  74. totalDiscount= cdbl(RS1("totalDiscount"))
  75. totalReverse= cdbl(RS1("totalReverse"))
  76. totalVat = cdbl(RS1("totalVat"))
  77. Voided= RS1("Voided")
  78. Issued= RS1("Issued")
  79. Approved= RS1("Approved")
  80. isReverse= RS1("IsReverse")
  81. IsA= RS1("IsA")
  82. InquiryNo= RS1("Number")
  83. mySQL="SELECT ID,AccountTitle FROM Accounts WHERE (ID='"& customerID & "')"
  84. Set RS1 = conn.Execute(mySQL)
  85. AccountNo=RS1("ID")
  86. customerName=RS1("AccountTitle")
  87. RS1.close
  88. if isReverse then
  89. 'Check for permission for EDITTING Rev. Inquiry
  90. if not Auth(6 , 5) then NotAllowdToViewThisPage()
  91. itemTypeName="ǘ ѐ"
  92. HeaderColor="#FF9900"
  93. else
  94. 'Check for permission for EDITTING Inquiry
  95. if not Auth(6 , 3) then NotAllowdToViewThisPage()
  96. itemTypeName="ǘ"
  97. HeaderColor="#C3C300"
  98. end if
  99. if Voided then
  100. Conn.close
  101. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  102. elseif Issued then
  103. if Auth(6 , "A") then
  104. ' Has the Priviledge to change the Inquiry
  105. response.write "<BR>"
  106. call showAlert (" .<br>э ǘ <br> Ԙ Ͽ",CONST_MSG_INFORM)
  107. else
  108. Conn.close
  109. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  110. end if
  111. end if
  112. %>
  113. <!-- -->
  114. <br>
  115. <input type="hidden" Name='tmpDlgArg' value=''>
  116. <input type="hidden" Name='tmpDlgTxt' value=''>
  117. <table Border="0" align="center" Width="100%" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
  118. <FORM METHOD=POST ACTION="?act=submitEdit">
  119. <tr bgcolor='<%=HeaderColor%>'>
  120. <td colspan='2'>
  121. <TABLE width='100%'>
  122. <TR>
  123. <TD align="left" > <%=itemTypeName%>:</TD>
  124. <TD align="right" width='15%'>&nbsp;<INPUT readonly class="InvGenInput" NAME="InquiryID" value="<%=InquiryID%>" style="direction:ltr" TYPE="text" maxlength="10" size="10"></TD>
  125. </TR>
  126. </TABLE></td>
  127. </tr>
  128. <tr bgcolor='<%=HeaderColor%>'>
  129. <td colspan="2">
  130. <TABLE Border="0" Width="100%" Cellspacing="1" Cellpadding="0" Dir="RTL">
  131. <TR>
  132. <TD><table>
  133. <tr>
  134. <td align="left">:</td>
  135. <td align="right">
  136. <span id="customer"><%' after any changes in this span "./Customers.asp" must be revised%>
  137. <INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>"><span><%=CustomerName%></span>.
  138. </span></td>
  139. <td><INPUT class="InvGenButton" TYPE="button" value="" onClick="selectCustomer();"></td>
  140. </tr>
  141. </table></TD>
  142. <TD align="left"><table>
  143. <tr>
  144. <td align="left"> :</td>
  145. <td dir="LTR">
  146. <INPUT class="InvGenInput" NAME="issueDate" TYPE="text" maxlength="10" size="10" value="<%=IssuedDate%>" onblur="acceptDate(this)"></td>
  147. <td dir="RTL"><%=""%></td>
  148. </tr>
  149. </table></TD>
  150. </TR></TABLE>
  151. </td>
  152. </tr>
  153. <tr bgcolor='<%=HeaderColor%>'>
  154. <TD align="right" width="50%">
  155. ():
  156. <span id="orders">
  157. <%
  158. tempWriteAnd=""
  159. mySQL="SELECT * FROM InquiryOrderRelations WHERE (Inquiry='"& InquiryID & "')"
  160. Set RS1 = conn.Execute(mySQL)
  161. while not(RS1.eof)
  162. response.write "<input type='hidden' name='selectedOrders' value='"& RS1("Order") & "'>"
  163. response.write tempWriteAnd & Link2Trace(RS1("Order"))
  164. tempWriteAnd=" "
  165. RS1.moveNext
  166. wend
  167. %> </span>&nbsp;
  168. <INPUT class="InvGenButton" TYPE="button" value="" onClick="selectOrder();">
  169. </TD>
  170. <TD align="left"><table>
  171. <tr>
  172. <td align="left">:</td>
  173. <td dir="LTR">
  174. <INPUT class="InvGenInput" NAME="InquiryNo" value="<%=InquiryNo%>" style="border:1px solid black;" TYPE="text" maxlength="10" size="10"></td>
  175. <td dir="RTL"><INPUT TYPE="checkbox" onClick="checkIsA();" NAME="IsA" <%if IsA then response.write "checked"%>> &nbsp;</td>
  176. </tr>
  177. </table></TD>
  178. </tr>
  179. <tr bgcolor='#CCCC88'>
  180. <TD colspan="10"><div>
  181. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
  182. <tr bgcolor='#CCCC88'>
  183. <td align='center' width="25px"> # </td>
  184. <td><INPUT class="InvHeadInput" readonly TYPE="text" value="" size="3" ></td>
  185. <td><INPUT class="InvHeadInput2" readonly TYPE="text" value="" size="30"></td>
  186. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value="" size="2"></td>
  187. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value="" size="2"></td>
  188. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value="" size="3"></td>
  189. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value="" size="2"></td>
  190. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value=" " size="6"></td>
  191. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value="" size="7"></td>
  192. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value="" size="9"></td>
  193. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value=""size="7"></td><!-- S A M -->
  194. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value="ѐ" size="5"></td><!-- S A M -->
  195. <td><INPUT class="InvHeadInput4" readonly TYPE="text" Value="" size="6"></td><!-- S A M -->
  196. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value=" " size="9"></td>
  197. </tr>
  198. </TABLE></div></TD>
  199. </TR>
  200. <tr bgcolor='#CCCC88'>
  201. <TD colspan="10"><div style="overflow:auto; height:190px; width:*;">
  202. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
  203. <Tbody id="InquiryLines">
  204. <%
  205. i=0
  206. mySQL="SELECT * FROM InquiryLines LEFT OUTER JOIN invoiceItems ON InquiryLines.item = invoiceItems.id WHERE (Inquiry='"& InquiryID & "') "
  207. Set RS1 = conn.Execute(mySQL)
  208. while not(RS1.eof)
  209. if RS1("Item") <> 39999 then
  210. i=i+1
  211. %>
  212. <tr bgcolor='#F0F0F0' onclick="setCurrentRow(this.rowIndex);" >
  213. <td align='center' width="25px"><%=i%></td>
  214. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Items" value="<%=RS1("Item")%>" size="3" Maxlength="6" onKeyPress="return mask(this);" onfocus="setCurrentRow(this.parentNode.parentNode.rowIndex);" onChange='return check(this);'>
  215. <INPUT TYPE="hidden" name="type" value="<%=RS1("type")%>">
  216. <INPUT TYPE="hidden" name="fee" value="<%=RS1("fee")%>">
  217. <input type='hidden' name='hasVat' value='<%=text2value(RS1("hasVat"))%>'>
  218. </td>
  219. <td dir="RTL"><INPUT class="InvRowInput2" TYPE="text" NAME="Descriptions" value="<%=RS1("Description")%>" size="30"></td>
  220. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="Lengths" value="<%=RS1("Length")%>" size="2" onBlur="setFeeQtty(this);"></td>
  221. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="Widths" value="<%=RS1("Width")%>" size="2" onBlur="setFeeQtty(this);"></td>
  222. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="Qttys" value="<%=RS1("Qtty")%>" size="3" onBlur="setFeeQtty(this);"></td>
  223. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="Sets" value="<%=RS1("Sets")%>" size="2" onBlur="setFeeQtty(this);"></td>
  224. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="AppQttys" value="<%=Separate(RS1("AppQtty"))%>" size="6" onBlur="setPrice(this);"></td>
  225. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Fees" value="<%if RS1("AppQtty") <> 0 then response.write Separate(RS1("Price")/RS1("AppQtty")) else response.write "0"%>" size="7" onBlur="setPrice(this);"></td>
  226. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Prices" value="<%=Separate(RS1("Price"))%>" size="9" readonly tabIndex="9999"></td>
  227. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Discounts" value="<%=Separate(RS1("Discount"))%>" size="7" onBlur="setPrice(this);"></td><!-- S A M -->
  228. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Reverses" value="<%=Separate(RS1("Reverse"))%>" size="5" onBlur="setPrice(this);" onfocus="setCurrentRow(this.parentNode.parentNode.rowIndex);"></td><!-- S A M -->
  229. <td dir="LTR"><INPUT class="InvRowInput4" TYPE="text" Name="Vat" value="<%=Separate(RS1("Vat"))%>" size="6" readonly></td><!-- S A M -->
  230. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="AppPrices" value="<%=Separate(RS1("Price") - RS1("Discount") - RS1("Reverse") + RS1("Vat"))%>" size="9" readonly tabIndex="9999"></td><!-- S A M -->
  231. </tr>
  232. <%
  233. end if
  234. RS1.moveNext
  235. wend
  236. RS1.close
  237. %>
  238. <tr bgcolor='#F0F0F0' onclick="setCurrentRow(this.rowIndex);" >
  239. <td colspan="15">
  240. <INPUT class="InvGenButton" TYPE="button" value="" onkeyDown="if(event.keyCode==9) {setCurrentRow(this.parentNode.parentNode.rowIndex); return false;};" onClick="addRow();">
  241. </td>
  242. </tr>
  243. </Tbody></TABLE></div>
  244. </TD>
  245. </tr>
  246. <tr bgcolor='#CCCC88'>
  247. <TD colspan="10"><div>
  248. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#CCCC88">
  249. <tr bgcolor='#CCCC88'>
  250. <td colspan='9' width='500px'>*** ǘ ***</td>
  251. <!--td align='center' width="25px"> &nbsp; </td>
  252. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="3" ></td>
  253. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="30"></td>
  254. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="2"></td>
  255. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="2"></td>
  256. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="3"></td>
  257. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="2"></td>
  258. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="6"></td>
  259. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="7"></td-->
  260. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="TotalPrice" value="<%=Separate(totalPrice)%>" TYPE="text" size="9"></td>
  261. <!-- S A M -->
  262. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="TotalDiscount" value="<%=Separate(totalDiscount)%>" TYPE="text" size="7"></td>
  263. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="TotalReverse" value="<%=Separate(totalReverse)%>" TYPE="text" size="5"></td>
  264. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="TotalVat" value="<%=Separate(totalVat)%>" TYPE="text" size="6"></td>
  265. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="Payable" value="<%=Separate(totalPrice - totalDiscount - totalReverse + totalVat)%>" TYPE="text" size="9"></td>
  266. </tr>
  267. <tr bgcolor='#CCCC88'>
  268. <td colspan="9"> &nbsp; </td>
  269. <td dir="LTR"><INPUT readonly class="InvHeadInput" TYPE="text" size="9"></td>
  270. <!-- S A M -->
  271. <td dir="LTR"><INPUT readonly class="InvHeadInput3" TYPE="text" Name="TPDiscount" value="<%=Pourcent(totalDiscount,totalPrice) & "%"%>" size="7"></td>
  272. <td dir="LTR"><INPUT readonly class="InvHeadInput3" TYPE="text" Name="TPReverse" value="<%=Pourcent(totalReverse,totalPrice) & "%ѐ"%>" size="5"></td>
  273. <td dir="LTR"><INPUT readonly calss="InvHeadINput" TYPE="text" size="6" value="3%"></td>
  274. <td dir="LTR"><INPUT readonly class="InvHeadInput" TYPE="text" size="9" value=" "></td>
  275. </tr>
  276. </TABLE></div></TD>
  277. </TR>
  278. </table>
  279. <TABLE Border="0" Cellspacing="5" Cellpadding="0" Dir="RTL" align='left'>
  280. <tr>
  281. <td align='center'>&nbsp;<!-- <INPUT class="InvGenButton" TYPE="button" value=" " onclick="ApproveInvoice();"> --></td>
  282. <td width="40">&nbsp;</td>
  283. <td align='center'>&nbsp;<!-- <INPUT class="InvGenButton" TYPE="button" value=" " onclick="IssueInvoice();"> --></td>
  284. <td width="40">&nbsp;</td>
  285. <td align='center'><INPUT class="InvGenButton" TYPE="button" value=" " onclick="submitOperations();"></td>
  286. <td align='center'><INPUT class="InvGenButton" TYPE="button" value="" onclick="window.location='AccountReport.asp?act=showInquiry&inquiry=<%=InquiryID%>';"></td>
  287. </tr>
  288. </TABLE>
  289. </FORM>
  290. <SCRIPT LANGUAGE="JavaScript">
  291. <!--
  292. //document.getElementsByName("Items")[0].focus();
  293. //-->
  294. </SCRIPT>
  295. <%
  296. elseif request("act")="submitEdit" then
  297. '******************** Checking and Preparing Input ****************
  298. errorFound=false
  299. ON ERROR RESUME NEXT
  300. InquiryID= clng(request.form("InquiryID"))
  301. CustomerID= clng(request.form("CustomerID"))
  302. issueDate= request.form("issueDate")
  303. if request.form("IsA") = "on" then
  304. IsA=1
  305. InquiryNo=request.form("InquiryNo")
  306. if InquiryNo <> "" then InquiryNo = clng(InquiryNo)
  307. else
  308. IsA=0
  309. InquiryNo=""
  310. end if
  311. for i=1 to request.form("selectedOrders").count
  312. theOrder= clng(request.form("selectedOrders")(i))
  313. mySQL="SELECT ID FROM Orders WHERE ID=" & theOrder
  314. Set rs=conn.Execute(mySQL)
  315. if rs.eof then
  316. errorFound=True
  317. exit for
  318. end if
  319. rs.close
  320. next
  321. Set rs= Nothing
  322. mySQL="SELECT * FROM Inquiries WHERE (ID='"& InquiryID & "')"
  323. Set rs= conn.Execute(mySQL)
  324. if NOT rs.eof then
  325. voided= rs("Voided")
  326. issued= rs("Issued")
  327. approved= rs("Approved")
  328. isReverse= rs("IsReverse")
  329. ApprovedBy= rs("ApprovedBy")
  330. else
  331. errorFound=True
  332. end if
  333. if Err.Number<>0 then
  334. Err.clear
  335. errorFound=True
  336. end if
  337. if NOT errorFound AND NOT issued then
  338. TotalPrice = 0
  339. TotalDiscount = 0
  340. TotalReverse = 0
  341. TotalReceivable = 0
  342. TotalVat = 0
  343. RFD = 0
  344. for i=1 to request.form("Items").count
  345. theItem = clng(text2value(request.form("Items")(i)))
  346. mySQL="SELECT ID FROM InvoiceItems WHERE ID=" & theItem
  347. Set rs=conn.Execute(mySQL)
  348. if rs.eof then
  349. errorFound=True
  350. exit for
  351. end if
  352. rs.close
  353. theDescription = left(sqlSafe(request.form("Descriptions")(i)),100)
  354. theAppQtty = cdbl(text2value(request.form("AppQttys")(i)))
  355. thePrice = clng(text2value(request.form("Prices")(i)))
  356. theDiscount = text2value(request.form("Discounts")(i))
  357. theReverse = text2value(request.form("Reverses")(i))
  358. theLength = text2value(request.form("Lengths")(i))
  359. theWidth = text2value(request.form("Widths")(i))
  360. theQtty = text2value(request.form("Qttys")(i))
  361. theSets = text2value(request.form("Sets")(i))
  362. theVat = text2value(request.form("Vat")(i))
  363. 'theHasVat = text2value(request.form("hasVat")(i))
  364. if theDiscount <>"" then theDiscount= clng(theDiscount)
  365. if theReverse <> "" then theReverse = clng(theReverse)
  366. if theLength <> "" then theLength = cdbl(theLength)
  367. if theWidth <> "" then theWidth = cdbl(theWidth)
  368. if theQtty <> "" then theQtty = clng(theQtty)
  369. if theSets <> "" then theSets = clng(theSets)
  370. TotalPrice = TotalPrice + thePrice
  371. TotalDiscount = TotalDiscount + theDiscount
  372. TotalReverse = TotalReverse + theReverse
  373. TotalReceivable = TotalReceivable + (thePrice - theDiscount - theReverse + theVat)
  374. TotalVat = TotalVat + theVat
  375. next
  376. RFD = TotalReceivable - fix(TotalReceivable / 1000) * 1000
  377. 'RFD = RFD / 1.03
  378. TotalReceivable = TotalReceivable - RFD
  379. TotalDiscount = TotalDiscount + RFD
  380. end if
  381. if Err.Number<>0 then
  382. Err.clear
  383. errorFound=True
  384. end if
  385. ON ERROR GOTO 0
  386. if errorFound then
  387. response.write "<br>"
  388. call showAlert (" ",CONST_MSG_ERROR)
  389. response.end
  390. end if
  391. '^^^^---------------- Checking Input ------------^^^^
  392. if isReverse then
  393. 'Check for permission for EDITTING Rev. Invoice
  394. if not Auth(6 , 5) then NotAllowdToViewThisPage()
  395. itemType=4
  396. else
  397. 'Check for permission for EDITTING Inquiry
  398. if not Auth(6 , 3) then NotAllowdToViewThisPage()
  399. itemType=1
  400. end if
  401. if voided then
  402. Conn.close
  403. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  404. elseif issued then
  405. if Auth(6 , "A") then
  406. ' Has the Priviledge to change the Inquiry / Reverse Inquiry
  407. 'mySQL="SELECT ID FROM ARItems WHERE (Type='"& itemType & "') AND (GL_Update=1) AND (Link='"& InvoiceID & "')"
  408. 'Changed by Kid ! 831124
  409. mySQL="SELECT ARItems.ID, ARItems.GL_Update, EffGLRows.GL, EffGLRows.GLDocID FROM ARItems LEFT OUTER JOIN (SELECT Link, GL, GLDocID FROM EffectiveGLRows WHERE SYS = 'AR') EffGLRows ON ARItems.ID = EffGLRows.Link WHERE (ARItems.Type = '"& itemType & "') AND (ARItems.Link = '"& InquiryID & "')"
  410. Set RS2 = conn.Execute(mySQL)
  411. if RS2.eof then
  412. Conn.close
  413. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" !! <br><br> .")
  414. else
  415. if RS2("GL_Update") = False then
  416. tmpGL=RS2("GL")
  417. tmpGLDoc=RS2("GLDocID")
  418. Conn.close
  419. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .<br><br> :"& tmpGL & " : "& tmpGLDoc & " .")
  420. else
  421. ARItemID=RS2("ID")
  422. IssuedButEdit=true
  423. end if
  424. end if
  425. RS2.close
  426. else
  427. Conn.close
  428. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  429. end if
  430. elseif approved then
  431. call UnApproveInquiry ( InquiryID , ApprovedBy )
  432. end if
  433. '******************* Editing *******************
  434. ' ****
  435. if IssuedButEdit then
  436. ' Only Updating IssuedDate, Number & IsA
  437. ' and related Orders
  438. '---- Checking wether issueDate is valid in current open GL
  439. If Not CheckDateFormat(issueDate) Then
  440. Conn.close
  441. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  442. end if
  443. if (issueDate < session("OpenGLStartDate")) OR (issueDate > session("OpenGLEndDate")) then
  444. Conn.close
  445. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode("!<br> . <br>( )")
  446. end if
  447. '----
  448. mySQL="UPDATE Inquiries SET IssuedDate=N'" & issueDate & "', Number='"& InquiryNo & "', IsA='"& IsA & "' WHERE (ID='"& InquiryID & "')"
  449. conn.Execute(mySQL)
  450. 'if IsA then
  451. ' GLAccount= "91001" 'This must be changed... (Sales A)
  452. 'else
  453. ' GLAccount= "91002" 'This must be changed... (Sales B)
  454. 'end if
  455. '
  456. ' Changed By Kid 860118 , seasing to use Sales B
  457. GLAccount= "91001" 'This must be changed... (Sales A)
  458. conn.Execute("UPDATE ARItems SET GL='"& OpenGL & "', EffectiveDate='" & issueDate & "', GLAccount='"& GLAccount & "' WHERE (ID='" & ARItemID & "')")
  459. '**************** Updating Inquiry-Order Relations ****************
  460. 'mySQL="UPDATE Orders SET Closed=0 WHERE ID IN (SELECT [Order] FROM InvoiceOrderRelations WHERE (Invoice= '" & InvoiceID & "'))"
  461. 'Changed By Kid ! 840509
  462. 'set orders which are ONLY related to this invoice, "Open"
  463. 'that means, orders which are related to this invoice and are NOT related to any OTHER issued invoices.
  464. mySQL ="UPDATE Orders SET Closed=0 WHERE ID IN (SELECT [Order] FROM InquiryOrderRelations WHERE (Inquiry = '" & InquiryID & "') AND ([Order] NOT IN (SELECT InquiryOrderRelations.[ORDER] FROM Inquiries INNER JOIN InquiryOrderRelations ON Inquiries.ID = InquirieOrderRelations.Inquiry WHERE (Inquiries.Issued = 1) AND (Inquiries.Voided = 0) AND (Inquiries.isReverse = 0) AND (Inquiries.ID <> '" & InquiryID & "'))))"
  465. conn.Execute(mySQL)
  466. mySQL ="DELETE FROM InquiryOrderRelations WHERE (Inquiry='" & InquiryID & "')"
  467. 'mySQL ="DELETE FROM InvoiceOrderRelations WHERE (Invoice = '" & InvoiceID & "') AND ([Order] NOT IN (SELECT InvoiceOrderRelations.[ORDER] FROM Invoices INNER JOIN InvoiceOrderRelations ON Invoices.ID = InvoiceOrderRelations.Invoice WHERE (Invoices.Issued = 1) AND (Invoices.Voided = 0) AND (Invoices.isReverse = 0) AND (Invoices.ID <> '" & InvoiceID & "')))"
  468. conn.Execute(mySQL)
  469. for i=1 to request.form("selectedOrders").count
  470. theOrder= clng(request.form("selectedOrders")(i))
  471. mySQL="INSERT INTO InquiryOrderRelations (Inquiry,[Order]) VALUES ('" & InquiryID & "', '" & theOrder & "')"
  472. conn.Execute(mySQL)
  473. next
  474. conn.Execute("UPDATE Orders SET Closed=1 WHERE ID IN (SELECT [Order] FROM InquiryOrderRelations WHERE (Inquiry='" & InquiryID & "'))")
  475. '^^^^------------ Updating Inquiry-Order Relations ------------^^^^
  476. conn.close
  477. response.redirect "AccountReport.asp?act=showInquiry&inquiry=" & InquiryID & "&msg=" &Server.URLEncode(" .<br>э ǘ <br> ʘ .")
  478. else
  479. ' S A M
  480. 'response.write(totalDiscount)
  481. 'response.end
  482. mySQL="UPDATE Inquiries SET Customer='"& CustomerID & "', Number='"& InquiryNo & "', TotalPrice='"& TotalPrice & "', TotalDiscount='"& TotalDiscount & "', TotalReverse='"& TotalReverse & "', TotalReceivable='"& TotalReceivable & "' , IsA='"& IsA & "', TotalVat='" & totalVat & "' WHERE (ID='"& InquiryID & "')"
  483. conn.Execute(mySQL)
  484. mySQL="DELETE FROM InquiryLines WHERE (Inquiry='"& InquiryID & "')"
  485. conn.Execute(mySQL)
  486. '**************************** Inserting Inquiry Lines ****************
  487. for i=1 to request.form("Items").count
  488. theItem = clng(text2value(request.form("Items")(i)))
  489. theDescription = left(sqlSafe(request.form("Descriptions")(i)),100)
  490. theAppQtty = cdbl(text2value(request.form("AppQttys")(i)))
  491. thePrice = clng(text2value(request.form("Prices")(i)))
  492. theDiscount = text2value(request.form("Discounts")(i))
  493. theReverse = text2value(request.form("Reverses")(i))
  494. theLength = text2value(request.form("Lengths")(i))
  495. theWidth = text2value(request.form("Widths")(i))
  496. theQtty = text2value(request.form("Qttys")(i))
  497. theSets = text2value(request.form("Sets")(i))
  498. theVat = clng(text2value(request.form("Vat")(i)))
  499. theHasVat = text2value(request.form("hasVat")(i))
  500. if theDiscount <>"" then theDiscount= clng(theDiscount)
  501. if theReverse <> "" then theReverse = clng(theReverse)
  502. if theLength <> "" then theLength = cdbl(theLength)
  503. if theWidth <> "" then theWidth = cdbl(theWidth)
  504. if theQtty <> "" then theQtty = clng(theQtty)
  505. if theSets <> "" then theSets = clng(theSets)
  506. mySQL="INSERT INTO InquiryLines (Inquiry, Item, Description, Length, Width, Qtty, Sets, AppQtty, Price, Discount, Reverse, Vat, hasVat) VALUES ('"& InquiryID & "', '" & theItem & "', N'" & theDescription & "', '" & theLength & "', '" & theWidth & "', '" & theQtty & "', '" & theSets & "', '" & theAppQtty & "', '" & thePrice & "', '" & theDiscount & "', '" & theReverse & "', '" & theVat & "', "& theHasVat &")"
  507. conn.Execute(mySQL)
  508. next
  509. if RFD > 0 then
  510. theItem = 39999
  511. theDescription = " ǘ"
  512. theAppQtty = 0
  513. thePrice = 0
  514. theDiscount = RFD
  515. theReverse = 0
  516. theLength = 0
  517. theWidth = 0
  518. theQtty = 0
  519. theSets = 0
  520. theVat = 0
  521. mySQL="INSERT INTO InquiryLines (Inquiry, Item, Description, Length, Width, Qtty, Sets, AppQtty, Price, Discount, Reverse, Vat) VALUES ('"& InquiryID & "', '" & theItem & "', N'" & theDescription & "', '" & theLength & "', '" & theWidth & "', '" & theQtty & "', '" & theSets & "', '" & theAppQtty & "', '" & thePrice & "', '" & theDiscount & "', '" & theReverse & "', '" & theVat & "')"
  522. conn.Execute(mySQL)
  523. end if
  524. '**************** Updating Inquiry-Order Relations ****************
  525. mySQL="DELETE FROM InquiryOrderRelations WHERE (Inquiry='" & InquiryID & "')"
  526. conn.Execute(mySQL)
  527. for i=1 to request.form("selectedOrders").count
  528. theOrder= clng(request.form("selectedOrders")(i))
  529. mySQL="INSERT INTO InquiryOrderRelations (Inquiry,[Order]) VALUES ('" & InquiryID & "', '" & theOrder & "')"
  530. conn.Execute(mySQL)
  531. next
  532. '^^^^------------ Updating Inquiry-Order Relations ------------^^^^
  533. end if
  534. '****
  535. '^^^^--------------- Editing ---------------^^^^
  536. response.redirect "AccountReport.asp?act=showInquiry&inquiry=" & InquiryID
  537. elseif request("act")="approveInquiry" then
  538. if not Auth(6 , "C") then
  539. 'Doesn't have the Priviledge to APPROVE the Inquiry
  540. response.write "<br>"
  541. call showAlert (" ",CONST_MSG_ERROR)
  542. response.end
  543. end if
  544. if request("inquiry")<>"" then
  545. InquiryID=request("inquiry")
  546. if not(isnumeric(request("inquiry"))) then
  547. ShowErrorMessage("")
  548. response.end
  549. end if
  550. mySQL="SELECT * FROM Inquiries WHERE (ID='"& InquiryID & "')"
  551. Set RS1 = conn.Execute(mySQL)
  552. if RS1.eof then
  553. ShowErrorMessage(" ")
  554. response.end
  555. else
  556. if RS1("Voided") = True then
  557. Conn.close
  558. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  559. elseif RS1("Issued") = True then
  560. Conn.close
  561. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  562. elseif RS1("Approved") = True then
  563. Conn.close
  564. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  565. end if
  566. end if
  567. else
  568. ShowErrorMessage("")
  569. response.end
  570. end if
  571. mySQL="UPDATE Inquiries SET Approved=1, ApprovedDate=N'"& shamsiToday() & "', ApprovedBy='"& session("ID") & "' WHERE (ID='"& InquiryID & "')"
  572. conn.Execute(mySQL)
  573. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID
  574. elseif request("act")="IssueInquiry" then
  575. if not Auth(6 , "D") then
  576. 'Doesn't have the Priviledge to ISSUE the Inquiry
  577. response.write "<br>"
  578. call showAlert (" ",CONST_MSG_ERROR)
  579. response.end
  580. end if
  581. ON ERROR RESUME NEXT
  582. InquiryID= clng(request("Inquiry"))
  583. if Err.Number<>0 then
  584. Err.clear
  585. conn.close
  586. response.redirect "top.asp?errMsg=" & Server.URLEncode("!")
  587. end if
  588. ON ERROR GOTO 0
  589. creationDate= shamsiToday()
  590. issueDate= SqlSafe(request("issueDate"))
  591. if issueDate="" then issueDate=creationDate
  592. if issueDate<>creationDate then
  593. if Auth(6 , "I") then
  594. ' can ISSUE the Inquiry / Rev. Inquiry on another Date
  595. '---- Checking wether issueDate is valid in current open GL
  596. If Not CheckDateFormat(issueDate) Then
  597. Conn.close
  598. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  599. end if
  600. if (issueDate < session("OpenGLStartDate")) OR (issueDate > session("OpenGLEndDate")) then
  601. Conn.close
  602. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode("!<br> . <br>( )")
  603. end if
  604. '----
  605. else
  606. 'Doesn't have the Priviledge to ISSUE the Inquiry on another Date
  607. response.write "<br>"
  608. call showAlert (" ",CONST_MSG_ERROR)
  609. response.end
  610. end if
  611. end if
  612. '---- Checking wether issueDate is valid in current open GL
  613. If Not CheckDateFormat(issueDate) Then
  614. Conn.close
  615. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode("!<br> .")
  616. end if
  617. if (issueDate < session("OpenGLStartDate")) OR (issueDate > session("OpenGLEndDate")) then
  618. Conn.close
  619. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode("!<br> . <br>( )")
  620. end if
  621. '----
  622. mySQL="SELECT * FROM Inquiries WHERE (ID='"& InquiryID & "')"
  623. Set RS1 = conn.Execute(mySQL)
  624. if RS1.eof then
  625. conn.close
  626. response.redirect "top.asp?errMsg=" & Server.URLEncode("! " & InquiryID & " .")
  627. else
  628. voided= RS1("Voided")
  629. issued= RS1("Issued")
  630. approved= RS1("Approved")
  631. isReverse= RS1("IsReverse")
  632. customerID= RS1("Customer")
  633. inquiryFee= RS1("TotalReceivable")
  634. IsA = RS1("IsA")
  635. Vat = RS1("TotalVat")' sam
  636. if voided then
  637. Conn.close
  638. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  639. elseif issued then
  640. Conn.close
  641. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  642. elseif not approved then
  643. Conn.close
  644. response.redirect "?act=editInquiry&inquiry="& InquiryID & "&errmsg=" & Server.URLEncode(" .")
  645. end if
  646. end if
  647. mySQL="UPDATE Inquiries SET Issued=1, IssuedDate=N'"& issueDate & "', IssuedBy='"& session("ID") & "' WHERE (ID='"& InquiryID & "')"
  648. conn.Execute(mySQL)
  649. if isReverse then
  650. isCredit=1
  651. itemType=4
  652. else
  653. isCredit=0
  654. itemType=1
  655. '----------------------- Declaring the related orders as closed --------------
  656. conn.Execute("UPDATE Orders SET Closed=1 WHERE ID IN (SELECT [Order] FROM InquiryOrderRelations WHERE (Inquiry='" & InquiryID & "'))")
  657. end if
  658. '**************************** Creating ARItem for Inquiry / Reverse Inquiry ****************
  659. '*** Type = 1 means ARItem is an Inquiry
  660. '*** Type = 4 means ARItem is a Reverse Inquiry
  661. firstGLAccount= "13003" 'This must be changed... (Business Debitors)
  662. 'if IsA then
  663. ' GLAccount= "91001" 'This must be changed... (Sales A)
  664. 'else
  665. ' GLAccount= "91002" 'This must be changed... (Sales B)
  666. 'end if
  667. '
  668. ' Changed By Kid 860118 , seasing to use Sales B
  669. GLAccount= "91001" 'This must be changed... (Sales A)
  670. mySQL="INSERT INTO ARItems (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, IsCredit, Type, Link, AmountOriginal, CreatedDate, CreatedBy, RemainedAmount, Vat) VALUES ('" &_
  671. GLAccount & "', '"& OpenGL & "', '"& firstGLAccount & "', '"& CustomerID & "', N'"& issueDate & "', '"& isCredit & "', '"& itemType & "', '"& InquiryID & "', '"& inquiryFee & "', N'"& creationDate & "', '"& session("ID") & "', '"& inquiryFee & "', '" & Vat & "')"
  672. conn.Execute(mySQL)
  673. if isReverse then
  674. '*** ATTENTION: Increasing AR Balance ....
  675. mySQL="UPDATE Accounts SET ARBalance = ARBalance + '"& inquiryFee & "' WHERE (ID='"& CustomerID & "')"
  676. else
  677. '*** ATTENTION: Decreasing AR Balance ....
  678. mySQL="UPDATE Accounts SET ARBalance = ARBalance - '"& inquiryFee & "' WHERE (ID='"& CustomerID & "')"
  679. end if
  680. conn.Execute(mySQL)
  681. conn.close
  682. response.redirect "AccountReport.asp?act=showInquiry&inquiry="& InquiryID
  683. elseif request("act")="voidInquiry" then
  684. if not Auth(6 , "F") then
  685. 'Doesn't have the Priviledge to VOID the Inquiry
  686. response.write "<br>"
  687. call showAlert (" ",CONST_MSG_ERROR)
  688. response.end
  689. end if
  690. comment=sqlSafe(request("comment"))
  691. InquiryID=request("inquiry")
  692. if InquiryID="" or not(isnumeric(InquiryID)) then
  693. response.write "<br>"
  694. call showAlert (" ",CONST_MSG_ERROR)
  695. response.end
  696. end if
  697. InquiryID=clng(InquiryID)
  698. mySQL="SELECT * FROM Inquiries WHERE (ID='"& InquiryID & "')"
  699. Set RS1 = conn.Execute(mySQL)
  700. if RS1.eof then
  701. ShowErrorMessage(" ")
  702. response.end
  703. else
  704. voided= RS1("Voided")
  705. issued= RS1("Issued")
  706. issuedBy= RS1("IssuedBy")
  707. isReverse= RS1("IsReverse")
  708. customerID= RS1("Customer")
  709. inquiryFee= RS1("TotalReceivable")
  710. IsA = RS1("IsA")
  711. if voided then
  712. ShowErrorMessage(" <span dir='LTR'>"& RS1("VoidedDate") & "</span> .")
  713. response.end
  714. end if
  715. end if
  716. mySQL="UPDATE Inquiries SET Voided=1, VoidedDate=N'"& shamsiToday() & "', VoidedBy='"& session("ID") & "' WHERE (ID='"& InquiryID & "')"
  717. conn.Execute(mySQL)
  718. if isReverse then
  719. isCredit=1
  720. itemType=4
  721. itemTypeName=" ѐ "
  722. else
  723. isCredit=0
  724. itemType=1
  725. itemTypeName=""
  726. '---------- Declaring the related orders as Open -------------------
  727. 'mySQL="UPDATE Orders SET Closed=0 WHERE ID IN (SELECT [Order] FROM InvoiceOrderRelations WHERE (Invoice= '" & InvoiceID & "'))"
  728. 'Changed By Kid ! 840509
  729. 'set orders which are ONLY related to this invoice, "Open"
  730. 'that means, orders which are related to this invoice and are NOT related to any OTHER issued invoices.
  731. mySQL ="UPDATE Orders SET Closed=0 WHERE ID IN (SELECT [Order] FROM InquiryOrderRelations WHERE (Inquiry = '" & InquiryID & "') AND ([Order] NOT IN (SELECT InquiryOrderRelations.[ORDER] FROM Inquiries INNER JOIN InquiryOrderRelations ON Inquiries.ID = InquiryOrderRelations.Inquiry WHERE (Inquiries.Issued = 1) AND (Inquiries.Voided = 0) AND (Inquiries.isReverse = 0) AND (Inquiries.ID <> '" & InquiryID & "'))))"
  732. conn.Execute(mySQL)
  733. end if
  734. '**************************** Voiding ARItem of Inquiry / Reverse Inquiry ****************
  735. '*** Type = 1 means ARItem is an Inquiry
  736. '*** Type = 4 means ARItem is a Reverse Inquiry
  737. '***
  738. '********* Finding the ARItem of Inquiry / Reverse Inquiry
  739. mySQL="SELECT ID FROM ARItems WHERE (Type = '"& itemType & "') AND (Link='"& InquiryID & "')"
  740. Set RS1=conn.Execute(mySQL)
  741. voidedARItem=RS1("ID")
  742. '********* Finding other ARItems related to this Item
  743. if isReverse then
  744. mySQL="SELECT ID AS RelationID, DebitARItem, Amount FROM ARItemsRelations WHERE (CreditARItem = '"& voidedARItem & "')"
  745. Set RS1=conn.Execute(mySQL)
  746. Do While not (RS1.eof)
  747. '********* Adding back the amount in the relation, to the credit ARItem ...
  748. conn.Execute("UPDATE ARItems SET RemainedAmount=RemainedAmount+ '"& RS1("Amount") & "', FullyApplied=0 WHERE (ID = '"& RS1("DebitARItem") & "')")
  749. '********* Deleting the relation
  750. conn.Execute("DELETE FROM ARItemsRelations WHERE ID='"& RS1("RelationID") & "'")
  751. RS1.movenext
  752. Loop
  753. else
  754. mySQL="SELECT ID AS RelationID, CreditARItem, Amount FROM ARItemsRelations WHERE (DebitARItem = '"& voidedARItem & "')"
  755. Set RS1=conn.Execute(mySQL)
  756. Do While not (RS1.eof)
  757. '********* Adding back the amount in the relation, to the credit ARItem ...
  758. conn.Execute("UPDATE ARItems SET RemainedAmount=RemainedAmount+ '"& RS1("Amount") & "', FullyApplied=0 WHERE (ID = '"& RS1("CreditARItem") & "')")
  759. '********* Deleting the relation
  760. conn.Execute("DELETE FROM ARItemsRelations WHERE ID='"& RS1("RelationID") & "'")
  761. RS1.movenext
  762. Loop
  763. end if
  764. '********* Voiding ARItem
  765. conn.Execute("UPDATE ARItems SET RemainedAmount=0, FullyApplied=0, Voided=1 WHERE (ID = '"& voidedARItem & "')")
  766. '**************************************************************
  767. '* Affecting Account's AR Balance
  768. '**************************************************************
  769. if isReverse then
  770. mySQL="UPDATE Accounts SET ARBalance = ARBalance - '"& inquiryFee & "' WHERE (ID='"& CustomerID & "')"
  771. else
  772. mySQL="UPDATE Accounts SET ARBalance = ARBalance + '"& inquiryFee & "' WHERE (ID='"& CustomerID & "')"
  773. end if
  774. conn.Execute(mySQL)
  775. '***
  776. '***---------------- End of Voiding ARItem of Inquiry / Reverse Inquiry ----------------
  777. ' Sending a Message to Issuer ...
  778. if trim(comment)<>"" then comment = chr(13) & chr(10) & "[" & comment & "]"
  779. MsgTo = issuedBy
  780. msgTitle = "Inquiry Voided"
  781. msgBody = "ǘ "& session("CSRName") & " ." & comment
  782. RelatedTable = "inquiries"
  783. relatedID = inquiryID
  784. replyTo = 0
  785. IsReply = 0
  786. urgent = 1
  787. MsgFrom = session("ID")
  788. MsgDate = shamsiToday()
  789. MsgTime = currentTime10()
  790. Conn.Execute ("INSERT INTO Messages (MsgFrom, MsgTo, MsgTime, MsgDate, IsRead, MsgTitle, MsgBody, replyTo, IsReply, relatedID, RelatedTable, urgent) VALUES ( "& MsgFrom & ", "& MsgTo & ", N'"& MsgTime & "', N'"& MsgDate & "', 0, N'"& MsgTitle & "', N'"& MsgBody & "', "& replyTo & ", "& IsReply & ", "& relatedID & ", '"& RelatedTable & "', "& urgent & ")")
  791. ' Copying the PreInquiry Data...
  792. response.redirect "InquiryInput.asp?act=copyInquiry&inquiry="& InquiryID & "&msg=" & Server.URLEncode(itemTypeName & " "& InquiryID & " .")
  793. elseif request("act")="removePreInquiry" then
  794. response.write "<br>"
  795. if not Auth(6 , "G") then
  796. 'Doesn't have the Priviledge to REMOVE the Pre-Inquiry
  797. call showAlert (" ",CONST_MSG_ERROR)
  798. response.end
  799. end if
  800. InquiryID=request("inquiry")
  801. if InquiryID="" or not(isnumeric(InquiryID)) then
  802. call showAlert (" ",CONST_MSG_ERROR)
  803. response.end
  804. end if
  805. InquiryID=clng(InquiryID)
  806. mySQL="SELECT * FROM Inquiries WHERE (ID='"& InquiryID & "')"
  807. Set RS1 = conn.Execute(mySQL)
  808. if RS1.eof then
  809. call showAlert (" .",CONST_MSG_ERROR)
  810. else
  811. voided= RS1("Voided")
  812. issued= RS1("Issued")
  813. isReverse= RS1("IsReverse")
  814. customerID= RS1("Customer")
  815. IsA = RS1("IsA")
  816. if issued then
  817. call showAlert (" .",CONST_MSG_ERROR)
  818. elseif voided then
  819. call showAlert (" .",CONST_MSG_ERROR)
  820. else
  821. Conn.execute("DELETE FROM InquiryOrderRelations Where (Inquiry='" & InquiryID & "')")
  822. 'Conn.execute("DELETE FROM InvoiceLines Where (Invoice='" & InvoiceID & "')")
  823. 'Conn.execute("DELETE FROM Invoices Where (ID='" & InvoiceID & "')")
  824. 'Changed By Kid 830929
  825. 'Conn.execute("UPDATE Invoices SET Voided=1 Where (ID='" & InvoiceID & "')")
  826. 'Changed By Kid 8400502 also adding VoidedBy & VoidedDate
  827. Conn.execute("UPDATE Inquiries SET Voided=1, VoidedDate=N'"& shamsiToday() & "', VoidedBy='"& session("ID") & "' WHERE (ID='"& InquiryID & "')")
  828. call showAlert (" .",CONST_MSG_INFORM)
  829. end if
  830. end if
  831. response.end
  832. end if
  833. conn.Close
  834. %>
  835. <!--#include file="include_JS_for_Inquiries.asp" -->
  836. <SCRIPT LANGUAGE="JavaScript">
  837. <!--
  838. function ApproveInquiry(){
  839. if (confirm(" '' Ͽ\n\n(: )\n"))
  840. window.location="?act=approveInquiry&inquiry=<%=InquiryID%>";
  841. }
  842. function IssueInquiry(){
  843. if (confirm(" '' Ͽ\n\n(: )\n"))
  844. window.location="?act=IssueInquiry&inquiry=<%=InquiryID%>";
  845. }
  846. function VoidInquiry(){
  847. if (confirm(" '' Ͽ\n"))
  848. window.location="?act=voidInquiry&inquiry=<%=InquiryID%>";
  849. }
  850. //-->
  851. </SCRIPT>
  852. <!--#include file="tah.asp" -->