Blame view

views/order/_form.php 11.7 KB
e0906f08   Alexey Boroda   -Fixing existing ...
1
2
  <?php
      
bb962a6d   Alexey Boroda   -Order in process
3
      use artweb\artbox\ecommerce\models\Label;
e0906f08   Alexey Boroda   -Fixing existing ...
4
      use artweb\artbox\ecommerce\models\Order;
30b799f2   Alexey Boroda   -Order in process 2
5
      use artweb\artbox\ecommerce\models\OrderPayment;
2ad65823   Alexey Boroda   -Added date range...
6
      use artweb\artbox\ecommerce\models\OrderProduct;
7520dc0e   Alexey Boroda   -Grid with input ...
7
      use kartik\grid\GridView;
bb962a6d   Alexey Boroda   -Order in process
8
      use kartik\widgets\DatePicker;
2ad65823   Alexey Boroda   -Added date range...
9
      use kartik\widgets\Select2;
bb962a6d   Alexey Boroda   -Order in process
10
      use kartik\widgets\SwitchInput;
7520dc0e   Alexey Boroda   -Grid with input ...
11
      use yii\data\ActiveDataProvider;
e0906f08   Alexey Boroda   -Fixing existing ...
12
13
      use yii\helpers\Html;
      use yii\bootstrap\ActiveForm;
6f14188b   Alexey Boroda   -Product card fixed
14
15
      use yii\helpers\ArrayHelper;
      use artweb\artbox\ecommerce\models\Delivery;
7520dc0e   Alexey Boroda   -Grid with input ...
16
      use yii\web\View;
2ad65823   Alexey Boroda   -Added date range...
17
      use yii\web\JsExpression;
e0906f08   Alexey Boroda   -Fixing existing ...
18
      
7520dc0e   Alexey Boroda   -Grid with input ...
19
20
21
22
23
24
      /**
       * @var View               $this
       * @var Order              $model
       * @var ActiveForm         $form
       * @var ActiveDataProvider $dataProvider
       */
2ad65823   Alexey Boroda   -Added date range...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
      
      $js = <<< JS
  $(document).on('submit', '#add-product-form', function(e) {
      e.preventDefault();
      var addFormData = $(this).serializeArray();
      var addFormAction = this.action;
      $.ajax({
          url: addFormAction,
          type: "POST",
          data: addFormData,
          success: function (data) {
               if (data.status === "success") {
                   $.pjax.reload({container:"#order-products-grid"});  //Reload GridView
               }
          },
          error: function () {
          }
      });
  });
  JS;
      
      $this->registerJs($js, View::POS_READY);
bb962a6d   Alexey Boroda   -Order in process
47
48
49
50
51
52
53
54
55
      
      $js = <<< JS
  $('#order-phone, #order-phone2').mask('+38(000)000-00-00', {
      placeholder: '+38(___)___-__-__'
  });
  JS;
      
      $this->registerJs($js, View::POS_READY);
  
e0906f08   Alexey Boroda   -Fixing existing ...
56
57
58
  ?>
  
  <?php $form = ActiveForm::begin(); ?>
6f14188b   Alexey Boroda   -Product card fixed
59
60
  <div class="container">
      <div class="row">
7520dc0e   Alexey Boroda   -Grid with input ...
61
62
63
64
65
66
67
68
          <div class="form-group">
              <?= Html::submitButton(
                  $model->isNewRecord ? 'Create' : 'Update',
                  [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
              ) ?>
          </div>
      </div>
      <div class="row">
6f14188b   Alexey Boroda   -Product card fixed
69
70
          <div class="col-sm-6">
              
30b799f2   Alexey Boroda   -Order in process 2
71
72
73
74
              <?= $form->field($model, 'deadline')
                       ->widget(
                           DatePicker::className(),
                           [
bb962a6d   Alexey Boroda   -Order in process
75
                  
30b799f2   Alexey Boroda   -Order in process 2
76
77
                           ]
                       ) ?>
bb962a6d   Alexey Boroda   -Order in process
78
79
80
81
82
83
84
85
86
87
88
89
90
91
              
              <?php
                  echo $form->field($model, 'pay')
                            ->widget(
                                SwitchInput::className(),
                                [
                                    'name'          => 'pay',
                                    'pluginOptions' => [
                                        'onText'  => \Yii::t('app', 'Оплачено'),
                                        'offText' => \Yii::t('app', 'Не оплачено'),
                                    ],
                                ]
                            ); ?>
              
ccfc5763   Alexey Boroda   -Order in process 3
92
93
94
95
96
97
98
99
100
              <?= $form->field($model, 'reason')
                       ->dropDownList(
                           [
                               1 => 'То',
                               2 => 'Сё',
                           ],
                           [ 'prompt' => 'Выберите причину' ]
                       ) ?>
              
bb962a6d   Alexey Boroda   -Order in process
101
102
103
104
105
106
107
108
109
              <?= $form->field($model, 'label')
                       ->dropDownList(
                           ArrayHelper::map(
                               Label::find()
                                    ->asArray()
                                    ->all(),
                               'id',
                               'label'
                           ),
ccfc5763   Alexey Boroda   -Order in process 3
110
                           [ 'prompt' => 'Выберите метку' ]
bb962a6d   Alexey Boroda   -Order in process
111
                       ); ?>
6f14188b   Alexey Boroda   -Product card fixed
112
113
114
115
116
117
118
119
120
              
              <?= $form->field($model, 'name') ?>
              
              <?= $form->field($model, 'phone') ?>
              
              <?= $form->field($model, 'phone2') ?>
              
              <?= $form->field($model, 'email') ?>
              
ccfc5763   Alexey Boroda   -Order in process 3
121
122
123
124
125
              <?= $form->field(
                  $model,
                  'numbercard'
              )
                       ->textInput([ 'readonly' => true ]) ?>
6f14188b   Alexey Boroda   -Product card fixed
126
              
bb962a6d   Alexey Boroda   -Order in process
127
              <?= $form->field($model, 'comment')
6f14188b   Alexey Boroda   -Product card fixed
128
                       ->textarea([ 'rows' => '3' ]) ?>
bb962a6d   Alexey Boroda   -Order in process
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
              <?= $form->field($model, 'delivery')
                       ->dropDownList(
                           ArrayHelper::map(
                               Delivery::find()
                                       ->joinWith('lang')
                                       ->asArray()
                                       ->all(),
                               'id',
                               'lang.title'
                           ),
                           [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ]
                       ) ?>
          
          </div>
          <div class="col-sm-6">
6f14188b   Alexey Boroda   -Product card fixed
144
145
146
147
148
              
              <?= $form->field($model, 'declaration') ?>
              
              <?= $form->field($model, 'stock') ?>
              
ccfc5763   Alexey Boroda   -Order in process 3
149
150
              <?= $form->field($model, 'consignment') ?>
              
6f14188b   Alexey Boroda   -Product card fixed
151
152
              <?= $form->field($model, 'payment')
                       ->dropDownList(
30b799f2   Alexey Boroda   -Order in process 2
153
154
155
156
157
158
159
160
161
                           ArrayHelper::map(
                               OrderPayment::find()
                                           ->joinWith('lang')
                                           ->where([ 'status' => OrderPayment::ACTIVE ])
                                           ->asArray()
                                           ->all(),
                               'id',
                               'lang.title'
                           ),
bb962a6d   Alexey Boroda   -Order in process
162
                           [ 'prompt' => 'Способ оплаты ...' ]
6f14188b   Alexey Boroda   -Product card fixed
163
164
165
166
167
168
                       ); ?>
              
              <?= $form->field($model, 'insurance') ?>
              
              <?= $form->field($model, 'amount_imposed') ?>
              
bb962a6d   Alexey Boroda   -Order in process
169
170
171
172
173
              <?= $form->field($model, 'shipping_by')
                       ->dropDownList(
                           ArrayHelper::getColumn(Order::SHIPPING_BY, 'label'),
                           [ 'prompt' => 'Оплата доставки ...' ]
                       ); ?>
6f14188b   Alexey Boroda   -Product card fixed
174
175
176
177
178
              
              <?= $form->field($model, 'city') ?>
              
              <?= $form->field($model, 'adress') ?>
              
bb962a6d   Alexey Boroda   -Order in process
179
              <?= $form->field($model, 'body')
6f14188b   Alexey Boroda   -Product card fixed
180
                       ->textarea([ 'rows' => '3' ]) ?>
ccfc5763   Alexey Boroda   -Order in process 3
181
182
183
184
185
  
              <?= $form->field($model, 'check') ?>
  
              <?= $form->field($model, 'sms') ?>
  
6f14188b   Alexey Boroda   -Product card fixed
186
          </div>
e0906f08   Alexey Boroda   -Fixing existing ...
187
188
      </div>
  </div>
7520dc0e   Alexey Boroda   -Grid with input ...
189
  <?php ActiveForm::end(); ?>
2ad65823   Alexey Boroda   -Added date range...
190
191
  
  
7520dc0e   Alexey Boroda   -Grid with input ...
192
193
194
195
196
197
  <div class="container">
      <div class="row">
          <?php
              echo GridView::widget(
                  [
                      'dataProvider' => $dataProvider,
bb962a6d   Alexey Boroda   -Order in process
198
                      'layout'       => '{items}{pager}',
7520dc0e   Alexey Boroda   -Grid with input ...
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
                      'columns'      => [
                          'id',
                          'product_name',
                          'sku',
                          [
                              'class'           => 'kartik\grid\EditableColumn',
                              'attribute'       => 'count',
                              'editableOptions' => [
                                  'header'    => \Yii::t('app', 'Количество'),
                                  'inputType' => kartik\editable\Editable::INPUT_SPIN,
                                  'options'   => [
                                      'pluginOptions' => [
                                          'min' => 0,
                                          'max' => 5000,
                                      ],
                                  ],
                              ],
7520dc0e   Alexey Boroda   -Grid with input ...
216
217
                              'format'          => [
                                  'decimal',
2ad65823   Alexey Boroda   -Added date range...
218
                                  0,
7520dc0e   Alexey Boroda   -Grid with input ...
219
                              ],
2ad65823   Alexey Boroda   -Added date range...
220
                              'pageSummary'     => false,
7520dc0e   Alexey Boroda   -Grid with input ...
221
222
                          ],
                          [
2ad65823   Alexey Boroda   -Added date range...
223
                              'class'    => 'yii\grid\ActionColumn',
7520dc0e   Alexey Boroda   -Grid with input ...
224
225
226
227
228
                              'template' => '{delete}',
                          ],
                      ],
                      'responsive'   => true,
                      'hover'        => true,
2ad65823   Alexey Boroda   -Added date range...
229
230
231
232
                      'pjax'         => true,
                      'pjaxSettings' => [
                          'options' => [
                              'scrollTo' => 'false',
bb962a6d   Alexey Boroda   -Order in process
233
                              'id'       => 'order-products-grid',
2ad65823   Alexey Boroda   -Added date range...
234
235
                          ],
                      ],
7520dc0e   Alexey Boroda   -Grid with input ...
236
237
238
                  ]
              );
          ?>
6f14188b   Alexey Boroda   -Product card fixed
239
      </div>
e0906f08   Alexey Boroda   -Fixing existing ...
240
  </div>
e0906f08   Alexey Boroda   -Fixing existing ...
241
  
2ad65823   Alexey Boroda   -Added date range...
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
  <div class="container">
      <div class="row">
          <?php $newProductForm = ActiveForm::begin(
              [
                  'action' => yii\helpers\Url::to([ 'add' ]),
                  'id'     => 'add-product-form',
              ]
          );
              $newOrderProduct = new OrderProduct();
          ?>
          <div class="col-md-8">
              <?php echo $newProductForm->field($newOrderProduct, 'id')
                                        ->widget(
                                            Select2::className(),
                                            [
                                                'options'       => [ 'placeholder' => 'Search for a product ...' ],
                                                'pluginOptions' => [
                                                    'allowClear'         => true,
bb962a6d   Alexey Boroda   -Order in process
260
                                                    'disabled'           => $model->isNewRecord ? true : false,
2ad65823   Alexey Boroda   -Added date range...
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
                                                    'minimumInputLength' => 3,
                                                    'language'           => [
                                                        'errorLoading' => new JsExpression(
                                                            "function () { return 'Waiting for results...'; }"
                                                        ),
                                                    ],
                                                    'ajax'               => [
                                                        'url'      => \yii\helpers\Url::to([ 'find-product' ]),
                                                        'dataType' => 'json',
                                                        'data'     => new JsExpression(
                                                            'function(params) { return {q:params.term}; }'
                                                        ),
                                                    ],
                                                    'escapeMarkup'       => new JsExpression(
                                                        'function (markup) { return markup; }'
                                                    ),
                                                    'templateResult'     => new JsExpression(
                                                        'function(data) { return data.sku; }'
                                                    ),
                                                    'templateSelection'  => new JsExpression(
                                                        'function (data) { return data.sku; }'
                                                    ),
                                                ],
                                            ]
                                        );
              
              ?>
          </div>
          <div class="col-md-2">
bb962a6d   Alexey Boroda   -Order in process
290
291
              <?php echo $newProductForm->field($newOrderProduct, 'count')
                                        ->input('number'); ?>
2ad65823   Alexey Boroda   -Added date range...
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
          </div>
          <div class="col-md-2">
              <?php echo Html::submitButton(
                  'Add',
                  [
                      'class' => $model->isNewRecord ? 'btn btn-primary disabled' : 'btn btn-primary',
                  ]
              ) ?>
          </div>
          <?php echo $newProductForm->field($newOrderProduct, 'order_id')
                                    ->hiddenInput(
                                        [
                                            'value' => $model->id,
                                        ]
                                    )
                                    ->label(false) ?>
          <?php ActiveForm::end(); ?>
      </div>
  </div>