diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php
index ed1fc64..6538894 100644
--- a/app/Http/Controllers/DashboardController.php
+++ b/app/Http/Controllers/DashboardController.php
@@ -1991,7 +1991,7 @@ class DashboardController extends Controller
$start = request('start_date');
$end = request('end_date');
$isHistory = filter_var(request('history'), FILTER_VALIDATE_BOOLEAN);
- $query = FileDirectory::where('statusenabled', true)
+ $query = FileDirectory::with('kategori')->where('statusenabled', true)
->where('pegawai_id_entry', auth()->user()->objectpegawaifk)
->when($isHistory, function($q){
$q->where('status_action', 'approved');
@@ -2014,7 +2014,6 @@ class DashboardController extends Controller
if($end){
$query->whereDate('entry_at','<=',$end);
}
-
$paginated = $query->paginate($perPage);
$data = $paginated->getCollection()->map(function($item){
$dataSlice = array_values(array_filter(explode('/', $item->file)));
@@ -2037,7 +2036,10 @@ class DashboardController extends Controller
'id_sub_unit_kerja' => $item->id_sub_unit_kerja,
'master_kategori_directory_id' => $item->master_kategori_directory_id,
'is_akre' => $item->is_akre,
- 'kategori_hukum' => $item->kategori_hukum
+ 'kategori_hukum' => $item->kategori_hukum,
+ 'name_kategori' => $item->kategori_hukum ?? $item->kategori?->nama_kategori_directory ?? null,
+ 'name_unit' => $item->unit?->name ?? null,
+ 'unit_kerja_name' => $item->unit?->name ?? null
];
});
return response()->json([
@@ -2237,6 +2239,8 @@ class DashboardController extends Controller
'id_unit_kerja' => $data ? $data->id_unit_kerja : null,
'id_sub_unit_kerja' => $data ? $data->id_sub_unit_kerja : null,
'action_type' => 'Revisi Dokumen',
+ 'is_akre' => $data->is_akre ?? null,
+ 'kategori_hukum' => $data->kategori_hukum ?? null
];
LogActivity::create($payloadLog);
@@ -2390,8 +2394,7 @@ class DashboardController extends Controller
{
$keyword = $request->query('keyword');
$perPage = (int) $request->query('per_page', 10);
- $query = FileDirectory::withOut('unit')
- ->where('statusenabled', true)
+ $query = FileDirectory::where('statusenabled', true)
->where('status_action', 'approved')
->where('is_akre', true);
diff --git a/public/js/pengajuanFile/index.js b/public/js/pengajuanFile/index.js
index acabf70..2e657ad 100644
--- a/public/js/pengajuanFile/index.js
+++ b/public/js/pengajuanFile/index.js
@@ -118,8 +118,8 @@ document.addEventListener('DOMContentLoaded', () => {
data-permission_file="${item.permission_file || '-'}">${item.nama_dokumen}
${item.is_akre ? `
Dokumen akreditasi | ` :
`
- ${item.folder || '-'} |
- ${item.part || '-'} |
+ ${item.name_kategori || '-'} |
+ ${item.name_unit || '-'} |
`
}
@@ -404,6 +404,10 @@ document.addEventListener('DOMContentLoaded', () => {
if (window.$ && $.fn.select2) $(selectEl).trigger('change');
}
+ function arrayFilterEmpty(arr){
+ return (arr || []).filter((val) => val !== null && val !== undefined && String(val).trim() !== '');
+ }
+
function initSelect2($el, options){
if (!$el || !$el.length || !window.$ || !$.fn.select2) return;
$el.select2(options);
@@ -426,7 +430,7 @@ document.addEventListener('DOMContentLoaded', () => {
processResults: function (data) {
return {
results: (data?.data || []).map(item => ({
- id: `${item.id}/${item.name}`,
+ id: String(item.id),
text: item.name
}))
};
@@ -449,8 +453,7 @@ document.addEventListener('DOMContentLoaded', () => {
editUnitSelect.on('change', function(){
const val = $(this).val();
if (!val) return;
- const unitId = String(val).split('/')[0];
- loadEditSubUnit(unitId, null, null);
+ loadEditSubUnit(String(val), null, null);
});
}
@@ -494,13 +497,13 @@ document.addEventListener('DOMContentLoaded', () => {
success: function(response) {
if (response?.data) {
response.data.forEach(unit => {
- const optVal = `${unit.id}/${unit.name}`;
+ const optVal = String(unit.id);
const isSelected = selectedSubId && String(unit.id) === String(selectedSubId);
const option = new Option(unit.name, optVal, false, isSelected);
editSubUnitSelect.append(option);
});
- if (selectedSubId && selectedSubName && editSubUnitSelect.find(`option[value="${selectedSubId}/${selectedSubName}"]`).length === 0) {
- editSubUnitSelect.append(new Option(selectedSubName, `${selectedSubId}/${selectedSubName}`, true, true));
+ if (selectedSubId && selectedSubName && editSubUnitSelect.find(`option[value="${selectedSubId}"]`).length === 0) {
+ editSubUnitSelect.append(new Option(selectedSubName, String(selectedSubId), true, true));
}
editSubUnitSelect.trigger('change');
}
@@ -513,7 +516,11 @@ document.addEventListener('DOMContentLoaded', () => {
if (!akreEl) return;
loadAkreData().then(() => {
fillAkreSelect(akreEl);
- setSelectValue(akreEl, value, value);
+ if (value && akreValueExists(value)) {
+ setSelectValue(akreEl, value, value);
+ } else {
+ akreEl.value = '';
+ }
triggerSelect2(akreEl);
});
}
@@ -527,9 +534,16 @@ document.addEventListener('DOMContentLoaded', () => {
function setEditKategoriDir(item, kategoriName){
const katEl = byId('edit_kategori');
- if (!katEl || !item.master_kategori_directory_id) return;
- const katVal = `${item.master_kategori_directory_id}/${kategoriName}`;
- setSelectValue(katEl, katVal, kategoriName || 'Kategori');
+ const katId = item?.master_kategori_directory_id;
+ if (!katEl || !katId) return;
+ const match = Array.from(katEl.options).find((opt) => String(opt.value).startsWith(`${katId}/`));
+ if (match) {
+ katEl.value = match.value;
+ } else {
+ const label = kategoriName || 'Kategori';
+ const katVal = `${katId}/${label}`;
+ setSelectValue(katEl, katVal, label);
+ }
triggerSelect2(katEl);
}
@@ -556,21 +570,24 @@ document.addEventListener('DOMContentLoaded', () => {
const displayName = item.fileName || (item.file ? String(item.file).split('/').pop() : '');
setTextValue(byId('edit_current_file'), displayName ? `File saat ini: ${displayName}` : '');
- const parts = (item.file || '').split('/');
+ const parts = arrayFilterEmpty((item.file || '').split('/'));
+ const unitNameFromPath = parts[0] || '';
+ const subNameFromPath = parts[1] || '';
const kategoriName = parts[2] || '';
- const unitName = item.unit_kerja_name || item.nama_unit_kerja || item.unit_name || item.unit_kerja || '';
-
+ const unitName = item.unit_kerja_name || item.name_unit || item.nama_unit_kerja || item.unit_name || item.unit_kerja || '';
if (editUnitSelect.length && item.id_unit_kerja) {
- const unitLabel = unitName || `Unit ${item.id_unit_kerja}`;
- const unitVal = `${item.id_unit_kerja}/${unitLabel}`;
+ const unitLabel = unitName || String(item.id_unit_kerja);
+ const unitVal = String(item.id_unit_kerja);
setSelectValue(editUnitSelect[0], unitVal, unitLabel);
- editUnitSelect.trigger('change');
- loadEditSubUnit(String(item.id_unit_kerja), item.id_sub_unit_kerja, null);
+ triggerSelect2(editUnitSelect[0]);
+ const subLabel = item.sub_unit_kerja_name || item.nama_sub_unit_kerja || item.sub_unit_name || item.sub_unit_kerja || String(item.id_sub_unit_kerja || '');
+ loadEditSubUnit(String(item.id_unit_kerja), item.id_sub_unit_kerja, subLabel || null);
}
setEditKategoriDir(item, kategoriName);
if (item.kategori_hukum) setEditKategoriHukum(item.kategori_hukum);
- setEditAkreValue(item.akre || '');
+ const akreFromFile = parts.length > 1 ? parts.slice(0, -1).join('/') : '';
+ setEditAkreValue(item.akre || akreFromFile || '');
$("#modalEditPengajuanFile").modal('show');
}
@@ -695,6 +712,11 @@ document.addEventListener('DOMContentLoaded', () => {
return akreFlat;
}
+ function akreValueExists(value){
+ if (!value) return false;
+ return getAkreFlat().some(opt => String(opt.value) === String(value));
+ }
+
function fillAkreSelect(selectEl){
if(!selectEl) return;
selectEl.innerHTML = '';
diff --git a/resources/views/dataAkreditasi/index.blade.php b/resources/views/dataAkreditasi/index.blade.php
index 7474ec3..419a67e 100644
--- a/resources/views/dataAkreditasi/index.blade.php
+++ b/resources/views/dataAkreditasi/index.blade.php
@@ -96,6 +96,7 @@
Aksi |
Nama Dokumen / Folder |
Tipe |
+ Unit |
Tgl Unggah |
@@ -258,6 +259,7 @@
${typeDok} |
+ |
${item.entry_at || '-'} |
`;
}
@@ -319,7 +321,7 @@
FOLDER |
- - | - |
+ | |
`;
if (isExpanded) {
@@ -389,6 +391,7 @@
${typeDok} |
+ ${item.unit?.name || '-'} |
${formatDateTime(item.entry_at)} |
`;
}
diff --git a/resources/views/layout/partials/sidenav.blade.php b/resources/views/layout/partials/sidenav.blade.php
index 930a2c3..94c430e 100644
--- a/resources/views/layout/partials/sidenav.blade.php
+++ b/resources/views/layout/partials/sidenav.blade.php
@@ -41,14 +41,14 @@
- @if(auth()->user()->dataUser->mappingUnitKerjaPegawai()->where('objectunitkerjapegawaifk', 51)->exists())
+ {{-- @if(auth()->user()->dataUser->mappingUnitKerjaPegawai()->where('objectunitkerjapegawaifk', 51)->exists()) --}}
- @endif
+ {{-- @endif --}}
{{-- AKTIVITAS --}}