Commit 55bc499320551d84247d69ca332cecb23623436b
1 parent
e9142b0d
add create_item to translate
Showing
3 changed files
with
26 additions
and
16 deletions
Show diff stats
models/Event.php
... | ... | @@ -16,18 +16,14 @@ use yii\web\Request; |
16 | 16 | * This is the model class for table "event". |
17 | 17 | * |
18 | 18 | * @property integer $id |
19 | - * @property string $name | |
20 | - * @property string $alias | |
21 | - * @property string $body | |
22 | 19 | * @property string $image |
23 | - * @property string $meta_title | |
24 | - * @property string $description | |
25 | - * @property string $h1 | |
26 | - * @property string $seo_text | |
27 | 20 | * @property integer $created_at |
28 | 21 | * @property integer $updated_at |
29 | 22 | * @property integer $end_at |
30 | 23 | * @property integer $status |
24 | + * @property integer $is_sale | |
25 | + * @property integer $is_event | |
26 | + * @property integer $percent | |
31 | 27 | * @property integer $banner |
32 | 28 | * * From language behavior * |
33 | 29 | * @property EventLang $lang |
... | ... | @@ -61,7 +57,8 @@ class Event extends \yii\db\ActiveRecord |
61 | 57 | { |
62 | 58 | public $imageUpload; |
63 | 59 | public $products_file; |
64 | - | |
60 | + const ACTIVE = 1; | |
61 | + const INACTIVE = 2; | |
65 | 62 | /** |
66 | 63 | * @inheritdoc |
67 | 64 | */ |
... | ... | @@ -117,9 +114,9 @@ class Event extends \yii\db\ActiveRecord |
117 | 114 | public function rules() |
118 | 115 | { |
119 | 116 | return [ |
120 | - [['created_at', 'updated_at','percent','status','sale','is_event','percent' ], 'integer'], | |
117 | + [['created_at', 'updated_at','percent','status','is_sale','is_event','percent' ], 'integer'], | |
121 | 118 | [['image', 'end_at','banner'], 'string', 'max' => 255], |
122 | - [['imageUpload','sale','is_event'], 'safe'], | |
119 | + [['imageUpload','is_sale','is_event'], 'safe'], | |
123 | 120 | [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], |
124 | 121 | [['products_file'], 'file'], |
125 | 122 | ]; |
... | ... | @@ -145,7 +142,7 @@ class Event extends \yii\db\ActiveRecord |
145 | 142 | 'end_at' => Yii::t('app', 'end_at'), |
146 | 143 | 'status' => Yii::t('app', 'Статус акции'), |
147 | 144 | 'products_file' => Yii::t('app', 'Загрузка файла'), |
148 | - 'sale' => Yii::t('app', 'Распродажа'), | |
145 | + 'is_sale' => Yii::t('app', 'Распродажа'), | |
149 | 146 | 'percent' => Yii::t('app', 'Процент'), |
150 | 147 | 'is_event' => Yii::t('app', 'Акция'), |
151 | 148 | ]; |
... | ... | @@ -197,7 +194,7 @@ class Event extends \yii\db\ActiveRecord |
197 | 194 | } |
198 | 195 | |
199 | 196 | public static function getSaleEvents(){ |
200 | - return ArrayHelper::toArray(self::find()->select('percent')->distinct('percent')->where('sale=true AND percent IS NOT NULL')->orderBy('percent')->all()); | |
197 | + return ArrayHelper::toArray(self::find()->select('percent')->distinct('percent')->where('is_sale=true AND percent IS NOT NULL')->orderBy('percent')->all()); | |
201 | 198 | } |
202 | 199 | |
203 | 200 | } | ... | ... |
models/EventsToProducts.php
... | ... | @@ -33,8 +33,8 @@ class EventsToProducts extends \yii\db\ActiveRecord |
33 | 33 | return [ |
34 | 34 | [['event_id', 'product_id'], 'required'], |
35 | 35 | [['event_id', 'product_id'], 'integer'], |
36 | - [['event_id'], 'exist', 'skipOnError' => true, 'targetClass' => Event::className(), 'targetAttribute' => ['event_id' => 'event_id']], | |
37 | - [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], | |
36 | + [['event_id'], 'exist', 'skipOnError' => true, 'targetClass' => Event::className(), 'targetAttribute' => ['event_id' => 'id']], | |
37 | + [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'id']], | |
38 | 38 | ]; |
39 | 39 | } |
40 | 40 | ... | ... |
views/event/_form.php
... | ... | @@ -5,6 +5,7 @@ use artweb\artbox\event\models\Event; |
5 | 5 | use artweb\artbox\event\models\EventLang; |
6 | 6 | use artweb\artbox\language\widgets\LanguageForm; |
7 | 7 | use kartik\date\DatePicker; |
8 | +use kartik\select2\Select2; | |
8 | 9 | use yii\helpers\Html; |
9 | 10 | use yii\widgets\ActiveForm; |
10 | 11 | |
... | ... | @@ -74,9 +75,21 @@ use yii\widgets\ActiveForm; |
74 | 75 | |
75 | 76 | |
76 | 77 | |
77 | - <?= $form->field($model, 'status')->checkbox() ?> | |
78 | + <?= $form->field($model, 'status') | |
79 | + ->widget(Select2::className(), ( [ | |
80 | + 'name' => 'status', | |
81 | + 'hideSearch' => true, | |
82 | + 'data' => [ | |
83 | + 1 => \Yii::t('app', 'Active'), | |
84 | + 2 => \Yii::t('app', 'Inactive'), | |
85 | + ], | |
86 | + 'options' => [ 'placeholder' => \Yii::t('app', 'Select status...') ], | |
87 | + 'pluginOptions' => [ | |
88 | + 'allowClear' => true, | |
89 | + ], | |
90 | + ] )) ?> | |
78 | 91 | |
79 | - <?= $form->field($model, 'sale')->checkbox() ?> | |
92 | + <?= $form->field($model, 'is_sale')->checkbox() ?> | |
80 | 93 | |
81 | 94 | <?= $form->field($model, 'is_event')->checkbox() ?> |
82 | 95 | ... | ... |