Commit d15518de77130b35cf47e2f8c45093229a0df3c6
Merge remote-tracking branch 'origin/clinica_alias'
Showing
7 changed files
with
132 additions
and
94 deletions
Show diff stats
clinica deleted
| 1 | -Subproject commit 8b1b0efde228ff71e43eba90086e0c15392645cc |
common/models/Question.php
common/models/Service.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace common\models; | 3 | namespace common\models; |
| 4 | 4 | ||
| 5 | +use artbox\core\models\Alias; | ||
| 5 | use artbox\core\models\Image; | 6 | use artbox\core\models\Image; |
| 6 | use artbox\core\models\traits\AliasableTrait; | 7 | use artbox\core\models\traits\AliasableTrait; |
| 7 | use backend\behaviors\LevelBehavior; | 8 | use backend\behaviors\LevelBehavior; |
common/models/ServiceLang.php
| @@ -5,7 +5,8 @@ | @@ -5,7 +5,8 @@ | ||
| 5 | use artbox\core\models\Alias; | 5 | use artbox\core\models\Alias; |
| 6 | use artbox\core\models\Language; | 6 | use artbox\core\models\Language; |
| 7 | use Yii; | 7 | use Yii; |
| 8 | - | 8 | + use yii\helpers\Json; |
| 9 | + | ||
| 9 | /** | 10 | /** |
| 10 | * This is the model class for table "service_lang". | 11 | * This is the model class for table "service_lang". |
| 11 | * | 12 | * |
frontend/controllers/SiteController.php
| 1 | <?php | 1 | <?php |
| 2 | namespace frontend\controllers; | 2 | namespace frontend\controllers; |
| 3 | 3 | ||
| 4 | + use artbox\core\models\Alias; | ||
| 4 | use artbox\core\models\Feedback; | 5 | use artbox\core\models\Feedback; |
| 6 | + use artbox\core\models\Language; | ||
| 5 | use common\models\Comment; | 7 | use common\models\Comment; |
| 6 | use common\models\Package; | 8 | use common\models\Package; |
| 7 | use common\models\Question; | 9 | use common\models\Question; |
| @@ -13,10 +15,13 @@ | @@ -13,10 +15,13 @@ | ||
| 13 | use yii\db\ActiveQuery; | 15 | use yii\db\ActiveQuery; |
| 14 | use yii\db\Expression; | 16 | use yii\db\Expression; |
| 15 | use yii\filters\VerbFilter; | 17 | use yii\filters\VerbFilter; |
| 18 | + use yii\helpers\ArrayHelper; | ||
| 19 | + use yii\helpers\Json; | ||
| 16 | use yii\swiftmailer\Mailer; | 20 | use yii\swiftmailer\Mailer; |
| 17 | use yii\web\BadRequestHttpException; | 21 | use yii\web\BadRequestHttpException; |
| 18 | use yii\web\Controller; | 22 | use yii\web\Controller; |
| 19 | use yii\web\Response; | 23 | use yii\web\Response; |
| 24 | + use yii\helpers\VarDumper as d; | ||
| 20 | 25 | ||
| 21 | /** | 26 | /** |
| 22 | * Site controller | 27 | * Site controller |
| @@ -224,6 +229,7 @@ | @@ -224,6 +229,7 @@ | ||
| 224 | } | 229 | } |
| 225 | 230 | ||
| 226 | public function actionQuestions($service_id = null){ | 231 | public function actionQuestions($service_id = null){ |
| 232 | + Language::getCurrent(); | ||
| 227 | 233 | ||
| 228 | if (\Yii::$app->request->isAjax){ | 234 | if (\Yii::$app->request->isAjax){ |
| 229 | Yii::$app->response->format = Response::FORMAT_JSON; | 235 | Yii::$app->response->format = Response::FORMAT_JSON; |
| @@ -248,11 +254,16 @@ | @@ -248,11 +254,16 @@ | ||
| 248 | ], | 254 | ], |
| 249 | ]); | 255 | ]); |
| 250 | $services = Service::find()->where(['status' => true])->andWhere(['parent_id' => null])->all(); | 256 | $services = Service::find()->where(['status' => true])->andWhere(['parent_id' => null])->all(); |
| 251 | - | 257 | + $route = []; |
| 258 | + foreach ($services as $service){ | ||
| 259 | + $route[] = Json::encode(['site/questions', 'service_id' => $service->id]); | ||
| 260 | + } | ||
| 261 | + $alias = Alias::find()->where(['route' => $route])->andWhere(['language_id' => Language::getCurrent()->id])->indexBy('route')->asArray()->all(); | ||
| 252 | return $this->render('questions', [ | 262 | return $this->render('questions', [ |
| 253 | 'dataProvider' => $dataProvider, | 263 | 'dataProvider' => $dataProvider, |
| 254 | 'services' => $services, | 264 | 'services' => $services, |
| 255 | - 'service_id' => $service_id | 265 | + 'service_id' => $service_id, |
| 266 | + 'alias' => $alias | ||
| 256 | ]); | 267 | ]); |
| 257 | } | 268 | } |
| 258 | 269 |
frontend/views/site/questions.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @var \yii\data\ActiveDataProvider $dataProvider | 3 | * @var \yii\data\ActiveDataProvider $dataProvider |
| 4 | - * @var \common\models\Service[] $services | ||
| 5 | - * @var \yii\web\View $this | ||
| 6 | - * @var int $service_id | 4 | + * @var \common\models\Service[] $services |
| 5 | + * @var \yii\web\View $this | ||
| 6 | + * @var int $service_id | ||
| 7 | + * @var array $alias; | ||
| 7 | */ | 8 | */ |
| 8 | 9 | ||
| 9 | use artbox\core\helpers\Url; | 10 | use artbox\core\helpers\Url; |
| 10 | use common\models\Question; | 11 | use common\models\Question; |
| 11 | use yii\helpers\ArrayHelper; | 12 | use yii\helpers\ArrayHelper; |
| 12 | use yii\helpers\Html; | 13 | use yii\helpers\Html; |
| 14 | + use yii\helpers\Json; | ||
| 13 | use yii\widgets\ActiveForm; | 15 | use yii\widgets\ActiveForm; |
| 14 | use yii\widgets\ListView; | 16 | use yii\widgets\ListView; |
| 17 | + use yii\helpers\VarDumper as d; | ||
| 18 | + use artbox\core\models\Alias; | ||
| 15 | 19 | ||
| 16 | - $this->params[ 'breadcrumbs'][] = \Yii::t('app', 'Quest/Answer'); | 20 | + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Quest/Answer'); |
| 17 | 21 | ||
| 18 | - $model = new Question(['service_id' => $service_id]); | 22 | + $model = new Question([ 'service_id' => $service_id ]); |
| 19 | $model->scenario = Question::SCENARIO_QUESTION; | 23 | $model->scenario = Question::SCENARIO_QUESTION; |
| 20 | 24 | ||
| 21 | - $data = ['' =>\Yii::t('app','General issues')] + ArrayHelper::map($services, 'id', 'title'); | ||
| 22 | - ?> | 25 | + $data = [ '' => \Yii::t('app', 'General issues') ] + ArrayHelper::map($services, 'id', 'title'); |
| 26 | +?> | ||
| 23 | 27 | ||
| 24 | 28 | ||
| 25 | <section class="section-service-page section-answer-page"> | 29 | <section class="section-service-page section-answer-page"> |
| 26 | - <div class="container"> | ||
| 27 | - <div class="row"> | ||
| 28 | - <div class="col-xs-12 col-sm-12"> | ||
| 29 | - <h1 class="title-pages"><?=\Yii::t('app','Quest/Answer')?></h1> | ||
| 30 | - </div> | 30 | + <div class="container"> |
| 31 | + <div class="row"> | ||
| 32 | + <div class="col-xs-12 col-sm-12"> | ||
| 33 | + <h1 class="title-pages"><?= \Yii::t('app', 'Quest/Answer') ?></h1> | ||
| 34 | + </div> | ||
| 35 | + </div> | ||
| 36 | + <div class="row"> | ||
| 37 | + <div class="col-xs-12 col-sm-12"> | ||
| 38 | + <div class="style add-answer-forms"> | ||
| 39 | + <span class="btn_"><?= \Yii::t('app', 'Asc question'); ?></span> | ||
| 31 | </div> | 40 | </div> |
| 32 | - <div class="row"> | ||
| 33 | - <div class="col-xs-12 col-sm-12"> | ||
| 34 | - <div class="style add-answer-forms"> | ||
| 35 | - <span class="btn_"><?=\Yii::t('app','Asc question');?></span> | ||
| 36 | - </div> | ||
| 37 | - <div class="style hidden-answer-comment-form hidden"> | ||
| 38 | - <div class="hidden-answer-comment-form-title"><?=\Yii::t('app','Asc question');?></div> | ||
| 39 | - <?php $form = ActiveForm::begin(['id' => 'total_question_form'])?> | ||
| 40 | - <div class="col-xs-12 col-sm-6"> | ||
| 41 | - <div class="input-wr"> | ||
| 42 | - <?=$form->field($model, 'service_id')->dropDownList($data) | ||
| 43 | - ->label(\Yii::t('app','Choosing department'))?> | ||
| 44 | - </div> | ||
| 45 | - | ||
| 46 | - <div class="input-wr required"> | ||
| 47 | - <?=$form->field($model, 'name') | ||
| 48 | - ->label(\Yii::t('app','FIO'))?> | ||
| 49 | - </div> | ||
| 50 | - <div class="input-wr required"> | ||
| 51 | - <?=$form->field($model, 'email') | ||
| 52 | - ->label(\Yii::t('app','Email'))?> | ||
| 53 | - </div> | ||
| 54 | - </div> | ||
| 55 | - <div class="col-xs-12 col-sm-6"> | ||
| 56 | - <div class="input-wr"> | ||
| 57 | - <?=$form->field($model, 'question')->textarea(['cols' => 30, 'rows' => 10]) | ||
| 58 | - ->label(\Yii::t('app','Yours question'))?> | ||
| 59 | -<!-- <label class="control-label" for="feedback-name">Ваш вопрос</label>--> | ||
| 60 | -<!-- <textarea name="" id="" cols="30" rows="10"></textarea>--> | ||
| 61 | - </div> | ||
| 62 | - </div> | ||
| 63 | - <div class="col-xs-12 col-sm-12"> | ||
| 64 | - <div class="button-wr submit-close-wr-c-a"> | ||
| 65 | - <?=Html::submitButton(\Yii::t('app','Send question'))?> | ||
| 66 | -<!-- <button type="submit">Отправить вопрос</button>--> | ||
| 67 | - <div class="submit-close-c-a submit-close-c-a-page"> | ||
| 68 | - <span><?=\Yii::t('app','Minimize a window');?></span></div> | ||
| 69 | - </div> | ||
| 70 | - </div> | ||
| 71 | - <?php $form::end();?> | ||
| 72 | - </div> | 41 | + <div class="style hidden-answer-comment-form hidden"> |
| 42 | + <div class="hidden-answer-comment-form-title"><?= \Yii::t('app', 'Asc question'); ?></div> | ||
| 43 | + <?php $form = ActiveForm::begin([ 'id' => 'total_question_form' ]) ?> | ||
| 44 | + <div class="col-xs-12 col-sm-6"> | ||
| 45 | + <div class="input-wr"> | ||
| 46 | + <?= $form->field($model, 'service_id') | ||
| 47 | + ->dropDownList($data) | ||
| 48 | + ->label(\Yii::t('app', 'Choosing department')) ?> | ||
| 73 | </div> | 49 | </div> |
| 74 | - <div class="col-xs-12 col-sm-12"> | ||
| 75 | - <ul class="answers-category-list"> | ||
| 76 | - <li <?=($service_id == null ? 'class="active"' : '')?>> | ||
| 77 | - <a href="<?=Url::current(['service_id' => null])?>"> | ||
| 78 | - <span><?=\Yii::t('app','General issues');?></span></a></li> | ||
| 79 | - <?php foreach ($services as $service){?> | ||
| 80 | - <li <?=($service_id == $service->id ? 'class="active"' : '')?>> | ||
| 81 | - <a href="<?=Url::current(['service_id' => $service->id])?>"><span><?=$service->title?></span></a></li> | ||
| 82 | - <?php } ?> | ||
| 83 | - </ul> | 50 | + |
| 51 | + <div class="input-wr required"> | ||
| 52 | + <?= $form->field($model, 'name') | ||
| 53 | + ->label(\Yii::t('app', 'FIO')) ?> | ||
| 84 | </div> | 54 | </div> |
| 85 | - <div class="col-xs-12 col-sm-12"> | ||
| 86 | - <div class="service-comments-wr style"> | ||
| 87 | - <?php echo ListView::widget( | ||
| 88 | - [ | ||
| 89 | - 'itemOptions' => [ | ||
| 90 | - ], | ||
| 91 | - 'layout' => '{items}', | ||
| 92 | - 'dataProvider' => $dataProvider, | ||
| 93 | - 'itemView' => '_question' | ||
| 94 | - ] | ||
| 95 | - );?> | ||
| 96 | - | ||
| 97 | - | ||
| 98 | - <div class="style navi-c-a"> | ||
| 99 | - <?php echo \frontend\widgets\FrontendPager::widget( | ||
| 100 | - [ | ||
| 101 | - 'pagination' => $dataProvider->pagination, | ||
| 102 | - 'prevPageLabel' => 'previous', | ||
| 103 | - 'nextPageLabel' => 'next', | ||
| 104 | - 'maxButtonCount' => 3, | ||
| 105 | - 'lastPageLabel' => 'last_number', | ||
| 106 | - ] | ||
| 107 | - );?> | ||
| 108 | - </div> | ||
| 109 | - | ||
| 110 | - | ||
| 111 | - </div> | 55 | + <div class="input-wr required"> |
| 56 | + <?= $form->field($model, 'email') | ||
| 57 | + ->label(\Yii::t('app', 'Email')) ?> | ||
| 58 | + </div> | ||
| 59 | + </div> | ||
| 60 | + <div class="col-xs-12 col-sm-6"> | ||
| 61 | + <div class="input-wr"> | ||
| 62 | + <?= $form->field($model, 'question') | ||
| 63 | + ->textarea( | ||
| 64 | + [ | ||
| 65 | + 'cols' => 30, | ||
| 66 | + 'rows' => 10, | ||
| 67 | + ] | ||
| 68 | + ) | ||
| 69 | + ->label(\Yii::t('app', 'Yours question')) ?> | ||
| 70 | + <!-- <label class="control-label" for="feedback-name">Ваш вопрос</label>--> | ||
| 71 | + <!-- <textarea name="" id="" cols="30" rows="10"></textarea>--> | ||
| 112 | </div> | 72 | </div> |
| 73 | + </div> | ||
| 74 | + <div class="col-xs-12 col-sm-12"> | ||
| 75 | + <div class="button-wr submit-close-wr-c-a"> | ||
| 76 | + <?= Html::submitButton(\Yii::t('app', 'Send question')) ?> | ||
| 77 | + <!-- <button type="submit">Отправить вопрос</button>--> | ||
| 78 | + <div class="submit-close-c-a submit-close-c-a-page"> | ||
| 79 | + <span><?= \Yii::t('app', 'Minimize a window'); ?></span></div> | ||
| 80 | + </div> | ||
| 81 | + </div> | ||
| 82 | + <?php $form::end(); ?> | ||
| 83 | + </div> | ||
| 84 | + </div> | ||
| 85 | + <div class="col-xs-12 col-sm-12"> | ||
| 86 | + <ul class="answers-category-list"> | ||
| 87 | + <li <?= ( $service_id == null ? 'class="active"' : '' ) ?>> | ||
| 88 | + <a href="<?= Url::current([ 'service_id' => null ]) ?>"> | ||
| 89 | + <span><?= \Yii::t('app', 'General issues'); ?></span></a></li> | ||
| 90 | + <?php foreach ($services as $service) { | ||
| 91 | + $route = Json::encode(['site/questions', 'service_id' => $service->id]); | ||
| 92 | + ?> | ||
| 93 | + <li <?= ( $service_id == $service->id ? 'class="active"' : '' ) ?>> | ||
| 94 | + <a href="<?= ( array_key_exists($route, $alias) ) ? Url::to( | ||
| 95 | + [ 'alias' => $alias[$route] ] | ||
| 96 | + ) : Url::current([ 'service_id' => $service->id ]) ?>"><span><?= $service->title ?></span></a></li> | ||
| 97 | + <?php } ?> | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + </ul> | ||
| 101 | + </div> | ||
| 102 | + <div class="col-xs-12 col-sm-12"> | ||
| 103 | + <div class="service-comments-wr style"> | ||
| 104 | + <?php echo ListView::widget( | ||
| 105 | + [ | ||
| 106 | + 'itemOptions' => [], | ||
| 107 | + 'layout' => '{items}', | ||
| 108 | + 'dataProvider' => $dataProvider, | ||
| 109 | + 'itemView' => '_question', | ||
| 110 | + ] | ||
| 111 | + ); ?> | ||
| 112 | + | ||
| 113 | + | ||
| 114 | + <div class="style navi-c-a"> | ||
| 115 | + <?php echo \frontend\widgets\FrontendPager::widget( | ||
| 116 | + [ | ||
| 117 | + 'pagination' => $dataProvider->pagination, | ||
| 118 | + 'prevPageLabel' => 'previous', | ||
| 119 | + 'nextPageLabel' => 'next', | ||
| 120 | + 'maxButtonCount' => 3, | ||
| 121 | + 'lastPageLabel' => 'last_number', | ||
| 122 | + ] | ||
| 123 | + ); ?> | ||
| 124 | + </div> | ||
| 125 | + | ||
| 126 | + | ||
| 113 | </div> | 127 | </div> |
| 128 | + </div> | ||
| 114 | </div> | 129 | </div> |
| 130 | + </div> | ||
| 115 | </section> | 131 | </section> |