Esempio n. 1
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/xajax/tservices_orders.common.php";
$xajax->printJavascript('/xajax/');
/**
 * @var TServiceCatalogController $this
 * 
 * @var $order заказ на основе ТУ
 */
//Заголовок заказа
$title = reformat(htmlspecialchars($order['title']), 30, 0, 1);
$order_price = tservices_helper::cost_format($order['order_price'], true);
$order_days = tservices_helper::days_format($order['order_days']);
$is_reserve = tservices_helper::isOrderReserve($order['pay_type']);
$is_reserved = $is_reserve && $order['reserve']->isExistReserveData() && $order['reserve']->isStatusReserved();
$class_color = '000';
if ($is_reserve) {
    $class_color = 'ee1d16';
    if ($is_reserved) {
        $class_color = '6db335';
    }
}
?>
<script type="text/javascript">
    var _ORDERID = <?php 
echo $order['id'];
?>
;
</script>
<?php 
$this->renderClip('order-breadcrumbs');
Esempio n. 2
0
 public function acceptOrder()
 {
     $is_reserve = tservices_helper::isOrderReserve($this->order['pay_type']);
     //Отправляем фрилансеру
     //@todo: пока только при резерве суммы а при обычном заказе нечего не отправляем
     //@todo: доработать по аналогии с заказчиком ниже при использовании обеих форм!
     $ret_f = true;
     if ($is_reserve) {
         $this->recipient = $this->_formatFullname($this->order['freelancer'], true);
         $message = Template::render(TSERVICES_TPL_MAIL_PATH . 'accept_order_reserve_frl.tpl.php', array('smail' => &$this, 'order' => $this->order, 'params' => $this->_addUrlParams('f'), 'emp_fullname' => $this->_formatFullname($this->order['employer'])));
         $this->message = nl2br($message);
         $ret_f = $this->send('text/html');
     }
     /*  
     $this->recipient = $this->_formatFullname($this->order['freelancer'],true);
     $this->message = Template::render(
             TSERVICES_TPL_MAIL_PATH . 'accept_order_'.($this->debt_timestamp?'debt_':'').'frl.tpl.php', 
             array(
                 'smail' => &$this, 
                 'order' => $this->order,
                 'params' => $this->_addUrlParams('f'),
                 'emp_fullname' => $this->_formatFullname($this->order['employer']),
                 'debt_timestamp' => $this->debt_timestamp
             )
     );
     
     $ret_f = $this->send('text/html');
     */
     //Отправляем заказчику
     $this->recipient = $this->_formatFullname($this->order['employer'], true);
     $template = $is_reserve ? 'accept_order_reserve_emp.tpl.php' : 'accept_order_emp.tpl.php';
     $status = $is_reserve ? tservices_sms::STATUS_RESERVE_ACCEPT : NULL;
     $message = Template::render(TSERVICES_TPL_MAIL_PATH . $template, array('smail' => &$this, 'order' => $this->order, 'params' => $this->_addUrlParams('e'), 'frl_fullname' => $this->_formatFullname($this->order['freelancer'])));
     $this->message = nl2br($message);
     $ret_e = $this->send('text/html');
     //Доп.события
     $this->sendEvent($message, TRUE, $status);
     return $ret_f && $ret_e;
 }
<?php

/**
 *  Шаблок окошка подтверждения заказа для фрилансера
 *  учитывается вариант с резервированием средств.
 */
$title = reformat(htmlspecialchars($title), 30, 0, 1);
$price = tservices_helper::cost_format($price, true, false, false);
$days = $days . ' ' . ending($days, 'день', 'дня', 'дней');
$accept_url = tservices_helper::getOrderStatusUrl($idx, 'accept');
$is_reserve = tservices_helper::isOrderReserve($pay_type);
$tax = $tax * 100;
?>
<div id="tservices_orders_status_popup_<?php 
echo $idx;
?>
" class="b-shadow b-shadow_center b-shadow_width_580 b-shadow_hide b-shadow__quick __tservices_orders_status_popup_hide" style="display:block;">
    <div class="b-shadow__body b-shadow__body_pad_20">
        <h2 class="b-layout__title">
            Подтверждение заказа
        </h2>
        <div class="b-layout__txt b-layout__txt_padbot_10">
            <b><?php 
echo $title;
?>
</b>
            <br/><br/>
            Сумма заказа: <b><?php 
echo $price;
?>
</b><br/>
/**
 * Редактирование стоимости и сроков заказа ТУ
 * 
 * @param type $order_id
 * @param type $price
 * @param type $days
 * 
 * @return \xajaxResponse
 */
function tservicesOrdersSetPrice($order_id, $price, $days, $paytype)
{
    $objResponse =& new xajaxResponse();
    $uid = get_uid(false);
    $price = intval($price);
    $days = intval($days);
    $paytype = intval($paytype);
    //Валидация входных параметров
    $validator = new validation();
    $valid = $validator->is_natural_no_zero($price) && $validator->greater_than_equal_to($price, 300);
    $valid = $valid && $validator->is_natural_no_zero($days) && $validator->numeric_interval($days, 1, 730);
    $valid = $valid && in_array($valid, array(TServiceOrderModel::PAYTYPE_DEFAULT, TServiceOrderModel::PAYTYPE_RESERVE));
    if (!$valid) {
        return $objResponse;
    }
    //Получение заказа
    $orderModel = TServiceOrderModel::model();
    $order_id = intval($order_id);
    $old_order = $orderModel->getCard($order_id, $uid);
    if (!$old_order) {
        return $objResponse;
    }
    //Валидация возможности изменений
    $is_new_status = $old_order['status'] == TServiceOrderModel::STATUS_NEW;
    $is_owner = $old_order['emp_id'] == $uid;
    $is_reserve_accepted = isset($old_order['reserve_data']);
    if (!($is_new_status && $is_owner && !$is_reserve_accepted)) {
        return $objResponse;
    }
    //Проверка возможности смены типа оплаты
    $is_reserve = tservices_helper::isOrderReserve($paytype);
    if ($is_reserve && !tservices_helper::isAllowOrderReserve($old_order['category_id'])) {
        return $objResponse;
    }
    if (!$is_reserve) {
        $paytype = TServiceOrderModel::PAYTYPE_DEFAULT;
    }
    $data = array('order_price' => $price, 'order_days' => $days, 'pay_type' => $paytype);
    //Меняем
    if ($orderModel->edit($order_id, $data, $old_order['tax'])) {
        $order = $old_order;
        $order['order_price'] = $price;
        $order['order_days'] = $days;
        $order['pay_type'] = $paytype;
        //Сохранить действие в историю
        $history = new tservices_order_history($order_id);
        $history->save($order, $old_order);
        //Уведомление на почту
        $tservices_smail = new tservices_smail();
        $tservices_smail->changeOrder2($order, $old_order);
        //Обновляем интерфейс цен и сроков
        $objResponse->script("\$('tu-container-price').set('html', '" . tservices_helper::cost_format($price) . "');");
        $objResponse->script("\$('tu-container-days').set('html', '" . tservices_helper::days_format($days) . "');");
        $objResponse->script("\$('tu_edit_budjet_price').set('value', '" . $price . "');");
        $objResponse->script("\$('tu_edit_budjet_days').set('value', '" . $days . "');");
        //Обновляем сообщение статуса, т.к. вторая сторона тоже могла его изменить
        $tserviceOrderStatusWidget = new TServiceOrderStatus();
        $tserviceOrderStatusWidget->setIsEmp(true);
        $tserviceOrderStatusWidget->setOrder($order);
        $tserviceOrderStatusWidget->init();
        ob_start();
        $tserviceOrderStatusWidget->run();
        $statusHtml = ob_get_contents();
        ob_end_clean();
        $objResponse->assign('tservices_order_status_' . $order_id, 'innerHTML', $statusHtml);
        $objResponse->script("\n            \$('tu-container-price').getParent()\n            .removeClass('b-layout__link_bordbot_dot_" . ($is_reserve ? '000' : 'ee1d16') . "')\n            .addClass('b-layout__link_bordbot_dot_" . ($is_reserve ? 'ee1d16' : '000') . "');\n            \$('tu-container-price').getPrevious('span').set('html','" . ($is_reserve ? 'Бюджет:' : 'Стоимость:') . "');    \n        ");
    }
    return $objResponse;
}
 /**
  * Сохранить историю заказа
  * 
  * @param type $new_order
  * @param type $old_order
  */
 public function save($new_order, $old_order = null)
 {
     if (!$old_order) {
         $this->addEvent(sprintf(self::MES_CREATE, htmlspecialchars($new_order['title']), tservices_helper::days_format($new_order['order_days']), tservices_helper::cost_format($new_order['order_price'], true), tservices_helper::isOrderReserve($new_order['pay_type']) ? self::TEXT_RESERVE : self::TEXT_NORESERVE));
     } else {
         if ($old_order['order_price'] != $new_order['order_price']) {
             $this->addEvent(sprintf(self::MES_UPD_PRICE, tservices_helper::cost_format($old_order['order_price'], true), tservices_helper::cost_format($new_order['order_price'], true)));
         }
         if ($old_order['order_days'] != $new_order['order_days']) {
             $this->addEvent(sprintf(self::MES_UPD_DAYS, tservices_helper::days_format($old_order['order_days']), tservices_helper::days_format($new_order['order_days'])));
         }
         if ($old_order['pay_type'] != $new_order['pay_type']) {
             $is_reserve = tservices_helper::isOrderReserve($new_order['pay_type']);
             $str_from = $is_reserve ? self::TEXT_NORESERVE : self::TEXT_RESERVE;
             $str_to = !$is_reserve ? self::TEXT_NORESERVE : self::TEXT_RESERVE;
             $this->addEvent(sprintf(self::MES_UPD_RESERVE, $str_from, $str_to));
         }
     }
 }