consolidated upcoming extractions with the mining calendar

This commit is contained in:
2021-03-08 21:56:46 +09:00
parent 2483ca525b
commit c68b419964

View File

@@ -97,6 +97,7 @@ class MiningTaxesController extends Controller
$config = config('esi'); $config = config('esi');
$sHelper = new StructureHelper($config['primary'], $config['corporation']); $sHelper = new StructureHelper($config['primary'], $config['corporation']);
$structures = array(); $structures = array();
$structuresCalendar = array();
$lava = new Lavacharts; $lava = new Lavacharts;
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) { if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
@@ -134,32 +135,34 @@ class MiningTaxesController extends Controller
$calendar = $lava->DataTable(); $calendar = $lava->DataTable();
$calendar->addDateTimeColumn('Date') $calendar->addDateTimeColumn('Date')
->addNumberColumn('Total'); ->addNumberColumn('Total')
->addStringColumn('Structure');
foreach($extractions as $extraction) { foreach($extractions as $extraction) {
$sInfo = $sHelper->GetStructureInfo($extraction->structure_id); $sInfo = $sHelper->GetStructureInfo($extraction->structure_id);
array_push($structures, [ array_push($structuresCalendar, [
'date' => $esiHelper->DecodeDate($extraction->chunk_arrival_time), 'date' => $esiHelper->DecodeDate($extraction->chunk_arrival_time),
'total' => 0, 'total' => 0,
'name' => $sInfo->name,
]); ]);
} }
foreach($extractions as $extraction) { foreach($extractions as $extraction) {
for($i = 0; $i < sizeof($structures); $i++) { for($i = 0; $i < sizeof($structures); $i++) {
//Create the dates in a carbon object, then only get the Y-m-d to compare. //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(); $tempStructureDate = Carbon::createFromFormat('Y-m-d H:i:s', $structuresCalendar[$i]['date'])->toDateString();
$extractionDate = Carbon::createFromFormat('Y-m-d H:i:s', $esiHelper->DecodeDate($extraction->chunk_arrival_time))->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 //check if the dates are equal then increase the total by 1
if($tempStructureDate == $extractionDate) { if($tempStructureDate == $extractionDate) {
$structures[$i]['total'] += 1; $structuresCalendar[$i]['total'] += 1;
} }
} }
} }
foreach($structures as $structure) { foreach($structuresCalendar as $str) {
$calendar->addRow([ $calendar->addRow([
$structure['date'], $str['date'],
$structure['total'], $str['total'],
]); ]);
} }