<?php
	use yii\helpers\Html;
	use yii\helpers\Url;
	use app\models\Inquirer;
	use yii\widgets\ListView;

	$this->title = 'Опросы';
	$this->params['breadcrumbs'][] = ['text' => 'Опросы', 'url' =>'/inquirer'];
	$url = '/inquirer';
	Yii::$app->og->title = $this->title;
	Yii::$app->og->description = 'Все опросы';

    Yii::$app->og->canonical = $url;
    \Yii::$app->og->og_url = $url;
    \Yii::$app->og->og_type = "article";

	\Yii::$app->og->og_title = htmlspecialchars(Yii::$app->og->title);
    \Yii::$app->og->og_description = Yii::$app->og->description;
    \Yii::$app->og->og_image = "/img/amic-logo.svg";

	$pages = 60;
	$query = Inquirer::find()->where([ 'active'=>'Y'])->orderBy([ 'id' => SORT_DESC]);
	$count = $query->count();

?>
<div class="archive">
	<div class="row">
        <div class="col-md-12">
            <div class="news-list mx-5">
                <?=$this->render("/layouts/breadcrumbs")?>
                <?php
				$request = Yii::$app->request;
				$ppage = $request->get('page');
				$ppage = ($ppage)?'-'.$ppage:'';

                echo Yii::$app->cache->getOrSet("archive_inq-{$ppage}",function () use($query, $pages){
                    return ListView::widget([
                        "dataProvider" => new \yii\data\ActiveDataProvider([
                            "query"=>$query,
							"pagination"=>['pageSize'=>$pages],
                        ]),
                        'options' => [
                            'tag' => "ul",
                            'class' => 'list-wrapper',
                            'id' => 'list-wrapper',
                        ],
                        "itemOptions"=>[
                            "tag"=>"li"
                        ],
                        "itemView" => "_item",
                        "layout" => "{items}{pager}"
                    ]);
                },1);
                ?>

            </div>
        </div>
    </div>
</div>
