87 lines
3.1 KiB
PHP
87 lines
3.1 KiB
PHP
<?php
|
|
|
|
use yii\helpers\Html;
|
|
use yii\grid\GridView;
|
|
use yii\helpers\Url;
|
|
use common\models\MobileDevice;
|
|
|
|
/* @var $this yii\web\View */
|
|
/* @var $searchModel frontend\models\CollectionSearch */
|
|
/* @var $card \common\models\Card */
|
|
/* @var $dataProvider \frontend\controllers\MobileDeviceController */
|
|
|
|
$this->title = "Vendég - mobil eszközök";
|
|
$this->params['breadcrumbs'][] = "Vendég";
|
|
$this->params['breadcrumbs'][] = "Mobil eszközök";
|
|
|
|
echo \frontend\components\CustomerTabWidget::widget(['card' => $card]);
|
|
|
|
|
|
echo GridView::widget([
|
|
'dataProvider' => $dataProvider,
|
|
'columns' => [
|
|
[
|
|
'attribute' => 'card_number',
|
|
'label' => 'Kártyaszám',
|
|
],
|
|
[
|
|
'attribute' => 'device_name',
|
|
'label' => 'Eszköz neve',
|
|
],
|
|
[
|
|
'attribute' => 'device_created_at',
|
|
'label' => 'Létrehozva',
|
|
'format' => 'datetime'
|
|
],
|
|
[
|
|
'attribute' => 'device_status',
|
|
'label' => 'Státusz',
|
|
'value' => function ($model, $key, $index, $column) {
|
|
return MobileDevice::toStatusHumanReadable($model['device_status']);
|
|
}
|
|
],
|
|
|
|
|
|
['class' => 'yii\grid\ActionColumn',
|
|
'header' => 'Műveletek',
|
|
'template' => '{activate} {delete}',
|
|
'buttons' => [
|
|
'activate' => function ($url, $model, $key) {
|
|
$status = $model['device_status'];
|
|
if ($status == MobileDevice::STATUS_ACTIVE) {
|
|
return null;
|
|
}
|
|
$options = [
|
|
'title' => 'Az aktuális eszköz aktiválása',
|
|
'data-confirm' => "Biztosan aktiválni szerenté ezt az eszközt?",
|
|
'data-method' => 'post',
|
|
'class' => 'btn btn-xs btn-success'
|
|
];
|
|
return Html::a('Aktivál', $url, $options);
|
|
},
|
|
'delete' => function ($url, $model, $key) {
|
|
$status = $model['device_status'];
|
|
if ($status !== MobileDevice::STATUS_ACTIVE) {
|
|
return null;
|
|
}
|
|
$options = [
|
|
'title' => 'Az aktuális eszköz törlése',
|
|
'data-confirm' => "Biztosan törölni szerenté ezt az eszközt?",
|
|
'data-method' => 'post',
|
|
'class' => 'btn btn-xs btn-danger'
|
|
];
|
|
return Html::a('Töröl', $url, $options);
|
|
},
|
|
],
|
|
'urlCreator' => function ($action, $model, $key, $index) {
|
|
$status = MobileDevice::STATUS_DELETED_MANUAL;
|
|
if ($action === 'activate') {
|
|
$status = MobileDevice::STATUS_ACTIVE;
|
|
}
|
|
$url = Url::to(['mobile-device/status', 'id_device' => $model['device_id'], 'status' => $status]);
|
|
return $url;
|
|
}
|
|
],
|
|
],
|
|
]); ?>
|