perbaikan alamat, foto pembading, diskon, dan perbaikan tampilan kjjp

This commit is contained in:
majid
2024-12-16 15:36:59 +07:00
parent a602f83d44
commit 41552f695c
15 changed files with 910 additions and 523 deletions

View File

@@ -190,7 +190,8 @@
<span class="ml-2">Tidak</span>
</label>
</div>
<em id="error-alamat" class="alert text-danger text-sm"></em>
<em id="error-alamat_sesuai" class="alert text-danger text-sm"></em>
<em id="error-alamat_sesuai" class="alert text-danger text-sm"></em>
</div>
@php
@@ -217,7 +218,7 @@
</div>
<div class="card-body">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Kordinat</label>
<label class="form-label max-w-56">“Koordinat</label>
<div id="perwakilan" class="flex items-baseline w-full gap-5">
<div class="grid grid-cols-2 gap-4 items-center w-full">
<input class="input" type="text" placeholder="Masukan Koordinat Latitude" type="text"
@@ -230,7 +231,7 @@
<a target="_blank" href="https://www.google.com/maps" type="button"
class="btn btn-md btn-outline btn-primary">
<i class="ki-filled ki-map"></i>Ambil
Kordinat</a>
Koordinat </a>
</div>
</div>
</div>
@@ -340,9 +341,13 @@
<div>
<div class="flex flex-wrap items-baseline w-full">
@foreach ($permohonan->debiture->documents as $dokumen)
{{ $dokumen->pemilik->hubungan_pemilik->name ?? '' }}
<input type="hidden" name="hub_cadeb_sesuai"
value="{{ $dokumen->pemilik->hubungan_pemilik->name }}" id="">
@php
$hubCadebPemilik = $dokumen->pemilik->hubungan_pemilik->name ?? 'N/A';
@endphp
{{ $hubCadebPemilik }}
<input type="hidden" name="hub_cadeb_sesuai" value="{{ $hubCadebPemilik }}"
id="">
@endforeach
</div>
@@ -375,10 +380,12 @@
<option value="">Select Hubungan Cadeb</option>
@if (isset($basicData['hubCadeb']))
@foreach ($basicData['hubCadeb'] as $item)
<option value="{{ $item->name }}"
{{ old('hub_cadeb_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
{{ $item->name }}
</option>
@if ($item->name != $hubCadebPemilik)
<option value="{{ $item->name }}"
{{ old('hub_cadeb_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
{{ $item->name }}
</option>
@endif
@endforeach
@endif
</select>
@@ -400,10 +407,12 @@
<div class="mt-2">
<div class="flex flex-wrap items-baseline w-full text-sm">
@foreach ($permohonan->debiture->documents as $dokumen)
{{ $dokumen->penghuni->hubungan_penghuni->name ?? 'N/A' }}
@php
$hubCadebPenghuni = $dokumen->penghuni->hubungan_penghuni->name ?? 'N/A';
@endphp
{{ $hubCadebPenghuni }}
<input type="hidden" name="hub_cadeb_penghuni_sesuai"
value="{{ isset($dokumen->penghuni->hubungan_penghuni->name) ?? '' }}"
id="">
value="{{ isset($hubCadebPenghuni) ?? '' }}" id="">
@endforeach
</div>
@@ -438,15 +447,17 @@
<option value="">Select Hubungan Cadeb</option>
@if (isset($basicData['hubPenghuni']))
@foreach ($basicData['hubPenghuni'] as $item)
<option value="{{ $item->name }}"
{{ old('hub_penghuni_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
{{ $item->name }}
</option>
@if ($item->name != $hubCadebPenghuni)
<option value="{{ $item->name }}"
{{ old('hub_penghuni_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
{{ $item->name }}
</option>
@endif
@endforeach
@endif
</select>
</div>
<em id="error-hub_cadeb" class="alert text-danger text-sm"></em>
<em id="error-hub_cadeb_penghuni" class="alert text-danger text-sm"></em>
</div>
</div>
</div>
@@ -482,102 +493,238 @@
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="address" class="form-label max-w-56">Jl.</label>
<div class="flex flex-wrap items-baseline w-full">
<input type="text" id="address" name="address" class="input w-full "
<input type="text" id="address" name="address" class="input w-full "
value="{{ isset($permohonan->debiture->address) ? $permohonan->debiture->address : old('address') }}">
</div>
</div>
<input type="hidden" name="province_code"
<input type="hidden" name="province_code"
value="{{ isset($permohonan->debiture->province) ? $permohonan->debiture->province->code : '' }}">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="province" class="form-label max-w-56">Provinsi</label>
<div class="flex flex-wrap items-baseline w-full">
<input type="text" id="province" class="input w-full cursor-not-allowed" readonly
<input type="text" id="province" class="input w-full cursor-not-allowed" readonly
value="{{ isset($permohonan->debiture->province) ? $permohonan->debiture->province->name : '' }}">
</div>
</div>
<input type="hidden" name="city_code"
<input type="hidden" name="city_code"
value="{{ isset($permohonan->debiture->city) ? $permohonan->debiture->city->code : '' }}">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="city" class="form-label max-w-56">Kabupaten/Kota</label>
<div class="flex flex-wrap items-baseline w-full">
<input type="text" id="city" class="input w-full cursor-not-allowed" readonly
<input type="text" id="city" class="input w-full cursor-not-allowed" readonly
value="{{ isset($permohonan->debiture->city) ? $permohonan->debiture->city->name : '' }}">
</div>
</div>
<input type="hidden" name="district_code"
</div>
</div>
<input type="hidden" name="district_code"
value="{{ isset($permohonan->debiture->district) ? $permohonan->debiture->district->code : '' }}">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="district" class="form-label max-w-56">Kecamatan</label>
<div class="flex flex-wrap items-baseline w-full">
<input type="text" id="district" class="input w-full cursor-not-allowed" readonly
<input type="text" id="district" class="input w-full cursor-not-allowed" readonly
value="{{ isset($permohonan->debiture->district) ? $permohonan->debiture->district->name : '' }}">
</div>
</div>
<input type="hidden" name="village_code"
</div>
</div>
<input type="hidden" name="village_code"
value="{{ isset($permohonan->debiture->village) ? $permohonan->debiture->village->code : '' }}">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="village" class="form-label max-w-56">Desa/Kelurahan</label>
<div class="flex flex-wrap items-baseline w-full">
<input type="text" id="village" class="input w-full cursor-not-allowed" readonly
<input type="text" id="village" class="input w-full cursor-not-allowed" readonly
value="{{ isset($permohonan->debiture->village) ? $permohonan->debiture->village->name : '' }}">
</div>
</div>
</div>
</div>
</div>
`;
}
if (data == 'tidak sesuai') {
if (data === 'tidak sesuai') {
createElementAlamat.innerHTML = `
<div class="grid gap-2.5 w-full">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="address" class="form-label max-w-56">Jl.</label>
<div class="flex flex-wrap items-baseline w-full">
<input type="text" id="address" name="address" class="input w-full"
placeholder="Masukkan Jl."
value="{{ old('address') }}">
<div class="grid gap-2.5 w-full">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="address" class="form-label max-w-56">Jl.</label>
<div class="flex flex-wrap items-baseline w-full">
<input type="text" id="address" name="address" class="input w-full"
placeholder="Masukkan Jl." value="{{ old('address') }}">
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="province_code" class="form-label max-w-56">Provinsi</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="province_code" name="province_code" class="input w-full" onchange="getCity(this.value)">
<option value="">Select Province</option>
@foreach ($provinces as $province)
<option value="{{ $province->code }}"
@if (
(isset($cekAlamat['province_code']) && $cekAlamat['province_code'] == $province->code) ||
(!isset($cekAlamat['province_code']) &&
isset($debitur->province_code) &&
$debitur->province_code == $province->code)) selected @endif>
{{ $province->name }}
</option>
@endforeach
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="city_code" class="form-label max-w-56">Kota/Kabupaten</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="city_code" name="city_code" class="select w-full" onchange="getDistrict(this.value)">
<option value="">Pilih Kota/Kabupaten</option>
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="district_code" class="form-label max-w-56">Kecamatan</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="district_code" name="district_code" class="select w-full" onchange="getVillage(this.value)">
<option value="">Pilih Kecamatan</option>
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="village_code" class="form-label max-w-56">Kelurahan</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="village_code" name="village_code" class="select w-full">
<option value="">Pilih Kelurahan</option>
</select>
</div>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="province_code" class="form-label max-w-56">Provinsi</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="province_code" name="province_code" class="input w-full" >
<option value="">Select Province</option>
@foreach ($provinces as $province)
<option value="{{ $province->code }}">{{ $province->name }}</option>
@endforeach
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="city_code" class="form-label max-w-56">Kota/Kabupaten</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="city_code" name="city_code" class="select w-full" >
<option value="">Pilih Kota/Kabupaten</option>
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="district_code" class="form-label max-w-56">Kecamatan</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="district_code" name="district_code" class="select w-full" >
<option value="">Pilih Kecamatan</option>
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="village_code" class="form-label max-w-56">Kelurahan</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="village_code" name="village_code" class="select w-full">
<option value="">Pilih Kelurahan</option>
</select>
</div>
</div>
</div>
`;
loadSavedLocationData();
}
}
document.addEventListener('DOMContentLoaded', () => {
loadSavedLocationData();
});
// Fungsi untuk memuat data lokasi yang tersimpan
async function loadSavedLocationData() {
const provinceCode = '{{ $cekAlamat['province_code'] ?? '' }}';
const cityCode = '{{ $cekAlamat['city_code'] ?? '' }}';
const districtCode = '{{ $cekAlamat['district_code'] ?? '' }}';
const villageCode = '{{ $cekAlamat['village_code'] ?? '' }}';
// Set province
const provinceSelect = document.getElementById('province_code');
if (provinceCode && provinceSelect) {
provinceSelect.value = provinceCode;
await getCity(provinceCode);
}
// Set city
const citySelect = document.getElementById('city_code');
if (cityCode && citySelect) {
citySelect.value = cityCode;
await getDistrict(cityCode);
}
// Set district
const districtSelect = document.getElementById('district_code');
if (districtCode && districtSelect) {
districtSelect.value = districtCode;
await getVillage(districtCode);
}
// Set village
const villageSelect = document.getElementById('village_code');
if (villageCode && villageSelect) {
villageSelect.value = villageCode;
}
}
// Modifikasi fungsi existing
async function getCity(provinceId) {
try {
const response = await fetch(`/locations/cities/province/${provinceId}`);
const data = await response.json();
const cityDropdown = document.getElementById('city_code');
if (cityDropdown) {
cityDropdown.innerHTML = '<option value="">Pilih Kota/Kabupaten</option>';
data.forEach(city => {
const option = document.createElement('option');
option.value = city.code;
option.textContent = city.name;
@if (isset($debitur->city_code))
if (city.code === '{{ $debitur->city_code }}') {
option.selected = true;
}
@endif
cityDropdown.appendChild(option);
});
// Reset dropdown kecamatan dan desa
document.getElementById('district_code').innerHTML = '<option value="">Pilih Kecamatan</option>';
document.getElementById('village_code').innerHTML = '<option value="">Pilih Kelurahan</option>';
}
} catch (error) {
console.error('Error fetching cities:', error);
}
}
// Lakukan hal serupa untuk getDistrict dan getVillage
async function getDistrict(cityId) {
try {
const response = await fetch(`/locations/districts/city/${cityId}`);
const data = await response.json();
const districtDropdown = document.getElementById('district_code');
if (districtDropdown) {
districtDropdown.innerHTML = '<option value="">Pilih Kecamatan</option>';
data.forEach(district => {
const option = document.createElement('option');
option.value = district.code;
option.textContent = district.name;
// Cek apakah ini adalah kecamatan yang sebelumnya dipilih
@if (isset($debitur->district_code))
if (district.code === '{{ $debitur->district_code }}') {
option.selected = true;
}
@endif
districtDropdown.appendChild(option);
});
// Reset dropdown desa
document.getElementById('village_code').innerHTML = '<option value="">Pilih Kelurahan</option>';
}
} catch (error) {
console.error('Error fetching districts:', error);
}
}
async function getVillage(districtId) {
try {
const response = await fetch(`/locations/villages/district/${districtId}`);
const data = await response.json();
const villageDropdown = document.getElementById('village_code');
if (villageDropdown) {
villageDropdown.innerHTML = '<option value="">Pilih Desa/Kelurahan</option>';
data.forEach(village => {
const option = document.createElement('option');
option.value = village.code;
option.textContent = village.name;
// Cek apakah ini adalah desa yang sebelumnya dipilih
@if (isset($debitur->village_code))
if (village.code === '{{ $debitur->village_code }}') {
option.selected = true;
}
@endif
villageDropdown.appendChild(option);
});
}
} catch (error) {
console.error('Error fetching villages:', error);
}
}
</script>