/beta/AP/MemoInput.asp

http://github.com/khaneh/Orders · ASP · 254 lines · 228 code · 15 blank · 11 comment · 20 complexity · 2852f3a1f99d32f500aa5eab7015dd70 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'AP (7)
  3. PageTitle= " /"
  4. SubmenuItem=4
  5. if not Auth(7 , 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 Link2Trace(OrderNo)
  12. Link2Trace="<A HREF='../order/orderEdit.asp?e=n&radif="& OrderNo & "' target='_balnk'>"& OrderNo & "</A>"
  13. end function
  14. %>
  15. <style>
  16. .MmoTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; direction: right-to-left;}
  17. .MmoMainTable { font-family:tahoma; font-size: 9pt; border:0; padding:0; background-color: #558855; text-align:right; direction: RTL;}
  18. .MmoMainTableTH { background-color: #C3C300;}
  19. .MmoMainTableTR { background-color: #CCCC88; border: 0; }
  20. .MmoRowInput { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
  21. .MmoRowInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #F0F0F0; text-align:right;}
  22. .MmoHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
  23. .MmoHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
  24. .MmoHeadInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid black; background-color: #D0E0FF; text-align:right; direction: RTL;}
  25. .MmoGenInput { font-family:tahoma; font-size: 9pt; border: none; text-align:right; direction: LTR;}
  26. .GenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
  27. </style>
  28. <SCRIPT LANGUAGE="JavaScript">
  29. <!--
  30. var okToProceed=false;
  31. var currentRow=null;
  32. //-->
  33. </SCRIPT>
  34. <font face="tahoma">
  35. <%
  36. if request("act")="submitsearch" then
  37. if request("CustomerNameSearchBox") <> "" then
  38. SA_TitleOrName=request("CustomerNameSearchBox")
  39. SA_Action="return true;"
  40. SA_SearchAgainURL="MemoInput.asp"
  41. SA_StepText=" : "
  42. SA_IsVendor = 1
  43. %>
  44. <FORM METHOD=POST ACTION="MemoInput.asp?act=getMemo">
  45. <!--#include File="../AR/include_SelectAccount.asp"-->
  46. </FORM>
  47. <%
  48. end if
  49. elseif request("act")="selectOrder" then
  50. if request("selectedCustomer") <> "" then
  51. SO_Customer=request("selectedCustomer")
  52. SO_Action="return true;"
  53. SO_StepText=" :"
  54. %>
  55. <FORM METHOD=POST ACTION="MemoInput.asp?act=getMemo">
  56. <!--#include File="../AR/include_SelectOrder.asp"-->
  57. </FORM>
  58. <%
  59. end if
  60. elseif request("act")="getMemo" then
  61. customerID=request("selectedCustomer")
  62. mySQL="SELECT * FROM Accounts WHERE (ID='"& CustomerID & "')"
  63. Set RS1 = conn.Execute(mySQL)
  64. AccountNo=RS1("ID")
  65. customerName=RS1("AccountTitle")
  66. creationDate=shamsiToday()
  67. creationTime=time
  68. ' creationTime=Hour(creationTime)&":"&Minute(creationTime)
  69. ' if instr(creationTime,":")<3 then creationTime="0" & creationTime
  70. ' if len(creationTime)<5 then creationTime=Left(creationTime,3) & "0" & Right(creationTime,1)
  71. %><BR><BR><BR>
  72. <div align=center dir='rtl'><B> : </B>
  73. </div>
  74. <!-- -->
  75. <br>
  76. <input type="hidden" Name='tmpDlgArg' value=''>
  77. <table class="MmoMainTable" Cellspacing="1" Cellpadding="5" Width="500" align="center">
  78. <FORM METHOD=POST ACTION="MemoInput.asp?act=submitMemo" onsubmit="if (document.all.AccountTitle.value=='') return false;">
  79. <tr class="MmoMainTableTH">
  80. <TD colspan="10"><TABLE class="MmoTable" Border="0" Width="100%" Cellspacing="1" Cellpadding="0"><TR>
  81. <TD align="left">:</TD>
  82. <TD align="right" width="5">
  83. <INPUT class="MmoGenInput" disabled TYPE="text" value="<%=customerID%>" maxlength="5" size="5" tabIndex="1">
  84. </TD>
  85. <TD align="right">
  86. <INPUT TYPE="hidden" NAME="customerID" value="<%=customerID%>"><%=CustomerName%>.
  87. </TD>
  88. <TD align="left">:</TD>
  89. <TD><TABLE class="MmoTable">
  90. <TR>
  91. <TD dir="LTR">
  92. <INPUT class="MmoGenInput" Style="text-align:left;" NAME="MemoDate" TYPE="text" maxlength="10" size="10" value="<%=CreationDate%>" onblur="acceptDate(this)">
  93. </TD>
  94. <TD dir="RTL"><%=weekdayname(weekday(date))%></TD>
  95. </TR>
  96. </TABLE></TD>
  97. </TR></TABLE></TD>
  98. </tr>
  99. <tr class="MmoMainTableTH" height="25">
  100. <TD> </TD>
  101. <TD> / </TD>
  102. <TD> </TD>
  103. <TD> </TD>
  104. </tr>
  105. <tr class="MmoMainTableTR">
  106. <TD valign="top">
  107. <SELECT class="MmoRowInput" NAME="MemoType">
  108. <%
  109. mySQL="SELECT * FROM AXMemoTypes WHERE Display=1"
  110. Set RS1=conn.execute(mySQL)
  111. while not RS1.eof
  112. %>
  113. <OPTION Value="<%=RS1("ID")%>"><%=RS1("Name")%></OPTION>
  114. <%
  115. RS1.moveNext
  116. wend
  117. %>
  118. </SELECT>
  119. </TD>
  120. <TD valign="top">
  121. <SELECT class="MmoRowInput" NAME="IsCredit">
  122. <OPTION Value="0"></OPTION>
  123. <OPTION Value="1" selected ></OPTION>
  124. </SELECT>
  125. </TD>
  126. <TD valign="top"><TEXTAREA class="MmoRowInput" dir="RTL" NAME="Description" ROWS="3" COLS="30"></TEXTAREA></TD>
  127. <TD valign="top"><INPUT class="MmoRowInput" Dir="LTR" NAME="Amount" TYPE="text" size="15" onblur="setPrice(this);" onKeyPress="return mask(this);"></TD>
  128. </tr>
  129. </table><br>
  130. <TABLE class="MmoTable" align=center Border="0" Cellspacing="5" Cellpadding="1">
  131. <tr>
  132. <td align='center' bgcolor="#000000"><INPUT class="MmoGenInput" style="text-align:center" TYPE="button" value="" onclick="submit();"></td>
  133. <td align='center' bgcolor="#000000"><INPUT class="MmoGenInput" style="text-align:center" TYPE="button" value="" onclick="window.location='MemoInput.asp';"></td>
  134. </tr>
  135. </TABLE>
  136. </FORM>
  137. <SCRIPT LANGUAGE="JavaScript">
  138. <!--
  139. // document.all.CashAmount.focus();
  140. //-->
  141. function setPrice(src){
  142. if (echoNum(getNum($(src).val()))=="NaN")
  143. $(src).val(0);
  144. else
  145. $(src).val(echoNum(getNum($(src).val())));
  146. }
  147. </SCRIPT>
  148. <%elseif request("act")="submitMemo" then
  149. ON ERROR RESUME NEXT
  150. MemoDate= sqlSafe(request.form("MemoDate"))
  151. CustomerID= clng(request.form("CustomerID"))
  152. Amount= cdbl(text2value(request.form("Amount")))
  153. Description=sqlSafe(request.form("Description"))
  154. MemoType= cint(request.form("MemoType"))
  155. IsCredit= cbool(request.form("IsCredit"))
  156. if IsCredit then IsCredit=1 else IsCredit=0 end if
  157. if Err.Number<>0 then
  158. Err.clear
  159. conn.close
  160. response.redirect "top.asp?errMsg=" & Server.URLEncode("!")
  161. end if
  162. ON ERROR GOTO 0
  163. '---- Checking wether EffectiveDate is valid in current open GL
  164. if (MemoDate < session("OpenGLStartDate")) OR (MemoDate > session("OpenGLEndDate")) then
  165. Conn.close
  166. response.redirect "?act=getMemo&selectedCustomer="& CustomerID & "&errMsg=" & Server.URLEncode("!<br> .")
  167. end if
  168. '----
  169. '----- Check GL is closed
  170. if (session("IsClosed")="True") then
  171. Conn.close
  172. response.redirect "?errMsg=" & Server.URLEncode("! .")
  173. end if
  174. '----
  175. creationDate= shamsiToday()
  176. GLAccount= "89099" 'This must be changed... (Misc. Purchase)
  177. firstGLAccount= "41001" 'This must be changed... (Business Creditors)
  178. mySQL="INSERT INTO APMemo (CreatedDate, CreatedBy, Account, Type, IsCredit, Description, Amount) VALUES (N'" &_
  179. MemoDate & "', '"& session("ID") & "', '"& CustomerID & "', '"& MemoType & "', '"& IsCredit & "', N'"& Description & "', '"& Amount & "');SELECT @@Identity AS NewMemo"
  180. Set RS1 = conn.Execute(mySQL).NextRecordSet
  181. MemoID=RS1("NewMemo")
  182. RS1.close
  183. '**************************** Creating APItem for Memo ****************
  184. '*** Type = 3 means APItem is a Memo
  185. mySQL="INSERT INTO APItems (GLAccount, GL, FirstGLAccount, Account, EffectiveDate, IsCredit, Type, Link, AmountOriginal, CreatedDate, CreatedBy, RemainedAmount) VALUES (" &_
  186. GLAccount & ", '"& OpenGL & "', '"& firstGLAccount & "', '"& CustomerID & "', N'"& MemoDate & "', '"& IsCredit & "', 3, '"& MemoID & "', '"& Amount & "', N'"& creationDate & "', '"& session("ID") & "', '"& Amount & "')"
  187. conn.Execute(mySQL)
  188. '***------------------------- Creating APItem for Memo ----------------
  189. if IsCredit then
  190. mySQL="UPDATE Accounts SET APBalance = APBalance + '"& Amount & "' WHERE (ID='"& CustomerID & "')"
  191. else
  192. mySQL="UPDATE Accounts SET APBalance = APBalance - '"& Amount & "' WHERE (ID='"& CustomerID & "')"
  193. end if
  194. conn.Execute(mySQL)
  195. conn.close
  196. response.redirect "AccountReport.asp?act=showMemo&sys=AP&memo=" & MemoID &"&msg=" & Server.URLEncode(" .")
  197. else%>
  198. <!-- -->
  199. <FORM METHOD=POST ACTION="MemoInput.asp?act=submitsearch" onsubmit="if (document.all.CustomerNameSearchBox.value=='') return false;"><BR><BR>
  200. <div dir='rtl'>&nbsp;<B> : </B>
  201. <INPUT TYPE="text" NAME="CustomerNameSearchBox">&nbsp;
  202. <INPUT class="GenButton" TYPE="submit" value=""><br>
  203. </div>
  204. </FORM>
  205. <SCRIPT LANGUAGE="JavaScript">
  206. <!--
  207. document.all.CustomerNameSearchBox.focus();
  208. //-->
  209. </SCRIPT>
  210. <%
  211. end if
  212. conn.Close
  213. %>
  214. </font>
  215. </BODY>
  216. </HTML>
  217. <% if request("act")="getMemo" then %>
  218. <script language="JavaScript">
  219. <!--
  220. function delRow(rowNo){
  221. chqTable=document.getElementById("ChequeLines");
  222. theRow=chqTable.getElementsByTagName("tr")[rowNo];
  223. chqTable.removeChild(theRow);
  224. for (rowNo=0; rowNo < document.getElementsByName("ChequeNos").length; rowNo++){
  225. chqTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0].innerText= rowNo+1;
  226. }
  227. }
  228. function mask(src){
  229. var theKey=event.keyCode;
  230. if (theKey==13){
  231. return true;
  232. }
  233. else if (theKey < 48 || theKey > 57) { // 0-9 are acceptible
  234. return false;
  235. }
  236. }
  237. //-->
  238. </script>
  239. <%end if%>