public function forHotelItem($item) { $hotelBooker = HotelBooker::model()->findByPk($item->hotelBookerId); $hotelPassports = HotelBookingPassport::model()->findAllByAttributes(array('hotelBookingId' => $item->hotelBookerId)); if ($hotelBooker) { $loop = true; $count = 0; while ($loop) { $voucherInfo = $this->hotelClient->voucher($hotelBooker->orderId); $voucherAvailable = true; //VarDumper::dump($voucherInfo); //die(); //UtilsHelper::soapObjectsArray($voucherInfo->voucherAvailable); foreach ($voucherInfo->voucherAvailable as $avail) { $voucherAvailable = $voucherAvailable && ($avail ? $avail != '0' ? true : false : false); } if ($voucherAvailable) { $loop = false; break; } else { $count++; if ($count > 2) { $loop = false; return false; break; } sleep(10); } } $hotelInfo = $this->hotelClient->hotelDetail($hotelBooker->hotel->hotelId); $this->hotelClient->hotelSearchDetails($hotelBooker->hotel); $pnr = implode(', ', $voucherInfo->references); if ($voucherInfo->suppliers) { $pnr .= ' (' . implode(', ', $voucherInfo->suppliers) . ')'; } if (!$this->orderBookingId) { $this->orderBookingId = $hotelBooker->orderBookingId; $this->orderBooking = OrderBooking::model()->findByPk($this->orderBookingId); } $pdfFileName = $this->controller->renderPdf('ticketHotel', array('type' => 'hotel', 'ticket' => $hotelBooker->hotel, 'bookingId' => $this->orderBooking->readableId, 'pnr' => $pnr, 'hotelPassports' => $hotelPassports, 'hotelInfo' => $hotelInfo)); return array('realName' => $pdfFileName, 'visibleName' => "hotel_{$hotelBooker->hotel->city->code}_" . date('Ymd', strtotime($hotelBooker->hotel->checkIn)) . ".pdf"); } }
public function getPassportsFromDb() { $hotelBookerId = $this->hotelBookerId; $hotelBooker = HotelBooker::model()->findByPk($hotelBookerId); if (!$hotelBooker) { return array(); } return HotelBookingPassport::model()->findAll(array('condition' => 'hotelBookingId=:hbid', 'params' => array(':hbid' => $hotelBooker->id), 'order' => 'id')); }