Dokeos PHP Cross Reference Learning Management Systems

Source: /main/mySpace/session.php - 157 lines - 4794 bytes - Summary - Text - Print

   1  <?php
   2  /* For licensing terms, see /dokeos_license.txt */
   3  /*
   4   * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
   5   * Somes fixes by Julio Montoya
   6   */
   7  ob_start();
   8  $nameTools= 'Sessions';
   9  // name of the language file that needs to be included
  10  $language_file = array ('registration', 'index', 'trad4all', 'tracking');
  11  $cidReset = true;
  12  
  13  require  '../inc/global.inc.php';
  14  require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
  15  require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  16  
  17  api_block_anonymous_users();
  18  
  19  $this_section = "session_my_space";
  20  
  21  api_block_anonymous_users();
  22  $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  23  Display :: display_header($nameTools);
  24  
  25  // Database Table Definitions
  26  $tbl_course_user         = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  27  $tbl_sessions             = Database :: get_main_table(TABLE_MAIN_SESSION);
  28  $tbl_session_course     = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  29  $tbl_course             = Database :: get_main_table(TABLE_MAIN_COURSE);
  30  
  31  $export_csv = false;
  32  
  33  if (isset($_GET['export']) && $_GET['export'] == 'csv') {
  34      $export_csv = true;
  35  }
  36  
  37  
  38  /*
  39  ===============================================================================
  40      FUNCTION
  41  ===============================================================================
  42  */
  43  
  44  function count_sessions_coached() {
  45      global $nb_sessions;
  46      return $nb_sessions;
  47  }
  48  
  49  function sort_sessions($a, $b) {
  50      global $tracking_column;
  51      if ($a[$tracking_column] > $b[$tracking_column]) {
  52          return 1;
  53      } else {
  54          return -1;
  55      }
  56  }
  57  
  58  function rsort_sessions($a, $b) {
  59      global $tracking_column;
  60      if ($b[$tracking_column] > $a[$tracking_column]) {
  61          return 1;
  62      } else {
  63          return -1;
  64      }
  65  }
  66  
  67  
  68  /*
  69  ===============================================================================
  70      MAIN CODE
  71  ===============================================================================
  72  */
  73  
  74  if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
  75      $id_coach = intval($_GET['id_coach']);
  76  } else {
  77      $id_coach = $_user['user_id'];
  78  }
  79  
  80  $a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
  81  $nb_sessions = count($a_sessions);
  82  
  83  if ($export_csv) {
  84      $csv_content = array();
  85  }
  86  
  87  if ($nb_sessions > 0) {
  88      echo '<div class="actions" align="right">
  89              <a href="javascript: void(0);" onclick="javascript: window.print();">'.Display::return_icon('pixel.gif',get_lang('Print'),array('class'=>'toolactionplaceholdericon toolactionprint32')).'&nbsp;'.get_lang('Print').'</a>
  90              <a href="'.api_get_self().'?export=csv">'.Display::return_icon('pixel.gif',get_lang('ExportAsCSV'),array('class'=>'toolactionplaceholdericon toolactionexportcourse')).'&nbsp'.get_lang('ExportAsCSV').'</a>
  91            </div>';
  92      $table = new SortableTable('tracking', 'count_sessions_coached');
  93      $table -> set_header(0, get_lang('Title'));
  94      $table -> set_header(1, get_lang('Status'));
  95      $table -> set_header(2, get_lang('Date'));
  96      $table -> set_header(3, get_lang('Details'), false);
  97  
  98      $all_data = array();
  99      foreach ($a_sessions as $session) {
 100          $row = array();
 101          $row[] = $session['name'];
 102          $row[] = $session['status'];
 103  
 104          if ($session['date_start'] != '0000-00-00' && $session['date_end'] != '0000-00-00') {
 105              $row[] = get_lang('From').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($session['date_start'])).' '.get_lang('To').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($session['date_end']));
 106          } else {
 107              $row[] = ' - ';
 108          }
 109  
 110          if ($export_csv) {
 111              $csv_content[] = $row;
 112          }
 113  
 114          if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
 115              $row[] = '<a href="student.php?id_session='.$session['id'].'&id_coach='.intval($_GET['id_coach']).'">'.Display::return_icon('pixel.gif','',array('class'=>'actionplaceholdericon actionstatisticsdetails')).'</a>';
 116          } else {
 117              $row[] = '<a href="course.php?id_session='.$session['id'].'">'.Display::return_icon('pixel.gif','',array('class'=>'actionplaceholdericon actionstatisticsdetails')).'</a>';
 118          }
 119          $all_data[] = $row;
 120      }
 121  
 122      if (!isset($tracking_column)) {
 123          $tracking_column = 0;
 124      }
 125  
 126      if ($_GET['tracking_direction'] == 'DESC') {
 127          usort($all_data, 'rsort_sessions');
 128      } else {
 129          usort($all_data, 'sort_sessions');
 130      }
 131  
 132      if ($export_csv) {
 133          usort($csv_content, 'sort_sessions');
 134      }
 135  
 136      foreach ($all_data as $row) {
 137          $table -> addRow($row);
 138      }
 139  echo '<div id="content">';
 140      $table -> setColAttributes(3, array('align' => 'center'));
 141      $table -> display();
 142  
 143      if ($export_csv) {
 144          ob_end_clean();
 145          Export :: export_table_csv($csv_content, 'reporting_student_list');
 146      }
 147  } else {
 148      get_lang('NoSession');
 149  }
 150  
 151  /*
 152  ==============================================================================
 153      FOOTER
 154  ==============================================================================
 155  */
 156  echo '</div>';
 157  Display::display_footer();

title

Description

title

Description

title

Description

title

title

Body