form
This commit is contained in:
@@ -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',
|
||||
]);
|
||||
|
||||
|
||||
@@ -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([
|
||||
|
||||
27
app/Models/Logistics/LogisticContract.php
Normal file
27
app/Models/Logistics/LogisticContract.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Logistics;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LogisticContract extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'logistics_contracts';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'contract_id',
|
||||
'accepted',
|
||||
'accepted_by_id',
|
||||
'accepted_by_name',
|
||||
'status',
|
||||
];
|
||||
}
|
||||
27
app/Models/Logistics/SolarSystemDistance.php
Normal file
27
app/Models/Logistics/SolarSystemDistance.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SolarSystemDistance extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'solar_system_distances';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are fillable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'start_id',
|
||||
'start_name',
|
||||
'end_id',
|
||||
'end_name',
|
||||
'distance',
|
||||
];
|
||||
}
|
||||
@@ -45,7 +45,10 @@ class CreateLogisticsTables extends Migration
|
||||
$table->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'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
110
resources/views/logistics/display/contracts.blade.php
Normal file
110
resources/views/logistics/display/contracts.blade.php
Normal file
@@ -0,0 +1,110 @@
|
||||
@extends('layouts.b4')
|
||||
@section('content')
|
||||
@if($totalCount == 0)
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Logistics Contracts</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h3>No open logistics contracts</h3>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Status</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="gauge-status-div"></div>
|
||||
{!! $lava->render('GaugeChart', 'Open Contracts', 'gauge-status-div') !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Open Contracts</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th>Date Issued</th>
|
||||
<th>Days To Complete</th>
|
||||
<th>Collateral</th>
|
||||
<th>Reward</th>
|
||||
<th>Volume</th>
|
||||
<th>Status</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($open as $op)
|
||||
<tr>
|
||||
<td>{{ $op->date_issued }}</td>
|
||||
<td>{{ $op->days_to_complete }}</td>
|
||||
<td>{{ $op->collateral }}</td>
|
||||
<td>{{ $op->reward }}</td>
|
||||
<td>{{ $op->volume }}</td>
|
||||
<td>{{ $op->status }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>In Progress Contracts</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th>Date Issued</th>
|
||||
<th>Days To Complete</th>
|
||||
<th>Collateral</th>
|
||||
<th>Reward</th>
|
||||
<th>Volume</th>
|
||||
<th>Status</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($inProgress as $in)
|
||||
<tr>
|
||||
<td>{{ $in->date_issued }}</td>
|
||||
<td>{{ $in->days_to_complete }}</td>
|
||||
<td>{{ $in->collateral }}</td>
|
||||
<td>{{ $in->reward }}</td>
|
||||
<td>{{ $in->volume }}</td>
|
||||
<td>{{ $in->status }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Finished Contracts</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th>Date Issued</th>
|
||||
<th>Days To Complete</th>
|
||||
<th>Collateral</th>
|
||||
<th>Reward</th>
|
||||
<th>Volume</th>
|
||||
<th>Status</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($finished as $fin)
|
||||
<tr>
|
||||
<td>{{ $fin->date_issued }}</td>
|
||||
<td>{{ $fin->days_to_complete }}</td>
|
||||
<td>{{ $fin->collateral }}</td>
|
||||
<td>{{ $fin->reward }}</td>
|
||||
<td>{{ $fin->volume }}</td>
|
||||
<td>{{ $fin->status }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endsection
|
||||
4
resources/views/logistics/display/courier.blade.php
Normal file
4
resources/views/logistics/display/courier.blade.php
Normal file
@@ -0,0 +1,4 @@
|
||||
@extends('layouts.b4')
|
||||
@section('content')
|
||||
|
||||
@endsection
|
||||
33
resources/views/logistics/display/courierform.blade.php
Normal file
33
resources/views/logistics/display/courierform.blade.php
Normal file
@@ -0,0 +1,33 @@
|
||||
@extends('layouts.b4')
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h2>Courier Calculation Form</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{!! Form::open([
|
||||
'action' => 'Logistics\LogisticsController@displayContractDetails',
|
||||
'method' => 'POST',
|
||||
]) !!}
|
||||
<div class="form-group">
|
||||
{{ Form::label('route', 'Route') }}
|
||||
{{ Form::select('route', $routes, 'None', ['class' => 'form-control']) }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ Form::label('volume', 'Volume') }}
|
||||
{{ Form::text('volume', null, ['class' => 'form-control']) }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ Form::label('collateral', 'Collateral') }}
|
||||
{{ Form::text('collateral', null, ['class' => 'form-control']) }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ Form::label('type', 'Type') }}
|
||||
{{ Form::select('type', $type, 'None', ['class' => 'form-control']) }}
|
||||
</div>
|
||||
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user