consolidated upcoming extractions with the mining calendar
This commit is contained in:
@@ -191,97 +191,6 @@ class MiningTaxesController extends Controller
|
|||||||
->with('calendar', $calendar);
|
->with('calendar', $calendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display a calendar of upcoming extractions
|
|
||||||
*/
|
|
||||||
public function DisplayExtractionCalendar() {
|
|
||||||
//Declare variables
|
|
||||||
$structures = array();
|
|
||||||
$lava = new Lavacharts;
|
|
||||||
$esiHelper = new Esi;
|
|
||||||
$config = config('esi');
|
|
||||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
|
||||||
|
|
||||||
//Check for the correct scopes
|
|
||||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
|
||||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the correct scopes for the services site.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
|
||||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
|
||||||
|
|
||||||
//Get the esi data for extractions
|
|
||||||
try {
|
|
||||||
$extractions = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions', [
|
|
||||||
'corporation_id' => $config['corporation'],
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
Log::critical('Could not retrieve the extractions from ESI in DisplayExtractionCalendar in MiningTaxesController');
|
|
||||||
return redirect('/dashboard')->with('error', 'Failed to get extraction data from ESI');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a 3 month calendar for the past, current, and future extractions
|
|
||||||
*/
|
|
||||||
//Create the data tables
|
|
||||||
$calendar = $lava->DataTable();
|
|
||||||
|
|
||||||
$calendar->addDateTimeColumn('Date')
|
|
||||||
->addNumberColumn('Total');
|
|
||||||
|
|
||||||
foreach($extractions as $extraction) {
|
|
||||||
$sInfo = $sHelper->GetStructureInfo($extraction->structure_id);
|
|
||||||
array_push($structures, [
|
|
||||||
'date' => $esiHelper->DecodeDate($extraction->chunk_arrival_time),
|
|
||||||
'total' => 0,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($extractions as $extraction) {
|
|
||||||
for($i = 0; $i < sizeof($structures); $i++) {
|
|
||||||
//Create the dates in a carbon object, then only get the Y-m-d to compare.
|
|
||||||
$tempStructureDate = Carbon::createFromFormat('Y-m-d H:i:s', $structures[$i]['date'])->toDateString();
|
|
||||||
$extractionDate = Carbon::createFromFormat('Y-m-d H:i:s', $esiHelper->DecodeDate($extraction->chunk_arrival_time))->toDateString();
|
|
||||||
//check if the dates are equal then increase the total by 1
|
|
||||||
if($tempStructureDate == $extractionDate) {
|
|
||||||
$structures[$i]['total'] += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($structures as $structure) {
|
|
||||||
$calendar->addRow([
|
|
||||||
$structure['date'],
|
|
||||||
$structure['total'],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$lava->CalendarChart('Extractions', $calendar, [
|
|
||||||
'title' => 'Upcoming Extractions',
|
|
||||||
'unusedMonthOutlineColor' => [
|
|
||||||
'stroke' => '#ECECEC',
|
|
||||||
'strokeOpacity' => 0.75,
|
|
||||||
'strokeWidth' => 1,
|
|
||||||
],
|
|
||||||
'dayOfWeekLabel' => [
|
|
||||||
'color' => '#4f5b0d',
|
|
||||||
'fontSize' => 16,
|
|
||||||
'italic' => true,
|
|
||||||
],
|
|
||||||
'noDataPattern' => [
|
|
||||||
'color' => '#DDD',
|
|
||||||
'backgroundColor' => '#11FFFF',
|
|
||||||
],
|
|
||||||
'colorAxis' => [
|
|
||||||
'values' => [0, 5],
|
|
||||||
'colors' => ['green', 'red'],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
return view('miningtax.user.display.calendar')->with('calendar', $calendar)
|
|
||||||
->with('lava', $lava);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the ledger for the moons.
|
* Display the ledger for the moons.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,12 +18,6 @@
|
|||||||
<p>Extractions</p>
|
<p>Extractions</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
|
||||||
<a href="/miningtax/display/calendar" class="nav-link">
|
|
||||||
<i class="fas fa-cog nav-icon"></i>
|
|
||||||
<p>Calendar</p>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="/miningtax/display/ledgers" class="nav-link">
|
<a href="/miningtax/display/ledgers" class="nav-link">
|
||||||
<i class="fas fa-cog nav-icon"></i>
|
<i class="fas fa-cog nav-icon"></i>
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
@extends('layouts.user.dashb4')
|
|
||||||
@section('content')
|
|
||||||
<br>
|
|
||||||
<div class="container">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h2>Mining Calendar</h2>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div id="extractions_div"></div>
|
|
||||||
{!! $lava->render('CalendarChart', 'Extractions', 'extractions_div') !!}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
||||||
@@ -70,7 +70,6 @@ Route::group(['middleware' => ['auth']], function(){
|
|||||||
Route::get('/miningtax/display/invoices', 'MiningTaxes\MiningTaxesController@DisplayInvoices');
|
Route::get('/miningtax/display/invoices', 'MiningTaxes\MiningTaxesController@DisplayInvoices');
|
||||||
Route::get('/miningtax/display/extractions', 'MiningTaxes\MiningTaxesController@DisplayUpcomingExtractions');
|
Route::get('/miningtax/display/extractions', 'MiningTaxes\MiningTaxesController@DisplayUpcomingExtractions');
|
||||||
Route::get('/miningtax/display/ledgers', 'MiningTaxes\MiningTaxesController@DisplayMoonLedgers');
|
Route::get('/miningtax/display/ledgers', 'MiningTaxes\MiningTaxesController@DisplayMoonLedgers');
|
||||||
Route::get('/miningtax/display/calendar', 'MiningTaxes\MiningTaxesController@DisplayExtractionCalendar');
|
|
||||||
Route::get('/miningtax/admin/display/unpaid', 'MiningTaxes\MiningTaxesAdminController@DisplayUnpaidInvoice');
|
Route::get('/miningtax/admin/display/unpaid', 'MiningTaxes\MiningTaxesAdminController@DisplayUnpaidInvoice');
|
||||||
Route::post('/miningtax/admin/update/invoice', 'MiningTaxes\MiningTaxesAdminController@UpdateInvoice');
|
Route::post('/miningtax/admin/update/invoice', 'MiningTaxes\MiningTaxesAdminController@UpdateInvoice');
|
||||||
Route::post('/miningtax/admin/delete/invoice', 'MiningTaxes\MiningTaxesAdminController@DeleteInvoice');
|
Route::post('/miningtax/admin/delete/invoice', 'MiningTaxes\MiningTaxesAdminController@DeleteInvoice');
|
||||||
|
|||||||
Reference in New Issue
Block a user