Compare commits

...

2 Commits

Author SHA1 Message Date
de2c087d93 done -> next review 2026-03-06 16:07:40 +07:00
f19a414f22 progress 2026-03-06 15:34:12 +07:00
7 changed files with 95 additions and 46 deletions

View File

@ -167,8 +167,16 @@ class DashboardController extends Controller
$allKategoriValues = array_values(array_filter(array_merge($kategoriValues, $kategoriHeaderValues)));
$kategoriTypes = [];
$kategoriIds = [];
$kategoriHukumValues = [];
foreach ($allKategoriValues as $val) {
$lower = strtolower(trim((string) $val));
if (str_starts_with($lower, 'hukum:')) {
$hukumVal = trim(substr((string) $val, strlen('hukum:')));
if ($hukumVal !== '') {
$kategoriHukumValues[] = $hukumVal;
}
continue;
}
if (in_array($lower, ['akreditasi', 'akre'], true)) {
$kategoriTypes[] = 'akreditasi';
continue;
@ -195,13 +203,17 @@ class DashboardController extends Controller
->whereIn('id_unit_kerja', $unitIds);
$query = (clone $baseQuery)
->when(!empty($kategoriIds) || !empty($kategoriTypes), function ($q) use ($kategoriIds, $kategoriTypes) {
$q->where(function ($sub) use ($kategoriIds, $kategoriTypes) {
->when(!empty($kategoriIds) || !empty($kategoriTypes) || !empty($kategoriHukumValues), function ($q) use ($kategoriIds, $kategoriTypes, $kategoriHukumValues) {
$q->where(function ($sub) use ($kategoriIds, $kategoriTypes, $kategoriHukumValues) {
$hasClause = false;
if (!empty($kategoriIds)) {
$sub->whereIn('master_kategori_directory_id', $kategoriIds);
$hasClause = true;
}
if (!empty($kategoriHukumValues)) {
$hasClause ? $sub->orWhereIn('kategori_hukum', $kategoriHukumValues) : $sub->whereIn('kategori_hukum', $kategoriHukumValues);
$hasClause = true;
}
if (in_array('akreditasi', $kategoriTypes, true)) {
$sub->where('is_akre', true);
$hasClause = true;
@ -230,11 +242,8 @@ class DashboardController extends Controller
return $item;
});
$kategoriList = (clone $baseQuery)->get()->map(function($item){
if ($item->is_akre) {
return ['id' => 'akreditasi', 'label' => 'Kategori Akreditasi'];
}
if (!empty($item->kategori_hukum)) {
return ['id' => 'hukum', 'label' => 'Kategori Hukum'];
return ['id' => 'hukum:' . $item->kategori_hukum, 'label' => $item->kategori_hukum];
}
$label = $item->kategori->nama_kategori_directory ?? $item->nama_kategori_directory ?? 'Kategori';
$id = $item->master_kategori_directory_id ?? $label;
@ -998,8 +1007,16 @@ class DashboardController extends Controller
$allKategoriValues = array_values(array_filter(array_merge($kategoriValues, $kategoriHeaderValues)));
$kategoriTypes = [];
$kategoriIds = [];
$kategoriHukumValues = [];
foreach ($allKategoriValues as $val) {
$lower = strtolower(trim((string) $val));
if (str_starts_with($lower, 'hukum:')) {
$hukumVal = trim(substr((string) $val, strlen('hukum:')));
if ($hukumVal !== '') {
$kategoriHukumValues[] = $hukumVal;
}
continue;
}
if (in_array($lower, ['akreditasi', 'akre'], true)) {
$kategoriTypes[] = 'akreditasi';
continue;
@ -1021,13 +1038,17 @@ class DashboardController extends Controller
});
$query = (clone $baseQuery)
->when(!empty($kategoriIds) || !empty($kategoriTypes), function ($q) use ($kategoriIds, $kategoriTypes) {
$q->where(function ($sub) use ($kategoriIds, $kategoriTypes) {
->when(!empty($kategoriIds) || !empty($kategoriTypes) || !empty($kategoriHukumValues), function ($q) use ($kategoriIds, $kategoriTypes, $kategoriHukumValues) {
$q->where(function ($sub) use ($kategoriIds, $kategoriTypes, $kategoriHukumValues) {
$hasClause = false;
if (!empty($kategoriIds)) {
$sub->whereIn('master_kategori_directory_id', $kategoriIds);
$hasClause = true;
}
if (!empty($kategoriHukumValues)) {
$hasClause ? $sub->orWhereIn('kategori_hukum', $kategoriHukumValues) : $sub->whereIn('kategori_hukum', $kategoriHukumValues);
$hasClause = true;
}
if (in_array('akreditasi', $kategoriTypes, true)) {
$hasClause ? $sub->orWhere('is_akre', true) : $sub->where('is_akre', true);
$hasClause = true;
@ -1063,11 +1084,8 @@ class DashboardController extends Controller
});
$kategoriList = (clone $baseQuery)->get()->map(function($item){
if ($item->is_akre) {
return ['id' => 'akreditasi', 'label' => 'Kategori Akreditasi'];
}
if (!empty($item->kategori_hukum)) {
return ['id' => 'hukum', 'label' => 'Kategori Hukum'];
return ['id' => 'hukum:' . $item->kategori_hukum, 'label' => $item->kategori_hukum];
}
$label = $item->kategori->nama_kategori_directory ?? $item->nama_kategori_directory ?? 'Kategori';
$id = $item->master_kategori_directory_id ?? $label;
@ -1541,7 +1559,6 @@ class DashboardController extends Controller
{
$rows = FileDirectory::where('statusenabled', true)
->whereNotNull('status_action')->where('status_action', 'approved')
->where('is_akre')
->whereIn('id_unit_kerja', $unitIds)
->pluck('file');
@ -1991,7 +2008,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 +2031,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 +2053,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 +2256,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 +2411,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);

View File

@ -93,12 +93,14 @@ class LogActivityController extends Controller
$query = LogActivity::select(
'pegawai_id_entry',
'pegawai_nama_entry',
DB::raw('COUNT(*) as total_open'),
DB::raw("SUM(CASE WHEN action_type = 'Membuka Dokumen' THEN 1 ELSE 0 END) as total_open"),
// Menghitung hanya yang Download Dokumen
DB::raw("SUM(CASE WHEN action_type = 'Download Dokumen' THEN 1 ELSE 0 END) as total_download"),
DB::raw('MAX(entry_at) as last_open')
)
->where('file_directory_id', $fileDirectoryId)
->where('statusenabled', true)
->where('action_type', 'Membuka Dokumen')
->whereIn('action_type', ['Membuka Dokumen', 'Download Dokumen'])
->groupBy('pegawai_id_entry', 'pegawai_nama_entry')
->orderByDesc('total_open');
@ -121,5 +123,5 @@ class LogActivityController extends Controller
]);
}
}

View File

@ -118,8 +118,8 @@ document.addEventListener('DOMContentLoaded', () => {
data-permission_file="${item.permission_file || '-'}">${item.nama_dokumen}</a></td>
${item.is_akre ? `<td colspan="2" class="text-center">Dokumen akreditasi</td>` :
`
<td>${item.folder || '-'}</td>
<td>${item.part || '-'}</td>
<td>${item.name_kategori || '-'}</td>
<td>${item.name_unit || '-'}</td>
`
}
@ -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 = '<option value="">Pilih Instrumen</option>';

View File

@ -96,6 +96,7 @@
<th style="width: 80px;">Aksi</th>
<th style="width: 40%;">Nama Dokumen / Folder</th>
<th>Tipe</th>
<th>Unit</th>
<th>Tgl Unggah</th>
</tr>
</thead>
@ -258,6 +259,7 @@
</div>
</td>
<td><span class="badge bg-light text-primary border">${typeDok}</span></td>
<td></td>
<td>${item.entry_at || '-'}</td>
</tr>`;
}
@ -319,7 +321,7 @@
</div>
</td>
<td><span class="badge bg-light text-muted border-0">FOLDER</span></td>
<td class="text-muted small">-</td> <td class="text-muted small">-</td> </tr>
<td class="text-muted small"></td> <td class="text-muted small"></td> </tr>
`;
if (isExpanded) {
@ -389,6 +391,7 @@
</div>
</td>
<td><span class="badge bg-danger">${typeDok}</span></td>
<td>${item.unit?.name || '-'}</td>
<td class="text-muted small">${formatDateTime(item.entry_at)}</td>
</tr>`;
}

View File

@ -30,7 +30,7 @@
<thead class="table-light shadow-sm">
<tr>
<th style="width:5%;" class="text-center">#</th>
<th style="width:30%;">Unit</th>
<th style="width:30%;">Unit / Akreditasi</th>
<th style="width:20%;">Kategori</th>
<th style="width:15%;" class="text-center">Jumlah File</th>
</tr>
@ -101,7 +101,7 @@ function fetchRecap(){
}).join('');
tbody.innerHTML = html + `
<tr class="table-light">
<td colspan="3" class="text-end fw-semibold">Total File</td>
<td colspan="4" class="text-end fw-semibold">Total File</td>
<td class="text-center fw-bold">${grandTotal}</td>
</tr>
`;

View File

@ -41,14 +41,14 @@
<span class="hide-menu">Dokumen Umum</span>
</a>
</li>
@if(auth()->user()->dataUser->mappingUnitKerjaPegawai()->where('objectunitkerjapegawaifk', 51)->exists())
{{-- @if(auth()->user()->dataUser->mappingUnitKerjaPegawai()->where('objectunitkerjapegawaifk', 51)->exists()) --}}
<li class="sidebar-item">
<a class="sidebar-link" href="{{ url('/data-akreditasi') }}" aria-expanded="false">
<i class="fa-solid fa-sliders"></i>
<span class="hide-menu">Dokumen Akreditasi</span>
</a>
</li>
@endif
{{-- @endif --}}
{{-- AKTIVITAS --}}
<li class="nav-small-cap"><span class="hide-menu">Aktivitas</span></li>

View File

@ -160,6 +160,7 @@ document.addEventListener('DOMContentLoaded', () => {
<td>${((currentPage - 1) * (pagination.per_page || 10)) + idx + 1}</td>
<td>${row.pegawai_nama_entry || '-'}</td>
<td>${row.total_open || 0}</td>
<td>${row.total_download || 0}</td>
<td>${formatTanggal(row.last_open)}</td>
</tr>
`).join('');
@ -341,6 +342,7 @@ document.addEventListener('DOMContentLoaded', () => {
<th>#</th>
<th>Nama</th>
<th>Jumlah Membuka</th>
<th>Jumlah Mengunduh</th>
<th>Terakhir Dilihat</th>
</tr>
</thead>