diff --git a/app/Http/Controllers/Logistics/FuelController.php b/app/Http/Controllers/Logistics/FuelController.php index 9b8aff585..b218356ef 100644 --- a/app/Http/Controllers/Logistics/FuelController.php +++ b/app/Http/Controllers/Logistics/FuelController.php @@ -23,58 +23,59 @@ class FuelController extends Controller //$this->middleware('permission:logistics.structures'); } - public function displayStructureFuel() { - $aHelper = new AssetHelper(null, null, null); + public function displayStructures() { + //Declare variables + $jumpGates = array(); + + //Declare the class helpers $sHelper = new StructureHelper(null, null, null); - $lava = new Lavacharts; - $gates = array(); - $i = 1; - - $jumpGates = $sHelper->GetStructuresByType('Ansiblex Jump Gate'); - - foreach($jumpGates as $jump) { - //Liquid Ozone's item id is 16273 - $lo = $aHelper->GetAssetByType(16273, $jump->structure_id); - - $temp = [ - 'id' => $i, - 'structure_id' => $jump->structure_id, - 'structure_name' => $jump->structure_name, - 'solar_system_name' => $jump->solar_system_name, - 'fuel_expires' => $jump->fuel_expires, - 'liquid_ozone' => $lo, - 'row' => 'Liquid Ozone ' . $i, - 'div' => 'Liquid-Ozone-' . $i . '-div', - ]; - - array_push($gates, $temp); - $i++; - } + $aHelper = new AssetHelper(null, null, null); + //Get all of the jump gates + $gates = $sHelper->GetStructuresByType('Ansiblex Jump Gate'); foreach($gates as $gate) { - $gateChart = $lava->DataTable(); - $gateChart->addStringColumn($gate['structure_name']) - ->addNumberColumn('Liquid Ozone') - ->addRow([$gate['row'], $gate['liquid_ozone']]); - - $lava->GaugeChart($gate['row'], $gateChart, [ - 'width' => 300, - 'redFrom' => 0, - 'redTo' => 50000, - 'yellowFrom' => 50000, - 'yellowTo' => 150000, - 'greenFrom' => 150000, - 'greenTo' => 1000000, - 'majorTicks' => [ - 'Critical', - 'Ok', - ], - ]); + $liquidOzone = $aHelper->GetAssetByType(16273, $gate->structure_id); + $temp = [ + 'name' => $gate->structure_name, + 'system' => $gate->solar_system_name, + 'fuel_expires' => $gate->fuel_expires, + 'liquid_ozone' => $liquidOzone, + 'link' => '/logistics/fuel/display/' . $gate->structure_id . '/', + ]; } - dd($lava); + return view('logistics.display.fuel')->with('gates', $gates); + } - return view('logistics.display.fuel')->with('lava', $lava) - ->with('gates', $gates); + /** + * Get the structure id passed to it and display fuel gauage for structure + */ + public function displayStructureFuel($id) { + //Declare class variables + $lava = new Lavacharts; + $aHelper = new AssetHelper(null, null, null); + //Get the quantity of liquid ozone in the structure + $liquidOzone = $aHelper->GetAssetByType(16273, $id); + + $gauge = $lava->DataTable(); + $gauge->addStringColumn('Fuel') + ->addNumberColumn('Liquid Ozone') + ->addRow(['Liquid Ozone', $liquidOzone]); + $lava->GaugeChart('Liquid Ozone', $gauge, [ + 'width' => 400, + 'redFrom' => 0, + 'redTo' => 75000, + 'yellowFrom' => 75000, + 'yellowTo' => 150000, + 'greenFrom' => 150000, + 'greenTo' => 1000000, + 'majorTicks' => [ + 'Empty', + 'Ok', + ], + ]); + + //Return the view + return view('logistics.display.fuelgauage')->with('lava', $lava); } } diff --git a/app/Library/Assets/AssetHelper.php b/app/Library/Assets/AssetHelper.php index 3eb6b0417..7a60e3f3c 100644 --- a/app/Library/Assets/AssetHelper.php +++ b/app/Library/Assets/AssetHelper.php @@ -110,13 +110,24 @@ class AssetHelper { * Get the liquid ozone asset */ public function GetAssetByType($type, $structureId) { + //See if the row is in the database table + $count = Asset::where([ + 'location_id' => $structureId, + 'type_id' => $type, + 'location_flag' => 'StructureFuel', + ])->count(); + //Get the row if it is in the table $asset = Asset::where([ 'location_id' => $structureId, 'type_id' => $type, 'location_flag' => 'StructureFuel', ])->first(); - return $asset['quantity']; + if($count == 0) { + return 0; + } else { + return $asset['quantity']; + } } /** diff --git a/resources/views/logistics/display/fuel.blade.php b/resources/views/logistics/display/fuel.blade.php index 3be500826..c22f9b0a1 100644 --- a/resources/views/logistics/display/fuel.blade.php +++ b/resources/views/logistics/display/fuel.blade.php @@ -1,8 +1,32 @@ @extends('layouts.b4') @section('content') -@foreach($gates as $gate) -
-{!! $lava->render('Gauge Chart', $gate['row'], $gate['div']) !!} -
-@endforeach +
+
+
+

Jump Gate Fuel Status

+
+
+ + + + + + + + + + @foreach($jumpGates as $jumpGate) + + + + + + + + @endforeach + +
Structure NameSystemFuel ExpiresLiquid Ozone QuantityFuel Gauge
{{ $jumpGate['name'] }}{{ $jumpGate['system'] }}{{ $jumpGate{'fuel_expires'} }}{{ $jumpGate['liquid_ozone'] }}Link
+
+
+
@endsection \ No newline at end of file diff --git a/resources/views/logistics/display/fuelgauge.blade.php b/resources/views/logistics/display/fuelgauge.blade.php new file mode 100644 index 000000000..7cf47edd1 --- /dev/null +++ b/resources/views/logistics/display/fuelgauge.blade.php @@ -0,0 +1,4 @@ +@extends('layouts.b4') +@section('content') + +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 15bc59c99..77c093c39 100644 --- a/routes/web.php +++ b/routes/web.php @@ -117,7 +117,8 @@ Route::group(['middleware' => ['auth']], function(){ Route::get('/logistics/courier/form', 'Logistics\LogisticsController@displayContractForm'); Route::post('/logistics/courier/form', 'Logistics\LogisticsController@displayContractDetails'); Route::get('/logistics/contracts/display', 'Logistics\LogisticsController@displayLogisticsContracts'); - Route::get('/logistics/fuel/display', 'Fuel\FuelController@displayStructureFuel'); + Route::get('/logistics/fuel/structures', 'Fuel\FuelController@displayStructures'); + Route::get('/logistics/fuel/display/{id}/', 'Fuel\FuelController@displayStructureFuel'); }); /**