diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 81da6d0..9110fbb 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -453,14 +453,45 @@ class DashboardController extends Controller public function downloadDataMultiple(){ try { - $rows = request('ids', []); // [[unit_id=>u, sub_unit_id=>s], ...] + $rows = request('ids', []); // [[file_directory_id=>x] | [sub_unit_id=>y] | "file_directory_id", ...] if (empty($rows)) { return response()->json(['message' => 'Tidak ada data'], 422); } $paths = []; foreach ($rows as $r) { - if(!empty($r['sub_unit_id'])){ - $files = FileDirectory::where('id_sub_unit_kerja', $r['sub_unit_id'])->where('statusenabled', true)->where('status_action', 'approved')->pluck('file'); + if (is_string($r) || is_numeric($r)) { + $file = FileDirectory::where('file_directory_id', $r) + ->where('statusenabled', true) + ->where('status_action', 'approved') + ->value('file'); + if ($file) { + $paths[] = $file; + } + continue; + } + + if (!empty($r['file_directory_id'] ?? null)) { + $file = FileDirectory::where('file_directory_id', $r['file_directory_id']) + ->where('statusenabled', true) + ->where('status_action', 'approved') + ->value('file'); + if ($file) { + $paths[] = $file; + } + continue; + } + + if (!empty($r['file'] ?? null)) { + $paths[] = $r['file']; + continue; + } + + $subUnitId = $r['sub_unit_id'] ?? $r['id_sub_unit_kerja'] ?? null; + if (!empty($subUnitId)) { + $files = FileDirectory::where('id_sub_unit_kerja', $subUnitId) + ->where('statusenabled', true) + ->where('status_action', 'approved') + ->pluck('file'); $paths = array_merge($paths, $files->toArray()); } @@ -632,13 +663,13 @@ class DashboardController extends Controller $status = null; - if(auth()->user()->masterPersetujuan){ + // if(auth()->user()->masterPersetujuan){ // $unitPegawaiIds = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray(); // $status = in_array($id_unit_kerja, $unitPegawaiIds) // ? 'approved' // : null; $status = $isAtasan ? 'approved' : null; - } + // } $payload = [ 'id_unit_kerja' => $id_unit_kerja, @@ -653,7 +684,6 @@ class DashboardController extends Controller 'action_by' => $status && $status === "approved" ? auth()->user()->objectpegawaifk : null, 'action_at' => $status && $status === "approved" ? now() : null ]; - $imageName = $uploadedFile->getClientOriginalName(); $path = "{$nama_unit_kerja}/{$nama_sub_unit_kerja}/{$nama_kategori}"; $uploadedFile->storeAs($path, $imageName, 'file_directory'); @@ -669,8 +699,8 @@ class DashboardController extends Controller 'text_notifikasi' => "Dokumen {$docNumber} memerlukan persetujuan. Diunggah oleh {$uploaderName}.", 'url' => '/pending-file', 'is_read' => false, - // 'pegawai_id' => $mapping?->objectatasanlangsungfk, - 'pegawai_id' => 23521, + 'pegawai_id' => $mapping?->objectatasanlangsungfk, + // 'pegawai_id' => 23521, ]; Notifkasi::create($payloadNotification); @@ -974,15 +1004,17 @@ class DashboardController extends Controller // ->orWhereNull('status_action'); // })->whereIn('id_unit_kerja', $authUnit)->orderBy('entry_at','desc'); $mapping = MappingUnitKerjaPegawai::where('statusenabled', true) - // ->where('objectatasanlangsungfk', auth()->user()->dataUser->id) - ->where('objectatasanlangsungfk', 22924) + ->where('objectatasanlangsungfk', auth()->user()->dataUser->id) + // ->where('objectatasanlangsungfk', 22924) ->get(['objectpegawaifk']); $objectpegawaifk = $mapping->pluck('objectpegawaifk') ->values() ->all(); $keyword = request('keyword'); $query = FileDirectory::where('statusenabled', true) - ->where('status_action', '!=', 'approved') + ->where(function($qsa){ + $qsa->where('status_action', '!=', 'approved')->orWhereNull('status_action'); + }) ->whereIn('pegawai_id_entry', $objectpegawaifk) ->when($keyword, function ($q) use ($keyword) { $q->where(function ($sub) use ($keyword) { @@ -1412,8 +1444,8 @@ class DashboardController extends Controller 'text_notifikasi' => "Dokumen {$docNumber} telah direvisi dan memerlukan persetujuan ulang. ". "Direvisi oleh {$uploaderName}.", 'url' => '/pending-file', 'is_read' => false, - // 'pegawai_id' => $mapping?->objectatasanlangsungfk, - 'pegawai_id' => 23521, + 'pegawai_id' => $mapping?->objectatasanlangsungfk, + // 'pegawai_id' => 23521, ]; Notifkasi::create($payloadNotification); diff --git a/public/js/pendingFile/index.js b/public/js/pendingFile/index.js index f80d384..5c62ec5 100644 --- a/public/js/pendingFile/index.js +++ b/public/js/pendingFile/index.js @@ -45,6 +45,13 @@ document.addEventListener('DOMContentLoaded', () => { if (status === 'revised') return 'Revised'; return 'Pending'; } + function aksesBadge(akses){ + if (akses){ + return 'Umum'; + } else{ + return 'Internal Unit'; + } + } function safeText(val){ return val ? String(val) : '-'; @@ -67,6 +74,7 @@ document.addEventListener('DOMContentLoaded', () => {
| + + | Nomor Surat | File | Kategori | @@ -185,6 +218,10 @@ const paginationEl = document.getElementById('paginationControls'); const summaryEl = document.getElementById('tableSummary'); const pageSizeSelect = document.getElementById('tablePageSize'); + const downloadBtn = document.getElementById('btnDownloadMultiple'); + const selectedCountEl = document.getElementById('selectedCount'); + const checkAllEl = document.getElementById('checkAllRows'); + const selectedIds = new Set(); if(pageSizeSelect){ const initialSize = parseInt(pageSizeSelect.value); @@ -232,8 +269,15 @@ statusLabel = 'Internal Unit'; statusClass = 'bg-secondary'; } + const checked = selectedIds.has(String(item.file_directory_id)) ? 'checked' : ''; return `|||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| + + | ${item.no_dokumen || '-'} |
@@ -368,7 +412,7 @@
if(pageData.length === 0){
tbody.innerHTML = `
+ |
Tidak ada data yang cocok
|
-
+ Data Unit- +
+
+
+
+
+
+ 0 dipilih
+
+
+
+
+
@@ -162,12 +192,16 @@
+
Memuat data...
| ||||||||||||||||||||||||||||||||||||