calendar_users.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /* For license terms, see /license.txt */
  3. require_once __DIR__.'/../../main/inc/global.inc.php';
  4. $calendarId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
  5. $plugin = LearningCalendarPlugin::create();
  6. $plugin->protectCalendar($calendarId);
  7. $item = $plugin->getCalendar($calendarId);
  8. if (empty($item)) {
  9. api_not_allowed(true);
  10. }
  11. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
  12. $formToString = '';
  13. $template = new Template();
  14. $actionLeft = Display::url(
  15. Display::return_icon(
  16. 'back.png',
  17. get_lang('Add'),
  18. null,
  19. ICON_SIZE_MEDIUM
  20. ),
  21. api_get_path(WEB_PLUGIN_PATH).'learning_calendar/start.php'
  22. );
  23. $actions = Display::toolbarAction('toolbar-forum', [$actionLeft]);
  24. // jqgrid will use this URL to do the selects
  25. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_calendar_users&id='.$calendarId;
  26. // The order is important you need to check the the $column variable in the model.ajax.php file
  27. $columns = [
  28. get_lang('First name'),
  29. get_lang('Last name'),
  30. get_lang('Exam'),
  31. ];
  32. // Column config
  33. $column_model = [
  34. ['name' => 'firstname', 'index' => 'firstname', 'width' => '35', 'align' => 'left', 'sortable' => 'false'],
  35. ['name' => 'lastname', 'index' => 'lastname', 'width' => '35', 'align' => 'left', 'sortable' => 'false'],
  36. [
  37. 'name' => 'exam',
  38. 'index' => 'exam',
  39. 'width' => '20',
  40. 'align' => 'center',
  41. 'sortable' => 'false',
  42. ],
  43. ];
  44. // Autowidth
  45. $extraParams['autowidth'] = 'true';
  46. // height auto
  47. $extraParams['height'] = 'auto';
  48. $extraParams['sortname'] = 'name';
  49. $extraParams['sortorder'] = 'desc';
  50. $extraParams['multiselect'] = true;
  51. $deleteIcon = Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL);
  52. $urlStats = api_get_path(WEB_CODE_PATH);
  53. $action_links = '';
  54. $deleteUrl = '';
  55. // Add the JS needed to use the jqgrid
  56. $htmlHeadXtra[] = api_get_jqgrid_js();
  57. Display::display_header();
  58. ?>
  59. <script>
  60. $(function() {
  61. <?php
  62. // grid definition see the $usergroup>display() function
  63. echo Display::grid_js(
  64. 'usergroups',
  65. $url,
  66. $columns,
  67. $column_model,
  68. $extraParams,
  69. [],
  70. $action_links,
  71. true
  72. );
  73. ?>
  74. $("#usergroups").jqGrid(
  75. "navGrid",
  76. "#usergroups_pager",
  77. { edit: false, add: false, del: true, search: false},
  78. { height:280, reloadAfterSubmit:false }, // edit options
  79. { height:280, reloadAfterSubmit:false }, // add options
  80. { reloadAfterSubmit:false, url: "<?php echo $deleteUrl; ?>" }, // del options
  81. { width:500 } // search options
  82. );
  83. });
  84. </script>
  85. <?php
  86. // action links
  87. echo '<div class="actions">';
  88. echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/usergroup_users.php?id='.$calendarId.'">'.
  89. Display::return_icon('back.png', get_lang('Back to').' '.get_lang('Administration'), '', '32').
  90. '</a>';
  91. echo '</div>';
  92. echo Display::grid_html('usergroups');
  93. Display::display_footer();