update
parent
f055b22ba8
commit
cb10a2c948
|
|
@ -13,10 +13,10 @@ enum SigdStatus: int
|
||||||
public function badge(): string
|
public function badge(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::PENDING => '<span class="badge badge-warning">PENDING</span>',
|
self::PENDING => '<span class="badge bg-warning">PENDING</span>',
|
||||||
self::PROSES => '<span class="badge badge-info">PROSES</span>',
|
self::PROSES => '<span class="badge bg-info">PROSES</span>',
|
||||||
self::SELESAI => '<span class="badge badge-success">SELESAI</span>',
|
self::SELESAI => '<span class="badge bg-success">SELESAI</span>',
|
||||||
self::GAGAL => '<span class="badge badge-danger">GAGAL</span>',
|
self::GAGAL => '<span class="badge bg-danger">GAGAL</span>',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,11 @@ class DashboardInventoryController extends Controller
|
||||||
try {
|
try {
|
||||||
$inventoryYear = $request->input('year', date('Y'));
|
$inventoryYear = $request->input('year', date('Y'));
|
||||||
|
|
||||||
$dashboardData = $this->emissionService->getDashboardData($inventoryYear);
|
$data['dashboardData'] = $this->emissionService->getDashboardData($inventoryYear);
|
||||||
|
$data['title'] = $this->title;
|
||||||
|
$data['route'] = $this->route;
|
||||||
|
|
||||||
return view($this->template.'.index', $dashboardData);
|
return view($this->template.'.index', $data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('Error loading dashboard data', [
|
Log::error('Error loading dashboard data', [
|
||||||
'message' => $e->getMessage(),
|
'message' => $e->getMessage(),
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ use Illuminate\Routing\Controllers\Middleware;
|
||||||
|
|
||||||
class CalculationController implements HasMiddleware
|
class CalculationController implements HasMiddleware
|
||||||
{
|
{
|
||||||
|
protected $title = 'Kalkulasi Emisi';
|
||||||
|
protected $template = 'modules.tool.calculation';
|
||||||
|
protected $route = 'modules.kalkulasi.kalkulasi-emisi';
|
||||||
protected $service;
|
protected $service;
|
||||||
|
|
||||||
public function __construct(CalculationService $service)
|
public function __construct(CalculationService $service)
|
||||||
|
|
@ -30,77 +33,21 @@ class CalculationController implements HasMiddleware
|
||||||
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
if ($request->ajax()) {
|
|
||||||
$query = $this->service->getRawAll();
|
$data['route'] = $this->route;
|
||||||
|
$data['title'] = $this->title;
|
||||||
|
$data['sectors'] = $this->service->getSectors();
|
||||||
|
|
||||||
// Apply category filter if a category is selected
|
return view($this->template.'.index', $data);
|
||||||
if ($request->has('sectorFilter') && $request->sectorFilter != '' && $request->sectorFilter != 'SEMUA SEKTOR') {
|
|
||||||
$query = $query->where($request->sectorFilter, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->has('inventoryYearFilter') && $request->inventoryYearFilter != '' && $request->inventoryYearFilter != 'SEMUA TAHUN') {
|
|
||||||
$query = $query->where('inventory_year', $request->inventoryYearFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = datatables()->of($query)
|
|
||||||
->addColumn('sector', function ($row) {
|
|
||||||
return $row->sector;
|
|
||||||
})
|
|
||||||
->addColumn('duration', function ($row) {
|
|
||||||
if ($row->finished_time === null || $row->executed_time === null) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
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->calculation_status);
|
|
||||||
return $status->badge() ?? '';
|
|
||||||
})
|
|
||||||
->rawColumns(['status', 'sector', 'duration'])
|
|
||||||
->make(true);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sectors = $this->service->getSectors();
|
|
||||||
return view('tool.calculation.index', compact('sectors'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
return view('tool.calculation.create');
|
$data['route'] = $this->route;
|
||||||
|
$data['title'] = $this->title;
|
||||||
|
|
||||||
|
return view($this->template.'.create',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
|
|
@ -132,7 +79,7 @@ class CalculationController implements HasMiddleware
|
||||||
$this->service->create($data);
|
$this->service->create($data);
|
||||||
logUserActivity(ActivityType::CALCULATION_EMISI);
|
logUserActivity(ActivityType::CALCULATION_EMISI);
|
||||||
|
|
||||||
return redirect()->route('calculation.index')->with('success', 'Kalkulasi Emisi berhasil ditambahkan.');
|
return redirect()->route($this->route.'.index')->with('success', 'Kalkulasi Emisi berhasil ditambahkan.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back()->withErrors(['error' => 'Kalkulasi Emisi gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
return back()->withErrors(['error' => 'Kalkulasi Emisi gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|
@ -147,4 +94,57 @@ class CalculationController implements HasMiddleware
|
||||||
'years' => $years
|
'years' => $years
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function grid(Request $request)
|
||||||
|
{
|
||||||
|
$_data = [];
|
||||||
|
|
||||||
|
$data = $this->service->getRawAll();
|
||||||
|
|
||||||
|
// Apply category filter if a category is selected
|
||||||
|
if ($request->has('sectorFilter') && $request->sectorFilter != '' && $request->sectorFilter != 'SEMUA SEKTOR') {
|
||||||
|
$data = $query->where($request->sectorFilter, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('inventoryYearFilter') && $request->inventoryYearFilter != '' && $request->inventoryYearFilter != 'SEMUA TAHUN') {
|
||||||
|
$data = $query->where('inventory_year', $request->inventoryYearFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($data->get() as $key => $row) {
|
||||||
|
|
||||||
|
$status = SigdStatus::from($row->calculation_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,
|
||||||
|
'sector' => $row->sector,
|
||||||
|
'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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,148 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Tool;
|
|
||||||
|
|
||||||
use App\Enums\ActivityType;
|
|
||||||
use App\Enums\SigdStatus;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Models\ActivityLock;
|
|
||||||
use App\Services\Tool\CalculationService;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Routing\Controllers\HasMiddleware;
|
|
||||||
use Illuminate\Routing\Controllers\Middleware;
|
|
||||||
|
|
||||||
class CalculationController implements HasMiddleware
|
|
||||||
{
|
|
||||||
protected $service;
|
|
||||||
|
|
||||||
public function __construct(CalculationService $service)
|
|
||||||
{
|
|
||||||
$this->service = $service;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function middleware(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
//new Middleware('permission:/tool/calculation'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function index(Request $request)
|
|
||||||
{
|
|
||||||
if ($request->ajax()) {
|
|
||||||
$query = $this->service->getRawAll();
|
|
||||||
|
|
||||||
// Apply category filter if a category is selected
|
|
||||||
if ($request->has('sectorFilter') && $request->sectorFilter != '' && $request->sectorFilter != 'SEMUA SEKTOR') {
|
|
||||||
$query = $query->where($request->sectorFilter, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->has('inventoryYearFilter') && $request->inventoryYearFilter != '' && $request->inventoryYearFilter != 'SEMUA TAHUN') {
|
|
||||||
$query = $query->where('inventory_year', $request->inventoryYearFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = datatables()->of($query)
|
|
||||||
->addColumn('sector', function ($row) {
|
|
||||||
return $row->sector;
|
|
||||||
})
|
|
||||||
->addColumn('duration', function ($row) {
|
|
||||||
if ($row->finished_time === null || $row->executed_time === null) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
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->calculation_status);
|
|
||||||
return $status->badge() ?? '';
|
|
||||||
})
|
|
||||||
->rawColumns(['status', 'sector', 'duration'])
|
|
||||||
->make(true);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sectors = $this->service->getSectors();
|
|
||||||
return view('tool.calculation.index', compact('sectors'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
return view('tool.calculation.create');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function store(Request $request)
|
|
||||||
{
|
|
||||||
// Validate the form data
|
|
||||||
$request->validate([
|
|
||||||
'inventory_year' => 'required|integer|min:2000|max:' . date('Y'),
|
|
||||||
'energy' => 'boolean',
|
|
||||||
'agriculture' => 'boolean',
|
|
||||||
'folu' => 'boolean',
|
|
||||||
'waste' => 'boolean',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$isLocked = ActivityLock::isLocked($request->inventory_year);
|
|
||||||
|
|
||||||
if ($isLocked) {
|
|
||||||
return back()->withErrors(['error' => 'Kalkulasi Emisi gagal disimpan. Tahun Inventory dikunci.']);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$data = $request->all();
|
|
||||||
$data['energy'] = $request->has('energy') ? 1 : 0;
|
|
||||||
$data['agriculture'] = $request->has('agriculture') ? 1 : 0;
|
|
||||||
$data['folu'] = $request->has('folu') ? 1 : 0;
|
|
||||||
$data['waste'] = $request->has('waste') ? 1 : 0;
|
|
||||||
|
|
||||||
$this->service->create($data);
|
|
||||||
logUserActivity(ActivityType::CALCULATION_EMISI);
|
|
||||||
|
|
||||||
return redirect()->route('calculation.index')->with('success', 'Kalkulasi Emisi berhasil ditambahkan.');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return back()->withErrors(['error' => 'Kalkulasi Emisi gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActivityYearRange(Request $request)
|
|
||||||
{
|
|
||||||
$inventoryYear = (int) $request->query('inventoryYear');
|
|
||||||
$years = activityYearRange($inventoryYear);
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'years' => $years
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -15,6 +15,9 @@ use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class CopyActivityController implements HasMiddleware
|
class CopyActivityController implements HasMiddleware
|
||||||
{
|
{
|
||||||
|
protected $title = 'Salin Aktivitas';
|
||||||
|
protected $template = 'modules.tool.copy';
|
||||||
|
protected $route = 'modules.kalkulasi.salin-aktivitas';
|
||||||
protected $service;
|
protected $service;
|
||||||
|
|
||||||
public function __construct(CopyActivityService $service)
|
public function __construct(CopyActivityService $service)
|
||||||
|
|
@ -31,63 +34,14 @@ class CopyActivityController implements HasMiddleware
|
||||||
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$availableYears = ActivityForm::select('inventory_year')->whereNull('agency_id')
|
$data['availableYears'] = ActivityForm::select('inventory_year')->whereNull('agency_id')
|
||||||
->distinct()->rowActive()->orderBy('inventory_year', 'desc')
|
->distinct()->rowActive()->orderBy('inventory_year', 'desc')
|
||||||
->get()->pluck('inventory_year')->toArray();
|
->get()->pluck('inventory_year')->toArray();
|
||||||
|
|
||||||
|
$data['route'] = $this->route;
|
||||||
|
$data['title'] = $this->title;
|
||||||
|
|
||||||
if ($request->ajax()) {
|
return view($this->template.'.index', $data);
|
||||||
$query = $this->service->getRawAll();
|
|
||||||
|
|
||||||
$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.copy.index', [
|
|
||||||
'availableYears' => $availableYears
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
|
|
@ -109,9 +63,53 @@ class CopyActivityController implements HasMiddleware
|
||||||
|
|
||||||
$this->service->create($data);
|
$this->service->create($data);
|
||||||
|
|
||||||
return redirect()->route('copy.index')->with('success', 'Salin Aktivitas berhasil ditambahkan.');
|
return redirect()->route($this->route.'.index')->with('success', 'Salin Aktivitas berhasil ditambahkan.');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back()->withErrors(['error' => 'Salin Aktivitas gagal disimpan. Silakan coba lagi. Error: ' . $e->getMessage()]);
|
return back()->withErrors(['error' => 'Salin 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,
|
||||||
|
'to_year' => $row->to_year,
|
||||||
|
'from_year' => $row->from_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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ use Illuminate\Routing\Controllers\Middleware;
|
||||||
|
|
||||||
class LockActivityController implements HasMiddleware
|
class LockActivityController implements HasMiddleware
|
||||||
{
|
{
|
||||||
|
protected $title = 'Kunci Aktivitas';
|
||||||
|
protected $template = 'modules.tool.lock';
|
||||||
|
protected $route = 'modules.kalkulasi.kunci-aktivitas';
|
||||||
protected $lockService;
|
protected $lockService;
|
||||||
|
|
||||||
public function __construct(LockActivityService $lockService)
|
public function __construct(LockActivityService $lockService)
|
||||||
|
|
@ -26,45 +29,10 @@ class LockActivityController implements HasMiddleware
|
||||||
|
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
if ($request->ajax()) {
|
$data['route'] = $this->route;
|
||||||
$locks = $this->lockService->getAll();
|
$data['title'] = $this->title;
|
||||||
|
|
||||||
$result = datatables()->of($locks)
|
return view($this->template.'.index',$data);
|
||||||
->editColumn('updated_at', function ($row) {
|
|
||||||
return $row->created_at->format('d-m-Y H:i:s')
|
|
||||||
?? '';
|
|
||||||
})
|
|
||||||
->addColumn('status', function ($row) {
|
|
||||||
if ($row->lock_status == 'locked') {
|
|
||||||
return '<span class="badge badge-warning">LOCKED</span>';
|
|
||||||
} else {
|
|
||||||
return '<span class="badge badge-info">OPEN</span>';
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->addColumn('action', function ($row) {
|
|
||||||
$buttonStyle = 'style="min-width: 120px;"'; // Adjust min-width as needed
|
|
||||||
|
|
||||||
$action = $row->lock_status == 'locked'
|
|
||||||
? '<form action="' . route('lock.unlock') . '" method="POST" style="display:inline-block;">'
|
|
||||||
. csrf_field()
|
|
||||||
. '<input type="hidden" name="year" value="' . $row->inventory_year . '">'
|
|
||||||
. '<button type="submit" class="btn btn-warning" ' . $buttonStyle . '>Buka Kunci</button>'
|
|
||||||
. '</form>'
|
|
||||||
: '<form action="' . route('lock.lock') . '" method="POST" style="display:inline-block;">'
|
|
||||||
. csrf_field()
|
|
||||||
. '<input type="hidden" name="year" value="' . $row->inventory_year . '">'
|
|
||||||
. '<button type="submit" class="btn btn-danger" ' . $buttonStyle . '>Kunci</button>'
|
|
||||||
. '</form>';
|
|
||||||
|
|
||||||
return $action;
|
|
||||||
})
|
|
||||||
->rawColumns(['status', 'action'])
|
|
||||||
->make(true);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('tool.lock.index');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lock(Request $request)
|
public function lock(Request $request)
|
||||||
|
|
@ -102,4 +70,46 @@ class LockActivityController implements HasMiddleware
|
||||||
return redirect()->back()->withErrors(['error' => 'Tahun Inventory ' . $request->year . 'gagal dibuka. Mohon dicoba kembali.']);
|
return redirect()->back()->withErrors(['error' => 'Tahun Inventory ' . $request->year . 'gagal dibuka. Mohon dicoba kembali.']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function grid(Request $request)
|
||||||
|
{
|
||||||
|
$_data = [];
|
||||||
|
|
||||||
|
$data = $this->lockService->getAll();
|
||||||
|
|
||||||
|
foreach ($data as $key => $row) {
|
||||||
|
|
||||||
|
if ($row->lock_status == 'locked') {
|
||||||
|
$status = '<span class="badge bg-warning">LOCKED</span>';
|
||||||
|
} else {
|
||||||
|
$status = '<span class="badge bg-info">OPEN</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$buttonStyle = 'style="min-width: 120px;"'; // Adjust min-width as needed
|
||||||
|
|
||||||
|
$action = $row->lock_status == 'locked'
|
||||||
|
? '<form action="' . route($this->route.'.unlock') . '" method="POST" style="display:inline-block;">'
|
||||||
|
. csrf_field()
|
||||||
|
. '<input type="hidden" name="year" value="' . $row->inventory_year . '">'
|
||||||
|
. '<button type="submit" class="btn btn-sm btn-warning" ' . $buttonStyle . '>Buka Kunci</button>'
|
||||||
|
. '</form>'
|
||||||
|
: '<form action="' . route($this->route.'.lock') . '" method="POST" style="display:inline-block;">'
|
||||||
|
. csrf_field()
|
||||||
|
. '<input type="hidden" name="year" value="' . $row->inventory_year . '">'
|
||||||
|
. '<button type="submit" class="btn btn-sm btn-danger" ' . $buttonStyle . '>Kunci</button>'
|
||||||
|
. '</form>';
|
||||||
|
|
||||||
|
|
||||||
|
$_data[] = [
|
||||||
|
'no' => $key+1,
|
||||||
|
'inventory_year' => $row->inventory_year,
|
||||||
|
'status' => $status,
|
||||||
|
'executed_time' => @$row->created_at ? date('d-m-Y H:i:s', strtotime(@$row->created_at)) : '',
|
||||||
|
'action' => $action,
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,19 +34,19 @@ class Calculation extends SigdModel
|
||||||
$badgeStyle = '';
|
$badgeStyle = '';
|
||||||
|
|
||||||
if ($this->energy) {
|
if ($this->energy) {
|
||||||
$tags[] = '<span class="badge badge-info" style="margin:1px; ' . $badgeStyle . '">ENERGI</span>';
|
$tags[] = '<span class="badge bg-info" style="margin:1px; ' . $badgeStyle . '">ENERGI</span>';
|
||||||
}
|
}
|
||||||
if ($this->agriculture) {
|
if ($this->agriculture) {
|
||||||
$tags[] = '<span class="badge badge-info" style="margin:1px; ' . $badgeStyle . '">PERTANIAN</span>';
|
$tags[] = '<span class="badge bg-info" style="margin:1px; ' . $badgeStyle . '">PERTANIAN</span>';
|
||||||
}
|
}
|
||||||
if ($this->folu) {
|
if ($this->folu) {
|
||||||
$tags[] = '<span class="badge badge-info" style="margin:1px; ' . $badgeStyle . '">LAHAN</span>';
|
$tags[] = '<span class="badge bg-info" style="margin:1px; ' . $badgeStyle . '">LAHAN</span>';
|
||||||
}
|
}
|
||||||
if ($this->waste) {
|
if ($this->waste) {
|
||||||
$tags[] = '<span class="badge badge-info" style="margin:1px; ' . $badgeStyle . '">LIMBAH</span>';
|
$tags[] = '<span class="badge bg-info" style="margin:1px; ' . $badgeStyle . '">LIMBAH</span>';
|
||||||
}
|
}
|
||||||
if ($this->ippu) {
|
if ($this->ippu) {
|
||||||
$tags[] = '<span class="badge badge-info" style="margin:1px; ' . $badgeStyle . '">IPPU</span>';
|
$tags[] = '<span class="badge bg-info" style="margin:1px; ' . $badgeStyle . '">IPPU</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(' ', $tags);
|
return implode(' ', $tags);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">Jenis Pengelolaan Kotoran Ternak</h5>
|
<h5 class="mb-0 font-weight-bold">Jenis Pengelolaan Kotoran Ternak</h5>
|
||||||
<a href="{{ route('livestockManure.create') }}" class="btn btn-primary float-right">Tambah Jenis Pengelolaan
|
<a href="{{ route('livestockManure.create') }}" class="btn btn-sm btn-primary float-right">Tambah Jenis Pengelolaan
|
||||||
Kotoran Ternak</a>
|
Kotoran Ternak</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">List AR</h5>
|
<h5 class="mb-0 font-weight-bold">List AR</h5>
|
||||||
<a href="{{ route($route.'.create') }}" class="btn btn-primary float-right">Tambah AR</a>
|
<a href="{{ route($route.'.create') }}" class="btn btn-sm btn-primary float-right">Tambah AR</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||||
<a href="{{ route($route.'.create') }}" class="btn btn-primary float-right">Tambah Sumber Data EF</a>
|
<a href="{{ route($route.'.create') }}" class="btn btn-sm btn-primary float-right">Tambah Sumber Data EF</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">List EF</h5>
|
<h5 class="mb-0 font-weight-bold">List EF</h5>
|
||||||
<a href="{{ route($route.'.create') }}" class="btn btn-primary float-right">Tambah EF</a>
|
<a href="{{ route($route.'.create') }}" class="btn btn-sm btn-primary float-right">Tambah EF</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">{{ $title }}</h5>
|
<h5 class="mb-0 font-weight-bold">{{ $title }}</h5>
|
||||||
<a href="{{ route($route.'.create') }}" class="btn btn-primary float-right">Upload</a>
|
<a href="{{ route($route.'.create') }}" class="btn btn-sm btn-primary float-right">Upload</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||||
<a href="{{ route($route.'.create') }}" class="btn btn-primary float-right">Upload</a>
|
<a href="{{ route($route.'.create') }}" class="btn btn-sm btn-primary float-right">Upload</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,11 @@
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">List Unit</h5>
|
<h5 class="mb-0 font-weight-bold">List Unit</h5>
|
||||||
<a href="{{ route($route.'.create') }}" class="btn btn-primary">Tambah Unit</a>
|
<a href="{{ route($route.'.create') }}" class="btn btn-sm btn-primary">Tambah Unit</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if (session('success'))
|
|
||||||
<div class="alert alert-success">
|
|
||||||
{{ session('success') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,16 @@
|
||||||
@extends('layouts.master')
|
@extends('layouts.master')
|
||||||
|
|
||||||
@section('title', 'Tambah Kalkulasi Emisi')
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-8">
|
<div class="col-md-12">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">Tambah Kalkulasi Emisi</h5>
|
<h5 class="mb-0 font-weight-bold">Tambah {{ $title }}</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if ($errors->has('error'))
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
{{ $errors->first('error') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
|
<form action="{{ route($route.'.store') }}" method="POST">
|
||||||
<form action="{{ route('calculation.store') }}" method="POST">
|
|
||||||
@csrf
|
@csrf
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
|
|
@ -68,7 +60,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<a href="{{ route('calculation.index') }}" class="btn btn-secondary">Kembali</a>
|
<a href="{{ route($route.'.index') }}" class="btn btn-secondary">Kembali</a>
|
||||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
@extends('layouts.master')
|
|
||||||
|
|
||||||
@section('title', 'Tambah Kalkulasi Emisi')
|
|
||||||
|
|
||||||
@section('content')
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-8">
|
|
||||||
<div class="card shadow-sm">
|
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
|
||||||
<h5 class="mb-0 font-weight-bold">Tambah Kalkulasi Emisi</h5>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card-body">
|
|
||||||
@if ($errors->has('error'))
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
{{ $errors->first('error') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
|
|
||||||
<form action="{{ route('calculation.store') }}" method="POST">
|
|
||||||
@csrf
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="inventory_year">Tahun Inventory</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<select name="inventory_year" id="inventory_year" class="form-control">
|
|
||||||
@for ($year = date('Y'); $year >= 2000; $year--)
|
|
||||||
<option value="{{ $year }}"
|
|
||||||
{{ old('inventory_year', date('Y')) == $year ? 'selected' : '' }}>
|
|
||||||
{{ $year }}
|
|
||||||
</option>
|
|
||||||
@endfor
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Sektor</label>
|
|
||||||
<div class="d-flex flex-wrap">
|
|
||||||
<div class="form-check mr-3">
|
|
||||||
<input type="checkbox" name="energy" id="energy" class="form-check-input"
|
|
||||||
value="1" {{ old('energy', 1) == 1 ? 'checked' : '' }}>
|
|
||||||
<label class="form-check-label" for="energy">Energi</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check mr-3">
|
|
||||||
<input type="checkbox" name="agriculture" id="agriculture" class="form-check-input"
|
|
||||||
value="1" {{ old('agriculture', 1) == 1 ? 'checked' : '' }}>
|
|
||||||
<label class="form-check-label" for="agriculture">Pertanian</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check mr-3">
|
|
||||||
<input type="checkbox" name="folu" id="folu" class="form-check-input"
|
|
||||||
value="1" {{ old('folu', 1) == 1 ? 'checked' : '' }}>
|
|
||||||
<label class="form-check-label" for="folu">Lahan</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input type="checkbox" name="waste" id="waste" class="form-check-input"
|
|
||||||
value="1" {{ old('waste', 1) == 1 ? 'checked' : '' }}>
|
|
||||||
<label class="form-check-label" for="waste">Limbah</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<a href="{{ route('calculation.index') }}" class="btn btn-secondary">Kembali</a>
|
|
||||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{-- </div> --}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
||||||
|
|
||||||
@section('js')
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$('#inventory_year').select2({
|
|
||||||
placeholder: 'Pilih Tahun',
|
|
||||||
// allowClear: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@endsection
|
|
||||||
|
|
@ -1,26 +1,17 @@
|
||||||
@extends('layouts.master')
|
@extends('layouts.master')
|
||||||
|
|
||||||
@section('title', 'Kalkulasi Emisi')
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">Kalkulasi Emisi</h5>
|
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||||
<a href="{{ route('calculation.create') }}" class="btn btn-primary float-right">Kalkulasi Emisi</a>
|
<a href="{{ route($route.'.create') }}" class="btn btn-sm btn-primary float-right">Tambah {{ @$title }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if (session('success'))
|
|
||||||
<div class="alert alert-success">
|
|
||||||
{{ session('success') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
|
<div id="toolbar">
|
||||||
<div class="row">
|
<div class="d-flex gap-3">
|
||||||
<div class="col-md-2">
|
<div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="sector">Filter Sektor:</label>
|
|
||||||
<select id="sector" name = "sector" class="form-control">
|
<select id="sector" name = "sector" class="form-control">
|
||||||
<option>SEMUA SEKTOR</option>
|
<option>SEMUA SEKTOR</option>
|
||||||
@foreach ($sectors as $sector)
|
@foreach ($sectors as $sector)
|
||||||
|
|
@ -31,40 +22,46 @@
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div>
|
||||||
<div class="col-md-2 pr-1">
|
<select name="inventoryYear" id="inventoryYear" class="form-control">
|
||||||
<div class="form-group">
|
<option>SEMUA TAHUN</option>
|
||||||
<label for="inventoryYear">Tahun Inventory:</label>
|
@for ($year = date('Y'); $year >= 2000; $year--)
|
||||||
<div class="input-group">
|
<option value="{{ $year }}"
|
||||||
<select name="inventoryYear" id="inventoryYear" class="form-control">
|
{{ old('inventoryYear') == $year ? 'selected' : '' }}>
|
||||||
<option>SEMUA TAHUN</option>
|
{{ $year }}
|
||||||
@for ($year = date('Y'); $year >= 2000; $year--)
|
</option>
|
||||||
<option value="{{ $year }}"
|
@endfor
|
||||||
{{ old('inventoryYear') == $year ? 'selected' : '' }}>
|
</select>
|
||||||
{{ $year }}
|
|
||||||
</option>
|
|
||||||
@endfor
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table align-items-center mb-0 display" id="data-table" style="width:100%">
|
<table class="table w-100"
|
||||||
<thead>
|
data-search="true"
|
||||||
|
data-toggle="table"
|
||||||
|
data-pagination="true"
|
||||||
|
data-toolbar="#toolbar"
|
||||||
|
data-show-refresh="false"
|
||||||
|
data-url="{{route($route.'.grid')}}"
|
||||||
|
data-ajax-options='{"xhrFields": {"withCredentials": true}}'
|
||||||
|
data-sort-name="ids"
|
||||||
|
data-sort-order="desc"
|
||||||
|
data-page-size="10"
|
||||||
|
data-id-field="id"
|
||||||
|
id="grid-data">
|
||||||
|
<thead class="table-primary text-primary">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Waktu Input</th>
|
<th data-field="created_at">Waktu Input</th>
|
||||||
<th scope="col">Tahun Inventory</th>
|
<th data-field="inventory_year">Tahun Inventory</th>
|
||||||
<th scope="col">Sektor</th>
|
<th data-field="sector">Sektor</th>
|
||||||
<th scope="col">Status</th>
|
<th data-field="status">Status</th>
|
||||||
<th scope="col">Waktu Eksekusi</th>
|
<th data-field="executed_time">Waktu Eksekusi</th>
|
||||||
<th scope="col">Waktu Selesai</th>
|
<th data-field="finished_time">Waktu Selesai</th>
|
||||||
<th scope="col">Durasi</th>
|
<th data-field="duration">Durasi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody></tbody>
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -83,54 +80,6 @@
|
||||||
// allowClear: true,
|
// allowClear: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
var table = $('#data-table').DataTable({
|
|
||||||
pageLength: 10,
|
|
||||||
responsive: true,
|
|
||||||
serverSide: true,
|
|
||||||
scrollX: true,
|
|
||||||
searchDelay: 1000,
|
|
||||||
ajax: {
|
|
||||||
url: '{{ route('calculation.index') }}',
|
|
||||||
data: function(d) {
|
|
||||||
d.sectorFilter = $('#sector').val();
|
|
||||||
d.inventoryYearFilter = $('#inventoryYear').val();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
data: 'created_at',
|
|
||||||
name: 'created_at',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'inventory_year',
|
|
||||||
name: 'inventory_year'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'sector',
|
|
||||||
name: 'sector'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'status',
|
|
||||||
name: 'status'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'executed_time',
|
|
||||||
name: 'executed_time',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'finished_time',
|
|
||||||
name: 'finished_time',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'duration',
|
|
||||||
name: 'duration'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
order: [
|
|
||||||
[0, 'desc']
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#sector').change(function() {
|
$('#sector').change(function() {
|
||||||
table.draw();
|
table.draw();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,42 @@
|
||||||
@extends('layouts.master')
|
@extends('layouts.master')
|
||||||
|
|
||||||
@section('title', 'Salin Aktivitas')
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">Salin Aktivitas</h5>
|
<h5 class="mb-0 font-weight-bold">{{ $title }}</h5>
|
||||||
<button type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#copyModal">
|
<button type="button" class="btn btn-sm btn-primary float-right" data-bs-toggle="modal" data-bs-target="#copyModal">
|
||||||
Salin Aktivitas
|
{{ $title }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if (session('success'))
|
|
||||||
<div class="alert alert-success">
|
|
||||||
{{ session('success') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($errors->any())
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
@foreach ($errors->all() as $error)
|
|
||||||
<p>{{ $error }}</p>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table align-items-center mb-0 display" id="data-table" style="width:100%">
|
<table class="table w-100"
|
||||||
<thead>
|
data-search="true"
|
||||||
|
data-toggle="table"
|
||||||
|
data-pagination="true"
|
||||||
|
data-toolbar="#toolbar"
|
||||||
|
data-show-refresh="false"
|
||||||
|
data-url="{{route($route.'.grid')}}"
|
||||||
|
data-ajax-options='{"xhrFields": {"withCredentials": true}}'
|
||||||
|
data-sort-name="ids"
|
||||||
|
data-sort-order="desc"
|
||||||
|
data-page-size="10"
|
||||||
|
data-id-field="id"
|
||||||
|
id="grid-data">
|
||||||
|
<thead class="table-primary text-primary">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Waktu Input</th>
|
<th data-field="created_at">Waktu Input</th>
|
||||||
<th scope="col">Tahun Tujuan</th>
|
<th data-field="to_year">Tahun Tujuan</th>
|
||||||
<th scope="col">Tahun Sumber</th>
|
<th data-field="from_year">Tahun Sumber</th>
|
||||||
<th scope="col">Status</th>
|
<th data-field="status">Status</th>
|
||||||
<th scope="col">Waktu Eksekusi</th>
|
<th data-field="executed_time">Waktu Eksekusi</th>
|
||||||
<th scope="col">Waktu Selesai</th>
|
<th data-field="finished_time">Waktu Selesai</th>
|
||||||
<th scope="col">Durasi</th>
|
<th data-field="duration">Durasi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody></tbody>
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -52,11 +48,8 @@
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title" id="copyModalLabel">Salin Aktivitas</h5>
|
<h5 class="modal-title" id="copyModalLabel">Salin Aktivitas</h5>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<form action="{{ route('copy.store') }}" method="POST" id="copyForm">
|
<form action="{{ route($route.'.store') }}" method="POST" id="copyForm">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -72,7 +65,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="from_year">Tahun Sumber Data Aktivitas <span class="text-danger">*</span></label>
|
<label for="from_year">Tahun Sumber Data Aktivitas <span class="text-danger">*</span></label>
|
||||||
<select name="from_year" id="from_year" class="form-control w-100" required>
|
<select name="from_year" id="from_year" class="form-control" required>
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
@if (isset($availableYears) && count($availableYears) > 0)
|
@if (isset($availableYears) && count($availableYears) > 0)
|
||||||
@foreach ($availableYears as $year)
|
@foreach ($availableYears as $year)
|
||||||
|
|
@ -85,7 +78,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
||||||
<button type="submit" class="btn btn-primary">Salin</button>
|
<button type="submit" class="btn btn-primary">Salin</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -97,57 +90,7 @@
|
||||||
@section('js')
|
@section('js')
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#from_year').select2({
|
|
||||||
placeholder: 'Pilih Tahun',
|
|
||||||
width: '100%',
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#to_year').select2({
|
|
||||||
placeholder: 'Pilih Tahun',
|
|
||||||
width: '100%',
|
|
||||||
});
|
|
||||||
|
|
||||||
var table = $('#data-table').DataTable({
|
|
||||||
processing: true,
|
|
||||||
serverSide: true,
|
|
||||||
ajax: {
|
|
||||||
url: '{{ route('copy.index') }}',
|
|
||||||
data: function(d) {}
|
|
||||||
},
|
|
||||||
columns: [{
|
|
||||||
data: 'created_at',
|
|
||||||
name: 'created_at'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'to_year',
|
|
||||||
name: 'to_year'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'from_year',
|
|
||||||
name: 'from_year'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'status',
|
|
||||||
name: 'status'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'executed_time',
|
|
||||||
name: 'executed_time'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'finished_time',
|
|
||||||
name: 'finished_time'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'duration',
|
|
||||||
name: 'duration'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
order: [
|
|
||||||
[0, 'desc']
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#copyForm').on('submit', function(e) {
|
$('#copyForm').on('submit', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,40 @@
|
||||||
@extends('layouts.master')
|
@extends('layouts.master')
|
||||||
|
|
||||||
@section('title', 'Kunci Aktivitas')
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
{{-- <div class="container"> --}}
|
{{-- <div class="container"> --}}
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">Kunci Aktivitas</h5>
|
<h5 class="mb-0 font-weight-bold">{{ @$title }}</h5>
|
||||||
<button type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#lockModal">
|
<button type="button" class="btn btn-sm btn-primary float-right" data-bs-toggle="modal" data-bs-target="#lockModal">
|
||||||
Kunci Aktivitas
|
{{ @$title }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if (session('success'))
|
|
||||||
<div class="alert alert-success">
|
|
||||||
{{ session('success') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($errors->has('error'))
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
{{ $errors->first('error') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table align-items-center mb-0 display" id="data-table" style="width:100%">
|
<table class="table w-100"
|
||||||
<thead>
|
data-search="true"
|
||||||
|
data-toggle="table"
|
||||||
|
data-pagination="true"
|
||||||
|
data-toolbar="#toolbar"
|
||||||
|
data-show-refresh="false"
|
||||||
|
data-url="{{route($route.'.grid')}}"
|
||||||
|
data-ajax-options='{"xhrFields": {"withCredentials": true}}'
|
||||||
|
data-sort-name="ids"
|
||||||
|
data-sort-order="desc"
|
||||||
|
data-page-size="10"
|
||||||
|
data-id-field="id"
|
||||||
|
id="grid-data">
|
||||||
|
<thead class="table-primary text-primary">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Tahun Inventory</th>
|
<th data-width="150" data-field="action">#</th>
|
||||||
<th scope="col">Status</th>
|
<th data-field="inventory_year">Tahun Inventory</th>
|
||||||
<th scope="col">Waktu Eksekusi</th>
|
<th data-field="status">Status</th>
|
||||||
<th scope="col" width="20%">Aksi</th>
|
<th data-field="executed_time">Waktu Eksekusi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody></tbody>
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -49,11 +47,8 @@
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title" id="lockModalLabel">Kunci Tahun Inventory</h5>
|
<h5 class="modal-title" id="lockModalLabel">Kunci Tahun Inventory</h5>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<form action="{{ route('lock.lock') }}" method="POST" id="lockForm">
|
<form action="{{ route($route.'.lock') }}" method="POST" id="lockForm">
|
||||||
@csrf
|
@csrf
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -84,7 +79,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
||||||
<button type="submit" class="btn btn-primary">Kunci</button>
|
<button type="submit" class="btn btn-primary">Kunci</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -95,42 +90,7 @@
|
||||||
|
|
||||||
@section('js')
|
@section('js')
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
|
||||||
$('#data-table').DataTable({
|
|
||||||
pageLength: 10,
|
|
||||||
responsive: true,
|
|
||||||
serverSide: true,
|
|
||||||
scrollX: true,
|
|
||||||
searchDelay: 1000,
|
|
||||||
ajax: {
|
|
||||||
url: '{{ route('lock.index') }}',
|
|
||||||
type: 'GET',
|
|
||||||
dataSrc: 'data'
|
|
||||||
},
|
|
||||||
columns: [{
|
|
||||||
data: 'inventory_year',
|
|
||||||
name: 'inventory_year'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'status',
|
|
||||||
name: 'status'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'updated_at',
|
|
||||||
name: 'updated_at'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
data: 'action',
|
|
||||||
name: 'action',
|
|
||||||
orderable: false,
|
|
||||||
searchable: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
order: [
|
|
||||||
[0, 'desc']
|
|
||||||
]
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
$(document).on('click', 'form button', function(e) {
|
$(document).on('click', 'form button', function(e) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 font-weight-bold">Hitung Data dari Produsen</h5>
|
<h5 class="mb-0 font-weight-bold">Hitung Data dari Produsen</h5>
|
||||||
<button type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#lockModal">
|
<button type="button" class="btn btn-sm btn-primary float-right" data-toggle="modal" data-target="#lockModal">
|
||||||
Hitung Data
|
Hitung Data
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -191,16 +191,20 @@ Route::name('management.')->prefix('management')->group(function () {
|
||||||
Route::resource('pengumuman', PeraturanController::class)->names('pengaturan.pengumuman');
|
Route::resource('pengumuman', PeraturanController::class)->names('pengaturan.pengumuman');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('tool')->group(function () {
|
Route::prefix('kalkulasi')->name('kalkulasi.')->group(function () {
|
||||||
Route::resource('calculation', CalculationController::class)->only('index', 'create', 'store')->names('calculation');
|
|
||||||
|
|
||||||
Route::get('lock_activity', [LockActivityController::class, 'index'])->name('lock.index');
|
Route::get('kalkulasi-emisi/grid', [CalculationController::class, 'grid'])->name('kalkulasi-emisi.grid');
|
||||||
Route::post('lock_activity/lock', [LockActivityController::class, 'lock'])->name('lock.lock');
|
Route::resource('kalkulasi-emisi', CalculationController::class)->only('index', 'create', 'store')->names('kalkulasi-emisi');
|
||||||
Route::post('lock_activity/unlock', [LockActivityController::class, 'unlock'])->name('lock.unlock');
|
|
||||||
|
|
||||||
Route::resource('copy_activity', CopyActivityController::class)->only('index', 'store')->names('copy');
|
Route::get('kunci-aktivitas/grid', [LockActivityController::class, 'grid'])->name('kunci-aktivitas.grid');
|
||||||
|
Route::get('kunci-aktivitas', [LockActivityController::class, 'index'])->name('kunci-aktivitas.index');
|
||||||
|
Route::post('kunci-aktivitas/lock', [LockActivityController::class, 'lock'])->name('kunci-aktivitas.lock');
|
||||||
|
Route::post('kunci-aktivitas/unlock', [LockActivityController::class, 'unlock'])->name('kunci-aktivitas.unlock');
|
||||||
|
|
||||||
Route::resource('produsen_calculate', ProdusenCalculateController::class)->only('index', 'store')->names('produsenCalculate');
|
Route::get('salin-aktivitas/grid', [CopyActivityController::class, 'grid'])->name('salin-aktivitas.grid');
|
||||||
|
Route::resource('salin-aktivitas', CopyActivityController::class)->only('index', 'store')->names('salin-aktivitas');
|
||||||
|
|
||||||
|
Route::resource('hitung-produsen', ProdusenCalculateController::class)->only('index', 'store')->names('hitung-produsen');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('reports')->group(function () {
|
Route::prefix('reports')->group(function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue