Пример #1
0
 public function summary()
 {
     if (is_null($this->query)) {
         $this->query = Orders::find()->alias('Orders');
     }
     $this->query->andWhere(['<>', 'Orders.status', Orders::STATUS_CANCEL]);
     $order = clone $this->query;
     $farm = clone $this->query;
     return (object) ['sum' => $this->query->joinWith('ordersHasProducts ohp')->sum('ohp.price*ohp.quantity'), 'count' => $this->query->sum('ohp.quantity'), 'farm_sum' => $farm->joinWith('products p')->sum('p.farm_price'), 'delivery_sum' => $order->sum('Orders.delivery_cost')];
 }
Пример #2
0
 public function run()
 {
     $view = $this->getView();
     $view->registerJs("\n        \$('.delivery_method input[type=checkbox]').change(function(){\n            var check_value = \$(this).val();\n            if (check_value == 3) {\n            } else {\n                \$('.for-load').text('Пожалуйста, подождите, идёт расчет стоимости доставки...');\n                \$.each(\$('.delivery_method input[type=checkbox]'), function(k, v){\n                    var c = \$(v);\n                    if (c.val() != check_value) {\n                        c.prop('checked', false);\n                    }\n                });\n            }\n            \$('.pay' + check_value).trigger('click');\n        });\n        ");
     if (\Yii::$app->request->get('delivery')) {
         if (\Yii::$app->request->get('delivery') == 3) {
             $view->registerJs("\n                \$('#orders-delivery').removeAttr('value');\n            ");
         } else {
             $view->registerJs("\n                \$('#orders-delivery').val(" . (int) \Yii::$app->request->get('delivery') . ");\n            ");
         }
     }
     $this->calculateDelivery();
     $order = new Orders();
     $delivery = $order->getDeliveryCost($this->weight);
     echo "<h3>СУММА ЗАКАЗА: {$this->orderSum} руб.</h3>";
     echo Html::a(null, ['index', 'delivery' => 1], ['class' => 'pay1']);
     echo Html::a(null, ['index', 'delivery' => 2], ['class' => 'pay2']);
     echo Html::a(null, ['index', 'delivery' => 3], ['class' => 'pay3']);
     echo "<h2>Способ оплаты:</h2>";
     echo "<div class='delivery_method'>\n                <label><input " . (\Yii::$app->request->get('delivery') == 2 ? 'checked' : '') . " type=\"checkbox\" name=\"delivery\" value=\"2\">&nbsp;&nbsp;&nbsp;<span style='font-size:1.3em'>" . $delivery['card'] . "руб.</span> Стоимость доставки по предоплате</label>\n                <label><input " . (\Yii::$app->request->get('delivery') == 1 ? 'checked' : '') . " type=\"checkbox\" name=\"delivery\" value=\"1\">&nbsp;&nbsp;&nbsp;<span style='font-size:1.3em'>" . $delivery['cash'] . "руб.</span> Оплата наложенным платежом при получении посылки</label>\n                <label><input " . (!in_array(\Yii::$app->request->get('delivery'), [1, 2]) ? 'checked' : '') . " type=\"checkbox\" name=\"delivery\" value=\"3\"> Выбрать способ доставки позднее, после разговора с менеджером</label><br />\n                </div>";
     echo "<br/><br/><br/><div class='for-load hide'><h3>СУММА ДОСТАВКИ: " . ($this->delivery_cost === 0 ? '-' : $this->delivery_cost) . " руб.</h3>";
     echo "<h3>ИТОГО: " . ($this->orderSum + $this->delivery_cost) . " руб.</h3></div>";
 }
Пример #3
0
?>

    <?php 
echo $form->field($model, 'email')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'sum_c')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(\stronglab\checkout\models\Orders::$statuses);
?>

    <?php 
echo $form->field($model, 'delivery')->dropDownList(\stronglab\checkout\models\Orders::getDeliveryENum());
?>

    <?php 
echo $form->field($model, 'delivery_cost')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'description')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'address')->textarea(['rows' => 6]);
?>

    <?php 
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrder()
 {
     return $this->hasOne(Orders::className(), ['id' => 'order_id']);
 }
Пример #5
0
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
$form = ActiveForm::begin(['id' => 'orders-form', 'enableAjaxValidation' => true, 'action' => ['update', 'id' => $model->id]]);
?>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'created', 'format' => ['date', 'php:d.m.Y H:i']], ['attribute' => 'status', 'value' => $form->field($model, 'status')->dropDownList(Orders::$statuses)->label(false) . Html::submitButton('Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']), 'format' => 'raw'], 'name', 'phone', 'address', ['label' => 'E-mail', 'value' => $model->email], ['attribute' => 'track', 'value' => $form->field($model, 'track')->textInput()->label(false) . Html::submitButton('Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) . ' ' . Html::a('Отправить трек на почту', ['send-track', 'id' => $model->id], ['class' => 'btn btn-primary', 'onclick' => 'return confirm("Вы действительно хотите отправить трек номер?")']), 'format' => 'raw'], 'description:ntext', ['label' => 'Ссылка на заказ', 'value' => Html::a(Url::toRoute(['/checkout/default/order', 'id' => $model->link_id], 'http'), Url::toRoute(['/checkout/default/order', 'id' => $model->link_id], 'http'), ['target' => '_blank']), 'format' => 'raw'], ['label' => 'Сумма заказа', 'value' => number_format($model->sum, 0, '.', ' ') . ' руб.<br /><br />' . $form->field($model, 'sum_c')->textInput()->hint('Действует только на сумму заказа, без учета доставки') . Html::submitButton('Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']), 'format' => 'raw'], ['attribute' => 'delivery_cost', 'value' => $form->field($model, 'delivery_cost')->textInput()->label(false) . $form->field($model, 'delivery')->dropDownList(Orders::getDeliveryENum())->label(false) . Html::submitButton('Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']), 'format' => 'raw'], 'weight', ['attribute' => 'sumWithDelivery', 'value' => !is_null($model->getSumWithDelivery()) ? number_format($model->getSumWithDelivery(), 0, '.', ' ') . ' руб.' : null], ['attribute' => 'comment', 'value' => $form->field($model, 'comment')->textarea()->label(false) . Html::submitButton('Сохранить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']), 'format' => 'raw'], ['label' => 'Добавить товар к заказу', 'value' => $form->field($model, 'newProduct')->label(false)->hint('Начните вводить часть названия товара')->widget(\yii\jui\AutoComplete::className(), ['clientOptions' => ['source' => new \yii\web\JsExpression("function(request, response) {\n                                    \$.getJSON('" . Url::to('find-product') . "', {\n                                        term: request.term\n                                    }, response);\n                                }"), 'select' => new \yii\web\JsExpression("function(event, ui) { \$(this).val(ui.item.label); addProduct(ui.item.value); return false; }")], 'options' => ['class' => 'form-control']]) . '<a href="#" class="btn btn-success" onclick="pushProduct(); event.preventDefault();">Добавить</a>', 'format' => 'raw'], ['label' => 'Перенести товары из заказа', 'value' => Html::textInput('split_from', null, ['id' => 'split_from', 'class' => 'form-control']) . '<br /><a href="#" class="btn btn-success" onclick="split(); event.preventDefault();">Перенести</a>', 'format' => 'raw']]]);
?>
    <?php 
ActiveForm::end();
?>

    <?php 
echo \yii\widgets\ListView::widget(['dataProvider' => $products, 'viewParams' => ['order' => $model], 'itemOptions' => ['class' => 'col-sm-6 col-md-4', 'style' => 'width: auto;'], 'itemView' => '_order-product']);
?>

</div>

<?php 
$this->registerJs("\nvar current_product_id = 0;\nfunction addProduct(id) {\n    current_product_id = id;\n}\nfunction pushProduct() {\n    if (current_product_id === 0) {\n        return ;\n    }\n    window.location.href = '" . Url::to(['add-product']) . "?productId=' + current_product_id + '&orderId=" . $model->id . "';\n}\nfunction split() {\n    var from = \$('#split_from').val();\n    window.location.href = '" . Url::to(['split']) . "?from=' + from + '&to=" . $model->id . "';\n}\n", \yii\web\View::POS_HEAD);
Пример #6
0
                <?php 
    if ($searchModel->status == \stronglab\checkout\models\Orders::STATUS_WAITING_DELIVERY) {
        ?>
                / Сумма доставки:
                <b><?php 
        echo number_format($summary->delivery_sum, 0, '.', '&nbsp;') . '</b>&nbsp;руб.';
        ?>
                    <?php 
    }
    ?>
                    <br/><br/>
                    <?php 
}
?>
                    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'value' => function ($model) {
    return Html::a('#' . $model->id, ['view', 'id' => $model->id]);
}, 'format' => 'raw', 'options' => ['style' => 'width: 55px;']], ['attribute' => 'created', 'format' => ['date', 'php:d.m.Y H:i'], 'filter' => DateRangePicker::widget(['model' => $searchModel, 'attribute' => 'created_range', 'pluginOptions' => ['timePicker' => true, 'timePicker24Hour' => true, 'timePickerIncrement' => 10, 'locale' => ['format' => 'DD.MM.YYYY HH:mm']]])], 'name', 'address', ['label' => 'N', 'value' => 'productsCount'], ['label' => 'Сумма заказа', 'value' => function ($model) {
    return number_format($model->sum, 0, '.', '&nbsp;') . '&nbsp;руб.';
}, 'format' => 'raw'], ['attribute' => 'sumWithDelivery', 'value' => function ($model) {
    return !is_null($model->sumWithDelivery) ? number_format($model->sumWithDelivery, 0, '.', '&nbsp;') . '&nbsp;руб.' : null;
}, 'format' => 'raw'], ['attribute' => 'delivery', 'value' => function ($model) {
    return $model->getDeliveryText();
}, 'filter' => \stronglab\checkout\models\Orders::getDeliveryENum(false)], ['attribute' => 'status', 'value' => function ($model) {
    return $model->textStatus;
}, 'filter' => \stronglab\checkout\models\Orders::$statuses], ['attribute' => 'comment', 'value' => function ($model) {
    return StringHelper::truncate($model->comment, 150);
}]]]);
?>
</div>