Esempio n. 1
0
 private function deleteCityOrder()
 {
     $eventOrder = EventOrder::model()->findByAttributes(array('eventId' => $this->event->id, 'startCityId' => $this->startCityId));
     if (!$eventOrder) {
         return;
     }
     /** @var Order $order  */
     $order = $eventOrder->order;
     if ($order) {
         foreach ($order->flightItems as $item) {
             $item->delete();
         }
         foreach ($order->hotelItems as $item) {
             $item->delete();
         }
         OrderHasFlightVoyage::model()->deleteAllByAttributes(array('orderId' => $order->id));
         OrderHasHotel::model()->deleteAllByAttributes(array('orderId' => $order->id));
         $order->delete();
     }
     $eventOrder->delete();
 }
Esempio n. 2
0
 public function saveReference($order)
 {
     $orderHasHotel = OrderHasHotel::model()->findByAttributes(array('orderId' => $order->id, 'orderHotel' => $this->internalId));
     if (!$orderHasHotel) {
         $orderHasHotel = new OrderHasHotel();
         $orderHasHotel->orderId = $order->id;
         $orderHasHotel->orderHotel = $this->internalId;
         $orderHasHotel->save();
         if (!$orderHasHotel->save()) {
             throw new CException(VarDumper::dumpAsString($orderHasHotel->errors));
         }
     }
 }