Merge remote-tracking branch 'composer/feature/senior-officer' into staging
This commit is contained in:
@@ -567,53 +567,75 @@ class PenilaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function storeLpjSederhanadanStandard(Request $request)
|
public function storeLpjSederhanadanStandard(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$validatedRequest = app(FormSurveyorRequest::class);
|
$validatedRequest = app(FormSurveyorRequest::class);
|
||||||
$this->surveyorController->store($validatedRequest);
|
$this->surveyorController->store($validatedRequest);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'luas_tanah' => $request->input('luas_tanah'),
|
||||||
|
'nilai_tanah_1' => $request->input('nilai_tanah_1'),
|
||||||
|
'nilai_tanah_2' => $request->input('nilai_tanah_2'),
|
||||||
|
'luas_bangunan' => $request->input('luas_bangunan'),
|
||||||
|
'nilai_bangunan_1' => $request->input('nilai_bangunan_1'),
|
||||||
|
'nilai_bangunan_2' => $request->input('nilai_bangunan_2'),
|
||||||
|
'sarana_pelengkap_penilai' => $request->input('sarana_pelengkap_penilai'),
|
||||||
|
'nilai_sarana_pelengkap_1' => $request->input('nilai_sarana_pelengkap_1'),
|
||||||
|
'nilai_sarana_pelengkap_2' => $request->input('nilai_sarana_pelengkap_2'),
|
||||||
|
'total_nilai_pasar_wajar' => $request->input('total_nilai_pasar_wajar'),
|
||||||
|
'likuidasi' => $request->input('likuidasi'),
|
||||||
|
'likuidasi_nilai_1' => $request->input('likuidasi_nilai_1'),
|
||||||
|
'likuidasi_nilai_2' => $request->input('likuidasi_nilai_2'),
|
||||||
|
'asuransi_luas_bangunan' => $request->input('asuransi_luas_bangunan'),
|
||||||
|
'asuransi_nilai_1' => $request->input('asuransi_nilai_1'),
|
||||||
|
'asuransi_nilai_2' => $request->input('asuransi_nilai_2'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$npwData = [];
|
||||||
|
$npwCounter = 1;
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
while ($request->has("name_npw_{$npwCounter}")) {
|
||||||
'luas_tanah' => $request->input('luas_tanah'),
|
$npwData[] = [
|
||||||
'nilai_tanah_1' => $request->input('nilai_tanah_1'),
|
'name' => $request->input("name_npw_{$npwCounter}"),
|
||||||
'nilai_tanah_2' => $request->input('nilai_tanah_2'),
|
'luas' => $request->input("luas_npw_{$npwCounter}"),
|
||||||
'luas_bangunan' => $request->input('luas_bangunan'),
|
'nilai_1' => $request->input("nilai_npw_{$npwCounter}_1"),
|
||||||
'nilai_bangunan_1' => $request->input('nilai_bangunan_1'),
|
'nilai_2' => $request->input("nilai_npw_{$npwCounter}_2")
|
||||||
'nilai_bangunan_2' => $request->input('nilai_bangunan_2'),
|
];
|
||||||
'sarana_pelengkap_penilai' => $request->input('sarana_pelengkap_penilai'),
|
$npwCounter++;
|
||||||
'nilai_sarana_pelengkap_1' => $request->input('nilai_sarana_pelengkap_1'),
|
}
|
||||||
'nilai_sarana_pelengkap_2' => $request->input('nilai_sarana_pelengkap_2'),
|
|
||||||
'total_nilai_pasar_wajar' => $request->input('total_nilai_pasar_wajar'),
|
if (!empty($npwData)) {
|
||||||
'likuidasi' => $request->input('likuidasi'),
|
$data['npw_tambahan'] = $npwData;
|
||||||
'likuidasi_nilai_1' => $request->input('likuidasi_nilai_1'),
|
}
|
||||||
'likuidasi_nilai_2' => $request->input('likuidasi_nilai_2'),
|
|
||||||
'asuransi_luas_bangunan' => $request->input('asuransi_luas_bangunan'),
|
// Update atau buat data baru
|
||||||
'asuransi_nilai_1' => $request->input('asuransi_nilai_1'),
|
$penilai = Penilai::updateOrCreate(
|
||||||
'asuransi_nilai_2' => $request->input('asuransi_nilai_2'),
|
[
|
||||||
];
|
'permohonan_id' => $request->permohonanId,
|
||||||
|
'dokument_id' => $request->documentId,
|
||||||
// Update atau buat data baru
|
'inspeksi_id' => $request->inspeksiId,
|
||||||
Penilai::updateOrCreate(
|
],
|
||||||
[
|
[
|
||||||
'permohonan_id' => $request->permohonanId,
|
'lpj' => json_encode($data),
|
||||||
'dokument_id' => $request->documentId,
|
]
|
||||||
'inspeksi_id' => $request->inspeksiId,
|
);
|
||||||
],
|
|
||||||
[
|
return response()->json([
|
||||||
'lpj' => json_encode($data),
|
'success' => true,
|
||||||
]
|
'message' => 'Berhasil menyimpan LPJ',
|
||||||
);
|
'data' => $penilai
|
||||||
return response()->json([
|
], 200);
|
||||||
'success' => true,
|
} catch (\Throwable $e) {
|
||||||
'message' => 'Berhasil menyimpan LPJ',
|
return response()->json([
|
||||||
], 200);
|
'success' => false,
|
||||||
} catch (\Throwable $e) {
|
'message' => 'Terjadi kesalahan saat menyimpan LPJ',
|
||||||
return response()->json([
|
'error' => $e->getMessage(),
|
||||||
'success' => false,
|
'trace' => $e->getTraceAsString()
|
||||||
'message' => 'Terjadi kesalahan saat menyimpan LPJ',
|
], 500);
|
||||||
'error' => $e->getMessage(),
|
}
|
||||||
], 500);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function print_out(Request $request)
|
public function print_out(Request $request)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<div style="display: none">
|
<div style="display: none">
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
|
||||||
<label class="form-label max-w-56">Debitur/Perwakilan</label>
|
<label class="form-label max-w-56">Debitur/Perwakilan</label>
|
||||||
@@ -158,9 +157,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@php
|
@php
|
||||||
$statusKey = isset($forminspeksi['asset']['alamat']['sesuai'])
|
$statusKey = isset($forminspeksi['asset']['alamat']['sesuai']) ? 'sesuai' : 'tidak sesuai';
|
||||||
? 'sesuai'
|
|
||||||
: 'tidak sesuai';
|
|
||||||
$address = $forminspeksi['asset']['alamat'][$statusKey] ?? null;
|
$address = $forminspeksi['asset']['alamat'][$statusKey] ?? null;
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
@@ -186,8 +183,8 @@
|
|||||||
<label class="form-label max-w-56">Koordinat</label>
|
<label class="form-label max-w-56">Koordinat</label>
|
||||||
<div id="perwakilan" class="flex items-baseline w-full gap-5">
|
<div id="perwakilan" class="flex items-baseline w-full gap-5">
|
||||||
<div class="grid grid-cols-2 gap-4 items-center w-full">
|
<div class="grid grid-cols-2 gap-4 items-center w-full">
|
||||||
<input class="input" type="text" placeholder="Masukan Koordinat Latitude"
|
<input class="input" type="text" placeholder="Masukan Koordinat Latitude" type="text"
|
||||||
type="text" name="kordinat_lat" id="lat"
|
name="kordinat_lat" id="lat"
|
||||||
value="{{ old('kordinat_lat', isset($forminspeksi['asset']['kordinat_lat']) ? $forminspeksi['asset']['kordinat_lat'] : '') }}">
|
value="{{ old('kordinat_lat', isset($forminspeksi['asset']['kordinat_lat']) ? $forminspeksi['asset']['kordinat_lat'] : '') }}">
|
||||||
<input class="input" type="text" placeholder="Masukan Koordinat Longitude"
|
<input class="input" type="text" placeholder="Masukan Koordinat Longitude"
|
||||||
name="kordinat_lng" id="lng"
|
name="kordinat_lng" id="lng"
|
||||||
@@ -298,8 +295,7 @@
|
|||||||
|
|
||||||
<input
|
<input
|
||||||
onclick="toggleFieldVisibility('hub_cadeb_penghuni','hub_penghuni_tidak_sesuai', ['tidak sesuai'])"
|
onclick="toggleFieldVisibility('hub_cadeb_penghuni','hub_penghuni_tidak_sesuai', ['tidak sesuai'])"
|
||||||
type="radio" class="radio" name="hub_cadeb_penghuni"
|
type="radio" class="radio" name="hub_cadeb_penghuni" value="sesuai"
|
||||||
value="sesuai"
|
|
||||||
{{ old('hub_cadeb_penghuni', isset($forminspeksi['asset']['hub_cadeb_penghuni'])) ? 'checked' : '' }}>
|
{{ old('hub_cadeb_penghuni', isset($forminspeksi['asset']['hub_cadeb_penghuni'])) ? 'checked' : '' }}>
|
||||||
|
|
||||||
<span class="ml-2">Ditempati Sendiri</span>
|
<span class="ml-2">Ditempati Sendiri</span>
|
||||||
@@ -314,9 +310,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<!-- Select dropdown untuk "Tidak Sesuai" -->
|
<!-- Select dropdown untuk "Tidak Sesuai" -->
|
||||||
@php
|
@php
|
||||||
$statusKey = isset(
|
$statusKey = isset($forminspeksi['asset']['hub_cadeb_penghuni']['sesuai'])
|
||||||
$forminspeksi['asset']['hub_cadeb_penghuni']['sesuai'],
|
|
||||||
)
|
|
||||||
? 'sesuai'
|
? 'sesuai'
|
||||||
: 'tidak sesuai';
|
: 'tidak sesuai';
|
||||||
$selectedData =
|
$selectedData =
|
||||||
@@ -346,18 +340,18 @@
|
|||||||
<div class="card border border-agi-100 min-w-full">
|
<div class="card border border-agi-100 min-w-full">
|
||||||
<div class="card-header bg-agi-50">
|
<div class="card-header bg-agi-50">
|
||||||
<h3 class="card-title">
|
<h3 class="card-title">
|
||||||
{{$title ?? 'Data Jaminan' }}
|
{{ $title ?? 'Data Jaminan' }}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
@if (isset($id))
|
@if (isset($id))
|
||||||
<a href="{{ route($backLink, ['id' => $id]) }}" class="btn btn-xs btn-info">
|
<a href="{{ route($backLink, ['id' => $id]) }}" class="btn btn-xs btn-info">
|
||||||
<i class="ki-filled ki-exit-left"></i> Back
|
<i class="ki-filled ki-exit-left"></i> Back
|
||||||
</a>
|
</a>
|
||||||
@else
|
@else
|
||||||
<a href="{{ url()->previous() }}" class="btn btn-xs btn-info">
|
<a href="{{ url()->previous() }}" class="btn btn-xs btn-info">
|
||||||
<i class="ki-filled ki-exit-left"></i> Back
|
<i class="ki-filled ki-exit-left"></i> Back
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body grid gap-5 grid-cols-2">
|
<div class="card-body grid gap-5 grid-cols-2">
|
||||||
@@ -552,6 +546,7 @@
|
|||||||
@php
|
@php
|
||||||
$kategoriArray = is_array($formKategori) ? $formKategori : [$formKategori];
|
$kategoriArray = is_array($formKategori) ? $formKategori : [$formKategori];
|
||||||
$kategoriUnik = array_unique($kategoriArray);
|
$kategoriUnik = array_unique($kategoriArray);
|
||||||
|
print_r($kategoriUnik);
|
||||||
@endphp
|
@endphp
|
||||||
<input type="hidden" name="action" value="{{ implode(',', $kategoriUnik) }}">
|
<input type="hidden" name="action" value="{{ implode(',', $kategoriUnik) }}">
|
||||||
<input type="hidden" name="type" value="{{ implode(',', $kategoriUnik) }}">
|
<input type="hidden" name="type" value="{{ implode(',', $kategoriUnik) }}">
|
||||||
@@ -577,213 +572,455 @@
|
|||||||
@include('lpj::penilai.components.informasi-pembanding')
|
@include('lpj::penilai.components.informasi-pembanding')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-agi-50">
|
<div class="card-header bg-agi-50">
|
||||||
<h3 class="card-title uppercase">
|
<h3 class="card-title uppercase">
|
||||||
total nilai pasar wajar
|
total nilai pasar wajar
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body gap-5">
|
<div class="card-body gap-5">
|
||||||
<div>
|
<div>
|
||||||
<label for="total_nilai_pasar_wajar" class="form-label">Total Nilai Pasar Wajar</label>
|
<label for="total_nilai_pasar_wajar" class="form-label">Total Nilai Pasar Wajar</label>
|
||||||
<div class="card-body grid gap-2.5 w-full">
|
<div class="card-body grid gap-2.5 ">
|
||||||
<div class="flex grid-col-3 gap-2.5 w-full">
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label for="province" class="form-label max-w-56">Luas Tanah</label>
|
|
||||||
<input type="text" id="luas_tanah" class="input w-full currency-format"
|
|
||||||
name="luas_tanah" value="{{ old('luas_tanah', $lpjData['luas_tanah'] ?? null) }}"
|
|
||||||
oninput="calculateTotal()">
|
|
||||||
</div>
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label for="province" class="">X</label>
|
|
||||||
<label class="input">
|
|
||||||
<i class="">Rp
|
|
||||||
</i>
|
|
||||||
<input type="text" id="nilai_tanah_1" class=" w-full currency-format"
|
|
||||||
name="nilai_tanah_1"
|
|
||||||
value="{{ old('nilai_tanah_1', $lpjData['nilai_tanah_1'] ?? null) }}"
|
|
||||||
oninput="calculateTotal()">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label class="input">
|
|
||||||
<i class="">Rp
|
|
||||||
</i>
|
|
||||||
<input id="nilai_tanah_2" type="text" class=" w-full currency-format"
|
|
||||||
name="nilai_tanah_2"
|
|
||||||
value="{{ old('nilai_tanah_2', $lpjData['nilai_tanah_2'] ?? null) }}">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex grid-col-3 gap-2.5 w-full">
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label for="province" class="form-label max-w-56">Luas Bangunan</label>
|
|
||||||
<input type="text" class="input w-full currency-format" id="luas_bangunan"
|
|
||||||
name="luas_bangunan"
|
|
||||||
value="{{ old('luas_bangunan', $lpjData['luas_bangunan'] ?? null) }}"
|
|
||||||
oninput="calculateTotal()">
|
|
||||||
</div>
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label for="province" class="">X</label>
|
|
||||||
<label class="input">
|
|
||||||
<i class="">Rp
|
|
||||||
</i>
|
|
||||||
<input type="text" class=" w-full currency-format" id="nilai_bangunan_1"
|
|
||||||
name="nilai_bangunan_1"
|
|
||||||
value="{{ old('nilai_bangunan_1', $lpjData['nilai_bangunan_1'] ?? null) }}"
|
|
||||||
oninput="calculateTotal()">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label class="input">
|
|
||||||
<i class="">Rp
|
|
||||||
</i>
|
|
||||||
<input type="text" class=" w-full currency-format" id="nilai_bangunan_2"
|
|
||||||
name="nilai_bangunan_2"
|
|
||||||
value="{{ old('nilai_bangunan_2', $lpjData['nilai_bangunan_2'] ?? null) }}">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex grid-col-3 gap-2.5 w-full">
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label for="province" class="form-label max-w-56">Sarana Pelengkap</label>
|
|
||||||
<input type="text" class="input w-full currency-format" id="sarana_pelengkap_penilai"
|
|
||||||
name="sarana_pelengkap_penilai"
|
|
||||||
value="{{ old('sarana_pelengkap_penilai', $lpjData['sarana_pelengkap_penilai'] ?? null) }}"
|
|
||||||
oninput="calculateTotal()">
|
|
||||||
</div>
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
|
|
||||||
<label for="province" class="">X</label>
|
|
||||||
<label class="input">
|
|
||||||
<i class="">Rp
|
|
||||||
</i>
|
|
||||||
<input type="text" class=" w-full currency-format"
|
|
||||||
id="nilai_sarana_pelengkap_1" name="nilai_sarana_pelengkap_1"
|
|
||||||
value="{{ old('nilai_sarana_pelengkap_1', $lpjData['nilai_sarana_pelengkap_1'] ?? null) }}"
|
|
||||||
oninput="calculateTotal()">
|
|
||||||
|
|
||||||
</label>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="grid gap-5 w-full">
|
|
||||||
|
|
||||||
|
@php
|
||||||
|
$labelNilai = [
|
||||||
|
'bangunan' => 'Luas Bangunan',
|
||||||
|
'tanah' => 'Luas Tanah',
|
||||||
|
'apartement-kantor' => 'Luas Apartemen/Kantor',
|
||||||
|
'alat-berat' => 'Luas Alat Berat',
|
||||||
|
'mesin' => 'Luas Mesin',
|
||||||
|
'kendaraan' => 'Luas Kendaraan',
|
||||||
|
'pesawat' => 'Luas Pesawat',
|
||||||
|
'kapal' => 'Luas Kapal',
|
||||||
|
];
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@foreach ($kategoriUnik as $item)
|
||||||
|
@if (isset($labelNilai[$item]))
|
||||||
|
<div class="flex grid-col-3 gap-2.5 w-full">
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<label for="province" class="form-label max-w-56">
|
||||||
|
{{ $labelNilai[$item] }}
|
||||||
|
</label>
|
||||||
|
<input type="text" id="luas_{{ $item }}"
|
||||||
|
class="input w-full currency-format" name="luas_{{ $item }}"
|
||||||
|
value="{{ old('luas_' . $item, $lpjData['luas_' . $item] ?? null) }}"
|
||||||
|
oninput="calculateTotal()">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<label for="province" class="">X</label>
|
||||||
<label class="input">
|
<label class="input">
|
||||||
<i class="">Rp
|
<i class="">Rp</i>
|
||||||
</i>
|
<input type="text" id="nilai_{{ $item }}_1"
|
||||||
<input type="text" class="w-full currency-format"
|
class="w-full currency-format" name="nilai_{{ $item }}_1"
|
||||||
id="nilai_sarana_pelengkap_2" name="nilai_sarana_pelengkap_2"
|
value="{{ old('nilai_' . $item . '_1', $lpjData['nilai_' . $item . '_1'] ?? null) }}"
|
||||||
value="{{ old('nilai_sarana_pelengkap_2', $lpjData['nilai_sarana_pelengkap_2'] ?? null) }}">
|
oninput="calculateTotal()">
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<label class="input">
|
||||||
<label for="province" class="input">
|
<i class="">Rp</i>
|
||||||
<i class="">Rp
|
<input id="nilai_{{ $item }}_2" type="text"
|
||||||
</i>
|
class="w-full currency-format" name="nilai_{{ $item }}_2"
|
||||||
<input type="text" class=" w-full currency-format"
|
value="{{ old('nilai_' . $item . '_2', $lpjData['nilai_' . $item . '_2'] ?? null) }}">
|
||||||
id="total_nilai_pasar_wajar" name="total_nilai_pasar_wajar"
|
|
||||||
value="{{ old('total_nilai_pasar_wajar', $lpjData['total_nilai_pasar_wajar'] ?? null) }}">
|
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div id="add_pasar_wajar" class="flex flex-wrap gap-2.5 w-full">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-end gap-2 ">
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full grid-col-2">
|
||||||
|
<label class="form-label max-w-56" for="">Total Nilai</label>
|
||||||
|
<label for="province" class="input">
|
||||||
|
<i class="">Rp
|
||||||
|
</i>
|
||||||
|
<input type="text" class=" w-full currency-format"
|
||||||
|
id="total_nilai_pasar_wajar" name="total_nilai_pasar_wajar"
|
||||||
|
value="{{ old('total_nilai_pasar_wajar', $lpjData['total_nilai_pasar_wajar'] ?? null) }}">
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
</div>
|
||||||
<label for="total_nilai_pasar_wajar" class="form-label uppercase">TOTAL NILAI
|
|
||||||
LIKUIDASI</label>
|
<div class="tambah mb-10" id="tambah-npw" style="margin-bottom: 20px;">
|
||||||
<div class="card-body grid gap-2.5 w-full">
|
<button type="button" class="btn btn-primary">
|
||||||
<div class="flex grid-col-3 gap-2.5 w-full">
|
<i class="ki-filled ki-plus"></i>
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
Tambah NPW </button>
|
||||||
<input type="text" id="likuidasi" name="likuidasi"
|
</div>
|
||||||
class="input w-full currency-format"
|
|
||||||
value="{{ old('likuidasi', $lpjData['likuidasi'] ?? null) }}"
|
<div>
|
||||||
|
<label for="total_nilai_pasar_wajar" class="form-label uppercase">TOTAL NILAI
|
||||||
|
LIKUIDASI</label>
|
||||||
|
<div class="card-body grid gap-2.5 w-full">
|
||||||
|
<div class="flex grid-col-3 gap-2.5 w-full">
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<input type="text" id="likuidasi" name="likuidasi"
|
||||||
|
class="input w-full currency-format"
|
||||||
|
value="{{ old('likuidasi', $lpjData['likuidasi'] ?? null) }}"
|
||||||
|
oninput="calculateTotal()">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<label for="province" class="">X</label>
|
||||||
|
<label class="input">
|
||||||
|
<i class="">Rp
|
||||||
|
</i>
|
||||||
|
<input type="text" class=" w-full currency-format" id="likuidasi_nilai_1"
|
||||||
|
name="likuidasi_nilai_1"
|
||||||
|
value="{{ old('likuidasi_nilai_1', $lpjData['likuidasi_nilai_1'] ?? null) }}"
|
||||||
oninput="calculateTotal()">
|
oninput="calculateTotal()">
|
||||||
</div>
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="grid gap-2.5 w-full">
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
<label for="province" class="">X</label>
|
|
||||||
<label class="input">
|
<label class="input">
|
||||||
<i class="">Rp
|
<i class="">Rp
|
||||||
</i>
|
</i>
|
||||||
<input type="text" class=" w-full currency-format" id="likuidasi_nilai_1"
|
<input type="text" class=" w-full currency-format" name="likuidasi_nilai_2"
|
||||||
name="likuidasi_nilai_1"
|
value="{{ old('likuidasi_nilai_2', $lpjData['likuidasi_nilai_2'] ?? null) }}">
|
||||||
value="{{ old('likuidasi_nilai_1', $lpjData['likuidasi_nilai_1'] ?? null) }}"
|
|
||||||
oninput="calculateTotal()">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="grid gap-2.5 w-full">
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
|
|
||||||
<label class="input">
|
|
||||||
<i class="">Rp
|
|
||||||
</i>
|
|
||||||
<input type="text" class=" w-full currency-format"
|
|
||||||
name="likuidasi_nilai_2"
|
|
||||||
value="{{ old('likuidasi_nilai_2', $lpjData['likuidasi_nilai_2'] ?? null) }}">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-agi-50">
|
<div class="card-header bg-agi-50">
|
||||||
<h3 class="card-title uppercase">
|
<h3 class="card-title uppercase">
|
||||||
nilai asuransi
|
nilai asuransi
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div>
|
<div>
|
||||||
<label for="total_nilai_pasar_wajar" class="form-label uppercase">TOTAL NILAI ASURANSI</label>
|
<label for="total_nilai_pasar_wajar" class="form-label uppercase">TOTAL NILAI ASURANSI</label>
|
||||||
<div class="card-body grid gap-2.5 w-full">
|
<div class="card-body grid gap-2.5 w-full">
|
||||||
<div class="flex grid-col-3 gap-2.5 w-full">
|
<div class="flex grid-col-3 gap-2.5 w-full">
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
<label for="province" class="form-label">Luas Bangunan</label>
|
<label for="province" class="form-label">Luas Bangunan</label>
|
||||||
<input type="text" class="input w-full currency-format"
|
<input type="text" class="input w-full currency-format" id="asuransi_luas_bangunan"
|
||||||
id="asuransi_luas_bangunan" name="asuransi_luas_bangunan"
|
name="asuransi_luas_bangunan"
|
||||||
value="{{ old('asuransi_luas_bangunan', $lpjData['asuransi_luas_bangunan'] ?? null) }}"
|
value="{{ old('asuransi_luas_bangunan', $lpjData['asuransi_luas_bangunan'] ?? null) }}"
|
||||||
oninput="calculateTotal()">
|
oninput="calculateTotal()">
|
||||||
</div>
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label for="province" class="">X</label>
|
|
||||||
<label class="input">
|
|
||||||
<i class="">Rp
|
|
||||||
</i>
|
|
||||||
<input type="text" class="input w-full currency-format" id="asuransi_nilai_1"
|
|
||||||
name="asuransi_nilai_1"
|
|
||||||
value="{{ old('asuransi_nilai_1', $lpjData['asuransi_nilai_1'] ?? null) }}"
|
|
||||||
oninput="calculateTotal()">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
|
||||||
<label class="input">
|
|
||||||
<i class="">Rp
|
|
||||||
</i>
|
|
||||||
<input type="text" class="input w-full currency-format"
|
|
||||||
name="asuransi_nilai_2"
|
|
||||||
value="{{ old('asuransi_nilai_2', $lpjData['asuransi_nilai_2'] ?? null) }}">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<label for="province" class="">X</label>
|
||||||
|
<label class="input">
|
||||||
|
<i class="">Rp
|
||||||
|
</i>
|
||||||
|
<input type="text" class="input w-full currency-format" id="asuransi_nilai_1"
|
||||||
|
name="asuransi_nilai_1"
|
||||||
|
value="{{ old('asuransi_nilai_1', $lpjData['asuransi_nilai_1'] ?? null) }}"
|
||||||
|
oninput="calculateTotal()">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<label class="input">
|
||||||
|
<i class="">Rp
|
||||||
|
</i>
|
||||||
|
<input type="text" class="input w-full currency-format" name="asuransi_nilai_2"
|
||||||
|
value="{{ old('asuransi_nilai_2', $lpjData['asuransi_nilai_2'] ?? null) }}">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const tambahNPWButton = document.getElementById('tambah-npw');
|
||||||
|
const addPasarWajarContainer = document.getElementById('add_pasar_wajar');
|
||||||
|
let npwCounter = 0;
|
||||||
|
|
||||||
|
tambahNPWButton.addEventListener('click', function() {
|
||||||
|
npwCounter++;
|
||||||
|
|
||||||
|
const newNPWRow = document.createElement('div');
|
||||||
|
newNPWRow.className = 'flex grid-col-3 gap-2.5 w-full npw-row';
|
||||||
|
newNPWRow.innerHTML = `
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<input type="text"
|
||||||
|
id="name_npw_${npwCounter}"
|
||||||
|
class="input w-full"
|
||||||
|
name="name_npw_${npwCounter}"
|
||||||
|
placeholder="Nama NPW">
|
||||||
|
|
||||||
|
<input type="text"
|
||||||
|
id="luas_npw_${npwCounter}"
|
||||||
|
class="input w-full currency-format"
|
||||||
|
name="luas_npw_${npwCounter}"
|
||||||
|
placeholder="Luas NPW"
|
||||||
|
oninput="calculateTotal()">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<input type="text"
|
||||||
|
id="nilai_npw_${npwCounter}_1"
|
||||||
|
class="input w-full currency-format"
|
||||||
|
name="nilai_npw_${npwCounter}_1"
|
||||||
|
placeholder="Harga per meter"
|
||||||
|
oninput="calculateTotal()">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<input type="text"
|
||||||
|
id="nilai_npw_${npwCounter}_2"
|
||||||
|
class="input w-full currency-format"
|
||||||
|
name="nilai_npw_${npwCounter}_2"
|
||||||
|
placeholder="Total Nilai"
|
||||||
|
readonly>
|
||||||
|
<button type="button" class="btn btn-danger remove-npw">
|
||||||
|
<i class="ki-filled ki-minus"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Tambahkan event listener untuk remove button
|
||||||
|
newNPWRow.querySelector('.remove-npw').addEventListener('click', function() {
|
||||||
|
newNPWRow.remove();
|
||||||
|
calculateTotal();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tambahkan event listener untuk currency format
|
||||||
|
newNPWRow.querySelectorAll('.currency-format').forEach(input => {
|
||||||
|
input.addEventListener('input', function() {
|
||||||
|
formatCurrency(this);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
addPasarWajarContainer.appendChild(newNPWRow);
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadSavedNPW() {
|
||||||
|
// Cek apakah ada data LPJ yang sudah tersimpan
|
||||||
|
const lpjDataElement = document.getElementById('lpj-data');
|
||||||
|
if (lpjDataElement) {
|
||||||
|
const lpjData = JSON.parse(lpjDataElement.value);
|
||||||
|
|
||||||
|
// Periksa apakah ada NPW tambahan
|
||||||
|
if (lpjData.npw_tambahan && lpjData.npw_tambahan.length > 0) {
|
||||||
|
lpjData.npw_tambahan.forEach((npw, index) => {
|
||||||
|
// Increment counter
|
||||||
|
npwCounter++;
|
||||||
|
|
||||||
|
// Buat row baru
|
||||||
|
const newNPWRow = document.createElement('div');
|
||||||
|
newNPWRow.className = 'flex grid-col-3 gap-2.5 w-full npw-row mb-3';
|
||||||
|
newNPWRow.innerHTML = `
|
||||||
|
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<input type="text"
|
||||||
|
id="name_npw_${npwCounter}"
|
||||||
|
class="input w-full"
|
||||||
|
name="name_npw_${npwCounter}"
|
||||||
|
placeholder="Nama NPW"
|
||||||
|
value="${npw.name || ''}">
|
||||||
|
<input type="text"
|
||||||
|
id="luas_npw_${npwCounter}"
|
||||||
|
class="input w-full currency-format"
|
||||||
|
name="luas_npw_${npwCounter}"
|
||||||
|
placeholder="Luas NPW"
|
||||||
|
value="${npw.luas || ''}"
|
||||||
|
oninput="calculateTotal()">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<input type="text"
|
||||||
|
id="nilai_npw_${npwCounter}_1"
|
||||||
|
class="input w-full currency-format"
|
||||||
|
name="nilai_npw_${npwCounter}_1"
|
||||||
|
placeholder="Harga per meter"
|
||||||
|
value="${npw.nilai_1 || ''}"
|
||||||
|
oninput="calculateTotal()">
|
||||||
|
</div>
|
||||||
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
|
||||||
|
<input type="text"
|
||||||
|
id="nilai_npw_${npwCounter}_2"
|
||||||
|
class="input w-full currency-format"
|
||||||
|
name="nilai_npw_${npwCounter}_2"
|
||||||
|
placeholder="Total Nilai"
|
||||||
|
value="${npw.nilai_2 || ''}"
|
||||||
|
readonly>
|
||||||
|
<div>
|
||||||
|
<button type="button" class="btn btn-danger remove-npw h-full">
|
||||||
|
<i class="ki-filled ki-minus"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Tambahkan event listener untuk remove button
|
||||||
|
newNPWRow.querySelector('.remove-npw').addEventListener('click', function() {
|
||||||
|
newNPWRow.remove();
|
||||||
|
calculateTotal();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tambahkan event listener untuk currency format
|
||||||
|
newNPWRow.querySelectorAll('.currency-format').forEach(input => {
|
||||||
|
input.addEventListener('input', function() {
|
||||||
|
formatCurrency(this);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tambahkan row baru di bagian bawah
|
||||||
|
addPasarWajarContainer.appendChild(newNPWRow);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Hitung total setelah memuat data
|
||||||
|
calculateTotal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panggil fungsi load NPW saat halaman dimuat
|
||||||
|
loadSavedNPW();
|
||||||
|
});
|
||||||
|
|
||||||
|
function calculateTotal() {
|
||||||
|
const parseInput = (value) => parseFloat(value.replace(/[^0-9]/g, '')) || 0;
|
||||||
|
|
||||||
|
// Bagian Likuidasi
|
||||||
|
let persentaseLikuidasi = parseInput(document.getElementById('likuidasi').value);
|
||||||
|
let totalNilaiPasarLikuidasi = document.querySelector('input[name="likuidasi_nilai_1"]');
|
||||||
|
let totalLikuidasi = document.querySelector('input[name="likuidasi_nilai_2"]');
|
||||||
|
|
||||||
|
// Bagian Asuransi
|
||||||
|
let luasBangunanAsuransi = parseInput(document.getElementById('asuransi_luas_bangunan').value);
|
||||||
|
let hargaPerMeterAsuransi = parseInput(document.querySelector('input[name="asuransi_nilai_1"]').value);
|
||||||
|
let totalNilaiAsuransi = document.querySelector('input[name="asuransi_nilai_2"]');
|
||||||
|
|
||||||
|
// Perhitungan Asuransi
|
||||||
|
const hasilAsuransi = luasBangunanAsuransi * hargaPerMeterAsuransi;
|
||||||
|
|
||||||
|
let totalNilaiPasarWajar = 0;
|
||||||
|
|
||||||
|
// Perhitungan untuk input yang sudah ada
|
||||||
|
const standardInputs = [{
|
||||||
|
luas: 'luas_tanah',
|
||||||
|
nilai: 'nilai_tanah_1',
|
||||||
|
output: 'nilai_tanah_2'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
luas: 'luas_bangunan',
|
||||||
|
nilai: 'nilai_bangunan_1',
|
||||||
|
output: 'nilai_bangunan_2'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
standardInputs.forEach(input => {
|
||||||
|
let luas = parseInput(document.getElementById(input.luas).value);
|
||||||
|
let hargaPerMeter = parseInput(document.querySelector(`input[name="${input.nilai}"]`).value);
|
||||||
|
let totalNilai = luas * hargaPerMeter;
|
||||||
|
|
||||||
|
document.querySelector(`input[name="${input.output}"]`).value = formatCurrency(totalNilai
|
||||||
|
.toString());
|
||||||
|
totalNilaiPasarWajar += totalNilai;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tambahkan perhitungan untuk NPW tambahan
|
||||||
|
const npwRows = document.querySelectorAll('.npw-row');
|
||||||
|
npwRows.forEach(row => {
|
||||||
|
let luasNPW = parseInput(row.querySelector('input[id^="luas_npw_"]').value);
|
||||||
|
let nilaiNPW = parseInput(row.querySelector('input[id^="nilai_npw_"][id$="_1"]').value);
|
||||||
|
let totalNilaiNPW = luasNPW * nilaiNPW;
|
||||||
|
|
||||||
|
row.querySelector('input[id^="nilai_npw_"][id$="_2"]').value = formatCurrency(totalNilaiNPW
|
||||||
|
.toString());
|
||||||
|
totalNilaiPasarWajar += totalNilaiNPW;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update total nilai pasar wajar
|
||||||
|
document.getElementById('total_nilai_pasar_wajar').value = formatCurrency(totalNilaiPasarWajar.toString());
|
||||||
|
|
||||||
|
// Perhitungan Likuidasi
|
||||||
|
const hasilLikuidasi = (persentaseLikuidasi / 100) * totalNilaiPasarWajar;
|
||||||
|
|
||||||
|
// Tampilkan nilai likuidasi dan asuransi
|
||||||
|
totalNilaiPasarLikuidasi.value = formatCurrency(totalNilaiPasarWajar.toString());
|
||||||
|
totalNilaiAsuransi.value = formatCurrency(hasilAsuransi.toString());
|
||||||
|
|
||||||
|
// Total likuidasi (total nilai pasar wajar + nilai likuidasi)
|
||||||
|
// const totalPasarWajarDenganLikuidasi = totalNilaiPasarWajar + hasilLikuidasi;
|
||||||
|
totalLikuidasi.value = formatCurrency(hasilLikuidasi.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function saveLpjSederhanadanStandard() {
|
||||||
|
const form = document.getElementById('form-lpj');
|
||||||
|
const formData = new FormData(form);
|
||||||
|
showLoadingSwal('Mengirim data ke server...');
|
||||||
|
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const permohonanId = {{ $permohonan->id }};
|
||||||
|
const documentId = urlParams.get('documentId');
|
||||||
|
const inspeksiId = urlParams.get('inspeksiId');
|
||||||
|
|
||||||
|
const requestUrl =
|
||||||
|
`{{ route('penilai.storeLpjSederhanadanStandard') }}?permohonanId=${permohonanId}&inspeksiId=${inspeksiId}&documentId=${documentId}`;
|
||||||
|
$.ajax({
|
||||||
|
url: requestUrl,
|
||||||
|
type: 'POST',
|
||||||
|
data: formData,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
hideLoadingSwal();
|
||||||
|
if (response.success) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Berhasil!',
|
||||||
|
text: response.message,
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
}).then((response) => {
|
||||||
|
if (response.isConfirmed) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Error!',
|
||||||
|
text: response.message || 'Terjadi kesalahan',
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'OK'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.log(response);
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
let errors = xhr.responseJSON?.errors;
|
||||||
|
$('.alert').text('');
|
||||||
|
if (errors) {
|
||||||
|
$.each(errors, function(key, value) {
|
||||||
|
$(`#error-${key}`).text(value[0]);
|
||||||
|
toastrErrorBuild(value[0]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
hideLoadingSwal();
|
||||||
|
console.log(errors);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
@section('breadcrumbs')
|
@section('breadcrumbs')
|
||||||
{{-- {{ Breadcrumbs::render(request()->route()->getName()) }}
|
{{-- {{ Breadcrumbs::render(request()->route()->getName()) }}
|
||||||
--}}
|
--}}
|
||||||
Standard
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
@@ -11,6 +10,7 @@
|
|||||||
<form id="form-lpj" method="post" class="w-full grid gap-5">
|
<form id="form-lpj" method="post" class="w-full grid gap-5">
|
||||||
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
||||||
<input type="hidden" name="dokument_id" value="{{ request('documentId') }}">
|
<input type="hidden" name="dokument_id" value="{{ request('documentId') }}">
|
||||||
|
<input type="hidden" id="lpj-data" value="{{ json_encode($lpjData ?? []) }}" />
|
||||||
@include('lpj::component.form-penilai')
|
@include('lpj::component.form-penilai')
|
||||||
<div class="flex card-footer justify-end gap-5">
|
<div class="flex card-footer justify-end gap-5">
|
||||||
<button type="button" class="btn btn-success" id="saveButton" onclick="saveLpjSederhanadanStandard()">
|
<button type="button" class="btn btn-success" id="saveButton" onclick="saveLpjSederhanadanStandard()">
|
||||||
@@ -20,137 +20,4 @@
|
|||||||
</form>
|
</form>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
document.querySelectorAll('.currency-format').forEach(input => {
|
|
||||||
input.addEventListener('input', function() {
|
|
||||||
formatCurrency(this);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelectorAll('.number-format').forEach(input => {
|
|
||||||
input.addEventListener('input', function() {
|
|
||||||
formatNumber(this);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function calculateTotal() {
|
|
||||||
// Fungsi untuk menghapus format ribuan/koma
|
|
||||||
const parseInput = (value) => parseFloat(value.replace(/[^0-9]/g, '')) || 0;
|
|
||||||
|
|
||||||
// Ambil elemen input dan parse nilainya
|
|
||||||
let luasTanah = parseInput(document.getElementById('luas_tanah').value);
|
|
||||||
let hargaPerMeterTanah = parseInput(document.querySelector('input[name="nilai_tanah_1"]').value);
|
|
||||||
let totalLuasTanah = document.querySelector('input[name="nilai_tanah_2"]');
|
|
||||||
|
|
||||||
let luasBangunan = parseInput(document.getElementById('luas_bangunan').value);
|
|
||||||
let hargaPerMeterBangunan = parseInput(document.querySelector('input[name="nilai_bangunan_1"]').value);
|
|
||||||
let totalLuasBangunan = document.querySelector('input[name="nilai_bangunan_2"]');
|
|
||||||
|
|
||||||
let saranaPelengkap = parseInput(document.getElementById('sarana_pelengkap_penilai').value);
|
|
||||||
let hargaPerMeterSarana = parseInput(document.querySelector('input[name="nilai_sarana_pelengkap_1"]').value);
|
|
||||||
let totalLuasSarana = document.querySelector('input[name="nilai_sarana_pelengkap_2"]');
|
|
||||||
|
|
||||||
// Bagian Likuidasi
|
|
||||||
let persentaseLikuidasi = parseInput(document.getElementById('likuidasi').value);
|
|
||||||
let totalNilaiPasarLikuidasi = document.querySelector('input[name="likuidasi_nilai_1"]');
|
|
||||||
let totalLikuidasi = document.querySelector('input[name="likuidasi_nilai_2"]');
|
|
||||||
|
|
||||||
// Bagian Asuransi
|
|
||||||
let luasBangunanAsuransi = parseInput(document.getElementById('asuransi_luas_bangunan').value);
|
|
||||||
let hargaPerMeterAsuransi = parseInput(document.querySelector('input[name="asuransi_nilai_1"]').value);
|
|
||||||
let totalNilaiAsuransi = document.querySelector('input[name="asuransi_nilai_2"]');
|
|
||||||
|
|
||||||
let total = document.querySelector('input[name="total_nilai_pasar_wajar"]');
|
|
||||||
|
|
||||||
// Hitung hasil
|
|
||||||
const hasilTanah = luasTanah * hargaPerMeterTanah;
|
|
||||||
const hasilBangunan = luasBangunan * hargaPerMeterBangunan;
|
|
||||||
const hasilSarana = saranaPelengkap * hargaPerMeterSarana;
|
|
||||||
|
|
||||||
const totalNilaiPasarWajar = hasilTanah + hasilBangunan + hasilSarana;
|
|
||||||
|
|
||||||
// Perhitungan Likuidasi
|
|
||||||
const hasilLikuidasi = (persentaseLikuidasi / 100) * totalNilaiPasarWajar;
|
|
||||||
|
|
||||||
// Perhitungan Asuransi
|
|
||||||
const hasilAsuransi = luasBangunanAsuransi * hargaPerMeterAsuransi;
|
|
||||||
|
|
||||||
// Tampilkan hasil dalam format currency
|
|
||||||
totalLuasTanah.value = formatCurrency(hasilTanah.toString());
|
|
||||||
totalLuasBangunan.value = formatCurrency(hasilBangunan.toString());
|
|
||||||
totalLuasSarana.value = formatCurrency(hasilSarana.toString());
|
|
||||||
total.value = formatCurrency(totalNilaiPasarWajar.toString());
|
|
||||||
|
|
||||||
// Tampilkan nilai likuidasi dan asuransi
|
|
||||||
totalNilaiPasarLikuidasi.value = formatCurrency(totalNilaiPasarWajar.toString());
|
|
||||||
totalNilaiAsuransi.value = formatCurrency(hasilAsuransi.toString());
|
|
||||||
|
|
||||||
// Total likuidasi (total nilai pasar wajar + nilai likuidasi)
|
|
||||||
// const totalPasarWajarDenganLikuidasi = totalNilaiPasarWajar + hasilLikuidasi;
|
|
||||||
totalLikuidasi.value = formatCurrency(hasilLikuidasi.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function saveLpjSederhanadanStandard() {
|
|
||||||
const form = document.getElementById('form-lpj');
|
|
||||||
const formData = new FormData(form);
|
|
||||||
showLoadingSwal('Mengirim data ke server...');
|
|
||||||
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const permohonanId = {{ $permohonan->id }};
|
|
||||||
const documentId = urlParams.get('documentId');
|
|
||||||
const inspeksiId = urlParams.get('inspeksiId');
|
|
||||||
|
|
||||||
const requestUrl = `{{ route('penilai.storeLpjSederhanadanStandard') }}?permohonanId=${permohonanId}&inspeksiId=${inspeksiId}&documentId=${documentId}`;
|
|
||||||
$.ajax({
|
|
||||||
url: requestUrl,
|
|
||||||
type: 'POST',
|
|
||||||
data: formData,
|
|
||||||
processData: false,
|
|
||||||
contentType: false,
|
|
||||||
headers: {
|
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
hideLoadingSwal();
|
|
||||||
if (response.success) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Berhasil!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'success',
|
|
||||||
confirmButtonText: 'OK'
|
|
||||||
}).then((response) => {
|
|
||||||
if (response.isConfirmed) {
|
|
||||||
window.location.href =
|
|
||||||
'{{ route('penilai.show', ['id' => $permohonan->id]) }}';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message || 'Terjadi kesalahan',
|
|
||||||
icon: 'error',
|
|
||||||
confirmButtonText: 'OK'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
console.log(response);
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
let errors = xhr.responseJSON?.errors;
|
|
||||||
$('.alert').text('');
|
|
||||||
if (errors) {
|
|
||||||
$.each(errors, function(key, value) {
|
|
||||||
$(`#error-${key}`).text(value[0]);
|
|
||||||
toastrErrorBuild(value[0]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
hideLoadingSwal();
|
|
||||||
console.log(errors);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@include('lpj::surveyor.js.utils')
|
@include('lpj::surveyor.js.utils')
|
||||||
|
|||||||
@@ -18,14 +18,14 @@
|
|||||||
<form id="form-lpj" method="post" class="w-full grid gap-5">
|
<form id="form-lpj" method="post" class="w-full grid gap-5">
|
||||||
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
||||||
<input type="hidden" name="dokument_id" value="{{ request('documentId') }}">
|
<input type="hidden" name="dokument_id" value="{{ request('documentId') }}">
|
||||||
|
<input type="hidden" id="lpj-data" value="{{ json_encode($lpjData ?? []) }}" />
|
||||||
@include('lpj::component.form-penilai', ['title' => 'Laporan'])
|
@include('lpj::component.form-penilai', ['title' => 'Laporan'])
|
||||||
<div class="flex card-footer justify-end gap-5">
|
<div class="flex card-footer justify-end gap-5">
|
||||||
<button type="button" class="btn btn-success" id="saveButton" onclick="saveLaporan()">
|
<button type="button" class="btn btn-success" id="saveButton" onclick="saveLpjSederhanadanStandard()">
|
||||||
<span id="saveButtonText">Save</span>
|
<span id="saveButtonText">Save</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button type="button" class="btn btn-warning" id="saveButton" onclick="saveLpjSederhanadanStandar()">
|
<button type="button" class="btn btn-warning" id="saveButton" onclick="saveLpjSederhanad()">
|
||||||
<span id="saveButtonText">Revisi</span>
|
<span id="saveButtonText">Revisi</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -38,140 +38,4 @@
|
|||||||
</form>
|
</form>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
const datas = @json($lpjData);
|
|
||||||
console.log(datas);
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
document.querySelectorAll('.currency-format').forEach(input => {
|
|
||||||
input.addEventListener('input', function() {
|
|
||||||
formatCurrency(this);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelectorAll('.number-format').forEach(input => {
|
|
||||||
input.addEventListener('input', function() {
|
|
||||||
formatNumber(this);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function calculateTotal() {
|
|
||||||
// Fungsi untuk menghapus format ribuan/koma
|
|
||||||
const parseInput = (value) => parseFloat(value.replace(/[^0-9]/g, '')) || 0;
|
|
||||||
|
|
||||||
// Ambil elemen input dan parse nilainya
|
|
||||||
let luasTanah = parseInput(document.getElementById('luas_tanah_penilai').value);
|
|
||||||
let hargaPerMeterTanah = parseInput(document.querySelector('input[name="nilai_tanah_1"]').value);
|
|
||||||
let totalLuasTanah = document.querySelector('input[name="nilai_tanah_2"]');
|
|
||||||
|
|
||||||
let luasBangunan = parseInput(document.getElementById('luas_bangunan_penilai').value);
|
|
||||||
let hargaPerMeterBangunan = parseInput(document.querySelector('input[name="nilai_bangunan_1"]').value);
|
|
||||||
let totalLuasBangunan = document.querySelector('input[name="nilai_bangunan_2"]');
|
|
||||||
|
|
||||||
let saranaPelengkap = parseInput(document.getElementById('sarana_pelengkap_penilai').value);
|
|
||||||
let hargaPerMeterSarana = parseInput(document.querySelector('input[name="nilai_sarana_pelengkap_1"]').value);
|
|
||||||
let totalLuasSarana = document.querySelector('input[name="nilai_sarana_pelengkap_2"]');
|
|
||||||
|
|
||||||
// Bagian Likuidasi
|
|
||||||
let persentaseLikuidasi = parseInput(document.getElementById('likuidasi').value);
|
|
||||||
let totalNilaiPasarLikuidasi = document.querySelector('input[name="likuidasi_nilai_1"]');
|
|
||||||
let totalLikuidasi = document.querySelector('input[name="likuidasi_nilai_2"]');
|
|
||||||
|
|
||||||
// Bagian Asuransi
|
|
||||||
let luasBangunanAsuransi = parseInput(document.getElementById('asuransi_luas_bangunan').value);
|
|
||||||
let hargaPerMeterAsuransi = parseInput(document.querySelector('input[name="asuransi_nilai_1"]').value);
|
|
||||||
let totalNilaiAsuransi = document.querySelector('input[name="asuransi_nilai_2"]');
|
|
||||||
|
|
||||||
let total = document.querySelector('input[name="total_nilai_pasar_wajar"]');
|
|
||||||
|
|
||||||
// Hitung hasil
|
|
||||||
const hasilTanah = luasTanah * hargaPerMeterTanah;
|
|
||||||
const hasilBangunan = luasBangunan * hargaPerMeterBangunan;
|
|
||||||
const hasilSarana = saranaPelengkap * hargaPerMeterSarana;
|
|
||||||
|
|
||||||
const totalNilaiPasarWajar = hasilTanah + hasilBangunan + hasilSarana;
|
|
||||||
|
|
||||||
// Perhitungan Likuidasi
|
|
||||||
const hasilLikuidasi = (persentaseLikuidasi / 100) * totalNilaiPasarWajar;
|
|
||||||
|
|
||||||
// Perhitungan Asuransi
|
|
||||||
const hasilAsuransi = luasBangunanAsuransi * hargaPerMeterAsuransi;
|
|
||||||
|
|
||||||
// Tampilkan hasil dalam format currency
|
|
||||||
totalLuasTanah.value = formatCurrency(hasilTanah.toString());
|
|
||||||
totalLuasBangunan.value = formatCurrency(hasilBangunan.toString());
|
|
||||||
totalLuasSarana.value = formatCurrency(hasilSarana.toString());
|
|
||||||
total.value = formatCurrency(totalNilaiPasarWajar.toString());
|
|
||||||
|
|
||||||
// Tampilkan nilai likuidasi dan asuransi
|
|
||||||
totalNilaiPasarLikuidasi.value = formatCurrency(totalNilaiPasarWajar.toString());
|
|
||||||
totalNilaiAsuransi.value = formatCurrency(hasilAsuransi.toString());
|
|
||||||
|
|
||||||
// Total likuidasi (total nilai pasar wajar + nilai likuidasi)
|
|
||||||
// const totalPasarWajarDenganLikuidasi = totalNilaiPasarWajar + hasilLikuidasi;
|
|
||||||
totalLikuidasi.value = formatCurrency(hasilLikuidasi.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function saveLaporan() {
|
|
||||||
const form = document.getElementById('form-lpj');
|
|
||||||
const formData = new FormData(form);
|
|
||||||
showLoadingSwal('Mengirim data ke server...');
|
|
||||||
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
const permohonanId = {{ $permohonan->id }};
|
|
||||||
const documentId = urlParams.get('documentId');
|
|
||||||
const inspeksiId = urlParams.get('inspeksiId');
|
|
||||||
|
|
||||||
const requestUrl = `{{ route('penilaian.storePenilaiLaporan') }}?permohonanId=${permohonanId}&inspeksiId=${inspeksiId}&documentId=${documentId}`;
|
|
||||||
$.ajax({
|
|
||||||
url: requestUrl,
|
|
||||||
type: 'POST',
|
|
||||||
data: formData,
|
|
||||||
processData: false,
|
|
||||||
contentType: false,
|
|
||||||
headers: {
|
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
hideLoadingSwal();
|
|
||||||
if (response.success) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Berhasil!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'success',
|
|
||||||
confirmButtonText: 'OK'
|
|
||||||
}).then((response) => {
|
|
||||||
if (response.isConfirmed) {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message || 'Terjadi kesalahan',
|
|
||||||
icon: 'error',
|
|
||||||
confirmButtonText: 'OK'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
console.log(response);
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
let errors = xhr.responseJSON?.errors;
|
|
||||||
$('.alert').text('');
|
|
||||||
if (errors) {
|
|
||||||
$.each(errors, function(key, value) {
|
|
||||||
$(`#error-${key}`).text(value[0]);
|
|
||||||
toastrErrorBuild(value[0]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
hideLoadingSwal();
|
|
||||||
console.log(errors);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@include('lpj::surveyor.js.utils')
|
@include('lpj::surveyor.js.utils')
|
||||||
|
|||||||
Reference in New Issue
Block a user