diff --git a/app/Http/Controllers/SampahBelumTerkelolaController.php b/app/Http/Controllers/SampahBelumTerkelolaController.php new file mode 100644 index 0000000..c81a31a --- /dev/null +++ b/app/Http/Controllers/SampahBelumTerkelolaController.php @@ -0,0 +1,178 @@ +title; + $data['route'] = $this->route; + return view($this->template.'.index', $data); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + // + } + + public function grid(Request $request) + { + if(session('group_alias') == 'sekolah'){ + $data = SampahBelumTerkelola::where('ms_sekolah_id',session('sekolah_id')) + ->orderBy('tahun','DESC') + ->orderBy('bulan','ASC'); + }else{ + if(session('kabupaten_id') != ''){ + $data = SampahBelumTerkelola::whereHas('sekolah',function($query){ + $query->where('ms_kabupaten_id',session('kabupaten_id')); + })->orderBy('tahun','DESC') + ->orderBy('bulan','ASC'); + + }else{ + $data = SampahBelumTerkelola::with(['sekolah'])->orderBy('tahun','DESC') + ->orderBy('bulan','ASC'); + } + } + + if(@request()->tahun){ + $tahun = request()->tahun; + }else{ + $tahun = date('Y'); + } + + $data->where('tahun',$tahun); + + + $_data = []; + + + + foreach ($data->get() as $key => $row) { + + $action = ''; + $action .= 'Edit'; + + + $sekolah = ''; + $sekolah .= @$row->sekolah->nama_sekolah.'
'; + $sekolah .= '
'; + $sekolah .= ''.@$row->sekolah->npsn.' '; + $sekolah .= ''.@$row->sekolah->kabupaten->name.' '; + $sekolah .= ''.@$row->sekolah->kecamatan->name.' '; + $sekolah .= '
'; + $sekolah .= 'Level '.levelAdiwiyata($row->sekolah->npsn).''; + // $sekolah .= ''.@$row->sekolah->profile->alamat_sekolah.' '; + + $_data[] = [ + 'no' => $key+1, + 'action' => $action, + 'id' => encode_id($row->SampahBelumTekelolaId), + 'tahun' => $row->tahun, + 'sekolah' => $sekolah, + 'bulan' => monthtString($row->bulan), + 'organik' => $row->organik, + 'mitra' => $row->mitra, + 'sampah_anorganik' => $row->sampah_anorganik, + 'b3' => $row->b3, + 'residu' => $row->residu, + ]; + + } + + // return response()->json($_data); // Return the data as a JSON response + return response()->json($_data); + + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + try { + if(@$request->secure_id){ + $data = SampahBelumTerkelola::find(decode_id($request->secure_id)); + $data->organik = $request->organik; + $data->sampah_anorganik = $request->anorganik; + $data->b3 = $request->b3; + $data->residu = $request->residu; + $data->save(); + }else{ + $data = SampahBelumTerkelola::updateOrCreate([ + 'tahun' => date('Y'), + 'bulan' => $request->bulan, + 'ms_sekolah_id' => session('sekolah_id'), + ],[ + 'tahun' => date('Y'), + 'ms_sekolah_id' => session('sekolah_id'), + 'bulan' => $request->bulan, + 'organik' => $request->organik, + 'sampah_anorganik' => $request->anorganik, + 'b3' => $request->b3, + 'residu' => $request->residu, + ]); + } + + return redirect()->back()->with([ + 'message' => 'Berhasil update data', + 'type' => 'success', + ]); + } catch (\Throwable $th) { + //throw $th; + + dd($th); + } + + + + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + $data['title'] = $this->title; + $data['route'] = $this->route; + $data['item'] = SampahBelumTerkelola::find(decode_id($id)); + return view($this->template.'.form', $data); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Models/SampahBelumTerkelola.php b/app/Models/SampahBelumTerkelola.php new file mode 100644 index 0000000..df56695 --- /dev/null +++ b/app/Models/SampahBelumTerkelola.php @@ -0,0 +1,20 @@ +belongsTo(\App\Models\Master\Sekolah::class,'ms_sekolah_id','MsSekolahId'); + } +} diff --git a/database/migrations/2026_05_07_093549_create_table_sampah_belum_terkelola.php b/database/migrations/2026_05_07_093549_create_table_sampah_belum_terkelola.php new file mode 100644 index 0000000..25eb5c4 --- /dev/null +++ b/database/migrations/2026_05_07_093549_create_table_sampah_belum_terkelola.php @@ -0,0 +1,41 @@ +id('SampahBelumTerkelolaId'); + $table->integer('ms_sekolah_id'); + $table->year('tahun'); + $table->integer('bulan'); + $table->string('organik'); + $table->string('sampah_anorganik'); + $table->string('b3'); + $table->string('residu'); + $table->timestampsTz(); + $table->softdeletesTz(); + + $table->foreign('ms_sekolah_id')->references('MsSekolahId')->on('ms_sekolah')->onDelete('cascade'); + }); + + Schema::table('sampah_terkelola', function (Blueprint $table) { + $table->string('residu')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('table_sampah_belum_terkelola'); + } +}; diff --git a/resources/views/modules/sampah-belum/form.blade.php b/resources/views/modules/sampah-belum/form.blade.php new file mode 100644 index 0000000..5981b5c --- /dev/null +++ b/resources/views/modules/sampah-belum/form.blade.php @@ -0,0 +1,149 @@ +@extends('layouts.master') + +@section('page-css') + +@endsection +@section('content') +
+
+
+
+ {{ csrf_field() }} + +
+
Form Edit Sampah Terkelola
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ + @error('bulan') + {{$message}} + @enderror +
+
+
+ +
+
+ +
+
+ +
+ +
+
+ @error('organik') + {{$message}} + @enderror +
+
+
+
+
+ +
+
+ +
+ +
+
+ @error('anorganik') + {{$message}} + @enderror +
+
+
+
+
+ +
+
+ +
+ +
+
+ @error('b3') + {{$message}} + @enderror +
+
+
+ +
+
+ +
+ + @error('mitra') + {{$message}} + @enderror +
+
+
+
+
+ +
+
+ +
+ +
+
+ @error('minyak_jelantah') + {{$message}} + @enderror +
+
+
+ +
+
+ +
+
+
+
+@endsection +@section('page-js') + +@endsection \ No newline at end of file diff --git a/resources/views/modules/sampah-belum/index.blade.php b/resources/views/modules/sampah-belum/index.blade.php new file mode 100644 index 0000000..522ea68 --- /dev/null +++ b/resources/views/modules/sampah-belum/index.blade.php @@ -0,0 +1,420 @@ +@extends('layouts.master') +@section('page-css') + + +@endsection +@section('content') +
+

+ {{$title}} +

+
+
+
+
+
+
+
+
+ Filter : +
+
+ +
+ {{--  Filter --}} + @if(session('group_alias') == 'sekolah') + + @endif +
+ + + + {{-- --}} + + @if(session('group_alias') == 'sekolah') + + @endif + @if(session('group_alias') != 'sekolah') + + @endif + {{-- --}} + + + + + + + + + +
#No#SekolahMitraTahunBulanOrganik (Kg)An Organik (Kg)B3 (Kg)Residu (Kg)
+ +
+
+
+
+
+ + +@endsection +@section('page-js') + + + +@endsection \ No newline at end of file diff --git a/resources/views/modules/sampah/index.blade.php b/resources/views/modules/sampah/index.blade.php index 9b5767d..57ad4c4 100644 --- a/resources/views/modules/sampah/index.blade.php +++ b/resources/views/modules/sampah/index.blade.php @@ -62,6 +62,7 @@ Organik (Kg) An Organik (Kg) B3 (Kg) + Residu (Kg) Minyak Jelantah (Liter) @@ -120,7 +121,7 @@ -
+
@@ -136,7 +137,7 @@
-
+
@@ -152,7 +153,7 @@
-
+
@@ -168,6 +169,22 @@
+
+
+ +
+
+ +
+ +
+
+ @error('residu') + {{$message}} + @enderror +
+
+
diff --git a/routes/modules/modules.php b/routes/modules/modules.php index f39a7c6..2c044fa 100644 --- a/routes/modules/modules.php +++ b/routes/modules/modules.php @@ -7,6 +7,7 @@ use App\Http\Controllers\AjaxController; use App\Http\Controllers\ProfileController; use App\Http\Controllers\KuesionerController; use App\Http\Controllers\SampahController; +use App\Http\Controllers\SampahBelumTerkelolaController; use App\Http\Controllers\Master\IndikatorController; use App\Http\Controllers\Master\KomponenController; use App\Http\Controllers\Master\FormKriteriaController; @@ -88,6 +89,12 @@ Route::name('sampah.')->prefix('sampah')->group(function () { Route::get('/grid',[SampahController::class,'grid'])->name('grid'); }); + Route::name('sampah-belum.')->prefix('sampah-belum-terkelola')->group(function () { + Route::resource('/',SampahBelumTerkelolaController::class); + Route::get('/update/{id}',[SampahBelumTerkelolaController::class,'update'])->name('update'); + Route::get('/grid',[SampahBelumTerkelolaController::class,'grid'])->name('grid'); + }); + Route::name('usulan.')->prefix('usulan')->group(function () { Route::name('csak.')->prefix('csak')->group(function () {