diff --git a/backend/controllers/CommentController.php b/backend/controllers/CommentController.php index 19376a3..1ab8bb2 100644 --- a/backend/controllers/CommentController.php +++ b/backend/controllers/CommentController.php @@ -13,8 +13,10 @@ use artbox\core\admin\actions\View; use artbox\core\admin\widgets\Form; use common\models\Comment; + use common\models\Service; use yii\filters\AccessControl; use yii\filters\VerbFilter; + use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -103,6 +105,7 @@ public function findModel($id) { + $model = Comment::find() ->where([ 'id' => $id ]) ->one(); @@ -122,6 +125,7 @@ ] ) ->one(); + return $category->delete(); } @@ -129,7 +133,8 @@ public function actionUpdate($id) { $model = $this->findModel($id); - + $services = Service::find()->all(); + $data = ArrayHelper::map($services, 'id', 'title'); if ($model->load(\Yii::$app->request->post()) && $model->save()) { return $this->redirect('index'); } else { @@ -137,6 +142,7 @@ 'update', [ 'model' => $model, + 'services' => $data ] ); } diff --git a/backend/controllers/QuestionController.php b/backend/controllers/QuestionController.php index a02749a..795b6dd 100644 --- a/backend/controllers/QuestionController.php +++ b/backend/controllers/QuestionController.php @@ -13,8 +13,10 @@ use artbox\core\admin\actions\View; use artbox\core\admin\widgets\Form; use common\models\Question; + use common\models\Service; use yii\filters\AccessControl; use yii\filters\VerbFilter; + use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -129,7 +131,8 @@ public function actionUpdate($id) { $model = $this->findModel($id); - + $services = Service::find()->all(); + $data = ArrayHelper::map($services, 'id', 'title'); $model->scenario = Question::SCENARIO_ANSWER; if ($model->load(\Yii::$app->request->post()) && $model->save()) { return $this->redirect('index'); @@ -138,6 +141,7 @@ 'update', [ 'model' => $model, + 'services' => $data ] ); } diff --git a/backend/views/comment/_form.php b/backend/views/comment/_form.php index a25ab7f..e61235f 100644 --- a/backend/views/comment/_form.php +++ b/backend/views/comment/_form.php @@ -1,5 +1,6 @@ registerJs($js, View::POS_READY); + ?>
+ field($model, 'service_id')->dropDownList($services, [ + 'class' => 'select_service' + ])?> field($model, 'name') ->textInput([ 'maxlength' => true ]) ?> diff --git a/backend/views/comment/update.php b/backend/views/comment/update.php index 0188871..f219f1a 100644 --- a/backend/views/comment/update.php +++ b/backend/views/comment/update.php @@ -4,6 +4,7 @@ /* @var $this yii\web\View */ /* @var $model \common\models\Comment */ + /* @var $services \common\models\Service[] */ $this->title = Yii::t( 'app', @@ -39,6 +40,7 @@ '_form', [ 'model' => $model, + 'services' => $services ] ) ?> diff --git a/backend/views/question/_form.php b/backend/views/question/_form.php index d1b8686..df363e7 100644 --- a/backend/views/question/_form.php +++ b/backend/views/question/_form.php @@ -16,6 +16,8 @@ $('.switchery').each(function(idx, elem) { secondaryColor:'#e2e2e2' }); }); + +$(".select_service").select2(); JS; @@ -25,7 +27,9 @@ JS;
- + field($model, 'service_id')->dropDownList($services, [ + 'class' => 'select_service' + ])?> field($model, 'name') ->textInput([ 'maxlength' => true ]) ?> diff --git a/backend/views/question/update.php b/backend/views/question/update.php index b52dc90..eb743e9 100644 --- a/backend/views/question/update.php +++ b/backend/views/question/update.php @@ -39,6 +39,7 @@ '_form', [ 'model' => $model, + 'services' => $services, ] ) ?> diff --git a/common/models/Comment.php b/common/models/Comment.php index 3d2fa84..b8fbb99 100644 --- a/common/models/Comment.php +++ b/common/models/Comment.php @@ -1,59 +1,114 @@ null], - [['service_id', 'created_at', 'updated_at'], 'integer'], - [['name', 'email'], 'string', 'max' => 255], - ]; - } + + namespace common\models; + + use Yii; + use yii\behaviors\TimestampBehavior; /** - * {@inheritdoc} + * This is the model class for table "comment". + * + * @property int $id + * @property string $name + * @property string $email + * @property string $comment + * @property bool $status + * @property int $service_id + * @property int $created_at + * @property int $updated_at */ - public function attributeLabels() + class Comment extends \yii\db\ActiveRecord { - return [ - 'id' => Yii::t('app', 'ID'), - 'name' => Yii::t('app', 'Name'), - 'email' => Yii::t('app', 'Email'), - 'comment' => Yii::t('app', 'Comment'), - 'status' => Yii::t('app', 'Status'), - 'service_id' => Yii::t('app', 'Service ID'), - 'created_at' => Yii::t('app', 'Created At'), - 'updated_at' => Yii::t('app', 'Updated At'), - ]; + /** + * {@inheritdoc} + */ + public static function tableName() + { + return 'comment'; + } + + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + [ + 'class' => TimestampBehavior::className(), + 'updatedAtAttribute' => false, + ], + ]; + } + /** + * {@inheritdoc} + */ + public function rules() + { + return [ + [ + [ 'comment' ], + 'string', + ], + [ + [ + 'status', + 'on_main', + ], + 'boolean', + ], + [ + [ + 'service_id', + 'created_at', + 'updated_at', + ], + 'default', + 'value' => null, + ], + [ + [ + 'service_id', + 'created_at', + 'updated_at', + ], + 'integer', + ], + [ + [ + 'name', + 'email', + ], + 'string', + 'max' => 255, + ], + [ + [ + 'name', 'email' + ], + 'required' + ], + [ + ['email'], + 'email' + ] + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('app', 'ID'), + 'name' => Yii::t('app', 'Name'), + 'email' => Yii::t('app', 'Email'), + 'comment' => Yii::t('app', 'Comment'), + 'status' => Yii::t('app', 'Status'), + 'service_id' => Yii::t('app', 'Service ID'), + 'created_at' => Yii::t('app', 'Created At'), + 'updated_at' => Yii::t('app', 'Updated At'), + ]; + } } -} diff --git a/common/models/Question.php b/common/models/Question.php index 96cc287..e1c059c 100644 --- a/common/models/Question.php +++ b/common/models/Question.php @@ -29,7 +29,7 @@ { return 'question'; } - + /** * @inheritdoc */ @@ -43,6 +43,7 @@ 'name', 'email', 'question', + 'service_id' ], self::SCENARIO_ANSWER => [ 'answer', @@ -112,6 +113,9 @@ 'targetClass' => Service::className(), 'targetAttribute' => [ 'service_id' => 'id' ], ], + [ + 'email', 'email' + ] ]; } diff --git a/frontend/config/main.php b/frontend/config/main.php index dbfdf69..46edc31 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -21,7 +21,6 @@ ] ], 'modules' => [ - 'feedback' => [ 'class' => 'artbox\core\forms\Module', 'activeRecord' => "artbox\core\models\Feedback", @@ -80,6 +79,115 @@ }', ], + + 'comments' => [ + 'class' => 'artbox\core\forms\Module', + 'activeRecord' => "common\models\Comment", + 'attributes' => [ + 'name', + 'email', + 'comment', + 'service_id' + ], + 'rules' => [ + [ + [ + 'name', + 'email', + ], + 'required', + ] + ], + 'labels' => [ + 'name' => 'ФИО', + 'email' => 'Email', + 'comment' => 'Ваш отзыв', + 'service_id' => false + ], + + 'inputOptions' => [ + 'name' => [ + 'template' => '
{input}
' + ], + 'email' => [ + 'template' => '
{input}
' + ], + 'comment' => [ + 'type' => 'textarea', + 'options' => [], + 'template' => '
{input}
' + ], + ], + 'buttonTemplate' => '
{button}
Закрыть окно
', + 'buttonOptions' => [], + 'buttonContent' => 'Отправить отзыв', + 'sendEmail' => false, + 'ajax' => true, + 'formId' => 'comment-form', + 'scenario' => 'default', + 'successCallback' => 'function (data) { + document.getElementById("comment-form").reset(); + var data = $("#comment-form").data(\'yiiActiveForm\'); + $("#comment-form").find(".submit-close-c-a span").click(); + $("#comment-form").parent().parent().parent().find(".service-c-a-btns").after("

Ваш отзыв появиться после проверки модератором

") + data.validated = false; + }', + + ], + 'questions' => [ + 'class' => 'artbox\core\forms\Module', + 'activeRecord' => "common\models\Question", + 'attributes' => [ + 'name', + 'email', + 'question', + 'service_id' + ], + 'rules' => [ + [ + [ + 'name', + 'email', + ], + 'required', + ] + ], + 'labels' => [ + 'name' => 'ФИО', + 'email' => 'Email', + 'question' => 'Ваш вопрос', + 'service_id' => false + ], + + 'inputOptions' => [ + 'name' => [ + 'template' => '
{input}
' + ], + 'email' => [ + 'template' => '
{input}
' + ], + 'question' => [ + 'type' => 'textarea', + 'options' => [], + 'template' => '
{input}
' + ], + ], + 'buttonTemplate' => '
{button}
Закрыть окно
', + 'buttonOptions' => [], + 'buttonContent' => 'Отправить вопрос', + 'sendEmail' => false, + 'ajax' => true, + 'formId' => 'question-form', + 'scenario' => 'question', + 'successCallback' => 'function (data) { + document.getElementById("comment-form").reset(); + var data = $("#question-form").data(\'yiiActiveForm\'); + $("#question-form").find(".submit-close-c-a span").click(); + $("#question-form").parent().parent().parent().find(".service-c-a-btns").after("

Спасибо за Вваш вопрос. Мы обязательно на него ответим

") + data.validated = false; + }', + + ], ], 'components' => [ 'assetManager' => [ diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index fe29514..6d8fb9b 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -19,7 +19,6 @@ use common\models\Service; use common\models\Settings; use frontend\assets\AppAsset; - use artbox\core\components\imagemanager\models\ImageManager; use frontend\assets\SliderAsset; use frontend\widgets\ArtboxModalWidget; use frontend\widgets\LanguageWidget; @@ -166,7 +165,7 @@ } $items[] = [ 'label' => \Yii::t('app', 'Цены'), - 'url' => '#', + 'url' => Url::to(['site/prices']), 'options' => [ 'class' => 'active' ] diff --git a/frontend/views/service/view.php b/frontend/views/service/view.php index 1b0f64a..1581b2a 100644 --- a/frontend/views/service/view.php +++ b/frontend/views/service/view.php @@ -2,15 +2,29 @@ /** * @var \common\models\Service $model; * @var \common\models\Service[] $others; + * @var \artbox\core\forms\Module $moduleComment; + * @var \artbox\core\forms\Module $moduleQuestion; */ use artbox\core\helpers\Url; - $this->params[ 'breadcrumbs' ][] = $model->title + $moduleComment = \Yii::$app->getModule('comments'); + $this->params[ 'breadcrumbs' ][] = $model->title; + + $moduleComment->inputOptions += ['service_id' => [ + 'type' => 'hiddenInput', + 'options' => ['value' => $model->id], + ]]; + + $moduleQuestion = \Yii::$app->getModule('questions'); + $moduleQuestion->inputOptions += ['service_id' => [ + 'type' => 'hiddenInput', + 'options' => ['value' => $model->id], + ]]; ?>
-
-comments) or !empty($model->questions)){?>
-
-
- comments)){?> -
-
Отзывы
-
- comments as $comment){?> -
-
name?>
-
comment?>
-
created_at)?>
-
- -
- - -
- Оставить отзыв -
-
- - -
-
Вопрос-ответ
+
+
+
+
Отзывы
+
+ comments as $comment){?> +
+
name?>
+
comment?>
+
created_at)?>
+
+ +
+ + +
+ Оставить отзыв +
+ +
+ +
+
Вопрос-ответ
+
+
+
Мария
+
У меня диагноз склерокистоз яичников, врачи назначили пить полгода гормональные а потом сказали возможно придется делать операцию, объясните пожалуйста зачем назначены гормональные если потом нужна операция и что это за операция и мсогу ли я иметь детей после такого лечения и операции?
+
+
врач-гинеколог Алексей нестеренко
+
+ Вероятно, врачи пытались решить Вашу проблему консервативными методами, так как любая операция, это крайняя мера, когда другие методы лечения уже не эффективны. Относительно объема операции, заочно судить об этом весьма затруднительно (поймете это правильно), так как у каждого человека любое заболевание протекает сугубо индивидуально. Возможно потребуется удаление только наиболее измененной части яичников, с тем чтобы нормально могла функционировать оставшаяся часть. Если сохранится даже часть яичников, то наступление беременности вполне возможно. +
+
+ + +
+ + +
+ Задать вопрос +
+ + +
+
- \ No newline at end of file diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js index c961f0a..6e10941 100644 --- a/frontend/web/js/script.js +++ b/frontend/web/js/script.js @@ -409,8 +409,8 @@ $(document).ready(function() { } - $('nav').addClass('hide_') - $('body').addClass('start-preloader') + $('nav').addClass('hide_'); + $('body').addClass('start-preloader'); window.onload = function () { // @@ -421,15 +421,17 @@ $(document).ready(function() { //альтернативный с задержкой выключения setTimeout(function () { $('body').addClass('end-preloader') - },2700) + },2700); setTimeout(function () { - $('nav').addClass('start') - $('body').addClass('disabled-preloader') + console.log('start'); + $('nav').addClass('start'); + $('body').addClass('disabled-preloader'); + },2700 + 2000) } -}) \ No newline at end of file +}); \ No newline at end of file -- libgit2 0.21.4