]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
added link to view in name column
authorJoySystem_v <fvv2011@gmail.com>
Thu, 15 Aug 2024 14:53:10 +0000 (17:53 +0300)
committerJoySystem_v <fvv2011@gmail.com>
Thu, 15 Aug 2024 14:53:10 +0000 (17:53 +0300)
erp24/views/crud/employee-payment/index.php
erp24/views/crud/employee-payment/view.php

index 16836a6e88aeb31dce84306999cb2cb787ceecb7..2c1d48728a68b4045ffce8cd687d127065636d4f 100755 (executable)
@@ -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;
 
     <h1><?= Html::encode($this->title) ?></h1>
 
-    <p>
-        <?= Html::a('Добавить запись', ['create'], ['class' => 'btn btn-success']) ?>
-    </p>
-
     <?php Pjax::begin(); ?>
     <?php echo $this->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 '#'; // на случай если как-то вызовется другое действие
+                }
             ],
         ],
     ]); ?>
 
     <?php Pjax::end(); ?>
 
+    <?php print_r($searchModel); ?>
+
 </div>
index ab6cb6de5b5a02e2f3514c3bce046d822723b286..77da5dbeb4f82942a123a6d458f4360c45794fd5 100755 (executable)
@@ -15,6 +15,10 @@ $this->params['breadcrumbs'][] = $this->title;
 
     <h1><?= Html::encode($this->title) ?></h1>
 
+    <p>
+        <?= Html::a('Добавить запись', ['create'], ['class' => 'btn btn-success']) ?>
+    </p>
+
     <p>
         <?= Html::a('Поменять', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
         <?= Html::a('Удалить', ['delete', 'id' => $model->id], [