diff --git a/backend/config/main.php b/backend/config/main.php index 23d5452..98f3385 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -43,6 +43,17 @@ return [ ], ], ], + 'imageCache' => [ + 'class' => 'iutbay\yii2imagecache\ImageCache', + 'sourcePath' => '@storage', + 'sourceUrl' => '/storage', + 'thumbsPath' => '@storage/thumbs', + 'thumbsUrl' => '/storage/thumbs', + + 'sizes' => [ + 'slider' => [720, 340], + ], + ], 'errorHandler' => [ 'errorAction' => 'site/error', ], diff --git a/backend/controllers/ArticlesController.php b/backend/controllers/ArticlesController.php new file mode 100755 index 0000000..7ad014a --- /dev/null +++ b/backend/controllers/ArticlesController.php @@ -0,0 +1,124 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Articles models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ArticlesSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Articles model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Articles model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Articles(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Articles 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Articles 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 Articles model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Articles the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Articles::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/BgController.php b/backend/controllers/BgController.php new file mode 100644 index 0000000..fdaa0d4 --- /dev/null +++ b/backend/controllers/BgController.php @@ -0,0 +1,124 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Bg models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new BgSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Bg model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Bg model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Bg(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Bg 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Bg 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 Bg model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Bg the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Bg::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/CustomerController.php b/backend/controllers/CustomerController.php new file mode 100644 index 0000000..b6e3a57 --- /dev/null +++ b/backend/controllers/CustomerController.php @@ -0,0 +1,124 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Customer models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new CustomerSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Customer model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Customer model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Customer(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Customer 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Customer 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 Customer model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Customer the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Customer::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/PageController.php b/backend/controllers/PageController.php index 35c46d2..17c5f4f 100755 --- a/backend/controllers/PageController.php +++ b/backend/controllers/PageController.php @@ -1,136 +1,124 @@ - [ - 'class' => AccessControl::className(), - 'rules' => [ - [ - 'actions' => ['login', 'error'], - 'allow' => true, - ], - [ - 'actions' => ['logout', 'index','create','update','view','delete','test-img' ], - 'allow' => true, - 'roles' => ['@'], - ], - ], - ], - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'logout' => ['post'], - ], - ], - ]; - } - - /** - * Lists all Page models. - * @return mixed - */ - public function actionIndex() - { - $searchModel = new PageSearch(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - - return $this->render('index', [ - 'searchModel' => $searchModel, - 'dataProvider' => $dataProvider, - ]); - } - - /** - * Displays a single Page model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Page model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new Page(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); - } - } - - /** - * Updates an existing Page 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->id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); - } - } - - /** - * Deletes an existing Page 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 Page model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Page the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Page::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } -} + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Page models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new PageSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Page model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Page model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Page(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Page 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Page 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 Page model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Page the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Page::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/SliderImageController.php b/backend/controllers/SliderImageController.php index a7ab1c3..e0cf010 100755 --- a/backend/controllers/SliderImageController.php +++ b/backend/controllers/SliderImageController.php @@ -9,7 +9,7 @@ use common\models\SliderImageSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; - +use yii\web\UploadedFile; /** * SliderImageController implements the CRUD actions for SliderImage model. */ @@ -73,7 +73,12 @@ class SliderImageController extends Controller if ($model->load(Yii::$app->request->post())) { $model->slider_id = $slider_id; - $model->save(); + if ( ($image = UploadedFile::getInstance($model, 'image')) ) { + $model->image = $image->name; + } + if ($model->save() && $image) { + $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name)); + } return $this->redirect(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id]); } else { @@ -98,7 +103,14 @@ class SliderImageController extends Controller { $model = $this->findModel($slider_id, $id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { + if ($model->load(Yii::$app->request->post())) { + if ( ($image = UploadedFile::getInstance($model, 'image')) ) { + $model->image = $image->name; + } + + if ($model->save() && $image) { + $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name)); + } return $this->redirect(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id]); } else { diff --git a/backend/controllers/SubscribeController.php b/backend/controllers/SubscribeController.php new file mode 100644 index 0000000..072435d --- /dev/null +++ b/backend/controllers/SubscribeController.php @@ -0,0 +1,124 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Subscribe models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new SubscribeSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Subscribe model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Subscribe model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Subscribe(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Subscribe 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Subscribe 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 Subscribe model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Subscribe the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Subscribe::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/views/articles/_form.php b/backend/views/articles/_form.php new file mode 100755 index 0000000..c9f8ad4 --- /dev/null +++ b/backend/views/articles/_form.php @@ -0,0 +1,57 @@ + + +
+ + + + + field($model, 'date') + ->widget(DatePicker::className(), [ + 'dateFormat' => 'yyyy-MM-dd', + 'clientOptions' => [ 'minDate' => 1 ], + ]) ?> + field($model, 'title')->textInput(['maxlength' => true]) ?> + + field($model, 'body')->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')->textInput(['maxlength' => true]) ?> + + field($model, 'translit')->textInput(['maxlength' => true]) ?> + + field($model, 'meta_title')->textInput(['maxlength' => true]) ?> + + field($model, 'meta_keywords')->textInput(['maxlength' => true]) ?> + + field($model, 'meta_description')->textInput(['maxlength' => true]) ?> + + field($model, 'seo_text')->textarea(['rows' => 6]) ?> + + field($model, 'h1')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/articles/_search.php b/backend/views/articles/_search.php new file mode 100755 index 0000000..afb9cfc --- /dev/null +++ b/backend/views/articles/_search.php @@ -0,0 +1,47 @@ + + + diff --git a/backend/views/articles/create.php b/backend/views/articles/create.php new file mode 100755 index 0000000..3129639 --- /dev/null +++ b/backend/views/articles/create.php @@ -0,0 +1,21 @@ +title = 'Create Articles'; +$this->params['breadcrumbs'][] = ['label' => 'Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/articles/index.php b/backend/views/articles/index.php new file mode 100755 index 0000000..c588d44 --- /dev/null +++ b/backend/views/articles/index.php @@ -0,0 +1,41 @@ +title = 'Articles'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'date', + 'title', + 'image', + // 'translit', + // 'meta_title', + // 'meta_keywords', + // 'meta_description', + // 'seo_text:ntext', + // 'h1', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/views/articles/update.php b/backend/views/articles/update.php new file mode 100755 index 0000000..a30c97d --- /dev/null +++ b/backend/views/articles/update.php @@ -0,0 +1,21 @@ +title = 'Update Articles: ' . $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/articles/view.php b/backend/views/articles/view.php new file mode 100755 index 0000000..ab5ad65 --- /dev/null +++ b/backend/views/articles/view.php @@ -0,0 +1,45 @@ +title = $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Articles', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'date', + 'title', + 'body:ntext', + 'image', + 'translit', + 'meta_title', + 'meta_keywords', + 'meta_description', + 'seo_text:ntext', + 'h1', + ], + ]) ?> + +
diff --git a/backend/views/bg/_form.php b/backend/views/bg/_form.php new file mode 100644 index 0000000..30dd166 --- /dev/null +++ b/backend/views/bg/_form.php @@ -0,0 +1,27 @@ + + +
+ + + + field($model, 'title')->textInput(['maxlength' => true]) ?> + + field($model, 'url')->textInput(['maxlength' => true]) ?> + + field($model, 'image')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/bg/_search.php b/backend/views/bg/_search.php new file mode 100644 index 0000000..70a8e3a --- /dev/null +++ b/backend/views/bg/_search.php @@ -0,0 +1,33 @@ + + + diff --git a/backend/views/bg/create.php b/backend/views/bg/create.php new file mode 100644 index 0000000..bf0913a --- /dev/null +++ b/backend/views/bg/create.php @@ -0,0 +1,21 @@ +title = 'Create Bg'; +$this->params['breadcrumbs'][] = ['label' => 'Bgs', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

title) ?>

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

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

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

title) ?>

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

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'title', + 'url:url', + 'image', + ], + ]) ?> + +
diff --git a/backend/views/customer/_form.php b/backend/views/customer/_form.php new file mode 100644 index 0000000..01f70af --- /dev/null +++ b/backend/views/customer/_form.php @@ -0,0 +1,47 @@ + + +
+ + + + field($model, 'id')->textInput() ?> + + field($model, 'username')->textInput(['maxlength' => true]) ?> + + field($model, 'password')->passwordInput(['maxlength' => true]) ?> + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + 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, 'birth_day')->textInput() ?> + + field($model, 'birth_month')->textInput() ?> + + field($model, 'birth_year')->textInput() ?> + + field($model, 'body')->textarea(['rows' => 6]) ?> + + field($model, 'group_id')->textInput() ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/customer/_search.php b/backend/views/customer/_search.php new file mode 100644 index 0000000..3a462e9 --- /dev/null +++ b/backend/views/customer/_search.php @@ -0,0 +1,51 @@ + + + diff --git a/backend/views/customer/create.php b/backend/views/customer/create.php new file mode 100644 index 0000000..45796e5 --- /dev/null +++ b/backend/views/customer/create.php @@ -0,0 +1,21 @@ +title = 'Create Customer'; +$this->params['breadcrumbs'][] = ['label' => 'Customers', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'username', + 'password', + 'name', + 'surname', + // 'phone', + // 'date_time', + // 'sex', + // 'birth_day', + // 'birth_month', + // 'birth_year', + // 'body:ntext', + // 'group_id', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/views/customer/update.php b/backend/views/customer/update.php new file mode 100644 index 0000000..360c058 --- /dev/null +++ b/backend/views/customer/update.php @@ -0,0 +1,21 @@ +title = 'Update Customer: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Customers', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

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

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'username', + 'password', + 'name', + 'surname', + 'phone', + 'date_time', + 'sex', + 'birth_day', + 'birth_month', + 'birth_year', + 'body:ntext', + 'group_id', + ], + ]) ?> + +
diff --git a/backend/views/layouts/main-sidebar.php b/backend/views/layouts/main-sidebar.php index f132d1b..463e835 100755 --- a/backend/views/layouts/main-sidebar.php +++ b/backend/views/layouts/main-sidebar.php @@ -54,9 +54,9 @@ use yii\widgets\Menu; ['label' => 'Зависимости', 'url' => ['/relation/manage']] ] ], - ['label' => 'Статические страницы', 'url' => ['/page/index']], + ['label' => 'Текстовые страницы', 'url' => ['/page/index']], + ['label' => 'Статьи', 'url' => ['/articles/index']], ['label' => 'Акции', 'url' => ['/event/index']], - ['label' => 'Услуги', 'url' => ['/service/index']], [ 'label' => 'SEO', 'template'=>' {label}', @@ -65,8 +65,11 @@ use yii\widgets\Menu; ['label' => 'Шаблоны', 'url' => ['/seo-category/index']] ] ], -// ['label' => 'Rubrication', 'url' => ['/rubrication/tax-group']], -// ['label' => 'Relation', 'url' => ['/relation/manage']], + ['label' => 'Фон', 'url' => ['/bg/index']], + ['label' => 'Подписка', 'url' => ['/subscribe/index']], + ['label' => 'Пользователи', 'url' => ['/customer/index']], + ['label' => 'Группы пользователей', 'url' => ['/group/index']], + ], ]); diff --git a/backend/views/page/_form.php b/backend/views/page/_form.php index 077f1a5..e3167b8 100755 --- a/backend/views/page/_form.php +++ b/backend/views/page/_form.php @@ -1,47 +1,46 @@ - - -
- - - - field($model, 'name')->textInput(['maxlength' => 255]) ?> - - field($model, 'alias')->textInput(['maxlength' => 250]) ?> - - field($model, 'title')->textInput(['maxlength' => 250]) ?> - - field($model, 'body')->widget(CKEditor::className(), - [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ - 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать - 'inline' => false, //по умолчанию false]), - 'allowedContent' => true, - 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload') - ] - ) - ]) ?> - - field($model, 'meta_title')->textInput(['maxlength' => 250]) ?> - - field($model, 'description')->textInput(['maxlength' => 250]) ?> - - field($model, 'h1')->textInput(['maxlength' => 255]) ?> - - field($model, 'seo_text')->textarea(['rows' => 6]) ?> - -
- isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> -
- - - -
+ + +
+ + + + field($model, 'title')->textInput(['maxlength' => true]) ?> + + + field($model, 'body')->widget(CKEditor::className(), + [ + 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ + 'preset' => 'full', //разработанны стандартные настройки basic, standard, full данную возможность не обязательно использовать + 'inline' => false, //по умолчанию false]), + 'allowedContent' => true, + 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/uploader/images-upload') + ] + ) + ]) ?> + + field($model, 'meta_title')->textInput(['maxlength' => true]) ?> + + field($model, 'meta_keywords')->textInput(['maxlength' => true]) ?> + + field($model, 'meta_description')->textInput(['maxlength' => true]) ?> + + field($model, 'seo_text')->textarea(['rows' => 6]) ?> + + field($model, 'h1')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/page/_search.php b/backend/views/page/_search.php index aa49636..088e081 100755 --- a/backend/views/page/_search.php +++ b/backend/views/page/_search.php @@ -1,43 +1,43 @@ - - - + + + diff --git a/backend/views/page/create.php b/backend/views/page/create.php index f5798f7..d47a8ad 100755 --- a/backend/views/page/create.php +++ b/backend/views/page/create.php @@ -1,21 +1,21 @@ -title = 'Create Page'; -$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> - -
+title = 'Create Page'; +$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/page/index.php b/backend/views/page/index.php index d7e5634..a1dd24c 100755 --- a/backend/views/page/index.php +++ b/backend/views/page/index.php @@ -1,41 +1,39 @@ -title = 'Статические страницы'; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

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

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

- - $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - - 'id', - 'name', - 'alias', - 'title', - // 'meta_title', - // 'description', - // 'h1', - // 'seo_text:ntext', - - ['class' => 'yii\grid\ActionColumn'], - ], - ]); ?> - -
+title = 'Pages'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'translit', + 'title', + 'meta_title', + // 'meta_keywords', + // 'meta_description', + // 'seo_text:ntext', + // 'h1', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/views/page/update.php b/backend/views/page/update.php index be6355d..a6755db 100755 --- a/backend/views/page/update.php +++ b/backend/views/page/update.php @@ -1,21 +1,21 @@ -title = 'Update Page: ' . ' ' . $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; -$this->params['breadcrumbs'][] = 'Обновление'; -?> -
- -

title) ?>

- - render('_form', [ - 'model' => $model, - ]) ?> - -
+title = 'Update Page: ' . $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/page/view.php b/backend/views/page/view.php index dda89a5..6ddfed8 100755 --- a/backend/views/page/view.php +++ b/backend/views/page/view.php @@ -1,42 +1,43 @@ -title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -?> -
- -

title) ?>

- -

- $model->id], ['class' => 'btn btn-primary']) ?> - $model->id], [ - 'class' => 'btn btn-danger', - 'data' => [ - 'confirm' => 'Вы уверены что хотите удалить этот элемент?', - 'method' => 'post', - ], - ]) ?> -

- - $model, - 'attributes' => [ - 'id', - 'name', - 'alias', - 'title', - 'meta_title', - 'description', - 'h1', - 'seo_text:ntext', - ], - ]) ?> - -
+title = $model->title; +$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'translit', + 'title', + 'body:ntext', + 'meta_title', + 'meta_keywords', + 'meta_description', + 'seo_text:ntext', + 'h1', + ], + ]) ?> + +
diff --git a/backend/views/slider-image/_form.php b/backend/views/slider-image/_form.php index 399376d..eb686c6 100755 --- a/backend/views/slider-image/_form.php +++ b/backend/views/slider-image/_form.php @@ -14,29 +14,27 @@ use yii\widgets\ActiveForm;
- - $model, - 'field'=>'image', - 'size' => [ - [ - 'width'=>$slider->width, - 'height'=>$slider->height, - ], - ], - 'gallery' =>$model->image, - 'name' => 'Загрузить миниатюру статьи' - ]); - ?> + ['enctype' => 'multipart/form-data']]); ?> + field($model, 'image')->widget(\kartik\file\FileInput::classname(), [ + 'options' => [ + 'accept' => 'image/*', + 'multiple' => true + ], + 'pluginOptions' => [ + 'allowedFileExtensions' => ['jpg','gif','png'], + 'initialPreview' => $model->imageUrl ? Yii::$app->imageCache->thumb($model->imageUrl, 'slider') : '', + 'overwriteInitial' => true, + 'showRemove' => true, + 'showUpload' => false, + ], + ]); ?> field($model, 'alt')->textInput(['maxlength' => true]) ?> field($model, 'title')->textInput(['maxlength' => true]) ?> field($model, 'url')->textInput(['maxlength' => true]) ?> - field($model, 'price')->textInput(['maxlength' => true]) ?> - field($model, 'status')->widget(Select2::className(),([ 'name' => 'status', 'hideSearch' => true, diff --git a/backend/views/subscribe/_form.php b/backend/views/subscribe/_form.php new file mode 100644 index 0000000..36ef492 --- /dev/null +++ b/backend/views/subscribe/_form.php @@ -0,0 +1,25 @@ + + +
+ + + + field($model, 'email')->textInput(['maxlength' => true]) ?> + + field($model, 'sale')->textInput() ?> + +
+ isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/subscribe/_search.php b/backend/views/subscribe/_search.php new file mode 100644 index 0000000..e2aaf8a --- /dev/null +++ b/backend/views/subscribe/_search.php @@ -0,0 +1,33 @@ + + + diff --git a/backend/views/subscribe/create.php b/backend/views/subscribe/create.php new file mode 100644 index 0000000..3f6f09f --- /dev/null +++ b/backend/views/subscribe/create.php @@ -0,0 +1,21 @@ +title = 'Create Subscribe'; +$this->params['breadcrumbs'][] = ['label' => 'Subscribes', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

title) ?>

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

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

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'email:email', + 'sale', + 'sand', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/views/subscribe/update.php b/backend/views/subscribe/update.php new file mode 100644 index 0000000..2137e89 --- /dev/null +++ b/backend/views/subscribe/update.php @@ -0,0 +1,21 @@ +title = 'Update Subscribe: ' . $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Subscribes', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/subscribe/view.php b/backend/views/subscribe/view.php new file mode 100644 index 0000000..7c96baa --- /dev/null +++ b/backend/views/subscribe/view.php @@ -0,0 +1,38 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Subscribes', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'email:email', + 'sale', + 'sand', + ], + ]) ?> + +
diff --git a/common/models/Articles.php b/common/models/Articles.php index 5bcd774..46ef392 100755 --- a/common/models/Articles.php +++ b/common/models/Articles.php @@ -2,13 +2,63 @@ namespace common\models; +use Yii; + +/** + * This is the model class for table "articles". + * + * @property integer $id + * @property string $date + * @property string $title + * @property string $body + * @property string $image + * @property string $translit + * @property string $meta_title + * @property string $meta_keywords + * @property string $meta_description + * @property string $seo_text + * @property string $h1 + */ class Articles extends \yii\db\ActiveRecord { + /** + * @inheritdoc + */ public static function tableName() { return 'articles'; } - - - -} \ No newline at end of file + + /** + * @inheritdoc + */ + public function rules() + { + return [ + [['date'], 'safe'], + [['title', 'body', 'image', 'translit'], 'required'], + [['body', 'seo_text'], 'string'], + [['title', 'image', 'translit', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'date' => 'Date', + 'title' => 'Title', + 'body' => 'Body', + 'image' => 'Image', + 'translit' => 'Translit', + 'meta_title' => 'Meta Title', + 'meta_keywords' => 'Meta Keywords', + 'meta_description' => 'Meta Description', + 'seo_text' => 'Seo Text', + 'h1' => 'H1', + ]; + } +} diff --git a/common/models/ArticlesSearch.php b/common/models/ArticlesSearch.php new file mode 100755 index 0000000..686dca2 --- /dev/null +++ b/common/models/ArticlesSearch.php @@ -0,0 +1,78 @@ + $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, + '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]) + ->andFilterWhere(['like', 'meta_description', $this->meta_description]) + ->andFilterWhere(['like', 'seo_text', $this->seo_text]) + ->andFilterWhere(['like', 'h1', $this->h1]); + + return $dataProvider; + } +} diff --git a/common/models/BgSearch.php b/common/models/BgSearch.php new file mode 100644 index 0000000..485aa6e --- /dev/null +++ b/common/models/BgSearch.php @@ -0,0 +1,71 @@ + $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, + ]); + + $query->andFilterWhere(['like', 'title', $this->title]) + ->andFilterWhere(['like', 'url', $this->url]) + ->andFilterWhere(['like', 'image', $this->image]); + + return $dataProvider; + } +} diff --git a/common/models/CustomerSearch.php b/common/models/CustomerSearch.php new file mode 100644 index 0000000..9cd6feb --- /dev/null +++ b/common/models/CustomerSearch.php @@ -0,0 +1,80 @@ + $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, + 'date_time' => $this->date_time, + 'birth_day' => $this->birth_day, + 'birth_month' => $this->birth_month, + 'birth_year' => $this->birth_year, + 'group_id' => $this->group_id, + ]); + + $query->andFilterWhere(['like', 'username', $this->username]) + ->andFilterWhere(['like', 'password', $this->password]) + ->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'surname', $this->surname]) + ->andFilterWhere(['like', 'phone', $this->phone]) + ->andFilterWhere(['like', 'sex', $this->sex]) + ->andFilterWhere(['like', 'body', $this->body]); + + return $dataProvider; + } +} diff --git a/common/models/Delivery.php b/common/models/Delivery.php new file mode 100644 index 0000000..d1a9304 --- /dev/null +++ b/common/models/Delivery.php @@ -0,0 +1,12 @@ + true, 'targetClass' => Orders::className(), 'targetAttribute' => ['order_id' => 'order_id']], - [['item_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductVariant::className(), 'targetAttribute' => ['item_id' => 'product_variant_id']], - ]; - } - - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'order_items_id' => Yii::t('app', 'order_items_id'), - 'order_id' => Yii::t('app', 'order_id'), - 'item_id' => Yii::t('app', 'item_id'), - 'item_count' => Yii::t('app', 'item_count'), - 'price' => Yii::t('app', 'price'), - ]; - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getOrder() - { - return $this->hasOne(Orders::className(), ['order_id' => 'order_id']); - } - - /** - * @return \yii\db\ActiveQuery - */ - public function getItem() - { - return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'item_id']); - } -} diff --git a/common/models/Orders.php b/common/models/Orders.php index 47d8fa4..772a483 100755 --- a/common/models/Orders.php +++ b/common/models/Orders.php @@ -1,106 +1,203 @@ 255], - [['phone'], 'string', 'max' => 32], + [['name', 'phone'], 'required','whenClient' => true], + //['email', 'email'], + [['total','body','patronymic','surname','email','phone2','delivery','payment'], 'safe'], + [['email'],'email'], ]; } - /** - * @inheritdoc - */ - public function behaviors() + public function attributeLabels() { return [ - TimestampBehavior::className(), + 'name' => 'Имя', + 'phone'=>'Телефон', + 'phone2'=>'Дополнительный телефон', + 'body'=>'Сообщение', + 'adress'=>'Адрес', + 'city'=>'Город', + 'patronymic'=>'Отчество', + 'surname'=>'Фамилия', + 'email'=>'E-mail', + 'date_time'=>'Дата', + 'total'=>'Сума', + 'status'=>'Статус', + 'delivery'=>'Вариант доставки', + 'payment'=>'Способы оплаты', ]; } + public function beforeSave($insert) { + $this->user_id = Yii::$app->user->id; + $this->date_time = new \yii\db\Expression('NOW()'); + return parent::beforeSave($insert); + } - public function getCreated(){ - if(!empty($this->created_at)){ - return date("Y-m-d" , $this->created_at); + public function beforeDelete() { + return parent::beforeDelete(); + } + + public function contact($email,$body) + { + if ($this->validate()) { + $body .= 'Вся сумма: '.$this->total; + $body .= "\n\r"; + $body .= 'Имя: '.$this->name; + $body .= "\n\r"; + $body .= 'Фамилия: '.$this->surname; + $body .= "\n\r"; + $body .= 'Отчество: '.$this->patronymic; + $body .= "\n\r"; + $body .= 'E-mail: '.$this->email; + $body .= "\n\r"; + $body .= 'Телефон: '.$this->phone; + $body .= "\n\r"; + $body .= 'Адрес: '.$this->adress; + $body .= "\n\r"; + $body .= 'Сообщение: '.$this->body; + $body .= "\n\r"; + + Yii::$app->mailer->compose() + ->setTo($email) + ->setFrom(['send@artweb.ua' => 'send']) + ->setSubject('Заказ на сайте Рюкзаки') + ->setTextBody($body) + ->send(); + return true; } else { - return ''; + return false; + } + } + public function addBasket ($mod_id, $count) + { + $session = new Session; + $session->open (); + $data = $session['basket']; + $i = 0; + if (isset($session['basket'])) + { + foreach ($session['basket'] as $key => $basket) + { + if ($mod_id == $basket['id']) + { + $data[$key]['count'] += $count; + $session['basket'] = $data; + $i++; + } + } + } + if ($i == 0) + { + $data[] = ['id' => $mod_id, 'count' => $count]; + $session['basket'] = $data; } } - public function getUpdated(){ - if(!empty($this->updated_at)){ - return date("Y-m-d" , $this->updated_at); - } else { - return ''; + public function rowBasket () + { + $session = new Session; + $session->open (); + $cost = 0; + $count = 0; + if (isset($session['basket']) && count ($session['basket'])) + { + foreach ($session['basket'] as $product) + { + $count += $product['count']; + } } + + return (object)['cost' => $cost, 'count' => $count]; } - /** - * @inheritdoc - */ - public function attributeLabels() + + public function deleteBasketMod ($id) { - return [ - 'order_id' => Yii::t('app', 'order_id'), - 'customer_id' => Yii::t('app', 'customer_id'), - 'name' => Yii::t('app', 'name'), - 'email' => Yii::t('app', 'email'), - 'phone' => Yii::t('app', 'phone'), - 'delivery' => Yii::t('app', 'delivery'), - 'payment' => Yii::t('app', 'payment'), - 'code' => Yii::t('app', 'code'), - 'status' => Yii::t('app', 'status'), - 'created_at' => Yii::t('app', 'created_at'), - 'updated_at' => Yii::t('app', 'updated_at'), - ]; + $session = new Session; + $session->open (); + $basket = $session['basket']; + foreach ($basket as $key => $product) + { + if ($id == $product['id']) unset($basket[$key]); + } + $session['basket'] = $basket; + } + + public function updateBasket ($row) + { + $session = new Session; + $session->open (); + //$data = array(); + if ($row['count'] > 0) $this->data[] = ['id' => $row['id'], 'count' => $row['count']]; + $session['basket'] = $this->data; + } + + + public function getBasketMods () + { + $session = new Session; + $session->open (); + $products = []; + if (empty($session['basket'])) return []; + foreach ($session['basket'] as $product) + { + $row = ProductVariant::find ()->select (['product_variant.*', 'product.name as product_name', 'product.alias']) + ->where (['product_variant.product_variant_id' => $product['id']]) + ->leftJoin ('product', 'product.product_id = product_variant.product_id') + ->one (); + $row->count = $product['count']; + $row->sum_cost = $product['count'] * $row->price; + $products[] = $row; + } + + return $products; + } + + public function getSumCost () + { + $session = new Session; + $session->open (); + $cost = 0; + if (empty($session['basket'])) return false; + foreach ($session['basket'] as $product) + { + $cost += ($this->getModCost ($product['id']) * $product['count']); + } + + return $cost; + } + + private function getModCost ($mod_id) + { + $mod = ProductVariant::find ()->where (['product_variant_id' => $mod_id])->one (); + + return $mod->price; + } + + public function getUser() + { + return $this->hasOne(User::className(), ['id' => 'user_id']); } - /** - * @return \yii\db\ActiveQuery - */ - public function getOrderItems() + public function getProducts() { - return $this->hasMany(OrderItems::className(), ['order_id' => 'order_id']); + return $this->hasMany(OrdersProducts::className(), ['order_id' => 'id']); } -} +} \ No newline at end of file diff --git a/common/models/OrdersProducts.php b/common/models/OrdersProducts.php new file mode 100644 index 0000000..5045d61 --- /dev/null +++ b/common/models/OrdersProducts.php @@ -0,0 +1,38 @@ +'Продукт', + 'name'=>'Вид', + 'art'=>'Артикул', + 'cost'=>'Цена за один', + 'count'=>'Кол.', + 'sum_cost'=>'Сумма', + ]; + } + + public function getMod() + { + return $this->hasOne(Mod::className(), ['id' => 'mod_id']); + } +} \ No newline at end of file diff --git a/common/models/Page.php b/common/models/Page.php index 76d62c4..bac6703 100755 --- a/common/models/Page.php +++ b/common/models/Page.php @@ -5,17 +5,17 @@ namespace common\models; use Yii; /** - * This is the model class for table "{{%page}}". + * This is the model class for table "page". * * @property integer $id - * @property string $name * @property string $translit * @property string $title * @property string $body * @property string $meta_title - * @property string $description - * @property string $h1 + * @property string $meta_keywords + * @property string $meta_description * @property string $seo_text + * @property string $h1 */ class Page extends \yii\db\ActiveRecord { @@ -24,56 +24,53 @@ class Page extends \yii\db\ActiveRecord */ public static function tableName() { - return '{{page}}'; + return 'page'; } - /** * @inheritdoc */ - public function rules() + public function behaviors() { return [ - [['name', 'body'], 'required'], - [['body', 'seo_text'], 'string'], - [['name', 'h1'], 'string', 'max' => 255], - [['alias', 'title', 'meta_title', 'description'], 'string', 'max' => 250] + 'slug' => [ + 'class' => 'common\behaviors\Slug', + 'in_attribute' => 'title', + 'out_attribute' => 'translit', + 'translit' => true + ] ]; } - /** * @inheritdoc */ - public function attributeLabels() - { - return [ - 'id' => Yii::t('app', 'id'), - 'name' => Yii::t('app', 'name'), - 'alias' => Yii::t('app', 'alias'), - 'title' => Yii::t('app', 'title'), - 'body' => Yii::t('app', 'body'), - 'meta_title' => Yii::t('app', 'meta_title'), - 'description' => Yii::t('app', 'description'), - 'h1' =>Yii::t('app', 'h1'), - 'seo_text' => Yii::t('app', 'seo_text'), - ]; - } - - public function behaviors() + public function rules() { return [ - 'slug' => [ - 'class' => 'common\behaviors\Slug', - 'in_attribute' => 'name', - 'out_attribute' => 'alias', - 'translit' => true - ] + [['body', 'seo_text'], 'string'], + [['translit', 'title', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255], ]; } - public function getPageTranslit($page){ return self::find() - ->where(['alias' => $page]) + ->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 a67633c..a914813 100755 --- a/common/models/PageSearch.php +++ b/common/models/PageSearch.php @@ -1,72 +1,76 @@ - $query, - ]); - - $this->load($params); - - if (!$this->validate()) { - // uncomment the following line if you do not want to any records when validation fails - // $query->where('0=1'); - return $dataProvider; - } - - $query->andFilterWhere([ - 'id' => $this->id, - ]); - - $query->andFilterWhere(['like', 'name', $this->name]) - ->andFilterWhere(['like', 'alias', $this->alias]) - ->andFilterWhere(['like', 'title', $this->title]) - ->andFilterWhere(['like', 'body', $this->body]) - ->andFilterWhere(['like', 'meta_title', $this->meta_title]) - ->andFilterWhere(['like', 'description', $this->description]) - ->andFilterWhere(['like', 'h1', $this->h1]) - ->andFilterWhere(['like', 'seo_text', $this->seo_text]); - - return $dataProvider; - } -} + $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, + ]); + + $query->andFilterWhere(['like', 'translit', $this->translit]) + ->andFilterWhere(['like', 'title', $this->title]) + ->andFilterWhere(['like', 'body', $this->body]) + ->andFilterWhere(['like', 'meta_title', $this->meta_title]) + ->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords]) + ->andFilterWhere(['like', 'meta_description', $this->meta_description]) + ->andFilterWhere(['like', 'seo_text', $this->seo_text]) + ->andFilterWhere(['like', 'h1', $this->h1]); + + return $dataProvider; + } +} diff --git a/common/models/SliderImage.php b/common/models/SliderImage.php index a759c26..b24fa3c 100755 --- a/common/models/SliderImage.php +++ b/common/models/SliderImage.php @@ -15,7 +15,6 @@ use Yii; * @property string $url * @property integer $status * @property integer $sort - * @property double $price * * @property Slider $slider */ @@ -36,7 +35,6 @@ class SliderImage extends \yii\db\ActiveRecord { return [ [['slider_id', 'status', 'sort'], 'integer'], - [['price'], 'number'], [['image', 'alt', 'title', 'url'], 'string', 'max' => 255], [['slider_id'], 'exist', 'skipOnError' => true, 'targetClass' => Slider::className(), 'targetAttribute' => ['slider_id' => 'slider_id']], ]; @@ -56,7 +54,6 @@ class SliderImage extends \yii\db\ActiveRecord 'url' => Yii::t('app', 'url'), 'status' => Yii::t('app', 'status'), 'sort' => Yii::t('app', 'sort'), - 'price' => Yii::t('app', 'price'), ]; } @@ -67,4 +64,13 @@ class SliderImage extends \yii\db\ActiveRecord { return $this->hasOne(Slider::className(), ['slider_id' => 'slider_id']); } + + public function getImageFile() { + return empty($this->image) ? null : '/storage/slider/'. $this->image; + } + + public function getImageUrl() { + return empty($this->image) ? null : '/storage/slider/'. $this->image; + } + } diff --git a/common/models/Subscribe.php b/common/models/Subscribe.php old mode 100644 new mode 100755 index e3baba3..e3baba3 --- a/common/models/Subscribe.php +++ b/common/models/Subscribe.php diff --git a/common/models/SubscribeSearch.php b/common/models/SubscribeSearch.php new file mode 100644 index 0000000..4aeca70 --- /dev/null +++ b/common/models/SubscribeSearch.php @@ -0,0 +1,71 @@ + $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, + 'sale' => $this->sale, + 'sand' => $this->sand, + ]); + + $query->andFilterWhere(['like', 'email', $this->email]); + + return $dataProvider; + } +} diff --git a/common/modules/product/controllers/ProductUnitController.php b/common/modules/product/controllers/ProductUnitController.php old mode 100644 new mode 100755 index 7ee6139..7ee6139 --- a/common/modules/product/controllers/ProductUnitController.php +++ b/common/modules/product/controllers/ProductUnitController.php diff --git a/common/modules/product/models/ProductUnitSearch.php b/common/modules/product/models/ProductUnitSearch.php old mode 100644 new mode 100755 index 8b0be90..8b0be90 --- a/common/modules/product/models/ProductUnitSearch.php +++ b/common/modules/product/models/ProductUnitSearch.php diff --git a/common/modules/product/models/ProductVariant.php b/common/modules/product/models/ProductVariant.php index 08aa5cb..6be34a5 100755 --- a/common/modules/product/models/ProductVariant.php +++ b/common/modules/product/models/ProductVariant.php @@ -24,6 +24,17 @@ use Yii; */ class ProductVariant extends \yii\db\ActiveRecord { + + /**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 = []; /** @@ -128,4 +139,8 @@ class ProductVariant extends \yii\db\ActiveRecord { return new ProductVariantQuery(get_called_class()); } + + public function getId(){ + return $this->product_variant_id; + } } diff --git a/common/modules/product/views/product-unit/_form.php b/common/modules/product/views/product-unit/_form.php old mode 100644 new mode 100755 index f1a1206..f1a1206 --- a/common/modules/product/views/product-unit/_form.php +++ b/common/modules/product/views/product-unit/_form.php diff --git a/common/modules/product/views/product-unit/_search.php b/common/modules/product/views/product-unit/_search.php old mode 100644 new mode 100755 index 5fbe4cc..5fbe4cc --- a/common/modules/product/views/product-unit/_search.php +++ b/common/modules/product/views/product-unit/_search.php diff --git a/common/modules/product/views/product-unit/create.php b/common/modules/product/views/product-unit/create.php old mode 100644 new mode 100755 index 5c54fcc..5c54fcc --- a/common/modules/product/views/product-unit/create.php +++ b/common/modules/product/views/product-unit/create.php diff --git a/common/modules/product/views/product-unit/index.php b/common/modules/product/views/product-unit/index.php old mode 100644 new mode 100755 index de9aad8..de9aad8 --- a/common/modules/product/views/product-unit/index.php +++ b/common/modules/product/views/product-unit/index.php diff --git a/common/modules/product/views/product-unit/update.php b/common/modules/product/views/product-unit/update.php old mode 100644 new mode 100755 index fcd5ef7..fcd5ef7 --- a/common/modules/product/views/product-unit/update.php +++ b/common/modules/product/views/product-unit/update.php diff --git a/common/modules/product/views/product-unit/view.php b/common/modules/product/views/product-unit/view.php old mode 100644 new mode 100755 index a5fbf82..a5fbf82 --- a/common/modules/product/views/product-unit/view.php +++ b/common/modules/product/views/product-unit/view.php diff --git a/console/migrations/m160320_174258_customer.php b/console/migrations/m160320_174258_customer.php old mode 100644 new mode 100755 index 172287b..172287b --- a/console/migrations/m160320_174258_customer.php +++ b/console/migrations/m160320_174258_customer.php diff --git a/console/migrations/m160321_232402_orders.php b/console/migrations/m160321_232402_orders.php deleted file mode 100755 index 13e6251..0000000 --- a/console/migrations/m160321_232402_orders.php +++ /dev/null @@ -1,49 +0,0 @@ -db->driverName === 'mysql') { - // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci - $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; - } - - $this->createTable('{{%orders}}', [ - 'order_id' => $this->primaryKey(), - 'customer_id' => $this->integer(), - 'name' => $this->string()->notNull(), - 'email' => $this->string()->notNull(), - 'phone' => $this->string(32)->notNull(), - 'delivery' => $this->integer(), - 'payment' => $this->integer(), - 'code' => $this->string(), - 'status' => $this->smallInteger(), - 'created_at' => $this->integer()->notNull(), - 'updated_at' => $this->integer()->notNull(), - ], $tableOptions); - - $this->createTable('{{%order_items}}', [ - 'order_items_id' => $this->primaryKey(), - 'order_id' => $this->integer(), - 'item_id' => $this->integer(), - 'item_count' => $this->integer(), - 'price' => $this->float(), - ], $tableOptions); - - $this->addForeignKey('orders_items_fk', '{{%order_items}}', 'order_id', '{{%orders}}', 'order_id', 'CASCADE', 'CASCADE'); - $this->addForeignKey('orders_items_items_fk', '{{%order_items}}', 'item_id', '{{%product}}', 'product_id', 'RESTRICT', 'RESTRICT'); - } - - public function down() - { - $this->dropForeignKey('orders_items_fk', '{{%order_items}}'); - $this->dropForeignKey('orders_items_items_fk', '{{%order_items}}'); - $this->dropTable('{{%orders}}'); - $this->dropTable('{{%order_items}}'); - } - -} diff --git a/console/migrations/m160321_232402_orders1.php b/console/migrations/m160321_232402_orders1.php new file mode 100755 index 0000000..13e6251 --- /dev/null +++ b/console/migrations/m160321_232402_orders1.php @@ -0,0 +1,49 @@ +db->driverName === 'mysql') { + // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci + $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; + } + + $this->createTable('{{%orders}}', [ + 'order_id' => $this->primaryKey(), + 'customer_id' => $this->integer(), + 'name' => $this->string()->notNull(), + 'email' => $this->string()->notNull(), + 'phone' => $this->string(32)->notNull(), + 'delivery' => $this->integer(), + 'payment' => $this->integer(), + 'code' => $this->string(), + 'status' => $this->smallInteger(), + 'created_at' => $this->integer()->notNull(), + 'updated_at' => $this->integer()->notNull(), + ], $tableOptions); + + $this->createTable('{{%order_items}}', [ + 'order_items_id' => $this->primaryKey(), + 'order_id' => $this->integer(), + 'item_id' => $this->integer(), + 'item_count' => $this->integer(), + 'price' => $this->float(), + ], $tableOptions); + + $this->addForeignKey('orders_items_fk', '{{%order_items}}', 'order_id', '{{%orders}}', 'order_id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('orders_items_items_fk', '{{%order_items}}', 'item_id', '{{%product}}', 'product_id', 'RESTRICT', 'RESTRICT'); + } + + public function down() + { + $this->dropForeignKey('orders_items_fk', '{{%order_items}}'); + $this->dropForeignKey('orders_items_items_fk', '{{%order_items}}'); + $this->dropTable('{{%orders}}'); + $this->dropTable('{{%order_items}}'); + } + +} diff --git a/console/migrations/m160509_214535_customer.php b/console/migrations/m160509_214535_customer.php new file mode 100755 index 0000000..21066ab --- /dev/null +++ b/console/migrations/m160509_214535_customer.php @@ -0,0 +1,44 @@ +createTable('{{%customer}}', [ + + + 'id' => $this->primaryKey(), + 'username' => $this->string()->notNull(), + 'password' => $this->string()->notNull(), + 'name' => $this->string()->notNull(), + 'surname' => $this->string(), + 'phone' => $this->string(), + 'date_time' => $this->date()->defaultExpression('NOW()'), + 'sex' => $this->string(32), + 'birth_day' => $this->integer(), + 'birth_month' => $this->integer(), + 'birth_year' => $this->integer(), + 'body' => $this->text(), + 'group_id' => $this->integer(), + ]); + } + + public function down() + { + $this->dropTable('{{%customer}}'); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/console/migrations/m160509_231345_auth_assignment.php b/console/migrations/m160509_231345_auth_assignment.php new file mode 100755 index 0000000..737bff1 --- /dev/null +++ b/console/migrations/m160509_231345_auth_assignment.php @@ -0,0 +1,33 @@ +createTable('{{%auth_assignment}}', [ + + + 'item_name' => $this->string(), + 'user_id' => $this->integer(), + 'created_at' => $this->integer(), + ]); + } + + public function down() + { + $this->dropTable('{{%auth_assignment}}'); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/console/migrations/m160512_153443_subscribe.php b/console/migrations/m160512_153443_subscribe.php new file mode 100644 index 0000000..2520be3 --- /dev/null +++ b/console/migrations/m160512_153443_subscribe.php @@ -0,0 +1,24 @@ +createTable('{{%subscribe}}', [ + + + 'id' => $this->primaryKey(), + 'email' => $this->string()->notNull(), + 'sale' => $this->integer()->notNull(), + 'sand' => $this->smallInteger()->notNull()->defaultValue(0), + ]); + } + + public function down() + { + $this->dropTable('{{%subscribe}}'); + } + +} diff --git a/console/migrations/m160516_222821_orders.php b/console/migrations/m160516_222821_orders.php new file mode 100644 index 0000000..80bf1ab --- /dev/null +++ b/console/migrations/m160516_222821_orders.php @@ -0,0 +1,72 @@ +db->driverName === 'mysql') { + // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci + $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; + } + + + $this->createTable('{{%orders}}', [ + 'id' => $this->primaryKey(), + 'user_id' => $this->integer(), + 'name' => $this->string()->notNull(), + 'surname' => $this->string()->notNull(), + 'patronymic' => $this->string()->notNull(), + 'phone' => $this->string(), + 'phone2' => $this->string(), + 'email' => $this->string(), + 'adress' => $this->string(), + 'body' => $this->text(), + 'total' => $this->float(), + 'date_time' => $this->dateTime(), + 'date_dedline' => $this->date(), + 'reserve' => $this->string(), + 'status' => $this->string(), + 'comment' => $this->text(), + 'label' => $this->integer(), + 'pay' => $this->integer(), + 'numbercard' => $this->integer(), + 'delivery' => $this->string(), + 'declaration' => $this->string(), + 'stock' => $this->string(), + 'consignment' => $this->string(), + 'payment' => $this->string(), + 'insurance' => $this->string(), + 'amount_imposed' => $this->float(), + 'shipping_by' => $this->string(), + 'city' => $this->string(), + ], $tableOptions); + + + $this->createTable('{{%orders_products}}', [ + 'id' => $this->primaryKey(), + 'order_id' => $this->integer(), + 'mod_id' => $this->integer(), + 'product_name' => $this->string(), + 'name' => $this->string(), + 'sku' => $this->string(), + 'price' => $this->float(), + 'count' => $this->integer(), + 'sum_cost' => $this->float(), + ], $tableOptions); + + $this->addForeignKey('orders_products_fk', '{{%orders_products}}', 'order_id', '{{%orders}}', 'id', 'CASCADE', 'CASCADE'); + $this->addForeignKey('orders_products_items_fk', '{{%orders_products}}', 'id', '{{%product}}', 'product_id', 'RESTRICT', 'RESTRICT'); + } + + public function down() + { + $this->dropForeignKey('orders_products_fk', '{{%orders_products}}'); + $this->dropForeignKey('orders_products_items_fk', '{{%orders_products}}'); + $this->dropTable('{{%orders}}'); + $this->dropTable('{{%orders_products}}'); + } + +} \ No newline at end of file diff --git a/console/migrations/m160516_234753_orders_delivery.php b/console/migrations/m160516_234753_orders_delivery.php new file mode 100644 index 0000000..29cff5b --- /dev/null +++ b/console/migrations/m160516_234753_orders_delivery.php @@ -0,0 +1,38 @@ +createTable('{{%orders_delivery}}', [ + 'id' => $this->primaryKey(), + 'parent_id' => $this->integer(), + 'title' => $this->string(), + 'title_ukr' => $this->string(), + 'value' => $this->integer(), + 'text' => $this->text(), + 'text_ukr' => $this->text(), + 'sort' => $this->integer(), + ]); + + } + + public function down() + { + $this->dropTable('{{%orders_delivery}}'); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/controllers/BasketController.php b/frontend/controllers/BasketController.php old mode 100755 new mode 100644 index a207c61..460a7a1 --- a/frontend/controllers/BasketController.php +++ b/frontend/controllers/BasketController.php @@ -1,30 +1,33 @@ deleteBasketMod($_GET['deleteID']); + $modelOrder->deleteBasketMod($_GET['deleteID']); return Yii::$app->response->redirect(['basket/index']); } if(isset($_POST['update'])){ foreach ($_POST['Mod'] as $index=>$row) { - $modelMod->updateBasket($row); + $modelOrder->updateBasket($row); } }elseif(isset($_POST['Mod'])){ $body = ''; @@ -36,7 +39,7 @@ class BasketController extends Controller if ($modelOrder->load(Yii::$app->request->post()) && $modelOrder->save() && $modelOrder->contact('borisenko.pavel@gmail.com',$body)) { foreach ($_POST['Mod'] as $index=>$row) { - $modelOrdersProducts = new OrdersProducts; + $modelOrdersProducts = new OrdersProducts(); $mod_id = $row['id']; unset($row['id']); $data['OrdersProducts'] = $row; @@ -47,7 +50,7 @@ class BasketController extends Controller $modelOrdersProducts->save(); } if(!Yii::$app->user->id){ - $modelUser = new User; + $modelUser = new Customer(); $modelUser->role = 'person'; $modelUser->username = $modelOrder->email; $modelUser->name = $modelOrder->name; @@ -61,10 +64,10 @@ class BasketController extends Controller } } - $basket_mods = $modelMod->getBasketMods(); + $basket_mods = $modelOrder->getBasketMods(); if(!empty(Yii::$app->user->id)){ - $user = User::findOne(Yii::$app->user->id); + $user = Customer::findOne(Yii::$app->user->id); $modelOrder->email = $user->username; $modelOrder->phone = $user->phone; $modelOrder->name = $user->name; @@ -79,7 +82,7 @@ class BasketController extends Controller } public function actionItems(){ - $modelMod = new Mod; + $modelMod = new Orders; if(!empty($_GET['deleteID'])){ $modelMod->deleteBasketMod($_GET['deleteID']); } @@ -98,7 +101,7 @@ class BasketController extends Controller public function actionInfo() { - $modelMod = new Mod; + $modelMod = new Orders(); $info = $modelMod->rowBasket(); return $this->renderAjax('ajax_info', [ 'info'=>$info, @@ -106,9 +109,9 @@ class BasketController extends Controller } public function actionAdd(){ - $modelMod = new Mod; + $modelOrders = new Orders(); if(isset($_GET['mod_id'],$_GET['count']) && $_GET['mod_id']>0 && $_GET['count']>0){ - $modelMod->addBasket($_GET['mod_id'],$_GET['count']); + $modelOrders->addBasket($_GET['mod_id'],$_GET['count']); } Yii::$app->end(); diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php old mode 100644 new mode 100755 index e60d215..e60d215 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php diff --git a/frontend/controllers/EventController.php b/frontend/controllers/EventController.php old mode 100644 new mode 100755 index 34e09b1..34e09b1 --- a/frontend/controllers/EventController.php +++ b/frontend/controllers/EventController.php diff --git a/frontend/controllers/OrdersController.php b/frontend/controllers/OrdersController.php old mode 100644 new mode 100755 index ab576bd..294bcd5 --- a/frontend/controllers/OrdersController.php +++ b/frontend/controllers/OrdersController.php @@ -1,311 +1,311 @@ -id == 'buy-items' || $action->id == 'delete') { - Yii::$app->controller->enableCsrfValidation = false; - } - - return true; - } - - public function actionFirst(){ - - $array = Yii::$app->session->get('order'); - - if(isset($array['order_id']) ) { - $model = Orders::findOne($array['order_id']); - }else { - $model = new Orders(); - } - - - if(Yii::$app->request->post() && $model->load(Yii::$app->request->post())){ - - if($model->save()){ - - $array['order_id'] = $model->order_id; - - Yii::$app->session->set('order', $array ); - - return $this->redirect(['orders/second']); - } - - } else { - if (!Yii::$app->user->isGuest) { - $customer = Yii::$app->user->identity; - $model->name = $customer->name; - $model->email = $customer->email; - $model->phone = $customer->phone; - } - } - - - return $this->render('basket-step-01',[ - 'model' => $model - ]); - } - - public function actionSecond(){ - - $sessionData = \Yii::$app->session->get('order'); - - $order_id = $sessionData['order_id']; - - if(!empty($order_id)){ - $order_model = Orders::findOne($order_id); - } else{ - $order_model = new Orders; - } - - unset($sessionData['order_id']); - - $variant = ProductVariant::find()->where(['product_variant_id'=>array_keys($sessionData)])->indexBy('product_variant_id')->all(); - - - if(Yii::$app->request->post()){ - - foreach ($sessionData as $k => $item) { - $itemModel = OrderItems::find()->where(['order_id'=>$order_id, 'item_id'=> $variant[$k]->product_variant_id])->one(); - if($itemModel instanceof OrderItems){ - $itemModel->order_id = $order_id; - $itemModel->item_id = $variant[$k]->product_variant_id; - $itemModel->item_count = $sessionData[$k]['num']; - $itemModel->price = $variant[$k]->price; - $itemModel->save(); - } else { - $itemModel = new OrderItems(); - $itemModel->order_id = $order_id; - $itemModel->item_id = $variant[$k]->product_variant_id; - $itemModel->item_count = $sessionData[$k]['num']; - $itemModel->price = $variant[$k]->price; - $itemModel->save(); - } - - } - Yii::$app->session->set('order', [] ); - return $this->redirect(['orders/third']); - - } else { - - $price = 0; - - $count = count($sessionData); - - foreach ($sessionData as $k => $item) { - $sessionData[$k]['item'] = $variant[$k]; - $price += $variant[$k]->price * $sessionData[$k]['num']; - } - - } - - return $this->render('basket-step-02',[ - 'items'=>$sessionData, - 'count' => $count, - 'price' => $price, - 'order_id' => $order_id, - 'order_model' => $order_model, - ]); - - } - - public function actionThird(){ - return $this->render('basket-step-03'); - } - - -// /** -// * Lists all Order models. -// * @return mixed -// */ -// public function actionIndex() -// { -// -// if (Yii::$app->request->post()) { -// $item = $items_id = array(); -// -// $i = 0; -// $order = Yii::$app->request->post(); -// -// $orderData['Order'] = $order['OrderForm']; -// -// foreach($order['OrderForm']['one_item'] as $k => $v ){ -// $item[$k]['num'] = $v['num']; -// $items_id[] = $k; -// $i++; -// } -// -// $items = Items::find()->where(['id'=>$items_id])->all(); -// -// -// $orderModel = new Order(); -// $orderModel->load($orderData); -// $orderModel->save(); -// -// -// foreach($items as $one_item){ -// $ItemOrderModel = new ItemOrder(); -// $ItemOrderModel->order_id = $orderModel->id; -// $ItemOrderModel->num = $item[$one_item->id]['num']; -// $ItemOrderModel->item_id = $one_item->id; -// $ItemOrderModel->price = $one_item->price * $item[$one_item->id]['num']; -// $ItemOrderModel->item_name = $one_item->name; -// $ItemOrderModel->save(); -// } -// Yii::$app->session->set('order', [] ); -// return $this->redirect(['order/complete']); -// } -// $total_price = 0; -// -// $items_id = []; -// -// $orders = Yii::$app->session->get('order'); -// -// if(!empty($orders)){ -// foreach($orders as $k => $v) { -// $items_id[] = $k; -// } -// } -// -// -// $items = Items::find()->where(['id'=>$items_id])->all(); -// -// foreach($items as $item) { -// $total_price += $orders[$item['id']]['num'] * $item['price']; -// } -// -// -// $dataProvider = new ArrayDataProvider([ -// 'allModels' => $items -// ]); -// -// return $this->render('index', [ -// 'dataProvider' => $dataProvider, -// 'total_price'=> $total_price, -// 'model' => new OrderForm() -// ]); -// } - - - public function actionComplete() - { - return $this->render('complete', [ - ]); - } - - public function actionBuyItems(){ - $data = Yii::$app->request->post(); - $sessionData = Yii::$app->session->get('order'); - if(isset($sessionData) && !array_search($data['id'],Yii::$app->session->get('order')) ){ - $array = Yii::$app->session->get('order'); - $array[$data['id']] = $data; - Yii::$app->session->set('order', $array ); - } else { - $array[$data['id']] = $data; - Yii::$app->session->set('order', $array ); - } - echo BasketModal::widget([]); - - } - /** - * Displays a single Order model. - * @param integer $id - * @return mixed - */ - public function actionView($id) - { - return $this->render('view', [ - 'model' => $this->findModel($id), - ]); - } - - /** - * Creates a new Order model. - * If creation is successful, the browser will be redirected to the 'view' page. - * @return mixed - */ - public function actionCreate() - { - $model = new Order(); - - if ($model->load(Yii::$app->request->post()) && $model->save()) { - return $this->redirect(['view', 'id' => $model->id]); - } else { - return $this->render('create', [ - 'model' => $model, - ]); - } - } - - /** - * Updates an existing Order 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->id]); - } else { - return $this->render('update', [ - 'model' => $model, - ]); - } - } - - /** - * Deletes an existing Order model. - * If deletion is successful, the browser will be redirected to the 'index' page. - * @param integer $id - * @return mixed - */ - public function actionDelete() - { - $data = Yii::$app->request->post(); - $sessionData = Yii::$app->session->get('order'); - unset($sessionData[$data['id']]); - Yii::$app->session->set('order', $sessionData); - return count(Yii::$app->session->get('order')); - } - - /** - * Finds the Order model based on its primary key value. - * If the model is not found, a 404 HTTP exception will be thrown. - * @param integer $id - * @return Order the loaded model - * @throws NotFoundHttpException if the model cannot be found - */ - protected function findModel($id) - { - if (($model = Order::findOne($id)) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } -} +id == 'buy-items' || $action->id == 'delete') { + Yii::$app->controller->enableCsrfValidation = false; + } + + return true; + } + + public function actionFirst(){ + + $array = Yii::$app->session->get('order'); + + if(isset($array['order_id']) ) { + $model = Orders::findOne($array['order_id']); + }else { + $model = new Orders(); + } + + + if(Yii::$app->request->post() && $model->load(Yii::$app->request->post())){ + + if($model->save()){ + + $array['order_id'] = $model->order_id; + + Yii::$app->session->set('order', $array ); + + return $this->redirect(['orders/second']); + } + + } else { + if (!Yii::$app->user->isGuest) { + $customer = Yii::$app->user->identity; + $model->name = $customer->name; + $model->email = $customer->email; + $model->phone = $customer->phone; + } + } + + + return $this->render('basket-step-01',[ + 'model' => $model + ]); + } + + public function actionSecond(){ + + $sessionData = \Yii::$app->session->get('order'); + + $order_id = $sessionData['order_id']; + + if(!empty($order_id)){ + $order_model = Orders::findOne($order_id); + } else{ + $order_model = new Orders; + } + + unset($sessionData['order_id']); + + $variant = ProductVariant::find()->where(['product_variant_id'=>array_keys($sessionData)])->indexBy('product_variant_id')->all(); + + + if(Yii::$app->request->post()){ + + foreach ($sessionData as $k => $item) { + $itemModel = OrderItems::find()->where(['order_id'=>$order_id, 'item_id'=> $variant[$k]->product_variant_id])->one(); + if($itemModel instanceof OrderItems){ + $itemModel->order_id = $order_id; + $itemModel->item_id = $variant[$k]->product_variant_id; + $itemModel->item_count = $sessionData[$k]['num']; + $itemModel->price = $variant[$k]->price; + $itemModel->save(); + } else { + $itemModel = new OrderItems(); + $itemModel->order_id = $order_id; + $itemModel->item_id = $variant[$k]->product_variant_id; + $itemModel->item_count = $sessionData[$k]['num']; + $itemModel->price = $variant[$k]->price; + $itemModel->save(); + } + + } + Yii::$app->session->set('order', [] ); + return $this->redirect(['orders/third']); + + } else { + + $price = 0; + + $count = count($sessionData); + + foreach ($sessionData as $k => $item) { + $sessionData[$k]['item'] = $variant[$k]; + $price += $variant[$k]->price * $sessionData[$k]['num']; + } + + } + + return $this->render('basket-step-02',[ + 'items'=>$sessionData, + 'count' => $count, + 'price' => $price, + 'order_id' => $order_id, + 'order_model' => $order_model, + ]); + + } + + public function actionThird(){ + return $this->render('basket-step-03'); + } + + +// /** +// * Lists all Order models. +// * @return mixed +// */ +// public function actionIndex() +// { +// +// if (Yii::$app->request->post()) { +// $item = $items_id = array(); +// +// $i = 0; +// $order = Yii::$app->request->post(); +// +// $orderData['Order'] = $order['OrderForm']; +// +// foreach($order['OrderForm']['one_item'] as $k => $v ){ +// $item[$k]['num'] = $v['num']; +// $items_id[] = $k; +// $i++; +// } +// +// $items = Items::find()->where(['id'=>$items_id])->all(); +// +// +// $orderModel = new Order(); +// $orderModel->load($orderData); +// $orderModel->save(); +// +// +// foreach($items as $one_item){ +// $ItemOrderModel = new ItemOrder(); +// $ItemOrderModel->order_id = $orderModel->id; +// $ItemOrderModel->num = $item[$one_item->id]['num']; +// $ItemOrderModel->item_id = $one_item->id; +// $ItemOrderModel->price = $one_item->price * $item[$one_item->id]['num']; +// $ItemOrderModel->item_name = $one_item->name; +// $ItemOrderModel->save(); +// } +// Yii::$app->session->set('order', [] ); +// return $this->redirect(['order/complete']); +// } +// $total_price = 0; +// +// $items_id = []; +// +// $orders = Yii::$app->session->get('order'); +// +// if(!empty($orders)){ +// foreach($orders as $k => $v) { +// $items_id[] = $k; +// } +// } +// +// +// $items = Items::find()->where(['id'=>$items_id])->all(); +// +// foreach($items as $item) { +// $total_price += $orders[$item['id']]['num'] * $item['price']; +// } +// +// +// $dataProvider = new ArrayDataProvider([ +// 'allModels' => $items +// ]); +// +// return $this->render('index', [ +// 'dataProvider' => $dataProvider, +// 'total_price'=> $total_price, +// 'model' => new OrderForm() +// ]); +// } + + + public function actionComplete() + { + return $this->render('complete', [ + ]); + } + + public function actionBuyItems(){ + $data = Yii::$app->request->post(); + $sessionData = Yii::$app->session->get('order'); + if(isset($sessionData) && !array_search($data['id'],Yii::$app->session->get('order')) ){ + $array = Yii::$app->session->get('order'); + $array[$data['id']] = $data; + Yii::$app->session->set('order', $array ); + } else { + $array[$data['id']] = $data; + Yii::$app->session->set('order', $array ); + } + echo BasketModal::widget([]); + + } + /** + * Displays a single Order model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Order model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Orders(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Order 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->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Order model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete() + { + $data = Yii::$app->request->post(); + $sessionData = Yii::$app->session->get('order'); + unset($sessionData[$data['id']]); + Yii::$app->session->set('order', $sessionData); + return count(Yii::$app->session->get('order')); + } + + /** + * Finds the Order model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Orders the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Orders::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/frontend/controllers/PageController.php b/frontend/controllers/PageController.php old mode 100644 new mode 100755 index a65088a..a65088a --- a/frontend/controllers/PageController.php +++ b/frontend/controllers/PageController.php diff --git a/frontend/controllers/PostController.php b/frontend/controllers/PostController.php old mode 100644 new mode 100755 index 8935ca7..8935ca7 --- a/frontend/controllers/PostController.php +++ b/frontend/controllers/PostController.php diff --git a/frontend/controllers/ServiceController.php b/frontend/controllers/ServiceController.php old mode 100644 new mode 100755 index 1b50bf2..1b50bf2 --- a/frontend/controllers/ServiceController.php +++ b/frontend/controllers/ServiceController.php diff --git a/frontend/controllers/SubscribeController.php b/frontend/controllers/SubscribeController.php index cbf2a03..51aab8c 100755 --- a/frontend/controllers/SubscribeController.php +++ b/frontend/controllers/SubscribeController.php @@ -7,6 +7,8 @@ use yii\web\Controller; use common\models\Subscribe; use yii\web\HttpException; use yii\data\Pagination; +use yii\web\Response; +use yii\widgets\ActiveForm; class SubscribeController extends Controller { @@ -14,12 +16,18 @@ class SubscribeController extends Controller public function actionIndex() { $model = new Subscribe; + if (Yii::$app->request->isAjax) { + Yii::$app->response->format = Response::FORMAT_JSON; + $model->load(Yii::$app->request->post()); + return ActiveForm::validate($model); + } else { + if ($model->load(Yii::$app->request->post()) && $model->save()) { + + Yii::$app->getSession()->setFlash('success', 'Вы успешно подписались на рассылку!'); + return $this->refresh(); + } + } - if ($model->load(Yii::$app->request->post()) && $model->save()) { - - Yii::$app->getSession()->setFlash('success', 'Вы успешно подписались на рассылку!'); - return $this->refresh(); - } return $this->render('index',['model'=>$model]); } diff --git a/frontend/views/basket/ajax_items.php b/frontend/views/basket/ajax_items.php index 8c93190..e54b605 100755 --- a/frontend/views/basket/ajax_items.php +++ b/frontend/views/basket/ajax_items.php @@ -3,16 +3,16 @@ use yii\widgets\ActiveForm; use yii\helpers\Html; ?> false,'id'=>'basket_form2']); ?> -$item):?> +$item):?>
field($item,'['.$i.']id')->hiddenInput()->label(false); ?>
-
+
product_name?>
- old_cost>0):?>
old_cost?> грн.
-
cost?> грн.
+ price_old>0):?>
price_old?> грн.
+
price?> грн.
@@ -21,7 +21,7 @@ use yii\helpers\Html;
sum_cost?> грн.
- +
Всего: getSumCost()?> грн.
diff --git a/frontend/views/basket/index.php b/frontend/views/basket/index.php index d4cdb68..4db06c3 100755 --- a/frontend/views/basket/index.php +++ b/frontend/views/basket/index.php @@ -5,7 +5,7 @@ use yii\web\View; use yii\helpers\ArrayHelper; use yii\widgets\Breadcrumbs; use yii\bootstrap\ActiveForm; -use app\models\Delivery; +use common\models\Delivery; $this->title = 'Корзина'; $this->registerMetaTag(['name' => 'description', 'content' => 'Корзина']); @@ -57,14 +57,14 @@ $('#order-delivery input[type=\"radio\"]').click(function(){ ?>
-where(['parent_id'=>0])->all() as $item):?> +where(['parent_id'=>0])->all() as $item):?>
text?> field($modelOrder, 'delivery') ->radioList(ArrayHelper::map(Delivery::find()->where(['parent_id'=>$item->id])->asArray()->all(), 'id', 'title'),['id' => 'order-delivery-childs'])->label(false) ?>
- + field($modelOrder, 'payment')->radioList(['Оплатить наличными'=>'Оплатить наличными','Оплатить на карту Приват Банка'=>'Оплатить на карту Приват Банка','Оплатить по безналичному расчету'=>'Оплатить по безналичному расчету','Оплатить Правекс-телеграф'=>'Оплатить Правекс-телеграф','Наложенным платежом'=>'Наложенным платежом']); ?>
@@ -77,32 +77,32 @@ $('#order-delivery input[type=\"radio\"]').click(function(){
-$item):?> +$item):?>
- +
product_name?> -

Код: art?>, цвет: color?>

+

Код: sku?>, цвет: name?>

field($item,'['.$i.']id')->hiddenInput()->label(false); ?> field($item,'['.$i.']product_name')->hiddenInput()->label(false); ?> - field($item,'['.$i.']art')->hiddenInput()->label(false); ?> + field($item,'['.$i.']sku')->hiddenInput()->label(false); ?> field($item,'['.$i.']name')->hiddenInput()->label(false); ?> - field($item,'['.$i.']cost')->hiddenInput()->label(false); ?> + field($item,'['.$i.']price')->hiddenInput()->label(false); ?> field($item,'['.$i.']sum_cost')->hiddenInput()->label(false); ?>
-
цена за один cost?> грн, цена sum_cost?> грн
+
цена за один price?> грн, цена sum_cost?> грн
field($item,'['.$i.']count')->textInput(['type'=>'number'])->label(false); ?>
Удалить
- + "update",'class'=>'submit4 fl')); ?>
- field($modelOrder, 'total')->hiddenInput(['value'=>$modelMod->getSumCost()])->label(false); ?> - Общая сумма: getSumCost();?> грн. + field($modelOrder, 'total')->hiddenInput(['value'=>$modelOrder->getSumCost()])->label(false); ?> + Общая сумма: getSumCost();?> грн.
diff --git a/frontend/views/cabinet/bookmarks.php b/frontend/views/cabinet/bookmarks.php old mode 100644 new mode 100755 index 804d20d..804d20d --- a/frontend/views/cabinet/bookmarks.php +++ b/frontend/views/cabinet/bookmarks.php diff --git a/frontend/views/cabinet/index.php b/frontend/views/cabinet/index.php old mode 100644 new mode 100755 index 0cd910e..0cd910e --- a/frontend/views/cabinet/index.php +++ b/frontend/views/cabinet/index.php diff --git a/frontend/views/cabinet/my-orders.php b/frontend/views/cabinet/my-orders.php old mode 100644 new mode 100755 index 72f32c9..72f32c9 --- a/frontend/views/cabinet/my-orders.php +++ b/frontend/views/cabinet/my-orders.php diff --git a/frontend/views/cabinet/update.php b/frontend/views/cabinet/update.php old mode 100644 new mode 100755 index dbb8439..dbb8439 --- a/frontend/views/cabinet/update.php +++ b/frontend/views/cabinet/update.php diff --git a/frontend/views/catalog/categories.php b/frontend/views/catalog/categories.php old mode 100644 new mode 100755 index cefd71b..cefd71b --- a/frontend/views/catalog/categories.php +++ b/frontend/views/catalog/categories.php diff --git a/frontend/views/catalog/product.php b/frontend/views/catalog/product.php old mode 100644 new mode 100755 index 7bb8053..7bb8053 --- a/frontend/views/catalog/product.php +++ b/frontend/views/catalog/product.php diff --git a/frontend/views/catalog/product_item.php b/frontend/views/catalog/product_item.php old mode 100644 new mode 100755 index de19184..de19184 --- a/frontend/views/catalog/product_item.php +++ b/frontend/views/catalog/product_item.php diff --git a/frontend/views/catalog/product_smart.php b/frontend/views/catalog/product_smart.php old mode 100644 new mode 100755 index a0313e4..a0313e4 --- a/frontend/views/catalog/product_smart.php +++ b/frontend/views/catalog/product_smart.php diff --git a/frontend/views/catalog/products.old.php b/frontend/views/catalog/products.old.php old mode 100644 new mode 100755 index 201dd88..201dd88 --- a/frontend/views/catalog/products.old.php +++ b/frontend/views/catalog/products.old.php diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php old mode 100644 new mode 100755 index 39cc79d..39cc79d --- a/frontend/views/catalog/products.php +++ b/frontend/views/catalog/products.php diff --git a/frontend/views/catalog/search.php b/frontend/views/catalog/search.php old mode 100644 new mode 100755 index db193fe..db193fe --- a/frontend/views/catalog/search.php +++ b/frontend/views/catalog/search.php diff --git a/frontend/views/event/_objects.php b/frontend/views/event/_objects.php old mode 100644 new mode 100755 index 20ae70b..20ae70b --- a/frontend/views/event/_objects.php +++ b/frontend/views/event/_objects.php diff --git a/frontend/views/event/index.php b/frontend/views/event/index.php old mode 100644 new mode 100755 index a93a500..a93a500 --- a/frontend/views/event/index.php +++ b/frontend/views/event/index.php diff --git a/frontend/views/event/view.php b/frontend/views/event/view.php old mode 100644 new mode 100755 index b6e8727..b6e8727 --- a/frontend/views/event/view.php +++ b/frontend/views/event/view.php diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 30664eb..2ec9d52 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -1,4 +1,5 @@
- user->isGuest): ?> + user->isGuest): ?> Личный кабинет - + user->identity->username, 20) ?> Выход - +
@@ -155,10 +156,10 @@ - - *
- *
- **/ ?> @@ -336,8 +324,8 @@ $subscribe = new Subscribe; $form = ActiveForm::begin (['action' => '/subscribe']); ?> - field ($subscribe, 'email')->textInput (['placeholder' => 'E-mail'])->label (false); ?> - field ($subscribe, 'sale')->dropDownList (['10' => '10%', '20' => '20%'], ['prompt' => 'Скидка'])->label (false); ?> + field ($subscribe, 'email')->textInput (['placeholder' => 'E-mail', 'enableAjaxValidation' => true])->label (false); ?> + field ($subscribe, 'sale')->dropDownList (['10' => '10%', '20' => '20%'], ['prompt' => 'Скидка', 'enableAjaxValidation' => true])->label (false); ?>
укажите желаемый размер скидки
'submit4m']); ?> @@ -364,7 +352,7 @@
-
© 2015 Rukzachok. Все права защищены.
+
© Rukzachok. Все права защищены.
diff --git a/frontend/views/modal/consultation_modal.php b/frontend/views/modal/consultation_modal.php old mode 100644 new mode 100755 index 0f05bc2..0f05bc2 --- a/frontend/views/modal/consultation_modal.php +++ b/frontend/views/modal/consultation_modal.php diff --git a/frontend/views/modal/forgot_password_form_model_window.php b/frontend/views/modal/forgot_password_form_model_window.php old mode 100644 new mode 100755 index eabe848..eabe848 --- a/frontend/views/modal/forgot_password_form_model_window.php +++ b/frontend/views/modal/forgot_password_form_model_window.php diff --git a/frontend/views/modal/login_window_model_window.php b/frontend/views/modal/login_window_model_window.php old mode 100644 new mode 100755 index 02ed6a0..02ed6a0 --- a/frontend/views/modal/login_window_model_window.php +++ b/frontend/views/modal/login_window_model_window.php diff --git a/frontend/views/modal/registration_window_model_window.php b/frontend/views/modal/registration_window_model_window.php old mode 100644 new mode 100755 index 160f165..160f165 --- a/frontend/views/modal/registration_window_model_window.php +++ b/frontend/views/modal/registration_window_model_window.php diff --git a/frontend/views/news/index.php b/frontend/views/news/index.php index 3ff5df4..dcc3cc1 100755 --- a/frontend/views/news/index.php +++ b/frontend/views/news/index.php @@ -1,12 +1,10 @@ - -title = 'Новости'; +title = 'Новости'; $this->registerMetaTag(['name' => 'description', 'content' => 'Новости']); $this->registerMetaTag(['name' => 'keywords', 'content' => 'Новости']); ?> diff --git a/frontend/views/news/show.php b/frontend/views/news/show.php index d3b063b..578736d 100755 --- a/frontend/views/news/show.php +++ b/frontend/views/news/show.php @@ -1,10 +1,8 @@ - -title = $news->meta_title; +title = $news->meta_title; $this->registerMetaTag(['name' => 'description', 'content' => $news->meta_description]); $this->registerMetaTag(['name' => 'keywords', 'content' => $news->meta_keywords]); ?> diff --git a/frontend/views/orders/basket-step-01.php b/frontend/views/orders/basket-step-01.php old mode 100644 new mode 100755 index 3a57a2d..3a57a2d --- a/frontend/views/orders/basket-step-01.php +++ b/frontend/views/orders/basket-step-01.php diff --git a/frontend/views/orders/basket-step-02.php b/frontend/views/orders/basket-step-02.php old mode 100644 new mode 100755 index beaf0b4..beaf0b4 --- a/frontend/views/orders/basket-step-02.php +++ b/frontend/views/orders/basket-step-02.php diff --git a/frontend/views/orders/basket-step-03.php b/frontend/views/orders/basket-step-03.php old mode 100644 new mode 100755 index 0c6deaf..0c6deaf --- a/frontend/views/orders/basket-step-03.php +++ b/frontend/views/orders/basket-step-03.php diff --git a/frontend/views/page/show.php b/frontend/views/page/show.php old mode 100644 new mode 100755 index dfcec53..dfcec53 --- a/frontend/views/page/show.php +++ b/frontend/views/page/show.php diff --git a/frontend/views/service/_objects.php b/frontend/views/service/_objects.php old mode 100644 new mode 100755 index d9a48cb..d9a48cb --- a/frontend/views/service/_objects.php +++ b/frontend/views/service/_objects.php diff --git a/frontend/views/service/index.php b/frontend/views/service/index.php old mode 100644 new mode 100755 index 07d5468..07d5468 --- a/frontend/views/service/index.php +++ b/frontend/views/service/index.php diff --git a/frontend/views/service/view.php b/frontend/views/service/view.php old mode 100644 new mode 100755 index ab983bb..ab983bb --- a/frontend/views/service/view.php +++ b/frontend/views/service/view.php diff --git a/frontend/views/site/_index.php b/frontend/views/site/_index.php index 27b26b6..5999ad3 100755 --- a/frontend/views/site/_index.php +++ b/frontend/views/site/_index.php @@ -48,8 +48,7 @@ use yii\bootstrap\ActiveForm; 'clientOptions' => ['step' => 1], ]) ?> -registerMetaTag(['name' => 'keywords', 'content' => 'Подписка']);

Подписаться на акции

-session->getFlash('success')):?> -
- + errorSummary($model); ?> diff --git a/frontend/views/text/index.php b/frontend/views/text/index.php index 7de473c..51a275e 100755 --- a/frontend/views/text/index.php +++ b/frontend/views/text/index.php @@ -1,7 +1,7 @@ - -title = $text->meta_title; $this->registerMetaTag(['name' => 'description', 'content' => $text->meta_description]); $this->registerMetaTag(['name' => 'keywords', 'content' => $text->meta_keywords]); diff --git a/frontend/web/img/ico_close2.png b/frontend/web/img/ico_close2.png new file mode 100755 index 0000000..d3e87b9 Binary files /dev/null and b/frontend/web/img/ico_close2.png differ diff --git a/frontend/web/img/no_photo.png b/frontend/web/img/no_photo.png old mode 100644 new mode 100755 index aef9e08..aef9e08 Binary files a/frontend/web/img/no_photo.png and b/frontend/web/img/no_photo.png differ diff --git a/frontend/web/img/no_photo_big.png b/frontend/web/img/no_photo_big.png old mode 100644 new mode 100755 index fc71420..fc71420 Binary files a/frontend/web/img/no_photo_big.png and b/frontend/web/img/no_photo_big.png differ diff --git a/frontend/web/js/basket.js b/frontend/web/js/basket.js old mode 100755 new mode 100644 index 6b3fadb..6b3fadb --- a/frontend/web/js/basket.js +++ b/frontend/web/js/basket.js diff --git a/frontend/web/js/basket2.js b/frontend/web/js/basket2.js new file mode 100755 index 0000000..5a2bcc1 --- /dev/null +++ b/frontend/web/js/basket2.js @@ -0,0 +1,193 @@ +$(function(){ + $('body').on('click', '#basket_button', function(event){ + event.preventDefault(); + $(".black").removeClass("hidden"); + }); + $(".black_close").click(function () { + $(this).parent().parent().addClass("hidden"); + }); + $(".cont_shop").click(function () { + $(".black").addClass("hidden"); + }); +}); +$(document).ready(function(){ + + var result_block = $('.basket_result'); + var one_item_block = $('.busket_block'); + + function countItems(){ + var length = $('.busket_modal_01').find('.order_list_li').length; + if(length >= 1){ + $('.head_basket_count').html(length); + $('.all_count').html(length); + } else { + $('.head_basket_count').html(''); + $('.all_count').html(''); + } + } + + + + function changeAjaxPrice(id, num){ + $.post( "/orders/buy-items", {id: id, num:num}, function( data ) { + }); + } + + function countPrise(block){ + var totalBlock = block.parents('.order_list'); + var total_price = 0; + totalBlock.find('.price_val').each(function(){ + total_price += +$(this).html(); + }); + $('.all_price_span').html(total_price); + } + + + $('.item').on('click', '.basket_add_but', function(e){ + var id = $('#product_id').val(); + $.post( "/orders/buy-items", {id: id, num:1}, function( data ) { + $('.basket_result').each(function(){ + $(this).html(data); + countItems(); + }); + + }); + + }); + + $('.main_cont_wrap').on('click', '.cart_btn', function(e){ + var id = $(this).data('id'); + var num = one_item_block.find('.buy_one_item').val(); + $.post( "/orders/buy-items", {id: id, num:num}, function( data ) { + $('.basket_result').each(function(){ + $(this).html(data) + }); + }); + + }); + + result_block.on('click', '.delete_item_btn', function(){ + var block = $(this).parents('.order_list_li'); + + + var id = block.data('id'); + + $.post( "/orders/delete", {id: id}, function( data ) { + }); + var forCount = block.parents('ul'); + $('.order_list_li[data-id='+id+']').each(function(){ + var block = $(this); + block.remove(); + }); + countPrise(forCount); + countItems(); + + + + }); + + result_block.on('click', '.button_minus', function(){ + var block = $(this).parents('.order_list_li'); + var price_block = block.find('.price_val'); + var input = block.find('input'); + var number = input.val(); + var id = block.data('id'); + + if(number > 1){ + number--; + input.val(number); + var price = price_block.data('price'); + var new_price = number * +price; + price_block.html(new_price); + changeAjaxPrice(id, number); + synchronizationPriceData(id, number); + } + + countPrise(block); + }); + + + result_block.on('click', '.button_plus', function(){ + var block = $(this).parents('.order_list_li'); + var price_block = block.find('.price_val'); + var input = block.find('input'); + var number = input.val(); + var id = block.data('id'); + + number++; + input.val(number); + var price = price_block.data('price'); + var new_price = number * +price; + price_block.html(new_price); + + changeAjaxPrice(id, number); + synchronizationPriceData(id, number); + countPrise(block); + }); + + result_block.on('change', '.buy_one_item', function(){ + var block = $(this).parents('.order_list_li'); + var num = $(this).val(); + var price_block = block.find('.price_val'); + var price = price_block.data('price'); + var id = block.data('id'); + + var new_price = num * +price; + price_block.html(new_price); + changeAjaxPrice(id, num); + synchronizationPriceData(id, num); + countPrise(block); + }); + + function synchronizationPriceData(id, number){ + $('.order_list_li[data-id='+id+']').each(function(){ + var block = $(this); + block.find('input').val(number); + var price_block = block.find('.price_val'); + var price = price_block.data('price'); + var new_price = number * +price; + price_block.html(new_price); + }); + } + + + + one_item_block.on('click', '.button_minus', function(){ + var input = one_item_block.find('.buy_one_item'); + var number = input.val(); + if(number > 1){ + number--; + input.val(number); + } + }); + + + one_item_block.on('click', '.button_plus', function(){ + var input = one_item_block.find('.buy_one_item'); + var number = input.val(); + number++; + input.val(number); + }); + + /****************************compare and bookmarks********************************************/ + + function addItemToCompare(id){ + $.post( "/orders/compare", {id: id}, function( data ) { + }); + } + + $('#add_to_compare').click(function (event) { + event.preventDefault(); + var id = $('#one_item_block').data('id'); + addItemToCompare(id); + }); + + $('#add_to_bookmarks').click(function(event){ + event.preventDefault(); + var id = $('#one_item_block').data('id'); + $.post( "/orders/bookmarks", {id: id}, function( data ) { + }); + }); + + +}); \ No newline at end of file diff --git a/frontend/web/js/main.js b/frontend/web/js/main.js index d917081..00490a9 100755 --- a/frontend/web/js/main.js +++ b/frontend/web/js/main.js @@ -68,4 +68,5 @@ $(function(){ $(this).addClass("closed"); } }); -}) \ No newline at end of file +}) + diff --git a/frontend/widgets/Slider.php b/frontend/widgets/Slider.php new file mode 100755 index 0000000..4275f11 --- /dev/null +++ b/frontend/widgets/Slider.php @@ -0,0 +1,30 @@ +where([\common\models\Slider::tableName().'.title'=>$this->title])->joinWith("sliderImage")->one(); + + return $this->render('slider',[ + 'slider'=>$slider + ]); + + + } + +} \ No newline at end of file -- libgit2 0.21.4