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; }
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; } }
public function getPayment() { $bookingModel = $this->getOrderBooking(); $haveStateStartPayment = true; $allTicketingValid = true; /** @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); } if ($status !== 'startPayment') { echo 'flight'; $haveStateStartPayment = false; } //$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); } if ($status !== 'softStartPayment' and $status !== 'hardStartPayment') { echo 'hotel' . $status; $haveStateStartPayment = false; } } if (!$haveStateStartPayment) { //TODO: make return money and go to find new objects $allTicketingValid = false; echo '=(('; } else { //TODO: make tiketing echo 'make ticketing'; /** @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); } if ($status == 'startPayment' and $allTicketingValid) { $flightBookerComponent = new FlightBookerComponent(); $flightBookerComponent->setFlightBookerFromId($flightBooker->id); $flightBookerComponent->status('ticketing'); //check that status is good //else $allTicketingValid = false; $newStatus = $flightBookerComponent->getStatus(); if ($newStatus == 'ticketingRepeat') { $allTicketingValid = false; } } //$flightBooker->timeout; } /** @var HotelBooker[] $hotelBookers */ $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); } if ($status == 'softStartPayment' and $allTicketingValid) { $hotelBookerComponent = new HotelBookerComponent(); $hotelBookerComponent->setHotelBookerFromId($hotelBooker->id); //TODO: may be task to cron??? $hotelBookerComponent->status('moneyTransfer'); } } foreach ($hotelBookers as $hotelBooker) { $status = $hotelBooker->status; if (strpos($status, '/') !== false) { $status = substr($status, strpos($status, '/') + 1); } if ($status == 'hardStartPayment' and $allTicketingValid) { $hotelBookerComponent = new HotelBookerComponent(); $hotelBookerComponent->setHotelBookerFromId($hotelBooker->id); $res = $hotelBookerComponent->checkValid(); if (!$res) { $allTicketingValid = false; } } } $haveProblems = false; foreach ($hotelBookers as $hotelBooker) { $status = $hotelBooker->status; if (strpos($status, '/') !== false) { $status = substr($status, strpos($status, '/') + 1); } if ($status == 'hardStartPayment' and $allTicketingValid) { $hotelBookerComponent = new HotelBookerComponent(); $hotelBookerComponent->setHotelBookerFromId($hotelBooker->id); $hotelBookerComponent->status('ticketing'); $newStatus = $hotelBookerComponent->getCurrent()->status; if (strpos($newStatus, '/') !== false) { $newStatus = substr($newStatus, strpos($newStatus, '/') + 1); } if ($newStatus == 'ticketingRepeat') { $allTicketingValid = false; $haveProblems = true; } } } if (!$allTicketingValid) { $this->returnMoney($haveProblems); } } }
public function actionTicketHotel($bookingId) { $booking = new HotelBookerComponent(); $booking->setHotelBookerFromId($bookingId); $booking->status('ticketing'); $this->redirect(array('view', 'id' => $booking->getCurrent()->orderBookingId)); }