/** * create notification action * Sends a notification to all contact persons of the given lesson/reservations * * @param \DWenzel\T3events\Domain\Model\Notification $newNotification * @param array $reservations */ public function createNotificationAction($newNotification, $reservations) { $uidList = implode(',', $reservations); $reservations = $this->reservationRepository->findMultipleByUid($uidList); $succesfullSent = []; $sendingFailed = []; foreach ($reservations as $reservation) { $notification = $this->notificationService->duplicate($newNotification); $notification->setRecipient($reservation->getContact()->getEmail()); $notification->setSender($this->settings['bookings']['notify']['fromEmail']); $notification->setFormat('plain'); $notificationSuccess = $this->notificationService->send($notification); if ($notificationSuccess) { $succesfullSent[] = $notification->getRecipient(); $notification->setSentAt(new \DateTime()); } else { $sendingFailed[] = $notification->getRecipient(); } $this->notificationRepository->add($notification); $this->persistenceManager->persistAll(); $reservation->addNotification($notification); $this->reservationRepository->update($reservation); } $this->persistenceManager->persistAll(); if (count($succesfullSent)) { $this->addFlashMessage(implode('<br />', $succesfullSent), $this->translate('message.bookings.sendNotification.successForRecipients'), AbstractMessage::OK); } if (count($sendingFailed)) { $this->addFlashMessage(implode('<br />', $sendingFailed), $this->translate('message.bookings.sendNotification.errorForRecipients'), AbstractMessage::ERROR); } $this->forward('list'); }
/** * Closes expired reservations * * @param boolean $dryRun * @return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult | NULL */ protected function closeReservations($dryRun) { $reservationDemand = $this->createReservationDemandByExpiredLessonDate(); $reservations = $this->reservationRepository->findDemanded($reservationDemand); if (!$dryRun) { foreach ($reservations as $reservation) { $reservation->setHidden(1); $reservation->setStatus(Reservation::STATUS_CLOSED); $this->reservationRepository->update($reservation); } } return $reservations; }
/** * updates the reservation * * @param Reservation $reservation * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException */ public function updateAction(Reservation $reservation) { $this->addFlashMessage($this->translate('message.reservation.update.success')); $this->reservationRepository->update($reservation); $this->redirect('edit', null, null, ['reservation' => $reservation]); }