fix(penilai):perbaikan save penilai untuk so
This commit is contained in:
@@ -3263,17 +3263,28 @@ class SurveyorController extends Controller
|
|||||||
?string $extraField = null
|
?string $extraField = null
|
||||||
): array {
|
): array {
|
||||||
if ($checkKesesuaian) {
|
if ($checkKesesuaian) {
|
||||||
return [
|
// Mengecek apakah status kesesuaian adalah 'sesuai'
|
||||||
$data[$fieldName] ?? '' => ($data[$fieldName] ?? '') === 'sesuai'
|
$isSesuai = ($data[$fieldName] ?? '') === 'sesuai';
|
||||||
? ($data["{$fieldName}_sesuai"] ?? '')
|
|
||||||
: ($data["{$fieldName}_tidak_sesuai"] ?? '')
|
// Menggunakan key berdasarkan status kesesuaian
|
||||||
|
$result = [
|
||||||
|
$isSesuai ? 'sesuai' : 'tidak_sesuai' => $data[$fieldName] ?? null
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Tambahkan field ekstra jika ada
|
||||||
|
if ($extraField) {
|
||||||
|
$result[$extraField] = $data["{$fieldName}_{$extraField}"] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jika tidak melakukan pengecekan kesesuaian, hanya ambil data berdasarkan fieldName
|
||||||
$result = [
|
$result = [
|
||||||
$fieldName => $data[$fieldName] ?? null
|
$fieldName => $data[$fieldName] ?? null,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Jika ada extra field, tambahkan ke result
|
||||||
if ($extraField) {
|
if ($extraField) {
|
||||||
$result[$extraField] = $data["{$fieldName}_{$extraField}"] ?? null;
|
$result[$extraField] = $data["{$fieldName}_{$extraField}"] ?? null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,27 +9,38 @@
|
|||||||
.dropdown {
|
.dropdown {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
.dropdowns-content {
|
|
||||||
|
.dropdowns-content {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
min-width: 224px;
|
min-width: 224px;
|
||||||
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
margin-top: 0; /* Hilangkan jarak antara tombol dan dropdown */
|
||||||
.dropdown:hover .dropdowns-content {
|
}
|
||||||
|
|
||||||
|
.dropdown:hover .dropdowns-content {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.dropdowns-content a {
|
|
||||||
|
/* Tambahkan hover untuk elemen dropdown agar tidak hilang */
|
||||||
|
.dropdowns-content:hover {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdowns-content a {
|
||||||
color: black;
|
color: black;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.dropdowns-content a:hover {
|
|
||||||
|
.dropdowns-content a:hover {
|
||||||
background-color: #f1f1f1;
|
background-color: #f1f1f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@endpush
|
@endpush
|
||||||
@@ -258,6 +269,7 @@
|
|||||||
<i class="ki-outline ki-eye"></i>
|
<i class="ki-outline ki-eye"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>`,
|
</div>`,
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -343,13 +343,19 @@
|
|||||||
<h3 class="card-title">
|
<h3 class="card-title">
|
||||||
{{ $title ?? 'Data Jaminan' }}
|
{{ $title ?? 'Data Jaminan' }}
|
||||||
</h3>
|
</h3>
|
||||||
|
@php
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
@endphp
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
@if (isset($id))
|
@if (Auth::user()->hasAnyRole(['administrator', 'senior-officer', 'EO Appraisal', 'DD Appraisal']) &&
|
||||||
<a href="{{ route($backLink, ['id' => $id]) }}" class="btn btn-xs btn-info">
|
Route::currentRouteName('otorisator.show'))
|
||||||
|
<a href="{{ route('otorisator.show', ['id' => $permohonan->id, 'type' => 'Pelaporan']) }}"
|
||||||
|
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
|
|
||||||
<a href="{{ url()->previous() }}" class="btn btn-xs btn-info">
|
@elseif (Auth::user()->hasAnyRole(['administrator','surveyor']) && Route::currentRouteName('penilai.show'))
|
||||||
|
<a href="{{ route('penilai.show', $permohonan->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>
|
||||||
@endif
|
@endif
|
||||||
@@ -616,8 +622,8 @@
|
|||||||
<label for="province" class="form-label max-w-56">
|
<label for="province" class="form-label max-w-56">
|
||||||
{{ $labelNilai[$item] }}
|
{{ $labelNilai[$item] }}
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="luas_{{ $item }}"
|
<input type="text" id="luas_{{ $item }}" class="input w-full"
|
||||||
class="input w-full" name="luas_{{ $item }}"
|
name="luas_{{ $item }}"
|
||||||
value="{{ old('luas_' . $item, $lpjData['luas_' . $item] ?? null) }}"
|
value="{{ old('luas_' . $item, $lpjData['luas_' . $item] ?? null) }}"
|
||||||
oninput="calculateTotal()">
|
oninput="calculateTotal()">
|
||||||
</div>
|
</div>
|
||||||
@@ -670,18 +676,24 @@
|
|||||||
Tambah NPW </button>
|
Tambah NPW </button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="total_nilai_pasar_wajar" class="form-label uppercase">TOTAL NILAI
|
<label for="total_nilai_pasar_wajar" class="form-label uppercase">TOTAL NILAI
|
||||||
LIKUIDASI</label>
|
LIKUIDASI</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">
|
||||||
|
<div class="w-full">
|
||||||
|
<label class="input">
|
||||||
|
|
||||||
<input type="text" id="likuidasi" name="likuidasi"
|
<input type="text" id="likuidasi" name="likuidasi"
|
||||||
class="input w-full currency-format"
|
class=" w-full currency"
|
||||||
value="{{ old('likuidasi', $lpjData['likuidasi'] ?? null) }}"
|
value="{{ old('likuidasi', $lpjData['likuidasi'] ?? null) }}"
|
||||||
oninput="calculateTotal()">
|
oninput="calculateTotal()">
|
||||||
|
<i class="">%
|
||||||
|
</i>
|
||||||
|
</label>
|
||||||
|
<span class="text-xs"> <span class="text-xs text-danger">*</span> Masukkan Angka Saja </span>
|
||||||
|
</div>
|
||||||
</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 for="province" class="">X</label>
|
<label for="province" class="">X</label>
|
||||||
@@ -795,6 +807,10 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
const datas = @json($forminspeksi);
|
||||||
|
console.log(datas);
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
|
|
||||||
@@ -971,11 +987,34 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function formatPercentage(value) {
|
||||||
|
// Hapus semua karakter kecuali angka dan koma
|
||||||
|
let numericValue = value.replace(/[^0-9,]/g, '');
|
||||||
|
|
||||||
|
// Pastikan hanya satu koma yang ada
|
||||||
|
let parts = numericValue.split(',');
|
||||||
|
if (parts.length > 2) {
|
||||||
|
numericValue = parts[0] + ',' + parts[1]; // Pertahankan hanya bagian pertama dan kedua
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jika nilai melebihi 100, batasi menjadi 100
|
||||||
|
let numericFloat = parseFloat(numericValue.replace(',', '.')) || 0;
|
||||||
|
if (numericFloat > 100) {
|
||||||
|
numericFloat = 100;
|
||||||
|
numericValue = '100';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kembalikan nilai dengan simbol %
|
||||||
|
return numericValue;
|
||||||
|
}
|
||||||
function calculateTotal() {
|
function calculateTotal() {
|
||||||
const parseInput = (value) => parseFloat(value.replace(/[^0-9]/g, '')) || 0;
|
const parseInput = (value) => parseFloat(value.replace(/[^0-9]/g, '')) || 0;
|
||||||
|
|
||||||
// Bagian Likuidasi
|
// Bagian Likuidasi
|
||||||
let persentaseLikuidasi = parseInput(document.getElementById('likuidasi').value);
|
let persentaseLikuidasiInput = document.getElementById('likuidasi');
|
||||||
|
let persentaseLikuidasi = parseInput(persentaseLikuidasiInput.value);
|
||||||
|
persentaseLikuidasiInput.value = formatPercentage(persentaseLikuidasiInput.value);
|
||||||
|
|
||||||
let totalNilaiPasarLikuidasi = document.querySelector('input[name="likuidasi_nilai_1"]');
|
let totalNilaiPasarLikuidasi = document.querySelector('input[name="likuidasi_nilai_1"]');
|
||||||
let totalLikuidasi = document.querySelector('input[name="likuidasi_nilai_2"]');
|
let totalLikuidasi = document.querySelector('input[name="likuidasi_nilai_2"]');
|
||||||
|
|
||||||
@@ -1085,7 +1124,7 @@
|
|||||||
confirmButtonText: 'OK'
|
confirmButtonText: 'OK'
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
if (response.isConfirmed) {
|
if (response.isConfirmed) {
|
||||||
// window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -1121,9 +1160,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format ke mata uang
|
// Format ke mata uang
|
||||||
const formattedValue = new Intl.NumberFormat('id-ID', { style: 'currency', currency: 'IDR' }).format(value);
|
const formattedValue = new Intl.NumberFormat('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR'
|
||||||
|
}).format(value);
|
||||||
|
|
||||||
input.value = formattedValue;
|
input.value = formattedValue;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -28,37 +28,39 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label class="form-label max-w-56">Harga Penawara</label>
|
<label class="form-label max-w-56">Harga Penawaran</label>
|
||||||
<div class="flex flex-wrap items-baseline w-full">
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
<span>{{ $item['harga_diskon'] }}</span>
|
<span>Rp. {{ $item['harga_diskon'] }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label class="form-label max-w-56">Penjualan (HP)</label>
|
<label class="form-label max-w-56">Penjualan (HP)</label>
|
||||||
<div class="flex flex-wrap items-baseline w-full">
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
<span>{{ $item['harga'] }}</span>
|
<span>Rp. {{ $item['harga'] }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label class="form-label max-w-56">Ditawarkan sejak</label>
|
<label class="form-label max-w-56">Ditawarkan sejak</label>
|
||||||
<div class="flex flex-wrap items-baseline w-full">
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
<span>{{ $item['harga'] }}</span>
|
<span>Rp. {{ $item['harga'] }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label class="form-label max-w-56">LT</label>
|
<label class="form-label max-w-56">LT</label>
|
||||||
<div class="flex flex-wrap items-baseline w-full">
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
<span>{{ $item['luas_tanah'] }}</span>
|
<span>{{ $item['luas_tanah'] }} </span>
|
||||||
|
<sup> m2</sup>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label class="form-label max-w-56">LB</label>
|
<label class="form-label max-w-56">LB</label>
|
||||||
<div class="flex flex-wrap items-baseline w-full">
|
<div class="flex flex-wrap items-baseline w-full">
|
||||||
<span>{{ $item['luas_bangunan'] }}</span>
|
<span>{{ $item['luas_bangunan'] }} </span>
|
||||||
|
<sup> m2</sup>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/signature_pad@4.1.7/dist/signature_pad.umd.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/signature_pad@4.1.7/dist/signature_pad.umd.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
const datas = @json($forminspeksi);
|
const datas = @json($forminspeksi ?? '');
|
||||||
console.log(datas);
|
console.log(datas);
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
@@ -304,125 +304,6 @@ const datas = @json($forminspeksi);
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function updateAlamatFields(status) {
|
|
||||||
// Ambil elemen formulir
|
|
||||||
const addressForm = document.getElementById('alamat_form');
|
|
||||||
const inputs = addressForm.querySelectorAll('input, select');
|
|
||||||
const addressInput = document.getElementById('address');
|
|
||||||
|
|
||||||
if (status === 'sesuai') {
|
|
||||||
addressInput.value = "{{ $dokumen->address ?? '' }}";
|
|
||||||
inputs.forEach(element => {
|
|
||||||
if (element.tagName === 'INPUT') {
|
|
||||||
element.setAttribute('readonly', true);
|
|
||||||
} else if (element.tagName === 'SELECT') {
|
|
||||||
element.setAttribute('disabled', true);
|
|
||||||
element.classList.add('disabled-input')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addressForm.style.display = 'grid';
|
|
||||||
addressForm.disabled = true;
|
|
||||||
addressForm.classList.add('disabled-input')
|
|
||||||
|
|
||||||
|
|
||||||
} else if (status === 'tidak sesuai') {
|
|
||||||
addressForm.style.display = 'grid';
|
|
||||||
|
|
||||||
addressForm.removeAttribute('disabled');
|
|
||||||
addressForm.classList.remove('disabled-input')
|
|
||||||
const formInspeksi = @json($forminspeksi);
|
|
||||||
const addressInput = document.getElementById('address');
|
|
||||||
|
|
||||||
if (formInspeksi && formInspeksi.asset && formInspeksi.asset.alamat) {
|
|
||||||
if (formInspeksi.asset.alamat['tidak sesuai'] && formInspeksi.asset.alamat['tidak sesuai'].address) {
|
|
||||||
addressInput.value = formInspeksi.asset.alamat['tidak sesuai'].address;
|
|
||||||
} else if (formInspeksi.asset.alamat['sesuai'] && formInspeksi.asset.alamat['sesuai'].address) {
|
|
||||||
addressInput.value = formInspeksi.asset.alamat['sesuai'].address;
|
|
||||||
} else {
|
|
||||||
addressInput.value = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inputs.forEach(element => {
|
|
||||||
if (element.tagName === 'INPUT') {
|
|
||||||
element.removeAttribute('readonly');
|
|
||||||
} else if (element.tagName === 'SELECT') {
|
|
||||||
element.removeAttribute('disabled');
|
|
||||||
element.classList.remove('disabled-input')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleFieldVisibility(fieldName, inputId, visibleValues = []) {
|
|
||||||
const selectedValue = $(`[name="${fieldName}"]:checked`).val();
|
|
||||||
const inputField = $(`#${inputId}`);
|
|
||||||
|
|
||||||
if (visibleValues.includes(selectedValue)) {
|
|
||||||
inputField.show();
|
|
||||||
} else {
|
|
||||||
inputField.hide().val('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function toggleCheckboxVisibility(fieldName, inputId, visibleValues = []) {
|
|
||||||
const selectedValues = $(`[name="${fieldName}[]"]:checked`)
|
|
||||||
.map(function() {
|
|
||||||
return $(this).val().toLowerCase(); // Konversi nilai ke huruf kecil
|
|
||||||
})
|
|
||||||
.get();
|
|
||||||
|
|
||||||
const inputField = $(`#${inputId}`);
|
|
||||||
|
|
||||||
// Cek apakah salah satu nilai yang dipilih cocok dengan visibleValues
|
|
||||||
const shouldShow = visibleValues.some(value => selectedValues.includes(value.toLowerCase()));
|
|
||||||
|
|
||||||
if (shouldShow) {
|
|
||||||
inputField.show();
|
|
||||||
} else {
|
|
||||||
inputField.hide().val('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function toggleMultipleFields(fieldName, mappings) {
|
|
||||||
// Ambil semua nilai checkbox yang dicentang
|
|
||||||
const selectedValues = $(`[name="${fieldName}[]"]:checked`)
|
|
||||||
.map(function() {
|
|
||||||
return $(this).val().toLowerCase(); // Konversi nilai ke huruf kecil
|
|
||||||
})
|
|
||||||
.get();
|
|
||||||
|
|
||||||
// Iterasi melalui setiap mapping
|
|
||||||
for (const [key, inputId] of Object.entries(mappings)) {
|
|
||||||
const inputField = $(`#${inputId}`);
|
|
||||||
|
|
||||||
// Tampilkan input jika nilai yang relevan dipilih
|
|
||||||
if (selectedValues.includes(key.toLowerCase())) {
|
|
||||||
inputField.show();
|
|
||||||
} else {
|
|
||||||
inputField.hide().val(''); // Sembunyikan dan reset nilai
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function toggleAlamatVisibility(idSesuai, idTidakSesuai, selectedValue) {
|
|
||||||
// Ambil elemen berdasarkan ID
|
|
||||||
const alamatSesuai = document.getElementById(idSesuai);
|
|
||||||
const alamatTidakSesuai = document.getElementById(idTidakSesuai);
|
|
||||||
|
|
||||||
// Periksa nilai yang dipilih dan tampilkan elemen yang sesuai
|
|
||||||
if (selectedValue === 'sesuai') {
|
|
||||||
alamatSesuai.style.display = 'grid'; // Tampilkan "Alamat Sesuai"
|
|
||||||
alamatTidakSesuai.style.display = 'none'; // Sembunyikan "Alamat Tidak Sesuai"
|
|
||||||
} else if (selectedValue === 'tidak sesuai') {
|
|
||||||
alamatSesuai.style.display = 'none'; // Sembunyikan "Alamat Sesuai"
|
|
||||||
alamatTidakSesuai.style.display = 'grid'; // Tampilkan "Alamat Tidak Sesuai"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -502,54 +383,7 @@ const datas = @json($forminspeksi);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function updateAnalisa(params) {
|
|
||||||
const inputMap = {
|
|
||||||
jenis_asset: 'jenis_asset_tidak_sesuai',
|
|
||||||
analisa_tanah: 'analisa_tanah_tidak_sesuai',
|
|
||||||
analisa_unit: 'analisa_luas_unit_tidak_sesuai',
|
|
||||||
analisa_bangunan: 'analisa_bangunan_tidak_sesuai',
|
|
||||||
};
|
|
||||||
|
|
||||||
// Pastikan elemen ID ada di inputMap
|
|
||||||
if (!inputMap[params]) {
|
|
||||||
console.error('Parameter tidak valid:', params);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ambil nilai berdasarkan parameter
|
|
||||||
const inputValue = document.getElementById(inputMap[params]).value;
|
|
||||||
const data = {
|
|
||||||
[params === 'jenis_asset' ? 'jenis_asset' : params.replace('analisa_', 'luas_')]: inputValue,
|
|
||||||
types: params
|
|
||||||
};
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: '{{ route('surveyor.update_analisa', ['id' => $permohonan->id]) }}',
|
|
||||||
type: 'POST',
|
|
||||||
data: data,
|
|
||||||
headers: {
|
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
console.log(response);
|
|
||||||
if (response.success) {
|
|
||||||
// window.location.href =
|
|
||||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
|
||||||
toastrSuccessBuild(response.message);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
console.error('Terjadi error:', error);
|
|
||||||
console.log('Status:', status);
|
|
||||||
console.log('Response:', xhr.responseText);
|
|
||||||
if (xhr.responseJSON.message) {
|
|
||||||
toastrErrorBuild(xhr.responseJSON.message);
|
|
||||||
} else {
|
|
||||||
toastrErrorBuild('Terjadi kesalahan');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script></script>
|
<script></script>
|
||||||
|
|||||||
@@ -336,4 +336,174 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateAnalisa(params) {
|
||||||
|
const inputMap = {
|
||||||
|
jenis_asset: 'jenis_asset_tidak_sesuai',
|
||||||
|
analisa_tanah: 'analisa_tanah_tidak_sesuai',
|
||||||
|
analisa_unit: 'analisa_luas_unit_tidak_sesuai',
|
||||||
|
analisa_bangunan: 'analisa_bangunan_tidak_sesuai',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Pastikan elemen ID ada di inputMap
|
||||||
|
if (!inputMap[params]) {
|
||||||
|
console.error('Parameter tidak valid:', params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ambil nilai berdasarkan parameter
|
||||||
|
const inputValue = document.getElementById(inputMap[params]).value;
|
||||||
|
const data = {
|
||||||
|
[params === 'jenis_asset' ? 'jenis_asset' : params.replace('analisa_', 'luas_')]: inputValue,
|
||||||
|
types: params
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ route('surveyor.update_analisa', ['id' => $permohonan->id]) }}',
|
||||||
|
type: 'POST',
|
||||||
|
data: data,
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
console.log(response);
|
||||||
|
if (response.success) {
|
||||||
|
// window.location.href =
|
||||||
|
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||||
|
toastrSuccessBuild(response.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error('Terjadi error:', error);
|
||||||
|
console.log('Status:', status);
|
||||||
|
console.log('Response:', xhr.responseText);
|
||||||
|
if (xhr.responseJSON.message) {
|
||||||
|
toastrErrorBuild(xhr.responseJSON.message);
|
||||||
|
} else {
|
||||||
|
toastrErrorBuild('Terjadi kesalahan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateAlamatFields(status) {
|
||||||
|
// Ambil elemen formulir
|
||||||
|
const addressForm = document.getElementById('alamat_form');
|
||||||
|
const inputs = addressForm.querySelectorAll('input, select');
|
||||||
|
const addressInput = document.getElementById('address');
|
||||||
|
|
||||||
|
if (status === 'sesuai') {
|
||||||
|
addressInput.value = "{{ $dokumen->address ?? '' }}";
|
||||||
|
inputs.forEach(element => {
|
||||||
|
if (element.tagName === 'INPUT') {
|
||||||
|
element.setAttribute('readonly', true);
|
||||||
|
} else if (element.tagName === 'SELECT') {
|
||||||
|
element.setAttribute('disabled', true);
|
||||||
|
element.classList.add('disabled-input')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addressForm.style.display = 'grid';
|
||||||
|
addressForm.disabled = true;
|
||||||
|
addressForm.classList.add('disabled-input')
|
||||||
|
|
||||||
|
|
||||||
|
} else if (status === 'tidak sesuai') {
|
||||||
|
addressForm.style.display = 'grid';
|
||||||
|
|
||||||
|
addressForm.removeAttribute('disabled');
|
||||||
|
addressForm.classList.remove('disabled-input')
|
||||||
|
const formInspeksi = @json($forminspeksi ?? '');
|
||||||
|
const addressInput = document.getElementById('address');
|
||||||
|
|
||||||
|
if (formInspeksi && formInspeksi.asset && formInspeksi.asset.alamat) {
|
||||||
|
if (formInspeksi.asset.alamat['tidak sesuai'] && formInspeksi.asset.alamat['tidak sesuai'].address) {
|
||||||
|
addressInput.value = formInspeksi.asset.alamat['tidak sesuai'].address;
|
||||||
|
} else if (formInspeksi.asset.alamat['sesuai'] && formInspeksi.asset.alamat['sesuai'].address) {
|
||||||
|
addressInput.value = formInspeksi.asset.alamat['sesuai'].address;
|
||||||
|
} else {
|
||||||
|
addressInput.value = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inputs.forEach(element => {
|
||||||
|
if (element.tagName === 'INPUT') {
|
||||||
|
element.removeAttribute('readonly');
|
||||||
|
} else if (element.tagName === 'SELECT') {
|
||||||
|
element.removeAttribute('disabled');
|
||||||
|
element.classList.remove('disabled-input')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleFieldVisibility(fieldName, inputId, visibleValues = []) {
|
||||||
|
const selectedValue = $(`[name="${fieldName}"]:checked`).val();
|
||||||
|
const inputField = $(`#${inputId}`);
|
||||||
|
|
||||||
|
if (visibleValues.includes(selectedValue)) {
|
||||||
|
inputField.show();
|
||||||
|
} else {
|
||||||
|
inputField.hide().val('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toggleCheckboxVisibility(fieldName, inputId, visibleValues = []) {
|
||||||
|
const selectedValues = $(`[name="${fieldName}[]"]:checked`)
|
||||||
|
.map(function() {
|
||||||
|
return $(this).val().toLowerCase(); // Konversi nilai ke huruf kecil
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const inputField = $(`#${inputId}`);
|
||||||
|
|
||||||
|
// Cek apakah salah satu nilai yang dipilih cocok dengan visibleValues
|
||||||
|
const shouldShow = visibleValues.some(value => selectedValues.includes(value.toLowerCase()));
|
||||||
|
|
||||||
|
if (shouldShow) {
|
||||||
|
inputField.show();
|
||||||
|
} else {
|
||||||
|
inputField.hide().val('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toggleMultipleFields(fieldName, mappings) {
|
||||||
|
// Ambil semua nilai checkbox yang dicentang
|
||||||
|
const selectedValues = $(`[name="${fieldName}[]"]:checked`)
|
||||||
|
.map(function() {
|
||||||
|
return $(this).val().toLowerCase(); // Konversi nilai ke huruf kecil
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Iterasi melalui setiap mapping
|
||||||
|
for (const [key, inputId] of Object.entries(mappings)) {
|
||||||
|
const inputField = $(`#${inputId}`);
|
||||||
|
|
||||||
|
// Tampilkan input jika nilai yang relevan dipilih
|
||||||
|
if (selectedValues.includes(key.toLowerCase())) {
|
||||||
|
inputField.show();
|
||||||
|
} else {
|
||||||
|
inputField.hide().val(''); // Sembunyikan dan reset nilai
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toggleAlamatVisibility(idSesuai, idTidakSesuai, selectedValue) {
|
||||||
|
// Ambil elemen berdasarkan ID
|
||||||
|
const alamatSesuai = document.getElementById(idSesuai);
|
||||||
|
const alamatTidakSesuai = document.getElementById(idTidakSesuai);
|
||||||
|
|
||||||
|
// Periksa nilai yang dipilih dan tampilkan elemen yang sesuai
|
||||||
|
if (selectedValue === 'sesuai') {
|
||||||
|
alamatSesuai.style.display = 'grid'; // Tampilkan "Alamat Sesuai"
|
||||||
|
alamatTidakSesuai.style.display = 'none'; // Sembunyikan "Alamat Tidak Sesuai"
|
||||||
|
} else if (selectedValue === 'tidak sesuai') {
|
||||||
|
alamatSesuai.style.display = 'none'; // Sembunyikan "Alamat Sesuai"
|
||||||
|
alamatTidakSesuai.style.display = 'grid'; // Tampilkan "Alamat Tidak Sesuai"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user