/beta/accounting/CompMemoInput.asp

http://github.com/khaneh/Orders · ASP · 1210 lines · 926 code · 188 blank · 96 comment · 140 complexity · a2afb2a0187dd937d32cc48b379e9c30 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'Accounting (8)
  3. PageTitle= " "
  4. SubmenuItem=2
  5. if not Auth(8 , "F") then NotAllowdToViewThisPage()
  6. '---------------------------------------------
  7. '---------------------------- ShowErrorMessage
  8. '---------------------------------------------
  9. function ShowErrorMessage(msg)
  10. response.write "<table align='center' cellpadding='5'><tr><td bgcolor='#FFCCCC' dir='rtl' align='center'> ! <br>"& msg & "<br></td></tr></table><br>"
  11. end function
  12. Sub MakeSubsystemItem()
  13. '--- variables used:
  14. ' Conn
  15. ' Account
  16. ' GLAccount
  17. ' GLMemoDate
  18. ' IsCredit
  19. ' Amount
  20. ' theDescription
  21. ' creationDate
  22. '
  23. ' Sys (Must have value before)
  24. ' theItem (Must have value before)
  25. mySQL = "SELECT ItemReason FROM AXItemReasonGLAccountRelations WHERE (GL = "& openGL & ") AND (GLAccount = "& GLAccount & ")"
  26. Set RS1=Conn.execute(mySQL)
  27. if RS1.eof then
  28. 'Using default reason (sys: AO, reason: Misc.)
  29. Reason=6
  30. else
  31. Reason= cint(RS1("ItemReason"))
  32. end if
  33. RS1.close
  34. mySQL="SELECT * FROM AXItemReasons WHERE (ID="& Reason & ")"
  35. Set RS1=Conn.execute(mySQL)
  36. sys= RS1("Acron")
  37. ReasonName = RS1("Name")
  38. RS1.close
  39. ' * Note: This is affecting the first line info (Account) so it must be the opposite of isCredit
  40. '*** Memo Type=8 means 'Compound Memo'
  41. mySQL="INSERT INTO "& sys & "Memo (CreatedDate, CreatedBy, Type, Account, IsCredit, Amount, Description) VALUES (N'"&_
  42. GLMemoDate & "' , "& session("ID") & ", 8, "& Account & ", "& IsCredit & ", "& Amount & ", N'"& theDescription & "');SELECT @@Identity AS NewMemo"
  43. set RS1 = Conn.execute(mySQL).NextRecordSet
  44. theMemo = RS1("NewMemo")
  45. RS1.close
  46. ' * Note: there is no FirstGLAccount because this is a compound memo
  47. '*** Type = 3 means A*Item is a Memo
  48. mySQL="INSERT INTO "& sys & "Items (GLAccount, GL, Account, EffectiveDate, IsCredit, Type, Link, Reason, AmountOriginal, CreatedDate, CreatedBy, RemainedAmount, GL_Update) VALUES ('" &_
  49. GLAccount & "', "& OpenGL &", '"& Account & "', N'"& GLMemoDate & "', "& IsCredit & ", 3, "& theMemo & ", "& Reason & ", "& Amount & ", N'"& creationDate & "', "& session("ID") & ", "& Amount & ", 0);SELECT @@Identity AS NewItem"
  50. set RS1 = Conn.execute(mySQL).NextRecordSet
  51. theItem = RS1("NewItem")
  52. RS1.close
  53. '*** Updating Accout's balance in the subsystem:
  54. if IsCredit then
  55. mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance + '"& Amount & "' WHERE (ID='"& Account & "')"
  56. else
  57. mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance - '"& Amount & "' WHERE (ID='"& Account & "')"
  58. end if
  59. conn.Execute(mySQL)
  60. End Sub
  61. %>
  62. <!--#include file="top.asp" -->
  63. <!--#include File="../include_farsiDateHandling.asp"-->
  64. <!--#include File="../include_JS_InputMasks.asp"-->
  65. <style>
  66. Table { font-size: 9pt;}
  67. .InvRowInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; direction:LTR; width:100%;}
  68. .InvHeadInput { font-family:tahoma; font-size: 9pt; border: none; background-color: #CCCC88; text-align:center;}
  69. .InvRowInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: transparent; text-align:right; width:100%;}
  70. .InvRowInput3 { font-family:tahoma; font-size: 9pt; border: 1px solid gray; background-color: #F0F0F0; text-align:right; width:100%;cursor:hand;}
  71. .InvHeadInput2 { font-family:tahoma; font-size: 9pt; border: none; background-color: #AACC77; text-align:center;}
  72. .InvHeadInput3 { font-family:tahoma; font-size: 9pt; border: none; background-color: #F0F0F0; text-align:right; direction: right-to-left;}
  73. .InvGenInput { font-family:tahoma; font-size: 9pt; border: none; }
  74. .InvGenButton { font-family:tahoma; font-size: 9pt; border: 1px solid black; }
  75. .GLInput1 { font-family:tahoma; font-size: 9pt; border: 1px solid black; direction:RTL;}
  76. .GLInput2 { font-family:tahoma; font-size: 9pt; border: 1px solid black; direction:LTR; text-align:right; }
  77. .GLTable1 { border: none; direction:RTL; border:1px dashed red ; width:685;}
  78. .GLTable1 tr {height:20; background-color: #CCCC88; }
  79. .GLTable2 { border: none; direction:RTL;}
  80. .GLTable2 tr {height:20; text-align:center; background-color: #F0F0F0; }
  81. .GLTable2 td {border-bottom: 1px solid black; border-right: 1px solid black;}
  82. .GLTable3 tr {background-color: #F0F0F0}
  83. .CompMemoEdit td {background-color: #CCCCCC; font-size:10pt;}
  84. .GLTable5 { font-family:tahoma; font-size: 10pt; background-color: #66CCCC; border:2 solid #225555; padding:0; }
  85. .GLTable5 TH { background-color: #66BBCC; border: 0; font-size:16pt;border-bottom: 2 solid #225555;}
  86. .GLTable5TR td { background-color: #EEEEEE; border: 0; font-size:10pt;}
  87. .GLTable5TR1 td{ background-color: #99DDDD; border: 0; }
  88. .GLTable5TR2 td{ background-color: #66CCCC; border: 0; }
  89. .GLTR1 { font-family:tahoma; font-size: 9pt; height:30; text-align:center; vertical-align:top; background-color: #C3C300; }
  90. .GLTR2 { height:20; text-align:center; background-color: #C3C300; }
  91. .GLTD1 { font-family:tahoma; font-size: 9pt; height:20; text-align:center; }
  92. </style>
  93. <SCRIPT LANGUAGE="JavaScript">
  94. <!--
  95. var okToProceed=false;
  96. var currentRow=0;
  97. var IsTaraz = false
  98. //-->
  99. </SCRIPT>
  100. <%
  101. ON ERROR RESUME NEXT
  102. DocID= clng(request("DocID"))
  103. if Err.Number<>0 then Err.clear:DocID=0
  104. id= clng(request("id"))
  105. if Err.Number<>0 then Err.clear:id=0
  106. ON ERROR GOTO 0
  107. '-----------------------------------------------------------------------------------------------------
  108. '----------------------------------------------------------------------------- Input a new GL Memo Doc
  109. '-----------------------------------------------------------------------------------------------------
  110. 'xml_GLAccount.asp
  111. if request("act")="" then
  112. if session("IsClosed")="True" then
  113. response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("! .")
  114. end if
  115. %>
  116. <!-- -->
  117. <br>
  118. <input type="hidden" Name='tmpDlgArg' value=''>
  119. <input type="hidden" Name='tmpDlgTxt' value=''>
  120. <BR>
  121. <FORM METHOD=POST ACTION="?act=submitMemo" onsubmit="return checkValidation()">
  122. <table class="GLTable1" align="center" Cellspacing="0" Cellpadding="0">
  123. <tr class="GLTR1" align="center" Cellspacing="1" Cellpadding="0">
  124. <TD colspan="10"><TABLE Border="0" Width="100%" Cellspacing="1" Cellpadding="2" Dir="RTL">
  125. <TR>
  126. <TD align="left"> :</TD>
  127. <TD> <%=OpenGLName%>
  128. </TD>
  129. <TD align="left"> :</TD>
  130. <TD>
  131. <INPUT class="GLInput2" NAME="GLMemoDate" TYPE="text" maxlength="10" size="10" value="<%=shamsiToday()%>" onblur="acceptDate(this)" >
  132. </TD>
  133. <TD align="left"> :</TD>
  134. <TD>
  135. <% mySQL="SELECT ISNULL(MAX(GLDocID),0) AS LastMemo FROM GLDocs WHERE GL='"& OpenGL & "'"
  136. Set RS1=conn.Execute (mySQL)
  137. LastMemo = RS1("LastMemo")
  138. %>
  139. <INPUT class="GLInput2" NAME="GLMemoNo" TYPE="text" maxlength="10" size="10" value="<%=LastMemo+1%>">
  140. </TD>
  141. </TR></TABLE></TD>
  142. </tr>
  143. <tr class="GLTR2">
  144. <TD colspan="10" align=right><div>
  145. <TABLE class="GLTable2" Cellspacing="0" Cellpadding="0" >
  146. <tr>
  147. <td style="width:26; border-right:none;"> # </td>
  148. <td style="width:60;"></td>
  149. <td style="width:40;"></td>
  150. <td style="width:300;"></td>
  151. <td style="width:80;"></td>
  152. <td style="width:80;"></td>
  153. </tr>
  154. </TABLE></div></TD>
  155. </tr>
  156. <tr>
  157. <td colspan="10">
  158. <div style="overflow:auto; height:250px; width:*;">
  159. <TABLE Border="0" Cellspacing="1" Cellpadding="0" Dir="RTL" bgcolor="#558855" class="GLTable3">
  160. <Tbody id="GLrows">
  161. <tr bgcolor='#F0F0F0' onclick="setCurrentRow(this.rowIndex);" >
  162. <td colspan="6">
  163. <INPUT class="InvGenButton" TYPE="button" value="" onkeyDown="if(event.keyCode==9) {setCurrentRow(this.parentNode.parentNode.rowIndex); return false;};" onClick="addRow();">
  164. </td>
  165. </tr>
  166. </Tbody></TABLE>
  167. </div>
  168. </td>
  169. </tr>
  170. <tr bgcolor='#CCCC88'>
  171. <td align=left>
  172. <B><span id="tarazDiv"> </span></B>
  173. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  174. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  175. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  176. : <input type=text name="totalDebit" style="border:none; background:none;" value=0>
  177. &nbsp;&nbsp;&nbsp;
  178. : <input type=text name="totalCredit" style="border:none; background:none;" value=0>
  179. </td>
  180. </tr>
  181. </table>
  182. <br>
  183. <TABLE Border="0" Cellspacing="5" Cellpadding="0" Dir="RTL" align='left'>
  184. <tr>
  185. <td align='center'><INPUT class="InvGenButton" TYPE="submit" name="submit" value=""></td>
  186. <td align='center'><INPUT class="InvGenButton" TYPE="submit" name="submit" value=" " onclick="saveDraft()"> </td>
  187. </tr>
  188. </TABLE>
  189. </FORM>
  190. <%
  191. '-----------------------------------------------------------------------------------------------------
  192. '----------------------------------------------------------------------------- Submit Edit GL Memo Doc
  193. '-----------------------------------------------------------------------------------------------------
  194. elseif request("act")="submitEditMemo" then
  195. if request.form("submit")="" then
  196. response.write "asdfasdf"
  197. response.end
  198. end if
  199. ON ERROR RESUME NEXT
  200. if request.form("submit")="" then
  201. IsTemporary = 0
  202. else
  203. IsTemporary = 1
  204. end if
  205. GLMemoDate= sqlSafe(request.form("GLMemoDate"))
  206. GLMemoNo= clng(request.form("GLMemoNo"))
  207. totalDebit = cdbl(text2value(request.form("totalDebit")))
  208. totalCredit= cdbl(text2value(request.form("totalCredit")))
  209. GLDoc = clng(request.form("GLDoc"))
  210. TotalItemCount = request.form("GLAccounts").count
  211. ReDim Accounts(TotalItemCount)
  212. ReDim GLAccounts(TotalItemCount)
  213. ReDim Descriptions(TotalItemCount)
  214. ReDim Amounts(TotalItemCount)
  215. ReDim IsCredits(TotalItemCount)
  216. ReDim Syss(TotalItemCount)
  217. ReDim Links(TotalItemCount)
  218. ReDim Functions(TotalItemCount)
  219. for i=1 to TotalItemCount
  220. Functions(i) = request.form("Functions")(i)
  221. Accounts(i) = clng(text2value(request.form("Accounts")(i)))
  222. GLAccounts(i) = clng(text2value(request.form("GLAccounts")(i)))
  223. Descriptions(i) = sqlSafe(request.form("Descriptions")(i))
  224. Syss(i) = sqlSafe(request.form("Syss")(i))
  225. Links(i) = sqlSafe(request.form("Links")(i))
  226. credit = cdbl(text2value(request.form("credits")(i)))
  227. debit = cdbl(text2value(request.form("debits")(i)))
  228. if credit <> "" and credit <> "0" then
  229. Amounts(i) = credit
  230. IsCredits(i)= 1
  231. else
  232. Amounts(i) = debit
  233. IsCredits(i)= 0
  234. end if
  235. next
  236. if Err.Number<>0 then
  237. Err.clear
  238. conn.close
  239. response.redirect "top.asp?errMsg=" & Server.URLEncode("!")
  240. end if
  241. ON ERROR GOTO 0
  242. creationDate = shamsiToday()
  243. voidDate = creationDate 'for voided Memos
  244. '---- Checking wether EffectiveDate is valid in current open GL
  245. if (GLMemoDate < session("OpenGLStartDate")) OR (GLMemoDate > session("OpenGLEndDate")) then
  246. Conn.close
  247. response.redirect "?act=editDoc&id="& GLMemoNo & "&errMsg=" & Server.URLEncode("! .")
  248. end if
  249. '----
  250. '----- Check GL is closed
  251. if (session("IsClosed")="True") then
  252. Conn.close
  253. response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("! .")
  254. end if
  255. '----
  256. '---- Marking old GLDoc and its GLRows as DELETED
  257. conn.Execute("UPDATE GLRows SET deleted = 1 WHERE (GLDoc = "& GLDoc & ")")
  258. conn.Execute("UPDATE GLDocs SET deleted = 1 WHERE (ID = "& GLDoc & ")")
  259. '----
  260. '---- Creating a new GLDoc
  261. mySQL="INSERT INTO GLDocs (GL, GLDocID, GLDocDate, CreatedDate, createdBy, IsTemporary, IsCompound) VALUES ("& openGL & " , "& GLMemoNo & ", N'"& GLMemoDate & "' , N'"& creationDate & "', "& session("ID") & ", "& IsTemporary & ",1);SELECT @@Identity AS NewGLDoc"
  262. set RS1 = Conn.execute(mySQL).NextRecordSet
  263. GLDoc = RS1 ("NewGLDoc")
  264. RS1.close
  265. '----
  266. '---- Inserting new GLRows
  267. for i=1 to TotalItemCount
  268. if Functions(i)="V" then
  269. if Accounts(i) <> 0 then
  270. ' Void Sybsystem Memo
  271. '***--- Voiding A*Item of Memo (Very Similar to sub voidMemo in ../AO/MemoVoid.asp ) ---
  272. '*** Type = 3 means the Item is a Memo
  273. '***
  274. sys = Syss(i)
  275. voidedItem = Links(i) '** Links(i) contains A*Item id from GLRows
  276. Account = Accounts(i)
  277. Amount = Amounts(i)
  278. IsCredit = IsCredits(i)
  279. '********* Finding the A*Memo
  280. mySQL="SELECT Link FROM "& sys & "Items WHERE (Type=3) AND (ID='"& voidedItem & "')"
  281. Set RS1=conn.Execute(mySQL)
  282. MemoID=RS1("Link")
  283. '-------------------SAM
  284. 'mySQL = "UPADTE "& sys & "Items SET GL_Update=0 WHERE (Type=3) AND (ID='"& voidedItem & "')"
  285. 'set RS1=conn.Execute(mySQL)
  286. '********* Void the A*Memo
  287. mySQL="UPDATE "& sys & "Memo SET Voided=1, VoidedDate=N'"& voidDate & "', VoidedBy='"& session("ID") & "' WHERE (ID='"& MemoID & "')"
  288. conn.Execute(mySQL)
  289. '********* Finding other Items related to this Item
  290. if isCredit then
  291. mySQL="SELECT ID AS RelationID, Debit"& sys & "Item, Amount FROM "& sys & "ItemsRelations WHERE (Credit"& sys & "Item = '"& voidedItem & "')"
  292. Set RS1=conn.Execute(mySQL)
  293. Do While not (RS1.eof)
  294. '********* Adding back the amount in the relation, to the *DEBIT* Item ...
  295. conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=RemainedAmount+ '"& RS1("Amount") & "', FullyApplied=0 WHERE (ID = '"& RS1("Debit"& sys & "Item") & "')")
  296. '********* Deleting the relation
  297. conn.Execute("DELETE FROM "& sys & "ItemsRelations WHERE ID='"& RS1("RelationID") & "'")
  298. RS1.movenext
  299. Loop
  300. else ' (isCredit==false)
  301. mySQL="SELECT ID AS RelationID, Credit"& sys & "Item, Amount FROM "& sys & "ItemsRelations WHERE (Debit"& sys & "Item = '"& voidedItem & "')"
  302. Set RS1=conn.Execute(mySQL)
  303. Do While not (RS1.eof)
  304. '********* Adding back the amount in the relation, to the *CREDIT* Item ...
  305. conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=RemainedAmount+ '"& RS1("Amount") & "', FullyApplied=0 WHERE (ID = '"& RS1("Credit"& sys & "Item") & "')")
  306. '********* Deleting the relation
  307. conn.Execute("DELETE FROM "& sys & "ItemsRelations WHERE ID='"& RS1("RelationID") & "'")
  308. RS1.movenext
  309. Loop
  310. end if
  311. '********* Voiding A*Item
  312. 'conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=0, FullyApplied=0, Voided=1 WHERE (ID = '"& voidedItem & "')")
  313. ' ------------- SAM ---------
  314. conn.Execute("UPDATE "& sys & "Items SET RemainedAmount=0, FullyApplied=0, Voided=1 WHERE (ID = '"& voidedItem & "')")
  315. conn.Execute("UPDATE "& sys & "Items SET GL_Update=0 WHERE ID="&voidedItem)
  316. '----------------------------
  317. '**************************************************************
  318. '* Affecting Account's A* Balance
  319. '**************************************************************
  320. if isCredit then
  321. mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance - '"& Amount & "' WHERE (ID='"& Account & "')"
  322. else
  323. mySQL="UPDATE Accounts SET "& sys & "Balance = "& sys & "Balance + '"& Amount & "' WHERE (ID='"& Account & "')"
  324. end if
  325. conn.Execute(mySQL)
  326. '***
  327. '***--- End of Voiding A*Item of Memo --------------------------------------------------
  328. end if
  329. else
  330. if Accounts(i) <> 0 and Functions(i)="I" then
  331. ' New Sybsystem Memo
  332. GLAccount = GLAccounts(i)
  333. Account = Accounts(i)
  334. Amount = Amounts(i)
  335. IsCredit = IsCredits(i)
  336. theDescription = Descriptions(i)
  337. Sys = Syss(i)
  338. theItem =Links(i)
  339. ' --------------------------------------------------------------
  340. ' ----- Creating a Memo and an A*Item for this line
  341. ' **************************************************
  342. Call MakeSubsystemItem()
  343. ' **************************************************
  344. ' ------ End of Creating Memo and A*Item for this line
  345. ' --------------------------------------------------------------
  346. Syss(i) = Sys
  347. Links(i) = theItem
  348. end if
  349. Syss(i) = "'" & Syss(i) & "'"
  350. if Accounts(i) = 0 then
  351. Accounts(i) = "NULL"
  352. Syss(i) = "NULL"
  353. Links(i) = "NULL"
  354. end if
  355. mySQL="INSERT INTO GLRows ( GLDoc, GLAccount, Tafsil, Amount, Description, Sys, Link, IsCredit) VALUES ( "&_
  356. GLDoc & ", "& GLAccounts(i) & ", "& Accounts(i) & ", "& Amounts(i) & ", N'"& Descriptions(i) & "', "& Syss(i) & ", "& Links(i) & ", "& IsCredits(i) & ")"
  357. response.write mySQL
  358. 'response.end
  359. conn.Execute(mySQL)
  360. end if
  361. next
  362. '----
  363. response.redirect "GLMemoDocShow.asp?id="& GLDoc & "&msg=" & Server.URLEncode(" .")
  364. '-----------------------------------------------------------------------------------------------------
  365. '------------------------------------------------------------------------------ Submit new GL Memo Doc
  366. '-----------------------------------------------------------------------------------------------------
  367. elseif request("act")="submitMemo" then
  368. GLMemoDate=request.form("GLMemoDate")
  369. GLMemoNo=request.form("GLMemoNo")
  370. totalDebit = text2value(request.form("totalDebit"))
  371. totalCredit = text2value(request.form("totalCredit"))
  372. creationDate = shamsiToday()
  373. if request.form("submit")=" " then
  374. IsTemporary = 0
  375. else
  376. IsTemporary = 1
  377. end if
  378. if GLMemoNo="" or not(isnumeric(GLMemoNo)) then
  379. ShowErrorMessage("! ")
  380. response.end
  381. end if
  382. '---- Checking wether EffectiveDate is valid in current open GL
  383. if (GLMemoDate < session("OpenGLStartDate")) OR (GLMemoDate > session("OpenGLEndDate")) then
  384. Conn.close
  385. response.write "<BR><BR><BR><CENTER>! .</CENTER>"
  386. response.end
  387. end if
  388. '----
  389. '----- Check GL is closed
  390. if (session("IsClosed")="True") then
  391. Conn.close
  392. response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("! .")
  393. end if
  394. '----
  395. WarningMsg=""
  396. Set RS3=Conn.Execute ("SELECT GLDocID FROM GLDocs WHERE (GLDocID='"& GLMemoNo & "') AND (GL='"& OpenGL & "')")
  397. if not RS3.eof then
  398. Set RS3= Conn.Execute("SELECT Max(GLDocID) AS MaxGLDocID FROM GLDocs WHERE (GL='"& OpenGL & "')")
  399. GLMemoNo=RS3("MaxGLDocID")+1
  400. WarningMsg=" .<br> <B>"& GLMemoNo & "</B> ."
  401. end if
  402. RS3.Close
  403. mySQL="INSERT INTO GLDocs (GL, GLDocID, GLDocDate, CreatedDate, createdBy, IsTemporary, IsCompound) VALUES ("& OpenGL & " , "& GLMemoNo & ", N'"& GLMemoDate & "' , N'"& creationDate & "', "& session("id") & ", "& IsTemporary & ", 1);SELECT @@Identity AS NewGLDoc"
  404. set RS1 = Conn.execute(mySQL).NextRecordSet
  405. GLDoc = RS1 ("NewGLDoc")
  406. RS1.close
  407. for i=1 to request.form("Accounts").count
  408. Account = text2value(request.form("Accounts")(i))
  409. GLAccount = text2value(request.form("GLAccounts")(i))
  410. theDescription = request.form("Descriptions")(i)
  411. debit = text2value(request.form("debits")(i))
  412. credit = text2value(request.form("credits")(i))
  413. Sys = "NULL"
  414. theItem ="NULL"
  415. if credit <> "" and credit <> "0" then
  416. Amount = credit
  417. IsCredit = 1
  418. else
  419. Amount = debit
  420. IsCredit = 0
  421. end if
  422. if amount = "" then amount = 0
  423. if Account <> 0 then
  424. ' --------------------------------------------------------------
  425. ' ----- Creating a Memo and an A*Item for this line
  426. ' **************************************************
  427. Call MakeSubsystemItem()
  428. ' **************************************************
  429. ' ------ End of Creating Memo and A*Item for this line
  430. ' --------------------------------------------------------------
  431. sys = "'" & sys & "'"
  432. end if
  433. ' --------------------------------------------------------------
  434. ' ----- Creating the GLRow for this line
  435. if Account=0 then
  436. Account = "NULL"
  437. Sys = "NULL"
  438. theItem ="NULL"
  439. end if
  440. mySQL="INSERT INTO GLRows (GLDoc, Tafsil, GLAccount, Amount, Description, SYS, Link, IsCredit) VALUES ("&_
  441. GLDoc & ", " & Account & ", " & GLAccount & ", " & Amount & ", N'" & theDescription & "', " & sys & ", " & theItem & ", " & IsCredit & ")"
  442. Conn.Execute(mySQL)
  443. ' **************************************************
  444. ' ----- End of Creating the GLRow for this line
  445. ' --------------------------------------------------------------
  446. next
  447. conn.close
  448. response.redirect "GLMemoDocShow.asp?id="& GLDoc &"&msg="& Server.URLEncode(" .") &"&errmsg="& Server.URLEncode(WarningMsg)
  449. '-----------------------------------------------------------------------------------------------------
  450. '---------------------------------------------------------------------------------- Edit a Compund Doc
  451. '-----------------------------------------------------------------------------------------------------
  452. elseif request("act")="editDoc" then
  453. mySQL="SELECT GLDocs.*, GLRows.GLAccount, GLRows.Tafsil, GLRows.Amount, GLRows.Description, GLRows.SYS, GLRows.Link, GLRows.IsCredit, GLAccounts.Name FROM GLDocs INNER JOIN GLRows ON GLDocs.ID = GLRows.GLDoc INNER JOIN GLAccounts ON GLRows.GLAccount = GLAccounts.ID WHERE (GLDocs.Deleted = 0) AND (GLDocs.GLDocID="& id & ") AND (GLDocs.isCompound=1) AND (GLDocs.GL = "& OpenGL & ") AND (GLAccounts.GL = "& OpenGL & ") ORDER BY GLRows.ID"
  454. set RS1=conn.execute(mySQL)
  455. if RS1.eof then
  456. response.write "<BR><BR><BR><CENTER>! </CENTER>"
  457. response.end
  458. end if
  459. GLDocID = RS1("GLDocID")
  460. Creator = RS1("CreatedBy")
  461. classType=1
  462. if RS1("IsRemoved") OR RS1("deleted") then
  463. response.write "<BR><BR><BR><CENTER>! .</CENTER>"
  464. response.end
  465. elseif RS1("BySubSystem") then
  466. response.write "<BR><BR><BR><CENTER>! .</CENTER>"
  467. response.end
  468. elseif RS1("IsFinalized") then
  469. response.write "<BR><BR><BR><CENTER>! .</CENTER>"
  470. response.end
  471. elseif RS1("IsChecked") then
  472. response.write "<BR><BR><BR><CENTER>! .</CENTER>"
  473. response.end
  474. elseif RS1("IsTemporary") then
  475. if Not (session("ID") = Creator OR Auth( 8 , 7 ) )then
  476. ShowErrorMessage(" .")
  477. conn.close
  478. response.end
  479. end if
  480. statusString = " "
  481. status = "Temporary"
  482. classType=1
  483. else
  484. if Not (session("ID") = Creator OR Auth( 8 , 8 ) )then
  485. ShowErrorMessage(" .")
  486. conn.close
  487. response.end
  488. end if
  489. statusString = " "
  490. status = "Draft"
  491. classType=3
  492. end if
  493. '----- Check GL is closed
  494. if (session("IsClosed")="True") then
  495. Conn.close
  496. response.redirect "AccountInfo.asp?errMsg=" & Server.URLEncode("! .")
  497. end if
  498. '----
  499. isBySubSystem = false
  500. if RS1("BySubSystem") then
  501. isBySubSystem = true
  502. if RS1("IsRemoved") then
  503. classType=2
  504. else
  505. classType=4
  506. end if
  507. end if
  508. isCompound = false
  509. if RS1("IsCompound") then
  510. isCompound = true
  511. if RS1("IsRemoved") then
  512. classType=2
  513. else
  514. classType=5
  515. end if
  516. end if
  517. %>
  518. <input type="hidden" Name='tmpDlgArg' value=''>
  519. <input type="hidden" Name='tmpDlgTxt' value=''>
  520. <FORM METHOD=POST ACTION="?act=submitEditMemo" onsubmit="return checkValidation()">
  521. <table border="0" cellpadding="0" cellspacing="0" align="center">
  522. <tr height="20">
  523. <td colspan=2></td>
  524. </tr>
  525. <tr height="10">
  526. <td width="250"></td>
  527. <td valign="top"><div style='position:absolute;'><%=stamp%></div></td>
  528. </tr>
  529. <tr height="20">
  530. <td colspan=2></td>
  531. </tr>
  532. </table>
  533. <table id="MemoTable" Border="0" align=center Cellspacing="1" Cellpadding="5" Dir="RTL" class="GLTable5">
  534. <tr>
  535. <th colspan=7>
  536. <%=RS1("GLDocID")%> <INPUT TYPE='hidden' name='GLMemoNo' value='<%= RS1("GLDocID")%>'>
  537. </th>
  538. </tr>
  539. <tr>
  540. <th colspan=7 style="padding:0">
  541. <TABLE width="100%" border=0 Cellspacing="1" Cellpadding="10" Dir="RTL">
  542. <TR class="GLTable5TR2">
  543. <TD> : <%= RS1("id")%><INPUT TYPE='hidden' name='GLDoc' value='<%= RS1("ID")%>'></TD>
  544. <TD align=center>: <%=statusString%></TD>
  545. <TD align=left> : <span dir=ltr><%= RS1("GLDocDate")%><INPUT TYPE='hidden' name='GLMemoDate' value='<%= RS1("GLDocDate")%>'></span></TD>
  546. </TR>
  547. </TABLE>
  548. </th>
  549. </tr>
  550. <tr class="GLTable5TR1">
  551. <td style="width:20;">
  552. <div id="mnuDivHome" style="width:100%;height:100%;position:relative;cursor:hand;">
  553. <div id="mnuDiv" style = 'position:absolute;top:-4;left:-3; width:100; height:20; background-color:#DDDDDD; border: 1px solid red; visibility:hidden;' onmouseout="hideMenu();" onmouseover="keepMenu();">
  554. <IMG SRC='../images/s_undo.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT='' onclick="undoRow();" onmouseover="keepMenu();">
  555. <IMG SRC='../images/s_delete.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT=' ' onclick="voidRow();" onmouseover="keepMenu();">
  556. <IMG SRC='../images/s_insert.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT=' ' onclick="insertRow();" onmouseover="keepMenu();">
  557. <IMG SRC='../images/s_edit.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT=' ' onclick="editRow();" onmouseover="keepMenu();">
  558. </div>
  559. </div>
  560. </td>
  561. <td style="width:20;"> # </td>
  562. <td style="width:50;"></td>
  563. <td style="width:45;"></td>
  564. <td style="width:300;"></td>
  565. <td style="width:80;"></td>
  566. <td style="width:80;"></td>
  567. </tr>
  568. <%
  569. i=0
  570. Do while not RS1.eof
  571. i = i + 1
  572. GLAccount = RS1("GLAccount")
  573. accTitle = RS1("name")
  574. theDescription = RS1("Description")
  575. Amount = Separate(RS1("Amount"))
  576. IsCredit = RS1("IsCredit")
  577. Tafsil = RS1("Tafsil")
  578. Sys = RS1("Sys")
  579. ItemLink = RS1("Link")
  580. if len(sys)>1 then 'if isBySubSystem then
  581. theLink = "ShowItem.asp?sys=" & sys & "&Item=" & ItemLink
  582. else
  583. theLink = "about:blank"
  584. end if
  585. credit = ""
  586. debit = ""
  587. if IsCredit then
  588. credit = Amount
  589. totalCredit = totalCredit + cdbl(Amount)
  590. else
  591. debit = Amount
  592. totalDebit = totalDebit + cdbl(Amount)
  593. end if
  594. %>
  595. <tr class="GLTable5TR">
  596. <td ><div align=center style="width:100%;height:100%;position:relative;cursor:hand;" onmouseover="showMenu(this);">[+]</div></td>
  597. <td > <%=i%>
  598. <INPUT TYPE='hidden' name='functions' value=''>
  599. <INPUT TYPE='hidden' name='Syss' value='<%=Sys%>'>
  600. <INPUT TYPE='hidden' name='Links' value='<%=ItemLink%>'>
  601. </td>
  602. <!---------------------SAM----------------->
  603. <td dir=ltr><INPUT class='InvRowInput2' TYPE='text' readonly NAME='Accounts' value='<%=Tafsil%>' style='width:50;' ></td>
  604. <td dir=ltr><INPUT class='InvRowInput2' TYPE='text' readonly NAME='GLAccounts' value='<%=GLAccount%>' style='width:45;' ></td>
  605. <td dir=rtl><INPUT class='InvRowInput2' TYPE='text' readonly NAME='Descriptions' value='<%=theDescription%>' style='width:300;' ></td>
  606. <td dir=ltr><INPUT class='InvRowInput2' TYPE='text' readonly NAME='debits' value='<%=debit%>' style='width:80;' ></td>
  607. <td dir=ltr><INPUT class='InvRowInput2' TYPE='text' readonly NAME='credits' value='<%=credit%>' style='width:80;' ></td>
  608. </tr>
  609. <%
  610. RS1.movenext
  611. loop
  612. %>
  613. <tr class="GLTable5TR1">
  614. <td style="width:20;" ><div align=center style="width:100%;height:100%;position:relative;cursor:hand;" onmouseover="showMenu(this);">[+]</div></td>
  615. <td></td>
  616. <td></td>
  617. <td></td>
  618. <td><DIV style="float:right;font-weight:bold;"><span id="tarazDiv"> </span></DIV><div style="float:left;"></div></td>
  619. <td><input type="text" name="totalDebit" style="border:none; background:none; width:100%;" value="<%=Separate(totalDebit)%>"></td>
  620. <td><input type="text" name="totalCredit" style="border:none; background:none;width:100%;" value="<%=Separate(totalCredit)%>"></td>
  621. </tr>
  622. </TABLE>
  623. <TABLE Border="0" Cellspacing="5" Cellpadding="0" Dir="RTL" align='left'>
  624. <tr>
  625. <td align='center'><INPUT class="InvGenButton" TYPE="submit" name="submit" value=""></td>
  626. <!--td align='center'><INPUT class="InvGenButton" TYPE="submit" name="submit" value="" style="border-color:red;" onclick="return confirm(' Ͽ')"> </td-->
  627. <td align='center'><INPUT class="InvGenButton" TYPE="button" value="" onclick="history.back()"></td>
  628. </tr>
  629. </TABLE>
  630. </FORM>
  631. <SCRIPT LANGUAGE="JavaScript">
  632. <!--
  633. var mnuCountr=0;
  634. var mnuDiv = document.getElementById("mnuDiv");
  635. function showMenu(src){
  636. if (! src.getElementsByTagName('DIV')[0]){
  637. mnuCountr+=2;
  638. mnuDiv.style.visibility="visible";
  639. src.appendChild(mnuDiv);
  640. }
  641. }
  642. function keepMenu(){
  643. //alert('keep');
  644. if (mnuCountr<4)
  645. mnuCountr+=2;
  646. }
  647. function hideMenu(){
  648. if (mnuCountr>0){
  649. mnuCountr-=1;
  650. setTimeout('hideMenu()',2000);
  651. return;
  652. }
  653. mnuCountr=0;
  654. mnuDiv.style.visibility='hidden';
  655. document.getElementById("mnuDivHome").appendChild(mnuDiv);
  656. }
  657. function insertRow(){
  658. theRow = mnuDiv.parentNode.parentNode.parentNode
  659. mnuCountr=0;
  660. hideMenu();
  661. newRow=document.createElement("tr");
  662. tempTD=document.createElement("td");
  663. tempTD.innerHTML="<div align=center style='width:100%;height:100%;position:relative;cursor:hand;' onmouseover='showMenu(this);'><IMG SRC='../images/s_insert.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT=' ' ></div>"
  664. newRow.appendChild(tempTD);
  665. tempTD=document.createElement("td");
  666. tempTD.innerHTML="<INPUT TYPE='hidden' name='functions' value='I'><INPUT TYPE='hidden' name='Syss' value=''><INPUT TYPE='hidden' name='Links' value=''>";
  667. newRow.appendChild(tempTD);
  668. tempTD=document.createElement("td");
  669. tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='Accounts' maxlength=6 onKeyPress='return mask(this);' onBlur='check(this);' >"
  670. newRow.appendChild(tempTD);
  671. tempTD=document.createElement("td");
  672. tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='GLAccounts' maxlength=5 onKeyPress='return mask(this);' onBlur='check(this);' >"
  673. newRow.appendChild(tempTD);
  674. tempTD=document.createElement("td");
  675. tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='Descriptions'>"
  676. newRow.appendChild(tempTD);
  677. tempTD=document.createElement("td");
  678. tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='debits' onblur='setPrice(this)' onKeyPress='return onlyNumber(this);' onfocus='this.value=txt2val(this.value);this.select()' >"
  679. newRow.appendChild(tempTD);
  680. tempTD=document.createElement("td");
  681. tempTD.innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='credits' onblur='setPrice(this)' onKeyPress='return onlyNumber(this);' onfocus='this.value=txt2val(this.value);this.select()' >"
  682. newRow.appendChild(tempTD);
  683. newRow.className="CompMemoEdit";
  684. theRow.parentNode.insertBefore(newRow,theRow)
  685. newRow.getElementsByTagName('TD')[2].getElementsByTagName('INPUT')[0].focus();
  686. }
  687. function undoRow(){
  688. theRow = mnuDiv.parentNode.parentNode.parentNode
  689. tds = theRow.getElementsByTagName('TD')
  690. mnuCountr=0;
  691. hideMenu();
  692. func = tds[1].getElementsByTagName('INPUT')[0];
  693. if (!func ){
  694. return;
  695. }
  696. else if (func.value=='I'){
  697. removeRow(theRow);
  698. memoIsTaraz();
  699. return;
  700. }
  701. else if (func.value!='E' && func.value!='V' ){
  702. alert(' .')
  703. return;
  704. }
  705. theRow.className="GLTable5TR";
  706. tds[0].getElementsByTagName('DIV')[0].innerHTML="[+]";
  707. func.value='';
  708. if(tds[1].getElementsByTagName('DIV')[0])
  709. tds[1].removeChild(tds[1].getElementsByTagName('DIV')[0]);
  710. tds[2].innerHTML="<INPUT class='InvRowInput2' TYPE='text' readonly NAME='Accounts' value='" + tds[2].getElementsByTagName('INPUT')[0].defaultValue + "' >"
  711. tds[3].innerHTML="<INPUT class='InvRowInput2' TYPE='text' readonly NAME='GLAccounts' value='" + tds[3].getElementsByTagName('INPUT')[0].defaultValue + "' >"
  712. tds[4].innerHTML="<INPUT class='InvRowInput2' TYPE='text' readonly NAME='Descriptions' value='" + tds[4].getElementsByTagName('INPUT')[0].defaultValue + "' >"
  713. tds[5].innerHTML= "<INPUT class='InvRowInput2' TYPE='text' readonly NAME='debits' value='" + tds[5].innerText + tds[5].getElementsByTagName('INPUT')[0].defaultValue + "' >"
  714. tds[6].innerHTML="<INPUT class='InvRowInput2' TYPE='text' readonly NAME='credits' value='" + tds[6].innerText + tds[6].getElementsByTagName('INPUT')[0].defaultValue + "' >"
  715. memoIsTaraz();
  716. }
  717. function editRow(){
  718. theRow = mnuDiv.parentNode.parentNode.parentNode
  719. tds = theRow.getElementsByTagName('TD')
  720. mnuCountr=0;
  721. hideMenu();
  722. func = tds[1].getElementsByTagName('INPUT')[0];
  723. if (!func || tds[2].getElementsByTagName('INPUT')[0].value){
  724. alert(' .')
  725. return;
  726. }
  727. theRow.className="CompMemoEdit";
  728. tds[0].getElementsByTagName('DIV')[0].innerHTML="<IMG SRC='../images/s_edit.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT=' ' >";
  729. tds[1].getElementsByTagName('INPUT')[0].value='E';
  730. tds[3].innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='GLAccounts' maxlength=5 style='width:45;border:1px solid gray;cursor:hand;' onKeyPress='return mask(this);' onBlur='check(this);' Value='" + tds[3].getElementsByTagName('INPUT')[0].value + "'>"
  731. tds[4].innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='Descriptions' maxlength=250 style='100%;border:1px solid gray;' Value='" + tds[4].getElementsByTagName('INPUT')[0].value + "'>"
  732. tds[5].innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='debits' style='border:1px solid gray;' onblur='setPrice(this)' onKeyPress='return onlyNumber(this);' onfocus='this.value=txt2val(this.value);this.select()' Value='" + tds[5].getElementsByTagName('INPUT')[0].value + "' >"
  733. tds[6].innerHTML="<INPUT class='InvRowInput3' TYPE='text' NAME='credits' style='border:1px solid gray;' onblur='setPrice(this)' onKeyPress='return onlyNumber(this);' onfocus='this.value=txt2val(this.value);this.select()' Value='" + tds[6].getElementsByTagName('INPUT')[0].value + "' >"
  734. tds[3].getElementsByTagName('INPUT')[0].focus();
  735. }
  736. function removeRow(theRow){
  737. //theRow = mnuDiv.parentNode.parentNode.parentNode
  738. tds = theRow.getElementsByTagName('TD')
  739. //mnuCountr=0;
  740. //hideMenu();
  741. func = tds[1].getElementsByTagName('INPUT')[0];
  742. if (!func ){
  743. alert(' .')
  744. return;
  745. }
  746. else if (func.value=='E' || func.value==''){
  747. alert(' .')
  748. return;
  749. }
  750. theRow.parentNode.removeChild(theRow);
  751. }
  752. function voidRow(){
  753. theRow = mnuDiv.parentNode.parentNode.parentNode
  754. tds = theRow.getElementsByTagName('TD')
  755. mnuCountr=0;
  756. hideMenu();
  757. func = tds[1].getElementsByTagName('INPUT')[0];
  758. if (!func || func.value!=''){
  759. alert(' .')
  760. return;
  761. }
  762. theRow.className="CompMemoEdit";
  763. tds[0].getElementsByTagName('DIV')[0].innerHTML="<IMG SRC='../images/s_delete.gif' WIDTH='20' HEIGHT='20' BORDER='0' ALT=' ' >";
  764. func.value="V"
  765. tds[1].innerHTML+="<div style='position:relative;'><div style='position:absolute;left:-610;top:-15;width:610;'><hr style='color:red;'></div></div>";
  766. tds[5].innerHTML = tds[5].getElementsByTagName('INPUT')[0].value + "<INPUT TYPE='hidden' name='debits' Value='"+tds[5].getElementsByTagName('INPUT')[0].value+"'>"
  767. tds[6].innerHTML = tds[6].getElementsByTagName('INPUT')[0].value + "<INPUT TYPE='hidden' name='credits' Value='"+tds[6].getElementsByTagName('INPUT')[0].value+"'>"
  768. memoIsTaraz()
  769. }
  770. //-->
  771. </SCRIPT>
  772. <%
  773. end if
  774. '-----------------------------------------------------------------------------------------------------
  775. '-----------------------------------------------------------------------------------------------------
  776. '-----------------------------------------------------------------------------------------------------
  777. conn.Close
  778. %>
  779. </font>
  780. <% if request("act")="" OR request("act")="editDoc" then%>
  781. <script language="JavaScript">
  782. <!--
  783. function setCurrentRow(rowNo){
  784. if (rowNo == -1) rowNo=0;
  785. invTable=document.getElementById("GLrows");
  786. theTD=invTable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[0];
  787. theTD.setAttribute("bgColor", '#F0F0F0');
  788. currentRow=rowNo;
  789. invTable=document.getElementById("GLrows");
  790. theTD=invTable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[0];
  791. theTD.setAttribute("bgColor", '#FFB0B0');
  792. }
  793. function delRow(rowNo){
  794. invTable=document.getElementById("GLrows");
  795. theRow=invTable.getElementsByTagName("tr")[rowNo];
  796. invTable.removeChild(theRow);
  797. rowsCount=document.getElementsByName("Accounts").length;
  798. for (rowNo=0; rowNo < rowsCount ; rowNo++){
  799. tempTD=invTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0]
  800. tempTD.bgColor= '#F0F0F0';
  801. tempTD.innerText= rowNo+1;
  802. }
  803. }
  804. function addRow(){
  805. rowNo = currentRow
  806. invTable=document.getElementById("GLrows");
  807. theRow=invTable.getElementsByTagName("tr")[rowNo];
  808. newRow=document.createElement("tr");
  809. newRow.setAttribute("bgColor", '#f0f0f0');
  810. newRow.setAttribute("onclick", theRow.getAttribute("onclick"));
  811. tempTD=document.createElement("td");
  812. tempTD.innerHTML=rowNo+1
  813. tempTD.setAttribute("align", 'center');
  814. tempTD.setAttribute("width", '26');
  815. newRow.appendChild(tempTD);
  816. tempTD=document.createElement("td");
  817. tempTD.setAttribute("dir", 'LTR');
  818. tempTD.setAttribute("width", '60');
  819. tempTD.innerHTML="<INPUT class='InvRowInput' TYPE='text' NAME='Accounts' maxlength=6 onKeyPress='return mask(this);' onBlur='check(this);' style='width:100%;' >"
  820. newRow.appendChild(tempTD);
  821. tempTD=document.createElement("td");
  822. tempTD.setAttribute("width", '40');
  823. tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='GLAccounts' maxlength=5 onKeyPress='return mask(this);' onBlur='check(this);' style='width:100%;' >"
  824. newRow.appendChild(tempTD);
  825. tempTD=document.createElement("td");
  826. tempTD.setAttribute("width", '300');
  827. tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='Descriptions' style='width:100%;'>"
  828. newRow.appendChild(tempTD);
  829. tempTD=document.createElement("td");
  830. tempTD.setAttribute("dir", 'LTR');
  831. tempTD.setAttribute("width", '80');
  832. tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='debits' style='width:100%;' onblur='setPrice(this)' onKeyPress='return onlyNumber(this);' onfocus='this.value=txt2val(this.value);this.select()'>"
  833. newRow.appendChild(tempTD);
  834. tempTD=document.createElement("td");
  835. tempTD.setAttribute("dir", 'LTR');
  836. tempTD.setAttribute("width", '80');
  837. tempTD.innerHTML="<INPUT class='InvRowInput2' TYPE='text' NAME='credits' style='width:100%;' onblur='setPrice(this)' onKeyPress='return onlyNumber(this);' onfocus='setCurrentRow(this.parentNode.parentNode.rowIndex);this.value=txt2val(this.value);this.select()'>"
  838. newRow.appendChild(tempTD);
  839. invTable.insertBefore(newRow,theRow);
  840. rowsCount=document.getElementsByName("Accounts").length;
  841. for (rowNo=0; rowNo < rowsCount ; rowNo++){
  842. tempTD=invTable.getElementsByTagName("tr")[rowNo].getElementsByTagName("td")[0]
  843. tempTD.bgColor= '#F0F0F0';
  844. tempTD.innerText= rowNo+1;
  845. }
  846. invTable.getElementsByTagName("tr")[currentRow].getElementsByTagName("td")[1].getElementsByTagName("Input")[0].focus();
  847. // document.all.dddd2.innerText=invTable.innerHTML
  848. }
  849. function saveDraft(){
  850. if (document.all.totalDebit.value != 0 || document.all.totalCredit.value != 0)
  851. IsTaraz = true
  852. }
  853. function checkValidation(){
  854. memoIsTaraz()
  855. if (IsTaraz==true)
  856. return true
  857. else{
  858. alert("! ")
  859. return false
  860. }
  861. }
  862. var dialogActive=false;
  863. function mask(src){
  864. var theKey=event.keyCode;
  865. if (src.name=="Accounts"){
  866. if (theKey==32){
  867. event.keyCode=0;
  868. dialogActive=true;
  869. document.all.tmpDlgArg.value="#"
  870. document.all.tmpDlgTxt.value=" :"
  871. var myTinyWindow = window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
  872. dialogActive=false;
  873. if (document.all.tmpDlgTxt.value !="") {
  874. var myTinyWindow = window.showModalDialog('../ar/dialog_selectAccount.asp?act=select&search='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:300px; dialogWidth:600px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
  875. if (document.all.tmpDlgArg.value!="#"){
  876. Arguments=document.all.tmpDlgArg.value.split("#")
  877. src.value=Arguments[0];
  878. src.title=Arguments[1];
  879. }
  880. }
  881. // src.parentNode.nextSibling.getElementsByTagName("INPUT")[0].focus();
  882. }
  883. else if (theKey >= 48 && theKey <= 57 )
  884. return true;
  885. else
  886. return false;
  887. }
  888. else if (src.name=="GLAccounts"){
  889. if (theKey==32){
  890. event.keyCode=0;
  891. dialogActive=true;
  892. document.all.tmpDlgArg.value="#"
  893. document.all.tmpDlgTxt.value=" :"
  894. var myTinyWindow = window.showModalDialog('../dialog_GenInput.asp',document.all.tmpDlgTxt,'dialogHeight:200px; dialogWidth:440px; dialogTop:; dialogLeft:; edge:None; center:Yes; help:No; resizable:No; status:No;');
  895. dialogActive=false;
  896. if (document.all.tmpDlgTxt.value !="") {
  897. var myTinyWindow = window.showModalDialog('dialog_selectGL.asp?act=select&name='+escape(document.all.tmpDlgTxt.value),document.all.tmpDlgArg,'dialogHeight:500px; dialogWidth:380px; dialogTop:; dialogLeft:; edge:Raised; center:Yes; help:No; resizable:Yes; status:No;');
  898. if (document.all.tmpDlgArg.value!="#"){
  899. Arguments=document.all.tmpDlgArg.value.split("#")
  900. src.value=Arguments[0];
  901. src.title=Arguments[1];
  902. }
  903. }
  904. // src.parentNode.nextSibling.getElementsByTagName("INPUT")[0].focus();
  905. }
  906. else if (theKey >= 48 && theKey <= 57 ) // [0]-[9] are acceptible
  907. return true;
  908. else
  909. return false;
  910. }
  911. else if (src.name=="debits" || src.name=="credits" || src.name=="Refs1"){
  912. if (theKey < 48 || theKey > 57) { // [0]-[9] are acceptible
  913. return false;
  914. }
  915. return true;
  916. }
  917. else if (src.name=="Descriptions" || src.name=="Refs2"){
  918. if (theKey==13){ // [Enter]
  919. return false;
  920. }
  921. return true;
  922. }
  923. }
  924. function onlyNumber(src){
  925. var theKey=event.keyCode;
  926. if (theKey==13){ // [Enter]
  927. return true;
  928. }
  929. else if (theKey < 48 || theKey > 57) { // 0-9 are acceptible
  930. return false;
  931. }
  932. }
  933. function areYouSureToExit()
  934. {
  935. a= confirm("are you sure?")
  936. return a
  937. }
  938. function setPrice(src){
  939. src.value=val2txt(txt2val(src.value));
  940. //rowNo=src.parentNode.parentNode.rowIndex;
  941. if (src.name=="credits" && src.value!=0)
  942. src.parentNode.previousSibling.getElementsByTagName('INPUT')[0].value = ""
  943. if (src.name=="debits" && src.value!=0)
  944. src.parentNode.nextSibling.getElementsByTagName('INPUT')[0].value = ""
  945. if (src.value ==0) src.value=""
  946. if (src.value ==" ") src.value=""
  947. memoIsTaraz();
  948. }
  949. function check(src){
  950. if (src.name=="Accounts"){
  951. if (!dialogActive){
  952. if (window.XMLHttpRequest) {
  953. var objHTTP=new XMLHttpRequest();
  954. } else if (window.ActiveXObject) {
  955. var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
  956. }
  957. objHTTP.open('GET','xml_CustomerAccount.asp?id='+src.value,false)
  958. objHTTP.send()
  959. tmpStr = unescape( objHTTP.responseText)
  960. src.title=tmpStr;
  961. if (tmpStr==" "){
  962. src.value="";
  963. }
  964. }
  965. }
  966. else if(src.name=="GLAccounts"){
  967. if (!dialogActive){
  968. if (window.XMLHttpRequest) {
  969. var objHTTP=new XMLHttpRequest();
  970. } else if (window.ActiveXObject) {
  971. var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
  972. }
  973. objHTTP.open('GET','xml_GLAccount.asp?id='+src.value,false)
  974. objHTTP.send()
  975. tmpStr = unescape( objHTTP.responseText)
  976. src.title=tmpStr;
  977. if (tmpStr==" "){
  978. src.value="";
  979. }
  980. }
  981. }
  982. else if(src.name=="debits" || src.name=="credits"){
  983. src.value=val2txt(txt2val(src.value));
  984. if (''+src.value=="NaN" || src.value=="0") src.value = ""
  985. //rowNo=src.parentNode.parentNode.rowIndex;
  986. if (src.value!=""){
  987. if (src.name=="credits")
  988. src.parentNode.previousSibling.getElementsByTagName('INPUT')[0].value = ""
  989. else
  990. src.parentNode.nextSibling.getElementsByTagName('INPUT')[0].value = ""
  991. }
  992. memoIsTaraz();
  993. }
  994. }
  995. function memoIsTaraz(){
  996. var totalCredit = 0;
  997. var totalDebit = 0;
  998. rowsCnt=document.getElementsByName("debits").length
  999. for (rowNo=0; rowNo < rowsCnt; rowNo++){
  1000. if (document.getElementsByName("credits")[rowNo].type!='hidden')
  1001. totalCredit += parseInt(txt2val(document.getElementsByName("credits")[rowNo].value));
  1002. if (document.getElementsByName("debits")[rowNo].type!='hidden')
  1003. totalDebit += parseInt(txt2val(document.getElementsByName("debits")[rowNo].value));
  1004. }
  1005. document.all.totalCredit.value = val2txt(totalCredit);
  1006. document.all.totalDebit.value = val2txt(totalDebit);
  1007. if (totalDebit == totalCredit && totalCredit != 0){
  1008. IsTaraz = true
  1009. document.all.tarazDiv.innerHTML = "<FONT COLOR='#008833'> </FONT>"
  1010. }
  1011. else{
  1012. IsTaraz = false
  1013. document.all.tarazDiv.innerHTML = "<FONT COLOR='#FF3300'> </FONT>"
  1014. }
  1015. }
  1016. setPrice(document.all.totalDebit)
  1017. setPrice(document.all.totalCredit)
  1018. if (parseInt(document.all.totalDebit.value)==0) IsTaraz=false;
  1019. //-->
  1020. </SCRIPT>
  1021. <%end if%>
  1022. <!--#include file="tah.asp" -->