view.php 10.4 KB
<?php
    /**
     * @var \common\models\Service $model;
     * @var \common\models\Service[] $others;
     * @var \artbox\core\forms\Module $moduleComment;
     * @var \artbox\core\forms\Module $moduleQuestion;
     * @var \yii\web\View $this
     * @var \artbox\core\components\SeoComponent $seo;
     */
    use artbox\core\helpers\ImageHelper;
    use artbox\core\helpers\Url;
    use artbox\core\models\Alias;
    use common\models\Language;
    use common\models\Service;
    use yii\web\View;
    
    $seo = \Yii::$app->get('seo');
#  die(var_dump($seo));
    $this->params['entity'] = Service::className();
    $this->params['entity_id'] = $model->id;
    
    $moduleComment = \Yii::$app->getModule('comments');
    
    
    $moduleComment->inputOptions = array_merge($moduleComment->inputOptions, ['entity_id' => [
        'type'    => 'hiddenInput',
        'options' => ['value' => $model->id],
    ],
                                                                                'entity' => [
                                                                                    'type'    => 'hiddenInput',
                                                                                    'options' => ['value' => Service::className()],
                                                                                ]]);
    
    $moduleQuestion = \Yii::$app->getModule('questions');
    $moduleQuestion->inputOptions += ['service_id' => [
        'type'    => 'hiddenInput',
        'options' => ['value' => $model->id],
    ]];
    if ($model->parent !== null){
        if ($model->parent->parent !== null){
            $this->params['breadcrumbs'][] = [
                'label' => $model->parent->parent->title,
                'url' => Url::to(['alias' => $model->parent->parent->language->alias]),
            ];
        }
        $this->params['breadcrumbs'][] = [
            'label' => $model->parent->title,
            'url' => Url::to(['alias' => $model->parent->language->alias]),
        ];
    }



    $aliases = Alias::find()->where(['route' => '{"0":"site/questions"}'])->indexBy('route')->andWhere(['language_id' => Language::getCurrent()->id])->asArray()->all();
    
    
    $js = <<<JS
    $(document).on('beforeSubmit', '#comment-form', function() {
             dataLayer.push({'event': 'formsend_review'});
             console.log('push');
             return true;
    });

$(document).on('beforeSubmit', '#question-form', function() {
             dataLayer.push({'event': 'formsend_question'});
             console.log('push');
             return true;
    });


    $(document).on('beforeSubmit', '#visit-form', function() {
        var service_id = {$model->id};
        var parent_id = {$model->parent_id};
        if (service_id == 4 || parent_id == 4){
            window.dataLayer.push({'event': 'formsend_dermatologiya'});
        }
        if (service_id == 16 || parent_id == 16){
           dataLayer.push({'event': 'formsend_vedenie-beremennosti'});
        }
        if (service_id == 22 || parent_id == 22){
             dataLayer.push({'event': 'formsend_lechenie-besplodiya'});
        }
        if (service_id == 21 || parent_id == 21){
             dataLayer.push({'event': 'formsend_labioplastika'});
        }
        if (service_id == 19 || parent_id == 19){
            dataLayer.push({'event': 'formsend_zabolevaniya-sheyki-matki'});
        }
        if (service_id == 20 || parent_id == 20){
            dataLayer.push({'event': 'formsend_polovye-infekcii'});
        }
             console.log('push');
             return true;
    });
JS;

    $this->registerJs($js, View::POS_LOAD);
    

    $this->params[ 'breadcrumbs' ][] = (!empty($seo->h1)) ? $seo->h1 :$model->title;
    ?>
    <?=$microdata;?>
    <section class="section-service-page">
    <div class="container">
        <div class="row">
          <div class="hidden-xs col-xs-12 col-sm-4 col-md-4 col-lg-3">
                <div class="style service-list-wr">
                    <ul>
                        <?php foreach ($others as $service){?>
                        <li class="<?=(($model->id == $service->id and $model->level != 2) ? 'active' : '')?>
                        <?=(($model->parent_id == $service->id and $model->level == 2) ? 'active2' : '')?>
                        <?=(!empty($service->services) ? 'has-list' : '')?>">
                            <a

                            <?php if(!(($model->id == $service->id and $model->level != 2))):?>
                                    href="<?=Url::to(['alias' => $service->language->alias])?>"
                            <?php endif;?>


                            ><?=$service->title?></a>
                         <?php
                           if (($model->id == $service->id or $model->parent_id == $service->id) and !empty($service->services)) {?>
                            <ul>
                              <?php foreach ($service->services as $item){?>

                                  <?php if($model->id == $item->id) : ?>
                                      <li class="active"><a ><?=$item->title?></a></li>
                                  <?php else: ?>
                                      <li class=""><a href="<?=Url::to(['alias' => $item->language->alias])?>"><?=$item->title?></a></li>
                                  <?php endif;?>

                              <?php }?>
                            </ul>
                          <?php } ?>
                        </li>
                        <?php }?>
                    </ul>
                </div>
            <div class="style">
                <?php if (!empty($model->packages)){
                  foreach ($model->packages as $package){?>
                    <div class="packages-page-col">
                      <a class="packages-page-link" href="<?=Url::to(['alias' => $package->language->alias])?>">
                        <div class="img-packages-page">
                          <!--555x344-->
	                        <?=
	                        ImageHelper::set(($package->image) ? $package->image->getPath() : null)
                                          ->cropResize(262, 185)
                                          ->quality(84)
		                        ->renderImage(); ?>
                        </div>
                        <div class="table-packages-wr">
                          <table cellspacing="0" cellpadding="0" border="0">
                            <tr>
                              <td><span class="title-packages"><?=$package->title?></span></td>
                            </tr>
                            <tr>
                              <td>
                                <span class="btn_ packages-btn"><?=\Yii::t('app','More info');?></span>
                              </td>
                            </tr>
                          </table>
                        </div>
                      </a>
                    </div>
                <?php }
                
                }?>
            </div>
            </div>
          <div class="col-xs-12 col-sm-8 col-md-8 col-lg-9">
                <div class="row">
                    <div class="col-xs-12">
                        <h1 class="title-pages"><?=(!empty($seo->h1)) ? $seo->h1 :$model->title?></h1>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 service-text-table-wrapp editor-text">

                        <?=$model->body?>
                        </div>
                </div>
            </div>
        </div>
    </div>
</section>
<section class="section-comments-answers fix-map-margin">
  <div class="container">
    <div class="row">
      <div class="col-xs-12 col-sm-4 col-md-4 fix-form-c-a-wr">
        <div class="title-c-a"><?=\Yii::t('app','Callbacks');?></div>
        <div class="service-comments-wr style">
          <?php foreach ($model->comments as $comment){?>
          <div class="service-comments style">
            <div class="style comments-h-autor"><?=$comment->name?></div>
            <div class="style comments-h-text"><?=$comment->comment?></div>
            <div class="style comments-h-date"><?=date('d.m.Y', $comment->created_at)?></div>
          </div>
          <?php }?>
        </div>
        
        <div class="style service-links-c-a"><a href="<?=Url::to(['site/comments'])?>">
                <?=\Yii::t('app','All callbacks');?></a></div>
        <div class="style service-c-a-btns">
          <span class="btn_"><?=\Yii::t('app','Give feedback');?></span>
        </div>
        <div class="style hidden-form-c-a-wr hidden">
          <div class="style hidden-form-c-a">
            <div class="title-forms-c-a style"><?=\Yii::t('app','Give feedback');?></div>
            <?php $moduleComment->renderForm($this)?>
          </div>
        </div>
      </div>
      <div class="hidden-xs hidden-sm col-sm-1"></div>
      <div class="col-xs-12 col-sm-8 col-md-7 service-ansver-mob-line">
        <div class="title-c-a"><?=\Yii::t('app','Quest/Answer');?></div>
        <?php foreach ($model->questions as $question){?>
        <div class="service-comments-wr style">
          <div class="service-comments style service-ansvers">
            <div class="style comments-h-autor"><?=$question->name?></div>
            <div class="style comments-h-text"><?=$question->question?> </div>
            <div class="service-ansvers-text-wr style">
              <?php if ($question->doctor !== null){?>
              <div class="service-ansvers-title"><?=$question->doctor->position?><span><?=$question->doctor->name?></span></div>
              <?php }?>
              <div class="service-ansvers-txt">
                <?=$question->answer?>
              </div>
            </div>
          </div>
        
        
        </div>
        <?php } ?>
        <div class="style service-links-c-a service-links-a">
            <a href="<?=(isset($aliases['{"0":"site/questions"}'])) ?
                Url::to(['alias' => $aliases['{"0":"site/questions"}']]) : Url::to(['site/questions'])?>"><?=\Yii::t('app','All questions');?></a></div>
        <div class="style service-c-a-btns">
          <span class="btn_"><?=\Yii::t('app','Asc question');?></span>
        </div>
        
        <div class="style hidden-form-c-a-wr hidden">
          <div class="style hidden-form-c-a">
            <div class="title-forms-c-a style"><?=\Yii::t('app','Asc question');?></div>
            <?php $moduleQuestion->renderForm($this)?>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>