Esempio n. 1
0
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     /* Fetch the array of the file stored temporarily in database */
     $afile = $form_state->getValue('afile');
     /* Load the object of the file by it's fid */
     dpm($afile[0]);
     $file = File::load($afile[0]);
     /* Set the status flag permanent of the file object */
     $file->setPermanent();
     /* Save the file in database */
     $file->save();
     $current_uri = \Drupal::request()->getRequestUri();
     $path_args = array_slice(explode('/', $current_uri), -2, 2);
     $entry = array('co_degre' => $path_args[0], 'co_modu' => explode('?', $path_args[1])[0], 'fid' => $afile[0], 'zone' => 3);
     // dpm($entry);
     $module = BbCrudController::create('gbb_file', $entry);
 }
Esempio n. 2
0
 public function sessionduplicate($co_degre, $co_modu, $sessid)
 {
     // load session informations
     $entry = array('sess_id' => $sessid);
     $session = BbCrudController::load('gbb_session', $entry);
     foreach ($session['0'] as $field => $val) {
         $tab[$field] = $val;
     }
     // kill unwanted informations
     unset($tab['sess_id']);
     unset($tab['denom_comp'], $tab['sigle']);
     unset($tab['nomu'], $tab['prenom']);
     // insert new row
     $DBWriteStatus = BbCrudController::create('gbb_session', $tab);
     $routeparameters = array('co_degre' => $co_degre, 'co_modu' => $co_modu);
     return $this->redirect('bb.moduleng', $routeparameters, array('fragment' => 'sessions'));
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $account = \Drupal::currentUser();
     $entry = array('uid' => $account->id(), 'co_modu' => $form_state->getValue('co_modu'), 'co_degre' => $form_state->getValue('co_degre'), 'date' => $form_state->getValue('date'), 'date_ts' => strtotime($form_state->getValue('date')), 'horaires' => $form_state->getValue('horaires'), 'co_lieu' => $form_state->getValue('lieu'), 'co_resp' => $form_state->getValue('formateur'), 'duree_a_payer' => $form_state->getValue('duree_a_payer'), 'duree_prevue' => $form_state->getValue('duree_prevue'), 'type_paiement' => $form_state->getValue('type_paiement'), 'groupe' => $form_state->getValue('groupe'), 'date_modif' => date("Y-m-d H:i:s"));
     if ($form_state->getValue('sess_id') == 1) {
         // Insert
         $DBWriteStatus = BbCrudController::create('gbb_session', $entry);
     } else {
         // Update
         $entry['sess_id'] = $form_state->getValue('sess_id');
         $DBWriteStatus = BbCrudController::update('gbb_session', $entry, array('sess_id' => $form_state->getValue('sess_id')));
     }
     $form_state->setRedirect('bb.moduleng', array('co_degre' => $form_state->getValue('co_degre'), 'co_modu' => $form_state->getValue('co_modu')), array('fragment' => 'sessions'));
 }