diff --git a/.gitignore b/.gitignore index 4d21ce4..488eaeb 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,7 @@ phpunit.phar /phpunit.xml /.vagrant /vendor/ +/fordelete.txt +/done.txt +/certificates.php +/backup diff --git a/.htaccess b/.htaccess index 11b24ea..a4043c8 100644 --- a/.htaccess +++ b/.htaccess @@ -2,7 +2,7 @@ AddDefaultCharset utf-8 -# Options +FollowSymlinks + Options +FollowSymlinks RewriteEngine On diff --git a/_collection.php b/_collection.php new file mode 100644 index 0000000..511b23f --- /dev/null +++ b/_collection.php @@ -0,0 +1,173 @@ +
+
+
+
+
Egger EMOTION CLASSIC
+
+
+
+
+
Дуб трилогия капучино 1-х
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Коллекция:CLASSIC 32 класс 7 mm
Номер по каталогу:H1059.59772
Страна производства:Германия
Цвет:темный
Класс:32
Толщина:7 мм
Наличие фаски:Без фаски
м2 в упаковке:2,48
+ +
+
+ +
+
+
+
    +
  • Технические характеристики
  • +
  • Сертификаты
  • +
  • Монтаж, уборка, уход
  • +
  • Галерея объектов
  • +
+
+
+

База данных

+

Форбо обладает большим разнообразием рекламной и технической документации для каждого из своих покрытий. Документ можно найти, пройдя по ссылке выбранного продукта, после этого можно будет + скачать необходимый файл.

+

Вы также можете скачать таблицу с техническими характеристиками

+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+

Поверхность бесшовного пола или пола на основе минералов должна полностью покрываться влагозащитной полиэтиленовой пленкой толщиной 0,2 мм. При этом на стыках полосы пленки должны укладываться с нахлестом не менее 20 см.

+

Для всех поверхностей рекомендуется соответствующая подложка. Подложка укладывается встык, то есть без нахлеста. При укладке искусственного паркета, имеющего на оборотной стороне звукопоглощающую подкладку, дополнительная подложка не нужна (кашированная подкладка НЕ заменяет полиэтиленовую пленку на поверхностях на основе минералов!).Элементы паркета всегда укладываются как плавающие.

+

Неподвижное скрепление половиц с поверхностью для укладки (клей, шурупы, гвозди) не допускается. Минимальный сдвиг головных стыков половиц соседних рядов - 200 мм.

+

Компенсационный зазор у всех твердых строительных поверхностей – 8-10 мм.
+ Во всех дверных проемах, переходах, помещениях со сложной конфигурацией, а также помещениях, имеющих более 10 м в длину или ширину, необходимо вставлять переходники/порожки.

+

+ 1. Проверьте, не повреждены ли элементы напольных покрытий, нет ли на них дефектов.
+ Рассмотрите шпунтование панелей, найдите на панели паз и гребень.
+ Начните укладку первого ряда панелей с дальнего левого угла помещения. Укладывайте так, чтобы обе стороны панели с гребнем были обращены к стене. Начиная укладку, установите распорки для соблюдения расстояния от стены. Укладывайте покрытие следующим образом: к первому и каждому последующему уложенному элементу прикладывайте новую панель, под углом вводя ее гребнем в шпунт уже уложенного элемента. Затем опускайте укладываемую панель до тех пор, пока она полностью не ляжет на пол. +

+

2. Отметьте на последней панели первого ряда требуемую длину (укладывайте гребень к гребню) и отпилите панель по маркировке. Начните укладку второго ряда с остатка последней панели первого ряда, если ее длина не меньше 200 мм. Укладку всех последующих рядов следует начинать с остатка панели предыдущего ряда.
+ Внимание! При укладке торцевые стыки панелей каждого последующего ряда должны быть смещены минимум на 200 мм относительно стыков панелей предыдущего ряда. Укладывая покрытия с фаской и/или особым декором (например, имитирующим плитку) необходимо следить, чтобы смещение было равномерным и соответствовало фаске и рисунку.

+

3. Закончив первый ряд, используйте остаток последней панели для начала укладки второго ряда. Вы можете также начать с отрезка панели, подогнанного по длине к рисунку декора или фаске покрытия.
+ Введите гребень новой панели в паз первого элемента первого ряда, все последующие панели этого ряда соединяйте короткими сторонами, как описано выше, пока не уложите весь ряд. Теперь все короткие стороны панелей этого ряда подогнаны и соединены друг с другом. Слегка приподнимите первую панель (отрезок панели) ряда, соедините ее длинной стороной с соответствующей панелью первого ряда. Проделывайте то же самое с другими панелями второго ряда, пока не соедините весь второй ряд с первым. Следите за тем, чтобы при этом не сдвигались торцы коротких сторон панелей второго ряда. +

+

4. Продолжайте укладку покрытия, как описано выше - элемент за элементом, ряд за рядом.

+

5. Для того, чтобы уложить последний ряд, разместите подлежащий установке элемент точно на предпоследнем ряду. При помощи отрезка панели (ширина стыка + ширина зазора) можно перенести на укладываемый элемент контур стены с учетом планируемого зазора.

+
+
+ +
+
+
+
+
+
+ + + + diff --git a/backend/config/main.php b/backend/config/main.php index 24fa31a..34f2ad1 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -168,7 +168,7 @@ return [ 'product/manage/' => 'product/manage/', 'product////' => 'product//', 'product////' => 'product//', - 'product//' => 'product/', +// 'product//' => 'product/', 'seo-dynamic///' => 'seo-dynamic/', 'seo-dynamic//' => 'seo-dynamic/', ] diff --git a/backend/controllers/ArticlesController.php b/backend/controllers/ArticlesController.php index f2ef542..04145bc 100644 --- a/backend/controllers/ArticlesController.php +++ b/backend/controllers/ArticlesController.php @@ -113,6 +113,7 @@ class ArticlesController extends Controller $model = $this->findModel($id); if ($model->load(Yii::$app->request->post())) { + if ( ($image = UploadedFile::getInstance($model, 'image')) ) { $model->image = $image->name; } diff --git a/backend/controllers/BlogController.php b/backend/controllers/BlogController.php deleted file mode 100644 index 4bf7891..0000000 --- a/backend/controllers/BlogController.php +++ /dev/null @@ -1,160 +0,0 @@ -[ - 'class' => AccessBehavior::className(), - 'rules' => - ['site' => - [ - [ - 'actions' => ['login', 'error'], - 'allow' => true, - ] - ] - ] - ], - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'logout' => ['post'], - ], - ], - ]; - } - - /** - * Lists all Blog models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new BlogSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single Blog model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Blog model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new Blog(); - - if ($model->load(Yii::$app->request->post())) { - - Fields::saveFieldData(Yii::$app->request->post('Fields'), $model->blog_id, Blog::className(), 'ru'); - - if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) { - $model->cover = $image->name; - } - - if ($model->save() && $image) { - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name)); - } - - return $this->redirect(['view', 'id' => $model->blog_id]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); - } - } - - /** - * Updates an existing Blog 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())) { - - Fields::saveFieldData(Yii::$app->request->post('Fields'), $model->blog_id, Blog::className(), 'ru'); - - if ( ($image = UploadedFile::getInstance($model, 'imageUpload')) ) { - $model->cover = $image->name; - } - - if ($model->save() && $image) { - $image->saveAs(Yii::getAlias('@imagesDir/articles/' . $image->name)); - } - - return $this->redirect(['view', 'id' => $model->blog_id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); - } - } - - /** - * Deletes an existing Blog 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 Blog model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Blog the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Blog::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } -} diff --git a/backend/controllers/CommentController.php b/backend/controllers/CommentController.php deleted file mode 100644 index 1023d5c..0000000 --- a/backend/controllers/CommentController.php +++ /dev/null @@ -1,159 +0,0 @@ -[ - 'class' => AccessBehavior::className(), - 'rules' => - ['site' => - [ - [ - 'actions' => ['login', 'error'], - 'allow' => true, - ] - ] - ] - ], - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - /** - * Lists all Comment models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new CommentSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - $query = $dataProvider->query; - $query->with(['rating', 'user']); - $sort = $dataProvider->sort; - $sort->defaultOrder = [ - 'status' => SORT_ASC, - ]; - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single Comment model. - * @param integer $id - * @return mixed - */ -// public function actionView($id) -// { -// return $this->render('view', [ -// 'model' => $this->findModel($id), -// ]); -// } - - /** - * Creates a new Comment model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ -// public function actionCreate() -// { -// $model = new Comment(); -// -// if ($model->load(Yii::$app->request->post()) && $model->save()) { -// return $this->redirect(['view', 'id' => $model->comment_id]); -// } else { -// return $this->render('create', [ -// 'model' => $model, -// ]); -// } -// } - - /** - * Updates an existing Comment 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->comment_id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); - } - } - - public function actionApprove($id) { - $model = $this->findModel($id); - $model->status = Comment::STATUS_ACTIVE; - $model->save(false); - - return $this->redirect(['index']); - } - - public function actionDisapprove($id) { - $model = $this->findModel($id); - $model->status = Comment::STATUS_HIDDEN; - $model->save(false); - - return $this->redirect(['index']); - } - - /** - * Deletes an existing Comment 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 Comment model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Comment the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Comment::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } -} diff --git a/backend/controllers/ProjectController.php b/backend/controllers/ProjectController.php new file mode 100644 index 0000000..5d8b355 --- /dev/null +++ b/backend/controllers/ProjectController.php @@ -0,0 +1,166 @@ +[ + 'class' => AccessBehavior::className(), + 'rules' => + ['site' => + [ + [ + 'actions' => ['login', 'error'], + 'allow' => true, + ] + ] + ] + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Project models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ProjectSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Project model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Project model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Project(); + if ($model->load(Yii::$app->request->post())) { + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); + if ($model->save()) { + if ($model->imagesUpload && (($images = $model->imagesUpload()) !== FALSE)) { + foreach ($images as $image) { + $imageModel = new ProjectImage(); + $imageModel->project_id = $model->project_id; + $imageModel->image = $image; + $imageModel->save(); + } + } + return $this->redirect(['view', 'id' => $model->project_id]); + } + } + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing Project 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->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); + if ($model->save()) { + if ($model->imagesUpload && (($images = $model->imagesUpload()) !== FALSE)) { + foreach ($images as $image) { + $imageModel = new ProjectImage(); + $imageModel->project_id = $model->project_id; + $imageModel->image = $image; + $imageModel->save(); + } + } + return $this->redirect(['view', 'id' => $model->project_id]); + } + } + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing Project 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']); + } + + public function actionDelimg($id) { + $model = ProjectImage::findOne($id); + if(empty($model)) { + throw new NotFoundHttpException(); + } + $model->delete(); + return '1'; + } + + /** + * Finds the Project model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Project the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Project::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/SiteController.php b/backend/controllers/SiteController.php index 86377ee..ebb6744 100755 --- a/backend/controllers/SiteController.php +++ b/backend/controllers/SiteController.php @@ -1,19 +1,15 @@ request->post(); - if($blog->load($post)) { - $blog->save(); - } - return $this->render('index',[ - 'blog' => $blog - ]); + return $this->render('index'); } public function actionLogin() @@ -307,25 +296,6 @@ class SiteController extends Controller $resizeObj->resizeImage (370, 370, 'auto'); $resizeObj->saveImage ($dir.'/big/' . $mod_image, 100); } - - $product_variant_type_name = ''; - if (! empty ($mod_color)) - $product_variant_type_name = 'Цвет'; - elseif (! empty ($mod_size)) - $product_variant_type_name = 'Размер'; - - // ===== Set variant type ==== - if ( $product_variant_type_name ) { - if ( ($product_variant_type = ProductVariantType::find()->filterWhere(['ilike', 'name', $product_variant_type_name])->one()) !== null ) { - $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; - } else { - // Create brand - $product_variant_type = new ProductVariantType(); - $product_variant_type->name = $product_variant_type_name; - $product_variant_type->save(); - $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; - } - } } } diff --git a/backend/models/CommentSearch.php b/backend/models/CommentSearch.php deleted file mode 100644 index cb831de..0000000 --- a/backend/models/CommentSearch.php +++ /dev/null @@ -1,79 +0,0 @@ - $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([ - 'comment_id' => $this->comment_id, - 'user_id' => $this->user_id, - 'comment_pid' => $this->comment_pid, - 'status' => $this->status, - 'date_add' => $this->date_add, - 'date_update' => $this->date_update, - 'date_delete' => $this->date_delete, - 'model_id' => $this->model_id, - ]); - - $query->andFilterWhere(['like', 'text', $this->text]) - ->andFilterWhere(['like', 'user_name', $this->user_name]) - ->andFilterWhere(['like', 'user_email', $this->user_email]) - ->andFilterWhere(['like', 'model', $this->model]); - - return $dataProvider; - } -} diff --git a/backend/models/Label.php b/backend/models/Label.php index fbbc9f7..8e75a40 100644 --- a/backend/models/Label.php +++ b/backend/models/Label.php @@ -1,8 +1,6 @@ name; - } - - - - - - + } } diff --git a/backend/models/Orders.php b/backend/models/Orders.php index 982e623..99cc411 100644 --- a/backend/models/Orders.php +++ b/backend/models/Orders.php @@ -1,72 +1,91 @@ 'jpg, gif, png', 'skipOnEmpty'=>true], - ]; - } - - public function attributeLabels() - { - return [ - 'id'=>'№ заказа', - 'name'=>'ФИО', - 'phone'=>'Телефон', - 'phone2'=>'Телефон 2', - 'adress'=>'Адрес', - 'body'=>'Сообщение', - 'reserve'=>'Резерв', - 'status'=>'Статус', - 'email'=>'E-mail', - 'total'=>'Сумма', - 'labels'=>'Метки', - 'label'=>'Метка', - 'comment'=>'Комментарий менеджера', - 'date_dedline'=>'Дедлайн', - 'numbercard'=>'№ карточки', - 'delivery'=>'Доставка', - 'declaration'=>'Декларация №', - 'stock'=>'№ склада', - 'consignment'=>'№ накладной', - 'payment'=>'Способ оплаты', - 'insurance'=>'Страховка', - 'amount_imposed'=>'Сумма наложенного', - 'shipping_by'=>'Отправка за счет', - 'city'=>'Город' - ]; - } - public function beforeSave($insert) { - return parent::beforeSave($insert); - } + public $labels; - public function beforeDelete() { - return parent::beforeDelete(); + public static function tableName() + { + return 'orders'; } - public function getUser() - { - return $this->hasOne(Customer::className(), ['id' => 'user_id']); + public function rules() + { + return [ + [ + [ 'name' ], + 'required', + ], + [ + [ + 'user_id', + 'adress', + 'body', + 'total', + 'status', + 'email', + 'comment', + 'labels', + 'pay', + 'date_dedline', + 'phone', + 'phone2', + 'numbercard', + 'delivery', + 'declaration', + 'stock', + 'consignment', + 'payment', + 'insurance', + 'amount_imposed', + 'shipping_by', + 'city', + 'date_time', + 'id', + ], + 'safe', + ], + ]; + } + + public function attributeLabels() + { + return [ + 'id' => '№ заказа', + 'name' => 'ФИО', + 'phone' => 'Телефон', + 'phone2' => 'Телефон 2', + 'adress' => 'Адрес', + 'body' => 'Сообщение', + 'reserve' => 'Резерв', + 'status' => 'Статус', + 'email' => 'E-mail', + 'total' => 'Сумма', + 'labels' => 'Метки', + 'label' => 'Метка', + 'comment' => 'Комментарий менеджера', + 'date_dedline' => 'Дедлайн', + 'numbercard' => '№ карточки', + 'delivery' => 'Доставка', + 'declaration' => 'Декларация №', + 'stock' => '№ склада', + 'consignment' => '№ накладной', + 'payment' => 'Способ оплаты', + 'insurance' => 'Страховка', + 'amount_imposed' => 'Сумма наложенного', + 'shipping_by' => 'Отправка за счет', + 'city' => 'Город', + ]; } - + public function getUser() + { + return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]); + } -} \ No newline at end of file + } \ No newline at end of file diff --git a/backend/models/OrdersProducts.php b/backend/models/OrdersProducts.php index 503f311..ebf8a57 100644 --- a/backend/models/OrdersProducts.php +++ b/backend/models/OrdersProducts.php @@ -1,38 +1,45 @@ 'Продукт', - 'name'=>'Вид', - 'art'=>'Артикул', - 'cost'=>'Цена за один', - 'count'=>'Кол.', - 'sum_cost'=>'Сумма', - ]; - } - - public function getMod() - { - return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'mod_id']); - } -} \ No newline at end of file + class OrdersProducts extends \yii\db\ActiveRecord + { + + public static function tableName() + { + return 'orders_products'; + } + + public function rules() + { + return [ + [ + [ + 'sku', + 'count', + 'order_id', + ], + 'required', + ], + ]; + } + + public function attributeLabels() + { + return [ + 'product_name' => 'Продукт', + 'name' => 'Вид', + 'art' => 'Артикул', + 'cost' => 'Цена за один', + 'count' => 'Кол.', + 'sum_cost' => 'Сумма', + ]; + } + + public function getMod() + { + return $this->hasOne(ProductVariant::className(), [ 'product_variant_id' => 'mod_id' ]); + } + } \ No newline at end of file diff --git a/backend/models/OrdersSearch.php b/backend/models/OrdersSearch.php index 5183ad6..39c5a18 100644 --- a/backend/models/OrdersSearch.php +++ b/backend/models/OrdersSearch.php @@ -2,10 +2,8 @@ namespace backend\models; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use backend\models\Orders; /** * OrdersSearch represents the model behind the search form about `backend\models\Orders`. diff --git a/backend/models/User.php b/backend/models/User.php index ad6e067..091aa2e 100644 --- a/backend/models/User.php +++ b/backend/models/User.php @@ -1,204 +1,231 @@ 255], - [['auth_key'], 'string', 'max' => 32], - [['password_reset_token'], 'unique'], - ['email', 'unique', 'targetClass' => '\backend\models\User', 'message' => Yii::t('app','message',[ - 'field' => 'Email' - ])], - ]; - } - - - /** - * @inheritdoc - */ - public function behaviors() - { - return [ - TimestampBehavior::className(), - [ - 'class' => 'common\behaviors\ShowImage', - ], - ]; - } - - - public function beforeSave($insert) - { - $this->setPassword($this->password); - $this->generateAuthKey(); - return parent::beforeSave($insert); - } - - - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'username' => 'Username', - 'auth_key' => 'Auth Key', - 'password_hash' => 'Password Hash', - 'password_reset_token' => 'Password Reset Token', - 'email' => 'Email', - 'status' => 'Status', - 'created_at' => 'Created At', - 'updated_at' => 'Updated At', - ]; - } - - - /** - * Generates "remember me" authentication key - */ - public function generateAuthKey() - { - $this->auth_key = Yii::$app->security->generateRandomString(); - } - - /** - * Generates password hash from password and sets it to the model - * - * @param string $password - */ - public function setPassword($password) - { - $this->password_hash = Yii::$app->security->generatePasswordHash($password); - } - - - - - - public function getRole(){ - return !empty($this->id) ? \Yii::$app->authManager->getRolesByUser($this->id) : ""; - } - - /** - * @inheritdoc - */ - public function getId() - { - return $this->getPrimaryKey(); - } - - /** - * @inheritdoc - */ - public function getAuthKey() - { - return $this->auth_key; - } - - /** - * @inheritdoc - */ - public function validateAuthKey($authKey) - { - return $this->getAuthKey() === $authKey; - } - - - /** - * @inheritdoc - */ - public static function findIdentityByAccessToken($token, $type = null) - { - throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.'); - } - - /** - * @inheritdoc - */ - public static function findIdentity($id) - { - return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getComments() - { - return $this->hasMany(Comment::className(), ['user_id' => 'id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getRatings() - { - return $this->hasMany(Rating::className(), ['user_id' => 'id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getShares() - { - return $this->hasMany(Share::className(), ['user_id' => 'id']); - } - - - public function getUserName() - { - return $this->username; + class User extends ActiveRecord implements UserRbacInterface, IdentityInterface + { + + const STATUS_DELETED = 0; + const STATUS_ACTIVE = 10; + + public $password; + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'user'; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'username', + 'password', + 'email', + ], + 'required', + ], + [ + [ + 'status', + 'created_at', + 'updated_at', + ], + 'integer', + ], + [ + [ + 'username', + 'password_hash', + 'password_reset_token', + 'email', + ], + 'string', + 'max' => 255, + ], + [ + [ 'auth_key' ], + 'string', + 'max' => 32, + ], + [ + [ 'password_reset_token' ], + 'unique', + ], + [ + 'email', + 'unique', + 'targetClass' => '\backend\models\User', + 'message' => Yii::t('app', 'message', [ + 'field' => 'Email', + ]), + ], + ]; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + TimestampBehavior::className(), + [ + 'class' => 'common\behaviors\ShowImage', + ], + ]; + } + + public function beforeSave($insert) + { + $this->setPassword($this->password); + $this->generateAuthKey(); + return parent::beforeSave($insert); + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'username' => 'Username', + 'auth_key' => 'Auth Key', + 'password_hash' => 'Password Hash', + 'password_reset_token' => 'Password Reset Token', + 'email' => 'Email', + 'status' => 'Status', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + ]; + } + + /** + * Generates "remember me" authentication key + */ + public function generateAuthKey() + { + $this->auth_key = Yii::$app->security->generateRandomString(); + } + + /** + * Generates password hash from password and sets it to the model + * + * @param string $password + */ + public function setPassword($password) + { + $this->password_hash = Yii::$app->security->generatePasswordHash($password); + } + + public function getRole() + { + return !empty( $this->id ) ? \Yii::$app->authManager->getRolesByUser($this->id) : ""; + } + + /** + * @inheritdoc + */ + public function getId() + { + return $this->getPrimaryKey(); + } + + /** + * @inheritdoc + */ + public function getAuthKey() + { + return $this->auth_key; + } + + /** + * @inheritdoc + */ + public function validateAuthKey($authKey) + { + return $this->getAuthKey() === $authKey; + } + + /** + * @inheritdoc + */ + public static function findIdentityByAccessToken($token, $type = NULL) + { + throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.'); + } + + /** + * @inheritdoc + */ + public static function findIdentity($id) + { + return static::findOne([ + 'id' => $id, + 'status' => self::STATUS_ACTIVE, + ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getComments() + { + return $this->hasMany(CommentModel::className(), [ 'user_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getRatings() + { + return $this->hasMany(RatingModel::className(), [ 'user_id' => 'id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getShares() + { + return $this->hasMany(Share::className(), [ 'user_id' => 'id' ]); + } + + public function getUserName() + { + return $this->username; + } + } - - -} diff --git a/backend/models/UserSearch.php b/backend/models/UserSearch.php index 5ac51e0..b434b9f 100644 --- a/backend/models/UserSearch.php +++ b/backend/models/UserSearch.php @@ -1,76 +1,112 @@ $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'); + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'id', + 'status', + 'created_at', + 'updated_at', + ], + 'integer', + ], + [ + [ + 'username', + 'auth_key', + 'password_hash', + 'password_reset_token', + 'email', + ], + 'safe', + ], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = User::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $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([ + 'id' => $this->id, + 'status' => $this->status, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere([ + 'like', + 'username', + $this->username, + ]) + ->andFilterWhere([ + 'like', + 'auth_key', + $this->auth_key, + ]) + ->andFilterWhere([ + 'like', + 'password_hash', + $this->password_hash, + ]) + ->andFilterWhere([ + 'like', + 'password_reset_token', + $this->password_reset_token, + ]) + ->andFilterWhere([ + 'like', + 'email', + $this->email, + ]); + return $dataProvider; } - - // grid filtering conditions - $query->andFilterWhere([ - 'id' => $this->id, - 'status' => $this->status, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, - ]); - - $query->andFilterWhere(['like', 'username', $this->username]) - ->andFilterWhere(['like', 'auth_key', $this->auth_key]) - ->andFilterWhere(['like', 'password_hash', $this->password_hash]) - ->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token]) - ->andFilterWhere(['like', 'email', $this->email]); - - return $dataProvider; } -} diff --git a/backend/views/articles/_form.php b/backend/views/articles/_form.php index f5eb6f8..db5386a 100644 --- a/backend/views/articles/_form.php +++ b/backend/views/articles/_form.php @@ -21,8 +21,7 @@ use yii\jui\DatePicker; field($model, 'date') ->widget(DatePicker::className(), [ - 'dateFormat' => 'yyyy-MM-dd', - 'clientOptions' => [ 'minDate' => 1 ], + 'dateFormat' => 'dd-MM-yyyy', ]) ?> field($model, 'title')->textInput(['maxlength' => true]) ?> @@ -35,7 +34,16 @@ use yii\jui\DatePicker; ] ) ]) ?> - + + field($model, 'body_preview')->widget(CKEditor::className(), + [ + 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ + 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать + 'inline' => false, //по умолчанию false]), + 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload') + ] + ) + ]) ?> field($model, 'image')->widget(\kartik\file\FileInput::classname(), [ 'language' => 'ru', diff --git a/backend/views/blog/_form.php b/backend/views/blog/_form.php deleted file mode 100644 index 5f27928..0000000 --- a/backend/views/blog/_form.php +++ /dev/null @@ -1,65 +0,0 @@ - - -
- - false, - 'options' => ['enctype' => 'multipart/form-data'] - ]); ?> - - field($model, 'name')->textInput(['maxlength' => true]) ?> - - field($model, 'link')->textInput(['maxlength' => true]) ?> - - field($model, 'description')->widget(CKEditor::className(), - [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ - 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать - 'inline' => false, //по умолчанию false]), - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload') - ] - ) - ]) ?> - - field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [ - 'language' => 'ru', - 'options' => [ - 'accept' => 'image/*', - 'multiple' => false, - ], - 'pluginOptions' => [ - 'allowedFileExtensions' => ['jpg', 'gif', 'png'], - 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '', - 'overwriteInitial' => true, - 'showRemove' => false, - 'showUpload' => false, - 'previewFileType' => 'image', - ], - ]); ?> - - 'education', - 'item_id' => $model->blog_id, - 'model' => 'common\models\Blog', - 'language' => 'ru', - ]); ?> -
- isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> -
- - - -
diff --git a/backend/views/blog/_search.php b/backend/views/blog/_search.php deleted file mode 100644 index c3ac459..0000000 --- a/backend/views/blog/_search.php +++ /dev/null @@ -1,43 +0,0 @@ - - - diff --git a/backend/views/blog/create.php b/backend/views/blog/create.php deleted file mode 100644 index 54c74d2..0000000 --- a/backend/views/blog/create.php +++ /dev/null @@ -1,21 +0,0 @@ -title = 'Create Blog'; -$this->params['breadcrumbs'][] = ['label' => 'Blogs', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/backend/views/blog/index.php b/backend/views/blog/index.php deleted file mode 100644 index 5a2716d..0000000 --- a/backend/views/blog/index.php +++ /dev/null @@ -1,40 +0,0 @@ -title = 'Blogs'; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- render('_search', ['model' => $searchModel]); ?> - -

- 'btn btn-success']) ?> -

- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'blog_id', - 'user_id', - 'name', - 'link', - 'date_add', - // 'user_add_id', - // 'view_count', - // 'description:ntext', - // 'cover', - - ['class' => 'yii\grid\ActionColumn'], - ], - ]); ?> -
diff --git a/backend/views/blog/update.php b/backend/views/blog/update.php deleted file mode 100644 index 05ecebd..0000000 --- a/backend/views/blog/update.php +++ /dev/null @@ -1,21 +0,0 @@ -title = 'Update Blog: ' . ' ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Blogs', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->blog_id]]; -$this->params['breadcrumbs'][] = 'Update'; -?> -
- -

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/backend/views/blog/view.php b/backend/views/blog/view.php deleted file mode 100644 index 08a4665..0000000 --- a/backend/views/blog/view.php +++ /dev/null @@ -1,43 +0,0 @@ -title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Blogs', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- -

- $model->blog_id], ['class' => 'btn btn-primary']) ?> - $model->blog_id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', - ], - ]) ?> -

- - $model, - 'attributes' => [ - 'blog_id', - 'user_id', - 'name', - 'link', - 'date_add', - 'user_add_id', - 'view_count', - 'description:ntext', - 'cover', - ], - ]) ?> - -
diff --git a/backend/views/brand/_search.php b/backend/views/brand/_search.php index ed1902f..5173e77 100644 --- a/backend/views/brand/_search.php +++ b/backend/views/brand/_search.php @@ -1,41 +1,35 @@ diff --git a/backend/views/brand/view.php b/backend/views/brand/view.php index ad1a066..083cb2e 100644 --- a/backend/views/brand/view.php +++ b/backend/views/brand/view.php @@ -29,7 +29,6 @@ $this->params['breadcrumbs'][] = $this->title; 'model' => $model, 'attributes' => [ 'brand_id', - 'brand_name_id', 'alias', 'imageUrl:image', 'meta_title', diff --git a/backend/views/category/_form.php b/backend/views/category/_form.php index 68cf4c8..3173b67 100644 --- a/backend/views/category/_form.php +++ b/backend/views/category/_form.php @@ -30,6 +30,9 @@ use kartik\select2\Select2; ] ])->label(Yii::t('product', 'Parent category')) ?> + field($model, 'taxGroup')->widget(Select2::className(), [ 'data' => \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'), 'language' => 'ru', @@ -42,6 +45,8 @@ use kartik\select2\Select2; ], ] ) ?> + */ + ?> field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [ 'language' => 'ru', @@ -77,10 +82,6 @@ use kartik\select2\Select2; ) ]) ?> - depth == 2) :?> - field($model, 'populary')->checkbox() ?> - -
isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> isNewRecord) :?> diff --git a/backend/views/category/_search.php b/backend/views/category/_search.php index 2740e88..8d636bc 100644 --- a/backend/views/category/_search.php +++ b/backend/views/category/_search.php @@ -25,20 +25,6 @@ use yii\widgets\ActiveForm; field($model, 'image') ?> - field($model, 'meta_title') ?> - - field($model, 'meta_desc') ?> - - field($model, 'meta_robots') ?> - - field($model, 'seo_text') ?> - - field($model, 'category_name_id') ?> - - field($model, 'product_unit_id') ?> - - field($model, 'alias') ?> -
'btn btn-primary']) ?> 'btn btn-default']) ?> diff --git a/backend/views/category/index.php b/backend/views/category/index.php index 66211a4..b93a275 100644 --- a/backend/views/category/index.php +++ b/backend/views/category/index.php @@ -1,72 +1,69 @@ title = Yii::t('product', 'Categories'); -$this->params['breadcrumbs'][] = $this->title; + + use yii\helpers\Html; + use kartik\grid\GridView; + + /** + * @var $this yii\web\View + * @var $searchModel common\modules\product\models\CategorySearch + * @var $dataProvider yii\data\ActiveDataProvider + */ + $this->title = Yii::t('product', 'Categories'); + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
- +

title) ?>

- render('_search', ['model' => $searchModel]); ?> - +

- 'btn btn-success']) ?> + 'btn btn-success' ]) ?>

$dataProvider, -// 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], + 'columns' => [ + [ 'class' => 'yii\grid\SerialColumn' ], [ - 'label'=> Yii::t('product', 'Name'), - 'content'=>function($data){ + 'label' => Yii::t('product', 'Name'), + 'content' => function($data) { $op = []; - foreach($data->getParents()->all() as $parent) { + foreach($data->getParents() + ->all() as $parent) { $op[] = $parent->name; } $op[] = $data->name; return implode(' → ', $op); -// return str_repeat('-', $data->depth) .' '. $data->name; - } + }, ], [ - 'class' => 'yii\grid\ActionColumn', - 'template' => '{view} {update} {delete} {populary}', - 'buttons' => [ - 'populary' => function ($url, $model) { - if ($model->depth == 2) { - return Html::a('', $url, [ - 'title' => Yii::t('product', ($model->populary ? 'Set not populary' : 'Set populary')), - ]); - } - }, - ], - 'urlCreator' => function ($action, $model, $key, $index) { - switch ($action) { - case 'populary': - return \yii\helpers\Url::to(['category/populary', 'id' => $model->category_id]); - break; + 'class' => 'yii\grid\ActionColumn', + 'template' => '{view} {update} {delete}', + 'urlCreator' => function($action, $model, $key, $index) { + switch($action) { case 'view': - return \yii\helpers\Url::to(['category/view', 'id' => $model->category_id]); + return \yii\helpers\Url::to([ + 'category/view', + 'id' => $model->category_id, + ]); break; case 'update': - return \yii\helpers\Url::to(['category/update', 'id' => $model->category_id]); + return \yii\helpers\Url::to([ + 'category/update', + 'id' => $model->category_id, + ]); break; case 'delete': - return \yii\helpers\Url::to(['category/delete', 'id' => $model->category_id]); + return \yii\helpers\Url::to([ + 'category/delete', + 'id' => $model->category_id, + ]); break; } - } + return ''; + }, ], ], - 'panel' => [ - 'type'=>'success', + 'panel' => [ + 'type' => 'success', ], ]); ?>
diff --git a/backend/views/category/view.php b/backend/views/category/view.php index 90945f3..643c0e9 100644 --- a/backend/views/category/view.php +++ b/backend/views/category/view.php @@ -42,10 +42,8 @@ $this->params['breadcrumbs'][] = $this->title; 'meta_robots', 'h1', 'seo_text:ntext', - 'category_name_id', 'product_unit_id', 'alias', - ], ]) ?> diff --git a/backend/views/comment/_form.php b/backend/views/comment/_form.php deleted file mode 100644 index efe6e86..0000000 --- a/backend/views/comment/_form.php +++ /dev/null @@ -1,33 +0,0 @@ - 'Активный', - Comment::STATUS_HIDDEN => 'Новый', - Comment::STATUS_DELETED => 'Удаленный', - ] -?> - -
- - - - field($model, 'text') - ->textarea([ 'rows' => 6 ]) ?> - - field($model, 'status') - ->dropDownList($status_list) ?> - -
- 'btn btn-primary' ]) ?> -
- - - -
diff --git a/backend/views/comment/_search.php b/backend/views/comment/_search.php deleted file mode 100644 index a61526e..0000000 --- a/backend/views/comment/_search.php +++ /dev/null @@ -1,49 +0,0 @@ - - - diff --git a/backend/views/comment/index.php b/backend/views/comment/index.php deleted file mode 100644 index 3514c68..0000000 --- a/backend/views/comment/index.php +++ /dev/null @@ -1,99 +0,0 @@ -title = 'Комменты'; - $this->params[ 'breadcrumbs' ][] = $this->title; -?> -
- -

title) ?>

- - $dataProvider, - 'columns' => [ - [ - 'class' => 'yii\grid\ActionColumn', - 'template' => '{approve} {update} {delete}', - 'buttons' => [ - 'approve' => function($url, $model, $key) { - /** - * @var Comment $model - */ - $options = array_merge([ - 'title' => "Подтвердить", - 'aria-label' => "Подтвердить", - 'data-confirm' => "Комментарий и оценка отобразится на публичной части сайта, подтвердить?", - 'data-method' => 'post', - 'data-pjax' => '0', - ]); - $glyphicon = 'glyphicon-ok'; - if($model->status == $model::STATUS_ACTIVE) { - $url = Url::to(['comment/disapprove', 'id' => $model->comment_id]); - $glyphicon = 'glyphicon-remove'; - } - return Html::a('', $url, $options); - } - ] - ], - 'comment_id', - [ - 'attribute' => 'rating.value', - 'label' => 'Оценка', - ], - 'text:ntext', - [ - 'content' => function($model) { - /** - * @var Comment $model - */ - if(!empty( $model->user )) { - return $model->user->username . " (ID: " . $model->user->id . ")"; - } else { - return $model->user_name . " (Гость: " . $model->user_email . ")"; - } - }, - 'label' => 'Пользователь', - ], - [ - 'attribute' => 'status', - 'value' => function($model) { - /** - * @var Comment $model - */ - $status = ''; - switch($model->status) { - case Comment::STATUS_ACTIVE: - $status = 'Активный'; - break; - case Comment::STATUS_HIDDEN: - $status = 'Новый'; - break; - case Comment::STATUS_DELETED: - $status = 'Удаленный'; - break; - default: - $status = 'Неизвестно'; - }; - return $status; - }, - ], - 'date_add', - [ - 'attribute' => 'model', - 'value' => function($model) { - /** - * @var Comment $model - */ - return $model->model . " (ID: " . $model->model_id . ")"; - }, - ], - ], - ]); ?> -
diff --git a/backend/views/comment/update.php b/backend/views/comment/update.php deleted file mode 100644 index 3c96c8f..0000000 --- a/backend/views/comment/update.php +++ /dev/null @@ -1,21 +0,0 @@ -title = 'Редактировать коммент: ' . $model->comment_id; -$this->params['breadcrumbs'][] = ['label' => 'Комментарии', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->comment_id, 'url' => ['view', 'id' => $model->comment_id]]; -$this->params['breadcrumbs'][] = 'Редактировать'; -?> -
- -

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/backend/views/comment/view.php b/backend/views/comment/view.php deleted file mode 100644 index 1af38ca..0000000 --- a/backend/views/comment/view.php +++ /dev/null @@ -1,46 +0,0 @@ -title = $model->comment_id; -$this->params['breadcrumbs'][] = ['label' => 'Comments', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- -

- $model->comment_id], ['class' => 'btn btn-primary']) ?> - $model->comment_id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Are you sure you want to delete this item?', - 'method' => 'post', - ], - ]) ?> -

- - $model, - 'attributes' => [ - 'comment_id', - 'text:ntext', - 'user_id', - 'user_name', - 'user_email:email', - 'comment_pid', - 'status', - 'date_add', - 'date_update', - 'date_delete', - 'model', - 'model_id', - ], - ]) ?> - -
diff --git a/backend/views/customer/_form.php b/backend/views/customer/_form.php index 01f70af..476f0b7 100644 --- a/backend/views/customer/_form.php +++ b/backend/views/customer/_form.php @@ -7,7 +7,6 @@ use yii\widgets\ActiveForm; /* @var $model common\models\Customer */ /* @var $form yii\widgets\ActiveForm */ ?> -
@@ -23,10 +22,8 @@ use yii\widgets\ActiveForm; field($model, 'surname')->textInput(['maxlength' => true]) ?> field($model, 'phone')->textInput(['maxlength' => true]) ?> - - field($model, 'date_time')->textInput() ?> - - field($model, 'sex')->textInput(['maxlength' => true]) ?> + + field($model, 'gender')->textInput(['maxlength' => true]) ?> field($model, 'birth_day')->textInput() ?> diff --git a/backend/views/customer/_search.php b/backend/views/customer/_search.php index 3a462e9..48aed17 100644 --- a/backend/views/customer/_search.php +++ b/backend/views/customer/_search.php @@ -25,22 +25,6 @@ use yii\widgets\ActiveForm; field($model, 'surname') ?> - field($model, 'phone') ?> - - field($model, 'date_time') ?> - - field($model, 'sex') ?> - - field($model, 'birth_day') ?> - - field($model, 'birth_month') ?> - - field($model, 'birth_year') ?> - - field($model, 'body') ?> - - field($model, 'group_id') ?> -
'btn btn-primary']) ?> 'btn btn-default']) ?> diff --git a/backend/views/customer/index.php b/backend/views/customer/index.php index b7e25bf..5964fe9 100644 --- a/backend/views/customer/index.php +++ b/backend/views/customer/index.php @@ -26,17 +26,9 @@ $this->params['breadcrumbs'][] = $this->title; 'id', 'username', - 'password', 'name', 'surname', - // 'phone', - // 'date_time', - // 'sex', - // 'birth_day', - // 'birth_month', - // 'birth_year', - // 'body:ntext', - // 'group_id', + 'phone', ['class' => 'yii\grid\ActionColumn'], ], diff --git a/backend/views/customer/view.php b/backend/views/customer/view.php index c070573..a954025 100644 --- a/backend/views/customer/view.php +++ b/backend/views/customer/view.php @@ -30,12 +30,10 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'id', 'username', - 'password', 'name', 'surname', 'phone', - 'date_time', - 'sex', + 'gender', 'birth_day', 'birth_month', 'birth_year', diff --git a/backend/views/event/_form.php b/backend/views/event/_form.php index 228ef35..3a12600 100644 --- a/backend/views/event/_form.php +++ b/backend/views/event/_form.php @@ -35,7 +35,7 @@ use mihaildev\elfinder\ElFinder; field($model, 'end_at') ->widget(DatePicker::className(), [ 'pluginOptions' => [ - 'format' => 'dd-M-yyyy', + 'format' => 'dd-mm-yyyy', 'todayHighlight' => true ]]) ?> diff --git a/backend/views/layouts/main-sidebar.php b/backend/views/layouts/main-sidebar.php index 23d7844..c60c4ba 100644 --- a/backend/views/layouts/main-sidebar.php +++ b/backend/views/layouts/main-sidebar.php @@ -102,6 +102,12 @@ use yii\widgets\Menu; 'options' => ['class'=>\Yii::$app->user->can('event') ? '' :'hide'], ], [ + 'label' => 'Проекты', + 'template'=>' {label}', + 'url' => ['/project'], + 'options' => ['class'=>\Yii::$app->user->can('event') ? '' :'hide'], + ], + [ 'label' => 'Статьи', 'template'=>' {label}', 'url' => ['/articles/index'], diff --git a/backend/views/orders/_form.php b/backend/views/orders/_form.php index 6579e53..a2e6c7c 100644 --- a/backend/views/orders/_form.php +++ b/backend/views/orders/_form.php @@ -30,7 +30,9 @@ use kartik\date\DatePicker; field($model, 'numbercard') ?> field($model, 'body')->textArea(['rows' => '3']) ?> -field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) ?> + + field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) */ ?> + field($model, 'declaration') ?> field($model, 'stock') ?> diff --git a/backend/views/orders/show.php b/backend/views/orders/show.php index 75abacb..0e8b5e7 100644 --- a/backend/views/orders/show.php +++ b/backend/views/orders/show.php @@ -47,7 +47,7 @@ use kartik\date\DatePicker; field($model, 'date_dedline') ->widget(DatePicker::className(), [ 'pluginOptions' => [ - 'format' => 'dd-M-yyyy', + 'format' => 'dd-mm-yyyy', 'todayHighlight' => true ]]) ?> diff --git a/backend/views/page/_form.php b/backend/views/page/_form.php index feaee5d..d4fed28 100644 --- a/backend/views/page/_form.php +++ b/backend/views/page/_form.php @@ -37,6 +37,8 @@ use mihaildev\elfinder\ElFinder; field($model, 'seo_text')->textarea(['rows' => 6]) ?> field($model, 'h1')->textInput(['maxlength' => true]) ?> + + field($model, 'in_menu')->checkbox() ?>
isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> diff --git a/backend/views/project/_form.php b/backend/views/project/_form.php new file mode 100644 index 0000000..8b7b9d4 --- /dev/null +++ b/backend/views/project/_form.php @@ -0,0 +1,63 @@ + + +
+ + ['enctype' => 'multipart/form-data'] + ]); ?> + + + field($model, 'date_add') + ->widget(DatePicker::className(), [ + 'dateFormat' => 'dd-MM-yyyy', + ]) ?> + + field($model, 'title')->textInput(['maxlength' => true]) ?> + + field($model, 'link')->textInput(['maxlength' => true]) ?> + + field($model, 'description')->widget(CKEditor::className(), + [ + 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ + 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать + 'inline' => false, //по умолчанию false]), + 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload') + ] + ) + ]) ?> + + 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, + 'uploadAsync' => !empty($model->project_id), + 'previewFileType' => 'image', + ], + ]); ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/project/_search.php b/backend/views/project/_search.php new file mode 100644 index 0000000..afb9cfc --- /dev/null +++ b/backend/views/project/_search.php @@ -0,0 +1,47 @@ + + + diff --git a/backend/views/project/create.php b/backend/views/project/create.php new file mode 100644 index 0000000..90ac906 --- /dev/null +++ b/backend/views/project/create.php @@ -0,0 +1,21 @@ +title = 'Create Project'; +$this->params['breadcrumbs'][] = ['label' => 'Projects', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/project/index.php b/backend/views/project/index.php new file mode 100644 index 0000000..c8d7a8a --- /dev/null +++ b/backend/views/project/index.php @@ -0,0 +1,32 @@ +title = 'Project'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ 'btn btn-success']) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + 'project_id', + 'date_add:date', + 'title', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/views/project/update.php b/backend/views/project/update.php new file mode 100644 index 0000000..d62bebb --- /dev/null +++ b/backend/views/project/update.php @@ -0,0 +1,21 @@ +title = 'Update Project: ' . $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Project', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->project_id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/project/view.php b/backend/views/project/view.php new file mode 100644 index 0000000..6eeb60e --- /dev/null +++ b/backend/views/project/view.php @@ -0,0 +1,37 @@ +title = $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Project', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->project_id], ['class' => 'btn btn-primary']) ?> + $model->project_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'project_id', + 'date_add:date', + 'title', + ], + ]) ?> + +
diff --git a/backend/web/js/fieldWidget.js b/backend/web/js/fieldWidget.js deleted file mode 100644 index 575b7b5..0000000 --- a/backend/web/js/fieldWidget.js +++ /dev/null @@ -1,24 +0,0 @@ -$(function(){ - $.each($('.delete-field-item'), function(index, value) { - var container = $(value).parents('.field_list').first(); - var count = $(container).find('.form-group').length; - if(count <= 1) { - $(container).find('.delete-field-item').addClass('hidden'); - } - }); - $(document).on('click', '.delete-field-item', function(){ - var container = $(this).parents('.field_list').first(); - $(this).parent('.form-group').remove(); - var count = $(container).find('.form-group').length; - if(count <= 1) { - $(container).find('.delete-field-item').addClass('hidden'); - } - }); - $(document).on('click', '[class*=add_field_w]', function() { - var container = $(this).siblings('.field_list').first(); - var count = $(container).find('.form-group').length; - if(count > 1) { - $(container).find('.delete-field-item').removeClass('hidden'); - } - }); -}); \ No newline at end of file diff --git a/collection.php b/collection.php deleted file mode 100644 index 020aa51..0000000 --- a/collection.php +++ /dev/null @@ -1,145 +0,0 @@ -
-
-
-
-
Egger EMOTION CLASSIC
-
-
-
-
-
Дуб трилогия капучино 1-х
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Коллекция:CLASSIC 32 класс 7 mm
Номер по каталогу:H1059.59772
Страна производства:Германия
Цвет:темный
Класс:32
Толщина:7 мм
Наличие фаски:Без фаски
м2 в упаковке:2,48
-
-
- -
- - - - - - - - -
-
- - - - diff --git a/common/behaviors/SaveImgBehavior.php b/common/behaviors/SaveImgBehavior.php new file mode 100644 index 0000000..2c16501 --- /dev/null +++ b/common/behaviors/SaveImgBehavior.php @@ -0,0 +1,83 @@ + 'beforeUpdate', + ActiveRecord::EVENT_BEFORE_INSERT => 'beforeInsert', + ]; + } + + public function beforeUpdate($event) + { + + + if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) { + $this->owner->image = $image->name; + } + + if(!$this->owner->image){ + $this->owner->image = $this->owner->getOldAttribute('image'); + } + + + if ($image) { + $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/'); + + if(!is_dir($imgDir)) { + mkdir($imgDir, 0755, true); + } + + $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name)); + } + } + + + public function beforeInsert($event) + { + + + if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) { + $this->owner->image = $image->name; + } + + + + if ($image) { + $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/'); + + if(!is_dir($imgDir)) { + mkdir($imgDir, 0755, true); + } + + $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name)); + } + } + + + + public function getImageFile() { + return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image; + } + + public function getImageUrl() { + return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image; + } +} \ No newline at end of file diff --git a/common/components/artboximage/ArtboxImageHelper.php b/common/components/artboximage/ArtboxImageHelper.php index 0735f98..3cf795c 100644 --- a/common/components/artboximage/ArtboxImageHelper.php +++ b/common/components/artboximage/ArtboxImageHelper.php @@ -6,7 +6,6 @@ use Yii; use yii\base\Object; use yii\helpers\ArrayHelper; use yii\helpers\Html; -use yii\web\HttpException; class ArtboxImageHelper extends Object { /** @var ArtboxImage $imageDriver */ diff --git a/common/components/artboxtree/ArtboxTreeBehavior.php b/common/components/artboxtree/ArtboxTreeBehavior.php index 8774aa1..5b946c9 100644 --- a/common/components/artboxtree/ArtboxTreeBehavior.php +++ b/common/components/artboxtree/ArtboxTreeBehavior.php @@ -2,8 +2,6 @@ namespace common\components\artboxtree; -use common\modules\rubrication\models\TaxOption; -use Yii; use yii\base\Behavior; use yii\base\Exception; use yii\base\NotSupportedException; diff --git a/common/components/artboxtree/ArtboxTreeQueryTrait.php b/common/components/artboxtree/ArtboxTreeQueryTrait.php index 048c359..017023e 100644 --- a/common/components/artboxtree/ArtboxTreeQueryTrait.php +++ b/common/components/artboxtree/ArtboxTreeQueryTrait.php @@ -2,8 +2,6 @@ namespace common\components\artboxtree; -use common\components\artboxtree\ArtboxTreeHelper; - trait ArtboxTreeQueryTrait { static public $cache_tree = []; diff --git a/common/config/main.php b/common/config/main.php index c37c83e..2620a90 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -156,6 +156,18 @@ 'height' => 110, ], ], + 'article_list' => [ + 'resize' => [ + 'width' => 555, + 'height' => 299, + ], + ], + 'project_list' => [ + 'resize' => [ + 'width' => 165, + 'height' => 100, + ], + ], ] ], 'basket' => [ diff --git a/common/models/Articles.php b/common/models/Articles.php index 06b7ac8..7e4ec9e 100644 --- a/common/models/Articles.php +++ b/common/models/Articles.php @@ -2,7 +2,7 @@ namespace common\models; -use common\behaviors\RatingBehavior; +use common\behaviors\SaveImgBehavior; use common\modules\comment\models\CommentModel; use Yii; @@ -10,7 +10,7 @@ use Yii; * This is the model class for table "articles". * * @property integer $id - * @property string $date + * @property integer $date * @property string $title * @property string $body * @property string $image @@ -20,6 +20,7 @@ use Yii; * @property string $meta_description * @property string $seo_text * @property string $h1 + * @property string $body_preview */ class Articles extends \yii\db\ActiveRecord { @@ -45,6 +46,9 @@ class Articles extends \yii\db\ActiveRecord 'out_attribute' => 'translit', 'translit' => true ], + [ + 'class' => SaveImgBehavior::className(), + ], ]; } @@ -54,12 +58,18 @@ class Articles extends \yii\db\ActiveRecord public function rules() { return [ + [['date'], 'default', 'value' => function() { + return time(); + }], [['date'], 'safe'], [['title', 'body'], 'required'], - [['body', 'seo_text'], 'string'], + [['body', 'body_preview', 'seo_text'], 'string'], [['title', 'image', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255], [['imageUpload'], 'safe'], [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], + [['date'], 'filter', 'filter' => function($value) { + return strtotime($value)?:time(); + }], ]; } @@ -73,6 +83,7 @@ class Articles extends \yii\db\ActiveRecord 'date' => 'Date', 'title' => 'Title', 'body' => 'Body', + 'body_preview' => 'Body preview', 'image' => 'Image', 'imageUrl' => Yii::t('app', 'Image'), 'translit' => 'Translit', diff --git a/common/models/ArticlesSearch.php b/common/models/ArticlesSearch.php index 686dca2..ce150d9 100644 --- a/common/models/ArticlesSearch.php +++ b/common/models/ArticlesSearch.php @@ -19,7 +19,7 @@ class ArticlesSearch extends Articles { return [ [['id'], 'integer'], - [['date', 'title', 'body', 'image', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'], + [['title', 'body', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'seo_text', 'h1'], 'safe'], ]; } @@ -60,12 +60,10 @@ class ArticlesSearch extends Articles // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, - 'date' => $this->date, ]); $query->andFilterWhere(['like', 'title', $this->title]) ->andFilterWhere(['like', 'body', $this->body]) - ->andFilterWhere(['like', 'image', $this->image]) ->andFilterWhere(['like', 'translit', $this->translit]) ->andFilterWhere(['like', 'meta_title', $this->meta_title]) ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords]) diff --git a/common/models/Blog.php b/common/models/Blog.php deleted file mode 100644 index 1cf7239..0000000 --- a/common/models/Blog.php +++ /dev/null @@ -1,121 +0,0 @@ - BlameableBehavior::className(), - 'createdByAttribute' => 'user_id', - 'updatedByAttribute' => false, - ], - [ - 'class' => TimestampBehavior::className(), - 'createdAtAttribute' => 'date_add', - 'updatedAtAttribute' => false, - 'value' => new Expression('NOW()'), - ], - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', - 'out_attribute' => 'link', - 'translit' => true - ] - ]; - } - - /** - * @inheritdoc - */ - public function rules() - { - return [ - [ - [ 'name', 'description' ], - 'required', - ], - [ - [ 'description' ], - 'string', - ], - [ - [ - 'name', - 'link', - 'cover', - ], - 'string', - 'max' => 255, - ], - [['imageUpload'], 'safe'], - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], - ]; - } - - public function getDateCreate(){ - return date('Y-m-d',strtotime($this->date_add)); - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'blog_id' => Yii::t('app', 'blog_id'), - 'user_id' => Yii::t('app', 'user_id'), - 'name' => Yii::t('app', 'name'), - 'link' => Yii::t('app', 'link'), - 'date_add' => Yii::t('app', 'date_add'), - 'user_add_id' => Yii::t('app', 'user_add_id'), - 'view_count' => Yii::t('app', 'view_count'), - 'description' => Yii::t('app', 'description'), - 'cover' => Yii::t('app', 'cover'), - 'image' => Yii::t('app', 'cover'), - 'imageUrl' => Yii::t('app', 'cover'), - ]; - } - - public function getImageFile() { - return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image); - } - - public function getImageUrl() - { - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/brands/' . $this->image); - } - } diff --git a/common/models/BlogSearch.php b/common/models/BlogSearch.php deleted file mode 100644 index b82adb0..0000000 --- a/common/models/BlogSearch.php +++ /dev/null @@ -1,135 +0,0 @@ - date('Y-m-d', 0), - ], - [ - [ - 'date_add_to', - ], - 'default', - 'value' => date('Y-m-d'), - ], - ]; - } - - /** - * @inheritdoc - */ - public function scenarios() - { - // bypass scenarios() implementation in the parent class - return Model::scenarios(); - } - - /** - * Creates data provider instance with search query applied - * - * @param array $params - * - * @return ActiveDataProvider - */ - public function search($params) - { - $query = Blog::find(); - - // add conditions that should always apply here - - $dataProvider = new ActiveDataProvider([ - 'query' => $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; - } - - $query->andWhere([ 'user_id' => \Yii::$app->user->getId() ]); - - // grid filtering conditions - $query->andFilterWhere([ - 'blog_id' => $this->blog_id, - 'date_add' => $this->date_add, - 'user_add_id' => $this->user_add_id, - 'view_count' => $this->view_count, - ]); - - $query->andFilterWhere([ - 'between', - 'date_add', - $this->date_add_from, - (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d') - ]); - - $query->andFilterWhere([ - 'like', - 'name', - $this->name, - ]) - ->andFilterWhere([ - 'like', - 'description', - $this->description, - ]) - ->andFilterWhere([ - 'like', - 'cover', - $this->cover, - ]); - - return $dataProvider; - } - - } diff --git a/common/models/Customer.php b/common/models/Customer.php index 8cb51e4..a4e6597 100644 --- a/common/models/Customer.php +++ b/common/models/Customer.php @@ -13,7 +13,6 @@ use Yii; * @property string $name * @property string $surname * @property string $phone - * @property string $date_time * @property string $gender * @property integer $birth_day * @property integer $birth_month @@ -27,9 +26,6 @@ use Yii; * @property integer $created_at * @property integer $updated_at * - * @property ArtboxComment[] $artboxComments - * @property ArtboxCommentRating[] $artboxCommentRatings - * @property ArtboxLike[] $artboxLikes * @property Share[] $shares */ class Customer extends User implements \yii\web\IdentityInterface @@ -49,7 +45,7 @@ class Customer extends User implements \yii\web\IdentityInterface { return [ [['username', 'password_hash'], 'required'], - [['date_time'], 'safe'], + [['password'], 'safe'], [['birth_day', 'birth_month', 'birth_year', 'group_id', 'status', 'created_at', 'updated_at'], 'integer'], [['body'], 'string'], [['status'],'default', 'value' => '10'], @@ -69,7 +65,6 @@ class Customer extends User implements \yii\web\IdentityInterface 'name' => 'Name', 'surname' => 'Surname', 'phone' => 'Phone', - 'date_time' => 'Date Time', 'gender' => 'Gender', 'birth_day' => 'Birth Day', 'birth_month' => 'Birth Month', @@ -88,30 +83,6 @@ class Customer extends User implements \yii\web\IdentityInterface /** * @return \yii\db\ActiveQuery */ - public function getArtboxComments() - { - return $this->hasMany(ArtboxComment::className(), ['user_id' => 'id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArtboxCommentRatings() - { - return $this->hasMany(ArtboxCommentRating::className(), ['user_id' => 'id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArtboxLikes() - { - return $this->hasMany(ArtboxLike::className(), ['user_id' => 'id']); - } - - /** - * @return \yii\db\ActiveQuery - */ public function getShares() { return $this->hasMany(Share::className(), ['user_id' => 'id']); @@ -132,5 +103,8 @@ class Customer extends User implements \yii\web\IdentityInterface return $this->username. ' '.$this->surname; } + public function getPassword() { + return false; + } } diff --git a/common/models/CustomerSearch.php b/common/models/CustomerSearch.php index 2798c95..431f6c9 100644 --- a/common/models/CustomerSearch.php +++ b/common/models/CustomerSearch.php @@ -19,7 +19,7 @@ class CustomerSearch extends Customer { return [ [['id', 'birth_day', 'birth_month', 'birth_year', 'group_id'], 'integer'], - [['username', 'name', 'surname', 'phone', 'date_time', 'body'], 'safe'], + [['username', 'name', 'surname', 'phone', 'body'], 'safe'], ]; } @@ -60,7 +60,6 @@ class CustomerSearch extends Customer // grid filtering conditions $query->andFilterWhere([ 'id' => $this->id, - 'date_time' => $this->date_time, 'birth_day' => $this->birth_day, 'birth_month' => $this->birth_month, 'birth_year' => $this->birth_year, diff --git a/common/models/Event.php b/common/models/Event.php index 7f34b95..c49e402 100644 --- a/common/models/Event.php +++ b/common/models/Event.php @@ -46,7 +46,7 @@ class Event extends \yii\db\ActiveRecord 'translit' => true ], [ - 'class' => 'common\behaviors\ShowImage', + 'class' => 'common\behaviors\ShowImage', ], ]; } diff --git a/common/models/Fields.php b/common/models/Fields.php deleted file mode 100644 index 3db277b..0000000 --- a/common/models/Fields.php +++ /dev/null @@ -1,155 +0,0 @@ - 255] - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'table_name' => 'Model Name', - 'table_id' => 'Model ID', - 'value' => 'Value', - 'field_name' => 'Field Name', - 'language' => 'Language', - ]; - } - - public static function getData($id, $model, $type){ - $data = ArrayHelper::toArray(self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->all()); - $result = []; - for($i=0; $i < count($data); $i ++){ - $result[$data[$i]['parent_key']][$data[$i]['field_name']] = $data[$i]['value']; - } - - return $result; - } - - - /** - * @param $post - array with field data - * @param $table_id - row id in model table - * @param $table_name - madel table name - * @param $language - language id - */ - - public static function saveFieldData($post,$table_id,$table_name, $language){ - - self::deleteAll(['table_id'=>$table_id, 'table_name'=>$table_name, 'language' => $language, 'field_type' => array_keys($post)]); - - if($post){ - - - foreach($post as $k => $field){ - - - - foreach($field as $parent_key => $row){ - - foreach($row as $key => $value){ - - $field_model = new Fields(); - $field_model->field_name = array_keys($value)[0]; - $field_model->value = $value[array_keys($value)[0]]; - $field_model->table_name = $table_name; - $field_model->table_id = $table_id; - $field_model->field_type = $k; - $field_model->language = 'ru'; - $field_model->parent_key = $parent_key; - $field_model->key = $key; - $field_model->save(); - } - - } - } - } - } - - - /** - * @param $post - array with field data - * @param $table_id - row id in model table - * @param $table_name - madel table name - * @param $language - language id - */ - - public static function saveFieldVideoData($post,$table_id,$table_name, $language){ - - self::deleteAll(['table_id'=>$table_id, 'table_name'=>$table_name, 'language' => $language, 'field_type' => array_keys($post)]); - - if($post){ - - - foreach($post as $k => $field){ - - - - foreach($field as $parent_key => $row){ - - foreach($row as $key => $value){ - - preg_match('/src=\"(.[^"]*)\"/', $value[array_keys($value)[0]], $video_url); - - if(isset($video_url[1]) && !empty($video_url[1])){ - - $field_model = new Fields(); - $field_model->field_name = array_keys($value)[0]; - $field_model->value = $video_url[1].'?showinfo=0&autoplay=0'; - $field_model->table_name = $table_name; - $field_model->table_id = $table_id; - $field_model->field_type = $k; - $field_model->language = 'ru'; - $field_model->parent_key = $parent_key; - $field_model->key = $key; - $field_model->save(); - - } - - - } - - } - } - } - } -} diff --git a/common/models/Orders.php b/common/models/Orders.php index 5685b4c..55df71b 100644 --- a/common/models/Orders.php +++ b/common/models/Orders.php @@ -49,6 +49,26 @@ 'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/', 'on' => self::SCENARIO_QUICK, ], + [ + [ + 'phone2', + 'numbercard', + 'body', + 'declaration', + 'stock', + 'consignment', + 'payment', + 'insurance', + 'amount_imposed', + 'shipping_by', + 'city', + 'adress', + 'total', + 'status', + ], + 'string', + 'max' => 255, + ], ]; } diff --git a/common/models/Page.php b/common/models/Page.php index bac6703..1bf0df5 100644 --- a/common/models/Page.php +++ b/common/models/Page.php @@ -1,76 +1,104 @@ [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'title', + 'out_attribute' => 'translit', + 'translit' => true, + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'body', + 'seo_text', + ], + 'string', + ], + [ + [ + 'translit', + 'title', + 'meta_title', + 'meta_keywords', + 'meta_description', + 'h1', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'in_menu', + ], + 'boolean', + ], + ]; + } + + public function getPageTranslit($page) + { + return self::find() + ->where([ 'translit' => $page ]) + ->one(); + + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'translit' => 'Translit', + 'title' => 'Title', + 'body' => 'Body', + 'meta_title' => 'Meta Title', + 'meta_keywords' => 'Meta Keywords', + 'meta_description' => 'Meta Description', + 'seo_text' => 'Seo Text', + 'h1' => 'H1', + 'in_menu' => 'Show in menu', + ]; + } } - /** - * @inheritdoc - */ - public function behaviors() - { - return [ - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'title', - 'out_attribute' => 'translit', - 'translit' => true - ] - ]; - } - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['body', 'seo_text'], 'string'], - [['translit', 'title', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255], - ]; - } - public function getPageTranslit($page){ - return self::find() - ->where(['translit' => $page]) - ->one(); - - } - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'translit' => 'Translit', - 'title' => 'Title', - 'body' => 'Body', - 'meta_title' => 'Meta Title', - 'meta_keywords' => 'Meta Keywords', - 'meta_description' => 'Meta Description', - 'seo_text' => 'Seo Text', - 'h1' => 'H1', - ]; - } -} diff --git a/common/models/PageSearch.php b/common/models/PageSearch.php index a914813..3123ec7 100644 --- a/common/models/PageSearch.php +++ b/common/models/PageSearch.php @@ -2,10 +2,8 @@ namespace common\models; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use common\models\Page; /** * PageSearch represents the model behind the search form about `common\models\Page`. diff --git a/common/models/Project.php b/common/models/Project.php new file mode 100644 index 0000000..59eeb12 --- /dev/null +++ b/common/models/Project.php @@ -0,0 +1,140 @@ + [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'title', + 'out_attribute' => 'link', + 'translit' => true + ], + ]; + } + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [['date_add'], 'default', 'value' => function() { + return time(); + }], + [['title'], 'required'], + [['description'], 'string'], + [['date_add', 'imagesUpload'], 'safe'], + [['title', 'link'], 'string', 'max' => 255], + [['date_add'], 'filter', 'filter' => function($value) { + return strtotime($value)?:time(); + }], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'project_id' => 'Project ID', + 'title' => 'Title', + 'link' => 'Link', + 'description' => 'Description', + 'date_add' => 'Date Add', + 'images' => 'Images', + ]; + } + + public function getImages() + { + return $this->hasMany(ProjectImage::className(), [ 'project_id' => 'project_id' ]); + } + + public function getImagesHTML() + { + $op = []; + if($this->images) { + foreach($this->images as $image) { + $op[] = \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'admin_thumb'); + } + } + return $op; + } + + public function getImagesConfig() + { + $op = []; + if($this->images) { + foreach($this->images as $image) { + $op[] = [ + 'caption' => $image->image, + 'width' => '120px', + 'url' => \yii\helpers\Url::to([ + '/project/delimg', + 'id' => $image->project_image_id, + ]), + 'key' => $image->project_image_id, + 'extra' => [ + 'id' => $image->project_image_id, + ], + ]; + } + } + return $op; + } + + public function imagesUpload() + { + if($this->validate()) { + $images = []; + foreach($this->imagesUpload as $image) { + $imageName = $image->baseName . '.' . $image->extension; + $i = 0; + while(file_exists(\Yii::getAlias('@storage/projects/' . $imageName))) { + $i++; + $imageName = $image->baseName . '_' . $i . '.' . $image->extension; + } + $imgDir = \Yii::getAlias('@storage/projects/'); + if(!is_dir($imgDir)) { + mkdir($imgDir, 0755, true); + } + + $image->saveAs($imgDir . $imageName); + $images[] = $imageName; + } + return $images; + } else { + return false; + } + } +} diff --git a/common/models/ProjectImage.php b/common/models/ProjectImage.php new file mode 100644 index 0000000..a2a6814 --- /dev/null +++ b/common/models/ProjectImage.php @@ -0,0 +1,109 @@ + 255], + [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'project_id']], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'project_image_id' => 'Project Image ID', + 'project_id' => 'Project ID', + 'image' => 'Image', + 'alt' => 'Alt', + 'title' => 'Title', + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProject() + { + return $this->hasOne(Project::className(), ['project_id' => 'project_id']); + } + + /** + * fetch stored image file name with complete path + * @return string + */ + public function getImageFile() + { + return isset($this->image) ? '/storage/projects/' . $this->image : null; + } + + /** + * fetch stored image url + * @return string + */ + public function getImageUrl() + { + // return a default image placeholder if your source image is not found + return isset($this->image) ? '/storage/projects/'. $this->image : '/storage/no-photo.png'; + } + + public function deleteImage() { + $file = $this->getImageFile(); + + // check if file exists on server + if (empty($file) || !file_exists($file)) { + return false; + } + + // check if uploaded file can be deleted on server + if (!unlink($file)) { + return false; + } + + // if deletion successful, reset your file attributes + $this->image = null; + $this->filename = null; + + return true; + } + + public function beforeDelete() + { + if (parent::beforeDelete()) { + $this->deleteImage(); + return true; + } else { + return false; + } + } +} diff --git a/common/models/ProjectSearch.php b/common/models/ProjectSearch.php new file mode 100644 index 0000000..040014a --- /dev/null +++ b/common/models/ProjectSearch.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([ + 'project_id' => $this->project_id, + 'date_add' => $this->date_add, + ]); + + $query->andFilterWhere(['like', 'title', $this->title]) + ->andFilterWhere(['like', 'link', $this->link]) + ->andFilterWhere(['like', 'description', $this->description]); + + return $dataProvider; + } +} diff --git a/common/modules/blog/Module.php b/common/modules/blog/Module.php deleted file mode 100644 index 4b46c45..0000000 --- a/common/modules/blog/Module.php +++ /dev/null @@ -1,15 +0,0 @@ - [[0 => property(свойство обьекта), ... дополнительные - * настройки]], ...[]] - * - */ - public $attributes; - - /** - * События - * - * События на которые должно срабатывать поведение. Задается ассоциативный массив, в котором ключ - событие - * связанного обьекта, а значение - метод, который вызывается при этом событии - * - * @return array [key(event) => val(method)] - * - */ - public function events() - { - return [ - ActiveRecord::EVENT_BEFORE_INSERT => 'autocomplete', - ActiveRecord::EVENT_BEFORE_UPDATE => 'autocomplete', - ]; - } - - /** - * События - * - * События на которые должно срабатывать поведение. Задается ассоциативный массив, в котором ключ - событие - * связанного обьекта, а значение - метод, который вызывается при этом событии - * Доступные автозаполнения: - * ['translit' => ['prop1', ... 'prop2']], - * где prop - свойство подлежащее транслитерации - * ['repeat' => [[string 'prop1', string 'target1', boolean 'skipFilled', int 'count', boolean 'truncate', string 'suffix'], ...[]], - * где prop - свойство для преобразования, - * target - свойство с которого взять данные, - * count - число для преобразования, - * skipFilled - пропустить непустые, - * truncate - true - обрезать по словам, false - по символам, - * suffix - суффикс, который добавить после обрезки - * - * @param mixed $event Yii обьект свойста https://github.com/yiisoft/yii2/blob/master/docs/guide-ru/concept-events.md - * - */ - public function autocomplete($event) - { - if(!empty($this->attributes['translit'])) { - foreach($this->attributes['translit'] as $translit) { - if($this->owner->hasAttribute($translit)) { - $this->owner->$translit = Tools::translit($this->owner->$translit); - } - } - } - if(!empty($this->attributes['repeat'])) { - foreach($this->attributes['repeat'] as $repeat) { - if(is_array($repeat) && $this->owner->hasAttribute($repeat[0]) && $this->owner->hasAttribute($repeat[1]) && is_int($repeat[3]) && (empty($this->owner->$repeat[0]) || $repeat[2])) { - $suffix = $repeat[5]?:''; - $truncate = $repeat[4]?'truncateWords':'truncate'; - $this->owner->$repeat[0] = StringHelper::$truncate($this->owner->$repeat[1], $repeat[3], $suffix); - } - } - } - } -} \ No newline at end of file diff --git a/common/modules/blog/config.php b/common/modules/blog/config.php deleted file mode 100644 index 8a7e162..0000000 --- a/common/modules/blog/config.php +++ /dev/null @@ -1,9 +0,0 @@ - [ - - ], - 'params' => [ - 'test' => 'Hello', - ], -]; diff --git a/common/modules/blog/controllers/AjaxController.php b/common/modules/blog/controllers/AjaxController.php deleted file mode 100644 index 6e6ebcd..0000000 --- a/common/modules/blog/controllers/AjaxController.php +++ /dev/null @@ -1,133 +0,0 @@ -request->getIsAjax()) { - //throw new ForbiddenHttpException('Permission denied'); - } - - if(!parent::beforeAction($action)) { - return false; - } - - return true; - } - - public function actionCategoryForm($language_id, $widget_id) - { - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one(); - if(!$model) { - throw new NotFoundHttpException('Language not found'); - } - $category_lang = new ArticleCategoryLang(); - return $this->renderAjax('_category_form', ['model' => $model, 'category_lang' => $category_lang, 'widget_id' => $widget_id]); - } - - public function actionArticleForm($language_id, $widget_id) - { - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one(); - if(!$model) { - throw new NotFoundHttpException('Language not found'); - } - $article_lang = new ArticleLang(); - return $this->renderAjax('_article_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id]); - } - - public function actionArticleMediaForm($language_id, $widget_id, $type) - { - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one(); - if(!$model) { - throw new NotFoundHttpException('Language not found'); - } - if(!in_array($type, ['full', 'preview'])) { - throw new InvalidParamException('Type must only be full/preview'); - } - $article_lang = new ArticleMedia(); - return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]); - } - - public function actionArticleCategoryMediaForm($language_id, $widget_id, $type) - { - $model = Language::find()->where(['>=', 'language_id', 1])->andWhere(['status' => 1, 'language_id' => $language_id])->one(); - if(!$model) { - throw new NotFoundHttpException('Language not found'); - } - if(!in_array($type, ['full', 'preview'])) { - throw new InvalidParamException('Type must only be full/preview'); - } - $article_lang = new ArticleCategoryMedia(); - return $this->renderAjax('_article_media_form', ['model' => $model, 'article_lang' => $article_lang, 'widget_id' => $widget_id, 'type' => $type]); - } - - public function actionRemoveImage() - { - $post = \Yii::$app->request->post(); - if(!empty($post['article_media_id'])) { - $article_media = ArticleMedia::findOne($post['article_media_id']); - if($post['remove_media']) { - $media = $article_media->media->delete(); - } - if(!empty($article_media)) { - $article_media->delete(); - } - return true; - } else { - return false; - } - } - - public function actionRemoveCategoryImage() - { - $post = \Yii::$app->request->post(); - if(!empty($post['category_media_id'])) { - $category_media = ArticleCategoryMedia::findOne($post['category_media_id']); - if($post['remove_media']) { - $media = $category_media->media->delete(); - } - if(!empty($category_media)) { - $category_media->delete(); - } - return true; - } else { - return false; - } - } - - public function actionRemoveImageCategory() - { - $post = \Yii::$app->request->post(); - if(!empty($post['category_media_id'])) { - $category_media = ArticleCategoryMedia::findOne($post['category_media_id']); - if($post['remove_media']) { - $media = $category_media->media->delete(); - } - if(!empty($category_media)) { - $category_media->delete(); - } - return true; - } else { - return false; - } - } - - public function actionMultilangForm($model, $ajaxView, $widget_id, $language_id = NULL) - { - $model = new $model(['language_id' => $language_id]); - return $this->renderAjax($ajaxView, ['model' => $model, 'widget_id' => $widget_id]); - } - -} diff --git a/common/modules/blog/controllers/ArticleController.php b/common/modules/blog/controllers/ArticleController.php deleted file mode 100644 index c5f18ab..0000000 --- a/common/modules/blog/controllers/ArticleController.php +++ /dev/null @@ -1,228 +0,0 @@ - Article::find(), - 'pagination' => [ - 'pageSize' => 1, - ], - ]); - return $this->render('index', ['dataProvider' => $dataProvider]); - } - - public function actionCreate() - { - $article_langs = array(); - $article = new Article(); - $default_lang = Language::getDefaultLang(); - $images = array(); - $images[$default_lang->language_id]['full'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_FULL]); - $images[$default_lang->language_id]['preview'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_PREVIEW]); - $images[0]['additional'] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); - $article->loadDefaultValues(); - $langs = Language::getActiveLanguages(); - $isValid = false; - if(!empty(\Yii::$app->request->post())) { - $isValid = true; - $article->load(\Yii::$app->request->post()); - $article->user_id = \Yii::$app->user->getId(); - $isValid = $article->validate(); - foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) { - foreach($value as $type => $fields) { - $images[$lang][$type] = new ArticleMedia(['scenario' => $type]); - $images[$lang][$type]->type = $type; - $images[$lang][$type]->language_id = $lang; - $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); - $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; - } - } - $images[0]['additional']->language_id = 0; - $images[0]['additional']->type = 'additional'; - $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile"); - if(empty(\Yii::$app->request->post()['ArticleLang'])) { - $article_langs[$default_lang->language_id] = new ArticleLang(); - $isValid = ArticleLang::validateMultiple($article_langs) && $isValid; - } else { - foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) { - $article_langs[$index] = new ArticleLang(); - } - ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post()); - $isValid = ArticleLang::validateMultiple($article_langs) && $isValid; - } - } else { - $article_langs[$default_lang->language_id] = new ArticleLang(); - } - if($isValid) { - $article->save(false); - $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray']; - if(!empty($article_categories)) { - foreach($article_categories as $article_category) { - $articletocategory[$article_category] = new ArticleToCategory(); - $articletocategory[$article_category]->article_category_id = $article_category; - $articletocategory[$article_category]->link('article', $article); - } - } - $first = 1; - foreach($images as $lang => $value) { - foreach($value as $type => $fields) { - $images[$lang][$type]->upload($article->article_id); - if($first && $type != 'additional') { - $media_clone = clone $images[$lang][$type]; - $media_clone->setIsNewRecord(true); - unset($media_clone->article_media_id); - $media_clone->language_id = 0; - $media_clone->upload($article->article_id); - unset($media_clone); - $first = 0; - } - } - } - $first = 1; - foreach($article_langs as $article_lang) { - if($first) { - $article_lang_clone = clone $article_lang; - $article_lang_clone->language_id = 0; - $article_lang_clone->link('article', $article); - unset($article_lang_clone); - } - $article_lang->link('article', $article); - $first = 0; - } - echo "ok"; - //$this->redirect('index'); - } else { - return $this->render('create', [ - 'article_langs' => $article_langs, - 'article' => $article, - 'langs' => $langs, - 'images' => $images - ]); - } - } - - public function actionUpdate($id) - { - $article = Article::findOne($id); - $imagestack = $article->getArticleMedia()->all(); - $images = []; - $images[0]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); - $images[0]['additional'][0]->type = 'additional'; - $images[0]['additional'][0]->language_id = 0; - foreach($imagestack as $image) { - if(in_array($image->type, ['full', 'preview'])) { - $images[$image->language_id][$image->type] = $image; - $images[$image->language_id][$image->type]->scenario = $image->type; - } else { - $images[$image->language_id][$image->type][$image->article_media_id] = $image; - $images[$image->language_id][$image->type][$image->article_media_id]->scenario = $image->type; - } - } - foreach($images as $lang => $value) { - $images[$lang]['additional'][0] = new ArticleMedia(['scenario' => ArticleMedia::SCENARIO_ADDITIONAL]); - } - $article_langs = $article->getArticleLangs()->where(['>=', 'language_id', '1'])->indexBy('language_id')->all(); - $langs = Language::getActiveLanguages(); - $default_lang = Language::getDefaultLang(); - $isValid = false; - if(!empty(\Yii::$app->request->post())) { - $isValid = true; - $article->load(\Yii::$app->request->post()); - ArticleToCategory::deleteAll(['article_id' => $article->article_id]); - $article_categories = \Yii::$app->request->post('Article')['articleCategoriesArray']; - if(!empty($article_categories)) { - foreach($article_categories as $article_category) { - $articletocategory[$article_category] = new ArticleToCategory(); - $articletocategory[$article_category]->article_category_id = $article_category; - $articletocategory[$article_category]->link('article', $article); - } - } - $isValid = $article->validate(); - $images[0]['additional'][0]->type = 'additional'; - $images[0]['additional'][0]->language_id = 0; - $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile"); - $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid; - foreach(\Yii::$app->request->post()['ArticleMedia'] as $lang => $value) { - foreach($value as $type => $fields) { - if(!in_array($type, ['full', 'preview'])) continue; - $images[$lang][$type] = new ArticleMedia(['scenario' => $type]); - $images[$lang][$type]->language_id = $lang; - $images[$lang][$type]->type = $type; - $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); - $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; - } - } - if(empty(\Yii::$app->request->post()['ArticleLang'])) { - $isValid = ArticleLang::validateMultiple($article_langs) && $isValid; - } else { - foreach(\Yii::$app->request->post()['ArticleLang'] as $index => $article_lang) { - if (!array_key_exists($index, $article_langs)) { - $article_langs[$index] = new ArticleLang(); - $article_langs[$index]->article_id = $article->article_id; - } - } - ArticleLang::loadMultiple($article_langs, \Yii::$app->request->post()); - $isValid = ArticleLang::validateMultiple($article_langs) && $isValid; - } - } - if($isValid) { - $article->save(false); - foreach($images as $lang => $value) { - foreach($value as $type => $fields) { - if($type == 'additional') { - $images[$lang][$type][0]->upload($article->id); - } else { - if(!empty($images[$lang][$type]->imageFile)) { - $images[$lang][$type]->replace($article->article_id); - } - } - } - } - foreach($article_langs as $article_lang) { - $article_lang->save(false); - } - echo "ok"; - //$this->redirect('index'); - } else { - return $this->render('update', [ - 'article_langs' => $article_langs, - 'article' => $article, - 'langs' => $langs, - 'images' => $images - ]); - } - } - - public function actionDelete($id) - { - $this->findModel($id)->delete(); - return $this->redirect(['index']); - } - - protected function findModel($id) - { - if (($model = Article::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } -} diff --git a/common/modules/blog/controllers/CategoryController.php b/common/modules/blog/controllers/CategoryController.php deleted file mode 100644 index 505f5b8..0000000 --- a/common/modules/blog/controllers/CategoryController.php +++ /dev/null @@ -1,219 +0,0 @@ - [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['post'] - ] - ] - ]; - } - - public function actionIndex() - { - $dataProvider = new ActiveDataProvider([ - 'query' => ArticleCategory::find(), - 'pagination' => [ - 'pageSize' => 1, - ], - ]); - return $this->render('index', ['dataProvider' => $dataProvider]); - } - - public function actionCreate() - { - $category_langs = array(); - $category = new ArticleCategory(); - $default_lang = Language::getDefaultLang(); - $images = array(); - $images[$default_lang->language_id]['full'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_FULL]); - $images[$default_lang->language_id]['preview'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_PREVIEW]); - $images[0]['additional'] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); - $category->loadDefaultValues(); - $langs = Language::getActiveLanguages(); - $isValid = false; - if(!empty(\Yii::$app->request->post())) { - $isValid = true; - $category->load(\Yii::$app->request->post()); - $isValid = $category->validate(); - foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) { - foreach($value as $type => $fields) { - $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]); - $images[$lang][$type]->type = $type; - $images[$lang][$type]->language_id = $lang; - $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); - $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; - } - } - $images[0]['additional']->language_id = 0; - $images[0]['additional']->type = 'additional'; - $images[0]['additional']->imageFile = UploadedFile::getInstances($images[0]['additional'], "[0][additional]imageFile"); - if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) { - $category_langs[$default_lang->language_id] = new ArticleCategoryLang(); - $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid; - } else { - foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) { - $category_langs[$index] = new ArticleCategoryLang(); - } - ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post()); - $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid; - } - } else { - $category_langs[$default_lang->language_id] = new ArticleCategoryLang(); - } - if($isValid) { - $category->save(false); - $first = 1; - foreach($images as $lang => $value) { - foreach($value as $type => $fields) { - $images[$lang][$type]->upload($category->article_category_id); - if($first && $type != 'additional') { - $media_clone = clone $images[$lang][$type]; - $media_clone->setIsNewRecord(true); - unset($media_clone->article_category_media_id); - $media_clone->language_id = 0; - $media_clone->upload($category->article_category_id); - unset($media_clone); - $first = 0; - } - } - } - $first = 1; - foreach($category_langs as $category_lang) { - if($first) { - $category_lang_clone = clone $category_lang; - $category_lang_clone->language_id = 0; - $category_lang_clone->link('category', $category); - unset($category_lang_clone); - } - $category_lang->link('category', $category); - $first = 0; - } - echo "ok"; - //$this->redirect('index'); - } else { - return $this->render('create', [ - 'category_langs' => $category_langs, - 'category' => $category, - 'langs' => $langs, - 'images' => $images - ]); - } - } - - public function actionUpdate($id) - { - $category = ArticleCategory::findOne($id); - $imagestack = $category->getArticleCategoryMedia()->all(); - $images = []; - $images[0]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); - $images[0]['additional'][0]->type = 'additional'; - $images[0]['additional'][0]->language_id = 0; - foreach($imagestack as $image) { - if(in_array($image->type, ['full', 'preview'])) { - $images[$image->language_id][$image->type] = $image; - $images[$image->language_id][$image->type]->scenario = $image->type; - } else { - $images[$image->language_id][$image->type][$image->article_category_media_id] = $image; - $images[$image->language_id][$image->type][$image->article_category_media_id]->scenario = $image->type; - } - } - foreach($images as $lang => $value) { - $images[$lang]['additional'][0] = new ArticleCategoryMedia(['scenario' => ArticleCategoryMedia::SCENARIO_ADDITIONAL]); - } - $category_langs = $category->getArticleCategoryLangs()->where(['>=', 'language_id', '1'])->indexBy('language_id')->all(); - $langs = Language::getActiveLanguages(); - $default_lang = Language::getDefaultLang(); - $isValid = false; - if(!empty(\Yii::$app->request->post())) { - $isValid = true; - $category->load(\Yii::$app->request->post()); - $isValid = $category->validate(); - $images[0]['additional'][0]->type = 'additional'; - $images[0]['additional'][0]->language_id = 0; - $images[0]['additional'][0]->imageFile = UploadedFile::getInstances($images[0]['additional'][0], "[0][additional]imageFile"); - $isValid = $images[0]['additional'][0]->validate(['imageFile']) && $isValid; - foreach(\Yii::$app->request->post()['ArticleCategoryMedia'] as $lang => $value) { - foreach($value as $type => $fields) { - if(!in_array($type, ['full', 'preview'])) continue; - $images[$lang][$type] = new ArticleCategoryMedia(['scenario' => $type]); - $images[$lang][$type]->language_id = $lang; - $images[$lang][$type]->type = $type; - $images[$lang][$type]->imageFile = UploadedFile::getInstance($images[$lang][$type], "[{$lang}][{$type}]imageFile"); - $isValid = $images[$lang][$type]->validate(['imageFile']) && $isValid; - } - } - if(empty(\Yii::$app->request->post()['ArticleCategoryLang'])) { - $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid; - } else { - foreach(\Yii::$app->request->post()['ArticleCategoryLang'] as $index => $category_lang) { - if(!array_key_exists($index, $category_langs)) { - $category_langs[$index] = new ArticleCategoryLang(); - $category_langs[$index]->article_category_id = $category->article_category_id; - } - } - ArticleCategoryLang::loadMultiple($category_langs, \Yii::$app->request->post()); - $isValid = ArticleCategoryLang::validateMultiple($category_langs) && $isValid; - } - } - if($isValid) { - $category->save(false); - foreach($images as $lang => $value) { - foreach($value as $type => $fields) { - if($type == 'additional') { - $images[$lang][$type][0]->upload($category->article_category_id); - } else { - if(!empty($images[$lang][$type]->imageFile)) { - $images[$lang][$type]->replace($category->article_category_id); - } - } - } - } - foreach($category_langs as $category_lang) { - $category_lang->save(false); - } - echo "ok"; - //$this->redirect('index'); - } else { - return $this->render('update', [ - 'category_langs' => $category_langs, - 'category' => $category, - 'langs' => $langs, - 'images' => $images - ]); - } - } - - public function actionDelete($id) - { - $this->findModel($id)->delete(); - return $this->redirect(['index']); - } - - protected function findModel($id) - { - if (($model = ArticleCategory::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } -} diff --git a/common/modules/blog/controllers/DefaultController.php b/common/modules/blog/controllers/DefaultController.php deleted file mode 100644 index 81604e5..0000000 --- a/common/modules/blog/controllers/DefaultController.php +++ /dev/null @@ -1,12 +0,0 @@ -render('index'); - } -} diff --git a/common/modules/blog/controllers/MediaController.php b/common/modules/blog/controllers/MediaController.php deleted file mode 100644 index 43e7920..0000000 --- a/common/modules/blog/controllers/MediaController.php +++ /dev/null @@ -1,45 +0,0 @@ -request->isPost) { - $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); - if($model->upload()) { - return true; - } else { - return false; - } - } - return $this->render('index', ['model' => $model]); - } - - public function actionCreate() - { - - } - - public function actionUpdate($id) - { - - } - - public function actionDelete($id) - { - $model = Media::findOne($id); - return $model->delete(); - } - - protected function findModel($id) - { - - } -} diff --git a/common/modules/blog/controllers/TestController.php b/common/modules/blog/controllers/TestController.php deleted file mode 100644 index 3039a12..0000000 --- a/common/modules/blog/controllers/TestController.php +++ /dev/null @@ -1,17 +0,0 @@ -language_id] = new ArticleLang(); - $model[3] = new ArticleLang(); - return $this->render('index', ['model' => $model]); - } -} \ No newline at end of file diff --git a/common/modules/blog/models/Article.php b/common/modules/blog/models/Article.php deleted file mode 100644 index 75c636d..0000000 --- a/common/modules/blog/models/Article.php +++ /dev/null @@ -1,163 +0,0 @@ - Autocomplete::className(), - 'attributes' => [ - 'translit' => ['code'], - ] - ] - ]; - } - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['sort', 'article_pid', 'status', 'comment', 'vote'], 'integer'], - [['date_add', 'date_update'], 'safe'], - [['code'], 'required'], - [['code', 'tag'], 'string'] - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'article_id' => Yii::t('app', 'ID'), - 'sort' => Yii::t('app', 'Sort'), - 'date_add' => Yii::t('app', 'Create At'), - 'date_update' => Yii::t('app', 'Update At'), - 'code' => Yii::t('app', 'Code'), - 'user_id' => Yii::t('app', 'Author'), - 'tag' => Yii::t('app', 'Tags'), - 'article_pid' => Yii::t('app', 'Parent ID'), - 'status' => Yii::t('app', 'Active'), - 'comment' => Yii::t('app', 'Comments'), - 'vote' => Yii::t('app', 'Voting'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getParent() - { - return $this->hasOne(Article::className(), ['article_id' => 'article_pid']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticles() - { - return $this->hasMany(Article::className(), ['article_pid' => 'article_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getUser() - { - return $this->hasOne(User::className(), ['id' => 'user_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticleLangs() - { - return $this->hasMany(ArticleLang::className(), ['article_id' => 'article_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticleMedia() - { - return $this->hasMany(ArticleMedia::className(), ['article_id' => 'article_id']); - } - - public function getMedia() - { - return $this->hasMany(Media::className(), ['article_id' => 'media_id'])->via('articleMedia'); - } - /** - * @return \yii\db\ActiveQuery - */ - public function getArticleToCategories() - { - return $this->hasMany(ArticleToCategory::className(), ['article_id' => 'article_id']); - } - - public function getArticleCategories() - { - return $this->hasMany(ArticleCategory::className(), ['article_category_id' => 'article_category_id'])->viaTable('article_to_category', ['article_id' => 'article_category_id']); - } - - public static function findArticleDropdown($id) - { - $query = new Query(); - return $query->select(['l.name', 'a.article_id']) - ->from(['article a']) - ->leftJoin(['article_lang l'], 'a.article_id = l.article_id') - ->where(['l.language_id' => 0, 'a.status' => 1]) - ->andWhere(['not', ['a.article_id' => $id]]) - ->indexBy('article_id') - ->column(); - } - - public function getArticleCategoriesArray() - { - return $this->getArticleToCategories()->select('article_category_id')->column(); - } - -} diff --git a/common/modules/blog/models/ArticleCategory.php b/common/modules/blog/models/ArticleCategory.php deleted file mode 100644 index 411c61a..0000000 --- a/common/modules/blog/models/ArticleCategory.php +++ /dev/null @@ -1,133 +0,0 @@ - Autocomplete::className(), - 'attributes' => [ - 'translit' => ['code'], - ] - ] - ]; - } - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['status', 'sort', 'article_category_pid'], 'integer'], - [['code'], 'required'], - [['code', 'tag'], 'string'], - [['date_add', 'date_update'], 'safe'], - [['status'], 'boolean'], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'article_category_id' => Yii::t('app', 'ID'), - 'status' => Yii::t('app', 'Active'), - 'sort' => Yii::t('app', 'Sort'), - 'code' => Yii::t('app', 'Code'), - 'date_add' => Yii::t('app', 'Created At'), - 'date_update' => Yii::t('app', 'Updated At'), - 'tag' => Yii::t('app', 'Tags'), - 'article_category_pid' => Yii::t('app', 'Parent ID'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticles() - { - return $this->hasMany(Article::className(), ['article_id' => 'article_id'])->viaTable('article_to_category', ['article_category_id' => 'article_category_id']) ; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getParent() - { - return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_pid']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticleCategories() - { - return $this->hasMany(ArticleCategory::className(), ['article_category_pid' => 'article_category_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticleCategoryLangs() - { - return $this->hasMany(ArticleCategoryLang::className(), ['article_category_id' => 'article_category_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticleCategoryMedia() - { - return $this->hasMany(ArticleCategoryMedia::className(), ['article_category_id' => 'article_category_id']); - } - - public static function findArticleCategoryDropdown($id) - { - $query = new Query(); - return $query->select(['l.name', 'c.article_category_id']) - ->from(['article_category c']) - ->leftJoin(['article_category_lang l'], 'c.article_category_id = l.article_category_id') - ->where(['l.language_id' => 0, 'c.status' => 1]) - ->andWhere(['not', ['c.article_category_id' => $id]]) - ->indexBy('article_category_id') - ->column(); - } - -} diff --git a/common/modules/blog/models/ArticleCategoryLang.php b/common/modules/blog/models/ArticleCategoryLang.php deleted file mode 100644 index 748f9c1..0000000 --- a/common/modules/blog/models/ArticleCategoryLang.php +++ /dev/null @@ -1,102 +0,0 @@ - Autocomplete::className(), - 'attributes' => [ - 'repeat' => [['preview', 'text', false, 5, true, '...']], - ] - ] - ]; - } - /** - * @inheritdoc - */ - public function rules() - { - return [ - [['language_id', 'article_category_id'], 'integer'], - [['text', 'name'], 'required'], - [['text', 'preview', 'seo_url', 'name', 'meta_title', 'meta_descr', 'meta_keyword', 'h1_tag', 'tag'], 'string'], - ['seo_url', function($attribute, $params) { - $pattern = "/^[a-zA-Z\d_-]+$/"; - if(!preg_match($pattern, $this->$attribute)) { - $this->addError($attribute, Yii::t('app', "Pattern doesn't match.")); - } - }] - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'article_category_language_id' => Yii::t('app', 'ID'), - 'language_id' => Yii::t('app', 'Lang ID'), - 'article_category_id' => Yii::t('app', 'Category ID'), - 'text' => Yii::t('app', 'Text'), - 'preview' => Yii::t('app', 'Preview'), - 'seo_url' => Yii::t('app', 'Seo Url'), - 'name' => Yii::t('app', 'Name'), - 'meta_title' => Yii::t('app', 'Meta Title'), - 'meta_descr' => Yii::t('app', 'Meta Descr'), - 'meta_keyword' => Yii::t('app', 'Meta Keywords'), - 'h1_tag' => Yii::t('app', 'H1 Tag'), - 'tag' => Yii::t('app', 'Tags'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getCategory() - { - return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLang() - { - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); - } -} diff --git a/common/modules/blog/models/ArticleCategoryMedia.php b/common/modules/blog/models/ArticleCategoryMedia.php deleted file mode 100644 index a8c135c..0000000 --- a/common/modules/blog/models/ArticleCategoryMedia.php +++ /dev/null @@ -1,162 +0,0 @@ - 10], - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL], - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_PREVIEW], - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'maxFiles' => 10, 'on' => self::SCENARIO_ADDITIONAL] - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'article_category_media_id' => Yii::t('app', 'ID'), - 'article_category_id' => Yii::t('app', 'Category ID'), - 'media_id' => Yii::t('app', 'Media ID'), - 'media_alt' => Yii::t('app', 'Media Alt'), - 'media_title' => Yii::t('app', 'Media Title'), - 'media_caption' => Yii::t('app', 'Media Caption'), - 'type' => Yii::t('app', 'Type'), - 'imageFile' => Yii::t('app', 'Image File'), - 'language_id' => Yii::t('app', 'Language ID'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getCategory() - { - return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getMedia() - { - return $this->hasOne(Media::className(), ['media_id' => 'media_id']); - } - - public function upload($category_id) - { - $this->article_category_id = $category_id; - if(is_array($this->imageFile)) { - $ok = true; - foreach($this->imageFile as $image) { - $media_category = clone $this; - $media = new Media(); - $media->imageFile = $image; - $media->upload(); - $media_category->media_id = $media->media_id; - $ok = $media_category->save() && $ok; - unset($media_category); - } - return $ok; - } elseif(!empty($this->imageFile)) { - $media = new Media(); - $media->imageFile = $this->imageFile; - $media->upload(); - $this->media_id = $media->media_id; - return $this->save(); - } - } - - public function replace($category_id, $removeMedia = false) - { - $this->article_category_id = $category_id; - if($removeMedia) { - $category_media = ArticleCategoryMedia::find()->select('media_id')->where(['article_category_id' => $this->article_category_id, 'type' => $this->type])->column(); - $media = array(); - foreach($category_media as $media_id) { - $media[] = Media::findOne(['media_id' => $media_id]); - } - $media = array_unique($media); - foreach($media as $one_media) { - if($one_media instanceof Media) { - $one_media->delete(); - } - } - unset($media); - unset($category_media); - } - if(is_array($this->imageFile)) { - $ok = true; - foreach($this->imageFile as $image) { - $media_category = clone $this; - $media = new Media(); - $media->imageFile = $image; - $media->upload(); - $media_category->media_id = $media->media_id; - $ok = $media_category->save() && $ok; - unset($media_category); - } - return $ok; - } elseif(!empty($this->imageFile)) { - ArticleCategoryMedia::deleteAll(['category_id' => $this->article_category_id, 'type' => $this->type]); - $media = new Media(); - $media->imageFile = $this->imageFile; - $media->upload(); - $this->media_id = $media->media_id; - $this->setIsNewRecord(true); - return $this->save(); - } - } - -} diff --git a/common/modules/blog/models/ArticleLang.php b/common/modules/blog/models/ArticleLang.php deleted file mode 100644 index 94bf761..0000000 --- a/common/modules/blog/models/ArticleLang.php +++ /dev/null @@ -1,85 +0,0 @@ - Yii::t('app', 'ID'), - 'language_id' => Yii::t('app', 'Lang ID'), - 'article_id' => Yii::t('app', 'Article ID'), - 'text' => Yii::t('app', 'Text'), - 'seo_url' => Yii::t('app', 'Seo Url'), - 'name' => Yii::t('app', 'Name'), - 'preview' => Yii::t('app', 'Preview'), - 'meta_title' => Yii::t('app', 'Meta Title'), - 'meta_descr' => Yii::t('app', 'Meta Descr'), - 'meta_keyword' => Yii::t('app', 'Meta Keywords'), - 'h1_tag' => Yii::t('app', 'H1 Tag'), - 'tag' => Yii::t('app', 'Tags'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticle() - { - return $this->hasOne(Article::className(), ['article_id' => 'article_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getLang() - { - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); - } -} diff --git a/common/modules/blog/models/ArticleMedia.php b/common/modules/blog/models/ArticleMedia.php deleted file mode 100644 index 977f8a8..0000000 --- a/common/modules/blog/models/ArticleMedia.php +++ /dev/null @@ -1,161 +0,0 @@ - 10], - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_FULL], - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'on' => self::SCENARIO_PREVIEW], - [['imageFile'], 'file', 'extensions' => 'png, gif, jpg, jpeg', 'skipOnEmpty' => true, 'maxFiles' => 10, 'on' => self::SCENARIO_ADDITIONAL] - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'article_media_id' => Yii::t('app', 'ID'), - 'article_id' => Yii::t('app', 'Article ID'), - 'media_id' => Yii::t('app', 'Media ID'), - 'type' => Yii::t('app', 'Type'), - 'media_alt' => Yii::t('app', 'Media Alt'), - 'media_title' => Yii::t('app', 'Media Title'), - 'media_caption' => Yii::t('app', 'Media Caption'), - 'imageFile' => Yii::t('app', 'Image File'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticle() - { - return $this->hasOne(Article::className(), ['article_id' => 'article_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getMedia() - { - return $this->hasOne(Media::className(), ['media_id' => 'media_id']); - } - - public function upload($article_id) - { - $this->article_id = $article_id; - if(is_array($this->imageFile)) { - $ok = true; - foreach($this->imageFile as $image) { - $media_article = clone $this; - $media = new Media(); - $media->imageFile = $image; - $media->upload(); - $media_article->media_id = $media->media_id; - $ok = $media_article->save() && $ok; - unset($media_article); - } - return $ok; - } elseif(!empty($this->imageFile)) { - $media = new Media(); - $media->imageFile = $this->imageFile; - $media->upload(); - $this->media_id = $media->media_id; - return $this->save(); - } - } - - public function replace($article_id, $removeMedia = false) - { - $this->article_id = $article_id; - if($removeMedia && !$this->getIsNewRecord()) { - $article_media = ArticleMedia::find()->select('media_id')->where(['article_id' => $this->article_id, 'type' => $this->type, 'language_id' => $this->language_id])->column(); - $media = array(); - foreach($article_media as $media_id) { - $media[] = Media::findOne(['media_id' => $media_id]); - } - $media = array_unique($media); - foreach($media as $one_media) { - if($one_media instanceof Media) { - $one_media->delete(); - } - } - unset($media); - unset($article_media); - } - if(is_array($this->imageFile)) { - $ok = true; - foreach($this->imageFile as $image) { - $media_article = clone $this; - $media = new Media(); - $media->imageFile = $image; - $media->upload(); - $media_article->media_id = $media->media_id; - $ok = $media_article->save() && $ok; - unset($media_article); - } - return $ok; - } elseif(!empty($this->imageFile)) { - ArticleMedia::deleteAll(['article_id' => $this->article_id, 'type' => $this->type, 'language_id' => $this->language_id]); - $media = new Media(); - $media->imageFile = $this->imageFile; - $media->upload(); - $this->media_id = $media->media_id; - $this->setIsNewRecord(true); - return $this->save(); - } - } - -} diff --git a/common/modules/blog/models/ArticleToCategory.php b/common/modules/blog/models/ArticleToCategory.php deleted file mode 100644 index 3032fde..0000000 --- a/common/modules/blog/models/ArticleToCategory.php +++ /dev/null @@ -1,62 +0,0 @@ - Yii::t('app', 'Article ID'), - 'article_category_id' => Yii::t('app', 'Category ID'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getArticle() - { - return $this->hasOne(Article::className(), ['article_id' => 'article_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getCategory() - { - return $this->hasOne(ArticleCategory::className(), ['article_category_id' => 'article_category_id']); - } -} diff --git a/common/modules/blog/views/ajax/_article_form.php b/common/modules/blog/views/ajax/_article_form.php deleted file mode 100644 index 22f8b05..0000000 --- a/common/modules/blog/views/ajax/_article_form.php +++ /dev/null @@ -1,38 +0,0 @@ - -
- - $model, 'attribute' => "[$model->language_id]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> - - $model, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> - - $model, 'attribute' => "[$model->language_id]preview", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> - - $model, 'attribute' => "[$model->language_id]seo_url"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]name"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]meta_title"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?> - - $model, 'attribute' => "[$model->language_id]meta_keyword"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]tag"]))->textInput() ?> - -
-end(); - } -?> diff --git a/common/modules/blog/views/ajax/_article_form_test.php b/common/modules/blog/views/ajax/_article_form_test.php deleted file mode 100644 index 237311e..0000000 --- a/common/modules/blog/views/ajax/_article_form_test.php +++ /dev/null @@ -1,38 +0,0 @@ - -
- - $model, 'attribute' => "[$model->language_id]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> - - $model, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> - - $model, 'attribute' => "[$model->language_id]preview", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> - - $model, 'attribute' => "[$model->language_id]seo_url"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]name"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]meta_title"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?> - - $model, 'attribute' => "[$model->language_id]meta_keyword"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?> - - $model, 'attribute' => "[$model->language_id]tag"]))->textInput() ?> - -
-end(); - } -?> diff --git a/common/modules/blog/views/ajax/_article_media_form.php b/common/modules/blog/views/ajax/_article_media_form.php deleted file mode 100644 index 6058444..0000000 --- a/common/modules/blog/views/ajax/_article_media_form.php +++ /dev/null @@ -1,17 +0,0 @@ - -
- - $article_lang, 'attribute' => "[$model->language_id][$type]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> - - $article_lang, 'attribute' => "[$model->language_id][$type]imageFile"]))->fileInput(['class' => 'image_inputs_field']) ?> - -
-end(); -?> diff --git a/common/modules/blog/views/ajax/_category_form.php b/common/modules/blog/views/ajax/_category_form.php deleted file mode 100644 index cff9b7e..0000000 --- a/common/modules/blog/views/ajax/_category_form.php +++ /dev/null @@ -1,33 +0,0 @@ - -
- - $category_lang, 'attribute' => "[$model->language_id]language_id"]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> - - $category_lang, 'attribute' => "[$model->language_id]text", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> - - $category_lang, 'attribute' => "[$model->language_id]preview", 'form' => $form]))->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ]]); ?> - - $category_lang, 'attribute' => "[$model->language_id]seo_url"]))->textInput() ?> - - $category_lang, 'attribute' => "[$model->language_id]name"]))->textInput() ?> - - $category_lang, 'attribute' => "[$model->language_id]meta_title"]))->textInput() ?> - - $category_lang, 'attribute' => "[$model->language_id]meta_descr"]))->textarea() ?> - - $category_lang, 'attribute' => "[$model->language_id]meta_keyword"]))->textInput() ?> - - $category_lang, 'attribute' => "[$model->language_id]h1_tag"]))->textInput() ?> - - $category_lang, 'attribute' => "[$model->language_id]tag"]))->textInput() ?> - -
-end(); -?> diff --git a/common/modules/blog/views/article/_form.php b/common/modules/blog/views/article/_form.php deleted file mode 100644 index 71d165e..0000000 --- a/common/modules/blog/views/article/_form.php +++ /dev/null @@ -1,172 +0,0 @@ - -
- - ['enctype' => 'multipart/form-data']]); ?> - - field($article, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?> - - field($article, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> - - field($article, 'sort')->input('number') ?> - - field($article, 'article_pid') - ->dropDownList(Article::findArticleDropdown($article->article_id), ['prompt' => Yii::t('app', 'Select parent')]) ?> - - field($article, 'articleCategoriesArray') - ->dropDownList(ArticleCategory::findArticleCategoryDropdown(NULL), ['multiple' => 'multiple'])->label(\Yii::t('app', 'Article Categories Array')); ?> - - field($article, 'status')->checkbox() ?> - - -
-
- Url::to(['/blog/ajax/article-media-form?type=full']), - 'form' => $form, - 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'full'])->indexBy('language_id')->all() - ]); - $first = 1; - foreach($images as $lang => $value) { - if(!array_key_exists('full', $value)) continue; - ?> -
- field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]); - echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']); - if(!empty($images[$lang]['full']->article_media_id)) { - echo "media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>"; - } - ?> -
- end(); - ?> -
-
- Url::to(['/blog/ajax/article-media-form?type=preview']), - 'form' => $form, - 'data_langs' => $article->getIsNewRecord()?$images:ArticleMedia::find()->where(['article_id' => $article->article_id, 'type' => 'preview'])->indexBy('language_id')->all() - ]); - $first = 1; - foreach($images as $lang => $value) { - if(!array_key_exists('preview', $value)) continue; - ?> -
- field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]); - echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']); - if(!empty($images[$lang]['preview']->article_media_id)) { - echo "media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>"; - } - ?> -
- end(); - ?> -
-
- field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']); - if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) { - foreach($images[0]['additional'] as $onefield => $oneimage) { - if($onefield) { - ?> - - -
-
- -
- - $article_langs, - 'form' => $form, - 'ajaxView' => '@common/modules/blog/views/ajax/_article_form', - ]); - /* - $multilang = Multilang::begin(['ajaxpath' => Url::to(['/blog/ajax/article-form']), 'form' => $form, 'data_langs' => $article_langs]); - ?> - $article_lang) { - ?> -
- - field($article_langs[$index], "[$index]language_id")->label(false)->hiddenInput(['value' => $index]) ?> - - field($article_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> - - field($article_langs[$index], "[$index]preview")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> - - field($article_langs[$index], "[$index]seo_url")->textInput() ?> - - field($article_langs[$index], "[$index]name")->textInput() ?> - - field($article_langs[$index], "[$index]meta_title")->textInput() ?> - - field($article_langs[$index], "[$index]meta_descr")->textarea(); ?> - - field($article_langs[$index], "[$index]meta_keywords")->textInput() ?> - - field($article_langs[$index], "[$index]h1_tag")->textInput() ?> - - field($article_langs[$index], "[$index]tags")->textInput() ?> - -
- - end(); - */ - ?> - -
- isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $article->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> -
- - - -
- \ No newline at end of file diff --git a/common/modules/blog/views/article/create.php b/common/modules/blog/views/article/create.php deleted file mode 100644 index 1524640..0000000 --- a/common/modules/blog/views/article/create.php +++ /dev/null @@ -1,19 +0,0 @@ -title = Yii::t('app', 'Article create'); -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Articles'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- - render('_form', [ - 'article_langs' => $article_langs, - 'article' => $article, - 'langs' => $langs, - 'images' => $images - ]) ?> - -
diff --git a/common/modules/blog/views/article/index.php b/common/modules/blog/views/article/index.php deleted file mode 100644 index 8229525..0000000 --- a/common/modules/blog/views/article/index.php +++ /dev/null @@ -1,32 +0,0 @@ - $dataProvider, - 'columns' => [ - 'article_id', - 'code', - 'date_add', - [ - 'value' => function($data) { - return $data->user->firstname.' '.$data->user->lastname; - }, - 'header' => Yii::t('app', 'Author') - ], - [ - 'class' => Column::className(), - 'header' => Yii::t('app', 'Name'), - 'content' => function($model, $key, $index, $column) { - return $model->getArticleLangs()->where(['language_id' => Language::getDefaultLang()->language_id])->one()->name; - } - ], - [ - 'class' => ActionColumn::className(), - 'template' => '{update} {delete}' - ] - ] -]); \ No newline at end of file diff --git a/common/modules/blog/views/article/update.php b/common/modules/blog/views/article/update.php deleted file mode 100644 index 12f4704..0000000 --- a/common/modules/blog/views/article/update.php +++ /dev/null @@ -1,18 +0,0 @@ -title = Yii::t('app', 'Article update'); -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Articles'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- render('_form', [ - 'article_langs' => $article_langs, - 'article' => $article, - 'langs' => $langs, - 'images' => $images - ]) ?> - -
diff --git a/common/modules/blog/views/category/_form.php b/common/modules/blog/views/category/_form.php deleted file mode 100644 index 71c0d42..0000000 --- a/common/modules/blog/views/category/_form.php +++ /dev/null @@ -1,158 +0,0 @@ - -
- - ['enctype' => 'multipart/form-data']]); ?> - - field($category, 'code')->hint(Yii::t('app', 'Insensitive latin non-space'))->textInput() ?> - - field($category, 'tag')->hint(Yii::t('app', 'Comma-separated'))->textInput() ?> - - field($category, 'sort')->input('number') ?> - - field($category, 'article_category_pid') - ->dropDownList(ArticleCategory::findArticleCategoryDropdown($category->article_category_id), ['prompt' => Yii::t('app', 'Select parent')]) ?> - - field($category, 'status')->checkbox() ?> - - -
-
- Url::to(['/blog/ajax/article-category-media-form?type=full']), - 'form' => $form, - 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'full'])->indexBy('language_id')->all() - ]); - $first = 1; - foreach($images as $lang => $value) { - if(!array_key_exists('full', $value)) continue; - ?> -
- field($images[$lang]['full'], "[{$lang}][full]language_id")->label(false)->hiddenInput(['value' => $lang]); - echo $form->field($images[$lang]['full'], "[{$lang}][full]imageFile")->fileInput(['class' => 'image_inputs_field']); - if(!empty($images[$lang]['full']->article_category_media_id)) { - echo "media->hash}/original.{$images[$lang]['full']->media->extension}' width='100' class='image_inputs_prev'>"; - } - ?> -
- end(); - ?> -
-
- Url::to(['/blog/ajax/article-category-media-form?type=preview']), - 'form' => $form, - 'data_langs' => $category->getIsNewRecord()?$images:ArticleCategoryMedia::find()->where(['article_category_id' => $category->article_category_id, 'type' => 'preview'])->indexBy('language_id')->all() - ]); - $first = 1; - foreach($images as $lang => $value) { - if(!array_key_exists('preview', $value)) continue; - ?> -
- field($images[$lang]['preview'], "[{$lang}][preview]language_id")->label(false)->hiddenInput(['value' => $lang]); - echo $form->field($images[$lang]['preview'], "[{$lang}][preview]imageFile")->fileInput(['class' => 'image_inputs_field']); - if(!empty($images[$lang]['preview']->article_category_media_id)) { - echo "media->hash}/original.{$images[$lang]['preview']->media->extension}' width='100' class='image_inputs_prev'>"; - } - ?> -
- end(); - ?> -
-
- field(is_array($images[0]['additional'])?$images[0]['additional'][0]:$images[0]['additional'], "[0][additional]imageFile[]")->fileInput(['multiple' => 'multiple', 'class' => 'image_inputs_field']); - if(is_array($images[0]['additional']) && count($images[0]['additional']) > 1) { - foreach($images[0]['additional'] as $onefield => $oneimage) { - if($onefield) { - ?> - - -
-
- -
- - Url::to(['/blog/ajax/category-form']), 'form' => $form, 'data_langs' => $category_langs]) - ?> - $category_lang) { - ?> -
- field($category_langs[$index], "[$index]language_id")->label(false)->hiddenInput(['value' => $index]) ?> - - field($category_langs[$index], "[$index]text")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> - - field($category_langs[$index], "[$index]preview")->widget(CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> - - field($category_langs[$index], "[$index]seo_url")->textInput() ?> - - field($category_langs[$index], "[$index]name")->textInput() ?> - - field($category_langs[$index], "[$index]meta_title")->textInput() ?> - - field($category_langs[$index], "[$index]meta_descr")->textarea(); ?> - - field($category_langs[$index], "[$index]meta_keyword")->textInput() ?> - - field($category_langs[$index], "[$index]h1_tag")->textInput() ?> - - field($category_langs[$index], "[$index]tag")->textInput() ?> - -
- - end(); - ?> - -
- isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $category->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> -
- - - -
- \ No newline at end of file diff --git a/common/modules/blog/views/category/create.php b/common/modules/blog/views/category/create.php deleted file mode 100644 index dc19a6f..0000000 --- a/common/modules/blog/views/category/create.php +++ /dev/null @@ -1,19 +0,0 @@ -title = Yii::t('app', 'Category create'); -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Categories'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- - render('_form', [ - 'category_langs' => $category_langs, - 'category' => $category, - 'langs' => $langs, - 'images' => $images - ]) ?> - -
diff --git a/common/modules/blog/views/category/index.php b/common/modules/blog/views/category/index.php deleted file mode 100644 index dce7f03..0000000 --- a/common/modules/blog/views/category/index.php +++ /dev/null @@ -1,26 +0,0 @@ - $dataProvider, - 'columns' => [ - 'article_category_id', - 'code', - 'date_add', - 'date_update', - [ - 'class' => Column::className(), - 'header' => Yii::t('app', 'Name'), - 'content' => function($model, $key, $index, $column) { - return $model->getArticleCategoryLangs()->orderBy(['language_id' => 'ASC'])->one()->name; - } - ], - [ - 'class' => ActionColumn::className(), - 'template' => '{update} {delete}' - ] - ] -]); \ No newline at end of file diff --git a/common/modules/blog/views/category/update.php b/common/modules/blog/views/category/update.php deleted file mode 100644 index 57e81e3..0000000 --- a/common/modules/blog/views/category/update.php +++ /dev/null @@ -1,18 +0,0 @@ -title = Yii::t('app', 'Update category'); -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Categories'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- render('_form', [ - 'category_langs' => $category_langs, - 'category' => $category, - 'langs' => $langs, - 'images' => $images - ]) ?> - -
diff --git a/common/modules/blog/views/default/index.php b/common/modules/blog/views/default/index.php deleted file mode 100644 index efb5c35..0000000 --- a/common/modules/blog/views/default/index.php +++ /dev/null @@ -1,7 +0,0 @@ -value); \ No newline at end of file diff --git a/common/modules/blog/views/media/index.php b/common/modules/blog/views/media/index.php deleted file mode 100644 index e536935..0000000 --- a/common/modules/blog/views/media/index.php +++ /dev/null @@ -1,37 +0,0 @@ - ['enctype' => 'multipart/form-data']]); - -echo $form->field($model, 'imageFile')->fileInput(['multiple' => 'multiple']); - -?> - your image -
- 'btn btn-success']) ?> -
- - diff --git a/common/modules/blog/views/test/index.php b/common/modules/blog/views/test/index.php deleted file mode 100644 index f24ade0..0000000 --- a/common/modules/blog/views/test/index.php +++ /dev/null @@ -1,11 +0,0 @@ - $model, - 'form' => $form, - 'ajaxView' => '@common/modules/blog/views/ajax/_article_form_test', -]); -$form->end(); \ No newline at end of file diff --git a/common/modules/product/CatalogUrlManager.php b/common/modules/product/CatalogUrlManager.php index 227b497..bc52f41 100644 --- a/common/modules/product/CatalogUrlManager.php +++ b/common/modules/product/CatalogUrlManager.php @@ -5,8 +5,6 @@ namespace common\modules\product; use common\modules\product\models\CategorySearch; use common\modules\product\models\ProductSearch; - -use Yii; use yii\helpers\Url; use yii\web\HttpException; use yii\web\UrlRuleInterface; diff --git a/common/modules/product/behaviors/FilterBehavior.php b/common/modules/product/behaviors/FilterBehavior.php index 26a3b0a..fbf90cc 100644 --- a/common/modules/product/behaviors/FilterBehavior.php +++ b/common/modules/product/behaviors/FilterBehavior.php @@ -4,18 +4,20 @@ namespace common\modules\product\behaviors; use common\modules\product\models\ProductOption; -use common\modules\rubrication\models\TaxGroup; use common\modules\rubrication\models\TaxOption; use yii\base\Behavior; - -use Yii; - +use yii\db\ActiveRecord; class FilterBehavior extends Behavior { public function getFilters(){ - - return $this->owner->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id']) + + /** + * @var ActiveRecord $owner + */ + $owner = $this->owner; + + return $owner->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id']) ->viaTable(ProductOption::tableName(),[ 'product_id'=> $this->owner->tableSchema->primaryKey[0]]) ->joinWith('taxGroup')->all(); } diff --git a/common/modules/product/controllers/ManageController.php b/common/modules/product/controllers/ManageController.php index a799a6b..bb8a8c1 100644 --- a/common/modules/product/controllers/ManageController.php +++ b/common/modules/product/controllers/ManageController.php @@ -1,276 +1,298 @@ [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => [ 'POST' ], + ], ], - ], - ]; - } - - public function actionDev() { - foreach (ProductVariant::find()->where(['>', 'price_old', 0])->all() as $item) { - if ($item->price >= $item->price_old || $item->price == 0) - print $item->price .' | '. $item->price_old ."
\n"; + ]; + } + + public function actionDev() + { + foreach(ProductVariant::find() + ->where([ + '>', + 'price_old', + 0, + ]) + ->all() as $item) { + if($item->price >= $item->price_old || $item->price == 0) { + print $item->price . ' | ' . $item->price_old . "
\n"; + } + } + print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'; } - print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'; - } - - /** - * Lists all Product models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new ProductSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single Product model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Product model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new Product(); - if ($model->load(Yii::$app->request->post())) { - $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); - - if ($model->save() && $model->imagesUpload) { - - $imgDir = Yii::getAlias('@storage/articles/'); - - if ( ($images = $model->imagesUpload()) !== FALSE) { - foreach ($images as $image) { - $imageModel = new ProductImage(); - $imageModel->product_id = $model->product_id; - $imageModel->image = $image; - $imageModel->save(); + /** + * Lists all Product models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ProductSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Product model. + * + * @param integer $id + * + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Product model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Product(); + + if($model->load(Yii::$app->request->post())) { + $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); + + if($model->save()) { + + if(!empty( $model->imagesUpload ) && ( ( $images = $model->imagesUpload() ) !== false )) { + foreach($images as $image) { + $imageModel = new ProductImage(); + $imageModel->product_id = $model->product_id; + $imageModel->image = $image; + $imageModel->save(); + } } + + return $this->redirect([ + 'view', + 'id' => $model->product_id, + ]); } - - return $this->redirect(['view', 'id' => $model->product_id]); } - } else { return $this->render('create', [ 'model' => $model, ]); } - } - - /** - * Updates an existing Product 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->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); - if ($model->save()) { -// foreach ($model->images as $image) { -// $image->delete(); -// } - if ( ($images = $model->imagesUpload()) !== FALSE) { - foreach ($images as $image) { - $imageModel = new ProductImage(); - $imageModel->product_id = $model->product_id; - $imageModel->image = $image; - $imageModel->save(); + + /** + * Updates an existing Product 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->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); + if($model->save()) { + if(!empty( $model->imagesUpload ) && ( ( $images = $model->imagesUpload() ) !== false )) { + foreach($images as $image) { + $imageModel = new ProductImage(); + $imageModel->product_id = $model->product_id; + $imageModel->image = $image; + $imageModel->save(); + } } + + return $this->redirect([ + 'view', + 'id' => $model->product_id, + ]); } - - return $this->redirect(['view', 'id' => $model->product_id]); } - } else { $groups = $model->getTaxGroupsByLevel(0); - + return $this->render('update', [ - 'model' => $model, + 'model' => $model, 'groups' => $groups, ]); } - } - - /** - * Deletes an existing Product 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']); - } - - public function actionDelimg($id) - { - $image = ProductImage::findOne($id); - - if ($image) { - $image->delete(); + + /** + * Deletes an existing Product 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' ]); } - - print '1'; - exit; - } - - public function actionIs_top($id) { - $model = $this->findModel($id); - - $model->is_top = intval(empty($model->is_top)); - - $model->save(false, ['is_top']); - - return $this->redirect(['index']); - } - - public function actionIs_new($id) { - $model = $this->findModel($id); - - $model->is_new = intval(empty($model->is_new)); - - $model->save(false, ['is_new']); - - return $this->redirect(['index']); - } - - public function actionAkciya($id) { - $model = $this->findModel($id); - - $model->akciya = intval(empty($model->akciya)); - - $model->save(false, ['akciya']); - - return $this->redirect(['index']); - } - - public function actionImport() { - $model = new Import(); - - if ($model->load(Yii::$app->request->post())) { - $file = UploadedFile::getInstances($model, 'file'); - $method = 'go'. ucfirst($model->type); - $target = Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFile'. ucfirst($model->type)); - if (empty($file)) { - $model->errors[] = 'File not upload'; - } elseif ($method == 'goPrices' && $file[0]->name != 'file_1.csv') { - $model->errors[] = 'File need "file_1.csv"'; - } elseif ($method == 'goProducts' && $file[0]->name == 'file_1.csv') { - $model->errors[] = 'File can not "file_1.csv"'; - } elseif ($model->validate() && $file[0]->saveAs($target)) { - // PROCESS PAGE - return $this->render('import-process', [ - 'model' => $model, - 'method' => $model->type, - 'target' => $target, - ]); -// $model->$method(); - } else { - $model->errors[] = 'File can not be upload or other error'; + + public function actionDelimg($id) + { + $image = ProductImage::findOne($id); + + if($image) { + $image->delete(); } + + print '1'; + exit; } - - return $this->render('import', [ - 'model' => $model, - ]); - } - - public function actionProducts() { - $from = Yii::$app->request->get('from', 0); - - $model = new Import(); - - if (Yii::$app->request->isAjax) { - Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; - return $model->goProducts($from, 10); + + public function actionIs_top($id) + { + $model = $this->findModel($id); + + $model->is_top = intval(empty( $model->is_top )); + + $model->save(false, [ 'is_top' ]); + + return $this->redirect([ 'index' ]); } - } - - public function actionPrices() { - $from = Yii::$app->request->get('from', 0); - - $model = new Import(); - - if (Yii::$app->request->isAjax) { - Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; - return $model->goPrices($from, 10); + + public function actionIs_new($id) + { + $model = $this->findModel($id); + + $model->is_new = intval(empty( $model->is_new )); + + $model->save(false, [ 'is_new' ]); + + return $this->redirect([ 'index' ]); } - } - - public function actionExport() { - $model = new Export(); - if (($file = $model->process(Yii::getAlias('@uploadDir')))) { - return Yii::$app->response->sendFile($file)->send(); + + public function actionAkciya($id) + { + $model = $this->findModel($id); + + $model->akciya = intval(empty( $model->akciya )); + + $model->save(false, [ 'akciya' ]); + + return $this->redirect([ 'index' ]); } - throw new NotFoundHttpException('Error'); - } - - /** - * Finds the Product model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Product the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Product::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); + + public function actionImport() + { + $model = new Import(); + + if($model->load(Yii::$app->request->post())) { + $file = UploadedFile::getInstances($model, 'file'); + $method = 'go' . ucfirst($model->type); + $target = Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFile' . ucfirst($model->type)); + if(empty( $file )) { + $model->errors[] = 'File not upload'; + } elseif($method == 'goPrices' && $file[ 0 ]->name != 'file_1.csv') { + $model->errors[] = 'File need "file_1.csv"'; + } elseif($method == 'goProducts' && $file[ 0 ]->name == 'file_1.csv') { + $model->errors[] = 'File can not "file_1.csv"'; + } elseif($model->validate() && $file[ 0 ]->saveAs($target)) { + // PROCESS PAGE + return $this->render('import-process', [ + 'model' => $model, + 'method' => $model->type, + 'target' => $target, + ]); + // $model->$method(); + } else { + $model->errors[] = 'File can not be upload or other error'; + } + } + + return $this->render('import', [ + 'model' => $model, + ]); + } + + public function actionProducts() + { + $from = Yii::$app->request->get('from', 0); + + $model = new Import(); + + if(Yii::$app->request->isAjax) { + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + return $model->goProducts($from, 10); + } + } + + public function actionPrices() + { + $from = Yii::$app->request->get('from', 0); + + $model = new Import(); + + if(Yii::$app->request->isAjax) { + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + return $model->goPrices($from, 10); + } + } + + public function actionExport() + { + $model = new Export(); + if(( $file = $model->process(Yii::getAlias('@uploadDir')) )) { + return Yii::$app->response->sendFile($file) + ->send(); + } + throw new NotFoundHttpException('Error'); + } + + /** + * Finds the Product model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * + * @param integer $id + * + * @return Product the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if(( $model = Product::findOne($id) ) !== NULL) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } } } -} diff --git a/common/modules/product/controllers/ProductVariantTypeController.php b/common/modules/product/controllers/ProductVariantTypeController.php deleted file mode 100644 index 840f498..0000000 --- a/common/modules/product/controllers/ProductVariantTypeController.php +++ /dev/null @@ -1,124 +0,0 @@ - [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - /** - * Lists all ProductVariantType models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new ProductVariantTypeSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single ProductVariantType model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new ProductVariantType model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new ProductVariantType(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->product_variant_type_id]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); - } - } - - /** - * Updates an existing ProductVariantType 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_variant_type_id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); - } - } - - /** - * Deletes an existing ProductVariantType 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 ProductVariantType model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return ProductVariantType the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = ProductVariantType::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } -} diff --git a/common/modules/product/controllers/VariantController.php b/common/modules/product/controllers/VariantController.php index 4d0ca7b..35acda2 100644 --- a/common/modules/product/controllers/VariantController.php +++ b/common/modules/product/controllers/VariantController.php @@ -9,6 +9,7 @@ use common\modules\product\models\ProductVariant; use common\modules\product\models\ProductVariantListSearch; use common\modules\product\models\Stock; use Yii; +use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -82,16 +83,80 @@ class VariantController extends Controller $model->validate(); if ($model->save()) { - - if ( ($images = $model->imagesUpload()) !== FALSE) { - foreach ($images as $image) { + + 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; + $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]); } @@ -150,41 +215,50 @@ class VariantController extends Controller $ProductStocks = Yii::$app->request->post('ProductStock'); - $quantity = 0; - - if(is_array($ProductStocks)){ - - foreach($ProductStocks as $index => $ProductStock){ - $stock = Stock::find()->where(['name'=>$ProductStock['name']])->one(); - if(!$stock instanceof Stock){ - $stock = new Stock(); - $stock->name = $ProductStock['name']; - $stock->save(); + $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']; + } } - - $psModel = ProductStock::find()->where(['product_variant_id'=>$model->product_variant_id, 'stock_id' =>$stock->stock_id ])->one(); - if(!$psModel instanceof ProductStock){ - $psModel = new ProductStock; - $psModel->load(['ProductStock'=>$ProductStock]); - $psModel->stock_id = $stock->stock_id; - $psModel->product_variant_id = $model->product_variant_id; - $psModel->product_id = $model->product->product_id; - $quantity = $quantity + $psModel->quantity; - $psModel->validate(); - $psModel->save(); + } + $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 { - $psModel->load(['ProductStock'=>$ProductStock]); - $quantity = $quantity + $psModel->quantity; - $psModel->save(); + $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->unlinkAll('stocks', true); } - - $model->stock = $quantity; + $model->stock = $total_quantity; $model->save(); } return $this->redirect(['index', 'product_id'=>$product_id]); diff --git a/common/modules/product/helpers/FilterHelper.php b/common/modules/product/helpers/FilterHelper.php index 9f4a573..e188abb 100644 --- a/common/modules/product/helpers/FilterHelper.php +++ b/common/modules/product/helpers/FilterHelper.php @@ -5,8 +5,6 @@ namespace common\modules\product\helpers; use common\modules\rubrication\models\TaxGroup; use yii\base\Object; -use Yii; -use yii\db\QueryInterface; use yii\helpers\ArrayHelper; class FilterHelper extends Object { diff --git a/common/modules/product/helpers/ProductHelper.php b/common/modules/product/helpers/ProductHelper.php index dfaecc7..f12b200 100644 --- a/common/modules/product/helpers/ProductHelper.php +++ b/common/modules/product/helpers/ProductHelper.php @@ -17,18 +17,15 @@ const PRODUCT_TAX_GROUP_ID_YEAR = 21; const PRODUCT_TAX_GROUP_ID_SEX = 22; - const PRODUCT_VARIANT_TYPE_COLOR = 1; - const PRODUCT_VARIANT_TYPE_SIZE = 2; - public static function getCategories() { return Category::find() - ->getTree(); // with('categoryName')-> + ->getTree(); } public static function getBrands() { - return Brand::find(); // ->with('brandName') + return Brand::find(); } /* @@ -104,6 +101,7 @@ public static function getSpecialProducts($type, $count, $sort = NULL) { + $data = []; switch($type) { case 'top': $data = [ 'is_top' => true ]; @@ -123,7 +121,7 @@ ProductVariant::tableName() . '.stock', 0, ]) - ->limit($count)/*->orderBy($sort)*/ + ->limit($count) ->all(); } @@ -153,8 +151,6 @@ 0, ]) ->andWhere([ 'product_category.category_id' => $product_categories ]); - // $query->andWhere(['>=', 'product_variant.price', $product->enabledVariant->price * 0.7]); - // $query->andWhere(['<=', 'product_variant.price', $product->enabledVariant->price * 1.3]); foreach($product->properties as $group) { $where = [ ]; foreach($group->_options as $option) { @@ -246,23 +242,26 @@ } break; default: + /** + * @todo Refactor this + */ $query->andWhere( Product::tableName() . '.product_id IN ( SELECT DISTINCT products - FROM ( - SELECT product_id AS products - FROM product_option - INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id - INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id - WHERE tax_group.alias LIKE \''. $key .'\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\') OR product_id IN ( - (SELECT product_id AS products - FROM product_variant_option - INNER JOIN product_variant ON product_variant_option.product_variant_id = product_variant.product_variant_id - INNER JOIN tax_option ON tax_option.tax_option_id = product_variant_option.option_id - INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id - WHERE tax_group.alias LIKE \''. $key .'\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\')) - ) - ) AS table_name + FROM ( + SELECT product_id AS products + FROM product_option + INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id + INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id + WHERE tax_group.alias LIKE \''. $key .'\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\') OR product_id IN ( + (SELECT product_id AS products + FROM product_variant_option + INNER JOIN product_variant ON product_variant_option.product_variant_id = product_variant.product_variant_id + INNER JOIN tax_option ON tax_option.tax_option_id = product_variant_option.option_id + INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id + WHERE tax_group.alias LIKE \''. $key .'\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\')) + ) + ) AS table_name )' ); } @@ -270,7 +269,14 @@ } } - + + /** + * @param null|Category $category + * @param array $params + * @param array $excludeKeys + * + * @return ActiveQuery + */ public static function productCountQuery($category = NULL, $params, $excludeKeys = [ ]) { $p = [ ]; diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php index f519631..e795cfa 100644 --- a/common/modules/product/models/Brand.php +++ b/common/modules/product/models/Brand.php @@ -2,9 +2,6 @@ namespace common\modules\product\models; -use common\behaviors\Slug; -use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; -use yii\web\UploadedFile; use Yii; /** @@ -12,7 +9,6 @@ use Yii; * * @property integer $brand_id - * @property integer $brand_name_id * @property string $alias * @property string $image * @property string $meta_title @@ -21,8 +17,6 @@ use Yii; * @property string $seo_text * @property string $name * - * @property BrandName $brandName - * @property BrandName[] $brandNames * @property Product[] $products */ class Brand extends \yii\db\ActiveRecord @@ -59,7 +53,6 @@ class Brand extends \yii\db\ActiveRecord { return [ [['name'], 'string'], - [['brand_name_id'], 'integer'], [['meta_desc', 'seo_text'], 'string'], [['alias', 'name'], 'string', 'max' => 250], [['meta_title', 'image'], 'string', 'max' => 255], @@ -77,7 +70,6 @@ class Brand extends \yii\db\ActiveRecord return [ 'name' => Yii::t('product', 'Name of the brand'), 'brand_id' => Yii::t('product', 'Brand ID'), - 'brand_name_id' => Yii::t('product', 'Brand Name ID'), 'alias' => Yii::t('product', 'Alias'), 'image' => Yii::t('product', 'Image'), 'imageUrl' => Yii::t('product', 'Image'), @@ -99,11 +91,11 @@ class Brand extends \yii\db\ActiveRecord } public function getImageFile() { - return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image); + return empty($this->image) ? null : Yii::getAlias('@imagesDir/brand/'. $this->image); } public function getImageUrl() { - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/brands/' . $this->image); + return empty($this->image) ? null : Yii::getAlias('@imagesUrl/brand/' . $this->image); } } diff --git a/common/modules/product/models/BrandName.php b/common/modules/product/models/BrandName.php deleted file mode 100644 index a495c95..0000000 --- a/common/modules/product/models/BrandName.php +++ /dev/null @@ -1,66 +0,0 @@ - 250], -// [['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => Brand::className(), 'targetAttribute' => ['brand_id' => 'brand_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'brand_name_id' => Yii::t('product', 'Brand Name ID'), - 'brand_id' => Yii::t('product', 'Brand ID'), - 'value' => Yii::t('product', 'Value'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBrands() - { - return $this->hasMany(Brand::className(), ['brand_name_id' => 'brand_name_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBrand() - { - return $this->hasOne(Brand::className(), ['brand_id' => 'brand_id']); - } -} diff --git a/common/modules/product/models/BrandQuery.php b/common/modules/product/models/BrandQuery.php deleted file mode 100644 index 5351a07..0000000 --- a/common/modules/product/models/BrandQuery.php +++ /dev/null @@ -1,47 +0,0 @@ -andWhere('[[status]]=1'); - }*/ - - /** - * @inheritdoc - * @return Brand[]|array - */ - public function all($db = null) - { -// $this->with('brandName'); - return parent::all($db); - } - - /** - * @inheritdoc - * @return Brand|array|null - */ - public function one($db = null) - { -// $this->with('brandName'); - return parent::one($db); - } - - /** - * Select brand by alias - * @param $slug - * @return $this - */ - public function byAlias($alias) - { - $this->andFilterWhere(['alias' => $alias]); - return $this; - } -} diff --git a/common/modules/product/models/BrandSearch.php b/common/modules/product/models/BrandSearch.php index 2d1a204..31ff34e 100644 --- a/common/modules/product/models/BrandSearch.php +++ b/common/modules/product/models/BrandSearch.php @@ -2,12 +2,10 @@ namespace common\modules\product\models; -use common\modules\product\helpers\ProductHelper; -use common\modules\rubrication\models\TaxOption; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use common\modules\product\models\Brand; +use yii\db\ActiveQuery; +use yii\web\NotFoundHttpException; /** * BrandSearch represents the model behind the search form about `common\modules\product\models\Brand`. @@ -21,7 +19,7 @@ class BrandSearch extends Brand public function rules() { return [ - [['brand_id', 'brand_name_id'], 'integer'], + [['brand_id'], 'integer'], [['alias', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'brand_name'], 'safe'], ]; } @@ -44,7 +42,7 @@ class BrandSearch extends Brand */ public function search($params) { - $query = Brand::find(); // ->with('brandName') + $query = Brand::find(); // add conditions that should always apply here @@ -70,7 +68,6 @@ class BrandSearch extends Brand // grid filtering conditions $query->andFilterWhere([ 'brand_id' => $this->brand_id, - 'brand_name_id' => $this->brand_name_id, ]); @@ -84,25 +81,19 @@ class BrandSearch extends Brand $query->andFilterWhere(['ilike', 'name', $this->brand_name]); } - $query->orderBy('brand_id', 'asc'); + $query->orderBy(['brand_id' => SORT_ASC]); return $dataProvider; } - + + /** + * @param null|Category $category + * @param array $params + * @param null|ActiveQuery $productQuery + * + * @return ActiveQuery + */ public function getBrands($category = null, $params = [], $productQuery = null) { -// $queryCount = ProductHelper::productCountQuery($category, $params, ['brands']); - - /*if (!empty($params['prices'])) { - if ($params['prices']['min'] > 0) { - $queryCount->andWhere(['>=', ProductVariant::tableName() .'.price', $params['prices']['min']]); - } - if ($params['prices']['max'] > 0) { - $queryCount->andWhere(['<=', ProductVariant::tableName() .'.price', $params['prices']['max']]); - } - }*/ -// if (!empty($params['options'])) { -// $queryCount->innerJoin(TaxOption::tableName(), TaxOption::tableName()) -// } $query = Brand::find() ->select([ @@ -110,35 +101,7 @@ class BrandSearch extends Brand ]) ->innerJoin(Product::tableName(), Product::tableName() .'.brand_id='. Brand::tableName() .'.brand_id') ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. Product::tableName() .'.product_id'); - - -// $queryCount = Product::find() -// ->select(['COUNT(product.product_id)']) -// ->where('product.brand_id = brand.brand_id'); -// $queryCount->andWhere('(SELECT COUNT(pv.product_variant_id) FROM "product_variant" "pv" WHERE pv.stock != 0 AND pv.product_id = product.product_id) > 0'); -// if (!empty($category)) { -// $queryCount->andWhere('(SELECT COUNT(pc.product_id) FROM product_category pc WHERE pc.product_id = product.product_id AND pc.category_id = '. $category->category_id .') > 0'); -// } -// if (!empty($params['options'])) { -// $queryCount->innerJoin('product_option', 'product_option.product_id = product.product_id'); -// $queryCount->innerJoin('tax_option', 'tax_option.tax_option_id = product_option.option_id'); -// $queryCount->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id'); -// foreach ($params['options'] as $group => $options) { -// $queryCount->andWhere([ -// 'tax_group.alias' => $group, -// 'tax_option.alias' => $options -// ]); -// } -//// $query->addSelect("(SELECT COUNT(product_option.product_id) AS products FROM product_option INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id WHERE tax_group.alias LIKE '$group' AND tax_option.alias IN (" . implode(',', $options) . ")) AS _items_count"); -// } -// $query->addSelect(['_items_count' => $queryCount]); - -// if ($productQuery) { -// $productQuery->select(['COUNT(product.product_id)']); -// $query->addSelect(['_items_count' => $productQuery]); -// } - - + $query->innerJoin('product_variant', 'product_variant.product_id = '. Product::tableName() .'.product_id'); $query->where(['!=', 'product_variant.stock', 0]); $query->groupBy(Product::tableName() .'.product_id'); diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php index d803136..7931aeb 100644 --- a/common/modules/product/models/Category.php +++ b/common/modules/product/models/Category.php @@ -2,15 +2,12 @@ namespace common\modules\product\models; - use common\components\artboxtree\ArtboxTreeBehavior; use common\components\artboxtree\ArtboxTreeHelper; - use common\modules\rubrication\models\TaxGroup; use Yii; use yii\db\Query; -use common\behaviors\Slug; /** * This is the model class for table "category". * @@ -24,16 +21,12 @@ use common\behaviors\Slug; * @property string $meta_desc * @property string $meta_robots * @property string $seo_text - * @property integer $category_name_id * @property integer $product_unit_id * @property string $alias - * @property boolean $populary * @property boolean $name * - * @property CategoryName $categoryName * @property Product[] $products * @property ProductUnit $productUnit - * @property CategoryName[] $categoryNames * @property ProductCategory[] $productCategories */ class Category extends \yii\db\ActiveRecord @@ -73,13 +66,12 @@ class Category extends \yii\db\ActiveRecord { return [ [['name'], 'string'], - [['parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'], + [['parent_id', 'depth', 'product_unit_id'], 'integer'], [['path', 'meta_desc', 'h1', 'seo_text'], 'string'], [['meta_title', 'image'], 'string', 'max' => 255], [['meta_robots'], 'string', 'max' => 50], [['alias', 'name'], 'string', 'max' => 250], - [['populary'], 'boolean'], - [['imageUpload','taxGroup'], 'safe'], + [['imageUpload'], 'safe'], [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], ]; } @@ -103,7 +95,6 @@ class Category extends \yii\db\ActiveRecord 'seo_text' => Yii::t('product', 'Seo Text'), 'product_unit_id' => Yii::t('product', 'Product Unit ID'), 'alias' => Yii::t('product', 'Alias'), - 'populary' => Yii::t('product', 'Populary'), 'name' => Yii::t('product', 'Name'), 'remote_id' => Yii::t('product', 'Remote ID'), ]; @@ -125,7 +116,6 @@ class Category extends \yii\db\ActiveRecord public function getProducts() { return $this->hasMany(Product::className(), ['product_id' => 'product_id']) ->viaTable('product_category', ['category_id' => 'category_id']); -// return $this->getRelations('product_categories'); } @@ -161,9 +151,6 @@ class Category extends \yii\db\ActiveRecord } } - - - public function getImageFile() { return empty($this->image) ? '/images/no_photo.png' : Yii::getAlias('@imagesDir/categories/'. $this->image); } @@ -184,18 +171,7 @@ class Category extends \yii\db\ActiveRecord } return false; } - - public function beforeDelete() - { - - if(!empty($this->products)){ - foreach($this->products as $product){ - $product->delete(); - } - } - ProductCategory::deleteAll(['category_id' => $this->category_id]); - return true; - } + public function getActiveFilters() { $query1 = (new Query()) ->distinct() @@ -208,7 +184,6 @@ 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') - ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id') ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE]) ->andWhere(['!=', 'product_variant.stock', 0]); @@ -223,7 +198,6 @@ 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') - ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id') ->where(['product_category.category_id' => $this->category_id, 'tax_group.is_filter' => TRUE]) ->andWhere(['!=', 'product_variant.stock', 0]); $query3 = (new Query()) @@ -232,14 +206,13 @@ class Category extends \yii\db\ActiveRecord 'tax_group.*', 'tax_option.alias as option_alias', 'tax_group.alias as group_alias', - 'tax_value_string.value as value', + 'tax_option.value as value', 'tax_option.sort AS tax_option_sort', 'tax_group.sort AS tax_group_sort', ]) ->from(['tax_option' ]) ->where(['tax_option.tax_option_id'=>$query1->union($query2)]) ->innerJoin('tax_group','tax_group.tax_group_id = tax_option.tax_group_id') - ->innerJoin('tax_value_string', 'tax_value_string.tax_option_id = tax_option.tax_option_id') ->orderBy('tax_option.sort, tax_group.sort'); return $query3; } @@ -251,7 +224,6 @@ class Category extends \yii\db\ActiveRecord $command = $connection->createCommand(' SELECT ton.alias as option_alias, * FROM tax_option as ton - LEFT JOIN tax_value_string as tvs ON ton.tax_option_id = tvs.tax_option_id RIGHT JOIN tax_group ON ton.tax_group_id = tax_group.tax_group_id RIGHT JOIN tax_group_to_category ON tax_group.tax_group_id = tax_group_to_category.tax_group_id WHERE ton.tax_option_id IN ( diff --git a/common/modules/product/models/CategoryName.php b/common/modules/product/models/CategoryName.php deleted file mode 100644 index e55331e..0000000 --- a/common/modules/product/models/CategoryName.php +++ /dev/null @@ -1,66 +0,0 @@ - 250], - [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'category_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'category_name_id' => Yii::t('product', 'Category Name ID'), - 'category_id' => Yii::t('product', 'Category ID'), - 'value' => Yii::t('product', 'Value'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getCategories() - { - return $this->hasMany(Category::className(), ['category_name_id' => 'category_name_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getCategory() - { - return $this->hasOne(Category::className(), ['category_id' => 'category_id']); - } -} diff --git a/common/modules/product/models/CategoryQuery.php b/common/modules/product/models/CategoryQuery.php index b7abeaa..8d92bef 100644 --- a/common/modules/product/models/CategoryQuery.php +++ b/common/modules/product/models/CategoryQuery.php @@ -32,7 +32,6 @@ class CategoryQuery extends \yii\db\ActiveQuery */ public function one($db = null) { -// $this->joinWith('categoryName'); return parent::one($db); } } diff --git a/common/modules/product/models/CategorySearch.php b/common/modules/product/models/CategorySearch.php index e2ccfd1..b6062ad 100644 --- a/common/modules/product/models/CategorySearch.php +++ b/common/modules/product/models/CategorySearch.php @@ -3,10 +3,8 @@ namespace common\modules\product\models; use common\components\artboxtree\ArtboxTreeHelper; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use common\modules\product\models\Category; use yii\web\NotFoundHttpException; /** @@ -32,8 +30,7 @@ class CategorySearch extends Category public function rules() { return [ - [['category_id', 'parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'], - [['populary'], 'boolean'], + [['category_id', 'parent_id', 'depth', 'product_unit_id'], 'integer'], [['path', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'alias'], 'safe'], ]; } @@ -76,7 +73,6 @@ class CategorySearch extends Category $query->andFilterWhere([ 'category.category_id' => $this->category_id, 'category.parent_id' => $this->parent_id, - 'category.category_name_id' => $this->category_name_id, 'category.product_unit_id' => $this->product_unit_id, ]); @@ -107,8 +103,4 @@ class CategorySearch extends Category } return null; } - -// public static function findByProductsKeywords($keywords = [], $category = null) { -// -// } } diff --git a/common/modules/product/models/Export.php b/common/modules/product/models/Export.php index f4db9d4..aec770f 100644 --- a/common/modules/product/models/Export.php +++ b/common/modules/product/models/Export.php @@ -1,117 +1,91 @@ joinWith(['variants'])->where(['!=', ProductVariant::tableName() .'.stock', 0])->select('product.product_id')->all(); - $products = Product::find() - ->joinWith(['variantsWithFilters','brand','categories'])->with('filters')->all(); - - foreach ($products as $product) + + namespace common\modules\product\models; + + use yii\base\Model; + + class Export extends Model + { + + public $errors = []; + + public $output = []; + + public function process($dirName, $filename = NULL, $use_not_enables = false) { - - - - /*if ($i>1e2) { - break; - }*/ - $mods = []; - - $filterString = $this->convertFilterToString($product->filters); - - foreach ($product->variantsWithFilters as $variant) - { - - $color = $variant->name; - - $mods[] = $variant->sku . - '=' . $this->convertFilterToString($variant->filters) . - '=' . $color . - '=' . ((!empty($variant->image)) ? $variant->image->image: ''). - '=' . $variant->stock; - } - - - $fotos = []; - -// foreach ($product->images as $image) -// { -// $fotos[] = $image->imageUrl; -// } - -// $filters = $product->properties; - $categories = []; - foreach($product->categories as $value){ - - $categories[] = $value->name; - + if(is_null($filename)) { + $filename = 'products_' . date('d_m_Y_H_i') . '.csv'; } - - - $categories = implode(',',$categories); - - $list = [ - - $categories, - $product->brand->name, - $product->name, - '', - ((! empty($product->description)) ? $product->description : ''), - $filterString, - (!empty($product->variant)) ? $product->variant->price_old : '', - (!empty($product->variant)) ? $product->variant->price : '', - intval($product->akciya), - '', - intval($product->is_new), - intval($product->is_top), - $product->video, - implode (',', $fotos), - ]; - - $to_write = array_merge ($list, $mods); - foreach($to_write as &$cell) { - $cell = iconv("UTF-8", "WINDOWS-1251", $cell); + setlocale(LC_ALL, 'ru_RU.CP1251'); + $handle = fopen($dirName . '/' . $filename, "w"); + $products = Product::find() + ->joinWith([ + 'variantsWithFilters', + 'brand', + 'categories', + ]) + ->with('filters') + ->all(); + + foreach($products as $product) { + $mods = []; + $filterString = $this->convertFilterToString($product->filters); + + foreach($product->variantsWithFilters as $variant) { + $color = $variant->name; + $mods[] = $variant->sku . '=' . $this->convertFilterToString($variant->filters) . '=' . $color . '=' . ( ( !empty( $variant->image ) ) ? $variant->image->image : '' ) . '=' . $variant->stock; + } + + $fotos = []; + + $categories = []; + foreach($product->categories as $value) { + $categories[] = $value->name; + } + + $categories = implode(',', $categories); + + $list = [ + $categories, + $product->brand->name, + $product->name, + '', + ( ( !empty( $product->description ) ) ? $product->description : '' ), + $filterString, + ( !empty( $product->variant ) ) ? $product->variant->price_old : '', + ( !empty( $product->variant ) ) ? $product->variant->price : '', + intval($product->akciya), + '', + intval($product->is_new), + intval($product->is_top), + $product->video, + implode(',', $fotos), + ]; + $to_write = array_merge($list, $mods); + foreach($to_write as &$cell) { + $cell = iconv("UTF-8", "WINDOWS-1251", $cell); + } + fputcsv($handle, $to_write, ';'); + unset( $product ); } - - - fputcsv($handle, $to_write, ';'); - unset($product); - - } - - - - fclose ($handle); - - return $dirName .'/'. $filename; - } - - - public function convertFilterToString($filters){ - $fittersArray = []; - foreach($filters as $filter){ - $fittersArray[$filter->taxGroup->alias][] = $filter->name; + + fclose($handle); + + return $dirName . '/' . $filename; } - $filterString=[]; - - foreach($fittersArray as $filterName =>$filterRows ){ - $row = implode(',',$filterRows); - $filterString[] = "[{$filterName}:{$row}]"; - + + public function convertFilterToString($filters) + { + $fittersArray = []; + foreach($filters as $filter) { + $fittersArray[ $filter->taxGroup->alias ][] = $filter->value; + } + $filterString = []; + + foreach($fittersArray as $filterName => $filterRows) { + $row = implode(',', $filterRows); + $filterString[] = "[{$filterName}:{$row}]"; + } + return implode('*', $filterString); } - return implode('*',$filterString); - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/common/modules/product/models/Import.php b/common/modules/product/models/Import.php index 2df4d3c..62934b0 100644 --- a/common/modules/product/models/Import.php +++ b/common/modules/product/models/Import.php @@ -2,20 +2,9 @@ namespace common\modules\product\models; -use common\modules\product\helpers\ProductHelper; -use common\modules\product\models\Category; -use common\modules\product\models\CategoryName; -use common\modules\product\models\ProductImage; -use common\modules\product\models\ProductVariantType; use common\modules\rubrication\models\TaxGroup; use common\modules\rubrication\models\TaxOption; -use common\modules\rubrication\models\TaxValueString; use Yii; -use common\modules\product\models\Brand; -use common\modules\product\models\BrandName; -use common\modules\product\models\Product; -use common\modules\product\models\ProductVariant; -use common\modules\product\models\RemoteProducts; use yii\base\Model; use yii\helpers\ArrayHelper; @@ -34,7 +23,6 @@ class Import extends Model { return [ [['type'], 'required'], [['type'], 'string'], -// [['file'], 'safe'], [['file'], 'file', 'extensions' => 'csv'], ]; } @@ -58,7 +46,6 @@ class Import extends Model { public function goPrices($from = 0, $limit = null) { set_time_limit(0); - $new_products = $linked_products = 0; if ( !($handle = $this->getProductsFile('uploadFilePrices')) ) { $this->errors[] = 'File not found'; @@ -98,35 +85,17 @@ class Import extends Model { // товары в пути if (empty ($city_name)) { -// $this->saveNotFoundRecord ( -// [$modification_code, $product_title], -// Yii::getAlias('@uploadFilePricesAway') -// ); - $this->output[] = 'Товар '. $product_title . ' в пути'; - continue; } if ( ($productVariant = ProductVariant::find()->filterWhere(['sku' => $modification_code])->one()) === null ) { - // 'Нет даной модификации в базе'; -// $this->saveNotFoundRecord ( -// [$modification_code, $product_title], -// Yii::getAlias('@uploadFilePricesNoVariant') -// ); - $this->output[] = 'Для товара '. $product_title . ' не найдено соотвествие'; - continue; } - - - - // ===== Set stock ==== if ( $city_name ) { if ( ($stock = Stock::find()->filterWhere(['name' => trim($city_name)])->one()) === null ) { - // Create stock $stock = new Stock(); $stock->name = trim($city_name); @@ -193,7 +162,6 @@ class Import extends Model { public function goProducts($from = 0, $limit = null) { set_time_limit(0); - $new_products = $linked_products = 0; if ( !($handle = $this->getProductsFile('uploadFileProducts')) ) { $this->errors[] = 'File not found'; @@ -201,8 +169,7 @@ class Import extends Model { } $filesize = filesize(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFileProducts')); - - + if ($from) { fseek($handle, $from); } @@ -215,8 +182,6 @@ class Import extends Model { while (($data = fgetcsv ($handle, 10000, ";")) !== FALSE && (empty($limit) || $j++ < $limit)) { - - foreach ($data as &$value) { if (!$is_utf) { @@ -224,7 +189,6 @@ class Import extends Model { } $value = trim ($value); } - // будет всегда 19 элементов for ($i = 0; $i <= 18; $i++) { @@ -233,8 +197,6 @@ class Import extends Model { $data[$i] = null; } } - - // 1 Группа (категория) $catalog_names = explode(',',$data[0]); if (empty ($catalog_names)) @@ -288,8 +250,7 @@ class Import extends Model { // 15 Топ продаж $product_top = (bool)$data[11]; - - + // 17 ВИДЕО КОД $product_video = $data[12]; @@ -310,6 +271,8 @@ class Import extends Model { $is_new_product = empty($_product->product_id); + $category_id = []; + foreach($catalog_names as $catalog_name){ // ==== Set category ==== if ( ($category = Category::find()->filterWhere(['ilike', 'name', trim($catalog_name)])->one()) === null ) { @@ -318,15 +281,16 @@ class Import extends Model { $category->name = trim($catalog_name); $category->save(); } - $category_id[] = $category->category_id; } - $_product->categories = $category_id; // ===== Set brand ==== if ( $brand_name ) { + /** + * @var Brand $brand + */ if ( ($brand = Brand::find()->filterWhere(['ilike', 'name', trim($brand_name)])->one()) !== null ) { $_product->brand_id = $brand->brand_id; } else { @@ -350,8 +314,6 @@ class Import extends Model { continue; } - - if (!empty($fotos)) { foreach($fotos as $foto) { $source_image = Yii::getAlias('@uploadDir') . '/product_images/'. urlencode($foto); @@ -368,7 +330,6 @@ class Import extends Model { } } - // нужно для проставления характеристик относящихся к модификациям $MOD_ARRAY = []; @@ -384,29 +345,23 @@ class Import extends Model { $mod_stock = isset($mod_arr[4]) ?$mod_arr[4]:1; $mod_cost = isset($product_cost) ? floatval($product_cost) : 0; $mod_old_cost = floatval($product_cost_old); - // Check product variant if ( ($_productVariant = ProductVariant::find()->andFilterWhere(['ilike', 'sku', $mod_art])->andFilterWhere(['product_id' => $_product->product_id])->one()) === null ) { $_productVariant = new ProductVariant(); $_productVariant->product_id = $_product->product_id; } $_productVariant->product_unit_id = 1; - $_productVariant->sku = $mod_art; $_productVariant->price = $mod_cost; $_productVariant->price_old = $mod_old_cost; $_productVariant->stock = $mod_stock; - $product_variant_type_name = ''; if (! empty ($mod_color)) { - $product_variant_type_name = 'Цвет'; $_productVariant->name = $mod_color; } if (! empty ($variant_filters)) { - $variants_options = $this->saveFilters($variant_filters,1,$category_id); - } @@ -414,25 +369,11 @@ class Import extends Model { $_productVariant->options = $variants_options; } - - // ===== Set variant type ==== - if ( $product_variant_type_name ) { - if ( ($product_variant_type = ProductVariantType::find()->filterWhere(['ilike', 'name', $product_variant_type_name])->one()) !== null ) { - $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; - } else { - $product_variant_type = new ProductVariantType(); - $product_variant_type->name = $product_variant_type_name; - $product_variant_type->save(); - $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id; - } - } - $_productVariant->save(false); $MOD_ARRAY[] = $_productVariant->product_variant_id; if ($mod_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) { @@ -451,9 +392,7 @@ class Import extends Model { if (! empty ($filters)) { - $options = $this->saveFilters($filters,0,$category_id); - } @@ -471,7 +410,6 @@ class Import extends Model { 'from' => ftell($handle), 'totalsize' => $filesize, 'items' => $result_items, - ]; fclose ($handle); @@ -496,7 +434,6 @@ class Import extends Model { { $str = implode (';', $line)."\n"; $str = iconv ("UTF-8//TRANSLIT//IGNORE", "windows-1251", $str); - $fg = fopen (Yii::getAlias('@uploadDir') .'/'. $filename, 'a+'); fputs ($fg, $str); fclose ($fg); @@ -526,8 +463,6 @@ class Import extends Model { $taxGroup->alias = $filter_name; $taxGroup->level = $level; $taxGroup->name = $filter_name; - $taxGroup->module = 'string'; - $taxGroup->hierarchical = FALSE; $taxGroup->categories = $catalog_names; $taxGroup->is_filter = FALSE; $taxGroup->save(); @@ -536,28 +471,18 @@ class Import extends Model { $filters_options = explode(',',$filter[2][0]); foreach($filters_options as $filter_options){ - $value = TaxValueString::find()->innerJoinWith('taxOption')->andFilterWhere(['ilike', 'value', $filter_options])->andFilterWhere(['tax_option.tax_group_id' => $taxGroup->tax_group_id])->one(); + $option = TaxOption::find()->andFilterWhere(['ilike', 'value', $filters_options])->andFilterWhere(['tax_group_id' => $taxGroup->tax_group_id])->one(); - if (!$value instanceof TaxValueString) { + if ($option === NULL) { // Create option $option = new TaxOption(); $option->tax_group_id = $taxGroup->tax_group_id; - $option->name = $filter_options; - $option->save(); - - $value = new TaxValueString(); - $value->tax_option_id = $option->tax_option_id; - $value->value = $filter_options; - $value->save(); - - $option->default_value = $value->tax_value_id; + $option->value = $filter_options; $option->save(); } - $options[] = $value->tax_option_id; + $options[] = $option->tax_option_id; } - - } return $options; diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index 5326577..0b7d507 100644 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -1,458 +1,514 @@ FilterBehavior::className(), - ], - [ - 'class' => Slug::className(), - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true - ] - ]; - } - - /** - * @inheritdoc - */ - public static function tableName() - { - return '{{%product}}'; - } - - /** - * @inheritdoc - */ - public function rules() - { - return [ -// [['categories'], 'required'], - [['brand_id'], 'integer'], - [['name'], 'string', 'max' => 150], - [['alias'], 'string', 'max' => 250], - [['categories', 'variants', 'options', 'imagesUpload'], 'safe'], -// [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], - [['description', 'video'], 'safe'], - [['is_top', 'is_new', 'akciya'], 'boolean'], -// [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'product_id' => Yii::t('product', 'ID'), - 'name' => Yii::t('product', 'Name'), - 'brand_id' => Yii::t('product', 'Brand'), - 'categories' => Yii::t('product', 'Categories'), // relation behavior field - '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'), - 'akciya' => Yii::t('product', 'Is promo'), - ]; - } - - public function getUrl() { - return '/product/'. $this->alias; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getBrand() - { - return $this->hasOne(Brand::className(), ['brand_id' => 'brand_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getImage() - { - return $this->hasOne(ProductImage::className(), ['product_id' => 'product_id']); - } - - /** - * fetch stored image url - * @return string - */ - public function getImageUrl() - { - $image = empty($this->variant) ? null : $this->variant->image; - return !empty($image) ? $image->imageUrl : '/images/no_photo.png'; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getImages() - { - return $this->hasMany(ProductImage::className(), ['product_id' => 'product_id'])->where(['product_variant_id' => null]); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getVariant() - { - return $this->hasOne(ProductVariant::className(), ['product_id' => 'product_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getEnabledVariant() - { - return $this->hasOne(ProductVariant::className(), ['product_id' => 'product_id'])->andOnCondition(['!=', ProductVariant::tableName() .'.stock', 0]); - } - - public function getVariantPrice() { - return $this->variant->price; - } - - public function getEnabledVariantPrice() { - return $this->enabledVariants[0]->price; - } - + + namespace common\modules\product\models; + + use common\behaviors\Slug; + use common\models\ProductToRating; + use common\modules\comment\models\CommentModel; + use common\modules\product\behaviors\FilterBehavior; + use common\modules\rubrication\models\TaxGroup; + use common\modules\rubrication\models\TaxOption; + use Yii; + use yii\db\ActiveQuery; + use yii\db\ActiveRecord; + use yii\helpers\ArrayHelper; + /** - * @return \yii\db\ActiveQuery - */ - public function getVariants() - { - return $this->hasMany(ProductVariant::className(), ['product_id' => 'product_id']); - } - - public function getEnabledVariants() - { - return $this->hasMany(ProductVariant::className(), ['product_id' => 'product_id'])->andOnCondition(['!=', ProductVariant::tableName() .'.stock', 0])->joinWith('image'); - } - - /* - * Get variants grouped by type + * This is the model class for table "{{%product}}". + * @property string $name + * @property integer $brand_id + * @property integer $product_id + * @property Category $category + * @property array $categories + * @property array of ProductVariant $variants + * @property ProductVariant $variant + * @property ProductImage $image + * @property array $images + * @property boolean $is_top + * @property boolean $is_new + * @property boolean $akciya + * @property ProductToRating $averageRating + * @property array $properties + * @property ProductVariant $enabledVariant + * @property array $enabledVariants + * @property string $video + * @property string $description + * @property TaxOption[] $options */ - public function getEnabledVariantsGrouped() + class Product extends \yii\db\ActiveRecord { - $variants = []; - foreach ($this->enabledVariants as $variant) { - $variants[$variant->product_variant_type_id ? $variant->product_variant_type_id : 1][] = $variant; + + /** @var array $_variants */ + public $_variants = []; + + /** @var array $_images */ + public $imagesUpload = ''; + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + [ + 'class' => FilterBehavior::className(), + ], + [ + 'class' => Slug::className(), + 'in_attribute' => 'name', + 'out_attribute' => 'alias', + 'translit' => true, + ], + ]; } - if (empty($variants)) { - return []; + + /** + * @inheritdoc + */ + public static function tableName() + { + return '{{%product}}'; } - $ids = array_keys($variants); - $variants_type = []; - foreach(ProductVariantType::find()->select(['product_variant_type_id', 'name2'])->where(['product_variant_type_id' => $ids])->all() as $variant_type) { - $variant_type->_variants = $variants[$variant_type->product_variant_type_id]; - $variants_type[] = $variant_type; + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ 'brand_id' ], + 'integer', + ], + [ + [ 'name' ], + 'string', + 'max' => 150, + ], + [ + [ 'alias' ], + 'string', + 'max' => 250, + ], + [ + [ + 'categories', + 'variants', + 'options', + 'imagesUpload', + ], + 'safe', + ], + [ + [ + 'description', + 'video', + ], + 'safe', + ], + [ + [ + 'is_top', + 'is_new', + 'akciya', + ], + 'boolean', + ], + ]; } - return $variants_type; - } - - public function setVariants($variants) { - $this->_variants = $variants; - } - - public function getFullName() - { - return empty($this->brand) ? $this->name : $this->brand->name .' '. $this->name; - } - - public function getCategories() { - return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']); -// return $this->getRelations('product_categories'); - } - public function getCategoriesWithName() { - return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']); -// return $this->getRelations('product_categories'); - } - - public function getCategoriesNames() { - $result = []; - foreach($this->categories as $category) { - $result[] = $category->name; + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'product_id' => Yii::t('product', 'ID'), + 'name' => Yii::t('product', 'Name'), + 'brand_id' => Yii::t('product', 'Brand'), + 'categories' => Yii::t('product', 'Categories'), + // relation behavior field + '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'), + 'akciya' => Yii::t('product', 'Is promo'), + ]; } - return $result; - } - - public function getVariantsWithFilters(){ - return $this->hasMany(ProductVariant::className(), ['product_id' => 'product_id'])->with(['filters','image']); - } - - /** - * @return ActiveQuery - */ - public function getCategory() { - return $this->hasOne(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']); - } - - public function getOptions() { - return $this->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id'])->viaTable('product_option', ['product_id' => 'product_id']); - } - - public function getProperties() { - $groups = $options = []; - foreach ($this->options as $option) { - $options[$option->tax_group_id][] = $option; - } - foreach (TaxGroup::find()->where(['tax_group_id' => array_keys($options)])->all() as $group) { - if (!empty($options[$group->tax_group_id])) { - $group->_options = $options[$group->tax_group_id]; - $groups[] = $group; - } + + public function getUrl() + { + return '/product/' . $this->alias; } - return $groups; - } - - public function getActiveProperties($category_id) { - $groups = $options = []; - foreach ($this->options as $option) { - $options[$option->tax_group_id][] = $option; - } - - $taxGroups = TaxGroup::find()->joinWith('categories')->where(['tax_group.tax_group_id' => array_keys($options), 'tax_group.display' => TRUE, 'category.category_id' => $category_id])->all(); - - foreach ($taxGroups as $group) { - if (!empty($options[$group->tax_group_id])) { - $group->_options = $options[$group->tax_group_id]; - $groups[] = $group; + + /** + * @return \yii\db\ActiveQuery + */ + public function getBrand() + { + return $this->hasOne(Brand::className(), [ 'brand_id' => 'brand_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getImage() + { + return $this->hasOne(ProductImage::className(), [ 'product_id' => 'product_id' ]); + } + + /** + * fetch stored image url + * @return string + */ + public function getImageUrl() + { + $image = empty( $this->variant ) ? NULL : $this->variant->image; + return !empty( $image ) ? $image->imageUrl : '/images/no_photo.png'; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getImages() + { + return $this->hasMany(ProductImage::className(), [ 'product_id' => 'product_id' ]) + ->where([ 'product_variant_id' => NULL ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getVariant() + { + return $this->hasOne(ProductVariant::className(), [ 'product_id' => 'product_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getEnabledVariant() + { + return $this->hasOne(ProductVariant::className(), [ 'product_id' => 'product_id' ]) + ->andOnCondition([ + '!=', + ProductVariant::tableName() . '.stock', + 0, + ]); + } + + public function getVariantPrice() + { + return $this->variant->price; + } + + public function getEnabledVariantPrice() + { + return $this->enabledVariants[ 0 ]->price; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getVariants() + { + return $this->hasMany(ProductVariant::className(), [ 'product_id' => 'product_id' ]); + } + + public function getEnabledVariants() + { + return $this->hasMany(ProductVariant::className(), [ 'product_id' => 'product_id' ]) + ->andOnCondition([ + '!=', + ProductVariant::tableName() . '.stock', + 0, + ]) + ->joinWith('image'); + } + + public function setVariants($variants) + { + $this->_variants = $variants; + } + + public function getFullName() + { + return empty( $this->brand ) ? $this->name : $this->brand->name . ' ' . $this->name; + } + + public function getCategories() + { + return $this->hasMany(Category::className(), [ 'category_id' => 'category_id' ]) + ->viaTable('product_category', [ 'product_id' => 'product_id' ]); + } + + public function getCategoriesWithName() + { + return $this->hasMany(Category::className(), [ 'category_id' => 'category_id' ]) + ->viaTable('product_category', [ 'product_id' => 'product_id' ]); + } + + public function getCategoriesNames() + { + $result = []; + foreach($this->categories as $category) { + $result[] = $category->name; } + return $result; } - return $groups; - } - - public function getStocks() { - return $this->hasMany(Stock::className(), ['stock_id' => 'stock_id'])->viaTable(ProductStock::tableName(), ['product_id' => 'product_id']); - } - - /** - * @inheritdoc - * @return ProductQuery the active query used by this AR class. - */ - public static function find() - { - return new ProductQuery(get_called_class()); - } - - public function getQuantity() { - return ProductStock::find() - ->where(['product_id' => $this->product_id]) - ->sum('quantity'); - } - - public function afterSave($insert, $changedAttributes) - { - parent::afterSave($insert, $changedAttributes); - - - $this->unlinkAll('categories', true); - $this->unlinkAll('options',true); - - - $categories = Category::findAll($this->categories); - $options = TaxOption::findAll($this->options); - - foreach($options as $option){ - $this->link('options', $option); - } - foreach($categories as $category){ - $this->link('categories', $category); - } - - if (!empty($this->_variants)) { - $todel = []; - foreach ($this->variants ?: [] as $_variant) { - $todel[$_variant->product_variant_id] = $_variant->product_variant_id; + + public function getVariantsWithFilters() + { + return $this->hasMany(ProductVariant::className(), [ 'product_id' => 'product_id' ]) + ->with([ + 'filters', + 'image', + ]); + } + + /** + * @return ActiveQuery + */ + public function getCategory() + { + return $this->hasOne(Category::className(), [ 'category_id' => 'category_id' ]) + ->viaTable('product_category', [ 'product_id' => 'product_id' ]); + } + + public function getOptions() + { + return $this->hasMany(TaxOption::className(), [ 'tax_option_id' => 'option_id' ]) + ->viaTable('product_option', [ 'product_id' => 'product_id' ]); + } + + public function getProperties() + { + $groups = $options = []; + foreach($this->options as $option) { + $options[ $option->tax_group_id ][] = $option; } - foreach ($this->_variants as $_variant) { - if (!is_array($_variant)) { - return; + foreach(TaxGroup::find() + ->where([ 'tax_group_id' => array_keys($options) ]) + ->all() as $group) { + if(!empty( $options[ $group->tax_group_id ] )) { + $group->_options = $options[ $group->tax_group_id ]; + $groups[] = $group; } - if (!empty($_variant['product_variant_id'])) { - unset($todel[$_variant['product_variant_id']]); - $model = ProductVariant::findOne($_variant['product_variant_id']); - } else { - $model = new ProductVariant(); + } + return $groups; + } + + public function getActiveProperties($category_id) + { + $groups = $options = []; + foreach($this->options as $option) { + $options[ $option->tax_group_id ][] = $option; + } + + $taxGroups = TaxGroup::find() + ->joinWith('categories') + ->where([ + 'tax_group.tax_group_id' => array_keys($options), + 'tax_group.display' => true, + 'category.category_id' => $category_id, + ]) + ->all(); + + foreach($taxGroups as $group) { + if(!empty( $options[ $group->tax_group_id ] )) { + $group->_options = $options[ $group->tax_group_id ]; + $groups[] = $group; } - $_variant['product_id'] = $this->product_id; - $model->load(['ProductVariant' => $_variant]); - $model->product_id = $this->product_id; - $model->save(); } - if (!empty($todel)) { - ProductVariant::deleteAll(['product_variant_id' => $todel]); + return $groups; + } + + public function getStocks() + { + return $this->hasMany(Stock::className(), [ 'stock_id' => 'stock_id' ]) + ->viaTable(ProductStock::tableName(), [ 'product_id' => 'product_id' ]); + } + + public function getQuantity() + { + return ProductStock::find() + ->where([ 'product_id' => $this->product_id ]) + ->sum('quantity'); + } + + public function afterSave($insert, $changedAttributes) + { + parent::afterSave($insert, $changedAttributes); + + $this->unlinkAll('categories', true); + $this->unlinkAll('options', true); + + $categories = Category::findAll($this->categories); + $options = TaxOption::findAll($this->options); + + foreach($options as $option) { + $this->link('options', $option); + } + foreach($categories as $category) { + $this->link('categories', $category); + } + + if(!empty( $this->_variants )) { + $todel = []; + foreach($this->variants ? : [] as $_variant) { + $todel[ $_variant->product_variant_id ] = $_variant->product_variant_id; + } + foreach($this->_variants as $_variant) { + if(!is_array($_variant)) { + return; + } + if(!empty( $_variant[ 'product_variant_id' ] )) { + unset( $todel[ $_variant[ 'product_variant_id' ] ] ); + $model = ProductVariant::findOne($_variant[ 'product_variant_id' ]); + } else { + $model = new ProductVariant(); + } + $_variant[ 'product_id' ] = $this->product_id; + $model->load([ 'ProductVariant' => $_variant ]); + $model->product_id = $this->product_id; + $model->save(); + } + if(!empty( $todel )) { + ProductVariant::deleteAll([ 'product_variant_id' => $todel ]); + } } } - } - - public function beforeDelete() { - ProductImage::deleteAll(['product_id' => $this->product_id]); - ProductCategory::deleteAll(['product_id' => $this->product_id]); - ProductVariant::deleteAll(['product_id' => $this->product_id]); - ProductOption::deleteAll(['product_id' => $this->product_id]); - ProductStock::deleteAll(['product_id' => $this->product_id]); - Share::deleteAll(['product_id' => $this->product_id]); - return true; - } - - public function imagesUpload() - { - if ($this->validate()) { - $images = []; - foreach ($this->imagesUpload as $image) { - $imageName = $image->baseName .'.'. $image->extension; - $i = 0; - while(file_exists(Yii::getAlias('@imagesDir/products/' . $imageName))) { - $i++; - $imageName = $image->baseName .'_'. $i .'.'. $image->extension; + + public function imagesUpload() + { + if($this->validate()) { + $images = []; + foreach($this->imagesUpload as $image) { + $imageName = $image->baseName . '.' . $image->extension; + $i = 0; + while(file_exists(Yii::getAlias('@imagesDir/products/' . $imageName))) { + $i++; + $imageName = $image->baseName . '_' . $i . '.' . $image->extension; + } + $imgDir = Yii::getAlias('@imagesDir/products/'); + if(!is_dir($imgDir)) { + mkdir($imgDir, 0755, true); + } + + $image->saveAs($imgDir . $imageName); + $images[] = $imageName; } - $imgDir =Yii::getAlias('@imagesDir/products/'); - if(!is_dir($imgDir)) { - mkdir($imgDir, 0755, true); + return $images; + } else { + return false; + } + } + + public function getImagesHTML() + { + $op = []; + if($this->images) { + foreach($this->images as $image) { + $op[] = \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'admin_thumb'); } - - - $image->saveAs($imgDir .$imageName); - $images[] = $imageName; } - return $images; - } else { - return false; + return $op; } - } - - public function getImagesHTML() { - $op = []; - if ($this->images) { - foreach ($this->images as $image) { - $op[] = \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'admin_thumb'); + + public function getImagesConfig() + { + $op = []; + if($this->images) { + foreach($this->images as $image) { + $op[] = [ + 'caption' => $image->image, + 'width' => '120px', + 'url' => \yii\helpers\Url::to([ + '/product/manage/delimg', + 'id' => $image->product_image_id, + ]), + 'key' => $image->product_image_id, + 'extra' => [ + 'id' => $image->product_image_id, + ], + ]; + } } + return $op; } - return $op; - } - - public function getImagesConfig() { - $op = []; - if ($this->images) { - foreach ($this->images as $image) { - $op[] = [ - 'caption' => $image->image, - 'width' => '120px', - 'url' => \yii\helpers\Url::to(['/product/manage/delimg', 'id' => $image->product_image_id]), - 'key' => $image->product_image_id, - 'extra' => [ - 'id' => $image->product_image_id, - ], - ]; + + public function recalculateRating() + { + /** + * @var ProductToRating $averageRating + */ + $average = $this->getComments() + ->joinWith('rating') + ->select([ 'average' => 'avg(artbox_comment_rating.value)::float' ]) + ->scalar(); + if(!$average) { + $average = 0; + } + $averageRating = $this->averageRating; + if(!empty( $averageRating )) { + $averageRating->value = $average; + } else { + $averageRating = new ProductToRating([ + 'product_id' => $this->product_id, + 'value' => $average, + ]); + } + if($averageRating->save()) { + return true; + } else { + return false; } } - return $op; - } - - public function recalculateRating() { - /** - * @var ProductToRating $averageRating - */ - $average = $this->getComments()->joinWith('rating')->select(['average' => 'avg(artbox_comment_rating.value)::float'])->scalar(); - if(!$average) { - $average = 0; + + public function getComments() + { + return $this->hasMany(CommentModel::className(), [ 'entity_id' => 'product_id' ]) + ->where([ + 'artbox_comment.entity' => self::className(), + 'artbox_comment.status' => CommentModel::STATUS_ACTIVE, + 'artbox_comment.artbox_comment_pid' => NULL, + ]); } - $averageRating = $this->averageRating; - if(!empty($averageRating)) { - $averageRating->value = $average; - } else { - $averageRating = new ProductToRating(['product_id' => $this->product_id, 'value' => $average]); + + public function getAverageRating() + { + return $this->hasOne(ProductToRating::className(), [ 'product_id' => 'product_id' ]); } - if($averageRating->save()) { - return true; - } else { - return false; + + public function getTaxGroupsByLevel($level) + { + $categories = ArrayHelper::getColumn($this->categories, 'category_id'); + return TaxGroup::find() + ->distinct() + ->innerJoin('tax_group_to_category', 'tax_group_to_category.tax_group_id = tax_group.tax_group_id') + ->andWhere([ 'tax_group_to_category.category_id' => $categories ]) + ->andWhere([ 'level' => $level ]); + } + + public function setCategories($values) + { + $this->categories = $values; + } + + public function setOptions($values) + { + $this->options = $values; + } + + public function getFilters() + { + return $this->hasMany(TaxOption::className(), [ 'tax_option_id' => 'option_id' ]) + ->viaTable('product_option', [ 'product_id' => 'product_id' ]) + ->joinWith('taxGroup'); } } - - public function getComments() { - return $this->hasMany(CommentModel::className(), ['entity_id' => 'product_id'])->where(['artbox_comment.entity' => self::className(), 'artbox_comment.status' => CommentModel::STATUS_ACTIVE, 'artbox_comment.artbox_comment_pid' => NULL]); - } - - public function getAverageRating() { - return $this->hasOne(ProductToRating::className(), ['product_id' => 'product_id']); - } - - public function getTaxGroupsByLevel($level) - { - $categories = ArrayHelper::getColumn($this->categories, 'category_id'); - return TaxGroup::find()->distinct()->innerJoin('tax_group_to_category', 'tax_group_to_category.tax_group_id = tax_group.tax_group_id')->andWhere(['tax_group_to_category.category_id' => $categories])->andWhere(['level' => $level]); - } - - public function setCategories($values) - { - $this->categories = $values; - } - - public function setOptions($values) - { - $this->options = $values; - } - - public function getFilters(){ - - return $this->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id']) - ->viaTable('product_option',[ 'product_id'=> 'product_id']) - ->joinWith('taxGroup'); - } -} diff --git a/common/modules/product/models/ProductCategory.php b/common/modules/product/models/ProductCategory.php index 36d2ed8..a58260b 100644 --- a/common/modules/product/models/ProductCategory.php +++ b/common/modules/product/models/ProductCategory.php @@ -47,12 +47,5 @@ class ProductCategory extends \yii\db\ActiveRecord 'category_id' => Yii::t('product', 'Category'), ]; } - - public function getProduct() { - return $this->getEntity1(); - } - - public function getCategory() { - return $this->getEntity2(); - } + } diff --git a/common/modules/product/models/ProductImage.php b/common/modules/product/models/ProductImage.php index a69a9f2..9c83b88 100644 --- a/common/modules/product/models/ProductImage.php +++ b/common/modules/product/models/ProductImage.php @@ -81,15 +81,6 @@ class ProductImage extends \yii\db\ActiveRecord return $this->hasOne(Product::className(), ['product_variant_id' => 'product_variant_id']); } -// /** -// * @inheritdoc -// * @return ProductImageQuery the active query used by this AR class. -// */ -// public static function find() -// { -// return new ProductImageQuery(get_called_class()); -// } - /** * fetch stored image file name with complete path * @return string diff --git a/common/modules/product/models/ProductImageQuery.php b/common/modules/product/models/ProductImageQuery.php deleted file mode 100644 index d10b794..0000000 --- a/common/modules/product/models/ProductImageQuery.php +++ /dev/null @@ -1,35 +0,0 @@ -andWhere('[[status]]=1'); - }*/ - - /** - * @inheritdoc - * @return ProductImage[]|array - */ - public function all($db = null) - { - $this->where(['product_variant_id' => NULL]); - return parent::all($db); - } - - /** - * @inheritdoc - * @return ProductImage|array|null - */ - public function one($db = null) - { - return parent::one($db); - } -} diff --git a/common/modules/product/models/ProductOption.php b/common/modules/product/models/ProductOption.php index de5d49f..68c4eb7 100644 --- a/common/modules/product/models/ProductOption.php +++ b/common/modules/product/models/ProductOption.php @@ -2,6 +2,7 @@ namespace common\modules\product\models; +use common\modules\rubrication\models\TaxOption; use Yii; /** diff --git a/common/modules/product/models/ProductQuery.php b/common/modules/product/models/ProductQuery.php deleted file mode 100644 index b5cf18c..0000000 --- a/common/modules/product/models/ProductQuery.php +++ /dev/null @@ -1,45 +0,0 @@ -andWhere('[[status]]=1'); - }*/ - - /** - * @inheritdoc - * @return Product[]|array - */ - public function all($db = null) - { - return parent::all($db); - } - - /** - * @inheritdoc - * @return Product|array|null - */ - public function one($db = null) - { - return parent::one($db); - } - - /** - * Select category by alias - * @param $slug - * @return $this - */ - public function byAlias($alias) - { - $this->andFilterWhere(['alias' => $alias]); - return $this; - } -} diff --git a/common/modules/product/models/ProductSearch.php b/common/modules/product/models/ProductSearch.php index 80ec3fa..2a96810 100644 --- a/common/modules/product/models/ProductSearch.php +++ b/common/modules/product/models/ProductSearch.php @@ -2,10 +2,9 @@ namespace common\modules\product\models; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use common\modules\product\models\Product; +use yii\db\ActiveQuery; use yii\web\NotFoundHttpException; /** @@ -30,7 +29,7 @@ class ProductSearch extends Product [['is_top', 'is_new', 'akciya'], 'boolean'], ]; } - + /** * @inheritdoc */ @@ -108,9 +107,9 @@ class ProductSearch extends Product } public static function findByAlias($alias) { - /** @var ProductQuery $query */ + /** @var ActiveQuery $query */ $query = Product::find(); - $query->byAlias($alias); + $query->andFilterWhere(['alias' => $alias]); if (($model = $query->one()) !== null) { return $model; } else { diff --git a/common/modules/product/models/ProductStock.php b/common/modules/product/models/ProductStock.php index ead58bc..f6db347 100644 --- a/common/modules/product/models/ProductStock.php +++ b/common/modules/product/models/ProductStock.php @@ -2,8 +2,6 @@ namespace common\modules\product\models; -use Yii; - /** * This is the model class for table "product_stock". * diff --git a/common/modules/product/models/ProductUnitSearch.php b/common/modules/product/models/ProductUnitSearch.php index 8b0be90..c4a7d15 100644 --- a/common/modules/product/models/ProductUnitSearch.php +++ b/common/modules/product/models/ProductUnitSearch.php @@ -2,10 +2,8 @@ namespace common\modules\product\models; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use common\modules\product\models\ProductUnit; /** * ProductUnitSearch represents the model behind the search form about `common\modules\product\models\ProductUnit`. diff --git a/common/modules/product/models/ProductVariant.php b/common/modules/product/models/ProductVariant.php index aa42bec..9562033 100644 --- a/common/modules/product/models/ProductVariant.php +++ b/common/modules/product/models/ProductVariant.php @@ -1,299 +1,341 @@ 255], - [['remote_id'], 'string', 'max' => 20], - [['options', 'imagesUpload'], 'safe'], -// [['imagesUpload'], 'safe'], -// [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], - [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'product_variant_id' => Yii::t('product', 'Product Variant ID'), - 'product_id' => Yii::t('product', 'Product ID'), - 'name' => Yii::t('product', 'Name'), - 'sku' => Yii::t('product', 'Sku'), - 'price' => Yii::t('product', 'Price'), - 'price_old' => Yii::t('product', 'Price Old'), - 'stock' => Yii::t('product', 'Stock'), - 'product_unit_id' => Yii::t('product', 'Product Unit ID'), - 'product_variant_type_id' => Yii::t('product', 'Product Variant Type ID'), - 'stock_caption' => Yii::t('product', 'Stock'), - 'image' => Yii::t('product', 'Image'), - 'images' => Yii::t('product', 'Images'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getProductUnit() - { - return $this->hasOne(ProductUnit::className(), ['product_unit_id' => 'product_unit_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getProductVariantType() - { - return $this->hasOne(ProductVariantType::className(), ['product_variant_type_id' => 'product_variant_type_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getProduct() - { - return $this->hasOne(Product::className(), ['product_id' => 'product_id']); - } - - public function getProductStock() { - return $this->hasMany(ProductStock::className(), ['product_variant_id' => 'product_variant_id']); - } - - public function getQuantity() { - return ProductStock::find() - ->where(['product_variant_id' => $this->product_variant_id]) - ->sum('quantity'); - } - - public function getStock_caption() { - return is_null($this->stock) ? '∞' : ($this->stock > 0 ? Yii::t('product', 'Enable') : Yii::t('product', 'Disable')); // intval($this->stock); - } - - public function getVariantStocks(){ - - return $this->hasMany(ProductStock::className(),['product_variant_id'=> 'product_variant_id'])->joinWith('stock'); - } - - public function getStocks(){ - - return $this->hasMany(Stock::className(),['stock_id'=>'stock_id']) - ->viaTable(ProductStock::tableName(),['product_variant_id'=> 'product_variant_id']); - } - - - public function getFilters(){ - - return $this->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id']) - ->viaTable('product_variant_option',[ 'product_variant_id'=> 'product_variant_id']) - ->joinWith('taxGroup'); - } - - - /** - * @return \yii\db\ActiveQuery - */ - public function getImage() - { - return $this->hasOne(ProductImage::className(), ['product_variant_id' => 'product_variant_id']); - } - + + namespace common\modules\product\models; + + use common\modules\rubrication\models\TaxGroup; + use common\modules\rubrication\models\TaxOption; + use Yii; + use yii\helpers\ArrayHelper; + /** - * fetch stored image url - * @return string + * This is the model class for table "product_variant". + * @property integer $product_variant_id + * @property integer $product_id + * @property string $name + * @property string $remote_id + * @property string $sku + * @property double $price + * @property double $price_old + * @property double $stock + * @property integer $product_unit_id + * @property ProductImage $image + * @property array $images + * @property TaxOption[] $options + * @property ProductUnit $productUnit */ - public function getImageUrl() + class ProductVariant extends \yii\db\ActiveRecord { - // return a default image placeholder if your source image is not found - return !empty($this->image) ? $this->image->imageUrl : '/images/no_photo.png'; - } - - public function getFullname() { - return empty($this->product) ? null : ($this->product->name . (empty($this->name) ? '' : ' '. $this->name)); - } - - public function getImagesHTML() { - $op = []; - if ($this->images) { - foreach ($this->images as $image) { - $op[] = \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'admin_thumb'); - } + + /**just for rukzachok**/ + public $count; + + public $sum_cost; + + public $product_name; + + //public $image; + public $translit; + + public $translit_rubric; + + private $data; + + /** @var array $_images */ + public $imagesUpload = ''; + + /** + * @inheritdoc + */ + public static function tableName() + { + return 'product_variant'; } - return $op; - } - - public function getImagesConfig() { - $op = []; - if ($this->images) { - foreach ($this->images as $image) { - $op[] = [ - 'caption' => $image->image, - 'width' => '120px', - 'url' => \yii\helpers\Url::to(['/product/manage/delimg', 'id' => $image->product_image_id]), - 'key' => $image->product_image_id, - 'extra' => [ - 'id' => $image->product_image_id, + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'product_id', + 'product_unit_id', + ], + 'required', + ], + [ + [ + 'product_id', + 'product_unit_id', ], - ]; + 'integer', + ], + [ + [ + 'price', + 'price_old', + 'stock', + ], + 'number', + ], + [ + [ + 'name', + 'sku', + ], + 'string', + 'max' => 255, + ], + [ + [ 'remote_id' ], + 'string', + 'max' => 20, + ], + [ + [ + 'options', + 'imagesUpload', + ], + 'safe', + ], + [ + [ 'product_unit_id' ], + 'exist', + 'skipOnError' => true, + 'targetClass' => ProductUnit::className(), + 'targetAttribute' => [ 'product_unit_id' => 'product_unit_id' ], + ], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'product_variant_id' => Yii::t('product', 'Product Variant ID'), + 'product_id' => Yii::t('product', 'Product ID'), + 'name' => Yii::t('product', 'Name'), + 'sku' => Yii::t('product', 'Sku'), + 'price' => Yii::t('product', 'Price'), + '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'), + 'image' => Yii::t('product', 'Image'), + 'images' => Yii::t('product', 'Images'), + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProductUnit() + { + return $this->hasOne(ProductUnit::className(), [ 'product_unit_id' => 'product_unit_id' ]); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProduct() + { + return $this->hasOne(Product::className(), [ 'product_id' => 'product_id' ]); + } + + public function getProductStock() + { + return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'product_variant_id' ]); + } + + public function getQuantity() + { + return ProductStock::find() + ->where([ 'product_variant_id' => $this->product_variant_id ]) + ->sum('quantity'); + } + + public function getStock_caption() + { + return is_null($this->stock) ? '∞' : ( $this->stock > 0 ? Yii::t('product', 'Enable') : Yii::t('product', 'Disable') ); // intval($this->stock); + } + + public function getVariantStocks() + { + + return $this->hasMany(ProductStock::className(), [ 'product_variant_id' => 'product_variant_id' ]) + ->joinWith('stock'); + } + + public function getStocks() + { + + return $this->hasMany(Stock::className(), [ 'stock_id' => 'stock_id' ]) + ->viaTable(ProductStock::tableName(), [ 'product_variant_id' => 'product_variant_id' ]); + } + + public function getFilters() + { + + return $this->hasMany(TaxOption::className(), [ 'tax_option_id' => 'option_id' ]) + ->viaTable('product_variant_option', [ 'product_variant_id' => 'product_variant_id' ]) + ->joinWith('taxGroup'); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getImage() + { + return $this->hasOne(ProductImage::className(), [ 'product_variant_id' => 'product_variant_id' ]); + } + + /** + * fetch stored image url + * @return string + */ + public function getImageUrl() + { + // return a default image placeholder if your source image is not found + return !empty( $this->image ) ? $this->image->imageUrl : '/images/no_photo.png'; + } + + public function getFullname() + { + return empty( $this->product ) ? NULL : ( $this->product->name . ( empty( $this->name ) ? '' : ' ' . $this->name ) ); + } + + public function getImagesHTML() + { + $op = []; + if($this->images) { + foreach($this->images as $image) { + $op[] = \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'admin_thumb'); + } } + return $op; } - return $op; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getImages() - { - return $this->hasMany(ProductImage::className(), ['product_variant_id' => 'product_variant_id']); - } - - public function getOptions() { - return $this->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id'])->viaTable('product_variant_option', ['product_variant_id' => 'product_variant_id']); - } - - public function getProperties() { - $groups = $options = []; - foreach ($this->options as $option) { - $options[$option->tax_group_id][] = $option; + + public function getImagesConfig() + { + $op = []; + if($this->images) { + foreach($this->images as $image) { + $op[] = [ + 'caption' => $image->image, + 'width' => '120px', + 'url' => \yii\helpers\Url::to([ + '/product/manage/delimg', + 'id' => $image->product_image_id, + ]), + 'key' => $image->product_image_id, + 'extra' => [ + 'id' => $image->product_image_id, + ], + ]; + } + } + return $op; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getImages() + { + return $this->hasMany(ProductImage::className(), [ 'product_variant_id' => 'product_variant_id' ]); } - foreach (TaxGroup::find()->where(['tax_group_id' => array_keys($options)])->all() as $group) { - if (!empty($options[$group->tax_group_id])) { - $group->_options = $options[$group->tax_group_id]; - $groups[] = $group; + + public function setOptions($values) + { + $this->options = $values; + } + + public function getOptions() + { + return $this->hasMany(TaxOption::className(), [ 'tax_option_id' => 'option_id' ]) + ->viaTable('product_variant_option', [ 'product_variant_id' => 'product_variant_id' ]); + } + + public function getProperties() + { + $groups = $options = []; + foreach($this->options as $option) { + $options[ $option->tax_group_id ][] = $option; } + foreach(TaxGroup::find() + ->where([ 'tax_group_id' => array_keys($options) ]) + ->all() as $group) { + if(!empty( $options[ $group->tax_group_id ] )) { + $group->_options = $options[ $group->tax_group_id ]; + $groups[] = $group; + } + } + return $groups; } - return $groups; - } - - /** - * @inheritdoc - * @return ProductVariantQuery the active query used by this AR class. - */ - public static function find() - { - return new ProductVariantQuery(get_called_class()); - } - - public function getId(){ - return $this->product_variant_id; - } - - public function setStocks($stocks) { - $this->stocks = (array) $stocks; - } - - public function getCategory() { - return $this->hasOne(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']); - } - - public function getCategories() { - return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']); - } - - public function getTaxGroupsByLevel($level) - { - $categories = ArrayHelper::getColumn($this->categories, 'category_id'); - return TaxGroup::find()->distinct()->innerJoin('tax_group_to_category', 'tax_group_to_category.tax_group_id = tax_group.tax_group_id')->where(['tax_group_to_category.category_id' => $categories])->where(['level' => $level]); - } - -// public function afterSave($insert, $changedAttributes) -// { -// if (!is_null($this->stocks)) { -// //ProductStock::deleteAll(['product_variant_id' => $this->product_variant_id]); -// $values = []; -// foreach ($this->stocks as $id => $quantity) { -// $productStock = ProductStock::find()->where(['product_variant_id' => $this->product_variant_id, 'stock_id' => $id])->one(); -// $productStock->quantity = $quantity; -// $productStock->save(); -// } -// } -// parent::afterSave($insert, $changedAttributes); -// } - - public function beforeDelete() { - ProductVariantOption::deleteAll(['product_variant_id' => $this->product_variant_id]); - ProductImage::deleteAll(['product_variant_id' => $this->product_variant_id]); - ProductStock::deleteAll(['product_variant_id' => $this->product_variant_id]); - return true; - } - - public function imagesUpload() - { - if ($this->validate()) { - $images = []; - foreach ($this->imagesUpload as $image) { - $imageName = $image->baseName .'.'. $image->extension; - $i = 0; - while(file_exists(Yii::getAlias('@imagesDir/products/' . $imageName))) { - $i++; - $imageName = $image->baseName .'_'. $i .'.'. $image->extension; + + public function getId() + { + return $this->product_variant_id; + } + + public function setStocks($stocks) + { + $this->stocks = (array) $stocks; + } + + public function getCategory() + { + return $this->hasOne(Category::className(), [ 'category_id' => 'category_id' ]) + ->viaTable('product_category', [ 'product_id' => 'product_id' ]); + } + + public function getCategories() + { + return $this->hasMany(Category::className(), [ 'category_id' => 'category_id' ]) + ->viaTable('product_category', [ 'product_id' => 'product_id' ]); + } + + public function getTaxGroupsByLevel($level) + { + $categories = ArrayHelper::getColumn($this->categories, 'category_id'); + return TaxGroup::find() + ->distinct() + ->innerJoin('tax_group_to_category', 'tax_group_to_category.tax_group_id = tax_group.tax_group_id') + ->where([ 'tax_group_to_category.category_id' => $categories ]) + ->where([ 'level' => $level ]); + } + + public function afterSave($insert, $changedAttributes) + { + parent::afterSave($insert, $changedAttributes); + $this->unlinkAll('options', true); + $options = TaxOption::findAll($this->options); + foreach($options as $option) { + $this->link('options', $option); + } + } + + public function imagesUpload() + { + if($this->validate()) { + $images = []; + foreach($this->imagesUpload as $image) { + $imageName = $image->baseName . '.' . $image->extension; + $i = 0; + while(file_exists(Yii::getAlias('@imagesDir/products/' . $imageName))) { + $i++; + $imageName = $image->baseName . '_' . $i . '.' . $image->extension; + } + + $image->saveAs(Yii::getAlias('@imagesDir/products/' . $imageName)); + $images[] = $imageName; } - - $image->saveAs(Yii::getAlias('@imagesDir/products/' .$imageName)); - $images[] = $imageName; + return $images; + } else { + return false; } - return $images; - } else { - return false; } } -} diff --git a/common/modules/product/models/ProductVariantListSearch.php b/common/modules/product/models/ProductVariantListSearch.php index 4593951..3b96801 100644 --- a/common/modules/product/models/ProductVariantListSearch.php +++ b/common/modules/product/models/ProductVariantListSearch.php @@ -2,7 +2,6 @@ namespace common\modules\product\models; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; @@ -17,7 +16,7 @@ class ProductVariantListSearch extends ProductVariant public function rules() { return [ - [['product_variant_id', 'product_id', 'product_unit_id', 'product_variant_type_id'], 'integer'], + [['product_variant_id', 'product_id', 'product_unit_id'], 'integer'], [['name', 'sku', 'remote_id'], 'safe'], [['price', 'price_old', 'stock'], 'number'], ]; @@ -70,7 +69,6 @@ class ProductVariantListSearch extends ProductVariant 'price_old' => $this->price_old, 'stock' => $this->stock, 'product_unit_id' => $this->product_unit_id, - 'product_variant_type_id' => $this->product_variant_type_id, ]); $query->andFilterWhere(['like', 'name', $this->name]) diff --git a/common/modules/product/models/ProductVariantOption.php b/common/modules/product/models/ProductVariantOption.php index c1d30ae..ba8148c 100644 --- a/common/modules/product/models/ProductVariantOption.php +++ b/common/modules/product/models/ProductVariantOption.php @@ -2,7 +2,7 @@ namespace common\modules\product\models; -use Yii; +use common\modules\rubrication\models\TaxOption; /** * This is the model class for table "product_variant_option". diff --git a/common/modules/product/models/ProductVariantQuery.php b/common/modules/product/models/ProductVariantQuery.php deleted file mode 100644 index 011164c..0000000 --- a/common/modules/product/models/ProductVariantQuery.php +++ /dev/null @@ -1,34 +0,0 @@ -andWhere('[[status]]=1'); - }*/ - - /** - * @inheritdoc - * @return ProductVariant[]|array - */ - public function all($db = null) - { - return parent::all($db); - } - - /** - * @inheritdoc - * @return ProductVariant|array|null - */ - public function one($db = null) - { - return parent::one($db); - } -} diff --git a/common/modules/product/models/ProductVariantSearch.php b/common/modules/product/models/ProductVariantSearch.php index 3e4bfae..fbc42dd 100644 --- a/common/modules/product/models/ProductVariantSearch.php +++ b/common/modules/product/models/ProductVariantSearch.php @@ -2,11 +2,9 @@ namespace common\modules\product\models; -use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; -use yii\web\NotFoundHttpException; - +use yii\db\ActiveQuery; /** * ProductVariantSearch represents the model behind the search form about `common\modules\product\models\ProductVariant`. */ @@ -120,19 +118,19 @@ class ProductVariantSearch extends ProductVariant $query->andFilterWhere(['ilike', 'sku', $this->sku]); $query->groupBy(['product_variant_id']); - $query->orderBy('product_variant.product_id', 'ASC'); + $query->orderBy(['product_variant.product_id' => SORT_ASC]); return $dataProvider; } public static function findBySku($sku) { - /** @var ProductQuery $query */ + /** @var ActiveQuery $query */ $query = ProductVariant::find() ->andFilterWhere(['sku' => $sku]); if (($model = $query->one()) !== null) { return $model; } - return; + return NULL; } public static function findByRemoteID($id) { @@ -142,6 +140,6 @@ class ProductVariantSearch extends ProductVariant if (($model = $query->one()) !== null) { return $model; } - return; + return NULL; } } diff --git a/common/modules/product/models/ProductVariantType.php b/common/modules/product/models/ProductVariantType.php deleted file mode 100644 index d8e813a..0000000 --- a/common/modules/product/models/ProductVariantType.php +++ /dev/null @@ -1,49 +0,0 @@ - 50], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'product_variant_type_id' => 'Product Variant Type ID', - 'name' => 'Name', - ]; - } - - public function getId() { - return $this->product_variant_type_id; - } -} diff --git a/common/modules/product/models/ProductVariantTypeSearch.php b/common/modules/product/models/ProductVariantTypeSearch.php deleted file mode 100644 index c4804b4..0000000 --- a/common/modules/product/models/ProductVariantTypeSearch.php +++ /dev/null @@ -1,70 +0,0 @@ - $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_variant_type_id' => $this->product_variant_type_id, - ]); - - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'name2', $this->name2]); - - return $dataProvider; - } -} diff --git a/common/modules/product/models/Stock.php b/common/modules/product/models/Stock.php index db3e191..a4a80f1 100644 --- a/common/modules/product/models/Stock.php +++ b/common/modules/product/models/Stock.php @@ -43,13 +43,4 @@ class Stock extends \yii\db\ActiveRecord 'name' => Yii::t('product', 'Name'), ]; } - - /** - * @inheritdoc - * @return StockQuery the active query used by this AR class. - */ - public static function find() - { - return new StockQuery(get_called_class()); - } } diff --git a/common/modules/product/models/StockQuery.php b/common/modules/product/models/StockQuery.php deleted file mode 100644 index 2650415..0000000 --- a/common/modules/product/models/StockQuery.php +++ /dev/null @@ -1,34 +0,0 @@ -andWhere('[[status]]=1'); - }*/ - - /** - * @inheritdoc - * @return Stock[]|array - */ - public function all($db = null) - { - return parent::all($db); - } - - /** - * @inheritdoc - * @return Stock|array|null - */ - public function one($db = null) - { - return parent::one($db); - } -} diff --git a/common/modules/product/views/manage/_form.php b/common/modules/product/views/manage/_form.php index 6c7f33f..53eed7b 100644 --- a/common/modules/product/views/manage/_form.php +++ b/common/modules/product/views/manage/_form.php @@ -1,15 +1,19 @@
@@ -60,7 +64,6 @@ use kartik\select2\Select2; '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', ], @@ -69,7 +72,7 @@ use kartik\select2\Select2; all() as $group) :?> field($model, 'options')->checkboxList( - ArrayHelper::map($group->options, 'tax_option_id', 'ValueRenderFlash'), + ArrayHelper::map($group->options, 'tax_option_id', 'value'), [ 'multiple' => true, 'unselect' => null, diff --git a/common/modules/product/views/manage/index.php b/common/modules/product/views/manage/index.php index 3c79fc9..eace124 100644 --- a/common/modules/product/views/manage/index.php +++ b/common/modules/product/views/manage/index.php @@ -125,7 +125,7 @@ $this->params['breadcrumbs'][] = $this->title; return \yii\helpers\Url::to(['manage/akciya', 'id' => $model->product_id]); break; case 'view': - return \yii\helpers\Url::to(['/catalog/product', 'id' => $model->product_id, ['target' => '_blank']]); + return \yii\helpers\Url::to(['manage/view', 'id' => $model->product_id]); break; case 'update': return \yii\helpers\Url::to(['manage/update', 'id' => $model->product_id]); diff --git a/common/modules/product/views/product-variant-type/_form.php b/common/modules/product/views/product-variant-type/_form.php deleted file mode 100644 index f0a7cfc..0000000 --- a/common/modules/product/views/product-variant-type/_form.php +++ /dev/null @@ -1,25 +0,0 @@ - - -
- - - - field($model, 'name')->textInput(['maxlength' => true]) ?> - - field($model, 'name2')->textInput(['maxlength' => true]) ?> - -
- isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> -
- - - -
diff --git a/common/modules/product/views/product-variant-type/_search.php b/common/modules/product/views/product-variant-type/_search.php deleted file mode 100644 index 7b3cdec..0000000 --- a/common/modules/product/views/product-variant-type/_search.php +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/common/modules/product/views/product-variant-type/create.php b/common/modules/product/views/product-variant-type/create.php deleted file mode 100644 index e7d68c8..0000000 --- a/common/modules/product/views/product-variant-type/create.php +++ /dev/null @@ -1,21 +0,0 @@ -title = Yii::t('product', 'Create Product Variant Type'); -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Variant Types'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/common/modules/product/views/product-variant-type/index.php b/common/modules/product/views/product-variant-type/index.php deleted file mode 100644 index 4e44be0..0000000 --- a/common/modules/product/views/product-variant-type/index.php +++ /dev/null @@ -1,32 +0,0 @@ -title = Yii::t('product', 'Product Variant Types'); -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- render('_search', ['model' => $searchModel]); ?> - -

- 'btn btn-success']) ?> -

- $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - 'name', - 'name2', - - ['class' => 'yii\grid\ActionColumn'], - ], - ]); ?> -
diff --git a/common/modules/product/views/product-variant-type/update.php b/common/modules/product/views/product-variant-type/update.php deleted file mode 100644 index d4eb6de..0000000 --- a/common/modules/product/views/product-variant-type/update.php +++ /dev/null @@ -1,23 +0,0 @@ -title = Yii::t('product', 'Update {modelClass}: ', [ - 'modelClass' => 'Product Variant Type', -]) . $model->name; -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Variant Types'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->product_variant_type_id]]; -$this->params['breadcrumbs'][] = Yii::t('product', 'Update'); -?> -
- -

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> - -
diff --git a/common/modules/product/views/product-variant-type/view.php b/common/modules/product/views/product-variant-type/view.php deleted file mode 100644 index 1a54e27..0000000 --- a/common/modules/product/views/product-variant-type/view.php +++ /dev/null @@ -1,37 +0,0 @@ -title = $model->name; -$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Variant Types'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- -

- $model->product_variant_type_id], ['class' => 'btn btn-primary']) ?> - $model->product_variant_type_id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), - 'method' => 'post', - ], - ]) ?> -

- - $model, - 'attributes' => [ - 'product_variant_type_id', - 'name', - 'name2', - ], - ]) ?> - -
diff --git a/common/modules/product/views/variant/_form.php b/common/modules/product/views/variant/_form.php index 37a8ba1..841d683 100644 --- a/common/modules/product/views/variant/_form.php +++ b/common/modules/product/views/variant/_form.php @@ -58,7 +58,7 @@ $this->registerJs($js, View::POS_END); 'attribute' => 'image', 'options' => [ 'accept' => 'image/*', - 'multiple' => true + 'multiple' => false ], 'pluginOptions' => [ 'allowedFileExtensions' => ['jpg','gif','png'], @@ -131,7 +131,7 @@ $this->registerJs($js, View::POS_END); all() as $group) :?> field($model, 'options')->checkboxList( - ArrayHelper::map($group->options, 'tax_option_id', 'ValueRenderFlash'), + ArrayHelper::map($group->options, 'tax_option_id', 'value'), [ 'multiple' => true, 'unselect' => null, diff --git a/common/modules/product/widgets/catalogSubmenuWidget.php b/common/modules/product/widgets/catalogSubmenuWidget.php deleted file mode 100644 index ef9388f..0000000 --- a/common/modules/product/widgets/catalogSubmenuWidget.php +++ /dev/null @@ -1,36 +0,0 @@ -root_id); - - $categories = $rootCategory->getAllChildren(2, [], 'categoryName')->all(); - $populary = []; - foreach($categories as $category) { - if ($category->populary) { - $populary[] = $category; - } - } - - return $this->render('submenu', [ - 'rootCategory' => $rootCategory, - 'rootClass' => $this->rootClass, - 'populary' => $populary, - 'items' => $rootCategory->buildTree($categories, $rootCategory->category_id) - ]); - } -} \ No newline at end of file diff --git a/common/modules/product/widgets/views/product_smart.php b/common/modules/product/widgets/views/product_smart.php index 52016b7..98fd428 100644 --- a/common/modules/product/widgets/views/product_smart.php +++ b/common/modules/product/widgets/views/product_smart.php @@ -54,7 +54,7 @@ use yii\helpers\Url;
  • Бренд: brand->name ?>
  • getActiveProperties($product->category->category_id) as $group): ?> -
  • name ?> _options as $option) : ?> ValueRenderHTML ?>
  • +
  • name ?> _options as $option) : ?> value ?>
  • diff --git a/common/modules/product/widgets/views/submenu.php b/common/modules/product/widgets/views/submenu.php index 5a5140e..190279a 100644 --- a/common/modules/product/widgets/views/submenu.php +++ b/common/modules/product/widgets/views/submenu.php @@ -1,27 +1,13 @@ + + + + + +
    +
    +
    Ваша заявка принята.
    Мы свяжемся в Вами в ближайшее время
    +
    endBody() ?> diff --git a/frontend/views/project/_list_item.php b/frontend/views/project/_list_item.php new file mode 100644 index 0000000..e1ea3f6 --- /dev/null +++ b/frontend/views/project/_list_item.php @@ -0,0 +1,61 @@ + +
    +
    + title, [ 'project/view', 'id' => $model->project_id ]); + ?> +
    +
    +
    +
    + images)) { + $image = current($model->images); + echo Html::a(ArtboxImageHelper::getImage($image->getImageUrl(), 'article_list'), [ 'project/view', 'id' => $model->project_id ]); + } + ?> +
    + description; + ?> +

    + $model->project_id ]); + ?> +

    +
    +
    + images) && count($model->images) > 1) { + $images = array_slice($model->images, 1); + ?> + + +
    \ No newline at end of file diff --git a/frontend/views/project/index.php b/frontend/views/project/index.php index cd29b12..f36c515 100755 --- a/frontend/views/project/index.php +++ b/frontend/views/project/index.php @@ -1,99 +1,31 @@ title = 'Фитнесс клуб Buena Vista в Детмольте, Германия'; + $this->title = 'Галерея объектов'; $this->params[ 'breadcrumbs' ][] = $this->title; ?> +
    title; ?>
    -
    -
    -
    -
    title;?>
    -
    -
    -
    - -
    -
    -

    Использован декор Орех кантри однополосный из коллекции Novara V2

    -

    Надежное с безупречным внешним видом напольное покрытие - залог уюта и тепла в Вашем доме. В этом плане Еgger ламинат выглядит отличным решением, позволяющим ощутить прилив жизненной энергии, исполнению мечты за счет разнообразия выбора изделия, уникальных характеристик и свойств. Благодаря высокой прочности и разной технологии по обработке поверхности ламинат Еgger используеться в качестве напольного покрытия не только в частных жилых домах, но и в коммерческих помещениях.

    -
    -
    -
    - - -
    -
    - -
    + $dataProvider, + 'itemView' => '_list_item', + 'itemOptions' => [ + 'class' => 'row', + ], + 'layout' => '{items}', + 'options' => [ + 'class' => 'style new_articles-wr', + ], + ]); + ?>
    \ No newline at end of file diff --git a/frontend/views/project/view.php b/frontend/views/project/view.php new file mode 100755 index 0000000..8c43274 --- /dev/null +++ b/frontend/views/project/view.php @@ -0,0 +1,114 @@ +title = $model->title; + $this->params['breadcrumbs'][] = [ + 'url' => ['/project'], + 'label' => 'Галерея объектов', + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
    +
    +
    +
    +
    title; ?>
    +
    +
    +
    + images)) { + $image = current($model->images); + echo ArtboxImageHelper::getImage($image->getImageUrl(), 'article_list'); + } else { + echo ArtboxImageHelper::getImage('/storage/no-image', 'article_list'); + } + ?> +
    +
    + description; + ?> +
    +
    + images) && count($model->images) > 1) { + $images = array_slice($model->images, 1); + ?> +
    + + +
    + +
    + +
    +
    \ No newline at end of file diff --git a/frontend/views/site/about.php b/frontend/views/site/about.php deleted file mode 100755 index b85583c..0000000 --- a/frontend/views/site/about.php +++ /dev/null @@ -1,26 +0,0 @@ -title = 'О компании'; - $this->params[ 'breadcrumbs' ][] = $this->title; -?> -
    title; ?>
    -
    -
    -
    - -
    -
    -

    В 1991 году промышленная группа WITEX® одной из первых в Германии начала производство ламинированных полов. Сегодня WITEX® один из самых успешных брендов на мировом рынке. WITEX® экспортирует свою продукцию более чем в 70 стран мира.

    -

    Ламинированные полы WITEX® развились в бренд , который отличается превосходным качеством и разнообразием коллекций. Широкий ассортимент продуктов и услуг вместе с аксессуарами для укладки составляют наш каталог для профессионалов.

    -

    Благодаря постоянным инновациям и оптимизации производства мы до сегодняшнего дня активно участвуем в развитии ламинированных напольных покрытий, превращаем ламинат в разносторонний качественный продукт.

    -

    Функциональность и индивидуальность. Интересные идеи и внимание к деталям - путь к новому качеству жизни. В этом философия компании и бренда WITEX®

    -
    -
    -
    - diff --git a/frontend/views/site/certificates.php b/frontend/views/site/certificates.php new file mode 100644 index 0000000..4e91388 --- /dev/null +++ b/frontend/views/site/certificates.php @@ -0,0 +1,22 @@ +title = 'сертификаты'; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
    title?>
    +
    +
    +
    +
    +
    20110523 WUA WITEX GERMANY. Distributor
    + +
    +
    +
    Висновок СЕС_ до 2012.08 WITEX. Підлога ламінована_79712
    + +
    +
    +
    \ No newline at end of file diff --git a/frontend/views/site/contact.php b/frontend/views/site/contact.php index f58e1fa..a4bc6d0 100755 --- a/frontend/views/site/contact.php +++ b/frontend/views/site/contact.php @@ -3,7 +3,6 @@ /** * @var $this yii\web\View */ - use yii\helpers\Html; $this->title = 'Контакты'; $this->params[ 'breadcrumbs' ][] = $this->title; @@ -19,12 +18,27 @@ Контрактный отдел: (044) 503-00-33,
    Отдел по работе с дизайнерами и архитекторами: (044) 503-00-30

    +

    e-mail: info@witex.ua

    -

    - registerJs(" + function initMap() { + var myLatLng = {lat: 50.524860, lng: 30.482552}; + var map = new google.maps.Map(document.getElementById('contact-map'), { + zoom: 17, + center: myLatLng + }); + var marker = new google.maps.Marker({ + position: myLatLng, + map: map, + title: 'ВІТЕКС УКРАЇНА!' + }); + } + ", $this::POS_BEGIN); + ?> + registerJsFile('https://maps.googleapis.com/maps/api/js?key=AIzaSyCaeB8Lppsl-JqjsGWVHxxMQ3WqU8vGlOQ&callback=initMap'); ?> -

    Восточная дирекция
    diff --git a/frontend/views/site/page.php b/frontend/views/site/page.php new file mode 100755 index 0000000..5efb9b7 --- /dev/null +++ b/frontend/views/site/page.php @@ -0,0 +1,17 @@ +title = $model->title; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
    title; ?>
    +
    + body; + ?> +
    + diff --git a/frontend/views/site/service.php b/frontend/views/site/service.php deleted file mode 100755 index c7a2983..0000000 --- a/frontend/views/site/service.php +++ /dev/null @@ -1,31 +0,0 @@ -title = 'Услуги'; - $this->params[ 'breadcrumbs' ][] = $this->title; -?> -
    title;?>
    -
    -
    -
    - -
    -
    -

    Компания "Витекс" заботится о своих клиентах и стремится к тому, чтобы процесс покупки в наших магазинах был максимально удобным и выгодным.

    -

    Мы не только предлагаем более 500 разнообразных декоров ламината, паркетной доски и массива от ведущих мировых производителей, мы предлагаем Вам новые решения для создания неповторимого стиля вашего дома.

    -

    Центральный офис находится в Киеве по адресу:

    -
    -
    -
      -
    • ООО Витекс Украина
    • -
    • ул. Богатырская, 11, оф. 705
    • -
    • тел.: (044) 503-73-76
    • -
    -
    -
    -
    \ No newline at end of file diff --git a/frontend/web/css/style.min.css b/frontend/web/css/style.min.css index 9c2ebd4..061c523 100644 --- a/frontend/web/css/style.min.css +++ b/frontend/web/css/style.min.css @@ -41,6 +41,28 @@ input, textarea, button { top:325px; right: -68px; } +.question-form span { + position: absolute; + min-width: 22px; + height: 22px; + padding: 0 4px; + line-height: 22px; + color: #fff; + background: #ed1c24; + font-size: 13px; + top: -10px; + right: -10px; + transform: rotate(90deg); + -webkit-transform: rotate(90deg); + border-radius: 22px; + text-align: center; +} +.calc-menu .question-form span { + transform: rotate(0deg); + -webkit-transform: rotate(0deg); + right: -26px; + top: -16px; +} /***header***/ .section-box-header { background: #fff; @@ -890,8 +912,278 @@ ul.main-menu li:first-child ul li a:before {display: none;} .mb-im-f-4 {} .mb-im-f-5 {text-align: right; display: table;} +.certificate_f { + text-decoration: none; + font-size: 13px; + color: #939598; + font-weight: 300; + padding-left: 25px; + position: relative; +} +.certificate_f:before { + content: ''; + position: absolute; + width: 20px; + height: 26px; + left: 0; + top: 50%; + margin-top: -13px; + background: url("../images/ico/ico-12.png") no-repeat; +} + +/*****forms*****/ +#overlay { + display: none; + /*display: block!important;*/ + width: 100%; + height: 100%; + position: fixed; + top: 0; + left: 0; + z-index: 99999; + background: #000; + opacity: 0.8; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; +} +.modal-form, #success-form { + width: 810px; + background: #fff; + position: absolute; + left: 50%; + margin-left: -405px; + top: 20px; + opacity: 0; + /*opacity: 1;*/ + z-index: 999991; + display: none; + /*display: block!important;*/ +} +#success-form { + height: 216px; + background: #fff; +} +#success-form .txt-success { + width: 810px; + height: 216px; + display: table-cell; + vertical-align: middle; + text-align: center; +} +.form-wr { + width: 100%; + float: left; + background: #fff; + position: relative; +} +#close-form { + width: 34px; + height: 34px; + background: url("../images/ico/ico-13.png") no-repeat; + position: absolute; + top: -57px; + right: -61px; + cursor: pointer; + z-index: 999; +} +.form-title { + font-size: 24px; + font-weight: 700; + width: 100%; + float: left; + text-align: center; + margin-top: 34px; +} + + +.modal-form form { + width: 100%; + float: left; + padding: 0 150px; + margin-bottom: 40px; +} +.input-wr { + width: 100%; + float: left; + position: relative; + margin-top: 21px; +} + +.modal-form form label { + font-size: 14px; + font-weight: 700; + text-transform: uppercase; + width: 150px; + text-align: right; + display: block; + line-height: 32px; + height: 30px; + float: left; + padding-right: 30px; + position: relative; +} +.modal-form form .required label:before { + content: '*'; + position: absolute; + top: 0; + right: 23px; + line-height: 30px; + color: #ed1c24; + font-size: 14px; + +} +.modal-form form input, .modal-form form textarea { + width: 360px; + max-width: 360px; + float: right; + height: 30px; + padding-left: 10px; +} +.modal-form form input { + outline: none!important; + font-size: 18px; + + border-top: 0; + border-left: 0; + border-right: 0; + border-bottom: 1px solid #dedfe0; +} +.modal-form form textarea { + + max-height: 30px; + border-top: 0; + border-left: 0; + border-right: 0; + border-bottom: 1px solid #dedfe0; + resize: none; +} +.modal-form form input:focus, .modal-form form textarea:focus {border-bottom: 1px solid #a7a7a7;transition: 0.2s;-webkit-transition: 0.2s;} +.modal-form form .has-error input, .modal-form form .has-error textarea { + border-bottom: 1px solid #ed1c24; +} +.modal-form form .help-block { + display: none; + position: absolute; + right: 0; + bottom: 1px; + width: 95px; + background: #fff; + height: 100%; +} +.modal-form form .has-error .help-block {display: block;} +.modal-form form .has-error .help-block:before { + position: absolute; + content: 'ошибка ввода'; + font-size: 13px; + line-height: 30px; + color: #ed1c24; + top: 0; + right: 0; + display: block !important; + width: 100%; + text-align: right; +} +.button-wr {width: 360px;float: right; margin-top: 40px;} +.modal-form form button[type="submit"] { + display: block; + margin: 0 auto; + width: 174px; + height: 40px; + line-height: 40px; + outline: none !important; + text-align: center; + text-transform: uppercase; + border: 1px solid #939598; + color: inherit; + font-size: 11px; + font-weight: 700; + cursor: pointer; + background: #fff; + + +} +.modal-form form button[type="submit"]:hover { + background: #939598; + color: #fff; + +} +.modal-form form button[type="submit"]:hover:active { + background: #68696b; +} + +.form-product-wr { + width: 100%; + height: 241px; + overflow: hidden; + float: left; + margin-top: 40px; +} +.scrollbar_ {height: 241px; + overflow-y: hidden;} +.form-product-wr table { + padding: 0; + border: 0; + collapse: 0; +} +.form-product-wr table tr { + width: 100%; + float: left; + margin-top: 9px; + position: relative; +} +.form-product-wr table tr:first-child {margin-top: 0;} +.form-product-wr table tr td { + min-height: 67px; + width: 360px; + position: relative; + padding-right: 50px; +} +.form-product-wr table tr td:first-child { + width: 150px; + text-align: right; + padding-right: 30px; +} +.form-product-wr table tr td.remove_ { + content: ''; + position: absolute; + right: 0; + top: 50%; + margin-top: -8px; + width: 16px !important; + height: 16px; + background: url("../images/ico/ico-14.png") no-repeat; + cursor: pointer; +} +.form-product-wr table tr td.remove_:hover { + background: url("../images/ico/ico-15.png") no-repeat; +} +.form-product-wr table tr td:first-child:before {display: none;} + + +.form-product-wr table tr td:first-child img {vertical-align: middle} +.form-product-wr table tr td a { + text-decoration: none; + font-size: 13px; + color: inherit; +} +.form-product-wr table tr td a span { + font-weight: 700; +} +.form-product-wr table tr td a span:first-child { + font-weight: 400; + text-transform: uppercase; +} +._more_ { + position: absolute; + left: 0; + bottom: 9px; + text-decoration: none; + font-size: 13px; + color: #939598; +} +._more_:hover {text-decoration: underline;} + /**********/ /*****home*****/ .margin-top {margin-top: 30px;} @@ -1303,14 +1595,14 @@ ul.breadcrumb li a { margin-top: 28px; } .brand-main-txt {margin-top: -2px; padding-bottom: 53px;} -.content-txt p, .brand-main-txt p, .brand-list-desc-txt p, .products-txt p, .service-txt p, .artile-view-txt p { +.content-txt p, .brand-main-txt p, .brand-list-desc-txt p, .products-txt p, .service-txt p, .artile-view-txt p, .tabs-content p { font-size: 13px; width: 100%; float: left; line-height: 16px; margin-top: 15px; } -.products-txt p, .brand-list-desc-txt p {float: none;} +.products-txt p, .brand-list-desc-txt p, .tabs-content p {float: none;} .content-txt p:first-child, .brand-main-txt p:first-child, .brand-list-desc-txt p:first-child, .artile-view-txt p:first-of-type {margin-top: 0} .brand-link a { @@ -1371,28 +1663,37 @@ ul.breadcrumb li a { overflow: hidden; } .brand-list-desc img {max-width: 100%;float: left;} -.brands-list { +.brands-list, .collection-list ul { padding-left: 15px; margin-top: 4px; padding-right: 15px; box-sizing: content-box; overflow: hidden; } -.brands-list li { +.collection-list ul { + margin-top: -26px; + padding: 0; + margin-left: -30px; +} +.brands-list li, .collection-list ul li { float: left; width: 116px; list-style: none; margin-right: 30px; margin-top: 26px; } -.brands-list li:last-child {margin-right: 0;} +.collection-list ul li { + margin-right: 0; + margin-left: 30px; +} +.brands-list li:last-child, .collection-list ul li:last-child {margin-right: 0;} -.brands-list li a { +.brands-list li a, .collection-list ul li a { text-decoration: none; color: inherit; } -.brands-list li a p { +.brands-list li a p, .collection-list ul li a p { font-size: 13px; color: inherit; width: 100%; @@ -1403,12 +1704,12 @@ ul.breadcrumb li a { overflow: hidden; margin-top: 9px; } -.brands-list li a div { +.brands-list li a div, .collection-list ul li a div { width: 116px; height: 116px; position: relative; } -.brands-list li a div:before { +.brands-list li a div:before, .collection-list ul li a div:before { content: ''; position: absolute; top: 0; @@ -1419,20 +1720,24 @@ ul.breadcrumb li a { opacity: 0; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; } -.brands-list li a div img {max-width: 100%;} -.brands-list li a:hover {text-decoration: underline;} -.brands-list li a:hover div:before { +.brands-list li a div img, .collection-list ul li a div img {max-width: 100%;} +.brands-list li a:hover, .collection-list ul li a:hover {text-decoration: underline;} +.brands-list li a:hover div:before, .collection-list ul li.active a div:before { transition: 0.3s; -webkit-transition: 0.3s; opacity: 0.5; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; } +.collection-list ul li a:hover div {opacity: 0.9;transition: 0.2s;-webkit-transition: 0.2s;} + .brands-list_ { width: 100%; float: left; margin-top: 48px; } + + /**********/ /***products***/ .products-title { @@ -1612,8 +1917,141 @@ ul.breadcrumb li a { padding-right: 10px; } +.load_collection { + position: fixed; + width: 100%; + height: 100%; + top: 0; + left: 0; + z-index: 99999; +} +.load_collection:before { + content: ''; + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + background: #fff; + opacity: 0.8; + z-index: 1; +} +.load_collection div { + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + z-index: 2; + background: url("../images/25.gif") 50% 50% no-repeat; +} + +.to_order { + display: block; + margin: 0 auto; + margin-top: 10px; + width: 174px; + height: 40px; + text-decoration: none; + line-height: 40px; + border: 1px solid #939598; + color: #414143; + font-size: 11px; + font-weight: 700; + text-transform: uppercase; + text-align: center; +} +.to_order:hover { + background: #939598; + color: #fff; + transition: 0.2s; + -webkit-transition: 0.2s; +} +.collect-tabs {margin-top: 60px;} + + + +.list-tabs { + padding-left: 55px; + width: 100%; + float: left; + position: relative; +} +.list-tabs:before { + position: absolute; + content: ''; + bottom: 0; + left: 0; + width: 100%; + height: 1px; + background: #dedfe0; + +} +.list-tabs li, .list-tabs li span { + width: 174px; + height: 39px; +} +.list-tabs li { + position: relative; + z-index: 2; + list-style: none; + float: left; + text-decoration: none; + color: inherit; + font-size: 11px; + text-transform: uppercase; + cursor: pointer; + border-left: 1px solid #dedfe0; + border-right: 1px solid #dedfe0; + border-top: 1px solid #dedfe0; + margin-right: 2px; + background: #dedfe0; +} +.list-tabs li span { + text-align: center; + display: table-cell; + vertical-align: middle; +} +.list-tabs li.active-tab { + background: #fff; +} +.tabs-content a { + text-decoration: underline; + color: inherit; +} +.tabs-content a:hover { + text-decoration: none; +} + +.t_content_wr { + margin-top: 13px; +} +.tabs-content { + display: none; +} +.tabs-content .certificate { + width: 100% !important; + height: 500px !important; + margin-top: 25px; +} +.certificate-page .certificate { + width: 450px !important; + height: 500px !important; + margin-top: 15px; +} +.tabs-content .gall-1 { + width: 100%; + float: left; +} +.tabs-content .gall-1 li { + list-style: none; + margin-top: 25px; +} +.tabs-content .gall-1 li a {float: left;} +.tabs-content .gall-1 li a img { +} @@ -1705,6 +2143,332 @@ ul.breadcrumb li a { background: #fff url("../images/ico/ico-11.png") 50% 50% no-repeat; } /**************/ +.certificate-page {margin-top: -30px;} +.title-certificate-pg { + font-weight: 700; + font-size: 18px; + margin-top: 20px; +} + + +/***scrollbar***/ + +.mCustomScrollbar{ -ms-touch-action: pinch-zoom; touch-action: pinch-zoom; /* direct pointer events to js */ } +.mCustomScrollbar.mCS_no_scrollbar, .mCustomScrollbar.mCS_touch_action{ -ms-touch-action: auto; touch-action: auto; } + +.mCustomScrollBox{ /* contains plugin's markup */ + position: relative; + overflow: hidden; + height: 100%; + max-width: 100%; + outline: none; + direction: ltr; +} + +.mCSB_container{ /* contains the original content */ + overflow: hidden; + width: auto; + height: auto; +} + + + +/* +------------------------------------------------------------------------------------------------------------------------ +2. VERTICAL SCROLLBAR +y-axis +------------------------------------------------------------------------------------------------------------------------ +*/ + + + +.mCSB_container.mCS_no_scrollbar_y.mCS_y_hidden{ margin-right: 0; } /* non-visible scrollbar */ + +.mCS-dir-rtl > .mCSB_inside > .mCSB_container{ /* RTL direction/left-side scrollbar */ + margin-right: 0; + margin-left: 30px; +} + +.mCS-dir-rtl > .mCSB_inside > .mCSB_container.mCS_no_scrollbar_y.mCS_y_hidden{ margin-left: 0; } /* RTL direction/left-side scrollbar */ + +.mCSB_scrollTools{ /* contains scrollbar markup (draggable element, dragger rail, buttons etc.) */ + position: absolute; + width: 16px; + height: auto; + left: auto; + top: 0; + right: 0; + bottom: 0; +} + +.mCSB_outside + .mCSB_scrollTools{ right: -26px; } /* scrollbar position: outside */ + +.mCS-dir-rtl > .mCSB_inside > .mCSB_scrollTools, +.mCS-dir-rtl > .mCSB_outside + .mCSB_scrollTools{ /* RTL direction/left-side scrollbar */ + right: auto; + left: 0; +} + +.mCS-dir-rtl > .mCSB_outside + .mCSB_scrollTools{ left: -26px; } /* RTL direction/left-side scrollbar (scrollbar position: outside) */ + +.mCSB_scrollTools .mCSB_draggerContainer{ /* contains the draggable element and dragger rail markup */ + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + height: auto; +} + +.mCSB_scrollTools a + .mCSB_draggerContainer{ margin: 20px 0; } + +.mCSB_scrollTools .mCSB_draggerRail{ + width: 3px; + height: 100%; + margin: 0 auto; + -webkit-border-radius: 16px; -moz-border-radius: 16px; border-radius: 16px; +} + +.mCSB_scrollTools .mCSB_dragger{ /* the draggable element */ + cursor: pointer; + width: 100%; + height: 30px; /* minimum dragger height */ + z-index: 1; +} + +.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar{ /* the dragger element */ + position: relative; + width: 9px; + height: 100%; + margin: 0 auto; + -webkit-border-radius: 16px; -moz-border-radius: 16px; border-radius: 16px; + text-align: center; +} + +.mCSB_scrollTools_vertical.mCSB_scrollTools_onDrag_expand .mCSB_dragger.mCSB_dragger_onDrag_expanded .mCSB_dragger_bar, +.mCSB_scrollTools_vertical.mCSB_scrollTools_onDrag_expand .mCSB_draggerContainer:hover .mCSB_dragger .mCSB_dragger_bar{ width: 12px; /* auto-expanded scrollbar */ } + +.mCSB_scrollTools_vertical.mCSB_scrollTools_onDrag_expand .mCSB_dragger.mCSB_dragger_onDrag_expanded + .mCSB_draggerRail, +.mCSB_scrollTools_vertical.mCSB_scrollTools_onDrag_expand .mCSB_draggerContainer:hover .mCSB_draggerRail{ width: 8px; /* auto-expanded scrollbar */ } + +.mCSB_scrollTools .mCSB_buttonUp, +.mCSB_scrollTools .mCSB_buttonDown{ + display: block; + position: absolute; + height: 20px; + width: 100%; + overflow: hidden; + margin: 0 auto; + cursor: pointer; +} + +.mCSB_scrollTools .mCSB_buttonDown{ bottom: 0; } + + +5. TRANSITIONS + ------------------------------------------------------------------------------------------------------------------------ + */ + +.mCSB_scrollTools, +.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar, +.mCSB_scrollTools .mCSB_buttonUp, +.mCSB_scrollTools .mCSB_buttonDown, +.mCSB_scrollTools .mCSB_buttonLeft, +.mCSB_scrollTools .mCSB_buttonRight{ + -webkit-transition: opacity .2s ease-in-out, background-color .2s ease-in-out; + -moz-transition: opacity .2s ease-in-out, background-color .2s ease-in-out; + -o-transition: opacity .2s ease-in-out, background-color .2s ease-in-out; + transition: opacity .2s ease-in-out, background-color .2s ease-in-out; +} + +.mCSB_scrollTools_vertical.mCSB_scrollTools_onDrag_expand .mCSB_dragger_bar, /* auto-expanded scrollbar */ +.mCSB_scrollTools_vertical.mCSB_scrollTools_onDrag_expand .mCSB_draggerRail, +.mCSB_scrollTools_horizontal.mCSB_scrollTools_onDrag_expand .mCSB_dragger_bar, +.mCSB_scrollTools_horizontal.mCSB_scrollTools_onDrag_expand .mCSB_draggerRail{ + -webkit-transition: width .2s ease-out .2s, height .2s ease-out .2s, + margin-left .2s ease-out .2s, margin-right .2s ease-out .2s, + margin-top .2s ease-out .2s, margin-bottom .2s ease-out .2s, + opacity .2s ease-in-out, background-color .2s ease-in-out; + -moz-transition: width .2s ease-out .2s, height .2s ease-out .2s, + margin-left .2s ease-out .2s, margin-right .2s ease-out .2s, + margin-top .2s ease-out .2s, margin-bottom .2s ease-out .2s, + opacity .2s ease-in-out, background-color .2s ease-in-out; + -o-transition: width .2s ease-out .2s, height .2s ease-out .2s, + margin-left .2s ease-out .2s, margin-right .2s ease-out .2s, + margin-top .2s ease-out .2s, margin-bottom .2s ease-out .2s, + opacity .2s ease-in-out, background-color .2s ease-in-out; + transition: width .2s ease-out .2s, height .2s ease-out .2s, + margin-left .2s ease-out .2s, margin-right .2s ease-out .2s, + margin-top .2s ease-out .2s, margin-bottom .2s ease-out .2s, + opacity .2s ease-in-out, background-color .2s ease-in-out; +} + + + +/* +------------------------------------------------------------------------------------------------------------------------ +6. SCROLLBAR COLORS, OPACITY AND BACKGROUNDS +------------------------------------------------------------------------------------------------------------------------ +*/ + +/* +---------------------------------------- +6.1 THEMES +---------------------------------------- +*/ + +/* default theme ("light") */ + +.mCSB_scrollTools{ opacity: 1!important;} + +.mCS-autoHide > .mCustomScrollBox > .mCSB_scrollTools, +.mCS-autoHide > .mCustomScrollBox ~ .mCSB_scrollTools{ opacity: 0; filter: "alpha(opacity=0)"; -ms-filter: "alpha(opacity=0)"; } + +.mCustomScrollbar > .mCustomScrollBox > .mCSB_scrollTools.mCSB_scrollTools_onDrag, +.mCustomScrollbar > .mCustomScrollBox ~ .mCSB_scrollTools.mCSB_scrollTools_onDrag, +.mCustomScrollBox:hover > .mCSB_scrollTools, +.mCustomScrollBox:hover ~ .mCSB_scrollTools, +.mCS-autoHide:hover > .mCustomScrollBox > .mCSB_scrollTools, +.mCS-autoHide:hover > .mCustomScrollBox ~ .mCSB_scrollTools{ opacity: 1; filter: "alpha(opacity=100)"; -ms-filter: "alpha(opacity=100)"; } + +.mCSB_scrollTools .mCSB_draggerRail{ + background-color: #f2f2f3; +} + +.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar{ + background: #dedfe0; +} + +.mCSB_scrollTools .mCSB_dragger:hover .mCSB_dragger_bar{ + +} +.mCSB_scrollTools .mCSB_dragger:active .mCSB_dragger_bar, +.mCSB_scrollTools .mCSB_dragger.mCSB_dragger_onDrag .mCSB_dragger_bar{ + +} + +/*.mCSB_scrollTools .mCSB_buttonUp,*/ +/*.mCSB_scrollTools .mCSB_buttonDown,*/ +/*.mCSB_scrollTools .mCSB_buttonLeft,*/ +/*.mCSB_scrollTools .mCSB_buttonRight{*/ + /*background-image: url(mCSB_buttons.png); !* css sprites *!*/ + /*background-repeat: no-repeat;*/ + /*opacity: 0.4; filter: "alpha(opacity=40)"; -ms-filter: "alpha(opacity=40)";*/ +/*}*/ + +.mCSB_scrollTools .mCSB_buttonUp{ + background-position: 0 0; + /* + sprites locations + light: 0 0, -16px 0, -32px 0, -48px 0, 0 -72px, -16px -72px, -32px -72px + dark: -80px 0, -96px 0, -112px 0, -128px 0, -80px -72px, -96px -72px, -112px -72px + */ +} + +.mCSB_scrollTools .mCSB_buttonDown{ + background-position: 0 -20px; + /* + sprites locations + light: 0 -20px, -16px -20px, -32px -20px, -48px -20px, 0 -92px, -16px -92px, -32px -92px + dark: -80px -20px, -96px -20px, -112px -20px, -128px -20px, -80px -92px, -96px -92px, -112 -92px + */ +} + +.mCSB_scrollTools .mCSB_buttonLeft{ + background-position: 0 -40px; + /* + sprites locations + light: 0 -40px, -20px -40px, -40px -40px, -60px -40px, 0 -112px, -20px -112px, -40px -112px + dark: -80px -40px, -100px -40px, -120px -40px, -140px -40px, -80px -112px, -100px -112px, -120px -112px + */ +} + +.mCSB_scrollTools .mCSB_buttonRight{ + background-position: 0 -56px; + /* + sprites locations + light: 0 -56px, -20px -56px, -40px -56px, -60px -56px, 0 -128px, -20px -128px, -40px -128px + dark: -80px -56px, -100px -56px, -120px -56px, -140px -56px, -80px -128px, -100px -128px, -120px -128px + */ +} + +.mCSB_scrollTools .mCSB_buttonUp:hover, +.mCSB_scrollTools .mCSB_buttonDown:hover, +.mCSB_scrollTools .mCSB_buttonLeft:hover, +.mCSB_scrollTools .mCSB_buttonRight:hover{ opacity: 0.75; filter: "alpha(opacity=75)"; -ms-filter: "alpha(opacity=75)"; } + +.mCSB_scrollTools .mCSB_buttonUp:active, +.mCSB_scrollTools .mCSB_buttonDown:active, +.mCSB_scrollTools .mCSB_buttonLeft:active, +.mCSB_scrollTools .mCSB_buttonRight:active{ opacity: 0.9; filter: "alpha(opacity=90)"; -ms-filter: "alpha(opacity=90)"; } + + +/* theme: "dark" */ + +/* ---------------------------------------- */ + + + +/* theme: "light-2", "dark-2" */ + +.mCS-light-2.mCSB_scrollTools .mCSB_draggerRail, +.mCS-dark-2.mCSB_scrollTools .mCSB_draggerRail{ + width: 4px; + background-color: #fff; background-color: rgba(255,255,255,0.1); + -webkit-border-radius: 1px; -moz-border-radius: 1px; border-radius: 1px; +} + +.mCS-light-2.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar, +.mCS-dark-2.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar{ + width: 4px; + background-color: #fff; background-color: rgba(255,255,255,0.75); + -webkit-border-radius: 1px; -moz-border-radius: 1px; border-radius: 1px; +} + +.mCS-light-2.mCSB_scrollTools_horizontal .mCSB_draggerRail, +.mCS-dark-2.mCSB_scrollTools_horizontal .mCSB_draggerRail, +.mCS-light-2.mCSB_scrollTools_horizontal .mCSB_dragger .mCSB_dragger_bar, +.mCS-dark-2.mCSB_scrollTools_horizontal .mCSB_dragger .mCSB_dragger_bar{ + width: 100%; + height: 4px; + margin: 6px auto; +} + +.mCS-light-2.mCSB_scrollTools .mCSB_dragger:hover .mCSB_dragger_bar{ background-color: #fff; background-color: rgba(255,255,255,0.85); } + +.mCS-light-2.mCSB_scrollTools .mCSB_dragger:active .mCSB_dragger_bar, +.mCS-light-2.mCSB_scrollTools .mCSB_dragger.mCSB_dragger_onDrag .mCSB_dragger_bar{ background-color: #fff; background-color: rgba(255,255,255,0.9); } + +.mCS-light-2.mCSB_scrollTools .mCSB_buttonUp{ background-position: -32px 0; } + +.mCS-light-2.mCSB_scrollTools .mCSB_buttonDown{ background-position: -32px -20px; } + +.mCS-light-2.mCSB_scrollTools .mCSB_buttonLeft{ background-position: -40px -40px; } + +.mCS-light-2.mCSB_scrollTools .mCSB_buttonRight{ background-position: -40px -56px; } + + + + + + + + + + + +/***************/ + + + + + + + + + + + @@ -1808,6 +2572,16 @@ ul.breadcrumb li a { } +@media (max-width: 950px) { + .modal-form, #success-form { + width: 610px; + margin-left: -305px; + } + .modal-form form {padding: 0 30px;} + + +} + @media (max-width: 940px) { @@ -1820,10 +2594,10 @@ ul.breadcrumb li a { @media (max-width: 896px) { } -@media (max-width: 835px) { - - - +@media (max-width: 835px) {} +@media (max-width: 810px) { + .list-tabs {padding-left: 30px;} + .list-tabs li, .list-tabs li span {width: 160px;} } @@ -1888,7 +2662,7 @@ ul.breadcrumb li a { display: block; height: auto; } - .mb-im-f-4, .mb-im-f-5 {margin-top: 31px;} + .mb-im-f-4, .mb-im-f-5, .mb-im-f-5_1 {margin-top: 31px;height: 34px;} .mb-im-f-3 {margin-top: 15px;} .prefooter .shadow .row {padding-top: 15px; padding-bottom: 15px;} [class*="moz-"], [class*="moz-"] a { @@ -1974,11 +2748,70 @@ ul.breadcrumb li a { } .brands-list_ .brand-list-desc img {margin-bottom: 10px;} + .collection-list ul {margin-top: 10px;} + .tabs-content .gall-1 li a {width: 100%;} + .tabs-content .gall-1 li a img {margin: 0 auto;} + .certificate_f span {display: none;} + .certificate_f {padding-left: 0;width: 20px;height: 26px;display: block;float: left;} + .certificate_f:before { + top: 0; + margin-top: 6px; + } + .list-tabs li {margin-top: 2px} + .modal-form, #success-form { + width: 300px; + margin-left: -150px; + } + .modal-form form {padding: 0 15px;} + .modal-form form label { + text-align: left; + width: auto; + padding-right: 0; + font-size: 11px; + line-height: 20px; + height: 20px; + } + .modal-form form input, .modal-form form textarea { + width: 100%; + border: 1px solid #dedfe0; + } + .modal-form form .required label:before { + right: -7px; + line-height: 20px; + height: 20px; + } + .modal-form form .has-error .help-block {display: none;} + .modal-form form .has-error input, .modal-form form .has-error textarea {border: 1px solid #ed1c24;} + .modal-form form input:focus, .modal-form form textarea:focus { + border: 1px solid #a7a7a7; } + .modal-form form textarea { + height: 50px; + max-height: 50px; + padding-top: 5px; + } + .button-wr { + margin-top: 0; + width: 100%; + } + ._more_ { + width: 100%; + height: 18px; + bottom: -28px; + text-align: center; + } + .form-product-wr table tr td {padding-right: 33px;} + .form-product-wr table tr td:first-child { + padding-right: 5px; + text-align: left; + } +} + + @media (max-width: 668px) { @@ -1992,19 +2825,26 @@ ul.breadcrumb li a { padding-top: 30px; } .box-mosaic a p:before {bottom: 32px;right: 9px;} + .certificate-page .certificate {width: 100% !important;} } @media (max-width: 480px) { } -@media (max-width: 460px) { - +@media (max-width: 460px) { } +@media (max-width: 450px) { + #close-form { + top: -58px; + right: 0;} } + @media (max-width: 400px) { .box-mosaic a p { padding-right: 23px; padding-top: 16px; } .box-mosaic a p:before {bottom: 46px;} + .tabs-content .certificate {height: 300px !important;} + } @media (max-width: 350px) { .box-mosaic a p { diff --git a/frontend/web/images/25.gif b/frontend/web/images/25.gif new file mode 100644 index 0000000..d4ea53f Binary files /dev/null and b/frontend/web/images/25.gif differ diff --git a/frontend/web/images/ico/ico-12.png b/frontend/web/images/ico/ico-12.png new file mode 100644 index 0000000..fe3639b Binary files /dev/null and b/frontend/web/images/ico/ico-12.png differ diff --git a/frontend/web/images/ico/ico-13.png b/frontend/web/images/ico/ico-13.png new file mode 100644 index 0000000..361ffbd Binary files /dev/null and b/frontend/web/images/ico/ico-13.png differ diff --git a/frontend/web/images/ico/ico-14.png b/frontend/web/images/ico/ico-14.png new file mode 100644 index 0000000..57dc22a Binary files /dev/null and b/frontend/web/images/ico/ico-14.png differ diff --git a/frontend/web/images/ico/ico-15.png b/frontend/web/images/ico/ico-15.png new file mode 100644 index 0000000..8a56369 Binary files /dev/null and b/frontend/web/images/ico/ico-15.png differ diff --git a/frontend/web/images/img_garbage/gallery/collect-gal-min-1.jpg b/frontend/web/images/img_garbage/gallery/collect-gal-min-1.jpg new file mode 100644 index 0000000..e29577c Binary files /dev/null and b/frontend/web/images/img_garbage/gallery/collect-gal-min-1.jpg differ diff --git a/frontend/web/images/img_garbage/gallery/collect-gal-min-2.jpg b/frontend/web/images/img_garbage/gallery/collect-gal-min-2.jpg new file mode 100644 index 0000000..1c722de Binary files /dev/null and b/frontend/web/images/img_garbage/gallery/collect-gal-min-2.jpg differ diff --git a/frontend/web/images/img_garbage/gallery/collect-gal-min-3.jpg b/frontend/web/images/img_garbage/gallery/collect-gal-min-3.jpg new file mode 100644 index 0000000..15512c6 Binary files /dev/null and b/frontend/web/images/img_garbage/gallery/collect-gal-min-3.jpg differ diff --git a/frontend/web/images/img_garbage/gallery/collect-gal-min-4.jpg b/frontend/web/images/img_garbage/gallery/collect-gal-min-4.jpg new file mode 100644 index 0000000..893a959 Binary files /dev/null and b/frontend/web/images/img_garbage/gallery/collect-gal-min-4.jpg differ diff --git a/frontend/web/images/img_garbage/gallery/collect-gal-min-5.jpg b/frontend/web/images/img_garbage/gallery/collect-gal-min-5.jpg new file mode 100644 index 0000000..ff91966 Binary files /dev/null and b/frontend/web/images/img_garbage/gallery/collect-gal-min-5.jpg differ diff --git a/frontend/web/images/img_garbage/img-form-1.jpg b/frontend/web/images/img_garbage/img-form-1.jpg new file mode 100644 index 0000000..497362e Binary files /dev/null and b/frontend/web/images/img_garbage/img-form-1.jpg differ diff --git a/frontend/web/images/img_garbage/img-form-2.jpg b/frontend/web/images/img_garbage/img-form-2.jpg new file mode 100644 index 0000000..2bdea57 Binary files /dev/null and b/frontend/web/images/img_garbage/img-form-2.jpg differ diff --git a/frontend/web/images/img_garbage/img-form-3.jpg b/frontend/web/images/img_garbage/img-form-3.jpg new file mode 100644 index 0000000..e353ce3 Binary files /dev/null and b/frontend/web/images/img_garbage/img-form-3.jpg differ diff --git a/frontend/web/js/jquery.mCustomScrollbar.concat.min.js b/frontend/web/js/jquery.mCustomScrollbar.concat.min.js new file mode 100644 index 0000000..6118086 --- /dev/null +++ b/frontend/web/js/jquery.mCustomScrollbar.concat.min.js @@ -0,0 +1,5 @@ +/* == jquery mousewheel plugin == Version: 3.1.13, License: MIT License (MIT) */ +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); +/* == malihu jquery custom scrollbar plugin == Version: 3.1.5, License: MIT License (MIT) */ +!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e:e(jQuery,window,document)}(function(e){!function(t){var o="function"==typeof define&&define.amd,a="undefined"!=typeof module&&module.exports,n="https:"==document.location.protocol?"https:":"http:",i="cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.min.js";o||(a?require("jquery-mousewheel")(e):e.event.special.mousewheel||e("head").append(decodeURI("%3Cscript src="+n+"//"+i+"%3E%3C/script%3E"))),t()}(function(){var t,o="mCustomScrollbar",a="mCS",n=".mCustomScrollbar",i={setTop:0,setLeft:0,axis:"y",scrollbarPosition:"inside",scrollInertia:950,autoDraggerLength:!0,alwaysShowScrollbar:0,snapOffset:0,mouseWheel:{enable:!0,scrollAmount:"auto",axis:"y",deltaFactor:"auto",disableOver:["select","option","keygen","datalist","textarea"]},scrollButtons:{scrollType:"stepless",scrollAmount:"auto"},keyboard:{enable:!0,scrollType:"stepless",scrollAmount:"auto"},contentTouchScroll:25,documentTouchScroll:!0,advanced:{autoScrollOnFocus:"input,textarea,select,button,datalist,keygen,a[tabindex],area,object,[contenteditable='true']",updateOnContentResize:!0,updateOnImageLoad:"auto",autoUpdateTimeout:60},theme:"light",callbacks:{onTotalScrollOffset:0,onTotalScrollBackOffset:0,alwaysTriggerOffsets:!0}},r=0,l={},s=window.attachEvent&&!window.addEventListener?1:0,c=!1,d=["mCSB_dragger_onDrag","mCSB_scrollTools_onDrag","mCS_img_loaded","mCS_disabled","mCS_destroyed","mCS_no_scrollbar","mCS-autoHide","mCS-dir-rtl","mCS_no_scrollbar_y","mCS_no_scrollbar_x","mCS_y_hidden","mCS_x_hidden","mCSB_draggerContainer","mCSB_buttonUp","mCSB_buttonDown","mCSB_buttonLeft","mCSB_buttonRight"],u={init:function(t){var t=e.extend(!0,{},i,t),o=f.call(this);if(t.live){var s=t.liveSelector||this.selector||n,c=e(s);if("off"===t.live)return void m(s);l[s]=setTimeout(function(){c.mCustomScrollbar(t),"once"===t.live&&c.length&&m(s)},500)}else m(s);return t.setWidth=t.set_width?t.set_width:t.setWidth,t.setHeight=t.set_height?t.set_height:t.setHeight,t.axis=t.horizontalScroll?"x":p(t.axis),t.scrollInertia=t.scrollInertia>0&&t.scrollInertia<17?17:t.scrollInertia,"object"!=typeof t.mouseWheel&&1==t.mouseWheel&&(t.mouseWheel={enable:!0,scrollAmount:"auto",axis:"y",preventDefault:!1,deltaFactor:"auto",normalizeDelta:!1,invert:!1}),t.mouseWheel.scrollAmount=t.mouseWheelPixels?t.mouseWheelPixels:t.mouseWheel.scrollAmount,t.mouseWheel.normalizeDelta=t.advanced.normalizeMouseWheelDelta?t.advanced.normalizeMouseWheelDelta:t.mouseWheel.normalizeDelta,t.scrollButtons.scrollType=g(t.scrollButtons.scrollType),h(t),e(o).each(function(){var o=e(this);if(!o.data(a)){o.data(a,{idx:++r,opt:t,scrollRatio:{y:null,x:null},overflowed:null,contentReset:{y:null,x:null},bindEvents:!1,tweenRunning:!1,sequential:{},langDir:o.css("direction"),cbOffsets:null,trigger:null,poll:{size:{o:0,n:0},img:{o:0,n:0},change:{o:0,n:0}}});var n=o.data(a),i=n.opt,l=o.data("mcs-axis"),s=o.data("mcs-scrollbar-position"),c=o.data("mcs-theme");l&&(i.axis=l),s&&(i.scrollbarPosition=s),c&&(i.theme=c,h(i)),v.call(this),n&&i.callbacks.onCreate&&"function"==typeof i.callbacks.onCreate&&i.callbacks.onCreate.call(this),e("#mCSB_"+n.idx+"_container img:not(."+d[2]+")").addClass(d[2]),u.update.call(null,o)}})},update:function(t,o){var n=t||f.call(this);return e(n).each(function(){var t=e(this);if(t.data(a)){var n=t.data(a),i=n.opt,r=e("#mCSB_"+n.idx+"_container"),l=e("#mCSB_"+n.idx),s=[e("#mCSB_"+n.idx+"_dragger_vertical"),e("#mCSB_"+n.idx+"_dragger_horizontal")];if(!r.length)return;n.tweenRunning&&Q(t),o&&n&&i.callbacks.onBeforeUpdate&&"function"==typeof i.callbacks.onBeforeUpdate&&i.callbacks.onBeforeUpdate.call(this),t.hasClass(d[3])&&t.removeClass(d[3]),t.hasClass(d[4])&&t.removeClass(d[4]),l.css("max-height","none"),l.height()!==t.height()&&l.css("max-height",t.height()),_.call(this),"y"===i.axis||i.advanced.autoExpandHorizontalScroll||r.css("width",x(r)),n.overflowed=y.call(this),M.call(this),i.autoDraggerLength&&S.call(this),b.call(this),T.call(this);var c=[Math.abs(r[0].offsetTop),Math.abs(r[0].offsetLeft)];"x"!==i.axis&&(n.overflowed[0]?s[0].height()>s[0].parent().height()?B.call(this):(G(t,c[0].toString(),{dir:"y",dur:0,overwrite:"none"}),n.contentReset.y=null):(B.call(this),"y"===i.axis?k.call(this):"yx"===i.axis&&n.overflowed[1]&&G(t,c[1].toString(),{dir:"x",dur:0,overwrite:"none"}))),"y"!==i.axis&&(n.overflowed[1]?s[1].width()>s[1].parent().width()?B.call(this):(G(t,c[1].toString(),{dir:"x",dur:0,overwrite:"none"}),n.contentReset.x=null):(B.call(this),"x"===i.axis?k.call(this):"yx"===i.axis&&n.overflowed[0]&&G(t,c[0].toString(),{dir:"y",dur:0,overwrite:"none"}))),o&&n&&(2===o&&i.callbacks.onImageLoad&&"function"==typeof i.callbacks.onImageLoad?i.callbacks.onImageLoad.call(this):3===o&&i.callbacks.onSelectorChange&&"function"==typeof i.callbacks.onSelectorChange?i.callbacks.onSelectorChange.call(this):i.callbacks.onUpdate&&"function"==typeof i.callbacks.onUpdate&&i.callbacks.onUpdate.call(this)),N.call(this)}})},scrollTo:function(t,o){if("undefined"!=typeof t&&null!=t){var n=f.call(this);return e(n).each(function(){var n=e(this);if(n.data(a)){var i=n.data(a),r=i.opt,l={trigger:"external",scrollInertia:r.scrollInertia,scrollEasing:"mcsEaseInOut",moveDragger:!1,timeout:60,callbacks:!0,onStart:!0,onUpdate:!0,onComplete:!0},s=e.extend(!0,{},l,o),c=Y.call(this,t),d=s.scrollInertia>0&&s.scrollInertia<17?17:s.scrollInertia;c[0]=X.call(this,c[0],"y"),c[1]=X.call(this,c[1],"x"),s.moveDragger&&(c[0]*=i.scrollRatio.y,c[1]*=i.scrollRatio.x),s.dur=ne()?0:d,setTimeout(function(){null!==c[0]&&"undefined"!=typeof c[0]&&"x"!==r.axis&&i.overflowed[0]&&(s.dir="y",s.overwrite="all",G(n,c[0].toString(),s)),null!==c[1]&&"undefined"!=typeof c[1]&&"y"!==r.axis&&i.overflowed[1]&&(s.dir="x",s.overwrite="none",G(n,c[1].toString(),s))},s.timeout)}})}},stop:function(){var t=f.call(this);return e(t).each(function(){var t=e(this);t.data(a)&&Q(t)})},disable:function(t){var o=f.call(this);return e(o).each(function(){var o=e(this);if(o.data(a)){o.data(a);N.call(this,"remove"),k.call(this),t&&B.call(this),M.call(this,!0),o.addClass(d[3])}})},destroy:function(){var t=f.call(this);return e(t).each(function(){var n=e(this);if(n.data(a)){var i=n.data(a),r=i.opt,l=e("#mCSB_"+i.idx),s=e("#mCSB_"+i.idx+"_container"),c=e(".mCSB_"+i.idx+"_scrollbar");r.live&&m(r.liveSelector||e(t).selector),N.call(this,"remove"),k.call(this),B.call(this),n.removeData(a),$(this,"mcs"),c.remove(),s.find("img."+d[2]).removeClass(d[2]),l.replaceWith(s.contents()),n.removeClass(o+" _"+a+"_"+i.idx+" "+d[6]+" "+d[7]+" "+d[5]+" "+d[3]).addClass(d[4])}})}},f=function(){return"object"!=typeof e(this)||e(this).length<1?n:this},h=function(t){var o=["rounded","rounded-dark","rounded-dots","rounded-dots-dark"],a=["rounded-dots","rounded-dots-dark","3d","3d-dark","3d-thick","3d-thick-dark","inset","inset-dark","inset-2","inset-2-dark","inset-3","inset-3-dark"],n=["minimal","minimal-dark"],i=["minimal","minimal-dark"],r=["minimal","minimal-dark"];t.autoDraggerLength=e.inArray(t.theme,o)>-1?!1:t.autoDraggerLength,t.autoExpandScrollbar=e.inArray(t.theme,a)>-1?!1:t.autoExpandScrollbar,t.scrollButtons.enable=e.inArray(t.theme,n)>-1?!1:t.scrollButtons.enable,t.autoHideScrollbar=e.inArray(t.theme,i)>-1?!0:t.autoHideScrollbar,t.scrollbarPosition=e.inArray(t.theme,r)>-1?"outside":t.scrollbarPosition},m=function(e){l[e]&&(clearTimeout(l[e]),$(l,e))},p=function(e){return"yx"===e||"xy"===e||"auto"===e?"yx":"x"===e||"horizontal"===e?"x":"y"},g=function(e){return"stepped"===e||"pixels"===e||"step"===e||"click"===e?"stepped":"stepless"},v=function(){var t=e(this),n=t.data(a),i=n.opt,r=i.autoExpandScrollbar?" "+d[1]+"_expand":"",l=["
    ","
    "],s="yx"===i.axis?"mCSB_vertical_horizontal":"x"===i.axis?"mCSB_horizontal":"mCSB_vertical",c="yx"===i.axis?l[0]+l[1]:"x"===i.axis?l[1]:l[0],u="yx"===i.axis?"
    ":"",f=i.autoHideScrollbar?" "+d[6]:"",h="x"!==i.axis&&"rtl"===n.langDir?" "+d[7]:"";i.setWidth&&t.css("width",i.setWidth),i.setHeight&&t.css("height",i.setHeight),i.setLeft="y"!==i.axis&&"rtl"===n.langDir?"989999px":i.setLeft,t.addClass(o+" _"+a+"_"+n.idx+f+h).wrapInner("
    ");var m=e("#mCSB_"+n.idx),p=e("#mCSB_"+n.idx+"_container");"y"===i.axis||i.advanced.autoExpandHorizontalScroll||p.css("width",x(p)),"outside"===i.scrollbarPosition?("static"===t.css("position")&&t.css("position","relative"),t.css("overflow","visible"),m.addClass("mCSB_outside").after(c)):(m.addClass("mCSB_inside").append(c),p.wrap(u)),w.call(this);var g=[e("#mCSB_"+n.idx+"_dragger_vertical"),e("#mCSB_"+n.idx+"_dragger_horizontal")];g[0].css("min-height",g[0].height()),g[1].css("min-width",g[1].width())},x=function(t){var o=[t[0].scrollWidth,Math.max.apply(Math,t.children().map(function(){return e(this).outerWidth(!0)}).get())],a=t.parent().width();return o[0]>a?o[0]:o[1]>a?o[1]:"100%"},_=function(){var t=e(this),o=t.data(a),n=o.opt,i=e("#mCSB_"+o.idx+"_container");if(n.advanced.autoExpandHorizontalScroll&&"y"!==n.axis){i.css({width:"auto","min-width":0,"overflow-x":"scroll"});var r=Math.ceil(i[0].scrollWidth);3===n.advanced.autoExpandHorizontalScroll||2!==n.advanced.autoExpandHorizontalScroll&&r>i.parent().width()?i.css({width:r,"min-width":"100%","overflow-x":"inherit"}):i.css({"overflow-x":"inherit",position:"absolute"}).wrap("
    ").css({width:Math.ceil(i[0].getBoundingClientRect().right+.4)-Math.floor(i[0].getBoundingClientRect().left),"min-width":"100%",position:"relative"}).unwrap()}},w=function(){var t=e(this),o=t.data(a),n=o.opt,i=e(".mCSB_"+o.idx+"_scrollbar:first"),r=oe(n.scrollButtons.tabindex)?"tabindex='"+n.scrollButtons.tabindex+"'":"",l=["","","",""],s=["x"===n.axis?l[2]:l[0],"x"===n.axis?l[3]:l[1],l[2],l[3]];n.scrollButtons.enable&&i.prepend(s[0]).append(s[1]).next(".mCSB_scrollTools").prepend(s[2]).append(s[3])},S=function(){var t=e(this),o=t.data(a),n=e("#mCSB_"+o.idx),i=e("#mCSB_"+o.idx+"_container"),r=[e("#mCSB_"+o.idx+"_dragger_vertical"),e("#mCSB_"+o.idx+"_dragger_horizontal")],l=[n.height()/i.outerHeight(!1),n.width()/i.outerWidth(!1)],c=[parseInt(r[0].css("min-height")),Math.round(l[0]*r[0].parent().height()),parseInt(r[1].css("min-width")),Math.round(l[1]*r[1].parent().width())],d=s&&c[1]r&&(r=s),c>l&&(l=c),[r>n.height(),l>n.width()]},B=function(){var t=e(this),o=t.data(a),n=o.opt,i=e("#mCSB_"+o.idx),r=e("#mCSB_"+o.idx+"_container"),l=[e("#mCSB_"+o.idx+"_dragger_vertical"),e("#mCSB_"+o.idx+"_dragger_horizontal")];if(Q(t),("x"!==n.axis&&!o.overflowed[0]||"y"===n.axis&&o.overflowed[0])&&(l[0].add(r).css("top",0),G(t,"_resetY")),"y"!==n.axis&&!o.overflowed[1]||"x"===n.axis&&o.overflowed[1]){var s=dx=0;"rtl"===o.langDir&&(s=i.width()-r.outerWidth(!1),dx=Math.abs(s/o.scrollRatio.x)),r.css("left",s),l[1].css("left",dx),G(t,"_resetX")}},T=function(){function t(){r=setTimeout(function(){e.event.special.mousewheel?(clearTimeout(r),W.call(o[0])):t()},100)}var o=e(this),n=o.data(a),i=n.opt;if(!n.bindEvents){if(I.call(this),i.contentTouchScroll&&D.call(this),E.call(this),i.mouseWheel.enable){var r;t()}P.call(this),U.call(this),i.advanced.autoScrollOnFocus&&H.call(this),i.scrollButtons.enable&&F.call(this),i.keyboard.enable&&q.call(this),n.bindEvents=!0}},k=function(){var t=e(this),o=t.data(a),n=o.opt,i=a+"_"+o.idx,r=".mCSB_"+o.idx+"_scrollbar",l=e("#mCSB_"+o.idx+",#mCSB_"+o.idx+"_container,#mCSB_"+o.idx+"_container_wrapper,"+r+" ."+d[12]+",#mCSB_"+o.idx+"_dragger_vertical,#mCSB_"+o.idx+"_dragger_horizontal,"+r+">a"),s=e("#mCSB_"+o.idx+"_container");n.advanced.releaseDraggableSelectors&&l.add(e(n.advanced.releaseDraggableSelectors)),n.advanced.extraDraggableSelectors&&l.add(e(n.advanced.extraDraggableSelectors)),o.bindEvents&&(e(document).add(e(!A()||top.document)).unbind("."+i),l.each(function(){e(this).unbind("."+i)}),clearTimeout(t[0]._focusTimeout),$(t[0],"_focusTimeout"),clearTimeout(o.sequential.step),$(o.sequential,"step"),clearTimeout(s[0].onCompleteTimeout),$(s[0],"onCompleteTimeout"),o.bindEvents=!1)},M=function(t){var o=e(this),n=o.data(a),i=n.opt,r=e("#mCSB_"+n.idx+"_container_wrapper"),l=r.length?r:e("#mCSB_"+n.idx+"_container"),s=[e("#mCSB_"+n.idx+"_scrollbar_vertical"),e("#mCSB_"+n.idx+"_scrollbar_horizontal")],c=[s[0].find(".mCSB_dragger"),s[1].find(".mCSB_dragger")];"x"!==i.axis&&(n.overflowed[0]&&!t?(s[0].add(c[0]).add(s[0].children("a")).css("display","block"),l.removeClass(d[8]+" "+d[10])):(i.alwaysShowScrollbar?(2!==i.alwaysShowScrollbar&&c[0].css("display","none"),l.removeClass(d[10])):(s[0].css("display","none"),l.addClass(d[10])),l.addClass(d[8]))),"y"!==i.axis&&(n.overflowed[1]&&!t?(s[1].add(c[1]).add(s[1].children("a")).css("display","block"),l.removeClass(d[9]+" "+d[11])):(i.alwaysShowScrollbar?(2!==i.alwaysShowScrollbar&&c[1].css("display","none"),l.removeClass(d[11])):(s[1].css("display","none"),l.addClass(d[11])),l.addClass(d[9]))),n.overflowed[0]||n.overflowed[1]?o.removeClass(d[5]):o.addClass(d[5])},O=function(t){var o=t.type,a=t.target.ownerDocument!==document&&null!==frameElement?[e(frameElement).offset().top,e(frameElement).offset().left]:null,n=A()&&t.target.ownerDocument!==top.document&&null!==frameElement?[e(t.view.frameElement).offset().top,e(t.view.frameElement).offset().left]:[0,0];switch(o){case"pointerdown":case"MSPointerDown":case"pointermove":case"MSPointerMove":case"pointerup":case"MSPointerUp":return a?[t.originalEvent.pageY-a[0]+n[0],t.originalEvent.pageX-a[1]+n[1],!1]:[t.originalEvent.pageY,t.originalEvent.pageX,!1];case"touchstart":case"touchmove":case"touchend":var i=t.originalEvent.touches[0]||t.originalEvent.changedTouches[0],r=t.originalEvent.touches.length||t.originalEvent.changedTouches.length;return t.target.ownerDocument!==document?[i.screenY,i.screenX,r>1]:[i.pageY,i.pageX,r>1];default:return a?[t.pageY-a[0]+n[0],t.pageX-a[1]+n[1],!1]:[t.pageY,t.pageX,!1]}},I=function(){function t(e,t,a,n){if(h[0].idleTimer=d.scrollInertia<233?250:0,o.attr("id")===f[1])var i="x",s=(o[0].offsetLeft-t+n)*l.scrollRatio.x;else var i="y",s=(o[0].offsetTop-e+a)*l.scrollRatio.y;G(r,s.toString(),{dir:i,drag:!0})}var o,n,i,r=e(this),l=r.data(a),d=l.opt,u=a+"_"+l.idx,f=["mCSB_"+l.idx+"_dragger_vertical","mCSB_"+l.idx+"_dragger_horizontal"],h=e("#mCSB_"+l.idx+"_container"),m=e("#"+f[0]+",#"+f[1]),p=d.advanced.releaseDraggableSelectors?m.add(e(d.advanced.releaseDraggableSelectors)):m,g=d.advanced.extraDraggableSelectors?e(!A()||top.document).add(e(d.advanced.extraDraggableSelectors)):e(!A()||top.document);m.bind("contextmenu."+u,function(e){e.preventDefault()}).bind("mousedown."+u+" touchstart."+u+" pointerdown."+u+" MSPointerDown."+u,function(t){if(t.stopImmediatePropagation(),t.preventDefault(),ee(t)){c=!0,s&&(document.onselectstart=function(){return!1}),L.call(h,!1),Q(r),o=e(this);var a=o.offset(),l=O(t)[0]-a.top,u=O(t)[1]-a.left,f=o.height()+a.top,m=o.width()+a.left;f>l&&l>0&&m>u&&u>0&&(n=l,i=u),C(o,"active",d.autoExpandScrollbar)}}).bind("touchmove."+u,function(e){e.stopImmediatePropagation(),e.preventDefault();var a=o.offset(),r=O(e)[0]-a.top,l=O(e)[1]-a.left;t(n,i,r,l)}),e(document).add(g).bind("mousemove."+u+" pointermove."+u+" MSPointerMove."+u,function(e){if(o){var a=o.offset(),r=O(e)[0]-a.top,l=O(e)[1]-a.left;if(n===r&&i===l)return;t(n,i,r,l)}}).add(p).bind("mouseup."+u+" touchend."+u+" pointerup."+u+" MSPointerUp."+u,function(){o&&(C(o,"active",d.autoExpandScrollbar),o=null),c=!1,s&&(document.onselectstart=null),L.call(h,!0)})},D=function(){function o(e){if(!te(e)||c||O(e)[2])return void(t=0);t=1,b=0,C=0,d=1,y.removeClass("mCS_touch_action");var o=I.offset();u=O(e)[0]-o.top,f=O(e)[1]-o.left,z=[O(e)[0],O(e)[1]]}function n(e){if(te(e)&&!c&&!O(e)[2]&&(T.documentTouchScroll||e.preventDefault(),e.stopImmediatePropagation(),(!C||b)&&d)){g=K();var t=M.offset(),o=O(e)[0]-t.top,a=O(e)[1]-t.left,n="mcsLinearOut";if(E.push(o),W.push(a),z[2]=Math.abs(O(e)[0]-z[0]),z[3]=Math.abs(O(e)[1]-z[1]),B.overflowed[0])var i=D[0].parent().height()-D[0].height(),r=u-o>0&&o-u>-(i*B.scrollRatio.y)&&(2*z[3]0&&a-f>-(l*B.scrollRatio.x)&&(2*z[2]30)){_=1e3/(v-p);var n="mcsEaseOut",i=2.5>_,r=i?[E[E.length-2],W[W.length-2]]:[0,0];x=i?[o-r[0],a-r[1]]:[o-h,a-m];var u=[Math.abs(x[0]),Math.abs(x[1])];_=i?[Math.abs(x[0]/4),Math.abs(x[1]/4)]:[_,_];var f=[Math.abs(I[0].offsetTop)-x[0]*l(u[0]/_[0],_[0]),Math.abs(I[0].offsetLeft)-x[1]*l(u[1]/_[1],_[1])];w="yx"===T.axis?[f[0],f[1]]:"x"===T.axis?[null,f[1]]:[f[0],null],S=[4*u[0]+T.scrollInertia,4*u[1]+T.scrollInertia];var y=parseInt(T.contentTouchScroll)||0;w[0]=u[0]>y?w[0]:0,w[1]=u[1]>y?w[1]:0,B.overflowed[0]&&s(w[0],S[0],n,"y",L,!1),B.overflowed[1]&&s(w[1],S[1],n,"x",L,!1)}}}function l(e,t){var o=[1.5*t,2*t,t/1.5,t/2];return e>90?t>4?o[0]:o[3]:e>60?t>3?o[3]:o[2]:e>30?t>8?o[1]:t>6?o[0]:t>4?t:o[2]:t>8?t:o[3]}function s(e,t,o,a,n,i){e&&G(y,e.toString(),{dur:t,scrollEasing:o,dir:a,overwrite:n,drag:i})}var d,u,f,h,m,p,g,v,x,_,w,S,b,C,y=e(this),B=y.data(a),T=B.opt,k=a+"_"+B.idx,M=e("#mCSB_"+B.idx),I=e("#mCSB_"+B.idx+"_container"),D=[e("#mCSB_"+B.idx+"_dragger_vertical"),e("#mCSB_"+B.idx+"_dragger_horizontal")],E=[],W=[],R=0,L="yx"===T.axis?"none":"all",z=[],P=I.find("iframe"),H=["touchstart."+k+" pointerdown."+k+" MSPointerDown."+k,"touchmove."+k+" pointermove."+k+" MSPointerMove."+k,"touchend."+k+" pointerup."+k+" MSPointerUp."+k],U=void 0!==document.body.style.touchAction&&""!==document.body.style.touchAction;I.bind(H[0],function(e){o(e)}).bind(H[1],function(e){n(e)}),M.bind(H[0],function(e){i(e)}).bind(H[2],function(e){r(e)}),P.length&&P.each(function(){e(this).bind("load",function(){A(this)&&e(this.contentDocument||this.contentWindow.document).bind(H[0],function(e){o(e),i(e)}).bind(H[1],function(e){n(e)}).bind(H[2],function(e){r(e)})})})},E=function(){function o(){return window.getSelection?window.getSelection().toString():document.selection&&"Control"!=document.selection.type?document.selection.createRange().text:0}function n(e,t,o){d.type=o&&i?"stepped":"stepless",d.scrollAmount=10,j(r,e,t,"mcsLinearOut",o?60:null)}var i,r=e(this),l=r.data(a),s=l.opt,d=l.sequential,u=a+"_"+l.idx,f=e("#mCSB_"+l.idx+"_container"),h=f.parent();f.bind("mousedown."+u,function(){t||i||(i=1,c=!0)}).add(document).bind("mousemove."+u,function(e){if(!t&&i&&o()){var a=f.offset(),r=O(e)[0]-a.top+f[0].offsetTop,c=O(e)[1]-a.left+f[0].offsetLeft;r>0&&r0&&cr?n("on",38):r>h.height()&&n("on",40)),"y"!==s.axis&&l.overflowed[1]&&(0>c?n("on",37):c>h.width()&&n("on",39)))}}).bind("mouseup."+u+" dragend."+u,function(){t||(i&&(i=0,n("off",null)),c=!1)})},W=function(){function t(t,a){if(Q(o),!z(o,t.target)){var r="auto"!==i.mouseWheel.deltaFactor?parseInt(i.mouseWheel.deltaFactor):s&&t.deltaFactor<100?100:t.deltaFactor||100,d=i.scrollInertia;if("x"===i.axis||"x"===i.mouseWheel.axis)var u="x",f=[Math.round(r*n.scrollRatio.x),parseInt(i.mouseWheel.scrollAmount)],h="auto"!==i.mouseWheel.scrollAmount?f[1]:f[0]>=l.width()?.9*l.width():f[0],m=Math.abs(e("#mCSB_"+n.idx+"_container")[0].offsetLeft),p=c[1][0].offsetLeft,g=c[1].parent().width()-c[1].width(),v="y"===i.mouseWheel.axis?t.deltaY||a:t.deltaX;else var u="y",f=[Math.round(r*n.scrollRatio.y),parseInt(i.mouseWheel.scrollAmount)],h="auto"!==i.mouseWheel.scrollAmount?f[1]:f[0]>=l.height()?.9*l.height():f[0],m=Math.abs(e("#mCSB_"+n.idx+"_container")[0].offsetTop),p=c[0][0].offsetTop,g=c[0].parent().height()-c[0].height(),v=t.deltaY||a;"y"===u&&!n.overflowed[0]||"x"===u&&!n.overflowed[1]||((i.mouseWheel.invert||t.webkitDirectionInvertedFromDevice)&&(v=-v),i.mouseWheel.normalizeDelta&&(v=0>v?-1:1),(v>0&&0!==p||0>v&&p!==g||i.mouseWheel.preventDefault)&&(t.stopImmediatePropagation(),t.preventDefault()),t.deltaFactor<5&&!i.mouseWheel.normalizeDelta&&(h=t.deltaFactor,d=17),G(o,(m-v*h).toString(),{dir:u,dur:d}))}}if(e(this).data(a)){var o=e(this),n=o.data(a),i=n.opt,r=a+"_"+n.idx,l=e("#mCSB_"+n.idx),c=[e("#mCSB_"+n.idx+"_dragger_vertical"),e("#mCSB_"+n.idx+"_dragger_horizontal")],d=e("#mCSB_"+n.idx+"_container").find("iframe");d.length&&d.each(function(){e(this).bind("load",function(){A(this)&&e(this.contentDocument||this.contentWindow.document).bind("mousewheel."+r,function(e,o){t(e,o)})})}),l.bind("mousewheel."+r,function(e,o){t(e,o)})}},R=new Object,A=function(t){var o=!1,a=!1,n=null;if(void 0===t?a="#empty":void 0!==e(t).attr("id")&&(a=e(t).attr("id")),a!==!1&&void 0!==R[a])return R[a];if(t){try{var i=t.contentDocument||t.contentWindow.document;n=i.body.innerHTML}catch(r){}o=null!==n}else{try{var i=top.document;n=i.body.innerHTML}catch(r){}o=null!==n}return a!==!1&&(R[a]=o),o},L=function(e){var t=this.find("iframe");if(t.length){var o=e?"auto":"none";t.css("pointer-events",o)}},z=function(t,o){var n=o.nodeName.toLowerCase(),i=t.data(a).opt.mouseWheel.disableOver,r=["select","textarea"];return e.inArray(n,i)>-1&&!(e.inArray(n,r)>-1&&!e(o).is(":focus"))},P=function(){var t,o=e(this),n=o.data(a),i=a+"_"+n.idx,r=e("#mCSB_"+n.idx+"_container"),l=r.parent(),s=e(".mCSB_"+n.idx+"_scrollbar ."+d[12]);s.bind("mousedown."+i+" touchstart."+i+" pointerdown."+i+" MSPointerDown."+i,function(o){c=!0,e(o.target).hasClass("mCSB_dragger")||(t=1)}).bind("touchend."+i+" pointerup."+i+" MSPointerUp."+i,function(){c=!1}).bind("click."+i,function(a){if(t&&(t=0,e(a.target).hasClass(d[12])||e(a.target).hasClass("mCSB_draggerRail"))){Q(o);var i=e(this),s=i.find(".mCSB_dragger");if(i.parent(".mCSB_scrollTools_horizontal").length>0){if(!n.overflowed[1])return;var c="x",u=a.pageX>s.offset().left?-1:1,f=Math.abs(r[0].offsetLeft)-u*(.9*l.width())}else{if(!n.overflowed[0])return;var c="y",u=a.pageY>s.offset().top?-1:1,f=Math.abs(r[0].offsetTop)-u*(.9*l.height())}G(o,f.toString(),{dir:c,scrollEasing:"mcsEaseInOut"})}})},H=function(){var t=e(this),o=t.data(a),n=o.opt,i=a+"_"+o.idx,r=e("#mCSB_"+o.idx+"_container"),l=r.parent();r.bind("focusin."+i,function(){var o=e(document.activeElement),a=r.find(".mCustomScrollBox").length,i=0;o.is(n.advanced.autoScrollOnFocus)&&(Q(t),clearTimeout(t[0]._focusTimeout),t[0]._focusTimer=a?(i+17)*a:0,t[0]._focusTimeout=setTimeout(function(){var e=[ae(o)[0],ae(o)[1]],a=[r[0].offsetTop,r[0].offsetLeft],s=[a[0]+e[0]>=0&&a[0]+e[0]=0&&a[0]+e[1]a");s.bind("contextmenu."+r,function(e){e.preventDefault()}).bind("mousedown."+r+" touchstart."+r+" pointerdown."+r+" MSPointerDown."+r+" mouseup."+r+" touchend."+r+" pointerup."+r+" MSPointerUp."+r+" mouseout."+r+" pointerout."+r+" MSPointerOut."+r+" click."+r,function(a){function r(e,o){i.scrollAmount=n.scrollButtons.scrollAmount,j(t,e,o)}if(a.preventDefault(),ee(a)){var l=e(this).attr("class");switch(i.type=n.scrollButtons.scrollType,a.type){case"mousedown":case"touchstart":case"pointerdown":case"MSPointerDown":if("stepped"===i.type)return;c=!0,o.tweenRunning=!1,r("on",l);break;case"mouseup":case"touchend":case"pointerup":case"MSPointerUp":case"mouseout":case"pointerout":case"MSPointerOut":if("stepped"===i.type)return;c=!1,i.dir&&r("off",l);break;case"click":if("stepped"!==i.type||o.tweenRunning)return;r("on",l)}}})},q=function(){function t(t){function a(e,t){r.type=i.keyboard.scrollType,r.scrollAmount=i.keyboard.scrollAmount,"stepped"===r.type&&n.tweenRunning||j(o,e,t)}switch(t.type){case"blur":n.tweenRunning&&r.dir&&a("off",null);break;case"keydown":case"keyup":var l=t.keyCode?t.keyCode:t.which,s="on";if("x"!==i.axis&&(38===l||40===l)||"y"!==i.axis&&(37===l||39===l)){if((38===l||40===l)&&!n.overflowed[0]||(37===l||39===l)&&!n.overflowed[1])return;"keyup"===t.type&&(s="off"),e(document.activeElement).is(u)||(t.preventDefault(),t.stopImmediatePropagation(),a(s,l))}else if(33===l||34===l){if((n.overflowed[0]||n.overflowed[1])&&(t.preventDefault(),t.stopImmediatePropagation()),"keyup"===t.type){Q(o);var f=34===l?-1:1;if("x"===i.axis||"yx"===i.axis&&n.overflowed[1]&&!n.overflowed[0])var h="x",m=Math.abs(c[0].offsetLeft)-f*(.9*d.width());else var h="y",m=Math.abs(c[0].offsetTop)-f*(.9*d.height());G(o,m.toString(),{dir:h,scrollEasing:"mcsEaseInOut"})}}else if((35===l||36===l)&&!e(document.activeElement).is(u)&&((n.overflowed[0]||n.overflowed[1])&&(t.preventDefault(),t.stopImmediatePropagation()),"keyup"===t.type)){if("x"===i.axis||"yx"===i.axis&&n.overflowed[1]&&!n.overflowed[0])var h="x",m=35===l?Math.abs(d.width()-c.outerWidth(!1)):0;else var h="y",m=35===l?Math.abs(d.height()-c.outerHeight(!1)):0;G(o,m.toString(),{dir:h,scrollEasing:"mcsEaseInOut"})}}}var o=e(this),n=o.data(a),i=n.opt,r=n.sequential,l=a+"_"+n.idx,s=e("#mCSB_"+n.idx),c=e("#mCSB_"+n.idx+"_container"),d=c.parent(),u="input,textarea,select,datalist,keygen,[contenteditable='true']",f=c.find("iframe"),h=["blur."+l+" keydown."+l+" keyup."+l];f.length&&f.each(function(){e(this).bind("load",function(){A(this)&&e(this.contentDocument||this.contentWindow.document).bind(h[0],function(e){t(e)})})}),s.attr("tabindex","0").bind(h[0],function(e){t(e)})},j=function(t,o,n,i,r){function l(e){u.snapAmount&&(f.scrollAmount=u.snapAmount instanceof Array?"x"===f.dir[0]?u.snapAmount[1]:u.snapAmount[0]:u.snapAmount);var o="stepped"!==f.type,a=r?r:e?o?p/1.5:g:1e3/60,n=e?o?7.5:40:2.5,s=[Math.abs(h[0].offsetTop),Math.abs(h[0].offsetLeft)],d=[c.scrollRatio.y>10?10:c.scrollRatio.y,c.scrollRatio.x>10?10:c.scrollRatio.x],m="x"===f.dir[0]?s[1]+f.dir[1]*(d[1]*n):s[0]+f.dir[1]*(d[0]*n),v="x"===f.dir[0]?s[1]+f.dir[1]*parseInt(f.scrollAmount):s[0]+f.dir[1]*parseInt(f.scrollAmount),x="auto"!==f.scrollAmount?v:m,_=i?i:e?o?"mcsLinearOut":"mcsEaseInOut":"mcsLinear",w=!!e;return e&&17>a&&(x="x"===f.dir[0]?s[1]:s[0]),G(t,x.toString(),{dir:f.dir[0],scrollEasing:_,dur:a,onComplete:w}),e?void(f.dir=!1):(clearTimeout(f.step),void(f.step=setTimeout(function(){l()},a)))}function s(){clearTimeout(f.step),$(f,"step"),Q(t)}var c=t.data(a),u=c.opt,f=c.sequential,h=e("#mCSB_"+c.idx+"_container"),m="stepped"===f.type,p=u.scrollInertia<26?26:u.scrollInertia,g=u.scrollInertia<1?17:u.scrollInertia;switch(o){case"on":if(f.dir=[n===d[16]||n===d[15]||39===n||37===n?"x":"y",n===d[13]||n===d[15]||38===n||37===n?-1:1],Q(t),oe(n)&&"stepped"===f.type)return;l(m);break;case"off":s(),(m||c.tweenRunning&&f.dir)&&l(!0)}},Y=function(t){var o=e(this).data(a).opt,n=[];return"function"==typeof t&&(t=t()),t instanceof Array?n=t.length>1?[t[0],t[1]]:"x"===o.axis?[null,t[0]]:[t[0],null]:(n[0]=t.y?t.y:t.x||"x"===o.axis?null:t,n[1]=t.x?t.x:t.y||"y"===o.axis?null:t),"function"==typeof n[0]&&(n[0]=n[0]()),"function"==typeof n[1]&&(n[1]=n[1]()),n},X=function(t,o){if(null!=t&&"undefined"!=typeof t){var n=e(this),i=n.data(a),r=i.opt,l=e("#mCSB_"+i.idx+"_container"),s=l.parent(),c=typeof t;o||(o="x"===r.axis?"x":"y");var d="x"===o?l.outerWidth(!1)-s.width():l.outerHeight(!1)-s.height(),f="x"===o?l[0].offsetLeft:l[0].offsetTop,h="x"===o?"left":"top";switch(c){case"function":return t();case"object":var m=t.jquery?t:e(t);if(!m.length)return;return"x"===o?ae(m)[1]:ae(m)[0];case"string":case"number":if(oe(t))return Math.abs(t);if(-1!==t.indexOf("%"))return Math.abs(d*parseInt(t)/100);if(-1!==t.indexOf("-="))return Math.abs(f-parseInt(t.split("-=")[1]));if(-1!==t.indexOf("+=")){var p=f+parseInt(t.split("+=")[1]);return p>=0?0:Math.abs(p)}if(-1!==t.indexOf("px")&&oe(t.split("px")[0]))return Math.abs(t.split("px")[0]);if("top"===t||"left"===t)return 0;if("bottom"===t)return Math.abs(s.height()-l.outerHeight(!1));if("right"===t)return Math.abs(s.width()-l.outerWidth(!1));if("first"===t||"last"===t){var m=l.find(":"+t);return"x"===o?ae(m)[1]:ae(m)[0]}return e(t).length?"x"===o?ae(e(t))[1]:ae(e(t))[0]:(l.css(h,t),void u.update.call(null,n[0]))}}},N=function(t){function o(){return clearTimeout(f[0].autoUpdate),0===l.parents("html").length?void(l=null):void(f[0].autoUpdate=setTimeout(function(){return c.advanced.updateOnSelectorChange&&(s.poll.change.n=i(),s.poll.change.n!==s.poll.change.o)?(s.poll.change.o=s.poll.change.n,void r(3)):c.advanced.updateOnContentResize&&(s.poll.size.n=l[0].scrollHeight+l[0].scrollWidth+f[0].offsetHeight+l[0].offsetHeight+l[0].offsetWidth,s.poll.size.n!==s.poll.size.o)?(s.poll.size.o=s.poll.size.n,void r(1)):!c.advanced.updateOnImageLoad||"auto"===c.advanced.updateOnImageLoad&&"y"===c.axis||(s.poll.img.n=f.find("img").length,s.poll.img.n===s.poll.img.o)?void((c.advanced.updateOnSelectorChange||c.advanced.updateOnContentResize||c.advanced.updateOnImageLoad)&&o()):(s.poll.img.o=s.poll.img.n,void f.find("img").each(function(){n(this)}))},c.advanced.autoUpdateTimeout))}function n(t){function o(e,t){return function(){ +return t.apply(e,arguments)}}function a(){this.onload=null,e(t).addClass(d[2]),r(2)}if(e(t).hasClass(d[2]))return void r();var n=new Image;n.onload=o(n,a),n.src=t.src}function i(){c.advanced.updateOnSelectorChange===!0&&(c.advanced.updateOnSelectorChange="*");var e=0,t=f.find(c.advanced.updateOnSelectorChange);return c.advanced.updateOnSelectorChange&&t.length>0&&t.each(function(){e+=this.offsetHeight+this.offsetWidth}),e}function r(e){clearTimeout(f[0].autoUpdate),u.update.call(null,l[0],e)}var l=e(this),s=l.data(a),c=s.opt,f=e("#mCSB_"+s.idx+"_container");return t?(clearTimeout(f[0].autoUpdate),void $(f[0],"autoUpdate")):void o()},V=function(e,t,o){return Math.round(e/t)*t-o},Q=function(t){var o=t.data(a),n=e("#mCSB_"+o.idx+"_container,#mCSB_"+o.idx+"_container_wrapper,#mCSB_"+o.idx+"_dragger_vertical,#mCSB_"+o.idx+"_dragger_horizontal");n.each(function(){Z.call(this)})},G=function(t,o,n){function i(e){return s&&c.callbacks[e]&&"function"==typeof c.callbacks[e]}function r(){return[c.callbacks.alwaysTriggerOffsets||w>=S[0]+y,c.callbacks.alwaysTriggerOffsets||-B>=w]}function l(){var e=[h[0].offsetTop,h[0].offsetLeft],o=[x[0].offsetTop,x[0].offsetLeft],a=[h.outerHeight(!1),h.outerWidth(!1)],i=[f.height(),f.width()];t[0].mcs={content:h,top:e[0],left:e[1],draggerTop:o[0],draggerLeft:o[1],topPct:Math.round(100*Math.abs(e[0])/(Math.abs(a[0])-i[0])),leftPct:Math.round(100*Math.abs(e[1])/(Math.abs(a[1])-i[1])),direction:n.dir}}var s=t.data(a),c=s.opt,d={trigger:"internal",dir:"y",scrollEasing:"mcsEaseOut",drag:!1,dur:c.scrollInertia,overwrite:"all",callbacks:!0,onStart:!0,onUpdate:!0,onComplete:!0},n=e.extend(d,n),u=[n.dur,n.drag?0:n.dur],f=e("#mCSB_"+s.idx),h=e("#mCSB_"+s.idx+"_container"),m=h.parent(),p=c.callbacks.onTotalScrollOffset?Y.call(t,c.callbacks.onTotalScrollOffset):[0,0],g=c.callbacks.onTotalScrollBackOffset?Y.call(t,c.callbacks.onTotalScrollBackOffset):[0,0];if(s.trigger=n.trigger,0===m.scrollTop()&&0===m.scrollLeft()||(e(".mCSB_"+s.idx+"_scrollbar").css("visibility","visible"),m.scrollTop(0).scrollLeft(0)),"_resetY"!==o||s.contentReset.y||(i("onOverflowYNone")&&c.callbacks.onOverflowYNone.call(t[0]),s.contentReset.y=1),"_resetX"!==o||s.contentReset.x||(i("onOverflowXNone")&&c.callbacks.onOverflowXNone.call(t[0]),s.contentReset.x=1),"_resetY"!==o&&"_resetX"!==o){if(!s.contentReset.y&&t[0].mcs||!s.overflowed[0]||(i("onOverflowY")&&c.callbacks.onOverflowY.call(t[0]),s.contentReset.x=null),!s.contentReset.x&&t[0].mcs||!s.overflowed[1]||(i("onOverflowX")&&c.callbacks.onOverflowX.call(t[0]),s.contentReset.x=null),c.snapAmount){var v=c.snapAmount instanceof Array?"x"===n.dir?c.snapAmount[1]:c.snapAmount[0]:c.snapAmount;o=V(o,v,c.snapOffset)}switch(n.dir){case"x":var x=e("#mCSB_"+s.idx+"_dragger_horizontal"),_="left",w=h[0].offsetLeft,S=[f.width()-h.outerWidth(!1),x.parent().width()-x.width()],b=[o,0===o?0:o/s.scrollRatio.x],y=p[1],B=g[1],T=y>0?y/s.scrollRatio.x:0,k=B>0?B/s.scrollRatio.x:0;break;case"y":var x=e("#mCSB_"+s.idx+"_dragger_vertical"),_="top",w=h[0].offsetTop,S=[f.height()-h.outerHeight(!1),x.parent().height()-x.height()],b=[o,0===o?0:o/s.scrollRatio.y],y=p[0],B=g[0],T=y>0?y/s.scrollRatio.y:0,k=B>0?B/s.scrollRatio.y:0}b[1]<0||0===b[0]&&0===b[1]?b=[0,0]:b[1]>=S[1]?b=[S[0],S[1]]:b[0]=-b[0],t[0].mcs||(l(),i("onInit")&&c.callbacks.onInit.call(t[0])),clearTimeout(h[0].onCompleteTimeout),J(x[0],_,Math.round(b[1]),u[1],n.scrollEasing),!s.tweenRunning&&(0===w&&b[0]>=0||w===S[0]&&b[0]<=S[0])||J(h[0],_,Math.round(b[0]),u[0],n.scrollEasing,n.overwrite,{onStart:function(){n.callbacks&&n.onStart&&!s.tweenRunning&&(i("onScrollStart")&&(l(),c.callbacks.onScrollStart.call(t[0])),s.tweenRunning=!0,C(x),s.cbOffsets=r())},onUpdate:function(){n.callbacks&&n.onUpdate&&i("whileScrolling")&&(l(),c.callbacks.whileScrolling.call(t[0]))},onComplete:function(){if(n.callbacks&&n.onComplete){"yx"===c.axis&&clearTimeout(h[0].onCompleteTimeout);var e=h[0].idleTimer||0;h[0].onCompleteTimeout=setTimeout(function(){i("onScroll")&&(l(),c.callbacks.onScroll.call(t[0])),i("onTotalScroll")&&b[1]>=S[1]-T&&s.cbOffsets[0]&&(l(),c.callbacks.onTotalScroll.call(t[0])),i("onTotalScrollBack")&&b[1]<=k&&s.cbOffsets[1]&&(l(),c.callbacks.onTotalScrollBack.call(t[0])),s.tweenRunning=!1,h[0].idleTimer=0,C(x,"hide")},e)}}})}},J=function(e,t,o,a,n,i,r){function l(){S.stop||(x||m.call(),x=K()-v,s(),x>=S.time&&(S.time=x>S.time?x+f-(x-S.time):x+f-1,S.time0?(S.currVal=u(S.time,_,b,a,n),w[t]=Math.round(S.currVal)+"px"):w[t]=o+"px",p.call()}function c(){f=1e3/60,S.time=x+f,h=window.requestAnimationFrame?window.requestAnimationFrame:function(e){return s(),setTimeout(e,.01)},S.id=h(l)}function d(){null!=S.id&&(window.requestAnimationFrame?window.cancelAnimationFrame(S.id):clearTimeout(S.id),S.id=null)}function u(e,t,o,a,n){switch(n){case"linear":case"mcsLinear":return o*e/a+t;case"mcsLinearOut":return e/=a,e--,o*Math.sqrt(1-e*e)+t;case"easeInOutSmooth":return e/=a/2,1>e?o/2*e*e+t:(e--,-o/2*(e*(e-2)-1)+t);case"easeInOutStrong":return e/=a/2,1>e?o/2*Math.pow(2,10*(e-1))+t:(e--,o/2*(-Math.pow(2,-10*e)+2)+t);case"easeInOut":case"mcsEaseInOut":return e/=a/2,1>e?o/2*e*e*e+t:(e-=2,o/2*(e*e*e+2)+t);case"easeOutSmooth":return e/=a,e--,-o*(e*e*e*e-1)+t;case"easeOutStrong":return o*(-Math.pow(2,-10*e/a)+1)+t;case"easeOut":case"mcsEaseOut":default:var i=(e/=a)*e,r=i*e;return t+o*(.499999999999997*r*i+-2.5*i*i+5.5*r+-6.5*i+4*e)}}e._mTween||(e._mTween={top:{},left:{}});var f,h,r=r||{},m=r.onStart||function(){},p=r.onUpdate||function(){},g=r.onComplete||function(){},v=K(),x=0,_=e.offsetTop,w=e.style,S=e._mTween[t];"left"===t&&(_=e.offsetLeft);var b=o-_;S.stop=0,"none"!==i&&d(),c()},K=function(){return window.performance&&window.performance.now?window.performance.now():window.performance&&window.performance.webkitNow?window.performance.webkitNow():Date.now?Date.now():(new Date).getTime()},Z=function(){var e=this;e._mTween||(e._mTween={top:{},left:{}});for(var t=["top","left"],o=0;o=0&&a[0]+ae(n)[0]=0&&a[1]+ae(n)[1]=0&&r[1]-i[1]*l[1][0]<0&&r[1]+n[1]-i[1]*l[1][1]>=0},mcsOverflow:e.expr[":"].mcsOverflow||function(t){var o=e(t).data(a);if(o)return o.overflowed[0]||o.overflowed[1]}})})})}); \ No newline at end of file diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js index 8c6d97e..da63883 100644 --- a/frontend/web/js/script.js +++ b/frontend/web/js/script.js @@ -9,6 +9,9 @@ $(function() homeSlider(); hoverCatList(); expandAllCatList(); + loadCollection(); + tabs(); + form(); if(device.mobile()) { deviceCheck(); @@ -238,7 +241,80 @@ $(function() } } - ) + ); + } + + function removeLoadCollection() { + $('.load_collection').animate({opacity:0},500,function () { + $('.load_collection').remove() + }) + } + + function loadCollection() { + $('.collection-list ul li a').click(function (e) { + e.preventDefault(); + $('.collection-list li').removeClass('active') + $(this).parent().addClass('active') + $('body').append('
    '); + //после того как загрузиться новый контент, вызвать ф-цию removeLoadCollection() + }) + } + + function tabs() { + var tabsLi = $('.collect-tabs ul li') + var tabsContent = $('.tabs-content') + tabsContent.css({display:'none'}); + $(tabsContent[0]).css({display:'block'}); + $(tabsLi[0]).addClass('active-tab'); + tabsLi.click(function () { + tabsLi.removeClass('active-tab'); + $(this).addClass('active-tab'); + var thisIndex=$(this).index(); + tabsContent.css({display:'none'}); + $(tabsContent[thisIndex]).css({display:'block'}); + }) + } + + function form() { + $('.question-form').click(function () { + $('#overlay').fadeIn(400, + function(){ + $('#modal_form') + .css('display', 'block') + .animate({opacity: 1, top: '80px'}, 200); + }); + $(".content").mCustomScrollbar(); + }); + + $('.to_order').click(function () { + $('#overlay').fadeIn(400, + function(){ + $('#modal_form-2') + .css('display', 'block') + .animate({opacity: 1, top: '80px'}, 200); + }); + $(".scrollbar_").mCustomScrollbar(); + }); + + $('#close-form, #overlay').click( function(){ + $('#modal_form, #modal_form-2, #success-form').animate({opacity: 0, top: 20}, 200,function(){ + $(this).css('display', 'none'); + $('#overlay').fadeOut(400); + }); + }); + + + // после отправки формы зарустить ф-цию success() + function success() { + $('#modal_form, #modal_form-2').animate({opacity: 0, top: 20}, 200,function(){ + $(this).css('display', 'none'); + }); + setTimeout(function () { + $('#success-form').css('display', 'block').animate({opacity: 1}, 700); + },400) + } + + } } ); diff --git a/frontend/web/js/script.min.js b/frontend/web/js/script.min.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/frontend/web/js/script.min.js diff --git a/storage/.htaccess b/storage/.htaccess new file mode 100644 index 0000000..0a379a4 --- /dev/null +++ b/storage/.htaccess @@ -0,0 +1,6 @@ +RewriteEngine on +RewriteBase / +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d + +RewriteRule . index.php -- libgit2 0.21.4