update field sosial ekonomi

This commit is contained in:
2026-07-02 14:36:25 +07:00
parent 5cee65f8df
commit 3b1a0f52dd
@@ -79,7 +79,8 @@
</select>
</td>
<td>
<input type="number" min="0" class="form-control" name="pendapatan_komoditas[{{ $i }}][pendapatan]" value="{{ old("pendapatan_komoditas.$i.pendapatan", $item?->pendapatan) }}">
@php($pendapatanValue = old("pendapatan_komoditas.$i.pendapatan", $item?->pendapatan))
<input type="text" inputmode="numeric" class="form-control currency-input" name="pendapatan_komoditas[{{ $i }}][pendapatan]" value="{{ filled($pendapatanValue) ? number_format((int) preg_replace('/\D/', '', $pendapatanValue), 0, ',', '.') : '' }}">
</td>
<td>
<select class="form-control" name="pendapatan_komoditas[{{ $i }}][periode]">
@@ -120,7 +121,8 @@
</select>
</td>
<td>
<input type="number" min="0" class="form-control" name="pendapatan_komoditas[{{ $index }}][pendapatan]" value="{{ old("pendapatan_komoditas.$index.pendapatan", $item?->pendapatan) }}">
@php($pendapatanValue = old("pendapatan_komoditas.$index.pendapatan", $item?->pendapatan))
<input type="text" inputmode="numeric" class="form-control currency-input" name="pendapatan_komoditas[{{ $index }}][pendapatan]" value="{{ filled($pendapatanValue) ? number_format((int) preg_replace('/\D/', '', $pendapatanValue), 0, ',', '.') : '' }}">
</td>
<td>
<select class="form-control" name="pendapatan_komoditas[{{ $index }}][periode]">
@@ -152,7 +154,8 @@
<input type="text" class="form-control pendapatan-trigger" name="pendapatan_luar_pertanian[{{ $i }}][jenis_pekerjaan]" value="{{ old("pendapatan_luar_pertanian.$i.jenis_pekerjaan", $item?->jenis_pekerjaan) }}">
</td>
<td>
<input type="number" min="0" class="form-control" name="pendapatan_luar_pertanian[{{ $i }}][estimasi_per_bulan]" value="{{ old("pendapatan_luar_pertanian.$i.estimasi_per_bulan", $item?->estimasi_per_bulan) }}">
@php($estimasiValue = old("pendapatan_luar_pertanian.$i.estimasi_per_bulan", $item?->estimasi_per_bulan))
<input type="text" inputmode="numeric" class="form-control currency-input" name="pendapatan_luar_pertanian[{{ $i }}][estimasi_per_bulan]" value="{{ filled($estimasiValue) ? number_format((int) preg_replace('/\D/', '', $estimasiValue), 0, ',', '.') : '' }}">
</td>
</tr>
@endfor
@@ -190,7 +193,8 @@
<div class="row">
<div class="col-md-4 mb-4 form-control-validation">
<label class="form-label" for="biaya-kebun">Total Estimasi Biaya Kebun per Musim (Rp)</label>
<input type="number" min="0" class="form-control @error('total_estimasi_biaya_kebun_per_musim') is-invalid @enderror" id="biaya-kebun" name="total_estimasi_biaya_kebun_per_musim" value="{{ old('total_estimasi_biaya_kebun_per_musim', $sosialEkonomi?->total_estimasi_biaya_kebun_per_musim) }}">
@php($biayaKebunValue = old('total_estimasi_biaya_kebun_per_musim', $sosialEkonomi?->total_estimasi_biaya_kebun_per_musim))
<input type="text" inputmode="numeric" class="form-control currency-input @error('total_estimasi_biaya_kebun_per_musim') is-invalid @enderror" id="biaya-kebun" name="total_estimasi_biaya_kebun_per_musim" value="{{ filled($biayaKebunValue) ? number_format((int) preg_replace('/\D/', '', $biayaKebunValue), 0, ',', '.') : '' }}">
@error('total_estimasi_biaya_kebun_per_musim')<div class="invalid-feedback">{{ $message }}</div>@enderror
</div>
<div class="col-md-4 mb-4 form-control-validation">
@@ -207,7 +211,8 @@
</div>
<div class="col-md-4 mb-4 form-control-validation">
<label class="form-label" for="tabungan-bulan">Estimasi Tabungan per Bulan (Rp)</label>
<input type="number" min="0" class="form-control @error('estimasi_tabungan_per_bulan') is-invalid @enderror" id="tabungan-bulan" name="estimasi_tabungan_per_bulan" value="{{ old('estimasi_tabungan_per_bulan', $sosialEkonomi?->estimasi_tabungan_per_bulan) }}">
@php($tabunganValue = old('estimasi_tabungan_per_bulan', $sosialEkonomi?->estimasi_tabungan_per_bulan))
<input type="text" inputmode="numeric" class="form-control currency-input @error('estimasi_tabungan_per_bulan') is-invalid @enderror" id="tabungan-bulan" name="estimasi_tabungan_per_bulan" value="{{ filled($tabunganValue) ? number_format((int) preg_replace('/\D/', '', $tabunganValue), 0, ',', '.') : '' }}">
@error('estimasi_tabungan_per_bulan')<div class="invalid-feedback">{{ $message }}</div>@enderror
</div>
</div>
@@ -404,8 +409,31 @@
}
}
function onlyDigits(value) {
return String(value || '').replace(/\D/g, '');
}
function formatRupiah(value) {
const digits = onlyDigits(value);
return digits.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
}
$('.sosial-ekonomi-komoditas-utama').on('change', syncKomoditasLainnyaOptions);
$('.pendapatan-trigger').on('change keyup', syncAllPendapatanRows);
$('.currency-input').on('input', function () {
const cursorAtEnd = this.selectionStart === this.value.length;
this.value = formatRupiah(this.value);
if (cursorAtEnd) {
this.setSelectionRange(this.value.length, this.value.length);
}
});
$('form').on('submit', function () {
$(this).find('.currency-input').each(function () {
this.value = onlyDigits(this.value);
});
});
$('#pihak-membantu').on('change', syncPihakMembantuFields);
syncKomoditasLainnyaOptions();
syncAllPendapatanRows();