Dokeos PHP Cross Reference Learning Management Systems

Source: /main/admin/session_category_list.php - 277 lines - 10205 bytes - Summary - Text - Print

   1  <?php
   2  /* For licensing terms, see /dokeos_license.txt */
   3  
   4  /**
   5  * @package dokeos.admin
   6  */
   7  
   8  // name of the language file that needs to be included
   9  $language_file = array ('registration','admin');
  10  
  11  // resetting the course id
  12  $cidReset = true;
  13  
  14  // setting the help
  15  $help_content = 'platformadministrationsessioncategorylist';
  16  
  17  // including the global Dokeos file
  18  require  ('../inc/global.inc.php');
  19  
  20  // including additional libraries
  21  require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  22  require_once (api_get_path(LIBRARY_PATH).'sessionmanager.lib.php');
  23  
  24  // setting the section (for the tabs)
  25  $this_section = SECTION_PLATFORM_ADMIN;
  26  
  27  // Access restrictions
  28  api_protect_admin_script(true);
  29  
  30  // setting breadcrumbs
  31  $interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'));
  32  
  33  // additional javascript, css, ...
  34  $htmlHeadXtra[] = '<script language="javascript">
  35  
  36  				function selectAll(idCheck,numRows,action) {
  37  
  38                      for(i=0;i<numRows;i++) {
  39                          idcheck = document.getElementById(idCheck+"_"+i);
  40                          if (action == "true"){
  41                              idcheck.checked = true;
  42                          } else {
  43                              idcheck.checked = false;
  44                          }
  45                      }
  46  
  47                  }
  48                  </script>';
  49  
  50  // Database table definitions
  51  $tbl_session_category     = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
  52  $tbl_session             = Database::get_main_table(TABLE_MAIN_SESSION);
  53  
  54  // variable handling
  55  $page=intval($_GET['page']);
  56  $action= Security::remove_XSS($_REQUEST['action']);
  57  $sort=in_array($_GET['sort'],array('name','nbr_session','date_start','date_end'))? Security::remove_XSS($_GET['sort']) : 'name';
  58  $idChecked = Security::remove_XSS($_REQUEST['idChecked']);
  59  $order = (isset($_REQUEST['order']))? Security::remove_XSS($_REQUEST['order']): 'ASC';
  60  
  61  if ($action == 'delete_on_session' || $action == 'delete_off_session') {
  62      $delete_session = ($action == 'delete_on_session')? true: false;
  63      SessionManager::delete_session_category($idChecked, $delete_session);
  64      header('Location: '.api_get_self().'?sort='.$sort.'&action=show_message&message='.urlencode(get_lang('SessionCategoryDelete')));
  65      exit();
  66  }
  67  
  68  if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
  69      $interbreadcrumb[] = array ("url" => 'session_category_list.php', "name" => get_lang('ListSessionCategory'));
  70      $tool_name = get_lang('SearchASession');
  71  
  72      // Display the header
  73      Display :: display_header($tool_name);
  74  
  75      // start the content div
  76      echo '<div id="content">';
  77  
  78      // create the form
  79      $form = new FormValidator('advanced_search','get');
  80      $form->addElement('header', '', $tool_name);
  81      $active_group = array();
  82      $active_group[] = $form->createElement('checkbox','active','',get_lang('Active'));
  83      $active_group[] = $form->createElement('checkbox','inactive','',get_lang('Inactive'));
  84      $form->addGroup($active_group,'',get_lang('ActiveSession'),'<br/>',false);
  85  
  86      $form->addElement('style_submit_button', 'submit',get_lang('SearchUsers'),'class="search"');
  87      $defaults['active'] = 1;
  88      $defaults['inactive'] = 1;
  89      $form->setDefaults($defaults);
  90  
  91      // Display the form
  92      $form->display();
  93  } else {
  94      $limit = 20;
  95      $from = $page * $limit;
  96      //if user is crfp admin only list its sessions
  97      if(!api_is_platform_admin()) {
  98          $where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
  99      }
 100      else {
 101          $where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
 102      }
 103  
 104      $query = "SELECT sc.*, (select count(id) FROM $tbl_session WHERE session_category_id = sc.id) as nbr_session
 105                   FROM $tbl_session_category sc
 106                   $where
 107                   ORDER BY $sort $order
 108                   LIMIT $from,".($limit+1);
 109  
 110      $query_rows = "SELECT count(*) as total_rows
 111                  FROM $tbl_session_category sc $where ";
 112  
 113      $order = ($order == 'ASC')? 'DESC': 'ASC';
 114      $result_rows = Database::query($query_rows,__FILE__,__LINE__);
 115      $recorset = Database::fetch_array($result_rows);
 116      $num = $recorset['total_rows'];
 117      $result = Database::query($query,__FILE__,__LINE__);
 118      $Sessions = Database::store_result($result);
 119      $nbr_results = sizeof($Sessions);
 120  
 121      // Display the header
 122      Display::display_header(get_lang('ListSessionCategory'));
 123  
 124      // Display the tool title
 125      // api_display_tool_title(get_lang('ListSessionCategory'));
 126  
 127      if (!empty($_GET['warn'])) {
 128          Display::display_warning_message(urldecode($_GET['warn']),false);
 129      }
 130      if(isset($_GET['action'])) {
 131          Display::display_confirmation_message(stripslashes($_GET['message']),false);
 132      }
 133      ?>
 134  
 135      <div class="actions">
 136      <?php
 137      echo '<div style="float:right;">
 138              <a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_add.php">'.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSessionCategory').'</a>
 139             </div>';
 140      ?>
 141      <form method="POST" action="session_category_list.php">
 142          <input type="text" name="keyword" value="<?php echo Security::remove_XSS($_GET['keyword']); ?>"/>
 143          <button class="search" type="submit" name="name" value="<?php echo get_lang('Search') ?>"><?php echo get_lang('Search') ?></button>
 144          <!-- <a href="session_list.php?search=advanced"><?php echo get_lang('AdvancedSearch'); ?></a> -->
 145          </form>
 146      <form method="post" action="<?php echo api_get_self(); ?>?action=delete&sort=<?php echo $sort; ?>" onsubmit="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;">
 147       </div>
 148      <div align="left">
 149      <?php
 150      if(count($Sessions)==0 && isset($_POST['keyword'])) {
 151          echo get_lang('NoSearchResults');
 152          echo '</div>';
 153      } else {
 154          if ($num > $limit) {
 155              if ($page) {
 156              ?>
 157              <a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&order=<?php echo  Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
 158              <?php
 159              } else {
 160                  echo get_lang('Previous');
 161              }
 162              ?>
 163              |
 164              <?php
 165              if($nbr_results > $limit) {
 166                  ?>
 167                  <a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&order=<?php echo  Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
 168                  <?php
 169              } else {
 170                  echo get_lang('Next');
 171              }
 172          }
 173          ?>
 174      </div>
 175      
 176      <?php 
 177      // start the content div
 178      echo '<div id="content">';
 179      ?>
 180  
 181          <table class="data_table" width="100%">
 182          <tr>
 183            <th>&nbsp;</th>
 184            <th><a href="<?php echo api_get_self(); ?>?sort=name&order=<?php echo ($sort=='name')? $order: 'ASC'; ?>"><?php echo get_lang('SessionCategoryName'); ?></a></th>
 185            <th><a href="<?php echo api_get_self(); ?>?sort=nbr_session&order=<?php echo ($sort=='nbr_session')? $order: 'ASC'; ?>"><?php echo get_lang('NumberOfSession'); ?></a></th>
 186            <th><a href="<?php echo api_get_self(); ?>?sort=date_start&order=<?php echo ($sort=='date_start')? $order: 'ASC'; ?>"><?php echo get_lang('StartDate'); ?></a></th>
 187            <th><a href="<?php echo api_get_self(); ?>?sort=date_end&order=<?php echo ($sort=='date_end')? $order: 'ASC'; ?>"><?php echo get_lang('EndDate'); ?></a></th>
 188            <th><?php echo get_lang('Actions'); ?></th>
 189          </tr>
 190  
 191          <?php
 192          $i=0;
 193          $x=0;
 194          foreach ($Sessions as $key=>$enreg) {
 195              if($key == $limit) {
 196                  break;
 197              }
 198          $sql = 'SELECT COUNT(session_category_id) FROM '.$tbl_session.' WHERE session_category_id = '.intval($enreg['id']);
 199          $rs = Database::query($sql, __FILE__, __LINE__);
 200          list($nb_courses) = Database::fetch_array($rs);
 201          ?>
 202          <tr class="<?php echo $i?'row_odd':'row_even'; ?>">
 203            <td><input type="checkbox" id="idChecked_<?php echo $x; ?>" name="idChecked[]" value="<?php echo $enreg['id']; ?>"></td>
 204            <td><?php echo api_htmlentities($enreg['name'],ENT_QUOTES,$charset); ?></td>
 205            <td><?php echo "<a href=\"session_list.php?id_category=".$enreg['id']."\">".$nb_courses." Sesion(es) </a>"; ?></td>
 206            <td><?php echo api_htmlentities($enreg['date_start'],ENT_QUOTES,$charset); ?></td>
 207            <td><?php echo api_htmlentities($enreg['date_end'],ENT_QUOTES,$charset); ?></td>
 208            <td>
 209              <a href="session_category_edit.php?&id=<?php echo $enreg['id']; ?>"><?php Display::display_icon('pixel.gif', get_lang('Edit'),array('class'=>'actionplaceholdericon actionedit')); ?></a>
 210              <a href="<?php echo api_get_self(); ?>?sort=<?php echo $sort; ?>&action=delete_off_session&idChecked=<?php echo $enreg['id']; ?>" onclick="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;"><?php Display::display_icon('delete.png', get_lang('Delete')); ?></a>
 211            </td>
 212          </tr>
 213          <?php
 214              $i=$i ? 0 : 1;
 215              $x++;
 216          }
 217          unset($Sessions);
 218          ?>
 219          </table>
 220          <br />
 221  
 222          <div align="left">
 223  
 224          <?php
 225  
 226          if ($num > $limit) {
 227          if ($page)
 228              {
 229              ?>
 230  
 231              <a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&order=<?php echo  Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
 232  
 233              <?php
 234              }
 235              else
 236              {
 237                  echo get_lang('Previous');
 238              }
 239              ?>
 240  
 241              |
 242  
 243              <?php
 244              if($nbr_results > $limit)
 245              {
 246              ?>
 247  
 248              <a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&order=<?php echo  Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
 249  
 250              <?php
 251              }
 252              else
 253              {
 254                  echo get_lang('Next');
 255              }
 256          } ?>
 257          </div>
 258          <br />
 259          <a href="#" onclick="selectAll('idChecked',<?php echo $x; ?>,'true');return false;"><?php echo get_lang('SelectAll') ?></a>&nbsp;-&nbsp;
 260          <a href="#" onclick="selectAll('idChecked',<?php echo $x; ?>,'false');return false;"><?php echo get_lang('UnSelectAll') ?></a>
 261          <select name="action">
 262              <option value="delete_off_session" selected="selected"><?php echo get_lang('DeleteSelectedSessionCategory'); ?></option>
 263              <option value="delete_on_session"><?php echo get_lang('DeleteSelectedFullSessionCategory'); ?></option>
 264          </select>
 265          <button class="save" type="submit" name="name" value="<?php echo get_lang('Ok') ?>"><?php echo get_lang('Ok') ?></button>
 266          <?php } ?>
 267      </table>
 268  
 269  <?php
 270  }
 271  
 272  // close the content div
 273  echo '</div>';
 274  
 275  // display the footer
 276  Display::display_footer();
 277  ?>

title

Description

title

Description

title

Description

title

title

Body