From 5e356ca1ee8b5a06bd36b17bf05952b214d04c2b Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Wed, 22 Apr 2026 08:19:47 +0700 Subject: [PATCH] fix: menampilkan daftar sertifikat spv ke spv terkait dan manager --- app/Cells/SidebarCertificateCell.php | 5 ++++- app/Controllers/Certificates.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Cells/SidebarCertificateCell.php b/app/Cells/SidebarCertificateCell.php index 9efa611..256ef3e 100644 --- a/app/Cells/SidebarCertificateCell.php +++ b/app/Cells/SidebarCertificateCell.php @@ -48,7 +48,10 @@ class SidebarCertificateCell extends Cell { SUM(CASE WHEN certificates.cert_type = 'IC' THEN 1 ELSE 0 END) as totalIc ") ->join('users', 'users.userid = certificates.user_id', 'left') - ->where('users.reportto', $userId) + ->groupStart() // Mulai kurung buka ( + ->where('users.reportto', $userId) + ->orWhere('certificates.user_id', $userId) + ->groupEnd() // Tutup kurung ) ->where('certificates.status', 'unvalidated') ->Where('certificates.spv_validation_at', null) ->where('certificates.deleted_at', null) diff --git a/app/Controllers/Certificates.php b/app/Controllers/Certificates.php index 3892d84..73eefe9 100644 --- a/app/Controllers/Certificates.php +++ b/app/Controllers/Certificates.php @@ -49,6 +49,7 @@ class Certificates extends BaseController { if (in_array($userPosId, [1, 3, 5])) { // Manager & IT: Tidak perlu filter tambahan (lihat semua) } else if ($userPosId == 2) { // SPV: Melihat data user yang "reportto"-nya adalah ID supervisor ini $builder->where('users.reportto', $userId); + $builder->Orwhere('certificates.user_id', $userId); } else if ($userPosId == 4) { // TSOIVD: Hanya melihat data milik sendiri $builder->where('certificates.user_id', $userId); } else {// Role lain: Tidak diberi akses @@ -214,6 +215,7 @@ class Certificates extends BaseController { if (in_array($userPosId, [1, 3, 5])) { // Manager & IT: Tidak perlu filter tambahan (lihat semua) } else if ($userPosId == 2) { // SPV: Melihat data user yang "reportto"-nya adalah ID supervisor ini $builder->where('users.reportto', $userId); + $builder->Orwhere('certificates.user_id', $userId); } else if ($userPosId == 4) { // TSOIVD: Hanya melihat data milik sendiri $builder->where('certificates.user_id', $userId); } else {// Role lain: Tidak diberi akses @@ -383,6 +385,7 @@ class Certificates extends BaseController { if (in_array($userPosId, [1, 3, 5])) { // Manager & IT: Tidak perlu filter tambahan (lihat semua) } else if ($userPosId == 2) { // SPV: Melihat data user yang "reportto"-nya adalah ID supervisor ini $builder->where('users.reportto', $userId); + $builder->Orwhere('certificates.user_id', $userId); } else if ($userPosId == 4) { // TSOIVD: Hanya melihat data milik sendiri $builder->where('certificates.user_id', $userId); } else {// Role lain: Tidak diberi akses