From 3b1a0f52ddf124f28db316ba4370c8197b87bc83 Mon Sep 17 00:00:00 2001 From: SyaharaniSalsabilla Date: Thu, 2 Jul 2026 14:36:25 +0700 Subject: [PATCH] update field sosial ekonomi --- .../petani/sosial-ekonomi/index.blade.php | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/resources/views/produktivitas/petani/sosial-ekonomi/index.blade.php b/resources/views/produktivitas/petani/sosial-ekonomi/index.blade.php index 57b8c0c..be8491b 100644 --- a/resources/views/produktivitas/petani/sosial-ekonomi/index.blade.php +++ b/resources/views/produktivitas/petani/sosial-ekonomi/index.blade.php @@ -79,7 +79,8 @@ - pendapatan) }}"> + @php($pendapatanValue = old("pendapatan_komoditas.$i.pendapatan", $item?->pendapatan)) + - pendapatan) }}"> + @php($pendapatanValue = old("pendapatan_komoditas.$index.pendapatan", $item?->pendapatan)) + jenis_pekerjaan) }}"> - estimasi_per_bulan) }}"> + @php($estimasiValue = old("pendapatan_luar_pertanian.$i.estimasi_per_bulan", $item?->estimasi_per_bulan)) + @endfor @@ -190,7 +193,8 @@
- + @php($biayaKebunValue = old('total_estimasi_biaya_kebun_per_musim', $sosialEkonomi?->total_estimasi_biaya_kebun_per_musim)) + @error('total_estimasi_biaya_kebun_per_musim')
{{ $message }}
@enderror
@@ -207,7 +211,8 @@
- + @php($tabunganValue = old('estimasi_tabungan_per_bulan', $sosialEkonomi?->estimasi_tabungan_per_bulan)) + @error('estimasi_tabungan_per_bulan')
{{ $message }}
@enderror
@@ -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();