diff --git a/backend/views/slider/_form.php b/backend/views/slider/_form.php index 4ea7c7e..c1bbcd5 100755 --- a/backend/views/slider/_form.php +++ b/backend/views/slider/_form.php @@ -13,6 +13,8 @@ use kartik\select2\Select2; + field($model, 'main_page')->checkbox() ?> + field($model, 'speed')->textInput() ?> field($model, 'duration')->textInput() ?> diff --git a/common/behaviors/DefaultVariantBehavior.php b/common/behaviors/DefaultVariantBehavior.php new file mode 100644 index 0000000..ce5be67 --- /dev/null +++ b/common/behaviors/DefaultVariantBehavior.php @@ -0,0 +1,78 @@ + 'addDefaultVariant', + ]; + } + + /** + * Creates new default product's variant and sets it's to stock + * marked as default and sets to it unit also marked as default + */ + public function addDefaultVariant() + { + /** + * @var Stock $stock + * @var ProductUnit $defaultUnit + */ + $defaultVariant = new ProductVariant(); + $defaultVariant->product_id = $this->owner->product_id; + + /** + * Gets default unit for variant + */ + $defaultUnit = ProductUnit::find() + ->where([ + 'is_default' => true, + ])->one(); + $defaultVariant->product_unit_id = $defaultUnit->product_unit_id; + $defaultVariant->stock = 1; + $defaultVariant->name = 'default'; + $defaultVariant->sku = 'default'; + $defaultVariant->save(); + + /** + * Gets default stock + */ + $stock = Stock::find() + ->where([ + 'is_default' => true, + ])->one(); + + /** + * Add a new stock record + */ + $defaultStock = new ProductStock(); + $defaultStock->product_id = $this->owner->product_id; + $defaultStock->stock_id = $stock->stock_id; + $defaultStock->quantity = $defaultVariant->stock; + $defaultStock->product_variant_id = $defaultVariant->product_variant_id; + $defaultStock->save(); + + } + +} \ No newline at end of file diff --git a/common/models/Slider.php b/common/models/Slider.php index e1d5520..9b36f0f 100755 --- a/common/models/Slider.php +++ b/common/models/Slider.php @@ -14,7 +14,7 @@ use Yii; * @property integer $status * @property integer $width * @property integer $height - * + * @property boolean $main_page * @property SliderImage[] $sliderImages */ class Slider extends \yii\db\ActiveRecord @@ -35,6 +35,7 @@ class Slider extends \yii\db\ActiveRecord return [ [['speed', 'duration', 'status', 'width', 'height'], 'integer'], [['title'], 'string', 'max' => 200], + [['main_page'], 'safe'], [['width', 'height'], 'required'], ['title', 'unique', 'targetClass' => '\common\models\Slider', 'message' => Yii::t('app','message',[ 'field' => 'Title' @@ -55,6 +56,7 @@ class Slider extends \yii\db\ActiveRecord 'status' => Yii::t('app', 'status'), 'width' => Yii::t('app', 'width'), 'height' => Yii::t('app', 'height'), + 'main_page' => 'Отображать на главной', ]; } diff --git a/common/modules/product/CatalogUrlManager.php b/common/modules/product/CatalogUrlManager.php index bc52f41..823168b 100755 --- a/common/modules/product/CatalogUrlManager.php +++ b/common/modules/product/CatalogUrlManager.php @@ -6,6 +6,7 @@ namespace common\modules\product; use common\modules\product\models\CategorySearch; use common\modules\product\models\ProductSearch; use yii\helpers\Url; +use yii\helpers\VarDumper; use yii\web\HttpException; use yii\web\UrlRuleInterface; @@ -59,19 +60,14 @@ class CatalogUrlManager implements UrlRuleInterface { } } } elseif ($paths[0] == 'product') { - if (!empty($paths[2])) { - throw new HttpException(404 ,'Page not found'); - } - $product = ProductSearch::findByAlias($paths[1]); - if (empty($product->product_id)) { - throw new HttpException(404 ,'Page not found'); - } + $route = 'catalog/product'; + $params = [ - 'product' => $product, + 'product' => $paths[1], + 'variant' => $paths[2] ]; } - return [$route, $params]; } /** @@ -118,7 +114,15 @@ class CatalogUrlManager implements UrlRuleInterface { $product_alias = is_object($params['product']) ? $params['product']->alias : strtolower($params['product']); unset($params['product']); } - $url = 'product/'. $product_alias; + if (!empty($params['variant'])) { + $variant_alias = is_object($params['variant']) ? $params['variant']->sku : strtolower($params['variant']); + unset($params['variant']); + } + + /** + * todo refactor this + */ + $url = 'product/'. $product_alias.'/'.$variant_alias; if (!empty($params) && ($query = http_build_query($params)) !== '') { $url .= '?' . $query; diff --git a/common/modules/product/controllers/VariantController.php b/common/modules/product/controllers/VariantController.php index 35acda2..7e35e64 100755 --- a/common/modules/product/controllers/VariantController.php +++ b/common/modules/product/controllers/VariantController.php @@ -231,7 +231,7 @@ class VariantController extends Controller } $ProductStocks = $sorted_array; $stock_names = array_keys($ProductStocks); - $stocks = Stock::find()->where(['name' => $stock_names])->indexBy('name')->one(); + $stocks = Stock::find()->where(['name' => $stock_names])->indexBy('name')->all(); foreach($ProductStocks as $name => $quantity) { $quantity = (int) $quantity; if(!array_key_exists($name, $stocks)) { diff --git a/common/modules/product/helpers/ProductHelper.php b/common/modules/product/helpers/ProductHelper.php index f12b200..25c83c5 100755 --- a/common/modules/product/helpers/ProductHelper.php +++ b/common/modules/product/helpers/ProductHelper.php @@ -9,7 +9,8 @@ use yii\base\Object; use Yii; use yii\db\ActiveQuery; - + use yii\helpers\VarDumper; + class ProductHelper extends Object { @@ -242,6 +243,7 @@ } break; default: + /** * @todo Refactor this */ diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php index 29971d2..36241ac 100755 --- a/common/modules/product/models/Category.php +++ b/common/modules/product/models/Category.php @@ -7,7 +7,10 @@ use common\components\artboxtree\ArtboxTreeHelper; use common\modules\rubrication\models\TaxGroup; use Yii; +use yii\db\ActiveQuery; use yii\db\Query; +use yii\helpers\VarDumper; + /** * This is the model class for table "category". * @@ -132,6 +135,18 @@ class Category extends \yii\db\ActiveRecord ->viaTable('product_category', ['category_id' => 'category_id']); } + /** + * Custom method for baccara + * + * @return ActiveQuery + */ + public function getBaccaraProducts() { + return Product::find()->joinWith('categories') + ->where([ + 'category.category_id' => $this->getChildrenByDepth(2)->column(), + ]); + } + /** * @return \yii\db\ActiveQuery @@ -204,6 +219,8 @@ class Category extends \yii\db\ActiveRecord } public function getActiveFilters() { + + $query1 = (new Query()) ->distinct() ->select([ @@ -215,7 +232,7 @@ class Category extends \yii\db\ActiveRecord ->innerJoin('product_variant', 'product_variant.product_variant_id = product_variant_option.product_variant_id') ->innerJoin('product', 'product.product_id = product_variant.product_id') ->innerJoin('product_category', 'product_category.product_id = product.product_id') - ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE]) + ->where(['product_category.category_id' => $this->getChildrenByDepth(2)->asArray()->column(), 'tax_group.is_filter' => TRUE]) ->andWhere(['!=', 'product_variant.stock', 0]); $query2 = (new Query()) @@ -229,7 +246,7 @@ class Category extends \yii\db\ActiveRecord ->innerJoin('product', 'product.product_id = product_option.product_id') ->innerJoin('product_category', 'product_category.product_id = product.product_id') ->innerJoin('product_variant', 'product_variant.product_id = product.product_id') - ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE]) + ->where(['product_category.category_id' => $this->getChildrenByDepth(2)->asArray()->column(), 'tax_group.is_filter' => TRUE]) ->andWhere(['!=', 'product_variant.stock', 0]); $query3 = (new Query()) ->select([ @@ -274,6 +291,12 @@ class Category extends \yii\db\ActiveRecord } + public function getChildrenByDepth($depth) + { + return $this->getAllChildren($depth)->where([ + 'depth' => $depth, + ])->asArray()->select(['category_id']); + } public function setTaxGroup($value) { diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index 8de286e..af1bed9 100755 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -12,6 +12,7 @@ use yii\db\ActiveQuery; use yii\db\ActiveRecord; use yii\helpers\ArrayHelper; + use common\behaviors\DefaultVariantBehavior; /** * This is the model class for table "{{%product}}". @@ -35,6 +36,7 @@ * @property string $description * @property TaxOption[] $options * @property ProductVariant[] $variants + * @property string $alias */ class Product extends \yii\db\ActiveRecord { @@ -55,6 +57,9 @@ 'class' => FilterBehavior::className(), ], [ + 'class' => DefaultVariantBehavior::className(), + ], + [ 'class' => Slug::className(), 'in_attribute' => 'name', 'out_attribute' => 'alias', diff --git a/common/modules/product/views/variant/create.php b/common/modules/product/views/variant/create.php index 1c3d2de..76de451 100755 --- a/common/modules/product/views/variant/create.php +++ b/common/modules/product/views/variant/create.php @@ -1,5 +1,6 @@ title = Yii::t('product', 'Create Product'); -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['/product/manage']]; +$this->params['breadcrumbs'][] = ['label' => $model->product->name, 'url' => ['view', 'id' => $model->product->product_id]]; +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Variants'), 'url' => Url::to(['/product/variant', 'product_id' => $model->product->product_id])]; +$this->params['breadcrumbs'][] = Yii::t('product', 'Create'); ?>
diff --git a/common/modules/product/views/variant/update.php b/common/modules/product/views/variant/update.php index a146f7d..4e7cb75 100755 --- a/common/modules/product/views/variant/update.php +++ b/common/modules/product/views/variant/update.php @@ -9,7 +9,7 @@ use yii\helpers\Url; $this->title = Yii::t('product', 'Update {modelClass}: ', [ 'modelClass' => 'Product', ]) . ' ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Products'), 'url' => ['/product/manage']]; $this->params['breadcrumbs'][] = ['label' => $model->product->name, 'url' => ['view', 'id' => $model->product->product_id]]; $this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Variants'), 'url' => Url::to(['/product/variant', 'product_id' => $model->product->product_id])]; $this->params['breadcrumbs'][] = Yii::t('product', 'Update'); diff --git a/console/migrations/m160920_152926_add_first_text_column_to_category_table.php b/console/migrations/m160920_152926_add_first_text_column_to_category_table.php old mode 100644 new mode 100755 index 38c784b..38c784b --- a/console/migrations/m160920_152926_add_first_text_column_to_category_table.php +++ b/console/migrations/m160920_152926_add_first_text_column_to_category_table.php diff --git a/console/migrations/m160920_153248_add_second_text_column_to_category_table.php b/console/migrations/m160920_153248_add_second_text_column_to_category_table.php old mode 100644 new mode 100755 index 5a8b807..5a8b807 --- a/console/migrations/m160920_153248_add_second_text_column_to_category_table.php +++ b/console/migrations/m160920_153248_add_second_text_column_to_category_table.php diff --git a/console/migrations/m160921_081919_add_new_collection_column_to_category_table.php b/console/migrations/m160921_081919_add_new_collection_column_to_category_table.php old mode 100644 new mode 100755 index 7701de2..7701de2 --- a/console/migrations/m160921_081919_add_new_collection_column_to_category_table.php +++ b/console/migrations/m160921_081919_add_new_collection_column_to_category_table.php diff --git a/console/migrations/m160921_093304_add_brand_image_column_to_category_table.php b/console/migrations/m160921_093304_add_brand_image_column_to_category_table.php old mode 100644 new mode 100755 index 2715ef3..2715ef3 --- a/console/migrations/m160921_093304_add_brand_image_column_to_category_table.php +++ b/console/migrations/m160921_093304_add_brand_image_column_to_category_table.php diff --git a/console/migrations/m160922_092444_add_date_end_column_to_articles_table.php b/console/migrations/m160922_092444_add_date_end_column_to_articles_table.php old mode 100644 new mode 100755 index 0c910ee..0c910ee --- a/console/migrations/m160922_092444_add_date_end_column_to_articles_table.php +++ b/console/migrations/m160922_092444_add_date_end_column_to_articles_table.php diff --git a/console/migrations/m160928_104309_add_is_default_column_to_stock_table.php b/console/migrations/m160928_104309_add_is_default_column_to_stock_table.php new file mode 100644 index 0000000..3d232e1 --- /dev/null +++ b/console/migrations/m160928_104309_add_is_default_column_to_stock_table.php @@ -0,0 +1,25 @@ +addColumn('stock', 'is_default', $this->boolean()->defaultValue(false)); + } + + /** + * @inheritdoc + */ + public function down() + { + return $this->dropColumn('stock', 'is_default'); + } +} diff --git a/console/migrations/m160928_141017_add_main_page_column_to_slider.php b/console/migrations/m160928_141017_add_main_page_column_to_slider.php new file mode 100644 index 0000000..b73f1e3 --- /dev/null +++ b/console/migrations/m160928_141017_add_main_page_column_to_slider.php @@ -0,0 +1,16 @@ +addColumn('slider', 'main_page', $this->boolean()->defaultValue(false)); + } + + public function down() + { + $this->dropColumn('slider', 'main_page'); + } +} diff --git a/frontend/config/main.php b/frontend/config/main.php index 2177d03..4afa489 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -44,6 +44,14 @@ return [ 'showScriptName' => false, // 'class'=>'common\modules\language\components\LanguageUrlManager', 'rules' => [ + [ + 'class' => '\common\modules\product\CatalogUrlManager', + 'route_map' => [ + 'catalog' => 'catalog/category', + 'product' => 'catalog/product', + + ] + ], '/' => 'site/index', '/'=>'/', ], diff --git a/frontend/controllers/CategoryController.php b/frontend/controllers/CategoryController.php index 9651a7c..669237a 100755 --- a/frontend/controllers/CategoryController.php +++ b/frontend/controllers/CategoryController.php @@ -7,6 +7,7 @@ use common\modules\product\models\Product; use yii\data\ActiveDataProvider; use yii\web\Controller; use yii\web\NotFoundHttpException; +use yii\helpers\VarDumper; /** * Category controller diff --git a/frontend/controllers/NewCollectionsController.php b/frontend/controllers/NewCollectionsController.php old mode 100644 new mode 100755 index d3d223e..d3d223e --- a/frontend/controllers/NewCollectionsController.php +++ b/frontend/controllers/NewCollectionsController.php diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index de14307..cb7ca91 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -3,6 +3,7 @@ namespace frontend\controllers; use common\models\Articles; use common\models\Blog; +use common\models\Slider; use common\modules\product\models\Category; use common\models\Page; use Yii; @@ -86,10 +87,15 @@ class SiteController extends Controller $blog_article = Blog::find()->one(); $event_article = Articles::find()->one(); + $slider = Slider::find() + ->where([ + 'main_page' => true, + ])->one(); return $this->render('index', [ 'newCollections' => $newCollections, 'blog_article' => $blog_article, 'event_article' => $event_article, + 'slider' => $slider, ]); } diff --git a/frontend/models/ProductFrontendSearch.php b/frontend/models/ProductFrontendSearch.php index 34ffaf6..5d3b160 100755 --- a/frontend/models/ProductFrontendSearch.php +++ b/frontend/models/ProductFrontendSearch.php @@ -97,7 +97,7 @@ class ProductFrontendSearch extends Product { if (!empty($category)) { /** @var ActiveQuery $query */ // $query = $category->getRelations('product_categories'); - $query = $category->getProducts(); + $query = $category->getBaccaraProducts(); } else { $query = Product::find(); } diff --git a/frontend/views/article/_article_item.php b/frontend/views/article/_article_item.php old mode 100644 new mode 100755 index 3e887eb..3e887eb --- a/frontend/views/article/_article_item.php +++ b/frontend/views/article/_article_item.php diff --git a/frontend/views/article/index.php b/frontend/views/article/index.php old mode 100644 new mode 100755 index cd9aebe..cd9aebe --- a/frontend/views/article/index.php +++ b/frontend/views/article/index.php diff --git a/frontend/views/article/view.php b/frontend/views/article/view.php old mode 100644 new mode 100755 index 9b5b5ec..9b5b5ec --- a/frontend/views/article/view.php +++ b/frontend/views/article/view.php diff --git a/frontend/views/blog/_blog_item.php b/frontend/views/blog/_blog_item.php old mode 100644 new mode 100755 index 510d29e..510d29e --- a/frontend/views/blog/_blog_item.php +++ b/frontend/views/blog/_blog_item.php diff --git a/frontend/views/blog/index.php b/frontend/views/blog/index.php old mode 100644 new mode 100755 index 639c962..639c962 --- a/frontend/views/blog/index.php +++ b/frontend/views/blog/index.php diff --git a/frontend/views/blog/view.php b/frontend/views/blog/view.php old mode 100644 new mode 100755 index 1c35c8d..1c35c8d --- a/frontend/views/blog/view.php +++ b/frontend/views/blog/view.php diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php index a23e024..272eed5 100755 --- a/frontend/views/catalog/products.php +++ b/frontend/views/catalog/products.php @@ -15,11 +15,6 @@ $this->title = $category->first_text; $this->params['breadcrumbs'][] = $this->title; ?> -$category, - 'groups'=> $groups, - 'filter'=> $filter, -])?>
@@ -87,118 +82,12 @@ $this->params['breadcrumbs'][] = $this->title;
Фильтры
-
- Дизайн -
-
- - -
- - - - - - - - - - -
-
-
-
-
- Узор / имитация -
-
- - -
- - - - - - - - - -
-
-
-
-
- Материал -
-
- - -
- - - - - -
-
-
-
-
- Размер -
-
- - -
- - - - - - - - - -
-
-
-
-
- Страна -
-
- - -
- - - - - - - - -
-
-
-
-
- Цена -
-
- - -
- - - - - -
-
-
-
+ + $category, + 'groups'=> $groups, + 'filter'=> $filter, + ])?>
diff --git a/frontend/views/catalog/view.php b/frontend/views/catalog/view.php index c87ead9..fe69f33 100755 --- a/frontend/views/catalog/view.php +++ b/frontend/views/catalog/view.php @@ -13,7 +13,7 @@ use yii\helpers\Url; use yii\web\View; use yii\widgets\Pjax; -$this->title = $product->name . ' - ' . $variant->sku; +$this->title = $product->name; $this->params['breadcrumbs'][] = [ 'label' => $product->category->parent->parent->name, 'url' => Url::to([ @@ -70,9 +70,9 @@ $this->params['breadcrumbs'][] = $this->title;
getImageUrl(), 'product_variant_main'), [ - 'product/view', - 'product_id' => $product->product_id, - 'variant_id' => $oneVariant->product_variant_id, + 'catalog/product', + 'product' => $product->alias, + 'variant' => $oneVariant->sku, ]); ?>
diff --git a/frontend/views/category/_brand_item.php b/frontend/views/category/_brand_item.php old mode 100644 new mode 100755 index 088c148..088c148 --- a/frontend/views/category/_brand_item.php +++ b/frontend/views/category/_brand_item.php diff --git a/frontend/views/category/brand.php b/frontend/views/category/brand.php old mode 100644 new mode 100755 index e305880..e305880 --- a/frontend/views/category/brand.php +++ b/frontend/views/category/brand.php diff --git a/frontend/views/category/collection.php b/frontend/views/category/collection.php old mode 100644 new mode 100755 index e486ae0..fea051d --- a/frontend/views/category/collection.php +++ b/frontend/views/category/collection.php @@ -49,9 +49,9 @@ $this->params['breadcrumbs'][] = $this->title; foreach ($products_col as $product) { ?>
name; ?>variant->sku; diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 20a1665..ace10d0 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -73,10 +73,7 @@ $brands = Category::find() 'product/index', 'id' => 19, ]); ?>">Обои -
  • Текстиль
  • +
  • Текстиль
  • Карнизы
  • Напольные покрытия
  • Contract Concept
  • diff --git a/frontend/views/new-collections/_new_collections_item.php b/frontend/views/new-collections/_new_collections_item.php old mode 100644 new mode 100755 index f0097d4..f0097d4 --- a/frontend/views/new-collections/_new_collections_item.php +++ b/frontend/views/new-collections/_new_collections_item.php diff --git a/frontend/views/new-collections/index.php b/frontend/views/new-collections/index.php old mode 100644 new mode 100755 index 8d142fc..8d142fc --- a/frontend/views/new-collections/index.php +++ b/frontend/views/new-collections/index.php diff --git a/frontend/views/product/_product_list.php b/frontend/views/product/_product_list.php old mode 100644 new mode 100755 index 61c1f72..61c1f72 --- a/frontend/views/product/_product_list.php +++ b/frontend/views/product/_product_list.php diff --git a/frontend/views/product/index.php b/frontend/views/product/index.php old mode 100644 new mode 100755 index 2e0bad3..2e0bad3 --- a/frontend/views/product/index.php +++ b/frontend/views/product/index.php diff --git a/frontend/views/product/view.php b/frontend/views/product/view.php old mode 100644 new mode 100755 index c87ead9..c87ead9 --- a/frontend/views/product/view.php +++ b/frontend/views/product/view.php diff --git a/frontend/views/site/_collections_item.php b/frontend/views/site/_collections_item.php old mode 100644 new mode 100755 index 99a8705..99a8705 --- a/frontend/views/site/_collections_item.php +++ b/frontend/views/site/_collections_item.php diff --git a/frontend/views/site/index.php b/frontend/views/site/index.php index f8486fc..32220b3 100755 --- a/frontend/views/site/index.php +++ b/frontend/views/site/index.php @@ -5,15 +5,18 @@ * @var ArrayDataProvider $newCollections * @var Blog $blog_article * @var Articles $event_article + * @var Slider $slider */ use common\components\artboximage\ArtboxImageHelper; use common\models\Articles; use common\models\Blog; +use common\models\Slider; use yii\data\ArrayDataProvider; use yii\web\View; use yii\widgets\ListView; use yii\helpers\Url; +use frontend\widgets\SliderWidget; $this->title = "Главная"; ?> @@ -21,33 +24,11 @@ $this->title = "Главная";
    @@ -77,7 +58,6 @@ $this->title = "Главная"; 'id' => $blog_article->id, ])?>" class="blog_link"> getImageUrl(), 'main_blog_one'); ?> -
    title; ?>
    diff --git a/frontend/views/site/page.php b/frontend/views/site/page.php old mode 100644 new mode 100755 index 54fa21a..54fa21a --- a/frontend/views/site/page.php +++ b/frontend/views/site/page.php diff --git a/frontend/web/css/style.css b/frontend/web/css/style.css old mode 100644 new mode 100755 index 9ab06d6..fb6f5e6 --- a/frontend/web/css/style.css +++ b/frontend/web/css/style.css @@ -1028,18 +1028,18 @@ footer .socbuts a:hover{ } .spoiler .control-label{display: none;} .spoiler input[type=checkbox], input[type=radio] { - margin: 1px 0 0; - opacity: 0; - margin-right: 7px; + /*margin: 1px 0 0;*/ + /*opacity: 0;*/ + /*margin-right: 7px;*/ } .spoiler label { - display: inline-block; + display: inline; max-width: 100%; font-weight: 700; width: 100%; letter-spacing: 0.4px; margin-bottom: 0px; - background: url('../images/knopka.png'); + /*background: url('../images/knopka.png');*/ background-position: left 5px; background-repeat: no-repeat; } diff --git a/frontend/web/images/act1.png b/frontend/web/images/act1.png old mode 100644 new mode 100755 index 0d37fea..0d37fea Binary files a/frontend/web/images/act1.png and b/frontend/web/images/act1.png differ diff --git a/frontend/web/images/act2.png b/frontend/web/images/act2.png old mode 100644 new mode 100755 index 6dd893f..6dd893f Binary files a/frontend/web/images/act2.png and b/frontend/web/images/act2.png differ diff --git a/frontend/web/images/act3.png b/frontend/web/images/act3.png old mode 100644 new mode 100755 index 286e029..286e029 Binary files a/frontend/web/images/act3.png and b/frontend/web/images/act3.png differ diff --git a/frontend/web/images/act4.png b/frontend/web/images/act4.png old mode 100644 new mode 100755 index 3279b59..3279b59 Binary files a/frontend/web/images/act4.png and b/frontend/web/images/act4.png differ diff --git a/frontend/web/images/armani_head1.jpg b/frontend/web/images/armani_head1.jpg old mode 100644 new mode 100755 index 32ed8af..32ed8af Binary files a/frontend/web/images/armani_head1.jpg and b/frontend/web/images/armani_head1.jpg differ diff --git a/frontend/web/images/armani_logo.jpg b/frontend/web/images/armani_logo.jpg old mode 100644 new mode 100755 index 4bc7495..4bc7495 Binary files a/frontend/web/images/armani_logo.jpg and b/frontend/web/images/armani_logo.jpg differ diff --git a/frontend/web/images/fb1.jpg b/frontend/web/images/fb1.jpg old mode 100644 new mode 100755 index b94973f..b94973f Binary files a/frontend/web/images/fb1.jpg and b/frontend/web/images/fb1.jpg differ diff --git a/frontend/web/images/fb2.jpg b/frontend/web/images/fb2.jpg old mode 100644 new mode 100755 index 7416430..7416430 Binary files a/frontend/web/images/fb2.jpg and b/frontend/web/images/fb2.jpg differ diff --git a/frontend/web/images/fb3.jpg b/frontend/web/images/fb3.jpg old mode 100644 new mode 100755 index 2fc4d2c..2fc4d2c Binary files a/frontend/web/images/fb3.jpg and b/frontend/web/images/fb3.jpg differ diff --git a/frontend/web/images/fb4.jpg b/frontend/web/images/fb4.jpg old mode 100644 new mode 100755 index a139bd2..a139bd2 Binary files a/frontend/web/images/fb4.jpg and b/frontend/web/images/fb4.jpg differ diff --git a/frontend/web/images/gpl1.jpg b/frontend/web/images/gpl1.jpg old mode 100644 new mode 100755 index 649afae..649afae Binary files a/frontend/web/images/gpl1.jpg and b/frontend/web/images/gpl1.jpg differ diff --git a/frontend/web/images/gpl2.jpg b/frontend/web/images/gpl2.jpg old mode 100644 new mode 100755 index 08f5851..08f5851 Binary files a/frontend/web/images/gpl2.jpg and b/frontend/web/images/gpl2.jpg differ diff --git a/frontend/web/images/gpl3.jpg b/frontend/web/images/gpl3.jpg old mode 100644 new mode 100755 index 4ad70a5..4ad70a5 Binary files a/frontend/web/images/gpl3.jpg and b/frontend/web/images/gpl3.jpg differ diff --git a/frontend/web/images/gpl4.jpg b/frontend/web/images/gpl4.jpg old mode 100644 new mode 100755 index a60d70f..a60d70f Binary files a/frontend/web/images/gpl4.jpg and b/frontend/web/images/gpl4.jpg differ diff --git a/frontend/web/images/line10.png b/frontend/web/images/line10.png old mode 100644 new mode 100755 index 94d0c11..94d0c11 Binary files a/frontend/web/images/line10.png and b/frontend/web/images/line10.png differ diff --git a/frontend/web/images/line9.png b/frontend/web/images/line9.png old mode 100644 new mode 100755 index 5962024..5962024 Binary files a/frontend/web/images/line9.png and b/frontend/web/images/line9.png differ diff --git a/frontend/web/images/marburg_head.jpg b/frontend/web/images/marburg_head.jpg old mode 100644 new mode 100755 index 24259a6..24259a6 Binary files a/frontend/web/images/marburg_head.jpg and b/frontend/web/images/marburg_head.jpg differ diff --git a/frontend/web/images/marburg_logo.jpg b/frontend/web/images/marburg_logo.jpg old mode 100644 new mode 100755 index 1ce4676..1ce4676 Binary files a/frontend/web/images/marburg_logo.jpg and b/frontend/web/images/marburg_logo.jpg differ diff --git a/frontend/web/images/moz1.jpg b/frontend/web/images/moz1.jpg old mode 100644 new mode 100755 index 2a46a2d..2a46a2d Binary files a/frontend/web/images/moz1.jpg and b/frontend/web/images/moz1.jpg differ diff --git a/frontend/web/images/moz2.jpg b/frontend/web/images/moz2.jpg old mode 100644 new mode 100755 index 6fb2589..6fb2589 Binary files a/frontend/web/images/moz2.jpg and b/frontend/web/images/moz2.jpg differ diff --git a/frontend/web/images/moz21.jpg b/frontend/web/images/moz21.jpg old mode 100644 new mode 100755 index 9343a4f..9343a4f Binary files a/frontend/web/images/moz21.jpg and b/frontend/web/images/moz21.jpg differ diff --git a/frontend/web/images/moz22.jpg b/frontend/web/images/moz22.jpg old mode 100644 new mode 100755 index e124b74..e124b74 Binary files a/frontend/web/images/moz22.jpg and b/frontend/web/images/moz22.jpg differ diff --git a/frontend/web/images/moz23.jpg b/frontend/web/images/moz23.jpg old mode 100644 new mode 100755 index fe2d2b4..fe2d2b4 Binary files a/frontend/web/images/moz23.jpg and b/frontend/web/images/moz23.jpg differ diff --git a/frontend/web/images/moz24.jpg b/frontend/web/images/moz24.jpg old mode 100644 new mode 100755 index 1ef0fb4..1ef0fb4 Binary files a/frontend/web/images/moz24.jpg and b/frontend/web/images/moz24.jpg differ diff --git a/frontend/web/images/moz25.jpg b/frontend/web/images/moz25.jpg old mode 100644 new mode 100755 index 0b430bd..0b430bd Binary files a/frontend/web/images/moz25.jpg and b/frontend/web/images/moz25.jpg differ diff --git a/frontend/web/images/moz26.jpg b/frontend/web/images/moz26.jpg old mode 100644 new mode 100755 index 5552776..5552776 Binary files a/frontend/web/images/moz26.jpg and b/frontend/web/images/moz26.jpg differ diff --git a/frontend/web/images/moz27.jpg b/frontend/web/images/moz27.jpg old mode 100644 new mode 100755 index 7f321fd..7f321fd Binary files a/frontend/web/images/moz27.jpg and b/frontend/web/images/moz27.jpg differ diff --git a/frontend/web/images/moz28.jpg b/frontend/web/images/moz28.jpg old mode 100644 new mode 100755 index 0921bc4..0921bc4 Binary files a/frontend/web/images/moz28.jpg and b/frontend/web/images/moz28.jpg differ diff --git a/frontend/web/images/moz29.jpg b/frontend/web/images/moz29.jpg old mode 100644 new mode 100755 index afefdf4..afefdf4 Binary files a/frontend/web/images/moz29.jpg and b/frontend/web/images/moz29.jpg differ diff --git a/frontend/web/images/moz3.jpg b/frontend/web/images/moz3.jpg old mode 100644 new mode 100755 index bebc30e..bebc30e Binary files a/frontend/web/images/moz3.jpg and b/frontend/web/images/moz3.jpg differ diff --git a/frontend/web/images/moz30.jpg b/frontend/web/images/moz30.jpg old mode 100644 new mode 100755 index df85ca6..df85ca6 Binary files a/frontend/web/images/moz30.jpg and b/frontend/web/images/moz30.jpg differ diff --git a/frontend/web/images/moz4.jpg b/frontend/web/images/moz4.jpg old mode 100644 new mode 100755 index eef1c7f..eef1c7f Binary files a/frontend/web/images/moz4.jpg and b/frontend/web/images/moz4.jpg differ diff --git a/frontend/web/images/moz5.jpg b/frontend/web/images/moz5.jpg old mode 100644 new mode 100755 index 0e9ce82..0e9ce82 Binary files a/frontend/web/images/moz5.jpg and b/frontend/web/images/moz5.jpg differ diff --git a/frontend/web/images/moz6.jpg b/frontend/web/images/moz6.jpg old mode 100644 new mode 100755 index a488f74..a488f74 Binary files a/frontend/web/images/moz6.jpg and b/frontend/web/images/moz6.jpg differ diff --git a/frontend/web/images/moz7.jpg b/frontend/web/images/moz7.jpg old mode 100644 new mode 100755 index 861e26f..861e26f Binary files a/frontend/web/images/moz7.jpg and b/frontend/web/images/moz7.jpg differ diff --git a/frontend/web/images/pic301.jpg b/frontend/web/images/pic301.jpg old mode 100644 new mode 100755 index c0b2ed8..c0b2ed8 Binary files a/frontend/web/images/pic301.jpg and b/frontend/web/images/pic301.jpg differ diff --git a/frontend/web/images/pic302.jpg b/frontend/web/images/pic302.jpg old mode 100644 new mode 100755 index f2a4048..f2a4048 Binary files a/frontend/web/images/pic302.jpg and b/frontend/web/images/pic302.jpg differ diff --git a/frontend/web/images/pic303.jpg b/frontend/web/images/pic303.jpg old mode 100644 new mode 100755 index 62e5dbe..62e5dbe Binary files a/frontend/web/images/pic303.jpg and b/frontend/web/images/pic303.jpg differ diff --git a/frontend/web/images/pic311.jpg b/frontend/web/images/pic311.jpg old mode 100644 new mode 100755 index 57c284d..57c284d Binary files a/frontend/web/images/pic311.jpg and b/frontend/web/images/pic311.jpg differ diff --git a/frontend/web/images/pic312.jpg b/frontend/web/images/pic312.jpg old mode 100644 new mode 100755 index 50ff18a..50ff18a Binary files a/frontend/web/images/pic312.jpg and b/frontend/web/images/pic312.jpg differ diff --git a/frontend/web/images/pic313.jpg b/frontend/web/images/pic313.jpg old mode 100644 new mode 100755 index 263d0fe..263d0fe Binary files a/frontend/web/images/pic313.jpg and b/frontend/web/images/pic313.jpg differ diff --git a/frontend/web/images/pic314.jpg b/frontend/web/images/pic314.jpg old mode 100644 new mode 100755 index 0f7f1d4..0f7f1d4 Binary files a/frontend/web/images/pic314.jpg and b/frontend/web/images/pic314.jpg differ diff --git a/frontend/web/images/pic315.jpg b/frontend/web/images/pic315.jpg old mode 100644 new mode 100755 index 870b42b..870b42b Binary files a/frontend/web/images/pic315.jpg and b/frontend/web/images/pic315.jpg differ diff --git a/frontend/web/images/pic316.jpg b/frontend/web/images/pic316.jpg old mode 100644 new mode 100755 index f0c9869..f0c9869 Binary files a/frontend/web/images/pic316.jpg and b/frontend/web/images/pic316.jpg differ diff --git a/frontend/web/images/pic317.jpg b/frontend/web/images/pic317.jpg old mode 100644 new mode 100755 index 9089fb8..9089fb8 Binary files a/frontend/web/images/pic317.jpg and b/frontend/web/images/pic317.jpg differ diff --git a/frontend/web/images/pic321.jpg b/frontend/web/images/pic321.jpg old mode 100644 new mode 100755 index 7cb492a..7cb492a Binary files a/frontend/web/images/pic321.jpg and b/frontend/web/images/pic321.jpg differ diff --git a/frontend/web/images/pic322.jpg b/frontend/web/images/pic322.jpg old mode 100644 new mode 100755 index 1637d46..1637d46 Binary files a/frontend/web/images/pic322.jpg and b/frontend/web/images/pic322.jpg differ diff --git a/frontend/web/images/pic323.jpg b/frontend/web/images/pic323.jpg old mode 100644 new mode 100755 index 0870cf1..0870cf1 Binary files a/frontend/web/images/pic323.jpg and b/frontend/web/images/pic323.jpg differ diff --git a/frontend/web/images/pic324.jpg b/frontend/web/images/pic324.jpg old mode 100644 new mode 100755 index de1ec28..de1ec28 Binary files a/frontend/web/images/pic324.jpg and b/frontend/web/images/pic324.jpg differ diff --git a/frontend/web/images/pic331.jpg b/frontend/web/images/pic331.jpg old mode 100644 new mode 100755 index 4458843..4458843 Binary files a/frontend/web/images/pic331.jpg and b/frontend/web/images/pic331.jpg differ diff --git a/frontend/web/images/pic332.jpg b/frontend/web/images/pic332.jpg old mode 100644 new mode 100755 index 684e0e1..684e0e1 Binary files a/frontend/web/images/pic332.jpg and b/frontend/web/images/pic332.jpg differ diff --git a/frontend/web/images/pic333.jpg b/frontend/web/images/pic333.jpg old mode 100644 new mode 100755 index d7576a1..d7576a1 Binary files a/frontend/web/images/pic333.jpg and b/frontend/web/images/pic333.jpg differ diff --git a/frontend/web/images/pic334.jpg b/frontend/web/images/pic334.jpg old mode 100644 new mode 100755 index ee91802..ee91802 Binary files a/frontend/web/images/pic334.jpg and b/frontend/web/images/pic334.jpg differ diff --git a/frontend/web/images/pic341.jpg b/frontend/web/images/pic341.jpg old mode 100644 new mode 100755 index 0e37e89..0e37e89 Binary files a/frontend/web/images/pic341.jpg and b/frontend/web/images/pic341.jpg differ diff --git a/frontend/web/images/pic342.jpg b/frontend/web/images/pic342.jpg old mode 100644 new mode 100755 index 1d0dd37..1d0dd37 Binary files a/frontend/web/images/pic342.jpg and b/frontend/web/images/pic342.jpg differ diff --git a/frontend/web/images/pic343.jpg b/frontend/web/images/pic343.jpg old mode 100644 new mode 100755 index 651c380..651c380 Binary files a/frontend/web/images/pic343.jpg and b/frontend/web/images/pic343.jpg differ diff --git a/frontend/web/images/pic344.jpg b/frontend/web/images/pic344.jpg old mode 100644 new mode 100755 index 0e4c820..0e4c820 Binary files a/frontend/web/images/pic344.jpg and b/frontend/web/images/pic344.jpg differ diff --git a/frontend/web/images/pic3_01.jpg b/frontend/web/images/pic3_01.jpg old mode 100644 new mode 100755 index ecc46a6..ecc46a6 Binary files a/frontend/web/images/pic3_01.jpg and b/frontend/web/images/pic3_01.jpg differ diff --git a/frontend/web/images/pic401.jpg b/frontend/web/images/pic401.jpg old mode 100644 new mode 100755 index a658942..a658942 Binary files a/frontend/web/images/pic401.jpg and b/frontend/web/images/pic401.jpg differ diff --git a/frontend/web/images/pic402.jpg b/frontend/web/images/pic402.jpg old mode 100644 new mode 100755 index 4bac0f7..4bac0f7 Binary files a/frontend/web/images/pic402.jpg and b/frontend/web/images/pic402.jpg differ diff --git a/frontend/web/images/pic410.jpg b/frontend/web/images/pic410.jpg old mode 100644 new mode 100755 index 6339706..6339706 Binary files a/frontend/web/images/pic410.jpg and b/frontend/web/images/pic410.jpg differ diff --git a/frontend/web/images/plus.png b/frontend/web/images/plus.png old mode 100644 new mode 100755 index 5cae6e8..5cae6e8 Binary files a/frontend/web/images/plus.png and b/frontend/web/images/plus.png differ diff --git a/frontend/web/images/ptst1.jpg b/frontend/web/images/ptst1.jpg old mode 100644 new mode 100755 index 94bd461..94bd461 Binary files a/frontend/web/images/ptst1.jpg and b/frontend/web/images/ptst1.jpg differ diff --git a/frontend/web/images/ptst2.jpg b/frontend/web/images/ptst2.jpg old mode 100644 new mode 100755 index 9be4427..9be4427 Binary files a/frontend/web/images/ptst2.jpg and b/frontend/web/images/ptst2.jpg differ diff --git a/frontend/web/images/ptst3.jpg b/frontend/web/images/ptst3.jpg old mode 100644 new mode 100755 index 35ddad3..35ddad3 Binary files a/frontend/web/images/ptst3.jpg and b/frontend/web/images/ptst3.jpg differ diff --git a/frontend/web/images/ptst4.jpg b/frontend/web/images/ptst4.jpg old mode 100644 new mode 100755 index 0b5062b..0b5062b Binary files a/frontend/web/images/ptst4.jpg and b/frontend/web/images/ptst4.jpg differ diff --git a/frontend/web/images/vk1.jpg b/frontend/web/images/vk1.jpg old mode 100644 new mode 100755 index 2bfe097..2bfe097 Binary files a/frontend/web/images/vk1.jpg and b/frontend/web/images/vk1.jpg differ diff --git a/frontend/web/images/vk2.jpg b/frontend/web/images/vk2.jpg old mode 100644 new mode 100755 index d75d391..d75d391 Binary files a/frontend/web/images/vk2.jpg and b/frontend/web/images/vk2.jpg differ diff --git a/frontend/web/images/vk3.jpg b/frontend/web/images/vk3.jpg old mode 100644 new mode 100755 index ceb426d..ceb426d Binary files a/frontend/web/images/vk3.jpg and b/frontend/web/images/vk3.jpg differ diff --git a/frontend/web/images/vk4.jpg b/frontend/web/images/vk4.jpg old mode 100644 new mode 100755 index cdc4b29..cdc4b29 Binary files a/frontend/web/images/vk4.jpg and b/frontend/web/images/vk4.jpg differ diff --git a/frontend/widgets/SliderWidget.php b/frontend/widgets/SliderWidget.php new file mode 100644 index 0000000..87dd563 --- /dev/null +++ b/frontend/widgets/SliderWidget.php @@ -0,0 +1,39 @@ +slider_id); + $images = $slider->getSliderImage()->all(); + return $this->render('_slider_view',[ + 'images' => $images, + ]); + + } + +} +?> diff --git a/frontend/widgets/views/_filter_view.php b/frontend/widgets/views/_filter_view.php index 42932d4..6f5d3c5 100755 --- a/frontend/widgets/views/_filter_view.php +++ b/frontend/widgets/views/_filter_view.php @@ -4,76 +4,39 @@ use yii\helpers\Url; use yii\web\View; ?> - -
    - -
    - -
    - - -
    - -

    - -
    -
    - -
    - - -
    - - $group) :?> -
    - -
    - - - - -
    - - -
    - - + $group) {?> + +
    + +
    +
    + + +
    + $category, 'filters' => FilterHelper::getFilterForOption($filter, $option['group_alias'], $option['option_alias'], $checked)]); + ?> +
    + /> +
    - +
    - - - - -
    -
    -
    + registerJs($js, - View::POS_LOAD -); ?> +//$this->registerJs($js, +// View::POS_LOAD +//); +?> diff --git a/frontend/widgets/views/_slider_view.php b/frontend/widgets/views/_slider_view.php new file mode 100644 index 0000000..d983e88 --- /dev/null +++ b/frontend/widgets/views/_slider_view.php @@ -0,0 +1,37 @@ + + + diff --git a/source/ProductStock.php b/source/ProductStock.php new file mode 100644 index 0000000..f6db347 --- /dev/null +++ b/source/ProductStock.php @@ -0,0 +1,93 @@ + true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], + [['product_variant_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductVariant::className(), 'targetAttribute' => ['product_variant_id' => 'product_variant_id']], + [['stock_id'], 'exist', 'skipOnError' => true, 'targetClass' => Stock::className(), 'targetAttribute' => ['stock_id' => 'stock_id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'product_id' => 'Product ID', + 'stock_id' => 'Stock ID', + 'quantity' => 'Количество', + 'product_variant_id' => 'Product Variant ID', + 'name' => "Название" + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProduct() + { + return $this->hasOne(Product::className(), ['product_id' => 'product_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProductVariant() + { + return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'product_variant_id']); + } + + + public function getName(){ + return (!empty($this->stock))? $this->stock->name : ''; + } + + public function setName($value){ + $this->name = $value; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getStock() + { + return $this->hasOne(Stock::className(), ['stock_id' => 'stock_id']); + } + + + public static function primaryKey() + { + return ["stock_id","product_variant_id"]; + } +} diff --git a/source/Stock.php b/source/Stock.php new file mode 100644 index 0000000..a4a80f1 --- /dev/null +++ b/source/Stock.php @@ -0,0 +1,46 @@ + 150], + [['name'], 'required'], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'stock_id' => Yii::t('product', 'Stock ID'), + 'name' => Yii::t('product', 'Name'), + ]; + } +} diff --git a/source/VariantController.php b/source/VariantController.php new file mode 100644 index 0000000..35acda2 --- /dev/null +++ b/source/VariantController.php @@ -0,0 +1,321 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all ProductVariant models. + * @return mixed + */ + public function actionIndex($product_id) + { + $searchModel = new ProductVariantListSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams,$product_id); + + if ( ($product = Yii::$app->request->get('product_id')) !== null) { + $product = Product::findOne($product); + } + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'product' => $product, + 'product_id' => $product_id, + ]); + } + + /** + * Displays a single ProductVariant model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new ProductVariant model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate($product_id) + { + $model = new ProductVariant(); + $model->product_id = $product_id; + if ($model->load(Yii::$app->request->post())) { + + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); + $model->validate(); + + if ($model->save()) { + + if ( ($image = UploadedFile::getInstance($model, 'image')) ) { + $imageModel = ProductImage::find()->where(['product_variant_id' => $model->product_variant_id])->one(); + + if($imageModel instanceof ProductImage) { + $imageModel->product_id = $model->product_id; + $imageModel->product_variant_id = $model->product_variant_id; + $imageModel->image = $image->name; + $imageModel->save(); + } else { + $imageModel = new ProductImage(); + $imageModel->product_id = $model->product_id; + $imageModel->product_variant_id = $model->product_variant_id; + $imageModel->image = $image->name; + $imageModel->save(); + } + + + $imgDir = Yii::getAlias('@storage/products/'); + + if(!is_dir($imgDir)) { + mkdir($imgDir, 0755, true); + } + + $image->saveAs(Yii::getAlias('@storage/products/' . $image->name)); + } + + $ProductStocks = Yii::$app->request->post('ProductStock'); + + $total_quantity = 0; + + if(!empty($ProductStocks) && is_array($ProductStocks)) { + $model->unlinkAll('stocks', true); + $sorted_array = []; + foreach ($ProductStocks as $subArray) { + if(!empty($subArray['name']) && !empty($subArray['quantity'])) { + if(!empty($sorted_array[$subArray['name']])) { + $sorted_array[$subArray['name']] += $subArray['quantity']; + } else { + $sorted_array[$subArray['name']] = $subArray['quantity']; + } + } + } + $ProductStocks = $sorted_array; + $stock_names = array_keys($ProductStocks); + $stocks = Stock::find()->where(['name' => $stock_names])->indexBy('name')->one(); + foreach($ProductStocks as $name => $quantity) { + $quantity = (int) $quantity; + if(!array_key_exists($name, $stocks)) { + $stock = new Stock([ + 'name' => $name + ]); + if(!$stock->save()) { + continue; + } + } else { + $stock = $stocks[$name]; + } + $psModel = new ProductStock([ + 'product_id' => $model->product_id, + 'product_variant_id' => $model->product_variant_id, + 'stock_id' => $stock->stock_id, + 'quantity' => $quantity, + ]); + if($psModel->save()) { + $total_quantity += $quantity; + } + } + } else { + $model->unlinkAll('stocks', true); + } + + $model->stock = $total_quantity; + $model->save(); + + return $this->redirect(['index', 'product_id' => $product_id]); + } + } else { + $groups = $model->getTaxGroupsByLevel(1); + + return $this->render('create', [ + 'model' => $model, + 'groups' => $groups, + 'stocks' => [new ProductStock()], + ]); + } + } + + /** + * Updates an existing ProductVariant model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $product_id + * @param integer $id + * @return mixed + */ + public function actionUpdate($product_id, $id) + { + $model = $this->findModel($id); + if ($model->load(Yii::$app->request->post())) { + + if ($model->save()) { + + + if ( ($image = UploadedFile::getInstance($model, 'image')) ) { + $imageModel = ProductImage::find()->where(['product_variant_id' => $model->product_variant_id])->one(); + + if($imageModel instanceof ProductImage) { + $imageModel->product_id = $model->product_id; + $imageModel->product_variant_id = $model->product_variant_id; + $imageModel->image = $image->name; + $imageModel->save(); + } else { + $imageModel = new ProductImage(); + $imageModel->product_id = $model->product_id; + $imageModel->product_variant_id = $model->product_variant_id; + $imageModel->image = $image->name; + $imageModel->save(); + } + + + $imgDir = Yii::getAlias('@storage/products/'); + + if(!is_dir($imgDir)) { + mkdir($imgDir, 0755, true); + } + + $image->saveAs(Yii::getAlias('@storage/products/' . $image->name)); + } + + + $ProductStocks = Yii::$app->request->post('ProductStock'); + + $total_quantity = 0; + + if(!empty($ProductStocks) && is_array($ProductStocks)) { + $model->unlinkAll('stocks', true); + $sorted_array = []; + foreach ($ProductStocks as $subArray) { + if(!empty($subArray['name']) && !empty($subArray['quantity'])) { + if(!empty($sorted_array[$subArray['name']])) { + $sorted_array[$subArray['name']] += $subArray['quantity']; + } else { + $sorted_array[$subArray['name']] = $subArray['quantity']; + } + } + } + $ProductStocks = $sorted_array; + $stock_names = array_keys($ProductStocks); + $stocks = Stock::find()->where(['name' => $stock_names])->indexBy('name')->one(); + foreach($ProductStocks as $name => $quantity) { + $quantity = (int) $quantity; + if(!array_key_exists($name, $stocks)) { + $stock = new Stock([ + 'name' => $name + ]); + if(!$stock->save()) { + continue; + } + } else { + $stock = $stocks[$name]; + } + $psModel = new ProductStock([ + 'product_id' => $model->product_id, + 'product_variant_id' => $model->product_variant_id, + 'stock_id' => $stock->stock_id, + 'quantity' => $quantity, + ]); + if($psModel->save()) { + $total_quantity += $quantity; + } + } + } else { + $model->unlinkAll('stocks', true); + } + + $model->stock = $total_quantity; + $model->save(); + } + return $this->redirect(['index', 'product_id'=>$product_id]); + + + + + } else { + $groups = $model->getTaxGroupsByLevel(1); + + return $this->render('update', [ + 'model' => $model, + 'groups' => $groups, + 'stocks' => (!empty($model->variantStocks)) ? $model->variantStocks : [new ProductStock], + ]); + } + } + + /** + * Deletes an existing ProductVariant model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($product_id, $id) + { + + $this->findModel($id)->delete(); + + return $this->redirect(['index', 'product_id'=>$product_id]); + } + + public function actionDelimg($id) + { + $image = ProductImage::findOne($id); + + if ($image) { + $image->delete(); + } + + print '1'; + exit; + } + + /** + * Finds the ProductVariant model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return ProductVariant the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = ProductVariant::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/source/blog.html b/source/blog.html old mode 100644 new mode 100755 index 3aa8972..3aa8972 --- a/source/blog.html +++ b/source/blog.html diff --git a/source/collections_armani.html b/source/collections_armani.html old mode 100644 new mode 100755 index 4d8a488..4d8a488 --- a/source/collections_armani.html +++ b/source/collections_armani.html diff --git a/source/dates.html b/source/dates.html old mode 100644 new mode 100755 index 9794a99..9794a99 --- a/source/dates.html +++ b/source/dates.html diff --git a/source/images/armani_logo.jpg b/source/images/armani_logo.jpg old mode 100644 new mode 100755 index 4bc7495..4bc7495 Binary files a/source/images/armani_logo.jpg and b/source/images/armani_logo.jpg differ diff --git a/source/index.html b/source/index.html old mode 100644 new mode 100755 index ca7e13c..ca7e13c --- a/source/index.html +++ b/source/index.html diff --git a/source/material.html b/source/material.html old mode 100644 new mode 100755 index 333dda1..333dda1 --- a/source/material.html +++ b/source/material.html diff --git a/source/newcoll.html b/source/newcoll.html old mode 100644 new mode 100755 index a8a7735..a8a7735 --- a/source/newcoll.html +++ b/source/newcoll.html diff --git a/source/oboi_armani.html b/source/oboi_armani.html old mode 100644 new mode 100755 index a6d488f..a6d488f --- a/source/oboi_armani.html +++ b/source/oboi_armani.html diff --git a/source/oboi_marburg.html b/source/oboi_marburg.html old mode 100644 new mode 100755 index e25fd2b..e25fd2b --- a/source/oboi_marburg.html +++ b/source/oboi_marburg.html diff --git a/source/post_blog1.html b/source/post_blog1.html old mode 100644 new mode 100755 index a394332..a394332 --- a/source/post_blog1.html +++ b/source/post_blog1.html diff --git a/source/post_dates1.html b/source/post_dates1.html old mode 100644 new mode 100755 index 858de46..858de46 --- a/source/post_dates1.html +++ b/source/post_dates1.html diff --git a/source/walls.html b/source/walls.html old mode 100644 new mode 100755 index b8b8ac4..b8b8ac4 --- a/source/walls.html +++ b/source/walls.html -- libgit2 0.21.4