added new structure controller function
This commit is contained in:
@@ -15,6 +15,11 @@ use App\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Corporation\CorpStructure;
|
||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class StructureController extends Controller
|
||||
{
|
||||
@@ -23,6 +28,68 @@ class StructureController extends Controller
|
||||
$this->middleware('permission:structure.operator');
|
||||
}
|
||||
|
||||
public function displayIndustryTaxes() {
|
||||
$this->middelware('role:Admin');
|
||||
|
||||
$corpId = 98287666;
|
||||
$months = 3;
|
||||
$name = array();
|
||||
|
||||
//Declare the structure tax helper class
|
||||
$sHelper = new StructureTaxHelper();
|
||||
|
||||
//Get the dates we are working with
|
||||
$dates = $sHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Get a list of structures
|
||||
$structures = StructureIndustryTaxJournal::select('context_id')
|
||||
->whereBetween('date', [$start, $end])
|
||||
->groupBy('context_id')
|
||||
->get();
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$token = EsiToken::where(['character_id' => 93738489])->get(['refresh_token']);
|
||||
|
||||
//Create an ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
|
||||
//Create the esi class varialble
|
||||
$esi = new Eseye($authentication);
|
||||
|
||||
//Cycle through all of the structures and build a list of names
|
||||
for($i = 0; $i < sizeof($structures); $i++) {
|
||||
//Get the structure name from the ESI API
|
||||
try {
|
||||
$temp = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
'structure_id' => $structures[$j]->context_id,
|
||||
]);
|
||||
|
||||
$name[$i] = $temp->name;
|
||||
} catch(RequestFailedException $e) {
|
||||
$name[$i] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
//Cycle through all of the structures and get the revenue
|
||||
for($j = 0; $j < sizeof($structures); $j++) {
|
||||
for($i = 0; $i < $months; $i++) {
|
||||
$totalTaxes[$i] = [
|
||||
'IndustryTaxes' => number_format($sHelper->GetIndustryTaxes($dates[$i]['start'], $dates[$i]['end'], $structures[$j])),
|
||||
'MonthStart' => $dates[$i]['start']->toFormattedDateString(),
|
||||
'Structure' => $name[$j],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return view('structures.taxhistory')->with(compact('totalTaxes', 'months'));
|
||||
}
|
||||
|
||||
public function chooseCorpTaxes() {
|
||||
$corps = CorpStructure::pluck('corporation_name', 'corporation_id');
|
||||
return view('structures.choosecorporation')->with('corps', $corps);
|
||||
|
||||
Reference in New Issue
Block a user