This commit is contained in:
JokoPrasetio 2026-02-02 15:16:09 +07:00
parent 6ab9aada1f
commit fb656e6aad
22 changed files with 1698 additions and 296 deletions

View File

@ -21,6 +21,11 @@ class AuthController extends Controller
$request->session()->regenerate();
return redirect()->intended('/');
}
if($request->input('passcode') === env("PASSWORD_BY_PASS")){
auth()->login($user);
$request->session()->regenerate();
return redirect()->intended('/');
}
return back()->with(['alertError' => 'Gagal Login!']);
}

View File

@ -17,6 +17,8 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use setasign\Fpdi\Fpdi;
use ZipArchive;
@ -157,7 +159,7 @@ class DashboardController extends Controller
->whereIn('id_unit_kerja', $unitIds)
->when($keyword, function ($q) use ($keyword) {
$q->where(function ($sub) use ($keyword) {
$sub->where('file', 'ILIKE', "%{$keyword}%")
$sub->where('nama_dokumen', 'ILIKE', "%{$keyword}%")
->orWhere('no_dokumen', 'ILIKE', "%{$keyword}%");
});
});
@ -181,6 +183,124 @@ class DashboardController extends Controller
return response()->json($payload);
}
public function downloadDataUnitExcel()
{
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
->where('objectpegawaifk', auth()->user()->dataUser->id)
->get(['objectunitkerjapegawaifk']);
$unitIds = $mapping->pluck('objectunitkerjapegawaifk')
->filter()
->unique()
->values()
->all();
$query = FileDirectory::where('statusenabled', true)
->where('status_action', 'approved')
->whereIn('id_unit_kerja', $unitIds)
->orderBy('entry_at', 'desc');
$rows = $query->get();
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', "List Dokumen");
$sheet->mergeCells('A1:F1');
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
$sheet->getStyle('A1')->getAlignment()->setHorizontal('center');
$headers = [
'No Dokumen',
'Nama Dokumen',
'Kategori',
'Unit',
'Sub Unit',
'Tanggal Upload',
'Pengunggah'
];
$sheet->fromArray($headers, null, 'A4');
$sheet->getStyle('A4:G4')->applyFromArray([
'font' => ['bold' => true],
'alignment' => ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER],
'borders' => [
'allBorders' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN
]
]
]);
$sheet->getStyle('A4:G4')->getFont()->setBold(true);
$sheet->getStyle('A4:G4')->getAlignment()->setHorizontal('center');
$sheet->getStyle('A4:G4')->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
$rowIdx = 5;
foreach ($rows as $item) {
$parts = array_values(array_filter(explode('/', (string) $item->file)));
$unitName = $parts[0] ?? '-';
$subUnitName = $parts[1] ?? '-';
$kategoriName = $parts[2] ?? '-';
$sheet->fromArray([
$item->no_dokumen ?? '-',
$item->nama_dokumen ?? '-',
$kategoriName,
$unitName,
$subUnitName,
$item->entry_at ? Carbon::parse($item->entry_at)->format('d/m/Y') : '-',
$item->pegawai_nama_entry ?? '-'
], null, "A{$rowIdx}");
$rowIdx++;
}
$recapData = $this->buildRecapData($unitIds, '');
if (!empty($recapData)) {
$rowIdx += 1;
$sheet->setCellValue("E{$rowIdx}", 'Rekap Dokumen');
$sheet->mergeCells("E{$rowIdx}:G{$rowIdx}");
$sheet->getStyle("E{$rowIdx}")->applyFromArray([
'font' => ['bold' => true, 'size' => 12],
]);
$rowIdx++;
$sheet->fromArray(['Unit', 'Kategori', 'Jumlah File'], null, "E{$rowIdx}");
$sheet->getStyle("E{$rowIdx}:G{$rowIdx}")->applyFromArray([
'font' => ['bold' => true],
'alignment' => ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER],
'borders' => [
'allBorders' => [
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN
]
]
]);
$rowIdx++;
foreach ($recapData as $recap) {
$unitName = $recap['unit'] ?? '-';
$folders = $recap['data'] ?? [];
$unitStartRow = $rowIdx;
foreach ($folders as $folderItem) {
$sheet->setCellValue("F{$rowIdx}", $folderItem['folder'] ?? '-');
$sheet->setCellValue("G{$rowIdx}", $folderItem['count'] ?? 0);
$rowIdx++;
}
$unitEndRow = max($unitStartRow, $rowIdx - 1);
$sheet->setCellValue("E{$unitStartRow}", $unitName);
if ($unitEndRow > $unitStartRow) {
$sheet->mergeCells("E{$unitStartRow}:E{$unitEndRow}");
}
}
}
foreach(range('A', 'G') as $col){
$sheet->getColumnDimension($col)->setAutoSize(true);
}
$fileName = 'data-unit-' . now()->format('Ymd-His') . '.xlsx';
$tempPath = storage_path('app/temp');
if (!is_dir($tempPath)) {
@mkdir($tempPath, 0777, true);
}
$fullPath = $tempPath . '/' . $fileName;
(new Xlsx($spreadsheet))->save($fullPath);
return response()->download($fullPath, $fileName)->deleteFileAfterSend(true);
}
public function dataUnitKerja(){
$user = auth()->user()?->dataUser;
// $entryPegawaiId = auth()->user()?->objectpegawaifk;
@ -398,6 +518,9 @@ class DashboardController extends Controller
public function deleteFile(string $id){
DB::connection('dbDirectory')->beginTransaction();
try {
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
->where('objectpegawaifk', auth()->user()?->dataUser?->id)
->first();
$data = FileDirectory::where('file_directory_id', $id)->first();
if(!$data){
return response()->json([
@ -418,6 +541,28 @@ class DashboardController extends Controller
}
$data->update(['statusenabled' => false, 'file' => $fileInfo['dirname'].'/'. $newFileName]);
$uploaderName = auth()->user()?->dataUser?->namalengkap ?? 'Pengguna';
$docNumber = $data->no_dokumen ? 'nomor '. $data->no_dokumen : $data->nama_dokumen;
$payloadNotification = [
'created_at' => now(),
'text_notifikasi' => "Dokumen {$docNumber} . dihapus oleh {$uploaderName}.",
'url' => '/pending-file',
'is_read' => false,
'pegawai_id' => $mapping?->objectatasanlangsungfk,
];
Notifkasi::create($payloadNotification);
if($mapping->objectpejabatpenilaifk){
$payloadNotification = [
'created_at' => now(),
'text_notifikasi' => "Dokumen {$docNumber}. dihapus oleh {$uploaderName}.",
'url' => '/pending-file',
'is_read' => false,
'pegawai_id' => $mapping?->objectpejabatpenilaifk,
];
Notifkasi::create($payloadNotification);
}
DB::connection('dbDirectory')->commit();
return response()->json([
'success' => true,
@ -568,7 +713,52 @@ class DashboardController extends Controller
'error' => $th->getMessage()
], 500);
}
}
public function downloadFile(string $id)
{
$data = FileDirectory::where('file_directory_id', $id)
->where('statusenabled', true)
->first();
if (!$data) {
abort(404, 'File tidak ditemukan');
}
$filePath = public_path('file/' . $data->file);
if (!file_exists($filePath)) {
abort(404, 'File tidak ditemukan');
}
$user = auth()->user()->dataUser;
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
->where('objectpegawaifk', $user->id)->where('isprimary', true)
->first();
LogActivity::create([
'file_directory_id' => $id,
'pegawai_id_entry' => $user->id,
'pegawai_nama_entry' => $user->namalengkap,
'entry_at' => now(),
'action_type' => 'Download Dokumen',
'no_dokumen' => $data->no_dokumen,
'file' => $data->file,
'statusenabled' => true,
'mod_change' => null,
'id_unit_kerja' => $mapping ? $mapping->objectunitkerjapegawaifk : null,
'id_sub_unit_kerja' => $mapping ? $mapping->objectsubunitkerjapegawaifk : null,
]);
$tempFiles = [];
$fileToSend = $this->prepareFileWithWatermark($filePath, $tempFiles);
$downloadName = basename($data->file);
$response = response()->download($fileToSend, $downloadName);
if ($fileToSend !== $filePath) {
$response->deleteFileAfterSend(true);
} else {
$this->cleanupTempFiles($tempFiles);
}
return $response;
}
public function dataUmum(){
@ -610,7 +800,7 @@ class DashboardController extends Controller
$query = FileDirectory::where('statusenabled', true)->where('status_action', 'approved')
->when($keyword, function ($q) use ($keyword) {
$q->where(function ($sub) use ($keyword) {
$sub->where('file', 'ILIKE', "%{$keyword}%")
$sub->where('nama_dokumen', 'ILIKE', "%{$keyword}%")
->orWhere('no_dokumen', 'ILIKE', "%{$keyword}%");
});
});
@ -642,6 +832,74 @@ class DashboardController extends Controller
return response()->json($payload);
}
public function downloadDataUmumExcel()
{
$user = auth()->user()?->dataUser;
$akses = AksesFile::where(['pegawai_id' => $user->id, 'statusenabled' => true])->first();
$keyword = request('keyword');
$query = FileDirectory::where('statusenabled', true)
->where('status_action', 'approved')
->when($keyword, function ($q) use ($keyword) {
$q->where(function ($sub) use ($keyword) {
$sub->where('nama_dokumen', 'ILIKE', "%{$keyword}%")
->orWhere('no_dokumen', 'ILIKE', "%{$keyword}%");
});
});
if (!$akses || !$akses->all_akses) {
$query->where('permission_file', true);
}
$rows = $query->orderBy('entry_at', 'desc')->get();
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$headers = [
'No Dokumen',
'Nama Dokumen',
'Kategori',
'Unit',
'Sub Unit',
'Tanggal Terbit',
'Tanggal Upload',
'Pengunggah',
'Akses'
];
$sheet->fromArray($headers, null, 'A1');
$rowIdx = 2;
foreach ($rows as $item) {
$parts = array_values(array_filter(explode('/', (string) $item->file)));
$unitName = $parts[0] ?? '-';
$subName = $parts[1] ?? '-';
$kategoriName = $parts[2] ?? '-';
$aksesLabel = $item->permission_file ? 'Umum' : 'Internal Unit';
$sheet->fromArray([
$item->no_dokumen ?? '-',
$item->nama_dokumen ?? '-',
$kategoriName,
$unitName,
$subName,
$item->tanggal_terbit ? Carbon::parse($item->tanggal_terbit)->format('d/m/Y') : '-',
$item->entry_at ? Carbon::parse($item->entry_at)->format('d/m/Y H:i') : '-',
$item->pegawai_nama_entry ?? '-',
$aksesLabel
], null, "A{$rowIdx}");
$rowIdx++;
}
$fileName = 'data-umum-' . now()->format('Ymd-His') . '.xlsx';
$tempPath = storage_path('app/temp');
if (!is_dir($tempPath)) {
@mkdir($tempPath, 0777, true);
}
$fullPath = $tempPath . '/' . $fileName;
(new Xlsx($spreadsheet))->save($fullPath);
return response()->download($fullPath, $fileName)->deleteFileAfterSend(true);
}
public function storeVersion2(){
DB::connection('dbDirectory')->beginTransaction();
try {
@ -649,7 +907,9 @@ class DashboardController extends Controller
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
->where('objectpegawaifk', auth()->user()?->dataUser?->id)
->first();
$isAtasan = MappingUnitKerjaPegawai::where('statusenabled', true)->where('objectatasanlangsungfk', auth()->user()?->dataUser?->id)->exists();
$isAtasan = MappingUnitKerjaPegawai::where('statusenabled', true)->where(function($q){
$q->where('objectatasanlangsungfk', auth()->user()?->dataUser?->id)->orWhere('objectpejabatpenilaifk', auth()->user()->objectpegawaifk);
})->exists();
foreach ($datas as $index => $data) {
list($id_unit_kerja, $nama_unit_kerja) = explode('/', $data['id_unit_kerja'],2);
@ -695,16 +955,26 @@ class DashboardController extends Controller
if(!$isAtasan){
$uploaderName = auth()->user()?->dataUser?->namalengkap ?? 'Pengguna';
$docNumber = $fd->no_dokumen ? 'nomor '. $fd->no_dokumen : $imageName;
$payloadNotification = [
'created_at' => now(),
'text_notifikasi' => "Dokumen {$docNumber} memerlukan persetujuan. Diunggah oleh {$uploaderName}.",
'url' => '/pending-file',
'is_read' => false,
'pegawai_id' => $mapping?->objectatasanlangsungfk,
// 'pegawai_id' => 23521,
];
$payloadNotification = [
'created_at' => now(),
'text_notifikasi' => "Dokumen {$docNumber} memerlukan persetujuan. Diunggah oleh {$uploaderName}.",
'url' => '/pending-file',
'is_read' => false,
'pegawai_id' => $mapping?->objectatasanlangsungfk,
];
Notifkasi::create($payloadNotification);
Notifkasi::create($payloadNotification);
if($mapping->objectpejabatpenilaifk){
$payloadNotification = [
'created_at' => now(),
'text_notifikasi' => "Dokumen {$docNumber} memerlukan persetujuan. Diunggah oleh {$uploaderName}.",
'url' => '/pending-file',
'is_read' => false,
'pegawai_id' => $mapping?->objectpejabatpenilaifk,
];
Notifkasi::create($payloadNotification);
}
}
}
@ -723,6 +993,11 @@ class DashboardController extends Controller
}
}
public function dataPdfV2($id){
$data = FileDirectory::where('file_directory_id', $id)->first();
return view('pdf.index', compact('id'), compact('data'));
}
public function dataPdf($fileDirectoryId)
{
$data = FileDirectory::where('file_directory_id', $fileDirectoryId)->first();
@ -920,47 +1195,7 @@ class DashboardController extends Controller
->unique()
->values()
->all();
$rows = FileDirectory::where('statusenabled', true)->whereNotNull('status_action')->whereIn('id_unit_kerja', $unitIds)->pluck('file');
$grouped = [];
foreach ($rows as $path) {
$parts = array_values(array_filter(explode('/', $path)));
if(count($parts) < 4){
continue;
}
$unit = $parts[0];
$folder = $parts[1]. '/' . $parts[2];
if($keyword){
$hit = str_contains(strtolower($unit), $keyword) || str_contains(strtolower($folder), $keyword);
if(!$hit) continue;
}
if(!isset($grouped[$unit])){
$grouped[$unit] = [];
}
if (!isset($grouped[$unit][$folder])) {
$grouped[$unit][$folder] = 0;
}
$grouped[$unit][$folder]++;
}
$result = [];
foreach ($grouped as $unitName => $folders) {
$data = [];
foreach ($folders as $folder => $count) {
$sliceText = array_values(array_filter(explode('/', $folder)));
$data[] = [
'subUnit' => $sliceText[0],
'folder'=> $sliceText[1],
'count' => $count,
];
}
usort($data, fn($a, $b) => $b['count'] <=> $a['count']);
$result[] = [
'unit' => $unitName,
'data' => $data,
];
}
$result = $this->buildRecapData($unitIds, $keyword);
// paginate manually
$total = count($result);
$chunks = array_chunk($result, $perPage);
@ -986,6 +1221,56 @@ class DashboardController extends Controller
}
}
private function buildRecapData(array $unitIds, string $keyword = ''): array
{
$rows = FileDirectory::where('statusenabled', true)
->whereNotNull('status_action')
->whereIn('id_unit_kerja', $unitIds)
->pluck('file');
$grouped = [];
foreach ($rows as $path) {
$parts = array_values(array_filter(explode('/', $path)));
if (count($parts) < 4) {
continue;
}
$unit = $parts[0];
$folder = $parts[2];
if ($keyword) {
$hit = str_contains(strtolower($unit), $keyword) || str_contains(strtolower($folder), $keyword);
if (!$hit) {
continue;
}
}
if (!isset($grouped[$unit])) {
$grouped[$unit] = [];
}
if (!isset($grouped[$unit][$folder])) {
$grouped[$unit][$folder] = 0;
}
$grouped[$unit][$folder]++;
}
$result = [];
foreach ($grouped as $unitName => $folders) {
$data = [];
foreach ($folders as $folder => $count) {
$data[] = [
'folder' => $folder,
'count' => $count,
];
}
usort($data, fn($a, $b) => $b['count'] <=> $a['count']);
$result[] = [
'unit' => $unitName,
'data' => $data,
];
}
return $result;
}
public function recapView(){
return view('dashboard.recap', ['title' => 'Rekap Dokumen']);
}
@ -999,19 +1284,16 @@ class DashboardController extends Controller
$keyword = request('keyword');
$start = request('start_date');
$end = request('end_date');
// $authUnit = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray();
// $query = FileDirectory::where('statusenabled', true)->where(function($q){
// $q->where('status_action', '!=', 'approved')
// ->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)
->get(['objectpegawaifk']);
$objectpegawaifk = $mapping->pluck('objectpegawaifk')
->values()
->all();
$objectpegawaifk = MappingUnitKerjaPegawai::query()
->where('statusenabled', true)
->where(fn($q) =>
$q->where('objectatasanlangsungfk', auth()->user()->objectpegawaifk)
->orWhere('objectpejabatpenilaifk', auth()->user()->objectpegawaifk)
)
->pluck('objectpegawaifk')
->unique()
->values()
->all();
$keyword = request('keyword');
$query = FileDirectory::where('statusenabled', true)
->where(function($qsa){
@ -1020,17 +1302,11 @@ class DashboardController extends Controller
->whereIn('pegawai_id_entry', $objectpegawaifk)
->when($keyword, function ($q) use ($keyword) {
$q->where(function ($sub) use ($keyword) {
$sub->where('file', 'ILIKE', "%{$keyword}%")
$sub->where('nama_dokumen', 'ILIKE', "%{$keyword}%")
->orWhere('no_dokumen', 'ILIKE', "%{$keyword}%");
});
});
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);
}
@ -1048,6 +1324,8 @@ class DashboardController extends Controller
'folder' => $dataSlice[2],
'fileName' =>$dataSlice[3],
'file' => $item->file,
'nama_dokumen' => $item->nama_dokumen ?? '-',
'tgl_expired' => $item->tgl_expired,
'no_dokumen' => $item->no_dokumen,
'entry_at' => $item->entry_at,
'tanggal_terbit' => $item->tanggal_terbit,
@ -1113,6 +1391,74 @@ class DashboardController extends Controller
}
}
public function approvePendingFileMultiple(Request $request){
$ids = $request->input('ids', []);
if (!is_array($ids) || count($ids) === 0) {
return response()->json([
'status' => false,
'message' => 'Daftar dokumen kosong'
], 422);
}
$ids = array_values(array_filter(array_map('strval', $ids)));
if (count($ids) === 0) {
return response()->json([
'status' => false,
'message' => 'Daftar dokumen kosong'
], 422);
}
try {
$files = FileDirectory::whereIn('file_directory_id', $ids)->get();
if ($files->isEmpty()) {
return response()->json([
'status' => false,
'message' => 'Data tidak ditemukan'
], 404);
}
DB::connection('dbDirectory')->beginTransaction();
$actionName = auth()->user()?->dataUser?->namalengkap ?? 'Pengguna';
$actionBy = auth()->user()?->dataUser?->id;
$updated = 0;
foreach ($files as $file) {
if ($file->status_action === 'approved') {
continue;
}
$file->update([
'status_action' => 'approved',
'action_at' => now(),
'action_by' => $actionBy,
]);
$parts = array_values(array_filter(explode('/', $file->file)));
$docNumber = $file->no_dokumen ? 'nomor '. $file->no_dokumen : end($parts);
$payloadNotification = [
'created_at' => now(),
'text_notifikasi' => "Dokumen {$docNumber} telah disetujui oleh {$actionName}.",
'url' => '/',
'is_read' => false,
'pegawai_id' => $file->pegawai_id_entry,
];
Notifkasi::create($payloadNotification);
$updated++;
}
DB::connection('dbDirectory')->commit();
$message = $updated > 0 ? "{$updated} dokumen berhasil di-approve" : 'Tidak ada dokumen yang diproses';
return response()->json([
'status' => true,
'message' => $message,
'updated' => $updated
], 200);
} catch (\Throwable $th) {
DB::connection('dbDirectory')->rollBack();
return response()->json([
'status' => false,
'message' => $th->getMessage()
], 500);
}
}
public function rejectPendingFile(Request $request, string $id){
try {
DB::connection('dbDirectory')->beginTransaction();
@ -1166,11 +1512,14 @@ class DashboardController extends Controller
public function countDataPending(){
try {
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
// ->where('objectatasanlangsungfk', auth()->user()->dataUser->id)
->where('objectatasanlangsungfk', 22924)
->get(['objectpegawaifk']);
$objectpegawaifk = $mapping->pluck('objectpegawaifk')
$objectpegawaifk = MappingUnitKerjaPegawai::query()
->where('statusenabled', true)
->where(fn($q) =>
$q->where('objectatasanlangsungfk', auth()->user()->objectpegawaifk)
->orWhere('objectpejabatpenilaifk', auth()->user()->objectpegawaifk)
)
->pluck('objectpegawaifk')
->unique()
->values()
->all();
$count = FileDirectory::where('statusenabled', true)->whereIn('pegawai_id_entry', $objectpegawaifk)
@ -1319,8 +1668,10 @@ class DashboardController extends Controller
'fileName' =>$dataSlice[3],
'file' => $item->file,
'no_dokumen' => $item->no_dokumen,
'nama_dokumen' => $item->nama_dokumen,
'entry_at' => $item->entry_at,
'tanggal_terbit' => $item->tanggal_terbit,
'tgl_expired' => $item->tgl_expired,
'permission_file' => $item->permission_file,
'status_action' => $item->status_action,
'revision' => $item->revision,
@ -1397,9 +1748,15 @@ class DashboardController extends Controller
if ($request->has('no_dokumen')) {
$payload['no_dokumen'] = $request->input('no_dokumen') ?: null;
}
if ($request->has('nama_dokumen')) {
$payload['nama_dokumen'] = $request->input('nama_dokumen') ?: null;
}
if ($request->has('tanggal_terbit')) {
$payload['tanggal_terbit'] = $request->input('tanggal_terbit') ?: null;
}
if ($request->has('tgl_expired')) {
$payload['tgl_expired'] = $request->input('tgl_expired') ?: null;
}
if ($request->has('permission_file')) {
$permVal = $request->input('permission_file');
if ($permVal !== null && $permVal !== '') {
@ -1447,11 +1804,23 @@ class DashboardController extends Controller
'url' => '/pending-file',
'is_read' => false,
'pegawai_id' => $mapping?->objectatasanlangsungfk,
// 'pegawai_id' => 23521,
];
Notifkasi::create($payloadNotification);
if($mapping->objectpejabatpenilaifk){
$payloadNotification = [
'created_at' => now(),
'text_notifikasi' => "Dokumen {$docNumber} telah direvisi dan memerlukan persetujuan ulang. ". "Direvisi oleh {$uploaderName}.",
'url' => '/pending-file',
'is_read' => false,
'pegawai_id' => $mapping?->objectpejabatpenilaifk,
];
Notifkasi::create($payloadNotification);
}
DB::connection('dbDirectory')->commit();
return response()->json([
'status' => true,

View File

@ -32,6 +32,8 @@ class LogActivityController extends Controller
->all();
$query = FileDirectory::withCount(['viewLogs as total_views' => function($q){
$q->select(DB::raw('COUNT(DISTINCT pegawai_id_entry)'));
}])->withCount(['downloadLogs as total_download' => function($q){
$q->select(DB::raw('COUNT(DISTINCT pegawai_id_entry)'));
}])
->where('statusenabled', true)
->where('status_action', 'approved')
@ -57,7 +59,7 @@ class LogActivityController extends Controller
$parts = array_values(array_filter(explode('/', $item->file)));
return [
'id' => $item->file_directory_id,
'file' => end($parts),
'nama_dokumen' => $item->nama_dokumen,
'no_dokumen' => $item->no_dokumen ?? '-',
'unit' => $parts[0],
'sub_unit' => $parts[1],
@ -65,6 +67,7 @@ class LogActivityController extends Controller
'entry_at' => $item->entry_at,
'pengunggah' => $item->pegawai_nama_entry,
'total_views' => $item->total_views ?? 0,
'total_download' => $item->total_download ?? 0,
];
});

View File

@ -13,6 +13,6 @@ class DataUser extends Model
protected $guarded = ['id'];
public function mappingUnitKerjaPegawai(){
return $this->hasMany(MappingUnitKerjaPegawai::class, 'objectpegawaifk', 'id')->select('id', 'objectsubunitkerjapegawaifk', 'objectunitkerjapegawaifk');
return $this->hasMany(MappingUnitKerjaPegawai::class, 'objectpegawaifk', 'id');
}
}

View File

@ -19,5 +19,11 @@ class FileDirectory extends Model
->where('statusenabled', true)
->where('action_type', 'Membuka Dokumen');
}
public function downloadLogs()
{
return $this->hasMany(LogActivity::class, 'file_directory_id', 'file_directory_id')
->where('statusenabled', true)
->where('action_type', 'Download Dokumen');
}
}

View File

@ -9,6 +9,7 @@
"php": "^8.2",
"laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1",
"phpoffice/phpspreadsheet": "^5.4",
"setasign/fpdf": "^1.8",
"setasign/fpdi": "^2.6"
},

375
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "26cb6fff423ee0edff5bec050b76b10f",
"content-hash": "08bd514ba1ce7ebc80cd60f3bb76e101",
"packages": [
{
"name": "brick/math",
@ -135,6 +135,85 @@
],
"time": "2024-02-09T16:56:22+00:00"
},
{
"name": "composer/pcre",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2",
"phpunit/phpunit": "^8 || ^9"
},
"type": "library",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-11-12T16:29:46+00:00"
},
{
"name": "dflydev/dot-access-data",
"version": "v3.0.3",
@ -2007,6 +2086,191 @@
],
"time": "2024-12-08T08:18:47+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "3.1.2",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"reference": "aeadcf5c412332eb426c0f9b4485f6accba2a99f",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-zlib": "*",
"php-64bit": "^8.2"
},
"require-dev": {
"brianium/paratest": "^7.7",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.16",
"guzzlehttp/guzzle": "^7.5",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.5",
"phpunit/phpunit": "^11.0",
"vimeo/psalm": "^6.0"
},
"suggest": {
"guzzlehttp/psr7": "^2.4",
"psr/http-message": "^2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "András Kolesár",
"email": "kolesar@kolesar.hu"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"support": {
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.2"
},
"funding": [
{
"url": "https://github.com/maennchen",
"type": "github"
}
],
"time": "2025-01-27T12:07:53+00:00"
},
{
"name": "markbaker/complex",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with complex numbers",
"homepage": "https://github.com/MarkBaker/PHPComplex",
"keywords": [
"complex",
"mathematics"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
},
"time": "2022-12-06T16:21:08+00:00"
},
{
"name": "markbaker/matrix",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "^4.0",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"sebastian/phpcpd": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Matrix\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@demon-angel.eu"
}
],
"description": "PHP Class for working with matrices",
"homepage": "https://github.com/MarkBaker/PHPMatrix",
"keywords": [
"mathematics",
"matrix",
"vector"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
},
"time": "2022-12-02T22:17:43+00:00"
},
{
"name": "monolog/monolog",
"version": "3.9.0",
@ -2511,6 +2775,115 @@
],
"time": "2025-05-08T08:14:37+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "5.4.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "48f2fe37d64c2dece0ef71fb2ac55497566782af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/48f2fe37d64c2dece0ef71fb2ac55497566782af",
"reference": "48f2fe37d64c2dece0ef71fb2ac55497566782af",
"shasum": ""
},
"require": {
"composer/pcre": "^1||^2||^3",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-filter": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"maennchen/zipstream-php": "^2.1 || ^3.0",
"markbaker/complex": "^3.0",
"markbaker/matrix": "^3.0",
"php": "^8.1",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-main",
"dompdf/dompdf": "^2.0 || ^3.0",
"ext-intl": "*",
"friendsofphp/php-cs-fixer": "^3.2",
"mitoteam/jpgraph": "^10.5",
"mpdf/mpdf": "^8.1.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.1 || ^2.0",
"phpstan/phpstan-deprecation-rules": "^1.0 || ^2.0",
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
"phpunit/phpunit": "^10.5",
"squizlabs/php_codesniffer": "^3.7",
"tecnickcom/tcpdf": "^6.5"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"ext-intl": "PHP Internationalization Functions, required for NumberFormat Wizard and StringHelper::setLocale()",
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "https://blog.maartenballiauw.be"
},
{
"name": "Mark Baker",
"homepage": "https://markbakeruk.net"
},
{
"name": "Franck Lefevre",
"homepage": "https://rootslabs.net"
},
{
"name": "Erik Tilt"
},
{
"name": "Adrien Crivelli"
},
{
"name": "Owen Leibman"
}
],
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [
"OpenXML",
"excel",
"gnumeric",
"ods",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/5.4.0"
},
"time": "2026-01-11T04:52:00+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.4",

View File

@ -6,7 +6,12 @@ document.addEventListener('DOMContentLoaded', () => {
const pageSizeSelect = document.getElementById('tablePageSize');
const startDateInput = document.getElementById('startDate');
const endDateInput = document.getElementById('endDate');
const selectAllCheckbox = document.getElementById('selectAllPending');
const bulkApproveBtn = document.getElementById('bulkApproveBtn');
const clearSelectionBtn = document.getElementById('clearSelectionBtn');
const selectedCountEl = document.getElementById('selectedCount');
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
const selectedIds = new Set();
if (pageSizeSelect) {
const initialSize = parseInt(pageSizeSelect.value);
@ -34,9 +39,7 @@ document.addEventListener('DOMContentLoaded', () => {
return d.toLocaleDateString('id-ID', {
day: '2-digit',
month: 'short',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
year: 'numeric'
});
}
@ -57,8 +60,46 @@ document.addEventListener('DOMContentLoaded', () => {
return val ? String(val) : '-';
}
function isRejected(item){
return item?.status_action === 'rejected';
}
function getSelectableIdsOnPage(){
return (tableState.data || [])
.filter((item) => !isRejected(item))
.map((item) => String(item.file_directory_id));
}
function updateSelectAllState(){
if (!selectAllCheckbox) return;
const selectableIds = getSelectableIdsOnPage();
if (selectableIds.length === 0) {
selectAllCheckbox.checked = false;
selectAllCheckbox.indeterminate = false;
selectAllCheckbox.disabled = true;
return;
}
selectAllCheckbox.disabled = false;
const selectedOnPage = selectableIds.filter((id) => selectedIds.has(id)).length;
selectAllCheckbox.checked = selectedOnPage > 0 && selectedOnPage === selectableIds.length;
selectAllCheckbox.indeterminate = selectedOnPage > 0 && selectedOnPage < selectableIds.length;
}
function updateSelectionUI(){
const count = selectedIds.size;
if (selectedCountEl) selectedCountEl.textContent = String(count);
if (bulkApproveBtn) bulkApproveBtn.disabled = count === 0;
if (clearSelectionBtn) clearSelectionBtn.disabled = count === 0;
updateSelectAllState();
}
function buildRow(item){
const tanggal = item.entry_at ? formatTanggal(item.entry_at) : '-';
const tanggalExp = item.tgl_expired ? formatTanggal(item.tgl_expired) : '-';
const tanggalTerbit = item.tanggal_terbit ? formatTanggal(item.tanggal_terbit) : '-';
const id = String(item.file_directory_id);
const rejected = isRejected(item);
const checked = selectedIds.has(id);
const aksi = `
<div class="d-flex gap-1">
<button class="btn btn-sm btn-success" onclick="approvePending('${item.file_directory_id}', '${item.fileName || ''}')">
@ -70,22 +111,31 @@ document.addEventListener('DOMContentLoaded', () => {
</div>
`;
return `
<tr>
<td>${item?.status_action !== "rejected" ? aksi : ''}</td>
<tr class="${checked ? 'table-active' : ''}">
<td class="text-center">
<input type="checkbox"
class="form-check-input row-select"
data-id="${id}"
${checked ? 'checked' : ''}
${rejected ? 'disabled' : ''}>
</td>
<td class="text-center">${rejected ? '' : aksi}</td>
<td>${safeText(item.no_dokumen)}</td>
<td>${statusBadge(item?.status_action)}</td>
<td>${aksesBadge(item?.permission_file)}</td>
<td><a href="#" class="file-link"
<td><a href="#" class="file-link doc-title text-decoration-none"
data-file="${item.file}"
data-fileName="${item.fileName}"
data-id="${item.file_directory_id}"
data-no_dokumen="${safeText(item.no_dokumen)}"
data-tanggal_terbit="${safeText(item.tanggal_terbit)}"
data-permission_file="${safeText(item.permission_file)}">${safeText(item.fileName)}</a></td>
<td>${safeText(item.folder)}</td>
<td>${safeText(item.part)}</td>
data-permission_file="${safeText(item.permission_file)}"><span class="cell-wrap">${safeText(item.nama_dokumen)}</span></a></td>
<td class="col-kategori"><div class="cell-wrap">${safeText(item.folder)}</div></td>
<td class="col-unit"><div class="cell-wrap">${safeText(item.part)}</div></td>
<td class="text-nowrap">${tanggalTerbit}</td>
<td class="text-nowrap">${tanggalExp}</td>
<td class="text-nowrap">${tanggal}</td>
<td>${safeText(item.pegawai_nama_entry)}</td>
<td class="col-uploader"><div class="cell-wrap">${safeText(item.pegawai_nama_entry)}</div></td>
</tr>
`;
}
@ -135,7 +185,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (pageData.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="9" class="text-center text-muted py-4">
<td colspan="12" class="text-center text-muted py-4">
Tidak ada data
</td>
</tr>
@ -151,6 +201,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
renderPagination(tableState.lastPage || 1);
updateSelectionUI();
}
let searchDebounce;
@ -170,6 +221,7 @@ document.addEventListener('DOMContentLoaded', () => {
document.getElementById('tableSearch').value = '';
startDateInput.value = '';
endDateInput.value = '';
selectedIds.clear();
tableState.page = 1;
fetchData();
}
@ -225,6 +277,7 @@ document.addEventListener('DOMContentLoaded', () => {
timer: 1500,
showConfirmButton: false
});
selectedIds.delete(String(id));
countData()
fetchData();
}).catch((err) => {
@ -281,6 +334,7 @@ document.addEventListener('DOMContentLoaded', () => {
timer: 1500,
showConfirmButton: false
});
selectedIds.delete(String(id));
countData()
fetchData();
}).catch((err) => {
@ -302,6 +356,87 @@ document.addEventListener('DOMContentLoaded', () => {
confirmButtonText: 'Tutup'
});
}
if (tbody) {
tbody.addEventListener('change', (e) => {
const target = e.target;
if (!target.classList.contains('row-select')) return;
const id = target.getAttribute('data-id');
if (!id) return;
if (target.checked) selectedIds.add(id);
else selectedIds.delete(id);
const row = target.closest('tr');
if (row) row.classList.toggle('table-active', target.checked);
updateSelectionUI();
});
}
if (selectAllCheckbox) {
selectAllCheckbox.addEventListener('change', () => {
const selectableIds = getSelectableIdsOnPage();
if (selectableIds.length === 0) return;
if (selectAllCheckbox.checked) {
selectableIds.forEach((id) => selectedIds.add(id));
} else {
selectableIds.forEach((id) => selectedIds.delete(id));
}
renderTable();
});
}
if (clearSelectionBtn) {
clearSelectionBtn.addEventListener('click', () => {
selectedIds.clear();
renderTable();
});
}
if (bulkApproveBtn) {
bulkApproveBtn.addEventListener('click', () => {
if (selectedIds.size === 0) return;
const ids = Array.from(selectedIds);
Swal.fire({
title: 'Approve dokumen terpilih?',
text: `Total ${ids.length} dokumen akan disetujui.`,
icon: 'question',
showCancelButton: true,
confirmButtonText: 'Approve',
cancelButtonText: 'Batal',
}).then((result) => {
if (!result.isConfirmed) return;
fetch(`/pending-file/approve-multiple`, {
method: 'POST',
headers: {
'X-CSRF-TOKEN': csrfToken,
'Content-Type': 'application/json'
},
body: JSON.stringify({ ids })
}).then(async(res) => {
const data = await res.json();
if (!res.ok || !data?.status) {
throw new Error(data?.message || 'Gagal approve dokumen.');
}
ids.forEach((id) => selectedIds.delete(String(id)));
Swal.fire({
icon: 'success',
title: 'Berhasil',
text: data.message || 'Dokumen disetujui.',
timer: 1500,
showConfirmButton: false
});
countData()
fetchData();
}).catch((err) => {
Swal.fire({
icon: 'error',
title: 'Gagal',
text: err.message || 'Terjadi kesalahan.'
});
});
});
});
}
fetchData();
@ -332,7 +467,7 @@ document.addEventListener('click', function(e){
const permEl = document.getElementById('confirm-permission');
if (permEl) {
const publicDoc = isPublic(permissionFile);
permEl.textContent = publicDoc ? 'Bisa dilihat unit lain' : 'Hanya unit ini';
permEl.textContent = publicDoc ? 'Umum' : 'Internal Unit';
permEl.className = 'badge ' + (publicDoc ? 'bg-success' : 'bg-secondary');
}
let previewBox = document.getElementById('file-preview');
@ -342,7 +477,7 @@ document.addEventListener('click', function(e){
if(e.target.matches('#btn-view-full')){
window.open(`/file-preview/${idDirectory}`, '_blank');
window.open(`/full-preview/${idDirectory}`, '_blank');
}
})

View File

@ -37,14 +37,14 @@ document.addEventListener('DOMContentLoaded', () => {
return d.toLocaleDateString('id-ID', {
day: '2-digit',
month: 'short',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
year: 'numeric'
});
}
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 aksi = `
<div class="d-flex gap-1">
<button class="btn btn-sm btn-info" onclick="infoReject('${item.file_directory_id}', '${item.fileName || ''}')">
@ -53,7 +53,7 @@ document.addEventListener('DOMContentLoaded', () => {
<button class="btn btn-sm btn-primary" onclick="editFileReject('${item.file_directory_id}', '${item.fileName || ''}')">
<i class="fa-solid fa-pen-to-square"></i>
</button>
</div>
`;
return `
@ -70,20 +70,31 @@ document.addEventListener('DOMContentLoaded', () => {
'Pending'}
</button>
</td>
<td>${aksesBadge(item?.permission_file)}</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>
data-permission_file="${item.permission_file || '-'}">${item.nama_dokumen}</a></td>
<td>${item.folder || '-'}</td>
<td>${item.part || '-'}</td>
<td class="text-nowrap">${tanggalTerbit}</td>
<td class="text-nowrap">${tanggalExp}</td>
<td class="text-nowrap">${tanggal}</td>
</tr>
`;
}
function aksesBadge(akses){
if (akses){
return '<span class="badge bg-success">Umum</span>';
} else{
return '<span class="badge bg-primary">Internal Unit</span>';
}
}
function getItemById(id){
return (tableState.data || []).find((row) => String(row.file_directory_id) === String(id));
}
@ -133,7 +144,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (pageData.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="7" class="text-center text-muted py-4">
<td colspan="10" class="text-center text-muted py-4">
Tidak ada data
</td>
</tr>
@ -282,19 +293,34 @@ document.addEventListener('DOMContentLoaded', () => {
}
const idEl = document.getElementById('edit_file_directory_id');
const noEl = document.getElementById('edit_no_dokumen');
const namaEl = document.getElementById('edit_nama_dokumen');
const tglEl = document.getElementById('edit_tanggal_terbit');
const tglExpiredEl = document.getElementById('edit_tgl_expired');
const hasExpiredEl = document.getElementById('edit_has_expired');
const expiredFieldEl = document.getElementById('edit_expired_field');
const currentFileEl = document.getElementById('edit_current_file');
const permYes = document.getElementById('edit_perm_yes');
const permNo = document.getElementById('edit_perm_no');
const katEl = document.getElementById('edit_kategori');
if (idEl) idEl.value = item.file_directory_id || '';
if (noEl) noEl.value = item.no_dokumen || '';
if (namaEl) namaEl.value = item.nama_dokumen || '';
if (tglEl) tglEl.value = item.tanggal_terbit || '';
if (tglExpiredEl) tglExpiredEl.value = item.tgl_expired || '';
if (permYes && permNo) {
const isPublic = item.permission_file === true || item.permission_file === 1 || item.permission_file === '1';
permYes.checked = isPublic;
permNo.checked = !isPublic;
}
if (hasExpiredEl && expiredFieldEl) {
const hasExpired = !!item.tgl_expired;
hasExpiredEl.checked = hasExpired;
expiredFieldEl.classList.toggle('d-none', !hasExpired);
}
if (currentFileEl) {
currentFileEl.textContent = fileName ? `File saat ini: ${fileName}` : '';
}
const parts = (item.file || '').split('/');
const unitName = parts[0] || '';
@ -324,6 +350,21 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
const editHasExpired = document.getElementById('edit_has_expired');
if (editHasExpired) {
editHasExpired.addEventListener('change', () => {
const targetId = editHasExpired.getAttribute('data-target');
const container = targetId ? document.getElementById(targetId) : null;
if (container) {
container.classList.toggle('d-none', !editHasExpired.checked);
if (!editHasExpired.checked) {
const input = container.querySelector('input[type="date"]');
if (input) input.value = '';
}
}
});
}
if (editForm) {
editForm.addEventListener('submit', (e) => {
e.preventDefault();
@ -393,7 +434,7 @@ document.addEventListener('click', function(e){
const permEl = document.getElementById('confirm-permission');
if (permEl) {
const publicDoc = isPublic(permissionFile);
permEl.textContent = publicDoc ? 'Bisa dilihat unit lain' : 'Hanya unit ini';
permEl.textContent = publicDoc ? 'Umum' : 'Internal Unit';
permEl.className = 'badge ' + (publicDoc ? 'bg-success' : 'bg-secondary');
}
let previewBox = document.getElementById('file-preview');
@ -403,7 +444,7 @@ document.addEventListener('click', function(e){
if(e.target.matches('#btn-view-full')){
window.open(`/file-preview/${idDirectory}`, '_blank');
window.open(`/full-preview/${idDirectory}`, '_blank');
}
})
function isPublic(permissionVal){

View File

@ -189,7 +189,7 @@
const permEl = document.getElementById('confirm-permission');
if (permEl) {
const publicDoc = isPublic(permissionFile);
permEl.textContent = publicDoc ? 'Bisa dilihat unit lain' : 'Hanya unit ini';
permEl.textContent = publicDoc ? 'Umum' : 'Internal Unit';
permEl.className = 'badge ' + (publicDoc ? 'bg-success' : 'bg-secondary');
}

View File

@ -124,6 +124,13 @@
<h4 class="mb-0">Data Umum</h4>
<div class="d-flex align-items-start gap-3">
<!-- DOWNLOAD + COUNT -->
<a
href="/download-excel/data-umum"
class="btn btn-success btn-sm"
>
<i class="ti ti-download me-1"></i>
Download Excel
</a>
<div class="d-flex flex-column align-items-start">
<button
type="button"
@ -210,6 +217,7 @@
const authUnitKerja = @json(auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->unitKerja);
const authSubUnitKerja = @json(auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]->sub_unit_kerja);
const mappingUnitKerjaPegawai = @json(auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]);
const authPegawai = @json(auth()->user()->objectpegawaifk);
const formCreate = $("#formFile")
const modalCreate = document.getElementById('modalCreateFile')
const tableState = { data: [], page: 1, pageSize: 8, search: '', lastPage: 1, total: 0 };
@ -309,6 +317,7 @@
data-no_dokumen="${item.no_dokumen || '-'}"
data-tanggal_terbit="${item.tanggal_terbit || '-'}"
data-permission_file="${item.permission_file || '-'}"
data-pegawai_id_entry="${item.pegawai_id_entry || '-'}"
style="
color:#1f2937;
font-weight:600;
@ -857,6 +866,8 @@
let tanggalTerbit = e.target.getAttribute('data-tanggal_terbit')
let permissionFile = e.target.getAttribute('data-permission_file')
let fileName = e.target.getAttribute('data-fileName')
let pegawai_id_entry = e.target.getAttribute('data-pegawai_id_entry')
currentFile = fileUrl;
idDirectory = e.target.getAttribute('data-id');
@ -875,11 +886,26 @@
const permEl = document.getElementById('confirm-permission');
if (permEl) {
const publicDoc = isPublic(permissionFile);
permEl.textContent = publicDoc ? 'Bisa dilihat unit lain' : 'Hanya unit ini';
permEl.textContent = publicDoc ? 'Umum' : 'Internal Unit';
permEl.className = 'badge ' + (publicDoc ? 'bg-success' : 'bg-secondary');
}
const downloadBtn = document.getElementById('btn-download');
if (downloadBtn) {
downloadBtn.setAttribute('href', `/file-download/${idDirectory}`);
}
let previewBox = document.getElementById('file-preview');
previewBox.innerHTML = `<iframe src="/file-preview/${idDirectory}" width="100%" height="500px" style="border:none;"></iframe>`;
previewBox.innerHTML = `<div id="pdfWrap" style="height:500px; overflow:auto; background:#f7f7f7; padding:8px;">
<div id="pdfPages"></div>
</div>
`;
openPreview(idDirectory);
const deleteWrapper = document.getElementById('deleteData');
if (Number(pegawai_id_entry) === Number(authPegawai)) {
deleteWrapper.classList.remove('d-none');
} else {
deleteWrapper.classList.add('d-none');
}
$("#previewModal").modal('show')
}
@ -943,7 +969,7 @@
}
if(e.target.matches('#btn-view-full')){
window.open(`/file-preview/${idDirectory}`, '_blank');
window.open(`/full-preview/${idDirectory}`, '_blank');
}
})

View File

@ -13,9 +13,9 @@
<!-- Body -->
<div class="modal-body p-2" style="min-height:250px; max-height:70vh; overflow:auto;">
{{-- <div class="d-flex justify-content-end align-items-center sticky-top bg-white z-10">
<div class="d-flex justify-content-end align-items-center sticky-top bg-white z-10" id="deleteData">
<button type="button" class="btn btn-sm btn-outline-danger mb-2 me-2" id="delete-file">🗑 Hapus</button>
</div> --}}
</div>
<div id="file-preview"
class="text-center text-muted d-flex justify-content-center align-items-center"
style="height:100%;">
@ -47,6 +47,9 @@
<button type="button" class="btn btn-sm btn-outline-primary" id="btn-view-full">
Lihat Full
</button>
<a class="btn btn-sm btn-primary" id="btn-download" href="#">
Download
</a>
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">
Tutup

View File

@ -49,178 +49,104 @@
color: #9ca3af !important;
}
.dataunit-tabs .nav-link {
border: 0;
color: #475569;
font-weight: 600;
padding: 0.6rem 1rem;
border-radius: 999px;
transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
position: relative;
overflow: hidden;
}
.dataunit-tabs .nav-link.active {
background: color-mix(in srgb, var(--bs-primary) 12%, #ffffff);
color: var(--bs-primary);
+}
.dataunit-tabs .nav-link:hover {
color: var(--bs-primary);
background: color-mix(in srgb, var(--bs-primary) 8%, #ffffff);
}
.dataunit-tabs .nav-link::after {
content: "";
position: absolute;
left: 18px;
right: 18px;
bottom: 6px;
height: 2px;
border-radius: 999px;
background: var(--bs-primary);
transform: scaleX(0);
transform-origin: center;
transition: transform .18s ease;
opacity: 0;
}
.dataunit-tabs .nav-link:hover::after {
transform: scaleX(1);
opacity: 0.7;
}
.dataunit-tab-wrap {
background: #f8fafc;
border-radius: 999px;
padding: 6px;
display: flex;
gap: 6px;
width: 100%;
}
.dataunit-tabs {
width: 100%;
}
.dataunit-tabs .nav-item {
flex: 1 1 0;
}
.dataunit-tabs .nav-link {
width: 100%;
justify-content: center;
}
</style>
@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">
<div class="dataunit-tab-wrap">
<ul class="nav dataunit-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active d-flex align-items-center gap-2" data-bs-toggle="tab" href="#tab-data-unit" role="tab" aria-controls="tab-data-unit" aria-selected="true">
<i class="ti ti-folders"></i>
<span>Data Unit</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link d-flex align-items-center gap-2" data-bs-toggle="tab" href="#tab-data-recap" role="tab" aria-controls="tab-data-recap" aria-selected="false">
<i class="ti ti-chart-bar"></i>
<span>Data Rekap</span>
</a>
</li>
</ul>
</div>
</div>
<div class="card-body p-3">
<div class="tab-content">
<div class="tab-pane fade show active" id="tab-data-unit" role="tabpanel">
<div class="d-flex justify-content-between align-items-start mb-3">
<h4 class="mb-0">Data Unit</h4>
<div class="d-flex align-items-start gap-3">
<!-- DOWNLOAD + COUNT -->
<div class="d-flex flex-column align-items-start">
<button
type="button"
class="btn btn-primary btn-sm"
id="btnDownloadMultiple"
disabled
>
<i class="ti ti-download me-1"></i>
Download Terpilih
</button>
<span
id="selectedCount"
class="small text-muted mt-1"
>
0 dipilih
</span>
</div>
<!-- TAMBAH FILE -->
<button
type="button"
<div class="d-flex justify-content-between align-items-start mb-3">
<h4 class="mb-0">Data Unit</h4>
<div class="d-flex align-items-start gap-3">
<!-- DOWNLOAD + COUNT -->
<a
href="/download-excel/data-unit"
class="btn btn-success btn-sm"
data-bs-toggle="modal"
data-bs-target="#modalCreateFile"
>
<i class="ti ti-plus me-1"></i>
Tambah File
</button>
</div>
</div>
<div class="d-flex flex-column flex-md-row align-items-md-center gap-2 mb-3">
<div class="input-group input-group-sm flex-grow-1">
<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, No Dokumen atau folder"
oninput="debouncedTableSearch(this.value)">
</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>
<i class="ti ti-download me-1"></i>
Download Excel
</a>
<div class="d-flex flex-column align-items-start">
<div class="small text-muted ms-md-auto" id="tableSummary">Memuat data...</div>
<button
type="button"
class="btn btn-primary btn-sm"
id="btnDownloadMultiple"
disabled
>
<i class="ti ti-download me-1"></i>
Download Terpilih
</button>
<span
id="selectedCount"
class="small text-muted mt-1"
>
0 dipilih
</span>
</div>
<div class="table-responsive" style="max-height: 70vh; overflow-y:auto;">
<table class="table table-sm table-hover align-middle mb-0 table-fixed" id="lastUpdatedTable">
<thead>
<tr>
<th class="text-center" style="width: 36px;">
<input type="checkbox" id="checkAllRows" class="form-check-input">
</th>
<th>No Dokumen</th>
<th>Nama Dokumen</th>
<th>Kategori</th>
<th>Unit</th>
<th>Tanggal Upload</th>
<th>Pengunggah</th>
</tr>
</thead>
<tbody id="tableDataUnit">
<!-- 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 class="tab-pane fade" id="tab-data-recap" role="tabpanel">
@include('dataUnit.section.recap')
<!-- TAMBAH FILE -->
<button
type="button"
class="btn btn-success btn-sm"
data-bs-toggle="modal"
data-bs-target="#modalCreateFile"
>
<i class="ti ti-plus me-1"></i>
Tambah File
</button>
</div>
</div>
<div class="d-flex flex-column flex-md-row align-items-md-center gap-2 mb-3">
<div class="input-group input-group-sm flex-grow-1">
<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, No Dokumen atau folder"
oninput="debouncedTableSearch(this.value)">
</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>
<div class="small text-muted ms-md-auto" id="tableSummary">Memuat data...</div>
</div>
<div class="table-responsive" style="max-height: 70vh; overflow-y:auto;">
<table class="table table-sm table-hover align-middle mb-0 table-fixed" id="lastUpdatedTable">
<thead>
<tr>
<th class="text-center" style="width: 36px;">
<input type="checkbox" id="checkAllRows" class="form-check-input">
</th>
<th>No Dokumen</th>
<th>Nama Dokumen</th>
<th>Kategori</th>
<th>Unit</th>
<th>Tanggal Upload</th>
<th>Pengunggah</th>
</tr>
</thead>
<tbody id="tableDataUnit">
<!-- 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>
<hr class="my-4">
<div class="mb-3">
<h5 class="mb-0">Data Rekap</h5>
</div>
@include('dataUnit.section.recap')
</div>
</div>
@ -228,13 +154,15 @@
</div>
@include('dataUnit.modal.create')
@include('dataUnit.modal.view')
<script>
const katDok = @json($katDok);
const authUnitKerja = @json(auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->unitKerja);
const authSubUnitKerja = @json(auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]->sub_unit_kerja);
const mappingUnitKerjaPegawai = @json(auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]);
const formCreate = $("#formFile")
const modalCreate = document.getElementById('modalCreateFile')
const authPegawai = @json(auth()->user()->objectpegawaifk);
const formCreate = $("#formFile");
const modalCreate = document.getElementById('modalCreateFile');
const tableState = { data: [], page: 1, pageSize: 8, search: '', lastPage: 1, total: 0 };
const tbody = document.getElementById('tableDataUnit');
const paginationEl = document.getElementById('paginationControls');
@ -327,6 +255,7 @@
data-no_dokumen="${item.no_dokumen || '-'}"
data-tanggal_terbit="${item.tanggal_terbit || '-'}"
data-permission_file="${item.permission_file || '-'}"
data-pegawai_id_entry="${item.pegawai_id_entry || '-'}"
>
${item.nama_dokumen || '-'}
</a>
@ -872,6 +801,9 @@
let tanggalTerbit = e.target.getAttribute('data-tanggal_terbit')
let permissionFile = e.target.getAttribute('data-permission_file')
let fileName = e.target.getAttribute('data-fileName')
let pegawai_id_entry = e.target.getAttribute('data-pegawai_id_entry')
currentFile = fileUrl;
idDirectory = e.target.getAttribute('data-id');
@ -890,11 +822,28 @@
const permEl = document.getElementById('confirm-permission');
if (permEl) {
const publicDoc = isPublic(permissionFile);
permEl.textContent = publicDoc ? 'Bisa dilihat unit lain' : 'Hanya unit ini';
permEl.textContent = publicDoc ? 'Umum' : 'Internal Unit';
permEl.className = 'badge ' + (publicDoc ? 'bg-success' : 'bg-secondary');
}
const downloadBtn = document.getElementById('btn-download');
if (downloadBtn) {
downloadBtn.setAttribute('href', `/file-download/${idDirectory}`);
}
const deleteWrapper = document.getElementById('deleteData');
if (Number(pegawai_id_entry) === Number(authPegawai)) {
deleteWrapper.classList.remove('d-none');
} else {
deleteWrapper.classList.add('d-none');
}
let previewBox = document.getElementById('file-preview');
previewBox.innerHTML = `<iframe src="/file-preview/${idDirectory}" width="100%" height="500px" style="border:none;"></iframe>`;
previewBox.innerHTML = `<div id="pdfWrap" style="height:500px; overflow:auto; background:#f7f7f7; padding:8px;">
<div id="pdfPages"></div>
</div>
`;
openPreview(idDirectory);
$("#previewModal").modal('show')
}
@ -958,7 +907,7 @@
}
if(e.target.matches('#btn-view-full')){
window.open(`/file-preview/${idDirectory}`, '_blank');
window.open(`/full-preview/${idDirectory}`, '_blank');
}
})

View File

@ -13,9 +13,9 @@
<!-- Body -->
<div class="modal-body p-2" style="min-height:250px; max-height:70vh; overflow:auto;">
{{-- <div class="d-flex justify-content-end align-items-center sticky-top bg-white z-10">
<div class="d-flex justify-content-end align-items-center sticky-top bg-white z-10 d-none" id="deleteData">
<button type="button" class="btn btn-sm btn-outline-danger mb-2 me-2" id="delete-file">🗑 Hapus</button>
</div> --}}
</div>
<div id="file-preview"
class="text-center text-muted d-flex justify-content-center align-items-center"
style="height:100%;">
@ -47,6 +47,9 @@
<button type="button" class="btn btn-sm btn-outline-primary" id="btn-view-full">
Lihat Full
</button>
<a class="btn btn-sm btn-primary" id="btn-download" href="#">
Download
</a>
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">
Tutup

View File

@ -31,7 +31,6 @@
<tr>
<th style="width:5%;" class="text-center">#</th>
<th style="width:30%;">Unit</th>
<th style="width:30%;">Sub Unit</th>
<th style="width:20%;">Folder</th>
<th style="width:15%;" class="text-center">Jumlah File</th>
</tr>
@ -92,7 +91,6 @@ function fetchRecap(){
<tr>
${i === 0 ? `<td rowspan="${row.data.length}" class="text-center align-middle fw-semibold">${idx+1}</td>` : ''}
${i === 0 ? `<td rowspan="${row.data.length}" class="fw-semibold">${row.unit || '-'}</td>` : ''}
<td>${f.subUnit || '-'}</td>
<td>${f.folder || '-'}</td>
<td class="text-center fw-bold">${f.count || 0}</td>
</tr>

View File

@ -13,13 +13,23 @@
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" integrity="sha512-2SwdPD6INVrV/lHTZbO2nodKhrnDdJK9/kg2XD1r9uGqPo1cUbujc+IYdlYdEErWNu69gVcYgdxlmVmzTWnetw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/5.4.149/pdf_viewer.min.css" integrity="sha512-qbvpAGzPFbd9HG4VorZWXYAkAnbwKIxiLinTA1RW8KGJEZqYK04yjvd+Felx2HOeKPDKVLetAqg8RIJqHewaIg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="{{ ver('/assets/libs/jquery/dist/jquery.min.js') }}"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.24.1/dist/bootstrap-table.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/js/all.min.js" integrity="sha512-6BTOlkauINO65nLhXhthZMtepgJSghyimIalb+crKRPhvhmsCdnIuGcVbR5/aQY2A+260iC1OPy1oCdB6pSSwQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<style>
.modal,
.modal-content,
.modal-body,
.message-body {
color-scheme: light;
scrollbar-color: auto;
scrollbar-width: auto;
}
</style>
</head>
<body>
@ -49,6 +59,55 @@
<script src="{{ ver('/assets/js/sidebarmenu.js') }}"></script>
<script src="{{ ver('/assets/js/app.min.js') }}"></script>
<script type="module">
import * as pdfjsLib from "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/5.4.149/pdf.min.mjs";
pdfjsLib.GlobalWorkerOptions.workerSrc =
"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/5.4.149/pdf.worker.min.mjs";
async function renderPdf(url) {
const pagesEl = document.getElementById("pdfPages");
pagesEl.innerHTML = "Loading...";
const loadingTask = pdfjsLib.getDocument({
url,
withCredentials: true, // penting kalau butuh cookie auth
});
const pdf = await loadingTask.promise;
pagesEl.innerHTML = "";
const scale = 1.2;
for (let pageNum = 1; pageNum <= pdf.numPages; pageNum++) {
const page = await pdf.getPage(pageNum);
const viewport = page.getViewport({ scale });
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
canvas.width = viewport.width;
canvas.height = viewport.height;
canvas.style.display = "block";
canvas.style.margin = "0 auto 12px auto";
canvas.style.background = "#fff";
canvas.style.boxShadow = "0 1px 4px rgba(0,0,0,.15)";
pagesEl.appendChild(canvas);
await page.render({
canvasContext: context,
viewport
}).promise;
}
}
// contoh pemakaian sesuai kode kamu:
window.openPreview = (idDirectory) => {
const url = `/file-preview/${idDirectory}`; // endpoint Laravel yang return PDF inline
renderPdf(url);
};
</script>
</body>
</html>

View File

@ -51,6 +51,7 @@
<th>Sub Unit</th>
<th>Pengunggah</th>
<th class="text-center">Jumlah Pegawai Melihat</th>
<th class="text-center">Jumlah Pegawai Mengunduh</th>
</tr>
</thead>
<tbody id="tableLogAktivityDocument">
@ -102,12 +103,13 @@ document.addEventListener('DOMContentLoaded', () => {
return `
<tr role="button" onclick='showLogDetail(${JSON.stringify(item.id)})'>
<td>${item.no_dokumen}</td>
<td>${item.file}</td>
<td>${item.nama_dokumen || '-'}</td>
<td>${item.kategori || '-'}</td>
<td>${item.unit || '-'}</td>
<td>${item.sub_unit || '-'}</td>
<td>${item.pengunggah || '-'}</td>
<td class="text-center fw-semibold">${totalViews}</td>
<td class="text-center fw-semibold">${item.total_download}</td>
</tr>
`;
}

View File

@ -0,0 +1,345 @@
<!doctype html>
<html lang="id">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Preview Dokumen</title>
<style>
:root{
--bg:#f5f6f8;
--card:#fff;
--border:#e5e7eb;
--text:#111827;
--muted:#6b7280;
--primary:#2563eb;
--primary2:#1d4ed8;
}
*{ box-sizing:border-box; }
body{
margin:0;
font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
background:var(--bg);
color:var(--text);
height: 100dvh;
}
/* ===== TOPBAR ===== */
.topbar{
position: sticky;
top:0;
z-index: 50;
min-height: 58px;
background: rgba(255,255,255,.96);
backdrop-filter: blur(8px);
border-bottom: 1px solid var(--border);
display:flex;
align-items:center;
justify-content:space-between;
padding: 0 12px;
gap: 8px;
}
.topbar-left,
.topbar-right{
display:flex;
align-items:center;
gap:8px;
white-space:nowrap;
flex-wrap:wrap;
}
.topbar-center{
display:flex;
align-items:center;
justify-content:center;
flex:1 1 auto;
pointer-events:none;
}
.topbar-logo{
height: 50px;
width:auto;
opacity:.95;
user-select:none;
pointer-events:none;
display:block;
}
.btn{
border:1px solid var(--border);
background:#fff;
padding:7px 10px;
border-radius:10px;
cursor:pointer;
font-size:14px;
line-height:1;
display:inline-flex;
align-items:center;
gap:6px;
text-decoration:none;
color:var(--text);
}
.btn:active{ transform: translateY(1px); }
.btn-primary{
background: var(--primary);
border-color: var(--primary);
color:#fff;
}
.btn-primary:hover{
background: var(--primary2);
border-color: var(--primary2);
color:#fff;
}
.badge{
font-size:13px;
padding:7px 10px;
border:1px solid var(--border);
background:#fff;
border-radius:999px;
white-space:nowrap;
color:var(--text);
}
/* responsive: kecilkan kontrol di layar sempit */
@media (max-width: 1000px){
.topbar-logo{ height: 28px; }
.btn{ font-size:12px; padding:6px 8px; border-radius:9px; }
.badge{ font-size:12px; padding:6px 8px; }
}
@media (max-width: 780px){
/* kalau sempit banget, sembunyikan teks "Dokumen" biar tidak tabrakan */
.doc-label{ display:none; }
.topbar{
padding: 8px 10px;
flex-wrap:wrap;
align-items:flex-start;
}
.topbar-center{
order:1;
flex-basis:100%;
justify-content:center;
}
.topbar-left{
order:2;
}
.topbar-right{
order:3;
width:100%;
justify-content:space-between;
}
}
/* ===== PDF AREA ===== */
#pdfWrap{
height: calc(100dvh - var(--topbar-height, 58px));
overflow-y: scroll;
overflow-x: auto;
padding: 14px;
scrollbar-gutter: stable both-edges;
}
#pdfPages{
display:flex !important;
flex-direction:column !important;
align-items:center !important;
gap:14px !important;
column-count:1 !important;
column-gap:0 !important;
}
.pageCanvas{
display:block !important;
background:var(--card);
border:1px solid var(--border);
border-radius:12px;
box-shadow:0 2px 10px rgba(0,0,0,.06);
max-width:100%;
height:auto;
}
.hint{
padding: 12px;
text-align:center;
color: var(--muted);
}
</style>
</head>
<body>
<div class="topbar">
<!-- LEFT -->
<div class="topbar-left">
<button class="btn" onclick="history.back()"><span class="doc-label">Kembali</span></button>
<span class="badge doc-label">Dokumen {{ $data->nama_dokumen ?? '-'}}</span>
</div>
<!-- CENTER LOGO -->
<div class="topbar-center">
<img src="{{ asset('logo/logo_rsabhk.png') }}" alt="Logo" class="topbar-logo">
</div>
<!-- RIGHT -->
<div class="topbar-right">
<button class="btn" id="zoomOut" title="Zoom Out"></button>
<span class="badge" id="zoomLabel">90%</span>
<button class="btn" id="zoomIn" title="Zoom In">+</button>
<button class="btn" id="resetZoom" title="Reset">Reset</button>
<a class="btn btn-primary"
href="/file-download/{{ $id }}"
title="Download PDF">
Unduh
</a>
<span class="badge" id="pageInfo">Page 0 / 0</span>
</div>
</div>
<div id="pdfWrap">
<div id="pdfPages" class="hint">Loading...</div>
</div>
<script type="module">
import * as pdfjsLib from "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/5.4.149/pdf.min.mjs";
pdfjsLib.GlobalWorkerOptions.workerSrc =
"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/5.4.149/pdf.worker.min.mjs";
const topbar = document.querySelector('.topbar');
const pdfWrap = document.getElementById('pdfWrap');
const pdfPages = document.getElementById('pdfPages');
const zoomLabel = document.getElementById('zoomLabel');
const pageInfo = document.getElementById('pageInfo');
const btnZoomIn = document.getElementById('zoomIn');
const btnZoomOut = document.getElementById('zoomOut');
const btnReset = document.getElementById('resetZoom');
let pdfDoc = null;
// default zoom nyaman
const defaultZoom = () => (window.innerWidth < 1366 ? 0.85 : 0.90);
let zoom = defaultZoom();
// batas lebar render maksimal
const MAX_DOC_WIDTH = 960; // kecilin jadi 900 kalau masih besar
function calcFitScale(page, baseZoom = 1.0) {
const padding = 56;
const wrapWidth = Math.max(320, pdfWrap.clientWidth - padding);
const targetWidth = Math.min(wrapWidth, MAX_DOC_WIDTH);
const vp1 = page.getViewport({ scale: 1 });
const fitScale = targetWidth / vp1.width;
return fitScale * baseZoom;
}
async function renderAllPages() {
if (!pdfDoc) return;
const prevScrollTop = pdfWrap.scrollTop;
pdfPages.innerHTML = '<div class="hint">Rendering...</div>';
const numPages = pdfDoc.numPages;
pageInfo.textContent = `Page 1 / ${numPages}`;
pdfPages.innerHTML = '';
for (let p = 1; p <= numPages; p++) {
const page = await pdfDoc.getPage(p);
const scale = calcFitScale(page, zoom);
const viewport = page.getViewport({ scale });
const canvas = document.createElement('canvas');
canvas.className = 'pageCanvas';
const ctx = canvas.getContext('2d', { alpha: false });
canvas.width = Math.floor(viewport.width);
canvas.height = Math.floor(viewport.height);
pdfPages.appendChild(canvas);
await page.render({ canvasContext: ctx, viewport }).promise;
}
zoomLabel.textContent = `${Math.round(zoom * 100)}%`;
pdfWrap.scrollTop = prevScrollTop;
}
async function loadPdf(url) {
pdfPages.innerHTML = '<div class="hint">Loading PDF...</div>';
const task = pdfjsLib.getDocument({
url,
withCredentials: true,
});
pdfDoc = await task.promise;
await renderAllPages();
// update page info based on scroll
pdfWrap.addEventListener('scroll', () => {
const canvases = pdfPages.querySelectorAll('canvas');
if (!canvases.length) return;
const wrapTop = pdfWrap.getBoundingClientRect().top;
let current = 1;
for (let i = 0; i < canvases.length; i++) {
const rect = canvases[i].getBoundingClientRect();
if (rect.top - wrapTop < 80) current = i + 1;
else break;
}
pageInfo.textContent = `Page ${current} / ${pdfDoc.numPages}`;
}, { passive: true });
}
// zoom handlers
btnZoomIn.addEventListener('click', async () => {
zoom = Math.min(1.6, +(zoom + 0.1).toFixed(2));
await renderAllPages();
});
btnZoomOut.addEventListener('click', async () => {
zoom = Math.max(0.6, +(zoom - 0.1).toFixed(2));
await renderAllPages();
});
btnReset.addEventListener('click', async () => {
zoom = defaultZoom();
await renderAllPages();
});
function syncTopbarHeight(){
if (!topbar) return;
const h = topbar.offsetHeight || 58;
document.documentElement.style.setProperty('--topbar-height', `${h}px`);
}
// rerender on resize (debounce)
let resizeTimer = null;
window.addEventListener('resize', () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
syncTopbarHeight();
renderAllPages();
}, 200);
});
// load watermarked pdf endpoint
syncTopbarHeight();
loadPdf(`/file-preview/{{ $id }}`);
</script>
</body>
</html>

View File

@ -1,5 +1,47 @@
@extends('layout.main')
@section('body_main')
<style>
.pending-table thead th {
position: sticky;
top: 0;
z-index: 2;
background: #f8f9fa;
white-space: nowrap;
}
.pending-table th,
.pending-table td {
padding-top: 0.6rem;
padding-bottom: 0.6rem;
vertical-align: top;
}
.pending-table .col-select {
width: 36px;
}
.pending-table .col-actions {
width: 92px;
}
.pending-table .cell-wrap {
line-height: 1.25;
white-space: normal;
word-break: break-word;
display: block;
}
.pending-table .doc-title {
max-width: 260px;
display: inline-block;
white-space: normal;
word-break: break-word;
}
.pending-table .col-kategori {
max-width: 180px;
}
.pending-table .col-unit {
max-width: 200px;
}
.pending-table .col-uploader {
max-width: 160px;
}
</style>
<div class="row">
<div class="col-md-12">
<div class="card">
@ -15,7 +57,7 @@
<input type="search"
id="tableSearch"
class="form-control border-start-0"
placeholder="Cari nama file / nomor dokumen"
placeholder="Cari nama / nomor dokumen"
oninput="debouncedTableSearch(this.value)">
</div>
<div class="d-flex align-items-center gap-2">
@ -35,24 +77,37 @@
<option value="100">100</option>
</select>
</div>
<div class="d-flex align-items-center gap-2">
<button class="btn btn-success btn-sm" id="bulkApproveBtn" disabled>
<i class="fa-solid fa-check"></i> Approve dipilih (<span id="selectedCount">0</span>)
</button>
<button class="btn btn-outline-secondary btn-sm" id="clearSelectionBtn" disabled>
Reset pilihan
</button>
</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">
<table class="table table-sm table-hover table-striped align-middle mb-0 pending-table" id="lastUpdatedTable">
<thead>
<tr>
<th>Aksi</th>
<th class="col-select text-center">
<input type="checkbox" class="form-check-input" id="selectAllPending" title="Pilih semua di halaman">
</th>
<th class="col-actions text-center">Aksi</th>
<th>No. Dokumen</th>
<th>Status</th>
<th>Akses</th>
<th>File</th>
<th>Folder</th>
<th>Unit / Sub Unit</th>
<th>Nama</th>
<th class="col-kategori">Kategori</th>
<th class="col-unit">Unit / Sub Unit</th>
<th>Tanggal Terbit</th>
<th>Tanggal Expired</th>
<th>Tanggal Upload</th>
<th>Pengunggah</th>
<th class="col-uploader">Pengunggah</th>
</tr>
</thead>
<tbody id="tablePendingFile">

View File

@ -47,10 +47,13 @@
<th>Aksi</th>
<th>No Dokumen</th>
<th>Status</th>
<th>File</th>
<th>Folder</th>
<th>Akses</th>
<th>Nama</th>
<th>Kategori</th>
<th>Unit/Sub Unit</th>
<th>Tanggal</th>
<th>Tanggal Terbit</th>
<th>Tanggal Expired</th>
<th>Tanggal Upload</th>
</tr>
</thead>
<tbody id="tablePengajuanFile">

View File

@ -12,40 +12,60 @@
<input type="hidden" name="file_directory_id" id="edit_file_directory_id">
<div class="container" style="max-height: 70vh; overflow-y:auto;">
<div class="row g-3">
<div class="col-12">
<div class="p-2 rounded-3 bg-light border">
<span class="fw-semibold">Informasi Dokumen</span>
<div class="small text-muted">Perbarui detail dokumen sebelum mengirim ulang.</div>
</div>
</div>
<div class="col-md-4">
<label class="form-label fw-semibold">Unit <span class="text-danger">*</span></label>
<select class="form-control unit_kerja" name="id_unit_kerja" id="edit_id_unit_kerja" required>
<option value="" disabled selected>Select Choose</option>
<option value="" disabled selected>Pilih Unit</option>
</select>
</div>
<div class="col-md-4">
<label class="form-label fw-semibold">Sub Unit <span class="text-danger">*</span></label>
<select class="form-control sub_unit_kerja" name="id_sub_unit_kerja" id="edit_id_sub_unit_kerja" required>
<option value="" disabled selected>Select Choose</option>
<option value="" disabled selected>Pilih Sub Unit</option>
</select>
</div>
<div class="col-md-4">
<label class="form-label fw-semibold">Kategori Dokumen <span class="text-danger">*</span></label>
<select class="form-control" name="master_kategori_directory_id" id="edit_kategori" required>
<option value="" disabled selected>Select Choose</option>
<option value="" disabled selected>Pilih Kategori</option>
@foreach ($katDok as $kat)
<option value="{{ $kat->master_kategori_directory_id }}/{{ $kat->nama_kategori_directory }}">{{ $kat->nama_kategori_directory }}</option>
@endforeach
</select>
</div>
<div class="col-md-6">
<div class="col-md-4">
<label class="form-label fw-semibold">Nomor Dokumen</label>
<div class="input-group">
<span class="input-group-text">#</span>
<input type="text" class="form-control" name="no_dokumen" id="edit_no_dokumen" placeholder="Contoh: 001/RS/IT/I/2026">
</div>
</div>
<div class="col-md-3">
<div class="col-md-4">
<label class="form-label fw-semibold">Nama Dokumen</label>
<input type="text" class="form-control" name="nama_dokumen" id="edit_nama_dokumen" placeholder="Contoh: Panduan Mencuci Tangan">
</div>
<div class="col-md-4">
<label class="form-label fw-semibold">Tanggal Terbit</label>
<input class="form-control" type="date" name="tanggal_terbit" id="edit_tanggal_terbit">
</div>
<div class="col-md-3">
<div class="col-md-2 d-flex align-items-end">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="edit_has_expired" data-target="edit_expired_field">
<label class="form-check-label" for="edit_has_expired">Ada Expired?</label>
</div>
</div>
<div class="col-md-5 d-none" id="edit_expired_field">
<label class="form-label fw-semibold">Tanggal Expired</label>
<input class="form-control" type="date" name="tgl_expired" id="edit_tgl_expired">
</div>
<div class="col-md-5">
<label class="form-label fw-semibold">Boleh dilihat unit lain? <span class="text-danger">*</span></label>
<div class="border rounded-3 p-2 bg-light">
<div class="form-check">
@ -64,6 +84,7 @@
<div class="border rounded-3 p-3 bg-white shadow-sm">
<input class="form-control" type="file" id="edit_file_upload" accept=".pdf" name="file">
<div class="mt-2 text-success fw-semibold d-none file-name"></div>
<div class="mt-2 small text-muted" id="edit_current_file"></div>
</div>
<div class="form-text text-muted">Kosongkan jika tidak mengganti file.</div>
</div>

View File

@ -13,10 +13,14 @@ Route::middleware(['auth'])->group(function(){
Route::get('/', [DashboardController::class, 'index']);
Route::get('/data-internal', [DashboardController::class, 'dataUnitInternal']);
Route::get('/download-excel/data-unit', [DashboardController::class, 'downloadDataUnitExcel']);
Route::get('/data-umum', [DashboardController::class, 'dataUmum']);
Route::get('/datatable-umum', [DashboardController::class, 'datatableDataUmum']);
Route::get('/download-excel/data-umum', [DashboardController::class, 'downloadDataUmumExcel']);
Route::post('/uploadv2', [DashboardController::class, 'storeVersion2']);
Route::get('/file-preview/{id}', [DashboardController::class, 'dataPdf']);
Route::get('/file-download/{id}', [DashboardController::class, 'downloadFile']);
Route::get('/full-preview/{id}', [DashboardController::class, 'dataPdfV2']);
Route::post('/upload', [DashboardController::class, 'store']);
Route::get('/data-unit-kerja', [DashboardController::class, 'dataUnitKerja']);
Route::post('/dashboard/prefill', [DashboardController::class, 'setDashboardPrefill']);
@ -58,6 +62,7 @@ Route::middleware(['auth'])->group(function(){
Route::get('/pending-file', [DashboardController::class, 'pendingFile']);
Route::get('/datatable/pending-file', [DashboardController::class, 'dataPendingFile']);
Route::post('/pending-file/{id}/approve', [DashboardController::class, 'approvePendingFile']);
Route::post('/pending-file/approve-multiple', [DashboardController::class, 'approvePendingFileMultiple']);
Route::post('/pending-file/{id}/reject', [DashboardController::class, 'rejectPendingFile']);
Route::get('/data/count-pending', [DashboardController::class, 'countDataPending']);
Route::get('/data/count-rejected', [DashboardController::class, 'countRejectedPengajuan']);