Dokeos PHP Cross Reference Learning Management Systems

Source: /main/admin/registration_step3.php - 302 lines - 14329 bytes - Summary - Text - Print

   1  <?php
   2  /* For licensing terms, see /dokeos_license.txt */
   3  
   4  /**
   5  * @author Bart Mollet
   6  * @package dokeos.admin
   7  */
   8  
   9  // name of the language file that needs to be included
  10  $language_file = array ('registration','admin');
  11  
  12  // resetting the course id
  13  $cidReset = true;
  14  
  15  // setting the help
  16  $help_content = 'platformadministrationsessionadd';
  17  
  18  // including the global Dokeos file
  19  require  ('../inc/global.inc.php');
  20  
  21  // including additional libraries
  22  require_once(api_get_path(LIBRARY_PATH).'sessionmanager.lib.php');
  23  require_once(api_get_path(LIBRARY_PATH).'language.lib.php');
  24  require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  25  require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  26  require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
  27  global $_user;
  28  
  29  // setting the section (for the tabs)
  30  $this_section = SECTION_PLATFORM_ADMIN;
  31  
  32  // Database Table Definitions
  33  $tbl_user        = Database::get_main_table(TABLE_MAIN_USER);
  34  $tbl_session_category     = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
  35  
  36  $htmlHeadXtra[] = '<style>        
  37  div.row div.label {
  38      width: 17%;                     
  39  } 
  40  div.row div.formw {
  41      width: 760px;                     
  42  }
  43  </style>';
  44  
  45  //display the header
  46  Display::display_header(get_lang('TrainingCategory'));
  47  
  48  if (!isset($_SESSION['steps'][3])) {
  49      $_SESSION['steps'][3] = true;
  50  }
  51  if (isset($_REQUEST['iden'])) {
  52      $iden = $_REQUEST['iden'];
  53      $_SESSION['iden'] =  $iden;
  54  }
  55  if (isset($_REQUEST['wish'])) {    
  56      $wish = $_REQUEST['wish'];
  57      if ($wish == 0) {    
  58      $user_id = $_user['user_id'];
  59      }
  60      $_SESSION['wish'] =  $wish;
  61  }
  62  if (isset($_REQUEST['user_id'])) {    
  63      $user_id = $_REQUEST['user_id'];
  64  }
  65  
  66  if (!empty($user_id)) {        
  67      $sql = "SELECT firstname,lastname,diplomas FROM $tbl_user WHERE user_id = ".$user_id;
  68      $result = Database::query($sql,__FILE__,__LINE__);
  69      while ($row = Database::fetch_array($result)) {        
  70              $firstname = $row['firstname'];            
  71              $lastname = $row['lastname'];
  72              $category = $row['diplomas'];
  73      }    
  74  }
  75  
  76  // start the content div
  77  echo '<div id="content">';
  78  // Steps breadcrumbs
  79  SessionManager::display_steps_breadcrumbs();
  80  
  81  //if(!isset($_REQUEST['id'])) {
  82  
  83  $product = SessionManager::get_session_category($_REQUEST['id']);                                            
  84  echo '<div class="row"><div class="form_header register-payment-steps-name"><h2>'.$product['name'].'</h2></div></div>';
  85  
  86  $form = new FormValidator('registration_step3', 'post', 'registration_step3.php?iden='.$iden.'&wish='.$wish.'&id='.intval($_SESSION['cat_id']).'&next=3');
  87  $form->addElement('hidden', 'cat_id', intval($_REQUEST['id']));
  88  
  89  $civilities = array('' => '--', get_lang('Mr') => get_lang('Mr'), get_lang('Mrs') => get_lang('Mrs'), get_lang('Miss') => get_lang('Miss'));              
  90  $form->addElement('select', 'civility', get_lang('Civility').' <span class="sym-error">*</span>', $civilities, 'style="width:250px;"');
  91  
  92  // Lastname
  93  $form->addElement('text', 'lastname', get_lang('LastName').' <span class="sym-error">*</span>','style="width:250px;"');
  94  $form->applyFilter('lastname', 'html_filter');
  95  $form->applyFilter('lastname', 'trim');
  96  $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
  97  
  98  $form->addElement('text', 'firstname', get_lang('FirstName').' <span class="sym-error">*</span>','class="focus" style="width:250px;"');
  99  $form->applyFilter('firstname', 'html_filter');
 100  $form->applyFilter('firstname', 'trim');
 101  $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
 102  
 103  $countries = LanguageManager::get_countries();          
 104  $countries = array(0 => '--') + $countries;
 105  $form->addElement('select', 'country', get_lang('Country').' <span class="sym-error">*</span>', $countries, 'style="width:250px;"');
 106  
 107  // EXTRA FIELDS
 108  $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC', false, 2);
 109  $extra_data = UserManager::get_extra_user_data(0, true);
 110  $display_vat = true;
 111  foreach($extra as $id => $field_details) {
 112      
 113          // Don't display phone when user is not payer
 114          if ($iden == 1 || ($iden == 0 && $wish == 1)) {            
 115              if ($field_details[1] == 'phone') {
 116                  continue;
 117              }
 118          }
 119      
 120      if ($field_details[6] == 1) { // only show extra fields that are visible
 121          switch ($field_details[2]) {
 122              case USER_FIELD_TYPE_TEXT:
 123                                  if (isset($_GET['iden']) && isset($_GET['wish']) && intval($_GET['iden']) === 0 && (intval($_GET['wish']) === 0 || intval($_GET['wish']) === 1) && $field_details[1] == 'tva_id') {
 124                                      $display_vat = false;
 125                                      break;
 126                                  }
 127  
 128                                  $required = '';
 129                                  if ($field_details[1] == 'street' || $field_details[1] == 'city' || $field_details[1] == 'phone') {
 130                                      $required = ' <span class="sym-error">*</span>';                                    
 131                                  }                                
 132                                  $form->addElement('text', 'extra_'.$field_details[1], $field_details[3].$required, array('size' => 40));
 133                                  $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
 134                                  $form->applyFilter('extra_'.$field_details[1], 'trim');                              
 135                                  if ($field_details[1] == 'street' || $field_details[1] == 'city' || $field_details[1] == 'phone') {
 136                                      $form->addRule('extra_'.$field_details[1], get_lang('ThisFieldIsRequired'), 'required');
 137                                  }
 138                                  
 139                  break;
 140              case USER_FIELD_TYPE_TEXTAREA:
 141                  $form->add_html_editor('extra_'.$field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
 142                  //$form->addElement('textarea', 'extra_'.$field_details[1], $field_details[3], array('size' => 80));
 143                  $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
 144                  $form->applyFilter('extra_'.$field_details[1], 'trim');
 145                  break;
 146              case USER_FIELD_TYPE_RADIO:
 147                  $group = array();
 148                  foreach ($field_details[9] as $option_id => $option_details) {
 149                      $options[$option_details[1]] = $option_details[2];
 150                      $group[] =& HTML_QuickForm::createElement('radio', 'extra_'.$field_details[1], $option_details[1], $option_details[2].'<br />', $option_details[1]);
 151                  }
 152                  $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
 153                  break;
 154              case USER_FIELD_TYPE_SELECT:                            
 155                  $options = array();
 156                  foreach($field_details[9] as $option_id => $option_details) {                    
 157                      $options[$option_details[1]] = $option_details[2];
 158                  }
 159                  $form->addElement('select','extra_'.$field_details[1],$field_details[3].$required,$options,'');                                
 160                  break;
 161              case USER_FIELD_TYPE_SELECT_MULTIPLE:
 162                  $options = array();
 163                  foreach($field_details[9] as $option_id => $option_details) {
 164                      $options[$option_details[1]] = $option_details[2];
 165                  }
 166                  $form->addElement('select', 'extra_'.$field_details[1], $field_details[3], $options, array('multiple' => 'multiple'));
 167                  break;
 168              case USER_FIELD_TYPE_DATE:
 169                  $form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3], array('form_name' => 'user_add'));
 170                  $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear', 1900);
 171                  $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
 172                  $form -> setDefaults($defaults);
 173                  $form->applyFilter('theme', 'trim');
 174                  break;
 175              case USER_FIELD_TYPE_DATETIME:
 176                  $form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3], array('form_name' => 'user_add'));
 177                  $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear', 1900);
 178                  $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
 179                  $form -> setDefaults($defaults);
 180                  $form->applyFilter('theme', 'trim');
 181                  break;
 182              case USER_FIELD_TYPE_DOUBLE_SELECT:
 183                  $values = array();
 184                  foreach ($field_details[9] as $key => $element) {
 185                      if ($element[2][0] == '*') {
 186                          $values['*'][$element[0]] = str_replace('*','',$element[2]);
 187                      } else {
 188                          $values[0][$element[0]] = $element[2];
 189                      }
 190                  }
 191                  $group = '';
 192                  $group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1], '', $values[0], '');
 193                  $group[] =& HTML_QuickForm::createElement('select', 'extra_'.$field_details[1].'*', '', $values['*'], '');
 194                  $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '&nbsp;');
 195                  if ($field_details[7] == 0)    $form->freeze('extra_'.$field_details[1]);
 196                  // recoding the selected values for double : if the user has selected certain values, we have to assign them to the correct select form
 197                  if (key_exists('extra_'.$field_details[1], $extra_data)) {
 198                      // exploding all the selected values (of both select forms)
 199                      $selected_values = explode(';', $extra_data['extra_'.$field_details[1]]);
 200                      $extra_data['extra_'.$field_details[1]] = array();
 201  
 202                      // looping through the selected values and assigning the selected values to either the first or second select form
 203                      foreach ($selected_values as $key => $selected_value) {
 204                          if (key_exists($selected_value, $values[0])) {
 205                              $extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1]] = $selected_value;
 206                          } else {
 207                              $extra_data['extra_'.$field_details[1]]['extra_'.$field_details[1].'*'] = $selected_value;
 208                          }
 209                      }
 210                  }
 211                  break;
 212              case USER_FIELD_TYPE_DIVIDER:
 213                  $form->addElement('static', $field_details[1], '<br /><strong>'.$field_details[3].'</strong>');
 214                  break;
 215          }
 216      }
 217  }
 218  
 219  // Email
 220  $form->addElement('text', 'email', get_lang('Email').' <span class="sym-error">*</span>', array('size' => '40'));
 221  $form->addRule('email', get_lang('EmailWrong'), 'email');
 222  $form->addRule('email', get_lang('EmailWrong'), 'required');
 223  
 224  // Confirmation email
 225  $form->addElement('text', 'email2', get_lang('ConfirmationEmail').' <span class="sym-error">*</span>', array('size' => '40'));
 226  $form->addRule('email2', get_lang('EmailWrong'), 'email');
 227  $form->addRule('email2', get_lang('EmailWrong'), 'required');
 228  $form->addRule(array('email', 'email2'), get_lang('EmailsNotMatch'), 'compare');
 229  
 230  $form->addElement('html','</br></br></br>');
 231  $select_level = array ();     
 232  $navigator_info = api_get_navigator(); 
 233  if ($navigator_info['name'] == 'Internet Explorer' && ($navigator_info['version'] >= '6')) {    
 234      $html_results_enabled[] = FormValidator :: createElement ('submit', 'submit_plus', get_lang('Previous'), 'style="background-color: #4171B5;;height:32px;border:1px solid #b8b8b6;text-transform:uppercase;font-weight:bold;color:#fff;"');
 235      $html_results_enabled[] = FormValidator :: createElement ('submit', 'submit', get_lang('Ok'), 'style="background-color: #4171B5;;height:32px;border:1px solid #b8b8b6;text-transform:uppercase;font-weight:bold;color:#fff;"');
 236  }
 237  else {
 238      $html_results_enabled[] = FormValidator :: createElement ('style_submit_button', 'submit_plus', get_lang('Previous'), '');
 239      $html_results_enabled[] = FormValidator :: createElement ('style_submit_button', 'submit', get_lang('Ok'), '');
 240  }
 241  $form->addGroup($html_results_enabled);
 242  
 243  $form->addElement('html', '<div class="row">
 244          <div class="label"></div>
 245          <div class="formw"><small>'.str_replace('*', '<span class="form_required"> *</span>', get_lang('FieldRequired')).'</small></div>
 246      </div>');
 247  
 248  //$form->add_fr_zipcode_required_rule(array('extra_zipcode', 'extra_country'), get_lang('ZipcodeForThisCountryIsRequired'), 'fr_zipcode_required');
 249  //$form->addRule(array('extra_zipcode', 'extra_country'), get_lang('ZipcodeMustBe5digits'), 'fr_zipcode');
 250  $defaults['firstname']         = isset($_SESSION['user_info']['firstname'])?$_SESSION['user_info']['firstname']:'';
 251  $defaults['lastname']         = isset($_SESSION['user_info']['lastname'])?$_SESSION['user_info']['lastname']:'';
 252  $defaults['email']         = isset($_SESSION['user_info']['email'])?$_SESSION['user_info']['email']:'';
 253  $defaults['email2']         = isset($_SESSION['user_info']['email2'])?$_SESSION['user_info']['email2']:'';
 254  $defaults['country']         = isset($_SESSION['user_info']['country'])?$_SESSION['user_info']['country']:'';
 255  $defaults['civility']         = isset($_SESSION['user_info']['civility'])?$_SESSION['user_info']['civility']:'';
 256  
 257  // extra default values
 258  $defaults['extra_street']     = isset($_SESSION['user_info']['extra_street'])?$_SESSION['user_info']['extra_street']:'';
 259  $defaults['extra_addressline2'] = isset($_SESSION['user_info']['extra_addressline2'])?$_SESSION['user_info']['extra_addressline2']:'';
 260  $defaults['extra_zipcode']     = isset($_SESSION['user_info']['extra_zipcode'])?$_SESSION['user_info']['extra_zipcode']:'';
 261  $defaults['extra_city']     = isset($_SESSION['user_info']['extra_city'])?$_SESSION['user_info']['extra_city']:'';
 262  $defaults['extra_organization'] = isset($_SESSION['user_info']['extra_organization'])?$_SESSION['user_info']['extra_organization']:'';
 263  if ($iden == 0 && $wish == 0) {
 264      $defaults['extra_phone'] = isset($_SESSION['user_info']['extra_phone'])?$_SESSION['user_info']['extra_phone']:'';
 265  }
 266  
 267  
 268  $form->setDefaults($defaults);
 269  if (isset($_POST['submit_plus'])) {
 270      echo '<script>window.location.href = "registration.php?iden='.$_SESSION['iden'].'&wish='.$_SESSION['wish'].'&id='.intval($_SESSION['cat_id']).'&prev=2";</script>';    
 271  }
 272  if( $form->validate()) {
 273      $user = $form->exportValues();  
 274      $id = $user['cat_id'];
 275      $_SESSION['user_info'] = $user;
 276      
 277      if (empty($user['extra_zipcode'])) {
 278          $_SESSION['user_info']['extra_zipcode'] = 0;
 279      }    
 280          
 281      if (isset($user['submit'])) {
 282          // go to step 3b
 283          if ($iden == 1 || ($iden == 0 && $wish == 1)) {
 284              echo '<script>window.location.href = "registration_step3b.php?iden='.$iden.'&wish='.$wish.'&id='.$id.'&next=3b";</script>';
 285          } else {
 286              if (isset($_SESSION['payer_info'])) {
 287                  unset($_SESSION['payer_info']);
 288              }
 289              // go to step 4
 290              echo '<script>window.location.href = "feedback.php?iden='.$iden.'&wish='.$wish.'&id='.$id.'&next=4";</script>';
 291          }
 292      }
 293  }
 294  $form->display();
 295  
 296  //}
 297  // close the content div
 298  echo '</div>';
 299  
 300  // display the footer
 301  Display::display_footer();
 302  ?>

title

Description

title

Description

title

Description

title

title

Body