From ca4dbf0486e7343c872cee1758b12a65d1a29277 Mon Sep 17 00:00:00 2001 From: JokoPrasetio Date: Mon, 22 Jun 2026 16:00:56 +0700 Subject: [PATCH] fixing bug di approval bertahap dokumen --- app/Http/Controllers/DashboardController.php | 109 ++++++---- public/js/pendingFile/index.js | 158 +++++++++----- public/js/pengajuanFile/index.js | 197 +++++++++++------- resources/views/dataUnit/index.blade.php | 3 +- .../views/dataUnit/modal/create.blade.php | 2 +- resources/views/pendingFile/index.blade.php | 2 +- resources/views/pengajuanFile/index.blade.php | 4 +- .../views/pengajuanFile/modal/edit.blade.php | 2 +- 8 files changed, 310 insertions(+), 167 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 3ee9d16..6ed516c 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -12,6 +12,7 @@ use App\Models\MasterKlasifikasi; use App\Models\Notifkasi; use App\Models\SubUnitKerja; use App\Models\UnitKerja; +use App\Models\DataUser; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -88,6 +89,41 @@ class PdfFpdiWithAlpha extends Fpdi class DashboardController extends Controller { + private function attachDeleteRecommendationMeta($items, $viewerPegawaiId) + { + $collection = collect($items); + $recommenderIds = $collection->pluck('turt_by') + ->filter(fn ($id) => !empty($id)) + ->map(fn ($id) => (int) $id) + ->unique() + ->values(); + + $recommenderNames = $recommenderIds->isEmpty() + ? collect() + : DataUser::whereIn('id', $recommenderIds->all())->pluck('namalengkap', 'id'); + + return $collection->map(function ($item) use ($viewerPegawaiId, $recommenderNames) { + $viewerId = $viewerPegawaiId ? (int) $viewerPegawaiId : null; + $entryId = !empty($item->pegawai_id_entry) ? (int) $item->pegawai_id_entry : null; + $recommenderId = !empty($item->turt_by) ? (int) $item->turt_by : null; + + $canViewRecommendation = (bool) ($item->hapus_turt ?? false) + && !empty($item->note_hapus_turt) + && $viewerId !== null + && ($viewerId === $entryId || $viewerId === $recommenderId); + + $item->delete_recommendation = $canViewRecommendation ? [ + 'visible' => true, + 'note' => $item->note_hapus_turt, + 'actor_name' => $recommenderNames->get($recommenderId) ?? 'TURT', + 'actor_role' => 'TURT', + 'created_at' => $item->turt_at, + ] : null; + + return $item; + }); + } + // public function index(){ // $katDok = MasterKategori::where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get(); // $klasifikasiDok = MasterKlasifikasi::where('statusenabled', true)->select('master_klasifikasi_directory_id', 'nama_klasifikasi_directory')->get(); @@ -131,9 +167,7 @@ class DashboardController extends Controller public function index(){ $katDok = MasterKategori::where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get(); - $authMapping = auth()->user()?->dataUser?->mappingUnitKerjaPegawai() - ->where('isprimary', true) - ->first(); + $authMapping = auth()->user()?->dataUser?->mappingUnitKerjaPegawai()->where('isprimary', true)->first(); // dd(auth()->user()?->dataUser); $authUnitKerja = $authMapping->objectunitkerjapegawaifk ?? null; $authSubUnitKerja = $authMapping->objectsubunitkerjapegawaifk ?? null; @@ -287,6 +321,7 @@ class DashboardController extends Controller $item->nama_kategori = $item->kategori->nama_kategori_directory ?? $item->kategori_hukum ?? null; return $item; }); + $items = $this->attachDeleteRecommendationMeta($items, $pegawaiId); $kategoriList = (clone $baseQuery)->get()->map(function($item){ if (!empty($item->kategori_hukum)) { return ['id' => 'hukum:' . $item->kategori_hukum, 'label' => $item->kategori_hukum]; @@ -1219,10 +1254,12 @@ class DashboardController extends Controller $data = $query->orderBy('entry_at', 'desc') ->paginate($perPage); + $pegawaiId = auth()->user()?->dataUser?->id; $items = collect($data->items())->map(function($item){ $item->nama_kategori = $item->kategori->nama_kategori_directory ?? $item->kategori_hukum ?? null; return $item; }); + $items = $this->attachDeleteRecommendationMeta($items, $pegawaiId); $kategoriList = (clone $baseQuery)->get()->map(function($item){ if (!empty($item->kategori_hukum)) { @@ -1398,18 +1435,18 @@ class DashboardController extends Controller ]; $fd = FileDirectory::create($payload); - $disk = Storage::disk('s3'); + // $disk = Storage::disk('s3'); $imageName = $this->buildStoredFileName( $fd->nama_dokumen ?? null, $fd->file_directory_id, $uploadedFile->getClientOriginalExtension() ); - $disk->putFileAs( - $path, - $uploadedFile, - $imageName, - ['visibility' => 'private'] - ); + // $disk->putFileAs( + // $path, + // $uploadedFile, + // $imageName, + // ['visibility' => 'private'] + // ); $fd->update([ 'file' => $path . '/' . $imageName ]); @@ -1933,14 +1970,14 @@ class DashboardController extends Controller $needTurt->whereNotNull('master_kategori_directory_id') ->where(function ($pendingTurt) { $pendingTurt->whereNull('status_turt') - ->orWhere('status_turt', 'rejected'); + ->orWhereIn('status_turt', ['rejected Turt', 'revised Turt']); }); }) ->orWhere(function ($needMutu) { $needMutu->where('is_akre', true) ->where(function ($pendingMutu) { $pendingMutu->whereNull('status_mutu') - ->orWhere('status_mutu', 'rejected'); + ->orWhereIn('status_mutu', ['rejected Mutu', 'revised Mutu']); }); }); }); @@ -1959,7 +1996,7 @@ class DashboardController extends Controller $sub->whereNotNull('master_kategori_directory_id') ->where(function ($pendingTurt) { $pendingTurt->whereNull('status_turt') - ->orWhere('status_turt', 'rejected'); + ->orWhereIn('status_turt', ['rejected Turt', 'revised Turt']); }); }); } @@ -1969,7 +2006,7 @@ class DashboardController extends Controller $sub->where('is_akre', true) ->where(function ($pendingMutu) { $pendingMutu->whereNull('status_mutu') - ->orWhere('status_mutu', 'rejected'); + ->orWhereIn('status_mutu', ['rejected Mutu', 'revised Mutu']); }); }); } @@ -2393,7 +2430,7 @@ class DashboardController extends Controller $sub->whereNotNull('master_kategori_directory_id') ->where(function ($pendingTurt) { $pendingTurt->whereNull('status_turt') - ->orWhere('status_turt', 'rejected'); + ->orWhereIn('status_turt', ['revised Turt']); }); }); } @@ -2403,7 +2440,7 @@ class DashboardController extends Controller $sub->where('is_akre', true) ->where(function ($pendingMutu) { $pendingMutu->whereNull('status_mutu') - ->orWhere('status_mutu', 'rejected'); + ->orWhereIn('status_mutu', ['revised Mutu']); }); }); } @@ -2846,7 +2883,7 @@ class DashboardController extends Controller $q->whereNotNull('master_kategori_directory_id') ->where(function ($pendingTurt) { $pendingTurt->whereNull('status_turt') - ->orWhere('status_turt', 'rejected'); + ->orWhereIn('status_turt', ['rejected Turt', 'revised Turt']); }); } if ($isKomiteMutu) { @@ -2855,7 +2892,7 @@ class DashboardController extends Controller $sub->where('is_akre', true) ->where(function ($pendingMutu) { $pendingMutu->whereNull('status_mutu') - ->orWhere('status_mutu', 'rejected'); + ->orWhereIn('status_mutu', ['rejected Mutu', 'revised Mutu']); }); }); } @@ -2873,14 +2910,14 @@ class DashboardController extends Controller $needTurt->whereNotNull('master_kategori_directory_id') ->where(function ($pendingTurt) { $pendingTurt->whereNull('status_turt') - ->orWhere('status_turt', 'rejected'); + ->orWhereIn('status_turt', ['rejected Turt', 'revised Turt']); }); }) ->orWhere(function ($needMutu) { $needMutu->where('is_akre', true) ->where(function ($pendingMutu) { $pendingMutu->whereNull('status_mutu') - ->orWhere('status_mutu', 'rejected'); + ->orWhereIn('status_mutu', ['rejected Mutu', 'revised Mutu']); }); }); }); @@ -2912,14 +2949,14 @@ class DashboardController extends Controller $needTurt->whereNotNull('master_kategori_directory_id') ->where(function ($pendingTurt) { $pendingTurt->whereNull('status_turt') - ->orWhere('status_turt', 'rejected'); + ->orWhere('status_turt', ['revised Turt', 'rejected Turt']); }); }) ->orWhere(function ($needMutu) { $needMutu->where('is_akre', true) ->where(function ($pendingMutu) { $pendingMutu->whereNull('status_mutu') - ->orWhere('status_mutu', 'rejected'); + ->orWhereIn('status_mutu', ['revised Mutu', 'rejected Mutu']); }); }); }); @@ -3124,34 +3161,32 @@ class DashboardController extends Controller } } $targetRoleNotifications = []; - $resetMutuApproval = $data->status_mutu === 'rejected'; - $resetTurtApproval = $data->status_turt === 'rejected'; + $resetMutuApproval = $data->status_mutu === 'rejected Mutu'; + $resetTurtApproval = $data->status_turt === 'rejected Turt'; $resetAtasanApproval = $data->status_action === 'rejected'; - + // dd($resetTurtApproval, $resetMutuApproval); if ($resetMutuApproval) { $payload['status_mutu'] = 'revised Mutu'; - $payload['mutu_revision'] = null; + // $payload['mutu_revision'] = null; $payload['action_mutu_at'] = null; $payload['action_mutu_by'] = null; $targetRoleNotifications[] = 51; } - if ($resetTurtApproval) { - $payload['status_turt'] = 'revised TURT'; - $payload['turt_revision'] = null; + $payload['status_turt'] = 'revised Turt'; + // $payload['turt_revision'] = null; $payload['action_turt_at'] = null; $payload['action_turt_by'] = null; $targetRoleNotifications[] = 22; } if($resetAtasanApproval){ - $payload['revision'] = null; + // $payload['revision'] = null; $payload['status_action'] = 'revised'; $payload['action_at'] = null; $payload['action_by'] = null; } - if (!empty($payload)) { $data->update($payload); } @@ -3940,14 +3975,11 @@ class DashboardController extends Controller ], 422); } $data->update([ - 'status_mutu' => 'rejected', + 'status_mutu' => 'rejected Mutu', 'action_mutu_at' => now(), 'action_mutu_by' => auth()->user()->dataUser->id, 'mutu_revision' => $revision, - 'revision' => 'Komite Mutu: ' . $revision, - 'status_action' => 'rejected', - 'action_at' => now(), - 'action_by' => auth()->user()->objectpegawaifk, + 'revision' => 'Komite Mutu: ' . $revision ]); $parts = array_values(array_filter(explode('/', $data->file))); @@ -4020,14 +4052,11 @@ class DashboardController extends Controller ], 422); } $data->update([ - 'status_turt' => 'rejected', + 'status_turt' => 'rejected Turt', 'action_turt_at' => now(), 'action_turt_by' => auth()->user()->dataUser->id, 'turt_revision' => $revision, 'revision' => 'TURT: ' . $revision, - 'status_action' => 'rejected', - 'action_at' => now(), - 'action_by' => auth()->user()->objectpegawaifk, ]); $parts = array_values(array_filter(explode('/', $data->file))); diff --git a/public/js/pendingFile/index.js b/public/js/pendingFile/index.js index dad946e..3765049 100644 --- a/public/js/pendingFile/index.js +++ b/public/js/pendingFile/index.js @@ -66,30 +66,49 @@ document.addEventListener('DOMContentLoaded', () => { } function approvalBadge(status, label){ - if (status === 'approved') return `Approved ${label}`; - if (status === 'rejected') return `Rejected ${label}`; + const normalized = String(status || '').toLowerCase(); + if (normalized === 'approved') return `Approved ${label}`; + if (normalized.startsWith('rejected')) return `Rejected ${label}`; + if (normalized.startsWith('revised')) return `Revised ${label}`; return `Pending ${label}`; } function getWorkflowStatusBadges(item){ - if (item?.status_mutu === 'rejected') return [`Rejected Mutu`]; - if (item?.status_turt === 'rejected') return [`Rejected TURT`]; - if (item?.status_action === 'rejected') return [`Rejected Atasan`]; - if (item?.status_action === 'revised') return [`Revised`]; + const actionStatus = String(item?.status_action || '').toLowerCase(); + const mutuStatus = String(item?.status_mutu || '').toLowerCase(); + const turtStatus = String(item?.status_turt || '').toLowerCase(); - if (item?.status_action !== 'approved') { + if (actionStatus.startsWith('revised')) { + return [`Revised`]; + } + + if (actionStatus.startsWith('rejected')) { + return [`Rejected Atasan`]; + } + + if (actionStatus !== 'approved') { return [`Pending Atasan`]; } const statuses = []; - if (item?.is_akre && item?.status_mutu !== 'approved') { - statuses.push(`Pending Mutu`); - } - if (item?.master_kategori_directory_id && item?.status_turt !== 'approved') { - statuses.push(`Pending TURT`); + + if (item?.is_akre) { + if (mutuStatus.startsWith('rejected')) { + statuses.push(`Rejected Mutu`); + } else if (mutuStatus !== 'approved') { + statuses.push(`Pending Mutu`); + } } - if (statuses.length) { + if (item?.master_kategori_directory_id) { + if (turtStatus.startsWith('rejected')) { + statuses.push(`Rejected TURT`); + } else if (turtStatus !== 'approved') { + statuses.push(`Pending TURT`); + } + } + + if (statuses.length > 0) { return statuses; } @@ -108,11 +127,18 @@ document.addEventListener('DOMContentLoaded', () => { } function isRejected(item){ - return item?.status_action === 'rejected' || item?.status_mutu === 'rejected' || item?.status_turt === 'rejected'; + return String(item?.status_action || '').toLowerCase().startsWith('rejected') + || String(item?.status_mutu || '').toLowerCase().startsWith('rejected') + || String(item?.status_turt || '').toLowerCase().startsWith('rejected'); } function isAtasanApproved(item){ - return item?.status_action === 'approved'; + return String(item?.status_action || '').toLowerCase() === 'approved'; + } + + function canProcessRoleStatus(status){ + const normalized = String(status || '').toLowerCase(); + return normalized === '' || normalized.startsWith('revised'); } function canApproveAsAtasan(item){ @@ -123,6 +149,62 @@ document.addEventListener('DOMContentLoaded', () => { return item?.can_edit_submission === true || item?.can_edit_submission === 1 || item?.can_edit_submission === '1'; } + function hasRevisionInfo(item){ + return !!(item?.revision || item?.mutu_revision || item?.turt_revision); + } + + function collectRevisionNotes(item){ + const notes = []; + const genericRevision = String(item?.revision || '').trim(); + const mutuRevision = String(item?.mutu_revision || '').trim(); + const turtRevision = String(item?.turt_revision || '').trim(); + + if (genericRevision) { + const lowerGeneric = genericRevision.toLowerCase(); + if (!lowerGeneric.startsWith('komite mutu:') && !lowerGeneric.startsWith('turt:')) { + notes.push({ label: 'Atasan', text: genericRevision }); + } + } + if (mutuRevision) { + notes.push({ label: 'Komite Mutu', text: mutuRevision }); + } + if (turtRevision) { + notes.push({ label: 'TURT', text: turtRevision }); + } + + return notes; + } + + function escapeHtml(value){ + return String(value ?? '') + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + function buildRevisionNotesHtml(notes){ + if (!notes.length) { + return '
Tidak ada catatan revisi.
'; + } + + return ` +
+ ${notes.map(note => ` +
+
${escapeHtml(note.label)}
+
${escapeHtml(note.text)}
+
+ `).join('')} +
+ `; + } + + function getItemById(id){ + return (tableState.data || []).find((row) => String(row.file_directory_id) === String(id)); + } + function getSelectableIdsOnPage(){ return (tableState.data || []) .filter((item) => !isRejected(item) && !isAtasanApproved(item) && canApproveAsAtasan(item)) @@ -169,6 +251,9 @@ document.addEventListener('DOMContentLoaded', () => { const rejected = isRejected(item); const atasanApproved = isAtasanApproved(item); const canAtasanApprove = canApproveAsAtasan(item); + const atasanRejected = String(item?.status_action || '').toLowerCase().startsWith('rejected'); + const canMutuAct = atasanApproved && isKomiteMutu && item.is_akre && canProcessRoleStatus(item.status_mutu); + const canTurtAct = atasanApproved && isTurt && item.master_kategori_directory_id && canProcessRoleStatus(item.status_turt); const checked = selectedIds.has(id); const actions = [ ``); actions.push(``); } - if (atasanApproved && isKomiteMutu && item.is_akre && item.status_mutu !== 'approved') { + if (canMutuAct) { actions.push(``); actions.push(``); } - if (atasanApproved && isTurt && item.master_kategori_directory_id && item.status_turt !== 'approved') { - actions.push(``); + if (canTurtAct) { + actions.push(``); actions.push(``); } - if (item.status_mutu === 'rejected' && item.mutu_revision) { - actions.push(``); - } - if (item.status_turt === 'rejected' && item.turt_revision) { - actions.push(``); - } } else { if (!atasanApproved) { actions.push(``); @@ -208,9 +287,14 @@ document.addEventListener('DOMContentLoaded', () => { } } - if (rejected) { + if (rejected && atasanRejected && !canMutuAct && !canTurtAct) { actions.length = 1; - actions.push(``); + } + + if (rejected) { + if (hasRevisionInfo(item)) { + actions.push(``); + } if (canEditSubmission(item)) { actions.push(``); } @@ -546,31 +630,11 @@ document.addEventListener('DOMContentLoaded', () => { }); } - window.infoRejectRole = function(label, revision){ - Swal.fire({ - title: `Catatan ${label}`, - text: revision || 'Tidak ada catatan revisi.', - icon: 'info', - confirmButtonText: 'Tutup' - }); - } - window.infoRejectPending = function(id){ const item = getItemById(id); - const notes = []; - if (item?.revision) { - notes.push(`Atasan: ${String(item.revision)}`); - } - if (item?.mutu_revision) { - notes.push(`Komite Mutu: ${String(item.mutu_revision)}`); - } - if (item?.turt_revision) { - notes.push(`TURT: ${String(item.turt_revision)}`); - } - Swal.fire({ title: 'Catatan Revisi', - text: notes.length ? notes.join('\n\n') : 'Tidak ada catatan revisi.', + html: buildRevisionNotesHtml(collectRevisionNotes(item)), icon: 'info', confirmButtonText: 'Tutup' }); diff --git a/public/js/pengajuanFile/index.js b/public/js/pengajuanFile/index.js index 99ed885..5c61624 100644 --- a/public/js/pengajuanFile/index.js +++ b/public/js/pengajuanFile/index.js @@ -19,7 +19,6 @@ document.addEventListener('DOMContentLoaded', () => { const selectedCountEl = document.getElementById('selectedCount'); const bulkActionsEl = document.getElementById('pengajuanBulkActions'); const deleteDataEl = document.getElementById('deleteData'); - const pendingPersetujuanTabBadge = document.getElementById('pendingPersetujuanTabBadge'); const pendingPersetujuanNotice = document.getElementById('pendingPersetujuanNotice'); const pendingPersetujuanNoticeCount = document.getElementById('pendingPersetujuanNoticeCount'); const formCreate = document.getElementById('formFile'); @@ -111,55 +110,137 @@ document.addEventListener('DOMContentLoaded', () => { } function approvalBadge(status, label){ - if (status === 'approved') return `Approved ${label}`; - if (status === 'rejected') return `Rejected ${label}`; + const normalized = String(status || '').toLowerCase(); + if (normalized === 'approved') return `Approved ${label}`; + if (normalized.startsWith('rejected')) return `Rejected ${label}`; + if (normalized.startsWith('revised')) return `Revised ${label}`; return `Pending ${label}`; } - function getPengajuanStatusBadge(item){ - if (item?.status_mutu === 'rejected') { - return `Rejected Mutu`; + function hasRevisionInfo(item){ + return !!(item?.revision || item?.mutu_revision || item?.turt_revision); + } + + function collectRevisionNotes(item){ + const notes = []; + const genericRevision = String(item?.revision || '').trim(); + const mutuRevision = String(item?.mutu_revision || '').trim(); + const turtRevision = String(item?.turt_revision || '').trim(); + + if (genericRevision) { + const lowerGeneric = genericRevision.toLowerCase(); + if (!lowerGeneric.startsWith('komite mutu:') && !lowerGeneric.startsWith('turt:')) { + notes.push({ label: 'Atasan/Bagian Terkait', text: genericRevision }); + } } - if (item?.status_turt === 'rejected') { - return `Rejected TURT`; + if (mutuRevision) { + notes.push({ label: 'Komite Mutu', text: mutuRevision }); } - if (item?.status_action === 'rejected') { - return `Rejected Atasan`; + if (turtRevision) { + notes.push({ label: 'TURT', text: turtRevision }); } - if (item?.status_action === 'revised') { + + return notes; + } + + function escapeHtml(value){ + return String(value ?? '') + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + function buildRevisionNotesHtml(notes){ + if (!notes.length) { + return '
Tidak ada catatan revisi.
'; + } + + return ` +
+ ${notes.map(note => ` +
+
${escapeHtml(note.label)}
+
${escapeHtml(note.text)}
+
+ `).join('')} +
+ `; + } + + function isRejectedStatus(item){ + return String(item?.status_action || '').toLowerCase().startsWith('rejected') + || String(item?.status_mutu || '').toLowerCase().startsWith('rejected') + || String(item?.status_turt || '').toLowerCase().startsWith('rejected'); + } + + function isApprovedStatus(status){ + return String(status || '').toLowerCase() === 'approved'; + } + + function canProcessRoleStatus(status){ + const normalized = String(status || '').toLowerCase(); + return normalized === '' || normalized.startsWith('revised'); + } + + function getPengajuanStatusBadges(item){ + const actionStatus = String(item?.status_action || '').toLowerCase(); + const mutuStatus = String(item?.status_mutu || '').toLowerCase(); + const turtStatus = String(item?.status_turt || '').toLowerCase(); + + if (actionStatus.startsWith('revised')) { return `Revised`; } - if (item?.status_action !== 'approved') { + if (actionStatus.startsWith('rejected')) { + return `Rejected Atasan`; + } + + if (actionStatus !== 'approved') { return `Pending Atasan`; } - const pendingApprovals = []; - if (item?.is_akre && item?.status_mutu !== 'approved') { - pendingApprovals.push('Pending Mutu'); - } - if (item?.master_kategori_directory_id && item?.status_turt !== 'approved') { - pendingApprovals.push('Pending TURT'); + const statuses = []; + if (item?.is_akre) { + if (mutuStatus.startsWith('rejected mutu')) { + statuses.push(`Rejected Mutu`); + } else if (mutuStatus === 'revised mutu') { + statuses.push(`Revisi Mutu`); + } else if(mutuStatus === 'approved'){ + statuses.push(`Approved Mutu`); + }else{ + statuses.push(`Pending Mutu`); + } } - if (pendingApprovals.length) { - return pendingApprovals.map((label) => `${label}`).join(' '); - } - if (item?.status_action === 'approved') { - return `Approved`; + if (item?.master_kategori_directory_id) { + if (turtStatus.startsWith('rejected turt')) { + statuses.push(`Rejected TURT`); + } else if (turtStatus === 'revised turt') { + statuses.push(`Revisi TURT`); + } else if(turtStatus === 'approved'){ + statuses.push(`Approved TURT`); + } else{ + statuses.push(`Pending TURT`); + } } - return `Pending Atasan`; + if (statuses.length > 0) { + return statuses.join(' '); + } + + return `Approved`; } function buildRow(item){ let tanggal = item.entry_at ? formatTanggal(item.entry_at) : '-'; let tanggalExp = item.tgl_expired ? formatTanggal(item.tgl_expired) : '-'; let tanggalTerbit = item.tanggal_terbit ? formatTanggal(item.tanggal_terbit) : '-'; - const isApproved = item?.status_action === 'approved'; - const isRejected = item?.status_action === 'rejected' || item?.status_mutu === 'rejected' || item?.status_turt === 'rejected'; - const showEdit = !isApproved || isRejected; - const showInfo = isRejected; + const isApproved = isApprovedStatus(item?.status_action); + const isRejected = isRejectedStatus(item); + const showEdit = isRejected; + const showInfo = isRejected && hasRevisionInfo(item); const id = String(item.file_directory_id); const checked = selectedIds.has(id); const aksi = ` @@ -195,7 +276,7 @@ document.addEventListener('DOMContentLoaded', () => { ${aksi} ${item.no_dokumen || '-'} - ${getPengajuanStatusBadge(item)} +
${getPengajuanStatusBadges(item)}
${aksesBadge(item?.permission_file)} { data-permission_file="${item.permission_file || '-'}">` ]; - if (showMutu && item.status_mutu !== 'approved') { + if (showMutu && canProcessRoleStatus(item.status_mutu)) { actions.push(``); actions.push(``); } - if (showTurt && item.status_turt !== 'approved') { - actions.push(``); + if (showTurt && canProcessRoleStatus(item.status_turt)) { + actions.push(``); actions.push(``); } - if (item.status_mutu === 'rejected' && item.mutu_revision) { - actions.push(``); - } - if (item.status_turt === 'rejected' && item.turt_revision) { - actions.push(``); + if (hasRevisionInfo(item)) { + actions.push(``); } const statusParts = []; @@ -499,10 +577,8 @@ document.addEventListener('DOMContentLoaded', () => { function updatePendingPersetujuanIndicators(total){ const count = Number(total || 0); - if (pendingPersetujuanTabBadge) { - pendingPersetujuanTabBadge.textContent = String(count); - pendingPersetujuanTabBadge.classList.toggle('d-none', count <= 0); - } + console.log(pendingPersetujuanNoticeCount); + if (pendingPersetujuanNotice && pendingPersetujuanNoticeCount) { pendingPersetujuanNoticeCount.textContent = String(count); pendingPersetujuanNotice.classList.toggle('d-none', count <= 0); @@ -513,19 +589,14 @@ document.addEventListener('DOMContentLoaded', () => { function fetchPendingPersetujuanCount(){ if (!(isKomiteMutu || isTurt || isAtasan)) return; - const params = new URLSearchParams({ - page: 1, - per_page: 1, - keyword: '', - start_date: '', - end_date: '', - mode: 'persetujuan' - }); - - fetch(`/datatable/pengajuan-file?${params.toString()}`) + fetch('/data/count-pending', { + headers: { + 'Accept': 'application/json' + } + }) .then(res => res.json()) .then(data => { - updatePendingPersetujuanIndicators(data?.pagination?.total || 0); + updatePendingPersetujuanIndicators(data?.count || 0); }) .catch(() => { updatePendingPersetujuanIndicators(0); @@ -633,29 +704,9 @@ document.addEventListener('DOMContentLoaded', () => { window.infoReject = function(id){ const item = getItemById(id); - const notes = []; - if (item?.revision) { - notes.push(`Atasan/Bagian Terkait: ${String(item.revision)}`); - } - if (item?.mutu_revision) { - notes.push(`Komite Mutu: ${String(item.mutu_revision)}`); - } - if (item?.turt_revision) { - notes.push(`TURT: ${String(item.turt_revision)}`); - } - const revision = notes.length ? notes.join('\n\n') : 'Tidak ada catatan revisi.'; Swal.fire({ title: 'Catatan Revisi', - text: revision, - icon: 'info', - confirmButtonText: 'Tutup' - }); - } - - window.infoRejectPersetujuan = function(label, revision){ - Swal.fire({ - title: `Catatan ${label}`, - text: revision || 'Tidak ada catatan revisi.', + html: buildRevisionNotesHtml(collectRevisionNotes(item)), icon: 'info', confirmButtonText: 'Tutup' }); diff --git a/resources/views/dataUnit/index.blade.php b/resources/views/dataUnit/index.blade.php index 9952c85..864e97e 100644 --- a/resources/views/dataUnit/index.blade.php +++ b/resources/views/dataUnit/index.blade.php @@ -660,6 +660,7 @@ function renderDeleteRecommendation(item){ const recommendation = item?.delete_recommendation; + if (!recommendation?.visible || !recommendation?.note) return ''; const actorRole = recommendation.actor_role || 'TURT'; @@ -1255,7 +1256,7 @@ data-input-target="expiredInput_${colCount}" data-base-target="dateActive_${colCount}" data-preview-target="expiredPreview_${colCount}"> - + diff --git a/resources/views/dataUnit/modal/create.blade.php b/resources/views/dataUnit/modal/create.blade.php index 35c1cf3..d259817 100644 --- a/resources/views/dataUnit/modal/create.blade.php +++ b/resources/views/dataUnit/modal/create.blade.php @@ -57,7 +57,7 @@ data-input-target="expiredInput_0" data-base-target="dateActive_0" data-preview-target="expiredPreview_0"> - + diff --git a/resources/views/pendingFile/index.blade.php b/resources/views/pendingFile/index.blade.php index c427e7f..fd3d583 100644 --- a/resources/views/pendingFile/index.blade.php +++ b/resources/views/pendingFile/index.blade.php @@ -58,7 +58,7 @@
-
+
diff --git a/resources/views/pengajuanFile/index.blade.php b/resources/views/pengajuanFile/index.blade.php index df9b496..50a16c1 100644 --- a/resources/views/pengajuanFile/index.blade.php +++ b/resources/views/pengajuanFile/index.blade.php @@ -135,7 +135,7 @@
-
+
@@ -145,8 +145,6 @@ - - diff --git a/resources/views/pengajuanFile/modal/edit.blade.php b/resources/views/pengajuanFile/modal/edit.blade.php index 6f6e03a..948e631 100644 --- a/resources/views/pengajuanFile/modal/edit.blade.php +++ b/resources/views/pengajuanFile/modal/edit.blade.php @@ -56,7 +56,7 @@ data-input-target="edit_tgl_expired" data-base-target="edit_tanggal_terbit" data-preview-target="edit_expired_preview"> - +
Kategori Unit AksiTanggal TerbitTanggal Kedaluwarsa Dokumen Tanggal Upload