session_list.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. //@todo fix sort in this table or use jqgrid
  4. $language_file = 'admin';
  5. $cidReset = true;
  6. require_once '../inc/global.inc.php';
  7. $this_section = SECTION_PLATFORM_ADMIN;
  8. api_protect_admin_script(true);
  9. //Add the JS needed to use the jqgrid
  10. $htmlHeadXtra[] = api_get_jquery_ui_js(true);
  11. $action=$_REQUEST['action'];
  12. $idChecked = $_REQUEST['idChecked'];
  13. if ($action == 'delete') {
  14. SessionManager::delete_session($idChecked);
  15. header('Location: '.api_get_self());
  16. exit();
  17. } elseif ($action == 'copy') {
  18. SessionManager::copy_session($idChecked);
  19. header('Location: '.api_get_self());
  20. exit();
  21. }
  22. $interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'));
  23. //table for the search
  24. $tool_name = get_lang('SessionList');
  25. Display::display_header($tool_name);
  26. //jqgrid will use this URL to do the selects
  27. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions';
  28. //The order is important you need to check the the $column variable in the model.ajax.php file
  29. $columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('SessionCategoryName'),
  30. get_lang('StartDate'), get_lang('EndDate'), get_lang('Coach'), get_lang('Status'), get_lang('Visibility'), get_lang('Actions'));
  31. //$activeurl = '?sidx=session_active';
  32. //Column config
  33. $column_model = array(
  34. array('name'=>'name', 'index'=>'name', 'width'=>'120', 'align'=>'left', 'search' => 'true'),
  35. array('name'=>'nbr_courses', 'index'=>'nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
  36. array('name'=>'category_name', 'index'=>'category_name', 'width'=>'70', 'align'=>'left', 'search' => 'true'),
  37. array('name'=>'date_start', 'index'=>'date_start', 'width'=>'40', 'align'=>'left', 'search' => 'true'),
  38. array('name'=>'date_end', 'index'=>'date_end', 'width'=>'40', 'align'=>'left', 'search' => 'true'),
  39. array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'80', 'align'=>'left', 'search' => 'false'),
  40. array('name'=>'status', 'index'=>'session_active', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'stype'=>'select',
  41. //for the bottom bar
  42. 'searchoptions' => array(
  43. 'defaultValue' => '1',
  44. 'value' => '1:'.get_lang('Active').';0:'.get_lang('Inactive')),
  45. //for the top bar
  46. 'editoptions' => array('value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))),
  47. array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
  48. array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false')
  49. );
  50. //Autowidth
  51. $extra_params['autowidth'] = 'true';
  52. //height auto
  53. $extra_params['height'] = 'auto';
  54. $extra_params['excel'] = 'excel';
  55. $extra_params['rowList'] = array(10, 20 ,30);
  56. //With this function we can add actions to the jgrid (edit, delete, etc)
  57. $action_links = 'function action_formatter(cellvalue, options, rowObject) {
  58. return \'<a href="session_edit.php?page=resume_session.php&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>'.
  59. '&nbsp;<a href="add_users_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('user_subscribe_session.png',get_lang('SubscribeUsersToSession'),'',22).'</a>'.
  60. '&nbsp;<a href="add_courses_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('courses_to_session.png',get_lang('SubscribeCoursesToSession'),'',22).'</a>'.
  61. '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="session_list.php?action=copy&idChecked=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',22).'</a>'.
  62. '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="session_list.php?action=delete&idChecked=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',22).'</a>'.
  63. '\';
  64. }';
  65. ?>
  66. <script>
  67. function setSearchSelect(columnName) {
  68. $("#sessions").jqGrid('setColProp', columnName,
  69. {
  70. searchoptions:{
  71. dataInit:function(el){
  72. $("option[value='1']",el).attr("selected", "selected");
  73. setTimeout(function(){
  74. $(el).trigger('change');
  75. },1000);
  76. }
  77. }
  78. });
  79. }
  80. $(function() {
  81. <?php
  82. echo Display::grid_js('sessions', $url,$columns,$column_model,$extra_params, array(), $action_links,true);
  83. ?>
  84. setSearchSelect("status");
  85. $("#sessions").jqGrid('navGrid','#sessions_pager', {edit:false,add:false,del:false},
  86. {height:280,reloadAfterSubmit:false}, // edit options
  87. {height:280,reloadAfterSubmit:false}, // add options
  88. {reloadAfterSubmit:false}, // del options
  89. {width:500} // search options
  90. );
  91. /*
  92. // add custom button to export the data to excel
  93. jQuery("#sessions").jqGrid('navButtonAdd','#sessions_pager',{
  94. caption:"",
  95. onClickButton : function () {
  96. jQuery("#sessions").excelExport();
  97. }
  98. });
  99. jQuery('#sessions').jqGrid('navButtonAdd','#sessions_pager',{id:'pager_csv',caption:'',title:'Export To CSV',onClickButton : function(e)
  100. {
  101. try {
  102. jQuery("#sessions").jqGrid('excelExport',{tag:'csv', url:'grid.php'});
  103. } catch (e) {
  104. window.location= 'grid.php?oper=csv';
  105. }
  106. },buttonicon:'ui-icon-document'})
  107. */
  108. //Adding search options
  109. var options = {
  110. 'stringResult': true,
  111. 'autosearch' : true,
  112. 'searchOnEnter':false,
  113. }
  114. jQuery("#sessions").jqGrid('filterToolbar',options);
  115. var sgrid = $("#sessions")[0];
  116. sgrid.triggerToolbar();
  117. });
  118. </script>
  119. <div class="actions">
  120. <?php
  121. echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('new_session.png',get_lang('AddSession'),'','32').'</a>';
  122. echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/add_many_session_to_category.php">'.Display::return_icon('session_to_category.png',get_lang('AddSessionsInCategories'),'','32').'</a>';
  123. echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_list.php">'.Display::return_icon('folder.png',get_lang('ListSessionCategory'),'','32').'</a>';
  124. echo '</div>';
  125. echo Display::grid_html('sessions');
  126. Display::display_footer();