progress
This commit is contained in:
parent
313cf64724
commit
6027986deb
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\LogActivity;
|
||||
use App\Models\MappingUnitKerjaPegawai;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@ -6,8 +6,10 @@ use App\Models\AksesFile;
|
||||
use App\Models\AksesFileDetail;
|
||||
use App\Models\FileDirectory;
|
||||
use App\Models\LogActivity;
|
||||
use App\Models\MappingUnitKerjaPegawai;
|
||||
use App\Models\MasterKategori;
|
||||
use App\Models\MasterKlasifikasi;
|
||||
use App\Models\Notifkasi;
|
||||
use App\Models\SubUnitKerja;
|
||||
use App\Models\UnitKerja;
|
||||
use Carbon\Carbon;
|
||||
@ -140,13 +142,19 @@ class DashboardController extends Controller
|
||||
|
||||
public function dataUnitInternal(){
|
||||
$perPage = (int) request('per_page', 10);
|
||||
$authUnitId = auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->objectunitkerjapegawaifk;
|
||||
// $authUnitId = auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->objectunitkerjapegawaifk;
|
||||
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
|
||||
->where('objectpegawaifk', auth()->user()->dataUser->id)
|
||||
->get(['objectunitkerjapegawaifk', 'objectsubunitkerjapegawaifk']);
|
||||
$unitIds = $mapping->pluck('objectunitkerjapegawaifk')
|
||||
->filter() // buang null
|
||||
->unique()
|
||||
->values()
|
||||
->all();
|
||||
$keyword = request('keyword');
|
||||
$query = FileDirectory::where('statusenabled', true)
|
||||
->where(function($subQuery){
|
||||
$subQuery->where('status_action', '!=', 'rejected')->whereNotNull('status_action');
|
||||
})
|
||||
->where('id_unit_kerja', $authUnitId)->where('permission_file', false)
|
||||
->where('status_action', 'approved')
|
||||
->whereIn('id_unit_kerja', $unitIds)
|
||||
->when($keyword, function ($q) use ($keyword) {
|
||||
$q->where(function ($sub) use ($keyword) {
|
||||
$sub->where('file', 'ILIKE', "%{$keyword}%")
|
||||
@ -175,7 +183,7 @@ class DashboardController extends Controller
|
||||
|
||||
public function dataUnitKerja(){
|
||||
$user = auth()->user()?->dataUser;
|
||||
$entryPegawaiId = auth()->user()?->objectpegawaifk;
|
||||
// $entryPegawaiId = auth()->user()?->objectpegawaifk;
|
||||
$authMapping = $user?->mappingUnitKerjaPegawai[0] ?? null;
|
||||
$authUnit = $authMapping?->objectunitkerjapegawaifk;
|
||||
$authSub = $authMapping?->objectsubunitkerjapegawaifk;
|
||||
@ -355,23 +363,6 @@ class DashboardController extends Controller
|
||||
$payload['file'] =$path .'/' .$imageName;
|
||||
}
|
||||
$fd = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -427,24 +418,6 @@ class DashboardController extends Controller
|
||||
}
|
||||
|
||||
$data->update(['statusenabled' => false, 'file' => $fileInfo['dirname'].'/'. $newFileName]);
|
||||
|
||||
$payloadLog = [
|
||||
'file_directory_id' => $data->file_directory_id,
|
||||
'pegawai_id_entry' => $data->pegawai_id_entry,
|
||||
'pegawai_nama_entry' => $data->pegawai_nama_entry,
|
||||
'entry_at' => $data->entry_at,
|
||||
'action_type' => 'Hapus Dokumen',
|
||||
'statusenabled' => true,
|
||||
'mod_change' => $data->entry_at,
|
||||
'id_unit_kerja' => $data->id_unit_kerja,
|
||||
'id_sub_unit_kerja' => $data->id_sub_unit_kerja,
|
||||
'file' => $data->file,
|
||||
'tanggal_terbit' => $data->tanggal_terbit,
|
||||
'no_dokumen' => $data->no_dokumen,
|
||||
'permission_file' => $data->permission_file,
|
||||
];
|
||||
LogActivity::create($payloadLog);
|
||||
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
@ -468,8 +441,6 @@ class DashboardController extends Controller
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function getFile($id_unit_kerja, $id_sub_unit_kerja, $master_kategori_directory_id){
|
||||
$klasifikasi = request('klasifikasi');
|
||||
$klaArray = explode(',', $klasifikasi);
|
||||
@ -583,44 +554,39 @@ class DashboardController extends Controller
|
||||
return view('dataUmum.index', $data);
|
||||
}
|
||||
|
||||
public function dataDocumentLast(){
|
||||
public function datatableDataUmum(){
|
||||
$perPage = (int) request('per_page', 10);
|
||||
$authUnitId = auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->objectunitkerjapegawaifk;
|
||||
// $authUnitId = auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->objectunitkerjapegawaifk;
|
||||
$user = auth()->user()?->dataUser;
|
||||
$entryPegawaiId = auth()->user()?->objectpegawaifk;
|
||||
// $entryPegawaiId = auth()->user()?->objectpegawaifk;
|
||||
$akses = AksesFile::where(['pegawai_id' => $user->id, 'statusenabled' => true])->first();
|
||||
$keyword = request('keyword');
|
||||
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
|
||||
->where('objectpegawaifk', $user->id)
|
||||
->get(['objectunitkerjapegawaifk', 'objectsubunitkerjapegawaifk']);
|
||||
|
||||
$query = FileDirectory::where('statusenabled', true)
|
||||
->where(function($subQuery){
|
||||
$subQuery->where('status_action', '!=', 'rejected')->whereNotNull('status_action');
|
||||
})->when($keyword, function ($q) use ($keyword) {
|
||||
// $unitIds = $mapping->pluck('objectunitkerjapegawaifk')
|
||||
// ->filter() // buang null
|
||||
// ->unique()
|
||||
// ->values()
|
||||
// ->all();
|
||||
|
||||
// $subUnitIds = $mapping->pluck('objectsubunitkerjapegawaifk')
|
||||
// ->filter()
|
||||
// ->unique()
|
||||
// ->values()
|
||||
// ->all();
|
||||
$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}%")
|
||||
->orWhere('no_dokumen', 'ILIKE', "%{$keyword}%");
|
||||
});
|
||||
});
|
||||
if($akses){
|
||||
if(!$akses->all_akses){
|
||||
$aksesFile = AksesFileDetail::where('akses_file_id', $akses->akses_file_id)->pluck('id_unit_kerja');
|
||||
$query->where(function ($query) use ($authUnitId, $aksesFile) {
|
||||
$query->where('permission_file', true)
|
||||
->orWhere(function ($sub) use ($authUnitId, $aksesFile) {
|
||||
$sub->where('permission_file', false)
|
||||
->whereIn('id_unit_kerja', $aksesFile);
|
||||
});
|
||||
});
|
||||
}else{
|
||||
$query;
|
||||
}
|
||||
if($akses && $akses->all_akses){
|
||||
$query;
|
||||
}else{
|
||||
$query->where(function ($query) use ($authUnitId) {
|
||||
$query->where('permission_file', true)
|
||||
->orWhere(function ($sub) use ($authUnitId) {
|
||||
$sub->where('permission_file', false)
|
||||
->where('id_unit_kerja', $authUnitId);
|
||||
});
|
||||
});
|
||||
$query->where('permission_file', true);
|
||||
}
|
||||
|
||||
|
||||
@ -641,6 +607,7 @@ class DashboardController extends Controller
|
||||
'total' => $data->total(),
|
||||
]
|
||||
];
|
||||
|
||||
return response()->json($payload);
|
||||
}
|
||||
|
||||
@ -648,6 +615,11 @@ class DashboardController extends Controller
|
||||
DB::connection('dbDirectory')->beginTransaction();
|
||||
try {
|
||||
$datas = request('data');
|
||||
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
|
||||
->where('objectpegawaifk', auth()->user()?->dataUser?->id)
|
||||
->first();
|
||||
$isAtasan = MappingUnitKerjaPegawai::where('statusenabled', true)->where('objectatasanlangsungfk', auth()->user()?->dataUser?->id)->exists();
|
||||
|
||||
foreach ($datas as $index => $data) {
|
||||
list($id_unit_kerja, $nama_unit_kerja) = explode('/', $data['id_unit_kerja'],2);
|
||||
list($id_sub_unit_kerja, $nama_sub_unit_kerja) = explode('/', $data['id_sub_unit_kerja'],2);
|
||||
@ -657,10 +629,17 @@ class DashboardController extends Controller
|
||||
if(!$uploadedFile){
|
||||
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;
|
||||
|
||||
|
||||
$status = null;
|
||||
if(auth()->user()->masterPersetujuan){
|
||||
// $unitPegawaiIds = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray();
|
||||
// $status = in_array($id_unit_kerja, $unitPegawaiIds)
|
||||
// ? 'approved'
|
||||
// : null;
|
||||
$status = $isAtasan ? 'approved' : null;
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'id_unit_kerja' => $id_unit_kerja,
|
||||
'id_sub_unit_kerja' => $id_sub_unit_kerja,
|
||||
@ -671,8 +650,8 @@ class DashboardController extends Controller
|
||||
'no_dokumen' => $data['no_dokumen'] ?? null,
|
||||
'permission_file' => ($data['is_permission'] ?? null) == "1",
|
||||
'status_action' => $status,
|
||||
'action_by' => $status === "approved" ? auth()->user()->objectpegawaifk : null,
|
||||
'action_at' => $status === "approved" ? now() : null
|
||||
'action_by' => $status && $status === "approved" ? auth()->user()->objectpegawaifk : null,
|
||||
'action_at' => $status && $status === "approved" ? now() : null
|
||||
];
|
||||
|
||||
$imageName = $uploadedFile->getClientOriginalName();
|
||||
@ -682,22 +661,21 @@ class DashboardController extends Controller
|
||||
|
||||
$fd = 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' => 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,
|
||||
'no_dokumen' => $fd->no_dokumen,
|
||||
'permission_file' => $fd->permission_file,
|
||||
];
|
||||
LogActivity::create($payloadLog);
|
||||
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,
|
||||
];
|
||||
|
||||
Notifkasi::create($payloadNotification);
|
||||
}
|
||||
|
||||
}
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
@ -716,6 +694,25 @@ class DashboardController extends Controller
|
||||
public function dataPdf($fileDirectoryId)
|
||||
{
|
||||
$data = FileDirectory::where('file_directory_id', $fileDirectoryId)->first();
|
||||
$user = auth()->user()->dataUser;
|
||||
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
|
||||
->where('objectpegawaifk', $user->id)->where('isprimary', true)
|
||||
->first();
|
||||
$payloadLog = [
|
||||
'file_directory_id' => $fileDirectoryId,
|
||||
'pegawai_id_entry' => auth()->user()->dataUser->id,
|
||||
'pegawai_nama_entry' => auth()->user()->dataUser->namalengkap,
|
||||
'entry_at' => now(),
|
||||
'action_type' => 'Membuka 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,
|
||||
];
|
||||
LogActivity::create($payloadLog);
|
||||
|
||||
|
||||
$filePath = public_path('file/' . $data->file);
|
||||
|
||||
@ -881,8 +878,17 @@ class DashboardController extends Controller
|
||||
$perPage = (int) request('per_page', 10);
|
||||
$page = max(1, (int) request('page', 1));
|
||||
$keyword = strtolower(request('keyword', ''));
|
||||
$authUnit = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray();
|
||||
$rows = FileDirectory::where('statusenabled', true)->whereNotNull('status_action')->whereIn('id_unit_kerja', $authUnit)->pluck('file');
|
||||
// $authUnit = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray();
|
||||
$user = auth()->user()->dataUser;
|
||||
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
|
||||
->where('objectpegawaifk', $user->id)
|
||||
->get(['objectunitkerjapegawaifk', 'objectsubunitkerjapegawaifk']);
|
||||
$unitIds = $mapping->pluck('objectunitkerjapegawaifk')
|
||||
->filter() // buang null
|
||||
->unique()
|
||||
->values()
|
||||
->all();
|
||||
$rows = FileDirectory::where('statusenabled', true)->whereNotNull('status_action')->whereIn('id_unit_kerja', $unitIds)->pluck('file');
|
||||
|
||||
$grouped = [];
|
||||
foreach ($rows as $path) {
|
||||
@ -961,6 +967,8 @@ class DashboardController extends Controller
|
||||
$keyword = request('keyword');
|
||||
$start = request('start_date');
|
||||
$end = request('end_date');
|
||||
// $mapping = MappingUnitKerjaPegawai::where('statusenabled', true)->whereIn('objectatasanlangsungfk', auth()->user()->objectpegawaifk)->get();
|
||||
|
||||
$authUnit = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray();
|
||||
|
||||
$query = FileDirectory::where('statusenabled', true)->where(function($q){
|
||||
@ -1014,39 +1022,40 @@ class DashboardController extends Controller
|
||||
|
||||
public function approvePendingFile(string $id){
|
||||
try {
|
||||
$data = FileDirectory::where('file_directory_id', $id)->first();
|
||||
if(!$data){
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Data tidak ditemukan'
|
||||
], 404);
|
||||
}
|
||||
$data->update([
|
||||
'status_action' => 'approved',
|
||||
'action_at' => now(),
|
||||
'action_by' => auth()->user()->dataUser->id,
|
||||
]);
|
||||
$payloadLog = [
|
||||
'file_directory_id' => $data->file_directory_id,
|
||||
'pegawai_id_entry' => $data->action_by,
|
||||
'pegawai_nama_entry' => auth()->user()->dataUser->namalengkap,
|
||||
'entry_at' => $data->action_at,
|
||||
'action_type' => 'Approval Dokumen',
|
||||
'statusenabled' => true,
|
||||
'mod_change' => $data->entry_at,
|
||||
'id_unit_kerja' => $data->id_unit_kerja,
|
||||
'id_sub_unit_kerja' => $data->id_sub_unit_kerja,
|
||||
'file' => $data->file,
|
||||
'tanggal_terbit' => $data->tanggal_terbit,
|
||||
'no_dokumen' => $data->no_dokumen,
|
||||
'permission_file' => $data->permission_file,
|
||||
DB::connection('dbDirectory')->beginTransaction();
|
||||
$data = FileDirectory::where('file_directory_id', $id)->first();
|
||||
if(!$data){
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Data tidak ditemukan'
|
||||
], 404);
|
||||
}
|
||||
$data->update([
|
||||
'status_action' => 'approved',
|
||||
'action_at' => now(),
|
||||
'action_by' => auth()->user()->dataUser->id,
|
||||
]);
|
||||
|
||||
$parts = array_values(array_filter(explode('/', $data->file)));
|
||||
$actionName = auth()->user()?->dataUser?->namalengkap ?? 'Pengguna';
|
||||
$docNumber = $data->no_dokumen ? 'nomor '. $data->no_dokumen : end($parts);
|
||||
$payloadNotification = [
|
||||
'created_at' => now(),
|
||||
'text_notifikasi' => "Dokumen {$docNumber} telah disetujui oleh {$actionName}.",
|
||||
'url' => '/',
|
||||
'is_read' => false,
|
||||
// 'pegawai_id' => $mapping?->objectatasanlangsungfk,
|
||||
'pegawai_id' => $data->pegawai_id_entry,
|
||||
];
|
||||
LogActivity::create($payloadLog);
|
||||
|
||||
Notifkasi::create($payloadNotification);
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'File berhasil di-approve'
|
||||
], 200);
|
||||
} catch (\Throwable $th) {
|
||||
DB::connection('dbDirectory')->rollBack();
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $th->getMessage()
|
||||
@ -1054,8 +1063,9 @@ class DashboardController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function rejectPendingFile(string $id){
|
||||
public function rejectPendingFile(Request $request, string $id){
|
||||
try {
|
||||
DB::connection('dbDirectory')->beginTransaction();
|
||||
$data = FileDirectory::where('file_directory_id', $id)->first();
|
||||
if(!$data){
|
||||
return response()->json([
|
||||
@ -1063,32 +1073,40 @@ class DashboardController extends Controller
|
||||
'message' => 'Data tidak ditemukan'
|
||||
], 404);
|
||||
}
|
||||
$revision = trim((string) $request->input('revision', ''));
|
||||
if ($revision === '') {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Catatan revisi wajib diisi'
|
||||
], 422);
|
||||
}
|
||||
$data->update([
|
||||
'status_action' => 'rejected',
|
||||
'action_at' => now(),
|
||||
'action_by' => auth()->user()->dataUser->id,
|
||||
'revision' => $revision,
|
||||
]);
|
||||
$payloadLog = [
|
||||
'file_directory_id' => $data->file_directory_id,
|
||||
'pegawai_id_entry' => $data->action_by,
|
||||
'pegawai_nama_entry' => auth()->user()->dataUser->namalengkap,
|
||||
'entry_at' => $data->action_at,
|
||||
'action_type' => 'Reject Dokumen',
|
||||
'statusenabled' => true,
|
||||
'mod_change' => $data->entry_at,
|
||||
'id_unit_kerja' => $data->id_unit_kerja,
|
||||
'id_sub_unit_kerja' => $data->id_sub_unit_kerja,
|
||||
'file' => $data->file,
|
||||
'tanggal_terbit' => $data->tanggal_terbit,
|
||||
'no_dokumen' => $data->no_dokumen,
|
||||
'permission_file' => $data->permission_file,
|
||||
];
|
||||
LogActivity::create($payloadLog);
|
||||
|
||||
$parts = array_values(array_filter(explode('/', $data->file)));
|
||||
$actionName = auth()->user()?->dataUser?->namalengkap ?? 'Pengguna';
|
||||
$docNumber = $data->no_dokumen ? 'nomor '. $data->no_dokumen : end($parts);
|
||||
$payloadNotification = [
|
||||
'created_at' => now(),
|
||||
'text_notifikasi' => "Dokumen {$docNumber} telah ditolak oleh {$actionName}. ". "Silakan periksa dokumen untuk melakukan perbaikan.",
|
||||
'url' => '/pengajuan-file',
|
||||
'is_read' => false,
|
||||
// 'pegawai_id' => $mapping?->objectatasanlangsungfk,
|
||||
'pegawai_id' => $data->pegawai_id_entry,
|
||||
];
|
||||
|
||||
Notifkasi::create($payloadNotification);
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'File berhasil di-reject'
|
||||
], 200);
|
||||
} catch (\Throwable $th) {
|
||||
DB::connection('dbDirectory')->rollBack();
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $th->getMessage()
|
||||
@ -1115,8 +1133,96 @@ class DashboardController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function countRejectedPengajuan()
|
||||
{
|
||||
try {
|
||||
$count = FileDirectory::where('statusenabled', true)
|
||||
->where('pegawai_id_entry', auth()->user()->objectpegawaifk)
|
||||
->where('status_action', 'rejected')
|
||||
->count();
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'count' => $count,
|
||||
'message' => 'Berhasil mendapatkan data'
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Terdapat kesalahan!'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function notifkasiList()
|
||||
{
|
||||
try {
|
||||
$pegawaiId = auth()->user()?->dataUser?->id;
|
||||
if (!$pegawaiId) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Pegawai tidak ditemukan',
|
||||
'data' => [],
|
||||
'unread' => 0
|
||||
], 404);
|
||||
}
|
||||
|
||||
$query = Notifkasi::where('pegawai_id', $pegawaiId);
|
||||
$unread = (clone $query)->where('is_read', false)->count();
|
||||
$items = $query->orderBy('created_at', 'desc')
|
||||
->limit(20)
|
||||
->get(['id', 'text_notifikasi', 'url', 'is_read', 'created_at']);
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $items,
|
||||
'unread' => $unread
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Terdapat kesalahan!',
|
||||
'data' => [],
|
||||
'unread' => 0
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function notifkasiMarkRead()
|
||||
{
|
||||
try {
|
||||
$pegawaiId = auth()->user()?->dataUser?->id;
|
||||
if (!$pegawaiId) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Pegawai tidak ditemukan'
|
||||
], 404);
|
||||
}
|
||||
|
||||
Notifkasi::where('pegawai_id', $pegawaiId)
|
||||
->where('is_read', false)
|
||||
->update(['is_read' => true]);
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Notifikasi ditandai dibaca'
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Terdapat kesalahan!'
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function pengajuanFile(){
|
||||
return view('pengajuanFile.index', ['title' => 'Data Pending']);
|
||||
$katDok = MasterKategori::where('statusenabled', true)
|
||||
->select('master_kategori_directory_id', 'nama_kategori_directory')
|
||||
->get();
|
||||
return view('pengajuanFile.index', [
|
||||
'title' => 'Data Pending',
|
||||
'katDok' => $katDok
|
||||
]);
|
||||
}
|
||||
|
||||
public function dataPengajuanFile(){
|
||||
@ -1156,7 +1262,11 @@ class DashboardController extends Controller
|
||||
'entry_at' => $item->entry_at,
|
||||
'tanggal_terbit' => $item->tanggal_terbit,
|
||||
'permission_file' => $item->permission_file,
|
||||
'status_action' => $item->status_action
|
||||
'status_action' => $item->status_action,
|
||||
'revision' => $item->revision,
|
||||
'id_unit_kerja' => $item->id_unit_kerja,
|
||||
'id_sub_unit_kerja' => $item->id_sub_unit_kerja,
|
||||
'master_kategori_directory_id' => $item->master_kategori_directory_id
|
||||
];
|
||||
});
|
||||
return response()->json([
|
||||
@ -1172,4 +1282,127 @@ class DashboardController extends Controller
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatePengajuanFile(Request $request, string $id)
|
||||
{
|
||||
DB::connection('dbDirectory')->beginTransaction();
|
||||
try {
|
||||
$data = FileDirectory::where('file_directory_id', $id)
|
||||
->where('pegawai_id_entry', auth()->user()->objectpegawaifk)
|
||||
->first();
|
||||
|
||||
if (!$data) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Data tidak ditemukan'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$payload = [];
|
||||
$unitName = null;
|
||||
$subName = null;
|
||||
$kategoriName = null;
|
||||
|
||||
$parseIdName = function ($value) {
|
||||
$value = is_string($value) ? trim($value) : $value;
|
||||
if (!$value) {
|
||||
return [null, null];
|
||||
}
|
||||
if (is_string($value) && str_contains($value, '/')) {
|
||||
[$idVal, $nameVal] = explode('/', $value, 2);
|
||||
return [trim($idVal), trim($nameVal)];
|
||||
}
|
||||
return [$value, null];
|
||||
};
|
||||
|
||||
if ($request->has('id_unit_kerja')) {
|
||||
[$unitId, $unitName] = $parseIdName($request->input('id_unit_kerja'));
|
||||
if ($unitId !== null && $unitId !== '') {
|
||||
$payload['id_unit_kerja'] = $unitId;
|
||||
}
|
||||
}
|
||||
if ($request->has('id_sub_unit_kerja')) {
|
||||
[$subId, $subName] = $parseIdName($request->input('id_sub_unit_kerja'));
|
||||
if ($subId !== null && $subId !== '') {
|
||||
$payload['id_sub_unit_kerja'] = $subId;
|
||||
}
|
||||
}
|
||||
if ($request->has('master_kategori_directory_id')) {
|
||||
[$kategoriId, $kategoriName] = $parseIdName($request->input('master_kategori_directory_id'));
|
||||
if ($kategoriId !== null && $kategoriId !== '') {
|
||||
$payload['master_kategori_directory_id'] = $kategoriId;
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->has('no_dokumen')) {
|
||||
$payload['no_dokumen'] = $request->input('no_dokumen') ?: null;
|
||||
}
|
||||
if ($request->has('tanggal_terbit')) {
|
||||
$payload['tanggal_terbit'] = $request->input('tanggal_terbit') ?: null;
|
||||
}
|
||||
if ($request->has('permission_file')) {
|
||||
$permVal = $request->input('permission_file');
|
||||
if ($permVal !== null && $permVal !== '') {
|
||||
$payload['permission_file'] = $permVal === '1' || $permVal === 1 || $permVal === true || $permVal === 'true';
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->hasFile('file')) {
|
||||
$uploadedFile = $request->file('file');
|
||||
$fileInfo = pathinfo($data->file);
|
||||
$folderPath = $fileInfo['dirname'] ?? '';
|
||||
if ($folderPath === '.' || $folderPath === DIRECTORY_SEPARATOR) {
|
||||
$folderPath = '';
|
||||
}
|
||||
$existingParts = array_values(array_filter(explode('/', $data->file)));
|
||||
$existingUnit = $existingParts[0] ?? null;
|
||||
$existingSub = $existingParts[1] ?? null;
|
||||
$existingKategori = $existingParts[2] ?? null;
|
||||
$targetUnit = $unitName ?: $existingUnit;
|
||||
$targetSub = $subName ?: $existingSub;
|
||||
$targetKategori = $kategoriName ?: $existingKategori;
|
||||
if ($targetUnit && $targetSub && $targetKategori) {
|
||||
$folderPath = "{$targetUnit}/{$targetSub}/{$targetKategori}";
|
||||
}
|
||||
$imageName = $uploadedFile->getClientOriginalName();
|
||||
$path = $folderPath ? "{$folderPath}" : '';
|
||||
$uploadedFile->storeAs($path, $imageName, 'file_directory');
|
||||
$payload['file'] = ($path ? $path . '/' : '') . $imageName;
|
||||
}
|
||||
$payload['status_action'] = 'revised';
|
||||
|
||||
|
||||
if (!empty($payload)) {
|
||||
$data->update($payload);
|
||||
}
|
||||
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
|
||||
->where('objectpegawaifk', auth()->user()?->dataUser?->id)
|
||||
->first();
|
||||
$parts = array_values(array_filter(explode('/', $data->file)));
|
||||
$uploaderName = auth()->user()?->dataUser?->namalengkap ?? 'Pengguna';
|
||||
$docNumber = $data->no_dokumen ? 'nomor '. $data->no_dokumen : end($parts);;
|
||||
$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?->objectatasanlangsungfk,
|
||||
'pegawai_id' => 23521,
|
||||
];
|
||||
|
||||
Notifkasi::create($payloadNotification);
|
||||
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Data berhasil diperbarui'
|
||||
], 200);
|
||||
} catch (\Throwable $th) {
|
||||
DB::connection('dbDirectory')->rollBack();
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $th->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14
app/Models/Notifkasi.php
Normal file
14
app/Models/Notifkasi.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Notifkasi extends Model
|
||||
{
|
||||
protected $connection = 'dbDirectory';
|
||||
protected $table = 'public.notifikasi_file_directory';
|
||||
public $timestamps = false;
|
||||
protected $primaryKey = 'id';
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
@ -40,8 +40,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
|
||||
function statusBadge(status){
|
||||
if (status === 'rejected') return '<span class="badge bg-danger">Rejected</span>';
|
||||
if (status === 'revised') return '<span class="badge bg-info">Revised</span>';
|
||||
return '<span class="badge bg-warning text-dark">Pending</span>';
|
||||
}
|
||||
|
||||
function safeText(val){
|
||||
return val ? String(val) : '-';
|
||||
}
|
||||
|
||||
function buildRow(item){
|
||||
let tanggal = item.entry_at ? formatTanggal(item.entry_at) : '-';
|
||||
const 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 || ''}')">
|
||||
@ -55,22 +65,19 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
return `
|
||||
<tr>
|
||||
<td>${item?.status_action !== "rejected" ? aksi : ''}</td>
|
||||
<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>${safeText(item.no_dokumen)}</td>
|
||||
<td>${statusBadge(item?.status_action)}</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>
|
||||
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>
|
||||
<td class="text-nowrap">${tanggal}</td>
|
||||
<td>${safeText(item.pegawai_nama_entry)}</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
@ -120,7 +127,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (pageData.length === 0) {
|
||||
tbody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="7" class="text-center text-muted py-4">
|
||||
<td colspan="8" class="text-center text-muted py-4">
|
||||
Tidak ada data
|
||||
</td>
|
||||
</tr>
|
||||
@ -230,6 +237,19 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Reject',
|
||||
cancelButtonText: 'Batal',
|
||||
input: 'textarea',
|
||||
inputLabel: 'Catatan',
|
||||
inputPlaceholder: 'Tulis alasan atau catatan revisi...',
|
||||
inputAttributes: {
|
||||
'aria-label': 'Catatan'
|
||||
},
|
||||
preConfirm: (value) => {
|
||||
const revision = (value || '').trim();
|
||||
if (!revision) {
|
||||
Swal.showValidationMessage('Catatan revisi wajib diisi.');
|
||||
}
|
||||
return revision;
|
||||
}
|
||||
}).then((result) => {
|
||||
if (!result.isConfirmed) return;
|
||||
fetch(`/pending-file/${id}/reject`, {
|
||||
@ -238,6 +258,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
'X-CSRF-TOKEN': csrfToken,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
revision: result.value
|
||||
})
|
||||
}).then(async(res) => {
|
||||
const data = await res.json();
|
||||
if (!res.ok || !data?.status) {
|
||||
@ -261,7 +284,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.infoReject = function(id, fileName){
|
||||
const item = id;
|
||||
const revision = item?.revision ? String(item.revision) : 'Tidak ada catatan revisi.';
|
||||
Swal.fire({
|
||||
title: 'Catatan Revisi',
|
||||
text: revision,
|
||||
icon: 'info',
|
||||
confirmButtonText: 'Tutup'
|
||||
});
|
||||
}
|
||||
fetchData();
|
||||
|
||||
|
||||
@ -305,7 +337,8 @@ document.addEventListener('click', function(e){
|
||||
window.open(`/file-preview/${idDirectory}`, '_blank');
|
||||
}
|
||||
})
|
||||
function isPublic(permissionVal){
|
||||
|
||||
function isPublic(permissionVal){
|
||||
if(permissionVal === null || permissionVal === undefined) return false;
|
||||
const val = String(permissionVal).toLowerCase();
|
||||
return val === '1' || val === 'true' || val === 'iya' || val === 'yes';
|
||||
|
||||
@ -6,6 +6,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const pageSizeSelect = document.getElementById('tablePageSize');
|
||||
const startDateInput = document.getElementById('startDate');
|
||||
const endDateInput = document.getElementById('endDate');
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
||||
const editForm = document.getElementById('formEditPengajuanFile');
|
||||
const editUnitSelect = $('#edit_id_unit_kerja');
|
||||
const editSubUnitSelect = $('#edit_id_sub_unit_kerja');
|
||||
|
||||
if (pageSizeSelect) {
|
||||
const initialSize = parseInt(pageSizeSelect.value);
|
||||
@ -43,20 +47,27 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
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 class="btn btn-sm btn-info" onclick="infoReject('${item.file_directory_id}', '${item.fileName || ''}')">
|
||||
<i class="fa-solid fa-circle-info"></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 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 `
|
||||
<tr>
|
||||
<td>${aksi}</td>
|
||||
<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 class="btn btn-sm
|
||||
${item?.status_action === "rejected" ? 'btn-danger' :
|
||||
item?.status_action === "revised" ? 'btn-info' :
|
||||
'btn-warning'}">
|
||||
${item?.status_action === "rejected" ? 'Rejected' :
|
||||
item?.status_action === "revised" ? 'Revised' :
|
||||
'Pending'}
|
||||
</button>
|
||||
</td>
|
||||
<td><a href="#" class="file-link"
|
||||
@ -73,6 +84,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
`;
|
||||
}
|
||||
|
||||
function getItemById(id){
|
||||
return (tableState.data || []).find((row) => String(row.file_directory_id) === String(id));
|
||||
}
|
||||
|
||||
function renderPagination(totalPages){
|
||||
if (!paginationEl) return;
|
||||
if (totalPages <= 1) {
|
||||
@ -180,9 +195,177 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
}
|
||||
|
||||
window.infoReject = function(id, fileName){
|
||||
const item = getItemById(id);
|
||||
const revision = item?.revision ? String(item.revision) : 'Tidak ada catatan revisi.';
|
||||
Swal.fire({
|
||||
title: 'Catatan Revisi',
|
||||
text: revision,
|
||||
icon: 'info',
|
||||
confirmButtonText: 'Tutup'
|
||||
});
|
||||
}
|
||||
|
||||
function initEditSelects(){
|
||||
if (editUnitSelect.length) {
|
||||
editUnitSelect.select2({
|
||||
placeholder: '-- Pilih Unit Kerja --',
|
||||
allowClear: true,
|
||||
width: '100%',
|
||||
dropdownParent: $('#modalEditPengajuanFile'),
|
||||
ajax: {
|
||||
url: '/select-unit-kerja',
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function (params) {
|
||||
return { q: params.term || '' };
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {
|
||||
results: (data?.data || []).map(item => ({
|
||||
id: `${item.id}/${item.name}`,
|
||||
text: item.name
|
||||
}))
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
minimumInputLength: 0
|
||||
});
|
||||
}
|
||||
|
||||
if (editSubUnitSelect.length) {
|
||||
editSubUnitSelect.select2({
|
||||
placeholder: '-- Pilih Sub Unit Kerja --',
|
||||
allowClear: true,
|
||||
width: '100%',
|
||||
dropdownParent: $('#modalEditPengajuanFile')
|
||||
});
|
||||
}
|
||||
|
||||
editUnitSelect.on('change', function(){
|
||||
const val = $(this).val();
|
||||
if (!val) return;
|
||||
const unitId = String(val).split('/')[0];
|
||||
loadEditSubUnit(unitId, null, null);
|
||||
});
|
||||
}
|
||||
|
||||
function loadEditSubUnit(unitId, selectedSubId, selectedSubName){
|
||||
editSubUnitSelect.empty().append('<option value="" disabled selected>-- Pilih Sub Unit Kerja --</option>');
|
||||
if (!unitId) return;
|
||||
$.ajax({
|
||||
url: `/select-sub-unit-kerja/${unitId}`,
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
if (response?.data) {
|
||||
response.data.forEach(unit => {
|
||||
const optVal = `${unit.id}/${unit.name}`;
|
||||
const isSelected = selectedSubId && String(unit.id) === String(selectedSubId);
|
||||
const option = new Option(unit.name, optVal, false, isSelected);
|
||||
editSubUnitSelect.append(option);
|
||||
});
|
||||
if (selectedSubId && selectedSubName && editSubUnitSelect.find(`option[value="${selectedSubId}/${selectedSubName}"]`).length === 0) {
|
||||
editSubUnitSelect.append(new Option(selectedSubName, `${selectedSubId}/${selectedSubName}`, true, true));
|
||||
}
|
||||
editSubUnitSelect.trigger('change');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.editFileReject = function(id, fileName){
|
||||
const item = getItemById(id);
|
||||
if (!item) {
|
||||
Swal.fire({ icon: 'error', title: 'Gagal', text: 'Data tidak ditemukan.' });
|
||||
return;
|
||||
}
|
||||
const idEl = document.getElementById('edit_file_directory_id');
|
||||
const noEl = document.getElementById('edit_no_dokumen');
|
||||
const tglEl = document.getElementById('edit_tanggal_terbit');
|
||||
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 (tglEl) tglEl.value = item.tanggal_terbit || '';
|
||||
if (permYes && permNo) {
|
||||
const isPublic = item.permission_file === true || item.permission_file === 1 || item.permission_file === '1';
|
||||
permYes.checked = isPublic;
|
||||
permNo.checked = !isPublic;
|
||||
}
|
||||
|
||||
const parts = (item.file || '').split('/');
|
||||
const unitName = parts[0] || '';
|
||||
const subName = parts[1] || '';
|
||||
const kategoriName = parts[2] || '';
|
||||
|
||||
if (editUnitSelect.length && item.id_unit_kerja) {
|
||||
const unitVal = `${item.id_unit_kerja}/${unitName}`;
|
||||
editUnitSelect.append(new Option(unitName || 'Unit', unitVal, true, true)).trigger('change');
|
||||
const unitId = String(item.id_unit_kerja);
|
||||
loadEditSubUnit(unitId, item.id_sub_unit_kerja, subName);
|
||||
}
|
||||
|
||||
if (katEl && item.master_kategori_directory_id) {
|
||||
const katVal = `${item.master_kategori_directory_id}/${kategoriName}`;
|
||||
if (katEl.querySelector(`option[value="${katVal}"]`)) {
|
||||
katEl.value = katVal;
|
||||
} else {
|
||||
katEl.append(new Option(kategoriName || 'Kategori', katVal, true, true));
|
||||
katEl.value = katVal;
|
||||
}
|
||||
}
|
||||
|
||||
const modalEl = document.getElementById('modalEditPengajuanFile');
|
||||
if (modalEl) {
|
||||
$("#modalEditPengajuanFile").modal('show');
|
||||
}
|
||||
}
|
||||
|
||||
if (editForm) {
|
||||
editForm.addEventListener('submit', (e) => {
|
||||
e.preventDefault();
|
||||
const id = document.getElementById('edit_file_directory_id')?.value;
|
||||
if (!id) {
|
||||
Swal.fire({ icon: 'error', title: 'Gagal', text: 'ID dokumen tidak ditemukan.' });
|
||||
return;
|
||||
}
|
||||
const formData = new FormData(editForm);
|
||||
|
||||
fetch(`/pengajuan-file/${id}/update`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': csrfToken
|
||||
},
|
||||
body: formData
|
||||
}).then(async (res) => {
|
||||
const data = await res.json();
|
||||
if (!res.ok || !data?.status) {
|
||||
throw new Error(data?.message || 'Gagal memperbarui data.');
|
||||
}
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
text: data.message || 'Data berhasil diperbarui.',
|
||||
timer: 1500,
|
||||
showConfirmButton: false
|
||||
});
|
||||
$("#modalEditPengajuanFile").modal('hide');
|
||||
fetchData();
|
||||
}).catch((err) => {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Gagal',
|
||||
text: err.message || 'Terjadi kesalahan.'
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
initEditSelects();
|
||||
fetchData();
|
||||
|
||||
|
||||
});
|
||||
document.addEventListener('click', function(e){
|
||||
if(e.target.matches('.file-link')){
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
<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</th>
|
||||
<th style="width:15%;" class="text-center">Jumlah File</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="recapBody">
|
||||
|
||||
@ -54,8 +54,10 @@
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@if($authUnit = auth()->user()->masterPersetujuan)
|
||||
@php
|
||||
$isAtasan = \App\Models\MappingUnitKerjaPegawai::where('statusenabled', true)->where('objectatasanlangsungfk', auth()->user()->objectpegawaifk)->exists();
|
||||
@endphp
|
||||
@if($isAtasan || auth()->user()->objectpegawaifk === 23521)
|
||||
<li class="sidebar-item">
|
||||
<a class="sidebar-link d-flex align-items-center justify-content-between"
|
||||
href="{{ url('/pending-file') }}" aria-expanded="false">
|
||||
|
||||
@ -1,3 +1,43 @@
|
||||
<style>
|
||||
/* ===== NOTIFIKASI STYLE FACEBOOK ===== */
|
||||
|
||||
.message-body {
|
||||
max-height: 360px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* item notif */
|
||||
.message-body .dropdown-item {
|
||||
padding: 8px 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
white-space: normal;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
/* jarak antar notif */
|
||||
.message-body .dropdown-item + .dropdown-item {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* judul teks */
|
||||
.message-body .notif-text {
|
||||
color: #212529;
|
||||
}
|
||||
|
||||
/* waktu */
|
||||
.message-body .notif-time {
|
||||
font-size: 11px;
|
||||
color: #6c757d;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* hover ala Facebook */
|
||||
.message-body .dropdown-item:hover {
|
||||
background-color: #f0f2f5;
|
||||
}
|
||||
</style>
|
||||
|
||||
<header class="app-header">
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<ul class="navbar-nav">
|
||||
@ -6,25 +46,28 @@
|
||||
<i class="ti ti-menu-2"></i>
|
||||
</a>
|
||||
</li>
|
||||
{{-- <li class="nav-item dropdown">
|
||||
<a class="nav-link " href="javascript:void(0)" id="drop1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="ti ti-bell"></i>
|
||||
<div class="notification bg-primary rounded-circle"></div>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-animate-up" aria-labelledby="drop1">
|
||||
<div class="message-body">
|
||||
<a href="javascript:void(0)" class="dropdown-item">
|
||||
Item 1
|
||||
</a>
|
||||
<a href="javascript:void(0)" class="dropdown-item">
|
||||
Item 2
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</li> --}}
|
||||
</ul>
|
||||
<div class="navbar-collapse justify-content-end px-0" id="navbarNav">
|
||||
<ul class="navbar-nav flex-row ms-auto align-items-center justify-content-end">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link position-relative" href="javascript:void(0)" id="drop1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<span class="d-inline-flex align-items-center justify-content-center rounded-circle bg-light" style="width:46px;height:46px;">
|
||||
<i class="ti ti-bell text-primary"></i>
|
||||
</span>
|
||||
<span id="notifCountBadge" class="position-absolute top-0 start-50 badge rounded-pill bg-danger d-none">
|
||||
0
|
||||
</span>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-end dropdown-menu-animate-up shadow" aria-labelledby="drop1" style="min-width: 320px;">
|
||||
<div class="d-flex align-items-center justify-content-between px-3 border-bottom">
|
||||
<span class="fw-semibold">Notifikasi</span>
|
||||
<span class="small text-muted" id="notifCountText">0 baru</span>
|
||||
</div>
|
||||
<div class="message-body" id="notifList">
|
||||
<div class="dropdown-item text-muted small">Memuat...</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link " href="javascript:void(0)" id="drop2" data-bs-toggle="dropdown"
|
||||
@ -48,3 +91,68 @@
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const listEl = document.getElementById('notifList');
|
||||
const countTextEl = document.getElementById('notifCountText');
|
||||
const badgeEl = document.getElementById('notifCountBadge');
|
||||
|
||||
function setList(items) {
|
||||
if (!listEl) return;
|
||||
if (!items.length) {
|
||||
listEl.innerHTML = '<div class="dropdown-item text-muted small">Tidak ada notifikasi</div>';
|
||||
return;
|
||||
}
|
||||
listEl.innerHTML = items.map(item => `
|
||||
<a href="${item.url || '#'}" class="dropdown-item d-flex align-items-start gap-2">
|
||||
<span class="badge ${item.is_read ? 'bg-secondary' : 'bg-primary'} rounded-circle" style="width:10px;height:10px;margin-top:6px;"></span>
|
||||
<div>
|
||||
<div class="fw-semibold">${item.text_notifikasi || '-'}</div>
|
||||
<div class="small text-muted">${item.created_at || ''}</div>
|
||||
</div>
|
||||
</a>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
fetch('/data/notifications')
|
||||
.then(r => r.json())
|
||||
.then(res => {
|
||||
const unread = res?.status ? Number(res.unread || 0) : 0;
|
||||
const items = res?.status ? (res.data || []) : [];
|
||||
|
||||
if (countTextEl) countTextEl.textContent = `${unread} baru`;
|
||||
if (badgeEl) {
|
||||
if (unread > 0) {
|
||||
badgeEl.classList.remove('d-none');
|
||||
badgeEl.textContent = unread;
|
||||
} else {
|
||||
badgeEl.classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
setList(items);
|
||||
})
|
||||
.catch(() => {
|
||||
if (listEl) listEl.innerHTML = '<div class="dropdown-item text-muted small">Gagal memuat notifikasi</div>';
|
||||
});
|
||||
|
||||
const notifToggle = document.getElementById('drop1');
|
||||
if (notifToggle) {
|
||||
notifToggle.addEventListener('show.bs.dropdown', () => {
|
||||
const unread = Number(badgeEl?.textContent || 0);
|
||||
if (unread > 0) {
|
||||
fetch('/data/notifications/read', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || '',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
}).then(() => {
|
||||
if (countTextEl) countTextEl.textContent = '0 baru';
|
||||
if (badgeEl) badgeEl.classList.add('d-none');
|
||||
}).catch(() => {});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -44,15 +44,14 @@
|
||||
<table class="table table-sm table-hover align-middle mb-0" id="lastUpdatedTable">
|
||||
<thead>
|
||||
<tr>
|
||||
@if(auth()->user()->masterPersetujuan)
|
||||
<th>Aksi</th>
|
||||
@endif
|
||||
<th>No Dokumen</th>
|
||||
<th>No. Dokumen</th>
|
||||
<th>Status</th>
|
||||
<th>File</th>
|
||||
<th>Folder</th>
|
||||
<th>Unit/Sub Unit</th>
|
||||
<th>Tanggal</th>
|
||||
<th>Unit / Sub Unit</th>
|
||||
<th>Tanggal Upload</th>
|
||||
<th>Pengunggah</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tablePendingFile">
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
<table class="table table-sm table-hover align-middle mb-0" id="lastUpdatedTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Aksi</th>
|
||||
<th>No Dokumen</th>
|
||||
<th>Status</th>
|
||||
<th>File</th>
|
||||
@ -64,5 +65,6 @@
|
||||
</div>
|
||||
</div>
|
||||
@include('pendingFile.modal.view')
|
||||
@include('pengajuanFile.modal.edit')
|
||||
<script src="{{ ver('/js/pengajuanFile/index.js') }}"></script>
|
||||
@endsection
|
||||
|
||||
81
resources/views/pengajuanFile/modal/edit.blade.php
Normal file
81
resources/views/pengajuanFile/modal/edit.blade.php
Normal file
@ -0,0 +1,81 @@
|
||||
<div class="modal fade" id="modalEditPengajuanFile" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5">Edit Dokumen</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<form id="formEditPengajuanFile" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="modal-body">
|
||||
<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-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>
|
||||
</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>
|
||||
</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>
|
||||
@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">
|
||||
<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">
|
||||
<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">
|
||||
<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">
|
||||
<input class="form-check-input" type="radio" name="permission_file" id="edit_perm_yes" value="1" required>
|
||||
<label class="form-check-label" for="edit_perm_yes">Iya</label>
|
||||
</div>
|
||||
<div class="form-check mt-1">
|
||||
<input class="form-check-input" type="radio" name="permission_file" id="edit_perm_no" value="0" required>
|
||||
<label class="form-check-label" for="edit_perm_no">Tidak</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 mb-2">
|
||||
<label for="edit_file_upload" class="form-label fw-semibold">📂 Upload Dokumen (PDF)</label>
|
||||
<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>
|
||||
<div class="form-text text-muted">Kosongkan jika tidak mengganti file.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tutup</button>
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -14,7 +14,7 @@ Route::middleware(['auth'])->group(function(){
|
||||
Route::get('/', [DashboardController::class, 'index']);
|
||||
Route::get('/data-internal', [DashboardController::class, 'dataUnitInternal']);
|
||||
Route::get('/data-umum', [DashboardController::class, 'dataUmum']);
|
||||
Route::get('/datatable-umum', [DashboardController::class, 'dataDocumentLast']);
|
||||
Route::get('/datatable-umum', [DashboardController::class, 'datatableDataUmum']);
|
||||
Route::post('/uploadv2', [DashboardController::class, 'storeVersion2']);
|
||||
Route::get('/file-preview/{id}', [DashboardController::class, 'dataPdf']);
|
||||
Route::post('/upload', [DashboardController::class, 'store']);
|
||||
@ -51,14 +51,18 @@ Route::middleware(['auth'])->group(function(){
|
||||
|
||||
Route::get('/pengajuan-file', [DashboardController::class, 'pengajuanFile']);
|
||||
Route::get('/datatable/pengajuan-file', [DashboardController::class, 'dataPengajuanFile']);
|
||||
Route::post('/pengajuan-file/{id}/update', [DashboardController::class, 'updatePengajuanFile']);
|
||||
|
||||
Route::middleware(['master.persetujuan'])->group(function () {
|
||||
// Route::middleware(['master.persetujuan'])->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/{id}/reject', [DashboardController::class, 'rejectPendingFile']);
|
||||
Route::get('/data/count-pending', [DashboardController::class, 'countDataPending']);
|
||||
});
|
||||
Route::get('/data/count-rejected', [DashboardController::class, 'countRejectedPengajuan']);
|
||||
// });
|
||||
Route::get('/data/notifications', [DashboardController::class, 'notifkasiList']);
|
||||
Route::post('/data/notifications/read', [DashboardController::class, 'notifkasiMarkRead']);
|
||||
});
|
||||
|
||||
Route::get('/login', [AuthController::class, 'index'])->name('login');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user