/**
 * Оплата из буфера.
 *
 * @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;
}