Compare commits
No commits in common. "8c1663f9c302b05a58041b1d46c12dedfb474dbd" and "21012d38c3ea58a9e3189b02d59d7ec83b6c2020" have entirely different histories.
8c1663f9c3
...
21012d38c3
@ -47,7 +47,7 @@ class AksesFileController extends Controller
|
|||||||
'pegawai_nama_entry' => auth()->user()?->dataUser?->namalengkap,
|
'pegawai_nama_entry' => auth()->user()?->dataUser?->namalengkap,
|
||||||
'entry_at' => Carbon::now()->format('Y-m-d H:i:s.u'),
|
'entry_at' => Carbon::now()->format('Y-m-d H:i:s.u'),
|
||||||
'all_akses' => $data['akses'] === "all" ? true : false,
|
'all_akses' => $data['akses'] === "all" ? true : false,
|
||||||
'master_akses' => isset($data['master_akses']) ? true : false,
|
'master_akses' => $data['master_akses'] === "yes" ? true : false,
|
||||||
];
|
];
|
||||||
$af = AksesFile::create($payload);
|
$af = AksesFile::create($payload);
|
||||||
if($data['akses'] === "unit"){
|
if($data['akses'] === "unit"){
|
||||||
@ -239,7 +239,7 @@ class AksesFileController extends Controller
|
|||||||
|
|
||||||
public function optionPegawai(){
|
public function optionPegawai(){
|
||||||
$q = request()->get('q');
|
$q = request()->get('q');
|
||||||
$query = DataUser::query();
|
$query = DataUser::where('statusenabled', true);
|
||||||
$data = $query->when($q, function($query, $q){
|
$data = $query->when($q, function($query, $q){
|
||||||
$query->where('nama', 'ILIKE', '%' . $q . '%');
|
$query->where('nama', 'ILIKE', '%' . $q . '%');
|
||||||
})->select('id','nama')->get();
|
})->select('id','nama')->get();
|
||||||
|
|||||||
@ -97,14 +97,17 @@ class DashboardController extends Controller
|
|||||||
$filterUnit = request('unitKerja');
|
$filterUnit = request('unitKerja');
|
||||||
$subUnit = request('subUnit');
|
$subUnit = request('subUnit');
|
||||||
$keyword = request('keyword');
|
$keyword = request('keyword');
|
||||||
$hasKeyword = !empty($keyword);
|
|
||||||
$subArray = $subUnit ? explode(',', $subUnit) : [];
|
$subArray = $subUnit ? explode(',', $subUnit) : [];
|
||||||
$katArray = $kategori ? explode(',', $kategori) : [];
|
$katArray = $kategori ? explode(',', $kategori) : [];
|
||||||
$katDok = MasterKategori::when($katArray, fn($q) => $q->whereIn('master_kategori_directory_id', $katArray))->where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get();
|
$katDok = MasterKategori::when($katArray, fn($q) => $q->whereIn('master_kategori_directory_id', $katArray))->where('statusenabled', true)->select('master_kategori_directory_id', 'nama_kategori_directory')->get();
|
||||||
|
|
||||||
$applyFileFilters = function ($q) use ($keyword, $katArray, $subArray, $entryPegawaiId) {
|
$applyFileFilters = function ($q) use ($keyword, $katArray, $subArray, $entryPegawaiId) {
|
||||||
$q->where(function($subQuery) use ($entryPegawaiId){
|
$q->where(function($subQuery) use ($entryPegawaiId){
|
||||||
$subQuery->where('status_action', '!=', 'rejected')->whereNotNull('status_action');
|
$subQuery->where('status_action', '!=', 'rejected')
|
||||||
|
->orWhere(function ($pending) use ($entryPegawaiId) {
|
||||||
|
$pending->whereNull('status_action')
|
||||||
|
->where('pegawai_id_entry', $entryPegawaiId);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
->when($subArray, fn($sq) => $sq->whereIn('id_sub_unit_kerja', $subArray))
|
->when($subArray, fn($sq) => $sq->whereIn('id_sub_unit_kerja', $subArray))
|
||||||
->when($katArray, fn($sq) => $sq->whereIn('master_kategori_directory_id', $katArray))
|
->when($katArray, fn($sq) => $sq->whereIn('master_kategori_directory_id', $katArray))
|
||||||
@ -155,21 +158,18 @@ class DashboardController extends Controller
|
|||||||
|
|
||||||
} elseif ($aksesAll) {
|
} elseif ($aksesAll) {
|
||||||
/* all akses */
|
/* all akses */
|
||||||
$unitKerja = UnitKerja::where('statusenabled', true)
|
$unitKerja = UnitKerja::where('statusenabled', true)->with([ // muat relasi
|
||||||
->when($hasKeyword, fn($q) => $q->whereHas('subUnitKerja.fileDirectory', fn($f) => $applyFileQuery($f)))
|
'subUnitKerja' => fn($q) => $q->with([ // sub-unit
|
||||||
->with([ // muat relasi
|
'fileDirectory' => fn($f) => $f->whereNotNull('status_action')->when($keyword, fn($q) =>
|
||||||
'subUnitKerja' => fn($q) => $q
|
$q->where('file', 'ilike', "%{$keyword}%")
|
||||||
->when($hasKeyword, fn($sq) => $sq->whereHas('fileDirectory', fn($f) => $applyFileQuery($f)))
|
)
|
||||||
->with([ // sub-unit
|
])
|
||||||
'fileDirectory' => fn($f) => $applyFileQuery($f)
|
|
||||||
])
|
|
||||||
])
|
])
|
||||||
->select('id', 'name')
|
->select('id', 'name')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
} elseif ($allowedUnitIds) {
|
} elseif ($allowedUnitIds) {
|
||||||
$unitKerja = UnitKerja::where('statusenabled', true)
|
$unitKerja = UnitKerja::where('statusenabled', true)
|
||||||
->when($hasKeyword, fn($q) => $q->whereHas('subUnitKerja.fileDirectory', fn($f) => $applyFileQuery($f)))
|
|
||||||
->where(function ($q) use ($allowedUnitIds, $applyFileQuery) {
|
->where(function ($q) use ($allowedUnitIds, $applyFileQuery) {
|
||||||
if ($allowedUnitIds && $allowedUnitIds->isNotEmpty()) {
|
if ($allowedUnitIds && $allowedUnitIds->isNotEmpty()) {
|
||||||
$q->whereIn('id', $allowedUnitIds);
|
$q->whereIn('id', $allowedUnitIds);
|
||||||
@ -185,7 +185,6 @@ class DashboardController extends Controller
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
$unitKerja = UnitKerja::where('statusenabled', true)
|
$unitKerja = UnitKerja::where('statusenabled', true)
|
||||||
->when($hasKeyword, fn($q) => $q->whereHas('subUnitKerja.fileDirectory', fn($f) => $applyFileQuery($f)))
|
|
||||||
->where(function ($q) use ($authUnit, $applyFileQuery) {
|
->where(function ($q) use ($authUnit, $applyFileQuery) {
|
||||||
if ($authUnit) {
|
if ($authUnit) {
|
||||||
$q->where('id', $authUnit);
|
$q->where('id', $authUnit);
|
||||||
@ -193,8 +192,8 @@ class DashboardController extends Controller
|
|||||||
$q->orWhereHas('subUnitKerja.fileDirectory', fn($f) => $applyFileQuery($f));
|
$q->orWhereHas('subUnitKerja.fileDirectory', fn($f) => $applyFileQuery($f));
|
||||||
})
|
})
|
||||||
->with([ // 1. sub-unit milik user
|
->with([ // 1. sub-unit milik user
|
||||||
'subUnitKerja' => fn($q) => $q->where(function ($sq) use ($authSub, $applyFileQuery, $hasKeyword) {
|
'subUnitKerja' => fn($q) => $q->where(function ($sq) use ($authSub, $applyFileQuery) {
|
||||||
if ($authSub && !$hasKeyword) {
|
if ($authSub) {
|
||||||
$sq->where('id', $authSub);
|
$sq->where('id', $authSub);
|
||||||
}
|
}
|
||||||
$sq->orWhereHas('fileDirectory', fn($f) => $applyFileQuery($f));
|
$sq->orWhereHas('fileDirectory', fn($f) => $applyFileQuery($f));
|
||||||
@ -244,24 +243,7 @@ class DashboardController extends Controller
|
|||||||
$file->storeAs($path, $imageName, 'file_directory');
|
$file->storeAs($path, $imageName, 'file_directory');
|
||||||
$payload['file'] =$path .'/' .$imageName;
|
$payload['file'] =$path .'/' .$imageName;
|
||||||
}
|
}
|
||||||
$fd = FileDirectory::create($payload);
|
FileDirectory::create($payload);
|
||||||
|
|
||||||
$payloadLog = [
|
|
||||||
'file_directory_id' => $fd->file_directory_id,
|
|
||||||
'pegawai_id_entry' => $fd->pegawai_id_entry,
|
|
||||||
'pegawai_nama_entry' => $fd->pegawai_nama_entry,
|
|
||||||
'entry_at' => Carbon::now(),
|
|
||||||
'action_type' => 'Upload Dokumen',
|
|
||||||
'statusenabled' => true,
|
|
||||||
'mod_change' => $fd->entry_at,
|
|
||||||
'id_unit_kerja' => $fd->id_unit_kerja,
|
|
||||||
'id_sub_unit_kerja' => $fd->id_sub_unit_kerja,
|
|
||||||
'file' => $fd->file,
|
|
||||||
'tanggal_terbit' => $fd->tanggal_terbit ?? null,
|
|
||||||
'no_dokumen' => $fd->no_dokumen ?? null,
|
|
||||||
'permission_file' => $fd->permission_file ?? null,
|
|
||||||
];
|
|
||||||
LogActivity::create($payloadLog);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,8 +464,12 @@ class DashboardController extends Controller
|
|||||||
$keyword = request('keyword');
|
$keyword = request('keyword');
|
||||||
|
|
||||||
$query = FileDirectory::where('statusenabled', true)
|
$query = FileDirectory::where('statusenabled', true)
|
||||||
->where(function($subQuery){
|
->where(function($subQuery) use ($entryPegawaiId){
|
||||||
$subQuery->where('status_action', '!=', 'rejected')->whereNotNull('status_action');
|
$subQuery->where('status_action', '!=', 'rejected')
|
||||||
|
->orWhere(function ($pending) use ($entryPegawaiId) {
|
||||||
|
$pending->whereNull('status_action')
|
||||||
|
->where('pegawai_id_entry', $entryPegawaiId);
|
||||||
|
});
|
||||||
})->when($keyword, function ($q) use ($keyword) {
|
})->when($keyword, function ($q) use ($keyword) {
|
||||||
$q->where(function ($sub) use ($keyword) {
|
$q->where(function ($sub) use ($keyword) {
|
||||||
$sub->where('file', 'ILIKE', "%{$keyword}%")
|
$sub->where('file', 'ILIKE', "%{$keyword}%")
|
||||||
@ -547,10 +533,7 @@ class DashboardController extends Controller
|
|||||||
if(!$uploadedFile){
|
if(!$uploadedFile){
|
||||||
throw new \RuntimeException('File wajib diunggah pada baris ke-' . ($index+1));
|
throw new \RuntimeException('File wajib diunggah pada baris ke-' . ($index+1));
|
||||||
}
|
}
|
||||||
$unitPegawaiIds = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray();
|
|
||||||
$status = in_array($id_unit_kerja, $unitPegawaiIds)
|
|
||||||
? 'approved'
|
|
||||||
: null;
|
|
||||||
$payload = [
|
$payload = [
|
||||||
'id_unit_kerja' => $id_unit_kerja,
|
'id_unit_kerja' => $id_unit_kerja,
|
||||||
'id_sub_unit_kerja' => $id_sub_unit_kerja,
|
'id_sub_unit_kerja' => $id_sub_unit_kerja,
|
||||||
@ -560,9 +543,6 @@ class DashboardController extends Controller
|
|||||||
'tanggal_terbit' => $data['date_active'] ?? null,
|
'tanggal_terbit' => $data['date_active'] ?? null,
|
||||||
'no_dokumen' => $data['no_dokumen'] ?? null,
|
'no_dokumen' => $data['no_dokumen'] ?? null,
|
||||||
'permission_file' => ($data['is_permission'] ?? null) == "1",
|
'permission_file' => ($data['is_permission'] ?? null) == "1",
|
||||||
'status_action' => $status,
|
|
||||||
'action_by' => $status === "approved" ? auth()->user()->objectpegawaifk : null,
|
|
||||||
'action_at' => $status === "approved" ? now() : null
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$imageName = $uploadedFile->getClientOriginalName();
|
$imageName = $uploadedFile->getClientOriginalName();
|
||||||
@ -576,7 +556,7 @@ class DashboardController extends Controller
|
|||||||
'file_directory_id' => $fd->file_directory_id,
|
'file_directory_id' => $fd->file_directory_id,
|
||||||
'pegawai_id_entry' => $fd->pegawai_id_entry,
|
'pegawai_id_entry' => $fd->pegawai_id_entry,
|
||||||
'pegawai_nama_entry' => $fd->pegawai_nama_entry,
|
'pegawai_nama_entry' => $fd->pegawai_nama_entry,
|
||||||
'entry_at' => now(),
|
'entry_at' => $fd->entry_at,
|
||||||
'action_type' => 'Upload Dokumen',
|
'action_type' => 'Upload Dokumen',
|
||||||
'statusenabled' => true,
|
'statusenabled' => true,
|
||||||
'mod_change' => $fd->entry_at,
|
'mod_change' => $fd->entry_at,
|
||||||
@ -902,7 +882,7 @@ class DashboardController extends Controller
|
|||||||
}
|
}
|
||||||
$data->update([
|
$data->update([
|
||||||
'status_action' => 'approved',
|
'status_action' => 'approved',
|
||||||
'action_at' => now(),
|
'action_at' => Carbon::now(),
|
||||||
'action_by' => auth()->user()->dataUser->id,
|
'action_by' => auth()->user()->dataUser->id,
|
||||||
]);
|
]);
|
||||||
$payloadLog = [
|
$payloadLog = [
|
||||||
@ -944,7 +924,7 @@ class DashboardController extends Controller
|
|||||||
}
|
}
|
||||||
$data->update([
|
$data->update([
|
||||||
'status_action' => 'rejected',
|
'status_action' => 'rejected',
|
||||||
'action_at' => now(),
|
'action_at' => Carbon::now(),
|
||||||
'action_by' => auth()->user()->dataUser->id,
|
'action_by' => auth()->user()->dataUser->id,
|
||||||
]);
|
]);
|
||||||
$payloadLog = [
|
$payloadLog = [
|
||||||
@ -993,62 +973,4 @@ class DashboardController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pengajuanFile(){
|
|
||||||
return view('pengajuanFile.index', ['title' => 'Data Pending']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dataPengajuanFile(){
|
|
||||||
$perPage = (int) request('per_page', 10);
|
|
||||||
$keyword = request('keyword');
|
|
||||||
$start = request('start_date');
|
|
||||||
$end = request('end_date');
|
|
||||||
$query = FileDirectory::where('statusenabled', true)->where('pegawai_id_entry', auth()->user()->objectpegawaifk)
|
|
||||||
->where(function($q){
|
|
||||||
$q->where('status_action', '!=', 'approved')
|
|
||||||
->orWhereNull('status_action');
|
|
||||||
})->orderBy('entry_at','desc');
|
|
||||||
if($keyword){
|
|
||||||
$query->where(function($q) use ($keyword){
|
|
||||||
$q->where('file', 'ILIKE', "%{$keyword}%")
|
|
||||||
->orWhere('no_dokumen', 'ILIKE', "%{$keyword}%");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if($start){
|
|
||||||
$query->whereDate('entry_at','>=',$start);
|
|
||||||
}
|
|
||||||
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)));
|
|
||||||
return [
|
|
||||||
'file_directory_id' => $item->file_directory_id,
|
|
||||||
'pegawai_nama_entry' => $item->pegawai_nama_entry,
|
|
||||||
'part' => $dataSlice[0] . '/' . $dataSlice[1],
|
|
||||||
'folder' => $dataSlice[2],
|
|
||||||
'fileName' =>$dataSlice[3],
|
|
||||||
'file' => $item->file,
|
|
||||||
'no_dokumen' => $item->no_dokumen,
|
|
||||||
'entry_at' => $item->entry_at,
|
|
||||||
'tanggal_terbit' => $item->tanggal_terbit,
|
|
||||||
'permission_file' => $item->permission_file,
|
|
||||||
'status_action' => $item->status_action
|
|
||||||
];
|
|
||||||
});
|
|
||||||
return response()->json([
|
|
||||||
'status' => true,
|
|
||||||
'data' => $data,
|
|
||||||
'pagination' => [
|
|
||||||
'current_page' => $paginated->currentPage(),
|
|
||||||
'next_page' => $paginated->hasMorePages() ? $paginated->currentPage() + 1 : null,
|
|
||||||
'has_more' => $paginated->hasMorePages(),
|
|
||||||
'last_page' => $paginated->lastPage(),
|
|
||||||
'per_page' => $paginated->perPage(),
|
|
||||||
'total' => $paginated->total(),
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'timezone' => env('APP_TIMEZONE'),
|
'timezone' => 'UTC',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
@ -1,230 +0,0 @@
|
|||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
const tableState = { data: [], page: 1, pageSize: 10, search: '', lastPage: 1, total: 0, startDate: '', endDate: '' };
|
|
||||||
const tbody = document.getElementById('tablePengajuanFile');
|
|
||||||
const paginationEl = document.getElementById('paginationControls');
|
|
||||||
const summaryEl = document.getElementById('tableSummary');
|
|
||||||
const pageSizeSelect = document.getElementById('tablePageSize');
|
|
||||||
const startDateInput = document.getElementById('startDate');
|
|
||||||
const endDateInput = document.getElementById('endDate');
|
|
||||||
|
|
||||||
if (pageSizeSelect) {
|
|
||||||
const initialSize = parseInt(pageSizeSelect.value);
|
|
||||||
if (!isNaN(initialSize)) tableState.pageSize = initialSize;
|
|
||||||
pageSizeSelect.addEventListener('change', (e) => {
|
|
||||||
const val = parseInt(e.target.value);
|
|
||||||
if (!isNaN(val) && val > 0) {
|
|
||||||
tableState.pageSize = val;
|
|
||||||
tableState.page = 1;
|
|
||||||
fetchData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
window.applyDateFilter = function(){
|
|
||||||
tableState.startDate = startDateInput.value || '';
|
|
||||||
tableState.endDate = endDateInput.value || '';
|
|
||||||
tableState.page = 1;
|
|
||||||
fetchData();
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatTanggal(dateString) {
|
|
||||||
if (!dateString) return '-';
|
|
||||||
const d = new Date(dateString);
|
|
||||||
return d.toLocaleDateString('id-ID', {
|
|
||||||
day: '2-digit',
|
|
||||||
month: 'short',
|
|
||||||
year: 'numeric',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildRow(item){
|
|
||||||
let tanggal = item.entry_at ? formatTanggal(item.entry_at) : '-';
|
|
||||||
const aksi = `
|
|
||||||
<div class="d-flex gap-1">
|
|
||||||
<button class="btn btn-sm btn-success" onclick="approvePending('${item.file_directory_id}', '${item.fileName || ''}')">
|
|
||||||
<i class="fa-solid fa-check"></i>
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-sm btn-danger" onclick="rejectPending('${item.file_directory_id}', '${item.fileName || ''}')">
|
|
||||||
<i class="fa-solid fa-xmark"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
return `
|
|
||||||
<tr>
|
|
||||||
<td>${item.no_dokumen || '-'}</td>
|
|
||||||
<td>
|
|
||||||
<button class="btn btn-sm ${item?.status_action !== "rejected" ? 'btn-warning' : 'btn-danger'} btn-warning ">
|
|
||||||
${item?.status_action !== "rejected" ? 'Pending' : 'Rejected'}
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
<td><a href="#" class="file-link"
|
|
||||||
data-file="${item.file}"
|
|
||||||
data-fileName="${item.fileName}"
|
|
||||||
data-id="${item.file_directory_id}"
|
|
||||||
data-no_dokumen="${item.no_dokumen || '-'}"
|
|
||||||
data-tanggal_terbit="${item.tanggal_terbit || '-'}"
|
|
||||||
data-permission_file="${item.permission_file || '-'}">${item.fileName}</a></td>
|
|
||||||
<td>${item.folder || '-'}</td>
|
|
||||||
<td>${item.part || '-'}</td>
|
|
||||||
<td class="text-nowrap">${tanggal}</td>
|
|
||||||
</tr>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderPagination(totalPages){
|
|
||||||
if (!paginationEl) return;
|
|
||||||
if (totalPages <= 1) {
|
|
||||||
paginationEl.innerHTML = '';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const maxButtons = 5;
|
|
||||||
let start = Math.max(1, tableState.page - Math.floor(maxButtons/2));
|
|
||||||
let end = Math.min(totalPages, start + maxButtons - 1);
|
|
||||||
start = Math.max(1, end - maxButtons + 1);
|
|
||||||
|
|
||||||
let buttons = '';
|
|
||||||
buttons += `<button class="btn btn-outline-secondary btn-sm" data-page="prev" ${tableState.page === 1 ? 'disabled' : ''}>‹</button>`;
|
|
||||||
for (let i = start; i <= end; i++) {
|
|
||||||
buttons += `<button class="btn btn-sm ${i === tableState.page ? 'btn-primary' : 'btn-outline-secondary'}" data-page="${i}">${i}</button>`;
|
|
||||||
}
|
|
||||||
buttons += `<button class="btn btn-outline-secondary btn-sm" data-page="next" ${tableState.page === totalPages ? 'disabled' : ''}>›</button>`;
|
|
||||||
|
|
||||||
paginationEl.innerHTML = `
|
|
||||||
<div class="d-flex align-items-center gap-2 flex-wrap">
|
|
||||||
<div class="btn-group" role="group">${buttons}</div>
|
|
||||||
<span class="small text-muted">Halaman ${tableState.page} dari ${totalPages}</span>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paginationEl) {
|
|
||||||
paginationEl.addEventListener('click', (e) => {
|
|
||||||
const page = e.target.getAttribute('data-page');
|
|
||||||
if (!page) return;
|
|
||||||
if (page === 'prev' && tableState.page > 1) tableState.page--;
|
|
||||||
else if (page === 'next') {
|
|
||||||
if (tableState.page < tableState.lastPage) tableState.page++;
|
|
||||||
} else {
|
|
||||||
tableState.page = parseInt(page);
|
|
||||||
}
|
|
||||||
fetchData();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderTable(){
|
|
||||||
const pageData = tableState.data || [];
|
|
||||||
if (pageData.length === 0) {
|
|
||||||
tbody.innerHTML = `
|
|
||||||
<tr>
|
|
||||||
<td colspan="7" class="text-center text-muted py-4">
|
|
||||||
Tidak ada data
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
`;
|
|
||||||
} else {
|
|
||||||
tbody.innerHTML = pageData.map(buildRow).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
const from = tableState.total === 0 ? 0 : ((tableState.page - 1) * tableState.pageSize) + 1;
|
|
||||||
const to = Math.min(((tableState.page - 1) * tableState.pageSize) + pageData.length, tableState.total);
|
|
||||||
if (summaryEl) {
|
|
||||||
summaryEl.textContent = tableState.total ? `Menampilkan ${from} - ${to} dari ${tableState.total} data` : 'Tidak ada data';
|
|
||||||
}
|
|
||||||
|
|
||||||
renderPagination(tableState.lastPage || 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let searchDebounce;
|
|
||||||
window.debouncedTableSearch = function(value){
|
|
||||||
clearTimeout(searchDebounce);
|
|
||||||
searchDebounce = setTimeout(() => {
|
|
||||||
tableState.search = value.trim();
|
|
||||||
tableState.page = 1;
|
|
||||||
fetchData();
|
|
||||||
}, 250);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.refreshLog = function(){
|
|
||||||
tableState.search = '';
|
|
||||||
tableState.startDate = '';
|
|
||||||
tableState.endDate = '';
|
|
||||||
document.getElementById('tableSearch').value = '';
|
|
||||||
startDateInput.value = '';
|
|
||||||
endDateInput.value = '';
|
|
||||||
tableState.page = 1;
|
|
||||||
fetchData();
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchData(){
|
|
||||||
if (summaryEl) summaryEl.textContent = 'Memuat data...';
|
|
||||||
const params = new URLSearchParams({
|
|
||||||
page: tableState.page,
|
|
||||||
per_page: tableState.pageSize,
|
|
||||||
keyword: tableState.search || '',
|
|
||||||
start_date: tableState.startDate || '',
|
|
||||||
end_date: tableState.endDate || ''
|
|
||||||
});
|
|
||||||
fetch(`/datatable/pengajuan-file?${params.toString()}`)
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(data => {
|
|
||||||
tableState.data = data?.data || [];
|
|
||||||
tableState.lastPage = data?.pagination?.last_page || 1;
|
|
||||||
tableState.total = data?.pagination?.total || 0;
|
|
||||||
renderTable();
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err);
|
|
||||||
if (summaryEl) summaryEl.textContent = 'Gagal memuat data';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchData();
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
document.addEventListener('click', function(e){
|
|
||||||
if(e.target.matches('.file-link')){
|
|
||||||
e.preventDefault();
|
|
||||||
let fileUrl = e.target.getAttribute('data-file');
|
|
||||||
let noDokumen = e.target.getAttribute('data-no_dokumen')
|
|
||||||
let tanggalTerbit = e.target.getAttribute('data-tanggal_terbit')
|
|
||||||
let permissionFile = e.target.getAttribute('data-permission_file')
|
|
||||||
let fileName = e.target.getAttribute('data-fileName')
|
|
||||||
currentFile = fileUrl;
|
|
||||||
idDirectory = e.target.getAttribute('data-id');
|
|
||||||
|
|
||||||
|
|
||||||
const titleEl = document.getElementById('confirm_preview_file');
|
|
||||||
if (titleEl) titleEl.textContent = fileName;
|
|
||||||
|
|
||||||
// set footer info
|
|
||||||
const noEl = document.getElementById('confirm-upload-dokumen');
|
|
||||||
if (noEl) noEl.textContent = noDokumen;
|
|
||||||
|
|
||||||
const tglEl = document.getElementById('confirm-time-dokumen');
|
|
||||||
|
|
||||||
if (tglEl) tglEl.textContent = tanggalTerbit;
|
|
||||||
|
|
||||||
const permEl = document.getElementById('confirm-permission');
|
|
||||||
if (permEl) {
|
|
||||||
const publicDoc = isPublic(permissionFile);
|
|
||||||
permEl.textContent = publicDoc ? 'Bisa dilihat unit lain' : 'Hanya unit ini';
|
|
||||||
permEl.className = 'badge ' + (publicDoc ? 'bg-success' : 'bg-secondary');
|
|
||||||
}
|
|
||||||
let previewBox = document.getElementById('file-preview');
|
|
||||||
previewBox.innerHTML = `<iframe src="/file-preview/${idDirectory}" width="100%" height="500px" style="border:none;"></iframe>`;
|
|
||||||
$("#previewModal").modal('show')
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(e.target.matches('#btn-view-full')){
|
|
||||||
window.open(`/file-preview/${idDirectory}`, '_blank');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
function isPublic(permissionVal){
|
|
||||||
if(permissionVal === null || permissionVal === undefined) return false;
|
|
||||||
const val = String(permissionVal).toLowerCase();
|
|
||||||
return val === '1' || val === 'true' || val === 'iya' || val === 'yes';
|
|
||||||
}
|
|
||||||
@ -44,7 +44,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label class="form-label fw-semibold">Tanggal Terbit</label>
|
<label class="form-label fw-semibold">Tanggal Terbit</label>
|
||||||
<input class="form-control" type="date" name="data[0][date_active]">
|
<input class="form-control" type="date" name="data[0][date_active]" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label class="form-label fw-semibold">Boleh dilihat unit lain? <span class="text-danger">*</span></label>
|
<label class="form-label fw-semibold">Boleh dilihat unit lain? <span class="text-danger">*</span></label>
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label class="form-label fw-semibold">Tanggal Terbit</label>
|
<label class="form-label fw-semibold">Tanggal Terbit</label>
|
||||||
<input class="form-control" type="date" name="data[0][date_active]">
|
<input class="form-control" type="date" name="data[0][date_active]" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<label class="form-label fw-semibold">Boleh dilihat unit lain? <span class="text-danger">*</span></label>
|
<label class="form-label fw-semibold">Boleh dilihat unit lain? <span class="text-danger">*</span></label>
|
||||||
|
|||||||
@ -62,17 +62,6 @@
|
|||||||
<span class="badge bg-danger rounded-pill d-none" id="pendingCountBadge">0</span>
|
<span class="badge bg-danger rounded-pill d-none" id="pendingCountBadge">0</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@else
|
|
||||||
<li class="sidebar-item">
|
|
||||||
<a class="sidebar-link d-flex align-items-center justify-content-between"
|
|
||||||
href="{{ url('/pengajuan-file') }}" aria-expanded="false">
|
|
||||||
|
|
||||||
<div class="d-flex align-items-center gap-3">
|
|
||||||
<i class="ti ti-clock"></i>
|
|
||||||
<span class="hide-menu">Pengajuan</span>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
@endif
|
@endif
|
||||||
{{-- RECAP --}}
|
{{-- RECAP --}}
|
||||||
<li class="nav-small-cap"><span class="hide-menu">Recap</span></li>
|
<li class="nav-small-cap"><span class="hide-menu">Recap</span></li>
|
||||||
|
|||||||
@ -1,68 +0,0 @@
|
|||||||
@extends('layout.main')
|
|
||||||
@section('body_main')
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header d-flex align-items-center justify-content-between">
|
|
||||||
<h4 class="mb-0">Data Pending</h4>
|
|
||||||
</div>
|
|
||||||
<div class="card-body p-3">
|
|
||||||
<div class="d-flex flex-column flex-md-row align-items-md-center gap-2 mb-3 flex-wrap">
|
|
||||||
<div class="input-group input-group-sm flex-grow-1" style="max-width:320px;">
|
|
||||||
<span class="input-group-text bg-white border-end-0">
|
|
||||||
<i class="fa fa-search text-muted"></i>
|
|
||||||
</span>
|
|
||||||
<input type="search"
|
|
||||||
id="tableSearch"
|
|
||||||
class="form-control border-start-0"
|
|
||||||
placeholder="Cari nama file / nomor dokumen"
|
|
||||||
oninput="debouncedTableSearch(this.value)">
|
|
||||||
</div>
|
|
||||||
<div class="d-flex align-items-center gap-2">
|
|
||||||
<label class="small mb-0 text-muted">Mulai</label>
|
|
||||||
<input type="date" id="startDate" class="form-control form-control-sm" onchange="applyDateFilter()">
|
|
||||||
</div>
|
|
||||||
<div class="d-flex align-items-center gap-2">
|
|
||||||
<label class="small mb-0 text-muted">Selesai</label>
|
|
||||||
<input type="date" id="endDate" class="form-control form-control-sm" onchange="applyDateFilter()">
|
|
||||||
</div>
|
|
||||||
<div class="d-flex align-items-center gap-2">
|
|
||||||
<select id="tablePageSize" class="form-select form-select-sm" style="width: auto;">
|
|
||||||
<option value="5">5</option>
|
|
||||||
<option value="10"selected>10</option>
|
|
||||||
<option value="20">20</option>
|
|
||||||
<option value="50">50</option>
|
|
||||||
<option value="100">100</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<button class="btn btn-outline-secondary btn-sm" onclick="refreshLog()">
|
|
||||||
<i class="fa fa-rotate"></i> Refresh
|
|
||||||
</button>
|
|
||||||
<div class="small text-muted ms-md-auto" id="tableSummary"></div>
|
|
||||||
</div>
|
|
||||||
<div class="table-responsive" style="max-height: 55vh; overflow-y:auto;">
|
|
||||||
<table class="table table-sm table-hover align-middle mb-0" id="lastUpdatedTable">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>No Dokumen</th>
|
|
||||||
<th>Status</th>
|
|
||||||
<th>File</th>
|
|
||||||
<th>Folder</th>
|
|
||||||
<th>Unit/Sub Unit</th>
|
|
||||||
<th>Tanggal</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="tablePengajuanFile">
|
|
||||||
<!-- data dari fetch masuk sini -->
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex flex-column flex-md-row align-items-md-center justify-content-between gap-2 mt-3" id="paginationControls"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@include('pendingFile.modal.view')
|
|
||||||
<script src="{{ ver('/js/pengajuanFile/index.js') }}"></script>
|
|
||||||
@endsection
|
|
||||||
@ -48,8 +48,6 @@ Route::middleware(['auth'])->group(function(){
|
|||||||
Route::get('/data/recap', [DashboardController::class, 'recapData']);
|
Route::get('/data/recap', [DashboardController::class, 'recapData']);
|
||||||
|
|
||||||
|
|
||||||
Route::get('/pengajuan-file', [DashboardController::class, 'pengajuanFile']);
|
|
||||||
Route::get('/datatable/pengajuan-file', [DashboardController::class, 'dataPengajuanFile']);
|
|
||||||
|
|
||||||
Route::middleware(['master.persetujuan'])->group(function () {
|
Route::middleware(['master.persetujuan'])->group(function () {
|
||||||
Route::get('/pending-file', [DashboardController::class, 'pendingFile']);
|
Route::get('/pending-file', [DashboardController::class, 'pendingFile']);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user