/beta/AR/InvoicePrintFormInput.asp

http://github.com/khaneh/Orders · ASP · 326 lines · 306 code · 12 blank · 8 comment · 23 complexity · 899e20afaa173e6a1ea71e085a8637c9 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. .InvRowInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0FFF0; 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. .InvGenInput { font-family:tahoma; font-size: 9pt; border: none; }
  27. .InvGenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
  28. </style>
  29. <SCRIPT LANGUAGE="JavaScript">
  30. <!--
  31. var selectedRow=-1;
  32. function selectAndDelete(rowNo){
  33. if (selectedRow==rowNo){
  34. delAndShiftUp(rowNo);
  35. document.getElementById("InvoiceLines").getElementsByTagName("TR")[selectedRow].getElementsByTagName("TD")[0].setAttribute("bgColor","");
  36. selectedRow=-1
  37. calcAndCheck()
  38. }
  39. else{
  40. if (selectedRow != -1)
  41. document.getElementById("InvoiceLines").getElementsByTagName("TR")[selectedRow].getElementsByTagName("TD")[0].setAttribute("bgColor","");
  42. document.getElementById("InvoiceLines").getElementsByTagName("TR")[rowNo].getElementsByTagName("TD")[0].setAttribute("bgColor","red");
  43. selectedRow=rowNo;
  44. }
  45. }
  46. function delAndShiftUp(rowNo){
  47. for (i=rowNo;i<9;i++){
  48. document.getElementsByName("Descriptions")[i].value=document.getElementsByName("Descriptions")[i+1].value
  49. document.getElementsByName("Qttys")[i].value=document.getElementsByName("Qttys")[i+1].value
  50. document.getElementsByName("Units")[i].value=document.getElementsByName("Units")[i+1].value
  51. document.getElementsByName("Fees")[i].value=document.getElementsByName("Fees")[i+1].value
  52. document.getElementsByName("Prices")[i].value=document.getElementsByName("Prices")[i+1].value
  53. }
  54. }
  55. function setPrice(src){
  56. if (src.name=="Qttys" || src.name=="Fees"){
  57. src.value=val2txt(txt2val(src.value))
  58. rowNo=src.parentNode.parentNode.rowIndex;
  59. tmpFee=txt2val(document.getElementsByName("Fees")[rowNo].value);
  60. tmpQtty=txt2val(document.getElementsByName("Qttys")[rowNo].value);
  61. tmpPrice= tmpFee * tmpQtty;
  62. document.getElementsByName("Prices")[rowNo].value = val2txt(parseInt(tmpPrice));
  63. }
  64. else if (src.name=="Discount"){
  65. src.value=val2txt(txt2val(src.value))
  66. }
  67. calcAndCheck()
  68. }
  69. function calcAndCheck(){
  70. var total=0;
  71. var payable;
  72. for(i=0;i<10;i++){
  73. total+=txt2val(document.getElementsByName("Prices")[i].value)
  74. }
  75. document.getElementsByName("TotalPrice")[0].value=val2txt(total)
  76. payable=total-txt2val(document.getElementsByName("Discount")[0].value);
  77. document.getElementsByName("Payable")[0].value=val2txt(payable)
  78. if(document.getElementsByName("Payable")[0].value==document.getElementsByName("MustBe")[0].value){
  79. document.getElementsByName("Payable")[0].style.backgroundColor='#00FF00';
  80. }
  81. else{
  82. document.getElementsByName("Payable")[0].style.backgroundColor='#FF0000';
  83. }
  84. }
  85. //-->
  86. </SCRIPT>
  87. <%
  88. response.end()
  89. if request("act")="getPrintForm" then
  90. if isnumeric(request("invoice")) then
  91. InvoiceID=clng(request("invoice"))
  92. mySQL="SELECT * FROM Invoices WHERE (ID='"& InvoiceID & "')"
  93. Set RS1 = conn.Execute(mySQL)
  94. if RS1.eof then
  95. conn.close
  96. response.redirect "?errmsg=" & Server.URLEncode(" .")
  97. end if
  98. else
  99. response.redirect "?errmsg=" & Server.URLEncode(" .")
  100. end if
  101. customerID= RS1("Customer")
  102. creationDate= RS1("CreatedDate")
  103. totalPrice= cdbl(RS1("totalPrice"))
  104. totalDiscount= cdbl(RS1("totalDiscount"))+cdbl(RS1("totalReverse"))
  105. totalReceivable=cdbl(RS1("totalReceivable"))
  106. totalVat = cdbl(RS1("totalVat"))
  107. Voided= RS1("Voided")
  108. Issued= RS1("Issued")
  109. Approved= RS1("Approved")
  110. isReverse= RS1("IsReverse")
  111. IsA= RS1("IsA")
  112. InvoiceNo= RS1("Number")
  113. if isReverse then
  114. 'Check for permission for EDITTING Rev. Invoice
  115. if not Auth(6 , 5) then NotAllowdToViewThisPage()
  116. itemTypeName="ǘ ѐ"
  117. HeaderColor="#FF9900"
  118. else
  119. 'Check for permission for EDITTING Invoice
  120. if not Auth(6 , 3) then NotAllowdToViewThisPage()
  121. itemTypeName="ǘ"
  122. HeaderColor="#C3C300"
  123. end if
  124. if Voided then
  125. Conn.close
  126. response.redirect "AccountReport.asp?act=showInvoice&invoice="& InvoiceID & "&errmsg=" & Server.URLEncode(" .")
  127. elseif Issued then
  128. if Auth(6 , "A") then
  129. ' Has the Priviledge to change the Invoice
  130. response.write "<BR>"
  131. call showAlert (" .<br>э ǘ <br> Ԙ Ͽ",CONST_MSG_INFORM)
  132. else
  133. Conn.close
  134. response.redirect "AccountReport.asp?act=showInvoice&invoice="& InvoiceID & "&errmsg=" & Server.URLEncode(" .")
  135. end if
  136. end if
  137. mySQL="SELECT ID,AccountTitle,Address1,Tel1,PostCode1,EconomicalCode FROM Accounts WHERE (ID='"& customerID & "')"
  138. Set RS1 = conn.Execute(mySQL)
  139. customerName=RS1("AccountTitle")
  140. customerAddress=RS1("Address1")
  141. customerTel=RS1("Tel1")
  142. customerPostCode=RS1("PostCode1")
  143. customerEcCode=RS1("EconomicalCode")
  144. RS1.close
  145. ' response.end
  146. creationDate=shamsiToday()
  147. ' creationTime=Hour(creationTime)&":"&Minute(creationTime)
  148. ' if instr(creationTime,":")<3 then creationTime="0" & creationTime
  149. ' if len(creationTime)<5 then creationTime=Left(creationTime,3) & "0" & Right(creationTime,1)
  150. %>
  151. <!-- -->
  152. <br>
  153. <input type="hidden" Name='tmpDlgArg' value=''>
  154. <input type="hidden" Name='tmpDlgTxt' value=''>
  155. <table Border="0" align="center" Width="100%" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
  156. <FORM METHOD=POST ACTION="?act=submitPrintForm">
  157. <tr bgcolor='#C3C300'>
  158. <td align="left"><TABLE>
  159. <TR>
  160. <TD align="left">:</td>
  161. <TD dir="LTR">
  162. <INPUT class="InvGenInput" NAME="InvoiceDate" TYPE="text" maxlength="10" size="10" value="<%=CreationDate%>"></td>
  163. <INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>">
  164. <TD dir="RTL"><%=weekdayname(weekday(date))%></td>
  165. </TR>
  166. </TABLE>
  167. </td>
  168. </tr>
  169. <tr bgcolor='#C3C300'>
  170. <td>
  171. <TABLE border="0" width="100%" >
  172. <TR>
  173. <TD align="left"> :</TD>
  174. <TD><TEXTAREA style="font-family:tahoma;font-size:9pt;direction:RTL;border:1 solid black;width:450px;" NAME="CustomerName" rows="1" cols="50"><%=CustomerName%></TEXTAREA></TD>
  175. <TD align="left"> :</TD>
  176. <TD><INPUT class="InvGenInput" style="border:1 solid black;width:100px;direction:LTR;text-align:left;" NAME="customerEcCode" TYPE="text" size="10" value="<%=customerEcCode%>"></TD>
  177. </TR>
  178. <TR>
  179. <TD align="left">:</TD>
  180. <TD><TEXTAREA style="font-family:tahoma;font-size:9pt;direction:RTL;border:1 solid black;width:450px;" NAME="customerAddress" rows="2" cols="50"><%=customerAddress%></TEXTAREA></TD>
  181. <TD align="left"> :</TD>
  182. <TD><INPUT class="InvGenInput" style="border:1 solid black;width:100px;" NAME="customerPostCode" TYPE="text" size="10" value="<%=customerPostCode%>"></TD>
  183. </TR>
  184. <TR>
  185. <TD align="left">:</TD>
  186. <TD><TEXTAREA style="font-family:tahoma;font-size:9pt;direction:RTL;border:1 solid black;width:450px;" NAME="customerTel" rows="1" cols="50"><%=customerTel%></TEXTAREA></TD>
  187. <TD align="left"> :</TD>
  188. <TD align=left><INPUT TYPE="radio" NAME="Cash" Value="1"> <INPUT TYPE="radio" NAME="Cash" Value="0" checked></TD>
  189. </TR>
  190. </TABLE>
  191. </td>
  192. </tr>
  193. <tr bgcolor='#CCCC88'>
  194. <td><div>
  195. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
  196. <TR bgcolor='#CCCC88'>
  197. <TD align='center' width="25px"> # </td>
  198. <TD><INPUT class="InvHeadInput2" readOnly TYPE="text" value=" " size="65" ></TD>
  199. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" value="" size="6"></TD> <!--S A M-->
  200. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value=" " size="10"></TD>
  201. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value=" " size="15"></TD>
  202. <td><INPUT class="InvHeadInput" readonly TYPE="text" value="" size="7"></td><!--S A M-->
  203. <TD><INPUT class="InvHeadInput2" readOnly TYPE="text" Value="" size="20"></TD>
  204. </TR>
  205. </TABLE></div>
  206. </td>
  207. </tr>
  208. <tr bgcolor='#CCCC88'>
  209. <td>
  210. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855">
  211. <TBODY id="InvoiceLines">
  212. <%
  213. Dim Descriptions(10)
  214. Dim Qttys(10)
  215. Dim Units(10) ' Allways empty!
  216. Dim Fees(10)
  217. Dim Prices(10)
  218. i=0
  219. mySQL="SELECT * FROM InvoiceLines left outer join invoiceItems on InvoiceLines.item = invoiceItems.ID WHERE (Invoice='"& InvoiceID & "') "
  220. Set RS1 = conn.Execute(mySQL)
  221. Do While NOT RS1.eof AND i<10
  222. i=i+1
  223. Descriptions(i)=RS1("Description")
  224. Qttys(i)=Separate(RS1("AppQtty"))
  225. if RS1("AppQtty") <> 0 then
  226. Fees(i)=Separate(RS1("Price")/RS1("AppQtty"))
  227. else
  228. Fees(i)="0"
  229. end if
  230. Prices(i)=Separate(RS1("Price"))
  231. RS1.moveNext
  232. Loop
  233. RS1.close
  234. for i=1 to 10
  235. %>
  236. <TR bgcolor='#F0F0F0'>
  237. <TD align='center' width="25px" onclick="selectAndDelete(this.parentNode.rowIndex);"><%=i%></TD>
  238. <TD><INPUT class="InvRowInput2" TYPE="text" Name="Descriptions" value="<%=Descriptions(i)%>" size="65"></TD>
  239. <TD><INPUT class="InvRowInput" TYPE="text" Name="Qttys" value="<%=Qttys(i)%>" size="6" onBlur="setPrice(this);"></TD>
  240. <TD><INPUT class="InvRowInput" TYPE="text" Name="Units" Value="<%=Units(i)%>" size="10"></TD>
  241. <TD><INPUT class="InvRowInput" TYPE="text" Name="Fees" Value="<%=Fees(i)%>" size="15" onBlur="setPrice(this);"></TD>
  242. <td><INPUT class="InvRowInput" TYPE="text" Name="Vat" value="<%Vat(i)%>" size="7" onBlur="this.value=val2txt(txt2val(this.value));calcAndCheck();"></td>
  243. <TD><INPUT class="InvRowInput3" TYPE="text" Name="Prices" Value="<%=Prices(i)%>" size="20" onBlur="this.value=val2txt(txt2val(this.value));calcAndCheck();"></TD>
  244. </TR>
  245. <%
  246. next
  247. %>
  248. </Tbody>
  249. </TABLE>
  250. </td>
  251. </tr>
  252. <tr bgcolor='#CCCC88'>
  253. <td colspan="10"><div>
  254. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#CCCC88">
  255. <TR bgcolor='#CCCC88'>
  256. <TD align='center' width="24px"></td>
  257. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>
  258. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  259. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  260. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value=" :" style="text-align:left;" size="15"></TD>
  261. <TD style="border:1 solid black;"><INPUT class="InvRowInput2" readOnly TYPE="text" Name="TotalPrice" Value="<%=Separate(totalPrice)%>" size="20"></TD>
  262. </TR>
  263. <TR bgcolor='#CCCC88'>
  264. <TD align='center' width="24px"></td>
  265. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>
  266. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  267. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  268. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value=":" style="text-align:left;" size="15"></TD>
  269. <TD style="border:1 solid black;"><INPUT class="InvRowInput3" TYPE="text" Name="Discount" Value="<%=Separate(totalDiscount)%>" size="20" onBlur="setPrice(this);"></TD>
  270. </TR>
  271. <tr bgcolor="#CCCC88">
  272. <TD align='center' width="24px"></td>
  273. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>
  274. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  275. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  276. <TD><INPUT class="InvHeadInput" readonly TYPE="text" Value=" :" style="text-align:left" size="15"></TD>
  277. <TD style="border:1 solid black;"><INPUT style="color:gray;" readonly TYPE="text" NAME="totalVat" value="<%=Separate(totalVat)%>" size="20"></TD>
  278. </td>
  279. <TR bgcolor='#CCCC88'>
  280. <TD align='center' width="24px"></td>
  281. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>
  282. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  283. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  284. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" Value=" :" style="text-align:left;" size="15"></TD>
  285. <TD style="border:1 solid black;"><INPUT class="InvRowInput3" readOnly TYPE="text" Name="Payable" Value="<%=Separate(totalReceivable)%>" size="20"></TD>
  286. </TR>
  287. <TR bgcolor='#CCCC88'>
  288. <TD></td>
  289. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="65"></TD>
  290. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  291. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="10"></TD>
  292. <TD><INPUT class="InvHeadInput" readOnly TYPE="text" size="15"></TD>
  293. <TD><INPUT class="InvHeadInput3" style="color:gray;" readOnly TYPE="text" Name="MustBe" Value="<%=Separate(totalReceivable)%>" size="20"></TD>
  294. </TR>
  295. </TABLE></div>
  296. </td>
  297. </tr>
  298. <tr>
  299. <td align='center'><INPUT class="InvGenButton" TYPE="button" value="" onclick="calcAndCheck();"></td>
  300. </tr>
  301. </table>
  302. </FORM>
  303. <br>
  304. <SCRIPT LANGUAGE="JavaScript">
  305. <!--
  306. // document.getElementsByName("Items")[0].focus();
  307. calcAndCheck();
  308. //-->
  309. </SCRIPT>
  310. <%
  311. end if
  312. conn.Close
  313. %>
  314. <!--#include file="tah.asp" -->