ringkasan dan summary petani

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-04 15:07:56 +07:00
co-authored by Copilot
parent 61f72e4352
commit 69d09e74e2
17 changed files with 933 additions and 38 deletions
@@ -35,7 +35,7 @@
<input type="datetime" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}"
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) }}" />
@elseif($k->tipe == 'boolean')
<select class="form-select @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" name="{{ $k->kolom }}">
<select class="form-select tipe-boolean @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" name="{{ $k->kolom }}">
<option value="1" {{ old($k->kolom) == 1 ? 'selected' : '' }}>Ya</option>
<option value="0" {{ old($k->kolom) == 0 ? 'selected' : '' }}>Tidak</option>
</select>
@@ -50,7 +50,7 @@
<div class="mt-4 text-end">
<a href="{{ route('tabel.data.index', [$tabel->id, 'program' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
<a href="{{ route('tabel.data.index', [$tabel->id, 'program_id' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
<button type="submit" class="btn btn-success data-submit">Simpan Data</button>
</div>
</form>
@@ -63,6 +63,7 @@
<script>
'use strict';
$(document).ready(function () {
$('#add-data-program,.tipe-boolean').select2();
$('#addNewDataForm').validate({
rules: {
@@ -13,6 +13,19 @@
@method('PUT')
<h6 class="mb-3">Informasi {{ $tabel->label }}</h6>
@if (!$program)
<div class="row">
<div class="col-md-3 mb-4 form-control-validation">
<label class="form-label" for="add-data-program">Program<span class="text-danger">*</span></label>
<select name="program_id" class="form-select form-select-sm w-auto" onchange="this.form.submit()">
<option value="">Pilih Program</option>
@foreach($programList as $prog)
<option value="{{ $prog->id }}" {{ request('program_id') == $prog->id ? 'selected' : '' }}>{{ $prog->nama }}</option>
@endforeach
</select>
</div>
</div>
@endif
<div class="row">
@foreach($kolom as $k)
<?php
@@ -40,8 +53,8 @@
name="{{ $k->kolom }}" placeholder="Cth: {{ $k->label }}" value="{{ old($k->kolom) ?? $value['value_'.$k->tipe] }}" />
@elseif($k->tipe == 'boolean')
<select class="form-select @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}" name="{{ $k->kolom }}">
<option value="1" {{ old($k->kolom) ?? $value['value_'.$k->tipe] == 1 ? 'selected' : '' }}>Ya</option>
<option value="0" {{ old($k->kolom) ?? $value['value_'.$k->tipe] == 0 ? 'selected' : '' }}>Tidak</option>
<option value="1" {{ (old($k->kolom) ?? ($value['value_'.$k->tipe] ?? null)) == 1 ? 'selected' : '' }}>Ya</option>
<option value="0" {{ (old($k->kolom) ?? ($value['value_'.$k->tipe] ?? null)) == 0 ? 'selected' : '' }}>Tidak</option>
</select>
@else
<input type="text" class="form-control @error($k->kolom) is-invalid @enderror" id="add-data-{{ $k->kolom }}"
@@ -54,7 +67,7 @@
<div class="mt-4 text-end">
<a href="{{ route('tabel.data.index', [$tabel->id, 'program' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
<a href="{{ route('tabel.data.index', [$tabel->id, 'program_id' => $program->id]) }}" class="btn btn-label-secondary me-2">Kembali</a>
<button type="submit" class="btn btn-success data-submit">Simpan Data</button>
</div>
</form>
@@ -2,6 +2,32 @@
@section('content')
<div class="container-xxl flex-grow-1 container-p-y">
@if($ringkasan->isNotEmpty())
<div class="row g-6 mb-6">
@foreach($ringkasan as $r)
<div class="col-3">
<div class="card">
<div class="card-body">
<div class="d-flex align-items-start justify-content-between">
<div class="content-left">
<span class="text-heading">{{ $r->heading }}</span>
<div class="d-flex align-items-center my-1">
<h4 class="mb-0 me-2">{{ $r->nilai }}</h4>
</div>
<small class="mb-0">{{ $r->subheading }}</small>
</div>
<div class="avatar">
<span class="avatar-initial rounded bg-label-primary">
<i class="icon-base ti tabler-gauge icon-26px"></i>
</span>
</div>
</div>
</div>
</div>
</div>
@endforeach
</div>
@endif
<div class="card">
<div class="card-header border-bottom">
<h5 class="card-title mb-0">Data {{ $tabel->label }}</h5>
@@ -40,7 +66,8 @@
<input type="text" name="search" class="form-control" placeholder="Cari Nama Tabel..." value="{{ request('search') }}">
<button type="submit" class="btn btn-outline-primary"><i class="ti tabler-search"></i></button>
</div>
<a href="{{ route('tabel.data.create', [$tabel->id, 'program_id' => request('program')]) }}" class="btn btn-sm btn-primary add-new">
<a href="{{ route('tabel.data.create', [$tabel->id, 'program_id' => request('program_id')]) }}" class="btn btn-sm btn-primary add-new"
style="display: {{ request('program_id') ? 'flex' : 'none' }};">
<i class="ti tabler-plus me-1"></i> Tambah
</a>
</div>
@@ -52,6 +79,7 @@
<thead class="border-top">
<tr>
<th>No</th>
<th>Nama Program</th>
@foreach($kolom as $k)
<th>{{ $k->label }}</th>
@endforeach
@@ -62,14 +90,15 @@
@forelse($values as $v)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $v->program_nama ?? 'N/A' }}</td>
@foreach($kolom as $k)
<td>{{ $v->{$k->kolom} }}</td>
@endforeach
<td>
<div class="d-flex align-items-center">
<a href="{{ route('tabel.data.edit', [$tabel->id, $v->value_id, 'program_id' => $k->program_id]) }}" class="btn btn-icon btn-text-secondary rounded-pill edit-record"><i class="ti tabler-edit ti-md"></i></a>
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-record" data-id="{{ $v->value_id }}" data-program-id="{{ $k->program_id }}"><i class="ti tabler-trash ti-md"></i></a>
<a href="{{ route('tabel.data.show', [$tabel->id, $v->value_id, 'program_id' => $k->program_id]) }}" class="btn btn-icon btn-text-secondary rounded-pill view-record"><i class="ti tabler-eye ti-md"></i></a>
<a href="{{ route('tabel.data.edit', [$tabel->id, $v->value_id, 'program_id' => $v->program_id]) }}" class="btn btn-icon btn-text-secondary rounded-pill edit-record"><i class="ti tabler-edit ti-md"></i></a>
<a href="javascript:;" class="btn btn-icon btn-text-secondary rounded-pill delete-record" data-id="{{ $v->value_id }}" data-program-id="{{ $v->program_id }}"><i class="ti tabler-trash ti-md"></i></a>
<a href="{{ route('tabel.data.show', [$tabel->id, $v->value_id, 'program_id' => $v->program_id]) }}" class="btn btn-icon btn-text-secondary rounded-pill view-record"><i class="ti tabler-eye ti-md"></i></a>
</div>
</td>
</tr>
@@ -98,6 +127,7 @@
e.preventDefault();
const id = $(this).data('id');
const programId = $(this).data('program-id');
Swal.fire({
title: 'Hapus?',
@@ -108,9 +138,19 @@
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
buttonsStyling: false
}).then(function (result) {
console.log(id);
console.log(programId);
var baseUrl = "{{ route('tabel.data.destroy', [$tabel->id, ':id']) }}"
.replace(':id', id)
var params = new URLSearchParams({
program_id: programId
});
var url = baseUrl + '?' + params.toString();
console.log(url);
if (result.value) {
$.ajax({
url: "{{ route('tabel.data.destroy', [$tabel->id, ':id', 'program_id' => ':programId']) }}".replace(':id', id).replace(':programId', programId),
url: url,
type: 'POST',
data: {
_token: '{{ csrf_token() }}',