Compare commits
9
Commits
079e300d5d
...
mobileweb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
712b10e405 | ||
|
|
6cfcf46ba6 | ||
|
|
b1b9828514 | ||
|
|
7af7e1bdaf | ||
|
|
bd05fc7f0f | ||
|
|
17b5687db8 | ||
|
|
e7f48b6500 | ||
|
|
a5884d0f8c | ||
|
|
9576c6295e |
@@ -11,6 +11,7 @@ use App\Models\User;
|
||||
use App\Models\Pertanian\Petani;
|
||||
use App\Models\Pertanian\Komoditas;
|
||||
use App\Models\Pertanian\Lahan;
|
||||
use App\Models\Pertanian\Tanaman;
|
||||
use App\Models\Pertanian\SurveyPelatihan;
|
||||
use App\Models\Pertanian\SurveySertifikasi;
|
||||
|
||||
@@ -143,24 +144,29 @@ class SurveyPetaniController extends Controller
|
||||
|
||||
// Ringkasan lahan
|
||||
|
||||
$totalLuasLahan = (float) Lahan::query()
|
||||
->sum('luas_lahan');
|
||||
|
||||
$totalJumlahTanaman = (int) Lahan::query()
|
||||
->sum('jumlah_tanaman');
|
||||
$totalLuasLahan = ((float) Lahan::query()
|
||||
->sum('luas_lahan')) / 10000;
|
||||
|
||||
// Jumlah tanaman berdasarkan komoditas petani
|
||||
|
||||
$tanamanPerKomoditasCollection = DB::table("{$lahanTable} as l")
|
||||
$tanamanTable = (new Tanaman())->getTable();
|
||||
|
||||
$tanamanPerKomoditasCollection = DB::table("{$tanamanTable} as t")
|
||||
->join("{$lahanTable} as l", 'l.id', '=', 't.lahan_id')
|
||||
->join("{$petaniTable} as p", 'p.id', '=', 'l.petani_id')
|
||||
->leftJoin("{$komoditasTable} as k", 'k.id', '=', 'p.komoditas_id')
|
||||
->leftJoin("{$komoditasTable} as k", 'k.id', '=', 't.komoditas_id')
|
||||
->selectRaw("COALESCE(k.nama, 'Belum ditentukan') as label")
|
||||
->selectRaw('COALESCE(SUM(l.jumlah_tanaman), 0) as total')
|
||||
->selectRaw('COUNT(t.id) as total')
|
||||
->where('k.is_utama', true)
|
||||
->whereNull('t.deleted_at')
|
||||
->whereNull('l.deleted_at')
|
||||
->whereNull('p.deleted_at')
|
||||
->groupBy('k.id', 'k.nama')
|
||||
->orderByDesc('total')
|
||||
->get();
|
||||
|
||||
$totalJumlahTanaman = (int) $tanamanPerKomoditasCollection->sum('total');
|
||||
|
||||
$tanamanPerKomoditas = $tanamanPerKomoditasCollection
|
||||
->map(function ($item, $index) use ($colors, $totalJumlahTanaman) {
|
||||
$color = $colors[$index % count($colors)];
|
||||
|
||||
@@ -25,9 +25,25 @@ class AksesPasarController extends Controller
|
||||
|
||||
$aksesPasar = AksesPasar::where('petani_id', $petaniId)->first();
|
||||
$hargaJualPanen = HargaJualPanen::where('petani_id', $petaniId)->get();
|
||||
$hargaJualRows = collect([
|
||||
'Buah segar hasil petik',
|
||||
'Biji basah',
|
||||
'Biji kering/Biji Kupas',
|
||||
'Terfermentasi (Rp/kg)',
|
||||
])->map(function (string $bentuk, int $index) use ($hargaJualPanen) {
|
||||
$existingData = $hargaJualPanen->firstWhere('bentuk_produk', $bentuk);
|
||||
|
||||
return [
|
||||
'index' => $index,
|
||||
'bentuk' => $bentuk,
|
||||
'harga_panen_terakhir' => $this->currencyForDisplay($existingData?->harga_panen_terakhir),
|
||||
'harga_tahun_lalu' => $this->currencyForDisplay($existingData?->harga_tahun_lalu),
|
||||
'harga_dua_tahun_lalu' => $this->currencyForDisplay($existingData?->harga_dua_tahun_lalu),
|
||||
];
|
||||
});
|
||||
|
||||
return view('produktivitas.petani.akses-pasar.index', array_merge(
|
||||
compact('petani', 'aksesPasar', 'hargaJualPanen'),
|
||||
compact('petani', 'aksesPasar', 'hargaJualPanen', 'hargaJualRows'),
|
||||
$this->aksesPasarOptions()
|
||||
));
|
||||
}
|
||||
@@ -251,4 +267,11 @@ class AksesPasarController extends Controller
|
||||
$digits = preg_replace('/\D/', '', (string) $value);
|
||||
return $digits === '' ? null : $digits;
|
||||
}
|
||||
}
|
||||
|
||||
private function currencyForDisplay(mixed $value): string
|
||||
{
|
||||
$digits = $this->currencyDigits($value);
|
||||
|
||||
return is_null($digits) ? '' : number_format((int) $digits, 0, ',', '.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ class PetaniController extends Controller
|
||||
$query->where('created_by', auth()->user()->id);
|
||||
}
|
||||
|
||||
$summaryPetaniIds = (clone $query)->pluck('id');
|
||||
$petani = $query->paginate($request->per_page ?? 10);
|
||||
|
||||
$komoditas = Komoditas::where('is_utama', true)->get();
|
||||
$lahan = Lahan::whereIn('petani_id', $petani->pluck('id'))
|
||||
$lahan = Lahan::whereIn('petani_id', $summaryPetaniIds)
|
||||
->whereIn('komoditas_id', $komoditas->pluck('id'))
|
||||
->get();
|
||||
$tanaman = Tanaman::whereIn('lahan_id', $lahan->pluck('id'))
|
||||
->whereIn('lahan_id', $lahan->pluck('id'))
|
||||
->get();
|
||||
|
||||
$case = "
|
||||
@@ -70,7 +70,7 @@ class PetaniController extends Controller
|
||||
END
|
||||
";
|
||||
$skor = SkorPetani::selectRaw("$case AS segmen, COUNT(*) AS total")
|
||||
->whereIn('petani_id', $petani->pluck('id'))
|
||||
->whereIn('petani_id', $summaryPetaniIds)
|
||||
->groupByRaw($case)
|
||||
->get();
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
@@ -17,6 +18,7 @@ use App\Models\Pertanian\Lahan;
|
||||
use App\Models\Wilayah\DesaKelurahan;
|
||||
use App\Models\Wilayah\Provinsi;
|
||||
use App\Models\Pertanian\Komoditas;
|
||||
use App\Models\Pertanian\PraktikBudidaya;
|
||||
use App\Models\Pertanian\Tanaman;
|
||||
use App\Models\Master\JenisTanaman;
|
||||
|
||||
@@ -64,8 +66,46 @@ class PetaniLahanController extends Controller
|
||||
|
||||
$komoditas = Komoditas::all();
|
||||
$tanamanPenaung = JenisTanaman::all();
|
||||
$autoPestDiseaseData = $this->autoPestDiseaseData($petaniId);
|
||||
$jenisHamaOtomatis = $autoPestDiseaseData['jenis_hama'];
|
||||
$jenisPenyakitOtomatis = $autoPestDiseaseData['jenis_penyakit'];
|
||||
|
||||
return view('produktivitas.petani.lahan.add', compact('petani', 'lahan', 'provinsi', 'komoditas', 'tanamanPenaung'));
|
||||
return view('produktivitas.petani.lahan.add', compact('petani', 'lahan', 'provinsi', 'komoditas', 'tanamanPenaung', 'jenisHamaOtomatis', 'jenisPenyakitOtomatis'));
|
||||
}
|
||||
|
||||
private function autoPestDiseaseData(string|int $petaniId): array
|
||||
{
|
||||
$praktikBudidaya = PraktikBudidaya::where('petani_id', $petaniId)->latest()->first();
|
||||
|
||||
return [
|
||||
'jenis_hama' => $this->normalizeArrayValue($praktikBudidaya?->jenis_hama),
|
||||
'jenis_penyakit' => $this->normalizeArrayValue($praktikBudidaya?->jenis_penyakit),
|
||||
];
|
||||
}
|
||||
|
||||
private function normalizeArrayValue(mixed $value): array
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return array_values(array_filter($value, fn ($item) => filled($item)));
|
||||
}
|
||||
|
||||
if (is_string($value) && $value !== '') {
|
||||
$decoded = json_decode($value, true);
|
||||
|
||||
if (is_array($decoded)) {
|
||||
return array_values(array_filter($decoded, fn ($item) => filled($item)));
|
||||
}
|
||||
|
||||
return [$value];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
private function hasPestDiseaseColumns(string $table): bool
|
||||
{
|
||||
return Schema::hasColumn($table, 'jenis_hama')
|
||||
&& Schema::hasColumn($table, 'jenis_penyakit');
|
||||
}
|
||||
|
||||
private function validateLahan(Request $request)
|
||||
@@ -167,6 +207,14 @@ class PetaniLahanController extends Controller
|
||||
]);
|
||||
|
||||
$validated = $this->validateLahan($request);
|
||||
$autoPestDiseaseData = $this->autoPestDiseaseData($petaniId);
|
||||
$lahanHasPestDiseaseColumns = $this->hasPestDiseaseColumns((new Lahan)->getTable());
|
||||
$tanamanHasPestDiseaseColumns = $this->hasPestDiseaseColumns((new Tanaman)->getTable());
|
||||
|
||||
if ($lahanHasPestDiseaseColumns) {
|
||||
$validated = array_merge($validated, $autoPestDiseaseData);
|
||||
}
|
||||
|
||||
$komoditas = Komoditas::where('id', $request->komoditas_id)->first();
|
||||
$lahanCount = Lahan::where('petani_id', $petaniId)
|
||||
->count();
|
||||
@@ -196,8 +244,8 @@ class PetaniLahanController extends Controller
|
||||
);
|
||||
|
||||
if ($lahan && $lahan->jumlah_tanaman > 0) {
|
||||
$data = collect(range(1, $lahan->jumlah_tanaman))->map(function ($i) use ($lahan, $komoditas, $lahanUid) {
|
||||
return [
|
||||
$data = collect(range(1, $lahan->jumlah_tanaman))->map(function ($i) use ($lahan, $komoditas, $lahanUid, $autoPestDiseaseData, $tanamanHasPestDiseaseColumns) {
|
||||
$row = [
|
||||
'lahan_id' => $lahan->id,
|
||||
'uid' => 'TNM-' . $lahanUid . '-' . strtoupper(Str::random(10)),
|
||||
'komoditas_id' => $lahan->komoditas_id,
|
||||
@@ -215,6 +263,13 @@ class PetaniLahanController extends Controller
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
|
||||
if ($tanamanHasPestDiseaseColumns) {
|
||||
$row['jenis_hama'] = json_encode($autoPestDiseaseData['jenis_hama'] ?? []);
|
||||
$row['jenis_penyakit'] = json_encode($autoPestDiseaseData['jenis_penyakit'] ?? []);
|
||||
}
|
||||
|
||||
return $row;
|
||||
});
|
||||
|
||||
$data->chunk(500)->each(function ($chunk) {
|
||||
@@ -269,10 +324,13 @@ class PetaniLahanController extends Controller
|
||||
|
||||
$komoditas = Komoditas::all();
|
||||
$tanamanPenaung = JenisTanaman::all();
|
||||
$autoPestDiseaseData = $this->autoPestDiseaseData($petaniId);
|
||||
$jenisHamaOtomatis = $autoPestDiseaseData['jenis_hama'];
|
||||
$jenisPenyakitOtomatis = $autoPestDiseaseData['jenis_penyakit'];
|
||||
|
||||
$provinsi = Provinsi::orderBy('kode', 'asc')->get();
|
||||
|
||||
return view('produktivitas.petani.lahan.edit', compact('lahan', 'lahanSelected', 'petani', 'komoditas', 'provinsi', 'tanamanPenaung'));
|
||||
return view('produktivitas.petani.lahan.edit', compact('lahan', 'lahanSelected', 'petani', 'komoditas', 'provinsi', 'tanamanPenaung', 'jenisHamaOtomatis', 'jenisPenyakitOtomatis'));
|
||||
}
|
||||
|
||||
public function update(Request $request, string $petaniId, string $id)
|
||||
@@ -290,6 +348,14 @@ class PetaniLahanController extends Controller
|
||||
->toArray()
|
||||
]);
|
||||
$validated = $this->validateLahan($request);
|
||||
$autoPestDiseaseData = $this->autoPestDiseaseData($petaniId);
|
||||
$lahanHasPestDiseaseColumns = $this->hasPestDiseaseColumns((new Lahan)->getTable());
|
||||
$tanamanHasPestDiseaseColumns = $this->hasPestDiseaseColumns((new Tanaman)->getTable());
|
||||
|
||||
if ($lahanHasPestDiseaseColumns) {
|
||||
$validated = array_merge($validated, $autoPestDiseaseData);
|
||||
}
|
||||
|
||||
$komoditas = Komoditas::where('id', $request->komoditas_id)->first();
|
||||
$tanamanCount = Tanaman::where('lahan_id', $lahan->id)->count();
|
||||
$lahanCount = Lahan::where('petani_id', $petaniId)->count();
|
||||
@@ -342,8 +408,8 @@ class PetaniLahanController extends Controller
|
||||
$this->syncTanamanPenaung($request);
|
||||
|
||||
if ($lahan && $lahan->jumlah_tanaman > $tanamanCount) {
|
||||
$data = collect(range($tanamanCount + 1, $lahan->jumlah_tanaman))->map(function ($i) use ($lahan, $komoditas, $lahanUid) {
|
||||
return [
|
||||
$data = collect(range($tanamanCount + 1, $lahan->jumlah_tanaman))->map(function ($i) use ($lahan, $komoditas, $lahanUid, $autoPestDiseaseData, $tanamanHasPestDiseaseColumns) {
|
||||
$row = [
|
||||
'lahan_id' => $lahan->id,
|
||||
'komoditas_id' => $lahan->komoditas_id,
|
||||
'jenis_komoditas_id' => $lahan->jenis_komoditas_id,
|
||||
@@ -361,6 +427,13 @@ class PetaniLahanController extends Controller
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
|
||||
if ($tanamanHasPestDiseaseColumns) {
|
||||
$row['jenis_hama'] = json_encode($autoPestDiseaseData['jenis_hama'] ?? []);
|
||||
$row['jenis_penyakit'] = json_encode($autoPestDiseaseData['jenis_penyakit'] ?? []);
|
||||
}
|
||||
|
||||
return $row;
|
||||
});
|
||||
|
||||
$data->chunk(500)->each(function ($chunk) {
|
||||
@@ -368,6 +441,14 @@ class PetaniLahanController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
if ($tanamanHasPestDiseaseColumns) {
|
||||
$lahan->tanaman()->update([
|
||||
'jenis_hama' => json_encode($autoPestDiseaseData['jenis_hama'] ?? []),
|
||||
'jenis_penyakit' => json_encode($autoPestDiseaseData['jenis_penyakit'] ?? []),
|
||||
'updated_by' => auth()->id(),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
|
||||
@@ -154,8 +154,7 @@ class SosialEkonomiController extends Controller
|
||||
});
|
||||
|
||||
if (!$request->expectsJson()) {
|
||||
return redirect()
|
||||
->route('petani.sosial-ekonomi.edit', [$sosialEkonomi->petani_id, $sosialEkonomi->id])
|
||||
return $this->redirectToEditSection($sosialEkonomi, $request)
|
||||
->with('success', 'Data sosial ekonomi berhasil disimpan.');
|
||||
}
|
||||
|
||||
@@ -206,8 +205,7 @@ class SosialEkonomiController extends Controller
|
||||
});
|
||||
|
||||
if (!$request->expectsJson()) {
|
||||
return redirect()
|
||||
->route('petani.sosial-ekonomi.edit', [$sosialEkonomi->petani_id, $sosialEkonomi->id])
|
||||
return $this->redirectToEditSection($sosialEkonomi, $request)
|
||||
->with('success', 'Data sosial ekonomi berhasil diperbarui.');
|
||||
}
|
||||
|
||||
@@ -218,6 +216,18 @@ class SosialEkonomiController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
private function redirectToEditSection(SosialEkonomi $sosialEkonomi, Request $request): RedirectResponse
|
||||
{
|
||||
$url = route('petani.sosial-ekonomi.edit', [$sosialEkonomi->petani_id, $sosialEkonomi->id]);
|
||||
$fragment = $request->input('redirect_fragment');
|
||||
|
||||
if (is_string($fragment) && preg_match('/^[A-Za-z0-9_-]+$/', $fragment)) {
|
||||
$url .= '#' . $fragment;
|
||||
}
|
||||
|
||||
return redirect()->to($url);
|
||||
}
|
||||
|
||||
public function destroy(string $id): JsonResponse
|
||||
{
|
||||
$sosialEkonomi = SosialEkonomi::findOrFail($id);
|
||||
@@ -589,6 +599,14 @@ class SosialEkonomiController extends Controller
|
||||
|
||||
$payload = $this->normalizeSkorPayload($payload);
|
||||
|
||||
if (array_key_exists('ada_sengketa', $payload) && !filter_var($payload['ada_sengketa'], FILTER_VALIDATE_BOOLEAN)) {
|
||||
$payload['keterangan_sengketa'] = null;
|
||||
$payload['pihak_membantu_konflik'] = null;
|
||||
$payload['pihak_membantu_konflik_nama'] = null;
|
||||
$payload['tahun_bantuan_konflik'] = null;
|
||||
$payload['status_konflik'] = null;
|
||||
}
|
||||
|
||||
if (($payload['pihak_membantu_konflik'] ?? null) === PihakMembantuKonflik::TIDAK_ADA_SELESAIKAN_SENDIRI->value) {
|
||||
$payload['pihak_membantu_konflik_nama'] = null;
|
||||
$payload['tahun_bantuan_konflik'] = null;
|
||||
|
||||
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\Pertanian\Petani;
|
||||
@@ -97,6 +98,31 @@ class PraktikBudidaya extends Model
|
||||
$kebiasaan = $praktikBudidaya->kebiasaan_konservasi_tanah ? count($praktikBudidaya->kebiasaan_konservasi_tanah) : 0;
|
||||
$pemahaman = $praktikBudidaya->pemahaman_manfaat_konservasi_tanah == 'Ya, tahu manfaatnya' ? 1 : 0;
|
||||
$skor_konservasi_tanah = 0;
|
||||
$jenisHama = $praktikBudidaya->jenis_hama ?? [];
|
||||
$jenisPenyakit = $praktikBudidaya->jenis_penyakit ?? [];
|
||||
|
||||
if (Schema::hasColumn((new Lahan)->getTable(), 'jenis_hama')
|
||||
&& Schema::hasColumn((new Lahan)->getTable(), 'jenis_penyakit')) {
|
||||
Lahan::where('petani_id', $praktikBudidaya->petani_id)->get()->each(function (Lahan $lahan) use ($jenisHama, $jenisPenyakit, $praktikBudidaya) {
|
||||
$lahan->update([
|
||||
'jenis_hama' => $jenisHama,
|
||||
'jenis_penyakit' => $jenisPenyakit,
|
||||
'updated_by' => $praktikBudidaya->updated_by,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasColumn((new Tanaman)->getTable(), 'jenis_hama')
|
||||
&& Schema::hasColumn((new Tanaman)->getTable(), 'jenis_penyakit')) {
|
||||
Tanaman::where('petani_id', $praktikBudidaya->petani_id)->get()->each(function (Tanaman $tanaman) use ($jenisHama, $jenisPenyakit, $praktikBudidaya) {
|
||||
$tanaman->update([
|
||||
'jenis_hama' => $jenisHama,
|
||||
'jenis_penyakit' => $jenisPenyakit,
|
||||
'updated_by' => $praktikBudidaya->updated_by,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
if ($kebiasaan == 0) {
|
||||
$skor_konservasi_tanah = 1;
|
||||
} elseif ($kebiasaan == 1 && $pemahaman == 0) {
|
||||
@@ -117,19 +143,6 @@ class PraktikBudidaya extends Model
|
||||
'skor_d2_k2_7_penglolaan_air_irigasi' => $praktikBudidaya->kondisi_pengelolaan_air,
|
||||
'skor_d2_k2_8_praktik_konservasi_tanah' => $skor_konservasi_tanah,
|
||||
]);
|
||||
|
||||
Lahan::where('petani_id', $petani->id)->update([
|
||||
'jenis_hama' => $praktikBudidaya->jenis_hama,
|
||||
'jenis_penyakit' => $praktikBudidaya->jenis_penyakit,
|
||||
]);
|
||||
|
||||
Tanaman::whereIn(
|
||||
'lahan_id',
|
||||
Lahan::where('petani_id', $petani->id)->select('id')
|
||||
)->update([
|
||||
'jenis_hama' => $praktikBudidaya->jenis_hama,
|
||||
'jenis_penyakit' => $praktikBudidaya->jenis_penyakit,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -137,4 +150,4 @@ class PraktikBudidaya extends Model
|
||||
{
|
||||
return $this->belongsTo(Petani::class, 'petani_id');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,26 +12,46 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('map_lahan', function (Blueprint $table) {
|
||||
$table->jsonb('jenis_hama')->nullable();
|
||||
$table->jsonb('jenis_penyakit')->nullable();
|
||||
if (! Schema::hasColumn('map_lahan', 'jenis_hama')) {
|
||||
$table->jsonb('jenis_hama')->nullable();
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('map_lahan', 'jenis_penyakit')) {
|
||||
$table->jsonb('jenis_penyakit')->nullable();
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('map_tanaman', function (Blueprint $table) {
|
||||
$table->jsonb('jenis_hama')->nullable();
|
||||
$table->jsonb('jenis_penyakit')->nullable();
|
||||
if (! Schema::hasColumn('map_tanaman', 'jenis_hama')) {
|
||||
$table->jsonb('jenis_hama')->nullable();
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('map_tanaman', 'jenis_penyakit')) {
|
||||
$table->jsonb('jenis_penyakit')->nullable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('map_lahan', function (Blueprint $table) {
|
||||
$table->dropColumn('jenis_hama');
|
||||
$table->dropColumn('jenis_penyakit');
|
||||
if (Schema::hasColumn('map_lahan', 'jenis_hama')) {
|
||||
$table->dropColumn('jenis_hama');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('map_lahan', 'jenis_penyakit')) {
|
||||
$table->dropColumn('jenis_penyakit');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('map_tanaman', function (Blueprint $table) {
|
||||
$table->dropColumn('jenis_hama');
|
||||
$table->dropColumn('jenis_penyakit');
|
||||
if (Schema::hasColumn('map_tanaman', 'jenis_hama')) {
|
||||
$table->dropColumn('jenis_hama');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('map_tanaman', 'jenis_penyakit')) {
|
||||
$table->dropColumn('jenis_penyakit');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<i class="icon-base ti tabler-trees icon-28px"></i>
|
||||
</span>
|
||||
</div>
|
||||
<h4 class="mb-0">{{ number_format($lahanSummary->sum('luas_lahan'), 0, ',', '.') }}m<sup>2</sup></h4>
|
||||
<h4 class="mb-0">{{ number_format($lahanSummary->sum('luas_lahan') / 10000, 2, ',', '.') }} ha</h4>
|
||||
</div>
|
||||
<p class="mb-1">Lahan</p>
|
||||
<p class="mb-0">
|
||||
@@ -701,4 +701,4 @@
|
||||
radarKomponen.render();
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endpush
|
||||
|
||||
@@ -88,12 +88,13 @@
|
||||
@if($profile)
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-icon btn-text-secondary rounded-pill"
|
||||
class="btn btn-sm btn-outline-primary d-inline-flex align-items-center gap-1 px-3"
|
||||
data-bs-toggle="offcanvas"
|
||||
data-bs-target="#editProfileOffcanvas"
|
||||
aria-controls="editProfileOffcanvas"
|
||||
title="Edit profil">
|
||||
<i class="icon-base ti tabler-edit icon-lg"></i>
|
||||
<i class="icon-base ti tabler-edit icon-sm"></i>
|
||||
<span>Edit</span>
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -338,7 +338,7 @@
|
||||
href="javascript:void(0);"
|
||||
data-bs-toggle="dropdown">
|
||||
<div class="avatar avatar-online">
|
||||
<img src="../../assets/img/avatars/3.jpg" alt class="rounded-circle" />
|
||||
<img src="{{ asset('assets/img/avatars/3.jpg') }}" alt="Avatar" class="rounded-circle" />
|
||||
</div>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
@@ -347,7 +347,7 @@
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="flex-shrink-0 me-2">
|
||||
<div class="avatar avatar-online">
|
||||
<img src="../../assets/img/avatars/3.jpg" alt class="rounded-circle" />
|
||||
<img src="{{ asset('assets/img/avatars/3.jpg') }}" alt="Avatar" class="rounded-circle" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-grow-1">
|
||||
|
||||
@@ -93,34 +93,30 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php($listBentukProduk = ['Buah segar hasil petik', 'Biji basah', 'Biji kering/Biji Kupas', 'Terfermentasi (Rp/kg)'])
|
||||
@php($hargaJualPanen = $hargaJualPanen ?? collect())
|
||||
|
||||
@foreach ($listBentukProduk as $index => $bentuk)
|
||||
@php($existingData = $hargaJualPanen->firstWhere('bentuk_produk', $bentuk))
|
||||
@foreach ($hargaJualRows as $row)
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="harga_jual[{{ $index }}][bentuk_produk]" value="{{ $bentuk }}">
|
||||
<strong>{{ $bentuk }}:</strong>
|
||||
<input type="hidden" name="harga_jual[{{ $row['index'] }}][bentuk_produk]" value="{{ $row['bentuk'] }}">
|
||||
<strong>{{ $row['bentuk'] }}:</strong>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">Rp</span>
|
||||
<input type="number" min="0" class="form-control" name="harga_jual[{{ $index }}][harga_panen_terakhir]" value="{{ old('harga_jual.' . $index . '.harga_panen_terakhir', $existingData?->harga_panen_terakhir) }}">
|
||||
<input type="text" inputmode="numeric" class="form-control rupiah-input" name="harga_jual[{{ $row['index'] }}][harga_panen_terakhir]" value="{{ old('harga_jual.' . $row['index'] . '.harga_panen_terakhir', $row['harga_panen_terakhir']) }}" placeholder="Contoh: 12.000">
|
||||
<span class="input-group-text">/kg</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">Rp</span>
|
||||
<input type="number" min="0" class="form-control" name="harga_jual[{{ $index }}][harga_tahun_lalu]" value="{{ old('harga_jual.' . $index . '.harga_tahun_lalu', $existingData?->harga_tahun_lalu) }}">
|
||||
<input type="text" inputmode="numeric" class="form-control rupiah-input" name="harga_jual[{{ $row['index'] }}][harga_tahun_lalu]" value="{{ old('harga_jual.' . $row['index'] . '.harga_tahun_lalu', $row['harga_tahun_lalu']) }}" placeholder="Contoh: 10.000">
|
||||
<span class="input-group-text">/kg</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">Rp</span>
|
||||
<input type="number" min="0" class="form-control" name="harga_jual[{{ $index }}][harga_dua_tahun_lalu]" value="{{ old('harga_jual.' . $index . '.harga_dua_tahun_lalu', $existingData?->harga_dua_tahun_lalu) }}">
|
||||
<input type="text" inputmode="numeric" class="form-control rupiah-input" name="harga_jual[{{ $row['index'] }}][harga_dua_tahun_lalu]" value="{{ old('harga_jual.' . $row['index'] . '.harga_dua_tahun_lalu', $row['harga_dua_tahun_lalu']) }}" placeholder="Contoh: 8.000">
|
||||
<span class="input-group-text">/kg</span>
|
||||
</div>
|
||||
</td>
|
||||
@@ -232,6 +228,16 @@
|
||||
const praktikBelumPernahValue = String(@json($praktikBelumPernahValue));
|
||||
const skorPengalamanBerhentiValues = @json($skorPengalamanBerhentiValues ?? [2,3]).map(Number);
|
||||
|
||||
function onlyDigits(value) {
|
||||
return String(value || '').replace(/\D/g, '');
|
||||
}
|
||||
|
||||
function formatRupiah(value) {
|
||||
const digits = onlyDigits(value);
|
||||
|
||||
return digits.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
||||
}
|
||||
|
||||
function syncAlasanBerhenti() {
|
||||
const val = Number($('input[name="skor_pengalaman"]:checked').val());
|
||||
const isBerhenti = skorPengalamanBerhentiValues.includes(val);
|
||||
@@ -256,10 +262,21 @@
|
||||
$('input[name="skor_pengalaman"]').on('change', 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);
|
||||
|
||||
if (cursorAtEnd) {
|
||||
this.setSelectionRange(this.value.length, this.value.length);
|
||||
}
|
||||
});
|
||||
$('.rupiah-input').each(function () {
|
||||
this.value = formatRupiah(this.value);
|
||||
});
|
||||
|
||||
syncAlasanBerhenti();
|
||||
syncSaluranLainnya();
|
||||
syncPraktikFermentasi();
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endpush
|
||||
|
||||
@@ -92,7 +92,13 @@
|
||||
? $petani->lahans()->get()
|
||||
: collect();
|
||||
$totalLuasLahan = $petani ? $lahanPetani->where('komoditas_id', $petani->komoditas_id)->sum('luas_lahan') : 0;
|
||||
$totalTanaman = $petani ? $lahanPetani->where('komoditas_id', $petani->komoditas_id)->sum('jumlah_tanaman') : 0;
|
||||
$totalLuasLahanHa = $totalLuasLahan / 10000;
|
||||
$lahanKomoditasUtamaIds = $petani
|
||||
? $lahanPetani->where('komoditas_id', $petani->komoditas_id)->pluck('id')
|
||||
: collect();
|
||||
$totalTanaman = $petani && \Illuminate\Support\Facades\Schema::hasTable('map_tanaman')
|
||||
? \App\Models\Pertanian\Tanaman::whereIn('lahan_id', $lahanKomoditasUtamaIds)->count()
|
||||
: 0;
|
||||
$pendidikanLabel = isset($petani) ? $petani->pendidikan_terakhir?->label() : null;
|
||||
|
||||
@endphp
|
||||
@@ -126,7 +132,7 @@
|
||||
<p class="mb-0 text-muted" style="font-size: 0.75rem;">Lahan & Tanaman</p>
|
||||
<h5 class="mb-0">
|
||||
@if($lahanPetani->isNotEmpty())
|
||||
{{ number_format($totalLuasLahan, 0, ',', '.') }} ha
|
||||
{{ number_format($totalLuasLahanHa, 2, ',', '.') }} ha
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="w-25">
|
||||
<x-summary-card
|
||||
title="Lahan & Tanaman"
|
||||
count="{{ number_format($lahan?->sum('luas_lahan'), 0, ',', '.') }}ha"
|
||||
count="{{ number_format(($lahan?->sum('luas_lahan') ?? 0) / 10000, 2, ',', '.') }} ha"
|
||||
subtitle="{{ $tanaman?->count() }} tanaman dari {{ $komoditas?->count() }} komoditas utama"
|
||||
icon="trees"
|
||||
color="success"
|
||||
|
||||
@@ -163,6 +163,10 @@
|
||||
z-index: 100000 !important;
|
||||
}
|
||||
.foto-lightbox-close:hover { color: #dc3545 !important; }
|
||||
.auto-pest-disease-field .form-check-label,
|
||||
.auto-pest-disease-field .text-muted {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@@ -259,7 +263,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3 mb-4 form-control-validation">
|
||||
<div class="col-md-3 mb-4 form-control-validation auto-pest-disease-field">
|
||||
<label class="form-label">Jenis Hama</label>
|
||||
|
||||
<div class="form-check mt-2">
|
||||
@@ -267,7 +271,8 @@
|
||||
type="checkbox"
|
||||
name="jenis_hama[]"
|
||||
value="Penggerek buah"
|
||||
id="jenis-hama-penggerek-buah">
|
||||
id="jenis-hama-penggerek-buah"
|
||||
{{ in_array('Penggerek buah', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Penggerek buah</label>
|
||||
</div>
|
||||
|
||||
@@ -276,7 +281,8 @@
|
||||
type="checkbox"
|
||||
name="jenis_hama[]"
|
||||
value="Penggerek batang"
|
||||
id="jenis-hama-penggerek-batang">
|
||||
id="jenis-hama-penggerek-batang"
|
||||
{{ in_array('Penggerek batang', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Penggerek batang</label>
|
||||
</div>
|
||||
|
||||
@@ -285,7 +291,8 @@
|
||||
type="checkbox"
|
||||
name="jenis_hama[]"
|
||||
value="Kutu putih/kutu sisik"
|
||||
id="jenis-hama-kutu">
|
||||
id="jenis-hama-kutu"
|
||||
{{ in_array('Kutu putih/kutu sisik', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Kutu putih/kutu sisik</label>
|
||||
</div>
|
||||
|
||||
@@ -294,7 +301,8 @@
|
||||
type="checkbox"
|
||||
name="jenis_hama[]"
|
||||
value="Ulat pemakan daun"
|
||||
id="jenis-hama-ulat">
|
||||
id="jenis-hama-ulat"
|
||||
{{ in_array('Ulat pemakan daun', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Ulat pemakan daun</label>
|
||||
</div>
|
||||
|
||||
@@ -303,15 +311,16 @@
|
||||
type="checkbox"
|
||||
name="jenis_hama[]"
|
||||
value="Tikus"
|
||||
id="jenis-hama-tikus">
|
||||
id="jenis-hama-tikus"
|
||||
{{ in_array('Tikus', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Tikus</label>
|
||||
</div>
|
||||
<small class="text-muted text-secondary">* Tidak diisi, terisi otomatis</small>
|
||||
<small class="text-muted text-secondary">* Tidak diisi, terisi otomatis di Praktik Budidaya</small>
|
||||
@error('jenis_hama')
|
||||
<div class="error invalid-feedback d-block">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-md-3 mb-4 form-control-validation">
|
||||
<div class="col-md-3 mb-4 form-control-validation auto-pest-disease-field">
|
||||
<label class="form-label">Jenis Penyakit</label>
|
||||
|
||||
<div class="form-check mt-2">
|
||||
@@ -319,7 +328,8 @@
|
||||
type="checkbox"
|
||||
name="jenis_penyakit[]"
|
||||
value="Karat daun"
|
||||
id="jenis-penyakit-karat-daun">
|
||||
id="jenis-penyakit-karat-daun"
|
||||
{{ in_array('Karat daun', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Karat daun</label>
|
||||
</div>
|
||||
|
||||
@@ -328,7 +338,8 @@
|
||||
type="checkbox"
|
||||
name="jenis_penyakit[]"
|
||||
value="Busuk buah/antraknosa"
|
||||
id="jenis-penyakit-busuk-buah">
|
||||
id="jenis-penyakit-busuk-buah"
|
||||
{{ in_array('Busuk buah/antraknosa', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Busuk buah/antraknosa</label>
|
||||
</div>
|
||||
|
||||
@@ -337,7 +348,8 @@
|
||||
type="checkbox"
|
||||
name="jenis_penyakit[]"
|
||||
value="Busuk akar"
|
||||
id="jenis-penyakit-busuk-akar">
|
||||
id="jenis-penyakit-busuk-akar"
|
||||
{{ in_array('Busuk akar', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Busuk akar</label>
|
||||
</div>
|
||||
|
||||
@@ -346,7 +358,8 @@
|
||||
type="checkbox"
|
||||
name="jenis_penyakit[]"
|
||||
value="Bercak daun"
|
||||
id="jenis-penyakit-bercak-daun">
|
||||
id="jenis-penyakit-bercak-daun"
|
||||
{{ in_array('Bercak daun', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Bercak daun</label>
|
||||
</div>
|
||||
|
||||
@@ -355,10 +368,11 @@
|
||||
type="checkbox"
|
||||
name="jenis_penyakit[]"
|
||||
value="Layu fusarium"
|
||||
id="jenis-penyakit-layu-fusarium">
|
||||
id="jenis-penyakit-layu-fusarium"
|
||||
{{ in_array('Layu fusarium', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Layu fusarium</label>
|
||||
</div>
|
||||
<small class="text-muted text-secondary">* Tidak diisi, terisi otomatis</small>
|
||||
<small class="text-muted text-secondary">* Tidak diisi, terisi otomatis di praktik budidaya</small>
|
||||
|
||||
@error('jenis_penyakit')
|
||||
<div class="error invalid-feedback d-block">{{ $message }}</div>
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
.foto-lightbox img { max-width: 90vw !important; max-height: 85vh !important; object-fit: contain !important; border-radius: 8px !important; box-shadow: 0 10px 40px rgba(0,0,0,0.5) !important; }
|
||||
.foto-lightbox-close { position: absolute !important; top: 20px !important; right: 30px !important; color: #fff !important; font-size: 40px !important; font-weight: bold !important; cursor: pointer !important; z-index: 100000 !important; }
|
||||
.foto-lightbox-close:hover { color: #dc3545 !important; }
|
||||
.auto-pest-disease-field .form-check-label,
|
||||
.auto-pest-disease-field .text-muted {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@@ -161,7 +165,7 @@
|
||||
<option value="{{ \App\Enums\PenyakitTanaman::TANAMAN_LAYU }}" {{ old('penyakit_tanaman', $lahanSelected->penyakit_tanaman) == \App\Enums\PenyakitTanaman::TANAMAN_LAYU ? 'selected' : '' }}>Tanaman Layu</option>
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="col-md-3 mb-4 form-control-validation">
|
||||
<div class="col-md-3 mb-4 form-control-validation auto-pest-disease-field">
|
||||
<label class="form-label">Jenis Hama</label>
|
||||
|
||||
<div class="form-check mt-2">
|
||||
@@ -170,7 +174,7 @@
|
||||
name="jenis_hama[]"
|
||||
value="Penggerek buah"
|
||||
id="jenis-hama-penggerek-buah"
|
||||
{{ in_array('Penggerek buah', old('jenis_hama', $lahanSelected->jenis_hama ?? [])) ? 'checked' : '' }}>
|
||||
{{ in_array('Penggerek buah', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Penggerek buah</label>
|
||||
</div>
|
||||
|
||||
@@ -180,7 +184,7 @@
|
||||
name="jenis_hama[]"
|
||||
value="Penggerek batang"
|
||||
id="jenis-hama-penggerek-batang"
|
||||
{{ in_array('Penggerek batang', old('jenis_hama', $lahanSelected->jenis_hama ?? [])) ? 'checked' : '' }}>
|
||||
{{ in_array('Penggerek batang', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Penggerek batang</label>
|
||||
</div>
|
||||
|
||||
@@ -190,7 +194,7 @@
|
||||
name="jenis_hama[]"
|
||||
value="Kutu putih/kutu sisik"
|
||||
id="jenis-hama-kutu"
|
||||
{{ in_array('Kutu putih/kutu sisik', old('jenis_hama', $lahanSelected->jenis_hama ?? [])) ? 'checked' : '' }}>
|
||||
{{ in_array('Kutu putih/kutu sisik', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Kutu putih/kutu sisik</label>
|
||||
</div>
|
||||
|
||||
@@ -200,7 +204,7 @@
|
||||
name="jenis_hama[]"
|
||||
value="Ulat pemakan daun"
|
||||
id="jenis-hama-ulat"
|
||||
{{ in_array('Ulat pemakan daun', old('jenis_hama', $lahanSelected->jenis_hama ?? [])) ? 'checked' : '' }}>
|
||||
{{ in_array('Ulat pemakan daun', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Ulat pemakan daun</label>
|
||||
</div>
|
||||
|
||||
@@ -210,15 +214,15 @@
|
||||
name="jenis_hama[]"
|
||||
value="Tikus"
|
||||
id="jenis-hama-tikus"
|
||||
{{ in_array('Tikus', old('jenis_hama', $lahanSelected->jenis_hama ?? [])) ? 'checked' : '' }}>
|
||||
{{ in_array('Tikus', $jenisHamaOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-hama-bentuk">Tikus</label>
|
||||
</div>
|
||||
<small class="text-muted text-secondary">* Tidak diisi, terisi otomatis</small>
|
||||
<small class="text-muted text-secondary">* Tidak diisi, terisi otomatis di praktik budidaya</small>
|
||||
@error('jenis_hama')
|
||||
<div class="error invalid-feedback d-block">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-md-3 mb-4 form-control-validation">
|
||||
<div class="col-md-3 mb-4 form-control-validation auto-pest-disease-field">
|
||||
<label class="form-label">Jenis Penyakit</label>
|
||||
|
||||
<div class="form-check mt-2">
|
||||
@@ -227,7 +231,7 @@
|
||||
name="jenis_penyakit[]"
|
||||
value="Karat daun"
|
||||
id="jenis-penyakit-karat-daun"
|
||||
{{ in_array('Karat daun', old('jenis_penyakit', $lahanSelected->jenis_penyakit ?? [])) ? 'checked' : '' }}
|
||||
{{ in_array('Karat daun', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Karat daun</label>
|
||||
</div>
|
||||
|
||||
@@ -237,7 +241,7 @@
|
||||
name="jenis_penyakit[]"
|
||||
value="Busuk buah/antraknosa"
|
||||
id="jenis-penyakit-busuk-buah"
|
||||
{{ in_array('Busuk buah/antraknosa', old('jenis_penyakit', $lahanSelected->jenis_penyakit ?? [])) ? 'checked' : '' }}
|
||||
{{ in_array('Busuk buah/antraknosa', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Busuk buah/antraknosa</label>
|
||||
</div>
|
||||
|
||||
@@ -247,7 +251,7 @@
|
||||
name="jenis_penyakit[]"
|
||||
value="Busuk akar"
|
||||
id="jenis-penyakit-busuk-akar"
|
||||
{{ in_array('Busuk akar', old('jenis_penyakit', $lahanSelected->jenis_penyakit ?? [])) ? 'checked' : '' }}
|
||||
{{ in_array('Busuk akar', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Busuk akar</label>
|
||||
</div>
|
||||
|
||||
@@ -257,7 +261,7 @@
|
||||
name="jenis_penyakit[]"
|
||||
value="Bercak daun"
|
||||
id="jenis-penyakit-bercak-daun"
|
||||
{{ in_array('Bercak daun', old('jenis_penyakit', $lahanSelected->jenis_penyakit ?? [])) ? 'checked' : '' }}
|
||||
{{ in_array('Bercak daun', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Bercak daun</label>
|
||||
</div>
|
||||
|
||||
@@ -267,10 +271,10 @@
|
||||
name="jenis_penyakit[]"
|
||||
value="Layu fusarium"
|
||||
id="jenis-penyakit-layu-fusarium"
|
||||
{{ in_array('Layu fusarium', old('jenis_penyakit', $lahanSelected->jenis_penyakit ?? [])) ? 'checked' : '' }}
|
||||
{{ in_array('Layu fusarium', $jenisPenyakitOtomatis ?? [], true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="jenis-penyakit-bentuk">Layu fusarium</label>
|
||||
</div>
|
||||
<small class="text-muted text-secondary">* Tidak diisi, terisi otomatis</small>
|
||||
<small class="text-muted text-secondary">* Tidak diisi, terisi otomatis di Praktik Budidaya</small>
|
||||
|
||||
@error('jenis_penyakit')
|
||||
<div class="error invalid-feedback d-block">{{ $message }}</div>
|
||||
@@ -820,7 +824,8 @@
|
||||
});
|
||||
document.getElementById('path').value = JSON.stringify(pathData);
|
||||
let area = L.GeometryUtil.geodesicArea(latlngs);
|
||||
$('#luas_lahan').val(area.toFixed(2));
|
||||
let areaHa = area / 10000;
|
||||
$('#luas_lahan').val(areaHa.toFixed(4));
|
||||
}
|
||||
|
||||
const previewTemplate = `
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
@extends('layout.main')
|
||||
|
||||
@push('scripts-head')
|
||||
<style>
|
||||
#section-utama,
|
||||
#section-sosial-budaya,
|
||||
#section-keanggotaan-kelompok,
|
||||
#section-akses-keuangan,
|
||||
#section-keterikatan-hutang {
|
||||
scroll-margin-top: 96px;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
@if (session('success'))
|
||||
@@ -1062,6 +1074,20 @@
|
||||
const pinjamanTokohAdatAda = @json($pinjamanTokohAdatAdaValue);
|
||||
const tekananJualSegeraAda = @json($tekananJualSegeraAdaValue);
|
||||
const kebebasanMemilihPembeliCukupBebas = Number(@json($kebebasanMemilihPembeliCukupBebasValue));
|
||||
const sectionAnchors = {
|
||||
utama: 'section-utama',
|
||||
sosial_budaya: 'section-sosial-budaya',
|
||||
keanggotaan_kelompok: 'section-keanggotaan-kelompok',
|
||||
akses_keuangan: 'section-akses-keuangan',
|
||||
keterikatan_hutang: 'section-keterikatan-hutang'
|
||||
};
|
||||
const nextSectionAnchors = {
|
||||
utama: 'section-sosial-budaya',
|
||||
sosial_budaya: 'section-keanggotaan-kelompok',
|
||||
keanggotaan_kelompok: 'section-akses-keuangan',
|
||||
akses_keuangan: 'section-keterikatan-hutang',
|
||||
keterikatan_hutang: 'section-keterikatan-hutang'
|
||||
};
|
||||
const fieldExamples = {
|
||||
jumlah_tanggungan: 'Contoh: 4',
|
||||
anak_masih_sekolah: 'Contoh: 2',
|
||||
@@ -1399,7 +1425,8 @@
|
||||
}
|
||||
|
||||
function syncPihakMembantuFields() {
|
||||
const isTidakAda = $('#pihak-membantu').val() === pihakMembantuTanpaBantuan;
|
||||
const isAdaSengketa = $('input[name="ada_sengketa"]:checked').val() === '1';
|
||||
const isTidakAda = !isAdaSengketa || $('#pihak-membantu').val() === pihakMembantuTanpaBantuan;
|
||||
const $fields = $('#pihak-membantu-nama, #tahun-bantuan');
|
||||
|
||||
$fields.prop('disabled', isTidakAda);
|
||||
@@ -1409,6 +1436,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
function syncSengketaFields() {
|
||||
const isAdaSengketa = $('input[name="ada_sengketa"]:checked').val() === '1';
|
||||
const $fields = $('#keterangan-sengketa, #pihak-membantu, #status-konflik');
|
||||
const $assistanceFields = $('#pihak-membantu-nama, #tahun-bantuan');
|
||||
|
||||
$fields.prop('disabled', !isAdaSengketa);
|
||||
|
||||
if (!isAdaSengketa) {
|
||||
$fields.add($assistanceFields).val('');
|
||||
$fields.filter('select').trigger('change.select2');
|
||||
}
|
||||
|
||||
syncPihakMembantuFields();
|
||||
}
|
||||
|
||||
function syncPernahJualHargaLebihTinggiFields() {
|
||||
const isPernah = $('#pernah-jual-harga-lebih-tinggi').val() === pernahJualHargaLebihTinggiPernah;
|
||||
const $field = $('#penyebab-harga-lebih-tinggi');
|
||||
@@ -1601,6 +1643,37 @@
|
||||
clearPendapatanRowValidation($row);
|
||||
}
|
||||
|
||||
function setupSectionAnchors() {
|
||||
$('input[name="form_section"]').each(function () {
|
||||
const section = this.value;
|
||||
const anchor = sectionAnchors[section];
|
||||
const nextAnchor = nextSectionAnchors[section] || anchor;
|
||||
const $form = $(this).closest('form');
|
||||
|
||||
if (anchor) {
|
||||
$form.find('> .card').first().attr('id', anchor);
|
||||
}
|
||||
|
||||
if (nextAnchor && !$form.find('input[name="redirect_fragment"]').length) {
|
||||
$('<input>', {
|
||||
type: 'hidden',
|
||||
name: 'redirect_fragment',
|
||||
value: nextAnchor
|
||||
}).appendTo($form);
|
||||
}
|
||||
});
|
||||
|
||||
if (window.location.hash) {
|
||||
const target = document.getElementById(window.location.hash.substring(1));
|
||||
|
||||
if (target) {
|
||||
setTimeout(function () {
|
||||
target.scrollIntoView({ block: 'start' });
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('change', '.sosial-ekonomi-komoditas-utama', syncKomoditasLainnyaOptions);
|
||||
$(document).on('input change', '.pendapatan-row input, .pendapatan-row select', function () {
|
||||
clearPendapatanRowValidation($(this).closest('.pendapatan-row'));
|
||||
@@ -1636,6 +1709,7 @@
|
||||
});
|
||||
});
|
||||
$('#pihak-membantu').on('change', syncPihakMembantuFields);
|
||||
$('input[name="ada_sengketa"]').on('change', syncSengketaFields);
|
||||
$('#pernah-jual-harga-lebih-tinggi').on('change', syncPernahJualHargaLebihTinggiFields);
|
||||
$('input[name="panutan_petani_sukses"]').on('change', syncPanutanFields);
|
||||
$('input[name="terdaftar_kelompok_tani"]').on('change', syncTerdaftarKelompokFields);
|
||||
@@ -1650,10 +1724,12 @@
|
||||
$('#total-hutang-tidak-bersedia').on('change', syncTotalHutangFields);
|
||||
$('input[name="tekanan_jual_segera"]').on('change', syncTekananJualFields);
|
||||
$('input[name="kebebasan_memilih_pembeli"]').on('change', syncKebebasanPembeliFields);
|
||||
setupSectionAnchors();
|
||||
applySosialEkonomiExamples();
|
||||
syncKomoditasLainnyaOptions();
|
||||
setupAllPendapatanRows();
|
||||
syncPihakMembantuFields();
|
||||
syncSengketaFields();
|
||||
syncPernahJualHargaLebihTinggiFields();
|
||||
syncPanutanFields();
|
||||
syncTerdaftarKelompokFields();
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
@extends('layout.main')
|
||||
|
||||
@push('scripts-head')
|
||||
<style>
|
||||
#section-utama,
|
||||
#section-sosial-budaya,
|
||||
#section-keanggotaan-kelompok,
|
||||
#section-akses-keuangan,
|
||||
#section-keterikatan-hutang {
|
||||
scroll-margin-top: 96px;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
@if (session('success'))
|
||||
@@ -1058,6 +1070,20 @@
|
||||
const pinjamanTokohAdatAda = @json($pinjamanTokohAdatAdaValue);
|
||||
const tekananJualSegeraAda = @json($tekananJualSegeraAdaValue);
|
||||
const kebebasanMemilihPembeliCukupBebas = Number(@json($kebebasanMemilihPembeliCukupBebasValue));
|
||||
const sectionAnchors = {
|
||||
utama: 'section-utama',
|
||||
sosial_budaya: 'section-sosial-budaya',
|
||||
keanggotaan_kelompok: 'section-keanggotaan-kelompok',
|
||||
akses_keuangan: 'section-akses-keuangan',
|
||||
keterikatan_hutang: 'section-keterikatan-hutang'
|
||||
};
|
||||
const nextSectionAnchors = {
|
||||
utama: 'section-sosial-budaya',
|
||||
sosial_budaya: 'section-keanggotaan-kelompok',
|
||||
keanggotaan_kelompok: 'section-akses-keuangan',
|
||||
akses_keuangan: 'section-keterikatan-hutang',
|
||||
keterikatan_hutang: 'section-keterikatan-hutang'
|
||||
};
|
||||
const fieldExamples = {
|
||||
jumlah_tanggungan: 'Contoh: 4',
|
||||
anak_masih_sekolah: 'Contoh: 2',
|
||||
@@ -1395,7 +1421,8 @@
|
||||
}
|
||||
|
||||
function syncPihakMembantuFields() {
|
||||
const isTidakAda = $('#pihak-membantu').val() === pihakMembantuTanpaBantuan;
|
||||
const isAdaSengketa = $('input[name="ada_sengketa"]:checked').val() === '1';
|
||||
const isTidakAda = !isAdaSengketa || $('#pihak-membantu').val() === pihakMembantuTanpaBantuan;
|
||||
const $fields = $('#pihak-membantu-nama, #tahun-bantuan');
|
||||
|
||||
$fields.prop('disabled', isTidakAda);
|
||||
@@ -1405,6 +1432,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
function syncSengketaFields() {
|
||||
const isAdaSengketa = $('input[name="ada_sengketa"]:checked').val() === '1';
|
||||
const $fields = $('#keterangan-sengketa, #pihak-membantu, #status-konflik');
|
||||
const $assistanceFields = $('#pihak-membantu-nama, #tahun-bantuan');
|
||||
|
||||
$fields.prop('disabled', !isAdaSengketa);
|
||||
|
||||
if (!isAdaSengketa) {
|
||||
$fields.add($assistanceFields).val('');
|
||||
$fields.filter('select').trigger('change.select2');
|
||||
}
|
||||
|
||||
syncPihakMembantuFields();
|
||||
}
|
||||
|
||||
function syncPernahJualHargaLebihTinggiFields() {
|
||||
const isPernah = $('#pernah-jual-harga-lebih-tinggi').val() === pernahJualHargaLebihTinggiPernah;
|
||||
const $field = $('#penyebab-harga-lebih-tinggi');
|
||||
@@ -1597,6 +1639,37 @@
|
||||
clearPendapatanRowValidation($row);
|
||||
}
|
||||
|
||||
function setupSectionAnchors() {
|
||||
$('input[name="form_section"]').each(function () {
|
||||
const section = this.value;
|
||||
const anchor = sectionAnchors[section];
|
||||
const nextAnchor = nextSectionAnchors[section] || anchor;
|
||||
const $form = $(this).closest('form');
|
||||
|
||||
if (anchor) {
|
||||
$form.find('> .card').first().attr('id', anchor);
|
||||
}
|
||||
|
||||
if (nextAnchor && !$form.find('input[name="redirect_fragment"]').length) {
|
||||
$('<input>', {
|
||||
type: 'hidden',
|
||||
name: 'redirect_fragment',
|
||||
value: nextAnchor
|
||||
}).appendTo($form);
|
||||
}
|
||||
});
|
||||
|
||||
if (window.location.hash) {
|
||||
const target = document.getElementById(window.location.hash.substring(1));
|
||||
|
||||
if (target) {
|
||||
setTimeout(function () {
|
||||
target.scrollIntoView({ block: 'start' });
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('change', '.sosial-ekonomi-komoditas-utama', syncKomoditasLainnyaOptions);
|
||||
$(document).on('input change', '.pendapatan-row input, .pendapatan-row select', function () {
|
||||
clearPendapatanRowValidation($(this).closest('.pendapatan-row'));
|
||||
@@ -1632,6 +1705,7 @@
|
||||
});
|
||||
});
|
||||
$('#pihak-membantu').on('change', syncPihakMembantuFields);
|
||||
$('input[name="ada_sengketa"]').on('change', syncSengketaFields);
|
||||
$('#pernah-jual-harga-lebih-tinggi').on('change', syncPernahJualHargaLebihTinggiFields);
|
||||
$('input[name="panutan_petani_sukses"]').on('change', syncPanutanFields);
|
||||
$('input[name="terdaftar_kelompok_tani"]').on('change', syncTerdaftarKelompokFields);
|
||||
@@ -1646,10 +1720,12 @@
|
||||
$('#total-hutang-tidak-bersedia').on('change', syncTotalHutangFields);
|
||||
$('input[name="tekanan_jual_segera"]').on('change', syncTekananJualFields);
|
||||
$('input[name="kebebasan_memilih_pembeli"]').on('change', syncKebebasanPembeliFields);
|
||||
setupSectionAnchors();
|
||||
applySosialEkonomiExamples();
|
||||
syncKomoditasLainnyaOptions();
|
||||
setupAllPendapatanRows();
|
||||
syncPihakMembantuFields();
|
||||
syncSengketaFields();
|
||||
syncPernahJualHargaLebihTinggiFields();
|
||||
syncPanutanFields();
|
||||
syncTerdaftarKelompokFields();
|
||||
|
||||
Reference in New Issue
Block a user