@php
$reservasiNotif = function () use ($users_rules, $user_login) {
try {
$roles = $users_rules ?? [];
$user = $user_login ?? null;
$query = DB::table('trs_pra_pr_header as h')
->where('h.isactive', '1');
if (in_array('spv', $roles, true) && $user) {
$query->join('users_karyawan as uk', 'h.user_karyawan_id', '=', 'uk.id')
->where('uk.user_id', $user->id)
->where('uk.isactive', '1')
->where(function ($spvNotif) {
$spvNotif->whereRaw("LOWER(TRIM(h.status)) = 'entry'")
->orWhereExists(function ($headReject) {
$headReject->select(DB::raw(1))
->from('trs_pr_detail as d_reject')
->whereColumn('d_reject.id_prapr', 'h.id')
->where('d_reject.isactive', '1')
->whereRaw("LOWER(TRIM(d_reject.status)) = 'reject'")
->whereNotNull('d_reject.appr_head_by')
->whereNull('d_reject.appr_ppic_by');
});
});
} elseif (in_array('head', $roles, true) && !in_array('admins', $roles, true) && !in_array('spv', $roles, true)) {
$deptId = method_exists($user, 'getDepartemenId') ? $user->getDepartemenId() : ($user->id_departemen ?? null);
$query->join('trs_pr_detail as d', 'd.id_prapr', '=', 'h.id')
->where('d.isactive', '1')
->whereRaw("LOWER(TRIM(d.status)) = 'pending head'");
if ($deptId) {
$query->where('h.id_departemen', $deptId);
}
} elseif (in_array('ppic', $roles, true) && !in_array('admins', $roles, true) && !in_array('spv', $roles, true)) {
$query->join('trs_pr_detail as d', 'd.id_prapr', '=', 'h.id')
->where('d.isactive', '1')
->whereIn(DB::raw('LOWER(TRIM(d.status))'), ['pending ppic', 'parsial']);
} elseif (in_array('admins', $roles, true)) {
$query->join('trs_pr_detail as d', 'd.id_prapr', '=', 'h.id')
->where('d.isactive', '1')
->whereIn(DB::raw('LOWER(TRIM(d.status))'), ['pending ppic']);
}
return $query->distinct('h.id')->count('h.id');
} catch (\Throwable $e) {
return 0;
}
};
@endphp
{{-- LOOPING GMENU --}}
@foreach ($gmenu as $g)
@if ($g->gmenu == 'blankx')
{{-- Query DMenu --}}
@php
$querydmenu = DB::table('sys_dmenu')
->join('sys_auth', 'sys_dmenu.dmenu', '=', 'sys_auth.dmenu')
->whereIn('sys_auth.idroles', $users_rules)
->where('sys_dmenu.isactive', '1')
->where('sys_dmenu.show', '1')
->where('sys_auth.isactive', '1')
->where('sys_dmenu.gmenu', $g->gmenu)
->select('sys_dmenu.*')
->distinct()
->orderBy('sys_dmenu.urut', 'asc')
->get();
@endphp
@foreach ($querydmenu as $d)
-
@endforeach
@else
-
name == $title_group ? 'aria-expanded=true' : '' }}>
{{ $g->name }}
@endif
@endforeach