/** * Extendable view */ protected function extendView() { // @todo f**k! this is executed 2 times?? if (isset($this->promo)) { return; } $this->promo = false; if (CHLibInput::cmd('promo')) { list($type, $id) = explode('-', CHLibInput::cmd('promo')); //CHLib::dumpItem($this->availability->results->search_rooms); // search promo in the discounts if ($type == 'discount') { $found_promo = $this->searchPormoInDiscounts($id); if ($found_promo) { $this->promo = (object) ['id' => (int) $id, 'type' => 'discount', 'title' => $found_promo->title]; } } // search promo in the extras if ($type == 'extra') { $found_extra = $this->searchPormoInExtras($id); if ($found_extra) { $this->promo = (object) ['id' => (int) $id, 'type' => 'extra', 'title' => $found_extra->title]; } } } }
/** * Get the search values */ static function getSearch() { // get app $app = self::getApp(); // check if search is already loaded if (isset($app->chclient->search)) { return $app->chclient->search; } // init search $search = new stdClass(); // currency & lang $search->lang = JFactory::getLanguage()->getTag(); $search->currency = $app->getUserStateFromRequest('chclient.currency', 'currency', null, 'cmd'); // get start & end dates & nights $default_start_date = CHLibDate::getDate()->format('Y-m-d'); $default_end_date = CHLibDate::getDate('+ 1 day')->format('Y-m-d'); $start_date = CHLibDate::getDate($app->getUserStateFromRequest('chclient.start_date', 'start_date', $default_start_date, 'string')); $end_date = CHLibDate::getDate($app->getUserStateFromRequest('chclient.end_date', 'end_date', $default_end_date, 'string')); $search->start_date = $start_date->format('Y-m-d'); $search->end_date = $end_date->format('Y-m-d'); $search->nights = ceil(($end_date->toUnix() - $start_date->toUnix()) / 86400); // search based on number of nights if (CHLibInput::uint('nights')) { $search->nights = CHLibInput::int('nights'); $search->end_date = CHLibDate::addToDate($search->start_date, "+{$search->nights} days"); } // store dates states $app->setUserState('chclient.start_date', $search->start_date); $app->setUserState('chclient.end_date', $search->end_date); // promo code $search->promo_code = $app->getUserStateFromRequest('chclient.promo_code', 'promo_code', '', 'cmd'); // load party object $search->party = self::loadParty(); // assign to global object $app->chclient->search = $search; return $search; }