fix(qma,pg): filterable inputs for unit transfer & timesheet, fix unit edit division, and auto guard rejection
This commit is contained in:
@@ -657,20 +657,14 @@
|
||||
<!-- Form Penolakan -->
|
||||
<form id="rejectForm" method="POST" action="" class="space-y-4">
|
||||
@csrf
|
||||
@if($currentGuard)
|
||||
<input type="hidden" name="security_guard_id" value="{{ $currentGuard->id }}">
|
||||
@elseif($guards->isNotEmpty())
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-700 mb-1">
|
||||
Petugas Satpam Pemeriksa <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<select name="security_guard_id" required class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-rose-600">
|
||||
@foreach($guards as $g)
|
||||
<option value="{{ $g->id }}">{{ $g->name }} (Reg: {{ $g->badge_id }})</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
<!-- Petugas yang Menolak (Otomatis Akun Login) -->
|
||||
<div class="p-3 bg-slate-50 border border-slate-200/80 rounded-2xl flex items-center justify-between text-xs">
|
||||
<span class="text-slate-500 font-medium">Petugas Pemeriksa:</span>
|
||||
<span class="font-bold text-slate-800 flex items-center space-x-1.5">
|
||||
<i class="fa-solid fa-user-shield text-[#1b5e20]"></i>
|
||||
<span>{{ auth()->user()?->name ?? 'Petugas Pos Gerbang' }}</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Quick Reason Chips -->
|
||||
<div>
|
||||
|
||||
@@ -529,13 +529,27 @@
|
||||
<span>Heavy Equipment <span class="text-rose-500">*</span></span>
|
||||
<span id="addUnitCounterBadge" class="text-[10px] font-semibold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded border border-emerald-200 hidden"></span>
|
||||
</label>
|
||||
<select name="vehicle_id"
|
||||
id="addVehicleSelect"
|
||||
required
|
||||
onchange="onVehicleSelectChanged(this, 'add')"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
||||
<option value="" disabled selected>-- Pilih Lokasi Kerja Terlebih Dahulu --</option>
|
||||
</select>
|
||||
<div class="space-y-1.5">
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-magnifying-glass absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
id="addVehicleSearch"
|
||||
placeholder="Ketik untuk filter unit (kode / merek)..."
|
||||
oninput="filterTimesheetVehicleOptions(this.value, 'add')"
|
||||
autocomplete="off"
|
||||
class="w-full pl-8 pr-7 py-2 text-xs rounded-xl border border-slate-200 bg-slate-50 focus:bg-white focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition font-medium">
|
||||
<button type="button" onclick="clearTimesheetVehicleFilter('add')" id="clearAddVehicleSearchBtn" class="hidden absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 cursor-pointer">
|
||||
<i class="fa-solid fa-xmark text-xs"></i>
|
||||
</button>
|
||||
</div>
|
||||
<select name="vehicle_id"
|
||||
id="addVehicleSelect"
|
||||
required
|
||||
onchange="onVehicleSelectChanged(this, 'add')"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
||||
<option value="" disabled selected>-- Pilih Lokasi Kerja Terlebih Dahulu --</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="addVehiclePreview" class="hidden mt-1.5 px-3 py-1.5 rounded-lg bg-emerald-50 border border-emerald-200/80 text-[11px] text-emerald-900 flex items-center justify-between">
|
||||
<span id="addVehiclePreviewText" class="font-bold"></span>
|
||||
<span id="addVehicleLastKmText" class="text-emerald-700 font-mono text-[10px]"></span>
|
||||
@@ -883,13 +897,27 @@
|
||||
<span>Heavy Equipment <span class="text-rose-500">*</span></span>
|
||||
<span id="editUnitCounterBadge" class="text-[10px] font-semibold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded border border-emerald-200 hidden"></span>
|
||||
</label>
|
||||
<select name="vehicle_id"
|
||||
id="editVehicleSelect"
|
||||
required
|
||||
onchange="onVehicleSelectChanged(this, 'edit')"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
||||
<option value="" disabled selected>-- Pilih Lokasi Kerja Terlebih Dahulu --</option>
|
||||
</select>
|
||||
<div class="space-y-1.5">
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-magnifying-glass absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
id="editVehicleSearch"
|
||||
placeholder="Ketik untuk filter unit (kode / merek)..."
|
||||
oninput="filterTimesheetVehicleOptions(this.value, 'edit')"
|
||||
autocomplete="off"
|
||||
class="w-full pl-8 pr-7 py-2 text-xs rounded-xl border border-slate-200 bg-slate-50 focus:bg-white focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition font-medium">
|
||||
<button type="button" onclick="clearTimesheetVehicleFilter('edit')" id="clearEditVehicleSearchBtn" class="hidden absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 cursor-pointer">
|
||||
<i class="fa-solid fa-xmark text-xs"></i>
|
||||
</button>
|
||||
</div>
|
||||
<select name="vehicle_id"
|
||||
id="editVehicleSelect"
|
||||
required
|
||||
onchange="onVehicleSelectChanged(this, 'edit')"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
||||
<option value="" disabled selected>-- Pilih Lokasi Kerja Terlebih Dahulu --</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="editVehiclePreview" class="hidden mt-1.5 px-3 py-1.5 rounded-lg bg-emerald-50 border border-emerald-200/80 text-[11px] text-emerald-900 flex items-center justify-between">
|
||||
<span id="editVehiclePreviewText" class="font-bold"></span>
|
||||
<span id="editVehicleLastKmText" class="text-emerald-700 font-mono text-[10px]"></span>
|
||||
@@ -1604,6 +1632,12 @@
|
||||
counterBadge.textContent = `${filteredUnits.length} Unit Ready`;
|
||||
}
|
||||
|
||||
// Reset input filter unit realtime
|
||||
const vSearch = document.getElementById(`${prefix}VehicleSearch`);
|
||||
if (vSearch) vSearch.value = '';
|
||||
const vClear = document.getElementById(`clear${prefix === 'add' ? 'Add' : 'Edit'}VehicleSearchBtn`);
|
||||
if (vClear) vClear.classList.add('hidden');
|
||||
|
||||
// Render option heavy equipment
|
||||
vehicleSelect.innerHTML = '';
|
||||
const defaultPrompt = document.createElement('option');
|
||||
@@ -1654,6 +1688,58 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Realtime Dropdown Heavy Equipment pada Timesheet berdasarkan Ketikan
|
||||
*/
|
||||
function filterTimesheetVehicleOptions(query, prefix) {
|
||||
const select = document.getElementById(`${prefix}VehicleSelect`);
|
||||
const clearBtn = document.getElementById(`clear${prefix === 'add' ? 'Add' : 'Edit'}VehicleSearchBtn`);
|
||||
const badge = document.getElementById(`${prefix}UnitCounterBadge`);
|
||||
if (!select) return;
|
||||
|
||||
const q = (query || '').trim().toLowerCase();
|
||||
if (clearBtn) {
|
||||
clearBtn.classList.toggle('hidden', !q);
|
||||
}
|
||||
|
||||
let visibleCount = 0;
|
||||
let firstMatch = null;
|
||||
|
||||
Array.from(select.options).forEach(opt => {
|
||||
if (!opt.value) {
|
||||
opt.hidden = false;
|
||||
return;
|
||||
}
|
||||
const code = (opt.getAttribute('data-code') || '').toLowerCase();
|
||||
const brand = (opt.getAttribute('data-brand') || '').toLowerCase();
|
||||
const loc = (opt.getAttribute('data-location') || '').toLowerCase();
|
||||
const text = opt.textContent.toLowerCase();
|
||||
|
||||
const match = text.includes(q) || code.includes(q) || brand.includes(q) || loc.includes(q);
|
||||
opt.hidden = !match;
|
||||
if (match) {
|
||||
visibleCount++;
|
||||
if (!firstMatch) firstMatch = opt;
|
||||
}
|
||||
});
|
||||
|
||||
if (badge) {
|
||||
badge.classList.remove('hidden');
|
||||
badge.textContent = q ? `${visibleCount} Unit Cocok` : `${visibleCount} Unit Ready`;
|
||||
}
|
||||
|
||||
if (q && visibleCount === 1 && firstMatch) {
|
||||
select.value = firstMatch.value;
|
||||
onVehicleSelectChanged(select, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
function clearTimesheetVehicleFilter(prefix) {
|
||||
const input = document.getElementById(`${prefix}VehicleSearch`);
|
||||
if (input) input.value = '';
|
||||
filterTimesheetVehicleOptions('', prefix);
|
||||
}
|
||||
|
||||
// 7. Handler saat Heavy Equipment Dipilih
|
||||
function onVehicleSelectChanged(selectEl, prefix) {
|
||||
const opt = selectEl.options[selectEl.selectedIndex];
|
||||
|
||||
@@ -68,29 +68,43 @@
|
||||
<div>
|
||||
<label for="origin_location" class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||
<span>Lokasi Awal (Asal Unit) <span class="text-rose-500">*</span></span>
|
||||
<span class="text-[10px] text-emerald-700 font-semibold">Filter Berdasarkan Posisi</span>
|
||||
<span class="text-[10px] text-emerald-700 font-semibold">Bisa ketik / filter</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-map-pin absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<select name="from_location"
|
||||
id="origin_location"
|
||||
required
|
||||
onchange="onOriginLocationChanged(this.value)"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-800 font-bold">
|
||||
<option value="" disabled {{ empty($selectedOriginLocation) && !old('from_location') ? 'selected' : '' }}>
|
||||
-- Pilih Lokasi Awal Alat Berat --
|
||||
</option>
|
||||
<option value="ALL" {{ old('from_location', $selectedOriginLocation) === 'ALL' ? 'selected' : '' }}>
|
||||
[Tampilkan Semua Lokasi / Semua Alat Berat]
|
||||
</option>
|
||||
@foreach($originLocations as $locName => $count)
|
||||
<option value="{{ $locName }}" {{ old('from_location', $selectedOriginLocation) === $locName ? 'selected' : '' }}>
|
||||
{{ $locName }} ({{ $count }} Unit Tersedia)
|
||||
<div class="space-y-1.5">
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-magnifying-glass absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
id="originLocationSearch"
|
||||
placeholder="Ketik untuk memfilter pilihan lokasi asal..."
|
||||
oninput="filterOriginLocationSelect(this.value)"
|
||||
autocomplete="off"
|
||||
class="w-full pl-9 pr-7 py-2 text-xs rounded-xl border border-slate-200 bg-slate-50 focus:bg-white focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition font-medium">
|
||||
<button type="button" onclick="clearOriginLocationFilter()" id="clearOriginLocationFilterBtn" class="hidden absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 cursor-pointer">
|
||||
<i class="fa-solid fa-xmark text-xs"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-map-pin absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<select name="from_location"
|
||||
id="origin_location"
|
||||
required
|
||||
onchange="onOriginLocationChanged(this.value)"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-800 font-bold">
|
||||
<option value="" disabled {{ empty($selectedOriginLocation) && !old('from_location') ? 'selected' : '' }}>
|
||||
-- Pilih Lokasi Awal Alat Berat --
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<option value="ALL" {{ old('from_location', $selectedOriginLocation) === 'ALL' ? 'selected' : '' }}>
|
||||
[Tampilkan Semua Lokasi / Semua Alat Berat]
|
||||
</option>
|
||||
@foreach($originLocations as $locName => $count)
|
||||
<option value="{{ $locName }}" {{ old('from_location', $selectedOriginLocation) === $locName ? 'selected' : '' }}>
|
||||
{{ $locName }} ({{ $count }} Unit Tersedia)
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-[10px] text-slate-400 mt-1">Memilih lokasi awal akan memfilter unit alat berat yang berada di titik tersebut.</p>
|
||||
<p class="text-[10px] text-slate-400 mt-1">Ketik nama lokasi atau pilih dari daftar untuk memfilter unit.</p>
|
||||
</div>
|
||||
|
||||
<!-- PILIH ALAT BERAT YANG AKAN DIPINDAHKAN -->
|
||||
@@ -99,27 +113,41 @@
|
||||
<span>Unit Alat Berat yang Dipindahkan <span class="text-rose-500">*</span></span>
|
||||
<span id="unitCounterBadge" class="text-[10px] font-semibold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded border border-emerald-200 hidden"></span>
|
||||
</label>
|
||||
<select name="vehicle_id"
|
||||
id="vehicle_id"
|
||||
required
|
||||
onchange="onHeavyUnitSelected(this)"
|
||||
class="w-full px-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-800 font-semibold">
|
||||
<option value="" disabled {{ empty($selectedVehicleId) && !old('vehicle_id') ? 'selected' : '' }}>
|
||||
-- Pilih Lokasi Awal Terlebih Dahulu --
|
||||
</option>
|
||||
@foreach($heavyUnits as $unit)
|
||||
<option value="{{ $unit->id }}"
|
||||
data-code="{{ $unit->code }}"
|
||||
data-brand="{{ $unit->brand_type }}"
|
||||
data-category="{{ $unit->unit_category ?? ($unit->parent?->brand_type ?? 'Heavy Equipment') }}"
|
||||
data-location="{{ $unit->location ?: 'Site Kerinci' }}"
|
||||
data-site-status="{{ $unit->site_status ?? 'inside_site' }}"
|
||||
data-photo="{{ $unit->photo_url }}"
|
||||
{{ old('vehicle_id', $selectedVehicleId) == $unit->id ? 'selected' : '' }}>
|
||||
{{ $unit->code }} - {{ $unit->brand_type }} [Posisi: {{ $unit->location ?: 'Site Kerinci' }}]
|
||||
<div class="space-y-1.5">
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-magnifying-glass absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
id="heavyUnitSearch"
|
||||
placeholder="Ketik kode / merek untuk filter unit..."
|
||||
oninput="filterHeavyUnitOptions(this.value)"
|
||||
autocomplete="off"
|
||||
class="w-full pl-9 pr-7 py-2 text-xs rounded-xl border border-slate-200 bg-slate-50 focus:bg-white focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition font-medium">
|
||||
<button type="button" onclick="clearHeavyUnitFilter()" id="clearHeavyUnitFilterBtn" class="hidden absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 cursor-pointer">
|
||||
<i class="fa-solid fa-xmark text-xs"></i>
|
||||
</button>
|
||||
</div>
|
||||
<select name="vehicle_id"
|
||||
id="vehicle_id"
|
||||
required
|
||||
onchange="onHeavyUnitSelected(this)"
|
||||
class="w-full px-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-800 font-semibold">
|
||||
<option value="" disabled {{ empty($selectedVehicleId) && !old('vehicle_id') ? 'selected' : '' }}>
|
||||
-- Pilih Lokasi Awal Terlebih Dahulu --
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@foreach($heavyUnits as $unit)
|
||||
<option value="{{ $unit->id }}"
|
||||
data-code="{{ $unit->code }}"
|
||||
data-brand="{{ $unit->brand_type }}"
|
||||
data-category="{{ $unit->unit_category ?? ($unit->parent?->brand_type ?? 'Heavy Equipment') }}"
|
||||
data-location="{{ $unit->location ?: 'Site Kerinci' }}"
|
||||
data-site-status="{{ $unit->site_status ?? 'inside_site' }}"
|
||||
data-photo="{{ $unit->photo_url }}"
|
||||
{{ old('vehicle_id', $selectedVehicleId) == $unit->id ? 'selected' : '' }}>
|
||||
{{ $unit->code }} - {{ $unit->brand_type }} [Posisi: {{ $unit->location ?: 'Site Kerinci' }}]
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@error('vehicle_id')
|
||||
<p class="text-rose-500 text-[11px] font-semibold mt-1">{{ $message }}</p>
|
||||
@enderror
|
||||
@@ -873,6 +901,11 @@
|
||||
// Kosongkan options
|
||||
unitSelect.innerHTML = '';
|
||||
|
||||
const searchInput = document.getElementById('heavyUnitSearch');
|
||||
if (searchInput) searchInput.value = '';
|
||||
const searchClear = document.getElementById('clearHeavyUnitFilterBtn');
|
||||
if (searchClear) searchClear.classList.add('hidden');
|
||||
|
||||
if (!selectedLocation) {
|
||||
const defaultOpt = document.createElement('option');
|
||||
defaultOpt.value = '';
|
||||
@@ -1020,5 +1053,103 @@
|
||||
text.innerHTML = `Armada luar (<strong>${displayName}</strong>) diberangkatkan dari <strong>${displayOrigin}</strong> → Menjemput alat berat di <strong>${originLoc}</strong> → Mengantarkannya ke tujuan <strong>${destLoc}</strong>.`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Realtime Dropdown Lokasi Awal berdasarkan Ketikan
|
||||
*/
|
||||
function filterOriginLocationSelect(query) {
|
||||
const select = document.getElementById('origin_location');
|
||||
const clearBtn = document.getElementById('clearOriginLocationFilterBtn');
|
||||
if (!select) return;
|
||||
|
||||
const q = (query || '').trim().toLowerCase();
|
||||
if (clearBtn) {
|
||||
clearBtn.classList.toggle('hidden', !q);
|
||||
}
|
||||
|
||||
let visibleCount = 0;
|
||||
let firstMatch = null;
|
||||
|
||||
Array.from(select.options).forEach(opt => {
|
||||
if (!opt.value) {
|
||||
opt.hidden = false;
|
||||
return;
|
||||
}
|
||||
if (opt.value === 'ALL') {
|
||||
opt.hidden = q.length > 0 && !opt.textContent.toLowerCase().includes(q);
|
||||
if (!opt.hidden && !firstMatch) firstMatch = opt;
|
||||
return;
|
||||
}
|
||||
const match = opt.textContent.toLowerCase().includes(q) || opt.value.toLowerCase().includes(q);
|
||||
opt.hidden = !match;
|
||||
if (match) {
|
||||
visibleCount++;
|
||||
if (!firstMatch) firstMatch = opt;
|
||||
}
|
||||
});
|
||||
|
||||
if (q && visibleCount === 1 && firstMatch) {
|
||||
select.value = firstMatch.value;
|
||||
onOriginLocationChanged(firstMatch.value);
|
||||
}
|
||||
}
|
||||
|
||||
function clearOriginLocationFilter() {
|
||||
const input = document.getElementById('originLocationSearch');
|
||||
if (input) input.value = '';
|
||||
filterOriginLocationSelect('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter Realtime Dropdown Unit Alat Berat berdasarkan Ketikan Kode / Merek
|
||||
*/
|
||||
function filterHeavyUnitOptions(query) {
|
||||
const select = document.getElementById('vehicle_id');
|
||||
const clearBtn = document.getElementById('clearHeavyUnitFilterBtn');
|
||||
const badge = document.getElementById('unitCounterBadge');
|
||||
if (!select) return;
|
||||
|
||||
const q = (query || '').trim().toLowerCase();
|
||||
if (clearBtn) {
|
||||
clearBtn.classList.toggle('hidden', !q);
|
||||
}
|
||||
|
||||
let visibleCount = 0;
|
||||
let firstMatch = null;
|
||||
|
||||
Array.from(select.options).forEach(opt => {
|
||||
if (!opt.value) {
|
||||
opt.hidden = false;
|
||||
return;
|
||||
}
|
||||
const code = (opt.getAttribute('data-code') || '').toLowerCase();
|
||||
const brand = (opt.getAttribute('data-brand') || '').toLowerCase();
|
||||
const cat = (opt.getAttribute('data-category') || '').toLowerCase();
|
||||
const text = opt.textContent.toLowerCase();
|
||||
|
||||
const match = text.includes(q) || code.includes(q) || brand.includes(q) || cat.includes(q);
|
||||
opt.hidden = !match;
|
||||
if (match) {
|
||||
visibleCount++;
|
||||
if (!firstMatch) firstMatch = opt;
|
||||
}
|
||||
});
|
||||
|
||||
if (badge) {
|
||||
badge.classList.remove('hidden');
|
||||
badge.textContent = q ? `${visibleCount} Unit Cocok` : `${visibleCount} Unit Tersedia`;
|
||||
}
|
||||
|
||||
if (q && visibleCount === 1 && firstMatch) {
|
||||
select.value = firstMatch.value;
|
||||
onHeavyUnitSelected(select);
|
||||
}
|
||||
}
|
||||
|
||||
function clearHeavyUnitFilter() {
|
||||
const input = document.getElementById('heavyUnitSearch');
|
||||
if (input) input.value = '';
|
||||
filterHeavyUnitOptions('');
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
@@ -654,6 +654,12 @@
|
||||
@endforeach
|
||||
</datalist>
|
||||
|
||||
<datalist id="divisionsDatalist">
|
||||
@foreach($availableDivisions ?? [] as $div)
|
||||
<option value="{{ $div }}">{{ $div }}</option>
|
||||
@endforeach
|
||||
</datalist>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<!-- MODAL: TAMBAH UNIT ALAT BERAT (HEAVY EQUIPMENT) -->
|
||||
<!-- ========================================================================= -->
|
||||
@@ -826,14 +832,21 @@
|
||||
<!-- Baris 7: Divisi & Kepemilikan Aset -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1">Divisi Penanggung Jawab</label>
|
||||
<select name="division"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-medium">
|
||||
<option value="">-- Pilih Divisi Penanggung Jawab --</option>
|
||||
@foreach($availableDivisions as $div)
|
||||
<option value="{{ $div }}" {{ old('division') === $div ? 'selected' : '' }}>{{ $div }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1 flex items-center justify-between">
|
||||
<span>Divisi Penanggung Jawab</span>
|
||||
<span class="text-[10px] text-emerald-700 font-semibold">Bisa ketik / filter</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-building absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
name="division"
|
||||
id="addDivision"
|
||||
list="divisionsDatalist"
|
||||
value="{{ old('division') }}"
|
||||
placeholder="Ketik atau pilih divisi..."
|
||||
autocomplete="off"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-medium">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1">Kepemilikan Aset (Owner)</label>
|
||||
@@ -894,6 +907,7 @@
|
||||
<form id="editVehicleForm" action="" method="POST" enctype="multipart/form-data" class="space-y-4">
|
||||
@csrf
|
||||
<input type="hidden" name="category" value="unit_support">
|
||||
<input type="hidden" name="brand_type" id="editBrandType" value="">
|
||||
|
||||
<!-- Foto Unit -->
|
||||
<div>
|
||||
@@ -1029,14 +1043,20 @@
|
||||
<!-- Baris 7: Divisi & Kepemilikan -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1">Divisi Penanggung Jawab</label>
|
||||
<select name="division" id="editDivision"
|
||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-medium">
|
||||
<option value="">-- Pilih Divisi Penanggung Jawab --</option>
|
||||
@foreach($availableDivisions as $div)
|
||||
<option value="{{ $div }}">{{ $div }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1 flex items-center justify-between">
|
||||
<span>Divisi Penanggung Jawab</span>
|
||||
<span class="text-[10px] text-emerald-700 font-semibold">Bisa ketik / filter</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-building absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
name="division"
|
||||
id="editDivision"
|
||||
list="divisionsDatalist"
|
||||
placeholder="Ketik atau pilih divisi..."
|
||||
autocomplete="off"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 bg-white text-slate-800 focus:outline-none focus:border-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 transition font-medium">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-800 mb-1">Kepemilikan Aset (Owner)</label>
|
||||
@@ -1561,8 +1581,11 @@
|
||||
|
||||
function openEditModal(v) {
|
||||
document.getElementById('editVehicleModal').classList.remove('hidden');
|
||||
document.getElementById('editVehicleForm').action = `/qma/vehicles/${v.id}`;
|
||||
document.getElementById('editVehicleForm').action = "{{ url('qma/vehicles') }}/" + v.id;
|
||||
document.getElementById('editCode').value = v.code || '';
|
||||
if (document.getElementById('editBrandType')) {
|
||||
document.getElementById('editBrandType').value = v.brand_type || '';
|
||||
}
|
||||
currentEditVehicleCode = (v.code || '').trim().toUpperCase();
|
||||
hideEditCodeError();
|
||||
|
||||
@@ -1606,26 +1629,9 @@
|
||||
document.getElementById('editFuelConsumption').value = v.fuel_consumption || '';
|
||||
}
|
||||
|
||||
const divSelect = document.getElementById('editDivision');
|
||||
if (divSelect) {
|
||||
if (v.division) {
|
||||
let found = false;
|
||||
for (let i = 0; i < divSelect.options.length; i++) {
|
||||
if (divSelect.options[i].value === v.division) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
const newOpt = document.createElement('option');
|
||||
newOpt.value = v.division;
|
||||
newOpt.textContent = v.division;
|
||||
divSelect.appendChild(newOpt);
|
||||
}
|
||||
divSelect.value = v.division;
|
||||
} else {
|
||||
divSelect.value = '';
|
||||
}
|
||||
const divInput = document.getElementById('editDivision');
|
||||
if (divInput) {
|
||||
divInput.value = v.division || '';
|
||||
}
|
||||
|
||||
const editPhotoPreview = document.getElementById('editPhotoPreview');
|
||||
|
||||
@@ -645,6 +645,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||
<span>Divisi Penanggung Jawab</span>
|
||||
<span class="text-[10px] text-emerald-700 font-semibold">Bisa ketik / filter</span>
|
||||
</label>
|
||||
<input type="text" name="division" id="edit_division" list="divisionsDatalistSupportUnits" placeholder="Ketik atau pilih divisi..." class="w-full text-xs px-3.5 py-2 rounded-xl border border-slate-200 bg-white text-slate-800 font-medium focus:outline-none focus:border-emerald-600">
|
||||
<datalist id="divisionsDatalistSupportUnits">
|
||||
@foreach($availableDivisions ?? [] as $div)
|
||||
<option value="{{ $div }}">{{ $div }}</option>
|
||||
@endforeach
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">Dokumen SILO</label>
|
||||
@@ -1161,6 +1174,9 @@
|
||||
}
|
||||
document.getElementById('edit_silo').value = unit.silo_document || '';
|
||||
document.getElementById('edit_kir').value = unit.kir_document || '';
|
||||
if (document.getElementById('edit_division')) {
|
||||
document.getElementById('edit_division').value = unit.division || '';
|
||||
}
|
||||
|
||||
const editPhotoPreview = document.getElementById('editPhotoPreview');
|
||||
const editPhotoPlaceholder = document.getElementById('editPhotoPlaceholder');
|
||||
|
||||
Reference in New Issue
Block a user