From 5aa9413e63363d8b171edf3a96819f71c03a8d89 Mon Sep 17 00:00:00 2001 From: Ilham Wara Nugroho Date: Thu, 8 Jan 2026 11:52:56 +0700 Subject: [PATCH] update --- .../Activity/FormKehutananController.php | 2 +- .../Activity/LivestockManureController.php | 112 +++++++++--------- .../modules/form/index-kehutanan.blade.php | 96 +++++++-------- .../form/livestock-manure/create.blade.php | 33 +----- .../form/livestock-manure/edit.blade.php | 20 +--- .../form/livestock-manure/index.blade.php | 96 ++++----------- resources/views/modules/form/table.blade.php | 2 +- routes/modules/modules.php | 7 +- 8 files changed, 133 insertions(+), 235 deletions(-) diff --git a/app/Http/Controllers/Activity/FormKehutananController.php b/app/Http/Controllers/Activity/FormKehutananController.php index 147e27d..4b9d4cd 100644 --- a/app/Http/Controllers/Activity/FormKehutananController.php +++ b/app/Http/Controllers/Activity/FormKehutananController.php @@ -139,7 +139,7 @@ class FormKehutananController implements HasMiddleware // Retrieve data $data = $this->data($sector, $code, $inventoryYear, $instansi); - return view('form.index-kehutanan', $data); + return view('modules.form.index-kehutanan', $data); } public function import(Request $request, $inventoryYear, $instansi = null) diff --git a/app/Http/Controllers/Activity/LivestockManureController.php b/app/Http/Controllers/Activity/LivestockManureController.php index a8369a2..a1c39f0 100644 --- a/app/Http/Controllers/Activity/LivestockManureController.php +++ b/app/Http/Controllers/Activity/LivestockManureController.php @@ -13,6 +13,9 @@ use Illuminate\Routing\Controllers\Middleware; class LivestockManureController implements HasMiddleware { + protected $title = 'Jenis Pengelolaan Kotoran Ternak'; + protected $template = 'modules.form.livestock-manure'; + protected $route = 'modules.pertanian.kotoran-ternak'; protected $service; public function __construct(LivestockManureService $service) @@ -26,69 +29,62 @@ class LivestockManureController implements HasMiddleware //new Middleware('permission:/agriculture/kotoran_ternak'), ]; } - - public function index(Request $request) + public function grid() { - if ($request->ajax()) { - $data = $this->service->getAll(); + $_data = []; + $data = $this->service->getAll(); - $result = datatables()::of($data) - ->addColumn('no_baris', function ($lm) { - return $lm->row_num; - }) - ->addColumn('status', function ($lm) { - if ($lm->active_status == 1) { - return 'Aktif'; - } else { - return 'Tidak Aktif'; - } - }) - ->editColumn('ef_direct_n2o_n', function ($lm) { - if ($lm->ef_direct_n2o_n === 0) { - return 0; // Show 0 as is - } + foreach ($data as $key => $row) { - $output = getFormattedValue($lm->ef_direct_n2o_n, 2); - return $output; - }) - ->editColumn('ef_evaporation_n', function ($lm) { - if ($lm->ef_evaporation_n === 0) { - return 0; // Show 0 as is - } + $btn = 'Edit'; + $btn .= '
'; + $btn .= csrf_field(); + $btn .= method_field('DELETE'); + $btn .= ''; + $btn .= '
'; - $output = getFormattedValue($lm->ef_evaporation_n); - return $output; - }) - ->addColumn('action', function ($lm) { - $btn = 'Edit'; - $btn .= '
'; + if ($row->active_status == 0) { + $btn .= ' '; $btn .= csrf_field(); - $btn .= method_field('DELETE'); - $btn .= ''; + $btn .= method_field('PUT'); + $btn .= ''; $btn .= '
'; + } + + if ($row->active_status == 1) { + $status = 'Aktif'; + } else { + $status = 'Tidak Aktif'; + } + + $_data[] = [ + 'no' => $key+1, + 'no_baris' => @$row->row_num, + 'ef_direct_n2o_n' => $row->ef_direct_n2o_n === 0 ? 0 : getFormattedValue($row->ef_direct_n2o_n, 2), + 'ef_evaporation_n' => $row->ef_evaporation_n === 0 ? 0 : getFormattedValue($row->ef_evaporation_n), + 'name' => $row->name, + 'description' => $row->description, + 'status' => $status, + 'action' => @$btn, + ]; - if ($lm->active_status == 0) { - $btn .= '
'; - $btn .= csrf_field(); - $btn .= method_field('PUT'); - $btn .= ''; - $btn .= '
'; - } - - return $btn; - }) - ->rawColumns(['no_baris', 'status', 'action']) - ->make(true); - - return $result; } - return view('form.livestock-manure.index'); + return response()->json($_data); + } + public function index(Request $request) + { + $data['route'] = $this->route; + $data['title'] = $this->title; + + return view($this->template.'.index',$data); } public function create() { - return view('form.livestock-manure.create'); + $data['route'] = $this->route; + $data['title'] = $this->title; + return view($this->template.'.create',$data); } public function store(Request $request) @@ -111,7 +107,7 @@ class LivestockManureController implements HasMiddleware ]); $this->service->create($data); - return redirect()->route('livestockManure.index')->with('success', 'Jenis Pengelolaan Kotoran Ternak berhasil ditambahkan.'); + return redirect()->route($this->route.'.index')->with('success', 'Jenis Pengelolaan Kotoran Ternak berhasil ditambahkan.'); } catch (\Exception $e) { return back()->withErrors(['error' => 'Jenis Pengelolaan Kotoran Ternak gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]); } @@ -119,8 +115,10 @@ class LivestockManureController implements HasMiddleware public function edit($id) { - $lm = $this->service->find($id); - return view('form.livestock-manure.edit', compact('lm')); + $data['lm'] = $this->service->find($id); + $data['route'] = $this->route; + $data['title'] = $this->title; + return view($this->template.'.edit', $data); } public function update(Request $request, LivestockManure $kotoran_ternak) @@ -130,7 +128,7 @@ class LivestockManureController implements HasMiddleware // 'required', // 'string', // 'max:255', - // new UniqueInSchema('activity', 'livestock_manure', 'code', $lm->id), + // new UniqueInSchema('activity', 'livestock_manure', 'code', $row->id), // ], 'name' => 'required|string|max:255', 'ef_direct_n2o_n' => 'nullable', @@ -149,7 +147,7 @@ class LivestockManureController implements HasMiddleware $this->service->update($kotoran_ternak, $data); - return redirect()->route('livestockManure.index')->with('success', 'Jenis Pengelolaan Kotoran Ternak berhasil diperbarui.'); + return redirect()->route($this->route.'.index')->with('success', 'Jenis Pengelolaan Kotoran Ternak berhasil diperbarui.'); } catch (\Exception $e) { return back()->withErrors(['error' => 'Jenis Pengelolaan Kotoran Ternak gagal diperbarui. Silakan coba lagi. Error: ' . $e->getMessage()]); } @@ -166,7 +164,7 @@ class LivestockManureController implements HasMiddleware $record->save(); } - return redirect()->route('livestockManure.index')->with('success', 'Jenis Pengelolaan Kotoran Ternak berhasil dihapus.'); + return redirect()->route($this->route.'.index')->with('success', 'Jenis Pengelolaan Kotoran Ternak berhasil dihapus.'); } catch (\Exception $e) { return back()->withErrors(['error' => 'Jenis Pengelolaan Kotoran Ternak gagal dihapus. Silakan coba lagi. Error: ' . $e->getMessage()]); } @@ -176,7 +174,7 @@ class LivestockManureController implements HasMiddleware { try { $this->service->setAktif($id); - return redirect()->route('livestockManure.index')->with('success', 'Jenis Pengelolaan Kotoran Ternak berhasil diaktifkan.'); + return redirect()->route($this->route.'.index')->with('success', 'Jenis Pengelolaan Kotoran Ternak berhasil diaktifkan.'); } catch (\Exception $e) { return back()->withErrors(['error' => 'Gagal mengaktifkan Jenis Pengelolaan Kotoran Ternak. Silakan coba lagi. Error: ' . $e->getMessage()]); } diff --git a/resources/views/modules/form/index-kehutanan.blade.php b/resources/views/modules/form/index-kehutanan.blade.php index cf9602f..a1e34a7 100644 --- a/resources/views/modules/form/index-kehutanan.blade.php +++ b/resources/views/modules/form/index-kehutanan.blade.php @@ -19,10 +19,10 @@ 'instansi' => $instansi, ]; - $routeImport = route('folu.import', $param); - $routeExport = route('folu.export', $param); - $routeExportTemplate = route('folu.export', array_merge($param, ['isTemplate' => true])); - $routeApproval = route('folu.approval', $param); + $routeImport = route('modules.folu.import', $param); + $routeExport = route('modules.folu.export', $param); + $routeExportTemplate = route('modules.folu.export', array_merge($param, ['isTemplate' => true])); + $routeApproval = route('modules.folu.approval', $param); $internal = $internal ?? null; $limitInternal = $internal !== null && !$agencies->isNotEmpty(); @@ -33,54 +33,19 @@
{{ $form->name ?? '' }}
- @if ($errors->has('error')) -
- {{ $errors->first('error') }} -
- @endif - - @if (session('success')) -
- {{ session('success') }} -
- @endif +
-
-
- @include('form.approve') -
-
- -
-
- -
- -
- -
-
-
-
+ +
+
- +
+
{{-- @if ($agencies->isNotEmpty()) --}} -
+
@@ -104,15 +69,44 @@
+
+
+ @include('modules.form.approve') +
+
+ +
+
+ +
+ +
+ +
+
{{-- @endif --}}
+ +
-
+
- +
{{ $inventoryYear - 1 }} @@ -162,10 +156,10 @@ - @include('form.import') + @include('modules.form.import') @if ($instansi !== 'all') - @include('form.aktivitas-user') - @include('form.metadata.index') + @include('modules.form.aktivitas-user') + @include('modules.form.metadata.index') @endif @endsection diff --git a/resources/views/modules/form/livestock-manure/create.blade.php b/resources/views/modules/form/livestock-manure/create.blade.php index fdd7b00..03f96eb 100644 --- a/resources/views/modules/form/livestock-manure/create.blade.php +++ b/resources/views/modules/form/livestock-manure/create.blade.php @@ -1,7 +1,5 @@ @extends('layouts.master') -@section('title', 'Tambah Jenis Pengelolaan Kotoran Ternak') - @section('content')
@@ -9,26 +7,10 @@
- @if ($errors->has('error')) -
- {{ $errors->first('error') }} -
- @endif - -
+ + @csrf - {{--
- - - @error('code') -
- {{ $message }} -
- @enderror -
--}} -
- {{--
- - - @error('row_num') -
- {{ $message }} -
- @enderror -
--}} - diff --git a/resources/views/modules/form/livestock-manure/edit.blade.php b/resources/views/modules/form/livestock-manure/edit.blade.php index 03a5068..f263fdc 100644 --- a/resources/views/modules/form/livestock-manure/edit.blade.php +++ b/resources/views/modules/form/livestock-manure/edit.blade.php @@ -1,7 +1,5 @@ @extends('layouts.master') -@section('title', 'Edit Jenis Pengelolaan Kotoran Ternak') - @section('content')
@@ -9,27 +7,11 @@
- @if ($errors->has('error')) -
- {{ $errors->first('error') }} -
- @endif -
+ @csrf @method('PUT') - {{--
- - - @error('code') -
- {{ $message }} -
- @enderror -
--}} -
--}}
-
Jenis Pengelolaan Kotoran Ternak
- Tambah Jenis Pengelolaan - Kotoran Ternak +
{{ $title }}
+ Tambah {{$title}}
- @if (session('success')) -
- {{ session('success') }} -
- @endif
- - +
+ - {{-- --}} - - - - - - + + + + + + - - - + +
KodeSistem Pengelolaan Kotoran TernakFaktor Emisi untuk Emisi Langsung N2O-NFaktor Emisi untuk Emisi N2O dari Penguapan NNomor BarisStatusAksi#Sistem Pengelolaan Kotoran TernakFaktor Emisi untuk Emisi Langsung N2O-NFaktor Emisi untuk Emisi N2O dari Penguapan NNomor BarisStatus
@@ -41,56 +43,6 @@ @section('js')