diff --git a/src/Controller/InvoiceServiceController.php b/src/Controller/InvoiceServiceController.php index 94e201a..c623812 100644 --- a/src/Controller/InvoiceServiceController.php +++ b/src/Controller/InvoiceServiceController.php @@ -183,7 +183,7 @@ public function getReservationsInPeriodAction(ManagerRegistry $doctrine, Request { $em = $doctrine->getManager(); $reservations = []; - $newInvoiceInformationArray = $requestStack->getSession()->get('invoiceInCreation'); + $newInvoiceInformationArray = $requestStack->getSession()->get('invoiceInCreation', []); $potentialReservations = $em->getRepository( Reservation::class @@ -209,7 +209,6 @@ public function getReservationsForCustomerAction(ManagerRegistry $doctrine, Requ { $em = $doctrine->getManager(); $reservations = []; - $newInvoiceInformationArray = $requestStack->getSession()->get('invoiceInCreation'); $customer = $em->getRepository(Customer::class)->findOneByLastname( $request->request->get('lastname') @@ -220,7 +219,7 @@ public function getReservationsForCustomerAction(ManagerRegistry $doctrine, Requ Reservation::class )->loadReservationsWithoutInvoiceForCustomer($customer); - $newInvoiceInformationArray = $requestStack->getSession()->get('invoiceInCreation'); + $newInvoiceInformationArray = $requestStack->getSession()->get('invoiceInCreation', []); foreach ($potentialReservations as $reservation) { if (!in_array($reservation->getId(), $newInvoiceInformationArray)) { @@ -247,6 +246,7 @@ public function selectReservationAction(ManagerRegistry $doctrine, InvoiceServic } if (null != $request->request->get('reservationid')) { + $newInvoiceInformationArray = $requestStack->getSession()->get('invoiceInCreation', []); $newInvoiceInformationArray[] = $request->request->get('reservationid'); $requestStack->getSession()->set('invoiceInCreation', $newInvoiceInformationArray); } diff --git a/src/Service/ReservationService.php b/src/Service/ReservationService.php index ad58085..fd7846e 100644 --- a/src/Service/ReservationService.php +++ b/src/Service/ReservationService.php @@ -19,6 +19,7 @@ use App\Entity\Reservation; use App\Entity\ReservationStatus; use App\Entity\Template; +use App\Entity\CustomerAddresses; use App\Interfaces\ITemplateRenderer; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; @@ -368,7 +369,7 @@ public function getRenderParams(Template $template, mixed $param) // params need to be an array containing a list of Reservation Objects $params = [ 'reservation1' => $param[0], - 'address' => (0 == count($param[0]->getBooker()->getCustomerAddresses()) ? null : $param[0]->getBooker()->getCustomerAddresses()[0]), + 'address' => (0 == count($param[0]->getBooker()->getCustomerAddresses()) ? new CustomerAddresses() : $param[0]->getBooker()->getCustomerAddresses()[0]), 'reservations' => $param, ]; $prices = $this->getTotalPricesForTemplate($param);