Example #1
0
 function index_action()
 {
     $form_fields['comment'] = array('caption' => _("Kommentar"), 'type' => 'textarea', 'attributes' => array('rows' => 4, 'style' => 'width:100%'));
     $form_fields['snd_message'] = array('caption' => _("Benachrichtigung über ausfallende Termine an alle Teilnehmer verschicken"), 'type' => 'checkbox', 'attributes' => array('style' => 'vertical-align:middle'));
     $form_buttons['save_close'] = array('caption' => _('OK'), 'info' => _("Termine absagen und Dialog schließen"));
     $form = new StudipForm($form_fields, $form_buttons, 'cancel_dates', false);
     if ($form->isClicked('save_close')) {
         $sem = Seminar::getInstance($this->course_id);
         $comment = $form->getFormFieldValue('comment');
         foreach ($this->dates as $date) {
             $sem->cancelSingleDate($date->getTerminId(), $date->getMetadateId());
             $date->setComment($comment);
             $date->setExTermin(true);
             $date->store();
         }
         if ($form->getFormFieldValue('snd_message') && count($this->dates)) {
             $snd_messages = raumzeit_send_cancel_message($comment, $this->dates);
             if ($snd_messages) {
                 $msg = sprintf(_("Es wurden %s Benachrichtigungen gesendet."), $snd_messages);
             }
         }
         PageLayout::postMessage(MessageBox::success(_("Folgende Termine wurden abgesagt") . ($msg ? ' (' . $msg . '):' : ':'), array_map(function ($d) {
             return $d->toString();
         }, $this->dates)));
         $this->redirect($this->url_for('course/dates'));
     }
     $this->form = $form;
 }