banki.test/views/list/index.php

78 lines
2.7 KiB
PHP
Raw Permalink Normal View History

2024-08-20 06:27:17 +02:00
<?php
2024-08-20 06:55:10 +02:00
use app\models\Parameter;
2024-08-20 06:27:17 +02:00
use yii\helpers\Html;
use yii\bootstrap5\ActiveForm;
use yii\grid\GridView;
/** @var yii\web\View $this */
$this->title = 'params list';
?>
<h1>Parameters</h1>
<?php $searchForm = ActiveForm::begin([
'action' => '/list/index',
'method' => 'get',
]); ?>
2024-08-20 07:53:49 +02:00
<?= Html::a('Create new', '/list/edit', [ 'class' => 'btn btn-l btn-success w-100 mb-1' ]) ?>
2024-08-20 06:27:17 +02:00
<?= Html::submitButton('Run search', [ 'class' => 'btn btn-l btn-success w-100' ]) ?>
<p class="small">Set your search query in the grid view</p>
<?php ActiveForm::end(); ?>
<?= GridView::widget([
'dataProvider' => $provider,
'filterModel' => $searchModel,
2024-08-20 06:55:10 +02:00
'columns' => [
'id', 'title', 'type',
[
'label' => 'Icon',
'value' => function (Parameter $model) {
if ($model->icon) {
$url = '/api/image?sha256=' . $model->icon->sha256;
2024-08-20 06:55:10 +02:00
return Html::a(Html::img($url, [ 'width' => 150, 'height' => 150 ]), $url, [ 'alt' => 'icon', 'target' => '_blank' ]);
}
},
'format' => 'raw',
],
2024-08-20 08:53:14 +02:00
[
'label' => 'Delete icon',
'value' => function (Parameter $model) {
if ($model->icon) {
return Html::a('Delete icon', '/list/delicon?type=normal&id=' . $model->id, [ 'class' => 'btn btn-sx btn-danger' ]);
}
},
'format' => 'raw',
],
2024-08-20 06:55:10 +02:00
[
'label' => 'Gray Icon',
'value' => function (Parameter $model) {
if ($model->iconGray) {
$url = '/api/image?sha256=' . $model->iconGray->sha256;
2024-08-20 06:55:10 +02:00
return Html::a(Html::img($url, [ 'width' => 150, 'height' => 150 ]), $url, [ 'alt' => 'grayscale icon', 'target' => '_blank' ]);
}
},
'format' => 'raw',
],
2024-08-20 08:53:14 +02:00
[
'label' => 'Delete gray icon',
'value' => function (Parameter $model) {
if ($model->iconGray) {
return Html::a('Delete gray icon', '/list/delicon?type=gray&id=' . $model->id, [ 'class' => 'btn btn-sx btn-danger' ]);
}
},
'format' => 'raw',
],
2024-08-20 06:55:10 +02:00
[
'label' => 'Edit',
'value' => function (Parameter $model) {
2024-08-21 04:08:55 +02:00
return Html::a('Edit', '/list/edit?id=' . $model->id, [ 'class' => 'w-100 btn btn-sx btn-secondary' ]) .
Html::a('Delete', '/list/del?id=' . $model->id, [ 'class' => 'w-100 btn btn-sx btn-danger' ]);
2024-08-20 06:55:10 +02:00
},
'format' => 'raw',
],
]
2024-08-20 06:27:17 +02:00
]); ?>