예제 #1
0
 public function run($key)
 {
     $parts = explode('_', $key);
     $searchKey = $parts[0];
     $searchId = $parts[1];
     $flightBooker = FlightBooker::model()->findByAttributes(array('flightVoyageId' => 'flight_voyage_' . $key));
     if ($flightBooker) {
         $flightVoyage = $flightBooker->flightVoyage;
         Yii::app()->flightBooker->flightVoyage = $flightVoyage;
     } else {
         $flightVoyage = FlightVoyage::getFromCache($searchKey, $searchId);
         if ($flightVoyage) {
             Yii::app()->flightBooker->flightVoyage = $flightVoyage;
         }
     }
     if (!$flightVoyage) {
         throw new CHttpException(500, 'Your request expired');
     }
     Yii::app()->flightBooker->book();
     $status = Yii::app()->flightBooker->current->swGetStatus()->getId();
     $actionName = 'stage' . ucfirst($status);
     if ($action = $this->getController()->createAction($actionName)) {
         $action->execute();
     } else {
         Yii::app()->flightBooker->{$actionName}();
     }
 }
예제 #2
0
 public function forFlightItem($item)
 {
     $flightBooker = FlightBooker::model()->findByPk($item->flightBookerId);
     $flightPassports = FlightBookingPassport::model()->findAllByAttributes(array('flightBookingId' => $item->flightBookerId));
     if ($flightBooker) {
         if (!$this->orderBookingId) {
             $this->orderBookingId = $flightBooker->orderBookingId;
             $this->orderBooking = OrderBooking::model()->findByPk($this->orderBookingId);
         }
         $pdfFileName = $this->controller->renderPdf('ticketAvia', array('type' => 'avia', 'ticket' => $flightBooker->flightVoyage, 'bookingId' => $this->orderBooking->readableId, 'pnr' => $flightBooker->pnr, 'flightPassports' => $flightPassports));
         return array('realName' => $pdfFileName, 'visibleName' => "avia_{$flightBooker->flightVoyage->departureCity->code}_{$flightBooker->flightVoyage->arrivalCity->code}_" . date('Ymd', strtotime($flightBooker->flightVoyage->departureDate)) . ".pdf");
     }
 }
예제 #3
0
 public function transferMoney()
 {
     $bookingModel = $this->getOrderBooking();
     /** @var FlightBooker[] $flightBookers  */
     $flightBookers = FlightBooker::model()->findAllByAttributes(array('orderBookingId' => $bookingModel->primaryKey));
     foreach ($flightBookers as $flightBooker) {
         $status = $flightBooker->status;
         if (strpos($status, '/') !== false) {
             $status = substr($status, strpos($status, '/') + 1);
         }
         $flightBookerComponent = new FlightBookerComponent();
         $flightBookerComponent->setFlightBookerFromId($flightBooker->id);
         $flightBookerComponent->status('transferMoney');
         //$flightBooker->timeout;
     }
     $hotelBookers = HotelBooker::model()->findAllByAttributes(array('orderBookingId' => $bookingModel->primaryKey));
     foreach ($hotelBookers as $hotelBooker) {
         $status = $hotelBooker->status;
         if (strpos($status, '/') !== false) {
             $status = substr($status, strpos($status, '/') + 1);
         }
         $hotelBookerComponent = new HotelBookerComponent();
         $hotelBookerComponent->setHotelBookerFromId($hotelBooker->id);
         $hotelBookerComponent->status('transferMoney');
     }
 }
예제 #4
0
파일: Bill.php 프로젝트: niranjan2m/Voyanga
 public function getChannel()
 {
     $parts = explode('_', $this->channel);
     $ucFirstParts = array();
     foreach ($parts as $part) {
         $ucFirstParts[] = ucfirst($part);
     }
     $className = 'Payments_Channel_' . implode('_', $ucFirstParts);
     Yii::import("common.extensions.payments.models." . $className);
     $flightBookers = FlightBooker::model()->findAllByAttributes(array('billId' => $this->id));
     $hotelBookers = HotelBooker::model()->findAllByAttributes(array('billId' => $this->id));
     $bookers = Yii::app()->payments->preProcessBookers(array_merge($flightBookers, $hotelBookers));
     if (count($bookers) > 1) {
         throw new Exception("More than 1 processed booker for bill");
     }
     $booker = $bookers[0];
     if (!$booker) {
         # Would never happen in theory
         throw new Exception("No booker for given bill");
     }
     # FIXME passing this is hella retarded
     return new $className($this, $booker);
 }
예제 #5
0
 public function setFlightBookerFromId($flightBookerId)
 {
     $this->flightBooker = FlightBooker::model()->findByPk($flightBookerId);
     if (!$this->flightBooker) {
         throw new CException('FlightBooker with id ' . $flightBookerId . ' not found');
     }
     $this->flightBooker->setFlightBookerComponent($this);
 }
예제 #6
0
 public function getPassportsFromDb()
 {
     $flightBookerId = $this->flightBookerId;
     $flightBooker = FlightBooker::model()->findByPk($flightBookerId);
     if (!$flightBooker) {
         return array();
     }
     return FlightBookingPassport::model()->findAll(array('condition' => 'flightBookingId=:fbid', 'params' => array(':fbid' => $flightBooker->id), 'order' => 'id'));
 }