/beta/Inquiry/InquiryInput.asp

http://github.com/khaneh/Orders · ASP · 549 lines · 463 code · 60 blank · 26 comment · 40 complexity · 89e31d3ae46458ec71884df46c9252d4 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'AR (6)
  3. PageTitle=" "
  4. SubmenuItem=1
  5. if not (Auth(6 , 1) OR Auth(6 , 4)) 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")="submitsearch" then
  38. if trim(request("query")) <> "" then
  39. if isnumeric(request("query")) then
  40. SO_Order=clng(request("query"))
  41. SO_Action="return true;"
  42. SO_StepText="<br> : "
  43. %>
  44. <FORM METHOD=POST ACTION="?act=getInquiry">
  45. <!--#include File="include_SelectOrdersByOrder.asp"-->
  46. </FORM>
  47. <%if Auth(6 , "K") then ' Has the priviledge to create a ReverseInquiry without an ORDER %>
  48. <p align='center' style='font-size:9pt;' dir='RTL'><a href='?act=getInquiry&selectedCustomer=<%=SO_Customer%>'> ...</a></p>
  49. <%end if%>
  50. <br>
  51. <% else
  52. SA_TitleOrName=request("query")
  53. SA_Action="return true;"
  54. SA_SearchAgainURL="InquiryInput.asp"
  55. SA_StepText=" : "
  56. %>
  57. <FORM METHOD=POST ACTION="?act=selectOrder">
  58. <!--#include File="include_SelectAccount.asp"-->
  59. </FORM>
  60. <%
  61. end if
  62. else
  63. response.redirect "?errmsg=" & Server.URLEncode(" э !")
  64. end if
  65. elseif request("act")="selectOrder" then
  66. if request("selectedCustomer") <> "" then
  67. SO_Customer=request("selectedCustomer")
  68. SO_Action="return true;"
  69. SO_StepText="<br> : "
  70. %>
  71. <FORM METHOD=POST ACTION="?act=getInquiry">
  72. <!--#include File="include_SelectOrder.asp"-->
  73. </FORM>
  74. <%if Auth(6 , "K") then ' Has the priviledge to create a ReverseInquiry without an ORDER %>
  75. <p align='center' style='font-size:9pt;' dir='RTL'><a href='?act=getInquiry&selectedCustomer=<%=SO_Customer%>'> ...</a></p>
  76. <%end if%>
  77. <br>
  78. <%
  79. end if
  80. elseif request("act")="getInquiry" then
  81. %>
  82. <!--#include file="include_JS_for_Inquiries.asp" -->
  83. <%
  84. '******************** Checking Input ****************
  85. errorFound=false
  86. ON ERROR RESUME NEXT
  87. customerID= clng(request("selectedCustomer"))
  88. mySQL="SELECT * FROM Accounts WHERE (ID='"& CustomerID & "')"
  89. Set rs = conn.Execute(mySQL)
  90. if rs.eof then
  91. errorFound=True
  92. else
  93. customerName=rs("AccountTitle")
  94. end if
  95. rs.close
  96. if Err.Number<>0 then
  97. Err.clear
  98. errorFound=True
  99. end if
  100. ON ERROR GOTO 0
  101. if errorFound then
  102. response.write "<br>"
  103. call showAlert (" ",CONST_MSG_ERROR)
  104. response.end
  105. end if
  106. '^^^^---------------- Checking Input ------------^^^^
  107. creationDate=shamsiToday()
  108. ' creationTime=Hour(creationTime)&":"&Minute(creationTime)
  109. ' if instr(creationTime,":")<3 then creationTime="0" & creationTime
  110. ' if len(creationTime)<5 then creationTime=Left(creationTime,3) & "0" & Right(creationTime,1)
  111. InquiryLinesNo=1
  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=submitInquiry">
  119. <tr bgcolor='#C3C300'>
  120. <td colspan="2"><TABLE Border="0" Width="100%" Cellspacing="1" Cellpadding="0" Dir="RTL"><TR>
  121. <TD><table>
  122. <tr>
  123. <td align="left">:</td>
  124. <td align="right">
  125. <span id="customer"><%' after any changes in this span "./Customers.asp" must be revised%>
  126. <INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>"><span><%=CustomerName%></span>.
  127. </span></td>
  128. <td><INPUT class="InvGenButton" TYPE="button" value="" onClick="selectCustomer();"></td>
  129. </tr>
  130. </table></TD>
  131. <TD align="left"><table>
  132. <tr>
  133. <td align="left">:</td>
  134. <td dir="LTR">
  135. <INPUT class="InvGenInput" NAME="InquiryDate" TYPE="text" maxlength="10" size="10" value="<%=CreationDate%>"></td>
  136. <td dir="RTL"><%=weekdayname(weekday(date))%></td>
  137. </tr>
  138. </table></TD>
  139. </TR></TABLE>
  140. </td>
  141. </tr>
  142. <tr bgcolor='#C3C300'>
  143. <TD align="right" width="50%">
  144. ():
  145. <span id="orders">
  146. <%
  147. tempWriteAnd=""
  148. for i=1 to request.form("selectedOrders").count
  149. response.write "<input type='hidden' name='selectedOrders' value='"& request.form("selectedOrders")(i)& "'>"
  150. response.write tempWriteAnd & Link2Trace(request.form("selectedOrders")(i))
  151. tempWriteAnd=" "
  152. next
  153. %>
  154. </span>&nbsp;
  155. <INPUT class="InvGenButton" TYPE="button" value="" onClick="selectOrder();">
  156. </TD>
  157. <TD align="left"><table>
  158. <tr>
  159. <td align="left">:</td>
  160. <td dir="LTR">
  161. <INPUT class="InvGenInput" NAME="InquiryNo" style="border:1px solid black;" TYPE="text" maxlength="10" size="10"></td>
  162. <td dir="RTL"><INPUT TYPE="checkbox" onClick="checkIsA();" NAME="IsA"> &nbsp;</td>
  163. </tr>
  164. </table></TD>
  165. </tr>
  166. <tr bgcolor='#CCCC88'>
  167. <TD colspan="10"><div>
  168. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
  169. <tr bgcolor='#CCCC88'>
  170. <td align='center' width="32px"> # </td>
  171. <td><INPUT class="InvHeadInput" readonly TYPE="text" value="" size="3" ></td>
  172. <td><INPUT class="InvHeadInput2" readonly TYPE="text" value="" size="30"></td>
  173. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value="" size="2"></td>
  174. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value="" size="2"></td>
  175. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value="" size="3"></td>
  176. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value="" size="2"></td>
  177. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value=" " size="6"></td>
  178. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value="" size="7"></td>
  179. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value="" size="9"></td>
  180. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value=""size="7"></td><!-- S A M -->
  181. <td><INPUT class="InvHeadInput" readonly TYPE="text" Value="ѐ" size="5"></td><!-- S A M -->
  182. <td><INPUT class="InvHeadInput4" readonly TYPE="text" Value="" size="6"></td><!-- S A M -->
  183. <td><INPUT class="InvHeadInput2" readonly TYPE="text" Value=" " size="9"></td>
  184. </tr>
  185. </TABLE></div></TD>
  186. </TR>
  187. <tr bgcolor='#CCCC88'>
  188. <TD colspan="10"><div style="overflow:auto; height:250px; width:*;">
  189. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
  190. <Tbody id="InquiryLines">
  191. <%
  192. for i=1 to 1
  193. %>
  194. <tr bgcolor='#F0F0F0' onclick="setCurrentRow(this.rowIndex);" >
  195. <td align='center' width="25px"><%=i%></td>
  196. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Items" size="3" Maxlength="6" onKeyPress="return mask(this);" onfocus="setCurrentRow(this.parentNode.parentNode.rowIndex);" onChange='return check(this);'>
  197. <INPUT TYPE="hidden" name="type" value=0>
  198. <INPUT TYPE="hidden" name="fee" value=0>
  199. <INPUT type='hidden' name='hasVat' value=0>
  200. </td>
  201. <td dir="RTL"><INPUT class="InvRowInput2" TYPE="text" NAME="Descriptions" size="30"></td>
  202. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="Lengths" size="2" onBlur="setFeeQtty(this);"></td>
  203. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="Widths" size="2" onBlur="setFeeQtty(this);"></td>
  204. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="Qttys" size="3" onBlur="setFeeQtty(this);"></td>
  205. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="Sets" size="2" onBlur="setFeeQtty(this);"></td>
  206. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="AppQttys" size="6" onBlur="setPrice(this);"></td>
  207. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Fees" size="7" onBlur="setPrice(this);"></td>
  208. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Prices" size="9" readonly tabIndex="9999"></td>
  209. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Discounts" size="7" onBlur="setPrice(this);"></td><!-- S A M -->
  210. <td dir="LTR"><INPUT class="InvRowInput" TYPE="text" NAME="Reverses" size="5" onBlur="setPrice(this);" onfocus="setCurrentRow(this.parentNode.parentNode.rowIndex);"></td><!-- S A M -->
  211. <td dir="LTR"><INPUT class="InvRowInput4" TYPE="text" NAME="Vat" size="6" readonly></td><!-- S A M -->
  212. <td dir="LTR"><INPUT class="InvRowInput2" TYPE="text" NAME="AppPrices" size="9" readonly tabIndex="9999"></td>
  213. </tr>
  214. <%
  215. next
  216. %>
  217. <tr bgcolor='#F0F0F0' onclick="setCurrentRow(this.rowIndex);" >
  218. <td colspan="15">
  219. <INPUT class="InvGenButton" TYPE="button" value="" onkeyDown="if(event.keyCode==9) {setCurrentRow(this.parentNode.parentNode.rowIndex); return false;};" onClick="addRow();">
  220. </td>
  221. </tr>
  222. </Tbody></TABLE></div>
  223. </TD>
  224. </tr>
  225. <tr bgcolor='#CCCC88'>
  226. <TD colspan="10"><div>
  227. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#CCCC88">
  228. <tr bgcolor='#CCCC88'>
  229. <td colspan='9' width='500px'>*** ǘ ***</td>
  230. <!--td><INPUT readonly class="InvHeadInput" TYPE="text" size="2"></td>
  231. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="2"></td>
  232. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="3"></td>
  233. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="2"></td>
  234. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="6"></td>
  235. <td><INPUT readonly class="InvHeadInput" TYPE="text" size="7"></td-->
  236. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="TotalPrice" TYPE="text" size="9"></td>
  237. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="TotalDiscount" TYPE="text" size="7"></td><!-- S A M -->
  238. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="TotalReverse" TYPE="text" size="5"></td><!-- S A M -->
  239. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="TotalVat" TYPE="test" size="6"></td><!-- S A M -->
  240. <td dir="LTR"><INPUT readonly class="InvHeadInput3" Name="Payable" TYPE="text" size="9"></td>
  241. </tr>
  242. <tr bgcolor='#CCCC88'>
  243. <td colspan="9"> &nbsp; </td>
  244. <td dir="LTR"><INPUT readonly class="InvHeadInput" TYPE="text" size="9"></td>
  245. <td dir="LTR"><INPUT readonly class="InvHeadInput3" TYPE="text" Name="TPDiscount" size="7"></td><!-- S A M -->
  246. <td dir="LTR"><INPUT readonly class="InvHeadInput3" TYPE="text" Name="TPReverse" size="5"></td><!-- S A M -->
  247. <td dir="LTR"><INPUT readonly class="invHeadInput3" TYPE="text" size="6" value="3%"></td><!-- S A M -->
  248. <td dir="LTR"><INPUT readonly class="InvHeadInput" TYPE="text" size="9" value=" "></td>
  249. </tr>
  250. </TABLE></div></TD>
  251. </TR>
  252. </table><br>
  253. <TABLE Border="0" Cellspacing="5" Cellpadding="0" Dir="RTL" align='left'>
  254. <tr>
  255. <td align='center'><INPUT class="InvGenButton" TYPE="button" value=" ..." onclick="submitOperations();"></td>
  256. <td align='center'><INPUT class="InvGenButton" TYPE="button" value="" onclick="window.close();"></td>
  257. </tr>
  258. </TABLE>
  259. </FORM>
  260. <SCRIPT LANGUAGE="JavaScript">
  261. <!--
  262. document.getElementsByName("Items")[0].focus();
  263. //-->
  264. </SCRIPT>
  265. <%elseif request("act")="submitInquiry" then
  266. '******************** Checking Input ****************
  267. errorFound=false
  268. ON ERROR RESUME NEXT
  269. InquiryDate= request.form("InquiryDate")
  270. If Not CheckDateFormat(InquiryDate) Then
  271. errorFound=True
  272. end if
  273. CustomerID= clng(request.form("CustomerID"))
  274. if request.form("IsA") = "on" then
  275. IsA=1
  276. InquiryNo=request.form("InquiryNo")
  277. if InquiryNo <> "" then InquiryNo = clng(InquiryNo)
  278. else
  279. IsA=0
  280. InquiryNo=""
  281. end if
  282. 'OLD Code:
  283. 'TotalPrice= cdbl(text2value(request.form("TotalPrice")))
  284. 'TotalDiscount= cdbl(text2value(request.form("TotalDiscount")))
  285. 'TotalReverse= cdbl(text2value(request.form("TotalReverse")))
  286. 'TotalReceivable=cdbl(text2value(request.form("TotalAppPrice")))
  287. '
  288. 'Changed By Kid 831021: calculating totals ServerSide
  289. TotalPrice = 0
  290. TotalDiscount = 0
  291. TotalReverse = 0
  292. TotalReceivable = 0
  293. TotalVat = 0
  294. RFD = 0
  295. for i=1 to request.form("Items").count
  296. theItem = clng(text2value(request.form("Items")(i)))
  297. mySQL="SELECT ID FROM InvoiceItems WHERE ID=" & theItem
  298. Set rs=conn.Execute(mySQL)
  299. if rs.eof then
  300. errorFound=True
  301. exit for
  302. end if
  303. rs.close
  304. theDescription = left(sqlSafe(request.form("Descriptions")(i)),100)
  305. theAppQtty = cdbl(text2value(request.form("AppQttys")(i)))
  306. thePrice = clng(text2value(request.form("Prices")(i)))
  307. theDiscount = text2value(request.form("Discounts")(i))
  308. theReverse = text2value(request.form("Reverses")(i))
  309. theLength = text2value(request.form("Lengths")(i))
  310. theWidth = text2value(request.form("Widths")(i))
  311. theQtty = text2value(request.form("Qttys")(i))
  312. theSets = text2value(request.form("Sets")(i))
  313. theVat = clng(text2value(request.form("Vat")(i)))
  314. if theDiscount <>"" then theDiscount= clng(theDiscount)
  315. if theReverse <> "" then theReverse = clng(theReverse)
  316. if theLength <> "" then theLength = cdbl(theLength)
  317. if theWidth <> "" then theWidth = cdbl(theWidth)
  318. if theQtty <> "" then theQtty = clng(theQtty)
  319. if theSets <> "" then theSets = clng(theSets)
  320. TotalPrice = TotalPrice + thePrice
  321. TotalDiscount = TotalDiscount + theDiscount
  322. TotalReverse = TotalReverse + theReverse
  323. TotalReceivable = TotalReceivable + (thePrice - theDiscount - theReverse + theVat)
  324. TotalVat = TotalVat + theVat
  325. next
  326. RFD = TotalReceivable - fix(TotalReceivable / 1000) * 1000
  327. 'RFD = RFD / 1.03
  328. TotalReceivable = TotalReceivable - RFD
  329. TotalDiscount = TotalDiscount + RFD
  330. for i = 1 to request.form("selectedOrders").count
  331. theOrder= clng(request.form("selectedOrders")(i))
  332. mySQL = "SELECT ID FROM Orders WHERE ID=" & theOrder
  333. Set rs = conn.Execute(mySQL)
  334. if rs.eof then
  335. errorFound=True
  336. exit for
  337. end if
  338. rs.close
  339. next
  340. Set rs = Nothing
  341. if Err.Number<>0 then
  342. Err.clear
  343. errorFound=True
  344. end if
  345. ON ERROR GOTO 0
  346. if errorFound then
  347. response.write "<br>"
  348. call showAlert (" ",CONST_MSG_ERROR)
  349. response.end
  350. end if
  351. '^^^^---------------- Checking Input ------------^^^^
  352. '**************************** Inserting new Inquiry ****************
  353. mySQL="INSERT INTO Inquiries (CreatedDate, CreatedBy, Customer, Number, TotalPrice, TotalDiscount, TotalReverse, TotalReceivable, IsA, TotalVat) VALUES (N'"& InquiryDate & "', '"& session("ID") & "', '"& CustomerID & "', '"& InquiryNo & "', '"& TotalPrice & "', '"& TotalDiscount & "', '"& TotalReverse & "', '"& TotalReceivable & "', '"& IsA & "', '" & TotalVat & "');SELECT @@Identity AS NewInquiry"
  354. set RS1 = Conn.execute(mySQL).NextRecordSet
  355. InquiryID = RS1 ("NewInquiry")
  356. RS1.close
  357. '**************************** Inserting Inquiry Lines ****************
  358. for i=1 to request.form("Items").count
  359. theItem = clng(text2value(request.form("Items")(i)))
  360. theDescription = left(sqlSafe(request.form("Descriptions")(i)),100)
  361. theAppQtty = cdbl(text2value(request.form("AppQttys")(i)))
  362. thePrice = clng(text2value(request.form("Prices")(i)))
  363. theDiscount = text2value(request.form("Discounts")(i))
  364. theReverse = text2value(request.form("Reverses")(i))
  365. theVat = text2value(request.form("Vat")(i))
  366. theHasVat = text2value(request.form("hasVat")(i))
  367. theLength = text2value(request.form("Lengths")(i))
  368. theWidth = text2value(request.form("Widths")(i))
  369. theQtty = text2value(request.form("Qttys")(i))
  370. theSets = text2value(request.form("Sets")(i))
  371. if theDiscount <>"" then theDiscount= clng(theDiscount)
  372. if theReverse <> "" then theReverse = clng(theReverse)
  373. if theLength <> "" then theLength = cdbl(theLength)
  374. if theWidth <> "" then theWidth = cdbl(theWidth)
  375. if theQtty <> "" then theQtty = clng(theQtty)
  376. if theSets <> "" then theSets = clng(theSets)
  377. 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&")"
  378. conn.Execute(mySQL)
  379. next
  380. if RFD > 0 then
  381. theItem = 39999
  382. theDescription = " ǘ"
  383. theAppQtty = 0
  384. thePrice = 0
  385. theDiscount = RFD
  386. theReverse = 0
  387. theVat = 0
  388. theLength = 0
  389. theWidth = 0
  390. theQtty = 0
  391. theSets = 0
  392. 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 & "')"
  393. conn.Execute(mySQL)
  394. end if
  395. '**************************** Making Inquiry-Order Relations ****************
  396. for i=1 to request.form("selectedOrders").count
  397. theOrder= clng(request.form("selectedOrders")(i))
  398. mySQL="INSERT INTO InquiryOrderRelations (Inquiry,[Order]) VALUES ('" & InquiryID & "', '" & theOrder & "')"
  399. conn.Execute(mySQL)
  400. next
  401. response.redirect "AccountReport.asp?act=showInquiry&inquiry=" & InquiryID
  402. elseif request("act")="copyInquiry" then
  403. InquiryID=request.queryString("inquiry")
  404. if InquiryID="" OR not isnumeric(InquiryID) then
  405. conn.close
  406. response.redirect "?errmsg=" & Server.URLEncode(" .")
  407. end if
  408. InquiryID=clng(InquiryID)
  409. mySQL="SELECT * FROM Inquiries WHERE (ID='"& InquiriID & "')"
  410. Set RS1 = conn.Execute(mySQL)
  411. if RS1.eof then
  412. conn.close
  413. response.redirect "?errmsg=" & Server.URLEncode(" .")
  414. end if
  415. customerID= RS1("Customer")
  416. creationDate= shamsiToday()
  417. totalPrice= cdbl(RS1("totalPrice"))
  418. totalDiscount= cdbl(RS1("totalDiscount"))
  419. totalReverse= cdbl(RS1("totalReverse"))
  420. totalVat = cdbl(RS1("totalVat"))
  421. TotalReceivable = totalPrice - totalDiscount - totalReverse + totalVat
  422. Issued = RS1("Issued")
  423. Voided = RS1("Voided")
  424. if RS1("IsReverse") then
  425. isReverse= 1
  426. else
  427. isReverse= 0
  428. end if
  429. if RS1("IsA") then
  430. IsA= 1
  431. else
  432. IsA= 0
  433. end if
  434. InquiryNo= RS1("Number")
  435. RS1.close
  436. if isReverse AND not Auth(6 , 4) then
  437. 'Doesn't have the permission for ADDING Rev. Inquiry
  438. response.write "<br>"
  439. call showAlert (" ѐ ",CONST_MSG_ERROR)
  440. response.end
  441. elseif not Auth(6 , 1) then
  442. 'Doesn't have the permission for ADDING Inquiry
  443. response.write "<br>"
  444. call showAlert (" ",CONST_MSG_ERROR)
  445. response.end
  446. end if
  447. 'Copying Inquiry ...
  448. mySQL="INSERT INTO Inquiries (CreatedDate, CreatedBy, Customer, IsA, Number, TotalPrice, TotalDiscount, TotalReverse, TotalReceivable, IsReverse, TotalVat) VALUES (N'"& creationDate & "', '"& session("ID") & "', '"& CustomerID & "', '"& IsA & "', '"& InquiryNo & "', '"& TotalPrice & "', '"& TotalDiscount & "', '"& TotalReverse & "', '"& TotalReceivable & "', '"& IsReverse & "', '" & TotalVat & "'); SELECT @@Identity AS NewInquiry"
  449. Set RS1 = conn.Execute(mySQL).NextRecordSet
  450. NewInquiry = RS1("NewInquiry")
  451. 'Copying InquiryLines ...
  452. mySQL="INSERT INTO InquiryLines (Inquiry, Item, Description, Length, Width, Qtty, Sets, AppQtty, Price, Discount, Reverse, Vat, hasVat) SELECT '"& NewInquiry & "' AS Inquiry, Item, Description, Length, Width, Qtty, Sets, AppQtty, Price, Discount, Reverse, Vat, hasVat FROM InquiryLines WHERE (Inquiry = '"& InquiryID & "')"
  453. conn.Execute(mySQL)
  454. 'Copying InquiryOrderRelations ...
  455. mySQL="INSERT INTO InquiryOrderRelations (Inquiry, [Order]) SELECT '"& NewInquiry & "' AS Inquiry, [Order] FROM InquiryOrderRelations WHERE (Inquiry = '"& InquiryID & "')"
  456. conn.Execute(mySQL)
  457. if Issued AND voided then
  458. ' if it's copied from a voided Inquiry, place a comment for the voided Inquiry
  459. MsgTo = 0
  460. msgTitle = "Inquiry Copied"
  461. msgBody = " "& NewInquiry & " ߁ ."
  462. RelatedTable = "Inquiries"
  463. relatedID = InquiryID
  464. replyTo = 0
  465. IsReply = 0
  466. urgent = 0
  467. MsgFrom = session("ID")
  468. MsgDate = shamsiToday()
  469. MsgTime = currentTime10()
  470. 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 & ")")
  471. end if
  472. ' Place a comment for the new Inquiry
  473. MsgTo = 0
  474. msgTitle = "Inquiry Copied"
  475. msgBody = " "& InquiryID & " ߁ ."
  476. RelatedTable = "Inquiries"
  477. relatedID = NewInquiry
  478. replyTo = 0
  479. IsReply = 0
  480. urgent = 0
  481. MsgFrom = session("ID")
  482. MsgDate = shamsiToday()
  483. MsgTime = currentTime10()
  484. 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 & ")")
  485. response.redirect "AccountReport.asp?act=showInquiry&inquiry=" & NewInquiry & "&msg=" & Server.URLEncode(request.queryString("msg") & "<br> "& InquiryID & " ߁ .")
  486. end if
  487. conn.Close
  488. %>
  489. <!--#include file="tah.asp" -->