181 lines
6.8 KiB
PHP
181 lines
6.8 KiB
PHP
<?php
|
|
|
|
use yii\helpers\Html;
|
|
use yii\grid\GridView;
|
|
|
|
/* @var $this yii\web\View */
|
|
/* @var $searchModel common\modules\event\models\EventSearch */
|
|
/* @var $permissions common\modules\event\models\EventPermissions */
|
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
|
|
|
$this->title = Yii::t('event', 'Events');
|
|
$this->params['breadcrumbs'][] = $this->title;
|
|
|
|
$indexTableTemplateButtons = ['{view}']; // '{view} {update} {reserve-card}';
|
|
if ( $permissions->allowCreate ){
|
|
$indexTableTemplateButtons[] = '{update}';
|
|
}
|
|
$indexTableTemplateButtons[] = '{reserve-card}';
|
|
//$indexTableTemplateButtons[] = '{equipment-types-assignment}';
|
|
|
|
|
|
?>
|
|
<div class="event-index">
|
|
|
|
<h1><?= Html::encode($this->title) ?></h1>
|
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
|
|
|
<p>
|
|
<?php
|
|
if ( $permissions->allowCreate ){
|
|
echo Html::a(Yii::t('event', 'Create Event'), ['create'], ['class' => 'btn btn-success']);
|
|
}
|
|
?>
|
|
</p>
|
|
|
|
<?php
|
|
|
|
/**
|
|
* Filter array of menu config by the 'allowed' property.
|
|
* If property not set , it means it is allowed ( allowed boolean default true)
|
|
* @param $array array of menu configs
|
|
* @return array the filtered array of menu configs
|
|
*/
|
|
function buildColumns($array){
|
|
$result = [];
|
|
foreach ($array as $item){
|
|
$allow = true;
|
|
if ( isset($item['allow'])){
|
|
$allow = $item['allow'];
|
|
unset($item['allow']);
|
|
}
|
|
if ( $allow ){
|
|
$result[] = $item;
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
$columns = buildColumns([
|
|
[
|
|
'attribute' => 'event_id',
|
|
'label' => \Yii::t('event', 'ID')
|
|
],
|
|
[
|
|
'attribute' => 'event_type_name',
|
|
'label' => \Yii::t('event', 'Id Event Type'),
|
|
'value' => function ($model, $key, $index, $column){
|
|
return "<span style='margin-right: 3px; display: inline-block; width: 1rem; height: 1rem;' class='event-theme-active-". $model['event_type_theme']."'></span>".$model['event_type_name'] ;
|
|
}
|
|
,
|
|
'format' => 'raw'
|
|
],
|
|
[
|
|
'attribute' => 'event_start',
|
|
'label' => \Yii::t('event', 'Start'),
|
|
'format' => 'datetime'
|
|
],
|
|
[
|
|
'attribute' => 'event_end',
|
|
'label' => \Yii::t('event', 'End'),
|
|
'format' => 'time'
|
|
],
|
|
[
|
|
'attribute' => 'event_seat_count',
|
|
'label' => \Yii::t('event', 'Seat Count')
|
|
],
|
|
[
|
|
'attribute' => 'registration_count',
|
|
'label' => \Yii::t('event', 'Registration Count')
|
|
],
|
|
[
|
|
'attribute' => 'room_name',
|
|
'label' => \Yii::t('event', 'Room Name')
|
|
],
|
|
[
|
|
'attribute' => 'trainer_name',
|
|
'label' => \Yii::t('event', 'Trainer Name')
|
|
],
|
|
[
|
|
'attribute' => 'event_created_at',
|
|
'label' => \Yii::t('event', 'Created At'),
|
|
'format' => 'datetime',
|
|
'allow' => $permissions->allowIndexCreatedAt
|
|
],
|
|
[
|
|
'attribute' => 'event_updated_at',
|
|
'label' => \Yii::t('event', 'Updated At'),
|
|
'format' => 'datetime'
|
|
],
|
|
[
|
|
'attribute' => 'event_deleted_at',
|
|
'label' => \Yii::t('event', 'Deleted At'),
|
|
'format' => 'datetime'
|
|
],
|
|
[
|
|
'class' => 'yii\grid\ActionColumn',
|
|
'template' => join(" ",$indexTableTemplateButtons),
|
|
'urlCreator' => function ($action, $model, $key, $index) {
|
|
$params = ['id' => $model['event_id']];
|
|
$params[0] = "event" . '/' . $action;
|
|
return \yii\helpers\Url::toRoute($params);
|
|
},
|
|
'buttons' => [
|
|
'view' => function ($url, $model, $key) {
|
|
$options = [
|
|
'title' => Yii::t('yii', 'View'),
|
|
'aria-label' => Yii::t('yii', 'View'),
|
|
'data-pjax' => '0',
|
|
];
|
|
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, $options);
|
|
},
|
|
'update' => function ($url, $model, $key) {
|
|
$options = [
|
|
'title' => Yii::t('yii', 'Update'),
|
|
'aria-label' => Yii::t('yii', 'Update'),
|
|
'data-pjax' => '0',
|
|
];
|
|
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, $options);
|
|
},
|
|
'delete' => function ($url, $model, $key) {
|
|
$options = [
|
|
'title' => Yii::t('yii', 'Delete'),
|
|
'aria-label' => Yii::t('yii', 'Delete'),
|
|
'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
|
|
'data-method' => 'post',
|
|
'data-pjax' => '0',
|
|
];
|
|
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options);
|
|
},
|
|
'reserve-card' => function ($url, $model, $key) {
|
|
$options = [
|
|
'title' => Yii::t('yii', 'Register'),
|
|
'aria-label' => Yii::t('yii', 'Register'),
|
|
'data-pjax' => '0',
|
|
];
|
|
if ( isset($model['event_deleted_at']) ){
|
|
return "";
|
|
}
|
|
return Html::a('<span class="glyphicon glyphicon-user"></span>', $url, $options);
|
|
},
|
|
// 'equipment-types-assignment' => function ($url, $model, $key) {
|
|
// $options = [
|
|
// 'title' => Yii::t('yii', 'Equipment Types'),
|
|
// 'aria-label' => Yii::t('yii', 'Equipment Types'),
|
|
// 'data-pjax' => '0',
|
|
// ];
|
|
// return Html::a('<span class="glyphicon glyphicon-wrench"></span>', $url, $options);
|
|
// }
|
|
]
|
|
|
|
],
|
|
]);
|
|
?>
|
|
|
|
<?= GridView::widget([
|
|
'dataProvider' => $dataProvider,
|
|
'columns' => $columns
|
|
]); ?>
|
|
|
|
</div>
|