Compare commits
371 Commits
v1
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
981245b503 | ||
| 5895f34c39 | |||
| ad6cfcb41f | |||
| a95c052ba0 | |||
| cc5bcbb97d | |||
| 94a30377f5 | |||
| 46da349088 | |||
| 667c7bfd49 | |||
| ebedcc903e | |||
| 425e430f8b | |||
| 8809c49c46 | |||
| c68b419964 | |||
| 2483ca525b | |||
| 7cccd77c8a | |||
| 1ccdfdac79 | |||
| fd899b1849 | |||
| c37d9fb949 | |||
| 85368ee09a | |||
| 2d9a3ce448 | |||
| 30d3a329dc | |||
| 8cff027f67 | |||
| c42f166eb1 | |||
| b8bd954b02 | |||
| 8945431457 | |||
| d799aad4f8 | |||
| 18b14f48bd | |||
| 856bab0a92 | |||
| 90c0accf58 | |||
| 5a640c3595 | |||
| 41a1abc9cb | |||
| 48dd5b81e3 | |||
| 6aa16464f8 | |||
| a3558fe4ef | |||
| 1d08027c11 | |||
| 9f7397feea | |||
| d2126bff48 | |||
| acb66d4a66 | |||
| 8d658aef1f | |||
| 62b2cc1003 | |||
| f642c759e2 | |||
| 350fd07efd | |||
| 1fbb438afa | |||
| b58e9e2820 | |||
| 28ef697b42 | |||
| 7dd625edb9 | |||
| fdb06996e5 | |||
| 36a33e86ff | |||
| 0c59a6527e | |||
| a1c6c4fd25 | |||
| 67c8d6161a | |||
| 1e55be001a | |||
| 7d3bd6d5f2 | |||
| aa25ce4be3 | |||
| 23111d727a | |||
| 4862deac95 | |||
| e185fd7b56 | |||
| 4855ac34f4 | |||
| fcf823663f | |||
| 27148dae22 | |||
| 1e40d8e0c9 | |||
| 4c513b7625 | |||
| 01f0a49bb4 | |||
| 1b949fca39 | |||
| 79de6a93fa | |||
| 3a18237502 | |||
| 8371c49e3d | |||
| e4a88303bb | |||
| c1595845f9 | |||
| 0b15850c15 | |||
| 75bfc0daf2 | |||
| 0f6b965066 | |||
| 68d04b338a | |||
| 674d026e51 | |||
| 137522fd02 | |||
| 186c79c8d3 | |||
| e2939629d5 | |||
| 25d0b8ae98 | |||
| 1156107243 | |||
| 460e7db116 | |||
| b746853520 | |||
| cd474b7e7f | |||
| 918107acab | |||
| 6dff921d5f | |||
| 9f1de2300e | |||
| 6d178b1b90 | |||
| 78234a9243 | |||
| ea60c5561d | |||
| 860863c8d5 | |||
| 0fb6bea722 | |||
| 693c66cf12 | |||
| 59868bb63a | |||
| e23c97f455 | |||
| a590dc43bb | |||
| 5c062ebe50 | |||
| 3bd1b2053b | |||
| d050563fb9 | |||
| 468eba7d2a | |||
| 8ebfc9fc34 | |||
| 77896aae9a | |||
| e12bfb75e9 | |||
| 22307c120f | |||
| 12b754a752 | |||
| 716a71d680 | |||
| d98ef78771 | |||
| e76e7a6298 | |||
| 225e6f74ec | |||
| 17bd69bf7c | |||
| 6d55eeae45 | |||
| 523e345350 | |||
| ca9612d830 | |||
| 9bfaab8ffc | |||
| c5cd63114d | |||
| e3f1e140e0 | |||
| 84d38d3803 | |||
| 2718b575a4 | |||
| 1451e97f31 | |||
| d031305111 | |||
| f270cf3134 | |||
| 16bca41d5d | |||
| 5df56e7f4f | |||
| bd068037cd | |||
| e794ef7a05 | |||
| a98c1e764f | |||
| b4ab55fc89 | |||
| fdf6c6a54f | |||
| 2d0241c8ad | |||
| b6853e8f3b | |||
| 14a37e869c | |||
| 9fc70ba03f | |||
| b092522d3a | |||
| d4b5ed3319 | |||
| 9cdf9cebfd | |||
| b538a7216c | |||
| 7be778ec01 | |||
| dedd050920 | |||
| 0b03b4ee4a | |||
| b75a7809de | |||
| fc07e8d968 | |||
| e3c9459017 | |||
| cb3a6b26e9 | |||
| f10196abb7 | |||
| 1743ffc14f | |||
| fc7dde27c4 | |||
| 7ebc49607d | |||
| f62f6239c0 | |||
| fa9d89ebe9 | |||
| af06c943c7 | |||
| 41b64ac646 | |||
| 8e72c71071 | |||
| 01bff58169 | |||
| 23873033bf | |||
| fcb0dbc7a0 | |||
| 896f6896e7 | |||
| e7c8b71ea4 | |||
| ed529b49df | |||
| 1a0e956d00 | |||
| 6bfa5873a8 | |||
| ff879833be | |||
| 525dddf52b | |||
| 71a567e923 | |||
| f179c7e671 | |||
| 40a4ce6fcc | |||
| c95f6835ca | |||
| 27a9715aa4 | |||
| 1717b464af | |||
| 7103791378 | |||
| bb1cb4a6fc | |||
| 65bd6022ac | |||
| 7be3bfeebc | |||
| a1e43596c2 | |||
| 02db5ce9a1 | |||
| e14f9c0764 | |||
| 5aafbc9ce0 | |||
| aa384fc171 | |||
| 93d9b2bf98 | |||
| 4cb79433c1 | |||
| 3725c40d03 | |||
| a4b665f525 | |||
| 5bbfaf1515 | |||
| 7aaf2afc5a | |||
| 8b827fe05b | |||
| d3db43de8b | |||
| 8f64a98e2d | |||
| f21d0dbf65 | |||
| 96c4b03481 | |||
| 3d04e3e62a | |||
| 51bb819409 | |||
| ecb33befdd | |||
| 5844dc5b93 | |||
| d71e05303d | |||
| 908197ae07 | |||
| 0aade82862 | |||
| fef8533ae0 | |||
| 376c9f9b91 | |||
| 92e7084cec | |||
| 7e932123d3 | |||
| 5e002d47a5 | |||
| f8a02c0933 | |||
| b94e39b53c | |||
| eaa56c31b6 | |||
| 4a117c6390 | |||
| 05db82f3cb | |||
| 99d5ef9220 | |||
| 8a4615b5a8 | |||
| fd20fb8725 | |||
| d521a0e593 | |||
| bb90a2ccc2 | |||
| f447bd6666 | |||
| f66604ba6a | |||
| ae37aa5856 | |||
| 4955a1a66a | |||
| 0da231827e | |||
| 5bd545efbe | |||
| 653c80cb87 | |||
| bea3cdd1a4 | |||
| 21aa932bd4 | |||
| 0b43349fac | |||
| 337cf04334 | |||
| 612f0925bf | |||
| 4b72a59e62 | |||
| 8af676c32a | |||
| 5cf8667c47 | |||
| 9dd0bbc536 | |||
| 63c7a04998 | |||
| 2026ea2c00 | |||
| 917641e469 | |||
| 925b9739da | |||
| 4da6e98c49 | |||
| b621e60316 | |||
| c35645df42 | |||
| f922289c03 | |||
| 2ab5f7d7bd | |||
| d4cf2afd1b | |||
| 86bd6cdd3b | |||
| 52af89800e | |||
| 830c360664 | |||
| 3231c4c1aa | |||
| d1aadb1f2d | |||
| 3c831b6b16 | |||
| a3d22ab179 | |||
| 5bb8853714 | |||
| 8e42f49d8f | |||
| a550240f08 | |||
| 32a19cb9d6 | |||
| b27dd18951 | |||
| 2a25fcf1b3 | |||
| 28fbf15706 | |||
| 2a5870ce9b | |||
| d5eb1a1bb9 | |||
| 9688e80a6b | |||
| 2212d34dd1 | |||
| 4eaab96848 | |||
| 15988c5588 | |||
| 81978d524f | |||
| 4f5c0e9c81 | |||
| 7a63f1370f | |||
| d54bb575ba | |||
| 2110cbff32 | |||
| 67af1f5b50 | |||
| 078d32cc31 | |||
| 6fcf9eba4a | |||
| 6d7864751f | |||
| 153588738d | |||
| e951285456 | |||
| 344974362c | |||
| b74e28388a | |||
| 509b0efdcd | |||
| 7901708be7 | |||
| 9f7a3500dc | |||
| 2bd74359ba | |||
| 84bac3431b | |||
| 84259f2bf7 | |||
| 23b3858a89 | |||
| 9c9f6c61fe | |||
| e8cf2810a0 | |||
| 5be7ef76bd | |||
| 8aa3d6177e | |||
| e7f564054c | |||
| 6a6151bff8 | |||
| 0ce7d24f69 | |||
| 6e7ec0564f | |||
| 5de85508a3 | |||
| 7d7ae6ffa9 | |||
| cfea3f4b90 | |||
| 17c31d9968 | |||
| 3de8c8b47d | |||
| 078067b6a7 | |||
| 8453b0c846 | |||
| 5a65b67245 | |||
| 6d75548144 | |||
| cb6da0c090 | |||
| f6c93028cc | |||
| 3d301f58c2 | |||
| 492a049797 | |||
| 3c776bc01e | |||
| 5cf77c6b18 | |||
| e16569b26b | |||
| d976d191cb | |||
| 6e623b5793 | |||
| a818452857 | |||
| dd5c1f4c2d | |||
| 338bd52f28 | |||
| 97e80c0456 | |||
| f1dca60e54 | |||
| ab8d501cb8 | |||
| 849b60841d | |||
| 1cbd2e7c87 | |||
| 17239b3a35 | |||
| e88728125e | |||
| f8426666ee | |||
| 0a11a5d23d | |||
| cf1876e43f | |||
| ac5ccadc55 | |||
| 75cc0b2355 | |||
| d8a198809e | |||
| a4b5ba0594 | |||
| 18fe063ef8 | |||
| a26db2652c | |||
| ab1730cfa3 | |||
| 8dbe424ad4 | |||
| bb4736187f | |||
| 62f661efa5 | |||
| 8178327828 | |||
| 19730208a6 | |||
| 90fcabc59b | |||
| eabbf5ce58 | |||
| 8ab88d29f3 | |||
| 0bb5f4cabf | |||
| e8649811f2 | |||
| df510b8680 | |||
| 3ff24118a5 | |||
| d4954bc7bf | |||
| 416f4abd03 | |||
| 314dd1c931 | |||
| 0e6ee620cc | |||
| 997e6a9cde | |||
| 23b78d709f | |||
| 46f95aa6f2 | |||
| 672d555c78 | |||
| ebbfd1a327 | |||
| 8ac0157cc6 | |||
| c55a5a1ba4 | |||
| ee8ab5c2f3 | |||
| 451119c743 | |||
| 20a0aecee1 | |||
| cc3ebc8af8 | |||
| b6efe4e54c | |||
| b598189626 | |||
| 70b3162964 | |||
| 66dbdef629 | |||
| c00324a03c | |||
| 2e8f2923ef | |||
| 3a33fa7faa | |||
| 38823b96ce | |||
| 9efb326b5f | |||
| f327b14fca | |||
| 6d88c9b703 | |||
| a5532120e9 | |||
| 34422925f1 | |||
| 70b24695f5 | |||
| af05210a48 | |||
| cfa01428ee | |||
| d84326742f | |||
| 722311eb89 | |||
| f11360e5e8 | |||
| 07b724ec55 | |||
| 5ef8fe188b | |||
| fda7c64c3a | |||
| b7e265088a | |||
| 017f72b42e | |||
| 0ddd298350 |
16
.env
16
.env
@@ -10,8 +10,8 @@ DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=w4rpservices2
|
||||
DB_USERNAME=minerva
|
||||
DB_PASSWORD=strtmage
|
||||
DB_USERNAME=
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@@ -33,13 +33,9 @@ MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
ESI_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||
ESI_SECRET_KEY=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||
ESI_USERAGENT='W4RP Services'
|
||||
ESI_CALLBACK_URI='http://services.w4rp.space/callback'
|
||||
ESI_CLIENT_ID=
|
||||
ESI_SECRET_KEY=
|
||||
ESI_USERAGENT=
|
||||
ESI_CALLBACK_URI=
|
||||
ESI_PRIMARY_CHAR=93738489
|
||||
ESI_ALLIANCE=99004116
|
||||
|
||||
EVEONLINE_CLIENT_ID=e5848fea3618427a8ee0dccb6a04fc62
|
||||
EVEONLINE_CLIENT_SECRET=TdnNGRM8RTNSifZdaIc9yHTTkYPgYEEXHRIbT6oY
|
||||
EVEONLINE_REDIRECT='https://services.w4rp.space/callback'
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Assets;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
//Job
|
||||
use App\Jobs\ProcessAssetsJob;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
class GetAssetsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetAssets';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Gets all of the assets of the holding corporation.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$assets = null;
|
||||
$pages = 0;
|
||||
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('GetAssets');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
|
||||
//Declare some variables
|
||||
$charId = $config['primary'];
|
||||
$corpId = 98287666;
|
||||
|
||||
//ESI Scope Check
|
||||
$esiHelper = new Esi();
|
||||
$assetScope = $esiHelper->HaveEsiScope($config['primary'], 'esi-assets.read_corporation_assets.v1');
|
||||
|
||||
if($assetScope == false) {
|
||||
Log::critical("Scope check for esi-assets.read_corporation_assets.v1 failed.");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
//Create the authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$assets = $esi->page(1)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch (RequestFailedException $e) {
|
||||
Log::critical("Failed to get asset list.");
|
||||
return null;
|
||||
}
|
||||
|
||||
$pages = $assets->pages;
|
||||
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
ProcessAssetsJob::dispatch($charId, $corpId, $i)->onQueue('assets');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Corps;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Corporation\AllianceCorp;
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
|
||||
//Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class GetCorpsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetCorps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get corporations in alliance and store in db.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('CorpJournal');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//try the esi call to get all of the corporations in the alliance
|
||||
try {
|
||||
$corporations = $esi->invoke('get', '/alliances/{alliance_id}/corporations/', [
|
||||
'alliance_id' => 99004116,
|
||||
]);
|
||||
} catch(RequestFailedException $e){
|
||||
dd($e->getEsiResponse());
|
||||
}
|
||||
//Delete all of the entries in the AllianceCorps table
|
||||
AllianceCorp::truncate();
|
||||
|
||||
//Foreach corporation, make entries into the database.
|
||||
foreach($corporations as $corp) {
|
||||
try {
|
||||
$corpInfo = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corp,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
$entry = new AllianceCorp;
|
||||
$entry->corporation_id = $corp;
|
||||
$entry->name = $corpInfo->name;
|
||||
$entry->save();
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class CleanStaleDataCommand extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:CleanData';
|
||||
protected $signature = 'data:CleanData';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
||||
@@ -5,13 +5,10 @@ namespace App\Console\Commands\Data;
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
use App\Models\Stock\Asset;
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class EmptyJumpBridges extends Command
|
||||
{
|
||||
@@ -20,7 +17,7 @@ class EmptyJumpBridges extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:EmptyJumpBridges';
|
||||
protected $signature = 'data:EmptyJumpBridges';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -46,16 +43,8 @@ class EmptyJumpBridges extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$task = new CommandHelper('EmptyJumpBridges');
|
||||
|
||||
//Add entry into the table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
Structure::truncate();
|
||||
Service::truncate();
|
||||
Asset::truncate();
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
|
||||
80
app/Console/Commands/Data/GetCorpsCommand.php
Normal file
80
app/Console/Commands/Data/GetCorpsCommand.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Models
|
||||
use App\Models\Corporation\AllianceCorp;
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
|
||||
//Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class GetCorpsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:GetCorps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get corporations in alliance and store in db.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//try the esi call to get all of the corporations in the alliance
|
||||
try {
|
||||
$corporations = $esi->invoke('get', '/alliances/{alliance_id}/corporations/', [
|
||||
'alliance_id' => 99004116,
|
||||
]);
|
||||
} catch(RequestFailedException $e){
|
||||
dd($e->getEsiResponse());
|
||||
}
|
||||
//Delete all of the entries in the AllianceCorps table
|
||||
AllianceCorp::truncate();
|
||||
|
||||
//Foreach corporation, make entries into the database.
|
||||
foreach($corporations as $corp) {
|
||||
try {
|
||||
$corpInfo = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corp,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
$entry = new AllianceCorp;
|
||||
$entry->corporation_id = $corp;
|
||||
$entry->name = $corpInfo->name;
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,6 @@ namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Moons\PurgeMoonLedgerJob;
|
||||
@@ -46,11 +41,6 @@ class PurgeCorpMoonLedgers extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$task = new CommandHelper('PurgeCorpLedgers');
|
||||
$task->SetStartStatus();
|
||||
|
||||
PurgeMoonLedgerJob::dispatch();
|
||||
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Users;
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
@@ -9,7 +9,6 @@ use Log;
|
||||
//Libraries
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Wiki\WikiHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
@@ -19,9 +18,6 @@ use App\Models\Esi\EsiToken;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
|
||||
|
||||
/**
|
||||
* The PurgeUsers command takes care of updating any user changes in terms of login role, as well as purging any users without at least
|
||||
@@ -35,7 +31,7 @@ class PurgeUsers extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:PurgeUsers';
|
||||
protected $signature = 'data:PurgeUsers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -187,13 +183,6 @@ class PurgeUsers extends Command
|
||||
EsiToken::where([
|
||||
'character_id' => $user->character_id,
|
||||
])->delete();
|
||||
|
||||
//Delete the user from the wiki
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
//Get the uid from the wiki tables utilizing the character's name
|
||||
$uid = DokuUser::where(['name' => $user->name])->first();
|
||||
$wikiHelper->DeleteWikiUser($uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
app/Console/Commands/Data/Test.php
Normal file
59
app/Console/Commands/Data/Test.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\ScheduledTask\ScheduleJob;
|
||||
|
||||
//Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use App\Library\Helpers\FinanceHelper;
|
||||
|
||||
class Test extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:test';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Test ESI stuff.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$helper = new FinanceHelper;
|
||||
$config = config('esi');
|
||||
$startTime = time();
|
||||
$receipt = $helper->GetApiWalletJournal(1, $config['primary']);
|
||||
$endTime = time();
|
||||
var_dump($endTime - $startTime);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,10 @@
|
||||
namespace App\Console\Commands\Eve;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use Comamnds\Library\CommandHelper;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;
|
||||
@@ -45,14 +44,19 @@ class ItemPricesUpdateCommand extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$task = new CommandHelper('ItemPriceUpdate');
|
||||
//Declare variables
|
||||
$moonHelper = new MoonCalc;
|
||||
$task = new CommandHelper('ItemPricesUpdateCommand');
|
||||
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
$moonHelper = new MoonCalc;
|
||||
//Fetch new prices from fuzzwork.co.uk for the item pricing schemes
|
||||
$moonHelper->FetchNewPrices();
|
||||
|
||||
//ItemPricesUpdateJob::dispatch()->onQueue('default');
|
||||
|
||||
//Set the task as completed
|
||||
$task->SetStopStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessWalletJournalJob;
|
||||
|
||||
class HoldingFinancesCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:HoldingJournal';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the holding corps finances.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('HoldingFinances');
|
||||
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Setup the Finances container
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get the total pages for the journal for the holding corporation
|
||||
$pages = $finance->GetJournalPageCount(1, $config['primary']);
|
||||
|
||||
//Dispatch a single job for each page to process
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
ProcessWalletJournalJob::dispatch(1, $config['primary'], $i)->onQueue('journal');
|
||||
}
|
||||
|
||||
//Get the total pages for the journal for the sov bills from the holding corporation
|
||||
$pages = $finance->GetJournalPageCount(6, $config['primary']);
|
||||
|
||||
//Dispatch a job for each page to process
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
ProcessWalletJournalJob::dispatch(6, $config['primary'], $i)->onQueue('journal');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessWalletJournalJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Finances\AllianceMarketTax;
|
||||
use App\Library\Finances\CorpMarketTax;
|
||||
use App\Library\Finances\MarketTax;
|
||||
use App\Library\Finances\PlayerDonation;
|
||||
use App\Library\Finances\ReprocessingTax;
|
||||
use App\Library\Finances\JumpBridgeTax;
|
||||
use App\Library\Finances\StructureIndustryTax;
|
||||
use App\Library\Finances\OfficeFee;
|
||||
use App\Library\Finances\PlanetProductionTax;
|
||||
use App\Library\Finances\PISale;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Finances\SovBillExpenses;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
class SovBillsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:SovBills';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the holding corps sov bills from wallet 6.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$sovBill = new SovBillExpenses;
|
||||
$esiHelper = new Esi;
|
||||
$finance = new FinanceHelper();
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('SovBills');
|
||||
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Create an ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$char = $lookup->GetCharacterInfo($config['primary']);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Get the total pages for the journal for the sov bills from the holding corporation
|
||||
$pages = $finance->GetJournalPageCount(6, $config['primary']);
|
||||
|
||||
//Try to figure it out from the command itself.
|
||||
for($i = 1; $i <= $pages; $i++) {
|
||||
printf("Getting page: " . $i . "\n");
|
||||
|
||||
try {
|
||||
$journals = $esi->page($i)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => 6,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
dd($wallet);
|
||||
foreach($wallet as $entry) {
|
||||
if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||
$sovBill->InsertSovBillExpense($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\FinanceHelper;
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class UpdateAllianceWalletJournal extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'finances:UpdateJournals';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = "Update the holding corporation's finance journal.";
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$fHelper = new FinanceHelper;
|
||||
$config = config('esi');
|
||||
$task = new CommandHelper('UpdateAllianceWalletJournal');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
$fHelper->GetApiWalletJournal(1, $config['primary']);
|
||||
|
||||
//Set the task as stopped
|
||||
$task->SetStopStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Flex;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Flex\FlexStructure;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class FlexStructureCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:FlexStructures';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mail out reminder for flex structure bills';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the new command helper container
|
||||
$task = new CommandHelper('FlexStructureMailer');
|
||||
//Add the entry into the jobs table saying the job has started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Create other variables
|
||||
$body = null;
|
||||
$delay = 5;
|
||||
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
$today->second = 2;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get all of the contacts for the flex structures
|
||||
$contacts = FlexStructure::select('requestor_id')->orderBy('requestor_id')->get();
|
||||
|
||||
//For each of the contacts, send a reminder mail about the total of the structures they are paying for
|
||||
foreach($contacts as $contact) {
|
||||
//Get all of the structures for requestor
|
||||
$structures = FlexStructure::where([
|
||||
'requestor_id' => $contact->requestor_id,
|
||||
])->get();
|
||||
|
||||
//Totalize the total cost of everything
|
||||
$totalCost = $this->TotalizeCost($structures);
|
||||
|
||||
//Build the body of the mail
|
||||
$body = "Flex Structure Overhead Cost is due for the following structures:<br>";
|
||||
foreach($structures as $structure) {
|
||||
|
||||
$body .= "System: " . $structure->system . " - " . $structure->structure_type . ": " . $structure->structure_cost . " ISK<br>";
|
||||
}
|
||||
$body .= "Total Cost: " . number_format($totalCost, 2,".", ",");
|
||||
$body .= "Please remit payment to Spatial Forces by the 3rd of the month.<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Dispatch the mail job
|
||||
$subject = "Warped Intentions Flex Structures Payment Due for " . $today->englishMonth;
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$structure->requestor_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
|
||||
//Increment the delay for the mail to not hit the rate limits
|
||||
$delay += 60;
|
||||
|
||||
//After the mail is dispatched, save the sent mail record
|
||||
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$structure->requestor_id, 'character');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
|
||||
private function TotalizeCost($structures) {
|
||||
//Declare the total cost
|
||||
$totalCost = 0.00;
|
||||
|
||||
foreach($structures as $structure) {
|
||||
$totalCost += $structure->structure_cost;
|
||||
}
|
||||
|
||||
return $totalCost;
|
||||
}
|
||||
|
||||
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||
$sentmail = new SentMail;
|
||||
$sentmail->sender = $sender;
|
||||
$sentmail->subject = $subject;
|
||||
$sentmail->body = $body;
|
||||
$sentmail->recipient = $recipient;
|
||||
$sentmail->recipient_type = $recipientType;
|
||||
$sentmail->save();
|
||||
}
|
||||
}
|
||||
155
app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php
Normal file
155
app/Console/Commands/MiningTaxes/MiningTaxesInvoices.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class MiningTaxesInvoices extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'MiningTax:Invoice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mining Taxes Invoice Command';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
$body = null;
|
||||
$task = new CommandHelper('MiningTaxesInvoices');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get the characters for each non-invoiced ledger entry
|
||||
$charIds = Ledger::distinct('character_id')->pluck('character_id');
|
||||
|
||||
//Foreach character tally up the mining ledger.
|
||||
foreach($charIds as $charId) {
|
||||
//Declare some variables we need for each iteration of the loop
|
||||
$invoice = array();
|
||||
$ores = array();
|
||||
$totalPrice = 0.00;
|
||||
|
||||
//Get the rows from the database for each character and the requirement of not been invoiced yet
|
||||
$rows = Ledger::where([
|
||||
'character_id' => $charId,
|
||||
'invoiced' => 'No',
|
||||
])->get()->toArray();
|
||||
|
||||
var_dump($rows);
|
||||
|
||||
//Taly up the item composition from each row and multiply by the quantity
|
||||
foreach($rows as $row) {
|
||||
if(!isset($ores[$row['type_id']])) {
|
||||
$ores[$row['type_id']] = 0;
|
||||
}
|
||||
$ores[$row['type_id']] = $ores[$row['type_id']] + $row['quantity'];
|
||||
|
||||
//Add up the total price from the ledger rows for the report later
|
||||
$totalPrice = $totalPrice + $row['amount'];
|
||||
}
|
||||
|
||||
//Reduce the total price by the take percentage
|
||||
$invoiceAmount = $totalPrice * 0.10;
|
||||
$invoiceAmount = round($invoiceAmount, 2);
|
||||
|
||||
//Get the character name from the character id
|
||||
$charName = $lookup->CharacterIdToName($charId);
|
||||
|
||||
//Generate a unique invoice id
|
||||
$invoiceId = uniqid();
|
||||
|
||||
//Save the invoice model
|
||||
$invoice = new Invoice;
|
||||
$invoice->character_id = $charId;
|
||||
$invoice->character_name = $charName;
|
||||
$invoice->invoice_id = $invoiceId;
|
||||
$invoice->invoice_amount = $invoiceAmount;
|
||||
$invoice->date_issued = Carbon::now();
|
||||
$invoice->date_due = Carbon::now()->addDays(7);
|
||||
$invoice->status = 'Pending';
|
||||
$invoice->save();
|
||||
|
||||
//Update the ledger entries
|
||||
Ledger::where([
|
||||
'character_id' => $charId,
|
||||
'invoiced' => 'No',
|
||||
])->update([
|
||||
'invoiced' => 'Yes',
|
||||
'invoice_id' => $invoiceId,
|
||||
]);
|
||||
|
||||
//Create the mail body
|
||||
$body .= "Dear Miner,<br><br>";
|
||||
$body .= "Mining Taxes are due for the following ores mined from alliance moons: <br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), 0, ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "Please remit " . number_format($totalPrice, 2, ".", ",") . " ISK to Spatial Forces by " . $invoice->date_due . "<br>";
|
||||
$body .= "Set the reason for transfer as MMT: " . $invoice->invoice_id . "<br>";
|
||||
$body .= "<br><br>";
|
||||
$body .= "You can also send a contract with the following ores in the contract with the reason set as MMT: " . $invoice->invoice_id . "<br>";
|
||||
foreach($ores as $ore => $quantity) {
|
||||
$oreName = $lookup->ItemIdToName($ore);
|
||||
$body .= $oreName . ": " . number_format(round($quantity * $config['mining_tax']), ".", ",") . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
|
||||
|
||||
//Mail the invoice to the character if the character is in
|
||||
//Warped Intentions or Legacy
|
||||
$subject = 'Warped Intentions Mining Taxes';
|
||||
$sender = $config['primary'];
|
||||
$recipientType = 'character';
|
||||
$recipient = $charId;
|
||||
|
||||
//Send the Eve Mail Job to the queue to be dispatched
|
||||
ProcessSendEveMailJob::dispatch($body, $recipient, $recipientType, $subject, $sender)->onQueue('mail');
|
||||
}
|
||||
|
||||
//Set the task as stopped
|
||||
$task->SetStopStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
138
app/Console/Commands/MiningTaxes/MiningTaxesLedgers.php
Normal file
138
app/Console/Commands/MiningTaxes/MiningTaxesLedgers.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
//Jobs
|
||||
//use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesLedgersJob;
|
||||
|
||||
class MiningTaxesLedgers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'MiningTax:Ledgers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Start getting the mining ledgers.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('MiningTaxesLedger');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get the site configuration which holds some data we need
|
||||
$config = config('esi');
|
||||
//Get the observers from the database
|
||||
$observers = Observer::all();
|
||||
//Job Variables to be moved later
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$mHelper = new MoonCalc;
|
||||
$esiHelper = new Esi;
|
||||
/*
|
||||
//For each of the observers, send a job to fetch the mining ledger
|
||||
foreach($observers as $obs) {
|
||||
//Dispatch the mining taxes ledger jobs
|
||||
FetchMiningTaxesLedgersJob::dispatch($config['primary'], $config['corporation'], $obs->observer_id)->onQueue('miningtaxes');
|
||||
}
|
||||
*/
|
||||
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
foreach($observers as $obs) {
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $config['corporation'],
|
||||
'observer_id' => $obs->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the mining ledger in FetchMiningTaxesLedgersCommand for observer id: ' . $this->observerId);
|
||||
return null;
|
||||
}
|
||||
|
||||
$ledgers = json_decode($response->raw);
|
||||
|
||||
foreach($ledgers as $ledger) {
|
||||
//Get some basic information we need to work with
|
||||
$charName = $lookup->CharacterIdToName($ledger->character_id);
|
||||
//Get the type name from the ledger ore stuff
|
||||
$typeName = $lookup->ItemIdToName($ledger->type_id);
|
||||
//Get the price from the helper function
|
||||
$price = $mHelper->CalculateOrePrice($ledger->type_id);
|
||||
//Calculate the total price based on the amount
|
||||
$amount = $price * $ledger->quantity;
|
||||
|
||||
//Insert or update the entry in the database
|
||||
$item = Ledger::updateOrCreate([
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charName,
|
||||
'observer_id' => $obs->observer_id,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore_name' => $typeName,
|
||||
'quantity' => $ledger->quantity,
|
||||
'amount' => $amount,
|
||||
], [
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charName,
|
||||
'observer_id' => $obs->observer_id,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore_name' => $typeName,
|
||||
'quantity' => $ledger->quantity,
|
||||
'amount' => $amount,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
//Clean up old data
|
||||
//Ledger::where(['updated_at', '<', Carbon::now()->subDays(120)])->delete();
|
||||
|
||||
//Return 0
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
119
app/Console/Commands/MiningTaxes/MiningTaxesObservers.php
Normal file
119
app/Console/Commands/MiningTaxes/MiningTaxesObservers.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Commands\Library\CommandHelper;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\FetchMiningTaxesObserversJob;
|
||||
|
||||
class MiningTaxesObservers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'MiningTax:Observer';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get mining tax observers.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('MiningTaxesObservers');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
$startTime = time();
|
||||
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
Log::critical('Esi scopes were not found for FetchMiningTaxesObserversJob.');
|
||||
print("Esi scopes not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
$char = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Get the refresh token for the character
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $char->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get moon observers in FetchMiningTaxesObservers");
|
||||
Log::critical($e);
|
||||
dd($e);
|
||||
}
|
||||
|
||||
$resp = json_decode($response->raw, false);
|
||||
|
||||
//Run through the mining observers, and add them to the database
|
||||
foreach($resp as $observer) {
|
||||
|
||||
Observer::updateOrInsert([
|
||||
'observer_id' => $observer->observer_id,
|
||||
], [
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_type' => $observer->observer_type,
|
||||
'last_updated' => $observer->last_updated,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup stale data that hasn't been updated in at least 1 week.
|
||||
*/
|
||||
$date = Carbon::now()->subDays(60);
|
||||
Observer::where('last_updated', '<', $date)->delete();
|
||||
|
||||
|
||||
|
||||
$task->SetStopStatus();
|
||||
$endTime = time();
|
||||
printf("Time to complete: " . ($endTime - $startTime) . "\n\r");
|
||||
|
||||
//Return 0 saying everything is fine
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
152
app/Console/Commands/MiningTaxes/MiningTaxesPayments.php
Normal file
152
app/Console/Commands/MiningTaxes/MiningTaxesPayments.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Lookup\LookupHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTaxes\Invoice;
|
||||
use App\Models\MiningTaxes\Payment;
|
||||
use App\Models\Finances\PlayerDonationJournal;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\MiningTaxes\ProcessMiningTaxesPaymentsJob;
|
||||
|
||||
class MiningTaxesPayments extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'MiningTax:Payments';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process mining tax payments';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('MiningTaxesPayments');
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Declare variables for the function
|
||||
$lookup = new LookupHelper;
|
||||
$currentTime = Carbon::now();
|
||||
$config = config('esi');
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-contracts.read_corporation_contracts.v1')) {
|
||||
Log::critical('Esi scopes were not found for MiningTaxesPayments');
|
||||
print("Esi scope not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get all of the contracts from esi
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporations/{corporation_id}/contracts/', [
|
||||
'corporation_id' => $config['corporation'],
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get contrcts in MiningTaxesPayments command.");
|
||||
Log::critical($e);
|
||||
dd($e);
|
||||
}
|
||||
|
||||
//Decode the contracts from the json response
|
||||
$contracts = json_decode($response->raw, false);
|
||||
|
||||
//Get the outstanding invoices
|
||||
$outstanding = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
//Use the player donation and the journal in order to check over the pending contracts to attempt
|
||||
//to pay the contract
|
||||
foreach($outstanding as $invoice) {
|
||||
//See if we have a reason with the correct uniqid from the player donation journal
|
||||
$found = PlayerDonationJournal::where([
|
||||
'reason' => "MMT: " . $invoice->invoice_id,
|
||||
])->count();
|
||||
|
||||
if($found == 1) {
|
||||
//If the bill is paid on time, then update the invoice as such
|
||||
if($currentTime->lessThanOrEqualTo($invoice->due_date)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid',
|
||||
]);
|
||||
}
|
||||
|
||||
//If the bill is paid late, then update the invoice as such
|
||||
if($currentTime->greaterThan($invoice->due_date)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid Late',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//If we didn't found a journal entry, then we shall check the contracts for a correct entry
|
||||
foreach($contracts as $contract) {
|
||||
if(($contract->title == ("MMT: " . $invoice->invoice_id)) && ($currentTime->lessThanOrEqualTo($invoice->due_date))) {
|
||||
Invoice::where([
|
||||
'invoice_i' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'stauts' => 'Paid'
|
||||
]);
|
||||
}
|
||||
|
||||
if(($contract->title == ("MMT: " . $invoice_id)) && ($currentTime->greaterThan($invoice->due_date))) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid Late',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Set the task as stopped
|
||||
$task->SetStopStatus();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\Moons\FetchMoonLedgerJob;
|
||||
use App\Jobs\Commands\Moons\FetchMoonObserverJob;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class MoonsUpdateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:MoonUpdate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update all of the moons registered for observers and ledgers.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$delay = 0;
|
||||
$characters = array();
|
||||
|
||||
//Create the new command helper container
|
||||
$task = new CommandHelper('MoonsUpdateCommand');
|
||||
//Set the task start status
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get all of the characters who have registered structures for moon ledgers
|
||||
$miningChars = EsiScope::where([
|
||||
'scope' => 'esi-industry.read_corporation_mining.v1',
|
||||
])->get();
|
||||
|
||||
foreach($miningChars as $mChars) {
|
||||
$universe = EsiScope::where([
|
||||
'character_id' => $mChars->character_id,
|
||||
'scope' => 'esi-universe.read_structures.v1',
|
||||
])->first();
|
||||
|
||||
if($universe != null) {
|
||||
array_push($characters, $universe->character_id);
|
||||
}
|
||||
}
|
||||
|
||||
//Cycle through each of the character Ids which have the correct scopes,
|
||||
//and dispatch jobs accordingly.
|
||||
foreach($characters as $charId) {
|
||||
//Fetch all of the corp observers with the job dispatch
|
||||
FetchMoonObserverJob::dispatch($charId);
|
||||
//Fetch all of the corp ledgers with the job dispatch
|
||||
FetchMoonLedgerJob::dispatch($charId);
|
||||
}
|
||||
|
||||
//Set task done status
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\RentalMoons\SendMoonRentalPaymentReminderJob;
|
||||
use App\Jobs\Commands\RentalMoons\UpdateMoonRentalPaidState;
|
||||
|
||||
class AllianceRentalMoonInvoiceCreationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:RentalInvoices';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send out rental invoice reminders';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Set the task as started
|
||||
$task = new CommandHelper('AllianceRentalInvoice');
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Send the job for the invoice creation command
|
||||
SendMoonRentalPaymentReminderJob::dispatch()->delay(Carbon::now()->addSeconds(10));
|
||||
|
||||
//Update the paid state for the moons
|
||||
UpdateMoonRentalPaidState::dispatch()->delay(Carbon::now()->addSeconds(600));
|
||||
|
||||
//Set the task as stopped
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\RentalMoons\UpdateMoonRentalPrice;
|
||||
|
||||
class AllianceRentalMoonUpdatePricingCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:UpdateRentalPrice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update alliance rental moon prices.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Setup the task handler
|
||||
$task = new CommandHelper('AllianceRentalMoonPriceUpdater');
|
||||
$task->SetStartStatus();
|
||||
|
||||
UpdateMoonRentalPrice::dispatch();
|
||||
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Structures;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use Commands\Library\CommandHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Job
|
||||
use App\Jobs\ProcessStructureJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
class GetStructuresCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetStructures';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the list of structures ';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the command helper container
|
||||
$task = new CommandHelper('GetStructures');
|
||||
//Add the entry into the jobs table saying the job is starting
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
//Declare some variables
|
||||
$charId = $config['primary'];
|
||||
$corpId = 98287666;
|
||||
$sHelper = new StructureHelper($charId, $corpId);
|
||||
$structures = null;
|
||||
|
||||
//ESI Scope Check
|
||||
$esiHelper = new Esi;
|
||||
$structureScope = $esiHelper->HaveEsiScope($charId, 'esi-universe.read_structures.v1');
|
||||
$corpStructureScope = $esiHelper->HaveEsiScope($charId, 'esi-corporations.read_structures.v1');
|
||||
|
||||
//Check scopes
|
||||
if($structureScope == false || $corpStructureScope == false) {
|
||||
if($structureScope == false) {
|
||||
Log::critical("Scope check for esi-universe.read_structures.v1 has failed.");
|
||||
}
|
||||
if($corpStructureScope == false) {
|
||||
Log::critical("Scope check for esi-corporations.read_structures.v1 has failed.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
//Create the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Set the current page
|
||||
$currentPage = 1;
|
||||
//Set our default total pages, and we will refresh this later
|
||||
$totalPages = 1;
|
||||
|
||||
//Try to get the ESI data
|
||||
try {
|
||||
$structures = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch (RequestFailedException $e) {
|
||||
Log::critical("Failed to get structure list.");
|
||||
return null;
|
||||
}
|
||||
|
||||
$totalPages = $structures->pages;
|
||||
|
||||
for($i = 1; $i <= $totalPages; $i++) {
|
||||
ProcessStructureJob::dispatch($charId, $corpId, $currentPage)->onQueue('structures');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
53
app/Console/Commands/Structures/GetStructuresCommand.php
Normal file
53
app/Console/Commands/Structures/GetStructuresCommand.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Structures;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\Structures\ProcessStructureJob;
|
||||
|
||||
class GetStructuresCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:GetStructures';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get the list of structures ';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
//Declare some variables
|
||||
$charId = $config['primary'];
|
||||
$corpId = 98287666;
|
||||
|
||||
//Dispatch the job to be done when the application has time
|
||||
ProcessStructureJob::dispatch($charId, $corpId);
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\SystemRental;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library
|
||||
use Command\Library\CommandHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Rentals\RentalSystem;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class SystemRentalCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:SystemRentals';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mail out bill for system rentals.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Create the new command helper container
|
||||
$task = new CommandHelper('SystemRentalMailer');
|
||||
//Add the entry into the jobs table saying the job has started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Create other variables
|
||||
$body = null;
|
||||
$delay = 30;
|
||||
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
$today->second = 2;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get all of the contacts for the system rentals
|
||||
$contacts = RentalSystem::select('contact_id')->orderBy('contact_id')->get();
|
||||
|
||||
//For each of the contacts send a reminder mail about the total of the systems they are paying for
|
||||
foreach($contacts as $contact) {
|
||||
//Get all of the systems
|
||||
$systems = RentalSystem::where([
|
||||
'contact_id' => $contact->contact_id,
|
||||
])->get();
|
||||
|
||||
//Totalize the total cost of all of the systems
|
||||
$totalCost = $this->TotalizeCost($systems);
|
||||
|
||||
//Build the body of the mail
|
||||
$body = "System Rental Cost is due for the following systems:<br>";
|
||||
foreach($systems as $system) {
|
||||
$body .= $system->system_name . "<br>";
|
||||
}
|
||||
|
||||
//Create the rest of the email body
|
||||
$body .= "Total Cost: " . number_format($totalCost, 2, ".", ",");
|
||||
$body .= "Please remite payment to White Wolves Holding.<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Fill in the subject
|
||||
$subject = "Warped Intentions System Rental Bill Due";
|
||||
|
||||
//Dispatch the mail job
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$contact->contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
|
||||
//Increase the delay for the next mail job
|
||||
$delay += 60;
|
||||
|
||||
//After the mail is dispatched, save the sent mail record
|
||||
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$contact->contact_id, 'character');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
|
||||
}
|
||||
|
||||
private function TotalizeCost($systems) {
|
||||
//Declare the starting total cost
|
||||
$totalCost = 0.00;
|
||||
|
||||
foreach($systems as $system) {
|
||||
$totalCost += $system->rental_cost;
|
||||
}
|
||||
|
||||
return $totalCost;
|
||||
}
|
||||
|
||||
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
|
||||
$sentmail = new SentMail;
|
||||
$sentmail->sender = $sender;
|
||||
$sentmail->subject = $subject;
|
||||
$sentmail->body = $body;
|
||||
$sentmail->recipient = $recipient;
|
||||
$sentmail->recipient_type = $recipientType;
|
||||
$sentmail->save();
|
||||
}
|
||||
}
|
||||
@@ -17,23 +17,28 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\Corps\GetCorpsCommand::class,
|
||||
Commands\Finances\HoldingFinancesCommand::class,
|
||||
Commands\Structures\GetStructuresCommand::class,
|
||||
Commands\Assets\GetAssetsCommand::class,
|
||||
Commands\Users\PurgeUsers::class,
|
||||
Commands\Flex\FlexStructureCommand::class,
|
||||
/**
|
||||
* Data Commands
|
||||
*/
|
||||
Commands\Data\PurgeUsers::class,
|
||||
Commands\Data\EmptyJumpBridges::class,
|
||||
Commands\Finances\SovBillsCommand::class,
|
||||
Commands\Data\CleanStaleDataCommand::class,
|
||||
Commands\Moons\MoonsUpdateCommand::class,
|
||||
Commands\Data\PurgeCorpMoonLedgers::class,
|
||||
Commands\Data\Test::class,
|
||||
/**
|
||||
* Eve Commands
|
||||
*/
|
||||
Commands\Eve\ItemPricesUpdateCommand::class,
|
||||
/**
|
||||
* Rental Moon Commands
|
||||
* Finance Commands
|
||||
*/
|
||||
Commands\RentalMoons\AllianceRentalMoonInvoiceCreationCommand::class,
|
||||
Commands\RentalMoons\AllianceRentalMoonUpdatePricingCommand::class,
|
||||
Commands\Finances\UpdateAllianceWalletJournal::class,
|
||||
/**
|
||||
* Mining Tax Commands
|
||||
*/
|
||||
Commands\MiningTaxes\MiningTaxesInvoices::class,
|
||||
Commands\MiningTaxes\MiningTaxesLedgers::class,
|
||||
Commands\MiningTaxes\MiningTaxesObservers::class,
|
||||
Commands\MiningTaxes\MiningTaxesPayments::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -46,49 +51,48 @@ class Kernel extends ConsoleKernel
|
||||
{
|
||||
//Horizon Graph Schedule
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
|
||||
/**
|
||||
* Rentals / Flex Schedule
|
||||
*/
|
||||
$schedule->command('services:UpdateRentalPrice')
|
||||
->dailyAt('11:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('services:FlexStructures')
|
||||
->monthlyOn(2, '00:01');
|
||||
|
||||
/**
|
||||
* Holding Corp Finance Schedule
|
||||
*/
|
||||
$schedule->command('services:HoldingJournal')
|
||||
->hourlyAt('45')
|
||||
->withoutOverlapping();
|
||||
|
||||
/**
|
||||
* Get Information Schedule
|
||||
*/
|
||||
$schedule->command('services:GetCorps')
|
||||
->monthlyOn(1, '09:00');
|
||||
$schedule->command('services:GetStructures')
|
||||
->dailyAt('09:00');
|
||||
$schedule->command('services:GetAssets')
|
||||
->hourlyAt('22');
|
||||
|
||||
/**
|
||||
* Purge Data Schedule
|
||||
*/
|
||||
$schedule->command('services:CleanData')
|
||||
$schedule->command('data:CleanData')
|
||||
->weekly(7, '11:00');
|
||||
$schedule->command('data:PurgeCorpLedgers')
|
||||
->monthly();
|
||||
$schedule->command('services:PurgeUsers')
|
||||
$schedule->command('data:PurgeUsers')
|
||||
->dailyAt('23:00');
|
||||
|
||||
/**
|
||||
* Finances Update Schedule
|
||||
*/
|
||||
$schedule->command('finances:UpdateJournals')
|
||||
->hourlyAt('45')
|
||||
->withoutOverlapping();
|
||||
|
||||
/**
|
||||
* Item Update Schedule
|
||||
*/
|
||||
$schedule->command('services:ItemPriceUpdate')
|
||||
->hourlyAt('30')
|
||||
->withoutOverlapping();
|
||||
|
||||
/**
|
||||
* Mining Tax Schedule
|
||||
*/
|
||||
$schedule->command('MiningTaxes:Observers')
|
||||
->dailyAt('22:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('MiningTaxes:Ledgers')
|
||||
->dailyAt('20:00')
|
||||
->withoutOverlapping();
|
||||
/*
|
||||
$schedule->command('MiningTaxes:Invoices')
|
||||
->weeklyOn(1, '8:00')
|
||||
->withoutOverlapping();
|
||||
$schedule->command('MiningTaxes:Payments')
|
||||
->hourlyAt('15')
|
||||
->withoutOverlapping();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
//use Exception;
|
||||
use Throwable;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@@ -32,7 +33,7 @@ class Handler extends ExceptionHandler
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
@@ -44,7 +45,7 @@ class Handler extends ExceptionHandler
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\AfterActionReports;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AfterActionReportsAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:fc.lead');
|
||||
}
|
||||
|
||||
public function DeleteReport() {
|
||||
|
||||
}
|
||||
|
||||
public function DeleteComment() {
|
||||
|
||||
}
|
||||
|
||||
public function PruneReports() {
|
||||
|
||||
}
|
||||
|
||||
public function DisplayStastics() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\AfterActionReports;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
//Models
|
||||
use App\Models\AfterActionReports\Report;
|
||||
use App\Models\AfterActionReports\Comment;
|
||||
|
||||
class AfterActionReportsController extends Controller
|
||||
{
|
||||
public function __contstruct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:fc.team');
|
||||
}
|
||||
|
||||
public function DisplayReportForm() {
|
||||
//
|
||||
}
|
||||
|
||||
public function StoreReport() {
|
||||
|
||||
}
|
||||
|
||||
public function StoreComment() {
|
||||
|
||||
}
|
||||
|
||||
public function DisplayAllReports() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,15 @@ namespace App\Http\Controllers\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Socialite;
|
||||
use Auth;
|
||||
use Laravel\Socialite\Contracts\Factory as Socialite;
|
||||
use Laravel\Socialite\Two\User as SocialiteUser;
|
||||
|
||||
//Library
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
@@ -73,50 +75,79 @@ class LoginController extends Controller
|
||||
*
|
||||
* @return Socialite
|
||||
*/
|
||||
public function redirectToProvider() {
|
||||
return Socialite::driver('eveonline')->redirect();
|
||||
public function redirectToProvider($profile = null, Socialite $social) {
|
||||
//The default scope is public data for everyone due to OAuth2 Tokens
|
||||
$scopes = ['publicData'];
|
||||
|
||||
//Collect any other scopes we need if we are logged in.
|
||||
//If we are logged in we are linking another character to this one.
|
||||
//Attempt to use the same scopes for this character as the original one
|
||||
if(Auth::check()) {
|
||||
$extraScopes = EsiScope::where([
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->get(['scope']);
|
||||
|
||||
//Pop each scope onto the array of scopes
|
||||
foreach($extraScopes as $extra) {
|
||||
array_push($scopes, $extra->scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Place the scopes in the session.
|
||||
* Place the original character id in the session.
|
||||
*/
|
||||
session()->put('scopes', $scopes);
|
||||
session()->put('orgCharacter', auth()->user()->getId());
|
||||
}
|
||||
|
||||
return $social->driver('eveonline')
|
||||
->scopes($scopes)
|
||||
->redirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get token from callback
|
||||
* Redirect to the dashboard if logging in successfully.
|
||||
*/
|
||||
public function handleProviderCallback() {
|
||||
public function handleProviderCallback(Socialite $social) {
|
||||
//Get the sso user from the socialite driver
|
||||
$ssoUser = Socialite::driver('eveonline')->user();
|
||||
$ssoUser = $social->driver('eveonline')->user();
|
||||
|
||||
$scpSession = session()->pull('scopes');
|
||||
|
||||
//If the user was already logged in, let's do some checks to see if we are adding
|
||||
//additional scopes to the user's account
|
||||
if(Auth::check()) {
|
||||
//If a refresh token is present, then we are doing a scope callback
|
||||
//to update scopes for an access token
|
||||
//If we are logged in already and the session contains the original characters, then we are creating an alt
|
||||
//for the original character
|
||||
if(session()->has('orgCharacter')) {
|
||||
$orgCharacter = session()->pull('orgCharacter');
|
||||
|
||||
if(isset($ssoUser->refreshToken)) {
|
||||
//See if an access token is present already
|
||||
$tokenCount = EsiToken::where('character_id', $ssoUser->id)->count();
|
||||
if($tokenCount > 0) {
|
||||
//Update the esi token
|
||||
$this->UpdateEsiToken($ssoUser);
|
||||
} else {
|
||||
//Save the ESI token
|
||||
$this->SaveEsiToken($ssoUser);
|
||||
}
|
||||
|
||||
//After creating the token, we need to update the table for scopes
|
||||
$this->SetScopes($ssoUser->user['Scopes'], $ssoUser->id);
|
||||
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully updated ESI Scopes.');
|
||||
} else {
|
||||
$created = $this->createAlt($ssoUser);
|
||||
if($created == 1) {
|
||||
if($this->createAlt($ssoUser, $orgCharacter)) {
|
||||
return redirect()->to('/profile')->with('success', 'Alt registered.');
|
||||
} else {
|
||||
return redirect()->to('/profile')->with('error', 'Alt was previously registered.');
|
||||
return redirect()->to('/profile')->with('error', 'Unable to register alt or it was previously registered.');
|
||||
}
|
||||
} else {
|
||||
if(sizeof($ssoUser->scopes) > 1) {
|
||||
$tokenCount = EsiToken::where([
|
||||
'character_id' => $ssoUser->id,
|
||||
])->count();
|
||||
if($tokenCount > 0) {
|
||||
$this->UpdateEsiToken($ssoUser);
|
||||
} else {
|
||||
$this->SaveEsiToken($ssoUser);
|
||||
}
|
||||
$this->SetScopes($ssoUser->scopes, $ssoUser->id);
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully updated ESI scopes.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//If the user wasn't logged in, then create a new user
|
||||
$user = $this->createOrGetUser($ssoUser);
|
||||
|
||||
//Login in the new user
|
||||
auth()->login($user, true);
|
||||
|
||||
//Redirect back to the dashboard
|
||||
return redirect()->to('/dashboard')->with('success', 'Successfully Logged In.');
|
||||
}
|
||||
}
|
||||
@@ -127,12 +158,14 @@ class LoginController extends Controller
|
||||
*
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createAlt($user) {
|
||||
private function createAlt($user, $orgCharacter) {
|
||||
|
||||
$altCount = UserAlt::where('character_id', $user->id)->count();
|
||||
if($altCount == 0) {
|
||||
//Create the new alt in the table
|
||||
$newAlt = new UserAlt;
|
||||
$newAlt->name = $user->getName();
|
||||
$newAlt->main_id = auth()->user()->getId();
|
||||
$newAlt->main_id = $orgCharacter;
|
||||
$newAlt->character_id = $user->id;
|
||||
$newAlt->avatar = $user->avatar;
|
||||
$newAlt->access_token = $user->token;
|
||||
@@ -140,8 +173,23 @@ class LoginController extends Controller
|
||||
$newAlt->inserted_at = time();
|
||||
$newAlt->expires_in = $user->expiresIn;
|
||||
$newAlt->save();
|
||||
|
||||
//Create the entry into the EsiToken table
|
||||
//Create the entry into the EsiToken table
|
||||
if(EsiToken::where(['character_id' => $user->id])->count() == 0) {
|
||||
$this->SaveEsiToken($user);
|
||||
} else {
|
||||
$this->UpdateEsiToken($user);
|
||||
}
|
||||
|
||||
//Create the entry into the EsiScopes table
|
||||
if(sizeof($user->scopes) > 1) {
|
||||
$this->SetScopes($user->scopes, $user->id);
|
||||
}
|
||||
//Return the successfull conclusion of the function
|
||||
return 1;
|
||||
} else {
|
||||
//Return the unsuccessfull conclusion of the function
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -152,44 +200,48 @@ class LoginController extends Controller
|
||||
*
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createOrGetUser($eve_user) {
|
||||
private function createOrGetUser($eveUser) {
|
||||
$authUser = null;
|
||||
|
||||
//Search to see if we have a matching user in the database.
|
||||
//At this point we don't care about the information
|
||||
$userCount = User::where('character_id', $eve_user->id)->count();
|
||||
$userCount = User::where([
|
||||
'character_id' => $eveUser->id,
|
||||
])->count();
|
||||
|
||||
//If the user is found, do more checks to see what type of login we are doing
|
||||
if($userCount > 0) {
|
||||
//Search for user in the database
|
||||
$authUser = User::where('character_id', $eve_user->id)->first();
|
||||
$authUser = User::where([
|
||||
'character_id' => $eveUser->id,
|
||||
])->first();
|
||||
|
||||
//Check to see if the owner has changed
|
||||
//If the owner has changed, then update their roles and permissions
|
||||
if($this->OwnerHasChanged($authUser->owner_hash, $eve_user->owner_hash)) {
|
||||
if($this->OwnerHasChanged($authUser->owner_hash, $eveUser->owner_hash)) {
|
||||
//Get the right role for the user
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
$role = $this->GetRole(null, $eveUser->id);
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
$this->SetRole($role, $eveUser->id);
|
||||
|
||||
//Update the user information never the less.
|
||||
$this->UpdateUser($eve_user, $role);
|
||||
$this->UpdateUser($eveUser, $role);
|
||||
|
||||
//Update the user's roles and permission
|
||||
$this->UpdatePermission($eve_user, $role);
|
||||
$this->UpdatePermission($eveUser, $role);
|
||||
}
|
||||
|
||||
//Return the user to the calling auth function
|
||||
return $authUser;
|
||||
} else {
|
||||
//Get the role for the character to be stored in the database
|
||||
$role = $this->GetRole(null, $eve_user->id);
|
||||
$role = $this->GetRole(null, $eveUser->id);
|
||||
|
||||
//Create the user account
|
||||
$user = $this->CreateNewUser($eve_user);
|
||||
$user = $this->CreateNewUser($eveUser);
|
||||
|
||||
//Set the role for the user
|
||||
$this->SetRole($role, $eve_user->id);
|
||||
$this->SetRole($role, $eveUser->id);
|
||||
|
||||
//Create a user account
|
||||
return $user;
|
||||
@@ -199,45 +251,45 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Update the ESI Token
|
||||
*/
|
||||
private function UpdateEsiToken($eve_user) {
|
||||
EsiToken::where('character_id', $eve_user->id)->update([
|
||||
'character_id' => $eve_user->getId(),
|
||||
'access_token' => $eve_user->token,
|
||||
'refresh_token' => $eve_user->refreshToken,
|
||||
private function UpdateEsiToken($eveUser) {
|
||||
EsiToken::where('character_id', $eveUser->id)->update([
|
||||
'character_id' => $eveUser->getId(),
|
||||
'access_token' => $eveUser->token,
|
||||
'refresh_token' => $eveUser->refreshToken,
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
'expires_in' => $eveUser->expiresIn,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ESI Token in the database
|
||||
*/
|
||||
private function SaveEsiToken($eve_user) {
|
||||
private function SaveEsiToken($eveUser) {
|
||||
$token = new EsiToken;
|
||||
$token->character_id = $eve_user->id;
|
||||
$token->access_token = $eve_user->token;
|
||||
$token->refresh_token = $eve_user->refreshToken;
|
||||
$token->character_id = $eveUser->id;
|
||||
$token->access_token = $eveUser->token;
|
||||
$token->refresh_token = $eveUser->refreshToken;
|
||||
$token->inserted_at = time();
|
||||
$token->expires_in = $eve_user->expiresIn;
|
||||
$token->expires_in = $eveUser->expiresIn;
|
||||
$token->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update avatar
|
||||
*/
|
||||
private function UpdateAvatar($eve_user) {
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
private function UpdateAvatar($eveUser) {
|
||||
User::where('character_id', $eveUser->id)->update([
|
||||
'avatar' => $eveUser->avatar,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user permission
|
||||
*/
|
||||
private function UpdatePermission($eve_user, $role) {
|
||||
UserPermission::where(['character_id' => $eve_user->id])->delete();
|
||||
private function UpdatePermission($eveUser, $role) {
|
||||
UserPermission::where(['character_id' => $eveUser->id])->delete();
|
||||
$perm = new UserPermission();
|
||||
$perm->character_id = $eve_user->id;
|
||||
$perm->character_id = $eveUser->id;
|
||||
$perm->permission = $role;
|
||||
$perm->save();
|
||||
}
|
||||
@@ -245,10 +297,10 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Update the user
|
||||
*/
|
||||
private function UpdateUser($eve_user, $role) {
|
||||
User::where('character_id', $eve_user->id)->update([
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
private function UpdateUser($eveUser, $role) {
|
||||
User::where('character_id', $eveUser->id)->update([
|
||||
'avatar' => $eveUser->avatar,
|
||||
'owner_hash' => $eveUser->owner_hash,
|
||||
'role' => $role,
|
||||
]);
|
||||
}
|
||||
@@ -256,18 +308,42 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Create a new user account
|
||||
*/
|
||||
private function CreateNewUser($eve_user) {
|
||||
private function CreateNewUser($eveUser) {
|
||||
$user = User::create([
|
||||
'name' => $eve_user->getName(),
|
||||
'avatar' => $eve_user->avatar,
|
||||
'owner_hash' => $eve_user->owner_hash,
|
||||
'character_id' => $eve_user->getId(),
|
||||
'name' => $eveUser->getName(),
|
||||
'avatar' => $eveUser->avatar,
|
||||
'owner_hash' => $eveUser->owner_hash,
|
||||
'character_id' => $eveUser->getId(),
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
'access_token' => $eve_user->token,
|
||||
'user_type' => $this->GetAccountType(null, $eve_user->id),
|
||||
'expires_in' => $eveUser->expiresIn,
|
||||
'user_type' => $this->GetAccountType(null, $eveUser->id),
|
||||
]);
|
||||
|
||||
//Look for an existing token for the characters
|
||||
$tokenFound = EsiToken::where([
|
||||
'character_id' => $eveUser->id,
|
||||
])->count();
|
||||
|
||||
if($tokenFound == 0) {
|
||||
$token = new EsiToken;
|
||||
$token->character_id = $eveUser->id;
|
||||
$token->access_token = $eveUser->token;
|
||||
$token->refresh_token = $eveUser->refreshToken;
|
||||
$token->inserted_at = time();
|
||||
$token->expires_in = $eveUser->expiresIn;
|
||||
$token->save();
|
||||
} else {
|
||||
EsiToken::where([
|
||||
'character_id' => $eveUser->id,
|
||||
])->update([
|
||||
'character_id' => $eveUser->id,
|
||||
'access_token' => $eveUser->token,
|
||||
'refresh_token' => $eveUser->refreshToken,
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eveUser->expiresIn,
|
||||
]);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
@@ -293,7 +369,6 @@ class LoginController extends Controller
|
||||
private function SetScopes($scopes, $charId) {
|
||||
//Delete the current scopes, so we can add new scopes into the database
|
||||
EsiScope::where('character_id', $charId)->delete();
|
||||
$scopes = explode(' ', $scopes);
|
||||
foreach($scopes as $scope) {
|
||||
$data = new EsiScope;
|
||||
$data->character_id = $charId;
|
||||
@@ -350,6 +425,7 @@ class LoginController extends Controller
|
||||
private function GetAccountType($refreshToken, $charId) {
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Instantiate a new ESI isntance
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
@@ -359,10 +435,10 @@ class LoginController extends Controller
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Get the character information
|
||||
$character_info = $esiHelper->GetCharacterData($charId);
|
||||
$character_info = $lookup->GetCharacterInfo($charId);
|
||||
|
||||
//Get the corporation information
|
||||
$corp_info = $esiHelper->GetCorporationData($character_info->corporation_id);
|
||||
$corp_info = $lookup->GetCorporationInfo($character_info->corporation_id);
|
||||
|
||||
if($character_info == null || $corp_info == null) {
|
||||
return redirect('/')->with('error', 'Could not create user at this time.');
|
||||
|
||||
@@ -9,7 +9,7 @@ use Log;
|
||||
use DB;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Blacklist\BlacklistEntity;
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
@@ -16,7 +16,7 @@ use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class SupplyChainController extends Controller
|
||||
{
|
||||
|
||||
@@ -8,10 +8,9 @@ use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
use App\Library\Wiki\WikiHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\SRPHelper;
|
||||
use App\Library\Helpers\TaxesHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
@@ -20,9 +19,6 @@ use App\Models\User\UserPermission;
|
||||
use App\Models\User\AvailableUserPermission;
|
||||
use App\Models\User\AvailableUserRole;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
use App\Models\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
@@ -336,187 +332,4 @@ class AdminController extends Controller
|
||||
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the wiki dashboard for wiki functions
|
||||
*/
|
||||
public function displayWikiDashboard() {
|
||||
//Declare some variables
|
||||
$wikiUsers = array();
|
||||
$wikiGroups = array();
|
||||
|
||||
$tempUsers = DokuUser::all();
|
||||
$tempGroups = DokuGroupNames::all();
|
||||
$wikiMembership = DokuMember::all();
|
||||
|
||||
//Create a list of users based on id and name for the select form
|
||||
foreach($tempUsers as $temp) {
|
||||
$wikiUsers[$temp->id] = $temp->name;
|
||||
}
|
||||
|
||||
asort($wikiUsers);
|
||||
|
||||
foreach($tempGroups as $temp) {
|
||||
$wikiGroups[$temp->id] = $temp->gname;
|
||||
}
|
||||
|
||||
asort($wikiGroups);
|
||||
|
||||
return view('admin.dashboards.wiki')->with('wikiUsers', $wikiUsers)
|
||||
->with('wikiGroups', $wikiGroups)
|
||||
->with('wikiMembership', $wikiMembership);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a wiki user
|
||||
*/
|
||||
public function deleteWikiUser(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
]);
|
||||
|
||||
//Declare helper variable
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
$wikiHelper->DeleteWikiUser($request->user);
|
||||
|
||||
redirect('/admin/dashboard/wiki')->with('success', 'User: ' . $request->user . ' has been deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a group to a wiki user
|
||||
*/
|
||||
public function addWikiUserGroup(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required', //User Id number
|
||||
'groupname' => 'required', //Group Id number
|
||||
]);
|
||||
|
||||
//Declare some helper variables
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
//Check to see if the user has the group we are going to add first
|
||||
if($wikiHelper->UserHasGroup($request->user, $request->groupname)) {
|
||||
return redirect('/admin/dashboard/wiki')->with('error', 'User already has the group.');
|
||||
}
|
||||
|
||||
//Add the user to the wiki group
|
||||
$results = $wikiHelper->AddUserToGroup($request->user, $request->groupname);
|
||||
|
||||
//Redirect based on the results of the add user to group function
|
||||
if($results) {
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'User added to group for the wiki.');
|
||||
} else {
|
||||
return redirect('/admin/dashboard/wiki')->with('error', 'Failed at add user to group, or user was already part of the group.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a group from a wiki user
|
||||
*/
|
||||
public function removeWikiUserGroup(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
'groupname' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some helper variables
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
//Check to see if the user has the group we are going to remove them from
|
||||
if(!$wikiHelper->UserHasGroup($request->user, $request->groupname)) {
|
||||
return redirect('/admin/dashboard/wiki')->with('error', 'User does not have the group to remove.');
|
||||
}
|
||||
|
||||
//Remove the user from the wiki group
|
||||
$wikiHelper->RemoveUserFromGroup($request->user, $request->groupname);
|
||||
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'Removed user from group ' . $request->grouopname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a user from all wiki groups
|
||||
*/
|
||||
public function removeWikiUserAllGroups(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
]);
|
||||
|
||||
//Declare variable
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
$wikiHelper->RemoveUserFromAllGroups($request->user);
|
||||
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'User successfully removed from all groups.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new group for wiki user's to be added to
|
||||
*/
|
||||
public function insertNewWikiUserGroup(Request $request) {
|
||||
$this->validate($request, [
|
||||
'group' => 'required',
|
||||
'description' => 'required',
|
||||
]);
|
||||
|
||||
//Declare variable
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
$wikiHelper->AddNewUserGroup($request->group, $request->description);
|
||||
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'Added new user group.');
|
||||
}
|
||||
|
||||
public function purgeWikiUsers(Request $request) {
|
||||
$this->validate($request, [
|
||||
'admin' => 'required',
|
||||
]);
|
||||
|
||||
//Declare helper classes
|
||||
$lookup = new LookupHelper;
|
||||
$wikiHelper = new WikiHelper;
|
||||
|
||||
//Get all of the users from the database
|
||||
$users = User::all();
|
||||
|
||||
//Search the names and verify against the lookup table
|
||||
//to find the corporation and / or alliance they belong to.
|
||||
foreach($users as $user) {
|
||||
//Let's look up the character in the user table by their name.
|
||||
//If no name is found, then delete the user and have them start over with the wiki permissions
|
||||
$count = DokuUser::where(['name' => $user->name])->count();
|
||||
|
||||
//If the user is found, then check if they are allowed on the wiki.
|
||||
//If the the count == 0, then the user wasn't found on the wiki, so do nothing.
|
||||
if($count > 0) {
|
||||
//If the user is not allowed, then delete the user, otherwise, leave the user untouched
|
||||
if(!$wikiHelper->AllowedUser($user->name)) {
|
||||
$uid = $wikiHelper->GetUID($user->name);
|
||||
$wikiHelper->DeleteWikiUser($uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Get all of the DokuUsers and verify against the Users on the services page
|
||||
$users = DokuUser::all();
|
||||
|
||||
//Search the names and verify against the lookup table to find the corporation / alliance the user belongs to.
|
||||
foreach($users as $user) {
|
||||
//Lookup the character in the user table on the services page
|
||||
$count = User::where(['name' => $user->name])->count();
|
||||
|
||||
//If the user is found, then check if they are allowed on the wiki.
|
||||
//If the count == 0, then delete the user anyways
|
||||
if($count > 0 ) {
|
||||
//If the user is not allowed, then delete the user, otherwise, leave them alone.
|
||||
if(!$wikiHelper->AllowedUser($user->name)) {
|
||||
$uid = $wikiHelper->GetUID($user->name);
|
||||
$wikiHelper->DeleteWikiUser($uid);
|
||||
} else {
|
||||
$wikiHelper->DeleteWikiUser($user->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'Wiki has been purged.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,9 @@ use Khill\Lavacharts\Lavacharts;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
use App\Library\Wiki\WikiHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\SRPHelper;
|
||||
use App\Library\Helpers\TaxesHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
|
||||
@@ -41,56 +40,7 @@ class AdminDashboardController extends Controller
|
||||
redirect('/dashboard');
|
||||
}
|
||||
|
||||
//Declare variables we will need
|
||||
$tHelper = new TaxesHelper();
|
||||
$srpHelper = new SRPHelper();
|
||||
$days = 30;
|
||||
$months = 1;
|
||||
$lava = new Lavacharts;
|
||||
|
||||
//Get the dates for the information being requested
|
||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||
|
||||
//Get the data for the sov expenses for a graph
|
||||
|
||||
//Setup the charts
|
||||
//Setup the chart to be able the show the categories for income
|
||||
/*
|
||||
$iChart = $lava->DataTable();
|
||||
$iChart->addStringColumn('Categories')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['pi', $pi])
|
||||
->addRow(['industry', $industry])
|
||||
->addRow(['reprocessing', $reprocessing])
|
||||
->addRow(['offices', $office])
|
||||
->addRow(['industry', $industry])
|
||||
->addRow(['market', $market])
|
||||
->addRow(['gate', $gate])
|
||||
->addRow(['iBuyback', $iBuyback])
|
||||
->addRow(['renters', $renters])
|
||||
->addRow(['ops', $ops]);
|
||||
*/
|
||||
|
||||
//Setup the chart to be able to show the categories for expenses
|
||||
/*
|
||||
$eChart = $lava->DataTable();
|
||||
$eCjart->addStringColumn('Categories')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['sov', $sovBills])
|
||||
->addRow(['srp', $srpActual])
|
||||
->addRow(['maintenance', $maintenance])
|
||||
->addRow(['wardecs', $wardecs])
|
||||
->addRow(['fcs', $fcs])
|
||||
->addRow(['keepstar_fuel', $keepstarFuel])
|
||||
->addRow(['fortizar_fuel', $fortizarFuel])
|
||||
->addRow(['astrahus_fuel', $astrahusFuel])
|
||||
->addRow(['sotiyo_fuel', $sotiyoFuel])
|
||||
->addRow(['azbel_fuel', $azbelFuel])
|
||||
->addRow(['raitaru_fuel', $raitaruFuel])
|
||||
->addRow(['beacon_fuel', $beaconFuel])
|
||||
->addRow(['bridge_fuel', $bridgeFuel])
|
||||
->addRow(['jammer_fuel', $jammerFuel]);
|
||||
*/
|
||||
return view('admin.dashboards.dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ use Illuminate\Support\Facades\DB;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
@@ -17,6 +21,8 @@ use App\Models\User\UserPermission;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\User\UserAlt;
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
@@ -42,9 +48,19 @@ class DashboardController extends Controller
|
||||
$open = array();
|
||||
$approved = array();
|
||||
$denied = array();
|
||||
$ores = array();
|
||||
$altCount = null;
|
||||
$alts = null;
|
||||
$structures = array();
|
||||
$esiHelper = new Esi;
|
||||
$config = config('esi');
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||
$lava = new Lavacharts;
|
||||
|
||||
|
||||
/**
|
||||
* Alt Counts
|
||||
*/
|
||||
//Get the number of the user's alt which are registered so we can process the alt's on the main dashboard page
|
||||
$altCount = UserAlt::where([
|
||||
'main_id' => auth()->user()->character_id,
|
||||
@@ -57,6 +73,9 @@ class DashboardController extends Controller
|
||||
])->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* SRP Items
|
||||
*/
|
||||
//See if we can get all of the open SRP requests
|
||||
$openCount = SRPShip::where([
|
||||
'character_id' => auth()->user()->character_id,
|
||||
@@ -160,8 +179,6 @@ class DashboardController extends Controller
|
||||
}
|
||||
|
||||
//Create a chart of number of approved, denied, and open requests via a fuel gauge chart
|
||||
$lava = new Lavacharts;
|
||||
|
||||
$adur = $lava->DataTable();
|
||||
|
||||
$adur->addStringColumn('Type')
|
||||
@@ -184,13 +201,93 @@ class DashboardController extends Controller
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Mining Tax Items
|
||||
*/
|
||||
//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('dashboard')->with('openCount', $openCount)
|
||||
->with('approvedCount', $approvedCount)
|
||||
->with('deniedCount', $deniedCount)
|
||||
->with('open', $open)
|
||||
->with('approved', $approved)
|
||||
->with('denied', $denied)
|
||||
->with('lava', $lava);
|
||||
->with('lava', $lava)
|
||||
->with('calendar', $calendar);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,400 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Dashboard;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\SRP\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
use App\Models\SRP\SrpFleetType;
|
||||
use App\Models\SRP\SRPShip;
|
||||
use App\Models\SRP\SrpShipType;
|
||||
use App\Models\SRP\SrpPayout;
|
||||
|
||||
|
||||
class StatisticsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Jump Bridge Statistics
|
||||
*/
|
||||
public function displayJumpBridgeStatistics() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$lava = new Lavacharts;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Taxes Statistics
|
||||
*/
|
||||
public function displayTaxes() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare variables needed for displaying items on the page
|
||||
$months = 3;
|
||||
$pi = array();
|
||||
$industry = array();
|
||||
$reprocessing = array();
|
||||
$office = array();
|
||||
$corpId = 98287666;
|
||||
$srpActual = array();
|
||||
$srpLoss = array();
|
||||
|
||||
/** Taxes Pane */
|
||||
//Declare classes needed for displaying items on the page
|
||||
$tHelper = new TaxesHelper;
|
||||
$srpHelper = new SRPHelper;
|
||||
//Get the dates for the tab panes
|
||||
$dates = $tHelper->GetTimeFrameInMonths($months);
|
||||
//Get the data for the Taxes Pane
|
||||
foreach($dates as $date) {
|
||||
//Get the srp actual pay out for the date range
|
||||
$srpActual[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPActual($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the srp loss value for the date range
|
||||
$srpLoss[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($srpHelper->GetAllianceSRPLoss($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
|
||||
//Get the pi taxes for the date range
|
||||
$pis[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the industry taxes for the date range
|
||||
$industrys[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the reprocessing taxes for the date range
|
||||
$reprocessings[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the office taxes for the date range
|
||||
$offices[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the market taxes for the date range
|
||||
$markets[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetAllianceMarketGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
//Get the jump gate taxes for the date range
|
||||
$jumpgates[] = [
|
||||
'date' => $date['start']->toFormattedDateString(),
|
||||
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||
];
|
||||
}
|
||||
|
||||
return view('admin.dashboards.taxes')->with('pis', $pis)
|
||||
->with('industrys', $industrys)
|
||||
->with('offices', $offices)
|
||||
->with('markets', $markets)
|
||||
->with('jumpgates', $jumpgates)
|
||||
->with('reprocessings', $reprocessings)
|
||||
->with('srpActual', $srpActual)
|
||||
->with('srpLoss', $srpLoss);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display wiki statistics
|
||||
*/
|
||||
public function displayWikiStatistics() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display SRP Statistics
|
||||
*/
|
||||
public function displaySRPStatistics() {
|
||||
$months = 3;
|
||||
$barChartData = array();
|
||||
$start = Carbon::now()->toDateTimeString();
|
||||
$end = Carbon::now()->subMonths(1)->toDateTimeString();
|
||||
|
||||
//Declare the Lavacharts variable
|
||||
$lava = new Lavacharts;
|
||||
|
||||
//We need a function from this library rather than recreating a new library
|
||||
$srpHelper = new SRPHelper();
|
||||
|
||||
/**
|
||||
* Pie chart for the number of approved, denied, and under review payouts currently in the system.
|
||||
*/
|
||||
//Get the count of open srp requests
|
||||
$pieOpen = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
//Get the count of approved srp requests
|
||||
$pieApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
//Get the count of denied srp requests
|
||||
$pieDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
['created_at', '>=', $end],
|
||||
])->count();
|
||||
|
||||
//Create a new datatable for the lavachart.
|
||||
$srp = $lava->DataTable();
|
||||
//Add string columns, number columns, and data rows for the chart
|
||||
$srp->addStringColumn('ISK Value')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['Approved', $pieApproved])
|
||||
->addRow(['Denied', $pieDenied])
|
||||
->addRow(['Under Review', $pieOpen]);
|
||||
//Create the pie chart in memory with any options needed to render the chart
|
||||
$lava->PieChart('SRP Stats', $srp, [
|
||||
'title' => 'SRP Stats',
|
||||
'is3D' => true,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Gauage chart for showing number of open srp requests
|
||||
*/
|
||||
//Create a new datatable in the
|
||||
$adur = $lava->DataTable();
|
||||
//Add string columns, number columns, and data row for the chart
|
||||
$adur->addStringColumn('Type')
|
||||
->addNumberColumn('Value')
|
||||
->addRow(['Under Review', $pieOpen]);
|
||||
//Create the gauge chart with any options needed to render the chart
|
||||
$lava->GaugeChart('SRP', $adur, [
|
||||
'width' => 400,
|
||||
'greenFrom' => 0,
|
||||
'greenTo' => 20,
|
||||
'yellowFrom' => 20,
|
||||
'yellowTo' => 40,
|
||||
'redFrom' => 40,
|
||||
'redTo' => 100,
|
||||
'majorTicks' => [
|
||||
'Safe',
|
||||
'Critical',
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Create a vertical chart of all of the cost codes for the ships being SRP'ed.
|
||||
* The chart will be by cost code of ships being replaced
|
||||
*/
|
||||
//Declare the data table
|
||||
$costCodeChart = $lava->DataTable();
|
||||
|
||||
//Get the approved, under review, and denied cost codes and amounts
|
||||
$t1fdcApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('paid_value');
|
||||
$t1fdcUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('loss_value');
|
||||
$t1fdcDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1FDC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1bcApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('paid_value');
|
||||
$t1bcUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('loss_value');
|
||||
$t1bcDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1BC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t2fdApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('paid_value');
|
||||
$t2fdUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('loss_value');
|
||||
$t2fdDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T2FD',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t3dApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('paid_value');
|
||||
$t3dUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('loss_value');
|
||||
$t3dDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T3D',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1t2logiApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('paid_value');
|
||||
$t1t2logiUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('loss_value');
|
||||
$t1t2logiDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1T2Logi',
|
||||
])->sum('loss_value');
|
||||
|
||||
$reconsApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('paid_value');
|
||||
$reconsUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('loss_value');
|
||||
$reconsDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'REC',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t2cApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('paid_value');
|
||||
$t2cUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('loss_value');
|
||||
$t2cDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T2C',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t3cApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('paid_value');
|
||||
$t3cUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('loss_value');
|
||||
$t3cDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T3C',
|
||||
])->sum('loss_value');
|
||||
|
||||
$commandApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('paid_value');
|
||||
$commandUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('loss_value');
|
||||
$commandDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'COM',
|
||||
])->sum('loss_value');
|
||||
|
||||
$interdictorApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('paid_value');
|
||||
$interdictorUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('loss_value');
|
||||
$interdictorDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'INTD',
|
||||
])->sum('loss_value');
|
||||
|
||||
$t1bsApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('paid_value');
|
||||
$t1bsUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('loss_value');
|
||||
$t1bsDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'T1BS',
|
||||
])->sum('loss_value');
|
||||
|
||||
$dksApproved = SRPShip::where([
|
||||
'approved' => 'Approved',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('paid_value');
|
||||
$dksUnderReview = SRPShip::where([
|
||||
'approved' => 'Under Review',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('loss_value');
|
||||
$dksDenied = SRPShip::where([
|
||||
'approved' => 'Denied',
|
||||
'ship_type' => 'DKS',
|
||||
])->sum('loss_value');
|
||||
|
||||
|
||||
//Add string column, number columns.
|
||||
$costCodeChart->addStringColumn('SRP Costs')
|
||||
->addNumberColumn('Approved')
|
||||
->addNumberColumn('Under Review')
|
||||
->addNumberColumn('Denied')
|
||||
->addRow(['T1FDC', $t1fdcApproved, $t1fdcUnderReview, $t1fdcDenied])
|
||||
->addRow(['T1BC', $t1bcApproved, $t1bcUnderReview, $t1bcDenied])
|
||||
->addRow(['T1BS', $t1bsApproved, $t1bsUnderReview, $t1bsDenied])
|
||||
->addRow(['T2FD', $t2fdApproved, $t2fdUnderReview, $t2fdDenied])
|
||||
->addRow(['T2C', $t2cApproved, $t2cUnderReview, $t2cDenied])
|
||||
->addRow(['T1T2Logi', $t1t2logiApproved, $t1t2logiUnderReview, $t1t2logiDenied])
|
||||
->addRow(['T3D', $t3dApproved, $t3dUnderReview, $t3dDenied])
|
||||
->addRow(['T3C', $t3cApproved, $t3cUnderReview, $t3cDenied])
|
||||
->addRow(['RECON', $reconsApproved, $reconsUnderReview, $reconsDenied])
|
||||
->addRow(['COMMAND', $commandApproved, $commandUnderReview, $commandDenied])
|
||||
->addRow(['DKS', $dksApproved, $dksUnderReview, $dksDenied]);
|
||||
|
||||
$lava->ColumnChart('Cost Codes', $costCodeChart, [
|
||||
'columns' => 4,
|
||||
'title' => 'Cost Code SRP Chart',
|
||||
'titleTextStyle' => [
|
||||
'color' => '#eb6b2c',
|
||||
'fontSize' => 14,
|
||||
],
|
||||
]);
|
||||
|
||||
return view('srp.admin.statistics')->with('lava', $lava);
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Flex;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Flex\FlexStructure;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class FlexAdminController extends Controller
|
||||
{
|
||||
//Constructor
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display all active flex structures and
|
||||
* the information regarding the flex structure
|
||||
*/
|
||||
public function displayFlexStructures() {
|
||||
//Get the structures from the database
|
||||
$structures = FlexStructure::all();
|
||||
|
||||
//Return the view with the data
|
||||
return view('flex.list')->with('structures', $structures);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display form for adding new flex structure
|
||||
*/
|
||||
public function displayAddFlexStructure() {
|
||||
return view('flex.add');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add new flex structure to the database
|
||||
*/
|
||||
public function addFlexStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'requestor_name' => 'required',
|
||||
'requestor_corp_name' => 'required',
|
||||
'system' => 'required',
|
||||
'structure_type' => 'required',
|
||||
'structure_cost' => 'required',
|
||||
]);
|
||||
|
||||
//Delcare variables and classes
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//From the character name find the character id
|
||||
$charId = $lookup->CharacterNameToId($request->requestor_name);
|
||||
|
||||
//From the corporation name find the corporation id
|
||||
$corpId = $lookup->CorporationNameToId($request->requestor_corp_name);
|
||||
|
||||
//From the system name find the system id
|
||||
$systemId = $lookup->SystemNameToId($request->system);
|
||||
|
||||
//Create the database model
|
||||
$flex = new FlexStructure;
|
||||
$flex->requestor_id = $charId;
|
||||
$flex->requestor_name = $request->requestor_name;
|
||||
$flex->requestor_corp_id = $corpId;
|
||||
$flex->requestor_corp_name = $request->requestor_corp_name;
|
||||
$flex->system_id = $systemId;
|
||||
$flex->system = $request->system;
|
||||
$flex->structure_type = $request->structure_type;
|
||||
$flex->structure_cost = $request->structure_cost;
|
||||
if(isset($request->paid_until)) {
|
||||
$flex->paid_until = $request->paid_until;
|
||||
}
|
||||
$flex->save();
|
||||
|
||||
return redirect('/flex/display')->with('success', 'Flex Structure Added.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update paid until section of the flex structure in the database
|
||||
*/
|
||||
public function updateFlexStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'paid_until' => 'required',
|
||||
'requestor_id' => 'required',
|
||||
'requestor_corp_id' => 'required',
|
||||
'system_id' => 'required',
|
||||
'structure_type' => 'required',
|
||||
]);
|
||||
|
||||
FlexStructure::where([
|
||||
'requestor_id' => $request->requestor_id,
|
||||
'requestor_corp_id' => $request->requestor_corp_id,
|
||||
'system_id' => $request->system_id,
|
||||
'structure_type' => $request->structure_type,
|
||||
])->update([
|
||||
'paid_until' => $request->paid_until,
|
||||
]);
|
||||
|
||||
return redirect('/flex/display')->with('success', 'Flex Structure Updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Funciton to remove flex structure from the database
|
||||
*/
|
||||
public function removeFlexStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'requestor_id' => 'required',
|
||||
'requestor_corp_id' => 'required',
|
||||
'system_id' => 'required',
|
||||
'structure_type' => 'required',
|
||||
]);
|
||||
|
||||
$count = FlexStructure::where([
|
||||
'requestor_id' => $request->requestor_id,
|
||||
'requestor_corp_id' => $request->requestor_corp_id,
|
||||
'system_id' => $request->system_id,
|
||||
'structure_type' => $request->structure_type,
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
FlexStructure::where([
|
||||
'requestor_id' => $request->requestor_id,
|
||||
'requestor_corp_id' => $request->requestor_corp_id,
|
||||
'system_id' => $request->system_id,
|
||||
'structure_type' => $request->structure_type,
|
||||
])->delete();
|
||||
|
||||
return redirect('/flex/display')->with('success', 'Flex Structure Entry Removed.');
|
||||
} else {
|
||||
return redirect('/flex/display')->with('error', 'Could not find flex structure to delete.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,11 +13,13 @@ use Auth;
|
||||
use Charts;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Assets\AssetHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Helpers\AssetHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Asset;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class FuelController extends Controller
|
||||
{
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
|
||||
class StructureRequestAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:fc.team');
|
||||
}
|
||||
|
||||
public function displayRequests() {
|
||||
$reqs = AnchorStructure::all();
|
||||
|
||||
return view('structurerequest.display.structurerequests')->with('reqs', $reqs);
|
||||
}
|
||||
|
||||
public function deleteRequest(Request $request) {
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
]);
|
||||
|
||||
AnchorStructure::where([
|
||||
'id' => $request->id,
|
||||
])->delete();
|
||||
|
||||
return redirect('/structures/display/requests');
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Logistics;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
class StructureRequestController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayForm() {
|
||||
return view('structurerequest.requeststructure');
|
||||
}
|
||||
|
||||
public function storeForm(Request $request) {
|
||||
$this->validate($request, [
|
||||
'corporation_name' => 'required',
|
||||
'system' => 'required',
|
||||
'structure_size' => 'required',
|
||||
'structure_type' => 'required',
|
||||
'requested_drop_time' => 'required',
|
||||
'requester' => 'required',
|
||||
]);
|
||||
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
$config = config('esi');
|
||||
|
||||
$requesterId = $lookup->CharacterNameToId($request->requester);
|
||||
$corporationId = $lookup->CorporationNameToId($request->corporation_name);
|
||||
|
||||
AnchorStructure::insert([
|
||||
'corporation_id' => $corporationId,
|
||||
'corporation_name' => $request->corporation_name,
|
||||
'system' => $request->system,
|
||||
'structure_size' => $request->structure_size,
|
||||
'structure_type' => $request->structure_type,
|
||||
'requested_drop_time' => $request->requested_drop_time,
|
||||
'requester_id' => $requesterId,
|
||||
'requester' => $request->requester,
|
||||
]);
|
||||
|
||||
//Send a mail out to the FC Team
|
||||
$fcTeam = UserPermission::where([
|
||||
'permission' => 'fc.team',
|
||||
])->get();
|
||||
|
||||
//Set the mail delay
|
||||
$delay = 30;
|
||||
|
||||
foreach($fcTeam as $fc) {
|
||||
$body = "Structure Anchor Request has been entered.<br>";
|
||||
$body .= "Please check the W4RP Services Site for the structure information.<br>";
|
||||
$body .= "<br>Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Dispatch the mail job
|
||||
$subject = "New Structure Anchor Request";
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$fc->character_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
|
||||
$delay += 30;
|
||||
}
|
||||
|
||||
return redirect('/dashboard')->with('success', 'Structure request successfully submitted.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Auth;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\MiningTax\Observer;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\MiningTax\Payment;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class MiningTaxesAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display current unpaid invoices
|
||||
*/
|
||||
public function DisplayUnpaidInvoice() {
|
||||
$invoices = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->orWhere([
|
||||
'status' => 'Late',
|
||||
])->orWhere([
|
||||
'status' => 'Deferred',
|
||||
])->paginate(50);
|
||||
|
||||
return view('miningtax.admin.display.unpaid')->with('invoices', $invoices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark an invoice paid
|
||||
*/
|
||||
public function UpdateInvoice(Request $request) {
|
||||
$this->validate($request, [
|
||||
'invoiceId' => 'required',
|
||||
'status' => 'required',
|
||||
]);
|
||||
|
||||
Invoice::where([
|
||||
'invoice_id' => $request->invoiceId,
|
||||
])->update([
|
||||
'status' => $request->status,
|
||||
]);
|
||||
|
||||
return redirect('/miningtax/admin/display/unpaid')->with('success', 'Invoice successfully updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display past paid invoices
|
||||
*/
|
||||
public function DisplayPaidInvoices() {
|
||||
$invoices = Invoice::where([
|
||||
'status' => 'Paid',
|
||||
])->orWhere([
|
||||
'status' => 'Paid Late',
|
||||
])->paginate(50);
|
||||
|
||||
return view('miningtax.admin.display.paidinvoices')->with('invoices', $invoices);
|
||||
}
|
||||
}
|
||||
278
app/Http/Controllers/MiningTaxes/MiningTaxesController.php
Normal file
278
app/Http/Controllers/MiningTaxes/MiningTaxesController.php
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Khill\Lavacharts\Lavacharts;
|
||||
use Auth;
|
||||
//Collection Stuff
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
//Library Helpers
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\MiningTax\Observer;
|
||||
use App\Models\MiningTax\Invoice;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\User\User;
|
||||
|
||||
class MiningTaxesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Construct to deal with middleware and other items
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the users invoices
|
||||
*/
|
||||
public function DisplayInvoices() {
|
||||
//Declare variables
|
||||
$paidAmount = 0.00;
|
||||
$unpaidAmount = 0.00;
|
||||
|
||||
//Get the unpaid invoices
|
||||
$unpaid = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->paginate(15);
|
||||
|
||||
//Get the late invoices
|
||||
$late = Invoice::where([
|
||||
'status' => 'Late',
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->paginate(10);
|
||||
|
||||
//Get the deferred invoices
|
||||
$deferred = Invoice::where([
|
||||
'status' => 'Deferred',
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->paginate(10);
|
||||
|
||||
//Get the paid invoices
|
||||
$paid = Invoice::where([
|
||||
'status' => 'Paid',
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->paginate(15);
|
||||
|
||||
//Total up the unpaid invoices
|
||||
foreach($unpaid as $un) {
|
||||
$unpaidAmount += $un->amount;
|
||||
}
|
||||
|
||||
//Total up the paid invoices
|
||||
foreach($paid as $p) {
|
||||
$paidAmount += $p;
|
||||
}
|
||||
|
||||
return view('miningtax.user.display.invoices')->with('unpaid', $unpaid)
|
||||
->with('late', $late)
|
||||
->with('deferred', $deferred)
|
||||
->with('paid', $paid)
|
||||
->with('unpaidAmount', $unpaidAmount)
|
||||
->with('paidAmount', $paidAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display all of the upcoming extractions
|
||||
*/
|
||||
public function DisplayUpcomingExtractions() {
|
||||
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
$esiHelper = new Esi;
|
||||
$config = config('esi');
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||
$structures = array();
|
||||
$structuresCalendar = array();
|
||||
$lava = new Lavacharts;
|
||||
|
||||
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::warning('Could not retrieve extractions from ESI in MiningTaxesController.php');
|
||||
return redirect('/dashboard')->with('error', "Could not pull extractions from ESI data.");
|
||||
}
|
||||
|
||||
//Basically get the structure info and attach it to the variable set
|
||||
foreach($extractions as $ex) {
|
||||
$sName = $sHelper->GetStructureInfo($ex->structure_id);
|
||||
array_push($structures, [
|
||||
'structure_name' => $sName->name,
|
||||
'start_time' => $esiHelper->DecodeDate($ex->extraction_start_time),
|
||||
'arrival_time' => $esiHelper->DecodeDate($ex->chunk_arrival_time),
|
||||
'decay_time' => $esiHelper->DecodeDate($ex->natural_decay_time),
|
||||
]);
|
||||
}
|
||||
|
||||
//Sort extractions by arrival time
|
||||
$structuresCollection = collect($structures);
|
||||
$sorted = $structuresCollection->sortBy('arrival_time');
|
||||
//Store the sorted collection back into the variable before being used again.
|
||||
$structures = $sorted->all();
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
array_push($structuresCalendar, [
|
||||
'date' => $esiHelper->DecodeDate($extraction->chunk_arrival_time),
|
||||
'total' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach($extractions as $extraction) {
|
||||
for($i = 0; $i < sizeof($structuresCalendar); $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', $structuresCalendar[$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) {
|
||||
$structuresCalendar[$i]['total'] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($structuresCalendar as $structureC) {
|
||||
$calendar->addRow([
|
||||
$structureC['date'],
|
||||
$structureC['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 the view with the extractions variable for html processing
|
||||
return view('miningtax.user.display.upcoming')->with('structures', $structures)
|
||||
->with('lava', $lava)
|
||||
->with('calendar', $calendar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the ledger for the moons.
|
||||
*/
|
||||
public function DisplayMoonLedgers() {
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
$tempLedgers = array();
|
||||
$miningLedgers = array();
|
||||
$ledgers = array();
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
$sHelper = new StructureHelper($config['primary'], $config['corporation']);
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the ESI for the holding corp for corp mining.');
|
||||
} else {
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the ESI for the holding corp for structures.');
|
||||
}
|
||||
}
|
||||
|
||||
//Get the refresh token if scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
|
||||
//Setup the esi container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Get the observers from the database
|
||||
$observers = Observer::all();
|
||||
|
||||
$corpInfo = $lookup->GetCorporationInfo(auth()->user()->getId());
|
||||
|
||||
//Get the ledgers for each structure one at a time
|
||||
foreach($observers as $obs) {
|
||||
/**
|
||||
* Get the ledger from each observer.
|
||||
* We don't care about observer type as it can only be an Athanor or Tatara
|
||||
*/
|
||||
$ledgers = Ledger::where([
|
||||
'observer_id' => $obs->structure_id,
|
||||
'character_id' => auth()->user()->getId(),
|
||||
])->where('last_updated', '>=', Carbon::now()->subDays(30))->get();
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Get the structure name from the database
|
||||
$structure = $sHelper->GetStructureInfo($obs->observer_id);
|
||||
|
||||
array_push($miningLedgers, [
|
||||
'structure' => $structure->name,
|
||||
'character' => auth()->user()->getName(),
|
||||
'corpTicker' => $corpInfo->ticker,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'updated' => $ledger->last_updated,
|
||||
]);
|
||||
|
||||
array_push($structures, [
|
||||
'name' => $structure->name,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
redirect('/dashboard')->with('error', 'No available data for the mining ledger to be displayed.');
|
||||
}
|
||||
}
|
||||
|
||||
//Return the view
|
||||
return view('miningtax.user.display.ledger')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
}
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Lookups\ItemLookup;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\CorpObserversRegistered;
|
||||
use App\Models\Moon\CorpMoonObserver;
|
||||
|
||||
class MoonLedgerController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayMoonLedgerNew() {
|
||||
|
||||
}
|
||||
|
||||
public function displayMoonLedger() {
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
$miningLedgers = array();
|
||||
$tempMiningLedger = array();
|
||||
$tempMining = array();
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope(auth()->user()->getId(), 'esi-industry.read_corporation_mining.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Need to add scopes for esi-industry.read_corporation_mining.v1');
|
||||
} else {
|
||||
if(!$esiHelper->HaveEsiScope(auth()->user()->getId(), 'esi-universe.read_structures.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Need to add scope for esi-universe.read_structures.v1');
|
||||
}
|
||||
}
|
||||
|
||||
//Get the refresh token if scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken(auth()->user()->getId());
|
||||
|
||||
//Setup the esi container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo(auth()->user()->getId());
|
||||
|
||||
//Try to get the mining observers for the corporation from esi
|
||||
try {
|
||||
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred for some reason redirect back to the dashboard with an error message
|
||||
return redirect('/dashboard')->with('error', 'Failed to get mining structures.');
|
||||
}
|
||||
|
||||
//For each mining observer, let's build the array of data to show on the page
|
||||
foreach($responses as $response) {
|
||||
//Try to get the structure information from esi
|
||||
try {
|
||||
$structureInfo = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
'structure_id' => $response->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred, then do nothing
|
||||
}
|
||||
|
||||
//We don't really care about the key, but it is better than just 0 through whatever number
|
||||
$structures[$response->observer_id] = $structureInfo->name;
|
||||
}
|
||||
|
||||
//For each of the structures we want to address it by it's key value pair.
|
||||
//This will allow us to do some interesting things in the display.
|
||||
foreach($structures as $key => $value) {
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $key,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
$ledgers = null;
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Declare a variable that will need to be cleared each time the foreach processes
|
||||
$tempArray = array();
|
||||
|
||||
//Get the character information from the character id
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corp ticker
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
//Get the ore name from the type id
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//We only want to push the mining ledger entry into the array if it matches
|
||||
//the date within 30 days
|
||||
$sortTime = Carbon::now()->subDays(30);
|
||||
$current = Carbon::createFromFormat('Y-m-d', $ledger->last_updated);
|
||||
if($current->greaterThanOrEqualTo($sortTime)) {
|
||||
array_push($miningLedgers, [
|
||||
'structure' => $value,
|
||||
'character' => $charInfo->name,
|
||||
'corpTicker' => $corpInfo->ticker,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'updated' => $ledger->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view('moons.ledger.displayledger')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
}
|
||||
|
||||
public function displayRentalMoonLedger() {
|
||||
//Declare variables
|
||||
$structures = array();
|
||||
$miningLedgers = array();
|
||||
$tempMiningLedger = array();
|
||||
$tempMining = array();
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
|
||||
//Get the configuration for the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the ESI for the holding corp.');
|
||||
} else {
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||
return redirect('/dashboard')->with('error', 'Tell the nub Minerva to register the ESI for the holding corp.');
|
||||
}
|
||||
}
|
||||
|
||||
//Get the refresh token if scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
|
||||
//Setup the esi container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Try to get the mining observers for the corporation from esi
|
||||
try {
|
||||
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred for some reason redirect back to the dashboard with an error message
|
||||
return redirect('/dashboard')->with('error', 'Failed to get mining structures.');
|
||||
}
|
||||
|
||||
//For each mining observer, let's build the array of data to show on the page
|
||||
foreach($responses as $response) {
|
||||
//Try to get the structure information from esi
|
||||
try {
|
||||
$structureInfo = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
'structure_id' => $response->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred, then do nothing
|
||||
}
|
||||
|
||||
//We don't really care about the key, but it is better than just 0 through whatever number
|
||||
$structures[$response->observer_id] = $structureInfo->name;
|
||||
}
|
||||
|
||||
//For each of the structures we want to address it by it's key value pair.
|
||||
//This will allow us to do some interesting things in the display.
|
||||
foreach($structures as $key => $value) {
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $key,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
$ledgers = null;
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Declare a variable that will need to be cleared each time the foreach processes
|
||||
$tempArray = array();
|
||||
|
||||
//Get the character information from the character id
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corp ticker
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
//Get the ore name from the type id
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//We only want to push the mining ledger entry into the array if it matches
|
||||
//the date within 30 days
|
||||
$sortTime = Carbon::now()->subDays(30);
|
||||
$current = Carbon::createFromFormat('Y-m-d', $ledger->last_updated);
|
||||
if($current->greaterThanOrEqualTo($sortTime)) {
|
||||
array_push($miningLedgers, [
|
||||
'structure' => $value,
|
||||
'character' => $charInfo->name,
|
||||
'corpTicker' => $corpInfo->ticker,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'updated' => $ledger->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view('moons.ledger.rentalledger')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
}
|
||||
}
|
||||
@@ -1,595 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class MoonsAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* Variable for the class
|
||||
*/
|
||||
private $romans = [
|
||||
'M' => 1000,
|
||||
'CM' => 900,
|
||||
'D' => 500,
|
||||
'CD' => 400,
|
||||
'C' => 100,
|
||||
'XC' => 90,
|
||||
'L' => 50,
|
||||
'XL' => 40,
|
||||
'X' => 10,
|
||||
'IX' => 9,
|
||||
'V' => 5,
|
||||
'IV' => 4,
|
||||
'I' => 1,
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor for the class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display moon requests
|
||||
*/
|
||||
public function displayMoonRequests() {
|
||||
$requests = AllianceMoonRequest::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
return view('moons.admin.moonrequest')->with('requests', $requests);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to approve a moon request
|
||||
*/
|
||||
public function storeApprovedMoonRequest(Request $request) {
|
||||
//Validate the input request
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
'status' => 'required',
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
]);
|
||||
|
||||
|
||||
//Get the request data which holds all of the information for the request user
|
||||
$moon = AllianceMoonRequest::where([
|
||||
'id' => $request->id,
|
||||
])->first();
|
||||
|
||||
//Get the configuration data to use later in the function
|
||||
$config = config('esi');
|
||||
|
||||
//If the request is approved, then update everything.
|
||||
if($request->status == 'Approved') {
|
||||
//Update the alliance moon request to either approved or denied
|
||||
AllianceMoonRequest::where([
|
||||
'id' => $request->id,
|
||||
])->update([
|
||||
'status' => $request->status,
|
||||
'approver_name' => auth()->user()->getName(),
|
||||
'approver_id' => auth()->user()->getId(),
|
||||
]);
|
||||
|
||||
//Update the alliance moon in the table to the correct status
|
||||
AllianceMoon::where([
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->update([
|
||||
'Corporation' => $moon->corporation_ticker,
|
||||
'Availability' => 'Deployed',
|
||||
]);
|
||||
|
||||
//Send an eve mail to the requestor stating they can set a moon up.
|
||||
//Setup the mail body
|
||||
$body = 'The moon request for ' . $request->system . ' - ' . $request->planet . ' - ' . $request->moon . ' has changed status.<br>';
|
||||
$body .= 'The request has been ' . $request->status . '.<br>';
|
||||
$body .= 'Please contact the FC Team should it be necessary to arrange a fleet to cover the structure drop.<br>';
|
||||
$body .= 'Sincerely,<br>';
|
||||
$body .= 'Warped Intentions Leadership<br>';
|
||||
|
||||
|
||||
} else {
|
||||
//If the status was Denied, then update the request, and mark the moon available again.
|
||||
AllianceMoonRequest::where([
|
||||
'id' => $request->id,
|
||||
])->update([
|
||||
'status' => $request->status,
|
||||
'approver_name' => auth()->user()->getName(),
|
||||
'approver_id' => auth()->user()->getId(),
|
||||
]);
|
||||
|
||||
//Update the alliance moon in the table to the correct status
|
||||
AllianceMoon::where([
|
||||
'System' => (string)$request->system,
|
||||
'Planet' => (string)$request->planet,
|
||||
'Moon' => (string)$request->moon,
|
||||
])->update([
|
||||
'Availability' => 'Available',
|
||||
]);
|
||||
|
||||
//Send an eve mail to the requestor stating they can set a moon up.
|
||||
//Setup the mail body
|
||||
$body = 'The moon request for ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon . ' has changed status.<br>';
|
||||
$body .= 'The request has been ' . $request->status . '.<br>';
|
||||
$body .= 'Should you have questions please contact alliance leadership for further clarification.<br>';
|
||||
$body .= 'Sincerely,<br>';
|
||||
$body .= 'Warped Intentions Leadership<br>';
|
||||
|
||||
}
|
||||
|
||||
//Setup the mail model
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$moon->requestor_id, 'character', 'Warped Intentions Moon Request', $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
|
||||
return redirect('/moons/admin/display/request')->with('success', 'Moon has been processed, and mail has been sent out.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the ability for the admins to update moons with who is renting,
|
||||
* and when it ends
|
||||
*/
|
||||
public function updateMoon() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare the variables we need
|
||||
$system = null;
|
||||
$planet = null;
|
||||
$moon = null;
|
||||
$name = null;
|
||||
$spmnTemp = array();
|
||||
$spmn = array();
|
||||
|
||||
//Get the moons and put in order by System, Planet, Moon number
|
||||
$moons = AllianceRentalMoon::orderBy('System', 'ASC')
|
||||
->orderBy('Planet', 'ASC')
|
||||
->orderBy('Moon', 'ASC')
|
||||
->get();
|
||||
|
||||
//Push our default value onto the stack
|
||||
array_push($spmn, 'N/A');
|
||||
|
||||
//Form our array of strings for each system, planet, and moon combination
|
||||
foreach($moons as $m) {
|
||||
$temp = $m->system . " - " . $m->planet . " - " . $m->moon . " - " . $m->structure_name;
|
||||
array_push($spmnTemp, $temp);
|
||||
}
|
||||
|
||||
//From the temporary array, build the final array
|
||||
foreach($spmnTemp as $key => $value) {
|
||||
$spmn[$value] = $value;
|
||||
}
|
||||
|
||||
//Pass the data to the blade display
|
||||
return view('moons.admin.updatemoon')->with('spmn', $spmn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to remove a renter from a moon
|
||||
* New function based on new table. Will
|
||||
* update description in a future update.
|
||||
*/
|
||||
public function storeMoonRemoval(Request $request) {
|
||||
//Check for the correct role for the user to utilize this function
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Validate the request
|
||||
$this->validate($request, [
|
||||
'remove' => 'required',
|
||||
]);
|
||||
|
||||
//Explode the remove request to an array of strings
|
||||
$str_array = explode(" - ", $request->remove);
|
||||
|
||||
//Decode the value for the SPM into a system, planet, and moon
|
||||
$system = $str_array[0];
|
||||
$planet = $str_array[1];
|
||||
$moon = $str_array[2];
|
||||
|
||||
//Update the moon rental
|
||||
AllianceRentalMoon::where([
|
||||
'system' => $system,
|
||||
'planet' => $planet,
|
||||
'moon' => $moon,
|
||||
])->update([
|
||||
'rental_type' => 'Not Rented',
|
||||
'rental_until' => null,
|
||||
'rental_contact_id' => 0,
|
||||
'rental_contact_type' => 'Not Rented',
|
||||
'paid' => 'Not Rented',
|
||||
'paid_until' => null,
|
||||
'alliance_use_until' => null,
|
||||
]);
|
||||
|
||||
//Once the action is completed, redirect to the original page
|
||||
return redirect('/moons/admin/display/rentals')->with('success', 'Renter removed from the moon.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons to admins
|
||||
* New function based on new table. Will
|
||||
* update description in a future update.
|
||||
*/
|
||||
public function displayRentalMoonsAdmin() {
|
||||
//Declare variables for the function
|
||||
$lookupHelper = new LookupHelper;
|
||||
$moonCalc = new MoonCalc;
|
||||
$contactId = null;
|
||||
$contactType = null;
|
||||
$paid = null;
|
||||
$paidUntil = null;
|
||||
$corpTicker = null;
|
||||
$table = array();
|
||||
//Setup the carbon date using Carbon\Carbon
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get the moon rentals from the database
|
||||
$rentalMoons = AllianceRentalMoon::orderBy('system', 'asc')->get();
|
||||
|
||||
//For each of the moons compile different data for the view for formatting
|
||||
foreach($rentalMoons as $moon) {
|
||||
|
||||
//Check if a current rental for the moon is on going
|
||||
if(($moon->rental_type == 'In Alliance' || $moon->rental_type == 'Out of Alliance')) {
|
||||
$paid = $moon->paid;
|
||||
$paidUntil = new Carbon($moon->paid_until);
|
||||
$paidUntil = $paidUntil->format('m-d');
|
||||
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($moon->rental_until);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the correct color for the table
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Set the contact name based on the contact type
|
||||
if($moon->rental_contact_type == 'Alliance') {
|
||||
$allianceInfo = $lookupHelper->GetAllianceInfo($moon->rental_contact_id);
|
||||
//Set the contact name and ticker
|
||||
$contact = $allianceInfo->name;
|
||||
$ticker = $allianceInfo->ticker;
|
||||
|
||||
} else if($moon->rental_contact_type == 'Corporation') {
|
||||
$corporationInfo = $lookupHelper->GetCorporationInfo($moon->rental_contact_id);
|
||||
//Set the contact name and ticker
|
||||
$contact = $corporationInfo->name;
|
||||
$ticker = $corporationInfo->ticker;
|
||||
|
||||
} else if($moon->rental_contact_type == 'Character') {
|
||||
$characterInfo = $lookupHelper->GetCharacterInfo($moon->rental_contact_id);
|
||||
//Set the contact name
|
||||
$contact = $characterInfo->name;
|
||||
//Get the ticker for the character from the corporation he belongs to
|
||||
$corpInfo = $lookupHelper->GetCorporationInfo($characterInfo->corporation_id);
|
||||
$ticker = $corpInfo->ticker;
|
||||
|
||||
} else {
|
||||
$contact = 'N/A';
|
||||
$ticker = 'N/A';
|
||||
$type = 'N/A';
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Check if the moon is currently being utilized by the alliance
|
||||
} else if($moon->rental_type == 'Alliance') {
|
||||
//If the moon is in use by the alliance then the moon isn't paid for
|
||||
$paid = 'No';
|
||||
|
||||
//Setup the rental end time as the end of the month
|
||||
$rentalTemp = Carbon::now()->endOfMonth();
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
//Set the color of the table
|
||||
$color = 'table-info';
|
||||
|
||||
//Setup the paid time as the same as the rental end
|
||||
$paidUntiltemp = $rentalTemp;
|
||||
$paidUntil = $rentalEnd;
|
||||
|
||||
//Set the other information for the spreadsheet
|
||||
$contact = 'Spatial Forces';
|
||||
$renter = 'SP3C';
|
||||
$ticker = 'SP3C';
|
||||
$type = 'Alliance';
|
||||
|
||||
//The last case is the moon is not utilized by the Alliance or is not being rented
|
||||
} else {
|
||||
//If the moon is not being rented, or being utilized by the alliance then set paid to No
|
||||
$paid = 'No';
|
||||
|
||||
//Setup the rental time to end as last month to show it's free
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Setup the paid until as last month to show it's free
|
||||
$paidUntilTemp = $lastMonth;
|
||||
$paidUntil = $lastMonth->format('m-d');
|
||||
|
||||
//Setup the other variables with the correct information
|
||||
$contact = 'None';
|
||||
$renter = 'None';
|
||||
$ticker = 'N/A';
|
||||
$type = 'N/A';
|
||||
|
||||
//Set the color of the table
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Set up the moon rental type
|
||||
if($moon->rental_type == 'In Alliance') {
|
||||
$type = 'IA';
|
||||
//Setup the row color
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
} else if($moon->rental_type == 'Out of Alliance') {
|
||||
$type = 'OOA';
|
||||
//Setup the row color
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
} else if($moon->rental_type == 'Alliance') {
|
||||
$type = 'W4RP';
|
||||
//Set the row color
|
||||
$color = 'table-info';
|
||||
} else {
|
||||
$type = 'N/A';
|
||||
//Set the row color
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Add the data to the html string to be passed to the view
|
||||
array_push($table, [
|
||||
'SPM' => $moon->system . " - " . $moon->planet . " - " . $moon->moon,
|
||||
'StructureName' => $moon->structure_name,
|
||||
'AlliancePrice' => $moon->alliance_rental_price,
|
||||
'OutOfAlliancePrice' => $moon->out_of_alliance_rental_price,
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
'Paid' => $moon->paid,
|
||||
'PaidUntil' => $paidUntil,
|
||||
'Contact' => $contact,
|
||||
'Type' => $moon->rental_type,
|
||||
'Renter' => $type,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('moons.admin.adminmoon')->with('table', $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to store the updates from the moons.
|
||||
* New function based on new table. Will update
|
||||
* the description in a future update
|
||||
*/
|
||||
public function storeUpdateMoon(Request $request) {
|
||||
//Require the site administration role
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some variables we will need
|
||||
$moonCalc = new MoonCalc;
|
||||
$lookup = new LookupHelper;
|
||||
$paid = false;
|
||||
$system = null;
|
||||
$planet = null;
|
||||
$mn = null;
|
||||
|
||||
//Validate our request from the html form
|
||||
$this->validate($request, [
|
||||
'spmn' => 'required',
|
||||
'contact' => 'required',
|
||||
'contact_type' => 'required',
|
||||
'paid_until' => 'required',
|
||||
'rental_end' => 'required',
|
||||
]);
|
||||
|
||||
//Decode the spmn
|
||||
$str_array = explode(" - ", $request->spmn);
|
||||
$system = $str_array[0];
|
||||
$planet = $str_array[1];
|
||||
$mn = $str_array[2];
|
||||
$name = $str_array[3];
|
||||
|
||||
//Update the paid value from the request value
|
||||
if($request->paid == 'Yes') {
|
||||
$paid = 'Yes';
|
||||
} else {
|
||||
$paid = 'No';
|
||||
}
|
||||
|
||||
//Setup the rental end and paid until variables
|
||||
$rentalEnd = $request->rental_end . " 23:59:59";
|
||||
$paidUntil = $request->paid_until . " 23:59:59";
|
||||
|
||||
//Check if the alliance is renting the moon for itself
|
||||
if($request->contact_type == 'Corporation' && $request->contact == 'Spatial Forces') {
|
||||
AllianceRentalMoon::where([
|
||||
'system' => $str_array[0],
|
||||
'planet' => $str_array[1],
|
||||
'moon' => $str_array[2],
|
||||
])->update([
|
||||
'rental_type' => 'Alliance',
|
||||
'rental_until' => $request->rental_end . " 23:59:59",
|
||||
'rental_contact_id' => 98287666,
|
||||
'rental_contact_type' => 'Alliance',
|
||||
'paid' => 'No',
|
||||
'paid_until' => null,
|
||||
'alliance_use_until' => $request->rental_end . " 23:59:59",
|
||||
]);
|
||||
} else if($request->contact_type == 'Character') {
|
||||
//Get the character id from the lookup helper
|
||||
$charId = $lookup->CharacterNameToId($request->contact);
|
||||
//Get the character information including the corporation from the lookup tables
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
//Get the corporation id from the lookup helper, followed by the alliance id
|
||||
//so we can determine if it's in alliance or out of alliance
|
||||
$corp = $lookup->GetCorporationInfo($char->corporation_id);
|
||||
|
||||
if($corp->alliance_id == 99004116) {
|
||||
$type = 'In Alliance';
|
||||
} else {
|
||||
$type = 'Out of Alliance';
|
||||
}
|
||||
|
||||
AllianceRentalMoon::where([
|
||||
'system' => $str_array[0],
|
||||
'planet' => $str_array[1],
|
||||
'moon' => $str_array[2],
|
||||
])->update([
|
||||
'rental_type' => $type,
|
||||
'rental_until' => $request->rental_end . " 23:59:59",
|
||||
'rental_contact_id' => $charId,
|
||||
'rental_contact_type' => 'Character',
|
||||
'paid' => $paid,
|
||||
'paid_until' => $request->paid_until . " 23:59:59",
|
||||
'alliance_use_until' => null,
|
||||
]);
|
||||
|
||||
} else if($request->contact_type == 'Corporation') {
|
||||
//Get the corporation id from the lookup helper
|
||||
$corpId = $lookup->CorporationNameToId($request->contact);
|
||||
//Get the corporation information to determine if they are in Warped Intentions or not.
|
||||
$corporation = $lookup->GetCorporationInfo($request->contact);
|
||||
|
||||
if($corp->alliance_id == 99004116) {
|
||||
$type = 'In Alliance';
|
||||
} else {
|
||||
$type = 'Out of Alliance';
|
||||
}
|
||||
|
||||
AllianceMoonRental::where([
|
||||
'system' => $str_array[0],
|
||||
'planet' => $str_array[1],
|
||||
'moon' => $str_array[2],
|
||||
])->update([
|
||||
'rental_type' => $type,
|
||||
'rental_until' => $request->rental_end . " 23:59:59",
|
||||
'rental_contact_id' => $corpId,
|
||||
'rental_contact_type' => 'Corporation',
|
||||
'paid' => $paid,
|
||||
'paid_until' => $request->paid_until . " 23:59:59",
|
||||
'alliance_use_until' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
//Redirect to the previous screen.
|
||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Rental updated.');
|
||||
}
|
||||
|
||||
public function ImportMoonSurveyData(Request $request) {
|
||||
//Declare variables
|
||||
$added = 0;
|
||||
$updated = 0;
|
||||
$moon = null;
|
||||
$newMoon = false;
|
||||
$num = 0;
|
||||
$planet = null;
|
||||
$moonNumber = null;
|
||||
|
||||
foreach(explode("\n", $request->input('data')) as $row) {
|
||||
$cols = explode("\t", $row);
|
||||
dd($cols);
|
||||
}
|
||||
|
||||
return redirect('/admin/dashboard')->with('success', 'Import done: ' . $added . ' moons added ' . $updated . ' moons updated.');
|
||||
}
|
||||
|
||||
private function romanNumberToInteger($roman) {
|
||||
$result = 0;
|
||||
|
||||
foreach($this->romans as $key => $value) {
|
||||
while(strpos($roman, $key) === 0) {
|
||||
$result += $value;
|
||||
$roman = substr($roman, strlen($key));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function integerToRomanNumber($number) {
|
||||
$returnValue = '';
|
||||
while($number > 0) {
|
||||
foreach($this->romans as $roman => $int) {
|
||||
if($number >= $int) {
|
||||
$number -= $int;
|
||||
$returnValue .= $roman;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
private function arrayToCsv(array $rows) {
|
||||
//Declare needed variable as text null
|
||||
$result = '';
|
||||
|
||||
//Open the temp file
|
||||
$fp = fopen('php://temp', 'w');
|
||||
|
||||
//Process the file
|
||||
foreach($rows as $fields) {
|
||||
fputcsv($fp, $fields, ';', '"');
|
||||
|
||||
}
|
||||
|
||||
//Go back to the beginning of the file
|
||||
rewind($fp);
|
||||
|
||||
//Continue through the buffer until the end
|
||||
while(($buffer = fgets($fp, 4096)) !== false) {
|
||||
$result .= $buffer;
|
||||
}
|
||||
|
||||
//Close the temp file
|
||||
fclose($fp);
|
||||
|
||||
//Return the result
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,568 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class MoonsController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
public function displayRentalMoonPage() {
|
||||
return view('moons.user.requestrental');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display all alliance moons and pass data to the blade template
|
||||
*/
|
||||
public function displayMoons() {
|
||||
//Setup variables for moons
|
||||
$moons = array();
|
||||
$systems = array();
|
||||
|
||||
//Get all of the alliance moon systems from the database
|
||||
$systems = AllianceMoon::groupBy('System')->pluck('System');
|
||||
|
||||
//Get all of the alliance moons from the database
|
||||
$moons = AllianceMoon::all();
|
||||
|
||||
$gasGoo = [
|
||||
'Zeolites',
|
||||
'Sylvite',
|
||||
'Bitumens',
|
||||
'Coesite',
|
||||
];
|
||||
|
||||
$r8Goo = [
|
||||
'Cobaltite',
|
||||
'Euxenite',
|
||||
'Titanite',
|
||||
'Scheelite',
|
||||
];
|
||||
|
||||
$r16Goo = [
|
||||
'Otavite',
|
||||
'Sperrylite',
|
||||
'Vanadinite',
|
||||
'Chromite',
|
||||
];
|
||||
|
||||
$r32Goo = [
|
||||
'Carnotite',
|
||||
'Zircon',
|
||||
'Pollucite',
|
||||
'Cinnabar',
|
||||
];
|
||||
|
||||
$r64Goo = [
|
||||
'Xenotime',
|
||||
'Monazite',
|
||||
'Loparite',
|
||||
'Ytterbite',
|
||||
];
|
||||
|
||||
return view('moons.user.allmoons')->with('systems', $systems)
|
||||
->with('moons', $moons)
|
||||
->with('gasGoo', $gasGoo)
|
||||
->with('r8Goo', $r8Goo)
|
||||
->with('r16Goo', $r16Goo)
|
||||
->with('r32Goo', $r32Goo)
|
||||
->with('r64Goo', $r64Goo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display moon request form
|
||||
*/
|
||||
public function displayRequestAllianceMoon() {
|
||||
return view('moons.user.requestmoon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to store the moon request
|
||||
*/
|
||||
public function storeRequestAllianceMoon(Request $request) {
|
||||
$this->validate($request, [
|
||||
'system' => 'required',
|
||||
'planet' => 'required',
|
||||
'moon' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some necessary arrays for figuring out what region a moon resides in
|
||||
$catch = [
|
||||
'6X7-JO',
|
||||
'A803-L',
|
||||
'I8-D0G',
|
||||
'WQH-4K',
|
||||
'GJ0-JO',
|
||||
'Q-S7ZD',
|
||||
'JWZ2-V',
|
||||
'J-ODE7',
|
||||
'OGL8-Q',
|
||||
'R-K4QY',
|
||||
];
|
||||
|
||||
$immensea = [
|
||||
'ZBP-TP',
|
||||
'XVV-21',
|
||||
'B9E-H6',
|
||||
'JDAS-0',
|
||||
'Y19P-1',
|
||||
'LN-56V',
|
||||
'O7-7UX',
|
||||
'Y2-QUV',
|
||||
'SPBS-6',
|
||||
'A4B-V5',
|
||||
'GXK-7F',
|
||||
'78TS-Q',
|
||||
'CJNF-J',
|
||||
'EA-HSA',
|
||||
'FYI-49',
|
||||
'WYF8-8',
|
||||
'NS2L-4',
|
||||
'B-S347',
|
||||
'AF0-V5',
|
||||
'QI-S9W',
|
||||
'B-A587',
|
||||
'PPFB-U',
|
||||
'L-5JCJ',
|
||||
'4-GB14',
|
||||
'REB-KR',
|
||||
'QE-E1D',
|
||||
'LK1K-5',
|
||||
'Z-H2MA',
|
||||
'B-KDOZ',
|
||||
'E8-YS9',
|
||||
'DY-P7Q',
|
||||
];
|
||||
|
||||
//Declare lookup variables
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Get all of the information needed to create the database entry
|
||||
$charId = auth()->user()->getId();
|
||||
$charInfo = $lookup->GetCharacterInfo($charId);
|
||||
$charName = $charInfo->name;
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
$corpId = $corpInfo->corporation_id;
|
||||
$corpName = $corpInfo->name;
|
||||
$corpTicker = $corpInfo->ticker;
|
||||
//Declare the region variable as null for the lookup if statement
|
||||
$region = null;
|
||||
|
||||
//Get the region the moon resides in from the system
|
||||
if(in_array($request->system, $catch, true)) {
|
||||
$region = 'Catch';
|
||||
} else if(in_array($request->system, $immensea, true)) {
|
||||
$region = 'Immensea';
|
||||
} else {
|
||||
//False value. Redirect back to page
|
||||
return redirct('/moons/display/request')->with('error', 'Region was not found.');
|
||||
}
|
||||
|
||||
//Check to see if the moon has been previously inputted for
|
||||
$allMoons = AllianceMoon::all();
|
||||
foreach($allMoons as $moon) {
|
||||
if($moon->Region == $region && $moon->System == $request->system && $moon->Planet == $request->planet && $moon->Moon == $request->moon) {
|
||||
if($moon->Availability != 'Available') {
|
||||
return redirect('moons/display/request')->with('error', 'The moon has already been reserved by another party.');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Create the new object to save into the database
|
||||
$moonRequest = new AllianceMoonRequest;
|
||||
$moonRequest->region = $region;
|
||||
$moonRequest->system = $request->system;
|
||||
$moonRequest->planet = $request->planet;
|
||||
$moonRequest->moon = $request->moon;
|
||||
$moonRequest->corporation_id = $corpId;
|
||||
$moonRequest->corporation_name = $corpName;
|
||||
$moonRequest->corporation_ticker = $corpTicker;
|
||||
$moonRequest->requestor_name = $charName;
|
||||
$moonRequest->requestor_id = $charId;
|
||||
$moonRequest->status = 'Pending';
|
||||
$moonRequest->save();
|
||||
|
||||
//Update the current moon's status in the model AllianceMoon
|
||||
AllianceMoon::where([
|
||||
'Region' => $region,
|
||||
'System' => $request->system,
|
||||
'Planet' => $request->planet,
|
||||
'Moon' => $request->moon,
|
||||
])->update([
|
||||
'Availability' => 'Request Pending',
|
||||
]);
|
||||
|
||||
//Send a mail over to the site admins to approve the moon request
|
||||
$config = config('esi');
|
||||
$body = 'A new moon request has been entered into the services site. Please approve or deny the request within 3 business days.<br><br>';
|
||||
$body .= 'Sincerely,<br>';
|
||||
$body .= 'W4RP Services Site';
|
||||
$subject = 'New Moon Request Available';
|
||||
|
||||
ProcessSendEveMailJob::dispatch($body, 92947432, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
ProcessSendEveMailJob::dispatch($body, 92626011, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(60));
|
||||
|
||||
return redirect('/moons/display/request')->with('success', 'Moon request submitted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons and pass to the blade template
|
||||
* Function description will be updated in a future release.
|
||||
*/
|
||||
public function displayRentalMoons() {
|
||||
//Declare variables
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
$table = array();
|
||||
$moonprice = null;
|
||||
|
||||
//Get the user type from the user Auth class
|
||||
$type = auth()->user()->getUserType();
|
||||
//Get all of the rental moons from the database
|
||||
$moons = AllianceRentalMoon::orderBy('system', 'ASC')
|
||||
->orderBy('planet', 'ASC')
|
||||
->orderBy('moon', 'ASC')
|
||||
->get();
|
||||
|
||||
//For each of the moons let's format the data for the display table
|
||||
foreach($moons as $moon) {
|
||||
$color = null;
|
||||
$rentalTemp = null;
|
||||
$rentalEnd = null;
|
||||
|
||||
//Check if someone is currently renting the moon
|
||||
if($moon->rental_type == 'In Alliance' || $moon->rental_type == 'Out of Alliance') {
|
||||
$rentalTemp = new Carbon($moon->rental_until);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Setup the correct color for the table
|
||||
if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
|
||||
$color = 'table-warning';
|
||||
} else if($today->lessThan($rentalTemp)) {
|
||||
$color = 'table-danger';
|
||||
} else {
|
||||
$color = 'table-primary';
|
||||
}
|
||||
} else if($moon->rental_type == 'Alliance') {
|
||||
$rentalTemp = Carbon::now()->endOfMonth();
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
$color = 'table-info';
|
||||
} else {
|
||||
//Set the rental date for if someone is not renting the moon
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
$color = 'table-primary';
|
||||
}
|
||||
|
||||
//Get the price of the moon from the database based on if the person is in Warped Intentions
|
||||
$userType = auth()->user()->getUserType();
|
||||
if($userType == 'W4RP') {
|
||||
$moonprice = $moon->alliance_rental_price;
|
||||
} else {
|
||||
$moonprice = $moon->out_of_alliance_rental_price;
|
||||
}
|
||||
|
||||
//Add the data to the html array to be passed to the view
|
||||
array_push($table, [
|
||||
'SPM' => $moon->system . " - " . $moon->planet . " - " . $moon->moon,
|
||||
'StructureName' => $moon->structure_name,
|
||||
'FirstOre' => $moon->first_ore,
|
||||
'FirstQuantity' => number_format($moon->first_quantity, 0, ".", ","),
|
||||
'SecondOre' => $moon->second_ore,
|
||||
'SecondQuantity' => number_format($moon->second_quantity, 0, ".", ","),
|
||||
'ThirdOre' => $moon->third_ore,
|
||||
'ThirdQuantity' => number_format($moon->third_quantity, 0, ".", ","),
|
||||
'FourthOre' => $moon->fourth_ore,
|
||||
'FourthQuantity' => number_format($moon->fourth_quantity, 0, ".", ","),
|
||||
'Price' => number_format($moonprice, 0, ".", ","),
|
||||
'Worth' => number_format($moon->moon_worth, 0, ".", ","),
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
//Pass the data to the view
|
||||
return view('moons.user.moon')->with('table', $table);
|
||||
}
|
||||
|
||||
public function displayTotalWorthForm() {
|
||||
return view('moons.user.formTotalWorth');
|
||||
}
|
||||
|
||||
public function displayTotalWorth(Request $request) {
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||
$composition = [
|
||||
'Tritanium' => 0,
|
||||
'Pyerite' => 0,
|
||||
'Mexallon' => 0,
|
||||
'Isogen' => 0,
|
||||
'Nocxium' => 0,
|
||||
'Zydrine' => 0,
|
||||
'Megacyte' => 0,
|
||||
'Atmospheric_Gases' => 0,
|
||||
'Evaporite_Deposits' => 0,
|
||||
'Hydrocarbons' => 0,
|
||||
'Silicates' => 0,
|
||||
'Cobalt' => 0,
|
||||
'Scandium' => 0,
|
||||
'Titanium' => 0,
|
||||
'Tungsten' => 0,
|
||||
'Cadmium' => 0,
|
||||
'Platinum' => 0,
|
||||
'Vanadium'=> 0,
|
||||
'Chromium' => 0,
|
||||
'Technetium' => 0,
|
||||
'Hafnium' => 0,
|
||||
'Caesium' => 0,
|
||||
'Mercury' => 0,
|
||||
'Dysprosium' => 0,
|
||||
'Neodymium' => 0,
|
||||
'Promethium' => 0,
|
||||
'Thulium' => 0,
|
||||
];
|
||||
|
||||
$firstOre = $request->firstOre;
|
||||
if($request->firstQuantity >= 1.00) {
|
||||
$firstQuantity = $request->firstQuantity / 100.00;
|
||||
} else {
|
||||
$firstQuantity = $request->firstQuantity;
|
||||
}
|
||||
|
||||
$secondOre = $request->secondOre;
|
||||
if($request->secondQuantity >= 1.00) {
|
||||
$secondQuantity = $request->secondQuantity / 100.00;
|
||||
} else {
|
||||
$secondQuantity = $request->secondQuantity;
|
||||
}
|
||||
|
||||
$thirdOre = $request->thirdOre;
|
||||
if($request->thirdQuantity >= 1.00) {
|
||||
$thirdQuantity = $request->thirdQuantity / 100.00;
|
||||
} else {
|
||||
$thirdQuantity = $request->thirdQuantity;
|
||||
}
|
||||
|
||||
$fourthOre = $request->fourthOre;
|
||||
if($request->fourthQuantity >= 1.00) {
|
||||
$fourthQuantity = $request->fourthQuantity / 100.00;
|
||||
} else {
|
||||
$fourthQuantity = $request->fourthQuantity;
|
||||
}
|
||||
|
||||
if($request->reprocessing >= 1.00) {
|
||||
$reprocessing = $request->reprocessing / 100.00;
|
||||
} else {
|
||||
$reprocessing = $request->reprocessing;
|
||||
}
|
||||
|
||||
//Set the reprocessing level for 84% if the value is null
|
||||
if($request->reprocessing == null) {
|
||||
$reprocessing = 0.84;
|
||||
}
|
||||
|
||||
//Get the total percentage of the ores, and normalize it to 1.00.
|
||||
$totalPercent = $firstQuantity + $secondQuantity + $thirdQuantity + $fourthQuantity;
|
||||
if($totalPercent < 1.00) {
|
||||
$firstQuantity = $firstQuantity / $totalPercent;
|
||||
$secondQuantity = $secondQuantity / $totalPercent;
|
||||
$thirdQuantity = $thirdQuantity / $totalPercent;
|
||||
$fourthQuantity = $fourthQuantity / $totalPercent;
|
||||
}
|
||||
|
||||
//Calculate the total worth of the moon
|
||||
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
//Format the number to send to the blade.
|
||||
$totalWorth = number_format($totalWorth, 2, ".", ",");
|
||||
|
||||
//Get the composition for the first ore if it is not None.
|
||||
//Add the first ore composition to the final composition
|
||||
if($firstOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$firstComp = $moonCalc->GetOreComposition($firstOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($firstOre, $firstQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
//Compile the composition of the ore
|
||||
$composition['Tritanium'] += floor(($firstComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($firstComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($firstComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($firstComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($firstComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($firstComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($firstComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($firstComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($firstComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($firstComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($firstComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($firstComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($firstComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($firstComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($firstComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($firstComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($firstComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($firstComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($firstComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($firstComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($firstComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($firstComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($firstComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($firstComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($firstComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($firstComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($firstComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the second ore if it is not None.
|
||||
//Add the second ore composition to the final composition
|
||||
if($secondOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$secondComp = $moonCalc->GetOreComposition($secondOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($secondOre, $secondQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($secondComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($secondComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($secondComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($secondComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($secondComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($secondComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($secondComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($secondComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($secondComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($secondComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($secondComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($secondComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($secondComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($secondComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($secondComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($secondComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($secondComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($secondComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($secondComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($secondComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($secondComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($secondComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($secondComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($secondComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($secondComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($secondComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($secondComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the third ore if it is not None.
|
||||
//Add the third ore composition to the final composition
|
||||
if($thirdOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$thirdComp = $moonCalc->GetOreComposition($thirdOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($thirdOre, $thirdQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($thirdComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($thirdComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($thirdComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($thirdComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($thirdComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($thirdComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($thirdComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($thirdComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($thirdComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($thirdComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($thirdComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($thirdComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($thirdComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($thirdComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($thirdComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($thirdComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($thirdComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($thirdComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($thirdComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($thirdComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($thirdComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($thirdComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($thirdComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($thirdComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($thirdComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($thirdComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($thirdComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
//Get the composition for the fourth ore if it is not None.
|
||||
//Add the fourth ore composition to the final composition
|
||||
if($fourthOre != 'None') {
|
||||
//Get the ore's composition
|
||||
$fourthComp = $moonCalc->GetOreComposition($fourthOre);
|
||||
//Get the amount of units mine-able from the moon
|
||||
$mUnits = $moonCalc->CalcOreUnits($fourthOre, $fourthQuantity);
|
||||
//Calculate the number of reprocessing units to happen from moon units
|
||||
$rUnits = floor($mUnits / 100.0);
|
||||
|
||||
$composition['Tritanium'] += floor(($fourthComp->Tritanium * $rUnits) * $reprocessing);
|
||||
$composition['Pyerite'] += floor(($fourthComp->Pyerite * $rUnits) * $reprocessing);
|
||||
$composition['Mexallon'] += floor(($fourthComp->Mexallon * $rUnits) * $reprocessing);
|
||||
$composition['Isogen'] += floor(($fourthComp->Isogen * $rUnits) * $reprocessing);
|
||||
$composition['Nocxium'] += floor(($fourthComp->Nocxium * $rUnits) * $reprocessing);
|
||||
$composition['Zydrine'] += floor(($fourthComp->Zydrine * $rUnits) * $reprocessing);
|
||||
$composition['Megacyte'] += floor(($fourthComp->Megacyte * $rUnits) * $reprocessing);
|
||||
$composition['Atmospheric_Gases'] += floor(($fourthComp->AtmosphericGases * $rUnits) * $reprocessing);
|
||||
$composition['Evaporite_Deposits'] += floor(($fourthComp->EvaporiteDeposits * $rUnits) * $reprocessing);
|
||||
$composition['Hydrocarbons'] += floor(($fourthComp->Hydrocarbons * $rUnits) * $reprocessing);
|
||||
$composition['Silicates'] += floor(($fourthComp->Silicates * $rUnits) * $reprocessing);
|
||||
$composition['Cobalt'] += floor(($fourthComp->Cobalt * $rUnits) * $reprocessing);
|
||||
$composition['Scandium'] += floor(($fourthComp->Scandium * $rUnits) * $reprocessing);
|
||||
$composition['Titanium'] += floor(($fourthComp->Titanium * $rUnits) * $reprocessing);
|
||||
$composition['Tungsten'] += floor(($fourthComp->Tungsten * $rUnits) * $reprocessing);
|
||||
$composition['Cadmium'] += floor(($fourthComp->Cadmium * $rUnits) * $reprocessing);
|
||||
$composition['Platinum'] += floor(($fourthComp->Platinium * $rUnits) * $reprocessing);
|
||||
$composition['Vanadium'] += floor(($fourthComp->Vanadium * $rUnits) * $reprocessing);
|
||||
$composition['Chromium'] += floor(($fourthComp->Chromium * $rUnits) * $reprocessing);
|
||||
$composition['Technetium'] += floor(($fourthComp->Technetium * $rUnits) * $reprocessing);
|
||||
$composition['Hafnium'] += floor(($fourthComp->Hafnium * $rUnits) * $reprocessing);
|
||||
$composition['Caesium'] += floor(($fourthComp->Caesium * $rUnits) * $reprocessing);
|
||||
$composition['Mercury'] += floor(($fourthComp->Mercury * $rUnits) * $reprocessing);
|
||||
$composition['Dysprosium'] += floor(($fourthComp->Dysprosium * $rUnits) * $reprocessing);
|
||||
$composition['Neodymium'] += floor(($fourthComp->Neodymium * $rUnits) * $reprocessing);
|
||||
$composition['Promethium'] += floor(($fourthComp->Promethium * $rUnits) * $reprocessing);
|
||||
$composition['Thulium'] += floor(($fourthComp->Thulium * $rUnits) * $reprocessing);
|
||||
}
|
||||
|
||||
return view('moons.user.displayTotalWorth')->with('totalWorth', $totalWorth)
|
||||
->with('composition', $composition)
|
||||
->with('reprocessing', $reprocessing);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\AllianceRentalMoon;
|
||||
|
||||
class RentalMoonsAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middelware('role:user');
|
||||
$this->middleware('permission:mining.director');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display rental moons being used for the alliance
|
||||
*/
|
||||
public function displayAllianceUsageRentalMoons() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the form for requesting new rental moon for the alliance
|
||||
*/
|
||||
public function displayRentalMoonForAllianceForm() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to store when a new rental moon is requested
|
||||
*/
|
||||
public function storeRentalMoonForAlliance(Request $request) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the form for figuring out item composition
|
||||
*/
|
||||
public function displayItemCompositionForm() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the results of the form for figuring out item composition
|
||||
*/
|
||||
public function displayItemCompositionResults(Request $request) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use Khill\Lavacharts\Lavacharts;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//User Libraries
|
||||
use App\Library\SRP\SRPHelper;
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SRPShip;
|
||||
|
||||
@@ -7,7 +7,8 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
|
||||
//User Libraries
|
||||
//Application Libraries
|
||||
use App\Library\Helpers\SRPHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\SRPShip;
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SystemRentals;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\SystemRentals\RentalSystem;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class RentalAdminController extends Controller
|
||||
{
|
||||
//Constructor
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display all active rental systems and
|
||||
* the information regarding the rental systems
|
||||
*/
|
||||
public function displayRentalSystems() {
|
||||
//Get the rental systems from the database
|
||||
$rentals = RentalSystem::all();
|
||||
|
||||
foreach($rentals as $rental) {
|
||||
//Format the rental cost
|
||||
if($rental->rental_cost > 1000000000.00) {
|
||||
$rental->rental_cost = $rental->rental_cost / 1000000000.00;
|
||||
$rental->rental_cost = $rental->rental_cost . "B";
|
||||
} else if($rental->rental_cost > 1000000.00 && $rental->rental_cost < 999999999.99) {
|
||||
$rental->rental_cost = $rental->rental_cost / 1000000.00;
|
||||
$rental->rental_cost = $rental->rental_cost . "M";
|
||||
}
|
||||
|
||||
//Format the date
|
||||
$rental->paid_until = Carbon::parse($rental->paid_until)->format('Y-m-d');
|
||||
}
|
||||
|
||||
//Return the view with the data
|
||||
return view('rental.list')->with('rentals', $rentals);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display form for adding new rental system
|
||||
*/
|
||||
public function displayAddRentalSystem() {
|
||||
return view('rental.add');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add new rental system to the database
|
||||
*/
|
||||
public function addRentalSystem(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contact_name' => 'required',
|
||||
'contact_corp_name' => 'required',
|
||||
'system' => 'required',
|
||||
'rental_cost' => 'required',
|
||||
'paid_until' => 'required',
|
||||
]);
|
||||
|
||||
//Declare the variables and classes needed
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//From the character name find the character id
|
||||
$charId = $lookup->CharacterNameToId($request->contact_name);
|
||||
|
||||
//From the corporation name find the corporation id
|
||||
$corpId = $lookup->CorporationNameToId($request->contact_corp_name);
|
||||
|
||||
//From the system name find the system id
|
||||
$systemId = $lookup->SystemNameToId($request->system);
|
||||
|
||||
//Sanitize the bid amount
|
||||
if(preg_match('(m|M|b|B)', $request->rental_cost) === 1) {
|
||||
if(preg_match('(m|M)', $request->rental_cost) === 1) {
|
||||
$cStringSize = strlen($request->rental_cost);
|
||||
$tempCol = str_split($request->rental_cost, $cStringSize - 1);
|
||||
$rentalCost = $tempCol[0];
|
||||
$rentalCost = $rentalCost * 1000000.00;
|
||||
} else if(preg_match('(b|B)', $request->rental_cost) === 1) {
|
||||
$cStringSize = strlen($request->rental_cost);
|
||||
$tempCol = str_split($request->rental_cost, $cStringSize - 1);
|
||||
$rentalCost = $tempCol[0];
|
||||
$rentalCost = $rentalCost * 1000000000.00;
|
||||
}
|
||||
} else {
|
||||
$rentalCost = $request->rental_cost;
|
||||
}
|
||||
|
||||
//Create the database model
|
||||
$rental = new RentalSystem;
|
||||
$rental->contact_id = $charId;
|
||||
$rental->contact_name = $request->contact_name;
|
||||
$rental->corporation_id = $corpId;
|
||||
$rental->corporation_name = $request->contact_corp_name;
|
||||
$rental->system_id = $systemId;
|
||||
$rental->system_name = $request->system;
|
||||
$rental->rental_cost = $rentalCost;
|
||||
$rental->paid_until = $request->paid_until;
|
||||
$rental->save();
|
||||
|
||||
return redirect('/system/rental/dashboard')->with('success', 'Rental System Added.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update paid until section of the rental system in the database
|
||||
*/
|
||||
public function updateRentalSystem(Request $request) {
|
||||
$this->validate($request, [
|
||||
'paid_until' => 'required',
|
||||
'contact_id' => 'required',
|
||||
'corporation_id' => 'required',
|
||||
'system_id' => 'required',
|
||||
]);
|
||||
|
||||
RentalSystem::where([
|
||||
'contact_id' => $request->contact_id,
|
||||
'corporation_id' => $request->corporation_id,
|
||||
'system_id' => $request->system_id,
|
||||
])->update([
|
||||
'paid_until' => $request->paid_until,
|
||||
]);
|
||||
|
||||
return redirect('/system/rental/dashboard')->with('success', 'Rental System updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to remove rental system from the database
|
||||
*/
|
||||
public function removeRentalSystem(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contact_id' => 'required',
|
||||
'corporation_id' => 'required',
|
||||
'system_id' => 'required',
|
||||
]);
|
||||
|
||||
RentalSystem::where([
|
||||
'contact_id' => $request->contact_id,
|
||||
'corporation_id' => $request->corporation_id,
|
||||
'system_id' => $request->system_id,
|
||||
])->delete();
|
||||
|
||||
return redirect('/system/rental/dashboard')->with('success', 'Removed renter from database.');
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Test;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wiki;
|
||||
|
||||
//Laravel libraries
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
|
||||
//User Libraries
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Wiki\WikiHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
use App\Models\User\User;
|
||||
|
||||
class WikiController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
public function displayRegister() {
|
||||
//make user name syntax like we want it.
|
||||
$name = Auth::user()->name;
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
|
||||
//Check to see if the user is already registered in the database
|
||||
$count = DokuUser::where([
|
||||
'login' => $name,
|
||||
])->count();
|
||||
|
||||
//If the count is greater than zero, also check the login name as a reference
|
||||
if($count > 0) {
|
||||
$check = DokuUser::where([
|
||||
'login' => $name,
|
||||
])->first();
|
||||
|
||||
if($check->login === $name) {
|
||||
return redirect('/dashboard')->with('error', 'Already registered for the wiki!');
|
||||
}
|
||||
}
|
||||
|
||||
return view('wiki.user.register')->with('name', $name);
|
||||
}
|
||||
|
||||
public function storeRegister(Request $request) {
|
||||
$this->validate($request, [
|
||||
'password' => 'required',
|
||||
'password2' => 'required',
|
||||
]);
|
||||
|
||||
$password = '';
|
||||
|
||||
//Check to make sure the password matches
|
||||
if($request->password !== $request->password2) {
|
||||
return view('/dashboard')->with('error');
|
||||
} else {
|
||||
$password = md5($request->password);
|
||||
}
|
||||
|
||||
if(Auth::user()->hasRole('User')) {
|
||||
$role = 1; //User role id from wiki_groupname table
|
||||
$roleDescription = 'user';
|
||||
} else if(Auth::user()->hasRole('Renter')) {
|
||||
$role = 8; //Renter role id from wiki_groupname table
|
||||
$roleDescription = 'renter';
|
||||
}
|
||||
|
||||
//Load the model
|
||||
$user = new DokuUser;
|
||||
$member = new DokuMember;
|
||||
|
||||
//make user name syntax like we want it.
|
||||
$name = Auth::user()->name;
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
|
||||
//Add the new user to the wiki
|
||||
$user->login = $name;
|
||||
$user->pass = $password;
|
||||
$user->name = Auth::user()->name;
|
||||
$user->save();
|
||||
|
||||
//Get the user from the table to get the uid
|
||||
$uid = DokuUser::where([
|
||||
'login' => $name,
|
||||
])->first();
|
||||
|
||||
//Save information in the model
|
||||
$member->uid = $uid->id;
|
||||
$member->gid = $role;
|
||||
$member->groupname = $roleDescription;
|
||||
$member->save();
|
||||
|
||||
//Return to the dashboard view
|
||||
return redirect('/dashboard')->with('success', 'Registration successful. Your username is: ' . $name);
|
||||
}
|
||||
|
||||
public function displayChangePassword() {
|
||||
$name = Auth::user()->name;
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
|
||||
//Get the password
|
||||
$check = DokuUser::where([
|
||||
'login' => $name
|
||||
])->count();
|
||||
|
||||
if($check == 0) {
|
||||
return redirect('/dashboard')->with('error', 'Login Not Found');
|
||||
}
|
||||
|
||||
return view('wiki.user.changepassword')->with('name', $name);
|
||||
}
|
||||
|
||||
public function changePassword(Request $request) {
|
||||
$this->validate($request, [
|
||||
'password' => 'required',
|
||||
'password2' => 'required',
|
||||
]);
|
||||
|
||||
//Check for a valid password
|
||||
$password = '';
|
||||
if($request->password !== $request->password2) {
|
||||
return redirect('/wiki/changepassword')->with('error', 'Passwords did not match');
|
||||
} else {
|
||||
$password = md5($request->password);
|
||||
}
|
||||
//Get a model ready for the database
|
||||
$user = new DokuUser;
|
||||
//Find the username for the database through the character name in auth
|
||||
$name = Auth::user()->name;
|
||||
$name = strtolower($name);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
|
||||
//Update the password for the login name
|
||||
DokuUser::where([
|
||||
'login' => $name,
|
||||
])->update([
|
||||
'pass' => $password,
|
||||
]);
|
||||
|
||||
return redirect('/dashboard')->with('success', 'Password changed successfully. Your username is: ' . $name);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@ class Kernel extends HttpKernel
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
//'callback' => \App\Http\Middleware\Callback::class,
|
||||
'role' => \App\Http\Middleware\RequireRole::class,
|
||||
'permission' => \App\Http\Middleware\RequirePermission::class,
|
||||
];
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
//Internal Library
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Socialite;
|
||||
use DB;
|
||||
|
||||
//Libraries
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class Callback
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request for callback. Set to handle the request after the
|
||||
* login controller does what it needs to do.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $ssoUser)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
if(isset($ssoUser->refreshToken)) {
|
||||
//See if an access token is present for the user
|
||||
$tokenCount = EsiToken::where(['character_id' => $ssoUser->id])->count();
|
||||
if($tokenCount > 0) {
|
||||
//Update the esi token
|
||||
$this->UpdateEsiToken($ssoUser);
|
||||
} else {
|
||||
//Save the esi token
|
||||
$this->SaveEsiToken($ssoUser);
|
||||
}
|
||||
|
||||
//After creating or updating the token, update the table for the scopes.
|
||||
$this->SetScopes($ssoUser->user['Scopes'], $ssoUser->id);
|
||||
} else {
|
||||
$created = $this->createAlt($ssoUser);
|
||||
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ESI Token
|
||||
*/
|
||||
private function UpdateEsiToken($eve_user) {
|
||||
EsiToken::where('character_id', $eve_user->id)->update([
|
||||
'character_id' => $eve_user->getId(),
|
||||
'access_token' => $eve_user->token,
|
||||
'refresh_token' => $eve_user->refreshToken,
|
||||
'inserted_at' => time(),
|
||||
'expires_in' => $eve_user->expiresIn,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ESI Token in the database
|
||||
*/
|
||||
private function SaveEsiToken($eve_user) {
|
||||
$token = new EsiToken;
|
||||
$token->character_id = $eve_user->id;
|
||||
$token->access_token = $eve_user->token;
|
||||
$token->refresh_token = $eve_user->refreshToken;
|
||||
$token->inserted_at = time();
|
||||
$token->expires_in = $eve_user->expiresIn;
|
||||
$token->save();
|
||||
}
|
||||
|
||||
private function SetScopes($scopes, $charId) {
|
||||
//Delete the current scopes, so we can add new scopes into the database
|
||||
EsiScope::where('character_id', $charId)->delete();
|
||||
$scopes = explode(' ', $scopes);
|
||||
foreach($scopes as $scope) {
|
||||
$data = new EsiScope;
|
||||
$data->character_id = $charId;
|
||||
$data->scope = $scope;
|
||||
$data->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an alt exists in the database, else, create and
|
||||
* return the user object.
|
||||
*
|
||||
* @param \Laravel\Socialite\Two\User $user
|
||||
*/
|
||||
private function createAlt($user) {
|
||||
$altCount = UserAlt::where('character_id', $user->id)->count();
|
||||
if($altCount == 0) {
|
||||
$newAlt = new UserAlt;
|
||||
$newAlt->name = $user->getName();
|
||||
$newAlt->main_id = auth()->user()->getId();
|
||||
$newAlt->character_id = $user->id;
|
||||
$newAlt->avatar = $user->avatar;
|
||||
$newAlt->access_token = $user->token;
|
||||
$newAlt->owner_hash = $user->owner_hash;
|
||||
$newAlt->inserted_at = time();
|
||||
$newAlt->expires_in = $user->expiresIn;
|
||||
$newAlt->save();
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
namespace App\Jobs\Commands\Eve;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -8,6 +8,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Spatie\RateLimitedMiddleware\RateLimited;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
@@ -29,17 +30,17 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* With new rate limiting, we shouldn't use this timeout
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
//public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* With new rate limiting, we shouldn't use this timeout
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
//public $retries = 3;
|
||||
|
||||
private $sender;
|
||||
private $body;
|
||||
@@ -107,6 +108,32 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Middleware to only allow 4 jobs to be run per minute
|
||||
* After a failed job, the job is released back into the queue for at least 1 minute x the number of times attempted
|
||||
*
|
||||
*/
|
||||
public function middleware() {
|
||||
|
||||
//Allow 4 jobs per minute, and implement a rate limited backoff on failed jobs
|
||||
$rateLimitedMiddleware = (new RateLimited())
|
||||
->allow(4)
|
||||
->everySeconds(60)
|
||||
->releaseAfterOneMinute()
|
||||
->releaseAfterBackoff($this->attempts());
|
||||
|
||||
return [new RateLimited()];
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the time at which the job should timeout.
|
||||
*
|
||||
*/
|
||||
public function retryUntil() : \DateTime
|
||||
{
|
||||
return Carbon::now()->addDay();
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process.
|
||||
*
|
||||
142
app/Jobs/Commands/MiningTaxes/FetchMiningTaxesLedgersJob.php
Normal file
142
app/Jobs/Commands/MiningTaxes/FetchMiningTaxesLedgersJob.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//App Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
use App\Models\MiningTax\Ledger;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
class FetchMiningTaxesLedgersJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $observerId;
|
||||
private $esi;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $observerId)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
//Import the variables from the calling function
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->observerId = $observerId;
|
||||
|
||||
//Setup the ESI stuff
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the private esi variables
|
||||
if(!$esiHelper->haveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1')) {
|
||||
Log::critical('Character: ' . $this->charId . ' did not have the correct esi scope in FetchMiningTaxesLedgersJob.');
|
||||
return null;
|
||||
}
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
$mHelper = new MoonCalc;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the ledger from ESI
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
'observer_id' => $this->observerId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the mining ledger in FetchMiningTaxesLedgersJob for observer id: ' . $this->observerId);
|
||||
return null;
|
||||
}
|
||||
|
||||
$ledgers = json_decode($response);
|
||||
|
||||
//Sort through the array, and create the variables needed for database entries
|
||||
foreach($ledgers as $ledger) {
|
||||
//Get some basic information we need to work with
|
||||
$charName = $lookup->CharacterIdToName($ledger->character_id);
|
||||
//Get the type name from the ledger ore stuff
|
||||
$typeName = $lookup->ItemIdToName($ledger->type_id);
|
||||
//Decode the date and store it.
|
||||
//$updated = $esiHelper->DecodeDate($ledger->last_updated);
|
||||
|
||||
$price = $mHelper->CalculateOrePrice($ledger->type_id);
|
||||
$amount = $price * $ledger->quantity;
|
||||
|
||||
//Insert or update the entry in the database
|
||||
$item = Ledger::updateOrCreate([
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charName,
|
||||
'observer_id' => $this->observerId,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore_name' => $typeName,
|
||||
'quantity' => $ledger->quantity,
|
||||
'price' => $amount,
|
||||
], [
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charName,
|
||||
'observer_id' => $this->observerId,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore_name' => $typeName,
|
||||
'quantity' => $ledger->quantity,
|
||||
'price' => $amount,
|
||||
]);
|
||||
}
|
||||
|
||||
//Clean up old data
|
||||
Ledger::where(['updated_at', '<', Carbon::now()->subDays(120)])->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MiningTaxes\Invoice;
|
||||
use App\Models\MiningTaxes\Payment;
|
||||
use App\Models\Finances\PlayerDonationJournal;
|
||||
|
||||
class ProcessMiningTaxesPaymentsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the variables we will need
|
||||
$looup = new LookupHelper;
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
//Get the outstanding invoices
|
||||
$outstanding = Invoice::where([
|
||||
'status' => 'Pending',
|
||||
])->get();
|
||||
|
||||
//Use the player donation journal from finances to see if the invoice_id is present
|
||||
//as a reason
|
||||
foreach($outstanding as $invoice) {
|
||||
//See if we have a reason with the correct uniqid from the player donation journal
|
||||
$found = PlayerDonationJournal::where([
|
||||
'reason' => "MMT: " . $invoice->invoice_id,
|
||||
])->count();
|
||||
|
||||
//If we have received the invoice, then mark the invoice as paid
|
||||
if($count > 0) {
|
||||
//If we have the count, then grab the journal entry in order to do some things with it
|
||||
$journal = PlayerDonationJournal::where([
|
||||
'reason' => "MMT: " . $invoice->invoice_id,
|
||||
])->first();
|
||||
|
||||
//If the bill is paid on time, then update the invoice as such
|
||||
if($currentTime->lessThanOrEqualTo($journal->inserted_at)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid',
|
||||
]);
|
||||
}
|
||||
|
||||
if($currentTime->greaterThan($journal->inserted_at)) {
|
||||
Invoice::where([
|
||||
'invoice_id' => $invoice->invoice_id,
|
||||
])->update([
|
||||
'status' => 'Paid Late',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonLedger;
|
||||
use App\Models\Moon\CorpMoonObserver;
|
||||
|
||||
|
||||
class FetchMoonLedgerJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Private Variables
|
||||
*/
|
||||
private $charId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId)
|
||||
{
|
||||
//Set the character id
|
||||
$this->charId = $charId;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare Variables
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
|
||||
//Get the configuration for the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for esi scope for the character
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonLedgerCommand.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token if the scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
|
||||
//Setup the esi information
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//Get the character data from the lookup table
|
||||
$character = $lookup->GetCharacterInfo($this->charId);
|
||||
|
||||
//Get the corporation data from the lookup table
|
||||
$corporation = $lookup->GetCorporationInfo($character->corporation_id);
|
||||
|
||||
//Setup the structure helper
|
||||
$structure = new StructureHelper($this->charId, $character->corporation_id, $esi);
|
||||
|
||||
//Get the moon observers from the database
|
||||
$observers = CorpMoonObserver::where([
|
||||
'corporation_id' => $character->corporation_id,
|
||||
])->get();
|
||||
|
||||
foreach($observers as $observer) {
|
||||
//Try to get the ledger data from the esi
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $observer->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//Log the exception
|
||||
Log::critical('FetchMoonLedger job failed to get the mining ledgers.');
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Get the ore name from the lookup table
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//Get the character name from the lookup helper
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corporation info from the lookup helper
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
//Get the recorded corporation information
|
||||
$recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id);
|
||||
|
||||
$entries[] = [
|
||||
'corporation_id' => $corpInfo->corporation_id,
|
||||
'corporation_name' => $corpInfo->name,
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charInfo->name,
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_name' => $observer->observer_name,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'recorded_corporation_id' => $ledger->recorded_corporation_id,
|
||||
'recorded_corporation_name' => $recordedCorpInfo->name,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'created_at' => $ledger->last_updated . ' 23:59:59',
|
||||
'updated_at' => $ledger->last_updated . ' 23:59:59',
|
||||
];
|
||||
}
|
||||
|
||||
//Insert or ignore each entry into the database
|
||||
CorpMoonLedger::insertOrIgnore($entries);
|
||||
|
||||
Log::info('FetchMoonLedgerJob inserted up to ' . count($entries) . 'into the database.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonObserver;
|
||||
|
||||
class FetchMoonObserverJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Private variables
|
||||
*/
|
||||
private $charId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId)
|
||||
{
|
||||
//Set the character id
|
||||
$this->charId = $charId;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the configuration from the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
|
||||
Log::warning('Esi scopes were not found for Fetch Moon Observers job.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token for the character
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
//With the lookup helper, get the character information
|
||||
$character = $lookup->GetCharacterInfo($this->charId);
|
||||
//With the lookup helper, get the corporation information
|
||||
$corporation = $lookup->GetCorporationInfo($character->corporation_id);
|
||||
|
||||
//Delcare the structure helper since we have the necessary data
|
||||
$structureHelper = new StructureHelper($this->charId, $character->corporation_id, $esi);
|
||||
|
||||
//Get the mining observers for the corporation's from esi
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical('FetchMoonObservers failed to get the moon observers for the corporation');
|
||||
return null;
|
||||
}
|
||||
|
||||
//Run through the mining observers, and add them to the database as needed
|
||||
foreach($response as $observer) {
|
||||
$count = CorpMoonObserver::where(['observer_id' => $observer->observer_id])->count();
|
||||
//If the observer is not found, then add it to the database
|
||||
if($count == 0) {
|
||||
//Get the structure information from the universe structure esi endpoint
|
||||
$structureInfo = $structureHelper->GetStructureInfo($observer->observer_id);
|
||||
//Create a new corp moon observer in the database
|
||||
$obs = new CorpMoonObserver;
|
||||
$obs->corporation_id = $character->corporation_id;
|
||||
$obs->corporation_name = $corporation->name;
|
||||
$obs->observer_id = $observer->observer_id;
|
||||
$obs->observer_name = $structureInfo->name;
|
||||
$obs->observer_owner_id = $structureInfo->owner_id;
|
||||
$obs->solar_system_id = $structureInfo->solar_system_id;
|
||||
$obs->observer_type = $observer->observer_type;
|
||||
$obs->observer_type_id = $structureInfo->type_id;
|
||||
$obs->last_updated = $observer->last_updated;
|
||||
$obs->save();
|
||||
} else {
|
||||
CorpMoonObserver::where([
|
||||
'observer_id' => $observer->observer_id,
|
||||
])->update([
|
||||
'last_updated' => $observer->last_updated,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Moons;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\CorpMoonLedger;
|
||||
|
||||
class PurgeMoonLedgerJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$previous = Carbon::now()->subDays(60);
|
||||
|
||||
//Remove old ledger entries
|
||||
CorpMoonLedger::where('created_at', '<', $previous)->delete();
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\RentalMoonLedger;
|
||||
use App\Models\RentalMoonObserver;
|
||||
|
||||
class FetchRentalMoonLedgerJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$response = null;
|
||||
$structureInfo = null;
|
||||
$entries = array();
|
||||
|
||||
//Get the configuration for the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonLedgerCommand.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token if scope checks have passed
|
||||
$refreshToken = $esiHelper->GetRefreshtoken($config['primary']);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Get all of the rental moon observers from the database
|
||||
$observers = RentalMoonObserver::all();
|
||||
|
||||
//Dump the mining ledger table for rental moons
|
||||
RentalMoonLedger::truncate();
|
||||
|
||||
//Foreach observer get the ledger
|
||||
foreach($observers as $observer) {
|
||||
//Get the observer name.
|
||||
$observerInfo = Structure::where([
|
||||
'structure_id' => $observer->observer_id,
|
||||
])->first();
|
||||
|
||||
try {
|
||||
$ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
'observer_id' => $observer->observer_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//If an exception has occurred, then log it
|
||||
Log::critical('FetchRentalMoonLedger command failed to get the mining ledger for observer id: ' . $observer->observer_id);
|
||||
}
|
||||
|
||||
if($ledgers != null) {
|
||||
foreach($ledgers as $ledger) {
|
||||
//Get the ore name from the lookup table
|
||||
$ore = $lookup->ItemIdToName($ledger->type_id);
|
||||
|
||||
//Get the character name from the lookup helper using the characterId
|
||||
$charInfo = $lookup->GetCharacterInfo($ledger->character_id);
|
||||
//Get the corporation information
|
||||
$corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id);
|
||||
|
||||
//Get the recorded corporation information
|
||||
$recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id);
|
||||
|
||||
$entries[] = [
|
||||
'corporation_id' => $corpInfo->corporation_id,
|
||||
'corporation_name' => $corpInfo->name,
|
||||
'character_id' => $ledger->character_id,
|
||||
'character_name' => $charInfo->name,
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_name' => $observerInfo->name,
|
||||
'type_id' => $ledger->type_id,
|
||||
'ore' => $ore,
|
||||
'quantity' => $ledger->quantity,
|
||||
'recorded_corporation_id' => $ledger->recorded_corporation_id,
|
||||
'recorded_corporation_name' => $recordedCorpInfo->name,
|
||||
'last_updated' => $ledger->last_updated,
|
||||
'created_at' => $ledger->last_updated . ' 23:59:59',
|
||||
'updated_at' => $ledger->last_updated . ' 23:59:59',
|
||||
];
|
||||
}
|
||||
|
||||
//Insert or ignore each of the records saved into the array through the foreach loop
|
||||
RentalMoonLedger::insertOrIgnore($entries);
|
||||
|
||||
Log::info(
|
||||
'FetchRentalMoonLedgerJob inserted up to ' .count($entires) . ' new ledger entries.'
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
|
||||
//App Models
|
||||
use App\Models\Moon\RentalMoonObserver;
|
||||
|
||||
class FetchRentalMoonObserversJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare some variables
|
||||
$lookup = new LookupHelper;
|
||||
$esi = new Esi;
|
||||
$obss = array();
|
||||
|
||||
//Get the configuration for the main site
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($config['primary'], 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('The primary character does not have the necessary scopes for FetchRentalMoonObservers.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token for spatial forces
|
||||
$refreshToken = $esiHelper->GetRefreshToken($config['primary']);
|
||||
|
||||
//Get the character data from the lookup table if possible or esi
|
||||
$character = $lookup->GetCharacterInfo($config['primary']);
|
||||
|
||||
//Get the mining observers for spatial forces from esi
|
||||
try {
|
||||
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical('RentalMoonObservers failed to get the moon observers for Spatial Forces.');
|
||||
}
|
||||
|
||||
//Run through the mining observers, and add them to the database as needed
|
||||
foreach($responses as $observer) {
|
||||
//Populate the array with the data, so we can do an insert or ignore after the foreach loop is completed.
|
||||
$obss[] = [
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_type' => $observer->observer_type,
|
||||
'last_updated' => $esi->DecodeDate($observer->last_updated)
|
||||
];
|
||||
}
|
||||
|
||||
RentalMoonObserver::insertOrIgnore($obss);
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\PublicContracts;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\Commands\PublicContracts\GetPublicContractItemsJob;
|
||||
|
||||
//Models
|
||||
use App\Models\PublicContracts\PublicContract;
|
||||
use App\Models\PublicContracts\PUblicContractItem;
|
||||
|
||||
class GetPublicContractItemsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Private Variables
|
||||
*/
|
||||
private $esi;
|
||||
private $contractId;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($esi, $contract)
|
||||
{
|
||||
//Setup the variables
|
||||
$this->esi = $esi;
|
||||
$this->contractId = $contract;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get the items from esi
|
||||
$responses = $this->esi->invoke('get', '/contracts/public/items/{contract_id}/', [
|
||||
'contract_id' => $this->contract,
|
||||
]);
|
||||
|
||||
foreach($response as $resp) {
|
||||
//See if the item exists
|
||||
$count = PublicContractItems::where([
|
||||
'record_id' => $resp->record_id,
|
||||
])->count();
|
||||
|
||||
//If the item doesn't exist in the database, save it to the database
|
||||
if($count == 0) {
|
||||
$contractItem = new PublicContractItems;
|
||||
if(isset($resp->is_blueprint_copy)) {
|
||||
$contractItem->is_blueprint_copy = $resp->is_blueprint_copy;
|
||||
}
|
||||
$contractItem->is_included = $resp->is_included;
|
||||
if(isset($resp->item_id)) {
|
||||
$contractItem->item_id = $resp->item_id;
|
||||
}
|
||||
if(isset($resp->material_efficiency)) {
|
||||
$contractItem->material_efficiency = $resp->material_efficiency;
|
||||
}
|
||||
$contractItem->quantity = $resp->quantity;
|
||||
$contractItem->recorded_id = $resp->recorded_id;
|
||||
if(isset($resp->runs)) {
|
||||
$contractItem->runs = $resp->runs;
|
||||
}
|
||||
if(isset($resp->time_efficiency)) {
|
||||
$contractItem->time_efficiency = $resp->time_efficiency;
|
||||
}
|
||||
$contractItem->type_id = $resp->type_id;
|
||||
$contractItem->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\PublicContracts;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHellper;
|
||||
|
||||
//Models
|
||||
use App\Models\PublicContracts\PublicContract;
|
||||
|
||||
class GetPublicContractsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $esi;
|
||||
private $region;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($regionId, $esi = null)
|
||||
{
|
||||
//Setup the esi authentication container
|
||||
if($esi == null) {
|
||||
$this->esi = new Esi();
|
||||
} else {
|
||||
$this->esi = $esi;
|
||||
}
|
||||
//Set the region code
|
||||
$this->region = $regionId;
|
||||
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job gets all of the contracts in a region
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$responses = $this->esi->invoke('get', '/contracts/public/{region_id}/', [
|
||||
'region_id' => $this->region,
|
||||
]);
|
||||
|
||||
foreach($response as $resp) {
|
||||
$count = PublicContract::where([
|
||||
'contract_id' => $resp->contract_id,
|
||||
])->count();
|
||||
if($count == 0) {
|
||||
$pub = new PublicContract;
|
||||
$pub->region_id = $this->region;
|
||||
if(isset($resp->buyout)) {
|
||||
$pub->buyout = $resp->buyout;
|
||||
}
|
||||
if(isset($resp->collateral)) {
|
||||
$pub->collateral = $resp->collateral;
|
||||
}
|
||||
$pub->contract_id = $resp->contract_id;
|
||||
$pub->date_expired = $resp->date_expired;
|
||||
$pub->date_issed = $resp->date_issed;
|
||||
if(isset($resp->days_to_complete)) {
|
||||
$pub->days_to_complete = $resp->days_to_complete;
|
||||
}
|
||||
if(isset($resp->end_location_id)) {
|
||||
$pub->end_location_id = $resp->end_location_id;
|
||||
}
|
||||
if(isset($resp->for_corporation)) {
|
||||
$pub->for_corporation = $resp->for_corporation;
|
||||
}
|
||||
$pub->issuer_corporation_id = $resp->issuer_corporation_id;
|
||||
$pub->issuer_id = $resp->issuer_id;
|
||||
if(isset($resp->price)) {
|
||||
$pub->price = $resp->price;
|
||||
}
|
||||
if(isset($resp->reward)) {
|
||||
$pub->reward = $resp->reward;
|
||||
}
|
||||
if(isset($resp->start_location_id)) {
|
||||
$pub->start_location_id = $resp->start_location_id;
|
||||
}
|
||||
if(isset($resp->title)) {
|
||||
$pub->title = $resp->title;
|
||||
}
|
||||
$pub->type = $resp->type;
|
||||
if(isset($resp->volume)) {
|
||||
$pub->volume = $resp->volume;
|
||||
}
|
||||
//Save the new contract
|
||||
$pub->save();
|
||||
|
||||
//Dispatch a job to collect the contract items
|
||||
GetPublicContractItemsJob::dispatch($this->esi, $resp->contract_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\PublicContracts;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
|
||||
//Models
|
||||
use App\Models\PublicContracts\PublicContract;
|
||||
use App\Models\PublicContracts\PublicContractItem;
|
||||
|
||||
|
||||
/**
|
||||
* Job to purge some old data from the public contracts
|
||||
*/
|
||||
class PurgePublicContracts implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
|
||||
//If the date for a contract has expired, then purge it from the system
|
||||
$contracts = PublicContract::all();
|
||||
|
||||
//Check each contract to see if it has expired
|
||||
foreach($contracts as $contract) {
|
||||
//If the contract has expired, then delete the contract and all of it's items
|
||||
if($today->greaterThan($contract->date_expired)) {
|
||||
//Delete the contract
|
||||
PublicContract::where([
|
||||
'id' => $contract->id,
|
||||
])->delete();
|
||||
|
||||
//Delete the items from the contract from the other table
|
||||
PublicContract::where([
|
||||
'contract_id' => $contract->id,
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEvveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
|
||||
/**
|
||||
* This job will send out a reminder about the moon rental payment being due
|
||||
* when it's due based on the rental paid date versus rental date. If the paid
|
||||
* date is in the future from today, then we don't need to send out a reminder.
|
||||
* If the paid date is today or less, then we need to send out a reminder about
|
||||
* paying for the moon rental.
|
||||
*/
|
||||
class SendMoonRentalPaymentReminderJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the queue connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Get today's date
|
||||
$today = Carbon::now();
|
||||
$today->second = 1;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
//Declare some other variables
|
||||
$totalCost = 0.00;
|
||||
$moonList = array();
|
||||
$delay = 30;
|
||||
$lookup = new LookupHelper;
|
||||
$config = config('esi');
|
||||
|
||||
//Get all of the contacts from the rentals group
|
||||
$contacts = AllianceMoonRental::select('rental_contact_id')->groupBy('rental_contact_id')->get();
|
||||
|
||||
//For each of the contacts, totalize the moon rentals, and create a reminder mail
|
||||
foreach($contacts as $contact) {
|
||||
//Get the moons the renter is renting, but only get the ones whose paid date is not after today.
|
||||
$dues = $this->GetMoonDueList($contact->rental_contact_id);
|
||||
|
||||
//Get the list of moons for the mail body.
|
||||
$alls = $this->GetMoonRentalList($contact->rental_contact_id);
|
||||
|
||||
//Totalize the cost for the moons whose rent is due
|
||||
$cost = $this->TotalizeMoonCost($contact->rental_contact_id);
|
||||
|
||||
//For each of the rentals, build the mail body, and totalize the cost of the moon
|
||||
$body = "Moon Rent is due for the following moons:<br>";
|
||||
foreach($rentalsDue as $due) {
|
||||
$body .= $due . "<br>";
|
||||
}
|
||||
//Put the price for the moons
|
||||
$body .= "The price for next month's rent is " . number_format($cost, 0, ".", ",") . "<br>";
|
||||
$body .= "Rental Payment is due on the 1st of the month. If the rental payment is not remitted to Spatial Forces by the 3rd of the month, the rental claim shall be forfeited.<br>";
|
||||
$body .= "Rental Payment should be transferred to Spatial Forces.<br>";
|
||||
$body .= "In the description of the payment please put the following transaction identification: " . $transId . "<br>";
|
||||
$body .= "<br>";
|
||||
$body .= $contact->contact_name . " is responsible for payment of the moons.<br>";
|
||||
$body .= "The following moons are being rented:<br>";
|
||||
foreach($alls as $all) {
|
||||
$body .= $all . "<br>";
|
||||
}
|
||||
$body .= "<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Create the subject line
|
||||
$subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
|
||||
//Dispatch the mail job if the contact type is a character, otherwise
|
||||
//dispatch the job to the ceo of the corporation instead. If the contact is an alliance
|
||||
//dispatch the job to the ceo of the holding corporation.
|
||||
if($contact->contact_type == 'Character') {
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$contact->rental_contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the delay to get ready for the next mail job
|
||||
$delay += 30;
|
||||
} else if($contact->contact_type == 'Corporation') {
|
||||
//Get the CEO of the corporation from the lookup helper
|
||||
$corporation = $lookup->GetCorporationInfo($contact->rental_contact_id);
|
||||
$charId = $corporation->ceo_id;
|
||||
//Send out the mail
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the delay to get ready for the next mail job
|
||||
$delay += 30;
|
||||
} else if($contact->contact_type == 'Alliance') {
|
||||
//Get the holding corporation from the lookup helper
|
||||
$alliance = $lookup->GetAllianceInfo($contact->rental_contact_id);
|
||||
//Get the CEO of the corporation of the holding corp from the lookup helper
|
||||
$corporation = $lookup->GetCorporationInfo($alliance->executor_corporation_id);
|
||||
$charId = $corporation->ceo_id;
|
||||
//Send out the mail
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primaryh'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
|
||||
//Increment the detaly to get ready for the next mail job
|
||||
$delay += 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function GetMoonRentalsList($contact) {
|
||||
//Declare the variables
|
||||
$list = array();
|
||||
|
||||
$moons = AllianceMoonRental::where([
|
||||
'rental_contact_id' => $contact,
|
||||
])->get();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
$temp = 'Rental: ' . $moon->region . ' - ' . $moon->system . ' - ' . $moon->planet . ' - ' . $moon->moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function GetMoonDueList($contact) {
|
||||
//Declare the variables
|
||||
$list = array();
|
||||
|
||||
$moons = AllianceMoonRental::where([
|
||||
'rental_contact_id' => $contact,
|
||||
])->where('paid_until', '<=', $today)->get();
|
||||
|
||||
//Create the list
|
||||
foreach($moons as $moon) {
|
||||
$temp = 'Rental: ' . $moon->region . ' - ' . $moon->system . ' - ' . $moon->planet . ' - ' . $moon->moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function TotalizeCost($rentals, $rentalType) {
|
||||
//Declare the stuff we need
|
||||
$totalCost = 0.00;
|
||||
|
||||
//Totalize the cost
|
||||
foreach($rentals as $rental) {
|
||||
if($rentalType = 'In Alliance') {
|
||||
$totalCost += $rental->alliance_rental_price;
|
||||
} else {
|
||||
$totalCost += $rental->out_of_alliance_rental_price;
|
||||
}
|
||||
}
|
||||
|
||||
return $totalCost;
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class UpdateMoonRentalPaidState implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1600;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the queue connection up
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$mailDelay = 5;
|
||||
|
||||
//Get all of the moons from the rental database
|
||||
$moons = AllianceRentalMoons::all();
|
||||
|
||||
//Set today's date
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get the esi configuration
|
||||
$esiConfig = config('esi');
|
||||
|
||||
/**
|
||||
* For each of the moons check the rental until date, the paid until date,
|
||||
* and compare them to today's current date.
|
||||
*
|
||||
* If the paid date is later than the rental until date, then update the rental until
|
||||
* date to match the paid date. If the paid until date is today or less, then update the
|
||||
* paid column of the moon to not paid. If the moon hasn't been paid 2 weeks after the first
|
||||
* of the month, then remove the renter, and send an eve mail to alliance leadership, and the renter
|
||||
* denoting failure of payment has resulted in the moon rental for the current month being
|
||||
* revoked.
|
||||
*/
|
||||
foreach($moon as $rental) {
|
||||
//Setup the rental date, paid until date, and today's date as functions of Carbon library
|
||||
$rentedUntil = new Carbon($rental->rental_until);
|
||||
$paidUntil = new Carbon($rental->paid_until);
|
||||
|
||||
//If the paid date is larger than the rental date, then update the rental date
|
||||
if($paidUntil->greaterThan($rentedUntil)) {
|
||||
AllianceMoonRental::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'rental_until' => $rental->paid_until,
|
||||
]);
|
||||
}
|
||||
|
||||
//If the paid date is today or less, then update the paid column of the moon as not paid
|
||||
if($paidUntil->greaterThanOrEqualTo($today)) {
|
||||
AllianceMoonRental::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'paid' => 'No',
|
||||
]);
|
||||
}
|
||||
|
||||
//If the moon hasn't been paid for in two weeks, then remove the renter,
|
||||
//then send the renter and w4rp leadership a mail.
|
||||
if($paidUntil->greaterThanOrEqualTo($today->subWeeks(2))) {
|
||||
//Declare the lookup helper as it will be needed
|
||||
$lookupHelper = new LookupHelper;
|
||||
|
||||
//Get the character id for Minerva Arbosa and Rock Onzo
|
||||
$minerva = $lookupHelper->CharacterNameToId('Minerva Arbosa');
|
||||
$rock = $lookupHelper->CharacterNameToId('Rock Onzo');
|
||||
|
||||
//Remove the renter
|
||||
AllianceMoonRental::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'rental_type' => 'Not Rented',
|
||||
'rental_until' => null,
|
||||
'rental_contact_id' => 0,
|
||||
'rental_contact_type' => null,
|
||||
'paid' => 'Not Rented',
|
||||
'paid_until' => null,
|
||||
]);
|
||||
|
||||
//Send a mail over to the alliance leadership, and the former renter with
|
||||
//why the moon was removed.
|
||||
$subject = "W4RP Moon Rental Cancelled";
|
||||
|
||||
//Dispatch the mail job
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$rental->rental_contact_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
$mailDelay += 30;
|
||||
if($minerva != null) {
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$minerva, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
$mailDelay += 30;
|
||||
}
|
||||
if($rock != null) {
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$rock, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($mailDelay));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
|
||||
/**
|
||||
* This job performs the action of updating the moon rental price once per day.
|
||||
*/
|
||||
class UpdateMoonRentalPrice implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3200;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 1;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the helper for moon calculations
|
||||
$moonHelper = new MoonCalc;
|
||||
//Get all the moons from the rental database
|
||||
$moons = AllianceRentalMoon::all();
|
||||
|
||||
/**
|
||||
* Calculate the worth of each moon along with the rental prices.
|
||||
* For all of the moon calculations, the price of the mineral is averaged,
|
||||
* thereby, the price of the moon worth is also averaged based on the averaging
|
||||
* of the mineral price.
|
||||
*/
|
||||
foreach($moons as $rental) {
|
||||
//Calculate the total worth of the moon
|
||||
$totalWorth = $moonHelper->SpatialMoonsTotalWorth(
|
||||
$rental->first_ore, $rental->first_quantity,
|
||||
$rental->second_ore, $rental->second_quantity,
|
||||
$rental->third_ore, $rental->third_quantity,
|
||||
$rental->fourth_ore, $rental->fourth_quantity,
|
||||
);
|
||||
|
||||
//Calculate the rental prices of the moon
|
||||
$rentalPrice = $moonHelper->SpatialMoons(
|
||||
$rental->first_ore, $rental->first_quantity,
|
||||
$rental->second_ore, $rental->second_quantity,
|
||||
$rental->third_ore, $rental->third_quantity,
|
||||
$rental->fourth_ore, $rental->fourth_quantity,
|
||||
);
|
||||
|
||||
//Update the moon in the database
|
||||
AllianceRentalMoon::where([
|
||||
'region' => $rental->region,
|
||||
'system' => $rental->system,
|
||||
'planet' => $rental->planet,
|
||||
'moon' => $rental->moon,
|
||||
])->update([
|
||||
'moon_worth' => $totalWorth,
|
||||
'alliance_rental_price' => $rentalPrice['alliance'],
|
||||
'out_of_alliance_rental_price' => $rentalPrice['outofalliance'],
|
||||
]);
|
||||
|
||||
Log::info('Alliance Rental Moon: ' . $rental->region . ' : ' . $rental->system . ' : ' . $rental->planet . ' : ' . $rental->moon . ' : ' . $rental->structure_name);
|
||||
Log::info('Total Worth: ' . $totalWorth);
|
||||
Log::info('Alliance Rental Price: ' . $rentalPrice['alliance']);
|
||||
Log::info('Out of Alliance Rental Price: ' . $rentalPrice['outofalliance']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\RentalMoons;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
class UpdateRentalMoonPullJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Set the queue connection
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Setup the configuration variable for ESI
|
||||
$config = config('esi');
|
||||
//Setup the esi helper variable
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1')) {
|
||||
//Send a mail to the holding toon to update the esi scopes
|
||||
return null;
|
||||
}
|
||||
|
||||
//Is this valid?
|
||||
AllianceRentalMoon::update([
|
||||
'next_moon_pull' => null,
|
||||
]);
|
||||
|
||||
//Reset all table entries to clear out the next moon pull entry
|
||||
$allMoons = AllianceRentalMoon::all();
|
||||
//Cycle through all of the moons, and make the next moon pull null
|
||||
foreach($allMoons as $moon) {
|
||||
AllianceRentalMoon::where([
|
||||
'system' => $moon->system,
|
||||
'planet' => $moon->planet,
|
||||
'moon' => $moon->moon,
|
||||
])->update([
|
||||
'next_moon_pull' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
//Get the refresh token
|
||||
$token = $esiHelper->GetRefreshToken($config['primary']);
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$responses = $esi->invoke('get', '/corporation/{corporation_id}/mining/extractions/', [
|
||||
'corporation_id' => 98287666,
|
||||
]);
|
||||
} catch(RequestExceptionFailed $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach($response as $response) {
|
||||
//Get whether the structure is being used by the alliance or not.
|
||||
$usage = AllianceRentalMoon::where([
|
||||
'structure_id' => $response->structure_id,
|
||||
'rental_type' => 'Alliance',
|
||||
])->count();
|
||||
|
||||
if($usage > 0) {
|
||||
AllianceRentalMoon::where([
|
||||
'structure_id' => $response->structure_id,
|
||||
])->update([
|
||||
'next_moon_pull' => $response->chunk_arrival_time,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class EndSupplyChainContractJob implements ShouldQueue
|
||||
{
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
|
||||
class ProcessAssetsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
private $esi;
|
||||
|
||||
protected $location_array = [
|
||||
'StructureFuel',
|
||||
'FighterBay',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $page)
|
||||
{
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->page = $page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all fo the information for all of the assets in
|
||||
* a structure and store them in the database. This task can take a few seconds
|
||||
* therefore we want the Horizon job queue to take care of the request rather
|
||||
* than the cronjob.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the asset helper
|
||||
$aHelper = new AssetHelper($this->charId, $this->corpId, $this->page);
|
||||
|
||||
//Get a page of assets
|
||||
$assets = $aHelper->GetAssetsByPage();
|
||||
|
||||
//Cycle through the assets, and attmept to store them.
|
||||
foreach($assets as $asset) {
|
||||
//If the asset is in one of the locations we want, then store
|
||||
//or update the asset
|
||||
if(in_array($asset->location_flag, $this->location_array)) {
|
||||
//Attempt to store the asset
|
||||
$aHelper->StoreNewAsset($asset);
|
||||
}
|
||||
}
|
||||
|
||||
//Purge Stale Data
|
||||
$aHelper->PurgeStaleData();
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessStructureJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $page)
|
||||
{
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->page = $page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all of the information for a particular structure
|
||||
* and store it in the database. This task can take a few seconds because of the ESI
|
||||
* calls required to store the information. We leave this type of job up to the queue
|
||||
* in order to take the load off of the cron job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$sHelper = new StructureHelper($this->charId, $this->corpId);
|
||||
|
||||
$structures = $sHelper->GetStructuresByPage($this->page);
|
||||
|
||||
foreach($structures as $structure) {
|
||||
$sHelper->ProcessStructure($structure);
|
||||
}
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Finances\Helper\FinanceHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessWalletJournal;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessWalletJournalJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
public $tries = 3;
|
||||
|
||||
private $division;
|
||||
private $charId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($division, $charId, $page) {
|
||||
$this->division = $division;
|
||||
$this->charId = $charId;
|
||||
$this->page = $page;
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* Utilized by using ProcessWalletJournalJob::dispatch()
|
||||
* The model is passed into the dispatch function, then added to the queue
|
||||
* for processing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare the class variable we need
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetWalletJournalPage($this->division, $this->charId, $this->page);
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* The job failed to process.
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function failed($exception)
|
||||
{
|
||||
Log::critical($exception);
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Assets;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
|
||||
class AssetHelper {
|
||||
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
public function __construct($char, $corp, $pg = null) {
|
||||
$this->charId = $char;
|
||||
$this->corpId = $corp;
|
||||
$this->page = $pg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Assets By Page in order to store in the database
|
||||
*/
|
||||
public function GetAssetsByPage() {
|
||||
//Declare the variable for the esi helper
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the scope needed
|
||||
$hasScope = $esiHelper->HaveEsiScope($this->charId, 'esi-assets.read_corporation_assets.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('ESI Scope check has failed for esi-assets.read_corporation_assets.v1 for character id: ' . $this->charId);
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$assets = $esi->page($this->page)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get page of assets from ESI.");
|
||||
$assets = null;
|
||||
}
|
||||
|
||||
return $assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new asset record in the database
|
||||
*/
|
||||
public function StoreNewAsset($asset) {
|
||||
//See if we find any assets which already exist
|
||||
$found = Asset::where([
|
||||
'item_id' => $asset->item_id,
|
||||
])->count();
|
||||
|
||||
//If nothing is found
|
||||
if($found == 0) {
|
||||
$item = new Asset;
|
||||
if(isset($asset->is_blueprint_copy)) {
|
||||
$item->is_blueprint_copy = $asset->is_blueprint_copy;
|
||||
}
|
||||
$item->is_singleton = $asset->is_singleton;
|
||||
$item->item_id = $asset->item_id;
|
||||
$item->location_flag = $asset->location_flag;
|
||||
$item->location_id = $asset->location_id;
|
||||
$item->location_type = $asset->location_type;
|
||||
$item->quantity = $asset->quantity;
|
||||
$item->type_id = $asset->type_id;
|
||||
$item->save();
|
||||
} else {
|
||||
$this->UpdateAsset($asset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge old data, so we don't run into data issues
|
||||
*/
|
||||
public function PurgeStaleData() {
|
||||
$date = Carbon::now()->subDay(1);
|
||||
|
||||
Asset::where('updated_at', '<', $date)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the liquid ozone asset
|
||||
*/
|
||||
public function GetAssetByType($type, $structureId) {
|
||||
//See if the row is in the database table
|
||||
$count = Asset::where([
|
||||
'location_id' => $structureId,
|
||||
'type_id' => $type,
|
||||
'location_flag' => 'StructureFuel',
|
||||
])->count();
|
||||
//Get the row if it is in the table
|
||||
$asset = Asset::where([
|
||||
'location_id' => $structureId,
|
||||
'type_id' => $type,
|
||||
'location_flag' => 'StructureFuel',
|
||||
])->first();
|
||||
|
||||
if($count == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return $asset['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing asset based off the esi pull
|
||||
*/
|
||||
private function UpdateAsset($asset) {
|
||||
|
||||
Asset::where([
|
||||
'item_id' => $asset->item_id,
|
||||
])->update([
|
||||
'is_singleton' => $asset->is_singleton,
|
||||
'location_flag' => $asset->location_flag,
|
||||
'location_id' => $asset->location_id,
|
||||
'location_type' => $asset->location_type,
|
||||
'quantity' => $asset->quantity,
|
||||
'type_id' => $asset->type_id,
|
||||
'updated_at' => Carbon::now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -4,13 +4,16 @@ namespace App\Library\Esi;
|
||||
|
||||
//Internal Libraries
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Client;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
@@ -50,101 +53,6 @@ class Esi {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function GetCharacterData($charId) {
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function GetCorporationData($corpId) {
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $corporation;
|
||||
}
|
||||
|
||||
public function GetCharacterName($charId) {
|
||||
$esi = $this->SetupEsiAuthentication;
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character->name;
|
||||
}
|
||||
|
||||
public function FindCharacterId($name) {
|
||||
$config = config('esi');
|
||||
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$character = $esi->setBody(array(
|
||||
$name,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($character->characters[0]->id)) {
|
||||
return $character->characters[0]->id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function FindCorporationId($charId) {
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character->corporation_id;
|
||||
}
|
||||
|
||||
public function FindCorporationName($charId) {
|
||||
$esi = $this->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return $corporation->name;
|
||||
}
|
||||
|
||||
public function DecodeDate($date) {
|
||||
//Find the end of the date
|
||||
$dateEnd = strpos($date, "T");
|
||||
@@ -160,39 +68,115 @@ class Esi {
|
||||
return $realDate;
|
||||
}
|
||||
|
||||
public function GetRefreshToken($charId) {
|
||||
//Get the refresh token from the database
|
||||
$tokenCount = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->count();
|
||||
public function TokenExpired($token) {
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
//If the token is not found, then don't return it.
|
||||
if($tokenCount == 0) {
|
||||
//Create the carbon time for expiration time
|
||||
$expires = $token->inserted_at + $token->expires_in;
|
||||
$tokenExpiration = Carbon::createFromTimeStamp($expires);
|
||||
|
||||
if($currentTime->greaterThan($tokenExpiration->subSeconds(5))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetRefreshToken($charId) {
|
||||
//Declare variables
|
||||
$currentTime = Carbon::now();
|
||||
$scopes = null;
|
||||
$i = 0;
|
||||
$config = config('esi');
|
||||
|
||||
//If the program doesn't find an ESI Token, there is nothing to return
|
||||
if(EsiToken::where(['character_id' => $charId])->count() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the ESI Token from the database
|
||||
$token = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->first();
|
||||
|
||||
return $token->refresh_token;
|
||||
//Check the expiration of the token to see if the token has expired and needs to be refreshed using the refresh token
|
||||
$expires = $token->inserted_at + $token->expires_in;
|
||||
$tokenExpiration = Carbon::createFromTimestamp($expires);
|
||||
//If the access token has expired, we need to do a request for a new access token
|
||||
//We give ourselves around 5 seconds leeway in order to deal with an expired token
|
||||
if($currentTime->greaterThan($tokenExpiration->subSeconds(5))) {
|
||||
//Get the current scopes of the token
|
||||
$scopesArr = EsiScope::where([
|
||||
'character_id' => $token->character_id,
|
||||
])->get(['scope'])->toArray();
|
||||
|
||||
//Cycle through the scopes, and create the string for scopes to send with the token
|
||||
foreach($scopesArr as $scp) {
|
||||
$scopes .= $scp['scope'];
|
||||
$i++;
|
||||
if($i < sizeof($scopesArr)) {
|
||||
$scopes .= '%20';
|
||||
}
|
||||
}
|
||||
|
||||
//Setup the guzzle client for the request to get a new token
|
||||
$client = new Client(['base_uri' => 'https://login.eveonline.com']);
|
||||
$response = $client->request('POST', '/v2/oauth/token', [
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||
'Host' => 'login.eveonline.com',
|
||||
'Authorization' => "Basic " . base64_encode($config['client_id'] . ":" . $config['secret']),
|
||||
],
|
||||
'form_params' => [
|
||||
'grant_type' => 'refresh_token',
|
||||
'refresh_token' => $token->refresh_token,
|
||||
],
|
||||
]);
|
||||
//Decode the body of the response which has the token information
|
||||
$body = json_decode($response->getBody(), true);
|
||||
//Update the old token, then send the new token back to the calling function
|
||||
EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->update([
|
||||
'access_token' => $body['access_token'],
|
||||
'refresh_token' => $body['refresh_token'],
|
||||
'expires_in' => $body['expires_in'],
|
||||
'inserted_at' => time(),
|
||||
]);
|
||||
|
||||
$newToken = new EsiToken;
|
||||
$newToken->character_id = $charId;
|
||||
$newToken->access_token = $body['access_token'];
|
||||
$newToken->refresh_token = $body['refresh_token'];
|
||||
$newToken->inserted_at = time();
|
||||
$newToken->expires_in = $body['expires_in'];
|
||||
|
||||
//Return the new token model
|
||||
return $newToken;
|
||||
}
|
||||
|
||||
//If we had a good token which has not expired yet, return the data
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function SetupEsiAuthentication($token = null) {
|
||||
//Get the platform configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Declare some variables
|
||||
$authentication = null;
|
||||
$esi = null;
|
||||
$config = config('esi');
|
||||
|
||||
if($token == null) {
|
||||
$esi = new Eseye();
|
||||
} else {
|
||||
$tokenExpires = $token->inserted_at + $token->expires_in;
|
||||
|
||||
//Setup the esi authentication container
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
'refresh_token' => $token->refresh_token,
|
||||
'access_token' => $token->access_token,
|
||||
'token_expires' => $tokenExpires,
|
||||
]);
|
||||
|
||||
//Setup the esi variable
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceMarketJournal;
|
||||
|
||||
class AllianceMarketTax {
|
||||
public function EntryExists($journal) {
|
||||
if(AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function InsertMarketTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new AllianceMarketJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,388 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances\Helper;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Finances\AllianceMarketTax;
|
||||
use App\Library\Finances\CorpMarketTax;
|
||||
use App\Library\Finances\MarketTax;
|
||||
use App\Library\Finances\PlayerDonation;
|
||||
use App\Library\Finances\ReprocessingTax;
|
||||
use App\Library\Finances\JumpBridgeTax;
|
||||
use App\Library\Finances\StructureIndustryTax;
|
||||
use App\Library\Finances\OfficeFee;
|
||||
use App\Library\Finances\PlanetProductionTax;
|
||||
use App\Library\Finances\PISale;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
use App\Library\Finances\SovBillExpenses;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
class FinanceHelper {
|
||||
|
||||
public function GetWalletJournal($division, $charId) {
|
||||
//Declare new class variables
|
||||
$market = new MarketTax();
|
||||
$reprocessing = new ReprocessingTax();
|
||||
$jb = new JumpBridgeTax();
|
||||
$other = new PlayerDonation();
|
||||
$industry = new StructureIndustryTax();
|
||||
$office = new OfficeFee();
|
||||
$esiHelper = new Esi();
|
||||
$sovBillHelper = new SovBillExpenses();
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Create an ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
//Set the version
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Set our current page to 1 which is the one we are starting on.
|
||||
$currentPage = 1;
|
||||
//Set our default total pages to 1 in case our try section fails out.
|
||||
$totalPages = 1;
|
||||
|
||||
//If more than one page is found, decode the first set of wallet entries, then call for the next pages
|
||||
do {
|
||||
//Call the first page of the wallet journal, as we are always going to get at least one page.
|
||||
//If we have more pages, then we will continue through the while loop.
|
||||
try {
|
||||
$journals = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($currentPage == 1) {
|
||||
//Set the total pages we need to cycle through.
|
||||
$totalPages = $journals->pages;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
//For each journal entry, attempt to store it in the database.
|
||||
//The PutWalletJournal function checks to see if it's already in the database.
|
||||
foreach($wallet as $entry) {
|
||||
if($entry['ref_type'] == 'brokers_fee') {
|
||||
$market->InsertMarketTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
||||
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
||||
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'player_donation' ||
|
||||
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
||||
$other->InsertPlayerDonation($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
||||
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
||||
$office->InsertOfficeFee($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||
$sovBillHelper->InsertSovBillExpense($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
|
||||
//Increment the current page we are on.
|
||||
$currentPage++;
|
||||
//Continue looping through the do while loop until the current page is greater than or equal to the total pages.
|
||||
} while ($currentPage < $totalPages);
|
||||
}
|
||||
|
||||
public function GetJournalPageCount($division, $charId) {
|
||||
//Declare class variables
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('Esi Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Refrence to see if the character is in our look up table for corporation and characters
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Create the ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Set the esi version to v4
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Call the first page so we can get the header data for the number of pages
|
||||
try {
|
||||
$journals = $esi->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
$pages = $journals->pages;
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function GetCorpWalletJournalPage($division, $charId, $corpId, $page = 1) {
|
||||
//Declare new class variables
|
||||
$corpMarket = new MarketTax();
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Call the page of the wallet journal
|
||||
try {
|
||||
$journals = $esi->page($page)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning($e->getEsiResponse());
|
||||
return null;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallets = json_decode($journals->raw, true);
|
||||
|
||||
//For each journal entry, attempt to store the information into the database
|
||||
foreach($wallets as $wallet) {
|
||||
if($wallet['amount'] > 0) {
|
||||
if($wallet['ref_type'] == 'brokers_fee') {
|
||||
$corpMarket->InsertCorpMarketTax($wallet, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function GetWalletJournalPage($division, $charId, $page = 1) {
|
||||
//Declare new class variables
|
||||
$market = new AllianceMarketTax;
|
||||
$reprocessing = new ReprocessingTax;
|
||||
$jb = new JumpBridgeTax;
|
||||
$other = new PlayerDonation;
|
||||
$industry = new StructureIndustryTax;
|
||||
$office = new OfficeFee;
|
||||
$pi = new PlanetProductionTax;
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
$sovBill = new SovBillExpenses;
|
||||
|
||||
//Get the ESI refresh token for the corporation to add new wallet journals into the database
|
||||
$hasScope = $esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('Esi Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
if($token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Reference to see if the character is in our look up table for corporations and characters
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Create an ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
$esi->setVersion('v4');
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Call the first page of the wallet journal, as we are always going to get at least one page.
|
||||
//If we have more pages, then we will continue through the while loop.
|
||||
try {
|
||||
$journals = $esi->page($page)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Decode the wallet from json into an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
//For each journal entry, attempt to store it in the database.
|
||||
//The PutWalletJournal function checks to see if it's already in the database.
|
||||
foreach($wallet as $entry) {
|
||||
if($entry['ref_type'] == 'brokers_fee') {
|
||||
$market->InsertMarketTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'reprocessing_tax') {
|
||||
$reprocessing->InsertReprocessingTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'structure_gate_jump') {
|
||||
$jb->InsertJumpBridgeTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'player_donation' ||
|
||||
($entry['ref_type'] == 'corporation_account_withdrawal' && $entry['second_party_id'] == 98287666)) {
|
||||
$other->InsertPlayerDonation($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'industry_job_tax' && $entry['second_party_id'] == 98287666) {
|
||||
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
|
||||
$office->InsertOfficeFee($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'planetary_export_tax' || $entry['ref_type'] == 'planetary_import_tax') {
|
||||
$pi->InsertPlanetProductionTax($entry, $corpId, $division);
|
||||
} else if($entry['ref_type'] == 'infrastructure_hub_maintenance' && $entry['first_party_id'] == 98287666) {
|
||||
$sovBill->InsertSovBillExpense($entry, $corpId, $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function GetPIMaterialsArray() {
|
||||
//Setup array for PI items
|
||||
$pi_items = [
|
||||
//R0 Materials
|
||||
'2073',
|
||||
'2667',
|
||||
'2268',
|
||||
'2270',
|
||||
'2272',
|
||||
'2286',
|
||||
'2287',
|
||||
'2288',
|
||||
'2305',
|
||||
'2306',
|
||||
'2307',
|
||||
'2308',
|
||||
'2309',
|
||||
'2310',
|
||||
'2311',
|
||||
//P1 Materials
|
||||
'2389',
|
||||
'2390',
|
||||
'2392',
|
||||
'2393',
|
||||
'2395',
|
||||
'2396',
|
||||
'2397',
|
||||
'2398',
|
||||
'2399',
|
||||
'2400',
|
||||
'2401',
|
||||
'3645',
|
||||
'3683',
|
||||
'3779',
|
||||
'9828',
|
||||
//P2 Materials
|
||||
'44',
|
||||
'2312',
|
||||
'2317',
|
||||
'2319',
|
||||
'2321',
|
||||
'2327',
|
||||
'2328',
|
||||
'2329',
|
||||
'2463',
|
||||
'3689',
|
||||
'3691',
|
||||
'3693',
|
||||
'3695',
|
||||
'3697',
|
||||
'3725',
|
||||
'3775',
|
||||
'3828',
|
||||
'9830',
|
||||
'9832',
|
||||
'9836',
|
||||
'9838',
|
||||
'9840',
|
||||
'9842',
|
||||
'15317',
|
||||
//P3 Materials
|
||||
'2344',
|
||||
'2345',
|
||||
'2346',
|
||||
'2348',
|
||||
'2349',
|
||||
'2351',
|
||||
'2352',
|
||||
'2354',
|
||||
'2358',
|
||||
'2360',
|
||||
'2361',
|
||||
'2366',
|
||||
'2367',
|
||||
'9834',
|
||||
'9846',
|
||||
'9848',
|
||||
'12836',
|
||||
'17136',
|
||||
'17392',
|
||||
'17898',
|
||||
'28974',
|
||||
//P4 Materials
|
||||
'2867',
|
||||
'2868',
|
||||
'2869',
|
||||
'2870',
|
||||
'2871',
|
||||
'2872',
|
||||
'2875',
|
||||
'2876',
|
||||
];
|
||||
|
||||
return $pi_items;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
/** W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Internal Library
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\JumpBridgeJournal;
|
||||
|
||||
class JumpBridgeTax {
|
||||
private $date;
|
||||
private $days;
|
||||
|
||||
public function __construct($days = null) {
|
||||
if($days === null) {
|
||||
$this->date = Carbon::now();
|
||||
$this->days = 0;
|
||||
} else {
|
||||
$this->date = Carbon::now()->subDays($days);
|
||||
$this->days = $days;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to insert journal entries into the database
|
||||
*/
|
||||
public function InsertJumpBridgeTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!JumpBridgeJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new JumpBridgeJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the overall usage for statistics
|
||||
*/
|
||||
public function OverallTax() {
|
||||
|
||||
//Get the total usage
|
||||
$usage = JumpBridgeJournal::select('amount')
|
||||
->whereTime('date', '>', $this->date)
|
||||
->sum('amount');
|
||||
|
||||
//Return the usage
|
||||
return $usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific briddge usage statistics for overall usage
|
||||
*/
|
||||
public function JBOverallUsage($structure) {
|
||||
|
||||
$usage = DB::table('jump_bridge_journal')
|
||||
->select('amount')
|
||||
->where('context_id', $structure)
|
||||
->sum('amount');
|
||||
|
||||
return $usage;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\OfficeFeesJournal;
|
||||
|
||||
class OfficeFee {
|
||||
|
||||
public function InsertOfficeFee($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!OfficeFeesJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new OfficeFeesJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\PISaleJournal;
|
||||
|
||||
class PISale {
|
||||
|
||||
public function InsertPISale($journal, $corpId) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Insert the PI Sale into the database
|
||||
if(!PISaleJournal::where(['journal_ref_id' => $journal['journal_ref_id']])->exists()) {
|
||||
$entry = new PISaleJournal;
|
||||
if(isset($journal['client_id'])) {
|
||||
$entry->client_id = $journal['client_id'];
|
||||
}
|
||||
if(isset($journal['date'])) {
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
}
|
||||
if(isset($journal['is_buy'])) {
|
||||
$entry->is_buy = $journal['is_buy'];
|
||||
}
|
||||
if(isset($journal['journal_ref_id'])) {
|
||||
$entry->journal_ref_id = $journal['journal_ref_id'];
|
||||
}
|
||||
if(isset($journal['location_id'])) {
|
||||
$entry->location_id = $journal['location_id'];
|
||||
}
|
||||
if(isset($journal['quantity'])) {
|
||||
$entry->quantity = $journal['quantity'];
|
||||
}
|
||||
if(isset($journal['transaction_id'])) {
|
||||
$entry->transaction_id = $journal['transaction_id'];
|
||||
}
|
||||
if(isset($journal['type_id'])) {
|
||||
$entry->type_id = $journal['type_id'];
|
||||
}
|
||||
if(isset($journal['unit_price'])) {
|
||||
$entry->unit_price = $journal['unit_price'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\PlanetProductionTaxJournal;
|
||||
|
||||
class PlanetProductionTax {
|
||||
|
||||
public function InsertPlanetProductionTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!PlanetProductionTaxJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new PlanetProductionTaxJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\PlayerDonationJournal;
|
||||
|
||||
class PlayerDonation {
|
||||
public function InsertPlayerDonation($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!PlayerDonationJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new PlayerDonationJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\ReprocessingTaxJournal;
|
||||
|
||||
class ReprocessingTax {
|
||||
public function InsertReprocessingTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!ReprocessingTaxJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new ReprocessingTaxJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\SovBillJournal;
|
||||
|
||||
class SovBillExpenses {
|
||||
public function InsertSovBillExpense($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!SovBillJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new SovBillJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Finances;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||
|
||||
class StructureIndustryTax {
|
||||
|
||||
public function InsertStructureIndustryTax($journal, $corpId, $division) {
|
||||
//Create the ESI Helper class
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check to see if we can find the entry in the database already.
|
||||
//If we don't then add it to the database
|
||||
if(!StructureIndustryTaxJournal::where(['id' => $journal['id']])->exists()) {
|
||||
$entry = new StructureIndustryTaxJournal;
|
||||
$entry->id = $journal['id'];
|
||||
$entry->corporation_id = $corpId;
|
||||
$entry->division = $division;
|
||||
if(isset($journal['amount'])) {
|
||||
$entry->amount = $journal['amount'];
|
||||
}
|
||||
if(isset($journal['balance'])) {
|
||||
$entry->balance = $journal['balance'];
|
||||
}
|
||||
if(isset($journal['context_id'])) {
|
||||
$entry->context_id = $journal['context_id'];
|
||||
}
|
||||
if(isset($journal['context_id_type'])) {
|
||||
$entry->context_id_type = $journal['context_id_type'];
|
||||
}
|
||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
||||
$entry->description = $journal['description'];
|
||||
if(isset($journal['first_party_id'])) {
|
||||
$entry->first_party_id = $journal['first_party_id'];
|
||||
}
|
||||
if(isset($journal['reason'])) {
|
||||
$entry->reason = $journal['reason'];
|
||||
}
|
||||
$entry->ref_type = $journal['ref_type'];
|
||||
if(isset($journal['second_party_id'])) {
|
||||
$entry->second_party_id = $journal['second_party_id'];
|
||||
}
|
||||
if(isset($journal['tax'])) {
|
||||
$entry->tax = $journal['tax'];
|
||||
}
|
||||
if(isset($journal['tax_receiver_id'])) {
|
||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
||||
}
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Fleets;
|
||||
|
||||
//Internal Libraries
|
||||
use Log;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Libraries
|
||||
use App\library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Fleets\AllianceFleet;
|
||||
use App\Models\Fleets\AllianceFleetMember;
|
||||
|
||||
class FleetHelper {
|
||||
//Variables
|
||||
private $esi;
|
||||
|
||||
//Constructi
|
||||
public function __construct($charId) {
|
||||
//Declare a variable for use by the constructor
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the ESI scope
|
||||
$check = $esiHelper->HaveEsiScope($charId, 'esi-fleets.read_fleet.v1');
|
||||
if($check) {
|
||||
//Setup the ESI authentication container
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication();
|
||||
} else {
|
||||
$this->esi = null;
|
||||
}
|
||||
}
|
||||
|
||||
//Get fleet information
|
||||
public function GetFleetInfo($fleetId) {
|
||||
|
||||
}
|
||||
|
||||
//Get fleet members
|
||||
public function GetFleetMembers($fleetId) {
|
||||
|
||||
}
|
||||
|
||||
//Get fleet wings
|
||||
public function GetFleetWings($fleetId) {
|
||||
|
||||
}
|
||||
|
||||
//Update fleet time
|
||||
public function UpdateFleetTime($fleetId) {
|
||||
|
||||
}
|
||||
|
||||
//Update fleet character names
|
||||
public function UpdateFleetCharacters($fleetId) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
113
app/Library/Helpers/AssetHelper.php
Normal file
113
app/Library/Helpers/AssetHelper.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//App Library
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class AssetHelper {
|
||||
|
||||
private $charId;
|
||||
private $corpId;
|
||||
|
||||
public function __construct($char, $corp) {
|
||||
$this->charId = $char;
|
||||
$this->corpId = $corp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Assets By Page in order to store in the database
|
||||
*/
|
||||
public function GetAssetsByPage($page) {
|
||||
//Declare the variable for the esi helper
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi authentication container
|
||||
$config = config('esi');
|
||||
|
||||
//Check for the scope needed
|
||||
$hasScope = $esiHelper->HaveEsiScope($this->charId, 'esi-assets.read_corporation_assets.v1');
|
||||
if($hasScope == false) {
|
||||
Log::critical('ESI Scope check has failed for esi-assets.read_corporation_assets.v1 for character id: ' . $this->charId);
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$assets = $esi->page($this->page)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get page of assets from ESI.");
|
||||
$assets = null;
|
||||
}
|
||||
|
||||
return $assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new asset record in the database
|
||||
*/
|
||||
public function StoreNewAsset($asset) {
|
||||
Asset::updateOrCreate([
|
||||
'item_id' => $asset->item_id,
|
||||
], [
|
||||
'is_blueprint_copy' => $asset->is_blueprint_copy,
|
||||
'is_singleton' => $asset->is_singleton,
|
||||
'item_id' => $asset->item_id,
|
||||
'location_flag' => $asset->location_flag,
|
||||
'location_id' => $asset->location_id,
|
||||
'location_type' => $asset->location_type,
|
||||
'quantity' => $asset->quantity,
|
||||
'type_id' => $asset->type_id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge old data, so we don't run into data issues
|
||||
*/
|
||||
public function PurgeStaleData() {
|
||||
Asset::where('updated_at', '<', Carbon::now()->subDay())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the liquid ozone asset
|
||||
*/
|
||||
public function GetAssetByType($type, $structureId) {
|
||||
//See if the row is in the database table
|
||||
$count = Asset::where([
|
||||
'location_id' => $structureId,
|
||||
'type_id' => $type,
|
||||
'location_flag' => 'StructureFuel',
|
||||
])->count();
|
||||
//Get the row if it is in the table
|
||||
$asset = Asset::where([
|
||||
'location_id' => $structureId,
|
||||
'type_id' => $type,
|
||||
'location_flag' => 'StructureFuel',
|
||||
])->first();
|
||||
|
||||
if($count == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return $asset['quantity'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
260
app/Library/Helpers/FinanceHelper.php
Normal file
260
app/Library/Helpers/FinanceHelper.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
//Application Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Finances\AllianceWalletJournal;
|
||||
|
||||
class FinanceHelper {
|
||||
|
||||
public function GetApiWalletJournal($division, $charId) {
|
||||
//Declare class variables
|
||||
$lookup = new LookupHelper;
|
||||
$finance = new FinanceHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the esi container.
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Check the scope
|
||||
if(!$esiHelper->HaveEsiScope($charId, 'esi-wallet.read_corporation_wallets.v1')) {
|
||||
Log::critical('Scope check failed for esi-wallet.read_corporation_wallets.v1 for character id: ' . $charId);
|
||||
return null;
|
||||
}
|
||||
|
||||
//Reference the character id to the corporation id
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Set the current page to 1 which is the page we start on
|
||||
$currentPage = 1;
|
||||
//Set the total pages to 1, but in the future we will set it to another number
|
||||
$totalPages = 1;
|
||||
//Setup a page failed variable
|
||||
$pageFailed = false;
|
||||
|
||||
do {
|
||||
/**
|
||||
* During the course of the operation, we want to ensure our token hasn't expired.
|
||||
* If the token has expired, then resetup the authentication container, which will refresh the
|
||||
* access token.
|
||||
*/
|
||||
if($esiHelper->TokenExpired($token)) {
|
||||
$token = $esiHelper->GetRefreshToken($charId);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the data from the esi api. If it fails, we skip the page, and go onto the next page, unless
|
||||
* the failed page is the first page.
|
||||
*/
|
||||
try {
|
||||
$journals = $esi->page($currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/wallets/{division}/journal/', [
|
||||
'corporation_id' => $corpId,
|
||||
'division' => $division,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get wallet journal page ' . $currentPage . ' for character id: ' . $charId);
|
||||
Log::warning($e);
|
||||
dd($e);
|
||||
$pageFailed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the current page is the first one and the page didn't fail, then update the total pages.
|
||||
* If the first page failed, just return as we aren't going to be able to get the total amount of data needed.
|
||||
*/
|
||||
if($currentPage == 1 && $pageFailed == false) {
|
||||
$totalPages = $journals->pages;
|
||||
} else if($currentPage == 1 && $pageFailed == true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the page was successfully pulled, we need to decode the data, then cycle through the data, and save it
|
||||
* where we can.
|
||||
*/
|
||||
if($pageFailed == false) {
|
||||
//Decode the json data, and return it as an array
|
||||
$wallet = json_decode($journals->raw, true);
|
||||
|
||||
|
||||
//Foreach journal entry, add the journal entry to the table
|
||||
foreach($wallet as $entry) {
|
||||
//See if we find the entry id in the database already
|
||||
$found = AllianceWalletJournal::where([
|
||||
'id' => $entry['id'],
|
||||
])->count();
|
||||
|
||||
if($found == 0) {
|
||||
$awj = new AllianceWalletJournal;
|
||||
$awj->id = $entry['id'];
|
||||
$awj->corporation_id = $corpId;
|
||||
$awj->division = $division;
|
||||
if(isset($entry['amount'])) {
|
||||
$awj->amount = $entry['amount'];
|
||||
}
|
||||
if(isset($entry['balance'])) {
|
||||
$awj->balance = $entry['balance'];
|
||||
}
|
||||
if(isset($entry['context_id'])) {
|
||||
$awj->context_id = $entry['context_id'];
|
||||
}
|
||||
if(isset($entry['date'])) {
|
||||
$awj->date = $esiHelper->DecodeDate($entry['date']);
|
||||
}
|
||||
if(isset($entry['description'])) {
|
||||
$awj->description = $entry['description'];
|
||||
}
|
||||
if(isset($entry['first_party_id'])) {
|
||||
$awj->first_party_id = $entry['first_party_id'];
|
||||
}
|
||||
if(isset($entry['reason'])) {
|
||||
$awj->reason = $entry['reason'];
|
||||
}
|
||||
if(isset($entry['ref_type'])) {
|
||||
$awj->ref_type = $entry['ref_type'];
|
||||
}
|
||||
if(isset($entry['tax'])) {
|
||||
$awj->tax = $entry['tax'];
|
||||
}
|
||||
if(isset($entry['tax_receiver_id'])) {
|
||||
$awj->tax_receiver_id = $entry['tax_receiver_id'];
|
||||
}
|
||||
$awj->save();
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* If the current page failed to get data from the esi, then reset the page failed data.
|
||||
* Continue to try to pull the next page of data. We might be able to get the current failed page
|
||||
* later in another pull if it is successful.
|
||||
*/
|
||||
$pageFailed = false;
|
||||
}
|
||||
|
||||
//Increment the current page counter
|
||||
$currentPage++;
|
||||
} while($currentPage <= $totalPages);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function GetPIMaterialsArray() {
|
||||
//Setup array for PI items
|
||||
$pi_items = [
|
||||
//R0 Materials
|
||||
'2073',
|
||||
'2667',
|
||||
'2268',
|
||||
'2270',
|
||||
'2272',
|
||||
'2286',
|
||||
'2287',
|
||||
'2288',
|
||||
'2305',
|
||||
'2306',
|
||||
'2307',
|
||||
'2308',
|
||||
'2309',
|
||||
'2310',
|
||||
'2311',
|
||||
//P1 Materials
|
||||
'2389',
|
||||
'2390',
|
||||
'2392',
|
||||
'2393',
|
||||
'2395',
|
||||
'2396',
|
||||
'2397',
|
||||
'2398',
|
||||
'2399',
|
||||
'2400',
|
||||
'2401',
|
||||
'3645',
|
||||
'3683',
|
||||
'3779',
|
||||
'9828',
|
||||
//P2 Materials
|
||||
'44',
|
||||
'2312',
|
||||
'2317',
|
||||
'2319',
|
||||
'2321',
|
||||
'2327',
|
||||
'2328',
|
||||
'2329',
|
||||
'2463',
|
||||
'3689',
|
||||
'3691',
|
||||
'3693',
|
||||
'3695',
|
||||
'3697',
|
||||
'3725',
|
||||
'3775',
|
||||
'3828',
|
||||
'9830',
|
||||
'9832',
|
||||
'9836',
|
||||
'9838',
|
||||
'9840',
|
||||
'9842',
|
||||
'15317',
|
||||
//P3 Materials
|
||||
'2344',
|
||||
'2345',
|
||||
'2346',
|
||||
'2348',
|
||||
'2349',
|
||||
'2351',
|
||||
'2352',
|
||||
'2354',
|
||||
'2358',
|
||||
'2360',
|
||||
'2361',
|
||||
'2366',
|
||||
'2367',
|
||||
'9834',
|
||||
'9846',
|
||||
'9848',
|
||||
'12836',
|
||||
'17136',
|
||||
'17392',
|
||||
'17898',
|
||||
'28974',
|
||||
//P4 Materials
|
||||
'2867',
|
||||
'2868',
|
||||
'2869',
|
||||
'2870',
|
||||
'2871',
|
||||
'2872',
|
||||
'2875',
|
||||
'2876',
|
||||
];
|
||||
|
||||
return $pi_items;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Lookups;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Libraries
|
||||
use Log;
|
||||
@@ -33,6 +33,32 @@ class LookupHelper {
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication();
|
||||
}
|
||||
|
||||
public function ItemNameToId($itemName) {
|
||||
$item = ItemLookup::where([
|
||||
'name' => $itemName,
|
||||
])->first();
|
||||
|
||||
if($item != null) {
|
||||
return $item->type_id;
|
||||
} else {
|
||||
try {
|
||||
$response = $this->esi->setBody(array(
|
||||
$itemName,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
printf("Failed to get the item information");
|
||||
Log::warning('Failed to get item information from /universe/');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($response->inventory_types)) {
|
||||
return $response->inventory_types[0]->id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function ItemIdToName($itemId) {
|
||||
//Check if the item is stored in our own database first
|
||||
$item = $this->LookupItem($itemId);
|
||||
@@ -46,6 +72,9 @@ class LookupHelper {
|
||||
'type_id' => $itemId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
printf("Failed to get the item name from the id.\r\n");
|
||||
var_dump($e);
|
||||
printf("\r\n");
|
||||
Log::warning('Failed to get item information from /universe/types/{type_id}/ in LookupHelper.');
|
||||
return null;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Library\Moons;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
@@ -80,6 +80,7 @@ class MiningLedgerHelper {
|
||||
public function GetMiningStructureInfo($observerId) {
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Check for ESI scopes
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-universe.read_structures.v1')) {
|
||||
@@ -98,7 +99,7 @@ class MiningLedgerHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
$system = $this->GetSolarSystemName($info->solar_system_id);
|
||||
$system = $lookup->SystemIdToName($info->solar_system_id);
|
||||
|
||||
return [
|
||||
'name' => $info->name,
|
||||
@@ -161,7 +162,7 @@ class MiningLedgerHelper {
|
||||
//Sort through the array and replace character id with name and item id with name
|
||||
foreach($items as $item) {
|
||||
$charName = $lookup->CharacterIdToName($item->character_id);
|
||||
$typeName = $this->GetItemName($item->type_id);
|
||||
$typeName = $lookup->ItemIdToName($item->type_id);
|
||||
$corpName = $lookup->CorporationIdToName($item->recorded_corporation_id);
|
||||
|
||||
if(isset($final[$charName])) {
|
||||
@@ -183,59 +184,5 @@ class MiningLedgerHelper {
|
||||
|
||||
return $final;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type id and return the name of the ore
|
||||
*
|
||||
* @var typeId
|
||||
* @return string
|
||||
*/
|
||||
private function GetItemName($typeId) {
|
||||
//Setup the esi helper variable
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the authentication container for ESI
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
try {
|
||||
$item = $esi->invoke('get', '/universe/types/{type_id}/', [
|
||||
'type_id' => $typeId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $item->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the solar system name
|
||||
*
|
||||
* @var systemId
|
||||
* @return string
|
||||
*/
|
||||
private function GetSolarSystemName($systemId) {
|
||||
//Setup the esi helper variable
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Setup the authentication container for ESI
|
||||
$esi = $esiHelper->SetupEsiAuthentication();
|
||||
|
||||
//Attempt to get the solar system name from ESI
|
||||
try {
|
||||
$solar = $esi->invoke('get', '/universe/systems/{system_id}/', [
|
||||
'system_id' => $systemId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
$solar = null;
|
||||
}
|
||||
|
||||
if($solar != null) {
|
||||
return $solar->name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\SRP;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Libraries
|
||||
use Carbon\Carbon;
|
||||
@@ -5,7 +5,7 @@
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Structures;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
@@ -34,19 +34,16 @@ class StructureHelper {
|
||||
public function __construct($char, $corp, $esi = null) {
|
||||
$this->charId = $char;
|
||||
$this->corpId = $corp;
|
||||
if($esi == null) {
|
||||
$esiHelper = new Esi;
|
||||
$token = $esiHelper->GetRefreshToken($char);
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
} else {
|
||||
$this->esi = $esi;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetStructuresByPage($page) {
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
if($this->esi == null) {
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Create the esi authentication container
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
}
|
||||
|
||||
//Try to get the ESI data
|
||||
try {
|
||||
@@ -63,13 +60,6 @@ class StructureHelper {
|
||||
}
|
||||
|
||||
public function ProcessStructure($structure) {
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Setup the esi authentication container
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Get the structure information
|
||||
$info = $this->GetStructureInfo($structure->structure_id);
|
||||
@@ -88,13 +78,6 @@ class StructureHelper {
|
||||
$esiHelper = new Esi;
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
if($this->esi == null) {
|
||||
//Get the refresh token
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Setup the esi authentication container
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
}
|
||||
|
||||
$solar = $lookup->SystemIdToName($systemId);
|
||||
|
||||
if($solar != null) {
|
||||
@@ -108,13 +91,6 @@ class StructureHelper {
|
||||
//Declare some variables
|
||||
$esiHelper = new Esi;
|
||||
|
||||
if($this->esi == null) {
|
||||
//Get the refresh token
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Setup the esi authentication container
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
}
|
||||
|
||||
try {
|
||||
$info = $this->esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
'structure_id' => $structureId,
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Taxes;
|
||||
namespace App\Library\Helpers;
|
||||
|
||||
//Internal Library
|
||||
use Carbon\Carbon;
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\JumpBridges;
|
||||
|
||||
//Internal Libraries
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Taxes\TaxesHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\JumpBridgeJournal;
|
||||
|
||||
class JumpBridgeHelper {
|
||||
|
||||
public function __construct() {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Market;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class MarketHelper {
|
||||
|
||||
/**
|
||||
* Private variables
|
||||
*
|
||||
* @var esi
|
||||
*/
|
||||
private $esi;
|
||||
|
||||
/**
|
||||
* Class Construct
|
||||
*/
|
||||
public function __construct($esi = null) {
|
||||
$this->esi = $esi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the regional market orders
|
||||
*
|
||||
* @var region
|
||||
*/
|
||||
public function GetRegionalMarketOrders($region) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Price an item out and return the different price schemes
|
||||
*
|
||||
* @var itemId
|
||||
*/
|
||||
public function PriceItem($itemId) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the market group infromation
|
||||
*
|
||||
* @var group
|
||||
*/
|
||||
public function GetMarketGroup($group) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the public contract items
|
||||
*
|
||||
* @var contractId
|
||||
*/
|
||||
public function GetPublicContractItem($contractId) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get market price for an item
|
||||
*
|
||||
* @var itemId
|
||||
*/
|
||||
public function GetMarketPrice($itemId) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -14,6 +14,9 @@ use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Client;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
use App\Models\Moon\ItemComposition;
|
||||
@@ -203,6 +206,98 @@ class MoonCalc {
|
||||
return $units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the per item price of a unit of ore
|
||||
*/
|
||||
public function CalculateOrePrice($oreId) {
|
||||
//Declare variables
|
||||
$lookupHelper = new LookupHelper;
|
||||
$finalName = null;
|
||||
|
||||
$pastTime = Carbon::now()->subDays(30);
|
||||
|
||||
//Get the price of the moongoo
|
||||
$tritaniumPrice = MineralPrice::where(['ItemId' => 34])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$pyeritePrice = MineralPrice::where(['ItemId' => 35])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$mexallonPrice = MineralPrice::where(['ItemId' => 36])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$isogenPrice = MineralPrice::where(['ItemId' => 37])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$nocxiumPrice = MineralPrice::where(['ItemId' => 38])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$zydrinePrice = MineralPrice::where(['ItemId' => 39])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$megacytePrice = MineralPrice::where(['ItemId' => 40])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$atmosphericGasesPrice = MineralPrice::where(['ItemId' => 16634])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$evaporiteDepositsPirce = MineralPrice::where(['ItemId' => 16635])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$hydrocarbonsPrice = MineralPrice::where(['ItemId' => 16633])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$silicatesPrice = MineralPrice::where(['ItemId' => 16636])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$cobaltPrice = MineralPrice::where(['ItemId' => 16640])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$scandiumPrice = MineralPrice::where(['ItemId' => 16639])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$titaniumPrice = MineralPrice::where(['ItemId' => 16638])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$tungstenPrice = MineralPrice::where(['ItemId' => 16637])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$cadmiumPrice = MineralPrice::where(['ItemId' => 16643])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$platinumPrice = MineralPrice::where(['ItemId' => 16644])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$vanadiumPrice = MineralPrice::where(['ItemId' => 16642])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$chromiumPrice = MineralPrice::where(['ItemId' => 16641])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$technetiumPrice = MineralPrice::where(['ItemId' => 16649])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$hafniumPrice = MineralPrice::where(['ItemId' => 16648])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$caesiumPrice = MineralPrice::where(['ItemId' => 16647])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$mercuryPrice = MineralPrice::where(['ItemId' => 16646])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$dysprosiumPrice = MineralPrice::where(['ItemId' => 16650])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$neodymiumPrice = MineralPrice::where(['ItemId' => 16651])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$promethiumPrice = MineralPrice::where(['ItemId' => 16652])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$thuliumPrice = MineralPrice::where(['ItemId' => 16653])->where('Time', '>', $pastTime)->avg('Price');
|
||||
|
||||
//Get the name through the lookup table
|
||||
$oreName = $lookupHelper->ItemIdToName($oreId);
|
||||
|
||||
//Strip the prefix from the ore name if it has one.
|
||||
//Then change the ore id if necessary
|
||||
$tempName = explode(' ', $oreName);
|
||||
|
||||
if(sizeof($tempName) == 1) {
|
||||
$finalName = $tempName[0];
|
||||
} else {
|
||||
$finalName = $tempName[sizeof($tempName) - 1];
|
||||
$oreId = $lookupHelper->ItemNameToId($finalName);
|
||||
}
|
||||
|
||||
//Get the item composition for the ore
|
||||
$composition = ItemComposition::where('ItemId', $oreId)->first();
|
||||
|
||||
//Calculate the Batch Price
|
||||
$batchPrice = ( ($composition->Tritanium * $tritaniumPrice) +
|
||||
($composition->Pyerite * $pyeritePrice) +
|
||||
($composition->Mexallon * $mexallonPrice) +
|
||||
($composition->Isogen * $isogenPrice) +
|
||||
($composition->Nocxium * $nocxiumPrice) +
|
||||
($composition->Zydrine * $zydrinePrice) +
|
||||
($composition->Megacyte * $megacytePrice) +
|
||||
($composition->AtmosphericGases * $atmosphericGasesPrice) +
|
||||
($composition->EvaporiteDeposits * $evaporiteDepositsPirce) +
|
||||
($composition->Hydrocarbons * $hydrocarbonsPrice) +
|
||||
($composition->Silicates * $silicatesPrice) +
|
||||
($composition->Cobalt * $cobaltPrice) +
|
||||
($composition->Scandium * $scandiumPrice) +
|
||||
($composition->Titanium * $titaniumPrice) +
|
||||
($composition->Tungsten * $tungstenPrice) +
|
||||
($composition->Cadmium * $cadmiumPrice) +
|
||||
($composition->Platinum * $platinumPrice) +
|
||||
($composition->Vanadium * $vanadiumPrice) +
|
||||
($composition->Chromium * $chromiumPrice)+
|
||||
($composition->Technetium * $technetiumPrice) +
|
||||
($composition->Hafnium * $hafniumPrice) +
|
||||
($composition->Caesium * $caesiumPrice) +
|
||||
($composition->Mercury * $mercuryPrice) +
|
||||
($composition->Dysprosium * $dysprosiumPrice) +
|
||||
($composition->Neodymium * $neodymiumPrice) +
|
||||
($composition->Promethium * $promethiumPrice) +
|
||||
($composition->Thulium * $thuliumPrice));
|
||||
|
||||
//Take the batch price, and divide by batch size to get unit price
|
||||
$price = $batchPrice / $composition->BatchSize;
|
||||
|
||||
//Return the price to the calling function
|
||||
return $price;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update item pricing after new prices were pulled
|
||||
*/
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\RegionalContracts;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
class RegionalContractHelper {
|
||||
|
||||
/**
|
||||
* Region variable
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $region;
|
||||
|
||||
/**
|
||||
* ESI Variable
|
||||
*
|
||||
* @var esi
|
||||
*/
|
||||
private $esi;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public function __construct($region, $esi) {
|
||||
$this->region = $region;
|
||||
$this->esi = $esi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contracts within a region
|
||||
*
|
||||
* @var private
|
||||
*/
|
||||
public function GetContracts() {
|
||||
|
||||
//Get the public contracts from the ESI
|
||||
$responses = $this->esi->invoke('get', '/contracts/public/{region_id}/', [
|
||||
'region_id' => $this->region,
|
||||
]);
|
||||
|
||||
//Send the contracts back to the calling function
|
||||
return $responses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Price the regional contract
|
||||
*
|
||||
* @var buyout
|
||||
* @var contract_id
|
||||
* @var date_expired
|
||||
* @var date_issued
|
||||
* @var days_to_complete
|
||||
* @var end_location_id
|
||||
* @var issuer_id
|
||||
* @var price
|
||||
* @var title
|
||||
* @var type [unknown, item_exchange, auction, courier, loan]
|
||||
* @var volume
|
||||
*/
|
||||
public function PriceContract($contract) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the items in a contract from ESI
|
||||
*
|
||||
* @var id
|
||||
*/
|
||||
public function GetContractItems($contractId) {
|
||||
$items = $this->esi->invoke('get', '/contracts/public/items/{contract_id}/', [
|
||||
'contract_id' => $contractId,
|
||||
]);
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,162 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Wiki;
|
||||
|
||||
//Internal Library
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Library
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserRole;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Doku\DokuGroupNames;
|
||||
use App\Models\Doku\DokuMember;
|
||||
use App\Models\Doku\DokuUser;
|
||||
use App\Models\Admin\AllowedLogin;
|
||||
|
||||
class WikiHelper {
|
||||
|
||||
/**
|
||||
* Check whether the user is allwoed or not allowed
|
||||
*/
|
||||
public function AllowedUser($user) {
|
||||
//Declare some variables
|
||||
$purge = true;
|
||||
|
||||
//Declare helper class
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
//Get the allowed logins list from the database
|
||||
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
|
||||
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
|
||||
|
||||
$charIdTemp = User::where(['name' => $user])->get(['character_id']);
|
||||
|
||||
//Set the character id
|
||||
$charId = $charIdTemp[0]->character_id;
|
||||
|
||||
//Set the corp id
|
||||
$char = $lookup->GetCharacterInfo($charId);
|
||||
$corpId = $char->corporation_id;
|
||||
|
||||
//Set the alliance id
|
||||
$corp = $lookup->GetCorporationInfo($corpId);
|
||||
if(isset($corp->alliance_id)) {
|
||||
$allianceId = $corp->alliance_id;
|
||||
} else {
|
||||
$allianceId = 0;
|
||||
}
|
||||
|
||||
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
|
||||
$purge = false;
|
||||
} else {
|
||||
$purge = true;
|
||||
}
|
||||
|
||||
return $purge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to a particular group
|
||||
*/
|
||||
public function AddUserToGroup($userId, $groupId) {
|
||||
//Get the group information
|
||||
$groups = DokuGroupNames::all();
|
||||
|
||||
//Check if the user already belongs to the group
|
||||
if(DokuMember::where(['gid' => $groupId, 'uid' => $userId])->count() > 0) {
|
||||
//If the count is greater than zero then we don't need to do anything,
|
||||
//just return false to indicate nothing was changed
|
||||
return false;
|
||||
} else {
|
||||
//Get the group the person needs to be added to.
|
||||
$newGroup = DokuGroupNames::where(['id' => $groupId])->first();
|
||||
//Add the user to the group
|
||||
DokuMember::insert([
|
||||
'uid' => $userId,
|
||||
'gid' => $groupId,
|
||||
'groupname' => $newGroup->gname,
|
||||
]);
|
||||
|
||||
//Return true saying we have inserted the user into the group
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a user from a particular group
|
||||
*/
|
||||
public function RemoveUserFromGroup($userId, $groupId) {
|
||||
//Remove the user from any groups he is associated with
|
||||
DokuMember::where([
|
||||
'uid' => $userId,
|
||||
'gid' => $groupId,
|
||||
])->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a user from all groups
|
||||
*/
|
||||
public function RemoveUserFromAllGroups($userId) {
|
||||
//Remove the user from all groups
|
||||
DokuMember::where([
|
||||
'uid' => $userId,
|
||||
])->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a user is already in a group
|
||||
*/
|
||||
public function UserHasGroup($userId, $groupId) {
|
||||
//Get the user information
|
||||
$user = DokuUser::where(['id' => $userId])->first();
|
||||
//Get all of the groups
|
||||
$allGroups = DokuGroupNames::all();
|
||||
|
||||
//cycle through all of the groups, and all of the user's groups to see if the user
|
||||
//is part of the group we are seeking
|
||||
foreach($allGroups as $all) {
|
||||
if($groupId === $all->id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//If we have made it here, then the user does not have the group, therefore,
|
||||
//return the user doesn't have the group
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new user group
|
||||
*/
|
||||
public function AddNewUserGroup($groupName, $description) {
|
||||
//Insert or ignore the group if it's already there.
|
||||
DokuGroupNames::insertOrIgnore([
|
||||
'gname' => $groupName,
|
||||
'description' => $description,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all traces of a wiki user
|
||||
*/
|
||||
public function DeleteWikiUser($userId) {
|
||||
//Delete the permissions of the user first.
|
||||
DokuMember::where([
|
||||
'uid' => $userId,
|
||||
])->delete();
|
||||
|
||||
//Delete the user from the user table
|
||||
DokuUser::where(['id' => $userId])->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get uid from name
|
||||
*/
|
||||
public function GetUID($name) {
|
||||
return DokuUser::where(['name' => $name])->first();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Corporation;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceCorp extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'AllianceCorps';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
'name',
|
||||
];
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Corporation;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class HoldingCorpJournal extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'HoldingCorpFinancesJournal';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = false;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Doku;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DokuGroupNames extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'wiki_groupnames';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'gname',
|
||||
'description',
|
||||
];
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Doku;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DokuMember extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'wiki_member';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'uid',
|
||||
'gid',
|
||||
'groupname',
|
||||
];
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user