add akses tata usaha
This commit is contained in:
parent
444426c8e5
commit
3be01956b3
@ -145,22 +145,18 @@ class DashboardController extends Controller
|
||||
public function dataUnitInternal(){
|
||||
$perPage = (int) request('per_page', 10);
|
||||
// $authUnitId = auth()->user()->dataUser?->mappingUnitKerjaPegawai[0]?->objectunitkerjapegawaifk;
|
||||
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true);
|
||||
if(auth()->user()){
|
||||
$mapping->where('objectpegawaifk', auth()->user()->dataUser->id);
|
||||
}else{
|
||||
$mapping->where('objectpegawaifk', 937);
|
||||
}
|
||||
$mapping->get(['objectunitkerjapegawaifk', 'objectsubunitkerjapegawaifk']);
|
||||
$userId = auth()->user()->dataUser->id ?? 937;
|
||||
$mapping = MappingUnitKerjaPegawai::where('statusenabled', true)
|
||||
->where('objectpegawaifk', $userId)
|
||||
->get(['objectunitkerjapegawaifk']);
|
||||
$unitIds = $mapping->pluck('objectunitkerjapegawaifk')
|
||||
->filter() // buang null
|
||||
->unique()
|
||||
->values()
|
||||
->all();
|
||||
->toArray();
|
||||
$keyword = request('keyword');
|
||||
$kategori = request('kategori');
|
||||
$kategoriHeader = request('kategori_header');
|
||||
|
||||
$unitFilter = request('unit');
|
||||
$kategoriValues = is_array($kategori)
|
||||
? array_values(array_filter($kategori))
|
||||
@ -195,16 +191,17 @@ class DashboardController extends Controller
|
||||
}
|
||||
$kategoriIds[] = $val;
|
||||
}
|
||||
$unitFilterIds = is_array($unitFilter)
|
||||
? array_values(array_filter($unitFilter))
|
||||
: array_values(array_filter(explode(',', (string) $unitFilter)));
|
||||
if (!empty($unitFilterIds)) {
|
||||
$unitIds = array_values(array_intersect($unitIds, $unitFilterIds));
|
||||
}
|
||||
$baseQuery = FileDirectory::with('kategori')
|
||||
->when(!empty($unitFilter), function($q) use($unitFilter){
|
||||
$q->whereIn('id_unit_kerja', $unitFilter);
|
||||
})
|
||||
->where('statusenabled', true)
|
||||
->where('status_action', 'approved')
|
||||
->whereIn('id_unit_kerja', $unitIds);
|
||||
->where('status_action', 'approved');
|
||||
|
||||
if(in_array(22, $unitIds)){
|
||||
}else{
|
||||
$baseQuery = $baseQuery->whereIn('id_unit_kerja', $unitIds);
|
||||
}
|
||||
|
||||
$query = (clone $baseQuery)
|
||||
->when(!empty($kategoriIds) || !empty($kategoriTypes) || !empty($kategoriHukumValues), function ($q) use ($kategoriIds, $kategoriTypes, $kategoriHukumValues) {
|
||||
@ -628,18 +625,23 @@ class DashboardController extends Controller
|
||||
|
||||
$unitIds = $mapping->pluck('objectunitkerjapegawaifk')->filter()->unique()->values();
|
||||
$subIds = $mapping->pluck('objectsubunitkerjapegawaifk')->filter()->unique()->values();
|
||||
$units = UnitKerja::where('statusenabled', true);
|
||||
if($unitIds->contains(22)){
|
||||
}else{
|
||||
$units->when($unitIds->isNotEmpty(), fn($q2) => $q2->whereIn('id', $unitIds));
|
||||
}
|
||||
|
||||
$units = UnitKerja::where('statusenabled', true)
|
||||
->when($unitIds->isNotEmpty(), fn($q2) => $q2->whereIn('id', $unitIds))
|
||||
->when($q, fn($q2) => $q2->where('name', 'ILIKE', '%' . $q . '%'))
|
||||
$units = $units->when($q, fn($q2) => $q2->where('name', 'ILIKE', '%' . $q . '%'))
|
||||
->select('id', 'name')
|
||||
->get();
|
||||
|
||||
$subUnits = $subIds->isNotEmpty()
|
||||
? SubUnitKerja::where('statusenabled', true)
|
||||
->whereIn('id', $subIds)
|
||||
->get(['id', 'name', 'objectunitkerjapegawaifk'])
|
||||
: collect();
|
||||
$subUnits = SubUnitKerja::where('statusenabled', true);
|
||||
if($unitIds->contains(22)){
|
||||
|
||||
}else{
|
||||
$subUnits = $subUnits->whereIn('id', $subIds);
|
||||
}
|
||||
$subUnits = $subUnits->get(['id', 'name', 'objectunitkerjapegawaifk']);
|
||||
|
||||
$subMap = $subUnits->groupBy('objectunitkerjapegawaifk')->map(function($items){
|
||||
return $items->map(fn($s) => ['id' => $s->id, 'name' => $s->name])->values();
|
||||
@ -1558,9 +1560,12 @@ class DashboardController extends Controller
|
||||
private function buildRecapData(array $unitIds, string $keyword = ''): array
|
||||
{
|
||||
$rows = FileDirectory::where('statusenabled', true)
|
||||
->whereNotNull('status_action')->where('status_action', 'approved')
|
||||
->whereIn('id_unit_kerja', $unitIds)
|
||||
->pluck('file');
|
||||
->whereNotNull('status_action')->where('status_action', 'approved');
|
||||
if(in_array(22, $unitIds)){
|
||||
$rows = $rows->pluck('file');
|
||||
}else{
|
||||
$rows = $rows->whereIn('id_unit_kerja', $unitIds)->pluck('file');
|
||||
}
|
||||
|
||||
$grouped = [];
|
||||
foreach ($rows as $path) {
|
||||
|
||||
@ -41,9 +41,12 @@ class LogActivityController extends Controller
|
||||
$q->select(DB::raw('COUNT(DISTINCT pegawai_id_entry)'));
|
||||
}])
|
||||
->where('statusenabled', true)
|
||||
->where('status_action', 'approved')
|
||||
->whereIn('id_unit_kerja', $unitIds)
|
||||
->orderBy('entry_at','desc');
|
||||
->where('status_action', 'approved');
|
||||
if(in_array(22, $unitIds)){
|
||||
}else{
|
||||
$query = $baseQuery->whereIn('id_unit_kerja', $unitIds);
|
||||
}
|
||||
$query = $query->orderBy('entry_at','desc');
|
||||
|
||||
if($keyword){
|
||||
$query->where(function($q) use ($keyword){
|
||||
|
||||
@ -36,6 +36,15 @@
|
||||
color: #111 !important;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--single .select2-selection__clear {
|
||||
display: inline-block !important;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #999;
|
||||
margin-right: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table-header-filter .dropdown-menu {
|
||||
z-index: 1080;
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
@extends('layout.main')
|
||||
<style>
|
||||
/* --- SELECT2: teks terlihat (hitam) --- */
|
||||
|
||||
.select2-container--default .select2-selection--multiple {
|
||||
background: #fff !important;
|
||||
border: 1px solid #ced4da !important;
|
||||
border: 1px solid rgb(206, 212, 218) !important;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
|
||||
@ -34,7 +35,14 @@
|
||||
border: 1px solid #dee2e6 !important;
|
||||
color: #111 !important;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--single .select2-selection__clear {
|
||||
display: inline-block !important;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #999;
|
||||
margin-right: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.table-header-filter .dropdown-menu {
|
||||
z-index: 1080;
|
||||
}
|
||||
@ -108,8 +116,10 @@
|
||||
</div>
|
||||
<div class="d-flex flex-column flex-md-row align-items-md-center gap-2 mb-3">
|
||||
<div class="d-flex flex-column flex-md-row align-items-md-center gap-2 flex-grow-1">
|
||||
<select id="tableUnit" class="form-select form-select-sm unit_kerja_filter" style="max-width: 260px;"></select>
|
||||
<select id="tableKategori" class="form-select form-select-sm kategori_kerja_filter" style="max-width: 260px;">
|
||||
<select id="tableUnit" style="max-width: 260px;">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
<select id="tableKategori" class="form-select form-select-sm" style="max-width: 260px;">
|
||||
<option value="">Kategori (Semua)</option>
|
||||
<option value="akreditasi">Kategori Akreditasi</option>
|
||||
<option value="hukum">Kategori Hukum</option>
|
||||
@ -220,6 +230,14 @@
|
||||
const colorCache = {};
|
||||
const colorPalette = ['#e8f4ff', '#fff6e5', '#e9f7ef', '#f3e8ff', '#ffe6ea', '#e6f5f3'];
|
||||
|
||||
function normalizeToArray(value){
|
||||
if (Array.isArray(value)) {
|
||||
return value.filter(v => v !== null && v !== undefined && v !== '');
|
||||
}
|
||||
if (value === null || value === undefined || value === '') return [];
|
||||
return [value];
|
||||
}
|
||||
|
||||
document.addEventListener('change', function(e){
|
||||
if(!e.target.classList.contains('toggle-expired')) return;
|
||||
const targetId = e.target.getAttribute('data-target');
|
||||
@ -248,8 +266,6 @@
|
||||
allowClear: true,
|
||||
width: '100%',
|
||||
closeOnSelect: false,
|
||||
selectionCssClass: 'select2-filter-selection',
|
||||
dropdownCssClass: 'select2-filter-dropdown',
|
||||
ajax: {
|
||||
url: '/select-unit-kerja-mapping',
|
||||
dataType: 'json',
|
||||
@ -268,9 +284,7 @@
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
$('#tableUnit').on('change', function () {
|
||||
tableState.unit = $(this).val() || [];
|
||||
});
|
||||
|
||||
}
|
||||
if (kategoriSelect) {
|
||||
$('#tableKategori').select2({
|
||||
@ -596,7 +610,7 @@
|
||||
${item.unit?.name || '-'}
|
||||
</td>
|
||||
<td class="text-nowrap">${formatTanggal(item.entry_at)}</td>
|
||||
<td class="text-nowrap">${item.pegawai_nama_entry || '-'}</td>
|
||||
<td style="max-width: 200px; white-space: normal; word-wrap: break-word;">${item.pegawai_nama_entry || '-'}</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
@ -674,7 +688,9 @@
|
||||
function applyTableSearch(){
|
||||
const value = searchInput ? searchInput.value : '';
|
||||
tableState.search = (value || '').trim();
|
||||
tableState.unit = unitSelect && window.$ ? ($('#tableUnit').val() || []) : (tableState.unit || []);
|
||||
tableState.unit = normalizeToArray(
|
||||
unitSelect && window.$ ? $('#tableUnit').val() : tableState.unit
|
||||
);
|
||||
const katVal = kategoriSelect && window.$ ? ($('#tableKategori').val() || '') : (kategoriSelect?.value || '');
|
||||
tableState.kategoriType = katVal ? [katVal] : (tableState.kategoriType || []);
|
||||
tableState.page = 1;
|
||||
@ -777,8 +793,9 @@
|
||||
per_page: tableState.pageSize,
|
||||
keyword: tableState.search
|
||||
});
|
||||
if (tableState.unit && tableState.unit.length > 0) {
|
||||
tableState.unit.forEach(id => params.append('unit[]', id));
|
||||
const unitValues = normalizeToArray(tableState.unit);
|
||||
if (unitValues.length > 0) {
|
||||
unitValues.forEach(id => params.append('unit[]', id));
|
||||
}
|
||||
if (tableState.kategoriType && tableState.kategoriType.length > 0) {
|
||||
tableState.kategoriType.forEach(id => params.append('kategori[]', id));
|
||||
@ -802,17 +819,13 @@
|
||||
})
|
||||
}
|
||||
|
||||
if (searchBtn) {
|
||||
searchBtn.addEventListener('click', applyTableSearch);
|
||||
}
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
applyTableSearch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function formatTanggal(dateString) {
|
||||
const d = new Date(dateString);
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
<span class="hide-menu">Dokumen Umum</span>
|
||||
</a>
|
||||
</li>
|
||||
@if(Auth::guard('admin')->check() || (Auth::check() && auth()->user()->dataUser->mappingUnitKerjaPegawai()->where('objectunitkerjapegawaifk', 51)->exists()))
|
||||
@if(Auth::guard('admin')->check() || (Auth::check() && auth()->user()->dataUser->mappingUnitKerjaPegawai()->whereIn('objectunitkerjapegawaifk', [51, 22])->exists()))
|
||||
<li class="sidebar-item">
|
||||
<a class="sidebar-link" href="{{ url('/data-akreditasi') }}" aria-expanded="false">
|
||||
<i class="fa-solid fa-sliders"></i>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user