perbaikan alamat, foto pembading, diskon, dan perbaikan tampilan kjjp
This commit is contained in:
@@ -110,34 +110,63 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-4 py-2">Luas Tanah (m²)</td>
|
||||
@php
|
||||
$cekLuas = $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'] ?? '' }}">
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
@php
|
||||
$apartemenKantorData = explode(',', $inspeksi->name);
|
||||
$isApartemenKantor = array_intersect($apartemenKantorData, [
|
||||
'tanah',
|
||||
'bangunan',
|
||||
]);
|
||||
|
||||
<input type="text" name="luas_tanah_pembanding[]"
|
||||
class="input number-format">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-4 py-2">Luas Bangunan (m²)</td>
|
||||
<td class="px-4 py-2">
|
||||
@endphp
|
||||
|
||||
@if ($isApartemenKantor)
|
||||
<tr>
|
||||
<td class="px-4 py-2">Luas Tanah (m²)</td>
|
||||
@php
|
||||
$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'] ?? '') }}">
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
|
||||
<input type="text" name="luas_tanah_pembanding[]"
|
||||
class="input number-format">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-4 py-2">Luas Bangunan (m²)</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'] ?? '') }}">
|
||||
</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 (m²)</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
|
||||
|
||||
<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>
|
||||
|
||||
<!-- 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"
|
||||
value="{{ $inspectionData['asset']['diskon'] ?? '' }}">
|
||||
<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">
|
||||
<input type="text" name="diskon_pembanding[]"
|
||||
class="input currency-format">
|
||||
<td class=" px-4 py-2">
|
||||
<div class="input">
|
||||
<input type="text" name="diskon_pembanding[]"
|
||||
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;
|
||||
|
||||
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');
|
||||
// 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[]');
|
||||
|
||||
// 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());
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Ambil nilai numerik dari input
|
||||
const harga = parseFloat(hargaInput.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
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user