From 8693a87411522e4fe8290483f8500788199034aa Mon Sep 17 00:00:00 2001 From: JoySystem_v Date: Thu, 15 Aug 2024 17:53:10 +0300 Subject: [PATCH] added link to view in name column --- erp24/views/crud/employee-payment/index.php | 36 +++++++++++++++------ erp24/views/crud/employee-payment/view.php | 4 +++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/erp24/views/crud/employee-payment/index.php b/erp24/views/crud/employee-payment/index.php index 16836a6e..2c1d4872 100755 --- a/erp24/views/crud/employee-payment/index.php +++ b/erp24/views/crud/employee-payment/index.php @@ -2,8 +2,8 @@ use yii\helpers\Html; use yii\helpers\Url; -use yii\grid\ActionColumn; use yii\grid\GridView; +use yii\grid\ActionColumn; use yii\widgets\Pjax; use yii_app\records\EmployeePayment; @@ -18,10 +18,6 @@ $this->params['breadcrumbs'][] = $this->title;

title) ?>

-

- 'btn btn-success']) ?> -

- render('_search', ['model' => $searchModel]); ?> @@ -31,9 +27,23 @@ $this->params['breadcrumbs'][] = $this->title; 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - 'id', - 'admin.id:text:ID', - 'admin.name:text:Сотрудник', + [ + 'attribute' => 'admin.id', + 'label' => 'ID', + 'format' => 'raw', + 'value' => function($model) { + return Html::a($model->id, ['employee-payment/view', 'id' => $model->admin_id]); + } + ], + [ + 'attribute' => 'admin_id', + 'label' => 'Сотрудник', + 'format' => 'raw', + 'value' => function($model) { + return $model->admin ? Html::a(Html::encode($model->admin->name), ['employee/view', 'id' => $model->admin_id]) : null; + } + ], + 'adminGroup.name:text:Должность', 'date', 'monthly_salary', @@ -41,13 +51,19 @@ $this->params['breadcrumbs'][] = $this->title; 'creator.name:text:Создавший правило', [ 'class' => ActionColumn::class, + 'template' => '{view}', // Оставляем только кнопку "view" 'urlCreator' => function ($action, EmployeePayment $model, $key, $index, $column) { - return Url::toRoute([$action, 'id' => $model->id]); - } + if ($action === 'view') { + return Url::to(['employee-payment/view', 'id' => $model->admin_id]); + } + return '#'; // на случай если как-то вызовется другое действие + } ], ], ]); ?> + + diff --git a/erp24/views/crud/employee-payment/view.php b/erp24/views/crud/employee-payment/view.php index ab6cb6de..77da5dbe 100755 --- a/erp24/views/crud/employee-payment/view.php +++ b/erp24/views/crud/employee-payment/view.php @@ -15,6 +15,10 @@ $this->params['breadcrumbs'][] = $this->title;

title) ?>

+

+ 'btn btn-success']) ?> +

+

$model->id], ['class' => 'btn btn-primary']) ?> $model->id], [ -- 2.39.5