/**
 * Оплата из буфера.
 *
 * @param type  $type
 * @param array $data (prof_id)
 *
 * @return type
 */
function quickPaymentFrlbindupBuffer($type, $data)
{
    $is_error = true;
    $uid = get_uid(false);
    $objResponse =& new xajaxResponse();
    $prof_id = (int) @$data['prof_id'];
    $is_spec = (bool) @$data['is_spec'];
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/buffer.php';
    $buffer = new buffer();
    $buffer_sum = $buffer->getSum();
    $freelancer_binds = new freelancer_binds();
    $is_binded = $freelancer_binds->isUserBinded($uid, $prof_id, $is_spec);
    $price = $freelancer_binds->getPriceUp($prof_id, $is_spec, $uid);
    if ($is_binded && $buffer_sum >= $price) {
        $bill = new billing($uid);
        $option = array('prof_id' => $prof_id);
        //Покупаем услугу смоимостью 0 рублей при любом заначении ЛС
        $ok = $bill->addServiceAndPayZero(freelancer_binds::OP_CODE_UP_BUFFER, $option);
        if ($ok) {
            $is_error = false;
            $buffer->setUsedSum($price);
            $objResponse->script('window.location.reload();');
        }
    }
    // Показываем предупреждение в случае ошибки
    if ($is_error) {
        $objResponse->script("\n            var qp = window.quick_payment_factory.getQuickPayment('frlbindup');\n            if(qp) qp.show_error('Возникла ошибка при поднятии закрепления в каталоге!');\n        ");
    }
    return $objResponse;
}
Ejemplo n.º 2
0
    $content = "content.php";
}
//------------------------------------------------------------------------------
// Попапы закреплений фрилансеров ----------------------------------------------
$popup = __paramInit('string', 'popup');
$freelancer_binds = new freelancer_binds();
$is_spec = $prof_id > 0;
$prof_use = $is_spec ? professions::GetProfessionOrigin($prof_id) : $prof_group_id;
$allow_frl_bind = $freelancer_binds->isAllowBind($uid, $prof_use, $is_spec);
$binded_to = $freelancer_binds->getBindDateStop($uid, $prof_use, $is_spec);
if ($allow_frl_bind || $binded_to) {
    quickPaymentPopupFrlbind::getInstance()->init(array('prof_id' => $prof_id, 'prof_group_id' => $prof_group_id, 'prof_use' => $prof_use, 'is_spec' => $is_spec, 'ammount' => $freelancer_binds->getPrice($prof_use, $is_spec, (bool) $binded_to, $uid), 'date_stop' => $binded_to, 'autoshow' => $popup == 'bind_prolong', 'addprof' => $is_spec && $freelancer_binds->needAddProf($uid, $prof_use)));
}
$is_bind_first = $freelancer_binds->isBindFirst($uid, $prof_use, $is_spec);
if ($binded_to && !$is_bind_first) {
    quickPaymentPopupFrlbindup::getInstance()->init(array('prof_id' => $prof_use, 'is_spec' => $is_spec, 'ammount' => $freelancer_binds->getPriceUp($prof_use, $is_spec, $uid), 'autoshow' => $popup == 'bind_up'));
}
$is_binded_hide = $binded_to && !$freelancer_binds->isAllowBind($uid, $prof_use, $is_spec, false);
//------------------------------------------------------------------------------
unset($_SESSION['payed_frl_' . md5($_SERVER['REQUEST_URI'])]);
$first_pages = array();
if ($prof_group_id) {
    $first_pages = firstpage::GetAll($prof_group_id, array(), true);
} else {
    $first_pages = firstpage::GetAll($prof_id ?: -1, array());
}
$_SESSION['payed_frl_' . md5($_SERVER['REQUEST_URI'])] = $first_pages ?: array();
$_SESSION['payed_frl_prof_id'] = $prof_group_id ? 0 : ($prof_id ?: -1);
$_SESSION['payed_frl_prof_group_id'] = $prof_group_id;
if ($popup == 'firstpage_prolong') {
    $_SESSION['firstpage_popup'] = 'prolong';