예제 #1
0
 /**
  * Инициализация тизера.
  *
  * @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';
 }
 /**
  * Отображение страницы /tu/.
  */
 public function actionIndex()
 {
     $uid = get_uid();
     $page = __paramInit('int', 'page', 'page', 1);
     $limit = 21;
     $empty_criteria = $this->filter_widget->filter->isEmpty();
     $prof_id = $this->filter_widget->filter->category ? $this->filter_widget->filter->category : $this->filter_widget->filter->category_group;
     $tserviceModel = TServiceModel::model();
     $freelancerModel = FreelancerModel::model();
     $tservicesCatalogModel = new tservices_catalog();
     $tservicesCatalogModel->category_id = $prof_id;
     $kind = tservices_binds::KIND_ROOT;
     if ($this->filter_widget->filter->category) {
         $kind = tservices_binds::KIND_SPEC;
     } elseif ($this->filter_widget->filter->category_group) {
         $kind = tservices_binds::KIND_GROUP;
     }
     if ($page == 1 && $uid && !is_emp()) {
         $this->getClips()->add('bind_teaser', $this->widget('TServiceBindTeaser', array('kind' => $kind, 'uid' => $uid, 'prof_id' => $prof_id, 'is_inner' => !$empty_criteria), true));
         $this->getClips()->add('bind_teaser_short', $this->widget('TServiceBindTeaserShort', array(), true));
     }
     $free_places = true;
     //Сначала берем закрепленные
     $tservicesCatalogModel->setPage($limit, $page);
     $tservices_binded = $tservicesCatalogModel->getBindedList($kind);
     //Тут только для текущей страницы
     $tservices_binded_ids = $tservicesCatalogModel->getBindedIds($kind);
     //Тут для всех страниц
     $count_binded = count($tservices_binded_ids);
     $count_binded_cur_page = count($tservices_binded);
     if ($count_binded_cur_page) {
         // расширение сведений о типовых услугах
         $tserviceModel->extend($tservices_binded, 'id')->readVideos($tservices_binded, 'videos', 'videos');
         // во всех строках "распаковать" массив видео-клипов
         // расширение сведений о пользователях
         $freelancerModel->extend($tservices_binded, 'user_id', 'user');
         //Добавляем попапы продления и поднятия к услугам текущего юзера
         foreach ($tservices_binded as $key => $tservice) {
             $is_owner = $tservice['user_id'] == $uid;
             if ($is_owner) {
                 $this->getClips()->add('bind_links_' . $tservice['id'], $this->widget('TServiceBindLinks', array('kind' => $kind, 'uid' => $uid, 'is_inner' => !$empty_criteria, 'date_stop' => $tservice['date_stop'], 'allow_up' => $page > 1 || $key > 0, 'tservice_id' => $tservice['id']), true));
                 if (quickPaymentPopupTservicebind::getInstance()->inited == false) {
                     quickPaymentPopupTservicebind::getInstance()->init(array('uid' => $uid, 'kind' => $kind, 'prof_id' => $prof_id));
                 }
                 $popup_id = quickPaymentPopupTservicebind::getInstance()->getPopupId($tservice['id']);
                 $popups[] = quickPaymentPopupTservicebind::getInstance()->render(array('is_prolong' => true, 'date_stop' => $tservice['date_stop'], 'popup_id' => $popup_id, 'tservices_cur' => $tservice['id'], 'tservices_cur_text' => $tservice['title']));
                 if ($key > 0) {
                     if (quickPaymentPopupTservicebindup::getInstance()->inited == false) {
                         quickPaymentPopupTservicebindup::getInstance()->init(array('uid' => $uid, 'tservices_id' => $tservice['id'], 'tservices_title' => $tservice['title'], 'kind' => $kind, 'prof_id' => $prof_id));
                     }
                     $popup_id = quickPaymentPopupTservicebindup::getInstance()->getPopupId($tservice['id']);
                     $popups[] = quickPaymentPopupTservicebindup::getInstance()->render(array('popup_id' => $popup_id, 'tservices_cur' => $tservice['id'], 'tservices_cur_text' => $tservice['title']));
                 }
             }
         }
         $free_places = $count_binded_cur_page < $limit;
     }
     if ($free_places) {
         //Есть места для отображения незакрепленных услуг
         $tservicesCatalogModel->keywords = $this->filter_widget->filter->keywords;
         $tservicesCatalogModel->price_ranges = $this->filter_widget->filter->prices;
         $tservicesCatalogModel->price_max = $this->filter_widget->filter->price_max;
         $tservicesCatalogModel->country_id = $this->filter_widget->filter->country;
         $tservicesCatalogModel->city_id = $this->filter_widget->filter->city;
         $tservicesCatalogModel->order = $this->filter_widget->filter->order;
         $tservicesCatalogModel->setPage($limit, $page, $count_binded, $count_binded_cur_page);
         // поиск записей
         $list = $tservicesCatalogModel->cache(300)->getList($tservices_binded_ids);
         $tservices_search = $list['list'];
         $total = $list['total'];
         // расширение сведений о типовых услугах
         $tserviceModel->extend($tservices_search, 'id')->readVideos($tservices_search, 'videos', 'videos');
         // во всех строках "распаковать" массив видео-клипов
         // расширение сведений о пользователях
         $freelancerModel->extend($tservices_search, 'user_id', 'user');
     }
     $tservices = $tservices_binded;
     foreach ($tservices_search as $tservice) {
         if (count($tservices) < $limit && !in_array($tservice['id'], $tservices_binded_ids)) {
             $tservices[] = $tservice;
         }
     }
     $tservicesCatalogModel2 = new tservices_catalog();
     $tservicesCatalogModel2->category_id = $prof_id;
     $tservicesCatalogModel2->order = TServiceFilter::ORDER_PRICE_ASC;
     $tservicesCatalogModel2->setPage(1, 1);
     $list2 = $tservicesCatalogModel2->cache(300)->getList();
     $min_price = $list2['list'][0]['price'];
     SeoTags::getInstance()->initTserviceList($prof_id, $this->filter_widget->filter->category > 0, $total, $min_price);
     $view_name = !$empty_criteria ? 'list' : 'tile';
     $this->is_main = $empty_criteria;
     /*
             if ($empty_criteria)
             {
                 // над списком типовых услуг вывести рекламный блок раздела
                 require_once($_SERVER['DOCUMENT_ROOT'] . '/tu/widgets/TServiceCatalogPromo.php');
                 $this->getClips()->add('content-promo', $this->widget('TServiceCatalogPromo', array(), true));
             }
     */
     $tservices_binds = new tservices_binds($kind);
     $this->render($view_name, array('category_title' => $this->filter_widget->getCategoryAngGroupTitle(' / '), 'total' => $total, 'nothing_found' => empty($tservices), 'tservices' => $tservices, 'page' => $tservicesCatalogModel->page, 'limit' => $limit, 'paging_base_url' => $this->filter_widget->getUserFriendlyUrl(), 'is_adm' => $this->is_adm, 'orders' => $this->filter_widget->getAllowedOrders(true), 'cur_order' => $this->filter_widget->filter->order, 'uid' => $uid, 'popups' => $popups, 'bind_up_price' => $tservices_binds->getPrice(true, $uid, $prof_id)));
 }
예제 #3
0
파일: index.php 프로젝트: upovod/fl-ru-damp
 require_once $_SERVER['DOCUMENT_ROOT'] . '/tu/widgets/TServiceBindTeaser.php';
 $tserviceBindTeaser = new TServiceBindTeaser();
 $tserviceBindTeaser->init(array('kind' => tservices_binds::KIND_LANDING, 'uid' => $uid));
 require_once $_SERVER['DOCUMENT_ROOT'] . '/tu/widgets/TServiceBindTeaserShort.php';
 $tServiceBindTeaserShort = new TServiceBindTeaserShort();
 $isExistsBindUp = false;
 //Добавляем попапы продления и поднятия к услугам текущего юзера
 foreach ($tservices as $key => $tservice) {
     $is_owner = $tservice['user_id'] == $uid;
     if ($is_owner) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/quick_payment/quickPaymentPopupTservicebind.php';
         if (quickPaymentPopupTservicebind::getInstance()->inited == false) {
             quickPaymentPopupTservicebind::getInstance()->init(array('uid' => $uid, 'kind' => tservices_binds::KIND_LANDING));
         }
         $popup_id = quickPaymentPopupTservicebind::getInstance()->getPopupId($tservice['id']);
         $popups[] = quickPaymentPopupTservicebind::getInstance()->render(array('is_prolong' => true, 'date_stop' => $tservice['date_stop'], 'popup_id' => $popup_id, 'tservices_cur' => $tservice['id'], 'tservices_cur_text' => $tservice['title']));
         if ($key > 0) {
             $isExistsBindUp = true;
             require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/quick_payment/quickPaymentPopupTservicebindup.php';
             if (quickPaymentPopupTservicebindup::getInstance()->inited == false) {
                 quickPaymentPopupTservicebindup::getInstance()->init(array('uid' => $uid, 'tservices_id' => $tservice['id'], 'tservices_title' => $tservice['title'], 'kind' => tservices_binds::KIND_LANDING));
             }
             $popup_id = quickPaymentPopupTservicebindup::getInstance()->getPopupId($tservice['id']);
             $popups[] = quickPaymentPopupTservicebindup::getInstance()->render(array('popup_id' => $popup_id, 'tservices_cur' => $tservice['id'], 'tservices_cur_text' => $tservice['title']));
         }
     }
 }
 if ($isExistsBindUp) {
     $tservicesBinds = new tservices_binds(tservices_binds::KIND_LANDING);
     $bindUpPrice = $tservicesBinds->getPrice(true, $uid);
 }
/**
 * Оплата через Плати потом.
 * 
 * @param type $type - тип оплаты
 * @param type $data - данные по параметрам покупаемой услуги
 *
 * @return \xajaxResponse
 */
function quickPaymentTservicebindPlatipotom($type, $data)
{
    $is_error = true;
    $uid = get_uid(false);
    $objResponse =& new xajaxResponse();
    $kind = (int) @$data['kind'];
    $tservice_id = (int) @$data['tservice_text_db_id'];
    $prof_id = (int) @$data['prof_id'];
    $is_prolong = (bool) @$data['is_prolong'];
    $promo_code = (string) @$data['promo'];
    $tservices_binds = new tservices_binds($kind);
    $tservices = new tservices($uid);
    $allow = $tservices_binds->isAllowBind($uid, $tservice_id, $kind, $prof_id);
    $valid = $tservices->isExists($tservice_id) && ($is_prolong ? !$allow : $allow);
    if ($valid) {
        $is_error = false;
        $bill = new billing($uid);
        //Допустимо использование промокодов
        $bill->setPromoCodes('SERVICE_TSERVICEBIND', $promo_code);
        $op_code = $tservices_binds->getOpCode();
        $option = array('weeks' => (int) @$data['weeks'], 'prof_id' => $prof_id, 'tservice_id' => $tservice_id, 'is_prolong' => $is_prolong);
        //Формируем заказ
        $billReserveId = $bill->addServiceAndCheckout($op_code, $option);
        $payed_sum = $bill->getRealPayedSum();
        $platipotom = new platipotom();
        $html_form = $platipotom->render($payed_sum, $bill->account->id, $billReserveId);
        if ($html_form) {
            $idx = quickPaymentPopupTservicebind::getPopupId($is_prolong ? $tservice_id : 0);
            $objResponse->script("\n                var qp_form_wrapper = \$\$('#" . $idx . " .__quick_payment_form');\n                if(qp_form_wrapper){    \n                    qp_form_wrapper.set('html','{$html_form}');\n                    qp_form_wrapper.getElement('form')[0].submit();\n                }\n            ");
            //сохранаем в сессию куда перейти при успешной покупке
            $redirect = (string) @$data['redirect'];
            $_SESSION[quickPaymentPopup::QPP_REDIRECT] = $redirect;
        }
    }
    // Показываем предупреждение в случае ошибки
    if ($is_error) {
        $idx = quickPaymentPopupTservicebind::getPopupId($is_prolong ? $tservice_id : 0);
        $action = $is_prolong ? 'продлении закрепления' : 'закреплении';
        $objResponse->script("\n            var qp = window.quick_payment_factory.getQuickPaymentById('tservicebind', '" . $idx . "');\n            if(qp) qp.show_error('Возникла ошибка при {$action} услуги!');\n        ");
    }
    return $objResponse;
}
예제 #5
0
 
                     <?php 
                //@todo Заменить div ниже на $tserviceBindLinks->run();
                ?>
                        <div class="b-pay-tu__hider b-layout_padleft_20">
                            <div class="b-layout__txt b-layout__txt_bold b-layout__txt_padbot_10 b-layout__txt_fontsize_15">
                                Услуга закреплена<br>до <?php 
                echo dateFormat('j', $tservice['date_stop']) . ' ' . monthtostr(dateFormat('m', $tservice['date_stop']), true);
                ?>
                            </div>
                            <div class="b-layout__txt b-layout__txt_bold b-layout__txt_color_6db335 b-layout__txt_padbot_5 b-layout__txt_fontsize_15">
                                Продлите закрепление<br>на 7 и более дней
                            </div>
                            <a class="b-button b-button_flat b-button_flat_green" href="#" 
                               data-popup="<?php 
                echo quickPaymentPopupTservicebind::getInstance()->getPopupId($tservice['id']);
                ?>
">
                                Продлить
                            </a>
                            <?php 
                if ($k > 0) {
                    ?>
                                <div class="b-layout__txt b-layout__txt_bold b-layout__txt_color_6db335 b-layout__txt_padbot_5 b-layout__txt_fontsize_15 b-layout__txt_padtop_20">
                                    Поднимите услугу на<br>1 место за <?php 
                    echo view_cost_format($bindUpPrice, false);
                    ?>
 рублей
                                </div>
                                <a class="b-button b-button_flat b-button_flat_green" href="#"
                                   data-popup="<?php 
예제 #6
0
 /**
  * Уведомление фрилансеру за 1 день до окончания 
  * размещения закрепления ТУ
  */
 public function remind24hEndBinds()
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/tservices/tservices_binds.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/quick_payment/quickPaymentPopupTservicebind.php";
     $tservices_categories = new tservices_categories();
     //Базовый шаблон письма
     $layout = Template::render(TSERVICES_BINDS_TPL_BASE_LAYOUT, array('params' => '', 'content' => '%CONTENT%'));
     $this->message = nl2br($layout);
     $count = 0;
     $page = 0;
     while ($binds = tservices_binds::getExpiring(++$page, 200)) {
         $bind_ids = array();
         foreach ($binds as $el) {
             $kind_txt = '';
             $link = '/?' . quickPaymentPopupTservicebind::getPopupId($el['tservice_id']) . '=1';
             switch ($el['kind']) {
                 case tservices_binds::KIND_LANDING:
                     $kind_txt = 'на главной странице сайта';
                     break;
                 case tservices_binds::KIND_ROOT:
                     $kind_txt = 'в общем разделе каталога услуг';
                     $link = '/tu' . $link;
                     break;
                 case tservices_binds::KIND_GROUP:
                     $category = $tservices_categories->getCategoryById($el['prof_id']);
                     $kind_txt = sprintf("в разделе %s каталога услуг", @$category['title']);
                     $link = sprintf("/tu/%s%s", @$category['link'], $link);
                     break;
                 case tservices_binds::KIND_SPEC:
                     $category = $tservices_categories->getCategoryById($el['prof_id']);
                     $kind_txt = sprintf("в подразделе %s каталога услуг", @$category['title']);
                     $link = sprintf("/tu/%s%s", @$category['link'], $link);
                     break;
             }
             //Шаблон уведомления
             $content = Template::render(TSERVICES_BINDS_TPL_MAIL_PATH . "remind_prolong.tpl.php", array('smail' => $this, 'time' => dateFormat('H:i', $el['date_stop']), 'kind' => $kind_txt, 'title' => $el['title'], 'link' => $link));
             $this->recipient[] = array('email' => $this->_formatFullname($el, true), 'extra' => array('CONTENT' => nl2br($content)));
             $bind_ids[] = $el['id'];
         }
         $count += count($bind_ids);
         $massId = $this->send('text/html');
         if ($massId) {
             tservices_binds::markSent('prolong', $bind_ids);
         }
     }
     return $count;
 }