<?php
    /**
     * @var \yii\data\ActiveDataProvider $dataProvider
     * @var  \common\models\Service[] $services
     * @var \yii\web\View $this
     * @var int $service_id
     */
    
    use artbox\core\helpers\Url;
    use common\models\Comment;
    use common\models\Service;
    use yii\helpers\ArrayHelper;
    use yii\helpers\Html;
    use yii\widgets\ActiveForm;
    use yii\widgets\ListView;
    
    $this->params[ 'breadcrumbs'][] = \Yii::t('app', 'Отзывы');
    
    $model = new Comment(['entity_id' => $service_id, 'entity' => Service::className()]);
    
    $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">
	                <?= ($service_id == 0) ? $data[''] . ' - ' . \Yii::t('app', 'Callbacks') :
		                $data[$service_id] . ' - ' . \Yii::t('app', 'Callbacks')
	                ?></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','Give feedback')?></span>
                </div>
                <div class="style hidden-answer-comment-form hidden">
                    <div class="hidden-answer-comment-form-title"><?=\Yii::t('app','Give feedback')?></div>
                    <?php $form = ActiveForm::begin(['id' => 'total_comment_form'])?>
                        <div class="col-xs-12 col-sm-6">
                            <div class="input-wr">
                              <?=$form->field($model, 'entity_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, 'comment')->textarea(['cols' => 30, 'rows' => 10])
                                  ->label(Yii::t('app','Yours feedback'))?>
<!--                                <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('Отправить отзыв')?>
<!--                                <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="<?=Url::current(['service_id' => null])?>">
                            <span><?=\Yii::t('app','Общие отзывы');?></span></a></li>
                    <?php foreach ($services as $service){?>
                    <li <?=($service_id == $service->id ? 'class="active"' : '')?>>
                        <a href="<?=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'     => '_comment'
                      ]
                  );?>
                  

                    <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>
