<?php
use yii\grid\GridView;
use yii\grid\SerialColumn;
use yii\helpers\VarDumper;
use yii\grid\ActionColumn;
use yii\helpers\Html;
use yii\widgets\Pjax;
$this->title = Yii::t('app', 'Requests');
?>
<div class="site-requests">
	<?php 
	echo GridView::widget([
		'dataProvider' => $dataProvider,
		'columns' => [
			[
				'class' => 'yii\grid\SerialColumn'
			],
			[
				'attribute' => 'created_at',
			],
			[
				'header' => Yii::t('app', 'values'),
				'content' => function($model, $key, $index, $column) {
					$value = '';
					$langs = $model->options;
					$lang = $model->getOptionDefaultLang(true);
					$value .= "<b>{$model->name}</b>:{$lang['value']}";
					foreach($langs as $onemodel) {
						$lang = $onemodel->getOptionDefaultLang(true);
						$value .= "<br><b>{$onemodel->name}</b>:{$lang['value']}";
					}
					return $value;
				}
			],
			[
				'class' => 'yii\grid\ActionColumn',
				'template' => '{requests} {delete-req}',
				'buttons' => [
					'requests' => function($url, $model, $key) { 
						return Html::a(
								'', 
								$model->options['is_new']->getOptionDefaultLang()->value?$url:'#', 
								[
									'class' => $model->options['is_new']->getOptionDefaultLang()->value?'glyphicon glyphicon-eye-open':'glyphicon glyphicon-eye-close', 
									'title' => Yii::t('app', 'Make already read')
								]
							); 
					},
					'delete-req' => function($url, $model, $key) {
						return Html::a(
							'',
							$url,
							[
								'class' => 'glyphicon glyphicon-trash',
								'title' => Yii::t('app', 'Delete'),
								'data' => [
									'label' => Yii::t('app', 'Delete'), 
									'confirm' => Yii::t('app', 'Are you sure you want delete this element?'),
									'method' => 'post',
									'pjax' => 0
								]
							]		
						);
					}
				]
			]
		],
	]);
	?>
</div>
