Blame view

common/modules/product/views/manage/_form.php 5.07 KB
4253cbec   root   first commit
1
2
3
4
5
6
7
  <?php

  

  use yii\helpers\Html;

  use yii\widgets\ActiveForm;

  use yii\helpers\ArrayHelper;

  use common\components\artboxtree\ArtboxTreeHelper;

  use common\modules\product\helpers\ProductHelper;

4253cbec   root   first commit
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
72
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
134
135
136
137
138
139
  use kartik\select2\Select2;

  

  /* @var $this yii\web\View */

  /* @var $model common\modules\product\models\Product */

  /* @var $form yii\widgets\ActiveForm */

  ?>

  

  <div class="product-form">

  

      <?php $form = ActiveForm::begin([

          'options' => ['enctype' => 'multipart/form-data']

      ]); ?>

  

      <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

  

      <?= $form->field($model, 'is_top')->checkbox(['label' => 'ТОП']) ?>

      <?= $form->field($model, 'is_new')->checkbox(['label' => 'Новинка']) ?>

      <?= $form->field($model, 'akciya')->checkbox(['label' => 'Акционный']) ?>

  

      <?= $form->field($model, 'description')->widget(\mihaildev\ckeditor\CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>

      <?= $form->field($model, 'video')->textarea(); ?>

  

      <?= $form->field($model, 'brand_id')->dropDownList(

          ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'),

          [

              'prompt' => Yii::t('product', 'Select brand')

          ]

      ) ?>

  

      <?= $form->field($model, 'categories')->widget(Select2::className(), [

              'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'),

              'language' => 'ru',

              'options' => [

                  'placeholder' => Yii::t('product', 'Select categories'),

                  'multiple' => true,

              ],

              'pluginOptions' => [

                  'allowClear' => true

              ],

          ]

      ) ?>

  

      <?= $form->field($model, 'imagesUpload[]')->widget(\kartik\file\FileInput::classname(), [

          'language' => 'ru',

          'options' => [

              'accept' => 'image/*',

              'multiple' => true,

          ],

          'pluginOptions' => [

              'allowedFileExtensions' => ['jpg', 'gif', 'png'],

              'initialPreview' => !empty($model->imagesHTML) ? $model->imagesHTML : [],

              'initialPreviewConfig' => $model->imagesConfig,

              'overwriteInitial' => false,

              'showRemove' => false,

              'showUpload' => false,

  //            'uploadUrl' => empty($model->product_id) ? null : \yii\helpers\Url::to(['/product/manage/uploadImage']),

              'uploadAsync' => !empty($model->product_id),

              'previewFileType' => 'image',

          ],

      ]); ?>

  

      <?php /*= $form->field($model, 'variants')->widget(MultipleInput::className(), [

          'columns' => [

              [

                  'name'  => 'product_variant_id',

                  'type'  => MultipleInputColumn::TYPE_HIDDEN_INPUT,

              ],

              [

                  'name'  => 'name',

                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,

                  'title' => Yii::t('product', 'Name'),

              ],

              [

                  'name'  => 'sku',

                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,

                  'title' => Yii::t('product', 'SKU'),

              ],

              [

                  'name'  => 'price',

                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,

                  'title' => Yii::t('product', 'Price'),

              ],

              [

                  'name'  => 'price_old',

                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,

                  'title' => Yii::t('product', 'Old Price'),

              ],

              [

                  'name'  => 'product_unit_id',

                  'type'  => MultipleInputColumn::TYPE_DROPDOWN,

                  'title' => Yii::t('product', 'Unit'),

                  'items' => ArrayHelper::map(\common\modules\product\models\ProductUnit::find()->all(), 'product_unit_id', 'name'),

              ],

              [

                  'name'  => 'stock',

                  'type'  => MultipleInputColumn::TYPE_TEXT_INPUT,

                  'title' => Yii::t('product', 'Stock'),

                  'options' => [

                      'placeholder' => '∞'

                  ],

              ],

              [

                  'name'  => 'image',

                  'type'  => 'fileInput',

                  'title' => Yii::t('product', 'Image'),

                  'options' => [

                      'multiple' => false

                  ],

              ],

          ],

      ]);

      */ ?>

  

      <?php if(isset($groups)) :?>

      <?php  foreach($groups->all() as $group) :?>

          <?= $form->field($model, 'options')->checkboxList(

          ArrayHelper::map($group->options, 'tax_option_id', 'ValueRenderFlash'),

          [

              'multiple' => true,

              'unselect' => null,

          ]

          )->label($group->name);?>

      <?php endforeach?>

      <?php endif?>

  

      <div class="form-group">

          <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

      </div>

  

      <?php ActiveForm::end(); ?>

  

  </div>