/** * * * * * @return Bill bill for given booker */ public function getBillForBooker($booker) { $channel = 'ecommerce'; if ($booker instanceof FlightBookerComponent) { $booker = $booker->getCurrent(); } if ($booker instanceof FlightBooker) { if ($booker->flightVoyage->webService == 'SABRE') { $channel = $booker->flightVoyage->valAirline->payableViaSabre ? 'gds_sabre' : 'ltr'; $channel = 'ltr'; } if ($booker->flightVoyage->webService == 'GALILEO') { $channel = $booker->flightVoyage->valAirline->payableViaGalileo ? 'gds_galileo' : 'ltr'; } } if ($booker->billId) { return Bill::model()->findByPk($booker->billId); } $bill = new Bill(); $bill->setChannel($channel); $bill->status = Bill::STATUS_NEW; $bill->amount = $booker->price; $bill->save(); $booker->billId = $bill->id; $booker->save(); return $bill; }