session_list.php 7.5 KB

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