From bea9be8a3963ae54b833a26e8e928575b02e7974 Mon Sep 17 00:00:00 2001 From: althaf Date: Fri, 16 Oct 2026 15:11:39 +0700 Subject: [PATCH] resolve aksespasar --- .../Produktivitas/AksesPasarController.php | 3 +- .../petani/akses-pasar/index.blade.php | 138 ++++++++++++------ 2 files changed, 95 insertions(+), 46 deletions(-) diff --git a/app/Http/Controllers/Web/Produktivitas/AksesPasarController.php b/app/Http/Controllers/Web/Produktivitas/AksesPasarController.php index 6f8fb1e..f22faa6 100644 --- a/app/Http/Controllers/Web/Produktivitas/AksesPasarController.php +++ b/app/Http/Controllers/Web/Produktivitas/AksesPasarController.php @@ -216,7 +216,6 @@ class AksesPasarController extends Controller { $payload = collect($validated)->except(['harga_jual'])->all(); - // Bersihkan input teks "Lainnya" jika checkbox Lainnya tidak dipilih if (!in_array('Lainnya', $payload['tujuan_penjualan'] ?? [], true)) { $payload['tujuan_penjualan_lainnya'] = null; } @@ -274,7 +273,7 @@ class AksesPasarController extends Controller $data['harga_jual'][$index]['harga_tahun_lalu'] = $this->currencyDigits($item['harga_tahun_lalu']); } if (array_key_exists('harga_dua_tahun_lalu', $item)) { - $data['harga_jual'][$index]['harga_dua_tahun_lalu'] = $this->currencyDigits($item['harga_dua_tahun_l'], 0); // fixed + $data['harga_jual'][$index]['harga_dua_tahun_lalu'] = $this->currencyDigits($item['harga_dua_tahun_lalu']); } } } diff --git a/resources/views/produktivitas/petani/akses-pasar/index.blade.php b/resources/views/produktivitas/petani/akses-pasar/index.blade.php index 2f333e3..8252bed 100644 --- a/resources/views/produktivitas/petani/akses-pasar/index.blade.php +++ b/resources/views/produktivitas/petani/akses-pasar/index.blade.php @@ -35,7 +35,7 @@
Saluran Penjualan Utama
- +
@php $tujuanOptions = ['Tengkulak/pedagang lokal', 'Koperasi', 'BUMDes', 'Langsung ke pembeli/eksportir']; @@ -130,52 +130,78 @@

-
Pengalaman Saluran Lain
-
- -
- - @foreach($skorPengalamanOptions as $option) -
- skor_pengalaman) === (string) $option['value'] ? 'checked' : '' }}> - +
Pengalaman Saluran Lain
+
+ +
+ + @foreach($skorPengalamanOptions as $option) +
+ skor_pengalaman) === (string) $option['value'] ? 'checked' : '' }}> + +
+ @endforeach + @error('skor_pengalaman')
{{ $message }}
@enderror +
+ +
+
+ +
+ + + @error('alasan_berhenti')
{{ $message }}
@enderror +
+ +
+ +
+ +
+ @foreach($saluranTerdahuluOptions as $option) + @if($option['value'] !== $saluranLainnyaValue) +
+
+ saluran_terdahulu ?? []), true) ? 'checked' : '' }}> + +
+
+ @endif + @endforeach + +
+
+
+ saluran_terdahulu ?? []), true) ? 'checked' : '' }}> + +
+ +
+
- @endforeach - @error('skor_pengalaman')
{{ $message }}
@enderror -
+ @error('saluran_terdahulu')
{{ $message }}
@enderror + @error('saluran_terdahulu_lainnya')
{{ $message }}
@enderror +
-
- - - @error('alasan_berhenti')
{{ $message }}
@enderror -
- -
- - @foreach($saluranTerdahuluOptions as $option) -
- saluran_terdahulu ?? []), true) ? 'checked' : '' }}> - -
- @endforeach - @error('saluran_terdahulu')
{{ $message }}
@enderror -
- -
- - - @error('saluran_terdahulu_lainnya')
{{ $message }}
@enderror
+
HARGA DI SETIAP TITIK
Harga Jual Panen Terakhir
@@ -358,6 +384,7 @@ const saluranLainnyaValue = @json($saluranLainnyaValue); const praktikBelumPernahValue = String(@json($praktikBelumPernahValue)); const skorPengalamanBerhentiValues = @json($skorPengalamanBerhentiValues ?? [2,3]).map(Number); + const skorBelumPernahValue = "1"; function onlyDigits(value) { return String(value || '').replace(/\D/g, ''); @@ -368,6 +395,22 @@ return digits.replace(/\B(?=(\d{3})+(?!\d))/g, '.'); } + function toggleSaluranLanjutan() { + const selectedRadio = $('input[name="skor_pengalaman"]:checked'); + const val = selectedRadio.val(); + const labelText = selectedRadio.parent().text().toLowerCase(); + + const isBelumPernah = !val || labelText.includes('belum pernah') || val === skorBelumPernahValue; + + if (isBelumPernah) { + $('#blok-saluran-lanjutan').addClass('d-none'); + $('#blok-saluran-lanjutan input[type="text"]').val(''); + $('#blok-saluran-lanjutan input[type="checkbox"]').prop('checked', false); + } else { + $('#blok-saluran-lanjutan').removeClass('d-none'); + } + } + function syncAlasanBerhenti() { const val = Number($('input[name="skor_pengalaman"]:checked').val()); const isBerhenti = skorPengalamanBerhentiValues.includes(val); @@ -389,9 +432,14 @@ } } - $('input[name="skor_pengalaman"]').on('change', syncAlasanBerhenti); + $('input[name="skor_pengalaman"]').on('change', function () { + toggleSaluranLanjutan(); + syncAlasanBerhenti(); + }); + $('input[name="saluran_terdahulu[]"]').on('change', syncSaluranLainnya); $('input[name="praktik_fermentasi"]').on('change', syncPraktikFermentasi); + $(document).on('input', '.rupiah-input', function () { const cursorAtEnd = this.selectionStart === this.value.length; this.value = formatRupiah(this.value); @@ -400,10 +448,12 @@ this.setSelectionRange(this.value.length, this.value.length); } }); + $('.rupiah-input').each(function () { this.value = formatRupiah(this.value); }); + toggleSaluranLanjutan(); syncAlasanBerhenti(); syncSaluranLainnya(); syncPraktikFermentasi();