public function __construct($bookers, $base, $billId)
 {
     $this->bookers = array();
     if ($base instanceof FlightBooker) {
         $bookerComp = new FlightBookerComponent();
         $bookerComp->setFlightBookerFromId($base->id);
         $base = $bookerComp;
     }
     $this->base = $base;
     foreach ($bookers as $booker) {
         if ($booker instanceof FlightBooker) {
             $bookerComp = new FlightBookerComponent();
             $bookerComp->setFlightBookerFromId($booker->id);
             $this->bookers[] = $bookerComp;
         } elseif ($booker instanceof HotelBooker) {
             $bookerComp = new HotelBookerComponent();
             $bookerComp->setHotelBookerFromId($booker->id);
             $this->bookers[] = $bookerComp;
         } else {
             $this->bookers[] = $booker;
         }
     }
     $this->_billId = $billId;
     if ($billId) {
         $this->setBillId($billId);
     }
 }
Esempio n. 2
0
 public function actionChangeState($hotelBookerId = 0, $newState = '')
 {
     if ($hotelBookerId) {
         /** @var HotelBookerComponent $hotelBookerComponent  */
         $hotelBookerComponent = new HotelBookerComponent();
         $hotelBookerComponent->setHotelBookerFromId($hotelBookerId);
         echo "HotelBookerId " . $hotelBookerComponent->getHotelBookerId() . PHP_EOL;
         echo "Current status is " . $hotelBookerComponent->getCurrent()->swGetStatus() . PHP_EOL;
         echo "Next possible status are " . $hotelBookerComponent->getCurrent()->swGetNextStatus() . PHP_EOL;
         echo "Trying to change status to {$newState}" . PHP_EOL;
         if ($newState) {
             $res = $hotelBookerComponent->status($newState);
             if (!$res) {
                 CVarDumper::dump($hotelBookerComponent->getCurrent()->getErrors());
                 CVarDumper::dump($hotelBookerComponent->getCurrent()->getAttributes());
                 echo PHP_EOL;
             } else {
                 $hotelBookerComponent->getCurrent()->onlySave();
             }
             echo "Status is " . $hotelBookerComponent->getCurrent()->swGetStatus() . "\n";
         }
     } else {
         $helpText = $this->getHelp();
         $helpText = str_replace('command', 'ChangeState', $helpText);
         echo $helpText;
     }
 }
 private function createHotelBookerComponent()
 {
     $hotelBookerComponent = new HotelBookerComponent();
     $hotelBookerComponent->setHotelBookerFromHotel($this->item->hotel, $this->item->searchParams);
     $currentHotelBooker = $hotelBookerComponent->getCurrent();
     $currentHotelBooker->orderBookingId = self::$bookingContactInfo->id;
     $currentHotelBooker->status = 'enterCredentials';
     if (!$currentHotelBooker->save()) {
         $errMsg = 'Couldn\'t save hotel booker instanse' . PHP_EOL . CVarDumper::dumpAsString($currentHotelBooker->getErrors());
         throw CException($errMsg);
     } else {
         Yii::trace("HotelBooker successfully saved. It's id:" . $hotelBookerComponent->getCurrent()->id, 'HotelTripElementWorkflow.createWorkflowAndLinkItWithItem');
     }
     return $hotelBookerComponent;
 }
Esempio n. 4
0
 public function getBookers()
 {
     $bookerIds = $this->getBookerIds();
     if (!$bookerIds) {
         throw new Exception("No bookers availiable");
     }
     $bookers = array();
     foreach ($bookerIds as $entry) {
         if ($entry['type'] == 'avia') {
             $flightBookerComponent = new FlightBookerComponent();
             $flightBookerComponent->setFlightBookerFromId($entry['bookerId']);
             $bookers[] = $flightBookerComponent;
         } else {
             if ($entry['type'] == 'hotel') {
                 $hotelBookerComponent = new HotelBookerComponent();
                 $hotelBookerComponent->setHotelBookerFromId($entry['bookerId']);
                 $bookers[] = $hotelBookerComponent;
             } else {
                 throw new Exception("Unexpected segment type");
             }
         }
     }
     return $bookers;
 }
 public function actionTicketHotel($bookingId)
 {
     $booking = new HotelBookerComponent();
     $booking->setHotelBookerFromId($bookingId);
     $booking->status('ticketing');
     $this->redirect(array('view', 'id' => $booking->getCurrent()->orderBookingId));
 }