index.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. $default_displayed = 500;
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  6. $default_ou=get_const('default_user_ou_id');
  7. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
  8. $default_sort='login';
  9. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
  10. $msg_error = "";
  11. if (isset($_POST["create"])) {
  12. $login = trim($_POST["newlogin"]);
  13. if (!empty($login)) {
  14. $lcount = get_count_records($db_link,"User_list","LCase(login)=LCase('$login')");
  15. if ($lcount > 0) {
  16. $msg_error = "WEB_cell_login $login $msg_exists!";
  17. unset($_POST);
  18. } else {
  19. $new['login'] = $login;
  20. $new['ou_id'] = $rou;
  21. $ou_info = get_record_sql($db,"SELECT * FROM OU WHERE id=".$rou);
  22. if (!empty($ou_info)) {
  23. $new['enabled'] = $ou_info['enabled'];
  24. $new['queue_id'] = $ou_info['queue_id'];
  25. $new['filter_group_id'] = $ou_info['filter_group_id'];
  26. }
  27. $lid=insert_record($db_link, "User_list", $new);
  28. LOG_WARNING($db_link,"Создан новый пользователь: Login => $login");
  29. header("Location: edituser.php?id=$lid");
  30. exit;
  31. }
  32. }
  33. header("Location: " . $_SERVER["REQUEST_URI"]);
  34. exit;
  35. }
  36. ?>
  37. <div id="cont">
  38. <?php
  39. if ($msg_error) {
  40. print "<div id='msg'><b>$msg_error</b></div><br>\n";
  41. }
  42. ?>
  43. <form id="filter" name="filter" action="index.php" method="post">
  44. <div>
  45. <b><?php print WEB_cell_ou; ?> - </b>
  46. <?php print_ou_select($db_link, 'ou', $rou); print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  47. <input id="btn_filter" name="btn_filter" type="submit" value="<?php echo WEB_btn_show; ?>">
  48. </div>
  49. <br>
  50. <div>
  51. <?php echo WEB_new_user."&nbsp"; ?>
  52. <input type=text name=newlogin value="Unknown">
  53. <input type="submit" name="create" value="<?php echo WEB_btn_add; ?>">
  54. </div>
  55. </form>
  56. <br>
  57. <a class="mainButton" href="#modal"><?php print WEB_btn_apply_selected; ?></a>
  58. <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  59. <div class="remodalBorder">
  60. <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
  61. <form id="formUserApply">
  62. <h2 id="modal1Title"><?php print WEB_selection_title; ?></h2>
  63. <input type="hidden" name="ApplyForAll" value="MassChange">
  64. <table class="data" align=center>
  65. <tr><td><input type=checkbox class="putField" name="e_enabled" value='1'></td><td><?php print WEB_cell_enabled."&nbsp";print_qa_select('a_enabled', 0); ?></td></tr>
  66. <tr><td><input type=checkbox class="putField" name="e_group_id" value='1'></td><td><?php print WEB_cell_filter."&nbsp";print_group_select($db_link, 'a_group_id', 0); ?></td></tr>
  67. <tr><td><input type=checkbox class="putField" name="e_queue_id" value='1'></td><td><?php print WEB_cell_shaper."&nbsp";print_queue_select($db_link, 'a_queue_id', 0); ?></td></tr>
  68. <tr><td><input type=checkbox class="putField" name="e_day_q" value='1'></td><td><?php print WEB_cell_perday."&nbsp"; ?><input type="text" name="a_day_q" value="0" size=5></td></tr>
  69. <tr><td><input type=checkbox class="putField" name="e_month_q" value='1'></td><td><?php print WEB_cell_permonth."&nbsp"; ?><input type="text" name="a_month_q" value="0" size=5></td></tr>
  70. <tr><td><input type=checkbox class="putField" name="e_new_ou" value='1'></td><td><?php print WEB_cell_ou."&nbsp";print_ou_select($db_link, 'a_new_ou', $rou); ?></td></tr>
  71. </table>
  72. <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
  73. </form>
  74. </div>
  75. </div>
  76. <a class="delButton" href="#modalDel"><?php print WEB_btn_delete; ?></a>
  77. <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modalDel" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  78. <div class="remodalBorder">
  79. <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
  80. <form id="formUserDel">
  81. <h2 id="modal1Title"><?php print WEB_msg_delete_selected; ?></h2>
  82. <input type="hidden" name="RemoveUser" value="MassChange">
  83. <?php print_qa_select('f_deleted', 0);?><br><br>
  84. <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
  85. </form>
  86. </div>
  87. </div>
  88. <?php
  89. $sort_table = 'U';
  90. $sort_url = "<a href=/admin/users/index.php?";
  91. if ($rou == 0) { $filter = "U.ou_id=O.id and U.deleted=0"; } else { $filter = "U.OU_id=O.id and U.deleted=0 and U.ou_id=$rou"; }
  92. $countSQL = "SELECT Count(*) FROM User_list U, OU O WHERE $filter";
  93. $res = mysqli_query($db_link, $countSQL);
  94. $count_records = mysqli_fetch_array($res);
  95. $total=ceil($count_records[0]/$displayed);
  96. if ($page>$total) { $page=$total; }
  97. if ($page<1) { $page=1; }
  98. $start = ($page * $displayed) - $displayed;
  99. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  100. $sSQL = "SELECT U.id, U.login, U.fio, O.ou_name, U.enabled, U.day_quota, U.month_quota, U.blocked FROM User_list U, OU O WHERE $filter ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
  101. ?>
  102. <form id="def" name="def" >
  103. <table class="data">
  104. <tr align="center">
  105. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  106. <td><b><?php print $sort_url . "sort=id&order=$new_order>id</a>"; ?></b></td>
  107. <td><b><?php print $sort_url . "sort=login&order=$new_order>" . WEB_cell_login . "</a>"; ?></b></td>
  108. <td><b><?php print $sort_url . "sort=fio&order=$new_order>" . WEB_cell_fio . "</a>"; ?></b></td>
  109. <td><b><?php print WEB_cell_rule; ?></b></td>
  110. <td><b><?php print WEB_cell_ou; ?></b></td>
  111. <td><b><?php print WEB_cell_enabled; ?></b></td>
  112. <td><b><?php print WEB_cell_perday; ?></b></td>
  113. <td><b><?php print WEB_cell_permonth; ?></b></td>
  114. <td><b><?php print WEB_cell_report; ?></b></td>
  115. </tr>
  116. <?php
  117. $users = get_records_sql($db_link, $sSQL);
  118. foreach ($users as $row) {
  119. $auth_customs = get_count_records($db_link,"User_auth","user_id=".$row['id']." AND deleted=0 AND enabled <>'".$row['enabled']."'");
  120. $cl = "data";
  121. if (! $row['enabled']) {
  122. $cl = "off";
  123. }
  124. if ($row['blocked']) {
  125. $cl = "error";
  126. }
  127. if ($auth_customs > 0) {
  128. $cl = "custom";
  129. }
  130. if (! get_auth_count($db_link, $row['id'])) {
  131. $cl = 'nb';
  132. }
  133. print "<tr align=center>\n";
  134. print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
  135. print "<td class=\"$cl\">".$row['id']."</td>\n";
  136. if (empty($row['login'])) { $row['login']=$row['id']; }
  137. print "<td class=\"$cl\" align=left><a href=edituser.php?id=".$row['id'].">" . $row['login'] . "</a></td>\n";
  138. print "<td class=\"$cl\">".$row['fio']."</td>\n";
  139. $rules_count = get_count_records($db_link,"auth_rules","user_id=".$row['id']);
  140. print "<td class=\"$cl\">".$rules_count."</td>\n";
  141. print "<td class=\"$cl\">".$row['ou_name']."</td>\n";
  142. print "<td class=\"$cl\">".get_qa($row['enabled']) . "</td>\n";
  143. print "<td class=\"$cl\">".$row['day_quota']."</td>\n";
  144. print "<td class=\"$cl\">".$row['month_quota']."</td>\n";
  145. print "<td class=\"$cl\" align=center colspan=2><a href=../reports/userday.php?id=".$row['id'].">Просмотр</a></td>\n";
  146. }
  147. ?>
  148. </table>
  149. <?php
  150. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  151. ?>
  152. </form>
  153. <table class="data">
  154. <tr>
  155. <td colspan = 3><?php echo WEB_color_description; ?></td>
  156. </tr>
  157. <tr>
  158. <td class="nb"><?php echo WEB_color_user_empty; ?></td>
  159. <td class="off"><?php echo WEB_color_user_disabled; ?></td>
  160. <td class="error"><?php echo WEB_color_user_blocked; ?></td>
  161. <td class="custom"><?php echo WEB_color_user_custom; ?></td>
  162. </table>
  163. <script src="/js/remodal/remodal.min.js"></script>
  164. <script src="/js/remodal-user.js"></script>
  165. <?php
  166. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  167. ?>