baru lagi
|
|
@ -17,6 +17,7 @@ public function index()
|
||||||
|
|
||||||
$sampah = Sampah::with('user')
|
$sampah = Sampah::with('user')
|
||||||
->orderBy('tahun', 'desc')
|
->orderBy('tahun', 'desc')
|
||||||
|
->orderBy('bulan', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return view('admin.sampah.index', compact('title', 'sampah'));
|
return view('admin.sampah.index', compact('title', 'sampah'));
|
||||||
|
|
@ -30,76 +31,38 @@ public function create()
|
||||||
return view('admin.sampah.create', compact('title', 'users'));
|
return view('admin.sampah.create', compact('title', 'users'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================================
|
|
||||||
STORE (TAMBAH DATA)
|
|
||||||
====================================================== */
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
// ===============================
|
|
||||||
// KONVERSI FORMAT INDONESIA
|
|
||||||
// ===============================
|
|
||||||
$request->merge([
|
$request->merge([
|
||||||
'total_sampah' => $this->convertToDecimal($request->total_sampah),
|
'total_sampah' => $this->convertToDecimal($request->total_sampah),
|
||||||
'total_kelola' => $this->convertToDecimal($request->total_kelola),
|
'total_kelola' => $this->convertToDecimal($request->total_kelola),
|
||||||
'total_daur_ulang' => $this->convertToDecimal($request->total_daur_ulang),
|
'total_daur_ulang' => $this->convertToDecimal($request->total_daur_ulang),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ===============================
|
$validator = Validator::make($request->all(), [
|
||||||
// VALIDASI
|
|
||||||
// ===============================
|
|
||||||
$validator = Validator::make(
|
|
||||||
$request->all(),
|
|
||||||
[
|
|
||||||
'tahun' => 'required|digits:4',
|
'tahun' => 'required|digits:4',
|
||||||
|
'bulan' => 'required|integer|min:1|max:12',
|
||||||
'total_sampah' => 'required|numeric|min:0',
|
'total_sampah' => 'required|numeric|min:0',
|
||||||
'total_kelola' => 'required|numeric|min:0',
|
'total_kelola' => 'required|numeric|min:0',
|
||||||
'total_daur_ulang' => 'required|numeric|min:0',
|
'total_daur_ulang' => 'required|numeric|min:0',
|
||||||
],
|
]);
|
||||||
[
|
|
||||||
'tahun.required' => 'Tahun wajib diisi.',
|
|
||||||
'tahun.digits' => 'Tahun harus 4 digit (contoh: 2024).',
|
|
||||||
|
|
||||||
'total_sampah.required' => 'Total sampah wajib diisi.',
|
|
||||||
'total_sampah.numeric' => 'Total sampah harus berupa angka.',
|
|
||||||
'total_sampah.min' => 'Total sampah tidak boleh negatif.',
|
|
||||||
|
|
||||||
'total_kelola.required' => 'Total kelola wajib diisi.',
|
|
||||||
'total_kelola.numeric' => 'Total kelola harus berupa angka.',
|
|
||||||
'total_kelola.min' => 'Total kelola tidak boleh negatif.',
|
|
||||||
|
|
||||||
'total_daur_ulang.required' => 'Total daur ulang wajib diisi.',
|
|
||||||
'total_daur_ulang.numeric' => 'Total daur ulang harus berupa angka.',
|
|
||||||
'total_daur_ulang.min' => 'Total daur ulang tidak boleh negatif.',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return back()->withErrors($validator)->withInput();
|
return back()->withErrors($validator)->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// VALIDASI LOGIKA
|
|
||||||
// ===============================
|
|
||||||
if (($request->total_kelola + $request->total_daur_ulang) > $request->total_sampah) {
|
if (($request->total_kelola + $request->total_daur_ulang) > $request->total_sampah) {
|
||||||
return back()
|
return back()->withErrors([
|
||||||
->withErrors([
|
'total_kelola' => 'Jumlah kelola + daur ulang tidak boleh melebihi total sampah.'
|
||||||
'total_kelola' => 'Jumlah kelola + daur ulang tidak boleh melebihi total sampah.',
|
])->withInput();
|
||||||
])
|
|
||||||
->withInput();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===============================
|
$sisa_sampah = $request->total_sampah - ($request->total_kelola + $request->total_daur_ulang);
|
||||||
// HITUNG SISA
|
|
||||||
// ===============================
|
|
||||||
$sisa_sampah = $request->total_sampah
|
|
||||||
- ($request->total_kelola + $request->total_daur_ulang);
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// SIMPAN DATA
|
|
||||||
// ===============================
|
|
||||||
Sampah::create([
|
Sampah::create([
|
||||||
'user_id' => Auth::id(),
|
'user_id' => Auth::id(),
|
||||||
'tahun' => $request->tahun,
|
'tahun' => $request->tahun,
|
||||||
|
'bulan' => $request->bulan,
|
||||||
'total_sampah' => $request->total_sampah,
|
'total_sampah' => $request->total_sampah,
|
||||||
'total_kelola' => $request->total_kelola,
|
'total_kelola' => $request->total_kelola,
|
||||||
'total_daur_ulang' => $request->total_daur_ulang,
|
'total_daur_ulang' => $request->total_daur_ulang,
|
||||||
|
|
@ -110,91 +73,48 @@ public function store(Request $request)
|
||||||
->with('success', 'Data sampah berhasil ditambahkan.');
|
->with('success', 'Data sampah berhasil ditambahkan.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================================
|
|
||||||
EDIT
|
|
||||||
====================================================== */
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$title = 'Edit Data Sampah';
|
$title = 'Edit Data Sampah';
|
||||||
$sampah = Sampah::findOrFail($id);
|
$sampah = Sampah::findOrFail($id);
|
||||||
$users = User::all();
|
|
||||||
|
|
||||||
return view('admin.sampah.edit', compact('title', 'sampah', 'users'));
|
return view('admin.sampah.edit', compact('title', 'sampah'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================================
|
|
||||||
UPDATE
|
|
||||||
====================================================== */
|
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
$sampah = Sampah::findOrFail($id);
|
$sampah = Sampah::findOrFail($id);
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// KONVERSI FORMAT INDONESIA
|
|
||||||
// ===============================
|
|
||||||
$request->merge([
|
$request->merge([
|
||||||
'total_sampah' => $this->convertToDecimal($request->total_sampah),
|
'total_sampah' => $this->convertToDecimal($request->total_sampah),
|
||||||
'total_kelola' => $this->convertToDecimal($request->total_kelola),
|
'total_kelola' => $this->convertToDecimal($request->total_kelola),
|
||||||
'total_daur_ulang' => $this->convertToDecimal($request->total_daur_ulang),
|
'total_daur_ulang' => $this->convertToDecimal($request->total_daur_ulang),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ===============================
|
$validator = Validator::make($request->all(), [
|
||||||
// VALIDASI
|
|
||||||
// ===============================
|
|
||||||
$validator = Validator::make(
|
|
||||||
$request->all(),
|
|
||||||
[
|
|
||||||
'user_id' => 'required|exists:users,id',
|
|
||||||
'tahun' => 'required|digits:4',
|
'tahun' => 'required|digits:4',
|
||||||
|
'bulan' => 'required|integer|min:1|max:12',
|
||||||
'total_sampah' => 'required|numeric|min:0',
|
'total_sampah' => 'required|numeric|min:0',
|
||||||
'total_kelola' => 'required|numeric|min:0',
|
'total_kelola' => 'required|numeric|min:0',
|
||||||
'total_daur_ulang' => 'required|numeric|min:0',
|
'total_daur_ulang' => 'required|numeric|min:0',
|
||||||
],
|
]);
|
||||||
[
|
|
||||||
'user_id.required' => 'Pengguna wajib dipilih.',
|
|
||||||
'user_id.exists' => 'Pengguna tidak valid.',
|
|
||||||
|
|
||||||
'tahun.required' => 'Tahun wajib diisi.',
|
|
||||||
'tahun.digits' => 'Tahun harus 4 digit.',
|
|
||||||
|
|
||||||
'total_sampah.required' => 'Total sampah wajib diisi.',
|
|
||||||
'total_sampah.numeric' => 'Total sampah harus berupa angka.',
|
|
||||||
|
|
||||||
'total_kelola.required' => 'Total kelola wajib diisi.',
|
|
||||||
'total_kelola.numeric' => 'Total kelola harus berupa angka.',
|
|
||||||
|
|
||||||
'total_daur_ulang.required' => 'Total daur ulang wajib diisi.',
|
|
||||||
'total_daur_ulang.numeric' => 'Total daur ulang harus berupa angka.',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return back()->withErrors($validator)->withInput();
|
return back()->withErrors($validator)->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// VALIDASI LOGIKA
|
|
||||||
// ===============================
|
|
||||||
if (($request->total_kelola + $request->total_daur_ulang) > $request->total_sampah) {
|
if (($request->total_kelola + $request->total_daur_ulang) > $request->total_sampah) {
|
||||||
return back()
|
return back()->withErrors([
|
||||||
->withErrors([
|
'total_kelola' => 'Jumlah kelola + daur ulang tidak boleh melebihi total sampah.'
|
||||||
'total_kelola' => 'Jumlah kelola + daur ulang tidak boleh melebihi total sampah.',
|
])->withInput();
|
||||||
])
|
|
||||||
->withInput();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===============================
|
$sisa_sampah = $request->total_sampah - ($request->total_kelola + $request->total_daur_ulang);
|
||||||
// HITUNG SISA
|
|
||||||
// ===============================
|
|
||||||
$sisa_sampah = $request->total_sampah
|
|
||||||
- ($request->total_kelola + $request->total_daur_ulang);
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
// UPDATE DATA
|
|
||||||
// ===============================
|
|
||||||
$sampah->update([
|
$sampah->update([
|
||||||
'user_id' => $request->user_id,
|
'user_id' => Auth::id(),
|
||||||
'tahun' => $request->tahun,
|
'tahun' => $request->tahun,
|
||||||
|
'bulan' => $request->bulan,
|
||||||
'total_sampah' => $request->total_sampah,
|
'total_sampah' => $request->total_sampah,
|
||||||
'total_kelola' => $request->total_kelola,
|
'total_kelola' => $request->total_kelola,
|
||||||
'total_daur_ulang' => $request->total_daur_ulang,
|
'total_daur_ulang' => $request->total_daur_ulang,
|
||||||
|
|
@ -214,16 +134,12 @@ public function destroy($id)
|
||||||
->with('success', 'Data sampah berhasil dihapus.');
|
->with('success', 'Data sampah berhasil dihapus.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================================
|
|
||||||
HELPER KONVERSI FORMAT INDONESIA
|
|
||||||
====================================================== */
|
|
||||||
private function convertToDecimal($value)
|
private function convertToDecimal($value)
|
||||||
{
|
{
|
||||||
if (!$value) {
|
if (!$value) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// hapus titik ribuan lalu ubah koma jadi titik
|
|
||||||
return str_replace(',', '.', str_replace('.', '', $value));
|
return str_replace(',', '.', str_replace('.', '', $value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,41 @@ class IndexController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$tahun = date('Y');
|
||||||
|
|
||||||
|
// Ambil data sampah per bulan
|
||||||
|
$dataSampah = Sampah::where('tahun', $tahun)
|
||||||
|
->orderBy('bulan')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$bulan = [];
|
||||||
|
$timbulan = [];
|
||||||
|
$kelola = [];
|
||||||
|
$daur = [];
|
||||||
|
$sisa = [];
|
||||||
|
|
||||||
|
foreach ($dataSampah as $d) {
|
||||||
|
$bulan[] = \Carbon\Carbon::create()->month($d->bulan)->translatedFormat('M');
|
||||||
|
$timbulan[] = $d->total_sampah;
|
||||||
|
$kelola[] = $d->total_kelola;
|
||||||
|
$daur[] = $d->total_daur_ulang;
|
||||||
|
$sisa[] = $d->sisa_sampah;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rekap total satu tahun
|
||||||
|
$rekap = [
|
||||||
|
'timbulan' => array_sum($timbulan),
|
||||||
|
'kelola' => array_sum($kelola),
|
||||||
|
'daur' => array_sum($daur),
|
||||||
|
'sisa' => array_sum($sisa),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Data sampah terbaru untuk card
|
||||||
$sampah = Sampah::orderBy('tahun', 'desc')->first();
|
$sampah = Sampah::orderBy('tahun', 'desc')->first();
|
||||||
|
|
||||||
|
// Data TPS
|
||||||
$kategoriTps = KategoriTps::orderBy('id_kategori_tps')->get();
|
$kategoriTps = KategoriTps::orderBy('id_kategori_tps')->get();
|
||||||
|
$tps = LokasiTps::all();
|
||||||
$tps = LokasiTps::all(); // disamakan dengan yang dipakai di view
|
|
||||||
|
|
||||||
$jumlahTps = LokasiTps::where('kategori_tps_id', 1)->count();
|
$jumlahTps = LokasiTps::where('kategori_tps_id', 1)->count();
|
||||||
$jumlahTps3r = LokasiTps::where('kategori_tps_id', 2)->count();
|
$jumlahTps3r = LokasiTps::where('kategori_tps_id', 2)->count();
|
||||||
|
|
@ -27,7 +57,14 @@ public function index()
|
||||||
'tps',
|
'tps',
|
||||||
'jumlahTps',
|
'jumlahTps',
|
||||||
'jumlahTps3r',
|
'jumlahTps3r',
|
||||||
'jumlahTpa'
|
'jumlahTpa',
|
||||||
|
'bulan',
|
||||||
|
'timbulan',
|
||||||
|
'kelola',
|
||||||
|
'daur',
|
||||||
|
'sisa',
|
||||||
|
'rekap',
|
||||||
|
'tahun'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,13 @@ class Sampah extends Model
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'user_id',
|
'user_id',
|
||||||
'tahun',
|
'tahun',
|
||||||
|
'bulan',
|
||||||
'total_sampah',
|
'total_sampah',
|
||||||
'total_kelola',
|
'total_kelola',
|
||||||
'total_daur_ulang',
|
'total_daur_ulang',
|
||||||
'sisa_sampah',
|
'sisa_sampah',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Relasi ke tabel users
|
|
||||||
* One Sampah belongs to one User
|
|
||||||
*/
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'user_id');
|
return $this->belongsTo(User::class, 'user_id');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('sampah', function (Blueprint $table) {
|
||||||
|
$table->tinyInteger('bulan')->after('tahun');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('sampah', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('bulan');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
After Width: | Height: | Size: 666 KiB |
|
After Width: | Height: | Size: 834 KiB |
|
After Width: | Height: | Size: 858 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 841 KiB |
|
After Width: | Height: | Size: 995 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 969 KiB |
|
After Width: | Height: | Size: 758 KiB |
|
After Width: | Height: | Size: 229 KiB |
|
After Width: | Height: | Size: 206 KiB |
|
After Width: | Height: | Size: 341 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 929 KiB |
|
After Width: | Height: | Size: 747 KiB |
|
After Width: | Height: | Size: 820 KiB |
|
After Width: | Height: | Size: 820 KiB |
|
After Width: | Height: | Size: 694 KiB |
|
After Width: | Height: | Size: 677 KiB |
|
After Width: | Height: | Size: 1016 KiB |
|
After Width: | Height: | Size: 820 KiB |
|
After Width: | Height: | Size: 893 KiB |
|
After Width: | Height: | Size: 263 KiB |
|
|
@ -1,124 +1,207 @@
|
||||||
@extends('admin.template')
|
@extends('admin.template')
|
||||||
|
|
||||||
@section('title', 'Tambah Data Sampah Tahunan')
|
@section('title', 'Tambah Data Sampah Bulanan')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 grid-margin stretch-card">
|
<div class="col-md-12 grid-margin stretch-card">
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">Tambah Data Sampah Tahunan</h4>
|
|
||||||
|
<h4 class="card-title">Tambah Data Sampah Bulanan</h4>
|
||||||
<p class="card-description">
|
<p class="card-description">
|
||||||
Form input data sampah harian per tahun (satuan dalam Ton)
|
Form input data sampah per bulan (satuan Ton)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form action="{{ route('admin.sampah.store') }}" method="POST">
|
<form action="{{ route('admin.sampah.store') }}" method="POST" id="formSampah">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Tahun</label>
|
<label>Tahun</label>
|
||||||
|
|
||||||
<input type="number" name="tahun"
|
<input type="number" name="tahun"
|
||||||
class="form-control @error('tahun') is-invalid @enderror"
|
class="form-control @error('tahun') is-invalid @enderror" value="{{ old('tahun') }}"
|
||||||
value="{{ old('tahun') }}"
|
|
||||||
placeholder="Contoh: 2024">
|
placeholder="Contoh: 2024">
|
||||||
|
|
||||||
@error('tahun')
|
@error('tahun')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Bulan</label>
|
||||||
|
|
||||||
|
<select name="bulan" class="form-control @error('bulan') is-invalid @enderror">
|
||||||
|
<option value="">-- Pilih Bulan --</option>
|
||||||
|
<option value="1">Januari</option>
|
||||||
|
<option value="2">Februari</option>
|
||||||
|
<option value="3">Maret</option>
|
||||||
|
<option value="4">April</option>
|
||||||
|
<option value="5">Mei</option>
|
||||||
|
<option value="6">Juni</option>
|
||||||
|
<option value="7">Juli</option>
|
||||||
|
<option value="8">Agustus</option>
|
||||||
|
<option value="9">September</option>
|
||||||
|
<option value="10">Oktober</option>
|
||||||
|
<option value="11">November</option>
|
||||||
|
<option value="12">Desember</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
@error('bulan')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah</label>
|
<label>Total Sampah</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" step="0.01" name="total_sampah"
|
<input type="text" name="total_sampah" id="total_sampah"
|
||||||
id="total_sampah"
|
class="form-control angka @error('total_sampah') is-invalid @enderror"
|
||||||
class="form-control @error('total_sampah') is-invalid @enderror"
|
value="{{ old('total_sampah') }}" placeholder="Contoh: 7.500,89">
|
||||||
value="{{ old('total_sampah') }}"
|
|
||||||
placeholder="Total sampah dihasilkan">
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@error('total_sampah')
|
@error('total_sampah')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah Dikelola</label>
|
<label>Total Sampah Dikelola</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" step="0.01" name="total_kelola"
|
<input type="text" name="total_kelola" id="total_kelola"
|
||||||
id="total_kelola"
|
class="form-control angka @error('total_kelola') is-invalid @enderror"
|
||||||
class="form-control @error('total_kelola') is-invalid @enderror"
|
value="{{ old('total_kelola') }}" placeholder="Contoh: 2.500,50">
|
||||||
value="{{ old('total_kelola') }}"
|
|
||||||
placeholder="Total sampah yang dikelola">
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@error('total_kelola')
|
@error('total_kelola')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah Daur Ulang</label>
|
<label>Total Sampah Daur Ulang</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" step="0.01" name="total_daur_ulang"
|
<input type="text" name="total_daur_ulang" id="total_daur_ulang"
|
||||||
id="total_daur_ulang"
|
class="form-control angka @error('total_daur_ulang') is-invalid @enderror"
|
||||||
class="form-control @error('total_daur_ulang') is-invalid @enderror"
|
value="{{ old('total_daur_ulang') }}" placeholder="Contoh: 1.200,25">
|
||||||
value="{{ old('total_daur_ulang') }}"
|
|
||||||
placeholder="Total sampah yang didaur ulang">
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@error('total_daur_ulang')
|
@error('total_daur_ulang')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Sisa Sampah</label>
|
<label>Sisa Sampah</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" step="0.01" name="sisa_sampah"
|
<input type="text" id="sisa_sampah" class="form-control" readonly>
|
||||||
id="sisa_sampah"
|
|
||||||
class="form-control" readonly>
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
Sisa sampah dihitung otomatis
|
Sisa sampah dihitung otomatis
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<button type="submit" class="mr-2 btn btn-primary">
|
<button type="submit" class="mr-2 btn btn-primary">
|
||||||
Simpan
|
Simpan
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a href="{{ route('admin.sampah.index') }}" class="btn btn-light">
|
<a href="{{ route('admin.sampah.index') }}" class="btn btn-light">
|
||||||
Batal
|
Batal
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function hitungSisa() {
|
function formatRupiah(angka) {
|
||||||
let total = parseFloat(document.getElementById('total_sampah').value) || 0;
|
|
||||||
let kelola = parseFloat(document.getElementById('total_kelola').value) || 0;
|
|
||||||
let daur = parseFloat(document.getElementById('total_daur_ulang').value) || 0;
|
|
||||||
|
|
||||||
let sisa = total - (kelola + daur);
|
angka = angka.replace(/[^,\d]/g, '');
|
||||||
document.getElementById('sisa_sampah').value = sisa >= 0 ? sisa : 0;
|
|
||||||
|
let split = angka.split(',');
|
||||||
|
let sisa = split[0].length % 3;
|
||||||
|
let rupiah = split[0].substr(0, sisa);
|
||||||
|
|
||||||
|
let ribuan = split[0].substr(sisa).match(/\d{3}/gi);
|
||||||
|
|
||||||
|
if (ribuan) {
|
||||||
|
let separator = sisa ? '.' : '';
|
||||||
|
rupiah += separator + ribuan.join('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('total_sampah').addEventListener('input', hitungSisa);
|
rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
|
||||||
document.getElementById('total_kelola').addEventListener('input', hitungSisa);
|
|
||||||
document.getElementById('total_daur_ulang').addEventListener('input', hitungSisa);
|
return rupiah;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toNumber(angka) {
|
||||||
|
|
||||||
|
return parseFloat(
|
||||||
|
angka.replace(/\./g, '').replace(',', '.')
|
||||||
|
) || 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function hitungSisa() {
|
||||||
|
|
||||||
|
let total = toNumber(document.getElementById('total_sampah').value);
|
||||||
|
let kelola = toNumber(document.getElementById('total_kelola').value);
|
||||||
|
let daur = toNumber(document.getElementById('total_daur_ulang').value);
|
||||||
|
|
||||||
|
let sisa = total - (kelola + daur);
|
||||||
|
|
||||||
|
document.getElementById('sisa_sampah').value =
|
||||||
|
formatRupiah(sisa.toFixed(2).replace('.', ','));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll('.angka').forEach(function(input) {
|
||||||
|
|
||||||
|
input.addEventListener('keyup', function() {
|
||||||
|
|
||||||
|
this.value = formatRupiah(this.value);
|
||||||
|
|
||||||
|
hitungSisa();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
@extends('admin.template')
|
@extends('admin.template')
|
||||||
|
|
||||||
@section('title', 'Edit Data Sampah Tahunan')
|
@section('title', 'Edit Data Sampah Bulanan')
|
||||||
|
|
||||||
@endsection
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 grid-margin stretch-card">
|
<div class="col-md-12 grid-margin stretch-card">
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="card-title">Edit Data Sampah Tahunan</h4>
|
|
||||||
|
<h4 class="card-title">Edit Data Sampah Bulanan</h4>
|
||||||
<p class="card-description">
|
<p class="card-description">
|
||||||
Form edit data sampah harian per tahun (satuan Ton)
|
Form edit data sampah per bulan (satuan Ton)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form action="{{ route('admin.sampah.update', $sampah->id_sampah) }}" method="POST">
|
<form action="{{ route('admin.sampah.update', $sampah->id_sampah) }}" method="POST">
|
||||||
|
|
@ -21,86 +21,227 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Tahun</label>
|
<label>Tahun</label>
|
||||||
|
|
||||||
<input type="number" name="tahun"
|
<input type="number" name="tahun"
|
||||||
class="form-control @error('tahun') is-invalid @enderror"
|
class="form-control @error('tahun') is-invalid @enderror"
|
||||||
value="{{ old('tahun', $sampah->tahun) }}">
|
value="{{ old('tahun', $sampah->tahun) }}">
|
||||||
|
|
||||||
@error('tahun')
|
@error('tahun')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Bulan</label>
|
||||||
|
|
||||||
|
<select name="bulan" class="form-control @error('bulan') is-invalid @enderror">
|
||||||
|
|
||||||
|
<option value="">-- Pilih Bulan --</option>
|
||||||
|
|
||||||
|
<option value="1" {{ old('bulan', $sampah->bulan) == 1 ? 'selected' : '' }}>Januari
|
||||||
|
</option>
|
||||||
|
<option value="2" {{ old('bulan', $sampah->bulan) == 2 ? 'selected' : '' }}>
|
||||||
|
Februari</option>
|
||||||
|
<option value="3" {{ old('bulan', $sampah->bulan) == 3 ? 'selected' : '' }}>Maret
|
||||||
|
</option>
|
||||||
|
<option value="4" {{ old('bulan', $sampah->bulan) == 4 ? 'selected' : '' }}>April
|
||||||
|
</option>
|
||||||
|
<option value="5" {{ old('bulan', $sampah->bulan) == 5 ? 'selected' : '' }}>Mei
|
||||||
|
</option>
|
||||||
|
<option value="6" {{ old('bulan', $sampah->bulan) == 6 ? 'selected' : '' }}>Juni
|
||||||
|
</option>
|
||||||
|
<option value="7" {{ old('bulan', $sampah->bulan) == 7 ? 'selected' : '' }}>Juli
|
||||||
|
</option>
|
||||||
|
<option value="8" {{ old('bulan', $sampah->bulan) == 8 ? 'selected' : '' }}>
|
||||||
|
Agustus</option>
|
||||||
|
<option value="9" {{ old('bulan', $sampah->bulan) == 9 ? 'selected' : '' }}>
|
||||||
|
September</option>
|
||||||
|
<option value="10" {{ old('bulan', $sampah->bulan) == 10 ? 'selected' : '' }}>
|
||||||
|
Oktober</option>
|
||||||
|
<option value="11" {{ old('bulan', $sampah->bulan) == 11 ? 'selected' : '' }}>
|
||||||
|
November</option>
|
||||||
|
<option value="12" {{ old('bulan', $sampah->bulan) == 12 ? 'selected' : '' }}>
|
||||||
|
Desember</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
@error('bulan')
|
||||||
|
<small class="text-danger">{{ $message }}</small>
|
||||||
|
@enderror
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah</label>
|
<label>Total Sampah</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_sampah"
|
|
||||||
class="form-control @error('total_sampah') is-invalid @enderror"
|
<input type="text" name="total_sampah" id="total_sampah"
|
||||||
value="{{ old('total_sampah', $sampah->total_sampah) }}">
|
class="form-control angka @error('total_sampah') is-invalid @enderror"
|
||||||
|
value="{{ number_format($sampah->total_sampah, 2, ',', '.') }}">
|
||||||
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@error('total_sampah')
|
@error('total_sampah')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah Dikelola</label>
|
<label>Total Sampah Dikelola</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_kelola"
|
|
||||||
class="form-control @error('total_kelola') is-invalid @enderror"
|
<input type="text" name="total_kelola" id="total_kelola"
|
||||||
value="{{ old('total_kelola', $sampah->total_kelola) }}">
|
class="form-control angka @error('total_kelola') is-invalid @enderror"
|
||||||
|
value="{{ number_format($sampah->total_kelola, 2, ',', '.') }}">
|
||||||
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@error('total_kelola')
|
@error('total_kelola')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Total Sampah Daur Ulang</label>
|
<label>Total Sampah Daur Ulang</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01" name="total_daur_ulang"
|
|
||||||
class="form-control @error('total_daur_ulang') is-invalid @enderror"
|
<input type="text" name="total_daur_ulang" id="total_daur_ulang"
|
||||||
value="{{ old('total_daur_ulang', $sampah->total_daur_ulang) }}">
|
class="form-control angka @error('total_daur_ulang') is-invalid @enderror"
|
||||||
|
value="{{ number_format($sampah->total_daur_ulang, 2, ',', '.') }}">
|
||||||
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@error('total_daur_ulang')
|
@error('total_daur_ulang')
|
||||||
<small class="text-danger">{{ $message }}</small>
|
<small class="text-danger">{{ $message }}</small>
|
||||||
@enderror
|
@enderror
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Sisa Sampah</label>
|
<label>Sisa Sampah</label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="number" step="0.01"
|
|
||||||
class="form-control"
|
<input type="text" id="sisa_sampah" class="form-control"
|
||||||
value="{{ $sampah->sisa_sampah }}"
|
value="{{ number_format($sampah->sisa_sampah, 2, ',', '.') }}" readonly>
|
||||||
readonly>
|
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text">Ton</span>
|
<span class="input-group-text">Ton</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
Sisa sampah dihitung otomatis oleh sistem
|
Sisa sampah dihitung otomatis
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<button type="submit" class="mr-2 btn btn-primary">
|
<button type="submit" class="mr-2 btn btn-primary">
|
||||||
Simpan
|
Simpan
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a href="{{ route('admin.sampah.index') }}" class="btn btn-light">
|
<a href="{{ route('admin.sampah.index') }}" class="btn btn-light">
|
||||||
Batal
|
Batal
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function formatAngka(angka) {
|
||||||
|
|
||||||
|
angka = angka.replace(/[^,\d]/g, '');
|
||||||
|
|
||||||
|
let split = angka.split(',');
|
||||||
|
let sisa = split[0].length % 3;
|
||||||
|
|
||||||
|
let rupiah = split[0].substr(0, sisa);
|
||||||
|
|
||||||
|
let ribuan = split[0].substr(sisa).match(/\d{3}/gi);
|
||||||
|
|
||||||
|
if (ribuan) {
|
||||||
|
|
||||||
|
let separator = sisa ? '.' : '';
|
||||||
|
|
||||||
|
rupiah += separator + ribuan.join('.');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
rupiah = split[1] != undefined ? rupiah + ',' + split[1] : rupiah;
|
||||||
|
|
||||||
|
return rupiah;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function toNumber(angka) {
|
||||||
|
|
||||||
|
return parseFloat(
|
||||||
|
angka.replace(/\./g, '').replace(',', '.')
|
||||||
|
) || 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function hitungSisa() {
|
||||||
|
|
||||||
|
let total = toNumber(document.getElementById('total_sampah').value);
|
||||||
|
|
||||||
|
let kelola = toNumber(document.getElementById('total_kelola').value);
|
||||||
|
|
||||||
|
let daur = toNumber(document.getElementById('total_daur_ulang').value);
|
||||||
|
|
||||||
|
let sisa = total - (kelola + daur);
|
||||||
|
|
||||||
|
document.getElementById('sisa_sampah').value =
|
||||||
|
formatAngka(sisa.toFixed(2).replace('.', ','));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
document.querySelectorAll('.angka').forEach(function(input) {
|
||||||
|
|
||||||
|
input.addEventListener('keyup', function() {
|
||||||
|
|
||||||
|
this.value = formatAngka(this.value);
|
||||||
|
|
||||||
|
hitungSisa();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,21 @@
|
||||||
@extends('admin.template')
|
@extends('admin.template')
|
||||||
|
|
||||||
@section('title', 'Data Sampah Tahunan')
|
@section('title', 'Data Sampah Bulanan')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="content-wrapper">
|
<div class="content-wrapper">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 grid-margin stretch-card">
|
<div class="col-lg-12 grid-margin stretch-card">
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<div class="mb-3 d-flex justify-content-between align-items-center">
|
<div class="mb-3 d-flex justify-content-between align-items-center">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h4 class="mb-0 card-title">Data Sampah</h4>
|
<h4 class="mb-0 card-title">Data Sampah Bulanan</h4>
|
||||||
<p class="mb-0 card-description">
|
<p class="mb-0 card-description">
|
||||||
Daftar sampah harian per tahun
|
Daftar data sampah per bulan
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -21,15 +23,16 @@
|
||||||
<i class="bi bi-plus-lg"></i> Tambah
|
<i class="bi bi-plus-lg"></i> Tambah
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tabel -->
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Tahun</th>
|
<th>Tahun</th>
|
||||||
|
<th>Bulan</th>
|
||||||
<th>Total Sampah</th>
|
<th>Total Sampah</th>
|
||||||
<th>Total Kelola</th>
|
<th>Total Kelola</th>
|
||||||
<th>Total Daur Ulang</th>
|
<th>Total Daur Ulang</th>
|
||||||
|
|
@ -37,51 +40,74 @@
|
||||||
<th>Aksi</th>
|
<th>Aksi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
@forelse ($sampah as $item)
|
@forelse ($sampah as $item)
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td>{{ $item->tahun }}</td>
|
<td>{{ $item->tahun }}</td>
|
||||||
<td>{{ $item->total_sampah }}</td>
|
|
||||||
<td>{{ $item->total_kelola }}</td>
|
<td>
|
||||||
<td>{{ $item->total_daur_ulang }}</td>
|
{{ \Carbon\Carbon::create()->month($item->bulan)->translatedFormat('F') }}
|
||||||
<td>{{ $item->sisa_sampah }}</td>
|
</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">
|
<td class="text-center">
|
||||||
|
|
||||||
<a href="{{ route('admin.sampah.edit', $item->id_sampah) }}"
|
<a href="{{ route('admin.sampah.edit', $item->id_sampah) }}"
|
||||||
class="btn btn-warning btn-sm me-1">
|
class="btn btn-warning btn-sm me-1">
|
||||||
<i class="bi bi-pencil-square"></i>
|
<i class="bi bi-pencil-square"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<form action="{{ route('admin.sampah.destroy', $item->id_sampah) }}" method="POST"
|
<form action="{{ route('admin.sampah.destroy', $item->id_sampah) }}"
|
||||||
class="form-hapus" style="display:inline;">
|
method="POST" class="form-hapus" style="display:inline;">
|
||||||
|
|
||||||
@csrf
|
@csrf
|
||||||
@method('DELETE')
|
@method('DELETE')
|
||||||
|
|
||||||
<button type="submit" class="btn btn-danger btn-sm">
|
<button type="submit" class="btn btn-danger btn-sm">
|
||||||
<i class="bi bi-trash"></i>
|
<i class="bi bi-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@empty
|
@empty
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-center">
|
<td colspan="7" class="text-center">
|
||||||
Data sampah belum tersedia
|
Data sampah belum tersedia
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforelse
|
@endforelse
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>
|
<script>
|
||||||
document.querySelectorAll('.form-hapus').forEach(form => {
|
document.querySelectorAll('.form-hapus').forEach(form => {
|
||||||
|
|
||||||
form.addEventListener('submit', function(e) {
|
form.addEventListener('submit', function(e) {
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
|
|
@ -97,12 +123,17 @@ class="form-hapus" style="display:inline;">
|
||||||
document.querySelector('.swal2-popup').style.fontFamily =
|
document.querySelector('.swal2-popup').style.fontFamily =
|
||||||
'Nunito, sans-serif';
|
'Nunito, sans-serif';
|
||||||
}
|
}
|
||||||
|
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
|
|
||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -118,4 +149,5 @@ class="form-hapus" style="display:inline;">
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
||||||
|
|
@ -10,82 +10,101 @@
|
||||||
<h1>Selamat Datang di <span>SIG TPS</span></h1>
|
<h1>Selamat Datang di <span>SIG TPS</span></h1>
|
||||||
<p>Sistem Informasi Geografis Pemetaan Tempat Pembuangan Sampah di Kabupaten Nganjuk</p>
|
<p>Sistem Informasi Geografis Pemetaan Tempat Pembuangan Sampah di Kabupaten Nganjuk</p>
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<a href="{{ route('user.sig-tps') }}" class="btn-get-started scrollto">Lihat Peta</a>
|
<a href="#sebaranTPS" class="btn-get-started scrollto">Lihat Peta</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section><!-- /Hero Section -->
|
</section><!-- /Hero Section -->
|
||||||
|
|
||||||
<!-- Featured Services Section -->
|
<section id="grafik-sampah" class="section">
|
||||||
<section id="featured-services" class="featured-services section">
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<div class="container section-title" data-aos="fade-up">
|
<div class="section-title">
|
||||||
<h2>Sampah</h2>
|
<h2>Dashboard Sampah {{ $tahun }}</h2>
|
||||||
<p>Total sampah yang terkumpul di seluruh wilayah Kabupaten Nganjuk pada tahun
|
<p>Statistik pengelolaan sampah Kabupaten Nganjuk</p>
|
||||||
{{ $sampah->tahun ?? 'Tahun Tidak Tersedia' }}</p>
|
|
||||||
</div><!-- End Section Title -->
|
|
||||||
|
|
||||||
<div class="row gy-4">
|
|
||||||
|
|
||||||
<!-- Total Timbulan Sampah -->
|
|
||||||
<div class="col-xl-3 col-md-6 d-flex" data-aos="fade-up" data-aos-delay="100">
|
|
||||||
<div class="text-center service-item position-relative">
|
|
||||||
<div class="icon">
|
|
||||||
<i class="bi bi-trash2 icon"></i>
|
|
||||||
</div>
|
|
||||||
<h2>
|
|
||||||
{{ number_format($sampah->total_sampah ?? 0, 2, ',', '.') }}
|
|
||||||
</h2>
|
|
||||||
<p>Total Timbulan Sampah (ton)</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Total Sampah Dikelola -->
|
<!-- Rekap Tahunan -->
|
||||||
<div class="col-xl-3 col-md-6 d-flex" data-aos="fade-up" data-aos-delay="200">
|
<div class="mb-4 text-center row">
|
||||||
<div class="text-center service-item position-relative">
|
|
||||||
<div class="icon">
|
<div class="col-md-3">
|
||||||
<i class="bi bi-gear icon"></i>
|
<h4>{{ number_format($rekap['timbulan'], 0, ',', '.') }}</h4>
|
||||||
</div>
|
<p>Total Timbulan</p>
|
||||||
<h2>
|
|
||||||
{{ number_format($sampah->total_kelola ?? 0, 2, ',', '.') }}
|
|
||||||
</h2>
|
|
||||||
<p>Total Sampah Dikelola (ton)</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Total Sampah Didaur Ulang -->
|
<div class="col-md-3">
|
||||||
<div class="col-xl-3 col-md-6 d-flex" data-aos="fade-up" data-aos-delay="300">
|
<h4>{{ number_format($rekap['kelola'], 0, ',', '.') }}</h4>
|
||||||
<div class="text-center service-item position-relative">
|
<p>Total Dikelola</p>
|
||||||
<div class="icon">
|
|
||||||
<i class="bi bi-recycle icon"></i>
|
|
||||||
</div>
|
|
||||||
<h2>
|
|
||||||
{{ number_format($sampah->total_daur_ulang ?? 0, 2, ',', '.') }}
|
|
||||||
</h2>
|
|
||||||
<p>Total Sampah Didaur Ulang (ton)</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Total Sisa Sampah -->
|
<div class="col-md-3">
|
||||||
<div class="col-xl-3 col-md-6 d-flex" data-aos="fade-up" data-aos-delay="400">
|
<h4>{{ number_format($rekap['daur'], 0, ',', '.') }}</h4>
|
||||||
<div class="text-center service-item position-relative">
|
<p>Total Daur Ulang</p>
|
||||||
<div class="icon">
|
|
||||||
<i class="bi bi-exclamation-triangle icon"></i>
|
|
||||||
</div>
|
|
||||||
<h2>
|
|
||||||
{{ number_format($sampah->sisa_sampah ?? 0, 2, ',', '.') }}
|
|
||||||
</h2>
|
|
||||||
<p>Total Sisa Sampah (ton)</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<h4>{{ number_format($rekap['sisa'], 0, ',', '.') }}</h4>
|
||||||
|
<p>Total Sisa</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Grafik -->
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="text-center col-md-8">
|
||||||
|
<canvas id="grafikSampah"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<!-- /Featured Services Section -->
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const ctx = document.getElementById('grafikSampah');
|
||||||
|
|
||||||
|
new Chart(ctx, {
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
labels: @json($bulan),
|
||||||
|
datasets: [{
|
||||||
|
label: 'Timbulan Sampah',
|
||||||
|
data: @json($timbulan),
|
||||||
|
backgroundColor: '#dc3545'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Sampah Dikelola',
|
||||||
|
data: @json($kelola),
|
||||||
|
backgroundColor: '#0d6efd'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Daur Ulang',
|
||||||
|
data: @json($daur),
|
||||||
|
backgroundColor: '#198754'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Sisa Sampah',
|
||||||
|
data: @json($sisa),
|
||||||
|
backgroundColor: '#ffc107'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
responsive: true,
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
position: 'top'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
beginAtZero: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<!-- About Section -->
|
<!-- About Section -->
|
||||||
|
|
@ -235,7 +254,12 @@ class="stretched-link">
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<section class="section">
|
<section class="section" id="sebaranTPS">
|
||||||
|
<!-- Section Title -->
|
||||||
|
<div class="container section-title" data-aos="fade-up">
|
||||||
|
<h2>Peta Sebaran TPS</h2>
|
||||||
|
<p>Peta interaktif yang menampilkan sebaran Tempat Pembuangan Sampah di Kabupaten Nganjuk.</p>
|
||||||
|
</div><!-- End Section Title -->
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="map-wrapper">
|
<div class="map-wrapper">
|
||||||
<div class="map-action">
|
<div class="map-action">
|
||||||
|
|
|
||||||