/beta/accounting/manageGL.asp

http://github.com/khaneh/Orders · ASP · 344 lines · 234 code · 42 blank · 68 comment · 21 complexity · 2b6bad8b01939a114cbde2eace21cdef MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. 'Accounting (8)
  3. PageTitle= " "
  4. SubmenuItem=4
  5. if not Auth(8 , 4) then NotAllowdToViewThisPage()
  6. %>
  7. <!--#include file="top.asp" -->
  8. <!--#include File="../include_farsiDateHandling.asp"-->
  9. <!--#include File="../include_JS_InputMasks.asp"-->
  10. <%
  11. '-----------------------------------------------------------------------------------------------------
  12. '---------------------------------------------------------------------------- Submit Change Default GL
  13. '-----------------------------------------------------------------------------------------------------
  14. if request("act")="change" then
  15. newOpenGL=request("OpenGL")
  16. forWhom=request("forWhom")
  17. if forWhom = 0 then
  18. conn.Execute("UPDATE GLs SET IsDefault = 0")
  19. conn.Execute("UPDATE GLs SET IsDefault = 1 , LastChangedBy="& session("ID")& " , LastChangedDate=N'"& shamsiToday() & "', LastChange=N'set to default' WHERE (ID = "& newOpenGL & ")")
  20. 'Changed 13282/01/09 for using UserDefaults table instead
  21. 'Set RS2 = conn.Execute("SELECT FiscalYear, name, ID FROM GLs WHERE (IsDefault = 1) ORDER BY ID DESC")
  22. mySQL="UPDATE UserDefaults SET WorkingGL='"& newOpenGL & "' WHERE ([User]=0)"
  23. conn.Execute(mySQL)
  24. responseRedirectAddress = "AccountInfo.asp?msg=" & Server.URLEncode(" .")
  25. else
  26. Set RS2 = conn.Execute("SELECT [User] as ID, WorkingGL FROM UserDefaults WHERE ([User] = "& forWhom & ") OR (UserDefaults.[User] = 0) ORDER BY ABS(UserDefaults.[User]) DESC")
  27. if RS2("id")="0" then
  28. mySQL="INSERT INTO UserDefaults ([User], WorkingGL) VALUES ("& forWhom & ","& newOpenGL & ")"
  29. conn.Execute(mySQL)
  30. else
  31. mySQL="UPDATE UserDefaults SET WorkingGL='"& newOpenGL & "' WHERE ([User]="& forWhom & ")"
  32. conn.Execute(mySQL)
  33. end if
  34. responseRedirectAddress = "GLMemoDocShow.asp?msg=" & Server.URLEncode(" "& session("CSRName") & " ")
  35. end if
  36. Set RS2 = conn.Execute("SELECT GLs.EndDate, GLs.StartDate, GLs.Name, GLs.ID, GLs.FiscalYear, UserDefaults.[User], GLs.IsClosed, GLs.Vat FROM GLs INNER JOIN UserDefaults ON GLs.ID = UserDefaults.WorkingGL WHERE (UserDefaults.[User] = '"& session("id") & "') OR (UserDefaults.[User] = 0) ORDER BY ABS(UserDefaults.[User]) DESC")
  37. session("OpenGL")=RS2("id")
  38. session("FiscalYear")=RS2("FiscalYear")
  39. session("OpenGLName")=RS2("name")
  40. session("OpenGLStartDate")=RS2("StartDate")
  41. session("OpenGLEndDate")=RS2("EndDate")
  42. session("IsClosed")=RS2("IsClosed")
  43. session("VatRate")=RS2("Vat")
  44. RS2.movenext
  45. session("differentGL") = False
  46. if not RS2.EOF then
  47. temp=RS2("id")
  48. if temp <> session("OpenGL") then
  49. session("differentGL") = True
  50. end if
  51. end if
  52. RS2.close
  53. response.redirect responseRedirectAddress
  54. '-----------------------------------------------------------------------------------------------------
  55. '-------------------------------------------------------------------------------- Submit Create New GL
  56. '-----------------------------------------------------------------------------------------------------
  57. elseif request("act")="submitNew" then
  58. name=request.form("name")
  59. FiscalYear=request.form("FiscalYear")
  60. copy = request.form("copy")
  61. OpenGL = request.form("OpenGL")
  62. CurrentDate = shamsiToday()
  63. tempStartDate=left(CurrentDate,4)&"/01/01"
  64. tempEndDate=left(CurrentDate,4)&"/12/30"
  65. conn.Execute("INSERT INTO GLs (Name, FiscalYear, StartDate, EndDate, IsDefault, IsClosed, LastChangedBy, LastChangedDate, LastChange) VALUES ( N'"& name & "', N'"& FiscalYear & "', N'"& tempStartDate & "', N'"& tempEndDate & "', 0, 0, "& session("id") & ", N'"& CurrentDate & "', N'Created')")
  66. if copy="on" then
  67. Set RS2 = conn.Execute("SELECT * from GLs where FiscalYear="& FiscalYear & " order by id DESC")
  68. GLID=RS2("id")
  69. conn.Execute("INSERT INTO GLAccountSuperGroups SELECT ID, Name, "& GLID & " AS GL, Type FROM GLAccountSuperGroups WHERE (GL = "& OpenGL & ")")
  70. conn.Execute("INSERT INTO GLAccountGroups SELECT ID, GLSuperGroup, Name, "& GLID & " AS GL FROM GLAccountGroups WHERE (GL = "& OpenGL & ")")
  71. conn.Execute("INSERT INTO GLAccounts SELECT ID, GLGroup, Name, "& GLID & " AS GL,HasAppendix FROM GLAccounts WHERE (GL = "& OpenGL & ")")
  72. end if
  73. response.write "<BR><BR><BR><CENTER><H2> </H2></CENTER>"
  74. '"INSERT INTO GLAccounts SELECT ID, GLGroup, Name, 3 AS GL FROM GLAccounts WHERE (GL = 1)"
  75. '-----------------------------------------------------------------------------------------------------
  76. '------------------------------------------------------------------------------- Close an open GL Form
  77. '-----------------------------------------------------------------------------------------------------
  78. elseif request("act")="new" then
  79. %>
  80. <CENTER>
  81. <BR><BR><BR><BR>
  82. <FORM METHOD=POST ACTION="manageGL.asp?act=submitNew">
  83. <TABLE>
  84. <TR>
  85. <TD colspan=2 align=center><H3> </H3></TD>
  86. </TR>
  87. <TR>
  88. <TD align=left> : </TD>
  89. <TD><INPUT TYPE="text" NAME="name"></TD>
  90. </TR>
  91. <TR>
  92. <TD align=left> : </TD>
  93. <TD><INPUT TYPE="text" NAME="FiscalYear" onkeypress="return maskNumber(this)" maxlength=4></TD>
  94. </TR>
  95. <TR>
  96. <TD colspan=2><BR></TD>
  97. </TR>
  98. <TR>
  99. <TD align=left><INPUT TYPE="checkbox" NAME="copy" checked> ߁ </TD>
  100. <TD>
  101. <%
  102. set RSSX=Conn.Execute ("SELECT * from GLs where order by id desc")
  103. %>
  104. <SELECT NAME="OpenGL" style="font-family:tahoma" class="GenButton">
  105. <%
  106. Do while not RSSX.eof
  107. %>
  108. <option <% if cint(OpenGL)=cint(RSSX("ID")) then
  109. response.write "selected"
  110. GLname = RSSX("name")
  111. end if %> value="<%=RSSX("ID")%>" ><%=RSSX("name")%> - <%=RSSX("FiscalYear")%></option>
  112. <%
  113. RSSX.moveNext
  114. Loop
  115. RSSX.close
  116. %>
  117. </SELECT>
  118. </TD>
  119. </TR>
  120. <TR>
  121. <TD colspan=2 align=center>
  122. <BR><BR>
  123. <INPUT TYPE="submit" value=""class="GenButton">
  124. <INPUT TYPE="button" value=""class="GenButton" onclick="window.location='AccountInfo.asp'">
  125. </TD>
  126. </TR>
  127. </TABLE>
  128. <%
  129. '-----------------------------------------------------------------------------------------------------
  130. '------------------------------------------------------------------------------- Close an open GL Form
  131. '-----------------------------------------------------------------------------------------------------
  132. elseif request("act")="close" then
  133. %>
  134. <CENTER>
  135. <BR><BR>
  136. <% call showAlert ("<B>: </B><BR> ѐ ǁ <BR> <BR> .<BR>",CONST_MSG_INFORM)%>
  137. <BR>
  138. <% call showAlert (" ",CONST_MSG_INFORM)%>
  139. <BR><BR>
  140. <%
  141. set RSSX=Conn.Execute ("SELECT * from GLs where IsClosed=0 and IsDefault=0 order by id desc")
  142. %>
  143. <FORM METHOD=POST ACTION="manageGL.asp?act=submitClose">
  144. <B> </B><SELECT NAME="OpenGL" style="font-family:tahoma" class="GenButton">
  145. <%
  146. Do while not RSSX.eof
  147. %>
  148. <option <% if cint(OpenGL)=cint(RSSX("ID")) then
  149. response.write "selected"
  150. GLname = RSSX("name")
  151. end if %> value="<%=RSSX("ID")%>" ><%=RSSX("name")%> - <%=RSSX("FiscalYear")%></option>
  152. <%
  153. RSSX.moveNext
  154. Loop
  155. RSSX.close
  156. %>
  157. </SELECT><BR><BR>
  158. <INPUT TYPE="submit" value=""class="GenButton">
  159. <INPUT TYPE="button" value=""class="GenButton" onclick="window.location='AccountInfo.asp'">
  160. </FORM>
  161. </CENTER>
  162. <%
  163. '-----------------------------------------------------------------------------------------------------
  164. '--------------------------------------------------------------------------------- submit Closing a GL
  165. '-----------------------------------------------------------------------------------------------------
  166. elseif request("act")="submitClose" then
  167. conn.Execute("UPDATE GLs SET IsClosed = 1 , LastChangedBy="& session("ID")& " , LastChangedDate=N'"& shamsiToday() & "', LastChange=N'Closed' WHERE (ID = "& request("OpenGL") & ")")
  168. response.redirect "AccountInfo.asp"
  169. '-----------------------------------------------------------------------------------------------------
  170. '-------------------------------------------------------------------------------- Show GLs Changes Log
  171. '-----------------------------------------------------------------------------------------------------
  172. elseif request("act")="showLog" then
  173. set RSSX=Conn.Execute ("SELECT Users.RealName, GLLog.ChangedDate, GLLog.Change, GLs.Name ,GLs.id , GLs.FiscalYear FROM GLLog INNER JOIN GLs ON GLLog.GLID = GLs.ID INNER JOIN Users ON GLLog.ChangedBy = Users.ID ORDER BY GLLog.id DESC")
  174. %>
  175. <TABLE dir=rtl align=center width=600>
  176. <TR >
  177. <TD colspan=6 align=center>
  178. <BR><H3> </H3><BR>
  179. </TD>
  180. </TR>
  181. <TR bgcolor="eeeeee" >
  182. <TD><SMALL> # </SMALL></TD>
  183. <TD><SMALL> </SMALL></TD>
  184. <TD><SMALL> </SMALL></TD>
  185. <TD><SMALL> </SMALL></TD>
  186. <TD><SMALL> </SMALL></TD>
  187. <TD><SMALL> </SMALL></TD>
  188. </TR>
  189. <%
  190. tmpCounter=0
  191. Do while not RSSX.eof
  192. tmpCounter = tmpCounter + 1
  193. if tmpCounter mod 2 = 1 then
  194. tmpColor="#FFFFFF"
  195. tmpColor2="#FFFFBB"
  196. Else
  197. tmpColor="#DDDDDD"
  198. tmpColor2="#EEEEBB"
  199. End if
  200. %>
  201. <TR bgcolor="<%=tmpColor%>" >
  202. <TD><%=RSSX("id")%> </TD>
  203. <TD><%=RSSX("Name")%> </TD>
  204. <TD><%=RSSX("FiscalYear")%></TD>
  205. <TD><span dir=ltr><%=RSSX("ChangedDate")%></span></TD>
  206. <TD><%=RSSX("RealName")%></TD>
  207. <TD><%=RSSX("Change")%></TD>
  208. </TD>
  209. </TR>
  210. <%
  211. RSSX.moveNext
  212. Loop
  213. %>
  214. </TABLE><br>
  215. <CENTER><INPUT TYPE="button" value="ѐ"class="GenButton" onclick="window.location='AccountInfo.asp'"></CENTER><BR><BR>
  216. <%
  217. set RSSX = nothing
  218. '-----------------------------------------------------------------------------------------------------
  219. '---------------------------------------------------------------------- Select Another Default GL Form
  220. '-----------------------------------------------------------------------------------------------------
  221. elseif request("act")="select" or request("act")="" then
  222. %>
  223. <CENTER>
  224. <BR><BR><BR>
  225. <% call showAlert ("<B>: </B><BR> <BR> <BR> ",CONST_MSG_INFORM)%>
  226. <BR><BR>
  227. <%
  228. set RSSX=Conn.Execute ("SELECT * from GLs order by id desc")
  229. %>
  230. <FORM METHOD=POST ACTION="manageGL.asp?act=change">
  231. <B> </B><SELECT NAME="OpenGL" style="font-family:tahoma" class="GenButton">
  232. <%
  233. Do while not RSSX.eof
  234. %>
  235. <option <% if cint(OpenGL)=cint(RSSX("ID")) then
  236. response.write "selected"
  237. GLname = RSSX("name")
  238. end if %> value="<%=RSSX("ID")%>" ><%=RSSX("name")%> - <%=RSSX("FiscalYear")%></option>
  239. <%
  240. RSSX.moveNext
  241. Loop
  242. RSSX.close
  243. %>
  244. </SELECT><BR><BR>
  245. <% if Auth(8 , "D") then %>
  246. <INPUT TYPE="radio" NAME="forWhom" value="0"> <br>
  247. <% end if %>
  248. <INPUT TYPE="radio" NAME="forWhom" checked value="<%=session("id")%>"> <%=session("CSRName")%>
  249. <BR><BR>
  250. <INPUT TYPE="submit" value=""class="GenButton">
  251. <INPUT TYPE="button" value=""class="GenButton" onclick="window.location='AccountInfo.asp'">
  252. </FORM>
  253. </CENTER>
  254. <%
  255. end if
  256. %>
  257. <!--#include file="tah.asp" -->
  258. <%
  259. '------------- Related Triggers ----------------
  260. '
  261. ' CREATE TRIGGER [setDefaultGL] ON [dbo].[GLs]
  262. ' FOR INSERT, UPDATE
  263. ' AS
  264. ' DECLARE
  265. ' @IsDefault binary,
  266. ' @id int
  267. ' SELECT
  268. ' @IsDefault = IsDefault,
  269. ' @id = [id]
  270. ' FROM inserted
  271. ' if @IsDefault = 1
  272. ' begin
  273. ' UPDATE GLs SET
  274. ' IsDefault = 0
  275. ' UPDATE GLs SET
  276. ' IsDefault = 1
  277. ' WHERE ID = @id
  278. ' end
  279. '
  280. '----------------------------------------------
  281. '
  282. ' CREATE TRIGGER Trig_GLLOGGER ON [dbo].[GLs]
  283. ' FOR INSERT, UPDATE
  284. ' AS
  285. ' DECLARE
  286. ' @GLID int,
  287. ' @LastChange nvarchar(100),
  288. ' @LastChangedDate nvarchar(10),
  289. ' @LastChangedBy int
  290. ' SELECT
  291. ' @GLID=[ID],
  292. ' @LastChange = LastChange,
  293. ' @LastChangedDate = LastChangedDate,
  294. ' @LastChangedBy = LastChangedBy
  295. ' FROM inserted
  296. ' IF UPDATE (LastChange)
  297. ' INSERT INTO GLLog (GLID, Change, ChangedDate, ChangedBy)
  298. ' VALUES (@GLID, @LastChange, @LastChangedDate, @LastChangedBy)
  299. '
  300. '
  301. '----------------------------------------------
  302. %>