/**
  * Edit contact
  *
  * @param Contact $contact
  * @param Reservation $reservation
  * @throws InvalidSourceException
  * @ignorevalidation $contact
  * @ignorevalidation $reservation
  */
 public function editAction(Contact $contact, Reservation $reservation)
 {
     if ($reservation->getContact() !== $contact) {
         throw new InvalidSourceException('Can not edit contact uid ' . $contact->getUid() . '. Contact not found in Reservation uid: ' . $reservation->getUid() . '.', 1460039887);
     }
     $this->view->assign('contact', $contact);
 }
 /**
  * Edit participant
  *
  * @param Person $participant
  * @param Reservation $reservation
  * @throws InvalidSourceException
  */
 public function editAction(Person $participant, Reservation $reservation)
 {
     if (!$reservation->getParticipants()->contains($participant)) {
         throw new InvalidSourceException('Can not edit participant uid ' . $participant->getUid() . '. Participant not found in Reservation uid: ' . $participant->getReservation()->getUid() . '.', 1459343264);
     }
     $this->view->assign('participant', $participant);
 }
 /**
  * @test
  */
 public function notificationCanBeRemoved()
 {
     $notification = new Notification();
     $this->subject->addNotification($notification);
     $this->subject->removeNotification($notification);
     $this->assertFalse($this->subject->getNotifications()->contains($notification));
 }
 /**
  * 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]);
 }
 /**
  * @test
  */
 public function newParticipantActionDoesNotDenyAccessIfReservationStatusIsDraft()
 {
     $mockRequest = $this->getMock(Request::class);
     $this->mockView();
     $this->inject($this->subject, 'request', $mockRequest);
     $reservation = new Reservation();
     $reservation->setStatus(Reservation::STATUS_DRAFT);
     $this->subject->expects($this->never())->method('denyAccess');
     $this->subject->newParticipantAction($reservation);
 }
 /**
  * @test
  */
 public function editActionAssignsVariablesToView()
 {
     $participant = new Person();
     $reservation = new Reservation();
     $reservation->addParticipant($participant);
     $participant->setReservation($reservation);
     $view = $this->mockView();
     $view->expects($this->once())->method('assign')->with('participant', $participant);
     $this->subject->editAction($participant, $reservation);
 }
 /**
  * @test
  */
 public function editActionAssignsVariablesToView()
 {
     $contact = new Contact();
     $reservation = new Reservation();
     $reservation->setContact($contact);
     $view = $this->mockView();
     $view->expects($this->once())->method('assign')->with('contact', $contact);
     $this->subject->editAction($contact, $reservation);
 }
 /**
  * @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]);
 }