diff --git a/app/Exports/WorksheetExport.php b/app/Exports/WorksheetExport.php index a357d67..172c905 100644 --- a/app/Exports/WorksheetExport.php +++ b/app/Exports/WorksheetExport.php @@ -21,7 +21,7 @@ class WorksheetExport implements FromView, WithStyles public function view(): View { - return view('reports.worksheet.report', [ + return view('modules.reports.worksheet.report', [ 'wsData' => $this->wsData, 'emisiData' => $this->emisiData, 'isExport' => true diff --git a/app/Http/Controllers/Reports/WorksheetController.php b/app/Http/Controllers/Reports/WorksheetController.php index 18f6d7f..860e2e0 100644 --- a/app/Http/Controllers/Reports/WorksheetController.php +++ b/app/Http/Controllers/Reports/WorksheetController.php @@ -12,6 +12,9 @@ use Illuminate\Support\Facades\Validator; class WorksheetController extends Controller { + protected $title = 'Laporan Worksheet'; + protected $template = 'modules.reports.worksheet'; + protected $route = 'modules.laporan.worksheet'; protected $service; public function __construct(WorksheetService $service) @@ -35,7 +38,9 @@ class WorksheetController extends Controller $emisiData = []; } - return view('reports.worksheet.index', [ + return view($this->template.'.index', [ + 'title' => $this->title, + 'route' => $this->route, 'inventoryYear' => $inventoryYear ?? date('Y'), 'activityYear' => $activityYear, 'sectorCode' => $sectorCode, diff --git a/app/Http/Controllers/Tool/ProdusenCalculateController.php b/app/Http/Controllers/Tool/ProdusenCalculateController.php index de5e0bf..7d7b91d 100644 --- a/app/Http/Controllers/Tool/ProdusenCalculateController.php +++ b/app/Http/Controllers/Tool/ProdusenCalculateController.php @@ -15,6 +15,9 @@ use Illuminate\Support\Facades\Auth; class ProdusenCalculateController implements HasMiddleware { + protected $title = 'Hitung Data dari Produsen'; + protected $template = 'modules.tool.produsen-calculate'; + protected $route = 'modules.kalkulasi.hitung-produsen'; protected $service; public function __construct(ProdusenCalculateService $service) @@ -31,63 +34,14 @@ class ProdusenCalculateController implements HasMiddleware public function index(Request $request) { - $availableYears = ActivityForm::select('inventory_year')->whereNotNull('agency_id') + $data['availableYears'] = ActivityForm::select('inventory_year')->whereNotNull('agency_id') ->distinct()->rowActive()->orderBy('inventory_year', 'desc') ->get()->pluck('inventory_year')->toArray(); - if ($request->ajax()) { - $query = $this->service->getRawAll(); + $data['route'] = $this->route; + $data['title'] = $this->title; - $result = datatables()->of($query) - ->addColumn('duration', function ($row) { - if ($row->finished_time === null || $row->executed_time === null) { - return ''; - } - - $start = Carbon::parse($row->executed_time); - $end = Carbon::parse($row->finished_time); - - // Calculate the difference in seconds - $diffInSeconds = $start->diffInSeconds($end); - - // Format the duration as HH:MM:SS - $hours = floor($diffInSeconds / 3600); - $minutes = floor(($diffInSeconds % 3600) / 60); - $seconds = $diffInSeconds % 60; - - return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds); - }) - ->editColumn('created_at', function ($row) { - return $row->created_at->format('d-m-Y H:i:s') - ?? ''; - }) - ->editColumn('executed_time', function ($row) { - if ($row->executed_time === null) { - return ''; - } - - return $row->executed_time->format('d-m-Y H:i:s'); - }) - ->editColumn('finished_time', function ($row) { - if ($row->finished_time === null) { - return ''; - } - - return $row->finished_time->format('d-m-Y H:i:s'); - }) - ->addColumn('status', function ($row) { - $status = SigdStatus::from($row->status); - return $status->badge() ?? ''; - }) - ->rawColumns(['status', 'duration']) - ->make(true); - - return $result; - } - - return view('tool.produsen-calculate.index', [ - 'availableYears' => $availableYears - ]); + return view($this->template.'.index', $data); } public function store(Request $request) @@ -108,9 +62,52 @@ class ProdusenCalculateController implements HasMiddleware $this->service->create($data); - return redirect()->route('produsenCalculate.index')->with('success', 'Proses Hitung Data dari Produsen berhasil ditambahkan.'); + return redirect()->route($this->route.'.index')->with('success', 'Proses Hitung Data dari Produsen berhasil ditambahkan.'); } catch (\Exception $e) { return back()->withErrors(['error' => 'Proses Hitung Data dari Produsen Aktivitas gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]); } } + + public function grid(Request $request) + { + $_data = []; + + $data = $this->service->getRawAll(); + + foreach ($data->get() as $key => $row) { + + $status = SigdStatus::from($row->status); + if ($row->finished_time === null || $row->executed_time === null) { + $duration = ''; + } + + // Parse the date-time strings into Carbon instances + $start = Carbon::parse($row->executed_time); + $end = Carbon::parse($row->finished_time); + + // Calculate the difference in seconds + $diffInSeconds = $start->diffInSeconds($end); + + // Format the duration as HH:MM:SS + $hours = floor($diffInSeconds / 3600); + $minutes = floor(($diffInSeconds % 3600) / 60); + $seconds = $diffInSeconds % 60; + + $duration = sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds); + + + $_data[] = [ + 'no' => $key+1, + 'inventory_year' => $row->inventory_year, + 'status' => $status->badge() ?? '', + 'finished_time' => @$row->finished_time ? date('d-m-Y H:i:s', strtotime(@$row->finished_time)) : '', + 'executed_time' => @$row->executed_time ? date('d-m-Y H:i:s', strtotime(@$row->executed_time)) : '', + 'created_at' => @$row->created_at ? date('d-m-Y H:i:s', strtotime(@$row->created_at)) : '', + 'duration' => $duration, + ]; + + } + + return response()->json($_data); + } } diff --git a/app/View/Components/ActivityYearSelect.php b/app/View/Components/ActivityYearSelect.php index 67efc96..0b8edb2 100644 --- a/app/View/Components/ActivityYearSelect.php +++ b/app/View/Components/ActivityYearSelect.php @@ -19,6 +19,6 @@ class ActivityYearSelect extends Component public function render(): View|Closure|string { - return view('components.activity-year-select'); + return view('modules.components.activity-year-select'); } } diff --git a/app/View/Components/InventoryYearSelect.php b/app/View/Components/InventoryYearSelect.php index aa4e3bc..0450a3f 100644 --- a/app/View/Components/InventoryYearSelect.php +++ b/app/View/Components/InventoryYearSelect.php @@ -19,6 +19,6 @@ class InventoryYearSelect extends Component public function render(): View|Closure|string { - return view('components.inventory-year-select'); + return view('modules.components.inventory-year-select'); } } diff --git a/resources/views/modules/components/activity-year-select.blade.php b/resources/views/modules/components/activity-year-select.blade.php index 0a4006a..633a891 100644 --- a/resources/views/modules/components/activity-year-select.blade.php +++ b/resources/views/modules/components/activity-year-select.blade.php @@ -15,7 +15,7 @@ -@section('js') +@push('js') -@endsection +@endpush diff --git a/resources/views/modules/reports/crf/table.blade.php b/resources/views/modules/reports/crf/table.blade.php index 5ba10b9..f08a86c 100644 --- a/resources/views/modules/reports/crf/table.blade.php +++ b/resources/views/modules/reports/crf/table.blade.php @@ -10,7 +10,7 @@ @endphp
- + diff --git a/resources/views/modules/reports/gcom-crf/index-backup.blade.php b/resources/views/modules/reports/gcom-crf/index-backup.blade.php index 13a7d6b..2a1b99b 100644 --- a/resources/views/modules/reports/gcom-crf/index-backup.blade.php +++ b/resources/views/modules/reports/gcom-crf/index-backup.blade.php @@ -42,7 +42,7 @@ @if ($gpcOutput)
Kategori CO2
(Gg)
- + diff --git a/resources/views/modules/reports/gcom-crf/note.blade.php b/resources/views/modules/reports/gcom-crf/note.blade.php index 58bfc63..bee23f4 100644 --- a/resources/views/modules/reports/gcom-crf/note.blade.php +++ b/resources/views/modules/reports/gcom-crf/note.blade.php @@ -10,7 +10,7 @@
Sectors and Subsectors Direct Emissions (tCO2e)
- + diff --git a/resources/views/modules/reports/gcom-crf/table.blade.php b/resources/views/modules/reports/gcom-crf/table.blade.php index 7f8fde1..404feaf 100644 --- a/resources/views/modules/reports/gcom-crf/table.blade.php +++ b/resources/views/modules/reports/gcom-crf/table.blade.php @@ -4,7 +4,7 @@
Notation Key Deskripsi dan Contoh
- + diff --git a/resources/views/modules/reports/gpc-output/table.blade.php b/resources/views/modules/reports/gpc-output/table.blade.php index ef4dbde..df59423 100644 --- a/resources/views/modules/reports/gpc-output/table.blade.php +++ b/resources/views/modules/reports/gpc-output/table.blade.php @@ -4,7 +4,7 @@
Sectors and Subsectors Direct Emissions (tCO2e)
- + diff --git a/resources/views/modules/reports/worksheet/index.blade.php b/resources/views/modules/reports/worksheet/index.blade.php index 7d02d89..296dd77 100644 --- a/resources/views/modules/reports/worksheet/index.blade.php +++ b/resources/views/modules/reports/worksheet/index.blade.php @@ -22,18 +22,6 @@
- @if ($errors->has('error')) -
- {{ $errors->first('error') }} -
- @endif - - @if (session('success')) -
- {{ session('success') }} -
- @endif -
@csrf
@@ -45,64 +33,66 @@
-
-
- -
- +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
-
-
- -
- -
-
-
-
- @if (\Illuminate\Support\Facades\File::exists(resource_path('views/reports/worksheet/tables/' . ($wsData ? $wsData->ws_code : 'test') . '.blade.php'))) - @include('reports.worksheet.tables.' . $wsData->ws_code) + @if (\Illuminate\Support\Facades\File::exists(resource_path('views/modules/reports/worksheet/tables/' . ($wsData ? $wsData->ws_code : 'test') . '.blade.php'))) + @include('modules.reports.worksheet.tables.' . $wsData->ws_code) @endif
@endsection -@push('styles') -@endsection @section('js')
Populasi