add akses tata usaha

This commit is contained in:
JokoPrasetio 2026-03-12 14:43:31 +07:00
parent 3be01956b3
commit 99a34e8e59
2 changed files with 19 additions and 6 deletions

View File

@ -198,7 +198,9 @@ class DashboardController extends Controller
->where('statusenabled', true)
->where('status_action', 'approved');
if(in_array(22, $unitIds)){
if(in_array(22, $unitIds)){
}elseif(auth()->user()->username === "admin.turt"){
}else{
$baseQuery = $baseQuery->whereIn('id_unit_kerja', $unitIds);
}
@ -627,6 +629,7 @@ class DashboardController extends Controller
$subIds = $mapping->pluck('objectsubunitkerjapegawaifk')->filter()->unique()->values();
$units = UnitKerja::where('statusenabled', true);
if($unitIds->contains(22)){
}elseif(auth()->user()->username === "admin.turt"){
}else{
$units->when($unitIds->isNotEmpty(), fn($q2) => $q2->whereIn('id', $unitIds));
}
@ -1328,9 +1331,13 @@ class DashboardController extends Controller
abort(404, 'PDF Tidak ditemukan');
}
$user = auth()->user()->dataUser;
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
$mapping = null;
if($user){
$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,
@ -1345,7 +1352,7 @@ class DashboardController extends Controller
'id_sub_unit_kerja' => $mapping ? $mapping->objectsubunitkerjapegawaifk : null,
];
LogActivity::create($payloadLog);
}
$fileInfo = get_file_s3($data->file);
if (!$fileInfo || empty($fileInfo['file'])) {
@ -1523,6 +1530,8 @@ class DashboardController extends Controller
$keyword = strtolower(request('keyword', ''));
// $authUnit = auth()->user()->masterPersetujuan->details->pluck('unit_pegawai_id')->unique()->toArray();
$user = auth()->user()->dataUser;
$unitIds = [];
if($user){
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
->where('objectpegawaifk', $user->id)
->get(['objectunitkerjapegawaifk', 'objectsubunitkerjapegawaifk']);
@ -1531,6 +1540,7 @@ class DashboardController extends Controller
->unique()
->values()
->all();
}
$result = $this->buildRecapData($unitIds, $keyword);
// paginate manually
$total = count($result);
@ -1550,6 +1560,7 @@ class DashboardController extends Controller
]
]);
} catch (\Throwable $th) {
dd($th);
return response()->json([
'status' => false,
'message' => 'Gagal! mendapatkan data'
@ -1563,10 +1574,11 @@ class DashboardController extends Controller
->whereNotNull('status_action')->where('status_action', 'approved');
if(in_array(22, $unitIds)){
$rows = $rows->pluck('file');
}elseif(auth()->user()->username === "admin.turt"){
$rows = $rows->pluck('file');
}else{
$rows = $rows->whereIn('id_unit_kerja', $unitIds)->pluck('file');
}
$grouped = [];
foreach ($rows as $path) {
$parts = array_values(array_filter(explode('/', $path)));

View File

@ -24,7 +24,8 @@ class LogActivityController extends Controller
$start = request('start_date');
$end = request('end_date');
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true);
if(auth()->user()){
// dd(auth()->user());
if(!Auth::guard('admin')){
$mapping->where('objectpegawaifk', auth()->user()->dataUser->id);
}else{
$mapping->where('objectpegawaifk', 937);
@ -42,7 +43,7 @@ class LogActivityController extends Controller
}])
->where('statusenabled', true)
->where('status_action', 'approved');
if(in_array(22, $unitIds)){
if(in_array(22, $unitIds) || Auth::guard('admin') && Auth::guard('admin')->user()->id == 300){
}else{
$query = $baseQuery->whereIn('id_unit_kerja', $unitIds);
}