admin.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Special reporting page for admins
  5. * @package chamilo.reporting
  6. */
  7. ob_start();
  8. $cidReset = true;
  9. //require_once '../inc/global.inc.php';
  10. $this_section = SECTION_TRACKING;
  11. $nameTools = get_lang('Administrators');
  12. api_block_anonymous_users();
  13. $interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('MySpace'));
  14. Display :: display_header($nameTools);
  15. api_display_tool_title($nameTools);
  16. // Database Table Definitions
  17. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  18. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  19. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  20. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  21. $tbl_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER);
  22. $tbl_admin = Database :: get_main_table(TABLE_MAIN_ADMIN);
  23. if (isset($_POST['export'])) {
  24. $order_clause = api_is_western_name_order(PERSON_NAME_DATA_EXPORT) ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
  25. } else {
  26. $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
  27. }
  28. $sql = "SELECT user.user_id,lastname,firstname,email
  29. FROM $tbl_user as user, $tbl_admin as admin
  30. WHERE admin.user_id=user.user_id" . $order_clause;
  31. $result_admins = Database::query($sql);
  32. if (api_is_western_name_order()) {
  33. echo '<table class="data_table"><tr><th>' . get_lang('FirstName') . '</th><th>' . get_lang('LastName') . '</th><th>' . get_lang('Email') . '</th></tr>';
  34. } else {
  35. echo '<table class="data_table"><tr><th>' . get_lang('LastName') . '</th><th>' . get_lang('FirstName') . '</th><th>' . get_lang('Email') . '</th></tr>';
  36. }
  37. if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
  38. $header[] = get_lang('FirstName', '');
  39. $header[] = get_lang('LastName', '');
  40. } else {
  41. $header[] = get_lang('LastName', '');
  42. $header[] = get_lang('FirstName', '');
  43. }
  44. $header[] = get_lang('Email', '');
  45. if (Database::num_rows($result_admins) > 0) {
  46. while ($admins = Database::fetch_array($result_admins)) {
  47. $user_id = $admins["user_id"];
  48. $lastname = $admins["lastname"];
  49. $firstname = $admins["firstname"];
  50. $email = $admins["email"];
  51. if ($i % 2 == 0) {
  52. $css_class = "row_odd";
  53. if ($i % 20 == 0 && $i != 0) {
  54. if (api_is_western_name_order()) {
  55. echo '<tr><th>' . get_lang('FirstName') . '</th><th>' . get_lang('LastName') . '</th><th>' . get_lang('Email') . '</th></tr>';
  56. } else {
  57. echo '<tr><th>' . get_lang('LastName') . '</th><th>' . get_lang('FirstName') . '</th><th>' . get_lang('Email') . '</th></tr>';
  58. }
  59. }
  60. } else {
  61. $css_class = "row_even";
  62. }
  63. $i++;
  64. if (api_is_western_name_order()) {
  65. echo "<tr class=" . $css_class . "><td>$firstname</td><td>$lastname</td><td><a href='mailto:" . $email . "'>$email</a></td></tr>";
  66. } else {
  67. echo "<tr class=" . $css_class . "><td>$lastname</td><td>$firstname</td><td><a href='mailto:" . $email . "'>$email</a></td></tr>";
  68. }
  69. if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
  70. $data[$user_id]["firstname"] = $firstname;
  71. $data[$user_id]["lastname"] = $lastname;
  72. } else {
  73. $data[$user_id]["lastname"] = $lastname;
  74. $data[$user_id]["firstname"] = $firstname;
  75. }
  76. $data[$user_id]["email"] = $email;
  77. }
  78. } else {
  79. // No results
  80. echo '<tr><td colspan="3">' . get_lang('NoResults') . '</td></tr>';
  81. }
  82. echo '</table>';
  83. if (isset($_POST['export'])) {
  84. export_csv($header, $data, 'administrators.csv');
  85. }
  86. echo "
  87. <br /><br />
  88. <form method='post' action='admin.php'>
  89. <button type='submit' class='save' name='export' value='" . get_lang('ExportExcel') . "'>
  90. " . get_lang('ExportExcel') . "
  91. </button>
  92. <form>
  93. ";
  94. Display::display_footer();