Compare commits

...

4 Commits

Author SHA1 Message Date
Daeng Deni Mardaeni
6cf4432642 📝 fix(linguistic): perbaiki label teks dan fallback variable
- Tambahkan fallback variable alamat untuk mencegah undefined error
- Gunakan null coalescing sebagai default value yang aman
- Perbaiki label tampilan dari "Jalan Lingkungan" menjadi "Jalan Utama"
- Tingkatkan kejelasan dan konsistensi istilah pada UI
- Pertahankan key data 'jalan_linkungan' untuk backward compatibility
- Tidak ada perubahan struktur data atau logic backend
- Perubahan terbatas pada layer tampilan (UI)
- Meningkatkan UX dan stabilitas pada edge case
2025-12-15 16:33:30 +07:00
Daeng Deni Mardaeni
7c5202021f 🐛 fix(currency): perbaiki thousand separator pada input currency dinamis
- Gunakan nilai mentah dari DB pada template JS (hapus number_format di JS)
- Inisialisasi IMask untuk nilai existing saat loadSavedNPW()
- Terapkan IMask pada class .currency dan .currency-format
- Tambahkan event blur untuk menjaga format saat edit ulang
- Perbaiki parsing nilai luas dengan parseFloat + regex cleaning
- Pastikan perhitungan total NPW tetap akurat
- Hapus fungsi formatCurrencyValue yang tidak terpakai
- Pastikan thousand separator muncul saat load dan input baru
2025-12-15 16:29:31 +07:00
Daeng Deni Mardaeni
e8a735e977 feat(lpj-print-out): perbaiki format currency dan parsing data NPW
- Standarisasi format currency menggunakan number_format() di seluruh print-out
- Hapus penggunaan formatRupiah() yang tidak konsisten
- Bersihkan data currency dengan str_replace() sebelum diproses
- Tangani karakter Rp, titik, dan koma agar parsing aman
- Perbaiki perhitungan total NPW dari data numerik murni
- Tambahkan null safety dengan default nilai 0
- Cegah error parsing akibat string currency
- Pastikan tampilan angka konsisten (contoh: 1.500.000)
2025-12-15 11:13:37 +07:00
Daeng Deni Mardaeni
1c5b48ff1b feat(lpj-form-penilai): gunakan IMask untuk formatting currency dinamis
- Ganti formatter manual formatCurrency dengan library IMask pada input class currency
- Terapkan thousand separator titik (.) dan radix koma (,) sesuai format lokal
- Gunakan mask Number tanpa desimal (scale 0) untuk nilai harga
- Pindahkan trigger event dari input ke change untuk efisiensi performa
- IMask otomatis menolak karakter non-numerik dan menormalkan nilai
- Thousand separator muncul otomatis saat input nilai besar
- Format angka menjadi konsisten dan standar di seluruh form penilaian
- Kurangi potensi error input akibat formatting manual
2025-12-15 11:08:42 +07:00
5 changed files with 56 additions and 23 deletions

View File

@@ -302,9 +302,20 @@
});
// Tambahkan event listener untuk currency format
newNPWRow.querySelectorAll('.currency-format').forEach(input => {
input.addEventListener('input', function() {
formatCurrency(this);
newNPWRow.querySelectorAll('.currency').forEach(input => {
input.addEventListener('change', function() {
window.IMask(this, {
mask: Number, // enable number mask
// other options are optional with defaults below
scale: 0, // digits after point, 0 for integers
thousandsSeparator: ".", // any single char
padFractionalZeros: false, // if true, then pads zeros at end to the length of scale
normalizeZeros: true, // appends or removes zeros at ends
radix: ",", // fractional delimiter
mapToRadix: ["."], // symbols to process as radix
autofix: true,
});
});
});
@@ -355,7 +366,7 @@
class="w-full currency"
name="nilai_npw_${npwCounter}_1"
placeholder="Harga per meter"
value="${npw.nilai_1 || ''}"
value="${npw.nilai_1 || '0'}"
oninput="calculateTotal()">
</label>
</div>
@@ -387,10 +398,36 @@
calculateTotal();
});
// Tambahkan event listener untuk currency format
newNPWRow.querySelectorAll('.currency-format').forEach(input => {
input.addEventListener('input', function() {
formatCurrency(this);
// Initialize currency formatting for existing values
newNPWRow.querySelectorAll('.currency').forEach(input => {
// Apply IMask immediately for existing values
if (input.value && input.value !== '0') {
window.IMask(input, {
mask: Number,
scale: 0,
thousandsSeparator: ".",
padFractionalZeros: false,
normalizeZeros: true,
radix: ",",
mapToRadix: ["."],
autofix: true,
});
}
// Also add blur event for future editing
input.addEventListener('blur', function() {
if (!this.imask) {
window.IMask(this, {
mask: Number,
scale: 0,
thousandsSeparator: ".",
padFractionalZeros: false,
normalizeZeros: true,
radix: ",",
mapToRadix: ["."],
autofix: true,
});
}
});
});
@@ -406,7 +443,7 @@
// Panggil fungsi load NPW saat halaman dimuat
loadSavedNPW();
document.querySelectorAll('.currency-format').forEach(input => {
document.querySelectorAll('.currency').forEach(input => {
input.addEventListener('input', function() {
formatCurrency(this);
});
@@ -492,7 +529,7 @@
const outputElement = row.querySelector('input[id^="nilai_npw_"][id$="_2"]');
if (luasInput && nilaiInput && outputElement) {
const luas = parseInput(luasInput.value);
const luas = parseFloat(luasInput.value.replace(/[^0-9.]/g, '')) || 0;
const nilai = parseInput(nilaiInput.value);
const hasil = luas * nilai;

View File

@@ -20,7 +20,7 @@
<td style="padding: 2px; vertical-align: top;">{{ $lingkungan['jarak_jalan_utama'] ?? '-' }}</td>
</tr>
<tr>
<td style="padding: 2px; vertical-align: top;">Jalan Lingkungan</td>
<td style="padding: 2px; vertical-align: top;">Jalan Utama</td>
<td style="padding: 2px; vertical-align: top;">:</td>
<td style="padding: 2px; vertical-align: top;">{{ $lingkungan['jalan_linkungan'] ?? '-' }}</td>

View File

@@ -582,16 +582,14 @@
</td>
<td width="5%" style="padding: 3px; text-align: center;">X</td>
<td width="25%" style="padding: 3px; text-align:right">
{{ formatRupiah($npw['nilai_1'] ?? 0, 0, false) ?? '' }}
</td>
<td width="5" style="padding: 3px; text-align: center;">
=
{{ number_format((float) str_replace(['Rp', '.', ','], '', $npw['nilai_1'] ?? 0), 0, ',', '.') }}
</td>
<td width="5" style="padding: 3px; text-align: center;">=</td>
<td width="25%" style="padding: 3px; text-align: left; text-align: right;">
{{ formatRupiah($npw['nilai_2'] ?? 0, 0, false) ?? '' }}
{{ number_format((float) str_replace(['Rp', '.', ','], '', $npw['nilai_2'] ?? 0), 0, ',', '.') }}
</td>
</tr>
@php $totalNilaiPasarWajar += str_replace(['Rp', '.'], '', $npw['nilai_2']); @endphp
@php $totalNilaiPasarWajar += str_replace(['Rp', '.', ','], '', $npw['nilai_2'] ?? 0); @endphp
@endforeach
@endif
<tr>

View File

@@ -370,7 +370,6 @@
@endif
@endforeach
@endif
@if (isset($lpjData['npw_tambahan']))
@foreach ($lpjData['npw_tambahan'] as $npw)
<tr>
@@ -382,15 +381,14 @@
</td>
<td width="5%" style="padding: 3px; text-align: center;">X</td>
<td width="25%" style="padding: 3px; text-align:right">
{{ number_format($npw['nilai_1'], 0, ',', '.') ?? '' }}
{{ number_format((float) str_replace(['Rp', '.', ','], '', $npw['nilai_1'] ?? 0), 0, ',', '.') }}
</td>
<td width="5" style="padding: 3px; text-align: center;">=</td>
<td width="25%" style="padding: 3px; text-align: left; text-align: right;">
{{ number_format($npw['nilai_2'], 0, ',', '.') ?? '' }}
{{ number_format((float) str_replace(['Rp', '.', ','], '', $npw['nilai_2'] ?? 0), 0, ',', '.') }}
</td>
</tr>
@php $totalNilaiPasarWajar += $npw['nilai_2']; @endphp
@php $totalNilaiPasarWajar += str_replace(['Rp', '.', ','], '', $npw['nilai_2'] ?? 0); @endphp
@endforeach
@endif

View File

@@ -235,7 +235,7 @@
@php
$statusKey = isset($forminspeksi['asset']['alamat']['sesuai']) ? 'sesuai' : 'tidak sesuai';
$address = $forminspeksi['asset']['alamat'][$statusKey] ?? null;
$cekAlamat = $address ?? '';
@endphp
<div id="alamat_form" class="grid gap-2 mt-5" style="display: none;">