<?php
    /**
     * @var \yii\data\ActiveDataProvider $dataProvider
     * @var  \common\models\Service[]    $services
     * @var \yii\web\View                $this
     * @var int                          $service_id
     * @var array $alias;
     * @var \artbox\core\components\SeoComponent $seo;
     */
    
    use artbox\core\helpers\Url;
    use common\models\Question;
    use yii\helpers\ArrayHelper;
    use yii\helpers\Html;
    use yii\helpers\Json;
    use yii\widgets\ActiveForm;
    use yii\widgets\ListView;
   
    
    $seo = \Yii::$app->get('seo');
    $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Quest/Answer');
    
    $model = new Question([ 'service_id' => $service_id ]);
    $model->scenario = Question::SCENARIO_QUESTION;
    
    $data = [ '' => \Yii::t('app', 'General issues') ] + ArrayHelper::map($services, 'id', 'title');
?>


<section class="section-service-page section-answer-page">
  <div class="container">
    <div class="row">
      <div class="col-xs-12 col-sm-12">
        <h1 class="title-pages"><?=(!empty($seo->h1)) ? $seo->h1 : \Yii::t('app', 'Quest/Answer') ?></h1>
      </div>
    </div>
    <div class="row">
      <div class="col-xs-12 col-sm-12">
        <div class="style add-answer-forms">
          <span class="btn_"><?= \Yii::t('app', 'Asc question'); ?></span>
        </div>
        <div class="style hidden-answer-comment-form hidden">
          <div class="hidden-answer-comment-form-title"><?= \Yii::t('app', 'Asc question'); ?></div>
            <?php $form = ActiveForm::begin([ 'id' => 'total_question_form' ]) ?>
          <div class="col-xs-12 col-sm-6">
            <div class="input-wr">
                <?= $form->field($model, 'service_id')
                         ->dropDownList($data)
                         ->label(\Yii::t('app', 'Choosing department')) ?>
            </div>
            
            <div class="input-wr required">
                <?= $form->field($model, 'name')
                         ->label(\Yii::t('app', 'FIO')) ?>
            </div>
            <div class="input-wr required">
                <?= $form->field($model, 'email')
                         ->label(\Yii::t('app', 'Email')) ?>
            </div>
          </div>
          <div class="col-xs-12 col-sm-6">
            <div class="input-wr">
                <?= $form->field($model, 'question')
                         ->textarea(
                             [
                                 'cols' => 30,
                                 'rows' => 10,
                             ]
                         )
                         ->label(\Yii::t('app', 'Yours question')) ?>
              <!--                                <label class="control-label" for="feedback-name">Ваш вопрос</label>-->
              <!--                                <textarea name="" id="" cols="30" rows="10"></textarea>-->
            </div>
          </div>
          <div class="col-xs-12 col-sm-12">
            <div class="button-wr submit-close-wr-c-a">
                <?= Html::submitButton(\Yii::t('app', 'Send question')) ?>
              <!--                                <button type="submit">Отправить вопрос</button>-->
              <div class="submit-close-c-a submit-close-c-a-page">
                <span><?= \Yii::t('app', 'Minimize a window'); ?></span></div>
            </div>
          </div>
            <?php $form::end(); ?>
        </div>
      </div>
      <div class="col-xs-12 col-sm-12">
        <ul class="answers-category-list">
          <li <?= ( $service_id == null ? 'class="active"' : '' ) ?>>
            <a href="<?= ( array_key_exists('{"0":"site/questions"}', $alias) ) ? Url::to(
                [ 'alias' => $alias[ '{"0":"site/questions"}'] ]
            ) : Url::current([ 'service_id' => null]) ?>">
              <span><?= \Yii::t('app', 'General issues'); ?></span></a></li>
            <?php foreach ($services as $service) {
              $route = Json::encode(['site/questions', 'service_id' => $service->id]);
              ?>
              <li <?= ( $service_id == $service->id ? 'class="active"' : '' ) ?>>
                <a href="<?= ( array_key_exists($route, $alias) ) ? Url::to(
                    [ 'alias' => $alias[$route] ]
                ) : Url::current([ 'service_id' => $service->id ]) ?>"><span><?= $service->title ?></span></a></li>
            <?php } ?>
        
        
        </ul>
      </div>
      <div class="col-xs-12 col-sm-12">
        <div class="service-comments-wr style">
            <?php echo ListView::widget(
                [
                    'itemOptions'  => [],
                    'layout'       => '{items}',
                    'dataProvider' => $dataProvider,
                    'itemView'     => '_question',
                ]
            ); ?>
          
          
          <div class="style navi-c-a">
              <?php echo \frontend\widgets\FrontendPager::widget(
                  [
                      'pagination'     => $dataProvider->pagination,
                      'prevPageLabel'  => 'previous',
                      'nextPageLabel'  => 'next',
                      'maxButtonCount' => 3,
                      'lastPageLabel'  => 'last_number',
                  ]
              ); ?>
          </div>
        
        
        </div>
      </div>
    </div>
  </div>
</section>
