174 lines
6.4 KiB
PHP
174 lines
6.4 KiB
PHP
@extends('admin.template')
|
|
|
|
@section('title', 'Data Sampah Bulanan')
|
|
|
|
@section('content')
|
|
<div class="content-wrapper">
|
|
<div class="row">
|
|
<div class="col-lg-12 grid-margin stretch-card">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<div class="mb-4 d-flex justify-content-between align-items-center">
|
|
|
|
<div>
|
|
<h4 class="mb-1 card-title">Data Sampah Bulanan</h4>
|
|
<p class="mb-0 text-muted">
|
|
Daftar data sampah per bulan
|
|
</p>
|
|
</div>
|
|
|
|
<div class="mb-3 d-flex justify-content-between align-items-center">
|
|
|
|
<form method="GET" action="{{ route('admin.sampah.index') }}" class="w-50">
|
|
|
|
<select name="tahun" class="form-control" onchange="this.form.submit()">
|
|
<option value="">Filter Tahun...</option>
|
|
|
|
@foreach ($listTahun as $thn)
|
|
<option value="{{ $thn }}"
|
|
{{ request('tahun') == $thn ? 'selected' : '' }}>
|
|
{{ $thn }}
|
|
</option>
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
</form>
|
|
|
|
<a href="{{ route('admin.sampah.create') }}" class="btn btn-primary">
|
|
<i class="bi bi-plus-lg"></i> Tambah
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="table-responsive">
|
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
<tr>
|
|
<th>Tahun</th>
|
|
<th>Bulan</th>
|
|
<th>Total Sampah</th>
|
|
<th>Total Kelola</th>
|
|
<th>Total Daur Ulang</th>
|
|
<th>Sisa Sampah</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
@forelse ($sampah as $item)
|
|
<tr>
|
|
|
|
<td>{{ $item->tahun }}</td>
|
|
|
|
<td>
|
|
{{ \Carbon\Carbon::create()->month($item->bulan)->translatedFormat('F') }}
|
|
</td>
|
|
|
|
<td>{{ number_format($item->total_sampah, 2, ',', '.') }} Ton</td>
|
|
<td>{{ number_format($item->total_kelola, 2, ',', '.') }} Ton</td>
|
|
<td>{{ number_format($item->total_daur_ulang, 2, ',', '.') }} Ton</td>
|
|
<td>{{ number_format($item->sisa_sampah, 2, ',', '.') }} Ton</td>
|
|
|
|
<td class="text-center">
|
|
|
|
<a href="{{ route('admin.sampah.edit', $item->id_sampah) }}"
|
|
class="btn btn-warning btn-sm me-1">
|
|
<i class="bi bi-pencil-square"></i>
|
|
</a>
|
|
|
|
<form action="{{ route('admin.sampah.destroy', $item->id_sampah) }}"
|
|
method="POST" class="form-hapus" style="display:inline;">
|
|
|
|
@csrf
|
|
@method('DELETE')
|
|
|
|
<button type="submit" class="btn btn-danger btn-sm">
|
|
<i class="bi bi-trash"></i>
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
@empty
|
|
|
|
<tr>
|
|
<td colspan="7" class="text-center">
|
|
Data sampah belum tersedia
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
document.querySelectorAll('.form-hapus').forEach(form => {
|
|
|
|
form.addEventListener('submit', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
Swal.fire({
|
|
title: 'Hapus Data Sampah?',
|
|
text: 'Data yang sudah dihapus tidak dapat dikembalikan!',
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#d33',
|
|
cancelButtonColor: '#6c757d',
|
|
confirmButtonText: 'Ya, Hapus',
|
|
cancelButtonText: 'Batal',
|
|
didOpen: () => {
|
|
document.querySelector('.swal2-popup').style.fontFamily =
|
|
'Nunito, sans-serif';
|
|
}
|
|
|
|
}).then((result) => {
|
|
|
|
if (result.isConfirmed) {
|
|
form.submit();
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
|
|
@if (session('success'))
|
|
<script>
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Berhasil',
|
|
text: '{{ session('success') }}',
|
|
timer: 2000,
|
|
showConfirmButton: false
|
|
});
|
|
</script>
|
|
@endif
|
|
|
|
@endsection
|