Exemple #1
0
 /**
  * @param ObjectManager $manager
  * @throws \Doctrine\DBAL\DBALException
  */
 protected function loadReservations(ObjectManager $manager)
 {
     echo "\nReservations ... ";
     $stmt = $this->connection->executeQuery('SELECT * FROM reservation');
     foreach ($stmt->fetchAll() as $record) {
         $reservation = new Reservation();
         $reservation->setClient($this->getReference('client-' . $record['client_id']));
         $reservation->setDestination($this->getReference('destination-' . $record['destination_id']));
         $reservation->setUniqid($record['uniqid']);
         $reservation->setRoundTrip($record['round_trip']);
         $reservation->setNoPax($record['no_pax']);
         $reservation->setHotel($record['hotel']);
         if ($record['arrival_date']) {
             $reservation->setArrivalDate(\DateTime::createFromFormat('Y-m-d H:i:s', preg_replace('/\\.[0-9]+$/', '', $record['arrival_date'])));
         }
         $reservation->setArrivalFlightNo($record['arrival_flight_no']);
         if ($record['departure_date']) {
             $reservation->setDepartureDate(\DateTime::createFromFormat('Y-m-d H:i:s', preg_replace('/\\.[0-9]+$/', '', $record['departure_date'])));
         }
         $reservation->setDepartureFlightNo($record['departure_flight_no']);
         $reservation->setPrice($record['price']);
         $reservation->setComment($record['comment']);
         $reservation->setStatus($record['status']);
         $reservation->setPaymentDate($record['payment_date']);
         $reservation->setCreated(\DateTime::createFromFormat('Y-m-d H:i:s', preg_replace('/\\.[0-9]+$/', '', $record['created_at'])));
         $reservation->setUpdated(\DateTime::createFromFormat('Y-m-d H:i:s', preg_replace('/\\.[0-9]+$/', '', $record['updated_at'])));
         $manager->persist($reservation);
         $this->addReference("reservation-" . $record['id'], $reservation);
     }
 }
 /**
  * Displays a form to create a new Reservation entity.
  *
  * @Route("/new", name="reservation_new")
  * @Method("GET")
  * @Template()
  */
 public function newAction()
 {
     $reservation = new Reservation();
     $reservation->setDepartureDate(new \DateTime());
     $reservation->setArrivalDate(new \DateTime());
     $client = new Client();
     $reservation->setClient($client);
     $form = $this->createCreateForm($reservation);
     return $this->render(':Reservation:new.html.twig', array('entity' => $reservation, 'form' => $form->createView(), 'prices' => json_encode($this->getDoctrine()->getRepository('AppBundle:Transfer')->getActivePrices())));
 }