diff --git a/backend/controllers/FeedbackController.php b/backend/controllers/FeedbackController.php index bc682da..c10ceca 100644 --- a/backend/controllers/FeedbackController.php +++ b/backend/controllers/FeedbackController.php @@ -44,12 +44,9 @@ 'index' => [ 'class' => Index::className(), 'columns' => [ - 'name' => [ + 'phone' => [ 'type' => Index::ACTION_COL, ], - 'email' => [ - 'type' => Index::STRING_COL - ], 'status' => [ 'type' => Index::STATUS_COL, ], @@ -74,22 +71,10 @@ ], 'fields' => [ [ - 'name' => 'name', - 'type' => Form::STRING, - ], - [ - 'name' => 'email', - 'type' => Form::STRING, - ], - [ 'name' => 'phone', 'type' => Form::STRING, ], [ - 'name' => 'message', - 'type' => Form::TEXTAREA, - ], - [ 'name' => 'ip', 'type' => Form::STRING, ], diff --git a/backend/views/feedback/_form.php b/backend/views/feedback/_form.php index 30b9a46..c0c9de9 100644 --- a/backend/views/feedback/_form.php +++ b/backend/views/feedback/_form.php @@ -11,12 +11,19 @@
В течении 30 минут
"; + break; + case 2: + echo "C 9.00 до 12.00
"; + break; + case 3: + echo "C 12.00 до 18.00
"; + break; + } + ?> = $form->field($model, 'phone') ->textInput([ 'maxlength' => true ]) ?> diff --git a/common/models/Feedback.php b/common/models/Feedback.php index ade069f..07914ba 100644 --- a/common/models/Feedback.php +++ b/common/models/Feedback.php @@ -26,9 +26,16 @@ const SCENARIO_FEEDBACK = 'feedback'; const SCENARIO_CALLBACK = 'callback'; + const DURING_30_MIN = '1'; + + const FROM_9_12 = '2'; + + const FROM_12_18 = '3' ; public $returnUrl; + public $agree; + /** * @inheritdoc */ @@ -53,9 +60,9 @@ 'returnUrl', ], self::SCENARIO_CALLBACK => [ - 'name', 'phone', - 'message', + 'time', + 'agree', 'returnUrl', ], ] @@ -120,7 +127,6 @@ [ [ 'phone', - 'name', ], 'required', 'on' => self::SCENARIO_CALLBACK, @@ -151,7 +157,7 @@ ], [ [ - 'status', + 'status' ], 'boolean', ], @@ -159,6 +165,17 @@ 'returnUrl', 'safe', ], + [ + [ 'time' ], 'integer' + ], + [ + [ + 'agree', + ], + 'in', + 'range' => [ 1 ], + 'allowArray' => false, + ], ]; } diff --git a/common/models/Visit.php b/common/models/Visit.php index 1f4ec44..0e6a404 100644 --- a/common/models/Visit.php +++ b/common/models/Visit.php @@ -17,6 +17,7 @@ */ class Visit extends \yii\db\ActiveRecord { + /** * @inheritdoc */ diff --git a/console/migrations/m180613_101610_alter_package_table.php b/console/migrations/m180613_101610_alter_package_table.php new file mode 100644 index 0000000..755caa6 --- /dev/null +++ b/console/migrations/m180613_101610_alter_package_table.php @@ -0,0 +1,49 @@ +addColumn('package', 'service_id', $this->integer()); + + $this->addForeignKey('package_service_fk', + 'package', + 'service_id', + 'service', + 'id', + 'SET NULL', + 'CASCADE'); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropForeignKey('package_service_fk', 'package'); + $this->dropColumn('service_id', 'package'); + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m180613_101610_alter_package_table cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/console/migrations/m180712_081623_alter_table_visit.php b/console/migrations/m180712_081623_alter_table_visit.php new file mode 100644 index 0000000..5c5c511 --- /dev/null +++ b/console/migrations/m180712_081623_alter_table_visit.php @@ -0,0 +1,40 @@ +addColumn('feedback', 'time', $this->integer()); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn('feedback', 'time'); + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m180712_081623_alter_table_visit cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 650c98d..c7f92f7 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -3,7 +3,7 @@ namespace frontend\controllers; use artbox\core\models\Alias; - use artbox\core\models\Feedback; + use common\models\Feedback; use artbox\core\models\Language; use common\models\Comment; use common\models\Package; @@ -176,6 +176,17 @@ return $this->renderFile($meta[ 'uri' ]); } + public function actionCallback(){ + \Yii::$app->response->format = Response::FORMAT_JSON; + $model = new Feedback(); + $model->scenario = Feedback::SCENARIO_CALLBACK; + if ($model->load(\Yii::$app->request->post()) && $model->save()){ + return ['success' => true]; + }else{ + return ['success' => false, 'errors' => $model->errors]; + } + } + public function actionFeedback() { Yii::$app->response->format = Response::FORMAT_JSON; diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index c7fba5e..981ba3b 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -1,5 +1,5 @@ user->identity; @@ -54,207 +54,232 @@ AppAsset::register($this); [ 'language.alias', 'services' => function (ActiveQuery $query) { - $query->where(['status' => true])->with( - [ - 'language.alias', - 'services' => function (ActiveQuery $query) { - $query->where(['status' => true])->with(['language.alias']); - }, - ] - ); + $query->where([ 'status' => true ]) + ->with( + [ + 'language.alias', + 'services' => function (ActiveQuery $query) { + $query->where([ 'status' => true ]) + ->with([ 'language.alias' ]); + }, + ] + ); }, ] - )->orderBy('sort') + ) + ->orderBy('sort') ->all(); - - -# для автоматической генерации SEO параметров (title/description) в ситуациях, когда этих параметров нету -# мне нужно будет автоматически их подгенеривать, поэтому вместо $seo->title, которые является readOnly я использую эту переменную -$seoTitleName = $seo->title; -if ($seo->title == '' - && \Yii::$app->controller->id == 'site' - && \Yii::$app->controller->action->id == 'comments' -) { - $currentServiceId = (!empty(\Yii::$app->request->get('service_id'))) ? \Yii::$app->request->get('service_id') : 0; - $serviceModel = new Service(['id' => $currentServiceId]); - if ($currentServiceId !== 0) { - $serviceName = $serviceModel->language->title; - $seoTitleName = $this->params['breadcrumbs'][0] . ' - ' . $serviceName . ' - ' . \Yii::t('app', 'ABC short reverse'); - } else $seoTitleName = $this->params['breadcrumbs'][0] . ' - ' . \Yii::t('app', 'General callbacks') . ' - ' . \Yii::t('app', 'ABC short reverse'); - -} - - -//----------------------------------------------------------------------------------------------------------------------- -// Блок с микроразметкой для FB - + + # для автоматической генерации SEO параметров (title/description) в ситуациях, когда этих параметров нету + # мне нужно будет автоматически их подгенеривать, поэтому вместо $seo->title, которые является readOnly я использую эту переменную + $seoTitleName = $seo->title; + if ($seo->title == '' && \Yii::$app->controller->id == 'site' && \Yii::$app->controller->action->id == 'comments') { + $currentServiceId = ( !empty(\Yii::$app->request->get('service_id')) ) ? \Yii::$app->request->get( + 'service_id' + ) : 0; + $serviceModel = new Service([ 'id' => $currentServiceId ]); + if ($currentServiceId !== 0) { + $serviceName = $serviceModel->language->title; + $seoTitleName = $this->params[ 'breadcrumbs' ][ 0 ] . ' - ' . $serviceName . ' - ' . \Yii::t( + 'app', + 'ABC short reverse' + ); + } else { + $seoTitleName = $this->params[ 'breadcrumbs' ][ 0 ] . ' - ' . \Yii::t( + 'app', + 'General callbacks' + ) . ' - ' . \Yii::t('app', 'ABC short reverse'); + } + + } + + //----------------------------------------------------------------------------------------------------------------------- + // Блок с микроразметкой для FB + # $property нужно для property="og:type" FB - switch (\Yii::$app->controller->id) - { + switch (\Yii::$app->controller->id) { case "site": - $property='website'; + $property = 'website'; break; case "blog": - $property='article'; + $property = 'article'; break; case 'service': - $property='product'; + $property = 'product'; break; default: - $property='website'; + $property = 'website'; break; } - -$this->registerMetaTag( - [ - 'property'=>'og:description', - 'content' => $seo->desc, - ] -); -$this->registerMetaTag( - [ - 'property'=>"og:type", - 'content' => $property, - ] -); -$this->registerMetaTag( - [ - 'property'=>"og:url", - 'content' => Url::current(), - ] -); -$this->registerMetaTag( - [ - 'property'=>"og:title", - 'content' =>$seo->title, - ] -); -$this->registerMetaTag( - [ - 'name' => 'description', - 'content' => (\Yii::$app->controller->id == 'site' && \Yii::$app->controller->action->id == 'comments' && $seo->desc == null) ? $seoTitleName : $seo->desc, - ] -); - -//---------------------------------------------------------------------------------------------------------------------- - - + + $this->registerMetaTag( + [ + 'property' => 'og:description', + 'content' => $seo->desc, + ] + ); + $this->registerMetaTag( + [ + 'property' => "og:type", + 'content' => $property, + ] + ); + $this->registerMetaTag( + [ + 'property' => "og:url", + 'content' => Url::current(), + ] + ); + $this->registerMetaTag( + [ + 'property' => "og:title", + 'content' => $seo->title, + ] + ); + $this->registerMetaTag( + [ + 'name' => 'description', + 'content' => ( \Yii::$app->controller->id == 'site' && \Yii::$app->controller->action->id == 'comments' && $seo->desc == null ) ? $seoTitleName : $seo->desc, + ] + ); + + //---------------------------------------------------------------------------------------------------------------------- + $this->registerMetaTag( [ 'name' => 'robots', -// 'content' => $seo->robots, + // 'content' => $seo->robots, 'content' => 'noindex,nofollow', ] ); $module = \Yii::$app->getModule('feedback'); - $aliases = Alias::find()->where(['route' => '{"0":"site/questions"}'])->indexBy('route')->andWhere(['language_id' => Language::getCurrent()->id])->asArray()->all(); -$commentUrl = Alias::find()->where(['route' => '{"0":"site/comments","service_id":0}'])->indexBy('route')->andWhere(['language_id' => Language::getCurrent()->id])->asArray()->all(); - - - + $aliases = Alias::find() + ->where([ 'route' => '{"0":"site/questions"}' ]) + ->indexBy('route') + ->andWhere([ 'language_id' => Language::getCurrent()->id ]) + ->asArray() + ->all(); + $commentUrl = Alias::find() + ->where([ 'route' => '{"0":"site/comments","service_id":0}' ]) + ->indexBy('route') + ->andWhere([ 'language_id' => Language::getCurrent()->id ]) + ->asArray() + ->all(); ?> beginPage() ?> - - - - - - - - - - - - - - - = Html::csrfMetaTags() ?> - - - - + + + + + + + + + + + + + + + = Html::csrfMetaTags() ?> + +