Commit db8fc84f0f30d4feb88ad05ecc13e2b4bb578b47

Authored by Alexey Boroda
2 parents 29c2e44d a704487c

Merge branch 'master' of gitlab.artweb.com.ua:steska/clinica

backend/controllers/PackageController.php
@@ -164,6 +164,13 @@ @@ -164,6 +164,13 @@
164 'name' => 'sort', 164 'name' => 'sort',
165 'type' => Form::NUMBER, 165 'type' => Form::NUMBER,
166 ], 166 ],
  167 + [
  168 + 'name' => 'service_id',
  169 + 'type' => Form::RELATION,
  170 + 'relationAttribute' => 'title',
  171 + 'relationName' => 'service',
  172 + 'multiple' => false,
  173 + ]
167 ], 174 ],
168 ]; 175 ];
169 } 176 }
common/models/Package.php
@@ -79,7 +79,7 @@ class Package extends ActiveRecord @@ -79,7 +79,7 @@ class Package extends ActiveRecord
79 { 79 {
80 return [ 80 return [
81 [['sort', 'created_at', 'updated_at'], 'default', 'value' => null], 81 [['sort', 'created_at', 'updated_at'], 'default', 'value' => null],
82 - [['sort', 'created_at', 'updated_at', 'image_id'], 'integer'], 82 + [['sort', 'created_at', 'updated_at', 'image_id', 'service_id'], 'integer'],
83 [['status'], 'boolean'], 83 [['status'], 'boolean'],
84 ]; 84 ];
85 } 85 }
@@ -130,4 +130,8 @@ class Package extends ActiveRecord @@ -130,4 +130,8 @@ class Package extends ActiveRecord
130 return $this->hasOne(Image::className(), ['id' => 'image_id']); 130 return $this->hasOne(Image::className(), ['id' => 'image_id']);
131 } 131 }
132 132
  133 + public function getService(){
  134 + return $this->hasOne(Service::className(), ['id' => 'service_id']);
  135 + }
  136 +
133 } 137 }
common/models/Service.php
@@ -162,4 +162,8 @@ class Service extends ActiveRecord @@ -162,4 +162,8 @@ class Service extends ActiveRecord
162 public function getQuestions(){ 162 public function getQuestions(){
163 return $this->hasMany(Question::className(), ['service_id' => 'id']); 163 return $this->hasMany(Question::className(), ['service_id' => 'id']);
164 } 164 }
  165 +
  166 + public function getPackages(){
  167 + return $this->hasMany(Package::className(), ['service_id' => 'id']);
  168 + }
165 } 169 }
frontend/assets/AppAsset.php
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 public $baseUrl = '@web'; 13 public $baseUrl = '@web';
14 public $css = [ 14 public $css = [
15 'css/style.css', 15 'css/style.css',
16 -// '//fonts.googleapis.com/css?family=Ubuntu:400,500,700&subset=cyrillic,cyrillic-ext,latin-ext' 16 + '//fonts.googleapis.com/css?family=Ubuntu:400,500,700&subset=cyrillic,cyrillic-ext,latin-ext'
17 ]; 17 ];
18 public $js = [ 18 public $js = [
19 'js/script.js', 19 'js/script.js',
frontend/controllers/ServiceController.php
@@ -20,6 +20,9 @@ @@ -20,6 +20,9 @@
20 $model = $this->findModel($id); 20 $model = $this->findModel($id);
21 if ($model->parent_id == null){ 21 if ($model->parent_id == null){
22 $others = Service::find()->where(['parent_id' => $model->id])->with('services.language.alias')->all(); 22 $others = Service::find()->where(['parent_id' => $model->id])->with('services.language.alias')->all();
  23 + if (empty($others)){
  24 + $others = Service::find()->where(['parent_id' => null, 'status' => true])->all();
  25 + }
23 }elseif ($model->level == 1){ 26 }elseif ($model->level == 1){
24 $others = Service::find()->where(['parent_id' => $model->parent_id])->with('services.language.alias')->all(); 27 $others = Service::find()->where(['parent_id' => $model->parent_id])->with('services.language.alias')->all();
25 }else{ 28 }else{
@@ -42,6 +45,8 @@ @@ -42,6 +45,8 @@
42 $query->where(['status' => true]); 45 $query->where(['status' => true]);
43 }, 'questions' => function (ActiveQuery $query){ 46 }, 'questions' => function (ActiveQuery $query){
44 $query->where(['status' => true])->with('doctor'); 47 $query->where(['status' => true])->with('doctor');
  48 + },'packages' => function (ActiveQuery $query){
  49 + $query->with(['image', 'language'])->where(['status' => true]);
45 }])->one(); 50 }])->one();
46 if (empty($model)){ 51 if (empty($model)){
47 throw new NotFoundHttpException('Model not found'); 52 throw new NotFoundHttpException('Model not found');
frontend/views/service/view.php
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 * @var \yii\web\View $this 7 * @var \yii\web\View $this
8 * @var \artbox\core\components\SeoComponent $seo; 8 * @var \artbox\core\components\SeoComponent $seo;
9 */ 9 */
  10 + use artbox\core\helpers\ImageHelper;
10 use artbox\core\helpers\Url; 11 use artbox\core\helpers\Url;
11 use common\models\Service; 12 use common\models\Service;
12 13
@@ -77,6 +78,36 @@ @@ -77,6 +78,36 @@
77 <?php }?> 78 <?php }?>
78 </ul> 79 </ul>
79 </div> 80 </div>
  81 + <div class="style">
  82 + <?php if (!empty($model->packages)){
  83 + foreach ($model->packages as $package){?>
  84 + <div class="packages-page-col">
  85 + <a class="packages-page-link" href="<?=Url::to(['alias' => $package->language->alias])?>">
  86 + <div class="img-packages-page">
  87 + <!--555x344-->
  88 + <?=ImageHelper::set(($package->image) ? $package->image->getPath() : null)
  89 + ->resize(262, 135)
  90 + ->quality(84)
  91 + ->renderImage()?>
  92 + </div>
  93 + <div class="table-packages-wr">
  94 + <table cellspacing="0" cellpadding="0" border="0">
  95 + <tr>
  96 + <td><span class="title-packages"><?=$package->title?></span></td>
  97 + </tr>
  98 + <tr>
  99 + <td>
  100 + <span class="btn_ packages-btn"><?=\Yii::t('app','More info');?></span>
  101 + </td>
  102 + </tr>
  103 + </table>
  104 + </div>
  105 + </a>
  106 + </div>
  107 + <?php }
  108 +
  109 + }?>
  110 + </div>
80 </div> 111 </div>
81 <div class="col-xs-12 col-sm-8 col-md-8 col-lg-9"> 112 <div class="col-xs-12 col-sm-8 col-md-8 col-lg-9">
82 <div class="row"> 113 <div class="row">
frontend/views/site/comments.php
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 use yii\widgets\ActiveForm; 14 use yii\widgets\ActiveForm;
15 use yii\widgets\ListView; 15 use yii\widgets\ListView;
16 16
17 - $this->params[ 'breadcrumbs'][] = \Yii::t('app', 'Quest/Answer'); 17 + $this->params[ 'breadcrumbs'][] = \Yii::t('app', 'Отзывы');
18 18
19 $model = new Comment(['entity_id' => $service_id, 'entity' => Service::className()]); 19 $model = new Comment(['entity_id' => $service_id, 'entity' => Service::className()]);
20 20
@@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
75 <ul class="answers-category-list"> 75 <ul class="answers-category-list">
76 <li <?=($service_id == null ? 'class="active"' : '')?>> 76 <li <?=($service_id == null ? 'class="active"' : '')?>>
77 <a href="<?=Url::current(['service_id' => null])?>"> 77 <a href="<?=Url::current(['service_id' => null])?>">
78 - <span><?=\Yii::t('app','General issues');?></span></a></li> 78 + <span><?=\Yii::t('app','Общие отзывы');?></span></a></li>
79 <?php foreach ($services as $service){?> 79 <?php foreach ($services as $service){?>
80 <li <?=($service_id == $service->id ? 'class="active"' : '')?>> 80 <li <?=($service_id == $service->id ? 'class="active"' : '')?>>
81 <a href="<?=Url::current(['service_id' => $service->id])?>"><span><?=$service->title?></span></a></li> 81 <a href="<?=Url::current(['service_id' => $service->id])?>"><span><?=$service->title?></span></a></li>