Blame view

views/order/index.php 16.1 KB
e0906f08   Alexey Boroda   -Fixing existing ...
1
  <?php
2ad65823   Alexey Boroda   -Added date range...
2
3
4
5
6
7
      /**
       * @var ActiveDataProvider $dataProvider
       * @var OrderSearch        $searchModel
       * @var View               $this
       */
      
bb962a6d   Alexey Boroda   -Order in process
8
9
      use artweb\artbox\ecommerce\models\Delivery;
      use artweb\artbox\ecommerce\models\Label;
ce75bc1d   Alexey Boroda   -Grid view half w...
10
      use artweb\artbox\ecommerce\models\Order;
2ad65823   Alexey Boroda   -Added date range...
11
      use artweb\artbox\ecommerce\models\OrderSearch;
01185786   Alexey Boroda   -Sms in process
12
      use common\models\User;
2ad65823   Alexey Boroda   -Added date range...
13
      use kartik\daterange\DateRangePicker;
bb962a6d   Alexey Boroda   -Order in process
14
      use kartik\select2\Select2;
2ad65823   Alexey Boroda   -Added date range...
15
      use yii\data\ActiveDataProvider;
01185786   Alexey Boroda   -Sms in process
16
      use yii\helpers\ArrayHelper;
e0906f08   Alexey Boroda   -Fixing existing ...
17
      use yii\helpers\Html;
ce75bc1d   Alexey Boroda   -Grid view half w...
18
19
      use kartik\grid\GridView;
      use yii\helpers\StringHelper;
bb962a6d   Alexey Boroda   -Order in process
20
      use yii\helpers\Url;
01185786   Alexey Boroda   -Sms in process
21
      use yii\web\JsExpression;
2ad65823   Alexey Boroda   -Added date range...
22
      use yii\web\View;
bb962a6d   Alexey Boroda   -Order in process
23
      use yii\widgets\ActiveForm;
01185786   Alexey Boroda   -Sms in process
24
      use yii\widgets\Pjax;
e0906f08   Alexey Boroda   -Fixing existing ...
25
26
27
      
      $this->title = 'Заказы';
      $this->params[ 'breadcrumbs' ][] = $this->title;
ccfc5763   Alexey Boroda   -Order in process 3
28
29
30
31
32
33
34
35
      
      $js = <<< JS
  $('[name="OrderSearch[phone]"]').mask('+38(000)000-00-00', {
      placeholder: '+38(___)___-__-__'
  });
  JS;
      
      $this->registerJs($js, View::POS_READY);
db3040d3   Alexey Boroda   -Order module alm...
36
  
e0906f08   Alexey Boroda   -Fixing existing ...
37
  ?>
2ad65823   Alexey Boroda   -Added date range...
38
39
  <h1>Заказы</h1>
  <p>
dbdd0d43   Alexey Boroda   -Images and spoil...
40
      <?= Html::a(\Yii::t('app', 'Добавить заказ'), [ 'create' ], [ 'class' => 'btn btn-success btn-lg' ]) ?>
2ad65823   Alexey Boroda   -Added date range...
41
  </p>
01185786   Alexey Boroda   -Sms in process
42
  <?php Pjax::begin(); ?>
bb962a6d   Alexey Boroda   -Order in process
43
44
45
46
47
48
49
50
51
52
  <?php
      $searchForm = ActiveForm::begin(
          [
              'method' => 'GET',
              'action' => Url::to([ 'order/index' ]),
              'id'     => 'search-form',
          ]
      );
  ?>
  
dbdd0d43   Alexey Boroda   -Images and spoil...
53
  
bb962a6d   Alexey Boroda   -Order in process
54
      
f2d1c773   Alexey Boroda   -Images popup fix...
55
     
bb962a6d   Alexey Boroda   -Order in process
56
  
f2d1c773   Alexey Boroda   -Images popup fix...
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  <?php
  //    echo Html::button(\Yii::t('app', 'Скрыть/Показать'), [
  //  'data-toggle' => 'collapse',
  //  'data-target' => '#search-fields',
  //  'class' => 'btn btn-default'
  //]);
  //?>
  <div class="box box-primary">
    <div class="box-header with-border">
  <!--    <h3 class="box-title"></h3>-->
        <?php echo Html::submitButton(
            \Yii::t('app', 'Искать'),
            [
                'class' => 'btn btn-primary',
            ]
        ) ?>
      <div class="box-tools pull-right">
        <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
      </div>
    </div>
    
  <div class="row box-body" id="search-fields">
54350885   Alexey Boroda   -Order module sma...
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    <div class="col-md-4">
        <?php
            echo $searchForm->field($searchModel, 'label')
                            ->widget(
                                Select2::className(),
                                [
                                    'data'          => Label::find()
                                                            ->joinWith('lang')
                                                            ->select(
                                                                [
                                                                    'CONCAT(order_label.label,order_label_lang.title) AS name',
                                                                    'id',
                                                                ]
                                                            )
                                                            ->indexBy('id')
                                                            ->asArray()
                                                            ->column(),
c83499b4   Alexey Boroda   -Order index tran...
96
                                    'options'       => [ 'placeholder' => 'Выберите метки ...' ],
54350885   Alexey Boroda   -Order module sma...
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
                                    'pluginOptions' => [
                                        'allowClear' => true,
                                        'multiple'   => true,
                                    ],
                                ]
                            );
        ?>
        <?php
            echo $searchForm->field($searchModel, 'delivery')
                            ->widget(
                                Select2::className(),
                                [
                                    'data'          => Delivery::find()
                                                               ->joinWith('lang')
                                                               ->select('order_delivery_lang.title, id')
                                                               ->indexBy('id')
                                                               ->asArray()
                                                               ->column(),
c83499b4   Alexey Boroda   -Order index tran...
115
                                    'options'       => [ 'placeholder' => 'Выберите способ доставки ...' ],
54350885   Alexey Boroda   -Order module sma...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
                                    'pluginOptions' => [
                                        'allowClear' => true,
                                        'multiple'   => true,
                                    ],
                                ]
                            );
        ?>
        
        <?php
            $query = new JsExpression(
                'function(params) { return {q:params.term}; }'
            );
            echo $searchForm->field($searchModel, 'sku')
                            ->widget(
                                Select2::className(),
                                [
                                    'options'       => [ 'placeholder' => 'Search for a product ...' ],
                                    'pluginOptions' => [
                                        'allowClear'         => true,
                                        'minimumInputLength' => 3,
                                        'language'           => [
                                            'errorLoading' => new JsExpression(
                                                "function () { return 'Waiting for results...'; }"
                                            ),
                                        ],
                                        'ajax'               => [
                                            'url'      => \yii\helpers\Url::to([ 'find-product' ]),
                                            'dataType' => 'json',
                                            'data'     => $query,
                                        ],
                                        'escapeMarkup'       => new JsExpression(
                                            'function (markup) { return markup; }'
                                        ),
                                        'templateResult'     => new JsExpression(
                                            'function(data) { return data.sku; }'
                                        ),
                                        'templateSelection'  => new JsExpression(
                                            'function (data) {
0893579c   Alexey Boroda   -Bug fixed
154
155
156
157
158
159
                                       if(data.sku == undefined) {
                                           return "sku"; 
                                       } else {
                                           return data.sku;
                                       }
                                      }'
54350885   Alexey Boroda   -Order module sma...
160
161
162
163
164
165
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
                                        ),
                                    ],
                                ]
                            );
        
        ?>
    </div>
  
  
    <div class="col-md-4">
        <?= $searchForm->field($searchModel, 'manager_id')
                       ->dropDownList(
                           ArrayHelper::map(
                               User::find()
                                   ->asArray()
                                   ->all(),
                               'id',
                               'username'
                           ),
                           [ 'prompt' => \Yii::t('app', 'Выберите менеджера ...') ]
                       ) ?>
        
        <?= $searchForm->field($searchModel, 'email')
                       ->textInput() ?>
  
    </div>
    <div class="col-md-4">
        <?= $searchForm->field($searchModel, 'declaration')
                       ->textInput() ?>
        
        <?= $searchForm->field($searchModel, 'consignment')
                       ->textInput() ?>
    </div>
28b51b30   Alexey Boroda   -Order module bug...
193
  </div>
01185786   Alexey Boroda   -Sms in process
194
  
f2d1c773   Alexey Boroda   -Images popup fix...
195
196
  </div>
    
bb962a6d   Alexey Boroda   -Order in process
197
  <p>
ce75bc1d   Alexey Boroda   -Grid view half w...
198
199
200
      <?php
          echo GridView::widget(
              [
622a985a   Alexey Boroda   -Feed in process
201
                  'hover'        => true,
ce75bc1d   Alexey Boroda   -Grid view half w...
202
203
204
205
206
207
208
209
210
211
212
213
214
215
                  'dataProvider' => $dataProvider,
                  'filterModel'  => $searchModel,
                  'rowOptions'   => function($model) {
                      if ($model->wasted) {
                          return [ 'class' => 'danger' ];
                      } else {
                          return [];
                      }
                  },
                  'columns'      => [
                      [
                          'attribute' => 'id',
                          'filter'    => $searchForm->field($searchModel, 'id')
                                                    ->textInput(),
28b51b30   Alexey Boroda   -Order module bug...
216
                          'content'   => function($model) {
b0c7d586   Alexey Boroda   -Bykov fixes
217
                              $manager = $model->manager;
54350885   Alexey Boroda   -Order module sma...
218
                              if (empty($manager)) {
f2d1c773   Alexey Boroda   -Images popup fix...
219
                                  return Html::a($model->id, ['update', 'id' => $model->id], ['target' => '_blank', 'data-pjax' => '0']);
b0c7d586   Alexey Boroda   -Bykov fixes
220
                              } else {
f2d1c773   Alexey Boroda   -Images popup fix...
221
                                  return Html::a($model->id, ['update', 'id' => $model->id], ['target' => '_blank', 'data-pjax' => '0']) . '<br>' . $manager->username;
b0c7d586   Alexey Boroda   -Bykov fixes
222
                              }
28b51b30   Alexey Boroda   -Order module bug...
223
                          },
ce75bc1d   Alexey Boroda   -Grid view half w...
224
225
226
                      ],
                      [
                          'attribute' => 'created_at',
622a985a   Alexey Boroda   -Feed in process
227
                          'content'   => function($model) {
54350885   Alexey Boroda   -Order module sma...
228
229
                              return date('d/m/Y', $model->created_at) . '<br>' . date('G:i', $model->created_at);
                          },
ce75bc1d   Alexey Boroda   -Grid view half w...
230
231
232
233
234
235
236
237
238
239
240
                          'filter'    => $searchForm->field($searchModel, 'date_range')
                                                    ->widget(
                                                        DateRangePicker::className(),
                                                        [
                                                            'convertFormat' => false,
                                                            'pluginOptions' => [
                                                                'locale' => [
                                                                    'format'    => 'D-M-Y',
                                                                    'separator' => ' to ',
                                                                ],
                                                                'opens'  => 'left',
bb962a6d   Alexey Boroda   -Order in process
241
                                                            ],
ce75bc1d   Alexey Boroda   -Grid view half w...
242
243
244
245
246
247
248
                                                        ]
                                                    )
                                                    ->label(false)
                                                    ->render(),
                      ],
                      [
                          'attribute' => 'deadline',
01185786   Alexey Boroda   -Sms in process
249
250
                          'content'   => function($model) {
                              if ($model->deadline == '') {
ce75bc1d   Alexey Boroda   -Grid view half w...
251
252
                                  return '';
                              } else {
622a985a   Alexey Boroda   -Feed in process
253
254
255
256
                                  return \Yii::$app->formatter->asDate(
                                          $model->deadline,
                                          'php:d M'
                                      ) . '<br>' . \Yii::$app->formatter->asDate($model->deadline, 'php:Y г');
ce75bc1d   Alexey Boroda   -Grid view half w...
257
                              }
01185786   Alexey Boroda   -Sms in process
258
                          },
ce75bc1d   Alexey Boroda   -Grid view half w...
259
260
                      ],
                      'name',
54350885   Alexey Boroda   -Order module sma...
261
262
263
264
                      [
                          'attribute' => 'total',
                          'content'   => function($model) {
                              if (empty($model->total)) {
622a985a   Alexey Boroda   -Feed in process
265
                                  return '';
54350885   Alexey Boroda   -Order module sma...
266
                              } else {
622a985a   Alexey Boroda   -Feed in process
267
                                  return $model->total;
54350885   Alexey Boroda   -Order module sma...
268
269
270
                              }
                          },
                      ],
ce75bc1d   Alexey Boroda   -Grid view half w...
271
272
273
274
275
276
277
278
279
280
                      [
                          'attribute' => 'pay',
                          'content'   => function($model) {
                              if ($model->pay == false) {
                                  return '<span class="glyphicon glyphicon-remove"></span>';
                              } else {
                                  return '<span class="glyphicon glyphicon-ok"></span>';
                              }
                          },
                      ],
de382cfb   Alexey Boroda   -Two numbers
281
282
283
284
285
286
                      [
                        'attribute' => 'phone',
                        'content' => function($model) {
                            return $model->phone . '<br>' . $model->phone2;
                        }
                      ],
653d2754   Alexey Boroda   -Order module sma...
287
288
289
                      [
                          'attribute' => 'adress',
                          'content'   => function($model) {
54350885   Alexey Boroda   -Order module sma...
290
291
292
293
294
295
296
297
298
299
                              if (!empty($model->adress)) {
                                  return Html::a(
                                      StringHelper::truncate($model->adress, 10, '...'),
                                      '#',
                                      [
                                          'data-toggle' => 'tooltip',
                                          'title'       => $model->adress,
                                          'onclick'     => 'event.preventDefault();',
                                      ]
                                  );
653d2754   Alexey Boroda   -Order module sma...
300
301
302
303
304
                              } else {
                                  return '';
                              }
                          },
                      ],
ce75bc1d   Alexey Boroda   -Grid view half w...
305
306
                      [
                          'attribute' => 'label',
01185786   Alexey Boroda   -Sms in process
307
                          'filter'    => false,
ce75bc1d   Alexey Boroda   -Grid view half w...
308
309
310
311
                          'value'     => function($model) {
                              /**
                               * @var Order $modl
                               */
54350885   Alexey Boroda   -Order module sma...
312
                              if (empty($model->orderLabel)) {
ce75bc1d   Alexey Boroda   -Grid view half w...
313
314
315
316
317
318
                                  return '--';
                              } else {
                                  return $model->orderLabel->label;
                              }
                          },
                      ],
ce75bc1d   Alexey Boroda   -Grid view half w...
319
320
321
                      [
                          'attribute' => 'body',
                          'content'   => function($model) {
54350885   Alexey Boroda   -Order module sma...
322
                              if (!empty($model->body)) {
b8e6a5c4   Alexey Boroda   -Order module sma...
323
                                  return StringHelper::truncate($model->body, 10, '...');
ce75bc1d   Alexey Boroda   -Grid view half w...
324
325
326
327
328
                              } else {
                                  return '';
                              }
                          },
                      ],
deaedeb0   Alexey Boroda   -Order module tas...
329
330
331
                      [
                          'attribute' => 'sms',
                          'content'   => function($model) {
54350885   Alexey Boroda   -Order module sma...
332
333
                              if (!empty($model->sms)) {
                                  return Html::a(
b8e6a5c4   Alexey Boroda   -Order module sma...
334
                                      StringHelper::truncate($model->sms, 10, '...'),
54350885   Alexey Boroda   -Order module sma...
335
336
337
338
339
340
341
                                      '#',
                                      [
                                          'data-toggle' => 'tooltip',
                                          'title'       => $model->sms,
                                          'onclick'     => 'event.preventDefault();',
                                      ]
                                  );
deaedeb0   Alexey Boroda   -Order module tas...
342
343
344
345
346
                              } else {
                                  return '';
                              }
                          },
                      ],
ce75bc1d   Alexey Boroda   -Grid view half w...
347
                      [
28b51b30   Alexey Boroda   -Order module bug...
348
349
                          'class'    => 'yii\grid\ActionColumn',
                          'template' => \Yii::$app->user->identity->isAdmin(
ff71eeed   Alexey Boroda   -Logs ready
350
                          ) ? '{history} {view} {update} {delete}' : '{view} {update}',
28b51b30   Alexey Boroda   -Order module bug...
351
352
353
354
355
                          'buttons'  => [
                              'update' => function($url, $model) {
                                  return Html::a(
                                      Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-pencil' ]),
                                      $url,
f2d1c773   Alexey Boroda   -Images popup fix...
356
357
358
359
                                      [
                                        'target' => '_blank',
                                        'data-pjax' => '0',
                                      ]
28b51b30   Alexey Boroda   -Order module bug...
360
361
                                  );
                              },
ff71eeed   Alexey Boroda   -Logs ready
362
363
364
365
366
367
368
369
370
371
                              'history' => function($url, $model) {
                                  return Html::a(
                                      Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-time' ]),
                                      ['log', 'id' => $model->id],
                                      [
                                          'target' => '_blank',
                                          'data-pjax' => '0',
                                      ]
                                  );
                              },
28b51b30   Alexey Boroda   -Order module bug...
372
                          ],
ce75bc1d   Alexey Boroda   -Grid view half w...
373
                      ],
bb962a6d   Alexey Boroda   -Order in process
374
                  ],
ce75bc1d   Alexey Boroda   -Grid view half w...
375
376
377
              ]
          );
      ?>
bb962a6d   Alexey Boroda   -Order in process
378
379
380
381
  </p>
  <?php
      ActiveForm::end();
  ?>
01185786   Alexey Boroda   -Sms in process
382
  <?php Pjax::end(); ?>