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