From c361f57467ab5d1f92f19f6b73c3acb1f23f2f16 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 4 Oct 2016 18:08:37 +0300 Subject: [PATCH] big commti --- backend/views/event/_form.php | 2 ++ common/models/Event.php | 3 ++- common/modules/product/models/Export.php | 1 + common/modules/product/models/Import.php | 8 ++++---- console/migrations/m160920_193159_add_isEvent_to_event.php | 27 +++++++++++++++++++++++++++ frontend/controllers/EventController.php | 2 +- 6 files changed, 37 insertions(+), 6 deletions(-) create mode 100755 console/migrations/m160920_193159_add_isEvent_to_event.php diff --git a/backend/views/event/_form.php b/backend/views/event/_form.php index 9dae734..d7285e7 100755 --- a/backend/views/event/_form.php +++ b/backend/views/event/_form.php @@ -92,6 +92,8 @@ use mihaildev\elfinder\ElFinder; field($model, 'sale')->checkbox() ?> + field($model, 'is_event')->checkbox() ?> + field($model, 'percent')->textInput() ?> diff --git a/common/models/Event.php b/common/models/Event.php index 1d34519..3231f03 100755 --- a/common/models/Event.php +++ b/common/models/Event.php @@ -91,7 +91,7 @@ class Event extends \yii\db\ActiveRecord { return [ [['body', 'seo_text'], 'string'], - [['created_at', 'updated_at','percent','sale' ], 'integer'], + [['created_at', 'updated_at','percent','sale','is_event' ], 'integer'], [['name', 'alias', 'image', 'meta_title', 'description', 'h1','end_at','banner'], 'string', 'max' => 255], [['name','body'], 'required'], [['imageUpload'], 'safe'], @@ -122,6 +122,7 @@ class Event extends \yii\db\ActiveRecord 'products_file' => Yii::t('app', 'Загрузка файла'), 'sale' => Yii::t('app', 'Распродажа'), 'percent' => Yii::t('app', 'Процент'), + 'is_event' => Yii::t('app', 'Акция'), ]; } diff --git a/common/modules/product/models/Export.php b/common/modules/product/models/Export.php index 93d2372..65e7edb 100755 --- a/common/modules/product/models/Export.php +++ b/common/modules/product/models/Export.php @@ -13,6 +13,7 @@ class Export extends Model { public function process($dirName, $filename = null, $use_not_enables = false) { set_time_limit(0); ini_set('max_execution_time', 900); + ini_set('memory_limit', '1024M'); if (is_null($filename)) { $filename = 'products_'. date('d_m_Y_H_i') .'.csv'; } diff --git a/common/modules/product/models/Import.php b/common/modules/product/models/Import.php index 8383642..f3c0450 100755 --- a/common/modules/product/models/Import.php +++ b/common/modules/product/models/Import.php @@ -443,17 +443,17 @@ class Import extends Model { $MOD_ARRAY[] = $_productVariant->product_variant_id; if ($mod_image) { - $source_image = Yii::getAlias('@uploadDir') . '/product_images/'. urlencode($mod_image); - if (file_exists($source_image)) { +// $source_image = Yii::getAlias('@uploadDir') . '/product_images/'. urlencode($mod_image); +// if (file_exists($source_image)) { if (($variantImage = ProductImage::find()->andFilterWhere(['ilike', 'image', $mod_image])->andFilterWhere(['product_variant_id' => $_productVariant->product_variant_id])->one()) === null) { - copy($source_image, Yii::getAlias('@productsDir') . "/" . $mod_image); +// copy($source_image, Yii::getAlias('@productsDir') . "/" . $mod_image); $variantImage = new ProductImage(); $variantImage->product_id = $_product->product_id; $variantImage->product_variant_id = $_productVariant->product_variant_id; $variantImage->image = $mod_image; $variantImage->save(); } - } +// } } } } diff --git a/console/migrations/m160920_193159_add_isEvent_to_event.php b/console/migrations/m160920_193159_add_isEvent_to_event.php new file mode 100755 index 0000000..2bdc786 --- /dev/null +++ b/console/migrations/m160920_193159_add_isEvent_to_event.php @@ -0,0 +1,27 @@ +addColumn('event', 'is_event', $this->boolean()); + } + + public function down() + { + $this->dropColumn('event', 'is_event'); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/controllers/EventController.php b/frontend/controllers/EventController.php index 4fc4b55..234d0e4 100755 --- a/frontend/controllers/EventController.php +++ b/frontend/controllers/EventController.php @@ -54,7 +54,7 @@ class EventController extends Controller protected function findModel($alias) { - if (($model = Event::findOne(["alias"=>$alias])) !== null) { + if (($model = Event::findOne(["alias"=>$alias,'is_event' => true])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); -- libgit2 0.21.4