-
+ ['enctype'=>'multipart/form-data']
+ ]); ?>
= $form->field($model, 'name')->textInput() ?>
= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
- = \common\modules\file\widgets\ImageUploader::widget([
- 'model'=> $model,
- 'field'=>'image',
- 'size' => [
- [
- 'width'=>102,
- 'height'=>57,
- ]
+ = $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
+ 'options' => [
+ 'accept' => 'image/*',
],
- 'multi'=>false,
- 'gallery' => $model->image,
- 'name' => 'Загрузить изображение'
- ]);
- ?>
+ 'pluginOptions' => [
+ 'allowedFileExtensions' => ['jpg','gif','png'],
+ 'initialPreview' => function() use ($model) {
+ if (!empty($model->imageUrl))
+ return Html::img($model->imageUrl);
+ },
+ 'overwriteInitial' => false,
+ ],
+ ]); ?>
= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
diff --git a/backend/views/brand/index.php b/backend/views/brand/index.php
index b0a0619..958be47 100755
--- a/backend/views/brand/index.php
+++ b/backend/views/brand/index.php
@@ -20,13 +20,16 @@ $this->params['breadcrumbs'][] = $this->title;
= GridView::widget([
'dataProvider' => $dataProvider,
-// 'filterModel' => $searchModel,
+ 'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
-
- 'name',
+ [
+ 'label' => Yii::t('product', 'Brand'),
+ 'value' => 'brandName.value',
+ 'attribute' => 'brand_name'
+ ],
'alias',
-
+ 'imageUrl:image',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
diff --git a/backend/views/brand/update.php b/backend/views/brand/update.php
index 7b60ab0..4c48157 100755
--- a/backend/views/brand/update.php
+++ b/backend/views/brand/update.php
@@ -7,9 +7,9 @@ use yii\helpers\Html;
$this->title = Yii::t('product', 'Update {modelClass}: ', [
'modelClass' => 'Brand',
-]) . ' ' . $model->brand_id;
+]) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Brands'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = ['label' => $model->brand_id, 'url' => ['view', 'id' => $model->brand_id]];
+$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->brand_id]];
$this->params['breadcrumbs'][] = Yii::t('product', 'Update');
?>
diff --git a/backend/views/brand/view.php b/backend/views/brand/view.php
index 8180ef0..c5e6820 100755
--- a/backend/views/brand/view.php
+++ b/backend/views/brand/view.php
@@ -31,7 +31,7 @@ $this->params['breadcrumbs'][] = $this->title;
'brand_id',
'brand_name_id',
'alias',
- 'image',
+ 'imageUrl:image',
'meta_title',
'meta_desc:ntext',
'meta_robots',
diff --git a/backend/views/category/_form.php b/backend/views/category/_form.php
index 23a0154..6735b34 100755
--- a/backend/views/category/_form.php
+++ b/backend/views/category/_form.php
@@ -12,18 +12,46 @@ use kartik\select2\Select2;
-
+ ['enctype'=>'multipart/form-data']
+ ]); ?>
= $form->field($model, 'name')->textInput() ?>
= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
- = $form->field($model, 'parent_id')->dropDownList($categories, [
+ field($model, 'parent_id')->dropDownList($categories, [
'prompt' => Yii::t('rubrication', 'Root category'),
'options' => [
$model->category_id => ['disabled' => true]
]
- ])->label(Yii::t('product', 'Parent category')) ?>
+ ])->label(Yii::t('rubrication', 'Parent category')) */?>
+
+ = $form->field($model, 'parent_id')->widget(Select2::className(), [
+ 'data' => $categories,
+ 'language' => 'ru',
+ 'options' => [
+ 'placeholder' => Yii::t('product', 'Parent category'),
+ 'multiple' => false,
+ ],
+ 'pluginOptions' => [
+ 'allowClear' => true
+ ],
+ ]
+ ) ?>
+
+ = $form->field($model, 'product_unit_id')->widget(Select2::className(), [
+ 'data' => \yii\helpers\ArrayHelper::map(\common\modules\product\models\ProductUnit::find()->all(), 'product_unit_id', 'name'),
+ 'language' => 'ru',
+ 'options' => [
+ 'placeholder' => Yii::t('product', 'Select unit'),
+ 'multiple' => false,
+ ],
+ 'pluginOptions' => [
+ 'allowClear' => true
+ ],
+ ]
+ ) ?>
field($model, 'group_to_category')->dropDownList(
@@ -45,20 +73,14 @@ use kartik\select2\Select2;
]
) ?>
- = ImageUploader::widget([
- 'model'=> $model,
- 'field'=>'image',
- 'size' => [
- [
- 'width'=>340,
- 'height'=>260,
- ]
+ = $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
+ 'options' => [
+ 'accept' => 'image/*',
+ ],
+ 'pluginOptions' => [
+ 'allowedFileExtensions' => ['jpg','gif','png'],
],
- 'multi'=>false,
- 'gallery' => $model->image,
- 'name' => 'Загрузить изображение'
- ]);
- ?>
+ ]); ?>
= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
diff --git a/backend/views/category/index.php b/backend/views/category/index.php
index f1cb227..b16b8bb 100755
--- a/backend/views/category/index.php
+++ b/backend/views/category/index.php
@@ -35,6 +35,7 @@ $this->params['breadcrumbs'][] = $this->title;
// return str_repeat('-', $data->depth) .' '. $data->name;
}
],
+// 'imageUrl:image',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete} {populary}',
diff --git a/backend/views/category/view.php b/backend/views/category/view.php
index 0713127..4b315ce 100755
--- a/backend/views/category/view.php
+++ b/backend/views/category/view.php
@@ -33,10 +33,8 @@ $this->params['breadcrumbs'][] = $this->title;
'model' => $model,
'attributes' => [
'category_id',
- 'parent_id',
- 'path',
- 'depth',
- 'image',
+ 'parent.name',
+ 'imageUrl:image',
'meta_title',
'meta_desc:ntext',
'meta_robots',
diff --git a/backend/views/layouts/main-sidebar.php b/backend/views/layouts/main-sidebar.php
index afd46f4..a72962d 100755
--- a/backend/views/layouts/main-sidebar.php
+++ b/backend/views/layouts/main-sidebar.php
@@ -33,6 +33,7 @@ use yii\widgets\Menu;
['label' => 'Категории', 'url' => ['/category']],
['label' => 'Бренды', 'url' => ['/brand']],
['label' => 'Характеристики', 'url' => ['/rubrication/tax-group']],
+ ['label' => 'Единицы измерения', 'url' => ['/product/product-unit']],
['label' => 'Статистика импорта', 'url' => ['/product/manage/import-stat']],
]
],
diff --git a/common/modules/product/CatalogUrlManager.php b/common/modules/product/CatalogUrlManager.php
index 4b8a3e0..9dfb0bc 100644
--- a/common/modules/product/CatalogUrlManager.php
+++ b/common/modules/product/CatalogUrlManager.php
@@ -111,6 +111,7 @@ class CatalogUrlManager implements UrlRuleInterface {
$params['word'] = [$params['word']];
}
$url .= 'word:'. implode(';', $params['word']);
+ unset($params['word']);
}
$filter = [];
@@ -147,6 +148,10 @@ class CatalogUrlManager implements UrlRuleInterface {
$url .= 'filter:'. implode(';', $filter);
}
+ if (!empty($params) && ($query = http_build_query($params)) !== '') {
+ $url .= '?' . $query;
+ }
+
return $url;
break;
@@ -155,6 +160,11 @@ class CatalogUrlManager implements UrlRuleInterface {
$product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']);
}
$url = 'product/'. $product_alias;
+
+ if (!empty($params) && ($query = http_build_query($params)) !== '') {
+ $url .= '?' . $query;
+ }
+
return $url;
break;
}
diff --git a/common/modules/product/controllers/ProductUnitController.php b/common/modules/product/controllers/ProductUnitController.php
new file mode 100644
index 0000000..7ee6139
--- /dev/null
+++ b/common/modules/product/controllers/ProductUnitController.php
@@ -0,0 +1,124 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['POST'],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Lists all ProductUnit models.
+ * @return mixed
+ */
+ public function actionIndex()
+ {
+ $searchModel = new ProductUnitSearch();
+ $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+ return $this->render('index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single ProductUnit model.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new ProductUnit model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return mixed
+ */
+ public function actionCreate()
+ {
+ $model = new ProductUnit();
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->product_unit_id]);
+ } else {
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+ }
+
+ /**
+ * Updates an existing ProductUnit model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionUpdate($id)
+ {
+ $model = $this->findModel($id);
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->product_unit_id]);
+ } else {
+ return $this->render('update', [
+ 'model' => $model,
+ ]);
+ }
+ }
+
+ /**
+ * Deletes an existing ProductUnit model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionDelete($id)
+ {
+ $this->findModel($id)->delete();
+
+ return $this->redirect(['index']);
+ }
+
+ /**
+ * Finds the ProductUnit model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param integer $id
+ * @return ProductUnit the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = ProductUnit::findOne($id)) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+}
diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php
index f2fbde7..9eb3cac 100755
--- a/common/modules/product/models/Brand.php
+++ b/common/modules/product/models/Brand.php
@@ -24,6 +24,8 @@ use Yii;
*/
class Brand extends \yii\db\ActiveRecord
{
+ public $imageUpload;
+
public function behaviors()
{
return [
@@ -64,6 +66,8 @@ class Brand extends \yii\db\ActiveRecord
[['alias', 'name'], 'string', 'max' => 250],
[['image', 'meta_title'], 'string', 'max' => 255],
[['meta_robots'], 'string', 'max' => 50],
+ [['imageUpload'], 'safe'],
+ [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
// [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']],
];
}
@@ -79,6 +83,7 @@ class Brand extends \yii\db\ActiveRecord
'brand_name_id' => Yii::t('product', 'Brand Name ID'),
'alias' => Yii::t('product', 'Alias'),
'image' => Yii::t('product', 'Image'),
+ 'imageUrl' => Yii::t('product', 'Image'),
'meta_title' => Yii::t('product', 'Meta Title'),
'meta_desc' => Yii::t('product', 'Meta Desc'),
'meta_robots' => Yii::t('product', 'Meta Robots'),
@@ -113,4 +118,8 @@ class Brand extends \yii\db\ActiveRecord
public function getName() {
return empty($this->brand_name_id) ? null : $this->brandName->value;
}
+
+ public function getImageUrl() {
+ return empty($this->image) ? null : '/images/brand/'. $this->image;
+ }
}
diff --git a/common/modules/product/models/BrandSearch.php b/common/modules/product/models/BrandSearch.php
index eac3036..425df5c 100755
--- a/common/modules/product/models/BrandSearch.php
+++ b/common/modules/product/models/BrandSearch.php
@@ -12,6 +12,7 @@ use common\modules\product\models\Brand;
*/
class BrandSearch extends Brand
{
+ public $brand_name;
/**
* @inheritdoc
*/
@@ -19,7 +20,7 @@ class BrandSearch extends Brand
{
return [
[['brand_id', 'brand_name_id'], 'integer'],
- [['alias', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text'], 'safe'],
+ [['alias', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'brand_name'], 'safe'],
];
}
@@ -57,18 +58,28 @@ class BrandSearch extends Brand
return $dataProvider;
}*/
+ $dataProvider->setSort([
+ 'attributes' => [
+ 'brand_name',
+ 'alias'
+ ]
+ ]);
+
// grid filtering conditions
$query->andFilterWhere([
'brand_id' => $this->brand_id,
'brand_name_id' => $this->brand_name_id,
]);
- $query->andFilterWhere(['like', 'alias', $this->alias])
- ->andFilterWhere(['like', 'image', $this->image])
- ->andFilterWhere(['like', 'meta_title', $this->meta_title])
- ->andFilterWhere(['like', 'meta_desc', $this->meta_desc])
- ->andFilterWhere(['like', 'meta_robots', $this->meta_robots])
- ->andFilterWhere(['like', 'seo_text', $this->seo_text]);
+ $query->joinWith('brandName');
+
+ $query->andFilterWhere(['ilike', 'alias', $this->alias])
+ ->andFilterWhere(['ilike', 'image', $this->image])
+ ->andFilterWhere(['ilike', 'meta_title', $this->meta_title])
+ ->andFilterWhere(['ilike', 'meta_desc', $this->meta_desc])
+ ->andFilterWhere(['ilike', 'meta_robots', $this->meta_robots])
+ ->andFilterWhere(['ilike', 'seo_text', $this->seo_text])
+ ->andFilterWhere(['ilike', 'brand_name.value', $this->brand_name]);
return $dataProvider;
}
diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php
index fd6549b..7ba9b7a 100755
--- a/common/modules/product/models/Category.php
+++ b/common/modules/product/models/Category.php
@@ -34,6 +34,8 @@ use Yii;
*/
class Category extends \yii\db\ActiveRecord
{
+ public $imageUpload;
+
public function behaviors()
{
return [
@@ -89,7 +91,8 @@ class Category extends \yii\db\ActiveRecord
[['populary'], 'boolean'],
[['group_to_category', 'remote_category'], 'safe'],
[['category_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => CategoryName::className(), 'targetAttribute' => ['category_name_id' => 'category_name_id']],
- // [['image'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif'],
+ [['imageUpload'], 'safe'],
+ [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
// [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']],
];
}
@@ -105,6 +108,7 @@ class Category extends \yii\db\ActiveRecord
'path' => Yii::t('product', 'Path'),
'depth' => Yii::t('product', 'Depth'),
'image' => Yii::t('product', 'Image'),
+ 'imageUrl' => Yii::t('product', 'Image'),
'meta_title' => Yii::t('product', 'Meta Title'),
'meta_desc' => Yii::t('product', 'Meta Desc'),
'meta_robots' => Yii::t('product', 'Meta Robots'),
@@ -117,7 +121,8 @@ class Category extends \yii\db\ActiveRecord
];
}
- public static function find() {
+ public static function find()
+ {
return new CategoryQuery(get_called_class());
}
@@ -145,28 +150,38 @@ class Category extends \yii\db\ActiveRecord
return $this->hasMany(ProductCategory::className(), ['category_id' => 'category_id']);
}
- public function getTaxGroups() {
+ public function getTaxGroups()
+ {
return $this->getRelations('tax_group_to_category');
}
- public function getRemote_category() {
+ public function getRemote_category()
+ {
return ArtboxTreeHelper::getArrayField($this->remote_id);
}
- public function setRemote_category($value) {
+ public function setRemote_category($value)
+ {
if (!empty($value) && is_array($value)) {
$this->remote_id = ArtboxTreeHelper::setArrayField($value, false);
}
}
- public function getCategoryName() {
+ public function getCategoryName()
+ {
return $this->hasOne(CategoryName::className(), ['category_name_id' => 'category_name_id']);
}
- public function getName() {
+ public function getName()
+ {
return empty($this->categoryName) ? null : $this->categoryName->value;
}
+ public function getImageUrl()
+ {
+ return empty($this->image) ? null : '/images/category/' . $this->image;
+ }
+
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php
index e866f0b..37f5f88 100755
--- a/common/modules/product/models/Product.php
+++ b/common/modules/product/models/Product.php
@@ -19,6 +19,8 @@ use yii\db\ActiveQuery;
* @property ProductVariant $variant
* @property ProductImage $image
* @property array $images
+ * @property boolean $is_top
+ * @property boolean $is_new
*/
class Product extends \yii\db\ActiveRecord
{
@@ -69,6 +71,7 @@ class Product extends \yii\db\ActiveRecord
[['categories', 'variants', 'options'], 'safe'],
// [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif'],
[['description', 'video'], 'safe'],
+ [['is_top', 'is_new'], 'boolean'],
// [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']],
];
}
@@ -86,6 +89,11 @@ class Product extends \yii\db\ActiveRecord
'category' => Yii::t('product', 'Category'), // relation behavior field
'image' => Yii::t('product', 'Image'),
'images' => Yii::t('product', 'Images'),
+ 'description' => Yii::t('product', 'Description'),
+ 'video' => Yii::t('product', 'Video embeded'),
+ 'variants' => Yii::t('product', 'Variants'),
+ 'is_top' => Yii::t('product', 'Is top'),
+ 'is_new' => Yii::t('product', 'Is new'),
];
}
@@ -146,7 +154,8 @@ class Product extends \yii\db\ActiveRecord
}
public function getCategories() {
- return $this->getRelations('product_categories');
+ return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']);
+// return $this->getRelations('product_categories');
}
public function getCategoriesNames() {
@@ -158,12 +167,7 @@ class Product extends \yii\db\ActiveRecord
}
public function getCategory() {
- /** @var ActiveQuery $categories */
- $categories = $this->getRelations('product_categories');
- $count = $categories->count();
- if ($count == 0)
- return;
- return $categories->one();
+ return $this->hasOne(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']);
}
public function getOptions() {
diff --git a/common/modules/product/models/ProductSearch.php b/common/modules/product/models/ProductSearch.php
index 4e96614..b74d03a 100755
--- a/common/modules/product/models/ProductSearch.php
+++ b/common/modules/product/models/ProductSearch.php
@@ -13,14 +13,18 @@ use yii\web\NotFoundHttpException;
*/
class ProductSearch extends Product
{
+ public $brand_name;
+ public $category_name;
+
/**
* @inheritdoc
*/
public function rules()
{
return [
- [['name'], 'safe'],
+ [['name', 'brand_name', 'category_name'], 'safe'],
[['tax_brand_id', 'product_id'], 'integer'],
+ [['is_top', 'is_new'], 'boolean'],
];
}
@@ -58,13 +62,27 @@ class ProductSearch extends Product
return $dataProvider;
}
+ $dataProvider->setSort([
+ 'attributes' => [
+ 'name',
+ 'brand_name',
+ 'category_name'
+ ]
+ ]);
+
+ $query->joinWith(['brand', 'brand.brandNames', 'categories', 'categories.categoryNames']);
+
// grid filtering conditions
$query->andFilterWhere([
'tax_brand_id' => $this->tax_brand_id,
'product_id' => $this->product_id,
+ 'is_top' => (bool)$this->is_top,
+ 'is_new' => (bool)$this->is_new,
]);
- $query->andFilterWhere(['like', 'name', $this->name]);
+ $query->andFilterWhere(['ilike', 'name', $this->name]);
+ $query->andFilterWhere(['ilike', 'brand_name.value', $this->brand_name]);
+ $query->andFilterWhere(['ilike', 'category_name.value', $this->category_name]);
return $dataProvider;
}
diff --git a/common/modules/product/models/ProductUnitSearch.php b/common/modules/product/models/ProductUnitSearch.php
new file mode 100644
index 0000000..8b0be90
--- /dev/null
+++ b/common/modules/product/models/ProductUnitSearch.php
@@ -0,0 +1,72 @@
+ $query,
+ ]);
+
+ $this->load($params);
+
+ if (!$this->validate()) {
+ // uncomment the following line if you do not want to return any records when validation fails
+ // $query->where('0=1');
+ return $dataProvider;
+ }
+
+ // grid filtering conditions
+ $query->andFilterWhere([
+ 'product_unit_id' => $this->product_unit_id,
+ 'is_default' => $this->is_default,
+ ]);
+
+ $query->andFilterWhere(['like', 'name', $this->name])
+ ->andFilterWhere(['like', 'code', $this->code]);
+
+ return $dataProvider;
+ }
+}
diff --git a/common/modules/product/models/ProductVariant.php b/common/modules/product/models/ProductVariant.php
index 5172ffa..57f67e7 100755
--- a/common/modules/product/models/ProductVariant.php
+++ b/common/modules/product/models/ProductVariant.php
@@ -58,6 +58,7 @@ class ProductVariant extends \yii\db\ActiveRecord
'price_old' => Yii::t('product', 'Price Old'),
'stock' => Yii::t('product', 'Stock'),
'product_unit_id' => Yii::t('product', 'Product Unit ID'),
+ 'stock_caption' => Yii::t('product', 'Stock'),
];
}
@@ -77,6 +78,14 @@ class ProductVariant extends \yii\db\ActiveRecord
return $this->hasOne(Product::className(), ['product_id' => 'product_id']);
}
+ public function getEnabled() {
+ return $this->stock !== 0;
+ }
+
+ public function getStock_caption() {
+ return is_null($this->stock) ? '∞' : intval($this->stock);
+ }
+
/**
* @inheritdoc
* @return ProductVariantQuery the active query used by this AR class.
diff --git a/common/modules/product/views/manage/_form.php b/common/modules/product/views/manage/_form.php
index c22a817..356f572 100755
--- a/common/modules/product/views/manage/_form.php
+++ b/common/modules/product/views/manage/_form.php
@@ -22,7 +22,7 @@ use kartik\select2\Select2;
= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
= $form->field($model, 'description')->widget(\mihaildev\ckeditor\CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
- = $form->field($model, 'video')->textarea()->label('Video embeded'); ?>
+ = $form->field($model, 'video')->textarea(); ?>
= $form->field($model, 'brand_id')->dropDownList(
ArrayHelper::map(ProductHelper::getBrands()->all(), 'brand_id', 'name'),
@@ -35,7 +35,7 @@ use kartik\select2\Select2;
'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'name'),
'language' => 'ru',
'options' => [
- 'placeholder' => 'Select a state ...',
+ 'placeholder' => Yii::t('product', 'Select categories'),
'multiple' => true,
],
'pluginOptions' => [
@@ -62,33 +62,33 @@ use kartik\select2\Select2;
[
'name' => 'name',
'type' => MultipleInputColumn::TYPE_TEXT_INPUT,
- 'title' => 'Name',
+ 'title' => Yii::t('product', 'Name'),
],
[
'name' => 'sku',
'type' => MultipleInputColumn::TYPE_TEXT_INPUT,
- 'title' => 'SKU',
+ 'title' => Yii::t('product', 'SKU'),
],
[
'name' => 'price',
'type' => MultipleInputColumn::TYPE_TEXT_INPUT,
- 'title' => 'Price',
+ 'title' => Yii::t('product', 'Price'),
],
[
'name' => 'price_old',
'type' => MultipleInputColumn::TYPE_TEXT_INPUT,
- 'title' => 'Old Price',
+ 'title' => Yii::t('product', 'Old Price'),
],
[
'name' => 'product_unit_id',
'type' => MultipleInputColumn::TYPE_DROPDOWN,
- 'title' => 'Unit',
+ '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' => 'Stock',
+ 'title' => Yii::t('product', 'Stock'),
'options' => [
'placeholder' => '∞'
],
diff --git a/common/modules/product/views/manage/index.php b/common/modules/product/views/manage/index.php
index 0b5e061..41eb978 100755
--- a/common/modules/product/views/manage/index.php
+++ b/common/modules/product/views/manage/index.php
@@ -22,12 +22,57 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
- 'product_id',
+// 'product_id',
'name',
- 'brand.name',
- 'category.name',
+ [
+ 'label' => Yii::t('product', 'Brand'),
+ 'attribute' => 'brand_name',
+ 'value' => 'brand.name',
+ ],
+ [
+ 'label' => Yii::t('product', 'Category'),
+ 'attribute' => 'category_name',
+ 'value' => 'category.name',
+ ],
+ 'variant.price',
+ 'variant.stock_caption',
- ['class' => 'yii\grid\ActionColumn'],
+
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{view} {is_top} {is_new} {update} {delete}',
+ 'buttons' => [
+ 'is_top' => function ($url, $model) {
+ return Html::a('', $url, [
+ 'title' => Yii::t('product', ($model->is_top ? 'Set not is top' : 'Set is top')),
+ ]);
+ },
+ 'is_new' => function ($url, $model) {
+ return Html::a('', $url, [
+ 'title' => Yii::t('product', ($model->is_new ? 'Set not is new' : 'Set is new')),
+ ]);
+ },
+ ],
+ 'urlCreator' => function ($action, $model, $key, $index) {
+ switch ($action) {
+ case 'is_top':
+ return \yii\helpers\Url::to(['manage/is_top', 'id' => $model->product_id]);
+ break;
+ case 'is_new':
+ return \yii\helpers\Url::to(['manage/is_new', 'id' => $model->product_id]);
+ break;
+ case 'view':
+ return \yii\helpers\Url::to(['/catalog/product', 'id' => $model->product_id, ['target' => '_blank']]);
+ break;
+ case 'update':
+ return \yii\helpers\Url::to(['manage/update', 'id' => $model->product_id]);
+ break;
+ case 'delete':
+ return \yii\helpers\Url::to(['manage/delete', 'id' => $model->product_id]);
+ break;
+ }
+ }
+ ],
],
]); ?>
diff --git a/common/modules/product/views/product-unit/_form.php b/common/modules/product/views/product-unit/_form.php
new file mode 100644
index 0000000..f1a1206
--- /dev/null
+++ b/common/modules/product/views/product-unit/_form.php
@@ -0,0 +1,27 @@
+
+
+
diff --git a/common/modules/product/views/product-unit/_search.php b/common/modules/product/views/product-unit/_search.php
new file mode 100644
index 0000000..5fbe4cc
--- /dev/null
+++ b/common/modules/product/views/product-unit/_search.php
@@ -0,0 +1,33 @@
+
+
+
+
+ ['index'],
+ 'method' => 'get',
+ ]); ?>
+
+ = $form->field($model, 'product_unit_id') ?>
+
+ = $form->field($model, 'name') ?>
+
+ = $form->field($model, 'code') ?>
+
+ = $form->field($model, 'is_default')->checkbox() ?>
+
+
+ = Html::submitButton(Yii::t('product', 'Search'), ['class' => 'btn btn-primary']) ?>
+ = Html::resetButton(Yii::t('product', 'Reset'), ['class' => 'btn btn-default']) ?>
+
+
+
+
+
diff --git a/common/modules/product/views/product-unit/create.php b/common/modules/product/views/product-unit/create.php
new file mode 100644
index 0000000..5c54fcc
--- /dev/null
+++ b/common/modules/product/views/product-unit/create.php
@@ -0,0 +1,21 @@
+title = Yii::t('product', 'Create Product Unit');
+$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Units'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/common/modules/product/views/product-unit/index.php b/common/modules/product/views/product-unit/index.php
new file mode 100644
index 0000000..de9aad8
--- /dev/null
+++ b/common/modules/product/views/product-unit/index.php
@@ -0,0 +1,34 @@
+title = Yii::t('product', 'Product Units');
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+ render('_search', ['model' => $searchModel]); ?>
+
+
+ = Html::a(Yii::t('product', 'Create Product Unit'), ['create'], ['class' => 'btn btn-success']) ?>
+
+ = GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+
+ 'name',
+ 'code:html',
+ 'is_default:boolean',
+
+ ['class' => 'yii\grid\ActionColumn'],
+ ],
+ ]); ?>
+
diff --git a/common/modules/product/views/product-unit/update.php b/common/modules/product/views/product-unit/update.php
new file mode 100644
index 0000000..fcd5ef7
--- /dev/null
+++ b/common/modules/product/views/product-unit/update.php
@@ -0,0 +1,23 @@
+title = Yii::t('product', 'Update {modelClass}: ', [
+ 'modelClass' => 'Product Unit',
+]) . $model->name;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Units'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->product_unit_id]];
+$this->params['breadcrumbs'][] = Yii::t('product', 'Update');
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/common/modules/product/views/product-unit/view.php b/common/modules/product/views/product-unit/view.php
new file mode 100644
index 0000000..a5fbf82
--- /dev/null
+++ b/common/modules/product/views/product-unit/view.php
@@ -0,0 +1,38 @@
+title = $model->name;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Units'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+
+ = Html::a(Yii::t('product', 'Update'), ['update', 'id' => $model->product_unit_id], ['class' => 'btn btn-primary']) ?>
+ = Html::a(Yii::t('product', 'Delete'), ['delete', 'id' => $model->product_unit_id], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'),
+ 'method' => 'post',
+ ],
+ ]) ?>
+
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'product_unit_id',
+ 'name',
+ 'code',
+ 'is_default:boolean',
+ ],
+ ]) ?>
+
+
diff --git a/common/modules/product/widgets/views/brandsCarousel.php b/common/modules/product/widgets/views/brandsCarousel.php
index 1c46693..6c0ad9b 100755
--- a/common/modules/product/widgets/views/brandsCarousel.php
+++ b/common/modules/product/widgets/views/brandsCarousel.php
@@ -3,7 +3,7 @@
- 
+ 
diff --git a/common/modules/product/widgets/views/submenu.php b/common/modules/product/widgets/views/submenu.php
index dda048d..c4cfca6 100755
--- a/common/modules/product/widgets/views/submenu.php
+++ b/common/modules/product/widgets/views/submenu.php
@@ -12,7 +12,7 @@
image)) :?>

-

+
@@ -34,7 +34,7 @@
image)) :?>