diff --git a/app/Http/Controllers/Logistics/LogisticsController.php b/app/Http/Controllers/Logistics/LogisticsController.php index 913b51677..d60318e2a 100644 --- a/app/Http/Controllers/Logistics/LogisticsController.php +++ b/app/Http/Controllers/Logistics/LogisticsController.php @@ -8,6 +8,7 @@ use App\Http\Controllers\Controller; use Auth; use DB; use Carbon\Carbon; +use Khill\Lavacharts\Lavacharts; //Models use App\Models\Contracts\EveContract; @@ -18,55 +19,96 @@ use App\Library\Lookups\LookupHelper; class LogisticsController extends Controller { + public function __construct() { + $this->middleware('auth'); + } + /** * Function to display available contracts */ public function displayLogisticsContracts() { + $this->middelware('permissions:logistics.courier'); + //Get the non-accepted contracts + $openCount == EveContract::where(['status' => 'outstanding'])->count(); $open = EveContract::where([ 'status' => 'outstanding', ])->get(); - + + $inProgressCount = EveContract::where(['status' => 'in_progress'])->count(); $inProgress = EveContract::where([ 'status' => 'in_progress', ])->get(); + $cancelledCount = EveContract::where(['status' => 'cancelled'])->count(); $cancelled = EveContract::where([ 'status' => 'cancelled', ])->get(); + $failedCount = EveContract::where(['status' => 'failed'])->count(); $failed = EveContract::where([ 'status' => 'failed', ])->get(); + $deletedCount = EveContract::where(['status' => 'deleted'])->count(); $deleted = EveContract::where([ 'status' => 'deleted', ])->get(); + $finishedCount = EveContract::where(['status' => 'finished'])->count(); $finished = EveContract::where([ 'status' => 'finished', ])->get(); + $totalCount = $openCount + $inProgressCount + $cancelledCoutn + $failedCount + $deletedCount + $finishedCount; + + //Fuel Gauge Chart Declarations + $lava = new Lavacharts; + + $openChart = $lava->DataTable(); + $openChart->addStringColumn('Contracts') + ->addNumberColumn('Number') + ->addRow(['Open Contracts', $openCount]); + + $lava->GaugeChart('Open Contracts', $openChart, [ + 'width' => 300, + 'greenFrom' => 0, + 'greenTo' => 10, + 'yellowFrom' => 10, + 'yellowTo', 30, + 'redFrom' => 30, + 'redTo' => 100, + 'majorTicks' => [ + 'Normal', + 'Delayed', + 'Backed Up', + ], + ]); + + return view('logistics.display.contracts')->with('open', $open) ->with('inProgress', $inProgress) ->with('cancelled', $cancelled) ->with('failed', $failed) ->with('deleted', $deleted) - ->with('finished', $finished); - } - - /** - * Function to display current contracts user holds - */ - public function displayUserContracts() { - + ->with('finished', $finished) + ->with('openCount', $openCount) + ->with('inProgressCount', $inProgressCount) + ->with('cancelledCount', $cancelledCount) + ->with('failedCount', $failedCount) + ->with('deletedCount', $deletedCount) + ->with('finishedCount', $finishedCount) + ->with('totalCount', $totalCount) + ->with('lava', $lava); } /** * Function to calculate details needing to be set for contracts */ public function displayContractForm() { + $distances = SolarSystemDistance::all(); + return view('logistics.display.courierform'); } /** @@ -74,9 +116,8 @@ class LogisticsController extends Controller */ public function displayContractDetails(Request $request) { $this->validate($request, [ - 'start_location', - 'end_location', - 'type', + 'route', + 'volume', 'collateral', ]); diff --git a/app/Library/Contracts/EveContractsHelper.php b/app/Library/Contracts/EveContractsHelper.php index 317cbe89b..a071d8ad5 100644 --- a/app/Library/Contracts/EveContractsHelper.php +++ b/app/Library/Contracts/EveContractsHelper.php @@ -75,6 +75,22 @@ class EveContractsHelper { public function StoreNewContract($contract) { //Declare esi helper for decoding the date $esiHelper = new Esi; + $endLocationName = null; + $issuerCorporationName = null; + $issuerName = null; + $startLocationName = null; + + //Setup the esi authentication container + $config = config('esi'); + //Get the refresh token from the database + $token = EsiToken::where(['character_id', $this->charId])->get(['refresh_token']); + $authentication = new EsiAuthentication([ + 'client_id' => $config['client_id'], + 'secret' => $config['secret'], + 'refresh_token' => $token[0]->refresh_token, + ]); + //Setup the ESI variable + $esi = new Eseye($authentication); //See if we find the contract in the database $found = LogisticsContract::where([ diff --git a/app/Models/Logistics/LogisticContract.php b/app/Models/Logistics/LogisticContract.php new file mode 100644 index 000000000..4de311569 --- /dev/null +++ b/app/Models/Logistics/LogisticContract.php @@ -0,0 +1,27 @@ +increments('id'); $table->string('contract_id'); $table->string('accepted')->default('No'); + $table->string('accepted_by_id')->nullalbe(); + $table->string('accepted_by_name')->nullalbe(); $table->string('status')->default('N/A'); + $table->timestamps(); }); } @@ -67,6 +70,14 @@ class CreateLogisticsTables extends Migration $table->decimal('distance', 20, 6); }); } + + DB::table('solar_system_distances')->insert([ + 'start_id' + 'start_name' + 'end_id' + 'end_name' + 'distance' + ]); } /** diff --git a/resources/views/logistics/display/contracts.blade.php b/resources/views/logistics/display/contracts.blade.php new file mode 100644 index 000000000..632193068 --- /dev/null +++ b/resources/views/logistics/display/contracts.blade.php @@ -0,0 +1,110 @@ +@extends('layouts.b4') +@section('content') +@if($totalCount == 0) +
+
+

Logistics Contracts

+
+
+

No open logistics contracts

+
+
+@else +
+
+

Status

+
+
+
+ {!! $lava->render('GaugeChart', 'Open Contracts', 'gauge-status-div') !!} +
+
+
+
+

Open Contracts

+
+
+ + + + + + + + + + + @foreach($open as $op) + + + + + + + + + @endforeach + +
Date IssuedDays To CompleteCollateralRewardVolumeStatus
{{ $op->date_issued }}{{ $op->days_to_complete }}{{ $op->collateral }}{{ $op->reward }}{{ $op->volume }}{{ $op->status }}
+
+
+
+
+

In Progress Contracts

+
+
+ + + + + + + + + + + @foreach($inProgress as $in) + + + + + + + + + @endforeach + +
Date IssuedDays To CompleteCollateralRewardVolumeStatus
{{ $in->date_issued }}{{ $in->days_to_complete }}{{ $in->collateral }}{{ $in->reward }}{{ $in->volume }}{{ $in->status }}
+
+
+
+
+

Finished Contracts

+
+
+ + + + + + + + + + + @foreach($finished as $fin) + + + + + + + + + @endforeach + +
Date IssuedDays To CompleteCollateralRewardVolumeStatus
{{ $fin->date_issued }}{{ $fin->days_to_complete }}{{ $fin->collateral }}{{ $fin->reward }}{{ $fin->volume }}{{ $fin->status }}
+
+
+@endif +@endsection \ No newline at end of file diff --git a/resources/views/logistics/display/courier.blade.php b/resources/views/logistics/display/courier.blade.php new file mode 100644 index 000000000..7cf47edd1 --- /dev/null +++ b/resources/views/logistics/display/courier.blade.php @@ -0,0 +1,4 @@ +@extends('layouts.b4') +@section('content') + +@endsection \ No newline at end of file diff --git a/resources/views/logistics/display/courierform.blade.php b/resources/views/logistics/display/courierform.blade.php new file mode 100644 index 000000000..61f302792 --- /dev/null +++ b/resources/views/logistics/display/courierform.blade.php @@ -0,0 +1,33 @@ +@extends('layouts.b4') +@section('content') +
+
+
+

Courier Calculation Form

+
+
+ {!! Form::open([ + 'action' => 'Logistics\LogisticsController@displayContractDetails', + 'method' => 'POST', + ]) !!} +
+ {{ Form::label('route', 'Route') }} + {{ Form::select('route', $routes, 'None', ['class' => 'form-control']) }} +
+
+ {{ Form::label('volume', 'Volume') }} + {{ Form::text('volume', null, ['class' => 'form-control']) }} +
+
+ {{ Form::label('collateral', 'Collateral') }} + {{ Form::text('collateral', null, ['class' => 'form-control']) }} +
+
+ {{ Form::label('type', 'Type') }} + {{ Form::select('type', $type, 'None', ['class' => 'form-control']) }} +
+ {{ Form::submit('Submit', ['class' => 'btn btn-primary']) }} +
+
+
+@endsection \ No newline at end of file