Dokeos PHP Cross Reference Learning Management Systems

Source: /main/admin/programme_list.php - 835 lines - 47266 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  include_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
  24  
  25  if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'export'){
  26      
  27      $data = export_csv_data();
  28      
  29      Export::export_table_csv($data);    
  30      break;
  31  }
  32  
  33  // setting the section (for the tabs)
  34  $this_section = SECTION_PLATFORM_ADMIN;
  35  
  36  // Access restrictions
  37  api_protect_admin_script(true);
  38  
  39  // setting breadcrumbs
  40  $interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'));
  41  $htmlHeadXtra[] = "<script>
  42                          function moveItem (origin , destination, sideItem, currItem) {                           
  43                                  
  44                                  for(var i = 0 ; i<origin.options.length ; i++) {
  45                                          if(origin.options[i].selected) {
  46                                          
  47                                                  destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
  48                                                  
  49                                                      for (var x = 1; x <= $('.sessionset_left').length; x++) {
  50                                                          if (x == currItem) {
  51                                                              continue;
  52                                                          }
  53                                                          var iSelect = document.getElementById('sessionset_left'+x);
  54                                                          if (sideItem == 'to-right') {
  55                                                              iSelect.options[i] = null;
  56                                                          } else if (sideItem == 'to-left') {
  57                                                              iSelect.options[iSelect.length] = new Option(origin.options[i].text,origin.options[i].value);
  58                                                          }
  59                                                      }
  60                                                  
  61                                                  origin.options[i]=null;
  62                                                  i = i-1;
  63                                          }
  64                                  }
  65                                  
  66                                  destination.selectedIndex = -1;
  67                                  sortOptions(destination.options);
  68                                  
  69                                  for (var x = 1; x <= $('.sessionset_left').length; x++) {
  70                                      if (x == currItem) {
  71                                          continue;
  72                                      }
  73                                      var iSelect = document.getElementById('sessionset_left'+x);
  74                                     if (sideItem == 'to-left') { 
  75                                          iSelect.selectedIndex = -1;
  76                                          sortOptions(iSelect.options); 
  77                                      }
  78                                  }
  79                                  
  80                          }
  81  
  82                          function sortOptions(options) {
  83  
  84                                  newOptions = new Array();
  85                                  for (i = 0 ; i<options.length ; i++)
  86                                          newOptions[i] = options[i];
  87  
  88                                  newOptions = newOptions.sort(mysort);
  89                                  options.length = 0;
  90                                  for(i = 0 ; i < newOptions.length ; i++)
  91                                          options[i] = newOptions[i];
  92                          }
  93  
  94                          function mysort(a, b) {
  95                                  if(a.text.toLowerCase() > b.text.toLowerCase()){
  96                                          return 1;
  97                                  }
  98                                  if(a.text.toLowerCase() < b.text.toLowerCase()){
  99                                          return -1;
 100                                  }
 101                                  return 0;
 102                          }    
 103                          
 104                          function valide() {                            
 105                                  var nbanswer = document.getElementById('nb_answers').value;
 106                                  for (var i = 1;i<=nbanswer;i++) {                                
 107                                          var options = document.getElementById('sessionset_right'+i).options;                                
 108                                          if (options.length != '0') {
 109                                          for (var j = 0 ; j<options.length ; j++)
 110                                              options[j].selected = true;
 111                                          }
 112                                  }
 113                                  document.programme.submit();
 114                          }
 115                          </script>";
 116  
 117  // Displaying the header
 118  Display::display_header($nameTools);
 119  
 120  echo '<div class="actions">';
 121  echo '<a href="'.api_get_self().'?action=add'.'">' . Display::return_icon('pixel.gif',get_lang('AddProgramme'), array('class' => 'toolactionplaceholdericon toolactionaddprogramme')) . get_lang('AddProgramme') . '</a>';
 122  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/catalogue_management.php">' . Display::return_icon('pixel.gif',get_lang('Catalogue'), array('class' => 'toolactionplaceholdericon toolactioncatalogue')) . get_lang('Catalogue') . '</a>';
 123  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/topic_list.php">' . Display :: return_icon('pixel.gif', get_lang('Topics'),array('class' => 'toolactionplaceholdericon toolactiontopic')) . get_lang('Topics') . '</a>';
 124  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/programme_list.php">' . Display :: return_icon('pixel.gif', get_lang('Programmes'),array('class' => 'toolactionplaceholdericon toolactionprogramme')) . get_lang('Programmes') . '</a>';
 125  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_list.php">' . Display :: return_icon('pixel.gif', get_lang('SessionList'),array('class' => 'toolactionplaceholdericon toolactionsession')) . get_lang('SessionList') . '</a>';
 126  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_export.php">'.Display::return_icon('pixel.gif',get_lang('ExportSessionListXMLCSV'),array('class' => 'toolactionplaceholdericon toolactionexportcourse')).get_lang('ExportSessionListXMLCSV').'</a>';
 127  echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_import.php">'.Display::return_icon('pixel.gif',get_lang('ImportSessionListXMLCSV'),array('class' => 'toolactionplaceholdericon toolactionimportcourse')).get_lang('ImportSessionListXMLCSV').'</a>';            
 128  echo '<a href="'.api_get_path(WEB_CODE_PATH).'coursecopy/copy_course_session.php">'.Display::return_icon('pixel.gif',get_lang('CopyFromCourseInSessionToAnotherSession'),array('class' => 'toolactionplaceholdericon toolsettings')).get_lang('CopyFromCourseInSessionToAnotherSession').'</a>';
 129  echo '</div>';
 130  
 131  $topic_table                = Database :: get_main_table(TABLE_MAIN_TOPIC);
 132  $session_table              = Database :: get_main_table(TABLE_MAIN_SESSION);
 133  $tbl_session_category       = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
 134  $session_rel_category       = Database :: get_main_table(TABLE_MAIN_SESSION_REL_CATEGORY);
 135  $tbl_session                = Database :: get_main_table(TABLE_MAIN_SESSION);
 136  $tbl_session_cat_rel_user   = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY_REL_USER);
 137  
 138  echo '<div id="content">';
 139  
 140  if(!isset($_REQUEST['action'])){
 141      $default_column = api_is_allowed_to_edit() ? 1 : 0;
 142      $tablename = 'programme_table';
 143      $sortable_data = get_programme_data();
 144  
 145      $table = new SortableTableFromArrayConfig($sortable_data,$default_column,20,$tablename,$column_show,$column_order,'ASC');
 146  
 147      if (api_is_allowed_to_edit()){
 148      $table->set_header(0, '', false);    
 149      $table->set_header(1, get_lang('Programme'));
 150      $table->set_header(2, get_lang('Topic'));    
 151      $table->set_header(3, get_lang('Sessions'));    
 152      $table->set_header(4, get_lang('Start'));
 153      $table->set_header(5, get_lang('End'));
 154      $table->set_header(6, get_lang('Edit'));
 155      $table->set_header(7, get_lang('Delete'));
 156      }
 157      if (api_is_allowed_to_edit()){
 158          $table->set_form_actions(array ('delete_programme' => get_lang('Delete')));
 159      } 
 160      $table->display();
 161  }
 162  
 163  if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
 164      echo '<script>
 165      $(document).ready(function (){
 166          $("#currency").change(function() {            
 167              var currency = $("#currency").val();
 168              if(currency == "840"){
 169                  $("#comma").hide();
 170                  $("#dot").show();
 171              }
 172              else {
 173                  $("#comma").show();
 174                  $("#dot").hide();
 175              }
 176          });
 177  });
 178      </script>';
 179  
 180      $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3;
 181      $nb_answers += ( isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
 182      
 183      if($nb_answers == '0') $nb_answers = 1;
 184      //if($nb_answers > '3')$nb_answers = 3;
 185      
 186      $form = new FormValidator('programme', 'post',api_get_self().'?action=add');
 187      $renderer = & $form->defaultRenderer();
 188      $form->addElement('header', '', get_lang('ProgrammeSettings'));
 189      $form->addElement('text', 'programme_name', get_lang('ProgrammeName'), 'class="focus";style="width:300px;"');        
 190          $form->addRule('programme_name', get_lang('ThisFieldIsRequired'), 'required');  
 191          
 192      $form->addElement('text', 'programme_code', get_lang('SessionCategoryCode'), 'class="focus";style="width:200px;"');
 193          $form->addRule('programme_code', get_lang('ThisFieldIsRequired'), 'required');  
 194      
 195      $form->addElement('html','<div class="row"><div style="width:100%;">'.get_lang('CatalogueDescription').'</div></div>');
 196      $renderer->setElementTemplate('<div class="row"><div style="width:100%;float:right;">{element}</div></div>', 'catalogue_description');
 197      $form->addElement('html_editor', 'catalogue_description',null,'style="vertical-align:middle"',array('ToolbarSet' => 'Documents', 'Width' => '100%', 'Height' => '200'));
 198      $sql = "SELECT id,topic FROM $topic_table";
 199      $res = Database::query($sql,__FILE__,__LINE__);
 200      $topics = array();    
 201      while ($obj = Database::fetch_object($res)) {
 202          $topics[$obj->id] = $obj->topic;
 203      }
 204      $form->addElement('select', 'topics', get_lang('Topic'), $topics);
 205      $form->addElement('text', 'location', get_lang('Location'), 'class="focus";style="width:300px;"');
 206      $modality = array('E-learning' => get_lang('Elearning'), 'Blended' => get_lang('Blended'), 'Face to Face' => get_lang('FacetoFace'), 'Certifying' => get_lang('Certifying'));
 207      $form->addElement('select', 'modality', get_lang('Modality'), $modality);
 208      $form->addElement('text', 'keywords', get_lang('Keywords'), 'class="focus";style="width:600px;"');
 209      $form->addElement('datepicker', 'start', get_lang('Start'), array('form_name'=>'programme'));
 210      $form->addElement('datepicker', 'end', get_lang('End'), array('form_name'=>'programme'));
 211      $form->addElement('text', 'student_access', get_lang('StudentAccess'), 'class="focus";style="width:50px;"');
 212      $form->addElement('select_language', 'language', get_lang('CourseLanguage'));
 213      $form->applyFilter('select_language','html_filter');
 214      $radios_catalogue_visible[] = FormValidator :: createElement('radio', null, null, get_lang('Yes'), '1');
 215      $radios_catalogue_visible[] = FormValidator :: createElement('radio', null, null, get_lang('No'), '0');
 216      $form->addGroup($radios_catalogue_visible, 'catalogue_visible', get_lang('CatalogueVisible'));
 217  /*    $form->addElement('text', 'unitprice', get_lang('UnitPrice'), 'class="focus";style="width:100px;"');
 218      $form->addRule('unitprice', get_lang('ThisFieldIsRequired'), 'required'); 
 219      $form->addRule('unitprice', get_lang('ThisFieldIsNumeric'), 'numeric'); */
 220      
 221      $group = array();
 222      $group[] = FormValidator::createElement('text', 'unitprice1', '', 'class="focus";style="width:100px;"');
 223      $group[] = FormValidator::createElement('static', 'unitprice2', '', '<img id="comma" src="../img/comma.png" style="vertical-align:bottom;"><img id="dot" src="../img/dot.png" style="display:none;vertical-align:bottom;">');
 224      $group[] = FormValidator::createElement('text', 'unitprice3', '', 'class="focus";style="width:100px;"');
 225      
 226      $element_template = <<<EOT
 227      <div class="row">        
 228          <div style="display:inline;width:100%;">
 229              <table cellpadding="0" cellspacing="0" style="padding-left:30px;">
 230                  <tr>
 231                      <!-- BEGIN error --><span class="form_error" style="padding-left:470px;">{error}</span><br /><!-- END error -->    <td>{element}</td>
 232                  </tr>
 233              </table>
 234          </div>
 235      </div>
 236  EOT;
 237      $renderer = &$form->defaultRenderer();
 238      $renderer -> setElementTemplate($element_template, 'group');
 239      $form -> addGroup($group,'unitpricegroup',get_lang('UnitPrice'));
 240      $form->addRule('unitpricegroup', get_lang('ThisFieldIsRequired'), 'required');
 241  
 242      $currency = array('978' => 'EUR - Euros', '840' => 'USD - U.S.Dollars');
 243      $form->addElement('select', 'currency', get_lang('Currency'), $currency,'id="currency"');
 244      $form->addElement('hidden', 'tax', get_lang('Tax'), 'class="focus";style="width:50px;"');
 245          
 246          $form->addElement('html','<div class="row"><div style="width:100%;padding-left:30px;"><b>'.get_lang('InscriptionCalendar').'</b></div></div>');
 247          $form->addElement('datepicker', 'inscription_start', get_lang('Start'), array('form_name'=>'programme'));
 248      $form->addElement('datepicker', 'inscription_end', get_lang('End'), array('form_name'=>'programme'));
 249          
 250      $form->addElement('html','<div class="row"><div style="width:100%;padding-left:30px;"><b>'.get_lang('ProgrammeContentOptions').'</b></div></div>');
 251  //    $form->addElement('html','<div class="row"><div style="width:100%;padding-left:30px;"><b>'.get_lang('SessionSet').'</b></div></div>');
 252      $sql = "SELECT id, name, nbr_courses FROM $session_table";
 253      $res = Database::query($sql,__FILE__,__LINE__);
 254      $sessions = array();
 255          $nbr_courses = 0;
 256      while($obj = Database::fetch_object($res)) {
 257          $sessions[$obj->id] = $obj->name.' ('.$obj->nbr_courses.' '.get_lang('Courses').')';
 258                  $nbr_courses += $obj->nbr_courses;
 259      }
 260      $sessionset_right1 = array();
 261  
 262      for($i=1;$i<=$nb_answers;$i++){
 263      $form->addElement('text', 'session_set'.$i, get_lang('SessionSet').'&nbsp;'.$i, 'class="focus";style="width:200px;"');
 264      $group = array();
 265      $group[] = FormValidator::createElement('select', 'sessionset_left'.$i, '', $sessions, 'id="sessionset_left'.$i.'" multiple=multiple size="7" style="width: 350px;" class="sessionset_left"');
 266      $group[] = FormValidator::createElement('select', 'sessionset_right'.$i, '', $sessionset_right1, 'id="sessionset_right'.$i.'" multiple=multiple size="7" style="width: 350px;" class="sessionset_right"');
 267      $element_template = <<<EOT
 268      <div class="row">        
 269          <div style="display:inline;width:100%;">
 270              <table cellpadding="0" cellspacing="0" style="padding-left:30px;">
 271                  <tr>
 272                      <!-- BEGIN error --><span class="form_error" style="padding-left:470px;">{error}</span><br /><!-- END error -->    <td>{element}</td>
 273                  </tr>
 274              </table>
 275          </div>
 276      </div>
 277  EOT;
 278      $renderer = &$form->defaultRenderer();
 279      $renderer -> setElementTemplate($element_template, 'group'.$i);
 280      $form -> addGroup($group,'group'.$i,'','</td><td width="80" align="center">'.
 281          '<input class="arrowr" style="width:30px;height:30px;padding-right:22px" type="button" onclick="moveItem(document.getElementById(\'sessionset_left'.$i.'\'), document.getElementById(\'sessionset_right'.$i.'\'), \'to-right\', '.$i.')" ><br><br>' .
 282          '<input class="arrowl" style="width:30px;height:30px;padding-right:22px" type="button" onclick="moveItem(document.getElementById(\'sessionset_right'.$i.'\'), document.getElementById(\'sessionset_left'.$i.'\'), \'to-left\', '.$i.')" ></td><td>');
 283      $form->addRule('group1', get_lang('ThisFieldIsRequired'), 'required');
 284  
 285      $max = range(0, $nbr_courses);    
 286          $maxgroup = array();
 287      $maxgroup[] = FormValidator::createElement('select', 'max'.$i, get_lang('Max'), $max, 'id="max'.$i.'" ');
 288      $maxgroup[] = FormValidator::createElement('select', 'min'.$i, get_lang('Min'), $max, 'id="min'.$i.'" ');
 289          
 290      $element_template = '<div class="row" ><div class="label"></div><div style="width:100%;padding-left:550px;">'.get_lang('ShouldSelect').'{element}</div></div>';    
 291      $renderer -> setElementTemplate($element_template, 'maxgroup'.$i);
 292      $form->addGroup($maxgroup,'maxgroup'.$i,'','&nbsp;&nbsp;'.get_lang('Min'));       
 293  
 294          if($i == 1){
 295              $defaults['maxgroup'.$i]['max'.$i] = 3;
 296              $defaults['maxgroup'.$i]['min'.$i] = 3;
 297      }
 298      elseif($i == 2){
 299              $defaults['maxgroup'.$i]['max'.$i] = 2;
 300              $defaults['maxgroup'.$i]['min'.$i] = 1;
 301      }
 302      elseif($i == 3){
 303              $defaults['maxgroup'.$i]['max'.$i] = 1;
 304              $defaults['maxgroup'.$i]['min'.$i] = 1;
 305      }
 306      
 307          
 308          }
 309      $form->addElement('html', '<table width="100%"><tr><td width="100%"><div style="padding-left:25px;">');                                
 310          if ($nb_answers > 1) {
 311              $form->addElement('submit', 'lessAnswers', '', 'style="background:url(\'../img/form-minus.png\') no-repeat;width:35px;height:40px;border:0px;"');
 312          } else {
 313              $form->addElement('static', 'lessAnswers', '', Display::return_icon('form-minus_na.png', '', array('style' => 'vertical-align:top;')));
 314          }
 315  
 316          $form->addElement('submit', 'moreAnswers', '', 'onclick="valide()"; style="background:url(\'../img/form-plus.png\') no-repeat;width:35px;height:40px;border:0px;"');        
 317          $form->addElement('html', '</div></td></tr></table>');
 318      
 319          $renderer->setElementTemplate('{element}', 'lessAnswers');
 320          
 321      $renderer->setElementTemplate('{element}&nbsp;', 'moreAnswers');  
 322      
 323          $form->addElement('hidden', 'nb_answers','','id="nb_answers"');
 324      $form->setConstants(array('nb_answers' => $nb_answers));
 325      //$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"');
 326      $form->addElement('style_submit_button', 'submit', get_lang('Ok'),'onclick="valide()"; class="save"');    
 327          
 328      $defaults['catalogue_visible'] = 1;
 329      $defaults['start'] = date('Y-m-d H:i:s');
 330      $defaults['end'] = date('Y-m-d H:i:s',time() + (7 * 24 * 60 * 60));
 331  
 332          
 333          $defaults['inscription_start'] = date('Y-m-d H:i:s');
 334      $defaults['inscription_end'] = date('Y-m-d H:i:s', time() + (7 * 24 * 60 * 60));
 335          
 336      $form->setDefaults($defaults);
 337      if($form -> validate()) {    
 338          $programme = $form->exportValues();
 339          $nb_answer = $programme['nb_answers'];
 340                  $programme['unitpricegroup']['unitprice1'] = empty($programme['unitpricegroup']['unitprice1'])?'0':intval($programme['unitpricegroup']['unitprice1']);
 341                  $programme['unitpricegroup']['unitprice3'] = empty($programme['unitpricegroup']['unitprice3'])?'0':intval($programme['unitpricegroup']['unitprice3']);
 342                  $cost = floatval($programme['unitpricegroup']['unitprice1'].'.'.$programme['unitpricegroup']['unitprice3']);
 343                  /*
 344          $cost = $programme['unitpricegroup']['unitprice1'];
 345                  
 346          if($programme['currency'] == '978'){
 347              $cost .= ',';
 348          }
 349          elseif($programme['currency'] == '840'){
 350              $cost .= '.';
 351          }
 352                  
 353          $cost .= $programme['unitpricegroup']['unitprice3'];
 354                  */
 355                  
 356          if(isset($_POST['submit'])){
 357  
 358          $sql = "INSERT INTO " . $tbl_session_category . " SET " .
 359                                             "name            = '".Database::escape_string($programme['programme_name'])."',
 360                                             description    = '".Database::escape_string($programme['catalogue_description'])."',
 361                                             topic                = '".$programme['topics']."',
 362                                             location         = '".Database::escape_string($programme['location'])."',
 363                                             modality                 = '".Database::escape_string($programme['modality'])."',
 364                                             keywords         = '".Database::escape_string($programme['keywords'])."',
 365                                             date_start             = '".$programme['start']."',
 366                                             date_end                 = '".$programme['end']."',
 367                                             student_access     = '".$programme['student_access']."',
 368                                             language     = '".Database::escape_string($programme['language'])."',
 369                                             visible     = '".$programme['catalogue_visible']."',
 370                                             currency     = '".$programme['currency']."',
 371                                             tax     = '".$programme['tax']."',
 372                                             cost        = '".$cost."',
 373                                                                                     inscription_date_start = '".$programme['inscription_start']."',
 374                                             inscription_date_end   = '".$programme['inscription_end']."',
 375                                             code        = '".$programme['programme_code']."'";
 376                      Database::query($sql, __FILE__, __LINE__);
 377                      $id = Database::insert_id();
 378                                        
 379                if (Database::affected_rows()){                          
 380                     for($i=1;$i<=$nb_answer;$i++){
 381                             $sessionset = $_POST['group'.$i]['sessionset_right'.$i];    
 382                             $sessionset_name = $_POST['session_set'.$i];    
 383                             foreach($sessionset as $key){
 384                                     $r_max = $programme['maxgroup'.$i]['max'.$i];
 385                                     $r_min = $programme['maxgroup'.$i]['min'.$i];
 386                                     $range = $r_max.'|'.$r_min;
 387                                     $sql = "INSERT INTO " . $session_rel_category . " SET " .
 388                                                                                        "category_id = '".$id."',
 389                                                                                        session_set  = '".$i."',
 390                                                                                        session_set_name            = '".$sessionset_name."',
 391                                                                                        session_id                = ".$key.",
 392                                                session_range = '$range'";                    
 393                                             Database::query($sql, __FILE__, __LINE__);
 394                                     // update category in session
 395                                     Database::query("UPDATE $tbl_session SET session_category_id = $id WHERE id = $key");
 396                             }
 397                     }
 398                }
 399                  
 400                  echo '<script>window.location.href = "'.api_get_self().'"</script>';
 401                  
 402          }
 403      //
 404      }
 405      
 406      $form->display();
 407  }
 408  if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit'){
 409  
 410      echo '<script>
 411      $(document).ready(function (){
 412          $("#currency").change(function() {            
 413              var currency = $("#currency").val();
 414              if(currency == "840"){
 415                  $("#comma").hide();
 416                  $("#dot").show();
 417              }
 418              else {
 419                  $("#comma").show();
 420                  $("#dot").hide();
 421              }
 422          });
 423  });
 424      </script>';
 425  
 426      $sql = "SELECT * FROM $tbl_session_category WHERE id = ".$_REQUEST['id'];
 427      $res = Database::query($sql,__FILE__,__LINE__);
 428      $programme_edit = Database::fetch_array($res);
 429  
 430      $sql_session = "SELECT count(DISTINCT(session_set)) AS session_set FROM $session_rel_category WHERE category_id = ".$_REQUEST['id'];
 431      $res_session = Database::query($sql_session,__FILE__,__LINE__);
 432      $session_set = Database::result($res_session, 0, 'session_set');
 433  
 434          $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3;
 435      $nb_answers += ( isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
 436      
 437      if($nb_answers == '0') $nb_answers = 1;
 438  
 439      $currency = $programme_edit['currency'];
 440      $cost = $programme_edit['cost'];
 441          $price1 = $price2 = 0;
 442          if (strpos($cost, '.') !== false) {
 443              list($price1, $price2) = explode('.', $cost);
 444          } else if (strpos($cost, ',') !== false) {
 445              list($price1, $price2) = explode(',', $cost);
 446          } else {
 447              $price1 = $cost;
 448              $price2 = 0;
 449          }
 450          
 451          /*
 452      if($currency == '978'){
 453          $find_string = ',';
 454      } else {
 455          $cost = str_replace('.',':',$cost);
 456          $find_string = ':';
 457      }    
 458          if (strpos($cost,$find_string) !== false){        
 459          list($price1,$price2) = split($find_string,$cost);        
 460      }*/     
 461                  
 462      $form = new FormValidator('programme', 'post',api_get_self().'?action=edit&id='.intval($_REQUEST['id']));
 463      $renderer = & $form->defaultRenderer();
 464      $form->addElement('header', '', get_lang('ProgrammeSettings'));
 465          
 466      $form->addElement('text', 'programme_name', get_lang('ProgrammeName'), 'class="focus";style="width:300px;"');        
 467          $form->addRule('programme_name', get_lang('ThisFieldIsRequired'), 'required');        
 468      $form->addElement('text', 'programme_code', get_lang('SessionCategoryCode'), 'class="focus";style="width:200px;"');
 469          $form->addRule('programme_code', get_lang('ThisFieldIsRequired'), 'required');
 470          
 471      $form->addElement('html','<div class="row"><div style="width:100%;">'.get_lang('CatalogueDescription').'</div></div>');
 472      $renderer->setElementTemplate('<div class="row"><div style="width:100%;float:right;">{element}</div></div>', 'catalogue_description');
 473      $form->addElement('html_editor', 'catalogue_description',null,'style="vertical-align:middle"',array('ToolbarSet' => 'Documents', 'Width' => '100%', 'Height' => '200'));
 474      $sql = "SELECT id,topic FROM $topic_table";
 475      $res = Database::query($sql,__FILE__,__LINE__);
 476      $topics = array();    
 477      while ($obj = Database::fetch_object($res)) {
 478              $topics[$obj->id] = $obj->topic;
 479      }
 480      $form->addElement('select', 'topics', get_lang('Topic'), $topics);
 481      $form->addElement('text', 'location', get_lang('Location'), 'class="focus";style="width:300px;"');
 482  //    $modality = array('E-learning','Blended','Face to Face','Certifying');    
 483  //    $modality = array('E-learning' => 'E-learning', 'Blended' => 'Blended', 'Face to Face' => 'Face to Face', 'Certifying' => 'Certifying');
 484      $modality = array('E-learning' => get_lang('Elearning'), 'Blended' => get_lang('Blended'), 'Face to Face' => get_lang('FacetoFace'), 'Certifying' => get_lang('Certifying'));
 485      $form->addElement('select', 'modality', get_lang('Modality'), $modality);
 486      $form->addElement('text', 'keywords', get_lang('Keywords'), 'class="focus";style="width:600px;"');
 487      $form->addElement('datepicker', 'start', get_lang('Start'), array('form_name'=>'programme'));
 488      $form->addElement('datepicker', 'end', get_lang('End'), array('form_name'=>'programme'));
 489      $form->addElement('text', 'student_access', get_lang('StudentAccess'), 'class="focus";style="width:50px;"');
 490      $form->addElement('select_language', 'language', get_lang('CourseLanguage'));
 491      $form->applyFilter('select_language','html_filter');
 492      $radios_catalogue_visible[] = FormValidator :: createElement('radio', null, null, get_lang('Yes'), '1');
 493      $radios_catalogue_visible[] = FormValidator :: createElement('radio', null, null, get_lang('No'), '0');
 494      $form->addGroup($radios_catalogue_visible, 'catalogue_visible', get_lang('CatalogueVisible'));
 495  //    $form->addElement('text', 'unitprice', get_lang('UnitPrice'), 'class="focus";style="width:100px;"');
 496  //    $currency = array('EUR - Euros','USD - U.S.Dollars');    
 497      
 498      $group = array();
 499      $group[] = FormValidator::createElement('text', 'unitprice1', '', 'class="focus";style="width:100px;"');
 500      if($currency == '978'){
 501      $group[] = FormValidator::createElement('static', 'unitprice2', '', '<img id="comma" src="../img/comma.png" style="vertical-align:bottom;"><img id="dot" src="../img/dot.png" style="display:none;vertical-align:bottom;">');
 502      }
 503      else {
 504      $group[] = FormValidator::createElement('static', 'unitprice2', '', '<img id="comma" src="../img/comma.png" style="display:none;vertical-align:bottom;"><img id="dot" src="../img/dot.png" style="vertical-align:bottom;">');
 505      }
 506      $group[] = FormValidator::createElement('text', 'unitprice3', '', 'class="focus";style="width:100px;"');
 507      
 508      $element_template = <<<EOT
 509      <div class="row">        
 510          <div style="display:inline;width:100%;">
 511              <table cellpadding="0" cellspacing="0" style="padding-left:30px;">
 512                  <tr>
 513                      <!-- BEGIN error --><span class="form_error" style="padding-left:470px;">{error}</span><br /><!-- END error -->    <td>{element}</td>
 514                  </tr>
 515              </table>
 516          </div>
 517      </div>
 518  EOT;
 519      $renderer = &$form->defaultRenderer();
 520      $renderer -> setElementTemplate($element_template, 'group');
 521      $form -> addGroup($group,'unitpricegroup',get_lang('UnitPrice'));
 522      $form->addRule('unitpricegroup', get_lang('ThisFieldIsRequired'), 'required');
 523  
 524      $defaults['unitpricegroup']['unitprice1'] = $price1;
 525      $defaults['unitpricegroup']['unitprice3'] = $price2;
 526  
 527      $currency = array('978' => 'EUR - Euros', '840' => 'USD - U.S.Dollars');
 528      $form->addElement('select', 'currency', get_lang('Currency'), $currency,'id="currency"');
 529      $form->addElement('hidden', 'tax', get_lang('Tax'), 'class="focus";style="width:50px;"');
 530          
 531          $form->addElement('html','<div class="row"><div style="width:100%;padding-left:30px;"><b>'.get_lang('InscriptionCalendar').'</b></div></div>');
 532          $form->addElement('datepicker', 'inscription_start', get_lang('Start'), array('form_name'=>'programme'));
 533      $form->addElement('datepicker', 'inscription_end', get_lang('End'), array('form_name'=>'programme'));
 534          
 535      $form->addElement('html','<div class="row"><div class="form_header" style="width:100%;padding-left:30px;"><b>'.get_lang('ProgrammeContentOptions').'</b></div></div>');
 536                  
 537      for ($i=1;$i<=$nb_answers;$i++) {
 538         //   $form->addElement('html','<div class="row"><div style="width:100%;padding-left:30px;"><b>'.get_lang('SessionSet').'&nbsp;'.$i.'</b></div></div>');
 539              $form->addElement('text', 'session_set'.$i, get_lang('SessionSet').'&nbsp;'.$i, 'class="focus";style="width:200px;"');
 540              $sessions = array();
 541              $sessionset_right1 = array();
 542              $sessionid_arr = array();
 543              $sessionset_name = '';
 544              $sql1 = "SELECT * FROM $session_rel_category WHERE category_id = ".$_REQUEST['id']." AND session_set = '".$i."'";
 545              $res1 = Database::query($sql1,__FILE__,__LINE__);
 546              $num_prg = Database::num_rows($res1);
 547              $a_rel_cat = array();
 548              if ($num_prg == 0) {            
 549                  $sessionid_arr[] = '\' \'';
 550              }
 551              else {
 552                  while($row1 = Database::fetch_array($res1)){  
 553                      $a_rel_cat[] = array('session_set' => $row1['session_set'], 'range' => $row1['session_range']);
 554                      $sessionid_arr[] = $row1['session_id'];
 555                      $sessionset_name = $row1['session_set_name'];
 556                  }
 557              }
 558              $defaults['session_set'.$i] = $sessionset_name;
 559  
 560              $session_id1 = implode(",",$sessionid_arr);
 561              $sql = "SELECT id, name, nbr_courses FROM $session_table WHERE id NOT IN (SELECT session_id FROM $session_rel_category WHERE category_id = {$_REQUEST['id']})";
 562  
 563              $res = Database::query($sql,__FILE__,__LINE__);
 564              $sessions = array();
 565              $nbr_courses = 0;
 566              while ($obj = Database::fetch_object($res)) {
 567                      $sessions[$obj->id] = $obj->name.' ('.$obj->nbr_courses.' '.get_lang('Courses').')';
 568                      $nbr_courses += $obj->nbr_courses;
 569              }
 570  
 571              $sql = "SELECT id, name, nbr_courses FROM $session_table WHERE id IN (".$session_id1.")";
 572              $res = Database::query($sql,__FILE__,__LINE__);
 573              $sessionset_right1 = array();    
 574              while ($obj = Database::fetch_object($res)) {
 575                      $sessionset_right1[$obj->id] = $obj->name.' ('.$obj->nbr_courses.' '.get_lang('Courses').')';
 576                      $nbr_courses += $obj->nbr_courses;
 577              }
 578  
 579      $group = array();
 580      $group[] = FormValidator::createElement('select', 'sessionset_left'.$i, '', $sessions, 'id="sessionset_left'.$i.'" multiple=multiple size="7" style="width: 350px;" class="sessionset_left"');
 581      $group[] = FormValidator::createElement('select', 'sessionset_right'.$i, '', $sessionset_right1, 'id="sessionset_right'.$i.'" multiple=multiple size="7" style="width: 350px;" class="sessionset_right"');
 582      $element_template = <<<EOT
 583      <div class="row">        
 584          <div style="display:inline;width:100%;">
 585              <table cellpadding="0" cellspacing="0" style="padding-left:30px;">
 586                  <tr><!-- BEGIN error --><span class="form_error" style="padding-left:470px;">{error}</span><br /><!-- END error --><td>{element}</td></tr>
 587              </table>
 588          </div>
 589      </div>
 590  EOT;
 591          
 592              $renderer = &$form->defaultRenderer();
 593              $renderer -> setElementTemplate($element_template, 'group'.$i);
 594              $form -> addGroup($group,'group'.$i,'','</td><td width="80" align="center">'.
 595                      '<input class="arrowr" style="width:30px;height:30px;padding-right:22px" type="button" onclick="moveItem(document.getElementById(\'sessionset_left'.$i.'\'), document.getElementById(\'sessionset_right'.$i.'\'), \'to-right\', '.$i.')" ><br><br>' .
 596                      '<input class="arrowl" style="width:30px;height:30px;padding-right:22px" type="button" onclick="moveItem(document.getElementById(\'sessionset_right'.$i.'\'), document.getElementById(\'sessionset_left'.$i.'\'), \'to-left\', '.$i.')" ></td><td>');
 597              $form->addRule('group1', get_lang('ThisFieldIsRequired'), 'required');
 598                    
 599              $max = range(0, $nbr_courses);    
 600              $maxgroup = array();
 601              $maxgroup[] = FormValidator::createElement('select', 'max'.$i, get_lang('Max'), $max, 'id="max'.$i.'"');
 602              $maxgroup[] = FormValidator::createElement('select', 'min'.$i, get_lang('Min'), $max, 'id="min'.$i.'"');
 603              $element_template = '<div class="row" ><div class="label"></div><div style="width:100%;padding-left:550px;">'.get_lang('ShouldSelect').'{element}</div></div>';    
 604              $renderer -> setElementTemplate($element_template, 'maxgroup'.$i);
 605              $form->addGroup($maxgroup,'maxgroup'.$i,'','&nbsp;&nbsp;'.get_lang('Min'));        
 606              if (!empty($a_rel_cat)) {            
 607                  foreach ($a_rel_cat as $rel_cat) {
 608                      $r_max = $r_min = 0;
 609                      if (!empty($rel_cat['range'])) {
 610                          list($r_max, $r_min) = explode('|', $rel_cat['range']);
 611                      }                
 612                      $defaults['maxgroup'.$rel_cat['session_set']]['max'.$rel_cat['session_set']] = $r_max;
 613                      $defaults['maxgroup'.$rel_cat['session_set']]['min'.$rel_cat['session_set']] = $r_min;
 614                  }            
 615              }        
 616      }
 617      $form->addElement('html', '<table width="100%"><tr><td width="100%"><div style="padding-left:25px;">');                
 618          if ($nb_answers > 1) {
 619              $form->addElement('submit', 'lessAnswers', '', 'style="background:url(\'../img/form-minus.png\') no-repeat;width:35px;height:40px;border:0px;"');
 620          } else {
 621              $form->addElement('static', 'lessAnswers', '', Display::return_icon('form-minus_na.png', '', array('style' => 'vertical-align:top;')));
 622          }    
 623          $form->addElement('submit', 'moreAnswers', '', 'style="background:url(\'../img/form-plus.png\') no-repeat;width:35px;height:40px;border:0px;"');
 624      $form->addElement('html', '</div></td></tr></table>');
 625      $renderer->setElementTemplate('{element}', 'lessAnswers');
 626      $renderer->setElementTemplate('{element}&nbsp;', 'moreAnswers');  
 627      $form->addElement('hidden', 'nb_answers','','id="nb_answers"');
 628  
 629      $form->setConstants(array('nb_answers' => $nb_answers));
 630      $form->addElement('style_submit_button', 'submit', get_lang('Ok'),'onclick="valide()"; class="save"');    
 631      $defaults['programme_name'] = $programme_edit['name'];
 632      $defaults['programme_code'] = $programme_edit['code'];
 633      $defaults['catalogue_description'] = $programme_edit['description'];
 634      $defaults['topics'] = $programme_edit['topic'];
 635      $defaults['location'] = isset($programme_edit['location'])?$programme_edit['location']:'';
 636      $defaults['modality'] = $programme_edit['modality'];
 637      $defaults['keywords'] = $programme_edit['keywords'];
 638      $defaults['student_access'] = isset($programme_edit['student_access'])?$programme_edit['student_access']:'';
 639      $defaults['language'] = $programme_edit['language'];
 640      $defaults['catalogue_visible'] = $programme_edit['visible'];
 641  //    $defaults['unitprice'] = $programme_edit['cost'];
 642      $defaults['currency'] = $programme_edit['currency'];
 643      $defaults['tax'] = $programme_edit['tax'];
 644      $defaults['start'] = $programme_edit['date_start'];
 645      $defaults['end'] = $programme_edit['date_end'];    
 646          $defaults['inscription_start'] = $programme_edit['inscription_date_start'];
 647      $defaults['inscription_end'] = $programme_edit['inscription_date_end'];
 648          $form->setDefaults($defaults);        
 649      if($form -> validate()) {
 650  
 651              $programme = $form->exportValues();
 652              $nb_answer = $programme['nb_answers'];
 653              $programme['unitpricegroup']['unitprice1'] = empty($programme['unitpricegroup']['unitprice1'])?'0':intval($programme['unitpricegroup']['unitprice1']);
 654              $programme['unitpricegroup']['unitprice3'] = empty($programme['unitpricegroup']['unitprice3'])?'0':intval($programme['unitpricegroup']['unitprice3']);            
 655              $cost = floatval($programme['unitpricegroup']['unitprice1'].'.'.$programme['unitpricegroup']['unitprice3']);
 656              
 657              /*
 658              $cost = $programme['unitpricegroup']['unitprice1'];
 659              if($programme['currency'] == '978'){
 660                      $cost .= ',';
 661              }
 662              elseif($programme['currency'] == '840'){
 663                      $cost .= '.';
 664              }
 665              $cost .= $programme['unitpricegroup']['unitprice3'];
 666               */
 667  
 668              if(isset($_POST['submit'])) {
 669                  $sql = "UPDATE " . $tbl_session_category . " SET " .
 670                                                                                     "name            = '".Database::escape_string($programme['programme_name'])."',
 671                                                                                     description    = '".Database::escape_string($programme['catalogue_description'])."',
 672                                                                                     topic                = ".$programme['topics'].",
 673                                                                                     location         = '".Database::escape_string($programme['location'])."',
 674                                                                                     modality                 = '".Database::escape_string($programme['modality'])."',
 675                                                                                     keywords         = '".Database::escape_string($programme['keywords'])."',
 676                                                                                     date_start             = '".$programme['start']."',
 677                                                                                     date_end                 = '".$programme['end']."',
 678                                                                                     student_access     = '".$programme['student_access']."',
 679                                                                                     language     = '".Database::escape_string($programme['language'])."',
 680                                                                                     visible     = '".$programme['catalogue_visible']."',
 681                                                                                     currency     = '".$programme['currency']."',
 682                                                                                     tax     = '".$programme['tax']."',
 683                                                                                     cost        = '".$cost."',
 684                                                                                     inscription_date_start = '".$programme['inscription_start']."',
 685                                                                                     inscription_date_end   = '".$programme['inscription_end']."',
 686                                                                                     code        = '".$programme['programme_code']."'
 687                                                                                     WHERE id = ".$_REQUEST['id'];
 688  
 689                                          Database::query($sql, __FILE__, __LINE__);
 690  
 691                   $sql = "DELETE FROM $session_rel_category WHERE category_id = ".$_REQUEST['id'];
 692  
 693                   Database::query($sql, __FILE__, __LINE__);
 694                  for($i=1;$i<=$nb_answer;$i++){
 695                          $sessionset = $_POST['group'.$i]['sessionset_right'.$i];
 696                          $sessionset_name = $_POST['session_set'.$i];
 697                          foreach($sessionset as $key){
 698                              $r_max = $programme['maxgroup'.$i]['max'.$i];
 699                              $r_min = $programme['maxgroup'.$i]['min'.$i];
 700                              $range = $r_max.'|'.$r_min;
 701                                  $sql = "INSERT INTO $session_rel_category SET 
 702                                              category_id = {$_REQUEST['id']},
 703                                              session_set    = $i,
 704                                              session_set_name    = '".$sessionset_name."',
 705                                              session_id    = $key,
 706                                              session_range = '$range';";                         
 707                                          Database::query($sql, __FILE__, __LINE__);
 708                              // update category in session
 709                              Database::query("UPDATE $tbl_session SET session_category_id = {$_REQUEST['id']} WHERE id = $key");
 710                          }
 711                  }
 712                  echo '<script>window.location.href = "'.api_get_self().'"</script>';
 713              }            
 714      }    
 715      $form->display();
 716  }
 717  if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete'){
 718  
 719      $sql = "DELETE FROM $session_rel_category WHERE category_id = ".intval($_REQUEST['id']);
 720      Database::query($sql,__FILE__,__LINE__);
 721  
 722      $sql = "DELETE FROM $tbl_session_category WHERE id = ".intval($_REQUEST['id']);
 723      Database::query($sql,__FILE__,__LINE__);
 724          
 725          // clean category rel user
 726          $verify = Database::query("SELECT * FROM $tbl_session_cat_rel_user WHERE category_id =".intval($_REQUEST['id']));
 727          if (Database::num_rows($verify)) {
 728              Database::query("DELETE FROM $tbl_session_cat_rel_user WHERE category_id =".intval($_REQUEST['id']));
 729          }
 730  
 731      echo '<script>window.location.href = "'.api_get_self().'"</script>';
 732  
 733  }
 734  if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete_programme'){
 735      
 736      if(isset($_POST['id'])){
 737          $delete_id = $_POST['id'];
 738      }
 739      foreach ($delete_id as $index => $programme_id){
 740      $sql = "DELETE FROM $session_rel_category WHERE category_id = ".$programme_id;
 741      Database::query($sql,__FILE__,__LINE__);
 742  
 743      $sql = "DELETE FROM $tbl_session_category WHERE id = ".$programme_id;
 744      Database::query($sql,__FILE__,__LINE__);
 745      }
 746      echo '<script>window.location.href = "'.api_get_self().'"</script>';
 747  }
 748  
 749  function get_programme_data(){
 750      $topic_table         = Database :: get_main_table(TABLE_MAIN_TOPIC);
 751      $tbl_session_category         = Database :: get_main_table(TABLE_MAIN_SESSION_CATEGORY);
 752      $session_rel_category         = Database :: get_main_table(TABLE_MAIN_SESSION_REL_CATEGORY);
 753  
 754      $sql = "SELECT * FROM $tbl_session_category";
 755      $res = Database::query($sql,__FILE__,__LINE__);
 756      $programmes = array ();
 757      while ($programme = Database::fetch_array($res)) {    
 758          $num_session = 0;
 759          $programme_name = '<img align="top" src="'.api_get_path(WEB_IMG_PATH).'/topic_22.png" />&nbsp;&nbsp;'.$programme['name'];
 760          
 761          $sql_topic = "SELECT topic FROM $topic_table WHERE id = ".$programme['topic'];
 762          $res_topic = Database::query($sql_topic,__FILE__,__LINE__);
 763          $topic_name = Database::result($res_topic, 0, 'topic');
 764  
 765          $sql_session = "SELECT DISTINCT(session_id) AS no_session FROM $session_rel_category WHERE category_id = ".$programme['id'];
 766          $res_session = Database::query($sql_session,__FILE__,__LINE__);
 767          $num_session = Database::num_rows($res_session);
 768          if(empty($num_session))$num_session = 0;
 769          
 770          $datetime = explode(" ", $programme['date_start']);
 771          $dateparts = explode("-", $datetime[0]);        
 772          $start = $dateparts[2].'-'.$dateparts[1].'-'.$dateparts[0];
 773  
 774          $datetime = explode(" ", $programme['date_end']);
 775          $dateparts = explode("-", $datetime[0]);        
 776          $end = $dateparts[2].'-'.$dateparts[1].'-'.$dateparts[0];
 777  
 778          $edit_link = '<center><a href="'.api_get_self().'?action=edit&id='.$programme['id'].'">'.Display::return_icon('pixel.gif', get_lang('Edit'), array('class' => 'actionplaceholdericon actionedit')).'</a></center>';
 779          $delete_link = '<center><a href="'.api_get_self().'?action=delete&id='.$programme['id'].'" onclick="javascript:if(!confirm(\''.get_lang('ConfirmYourChoice').'\')) return false;">'.Display::return_icon('pixel.gif', get_lang('Delete'), array('class' => 'actionplaceholdericon actiondelete')).'</a></center>';
 780  
 781          $programmes[] = array($programme['id'],$programme_name,'<center>'.$topic_name.'</center>','<center>'.$num_session.'&nbsp;'.get_lang('Sessions').'</center>','<center>'.$start.'</center>','<center>'.$end.'</center>',$edit_link,$delete_link);
 782      }
 783      return $programmes;
 784  }
 785  
 786  echo '</div>';
 787  
 788  echo '<div class="actions"><a href="programme_list.php?'.api_get_cidreq().'&action=export&type=csv">'.Display::return_icon('pixel.gif', get_lang('ExportAsCSV'), array('class' => 'actionplaceholdericon actionexport')).get_lang('ExportAsCSV').'</a></div>';
 789  
 790  function export_csv_data(){
 791  
 792      $topic_table         = Database :: get_main_table(TABLE_MAIN_TOPIC);
 793      $tbl_session_category         = Database :: get_main_table(TABLE_MAIN_SESSION_CATEGORY);
 794      $session_rel_category         = Database :: get_main_table(TABLE_MAIN_SESSION_REL_CATEGORY);
 795  
 796      $data = array();
 797      $data[] = array(get_lang('Programme'),get_lang('Topic'),get_lang('Sessions'),get_lang('Start'),get_lang('End'));
 798  
 799      $sql = "SELECT * FROM $tbl_session_category";
 800      $res = Database::query($sql,__FILE__,__LINE__);
 801      $programmes = array ();
 802      while ($programme = Database::fetch_array($res)) {    
 803          $programme_name = $programme['name'];
 804          $sql_topic = "SELECT topic FROM $topic_table WHERE id = ".$programme['topic'];
 805          $res_topic = Database::query($sql_topic,__FILE__,__LINE__);
 806          $topic_name = Database::result($res_topic, 0, 'topic');
 807  
 808          $sql_session = "SELECT DISTINCT(session_id) AS no_session FROM $session_rel_category WHERE category_id = ".$programme['id'];
 809          $res_session = Database::query($sql_session,__FILE__,__LINE__);
 810          $num_session = Database::num_rows($res_session);
 811          if(empty($num_session))$num_session = 0;
 812          
 813          $datetime = explode(" ", $programme['date_start']);
 814          $dateparts = explode("-", $datetime[0]);        
 815          $start = $dateparts[2].'-'.$dateparts[1].'-'.$dateparts[0];
 816  
 817          $datetime = explode(" ", $programme['date_end']);
 818          $dateparts = explode("-", $datetime[0]);        
 819          $end = $dateparts[2].'-'.$dateparts[1].'-'.$dateparts[0];
 820          $row = array();
 821                      
 822          $row[] = $programme_name;
 823          $row[] = $topic_name;    
 824          $row[] = $num_session;    
 825          $row[] = $start;
 826          $row[] = $end;
 827          $data[] = $row;
 828      }
 829      return $data;
 830  }
 831  
 832  // display the footer
 833  Display::display_footer();
 834  ?>
 835  

title

Description

title

Description

title

Description

title

title

Body