/beta/admin/userManager.asp

http://github.com/khaneh/Orders · ASP · 695 lines · 611 code · 51 blank · 33 comment · 44 complexity · 7384ea46a277079a0e685aa23f0eb5cc MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1256"%><%
  2. ' Admin
  3. PageTitle=" "
  4. SubmenuItem=1
  5. %>
  6. <!--#include file="top.asp" -->
  7. <%
  8. NumberOfCategories = 14
  9. dim pagesPermissions(20,25)
  10. dim pages(20,25)
  11. '-------------------------------------
  12. pages ( 0 , 0 ) = " "
  13. pages ( 0 , 1 ) = " "
  14. pages ( 0 , 2 ) = " "
  15. pages ( 0 , 3 ) = " "
  16. pages ( 0 , 4 ) = " "
  17. pages ( 0 , 5 ) = " "
  18. pages ( 0 , 6 ) = " "
  19. pages ( 0 , 7 ) = " "
  20. pages ( 0 , 8 ) = ""
  21. pages (0,9) = " "
  22. '-------------------------------------
  23. pages ( 1 , 0 ) = " "
  24. pages ( 1 , 1 ) = " "
  25. pages ( 1 , 2 ) = ""
  26. pages ( 1 , 3 ) = ""
  27. pages ( 1 , 4 ) = " "
  28. pages ( 1 , 5 ) = " "
  29. pages (1, 6) = "ԝ"
  30. pages (1, 7) = " "
  31. pages (1, 8) = " "
  32. pages (1, 9) = " "
  33. pages (1, 10) = " "
  34. '-------------------------------------
  35. pages ( 2 , 0 ) = ""
  36. pages ( 2 , 1 ) = " "
  37. pages ( 2 , 2 ) = " "
  38. pages ( 2 , 3 ) = " "
  39. pages ( 2 , 4 ) = " "
  40. pages ( 2 , 5 ) = " "
  41. pages ( 2 , 6 ) = " "
  42. pages ( 2 , 7 ) = " "
  43. pages ( 2 , 8 ) = " - "
  44. pages ( 2 , 9 ) = ""
  45. pages ( 2 , 10 ) = "" 'A
  46. pages ( 2 , 11 ) = "ǁ" 'B
  47. pages ( 2 , 12 ) = " " 'C
  48. pages ( 2 , 13 ) = " " 'D
  49. pages ( 2 , 14 ) = "ǁ " 'E
  50. pages ( 2 , 15 ) = " " 'F
  51. pages ( 2 , 16 ) = " " 'G
  52. pages ( 2 , 17 ) = " " 'H
  53. '-------------------------------------
  54. pages ( 3 , 0 ) = ""
  55. pages ( 3 , 1 ) = " "
  56. pages ( 3 , 2 ) = " "
  57. pages ( 3 , 3 ) = " "
  58. pages ( 3 , 4 ) = " "
  59. pages ( 3 , 5 ) = " "
  60. pages ( 3 , 6 ) = " "
  61. pages (3,7) = ""
  62. pages (3,9) = " "
  63. pages (3,10) = " " 'A
  64. pages (3,8) = " "
  65. pages (3,11) = " " 'B
  66. '-------------------------------------
  67. pages ( 4 , 0 ) = ""
  68. pages ( 4 , 1 ) = " "
  69. pages ( 4 , 2 ) = " "
  70. pages ( 4 , 3 ) = " "
  71. pages ( 4 , 4 ) = " "
  72. pages ( 4 , 5 ) = ""
  73. pages ( 4 , 6 ) = " "
  74. pages (4,7) = " "
  75. pages (4,8) = " "
  76. '-------------------------------------
  77. pages ( 5 , 0 ) = ""
  78. pages ( 5 , 1 ) = " "
  79. pages ( 5 , 2 ) = " "
  80. pages ( 5 , 3 ) = " "
  81. pages ( 5 , 4 ) = " "
  82. pages ( 5 , 5 ) = ""
  83. pages ( 5 , 6 ) = " "
  84. pages ( 5 , 7 ) = " "
  85. pages ( 5 , 8 ) = " "
  86. pages ( 5 , 9 ) = " "
  87. pages ( 5 , 10 ) = " " 'A
  88. pages ( 5 , 11 ) = " " 'B
  89. pages ( 5 , 12 ) = " / " 'C
  90. pages ( 5 , 13 ) = " " 'D
  91. pages (5,14) = " " 'E
  92. pages (5,15) = " " 'F
  93. pages (5,16) = " " 'G
  94. pages (5,17) = " ѝ" 'H
  95. pages (5,18) = " " 'I
  96. pages (5,19) = " " 'J
  97. pages (5,20) = " " 'K
  98. '-------------------------------------
  99. pages ( 6 , 0 ) = " "
  100. pages ( 6 , 1 ) = " "
  101. pages ( 6 , 2 ) = " /"
  102. pages ( 6 , 3 ) = " "
  103. pages ( 6 , 4 ) = " ѐ"
  104. pages ( 6 , 5 ) = " ѐ"
  105. pages ( 6 , 6 ) = " "
  106. pages ( 6 , 7 ) = ""
  107. pages ( 6 , 8 ) = " "
  108. pages ( 6 , 9 ) = " "
  109. pages ( 6 , 10 ) = " " 'A
  110. pages ( 6 , 11 ) = "unused" 'B
  111. pages ( 6 , 12 ) = " " 'C
  112. pages ( 6 , 13 ) = " " 'D
  113. pages ( 6 , 14 ) = "ǁ " 'E
  114. pages ( 6 , 15 ) = " " 'F
  115. pages ( 6 , 16 ) = " " 'G
  116. pages ( 6 , 17 ) = " " 'H
  117. pages ( 6 , 18 ) = " " 'I
  118. pages ( 6 , 19 ) = "ǁ " 'J
  119. pages ( 6 , 20 ) = " ( / ѐ ) " 'K
  120. pages ( 6 , 21 ) = "߁ " 'L
  121. pages ( 6 , 22 ) = " / " 'M
  122. pages (6, 23) = " / " 'N
  123. pages (6,24) = "ǁ " 'O
  124. '-------------------------------------
  125. pages ( 7 , 0 ) = " "
  126. pages ( 7 , 1 ) = " "
  127. pages ( 7 , 2 ) = " "
  128. pages ( 7 , 3 ) = ""
  129. pages ( 7 , 4 ) = " /"
  130. pages ( 7 , 5 ) = " "
  131. pages ( 7 , 6 ) = ""
  132. pages ( 7 , 7 ) = " "
  133. pages ( 7 , 8 ) = " "
  134. pages ( 7 , 9 ) = " "
  135. pages ( 7 , 10 ) = "ǁ " 'A
  136. pages ( 7 , 11 ) = " " 'B
  137. '-------------------------------------
  138. pages ( 8 , 0 ) = " "
  139. pages ( 8 , 1 ) = " "
  140. pages ( 8 , 2 ) = " "
  141. pages ( 8 , 3 ) = "[] "
  142. pages ( 8 , 4 ) = " "
  143. pages ( 8 , 5 ) = " "
  144. pages ( 8 , 6 ) = " "
  145. pages ( 8 , 7 ) = " "
  146. pages ( 8 , 8 ) = " "
  147. pages ( 8 , 9 ) = " "
  148. pages ( 8 , 10 ) = " " 'A
  149. pages ( 8 , 11 ) = " " 'B
  150. pages ( 8 , 12 ) = " " 'C
  151. pages ( 8 , 13 ) = " " 'D
  152. pages ( 8 , 14 ) = " " 'E
  153. pages ( 8 , 15 ) = " ( ) " 'F
  154. pages ( 8 , 16 ) = " " 'G
  155. pages ( 8 , 17 ) = " " 'H
  156. '-------------------------------------
  157. pages ( 9 , 0 ) = ""
  158. pages ( 9 , 1 ) = ""
  159. pages ( 9 , 2 ) = " "
  160. pages ( 9 , 3 ) = " "
  161. pages ( 9 , 4 ) = ""
  162. pages ( 9 , 5 ) = ""
  163. pages ( 9 , 6 ) = " с "
  164. pages ( 9 , 9 ) = " с ()"
  165. pages ( 9 , 7 ) = " /"
  166. pages ( 9 , 8 ) = "ǁ "
  167. '-------------------------------------
  168. pages ( 10 , 0 ) = "" 'A
  169. pages ( 10 , 1 ) = " "
  170. pages ( 10 , 2 ) = " "
  171. pages ( 10 , 3 ) = " "
  172. pages ( 10 , 4 ) = " "
  173. pages ( 10 , 5 ) = " "
  174. pages ( 10 , 6 ) = " "
  175. pages ( 10 , 7 ) = " "
  176. pages ( 10 , 8 ) = " "
  177. pages ( 10 , 9 ) = ""
  178. '-------------------------------------
  179. pages ( 11 , 0 ) = " " 'B
  180. pages ( 11 , 1 ) = " "
  181. pages ( 11 , 2 ) = " "
  182. pages ( 11 , 3 ) = ""
  183. pages ( 11 , 4 ) = ""
  184. pages ( 11 , 5 ) = " "
  185. pages ( 11 , 6 ) = " "
  186. pages ( 11 , 7 ) = "ǁ "
  187. pages ( 11 , 8 ) = ""
  188. '-------------------------------------
  189. pages ( 12 , 0 ) = " " 'C
  190. pages ( 12 , 1 ) = " "
  191. pages ( 12 , 2 ) = " "
  192. pages ( 12 , 3 ) = " "
  193. pages ( 12 , 4 ) = " "
  194. pages ( 12 , 5 ) = " "
  195. pages ( 12 , 6 ) = " "
  196. pages ( 12 , 7 ) = " "
  197. pages ( 12 , 8 ) = " "
  198. pages ( 12 , 9 ) = " "
  199. pages (12,10) = " ѐ " 'A
  200. pages ( 12 , 11 ) = " " 'B
  201. '-------------------------------------
  202. pages ( 13 , 0 ) = " " 'D
  203. pages ( 13 , 1 ) = " "
  204. pages ( 13 , 2 ) = " "
  205. pages ( 13 , 3 ) = " ( )"
  206. pages ( 13 , 4 ) = " ( )"
  207. pages ( 13 , 5 ) = " "
  208. pages ( 13 , 6 ) = " ѐ"
  209. pages ( 13 , 7 ) = " "
  210. '-------------------------------------
  211. pages ( 14 , 0 ) = "" 'E
  212. pages ( 14 , 1 ) = "Reserved - admin"
  213. pages ( 14 , 2 ) = "Reserved - "
  214. pages ( 14 , 3 ) = "Reserved"
  215. pages ( 14 , 4 ) = "Reserved"
  216. pages ( 14 , 5 ) = " "
  217. pages ( 14 , 6 ) = " ԝ "
  218. function Auth(menuID, subMenuID, permission)
  219. pr = permission
  220. st = inStr(pr,"#"&menuID)
  221. if subMenuID >= "A" then
  222. subMenuID_int = cint(asc(subMenuID)-55)
  223. else
  224. subMenuID_int = cint(subMenuID)
  225. end if
  226. Auth = false
  227. if st > 0 then
  228. en = inStr(st+1, pr, "#")
  229. sm = inStr(st+2, pr, subMenuID)
  230. if subMenuID_int = 0 or ((sm <> 0) and (en > sm or en = 0 )) then
  231. Auth = true
  232. end if
  233. end if
  234. end function
  235. %>
  236. <style>
  237. .TABLE1 {font-family: tahoma; font-size: 8pt; Background-Color:navy; border:2 solid navy; cursor:pointer;}
  238. .TD_Rowspan {Background-Color:navy;}
  239. .textbox1 {border:none; width:100px; font-family: tahoma; font-size: 8pt; Background-Color:transparent; cursor:pointer;}
  240. .TABLE1 TR {Background-Color:white; height:20px; }
  241. .TD10 {Background-Color:#CCCCCC;height:10px;}
  242. .TD00 {Background-Color:#BBBBFF;height:10px;}
  243. .TD11 {Background-Color:#FFFFFF;height:10px;}
  244. .TD01 {Background-Color:#DDDDFF;height:10px;}
  245. </style>
  246. <SCRIPT LANGUAGE="JavaScript">
  247. <!--
  248. function showUser(user){
  249. window.location="?act=edit&userID="+user;
  250. }
  251. //-->
  252. </SCRIPT>
  253. <%
  254. '-----------------------------------------------------------------------------------------------------
  255. '------------------------------------------------------------------------------------------ Users List
  256. '-----------------------------------------------------------------------------------------------------
  257. if request("act")="" then
  258. set RSc=Conn.Execute ("SELECT count(*) as c FROM Users WHERE ID<>0")
  259. %>
  260. <BR>
  261. <TABLE class="table1" border=0 cellspacing=1 cellpadding=1 align=right>
  262. <TR>
  263. <TD rowspan="3" height=100></TD>
  264. </tr>
  265. <TR>
  266. <%
  267. for i=0 to NumberOfCategories
  268. j=0
  269. if not pagesPermissions(i,j)="ok" then
  270. disableChecks="disabled"
  271. rowBGColor="#F0F0F0"
  272. groupChecked=""
  273. else
  274. disableChecks=""
  275. rowBGColor="#33AACC"
  276. groupChecked="checked"
  277. end if
  278. Do While pages(i,j+1)<>""
  279. j=j+1
  280. Loop
  281. %>
  282. <td colspan=<%=j%> align=center ><%=pages(i,0)%></td>
  283. <td rowspan=<%=RSc("c")+3%> class="TD_Rowspan" ></td>
  284. <%
  285. next
  286. %>
  287. </tr>
  288. <TR>
  289. <%
  290. for i=0 to NumberOfCategories
  291. j=0
  292. while pages(i,j+1)<>""
  293. j=j+1
  294. if j <10 then
  295. jj = j
  296. else
  297. jj = chr(55+j)
  298. end if
  299. %>
  300. <td title="<%=pages(i,j)%>"><%response.write jj'pages(i,j)%></td>
  301. <%
  302. wend
  303. next
  304. %>
  305. </TR>
  306. <%
  307. set RSV=Conn.Execute ("SELECT * FROM Users WHERE ID<>0 ORDER BY RealName")
  308. tmpRowCounter=0
  309. Do while not RSV.eof
  310. Permission = RSV("Permission")
  311. RealName = RSV("RealName")
  312. tmpRowCounter = tmpRowCounter + 1
  313. %>
  314. <TR height='10px' onclick="showUser(<%=RSV("ID")%>);">
  315. <TD height='10px' class="TD<%=tmpRowCounter Mod 2%>1"><INPUT TYPE="text" class="textbox1" Value="<%=RealName%>"><br></TD>
  316. <%
  317. tmpColCounter=0
  318. for i=0 to NumberOfCategories
  319. j=0
  320. while pages(i,j+1)<>""
  321. tmpColCounter = tmpColCounter + 1
  322. j=j+1
  323. if i <10 then
  324. ii = i
  325. else
  326. ii = chr(55+i)
  327. end if
  328. if j <10 then
  329. jj = j
  330. else
  331. jj = chr(55+j)
  332. end if
  333. %>
  334. <td height='10px' class="TD<%=tmpRowCounter Mod 2%><%=tmpColCounter Mod 2%>" title="<%=RealName & ": " & vbCrLf & pages(i,j) %>"><%if Auth (ii,jj,Permission) then %><B>x</B><%else%>&nbsp;<%end if%></td>
  335. <%
  336. wend
  337. next
  338. %>
  339. </TR>
  340. <%
  341. RSV.moveNext
  342. Loop
  343. RSV.close
  344. %>
  345. <TR height='10px' onclick="showUser('');">
  346. <TD height='10px' class="TD<%=(tmpRowCounter+1) Mod 2%>1"><INPUT TYPE="text" class="textbox1" Value="**"><br></TD>
  347. </TR>
  348. <%
  349. '-----------------------------------------------------------------------------------------------------
  350. '------------------------------------------------------------------------------------ Show Permissions
  351. '-----------------------------------------------------------------------------------------------------
  352. elseif request("act")="edit" then
  353. %>
  354. <BR><BR>
  355. <%
  356. userID = request("userID")
  357. if userID="" then
  358. Password = ""
  359. %>
  360. <center>
  361. <H3> </H3>
  362. </center>
  363. <%
  364. else
  365. userID = cint(request("userID"))
  366. set RSM = conn.Execute ("SELECT * from Users where ID="& userID & "")
  367. UserName = RSM("UserName")
  368. Password = "$aMe@sB4" 'Same as Before instead of : RSM("Password")
  369. if left(RSM("Password"),1)="'" then
  370. DisabledChecked="checked"
  371. else
  372. DisabledChecked=""
  373. end if
  374. RealName = RSM("RealName")
  375. Account = RSM("Account")
  376. Permission = RSM("Permission")
  377. Display = RSM("Display")
  378. 'costCenterString= RSM("costCenter")
  379. RSM.close
  380. if Display then
  381. DisplayChecked="checked"
  382. else
  383. DisplayChecked=""
  384. end if
  385. sp = split (Permission,"#")
  386. for u=1 to ubound(sp)
  387. x = left(sp(u),1)
  388. if x >= "A" then
  389. i=cint(asc(x)-55)
  390. else
  391. i=cint(x)
  392. end if
  393. pagesPermissions(i,0)="ok"
  394. for v = 2 to len(sp(u))
  395. tmpp=mid(sp(u),v,1)
  396. if tmpp >= "A" then
  397. j=cint(asc(tmpp)-55)
  398. else
  399. j=cint(tmpp)
  400. end if
  401. 'j=cint(mid(sp(u),v,1))
  402. pagesPermissions(i,j)="ok"
  403. next
  404. next
  405. %>
  406. <center>
  407. <H3> : "<%=RealName%>"</H3>
  408. </center>
  409. <%
  410. end if
  411. %>
  412. <FORM METHOD=POST ACTION="?act=submit">
  413. <TABLE style="font-family:tahoma;font-size:9pt; " Cellspacing="0" Cellpadding="5" width=100%>
  414. <TR>
  415. <TD valign=top>
  416. :<br><br>
  417. <TABLE border=1>
  418. <TR>
  419. <TD> :</TD>
  420. <TD dir=LTR><%=userID%>&nbsp;<INPUT TYPE="hidden" Name="userID" Value="<%=userID%>"></TD>
  421. </TR>
  422. <TR>
  423. <TD> :</TD>
  424. <TD><INPUT TYPE="text" NAME="UserName" Value="<%=UserName%>" dir=LTR></TD>
  425. </TR>
  426. <TR>
  427. <TD> </TD>
  428. <TD><INPUT TYPE="Password" NAME="Password" Value="<%=Password%>" dir=LTR></TD>
  429. </TR>
  430. <TR>
  431. <TD> :</TD>
  432. <TD><INPUT TYPE="text" NAME="RealName" Value="<%=RealName%>"></TD>
  433. </TR>
  434. <TR>
  435. <TD> :</TD>
  436. <TD><INPUT TYPE="text" NAME="Account" Value="<%=Account%>"></TD>
  437. </TR>
  438. <TR>
  439. <TD> </TD>
  440. <TD><INPUT TYPE="checkbox" NAME="Display" <%=DisplayChecked%> ></TD>
  441. </TR>
  442. <TR>
  443. <TD> </TD>
  444. <TD><INPUT TYPE="checkbox" NAME="disable" <%=DisabledChecked%>></TD>
  445. </TR>
  446. <tr>
  447. <td> </td>
  448. <td>
  449. <table width="100%">
  450. <%
  451. '----------------------------- COST CENTER ---------------------------------
  452. if userID<>"" then
  453. mySQL="SELECT cost_centers.name as costCenterName, cost_drivers.*,isnull(cost_user_relations.driver_id,-1) as driver_id FROM cost_centers inner join cost_drivers on cost_centers.id=cost_drivers.cost_center_id left outer join cost_user_relations on cost_drivers.id=cost_user_relations.driver_id and cost_user_relations.user_id=" & userID
  454. else
  455. mySQL="SELECT cost_centers.name as costCenterName, cost_drivers.*,isnull(cost_user_relations.driver_id,-1) as driver_id FROM cost_centers inner join cost_drivers on cost_centers.id=cost_drivers.cost_center_id left outer join cost_user_relations on cost_drivers.id=cost_user_relations.driver_id"
  456. end if
  457. set rrs=Conn.Execute(mySQL)
  458. oldCostCenter=-1
  459. while not rrs.eof
  460. theTitle=""
  461. set oprs=Conn.Execute("select * from cost_operation_type where driver_id=" & rrs("id"))
  462. 'response.write ("select * from cost_operation_type where driver_id=" & rrs("id"))
  463. while not oprs.eof
  464. theTitle= theTitle & oprs("name") & " "
  465. oprs.moveNext
  466. wend
  467. oprs.close
  468. if oldCostCenter=cint(rrs("cost_center_id")) then
  469. %>
  470. <tr>
  471. <td title="<%=theTitle%>"><%=rrs("name")%></td>
  472. <td><input type="checkbox" name="costDriver-<%=rrs("id")%>" <%if cint(rrs("driver_id"))>0 then response.write("checked='checked'")%>></td>
  473. </tr>
  474. <%
  475. else
  476. %>
  477. <tr bgcolor="#33AACC">
  478. <td colspan="2" align="center"><b><%=rrs("costCenterName")%></b></td>
  479. </tr>
  480. <tr>
  481. <td title="<%=theTitle%>"><%=rrs("name")%></td>
  482. <td><input type="checkbox" name="costDriver-<%=rrs("id")%>" <%if cint(rrs("driver_id"))>0 then response.write("checked='checked'")%>></td>
  483. </tr>
  484. <%
  485. end if
  486. %>
  487. <%
  488. oldCostCenter=cint(rrs("cost_center_id"))
  489. rrs.MoveNext
  490. wend
  491. rrs.close
  492. '--------------------------------------------------------------------------------
  493. %>
  494. </table>
  495. </td>
  496. </tr>
  497. <TR>
  498. <TD colspan=2 align=center><INPUT TYPE="submit" value=""></TD>
  499. </TR>
  500. </TABLE>
  501. </TD>
  502. <TD Width="350" >
  503. :<br><br>
  504. <table style="font-family:tahoma;font-size:9pt; border:1 dashed #888888; direction:RTL;" Cellspacing="0" Cellpadding="5">
  505. <tbody id="PermissionsTable">
  506. <%
  507. for i=0 to NumberOfCategories
  508. j=0
  509. if not pagesPermissions(i,j)="ok" then
  510. disableChecks="disabled"
  511. rowBGColor="#F0F0F0"
  512. groupChecked=""
  513. else
  514. disableChecks=""
  515. rowBGColor="#33AACC"
  516. groupChecked="checked"
  517. end if
  518. %>
  519. <tr bgcolor='<%=rowBGColor%>'>
  520. <td width=20> <INPUT TYPE="checkbox" NAME="P<%=i%>" value="<%=j%>" onclick="activeGroup(this)" <%=groupChecked%>> </td>
  521. <td align=right><B><%=pages(i,0)%></B></td>
  522. </tr>
  523. <tr>
  524. <td width=20> </td>
  525. <td align=right>
  526. <%
  527. while pages(i,j+1)<>""
  528. j=j+1
  529. if j <10 then
  530. jj = j
  531. else
  532. jj = chr(55+j)
  533. end if
  534. %>
  535. <INPUT TYPE="checkbox" <%=disableChecks%> NAME="P<%=i%>" value="<%=jj%>" <%if pagesPermissions(i,j)="ok" then %>checked<% end if %>> <%=pages(i,j)%> <BR>
  536. <%
  537. wend
  538. next
  539. %>
  540. </td>
  541. </tr>
  542. </table>
  543. </TD>
  544. </TR>
  545. </TABLE>
  546. </FORM>
  547. <%
  548. '-----------------------------------------------------------------------------------------------------
  549. '-------------------------------------------------------------------------------------- Submit Changes
  550. '-----------------------------------------------------------------------------------------------------
  551. elseif request("act")="submit" then
  552. userID = request("userID")
  553. RealName = request("RealName")
  554. RealName = "N'" & RealName & "'"
  555. Account = request("Account")
  556. UserName = request("UserName")
  557. UserName = "'" & UserName & "'"
  558. Password = request("Password")
  559. if Password="$aMe@sB4" then
  560. Password= "Password"
  561. else
  562. Password= "'" & Password & "'"
  563. end if
  564. if request("disable")="on" then
  565. Password = "'''' + REPLACE(" & Password & ",'''','')"
  566. else
  567. Password = "REPLACE(" & Password & ",'''','')"
  568. end if
  569. Permission = ""
  570. for i=0 to NumberOfCategories
  571. if request.form("P"& i ) <> "" then
  572. if i <10 then
  573. ii = i
  574. else
  575. ii = chr(55+i)
  576. end if
  577. alll = replace(request.form("P"& i ),", ","")
  578. Permission = Permission & "#" & ii & right( alll, len(alll)-1)
  579. end if
  580. next
  581. Permission = "'" & Permission & "'"
  582. Display = request("Display")
  583. if Display="on" then
  584. Display="1"
  585. else
  586. Display="0"
  587. end if
  588. '------------------------ COST CENTER -----------------------------------
  589. if userID<>"" then
  590. conn.Execute("delete cost_user_relations where user_id=" & userID)
  591. end if
  592. set rrs = Conn.execute("select id from cost_drivers")
  593. while not rrs.eof
  594. if request("costDriver-"&rrs("id"))="on" then
  595. conn.Execute("insert into cost_user_relations (user_id,driver_id) values ("& userID & "," & rrs("id") & ")")
  596. end if
  597. rrs.MoveNext
  598. wend
  599. rrs.close
  600. if userID="" then
  601. ' Add New User
  602. mySQL="SELECT MAX(ID)+1 AS NewID FROM Users"
  603. set RS=Conn.Execute (mySQL)
  604. userID = RS("NewID")
  605. RS.close
  606. mySQL="INSERT INTO Users (ID, UserName, Password, RealName, Account, Permission, Display) VALUES (" & userID & ", " & userName & ", " & Password & ", " & RealName & ", " & Account & ", " & Permission & "," & Display & ")"
  607. msg=" ."
  608. else
  609. ' Update User Info
  610. userID = cint(request("userID"))
  611. mySQL="UPDATE Users SET UserName=" & UserName & ", Password=" & Password & ", RealName=" & RealName & ", Account=" & Account& ", Permission= " & Permission & ", Display=" & Display & " WHERE ID="& userID & ""
  612. msg=" "
  613. end if
  614. conn.Execute (mySQL)
  615. conn.close
  616. response.redirect "?act=edit&userID=" & userID & "&msg=" & Server.URLEncode(msg)
  617. end if
  618. %>
  619. <SCRIPT LANGUAGE="JavaScript">
  620. <!--
  621. function activeGroup(src){
  622. rowNo=src.parentNode.parentNode.rowIndex;
  623. invTable=document.getElementById("PermissionsTable");
  624. theRowPr=invTable.getElementsByTagName("tr")[rowNo];
  625. theRow=invTable.getElementsByTagName("tr")[rowNo+1];
  626. boxCount=theRow.getElementsByTagName("INPUT").length;
  627. if (src.checked){
  628. theRowPr.bgColor= '#33AACC';
  629. for (i=0;i<boxCount;i++){
  630. theRow.getElementsByTagName("INPUT")[i].disabled=false;
  631. }
  632. // theRow.disabled=false;
  633. }
  634. else{
  635. for (i=0;i<boxCount;i++){
  636. theRow.getElementsByTagName("INPUT")[i].disabled=true;
  637. }
  638. theRowPr.bgColor= '#F0F0F0';
  639. // theRow.disabled=true;
  640. }
  641. }
  642. //-->
  643. </SCRIPT>
  644. <!--#include file="tah.asp" -->