/beta/admin/manageGL.asp

http://github.com/khaneh/Orders · ASP · 411 lines · 293 code · 47 blank · 71 comment · 27 complexity · 1304c456c57159c38302a95ee65784f7 MD5 · raw file

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