/** * Инициализация тизера. * * @global array $js_file * * @param array $options [kind, uid] */ public function init($options = array()) { global $js_file; $js_file[] = 'tservices/tservices_binds.js'; if ($options) { $this->kind = (int) $options['kind']; $this->uid = (int) $options['uid']; } $time_to = time() + 7 * 86400; $use_bind_popup = false; $tu_bind_teaser = array('date' => date('j', $time_to) . ' ' . monthtostr(date('n', $time_to), true), 'href' => 'javascript:void(0);'); $tservices_binds = new tservices_binds($this->kind); $tservices_class = new tservices($this->uid); $profs = array(); if ($this->kind == tservices_binds::KIND_SPEC) { $profs[] = $this->prof_id; } elseif ($this->kind == tservices_binds::KIND_GROUP) { $tservices_categories = new tservices_categories(); $categories = $tservices_categories->getCategoriesByParent($this->prof_id); foreach ($categories as $category) { $profs[] = $category['id']; } } if ($countBindedTu = $tservices_binds->countBindedTu($this->uid, (int) $this->prof_id)) { $binded_text = ending($countBindedTu, 'ваша услуга', 'ваши услуги', 'ваших услуг'); $tu_bind_teaser['subtitle'] = $countBindedTu . ' ' . $binded_text . ' уже <br>закреплен' . ($countBindedTu > 1 ? 'ы' : 'а') . ' в этом разделе'; if ($tservices_class->hasUnbindedTservices($this->kind, $this->uid, $profs)) { $use_bind_popup = true; $tu_bind_teaser['title'] = 'Закрепите еще одну услугу'; $tu_bind_teaser['btn_text'] = 'Закрепить'; } else { $tu_bind_teaser['title'] = 'Добавьте еще одну услугу<br>и закрепите ее здесь'; $tu_bind_teaser['href'] = '/users/' . $_SESSION['login'] . '/tu/new/'; $tu_bind_teaser['btn_text'] = 'Добавить'; } } else { if ($tservices_class->hasUserTservice(true, $profs)) { $use_bind_popup = true; $tu_bind_teaser['title'] = 'Закрепите здесь услугу'; $tu_bind_teaser['btn_text'] = 'Закрепить'; } else { $tu_bind_teaser['title'] = 'Добавьте свою услугу<br>и закрепите ее здесь'; $tu_bind_teaser['href'] = '/users/' . $_SESSION['login'] . '/tu/new/'; $tu_bind_teaser['btn_text'] = 'Добавить'; } } if ($use_bind_popup) { quickPaymentPopupTservicebind::getInstance()->init(array('uid' => $this->uid, 'kind' => $this->kind, 'prof_id' => $this->prof_id)); $tu_bind_teaser['popup_id'] = quickPaymentPopupTservicebind::getInstance()->getPopupId(0); $tu_bind_teaser['popup'] = quickPaymentPopupTservicebind::getInstance()->render(); } $this->data = $tu_bind_teaser; $this->data['price'] = $tservices_binds->getPrice(false, $this->uid, $this->prof_id); $this->data['main_div_class'] = $this->kind == tservices_binds::KIND_LANDING ? 'b-layout__tu-cols b-layout__tu-cols_height_330' : 'i-pic i-pic_port i-pic_width_225 i-pic_margbot_30'; }
public function run() { $tservicesCategoriesModel = new tservices_categories(); $categories = array(); if ($this->category_group) { $categories = $tservicesCategoriesModel->getCategoriesByParent($this->category_group); } else { $categories = $tservicesCategoriesModel->getParents(); } $this->render('t-service-catalog-categories', array('categories' => $categories, 'get_params' => $this->filter_get_params)); }
public function init($params) { $kind = $params['kind'] ?: 1; //По умолчанию ставим лендинг $prof_id = (int) $params['prof_id']; $profs = array(); if ($kind == tservices_binds::KIND_SPEC) { $profs[] = $prof_id; } elseif ($kind == tservices_binds::KIND_GROUP) { $tservices_categories = new tservices_categories(); $categories = $tservices_categories->getCategoriesByParent($prof_id); foreach ($categories as $category) { $profs[] = $category['id']; } } $tservices = new tservices($params['uid']); $data = $tservices->getNotBindedList($kind, $profs); $tservices_text = $tservices_cur_text = ''; $tservices_cur = 0; if ($data) { foreach ($data as $tservice) { if (!$tservices_cur) { $tservices_cur = $tservice['id']; } if (!$tservices_cur_text) { $tservices_cur_text = $tservice['title']; } $tservices_list[] = $tservice['id'] . ": '" . addslashes($tservice['title']) . "'"; } $tservices_text = '{' . implode(', ', $tservices_list) . '}'; } else { $tservices_text = '{}'; } $this->setBuyPopupTemplate('buy_popup_tservicebind.tpl.php'); $tservices_binds = new tservices_binds($kind); $promoCodes = new PromoCodes(); $options = array('popup_title_class_bg' => 'b-fon_bg_po', 'popup_title_class_icon' => 'b-icon__po', 'popup_title' => $is_prolong ? 'Продление закрепления' : 'Закрепление услуги', 'popup_subtitle' => $is_prolong ? 'Срок продления закрепления' : 'Срок закрепления услуги', 'popup_id' => $this->getPopupId(0), 'unic_name' => $this->UNIC_NAME, 'payments_title' => 'Сумма и способ оплаты', 'payments_exclude' => array(self::PAYMENT_TYPE_BANK), 'ac_sum' => round($_SESSION['ac_sum'], 2), 'payment_account' => self::PAYMENT_TYPE_ACCOUNT, 'kind' => $kind, 'profession' => $tservices_binds->getProfessionText(false, $prof_id), 'tservices' => $tservices_text, 'tservices_cur' => $tservices_cur, 'tservices_cur_text' => $tservices_cur_text, 'ammount' => $tservices_binds->getPrice(false, $params['uid'], $prof_id), 'disable_tservices' => false, 'prof_id' => $prof_id, 'promo_code' => $promoCodes->render(PromoCodes::SERVICE_TSERVICEBIND)); //Обязательно передаем родителю parent::init($options); //Добавляем свойство к одному способу оплаты $this->options['payments'][self::PAYMENT_TYPE_CARD]['wait'] = 'Ждите ....'; $this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'] = sprintf($this->options['payments'][self::PAYMENT_TYPE_PLATIPOTOM]['content_after'], 'закрепление'); $this->inited = true; }