Blame view

views/order/view.php 11 KB
db3040d3   Alexey Boroda   -Order module alm...
1
2
3
  <?php
      
      use artweb\artbox\ecommerce\models\Order;
a1604eb2   Alexey Boroda   -In order's view ...
4
      use artweb\artbox\ecommerce\models\OrderProduct;
b522bd6c   Alexey Boroda   -View bug fix
5
      use common\components\CreditHelper;
db3040d3   Alexey Boroda   -Order module alm...
6
      use kartik\grid\GridView;
3bee3445   Alexey Boroda   -Order history ready
7
8
      use yii\data\ActiveDataProvider;
      use yii\grid\SerialColumn;
db3040d3   Alexey Boroda   -Order module alm...
9
      use yii\helpers\Html;
a1604eb2   Alexey Boroda   -In order's view ...
10
      use yii\helpers\StringHelper;
db3040d3   Alexey Boroda   -Order module alm...
11
12
      use yii\web\View;
      use yii\widgets\DetailView;
3bee3445   Alexey Boroda   -Order history ready
13
      use yii\widgets\ListView;
db3040d3   Alexey Boroda   -Order module alm...
14
15
      
      /**
3bee3445   Alexey Boroda   -Order history ready
16
17
18
19
       * @var View               $this
       * @var Order              $model
       * @var ActiveDataProvider $products
       * @var ActiveDataProvider $historyData
db3040d3   Alexey Boroda   -Order module alm...
20
21
22
23
24
25
26
27
       */
      
      $this->title = 'Заказ #' . $model->id;
      $this->params[ 'breadcrumbs' ][] = [
          'label' => \Yii::t('app', 'Заказы'),
          'url'   => [ 'index' ],
      ];
      $this->params[ 'breadcrumbs' ][] = $this->title;
b522bd6c   Alexey Boroda   -View bug fix
28
29
30
31
32
33
34
35
36
      
      if (empty($model->payment)) {
          $payment = '';
      } elseif ($model->payment == 10) {
          $payment = Html::tag('h4', $model->orderPayment->lang->title, [ 'class' => 'text-navy' ]) . Html::beginTag(
                  'table',
                  [ 'class' => 'table table-bordered' ]
              ) . Html::tag(
                  'tr',
0b43e0d3   Alexey Boroda   -Credit informati...
37
38
39
40
41
42
                  Html::tag('td', $model->getAttributeLabel('credit_sum')) . Html::tag(
                      'td',
                      CreditHelper::checkSum(
                          $model->credit_sum
                      )
                  )
b522bd6c   Alexey Boroda   -View bug fix
43
44
              ) . Html::tag(
                  'tr',
0b43e0d3   Alexey Boroda   -Credit informati...
45
46
47
48
49
50
                  Html::tag('td', $model->getAttributeLabel('credit_month')) . Html::tag(
                      'td',
                      CreditHelper::checkMonth(
                          $model->credit_month
                      )
                  )
b522bd6c   Alexey Boroda   -View bug fix
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
              ) . Html::tag(
                  'tr',
                  Html::tag('td', 'Кредит') . Html::tag('td', $model->total - $model->credit_sum)
              ) . Html::tag(
                  'tr',
                  Html::tag('td', 'Оплата в месяц') . Html::tag(
                      'td',
                      CreditHelper::getCredit(
                          $model->total - $model->credit_sum,
                          $model->credit_month
                      ) . ' грн/мес'
                  )
              ) . Html::endTag('table');
      } else {
          $payment = $model->orderPayment->lang->title;
      }
  
a1604eb2   Alexey Boroda   -In order's view ...
68
69
70
71
72
    $js = <<< JS
    $('[data-toggle="popover"]').popover();
  JS;
    $this->registerJs($js, View::POS_READY);
  
db3040d3   Alexey Boroda   -Order module alm...
73
74
  ?>
  <div class="order-view">
3bee3445   Alexey Boroda   -Order history ready
75
76
77
78
79
80
81
82
83
84
85
86
  
    <h1><?= Html::encode($this->title) ?></h1>
  
    <p>
        <?= Html::a(
            'Обновить',
            [
                'update',
                'id' => $model->id,
            ],
            [ 'class' => 'btn btn-primary' ]
        ) ?>
b522bd6c   Alexey Boroda   -View bug fix
87
        
ff71eeed   Alexey Boroda   -Logs ready
88
89
90
91
92
93
94
95
        <?= Html::a(
            'История',
            [
                'log',
                'id' => $model->id,
            ],
            [ 'class' => 'btn bg-orange' ]
        ) ?>
3bee3445   Alexey Boroda   -Order history ready
96
97
98
99
100
101
102
103
104
105
106
    </p>
  
    <div class="box box-default">
      <div class="box-header with-border">
        <h3 class="box-title">Данные заказа</h3>
        <div class="box-tools pull-right">
          <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
        </div><!-- /.box-tools -->
      </div><!-- /.box-header -->
      <div class="box-body">
          <?= DetailView::widget(
db3040d3   Alexey Boroda   -Order module alm...
107
              [
3bee3445   Alexey Boroda   -Order history ready
108
109
                  'model'      => $model,
                  'attributes' => [
db3040d3   Alexey Boroda   -Order module alm...
110
                      'id',
3bee3445   Alexey Boroda   -Order history ready
111
112
                      'deadline',
                      'pay',
ff71eeed   Alexey Boroda   -Logs ready
113
114
                      [
                          'label' => 'Причина',
b522bd6c   Alexey Boroda   -View bug fix
115
                          'value' => empty($model->reason) ? '' : Order::REASONS[ $model->reason ],
ff71eeed   Alexey Boroda   -Logs ready
116
                      ],
3bee3445   Alexey Boroda   -Order history ready
117
118
                      [
                          'label' => 'Статус',
ddbd75a1   Alexey Boroda   -View bug fix
119
                          'value' => empty($model->label) ? '' : $model->orderLabel->lang->title,
3bee3445   Alexey Boroda   -Order history ready
120
                      ],
db3040d3   Alexey Boroda   -Order module alm...
121
                      'name',
3bee3445   Alexey Boroda   -Order history ready
122
123
124
125
126
                      'phone',
                      'email',
                      'comment',
                      [
                          'label' => 'Способ доставки',
ddbd75a1   Alexey Boroda   -View bug fix
127
                          'value' => empty($model->delivery) ? '' : $model->orderDelivery->lang->title,
3bee3445   Alexey Boroda   -Order history ready
128
129
130
131
                      ],
                      'declaration',
                      'stock',
                      [
b522bd6c   Alexey Boroda   -View bug fix
132
133
134
                          'label'  => 'Способ оплаты',
                          'value'  => $payment,
                          'format' => 'html',
3bee3445   Alexey Boroda   -Order history ready
135
136
137
138
139
140
141
                      ],
                      'insurance',
                      'city',
                      'adress',
                      'body',
                      'check',
                      'sms',
db3040d3   Alexey Boroda   -Order module alm...
142
143
                  ],
              ]
3bee3445   Alexey Boroda   -Order history ready
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
          ) ?>
      </div><!-- /.box-body -->
    </div><!-- /.box -->
  
  
    <div class="box box-default">
      <div class="box-header with-border">
        <h3 class="box-title">Товары</h3>
        <div class="box-tools pull-right">
          <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
        </div><!-- /.box-tools -->
      </div><!-- /.box-header -->
      <div class="box-body">
          <?php
              echo GridView::widget(
                  [
                      'dataProvider' => $products,
                      'columns'      => [
                          [
                              'class' => SerialColumn::className(),
                          ],
3bee3445   Alexey Boroda   -Order history ready
165
                          'sku',
a1604eb2   Alexey Boroda   -In order's view ...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
                          [
                              'attribute' => 'product_name',
                              'content'   => function (OrderProduct $model) {
                                  if (!empty( $model->product_name )) {
              
                                      if (empty( $model->productVariant )) {
                                          return '';
                                      }
              
                                      return Html::a(
                                          StringHelper::truncate($model->product_name, 10, '...'),
                                          '#',
                                          [
                                              'onclick'        => 'event.preventDefault();',
                                              'data-toggle'    => 'popover',
                                              'data-placement' => 'right',
                                              'data-html'      => 'true',
                                              'data-content'   => Html::img(
                                                      $model->productVariant->imageUrl,
                                                      [
                                                          'class' => 'img-rounded',
                                                      ]
                                                  ) . Html::tag('p', $model->product_name),
                                          ]
                                      );
                                  } else {
                                      return '';
                                  }
                              },
                          ],
                          [
                              'attribute' => 'productVariant.product.brand.lang.title',
                              'label'     => 'Брэнд',
                          ],
                          [
                              'attribute' => 'productVariant.lang.title',
                              'label'     => \Yii::t('app', 'Цвет'),
                              'content'   => function (OrderProduct $model) {
          
                                  if (empty( $model->productVariant )) {
                                      return '';
                                  }
          
                                  if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) {
                                      return '';
                                  } else {
                                      return $model->productVariant->lang->title;
                                  }
                              },
                          ],
                          [
                              'attribute' => 'productVariant.size',
                              'label'     => 'Размер',
                          ],
3bee3445   Alexey Boroda   -Order history ready
220
221
222
                          'price',
                          'count',
                          'sum_cost',
a1604eb2   Alexey Boroda   -In order's view ...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
                          'booking',
                          'status',
                          'return',
                          [
                              'content' => function (OrderProduct $model) {
          
                                  if (empty( $model->productVariant )) {
                                      return '<i class="glyphicon glyphicon-remove"></i>';
                                  }
          
                                  $content = '<table class="table"><tbody><tr><th>Склад</th><th>кол.</th></tr>';
                                  foreach ($model->productVariant->variantStocks as $stock) {
                                      $content .= '<tr><td>' . $stock->stock->title . '</td><td>' . $stock->quantity . '</td></tr>';
                                  }
                                  return Html::a(
                                      '<i class="glyphicon glyphicon-home"></i>',
                                      '#',
                                      [
                                          'onclick'        => 'event.preventDefault();',
                                          'data-toggle'    => 'popover',
                                          'data-placement' => 'left',
                                          'data-html'      => 'true',
                                          'data-content'   => $content . '</tbody></table>',
                                      ]
                                  );
                              },
                          ],
3bee3445   Alexey Boroda   -Order history ready
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
                      ],
                  ]
              );
          ?>
      </div><!-- /.box-body -->
    </div><!-- /.box -->
  
    <div class="box box-default">
      <div class="box-header with-border">
        <h3 class="box-title">История</h3>
        <div class="box-tools pull-right">
          <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
        </div><!-- /.box-tools -->
      </div><!-- /.box-header -->
      <div class="box-body">
b522bd6c   Alexey Boroda   -View bug fix
265
266
267
268
269
270
271
272
273
          
          
          <?php
              echo ListView::widget(
                  [
                      'dataProvider'     => $historyData,
                      'layout'           => '{items}',
                      'itemView'         => '_timeline_item',
                      'itemOptions'      => [
3bee3445   Alexey Boroda   -Order history ready
274
                          'tag' => false,
b522bd6c   Alexey Boroda   -View bug fix
275
276
277
278
279
280
281
282
283
284
285
286
                      ],
                      'options'          => [
                          'tag'   => $historyData->totalCount == 0 ? 'div' : 'ul',
                          'class' => $historyData->totalCount == 0 ? 'list-view' : 'list-view timeline',
                      ],
                      'emptyText'        => 'У этого заказа пока нет истории',
                      'emptyTextOptions' => [
                          'class' => 'callout callout-info',
                      ],
                  ]
              );
          ?>
3bee3445   Alexey Boroda   -Order history ready
287
288
289
290
  
  
      </div><!-- /.box-body -->
    </div><!-- /.box -->
db3040d3   Alexey Boroda   -Order module alm...
291
292
  
  </div>