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

@@ -521,7 +521,7 @@ class KJPPController extends Controller
$filteredRecords = $query->count();
// Get the data for the current page
$data = $query->get();
$data = $query->with('city')->get();
// Calculate the page count
$pageCount = ceil($totalRecords / $request->get('size'));

View File

@@ -9,7 +9,7 @@ use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Facades\Excel;
use Modules\Lpj\Exports\KertasKerjaExport;
use App\Http\Controllers\SurveyorController;
use Modules\Lpj\Http\Controllers\SurveyorController;
class PenilaiController extends Controller
{
@@ -62,20 +62,40 @@ class PenilaiController extends Controller
$basicData = $data->getCommonData();
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id);
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan', 'basicData'));
$jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
$forminspeksi = null;
if ($inpeksi) {
$forminspeksi = json_decode($inpeksi->data_form, true);
}
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan', 'basicData', 'forminspeksi'));
}
public function standard($id)
{
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id);
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan'));
$jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
$forminspeksi = null;
if ($inpeksi) {
$forminspeksi = json_decode($inpeksi->data_form, true);
}
public function resume(){
$data = new SurveyorController();
$basicData = $data->getCommonData();
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan', 'forminspeksi', 'basicData'));
}
public function resume()
{
return view('lpj::resume.index');
}
public function memo(){
public function memo()
{
return view('lpj::resume.index');
}

View File

@@ -591,7 +591,7 @@ class SurveyorController extends Controller
->first();
if ($inspeksi) {
$existingData = $inspeksi->data_pembanding ?? [];
$existingData = json_decode($inspeksi->data_pembanding, true) ?? [];
}
}
@@ -600,8 +600,8 @@ class SurveyorController extends Controller
$existingFoto = null;
if ($existingData && isset($existingData[$i]['foto_objek'])) {
$existingFoto = $existingData[$i]['foto_objek'];
if ($existingData && isset($existingData['data_pembanding'][$i]['foto_objek'])) {
$existingFoto = $existingData['data_pembanding'][$i]['foto_objek'];
}
// Penanganan foto pembanding
@@ -873,6 +873,7 @@ class SurveyorController extends Controller
'data_pembanding' => $this->formatDataPembanding($request)
];
$inspeksi = $this->saveInspeksi($formattedData);
DB::commit();
@@ -1041,7 +1042,6 @@ class SurveyorController extends Controller
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Exception('Error decoding comparison data: ' . json_last_error_msg());
}
}
$fotoForm = json_decode($inspeksi->foto_form, true);
@@ -1055,8 +1055,6 @@ class SurveyorController extends Controller
$districts = District::where('city_code', $this->getCodeAlamat('city_code', $inspectionData))->get();
$villages = Village::where('district_code', $this->getCodeAlamat('district_code', $inspectionData))->get();
return view('lpj::surveyor.components.data-pembanding', compact(
'permohonan',
'id',
@@ -1068,7 +1066,8 @@ class SurveyorController extends Controller
'cities',
'districts',
'villages',
'provinces'
'provinces',
'inspeksi'
));
} catch (\Exception $e) {
@@ -1562,7 +1561,7 @@ class SurveyorController extends Controller
private function getCommonData()
public function getCommonData()
{
return [
'branches' => Branch::all(),
@@ -1809,11 +1808,9 @@ class SurveyorController extends Controller
'jarak_tps' => $data['jarak_tps'] ?? null,
'nama_tps' => $data['nama_tps'] ?? null,
'merupakan_daerah' => $data['merupakan_daerah'] ?? null,
'fasilitas_dekat_object' => $this->getFieldData(
$data,
'fasilitas_dekat_object',
false,
'lainnya'
'fasilitas_dekat_object' => $this->mapArrayWithInputs(
$data['fasilitas_dekat_object'] ?? [],
$data['fasilitas_dekat_object_input'] ?? []
),
]
];

View File

@@ -76,7 +76,7 @@ class FormSurveyorRequest extends FormRequest
'hadap_mata_angin' => 'required',
'hadap_mata_angin_sesuai' => 'nullable',
'hadap_mata_angin_tidak_sesuai' => 'nullable',
'bentuk_tanah' => 'nullable|array',
'bentuk_tanah' => 'required|array',
'bentuk_tanah_lainnya' => 'nullable',
'kontur_tanah' => 'required|array',
'ketinggian_jalan' => 'required|array',
@@ -102,8 +102,8 @@ class FormSurveyorRequest extends FormRequest
'luas_tanah_bangunan_sesuai' => 'nullable',
'luas_tanah_bagunan' => 'required',
'luas_tanah_bangunan_tidak_sesuai' => 'nullable',
'jenis_bangunan' => 'required',
'kondisi_bangunan' => 'nullable',
'jenis_bangunan' => 'required|array',
'kondisi_bangunan' => 'required|array',
'sifat_bangunan' => 'required|array',
'sifat_bangunan_input' => 'nullable|array',
@@ -167,7 +167,7 @@ class FormSurveyorRequest extends FormRequest
'nama_tpu' => 'nullable',
'merupakan_daerah' => 'nullable',
'fasilitas_dekat_object' => 'nullable|array',
'fasilitas_dekat_object_lainnya' => 'nullable',
'fasilitas_dekat_object_input' => 'nullable|array',
];
}

View File

@@ -2,7 +2,7 @@
namespace Modules\Lpj\Models;
use Modules\Location\Models\Province;
use Modules\Location\Models\City;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -25,4 +25,12 @@ class KJPP extends Model
{
return $this->hasMany(PenawaranDetailTender::class, 'kjpp_rekanan_id', 'id');
}
public function city()
{
return $this->belongsTo(City::class, 'city_code', 'code');
}
}

View File

@@ -48,6 +48,14 @@
<span class="sort"> <span class="sort-label"> Jenis Kantor </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[50px]" data-datatable-column="jenis_kantor">
<span class="sort"> <span class="sort-label"> Kota/Kabupaten </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[50px]" data-datatable-column="jenis_kantor">
<span class="sort"> <span class="sort-label"> Alamat </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
</tr>
</thead>
@@ -131,6 +139,15 @@
jenis_kantor: {
title: 'Jenis Kantor',
},
city: {
title: 'Kota/Kabupaten',
render: (item, data) => {
return data.city.name;
}
},
address: {
title: 'Alamat KJPP',
},
actions: {
title: 'Action',
render: (item, data) => {

View File

@@ -22,7 +22,7 @@
@endforeach
@endif
<div class="flex flex-wrap items-baseline w-full">
<div class="flex-wrap items-stretch">
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-2">
<label class="form-label flex items-center gap-3 text-nowrap">
<input type="radio"
@@ -67,14 +67,18 @@
<!-- Jenis Bangunan -->
<div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Jenis Bangunan</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="flex-wrap items-stretch">
<div class="flex flex-col items-start gap-4">
@if (isset($basicData['jenisBangunan']))
@foreach ($basicData['jenisBangunan'] as $item)
<label class="form-label flex items-center gap-2.5 text-nowrap">
<input class="checkbox" name="jenis_bangunan[]" type="checkbox"
value="{{ $item->name }}"
{{ old('jenis_bangunan') == $item->name || isset($forminspeksi['bangunan']['jenis_bangunan']) == $item->name ? 'checked' : '' }}
{{ (is_array(old('jenis_bangunan')) && in_array($item->name, old('jenis_bangunan'))) ||
(isset($forminspeksi['bangunan']['jenis_bangunan']) &&
(is_array($forminspeksi['bangunan']['jenis_bangunan']) &&
in_array($item->name, $forminspeksi['bangunan']['jenis_bangunan'])))
? 'checked' : '' }}
onclick="toggleCheckboxVisibility('jenis_bangunan', 'jenis_bangunan_lainnya', ['lainnya'])" />
{{ $item->name }}
</label>
@@ -86,16 +90,15 @@
@endforeach
@endif
</div>
<em id="error-jenis_bangunan" class="alert text-danger text-sm"></em>
</div>
</div>
</div>
</div>
<!-- Kondisi Bangunan -->
<div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Kondisi Bangunan</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="flex-wrap items-stretch">
<div class="flex flex-col items-start gap-4">
@if (isset($basicData['kondisiBangunan']))
@foreach ($basicData['kondisiBangunan'] as $item)
@@ -128,7 +131,7 @@
<!-- Sifat Bangunan -->
<div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Sifat Bangunan</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="flex-wrap items-stretch">
<div class="flex flex-col items-start gap-4">
@if (isset($basicData['sifatBangunan']))
@foreach ($basicData['sifatBangunan'] as $item)
@@ -249,13 +252,14 @@
<i class="ki-filled ki-plus"></i>
</button>
</div>
</div>
<!-- Sarana pelengkap -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Sarana pelengkap</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="flex-wrap items-stretch">
<div class="flex flex-col items-start gap-4">
@if (isset($basicData['saranaPelengkap']))
@foreach ($basicData['saranaPelengkap'] as $item)

View File

@@ -110,15 +110,29 @@
</select>
</td>
</tr>
@php
$apartemenKantorData = explode(',', $inspeksi->name);
$isApartemenKantor = array_intersect($apartemenKantorData, [
'tanah',
'bangunan',
]);
@endphp
@if ($isApartemenKantor)
<tr>
<td class="px-4 py-2">Luas Tanah ()</td>
@php
$cekLuas = $inspectionData['tanah']['luas_tanah'] == 'sesuai' ? 'sesuai' :'tidak sesuai';
$cekLuas =
isset($inspectionData['tanah']['luas_tanah']) == 'sesuai'
? 'sesuai'
: 'tidak sesuai';
@endphp
<td class="px-4 py-2">
<input type="text" name="luas_tanah" class="input number-format"
value="{{ $inspectionData['tanah']['luas_tanah']['sesuai'] ?? $inspectionData['tanah']['luas_tanah']['tidak sesuai'] ?? '' }}">
value="{{ $inspectionData['tanah']['luas_tanah']['sesuai'] ?? ($inspectionData['tanah']['luas_tanah']['tidak sesuai'] ?? '') }}">
</td>
<td class="px-4 py-2">
@@ -130,14 +144,29 @@
<td class="px-4 py-2">Luas Bangunan ()</td>
<td class="px-4 py-2">
<input type="text" name="luas_tanah_bagunan" class="input number-format"
value="{{ $inspectionData['bangunan']['luas_tanah_bagunan']['sesuai'] ?? $inspectionData['bangunan']['luas_tanah_bagunan']['tidak sesuai'] ?? '' }}">
<input type="text" name="luas_tanah_bagunan"
class="input number-format"
value="{{ $inspectionData['bangunan']['luas_tanah_bagunan']['sesuai'] ?? ($inspectionData['bangunan']['luas_tanah_bagunan']['tidak sesuai'] ?? '') }}">
</td>
<td class="px-4 py-2">
<input type="text" name="luas_bangunan_pembanding[]"
class="input number-format">
</td>
</tr>
@else
<tr>
<td class="px-4 py-2">Luas Unit ()</td>
<td class="px-4 py-2">
<input type="text" name="luas_unit" class="input number-format"
value="{{ $inspectionData['unit']['luas_unit']['sesuai'] ?? ($inspectionData['unit']['luas_unit']['tidak sesuai'] ?? '') }}">
</td>
<td class="px-4 py-2">
<input type="text" name="luas_unit_pembanding[]"
class="input number-format">
</td>
</tr>
@endif
<!-- Informasi Harga -->
<tr class="bg-gray-100">
@@ -374,15 +403,28 @@
<tr>
<td class="px-4 py-2">Diskon</td>
<td class="px-4 py-2">
<input type="text" name="diskon" class="input currency-format"
<div class="input">
<input type="text" name="diskon" class=" currency-format"
value="{{ $inspectionData['asset']['diskon'] ?? '' }}">
<span class="btn btn-icon">
<i class="ki-outline ki-percentage"></i>
</span>
</div>
</td>
<td class=" px-4 py-2">
<div class="input">
<input type="text" name="diskon_pembanding[]"
class="input currency-format">
class="currency-format">
<span class="btn btn-icon">
<i class="ki-outline ki-percentage"></i>
</i>
</span>
</div>
</td>
</tr>
<tr>
<tr style="display: none;">
<td class="px-4 py-2">Total</td>
<td class="px-4 py-2">
<input type="text" name="total" class="input currency-format"
@@ -434,27 +476,56 @@
// Fungsi calculate prices yang diperbaiki
function calculatePrices(index) {
const hargaInput = document.getElementsByName('harga_pembanding[]')[index];
const diskonInput = document.getElementsByName('diskon_pembanding[]')[index];
const totalInput = document.getElementsByName('total_pembanding[]')[index];
const hargaDiskonInput = document.getElementsByName('harga_diskon_pembanding[]')[index];
function calculatePrices(type = 'main', index = null) {
let hargaInput, diskonInput, totalInput, hargaDiskonInput;
// Tentukan input berdasarkan tipe (main atau pembanding)
if (type === 'main') {
hargaInput = document.querySelector('input[name="harga"]');
diskonInput = document.querySelector('input[name="diskon"]');
totalInput = document.querySelector('input[name="total"]');
hargaDiskonInput = document.querySelector('input[name="harga_diskon"]');
} else {
// Untuk pembanding, gunakan array input dengan index
const hargaInputs = document.getElementsByName('harga_pembanding[]');
const diskonInputs = document.getElementsByName('diskon_pembanding[]');
const totalInputs = document.getElementsByName('total_pembanding[]');
const hargaDiskonInputs = document.getElementsByName('harga_diskon_pembanding[]');
// Pastikan index valid
if (index !== null && index < hargaInputs.length) {
hargaInput = hargaInputs[index];
diskonInput = diskonInputs[index];
totalInput = totalInputs[index];
hargaDiskonInput = hargaDiskonInputs[index];
} else {
return; // Keluar jika index tidak valid
}
}
// Validasi input
if (!hargaInput || !diskonInput || !totalInput || !hargaDiskonInput) {
return;
}
if (hargaInput && diskonInput && totalInput && hargaDiskonInput) {
// Ambil nilai numerik dari input
const harga = parseFloat(hargaInput.value.replace(/[^\d]/g, '') || '0');
const diskon = parseFloat(diskonInput.value.replace(/[^\d]/g, '') || '0');
let diskon = parseFloat(diskonInput.value.replace(/[^\d]/g, '') || '0');
// Batasi diskon maksimal 100%
diskon = Math.min(diskon, 100);
diskonInput.value = formatCurrency(diskon.toString());
// Hitung total dan harga setelah diskon
const total = harga;
const hargaSetelahDiskon = harga - (harga * (diskon / 100));
// Update nilai dengan format currency
if (totalInput) totalInput.value = formatCurrency(total.toString());
if (hargaDiskonInput) hargaDiskonInput.value = formatCurrency(hargaSetelahDiskon.toString());
}
totalInput.value = formatCurrency(total.toString());
hargaDiskonInput.value = formatCurrency(hargaSetelahDiskon.toString());
}
// Update fungsi fillPembandingData
function fillPembandingData(data, index) {
if (!data) return;
@@ -543,12 +614,28 @@
// Update event listener untuk input harga dan diskon
function initializePriceCalculation() {
document.querySelectorAll('[name="harga_pembanding[]"], [name="diskon_pembanding[]"]').forEach((input) => {
input.addEventListener('input', function() {
const inputs = document.getElementsByName(this.name);
const index = Array.from(inputs).indexOf(this);
calculatePrices(index);
// Event listener untuk input utama
const mainHargaInput = document.querySelector('input[name="harga"]');
const mainDiskonInput = document.querySelector('input[name="diskon"]');
if (mainHargaInput) {
mainHargaInput.addEventListener('input', () => calculatePrices('main'));
}
if (mainDiskonInput) {
mainDiskonInput.addEventListener('input', () => calculatePrices('main'));
}
// Event listener untuk input pembanding
const pembandingHargaInputs = document.getElementsByName('harga_pembanding[]');
const pembandingDiskonInputs = document.getElementsByName('diskon_pembanding[]');
pembandingHargaInputs.forEach((input, index) => {
input.addEventListener('input', () => calculatePrices('pembanding', index));
});
pembandingDiskonInputs.forEach((input, index) => {
input.addEventListener('input', () => calculatePrices('pembanding', index));
});
}
@@ -657,18 +744,30 @@
if (input.classList.contains('currency-format')) {
input.addEventListener('input', function() {
formatCurrency(this);
// Special handling for price-related inputs
if (input.name.includes('harga_pembanding') ||
input.name.includes('diskon_pembanding')) {
const inputs = document.getElementsByName(input.name);
const index = Array.from(inputs).indexOf(this);
calculatePrices(index);
}
});
}
if (input.classList.contains('number-format')) {
// Specific handling for discount to limit to 100%
if (input.name.includes('diskon_pembanding')) {
input.addEventListener('input', function() {
formatNumber(this);
let value = parseFloat(this.value.replace(/[^\d]/g, '') || '0');
value = Math.min(value, 100);
this.value = formatCurrency(value.toString());
});
}
});
}
row.appendChild(newCell);
});
initializePriceCalculation();
updateRemoveButtonVisibility();
}
@@ -913,8 +1012,6 @@
window.location.href =
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
}
});
} else {
@@ -925,6 +1022,7 @@
confirmButtonText: 'OK'
});
}
},
error: function(xhr, status, error) {
hideLoadingSwal();

View File

@@ -15,7 +15,8 @@
@foreach ($forminspeksi['fakta']['fakta_positif'] as $index => $positif)
<div class="fakta_positif flex items-center gap-2 mt-2 textarea-group w-full">
<textarea class="textarea mt-2" name="fakta_positif[]" rows="3">{{ old("fakta_positif.$index", $positif) }}</textarea>
<button class="btn btn-danger btn-sm remove-btn" type="button">
<button class="btn btn-danger btn-sm remove-btn" type="button"
style="display: none;">
<i class="ki-outline ki-trash"></i>
</button>
</div>

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)
@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)
@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>
@@ -526,25 +537,31 @@
`;
}
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') }}">
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" >
<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 }}">{{ $province->name }}</option>
<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>
@@ -553,7 +570,7 @@
<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" >
<select id="city_code" name="city_code" class="select w-full" onchange="getDistrict(this.value)">
<option value="">Pilih Kota/Kabupaten</option>
</select>
</div>
@@ -562,7 +579,7 @@
<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" >
<select id="district_code" name="district_code" class="select w-full" onchange="getVillage(this.value)">
<option value="">Pilih Kecamatan</option>
</select>
</div>
@@ -578,6 +595,136 @@
</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>

View File

@@ -23,19 +23,28 @@
'label' => 'KDB',
'name' => 'kdb',
'index' => 1,
'value' => old('kdb', isset($forminspeksi['fakta']['kdb']) ? $forminspeksi['fakta']['kdb'] : ''),
'value' => old(
'kdb',
isset($forminspeksi['fakta']['kdb']) ? $forminspeksi['fakta']['kdb'] : '',
),
],
[
'label' => 'KDH',
'name' => 'kdh',
'index' => 2,
'value' => old('kdh', isset($forminspeksi['fakta']['kdh']) ? $forminspeksi['fakta']['kdh'] : ''),
'value' => old(
'kdh',
isset($forminspeksi['fakta']['kdh']) ? $forminspeksi['fakta']['kdh'] : '',
),
],
[
'label' => 'GSB',
'name' => 'gsb',
'index' => 3,
'value' => old('gsb', isset($forminspeksi['fakta']['gsb']) ? $forminspeksi['fakta']['gsb'] : ''),
'value' => old(
'gsb',
isset($forminspeksi['fakta']['gsb']) ? $forminspeksi['fakta']['gsb'] : '',
),
],
[
'label' => 'Max Lantai',
@@ -50,13 +59,19 @@
'label' => 'KLB',
'name' => 'klb',
'index' => 5,
'value' => old('klb', isset($forminspeksi['fakta']['klb']) ? $forminspeksi['fakta']['klb'] : ''),
'value' => old(
'klb',
isset($forminspeksi['fakta']['klb']) ? $forminspeksi['fakta']['klb'] : '',
),
],
[
'label' => 'GSS',
'name' => 'gss',
'index' => 6,
'value' => old('gss', isset($forminspeksi['fakta']['gss']) ? $forminspeksi['fakta']['gss'] : ''),
'value' => old(
'gss',
isset($forminspeksi['fakta']['gss']) ? $forminspeksi['fakta']['gss'] : '',
),
],
[
'label' => 'Pelebaran Jalan',
@@ -64,7 +79,9 @@
'index' => 7,
'value' => old(
'pelebaran_jalan',
isset($forminspeksi['fakta']['pelebaran_jalan']) ? $forminspeksi['fakta']['pelebaran_jalan'] : '',
isset($forminspeksi['fakta']['pelebaran_jalan'])
? $forminspeksi['fakta']['pelebaran_jalan']
: '',
),
],
[
@@ -73,7 +90,9 @@
'index' => 8,
'value' => old(
'nama_petugas',
isset($forminspeksi['fakta']['nama_petugas']) ? $forminspeksi['fakta']['nama_petugas'] : '',
isset($forminspeksi['fakta']['nama_petugas'])
? $forminspeksi['fakta']['nama_petugas']
: '',
),
],
];
@@ -105,10 +124,13 @@
<input id="inputGistaru" type="file" name="foto_gistaru"
class="file-input file-input-bordered w-full" accept="image/*"
onchange="previewImage(this, 'gistaru-preview')">
<img id="gistaru-preview"
src="{{ asset('storage/' . (isset($forminspeksi['foto_gistaru']) ? $forminspeksi['foto_gistaru'] : '')) }}"
alt="Foto Gistaru" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_gistaru']) ? '' : 'display: none;' }}">
alt="Foto Bhumi" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_gistaru']) ? '' : 'display: none;' }}" />
</div>
<a href="https://gistaru.atrbpn.go.id/rtronline" type="button" class="btn btn-light"
target="_blank">
@@ -123,17 +145,18 @@
</label>
<div class="input-group w-full flex gap-2">
<input class="name_rute" type="hidden" name="name_rute" value="rute">
<div class="w-full">
<div class="w-full grid gap-2">
<input id="inputBhumi" type="file" name="foto_bhumi"
class="file-input file-input-bordered w-full " accept="image/*"
onchange="previewImage(this, 'bhumi-preview')">
<img id="bhumi-preview"
src="{{ asset('storage/' . (isset($forminspeksi['foto_bhumi']) ? $forminspeksi['foto_bhumi'] : '')) }}"
alt="Foto Bhumi" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_bhumi']) ? '' : 'display: none;' }}">
style="{{ isset($forminspeksi['foto_bhumi']) ? '' : 'display: none;' }}" />
</div>
<a href="https://bhumi.atrbpn.go.id/peta" type="button" class="btn btn-light"
target="_blank">
<a href="https://bhumi.atrbpn.go.id/peta" type="button" class="btn btn-light" target="_blank">
<i class="ki-filled ki-map"></i> Bhumi
</a>
</div>
@@ -172,11 +195,9 @@
<div class="w-full grid gap-5">
<div class="input-group w-full flex gap-2">
<input id="foto_tempat" type="file" name="foto_tempat"
class="file-input file-input-bordered w-full" accept="image/*"
onchange="previewImage(this, 'foto_tempat-preview')">
<button type="button" id="btnCamera" class="btn btn-light"
data-modal-toggle="#cameraModal">
<button type="button" id="btnCamera" class="btn btn-light" data-modal-toggle="#cameraModal">
<i class="ki-outline ki-abstract-33"></i> Camera
</button>
</div>
@@ -191,7 +212,7 @@
<!-- Notes Section -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
<label class="form-label max-w-56">Catatan yang Perlu Diperhatikan
<label class="form-label lg:form-label max-w-56 ">Catatan yang Perlu Diperhatikan
</label>
<div class="input-group w-full flex gap-2">
<textarea name="keterangan" class="textarea mt-2" placeholder="Masukkan catatan penting" rows="3">{{ old('keterangan', $forminspeksi['fakta']['keterangan'] ?? '') }}</textarea>
@@ -205,4 +226,3 @@
@push('scripts')
@include('lpj::surveyor.js.camera-editor')
@endpush

View File

@@ -200,8 +200,8 @@
confirmButtonText: 'OK'
}).then((response) => {
if (response.isConfirmed) {
// window.location.href =
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
window.location.href =
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
}
});
} else {
@@ -231,52 +231,7 @@
});
}
function previewImage(input, previewId) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#' + previewId).attr('src', e.target.result).show();
}
reader.readAsDataURL(input.files[0]);
} else {
$('#' + previewId).hide();
}
}
function addClonableItem(containerId, itemClass) {
const container = document.getElementById(containerId);
if (!container) {
console.error(`Container with ID "${containerId}" not found.`);
return;
}
const template = container.querySelector(`.${itemClass}`);
if (!template) {
console.error(`Template with class "${itemClass}" not found in container "${containerId}".`);
return;
}
// Clone the template element
const newElement = template.cloneNode(true);
// Reset input fields
const inputs = newElement.querySelectorAll('input');
inputs.forEach(input => {
input.value = '';
});
// Make the delete button visible and bind the click event
const deleteButton = newElement.querySelector('.remove-btn');
if (deleteButton) {
deleteButton.style.display = 'inline-block';
deleteButton.addEventListener('click', () => {
newElement.remove();
});
}
// Append the cloned element to the container
container.appendChild(newElement);
}
// Ensure existing remove buttons are functional
document.addEventListener('DOMContentLoaded', () => {

View File

@@ -35,7 +35,10 @@
<div class="w-full mt-4">
<label class="block text-sm font-medium text-gray-700">Lebar Perkerasan Jalan Depan objek</label>
@php
$lebarPerkerasanJalan = old('lebar_perkerasan_jalan', $forminspeksi['lingkungan']['lebar_perkerasan_jalan'] ?? '');
$lebarPerkerasanJalan = old(
'lebar_perkerasan_jalan',
$forminspeksi['lingkungan']['lebar_perkerasan_jalan'] ?? '',
);
@endphp
<input type="text" name="lebar_perkerasan_jalan" class="input mt-2" placeholder="Meter"
value="{{ $lebarPerkerasanJalan }}">
@@ -50,12 +53,16 @@
@if (isset($basicData['perkerasanJalan']))
@foreach ($basicData['perkerasanJalan'] as $item)
@php
$isChecked = in_array($item->name, isset($forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan']) ? $forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan'] : []);
$isChecked = in_array(
$item->name,
isset($forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan'])
? $forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan']
: [],
);
@endphp
<label class="form-label flex items-center gap-2.5 text-nowrap">
<input class="checkbox" name="perkerasan_jalan[]" type="checkbox"
value="{{ $item->name }}"
{{ $isChecked ? 'checked' : '' }}
value="{{ $item->name }}" {{ $isChecked ? 'checked' : '' }}
onclick="toggleCheckboxVisibility('perkerasan_jalan', 'perkerasan_jalan_lainnya', ['lainnya'])" />
{{ $item->name }}
</label>
@@ -63,15 +70,18 @@
@if (strcasecmp($item->name, 'Lainnya') == 0)
@php
$lainnyaValue = old('perkerasan_jalan_lainnya', isset($forminspeksi['lingkungan']['perkerasan_jalan']['lainnya']) ? $forminspeksi['lingkungan']['perkerasan_jalan']['lainnya'] : '');
$lainnyaValue = old(
'perkerasan_jalan_lainnya',
isset($forminspeksi['lingkungan']['perkerasan_jalan']['lainnya'])
? $forminspeksi['lingkungan']['perkerasan_jalan']['lainnya']
: '',
);
@endphp
<input id="perkerasan_jalan_lainnya" type="text"
style="{{ isset($forminspeksi['lingkungan']['perkerasan_jalan']['lainnya']) && $forminspeksi['lingkungan']['perkerasan_jalan']['lainnya'] ? '' : 'display: none' }}"
name="perkerasan_jalan_lainnya" class="input w-full mt-2"
value="{{ $lainnyaValue }}"
placeholder="Masukkan lainnya..." />
value="{{ $lainnyaValue }}" placeholder="Masukkan lainnya..." />
@endif
@endforeach
@endif
</div>
@@ -103,7 +113,7 @@
</div>
<!-- Golongan Hidup Sekitar -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Golongan Masy Sekitar</label>
<label class="form-label max-w-56">Golongan Masyarakat Sekitar</label>
<div class="flex flex-wrap items-baseline w-full">
<div class="flex flex-col items-start gap-4">
@if (isset($basicData['golMasySekitar']))
@@ -160,15 +170,18 @@
</label>
@if (strcasecmp($item->name, 'Lainnya') == 0)
@php
$lainnyaValue = old('terletak_diarea_lainnya', isset($forminspeksi['lingkungan']['terletak_diarea']['lainnya']) ? $forminspeksi['lingkungan']['terletak_diarea']['lainnya'] : '');
$lainnyaValue = old(
'terletak_diarea_lainnya',
isset($forminspeksi['lingkungan']['terletak_diarea']['lainnya'])
? $forminspeksi['lingkungan']['terletak_diarea']['lainnya']
: '',
);
@endphp
<input id="terletak_diarea_lainnya" type="text"
style="{{ isset($forminspeksi['lingkungan']['terletak_diarea']['lainnya']) && $forminspeksi['lingkungan']['terletak_diarea']['lainnya'] ? '' : 'display: none' }}"
name="terletak_diarea_lainnya" class="input w-full mt-2"
value="{{ $lainnyaValue }}"
placeholder="Masukkan lainnya..." />
value="{{ $lainnyaValue }}" placeholder="Masukkan lainnya..." />
@endif
@endforeach
@endif
</div>
@@ -356,48 +369,37 @@
@if (isset($basicData['fasilitasObjek']))
@foreach ($basicData['fasilitasObjek'] as $item)
@php
$isChecked = false;
$inputValue = '';
$selectedFasilitas = is_array(
old(
'fasilitas_dekat_object',
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? [],
),
)
? old(
'fasilitas_dekat_object',
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? [],
)
: explode(
',',
old(
'fasilitas_dekat_object',
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? '',
),
);
// Cek old input terlebih dahulu
if (old('fasilitas_dekat_object') && in_array($item->name, old('fasilitas_dekat_object'))) {
$isChecked = true;
$oldInputIndex = array_search($item->name, old('fasilitas_dekat_object'));
$inputValue = old('fasilitas_dekat_object_input')[$oldInputIndex] ?? '';
}
elseif (isset($forminspeksi['lingkungan']['fasilitas_dekat_object'])) {
foreach ($forminspeksi['lingkungan']['fasilitas_dekat_object'] as $key => $value) {
if ($key === $item->name) {
$isChecked = true;
$inputValue = $value;
break;
}
}
}
@endphp
<label class="form-label flex items-center gap-2.5 text-nowrap">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56 gap-2.5" style="width: 500px">
<input class="checkbox" name="fasilitas_dekat_object[]" type="checkbox"
value="{{ $item->name }}"
{{ in_array(
$item->name,
is_array(old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? ''))
? old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? [])
: explode(',', old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? '')),
)
? 'checked'
: '' }}
onclick="toggleCheckboxVisibility('fasilitas_dekat_object', 'fasilitas_dekat_object_lainnya', ['Lainnya'])"
/>
{{ $isChecked ? 'checked' : '' }} />
{{ $item->name }}
</label>
@if (strcasecmp($item->name, 'Lainnya') == 0)
<input id="fasilitas_dekat_object_lainnya" type="text" style="{{ in_array('Lainnya', $selectedFasilitas) ? '' : 'display: none' }}"
name="fasilitas_dekat_object_lainnya" class="input w-full mt-2"
value="{{ old('fasilitas_dekat_object_lainnya', $forminspeksi['lingkungan']['fasilitas_dekat_object']['lainnya'] ?? '') }}"
placeholder="Masukkan lainnya..." />
@endif
<input type="text" name="fasilitas_dekat_object_input[]" class="input w-full"
placeholder="Masukkan fasilitas {{ $item->name }}..."
value="{{ $inputValue }}">
</div>
@endforeach
@endif
</div>
@@ -405,6 +407,9 @@
</div>
</div>
</div>
</div>
</div>

View File

@@ -24,7 +24,7 @@
@endforeach
@endif
<div class="flex-wrap items-stretch">
<div class="flex flex-wrap items-baseline w-full">
<div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
<label class="form-label flex items-center gap-3 text-nowrap">
<input type="radio" class="radio" name="luas_tanah" value="sesuai"
@@ -48,7 +48,7 @@
</div>
</div>
<em id="error-luas_tanah" class="alert text-danger text-sm"></em>
</div>
</div>
</div>
</div>

View File

@@ -52,4 +52,119 @@
return formattedValue;
}
function previewImage(input, previewId) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#' + previewId).attr('src', e.target.result).show();
}
reader.readAsDataURL(input.files[0]);
} else {
$('#' + previewId).hide();
}
}
function addClonableItem(containerId, itemClass) {
const container = document.getElementById(containerId);
if (!container) {
console.error(`Container with ID "${containerId}" not found.`);
return;
}
const template = container.querySelector(`.${itemClass}`);
if (!template) {
console.error(`Template with class "${itemClass}" not found in container "${containerId}".`);
return;
}
// Clone the template element
const newElement = template.cloneNode(true);
// Reset all input fields comprehensively
const inputs = newElement.querySelectorAll('input, select, textarea');
inputs.forEach(input => {
// Reset based on input type
switch (input.type) {
case 'text':
case 'number':
case 'email':
case 'tel':
case 'password':
case 'search':
case 'url':
case 'textarea':
input.value = '';
break;
case 'checkbox':
case 'radio':
input.checked = false;
break;
case 'select-one':
case 'select-multiple':
input.selectedIndex = 0;
break;
case 'file':
input.value = '';
break;
}
// Remove any error classes or validation states
input.classList.remove('is-invalid', 'error');
// Reset any custom attributes if needed
input.removeAttribute('data-previous-value');
});
// Reset select elements to their default state
const selects = newElement.querySelectorAll('select');
selects.forEach(select => {
select.selectedIndex = 0;
});
// Make the delete button visible and bind the click event
const deleteButton = newElement.querySelector('.remove-btn');
if (deleteButton) {
deleteButton.style.display = 'inline-block';
deleteButton.addEventListener('click', () => {
newElement.remove();
});
}
// Reset any custom data attributes
newElement.querySelectorAll('[data-clone-reset]').forEach(element => {
const resetValue = element.getAttribute('data-clone-reset');
if (resetValue) {
if (element.tagName === 'INPUT' || element.tagName === 'SELECT' || element.tagName ===
'TEXTAREA') {
element.value = resetValue;
} else {
element.textContent = resetValue;
}
}
});
// Optional: Regenerate unique IDs if needed
const elementsWithId = newElement.querySelectorAll('[id]');
elementsWithId.forEach(element => {
const originalId = element.id;
const newId = `${originalId}_${Date.now()}`;
element.id = newId;
// Update any labels or references
const labels = newElement.querySelectorAll(`label[for="${originalId}"]`);
labels.forEach(label => {
label.setAttribute('for', newId);
});
});
// Append the cloned element to the container
container.appendChild(newElement);
// Optional: Trigger any custom events or reinitialize plugins
const event = new Event('cloneAdded', {
bubbles: true
});
newElement.dispatchEvent(event);
}
</script>