Blame view

views/order/index.php 4.41 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;
2ad65823   Alexey Boroda   -Added date range...
10
11
      use artweb\artbox\ecommerce\models\OrderSearch;
      use kartik\daterange\DateRangePicker;
bb962a6d   Alexey Boroda   -Order in process
12
      use kartik\select2\Select2;
2ad65823   Alexey Boroda   -Added date range...
13
      use yii\data\ActiveDataProvider;
e0906f08   Alexey Boroda   -Fixing existing ...
14
      use yii\helpers\Html;
bb962a6d   Alexey Boroda   -Order in process
15
16
      use yii\grid\GridView;
      use yii\helpers\Url;
2ad65823   Alexey Boroda   -Added date range...
17
      use yii\web\View;
bb962a6d   Alexey Boroda   -Order in process
18
      use yii\widgets\ActiveForm;
e0906f08   Alexey Boroda   -Fixing existing ...
19
20
21
      
      $this->title = 'Заказы';
      $this->params[ 'breadcrumbs' ][] = $this->title;
ccfc5763   Alexey Boroda   -Order in process 3
22
23
24
25
26
27
28
29
      
      $js = <<< JS
  $('[name="OrderSearch[phone]"]').mask('+38(000)000-00-00', {
      placeholder: '+38(___)___-__-__'
  });
  JS;
      
      $this->registerJs($js, View::POS_READY);
e0906f08   Alexey Boroda   -Fixing existing ...
30
  ?>
2ad65823   Alexey Boroda   -Added date range...
31
32
33
34
35
  <h1>Заказы</h1>
  <p>
      <?= Html::a('Add order', [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
  </p>
  
bb962a6d   Alexey Boroda   -Order in process
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  <?php
      $searchForm = ActiveForm::begin(
          [
              'method' => 'GET',
              'action' => Url::to([ 'order/index' ]),
              'id'     => 'search-form',
          ]
      );
  ?>
  
  <p>
      
      <?php echo Html::submitButton(
          'Search',
          [
              'class' => 'btn btn-primary',
          ]
      ) ?>
  
  </p>
  
  <?php
      echo Select2::widget(
          [
              'model'         => $searchModel,
              'attribute'     => 'label',
              'data'          => Label::find()
                                         ->joinWith('lang')
                                         ->select(['CONCAT(order_label.label,order_label_lang.title) AS name', 'id'])
                                         ->indexBy('id')
                                         ->asArray()
                                         ->column(),
              'options'       => [ 'placeholder' => 'Select a state ...' ],
              'pluginOptions' => [
                  'allowClear' => true,
                  'multiple'   => true,
e0906f08   Alexey Boroda   -Fixing existing ...
72
              ],
bb962a6d   Alexey Boroda   -Order in process
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
          ]
      );
  ?>
  <br>
  <?php
      echo Select2::widget(
          [
              'model'         => $searchModel,
              'attribute'     => 'delivery',
              'data'          => Delivery::find()
                                         ->joinWith('lang')
                                         ->select('order_delivery_lang.title, id')
                                         ->indexBy('id')
                                         ->asArray()
                                         ->column(),
              'options'       => [ 'placeholder' => 'Select a state ...' ],
              'pluginOptions' => [
                  'allowClear' => true,
                  'multiple'   => true,
              ],
          ]
      );
  ?>
  <p>
  <?php
      echo GridView::widget(
          [
              'dataProvider' => $dataProvider,
              'filterModel'  => $searchModel,
              'columns'      => [
                  [
                      'attribute' => 'id',
                      'filter'    => $searchForm->field($searchModel, 'id')
                                                ->textInput(),
                  ],
                  [
                      'attribute' => 'created_at',
                      'format'    => 'date',
                      'filter'    => $searchForm->field($searchModel, 'date_range')
                                                ->widget(
                                                    DateRangePicker::className(),
                                                    [
                                                        'convertFormat' => false,
                                                        'pluginOptions' => [
                                                            'locale' => [
                                                                'format'    => 'D-M-Y',
                                                                'separator' => ' to ',
                                                            ],
                                                            'opens'  => 'left',
                                                        ],
                                                    ]
                                                )
                                                ->label(false)
                                                ->render(),
                  ],
                  'name',
                  'phone',
                  'status',
                  [
                      'class' => 'yii\grid\ActionColumn',
                  ],
e0906f08   Alexey Boroda   -Fixing existing ...
134
              ],
bb962a6d   Alexey Boroda   -Order in process
135
136
137
138
139
140
141
          ]
      );
  ?>
  </p>
  <?php
      ActiveForm::end();
  ?>