admin.php 4.1 KB

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