Files
database-pertani-web/resources/views/ekosistem/value-basis-data/index.blade.php
T
2026-05-04 15:07:56 +07:00

169 lines
7.8 KiB
PHP

@extends('layout.main')
@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>
</div>
<div class="card-body border-bottom pt-4">
<form method="GET" action="{{ route('tabel.data.index', $tabel->id) }}" class="d-flex justify-content-between align-items-center row gap-3 gap-md-0">
<div class="col-md-auto">
<div class="d-flex align-items-center">
<label class="me-2 text-nowrap">Show</label>
<select name="per_page" class="form-select form-select-sm w-auto" onchange="this.form.submit()">
<option value="10" {{ request('per_page') == 10 ? 'selected' : '' }}>10</option>
<option value="25" {{ request('per_page') == 25 ? 'selected' : '' }}>25</option>
<option value="50" {{ request('per_page') == 50 ? 'selected' : '' }}>50</option>
</select>
<label class="ms-2 text-nowrap">entries</label>
</div>
</div>
<div class="col-md-auto d-flex gap-2">
@if (app()->has('SystemProgram'))
@else
<div class="col-md-auto">
<div class="d-flex align-items-center">
<label class="me-2 text-nowrap">Program</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>
<label class="ms-2 text-nowrap">entries</label>
</div>
</div>
@endif
<div class="input-group input-group-sm w-auto">
<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_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>
</form>
</div>
<div class="table-responsive text-nowrap">
<table class="table table-hover">
<thead class="border-top">
<tr>
<th>No</th>
<th>Nama Program</th>
@foreach($kolom as $k)
<th>{{ $k->label }}</th>
@endforeach
<th>Aksi</th>
</tr>
</thead>
<tbody>
@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' => $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>
@empty
<tr>
<td colspan="{{ count($kolom) + 2 }}" class="text-center py-4">Tidak ada data ditemukan.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="card-footer d-flex justify-content-center justify-content-md-end border-top">
{{ $values->appends(request()->query())->links('pagination::bootstrap-5') }}
</div>
</div>
</div>
@endsection
@push('scripts')
<script>
'use strict';
$(document).ready(function () {
$(".delete-record").click(function (e) {
e.preventDefault();
const id = $(this).data('id');
const programId = $(this).data('program-id');
Swal.fire({
title: 'Hapus?',
text: `Data tersebut akan dihapus!`,
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Ya, Hapus!',
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: url,
type: 'POST',
data: {
_token: '{{ csrf_token() }}',
_method: 'DELETE'
},
success: function () {
Swal.fire({ icon: 'success', title: 'Terhapus!', showConfirmButton: false, timer: 1500 })
.then(() => location.reload());
}
});
}
});
});
});
</script>
@endpush