/**
  * action removeParticipant
  *
  * @param Reservation $reservation
  * @param Person $participant
  * @param string $reason Reason for cancellation of reservation for this participant. Allowed:  'byOrganizer', 'withCosts', 'withoutCost'
  * @return void
  */
 public function removeParticipantAction(Reservation $reservation, Person $participant, $reason)
 {
     $reservation->removeParticipant($participant);
     $reservation->getLesson()->removeParticipant($participant);
     $this->personRepository->remove($participant);
     $this->addFlashMessage($this->translate('message.reservation.removeParticipant.success'));
     if ($this->settings['bookings']['removeParticipant'][$reason]['confirm']['sendNotification']) {
         /**@var Notification $notification * */
         $notification = $this->objectManager->get(Notification::class);
         $bodytext = $this->notificationService->render($this->settings['bookings']['removeParticipant'][$reason]['confirm']['templateFileName'], 'html', 'Bookings/Email/RemoveParticipant', ['reservation' => $reservation, 'participant' => $participant, 'reason' => $reason, 'baseUrl' => $this->getBaseUrlForFrontend()]);
         $notification->setRecipient($reservation->getContact()->getEmail());
         $notification->setBodytext($bodytext);
         $notification->setSubject($this->settings['bookings']['removeParticipant'][$reason]['confirm']['subject']);
         $notification->setSender($this->settings['bookings']['removeParticipant'][$reason]['confirm']['fromEmail']);
         $notification->setReservation($reservation);
         $notificationSuccess = $this->notificationService->send($notification);
         if ($notificationSuccess) {
             $mailMessageKey = 'message.bookings.cancel.sendNotification.success';
             $mailMessageSeverity = AbstractMessage::OK;
             $notification->setSentAt(new \DateTime());
         } else {
             $mailMessageKey = 'message.bookings.cancel.sendNotification.error';
             $mailMessageSeverity = AbstractMessage::WARNING;
         }
         $this->notificationRepository->add($notification);
         $this->persistenceManager->persistAll();
         $reservation->addNotification($notification);
         $this->addFlashMessage($this->translate($mailMessageKey), null, $mailMessageSeverity);
     }
     $this->redirect('edit', null, null, ['reservation' => $reservation]);
 }
 /**
  * Download action
  *
  * @param \CPSIT\T3eventsReservation\Domain\Model\Schedule $schedule
  * @ignorevalidation $schedule
  * @param string $ext File extension for download
  * @return string
  */
 public function downloadAction($schedule = null, $ext = 'csv')
 {
     if (is_null($schedule)) {
         $demand = $this->createDemandFromSettings($this->settings);
         $this->overwriteDemandObject($demand, $this->moduleData->getOverwriteDemand());
         $participants = $this->personRepository->findDemanded($demand);
     } else {
         $participants = $schedule->getParticipants();
         $participants->rewind();
         /** @var Person $objectForFileName */
         $objectForFileName = $participants->current();
     }
     $this->view->assign('participants', $participants);
     return $this->getContentForDownload($ext, $objectForFileName);
 }
 /**
  * Delete expired reservations
  * I.e. reservations of status new which are older then a given minAge
  *
  * @param boolean $dryRun
  * @param int $age Age in seconds
  * @return int
  */
 protected function deleteInvalidReservations($dryRun, $age)
 {
     $reservations = $this->getInvalidReservations($age);
     $deletedCount = 0;
     if (!$dryRun) {
         /** @var Reservation $reservation */
         foreach ($reservations as $reservation) {
             /** @var Schedule $lesson */
             if ($lesson = $reservation->getLesson()) {
                 /** @var Person $participants */
                 if ($participants = $reservation->getParticipants()) {
                     foreach ($participants as $participant) {
                         $lesson->removeParticipant($participant);
                         $this->personRepository->remove($participant);
                     }
                 }
             }
             $this->reservationRepository->remove($reservation);
             $deletedCount++;
         }
     }
     return $dryRun ? count($reservations) : $deletedCount;
 }
 /**
  * Updates a participant
  *
  * @param Person $participant
  * @validate $participant \CPSIT\T3eventsReservation\Domain\Validator\ParticipantValidator
  */
 public function updateAction(Person $participant)
 {
     $this->participantRepository->update($participant);
     $this->redirect('edit', self::PARENT_CONTROLLER_NAME, null, ['reservation' => $participant->getReservation()]);
 }
 /**
  * @param Reservation $reservation
  * @param BillingAddress $newBillingAddress
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
  * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
  */
 public function createBillingAddressAction(Reservation $reservation, BillingAddress $newBillingAddress)
 {
     $reservation->setBillingAddress($newBillingAddress);
     $this->personRepository->add($newBillingAddress);
     $this->reservationRepository->update($reservation);
     $this->addFlashMessage($this->translate('message.reservation.createBillingAddress.success'));
     $this->redirect('edit', null, null, ['reservation' => $reservation]);
 }