Commit b522bd6c27bf241c359c96375f594dbc1fcd832e

Authored by Alexey Boroda
1 parent ddbd75a1

-View bug fix

views/order/_form.php
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 use artweb\artbox\ecommerce\models\OrderPayment; 5 use artweb\artbox\ecommerce\models\OrderPayment;
6 use artweb\artbox\ecommerce\models\OrderProduct; 6 use artweb\artbox\ecommerce\models\OrderProduct;
7 use backend\models\SmsTemplate; 7 use backend\models\SmsTemplate;
8 - use common\components\CreditHelper;  
9 use common\models\User; 8 use common\models\User;
10 use kartik\grid\GridView; 9 use kartik\grid\GridView;
11 use kartik\grid\SerialColumn; 10 use kartik\grid\SerialColumn;
@@ -146,7 +145,6 @@ JS; @@ -146,7 +145,6 @@ JS;
146 <?php $form = ActiveForm::begin( 145 <?php $form = ActiveForm::begin(
147 [ 146 [
148 'id' => 'main-form', 147 'id' => 'main-form',
149 - // 'options' => [ 'class' => 'form-inline' ],  
150 ] 148 ]
151 ); ?> 149 ); ?>
152 <div class="container"> 150 <div class="container">
@@ -332,53 +330,11 @@ JS; @@ -332,53 +330,11 @@ JS;
332 'id', 330 'id',
333 'short' 331 'short'
334 ), 332 ),
335 - [ 'prompt' => 'Способ оплаты ...' ] 333 + [
  334 + 'prompt' => 'Способ оплаты ...',
  335 + 'disabled' => $model->payment == 10 ? 'disabled' : false,
  336 + ]
336 ); ?> 337 ); ?>
337 - <?php  
338 - if ($model->payment == 10) {  
339 - ?>  
340 - <div>  
341 - <div class="col-xs-4">  
342 - <?php  
343 - echo $form->field($model, 'credit_sum')  
344 - ->textInput(  
345 - [  
346 - 'class' => 'form-control credit_input',  
347 - 'data-sum' => $model->total,  
348 - ]  
349 - );  
350 - ?>  
351 - </div>  
352 - <div class="col-xs-4">  
353 - <?php  
354 - echo Html::tag('span', $model->total - $model->credit_sum, [  
355 - 'class' => 'credit_value_full',  
356 - ]);  
357 - ?>  
358 - </div>  
359 - <div class="col-xs-4">  
360 - <?php  
361 - echo $form->field($model, 'credit_month')  
362 - ->textInput(  
363 - [  
364 - 'class' => 'form-control credit_input',  
365 - ]  
366 - );  
367 - ?>  
368 - </div>  
369 - <div class="clearfix"></div>  
370 - <p>  
371 - <span class="credit_value">  
372 - <?php  
373 - echo CreditHelper::getCredit($model->total - $model->credit_sum, $model->credit_month);  
374 - ?>  
375 - </span>  
376 - <span>грн/мес</span>  
377 - </p>  
378 - </div>  
379 - <?php  
380 - }  
381 - ?>  
382 338
383 <?= $form->field($model, 'insurance') ?> 339 <?= $form->field($model, 'insurance') ?>
384 340
views/order/update.php
@@ -10,11 +10,15 @@ @@ -10,11 +10,15 @@
10 use yii\helpers\Html; 10 use yii\helpers\Html;
11 use yii\web\View; 11 use yii\web\View;
12 12
13 - $this->title = 'Заказ #' . $model->id; 13 + $this->title = 'Обновить заказ #' . $model->id;
14 $this->params[ 'breadcrumbs' ][] = [ 14 $this->params[ 'breadcrumbs' ][] = [
15 'url' => yii\helpers\Url::to([ '/ecommerce/order/index' ]), 15 'url' => yii\helpers\Url::to([ '/ecommerce/order/index' ]),
16 'label' => \Yii::t('app', 'Заказы'), 16 'label' => \Yii::t('app', 'Заказы'),
17 ]; 17 ];
  18 + $this->params[ 'breadcrumbs' ][] = [
  19 + 'url' => yii\helpers\Url::to([ '/ecommerce/order/view', 'id' => $model->id, ]),
  20 + 'label' => \Yii::t('app', 'Заказ #') . $model->id,
  21 + ];
18 $this->params[ 'breadcrumbs' ][] = $this->title; 22 $this->params[ 'breadcrumbs' ][] = $this->title;
19 23
20 $js = ' 24 $js = '
views/order/view.php
1 <?php 1 <?php
2 2
3 use artweb\artbox\ecommerce\models\Order; 3 use artweb\artbox\ecommerce\models\Order;
  4 + use common\components\CreditHelper;
4 use kartik\grid\GridView; 5 use kartik\grid\GridView;
5 use yii\data\ActiveDataProvider; 6 use yii\data\ActiveDataProvider;
6 use yii\grid\SerialColumn; 7 use yii\grid\SerialColumn;
@@ -22,6 +23,36 @@ @@ -22,6 +23,36 @@
22 'url' => [ 'index' ], 23 'url' => [ 'index' ],
23 ]; 24 ];
24 $this->params[ 'breadcrumbs' ][] = $this->title; 25 $this->params[ 'breadcrumbs' ][] = $this->title;
  26 +
  27 + if (empty($model->payment)) {
  28 + $payment = '';
  29 + } elseif ($model->payment == 10) {
  30 + $payment = Html::tag('h4', $model->orderPayment->lang->title, [ 'class' => 'text-navy' ]) . Html::beginTag(
  31 + 'table',
  32 + [ 'class' => 'table table-bordered' ]
  33 + ) . Html::tag(
  34 + 'tr',
  35 + Html::tag('td', $model->getAttributeLabel('credit_sum')) . Html::tag('td', $model->credit_sum)
  36 + ) . Html::tag(
  37 + 'tr',
  38 + Html::tag('td', $model->getAttributeLabel('credit_month')) . Html::tag('td', $model->credit_month)
  39 + ) . Html::tag(
  40 + 'tr',
  41 + Html::tag('td', 'Кредит') . Html::tag('td', $model->total - $model->credit_sum)
  42 + ) . Html::tag(
  43 + 'tr',
  44 + Html::tag('td', 'Оплата в месяц') . Html::tag(
  45 + 'td',
  46 + CreditHelper::getCredit(
  47 + $model->total - $model->credit_sum,
  48 + $model->credit_month
  49 + ) . ' грн/мес'
  50 + )
  51 + ) . Html::endTag('table');
  52 + } else {
  53 + $payment = $model->orderPayment->lang->title;
  54 + }
  55 +
25 ?> 56 ?>
26 <div class="order-view"> 57 <div class="order-view">
27 58
@@ -36,7 +67,7 @@ @@ -36,7 +67,7 @@
36 ], 67 ],
37 [ 'class' => 'btn btn-primary' ] 68 [ 'class' => 'btn btn-primary' ]
38 ) ?> 69 ) ?>
39 - 70 +
40 <?= Html::a( 71 <?= Html::a(
41 'История', 72 'История',
42 [ 73 [
@@ -64,7 +95,7 @@ @@ -64,7 +95,7 @@
64 'pay', 95 'pay',
65 [ 96 [
66 'label' => 'Причина', 97 'label' => 'Причина',
67 - 'value' => empty($model->reason) ? '' : Order::REASONS[$model->reason], 98 + 'value' => empty($model->reason) ? '' : Order::REASONS[ $model->reason ],
68 ], 99 ],
69 [ 100 [
70 'label' => 'Статус', 101 'label' => 'Статус',
@@ -81,8 +112,9 @@ @@ -81,8 +112,9 @@
81 'declaration', 112 'declaration',
82 'stock', 113 'stock',
83 [ 114 [
84 - 'label' => 'Способ оплаты',  
85 - 'value' => empty($model->payment) ? '' : $model->orderPayment->lang->title, 115 + 'label' => 'Способ оплаты',
  116 + 'value' => $payment,
  117 + 'format' => 'html',
86 ], 118 ],
87 'insurance', 119 'insurance',
88 'city', 120 'city',
@@ -134,24 +166,28 @@ @@ -134,24 +166,28 @@
134 </div><!-- /.box-tools --> 166 </div><!-- /.box-tools -->
135 </div><!-- /.box-header --> 167 </div><!-- /.box-header -->
136 <div class="box-body"> 168 <div class="box-body">
137 -  
138 -  
139 - <?php  
140 - echo ListView::widget(  
141 - [  
142 - 'dataProvider' => $historyData,  
143 - 'layout' => '{items}',  
144 - 'itemView' => '_timeline_item',  
145 - 'itemOptions' => [ 169 +
  170 +
  171 + <?php
  172 + echo ListView::widget(
  173 + [
  174 + 'dataProvider' => $historyData,
  175 + 'layout' => '{items}',
  176 + 'itemView' => '_timeline_item',
  177 + 'itemOptions' => [
146 'tag' => false, 178 'tag' => false,
147 - ],  
148 - 'options' => [  
149 - 'tag' => 'ul',  
150 - 'class' => 'list-view timeline',  
151 - ],  
152 - ]  
153 - );  
154 - ?> 179 + ],
  180 + 'options' => [
  181 + 'tag' => $historyData->totalCount == 0 ? 'div' : 'ul',
  182 + 'class' => $historyData->totalCount == 0 ? 'list-view' : 'list-view timeline',
  183 + ],
  184 + 'emptyText' => 'У этого заказа пока нет истории',
  185 + 'emptyTextOptions' => [
  186 + 'class' => 'callout callout-info',
  187 + ],
  188 + ]
  189 + );
  190 + ?>
155 191
156 192
157 </div><!-- /.box-body --> 193 </div><!-- /.box-body -->