Compare commits
1 Commits
dependabot
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7660b2aa67 |
103
app/Console/Commands/Assets/GetAssets.php
Normal file
103
app/Console/Commands/Assets/GetAssets.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
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;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessAsset;
|
||||
|
||||
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++) {
|
||||
$job = new JobProcessAsset;
|
||||
$job->charId = $charId;
|
||||
$job->corpId = $corpId;
|
||||
$job->page = $i;
|
||||
ProcessAssetsJob::dispatch($job)->onQueue('assets');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
89
app/Console/Commands/Corps/GetCorps.php
Normal file
89
app/Console/Commands/Corps/GetCorps.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Data;
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
class PurgeCorpMoonLedgers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'data:PurgeCorpLedgers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Purge old corp ledgers data';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$task = new CommandHelper('PurgeCorpLedgers');
|
||||
$task->SetStartStatus();
|
||||
|
||||
PurgeMoonLedgerJob::dispatch();
|
||||
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Eve;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\Eve\ItemPricesUpdateJob;
|
||||
|
||||
class ItemPricesUpdateCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:ItemPriceUpdate';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update mineral and ore prices';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$task = new CommandHelper('ItemPriceUpdate');
|
||||
$task->SetStartStatus();
|
||||
|
||||
$moonHelper = new MoonCalc;
|
||||
$moonHelper->FetchNewPrices();
|
||||
|
||||
//ItemPricesUpdateJob::dispatch()->onQueue('default');
|
||||
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Files;
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Files;
|
||||
|
||||
//Internal Stuff
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class UpdateItemCompositionFromSDECommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'sde:update:ItemCompositions';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Updates item compositions from sql file.';
|
||||
|
||||
/**
|
||||
* The SDE storage path
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
protected $storage_path;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the sql file for the related database information
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Start by warning the user about the command which will be run
|
||||
$this->comment('Warning! This Laravel command uses exec() to execute a ');
|
||||
$this->comment('mysql shell command to import an extracted dump. Due');
|
||||
$this->comment('to the way the command is constructed, should someone ');
|
||||
$this->comment('view the current running processes of your server, they ');
|
||||
$this->comment('will be able to see your SeAT database users password.');
|
||||
$this->line('');
|
||||
$this->line('Ensure that you understand this before continuing.');
|
||||
|
||||
//Test we have valid database parameters
|
||||
DB::connection()->getDatabaseName();
|
||||
|
||||
//Warn the user about the operation to begin
|
||||
if (! $this->confirm('Are you sure you want to update to the latest EVE SDE?', true)) {
|
||||
$this->warn('Exiting');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$fileName = $this->getSde();
|
||||
$this->importSde($fileName);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the EVE Sde from Fuzzwork and save it
|
||||
* in the storage_path/sde folder
|
||||
*/
|
||||
public function getSde() {
|
||||
|
||||
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the SDE file downloaded and run the MySQL command to import the table into the database
|
||||
*/
|
||||
public function importSde($fileName) {
|
||||
$import_command = 'mysql -u username -p password database < ' . $file;
|
||||
|
||||
//run the command
|
||||
exec($import_command, $output, $exit_code);
|
||||
|
||||
if($exit_code !== 0) {
|
||||
$this->error('Warning: Import failed with exit code ' .
|
||||
$exit_code . ' and command outut: ' . implode('\n', $output));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Finances;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class AllianceBondsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'command:name';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
89
app/Console/Commands/Finances/HoldingFinances.php
Normal file
89
app/Console/Commands/Finances/HoldingFinances.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
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\Jobs\JobProcessWalletJournal;
|
||||
|
||||
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++) {
|
||||
$job = new JobProcessWalletJournal;
|
||||
$job->division = 1;
|
||||
$job->charId = $config['primary'];
|
||||
$job->page = $i;
|
||||
ProcessWalletJournalJob::dispatch($job)->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++) {
|
||||
$job = new JobProcessWalletJournal;
|
||||
$job->division = 6;
|
||||
$job->charId = $config['primary'];
|
||||
$job->page = $i;
|
||||
ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
142
app/Console/Commands/Finances/SovBills.php
Normal file
142
app/Console/Commands/Finances/SovBills.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
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\Jobs\JobProcessWalletJournal;
|
||||
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']);
|
||||
|
||||
//Dispatch a job for each page to process
|
||||
//for($i = 1; $i <= $pages; $i++) {
|
||||
// $job = new JobProcessWalletJournal;
|
||||
// $job->division = 6;
|
||||
// $job->charId = $config['primary'];
|
||||
// $job->page = $i;
|
||||
// ProcessWalletJournalJob::dispatch($job)->onQueue('journal');
|
||||
//}
|
||||
|
||||
//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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Flex;
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
@@ -15,6 +15,7 @@ use Commands\Library\CommandHelper;
|
||||
//Models
|
||||
use App\Models\Flex\FlexStructure;
|
||||
use App\Models\Mail\SentMail;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
class FlexStructureCommand extends Command
|
||||
{
|
||||
@@ -83,23 +84,27 @@ class FlexStructureCommand extends Command
|
||||
//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 += "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>";
|
||||
$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));
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = "Warped Intentions Flex Structures Payment Due for " . $today->englishMonth;
|
||||
$mail->body = $body;
|
||||
$mail->recipient = (int)$structure->requestor_id;
|
||||
$mail->recipient_type = 'character';
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueueu('mail')->delay($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');
|
||||
$this->SaveSentRecord($mail->sender, $mail->subject, $mail->body, $mail->recipient, $mail->recipient_type);
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
|
||||
226
app/Console/Commands/Moons/MoonMailer.php
Normal file
226
app/Console/Commands/Moons/MoonMailer.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Library
|
||||
use Commands\Library\CommandHelper;
|
||||
use App\Library\Moons\MoonCalc;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\RentalMoon;
|
||||
use App\Models\MoonRent\MoonRental;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
use App\Models\Mail\SentMail;
|
||||
|
||||
class MoonMailerCommand extends Command
|
||||
{
|
||||
/**
|
||||
* Next update will include checking for if the moon has been paid in advance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:MoonMailer';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Mail out the moon rental bills automatically';
|
||||
|
||||
/**
|
||||
* 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('MoonMailer');
|
||||
//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 = 1;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
//Get the esi configuration
|
||||
$config = config('esi');
|
||||
|
||||
//Get all contacts from the rentals group
|
||||
$contacts = MoonRental::select('Contact')->groupBy('Contact')->get();
|
||||
|
||||
//For each of the contacts totalize the moon rental, and create the mail to send to them,
|
||||
//then update parameters of the moon
|
||||
foreach($contacts as $contact) {
|
||||
//Get the moons the renter is renting. Also only get the moons which are not paid as of today
|
||||
$rentals = MoonRental::where(['Contact' => $contact->Contact])->get();
|
||||
|
||||
//Totalize the cost of the moons
|
||||
$cost = $this->TotalizeMoonCost($rentals);
|
||||
|
||||
//Get the list of moons in a list format
|
||||
$listItems = $this->GetMoonList($rentals);
|
||||
|
||||
//Build the mail body
|
||||
$body = "Moon Rent is due for the following moons:<br>";
|
||||
foreach($listItems as $item) {
|
||||
$body .= $item . "<br>";
|
||||
}
|
||||
$body .= "The price for the next month's rent is " . number_format($cost, 2, ".", ",") . "<br>";
|
||||
$body .= "Please remit payment to Spatial Forces on the 1st should you continue to wish to rent the moon.<br>";
|
||||
$body .= "Sincerely,<br>";
|
||||
$body .= "Warped Intentions Leadership<br>";
|
||||
|
||||
//Dispatch the mail job
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = "Warped Intentions Moon Rental Payment Due for " . $today->englishMonth;
|
||||
$mail->body = $body;
|
||||
$mail->recipient = (int)$contact->Contact;
|
||||
$mail->recipient_type = 'character';
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay($delay);
|
||||
//Increment the delay for the mail to not hit rate limits
|
||||
$delay += 30;
|
||||
|
||||
//Update the moon as not being paid for the next month?
|
||||
foreach($rentals as $rental) {
|
||||
$previous = new Carbon($rental->Paid_Until);
|
||||
|
||||
if($today->greaterThanOrEqualTo($previous)) {
|
||||
$this->UpdateNotPaid($rental);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$task->SetStopStatus();
|
||||
}
|
||||
|
||||
private function SendMail() {
|
||||
return;
|
||||
}
|
||||
|
||||
private function UpdateNotPaid(MoonRental $rental) {
|
||||
MoonRental::where([
|
||||
'System' => $rental->System,
|
||||
'Planet'=> $rental->Planet,
|
||||
'Moon'=> $rental->Moon,
|
||||
])->update([
|
||||
'Paid' => 'No',
|
||||
]);
|
||||
}
|
||||
|
||||
private function GetMoonList($moons) {
|
||||
//Declare the variable to be used as a global part of the function
|
||||
$list = array();
|
||||
|
||||
//For each of the moons, build the System Planet and Moon.
|
||||
foreach($moons as $moon) {
|
||||
$temp = 'Moon: ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon;
|
||||
array_push($list, $temp);
|
||||
}
|
||||
|
||||
//Return the list
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function GetRentalMoons($contact) {
|
||||
$rentals = MoonRental::where([
|
||||
'Contact' => $contact,
|
||||
])->get();
|
||||
|
||||
return $rentals;
|
||||
}
|
||||
|
||||
private function TotalizeMoonCost($rentals) {
|
||||
//Delcare variables and classes
|
||||
$moonCalc = new MoonCalc;
|
||||
$totalCost = 0.00;
|
||||
$price = null;
|
||||
|
||||
//Create the date for today
|
||||
$today = Carbon::now();
|
||||
$today->second = 1;
|
||||
$today->minute = 0;
|
||||
$today->hour = 0;
|
||||
|
||||
foreach($rentals as $rental) {
|
||||
$moon = RentalMoon::where([
|
||||
'System' => $rental->System,
|
||||
'Planet' => $rental->Planet,
|
||||
'Moon' => $rental->Moon,
|
||||
])->first();
|
||||
|
||||
//Create the date time object for the rental end
|
||||
$end = new Carbon($rental->Paid_Until);
|
||||
|
||||
//If today is greater than the rental end, then calculate the moon cost
|
||||
if($today->greaterThanOrEqualTo($end)) {
|
||||
//Get the updated price for the moon
|
||||
$price = $moonCalc->SpatialMoonsOnlyGooMailer($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//Check the type and figure out which price to add in
|
||||
if($rental->Type == 'alliance') {
|
||||
$totalCost += $price['alliance'];
|
||||
} else{
|
||||
$totalCost += $price['outofalliance'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Return the total cost back to the calling function
|
||||
return $totalCost;
|
||||
}
|
||||
|
||||
private function GetRentalType($rentals) {
|
||||
$alliance = 0;
|
||||
$outofalliance = 0;
|
||||
|
||||
//Go through the data and log whether the renter is in the alliance,
|
||||
//or the renter is out of the alliance
|
||||
foreach($rentals as $rental) {
|
||||
if($rental->Type == 'alliance') {
|
||||
$alliance++;
|
||||
} else {
|
||||
$outofalliance++;
|
||||
}
|
||||
}
|
||||
|
||||
//Return the rental type
|
||||
if($alliance > $outofalliance) {
|
||||
return 'alliance';
|
||||
} else {
|
||||
return 'outofalliance';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
55
app/Console/Commands/Moons/UpdateMoonPricing.php
Normal file
55
app/Console/Commands/Moons/UpdateMoonPricing.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use Commands\Library\CommandHelper;
|
||||
|
||||
use App\Library\Moons\MoonCalc;
|
||||
|
||||
class UpdateMoonPriceCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:UpdateMoonPrice';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update moon pricing on a scheduled basis';
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
$moonCalc = new MoonCalc();
|
||||
$moonCalc->FetchNewPrices();
|
||||
|
||||
//Mark the job as finished
|
||||
$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();
|
||||
}
|
||||
}
|
||||
119
app/Console/Commands/Structures/GetStructures.php
Normal file
119
app/Console/Commands/Structures/GetStructures.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
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\Jobs\JobProcessStructure;
|
||||
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++) {
|
||||
$job = new JobProcessStructure;
|
||||
$job->charId = $charId;
|
||||
$job->corpId = $corpId;
|
||||
$job->page = $currentPage;
|
||||
ProcessStructureJob::dispatch($job)->onQueue('structures');
|
||||
}
|
||||
|
||||
//Mark the job as finished
|
||||
$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();
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\SupplyChain;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Job
|
||||
use App\Jobs\Commands\SupplyChain\EndSupplyChainContractJob;
|
||||
|
||||
class EndSupplyChainContractCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:supplychain';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Checks and ends any supply chain contracts needs to be closed.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get the supply chain contracts which are open, but need to be closed.
|
||||
$contracts = SupplyChainContract::where([
|
||||
'state' => 'open',
|
||||
])->where('end_date', '>', $today)->get();
|
||||
|
||||
//Create jobs to complete each contract
|
||||
foreach($contracts as $contract) {
|
||||
EndSupplyChainContractJob::dispatch($contract)->onQueue('default');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Users;
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//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,8 +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;
|
||||
|
||||
|
||||
/**
|
||||
@@ -187,13 +184,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
50
app/Console/Commands/Wormholes/PurgeWormholes.php
Normal file
50
app/Console/Commands/Wormholes/PurgeWormholes.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Wormholes\AllianceWormhole;
|
||||
|
||||
class PurgeWormholes extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:PurgeWormholeData';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Purge stale wormhole data automatically';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Time of now
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
AllianceWormhole::where('created_at', '<', $currentTime->subHours(48))->delete();
|
||||
}
|
||||
}
|
||||
@@ -17,23 +17,18 @@ 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,
|
||||
Commands\Data\EmptyJumpBridges::class,
|
||||
Commands\Finances\SovBillsCommand::class,
|
||||
Commands\Data\CleanStaleDataCommand::class,
|
||||
Commands\Moons\MoonsUpdateCommand::class,
|
||||
Commands\Data\PurgeCorpMoonLedgers::class,
|
||||
Commands\Eve\ItemPricesUpdateCommand::class,
|
||||
/**
|
||||
* Rental Moon Commands
|
||||
*/
|
||||
Commands\RentalMoons\AllianceRentalMoonInvoiceCreationCommand::class,
|
||||
Commands\RentalMoons\AllianceRentalMoonUpdatePricingCommand::class,
|
||||
Commands\GetCorpsCommand::class,
|
||||
Commands\UpdateMoonPriceCommand::class,
|
||||
Commands\HoldingFinancesCommand::class,
|
||||
Commands\MoonMailerCommand::class,
|
||||
Commands\GetStructuresCommand::class,
|
||||
Commands\GetAssetsCommand::class,
|
||||
Commands\PurgeUsers::class,
|
||||
Commands\FlexStructureCommand::class,
|
||||
Commands\EmptyJumpBridges::class,
|
||||
Commands\PurgeWormholes::class,
|
||||
Commands\SovBillsCommand::class,
|
||||
Commands\CleanStaleDataCommand::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -44,51 +39,51 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
//Command to get the holding journal finances
|
||||
$schedule->command('services:HoldingJournal')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
//Command to update moon rental pricing
|
||||
$schedule->command('services:UpdateMoonPrice')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
//Get the corps within the alliance
|
||||
$schedule->command('services:GetCorps')
|
||||
->monthlyOn(1, '09:00')
|
||||
->withoutOverlapping();
|
||||
//Update the moons, and send out mails for current moon rentals
|
||||
$schedule->command('services:MoonMailer')
|
||||
->monthlyOn(1, '00:01')
|
||||
->withoutOverlapping();
|
||||
//Get the structures within the alliance and their information
|
||||
$schedule->command('services:GetStructures')
|
||||
->dailyAt('09:00')
|
||||
->withoutOverlapping();
|
||||
//Get the assets for the alliance. Only saves the Liquid Ozone for jump bridges
|
||||
$schedule->command('services:GetAssets')
|
||||
->hourlyAt('22')
|
||||
->withoutOverlapping();
|
||||
//Clean old data from the database
|
||||
$schedule->command('services:CleanData')
|
||||
->monthlyOn(15, '18:00');
|
||||
//Purge users from the database which don't belong and reset the user roles as necessary
|
||||
$schedule->command('services:PurgeUsers')
|
||||
->dailyAt('23:00')
|
||||
->withoutOverlapping();
|
||||
//Mail about payments for flex structures
|
||||
$schedule->command('services:FlexStructures')
|
||||
->monthlyOn(2, '00:01')
|
||||
->withoutOverlapping();
|
||||
//Wormhole data purge
|
||||
$schedule->command('services:PurgeWormholeData')
|
||||
->hourlyAt(20);
|
||||
//Purge old data from the database
|
||||
$schedule->command('services:CleanData')
|
||||
->weekly(7, '11:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
//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')
|
||||
->weekly(7, '11:00');
|
||||
$schedule->command('data:PurgeCorpLedgers')
|
||||
->monthly();
|
||||
$schedule->command('services:PurgeUsers')
|
||||
->dailyAt('23:00');
|
||||
|
||||
/**
|
||||
* Item Update Schedule
|
||||
*/
|
||||
$schedule->command('services:ItemPriceUpdate')
|
||||
->hourlyAt('30')
|
||||
->withoutOverlapping();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
//use Exception;
|
||||
use Throwable;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@@ -33,7 +32,7 @@ class Handler extends ExceptionHandler
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Throwable $exception)
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
@@ -45,7 +44,7 @@ class Handler extends ExceptionHandler
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Throwable $exception)
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class BlacklistController extends Controller
|
||||
|
||||
public function AddToBlacklist(Request $request) {
|
||||
//Middleware needed for the function
|
||||
$this->middleware('permission:blacklist.admin');
|
||||
$this->middleware('permission:alliance.recruiter');
|
||||
|
||||
//Validate the user input
|
||||
$this->validate($request, [
|
||||
@@ -84,16 +84,15 @@ class BlacklistController extends Controller
|
||||
}
|
||||
|
||||
//Store the entity in the table
|
||||
$blacklist = new BlacklistEntity;
|
||||
$blacklist->entity_id = $entityId;
|
||||
$blacklist->entity_name = $request->name;
|
||||
$blacklist->entity_type = $request->type;
|
||||
$blacklist->reason = $request->reason;
|
||||
$blacklist->alts = $request->alts;
|
||||
$blacklist->lister_id = auth()->user()->getId();
|
||||
$blacklist->lister_name = auth()->user()->getName();
|
||||
$blacklist->validity = 'Valid';
|
||||
$blacklist->save();
|
||||
BlacklistEntity::insert([
|
||||
'entity_id' => $entityId,
|
||||
'entity_name' => $request->name,
|
||||
'entity_type' => $request->type,
|
||||
'reason' => $request->reason,
|
||||
'alts' => $request->alts,
|
||||
'lister_id' => auth()->user()->getId(),
|
||||
'lister_name' => auth()->user()->getName(),
|
||||
]);
|
||||
|
||||
//Return to the view
|
||||
return redirect('/blacklist/display/add')->with('success', $request->name . ' added to the blacklist.');
|
||||
@@ -109,22 +108,17 @@ class BlacklistController extends Controller
|
||||
|
||||
public function RemoveFromBlacklist(Request $request) {
|
||||
//Middleware needed
|
||||
$this->middleware('permission:blacklist.admin');
|
||||
$this->middleware('permission:alliance.recruiter');
|
||||
|
||||
//Validate the input request
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
]);
|
||||
|
||||
//Set the character on the blacklist to removed
|
||||
//Delete the blacklist character
|
||||
BlacklistEntity::where([
|
||||
'entity_name' => $request->name,
|
||||
])->update([
|
||||
'validity' => 'Invalid',
|
||||
'removed_by_id' => auth()->user()->getId(),
|
||||
'removed_by_name' => auth()->user()->getName(),
|
||||
'removed_notes' => $request->notes,
|
||||
]);
|
||||
])->delete();
|
||||
|
||||
//Return the view
|
||||
return redirect('/blacklist/display')->with('success', 'Character removed from the blacklist.');
|
||||
@@ -133,9 +127,7 @@ class BlacklistController extends Controller
|
||||
public function DisplayBlacklist() {
|
||||
|
||||
//Get the entire blacklist
|
||||
$blacklist = BlacklistEntity::where([
|
||||
'validity' => 'Valid',
|
||||
])->orderBy('entity_name', 'asc')->paginate(50);
|
||||
$blacklist = BlacklistEntity::orderBy('entity_name', 'asc')->paginate(50);
|
||||
|
||||
//Return the view with the data
|
||||
return view('blacklist.list')->with('blacklist', $blacklist);
|
||||
@@ -149,9 +141,9 @@ class BlacklistController extends Controller
|
||||
]);
|
||||
|
||||
$blacklist = DB::table('alliance_blacklist')->where('entity_name', 'like', $request->parameter . "%")
|
||||
->orWhere('entity_type', 'like', "%" . $request->parameter . "%")
|
||||
->orWhere('alts', 'like', "%" . $request->parameter . "%")
|
||||
->orWhere('reason', 'like', "%" . $request->parameter . "%")
|
||||
->orWhere('entity_type', 'like', $request->parameter . "%")
|
||||
->orWhere('alts', 'like', $request->parameter . "%")
|
||||
->orWhere('reason', 'like', $request->parameter . "%")
|
||||
->orderBy('entity_name', 'asc')
|
||||
->paginate(50);
|
||||
|
||||
|
||||
198
app/Http/Controllers/Contracts/ContractAdminController.php
Normal file
198
app/Http/Controllers/Contracts/ContractAdminController.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Contracts;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Esi\Mail;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Contracts\Contract;
|
||||
use App\Models\Contracts\Bid;
|
||||
use App\Models\Contracts\AcceptedBid;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
class ContractAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:contract.admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Contract display functions
|
||||
*/
|
||||
public function displayContractDashboard() {
|
||||
$contracts = Contract::where(['finished' => false])->get();
|
||||
|
||||
return view('contracts.admin.contractpanel')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
public function displayPastContracts() {
|
||||
$contracts = Contract::where(['finished' => true])->get();
|
||||
|
||||
return view('contracs.admin.past')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* New contract functionality
|
||||
*/
|
||||
public function displayNewContract() {
|
||||
return view('contracts.admin.newcontract');
|
||||
}
|
||||
|
||||
public function storeNewContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'date' => 'required',
|
||||
'body' => 'required',
|
||||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$date = new Carbon($request->date);
|
||||
$body = nl2br($request->body);
|
||||
|
||||
//Store the contract in the database
|
||||
$contract = new Contract;
|
||||
$contract->title = $request->name;
|
||||
$contract->end_date = $request->date;
|
||||
$contract->body = $body;
|
||||
$contract->type = $request->type;
|
||||
$contract->save();
|
||||
|
||||
//Send a mail out to all of the people who can bid on a contract
|
||||
$this->NewContractMail();
|
||||
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract written.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to store a finished contract in the database
|
||||
*/
|
||||
public function storeAcceptContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contract_id' => 'required',
|
||||
'bid_id' => 'required',
|
||||
'character_id' => 'required',
|
||||
'bid_amount' => 'required',
|
||||
]);
|
||||
|
||||
//Update the contract
|
||||
Contract::where([
|
||||
'contract_id' => $request->contract_id,
|
||||
])->update([
|
||||
'finished' => true,
|
||||
'final_cost' => $request->bid_amount,
|
||||
]);
|
||||
|
||||
//Save the accepted bid in the database
|
||||
$accepted = new AcceptedBid;
|
||||
$accepted->contract_id = $request->contract_id;
|
||||
$accepted->bid_id = $request->bid_id;
|
||||
$accepted->bid_amount = $request->bid_amount;
|
||||
$accepted->save();
|
||||
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract accepted and closed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a contract from every user
|
||||
*/
|
||||
public function deleteContract($id) {
|
||||
|
||||
Contract::where(['contract_id' => $id])->delete();
|
||||
|
||||
Bid::where(['contract_id' => $id])->delete();
|
||||
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract has been deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* End Contract Functionality
|
||||
*/
|
||||
public function displayEndContract($id) {
|
||||
//Gather the information for the contract, and all bids on the contract
|
||||
$contract = Contract::where(['contract_id' => $id])->first()->toArray();
|
||||
$bids = Bid::where(['contract_id' => $id])->get()->toArray();
|
||||
|
||||
return view('contracts.admin.displayend')->with('contract', $contract)
|
||||
->with('bids', $bids);
|
||||
}
|
||||
|
||||
public function storeEndContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contract_id' => 'required',
|
||||
'accept' => 'required',
|
||||
]);
|
||||
|
||||
//Declare class variables
|
||||
$tries = 1;
|
||||
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
$contract = Contract::where(['contract_id' => $request->contract_id])->first()->toArray();
|
||||
$bid = Bid::where(['id' => $request->accept, 'contract_id' => $request->contract_id])->first()->toArray();
|
||||
|
||||
//Send mail out to winner of the contract
|
||||
$subject = 'Contract Won';
|
||||
$body = 'You have been accepted to perform the following contract:<br>';
|
||||
$body .= $contract['contract_id'] . ' : ' . $contract['title'] . '<br>';
|
||||
$body .= 'Notes:<br>';
|
||||
$body .= $contract['body'] . '<br>';
|
||||
$body .= 'Please remit contract when the items are ready to Spatial Forces. Description should be the contract identification number. Request ISK should be the bid amount.';
|
||||
$body .= 'Sincerely,<br>Spatial Forces Contracting Department';
|
||||
|
||||
//Setup the mail job
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->subject = $subject;
|
||||
$mail->recipient_type = 'character';
|
||||
$mail->recipient = $bid['character_id'];
|
||||
$mail->body = $body;
|
||||
$mail->sender = $config['primary'];
|
||||
//Dispatch the mail job
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail');
|
||||
|
||||
//Tidy up the contract by doing a few things.
|
||||
$this->TidyContract($contract, $bid);
|
||||
|
||||
//Redirect back to the contract admin dashboard.
|
||||
return redirect('/contracts/admin/display')->with('success', 'Contract finalized. Mail has been sent to the queue for processing.');
|
||||
}
|
||||
|
||||
private function TidyContract($contract, $bid) {
|
||||
Contract::where(['contract_id' => $contract['contract_id']])->update([
|
||||
'finished' => true,
|
||||
]);
|
||||
|
||||
//Create the accepted contract entry into the table
|
||||
$accepted = new AcceptedBid;
|
||||
$accepted->contract_id = $contract['contract_id'];
|
||||
$accepted->bid_id = $bid['id'];
|
||||
$accepted->bid_amount = $bid['bid_amount'];
|
||||
$accepted->notes = $bid['notes'];
|
||||
$accepted->save();
|
||||
}
|
||||
|
||||
private function NewContractMail() {
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = 'New Alliance Production Contract Available';
|
||||
$mail->recipient = $config['alliance'];
|
||||
$mail->recipient_type = 'alliance';
|
||||
$mail->body = "A new contract is available for the alliance contracting system. Please check out <a href='https://services.w4rp.space'>Services Site</a> if you want to bid on the production contract.<br><br>Sincerely,<br>Warped Intentions Leadership";
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail');
|
||||
}
|
||||
}
|
||||
322
app/Http/Controllers/Contracts/ContractController.php
Normal file
322
app/Http/Controllers/Contracts/ContractController.php
Normal file
@@ -0,0 +1,322 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Contracts;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\User\UserPermission;
|
||||
use App\Models\Contracts\Contract;
|
||||
use App\Models\Contracts\Bid;
|
||||
|
||||
class ContractController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display the bids placed on contracts
|
||||
*/
|
||||
public function displayBids($id) {
|
||||
$bids = Bids::where(['contract_id' => $id, 'character_name' => auth()->user()->getName()])->get();
|
||||
|
||||
return view('contracts.bids')->with('bids', $bids);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Controller function to display all current open contracts
|
||||
*
|
||||
*/
|
||||
public function displayContracts() {
|
||||
//Calculate today's date to know which contracts to display
|
||||
$today = Carbon::now();
|
||||
|
||||
//Declare our array variables
|
||||
$bids = array();
|
||||
$contracts = array();
|
||||
$i = 0;
|
||||
|
||||
//Fetch all of the current contracts from the database
|
||||
$contractsTemp = Contract::where('end_date', '>=', $today)
|
||||
->where(['finished' => false])->get()->toArray();
|
||||
|
||||
//Count the number of bids, and add them to the arrays
|
||||
for($i = 0; $i < sizeof($contractsTemp); $i++) {
|
||||
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
|
||||
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
|
||||
|
||||
//Assemble the finaly array
|
||||
$contracts[$i] = $contractsTemp[$i];
|
||||
$contracts[$i]['bid_count'] = $tempCount;
|
||||
$contracts[$i]['bids'] = $bids;
|
||||
}
|
||||
|
||||
//Call for the view to be displayed
|
||||
return view('contracts.allcontracts')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display all current public contracts
|
||||
*/
|
||||
public function displayPublicContracts() {
|
||||
//Calculate today's date to know which contracts to display
|
||||
$today = Carbon::now();
|
||||
|
||||
//Declare our array variables
|
||||
$bids = array();
|
||||
$contracts = array();
|
||||
$i = 0;
|
||||
$lowestBid = null;
|
||||
$lowestCorp = null;
|
||||
$lowestChar = null;
|
||||
|
||||
//Fetch all of the current contracts from the database
|
||||
$contractsTemp = Contract::where('end_date', '>=', $today)
|
||||
->where(['type' => 'Public', 'finished' => false])->get()->toArray();
|
||||
|
||||
//Count the number of bids, and add them to the arrays
|
||||
for($i = 0; $i < sizeof($contractsTemp); $i++) {
|
||||
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
|
||||
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
|
||||
|
||||
foreach($bids as $bid) {
|
||||
if($lowestBid == null) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
$lowestCorp = $bid['corporation_name'];
|
||||
$lowestChar = $bid['character_name'];
|
||||
} else {
|
||||
if($bid['bid_amount'] < $lowestBid) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
$lowestCorp = $bid['corporation_name'];
|
||||
$lowestChar = $bid['character_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($lowestBid == null) {
|
||||
$lowestBid = 'No Bids Placed.';
|
||||
$lowestCorp = 'No Corporation has placed a bid.';
|
||||
}
|
||||
|
||||
//Assemble the finaly array
|
||||
$contracts[$i] = $contractsTemp[$i];
|
||||
$contracts[$i]['bid_count'] = $tempCount;
|
||||
$contracts[$i]['bids'] = $bids;
|
||||
$contracts[$i]['lowestbid'] = $lowestBid;
|
||||
$contracts[$i]['lowestcorp'] = $lowestCorp;
|
||||
$contracts[$i]['lowestchar'] = $lowestChar;
|
||||
|
||||
//Reset the lowestBid back to null
|
||||
$lowestBid = null;
|
||||
}
|
||||
|
||||
//Call for the view to be displayed
|
||||
return view('contracts.publiccontracts')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display current private contracts
|
||||
*/
|
||||
public function displayPrivateContracts() {
|
||||
//Declare our array variables
|
||||
$bids = array();
|
||||
$contracts = array();
|
||||
$lowestBid = null;
|
||||
|
||||
//Calucate today's date to know which contracts to display
|
||||
$today = Carbon::now();
|
||||
|
||||
//Fetch all of the current contracts from the database
|
||||
$contractsTemp = Contract::where('end_date', '>=', $today)
|
||||
->where(['type' => 'Private', 'finished' => false])->get();
|
||||
|
||||
//Count the number of bids, and add them to the arrays
|
||||
for($i = 0; $i < sizeof($contractsTemp); $i++) {
|
||||
$tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id');
|
||||
$bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray();
|
||||
|
||||
foreach($bids as $bid) {
|
||||
if($lowestBid == null) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
} else {
|
||||
if($bid['bid_amount'] < $lowestBid) {
|
||||
$lowestBid = $bid['bid_amount'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($lowestBid == null) {
|
||||
$lowestBid = 'No Bids Placed.';
|
||||
}
|
||||
|
||||
//Assemble the finaly array
|
||||
$contracts[$i] = $contractsTemp[$i];
|
||||
$contracts[$i]['bid_count'] = $tempCount;
|
||||
$contracts[$i]['bids'] = $bids;
|
||||
$contracts[$i]['lowestbid'] = $lowestBid;
|
||||
}
|
||||
|
||||
return view ('contracts.privatecontracts')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display expired contracts
|
||||
*
|
||||
*/
|
||||
public function displayExpiredContracts() {
|
||||
//Calculate today's date to know which contracts to display
|
||||
$today = Carbon::now();
|
||||
|
||||
//Retrieve the contracts from the database
|
||||
$contracts = Contract::where('end_date', '<', $today)->get();
|
||||
|
||||
return view('contracts.expiredcontracts')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display a page to allow a bid
|
||||
*
|
||||
*/
|
||||
public function displayNewBid($id) {
|
||||
|
||||
$contractId = $id;
|
||||
|
||||
return view('contracts.enterbid')->with('contractId', $contractId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to store a new bid
|
||||
*/
|
||||
public function storeBid(Request $request) {
|
||||
//Valid the request from the enter bid page
|
||||
$this->validate($request, [
|
||||
'contract_id' => 'required',
|
||||
'bid' => 'required',
|
||||
]);
|
||||
|
||||
//Delcare some class variables we will need
|
||||
$lookup = new LookupHelper;
|
||||
|
||||
$amount = 0.00;
|
||||
|
||||
//Convert the amount to a whole number from abbreviations
|
||||
if($request->suffix == 'B') {
|
||||
$amount = $request->bid * 1000000000.00;
|
||||
} else if($request->suffix == 'M') {
|
||||
$amount = $request->bid * 1000000.00;
|
||||
} else {
|
||||
$amount = $request->bid * 1.00;
|
||||
}
|
||||
|
||||
if(isset($request->notes)) {
|
||||
$notes = nl2br($request->notes);
|
||||
} else {
|
||||
$notes = null;
|
||||
}
|
||||
|
||||
//Get the character id and character name from the auth of the user calling
|
||||
//this function
|
||||
$characterId = auth()->user()->getId();
|
||||
$characterName = auth()->user()->getName();
|
||||
//Use the lookup helper in order to find the user's corporation id and name
|
||||
$char = $lookup->GetCharacterInfo($characterId);
|
||||
$corporationId = $char->corporation_id;
|
||||
//use the lookup helper in order to find the corporation's name from it's id.
|
||||
$corp = $lookup->GetCorporationInfo($corporationId);
|
||||
$corporationName = $corp->name;
|
||||
|
||||
//Before saving a bid let's check to see if the user already placed a bid on the contract
|
||||
$found = Bid::where([
|
||||
'contract_id' => $request->contract_id,
|
||||
'character_id' => $characterId,
|
||||
])->first();
|
||||
|
||||
if(isset($found->contract_id)) {
|
||||
return redirect('/contracts/display/all')->with('error', 'You have already placed a bid for this contract. Please modify the existing bid.');
|
||||
} else {
|
||||
//Create the model object to save data to
|
||||
$bid = new Bid;
|
||||
$bid->contract_id = $request->contract_id;
|
||||
$bid->bid_amount = $amount;
|
||||
$bid->character_id = $characterId;
|
||||
$bid->character_name = $characterName;
|
||||
$bid->corporation_id = $corporationId;
|
||||
$bid->corporation_name = $corporationName;
|
||||
$bid->notes = $notes;
|
||||
$bid->save();
|
||||
|
||||
//Redirect to the correct page
|
||||
return redirect('/contracts/display/all')->with('success', 'Bid accepted.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to delete a bid
|
||||
*/
|
||||
public function deleteBid($id) {
|
||||
//Delete the bid entry from the database
|
||||
Bid::where([
|
||||
'id' => $id,
|
||||
])->delete();
|
||||
|
||||
return redirect('/contracts/display/public')->with('success', 'Bid deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display modify bid page
|
||||
*/
|
||||
public function displayModifyBid($id) {
|
||||
//With the bid id number, look up the bid in the database to get the contract information
|
||||
$bid = Bid::where(['id' => $id])->first();
|
||||
|
||||
//Retrieve the contract from the database
|
||||
$contract = Contract::where(['contract_id' => $bid->contract_id])->first()->toArray();
|
||||
|
||||
return view('contracts.modifybid')->with('contract', $contract)
|
||||
->with('bid', $bid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to modify a bid
|
||||
*/
|
||||
public function modifyBid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'bid' => 'required',
|
||||
]);
|
||||
|
||||
$amount = $request->bid;
|
||||
$type = $request->type;
|
||||
$contractId = $request->contract_id;
|
||||
|
||||
if($request->suffix == 'B') {
|
||||
$amount = $amount * 1000000000.00;
|
||||
} else if($request->suffix == 'M') {
|
||||
$amount = $amount * 1000000.00;
|
||||
} else {
|
||||
$amount = $amount * 1.00;
|
||||
}
|
||||
|
||||
Bid::where([
|
||||
'character_id' => auth()->user()->getId(),
|
||||
'contract_id' => $contractId,
|
||||
])->update([
|
||||
'bid_amount' => $amount,
|
||||
]);
|
||||
|
||||
if($type == 'public') {
|
||||
return redirect('/contracts/display/public')->with('success', 'Bid modified.');
|
||||
} else {
|
||||
return redirect('/contracts/display/private')->with('success', 'Bid modified');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,501 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Contracts;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\User\User;
|
||||
use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class SupplyChainController extends Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Renter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the supply chain dashboard
|
||||
* Should contain a section for open contracts, closed contracts, and expired contracts.
|
||||
*/
|
||||
public function displaySupplyChainDashboard() {
|
||||
$openContracts = SupplyChainContract::where([
|
||||
'state' => 'open',
|
||||
])->get();
|
||||
|
||||
$closedContracts = SupplyChainContract::where([
|
||||
'state' => 'closed',
|
||||
])->get();
|
||||
|
||||
$completedContracts = SupplyChainContract::where([
|
||||
'state' => 'completed',
|
||||
])->get();
|
||||
|
||||
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
|
||||
->with('closedContracts', $closedContracts)
|
||||
->with('completedContracts', $completedContracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display my supply chain contracts dashboard
|
||||
* Should contain a section for open contracts, closed contracts, and expired contracts
|
||||
*/
|
||||
public function displayMySupplyChainDashboard() {
|
||||
$openContracts = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'state' => 'open',
|
||||
])->get();
|
||||
|
||||
$closedContracts = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'state' => 'closed',
|
||||
])->get();
|
||||
|
||||
$completedContracts = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'state' => 'completed',
|
||||
])->get();
|
||||
|
||||
return view('supplychain.dashboard.main')->with('openContracts', $openContracts)
|
||||
->with('closedContracts', $closedContracts)
|
||||
->with('completedContracts', $completedContracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display new contract page
|
||||
*/
|
||||
public function displayNewSupplyChainContract() {
|
||||
return view('supplychain.forms.newcontract');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store new contract page
|
||||
*/
|
||||
public function storeNewSupplyChainContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'date' => 'required',
|
||||
'delivery' => 'required',
|
||||
'body' => 'required',
|
||||
]);
|
||||
|
||||
$contract = new SupplyChainContract;
|
||||
$contract->issuer_id = auth()->user()->getId();
|
||||
$contract->issuer_name = auth()->user()->getName();
|
||||
$contract->title = $request->name;
|
||||
$contract->end_date = $request->date;
|
||||
$contract->delivery_by = $request->delivery;
|
||||
$contract->body = $request->body;
|
||||
$contract->state = 'open';
|
||||
$contract->bids = 0;
|
||||
$contract->save();
|
||||
|
||||
$this->NewSupplyChainContractMail($contract);
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'New Contract created.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the delete contract page
|
||||
*/
|
||||
public function displayDeleteSupplyChainContract() {
|
||||
$contracts = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'state' => 'open',
|
||||
])->get();
|
||||
|
||||
return view('supplychain.forms.delete')->with('contracts', $contracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a supply chain contract
|
||||
*/
|
||||
public function deleteSupplyChainContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contractId' => 'required',
|
||||
]);
|
||||
|
||||
$contractId = $request->contractId;
|
||||
|
||||
/**
|
||||
* Remove the supply chain contract if it's yours.
|
||||
*/
|
||||
$count = SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'contract_id' => $contractId,
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
//Remove the supply chain contract
|
||||
SupplyChainContract::where([
|
||||
'issuer_id' => auth()->user()->getId(),
|
||||
'contract_id' => $contractId,
|
||||
])->delete();
|
||||
|
||||
//Remove all bids associated with the supply chain contract
|
||||
SupplyChainBid::where([
|
||||
'contract_id' => $contractId,
|
||||
])->delete();
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Supply Chain Contract deleted successfully.');
|
||||
} else {
|
||||
return redirect('/supplychain/dashboard')->with('error', 'Unable to delete supply chain contract.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the end supply chain contrage page
|
||||
*/
|
||||
public function displayEndSupplyChainContract() {
|
||||
return view('supplychain.forms.end');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the end supply chain contract page
|
||||
*/
|
||||
public function storeEndSupplyChainContract(Request $request) {
|
||||
$this->validate($request, [
|
||||
'accept' => 'required',
|
||||
'contractId' => 'required',
|
||||
]);
|
||||
|
||||
//Check to make sure the user owns the contract
|
||||
$count = SupplyChainContract::where([
|
||||
'issuer_name' => auth()->user()->getName(),
|
||||
'contract_id' => $request->contractId,
|
||||
])->count();
|
||||
|
||||
//If the count is greater than 0, the user owns the contract.
|
||||
//Proceed with ending the contract
|
||||
if($count > 0) {
|
||||
SupplyChainContract::where([
|
||||
|
||||
])->update([
|
||||
|
||||
]);
|
||||
|
||||
SupplyChainBid::where([
|
||||
|
||||
])->update([
|
||||
|
||||
]);
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Contract ended, and mails sent to the winning bidder.');
|
||||
} else {
|
||||
//If the count is zero, then redirect with error messsage
|
||||
return redirect('/supplychain/dashboard')->with('error', 'Contract was not yours to end.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display supply chain contract bids page
|
||||
*/
|
||||
public function displaySupplyChainBids() {
|
||||
//Display bids for the user on a page
|
||||
$bids = array();
|
||||
|
||||
$bidsCount = SupplyChainBid::where([
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'bid_type' => 'pending',
|
||||
])->count();
|
||||
|
||||
$myBids = SupplyChainBid::where([
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'bid_type' => 'pending',
|
||||
])->get();
|
||||
|
||||
foreach($myBids as $bid) {
|
||||
//Declare the temporary array
|
||||
$temp = array();
|
||||
|
||||
//Get the contract information for the bid
|
||||
$contract = SupplyChainContract::where([
|
||||
'contract_id' => $bid->contract_id,
|
||||
])->first();
|
||||
|
||||
$temp['bid_id'] = $bid->bid_id;
|
||||
$temp['contract_id'] = $bid->contract_id;
|
||||
$temp['issuer_name'] = $contract->issuer_name;
|
||||
$temp['title'] = $contract->title;
|
||||
$temp['end_date'] = $contract->end_date;
|
||||
$temp['body'] = $contract->body;
|
||||
$temp['bid_amount'] = $bid->bid_amount;
|
||||
|
||||
array_push($bids, $temp);
|
||||
}
|
||||
|
||||
return view('supplychain.dashboard.bids')->with('bids', $bids)
|
||||
->with('bidsCount', $bidsCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display expired supply chain contracts page
|
||||
*/
|
||||
public function displayExpiredSupplyChainContracts() {
|
||||
|
||||
return view('supplychain.dashboard.expired');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the new bid on a supply chain contract page
|
||||
*/
|
||||
public function displaySupplyChainContractBid($contract) {
|
||||
$contractId = $contract;
|
||||
|
||||
return view('supplychain.forms.enterbid')->with('contractId', $contractId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter a new bid on a supply chain contract
|
||||
*/
|
||||
public function storeSupplyChainContractBid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'bid' => 'required',
|
||||
'contract_id' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some needed variables
|
||||
$bidAmount = 0.00;
|
||||
|
||||
//See if a bid has been placed by the user for this contract
|
||||
$count = SupplyChainBid::where([
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'entity_name' => auth()->user()->getName(),
|
||||
'contract_id' => $request->contract_id,
|
||||
])->count();
|
||||
|
||||
//If the person already has a bid in, then deny them the option to place another bid on the same contract.
|
||||
//Otherwise, enter the bid into the database
|
||||
if($count > 0) {
|
||||
return redirect('/supplychain/dashboard')->with('error', 'Unable to insert bid as one is already present for the supply chain contract.');
|
||||
} else {
|
||||
//Sanitize the bid amount
|
||||
if(preg_match('(m|M|b|B)', $request->bid) === 1) {
|
||||
if(preg_match('(m|M)', $request->bid) === 1) {
|
||||
$cStringSize = strlen($request->bid);
|
||||
$tempCol = str_split($request->bid, $cStringSize - 1);
|
||||
$bidAmount = $tempCol[0];
|
||||
$bidAmount = $bidAmount * 1000000.00;
|
||||
} else if(preg_match('(b|B)', $request->bid) === 1) {
|
||||
$cStringSize = strlen($request->bid);
|
||||
$tempCol = str_split($request->bid, $cStringSize - 1);
|
||||
$bidAmount = $tempCol[0];
|
||||
$bidAmount = $bidAmount * 1000000000.00;
|
||||
}
|
||||
} else {
|
||||
$bidAmount = $request->bid;
|
||||
}
|
||||
|
||||
//Create the database entry
|
||||
$bid = new SupplyChainBid;
|
||||
$bid->contract_id = $request->contract_id;
|
||||
$bid->bid_amount = $bidAmount;
|
||||
$bid->entity_id = auth()->user()->getId();
|
||||
$bid->entity_name = auth()->user()->getName();
|
||||
$bid->entity_type = 'character';
|
||||
if(isset($request->notes)) {
|
||||
$bid->bid_note = $request->notes;
|
||||
}
|
||||
$bid->bid_type = 'pending';
|
||||
$bid->save();
|
||||
|
||||
//Update the database entry for the supply chain contract bid number
|
||||
$num = SupplyChainContract::where([
|
||||
'contract_id' => $request->contract_id,
|
||||
])->select('bids')->first();
|
||||
|
||||
//Increment the number of bids
|
||||
$numBids = $num->bids + 1;
|
||||
|
||||
//Update the database
|
||||
SupplyChainContract::where([
|
||||
'contract_id' => $request->contract_id,
|
||||
])->update([
|
||||
'bids' => $numBids,
|
||||
]);
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Bid succesfully entered into the contract.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a bid on a supply chain contract
|
||||
*
|
||||
* @var contractId
|
||||
* @var bidId
|
||||
*/
|
||||
public function deleteSupplyChainContractBid($contractId, $bidId) {
|
||||
|
||||
//See if the user has put in a bid. If not, then redirect to failure.
|
||||
$count = SupplyChainBid::where([
|
||||
'contract_id' => $contractId,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'bid_id' => $bidId,
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
SupplyChainBid::where([
|
||||
'contract_id' => $contractId,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
'bid_id' => $bidId,
|
||||
])->delete();
|
||||
|
||||
//Update the database entry for the supply chain contract bid number
|
||||
$num = SupplyChainContract::where([
|
||||
'contract_id' => $contractId,
|
||||
])->select('bids')->first();
|
||||
|
||||
//Decrement the number of bids
|
||||
$numBids = $num->bids - 1;
|
||||
|
||||
//Update the database
|
||||
SupplyChainContract::where([
|
||||
'contract_id' => $contractId,
|
||||
])->update([
|
||||
'bids' => $numBids,
|
||||
]);
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Deleted supply chain contract bid.');
|
||||
} else {
|
||||
return redirect('/supplychain/dashboard')->with('error', 'No bid found to delete.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the modify a bid on supply chain contract page
|
||||
*/
|
||||
public function displayModifySupplyChainContractBid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'contract_id' => 'required',
|
||||
]);
|
||||
|
||||
//Get the contract id
|
||||
$contractId = $request->contract_id;
|
||||
//Get the bid id to be modified later
|
||||
$bid = SupplyChainBid::where([
|
||||
'contract_id' => $contractId,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
])->first();
|
||||
|
||||
$bidId = $bid->id;
|
||||
|
||||
return view('supplychain.forms.modifybid')->with('contractId', $contractId)
|
||||
->with('bidId', $bidId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a bid on a supply chain contract
|
||||
*/
|
||||
public function modifySupplyChainContractBid(Request $request) {
|
||||
$this->validate($request, [
|
||||
'bid_id' => 'required',
|
||||
'contract_id' => 'required',
|
||||
'bid_amount' => 'required',
|
||||
]);
|
||||
|
||||
//Check for the owner of the bid
|
||||
$count = SupplyChainBid::where([
|
||||
'bid_id' => $request->bid_id,
|
||||
'contract_id' => $request->contract_id,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
])->count();
|
||||
|
||||
if($count > 0) {
|
||||
if(isset($request->bid_note)) {
|
||||
SupplyChainBid::where([
|
||||
'bid_id' => $request->bid_id,
|
||||
'contract_id' => $request->contract_id,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
])->update([
|
||||
'bid_amount' => $request->bid_amount,
|
||||
'bid_note' => $request->bid_note,
|
||||
]);
|
||||
} else {
|
||||
SupplyChainBid::where([
|
||||
'bid_id' => $request->bid_id,
|
||||
'contract_id' => $request->contract_id,
|
||||
'entity_id' => auth()->user()->getId(),
|
||||
])->update([
|
||||
'bid_amount' => $request->bid_amount,
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect('/supplychain/dashboard')->with('success', 'Modified supply chain contract bid.');
|
||||
} else {
|
||||
return redirect('/supplychain/dashboard')->with('error', 'Not able to modify supply chain contract bid.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a new supply chain contract mail
|
||||
*/
|
||||
private function NewSupplyChainContractMail(SupplyChainContract $contract) {
|
||||
//Get the config for the esi
|
||||
$config = config('esi');
|
||||
$todayDate = Carbon::now()->toFormattedDateString();
|
||||
|
||||
$subject = 'New Supply Chain Contract ' . $todayDate;
|
||||
$body = "A supply chain contract is available.<br>";
|
||||
$body .= "Contract: " . $contract->title . "<br>";
|
||||
$body .= "Notes: " . $contract->body . "<br>";
|
||||
$body .= "Delivery Date: " . $contract->delivery_date . "<br>";
|
||||
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name . "<br>";
|
||||
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send out a mail when the supply chain contract has been deleted
|
||||
*/
|
||||
private function DeleteSupplyChainContractMail($contract) {
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
|
||||
$subject = 'Production Contract Removal';
|
||||
$body = "A production contract has been deleted.<br>";
|
||||
$body .= "Contract: " . $contract->title . "<br>";
|
||||
$body .= "Notes: " . $contract->note . "<br>";
|
||||
$body .= "<br>Sincerely on behalf of,<br>" . $contract->issuer_name;
|
||||
ProcessSendEveMailJob::dispatch($body, 145223267, 'mailing_list', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tidy up datatables from a completed supply chain contract
|
||||
*/
|
||||
private function TidySupplyChainContract($contract, $bid) {
|
||||
//Set the contract as finished
|
||||
SupplyChainContract::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'state' => 'finished',
|
||||
]);
|
||||
|
||||
//Set all of the bids as not_accepted as default
|
||||
SupplyChainBid::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
])->update([
|
||||
'bid_type' => 'not_accepted',
|
||||
]);
|
||||
|
||||
//Set the correct bid as accepted
|
||||
SupplyChainBid::where([
|
||||
'contract_id' => $contract->contract_id,
|
||||
'bid_id' => $bid->bid_id,
|
||||
])->update([
|
||||
'bid_type' => 'accepted',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ use App\Models\User\User;
|
||||
use App\Models\User\UserRole;
|
||||
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;
|
||||
@@ -39,7 +38,7 @@ class AdminController extends Controller
|
||||
$dateInit = Carbon::now();
|
||||
$date = $dateInit->subDays(30);
|
||||
|
||||
$journal = DB::select('SELECT amount,reason,description,date FROM `player_donation_journal` WHERE corporation_id=98287666 AND date >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 2 MONTH) ORDER BY date DESC');
|
||||
$journal = DB::select('SELECT amount,reason,description,date FROM `player_donation_journal` WHERE corporation_id=98287666 AND date >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) ORDER BY date DESC');
|
||||
|
||||
return view('admin.dashboards.walletjournal')->with('journal', $journal);
|
||||
}
|
||||
@@ -221,41 +220,37 @@ class AdminController extends Controller
|
||||
$permissions[$p->permission] = $p->permission;
|
||||
}
|
||||
|
||||
$roles = AvailableUserRole::all();
|
||||
|
||||
$role = $user->getRole();
|
||||
|
||||
//Pass the user information to the page for hidden text entries
|
||||
return view('admin.user.modify')->with('user', $user)
|
||||
->with('permissions', $permissions)
|
||||
->with('role', $role)
|
||||
->with('roles', $roles);
|
||||
->with('permissions', $permissions);
|
||||
}
|
||||
|
||||
public function modifyRole(Request $request) {
|
||||
$this->validate($request, [
|
||||
'user' => 'required',
|
||||
'role' => 'required|role!=None',
|
||||
]);
|
||||
public function modifyUser(Request $request) {
|
||||
$type = $request->type;
|
||||
if(isset($request->permission)) {
|
||||
$permission = $request->permission;
|
||||
}
|
||||
if(isset($request->user)) {
|
||||
$user = $request->user;
|
||||
}
|
||||
|
||||
UserRole::where(['character_id' => $user])->update([
|
||||
'role' => $request->role,
|
||||
]);
|
||||
|
||||
return redirect('/admin/dashboard/users')->with('success', "User: " . $user . " has been modified to a new role: " . $request->role . ".");
|
||||
return redirect('/admin/dashboard/users')->with('error', 'Not Implemented Yet.');
|
||||
}
|
||||
|
||||
public function addPermission(Request $request) {
|
||||
//Get the user and permission from the form
|
||||
$character = $request->user;
|
||||
$user = $request->user;
|
||||
$permission = $request->permission;
|
||||
|
||||
//Get the character id from the username using the user table
|
||||
$character = User::where(['name' => $user])->get(['character_id']);
|
||||
|
||||
//Check to see if the character already has the permission
|
||||
$check = UserPermission::where(['character_id' => $character, 'permission' => $permission])->get(['permission']);
|
||||
$check = UserPermission::where(['character_id' => $character[0]->character_id, 'permission' => $permission])->get(['permission']);
|
||||
|
||||
if(!isset($check[0]->permission)) {
|
||||
$perm = new UserPermission;
|
||||
$perm->character_id = $character;
|
||||
$perm->character_id = $character[0]->character_id;
|
||||
$perm->permission = $permission;
|
||||
$perm->save();
|
||||
|
||||
@@ -400,14 +395,9 @@ class AdminController extends Controller
|
||||
}
|
||||
|
||||
//Add the user to the wiki group
|
||||
$results = $wikiHelper->AddUserToGroup($request->user, $request->groupname);
|
||||
$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.');
|
||||
}
|
||||
return redirect('/admin/dashboard/wiki')->with('success', 'User added to group for the wiki.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,45 +465,19 @@ class AdminController extends Controller
|
||||
$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.
|
||||
$count = User::where(['name' => $user])->count();
|
||||
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);
|
||||
if(!$wikiHelper->AllowedUser($user)) {
|
||||
$wikiHelper->DeleteWikiUser($user);
|
||||
}
|
||||
} else {
|
||||
$wikiHelper->DeleteWikiUser($user);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,66 +42,18 @@ class AdminDashboardController extends Controller
|
||||
}
|
||||
|
||||
//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 alliance income for a graph
|
||||
$pi = $tHelper->GetPIGross($dates['start'], $dates['end']);
|
||||
$industry = $tHelper->GetIndustryGross($dates['start'], $dates['end']);
|
||||
$reprocessing = $tHelper->GetReprocessingGross($dates['start'], $dates['end']);
|
||||
$office = $tHelper->GetOfficeGross($dates['start'], $dates['end']);
|
||||
$market = $tHelper->GetAllianceMarketGross($dates['start'], $dates['end']);
|
||||
$gate = $tHelper->GetJumpGateGross($dates['start'], $dates['end']);
|
||||
$sovBills = array();
|
||||
$pi = array();
|
||||
$industry = array();
|
||||
$reprocessing = array();
|
||||
$office = array();
|
||||
$sprActual = array();
|
||||
$srpLoss = array();
|
||||
|
||||
//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
|
||||
//This will be a pi-chart
|
||||
|
||||
$iChart = $lava->DataTable();
|
||||
$iChart->addStringColumn('Categories')
|
||||
->addNumberColumn('ISK')
|
||||
->addRow(['pi', $pi])
|
||||
->addRow(['industry', $industry])
|
||||
->addRow(['reprocessing', $reprocessing])
|
||||
->addRow(['offices', $office])
|
||||
->addRow(['market', $market])
|
||||
->addRow(['gate', $gate]);
|
||||
|
||||
$lava->PieChart('Alliance Income', $iChart, [
|
||||
'title' => 'Alliance Income',
|
||||
'is3D' => true,
|
||||
]);
|
||||
|
||||
|
||||
//Setup the chart to be able to show the categories for expenses
|
||||
//This will be a pi-chart
|
||||
/*
|
||||
$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')->with('lava', $lava);
|
||||
return view('admin.dashboards.dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Finances;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AdminWarpedBondsController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Admin');
|
||||
$this->middleware('permission:admin.bonds');
|
||||
}
|
||||
|
||||
public function DisplayNewBondForm() {
|
||||
|
||||
}
|
||||
|
||||
public function StoreNewBond() {
|
||||
|
||||
}
|
||||
|
||||
public function DeleteBond() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Finances;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WarpedBondsController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function DisplayAvailableBonds() {
|
||||
|
||||
}
|
||||
|
||||
public function StoreBonds() {
|
||||
|
||||
}
|
||||
|
||||
public function RedeemBonds() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -120,29 +120,14 @@ class FlexAdminController extends Controller
|
||||
'structure_type' => 'required',
|
||||
]);
|
||||
|
||||
$count = FlexStructure::where([
|
||||
FlexStructure::where([
|
||||
'requestor_id' => $request->requestor_id,
|
||||
'requestor_corp_id' => $request->requestor_corp_id,
|
||||
'system_id' => $request->system_id,
|
||||
'system' => $request->system_id,
|
||||
'structure_type' => $request->structure_type,
|
||||
])->count();
|
||||
])->delete();
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return redirect('/flex/display')->with('success', 'Flex Structure Entry Removed.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,12 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
class StructureRequestAdminController extends Controller
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace App\Http\Controllers\Logistics;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
@@ -16,6 +15,7 @@ use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\Logistics\AnchorStructure;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
class StructureRequestController extends Controller
|
||||
@@ -63,7 +63,7 @@ class StructureRequestController extends Controller
|
||||
])->get();
|
||||
|
||||
//Set the mail delay
|
||||
$delay = 30;
|
||||
$delay = 5;
|
||||
|
||||
foreach($fcTeam as $fc) {
|
||||
$body = "Structure Anchor Request has been entered.<br>";
|
||||
@@ -72,12 +72,17 @@ class StructureRequestController extends Controller
|
||||
$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));
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = "New Structure Anchor Request";
|
||||
$mail->body = $body;
|
||||
$mail->recipient = (int)$fc->character_id;
|
||||
$mail->recipient_type = 'character';
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay($delay);
|
||||
|
||||
$delay += 30;
|
||||
$delay += 15;
|
||||
}
|
||||
|
||||
return redirect('/dashboard')->with('success', 'Structure request successfully submitted.');
|
||||
return redirect('/structures/display/requests');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,15 @@ use App\Library\Lookups\LookupHelper;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Lookups\ItemLookup;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\MoonRent\MoonRental;
|
||||
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() {
|
||||
|
||||
$this->middleware('permission:corp.lead');
|
||||
}
|
||||
|
||||
public function displayMoonLedger() {
|
||||
@@ -130,7 +125,7 @@ class MoonLedgerController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return view('moons.ledger.displayledger')->with('miningLedgers', $miningLedgers)
|
||||
return view('moons.ledger.corpmoons')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
}
|
||||
|
||||
@@ -233,7 +228,7 @@ class MoonLedgerController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return view('moons.ledger.rentalledger')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
return view('moons.ledger.corpmoons')->with('miningLedgers', $miningLedgers)
|
||||
->with('structures', $structures);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
@@ -15,9 +14,10 @@ use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\MoonRent\MoonRental;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
//Library
|
||||
use App\Library\Moons\MoonCalc;
|
||||
@@ -29,25 +29,6 @@ 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
|
||||
*/
|
||||
@@ -149,251 +130,122 @@ class MoonsAdminController extends Controller
|
||||
}
|
||||
|
||||
//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));
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = 'Warped Intentions Moon Request';
|
||||
$mail->body = $body;
|
||||
$mail->recipient = (int)$moon->requestor_id;
|
||||
$mail->recipient_type = 'character';
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail');
|
||||
|
||||
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
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$lookupHelper = new LookupHelper;
|
||||
$moonCalc = new MoonCalc;
|
||||
$contactId = null;
|
||||
$contactType = null;
|
||||
$paid = null;
|
||||
$paidUntil = null;
|
||||
$corpTicker = null;
|
||||
$contact = '';
|
||||
$paid = '';
|
||||
$rentalEnd = '';
|
||||
$renter = '';
|
||||
$ticker = '';
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//Get all of the moons from the database
|
||||
$moons = RentalMoon::orderBy('System', 'asc')->get();
|
||||
//Declare the html variable and set it to null
|
||||
$table = array();
|
||||
//Setup the carbon date using Carbon\Carbon
|
||||
//Set carbon dates as needed
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
|
||||
//Get the moon rentals from the database
|
||||
$rentalMoons = AllianceRentalMoon::orderBy('system', 'asc')->get();
|
||||
foreach($moons as $moon) {
|
||||
//Get the rental data for the moon
|
||||
$count = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->count();
|
||||
|
||||
//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
|
||||
//Check if their is a current rental for a moon going on
|
||||
if($count == 0) {
|
||||
//If we don't find a rental record, mark the moon as not paid
|
||||
$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
|
||||
//If we don't find a rental record, set the rental date as last month
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Setup the paid until as last month to show it's free
|
||||
//If we don't find a rental record, set the paid until date as last month
|
||||
$paidUntilTemp = $lastMonth;
|
||||
$paidUntil = $lastMonth->format('m-d');
|
||||
$paidUntil = $paidUntilTemp->format('m-d');
|
||||
|
||||
//Setup the other variables with the correct information
|
||||
//Set the contact info
|
||||
$contact = 'None';
|
||||
|
||||
//Set the renter info
|
||||
$renter = 'None';
|
||||
|
||||
//Set the ticker info
|
||||
$ticker = 'N/A';
|
||||
|
||||
//Set the type info as it's needed
|
||||
$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';
|
||||
//Get the rental data for the moon
|
||||
$rental = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
|
||||
//If we find a rental record, mark the moon as whether it's paid or not
|
||||
$paid = $rental->Paid;
|
||||
$paidUntil = new Carbon($rental->Paid_Until);
|
||||
$paidUntil = $paidUntil->format('m-d');
|
||||
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($rental->RentalEnd);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the contact name
|
||||
$contact = $lookupHelper->CharacterIdToName($rental->Contact);
|
||||
|
||||
//Set up the renter whether it's a corporation in W4RP or another alliance
|
||||
$ticker = $rental->RentalCorp;
|
||||
$type = $rental->Type;
|
||||
}
|
||||
|
||||
//Set the color for the table
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-success';
|
||||
} else {
|
||||
$color = 'table-danger';
|
||||
}
|
||||
|
||||
//Calculate hte price of the moon based on what is in the moon
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity, $moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//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,
|
||||
'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
|
||||
'StructureName' => $moon->StructureName,
|
||||
'AlliancePrice' => $price['alliance'],
|
||||
'OutOfAlliancePrice' => $price['outofalliance'],
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
'Paid' => $moon->paid,
|
||||
'Paid' => $paid,
|
||||
'PaidUntil' => $paidUntil,
|
||||
'Contact' => $contact,
|
||||
'Type' => $moon->rental_type,
|
||||
'Renter' => $type,
|
||||
'Type' => $type,
|
||||
'Renter' => $ticker,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -401,195 +253,289 @@ class MoonsAdminController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to store the updates from the moons.
|
||||
* New function based on new table. Will update
|
||||
* the description in a future update
|
||||
* Function to remove a renter from a moon
|
||||
*/
|
||||
public function storeUpdateMoon(Request $request) {
|
||||
//Require the site administration role
|
||||
public function storeMoonRemoval(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some variables we will need
|
||||
$this->validate($request, [
|
||||
'remove' => 'required',
|
||||
]);
|
||||
|
||||
$str_array = explode(" - ", $request->remove);
|
||||
|
||||
//Decode the value for the SPM into a system, planet, and moon for the database to update
|
||||
$system = $str_array[0];
|
||||
$planet = $str_array[1];
|
||||
$moon = $str_array[2];
|
||||
|
||||
$found = MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->count();
|
||||
|
||||
if($found != 0) {
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->delete();
|
||||
|
||||
return redirect('/moons/admin/display/rentals')->with('success', 'Renter removed.');
|
||||
}
|
||||
|
||||
//Redirect back to the moon page, which should call the page to be displayed correctly
|
||||
return redirect('/moons/admin/display/rentals')->with('error', 'Something went wrong.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function displays the ability for admins to update moons with who is renting, and when it ends.
|
||||
*/
|
||||
public function updateMoon() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some variables
|
||||
$system = null;
|
||||
$planet = null;
|
||||
$moon = null;
|
||||
$name = null;
|
||||
$spmnTemp = array();
|
||||
$spmn = array();
|
||||
|
||||
//Get the moons and put in order by System, Planet, then Moon number
|
||||
$moons = RentalMoon::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->StructureName;
|
||||
array_push($spmnTemp, $temp);
|
||||
}
|
||||
|
||||
//From our temporary array with all the values in a numbered key, create the real array with the value being the key
|
||||
foreach($spmnTemp as $key => $value) {
|
||||
$spmn[$value] = $value;
|
||||
}
|
||||
|
||||
//Return the view and the form from the blade display
|
||||
//Pass the data to the view as well
|
||||
return view('moons.admin.updatemoon')->with('spmn', $spmn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the updated moon
|
||||
*/
|
||||
public function storeUpdateMoon(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some static variables as needed
|
||||
$moonCalc = new MoonCalc;
|
||||
$lookup = new LookupHelper;
|
||||
$paid = false;
|
||||
$system = null;
|
||||
$planet = null;
|
||||
$mn = null;
|
||||
$name = 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
|
||||
//Decode the System, Planet, Moon, Name combinatio sent from the controller
|
||||
$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
|
||||
//Take the contact name and create a character_id from it
|
||||
if($request->contact == 'None') {
|
||||
$contact = -1;
|
||||
} else {
|
||||
$contact = $lookup->CharacterNameToId($request->contact);
|
||||
}
|
||||
|
||||
//After we get the contact, from his name to the character Id, let's do some other functions before continuing.
|
||||
//Let's find the corporation and alliance information to ascertain whethery they are in Warped Intentions or another Legacy Alliance
|
||||
$char = $lookup->GetCharacterInfo($contact);
|
||||
//Takes the corp id and looks up the corporation info
|
||||
$corp = $lookup->GetCorporationInfo($char->corporation_id);
|
||||
$alliance = $lookup->GetAllianceInfo($corp->alliance_id);
|
||||
$allianceId = $corp->alliance_id;
|
||||
|
||||
//Update the paid value for database entry
|
||||
if($request->paid == 'Yes') {
|
||||
$paid = 'Yes';
|
||||
} else {
|
||||
$paid = 'No';
|
||||
}
|
||||
|
||||
//Create the rnetal ticker if the corp is in Warped Intentions, otherwise just display the alliance ticker
|
||||
if($allianceId == 99004116) {
|
||||
$renter = $corp->ticker;
|
||||
} else {
|
||||
$renter = $alliance->ticker;
|
||||
}
|
||||
|
||||
//Setup the rental end and paid until variables
|
||||
$rentalEnd = $request->rental_end . " 23:59:59";
|
||||
$paidUntil = $request->paid_until . " 23:59:59";
|
||||
//Create the paid until date
|
||||
if(isset($request->paid_until)) {
|
||||
$paidUntil = new Carbon($request->paid_until . '00:00:01');
|
||||
} else {
|
||||
$paidUntil = Carbon::now();
|
||||
}
|
||||
|
||||
//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);
|
||||
//Create the rental end date
|
||||
if(isset($request->rental_end)) {
|
||||
$rentalEnd = new Carbon($request->rental_end . '23:59:59');
|
||||
} else {
|
||||
$rentalEnd = Carbon::now();
|
||||
}
|
||||
|
||||
if($corp->alliance_id == 99004116) {
|
||||
$type = 'In Alliance';
|
||||
//Calculate the price of the moon for when it's updated
|
||||
$moon = RentalMoon::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
])->first();
|
||||
|
||||
//Calculate the price of the rental and store it in the database
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//Count how many rentals we find for later database processing
|
||||
$count = MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'Contact' => $contact,
|
||||
])->count();
|
||||
|
||||
//If the database entry isn't found, then insert it into the database,
|
||||
//otherwise, account for it being in the system already.
|
||||
//Also check for the weird condition of more than one moon entry existing
|
||||
if($count > 1) {
|
||||
//If more than one entry is found for a particular system, planet, moon combo, then delete all the entries, and put in
|
||||
// a single new entry
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->delete();
|
||||
|
||||
if($allianceId == 99004116) {
|
||||
$store = new MoonRental;
|
||||
$store->System = $system;
|
||||
$store->Planet = $planet;
|
||||
$store->Moon = $mn;
|
||||
$store->RentalCorp = $renter;
|
||||
$store->RentalEnd = $rentalEnd;
|
||||
$store->Contact = $contact;
|
||||
$store->Price = $price['alliance'];
|
||||
$store->Type = 'alliance';
|
||||
$store->Paid = $paid;
|
||||
$store->Paid_Until = $paidUntil;
|
||||
$store->save();
|
||||
} else {
|
||||
$type = 'Out of Alliance';
|
||||
$store = new MoonRental;
|
||||
$store->System = $system;
|
||||
$store->Planet = $planet;
|
||||
$store->Moon = $mn;
|
||||
$store->RentalCorp = $renter;
|
||||
$store->RentalEnd = $rentalEnd;
|
||||
$store->Contact = $contact;
|
||||
$store->Price = $price['outofalliance'];
|
||||
$store->Type = 'outofalliance';
|
||||
$store->Paid = $paid;
|
||||
$store->Paid_Until = $paidUntil;
|
||||
$store->save();
|
||||
}
|
||||
|
||||
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 if($count == 1) {
|
||||
if($allianceId = 99004116) {
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'Contact' => $contact,
|
||||
])->update([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'RentalCorp' => $renter,
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['alliance'],
|
||||
'Type' => 'alliance',
|
||||
'Paid' => $paid,
|
||||
'Paid_Until' => $paidUntil,
|
||||
]);
|
||||
} else {
|
||||
$type = 'Out of Alliance';
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'Contact' => $contact,
|
||||
])->update([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $mn,
|
||||
'RentalCorp' => $renter,
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'Contact' => $contact,
|
||||
'Price' => $price['outofalliance'],
|
||||
'Type' => 'outofalliance',
|
||||
'Paid' => $paid,
|
||||
'Paid_Until' => $paidUntil,
|
||||
]);
|
||||
}
|
||||
|
||||
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));
|
||||
} else {
|
||||
//If the entry is not found, then attempt to delete whatever existing data is there, then
|
||||
//insert the new data
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->delete();
|
||||
|
||||
if($allianceId == 99004116) {
|
||||
$store = new MoonRental;
|
||||
$store->System = $system;
|
||||
$store->Planet = $planet;
|
||||
$store->Moon = $mn;
|
||||
$store->RentalCorp = $renter;
|
||||
$store->RentalEnd = $rentalEnd;
|
||||
$store->Contact = $contact;
|
||||
$store->Price = $price['alliance'];
|
||||
$store->Type = 'alliance';
|
||||
$store->Paid = $paid;
|
||||
$store->Paid_Until = $paidUntil;
|
||||
$store->save();
|
||||
} else {
|
||||
$store = new MoonRental;
|
||||
$store->System = $system;
|
||||
$store->Planet = $planet;
|
||||
$store->Moon = $mn;
|
||||
$store->RentalCorp = $renter;
|
||||
$store->RentalEnd = $rentalEnd;
|
||||
$store->Contact = $contact;
|
||||
$store->Price = $price['outofalliance'];
|
||||
$store->Type = 'outofalliance';
|
||||
$store->Paid = $paid;
|
||||
$store->Paid_Until = $paidUntil;
|
||||
$store->save();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
//Redirect to the update moon page
|
||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Updated');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,19 +12,17 @@ use Carbon\Carbon;
|
||||
//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\MoonRent\MoonRental;
|
||||
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() {
|
||||
@@ -32,10 +30,6 @@ class MoonsController extends Controller
|
||||
$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
|
||||
*/
|
||||
@@ -156,7 +150,6 @@ class MoonsController extends Controller
|
||||
'Z-H2MA',
|
||||
'B-KDOZ',
|
||||
'E8-YS9',
|
||||
'DY-P7Q',
|
||||
];
|
||||
|
||||
//Declare lookup variables
|
||||
@@ -183,6 +176,20 @@ class MoonsController extends Controller
|
||||
return redirct('/moons/display/request')->with('error', 'Region was not found.');
|
||||
}
|
||||
|
||||
/* Not working correctly with certain systems
|
||||
//Check to see if the moon is not available
|
||||
$future = AllianceMoon::where([
|
||||
'Region' => (string)$region,
|
||||
'System' => (string)$request->system,
|
||||
'Planet' => (string)$request->planet,
|
||||
'Moon' => (string)$request->moon,
|
||||
])->first();
|
||||
|
||||
if($future->Availability != 'Available') {
|
||||
return redirect('/moons/display/request')->with('error', 'The moon has already been reserved by another party.');
|
||||
}
|
||||
*/
|
||||
|
||||
//Check to see if the moon has been previously inputted for
|
||||
$allMoons = AllianceMoon::all();
|
||||
foreach($allMoons as $moon) {
|
||||
@@ -219,96 +226,87 @@ class MoonsController extends Controller
|
||||
'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.
|
||||
* Function to display the moons and pass data to the blade template
|
||||
*/
|
||||
public function displayRentalMoons() {
|
||||
//Declare variables
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
$table = array();
|
||||
$moonprice = null;
|
||||
$rentalEnd = '';
|
||||
|
||||
//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
|
||||
$type = Auth::user()->getUserType();
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//get all of the rental moons from the database
|
||||
$moons = DB::table('RentalMoons')->orderBy('System', 'asc')->get();
|
||||
//Set the rental date as last month for moons not rented
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
//Set a variable for today's date
|
||||
$today = Carbon::now();
|
||||
|
||||
//declare the html variable and set it to null
|
||||
|
||||
$table = array();
|
||||
$moonprice = null;
|
||||
foreach($moons as $moon) {
|
||||
$color = null;
|
||||
$rentalTemp = null;
|
||||
$rentalEnd = null;
|
||||
//get the rental data for the moon
|
||||
$rental = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
|
||||
//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
|
||||
if($rental == false) {
|
||||
//If we don't find a rental record, set the rental date as last month
|
||||
$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;
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($rental->RentalEnd);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
}
|
||||
|
||||
//Add the data to the html array to be passed to the view
|
||||
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
$worth = $moonCalc->SpatialMoonsTotalWorth($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
if($type == 'W4RP') {
|
||||
$moonprice = $price['alliance'];
|
||||
} else {
|
||||
$moonprice = $price['outofalliance'];
|
||||
}
|
||||
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-primary';
|
||||
} else {
|
||||
$color = 'table-danger';
|
||||
}
|
||||
|
||||
//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,
|
||||
'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, ".", ","),
|
||||
'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
|
||||
'StructureName' => $moon->StructureName,
|
||||
'FirstOre' => $moon->FirstOre,
|
||||
'FirstQuantity' => $moon->FirstQuantity,
|
||||
'SecondOre' => $moon->SecondOre,
|
||||
'SecondQuantity' => $moon->SecondQuantity,
|
||||
'ThirdOre' => $moon->ThirdOre,
|
||||
'ThirdQuantity' => $moon->ThirdQuantity,
|
||||
'FourthOre' => $moon->FourthOre,
|
||||
'FourthQuantity' => $moon->FourthQuantity,
|
||||
'Price' => $moonprice,
|
||||
'Worth' => number_format($worth, "2", ".", ","),
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
//Pass the data to the view
|
||||
return view('moons.user.moon')->with('table', $table);
|
||||
}
|
||||
|
||||
@@ -333,10 +331,6 @@ class MoonsController extends Controller
|
||||
'Hydrocarbons' => 0,
|
||||
'Silicates' => 0,
|
||||
'Cobalt' => 0,
|
||||
'Scandium' => 0,
|
||||
'Titanium' => 0,
|
||||
'Tungsten' => 0,
|
||||
'Cadmium' => 0,
|
||||
'Platinum' => 0,
|
||||
'Vanadium'=> 0,
|
||||
'Chromium' => 0,
|
||||
@@ -389,14 +383,11 @@ class MoonsController extends Controller
|
||||
$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 moon goo value
|
||||
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
$thirdOre, $thirdQuantity, $fourthOre, $fourthQuantity);
|
||||
//Format the number to send to the blade
|
||||
$totalGoo = number_format($totalGoo, 2, ".", ",");
|
||||
|
||||
//Calculate the total worth of the moon
|
||||
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity, $secondOre, $secondQuantity,
|
||||
@@ -427,10 +418,6 @@ class MoonsController extends Controller
|
||||
$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);
|
||||
@@ -466,10 +453,6 @@ class MoonsController extends Controller
|
||||
$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);
|
||||
@@ -505,10 +488,6 @@ class MoonsController extends Controller
|
||||
$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);
|
||||
@@ -544,10 +523,6 @@ class MoonsController extends Controller
|
||||
$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);
|
||||
@@ -562,6 +537,7 @@ class MoonsController extends Controller
|
||||
}
|
||||
|
||||
return view('moons.user.displayTotalWorth')->with('totalWorth', $totalWorth)
|
||||
->with('totalGoo', $totalGoo)
|
||||
->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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -85,13 +85,8 @@ class SRPAdminController extends Controller
|
||||
//Calculate the recommended srp amount
|
||||
foreach($payouts as $p) {
|
||||
if($r['ship_type'] == $p->code) {
|
||||
$payout = $p->payout;
|
||||
if($temp['character_name'] == $temp['fleet_commander_name']) {
|
||||
$payout = 100.00;
|
||||
}
|
||||
|
||||
$temp['actual_srp'] = $r['loss_value'] * ($payout / 100.00 );
|
||||
$temp['payout_percentage'] = $payout;
|
||||
$temp['actual_srp'] = $r['loss_value'] * ($p->payout / 100.00 );
|
||||
$temp['payout_percentage'] = $p->payout;
|
||||
$sum_actual += $temp['actual_srp'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
}
|
||||
148
app/Http/Controllers/Wormholes/WormholeController.php
Normal file
148
app/Http/Controllers/Wormholes/WormholeController.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wormholes;
|
||||
|
||||
//Laravel Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//User Libraries
|
||||
|
||||
//Models
|
||||
use App\Models\Wormholes\AllianceWormhole;
|
||||
use App\Models\Wormholes\WormholeType;
|
||||
|
||||
class WormholeController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displayWormholeForm() {
|
||||
//Declare a few array variables
|
||||
$duration = array();
|
||||
$class = array();
|
||||
$stability = array();
|
||||
$size = array();
|
||||
|
||||
//Get the duration from the table
|
||||
$duration = [
|
||||
'This wormhole has not yet begun its natural cycle of decay and should last at least another day.',
|
||||
'This wormhole is beginning to decay, but will not last another day.',
|
||||
'This wormhole is reaching the end of its natural lifetime',
|
||||
];
|
||||
|
||||
//Get the wh classes from the table
|
||||
$class = [
|
||||
'C1',
|
||||
'C2',
|
||||
'C3',
|
||||
'C4',
|
||||
'C5',
|
||||
'C6',
|
||||
'C7',
|
||||
'C8',
|
||||
'C9',
|
||||
'C13',
|
||||
'Drifter',
|
||||
'Thera',
|
||||
'Exit WH',
|
||||
];
|
||||
|
||||
//Get the wh types from the table
|
||||
$type = WormholeType::groupBy('type')->pluck('type');
|
||||
|
||||
//Get the wh sizes from the table
|
||||
$size = [
|
||||
'XS',
|
||||
'S',
|
||||
'M',
|
||||
'L',
|
||||
'XL',
|
||||
];
|
||||
|
||||
//Get the wh stabilities from the table
|
||||
$stability = [
|
||||
'Stable',
|
||||
'Non-Critical',
|
||||
'Critical',
|
||||
];
|
||||
|
||||
//Return all the variables to the view
|
||||
return view('wormholes.form')->with('class', $class)
|
||||
->with('type', $type)
|
||||
->with('size', $size)
|
||||
->with('stability', $stability)
|
||||
->with('duration', $duration);
|
||||
}
|
||||
|
||||
public function storeWormhole() {
|
||||
$this->validate($request, [
|
||||
'sig' => 'required',
|
||||
'duration' => 'required',
|
||||
'dateTiume' => 'required',
|
||||
'class' => 'required',
|
||||
'size' => 'required',
|
||||
'stability' => 'required',
|
||||
'system' => 'required',
|
||||
]);
|
||||
|
||||
//Declare some variables
|
||||
$duration = null;
|
||||
|
||||
//Create the stable time for the database
|
||||
if($request->duration == 'This wormhole has not yet begun its natural cycle of decay and should last at least another day.') {
|
||||
$duration = '>24 hours';
|
||||
} else if ($request->duration == 'This wormhole is beginning to decay, but will not last another day.') {
|
||||
$duration = '>4 hours <24 hours';
|
||||
} else if($request->duration == 'This wormhole is reaching the end of its natural lifetime') {
|
||||
'<4 hours';
|
||||
}
|
||||
|
||||
//Get the wormhole type from the database so we can enter other details
|
||||
$wormholeType = WormholeType::where([
|
||||
'type' => $request->type,
|
||||
])->first();
|
||||
|
||||
$found = AllianceWormhole::where([
|
||||
'system' => $request->system,
|
||||
'sig_ig' => $request->sig,
|
||||
])->count();
|
||||
|
||||
if($found == 0) {
|
||||
AllianceWormhole::insert([
|
||||
'system' => $request->system,
|
||||
'sig_id' => $request->sig_id,
|
||||
'duration_left' => $duration,
|
||||
'dateTime' => $request->dateTime,
|
||||
'class' => $request->class,
|
||||
'type' => $request->class,
|
||||
'hole_size' => $request->size,
|
||||
'stability' => $request->stability,
|
||||
'details' => $request->details,
|
||||
'link' => $request->link,
|
||||
'mass_allowed' => $wormholeType->mass_allowed,
|
||||
'individual_mass' => $wormholeType->individual_mass,
|
||||
'regeneration' => $wormholeType->regeneration,
|
||||
'max_stable_time' => $wormholeType->max_stable_time,
|
||||
]);
|
||||
|
||||
return redirect('/wormholes/display')->with('success', 'Wormhole Info Added.');
|
||||
} else {
|
||||
return redirect('/wormholes/display')->with('error', 'Wormhole already in database.');
|
||||
}
|
||||
}
|
||||
|
||||
public function displayWormholes() {
|
||||
//Create the date and time
|
||||
$dateTime = Carbon::now()->subDays(2);
|
||||
|
||||
//Get all of the wormholes from the last 48 hours from the database to display
|
||||
$wormholes = AllianceWormhole::where('created_at', '>=', $dateTime)->get();
|
||||
|
||||
return view('wormholes.display')->with('wormholes', $wormholes);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ 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,
|
||||
'callback' => \App\Http\Middleware\Callback::class,
|
||||
'role' => \App\Http\Middleware\RequireRole::class,
|
||||
'permission' => \App\Http\Middleware\RequirePermission::class,
|
||||
];
|
||||
|
||||
@@ -2,120 +2,29 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
//Internal Library
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Socialite;
|
||||
use DB;
|
||||
use App\Models\User\User;
|
||||
|
||||
//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.
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $ssoUser)
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ class TrimStrings extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Eve;
|
||||
|
||||
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;
|
||||
|
||||
class ItemPricesUpdateJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$moonHelper = new MoonCalc;
|
||||
|
||||
$moonHelper->FetchNewPrices();
|
||||
}
|
||||
}
|
||||
@@ -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\NotUsed;
|
||||
|
||||
//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\NotUsed;
|
||||
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\SupplyChain;
|
||||
|
||||
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\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
class EndSupplyChainContractJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 1200;
|
||||
|
||||
/**
|
||||
* Retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $retries = 3;
|
||||
|
||||
/**
|
||||
* Private Variables
|
||||
*/
|
||||
private $contractId;
|
||||
private $issuerId;
|
||||
private $issuerName;
|
||||
private $title;
|
||||
private $endDate;
|
||||
private $deliveryBy;
|
||||
private $body;
|
||||
private $state;
|
||||
private $finalCost;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(SupplyChainContract $contract)
|
||||
{
|
||||
//Set the queue connection up
|
||||
$this->connection = 'redis';
|
||||
|
||||
//Set the variables
|
||||
$contractId = $contract->contract_id;
|
||||
$issuerId = $contract->issuer_id;
|
||||
$issuerName = $contract->issuer_name;
|
||||
$title = $contract->title;
|
||||
$endDate = $contract->end_date;
|
||||
$deliveryBy = $contract->delivery_by;
|
||||
$body = $contract->body;
|
||||
$state = $contract->state;
|
||||
$finalCost = $contract->final_cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$bidId = null;
|
||||
$bidAmount = null;
|
||||
|
||||
//Get all of the bids from the contract
|
||||
$bids = SupplyChainBids::where([
|
||||
'contract_id' => $contractId,
|
||||
])->get();
|
||||
|
||||
//Loop through the bids and find the lowest bid
|
||||
foreach($bids as $bid) {
|
||||
if($bidId == null) {
|
||||
$bidId = $bid->id;
|
||||
$bidAmount = $bid->bid_amount;
|
||||
} else {
|
||||
if($bid->bid_amount < $bidAmount) {
|
||||
$bidId = $bid->id;
|
||||
$bidAmount = $bid->bid_amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Clean up the bids and update the contract with the winning bid
|
||||
SupplyChainContract::where([
|
||||
'contract_id' => $this->contractId,
|
||||
])->update([
|
||||
'final_cost' => $bidAmount,
|
||||
'winning_bid_id' => $bidId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
//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 Log;
|
||||
use DB;
|
||||
|
||||
//App Library
|
||||
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\Jobs\Library\JobHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Finances\AllianceBond;
|
||||
use App\Models\Finances\Bondee;
|
||||
|
||||
class ProcessAllianceBond implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessAsset;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
|
||||
@@ -57,11 +58,11 @@ class ProcessAssetsJob implements ShouldQueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $page)
|
||||
public function __construct(JobProcessAsset $jpa)
|
||||
{
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->page = $page;
|
||||
$this->charId = $jpa->charId;
|
||||
$this->corpId = $jpa->corpId;
|
||||
$this->page = $jpa->page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
@@ -9,7 +9,6 @@ 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;
|
||||
@@ -22,6 +21,7 @@ use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Mail\SentMail;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
class ProcessSendEveMailJob implements ShouldQueue
|
||||
{
|
||||
@@ -52,12 +52,12 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($body, $recipient, $recipient_type, $subject, $sender) {
|
||||
$this->body = $body;
|
||||
$this->recipient = $recipient;
|
||||
$this->recipient_type = $recipient_type;
|
||||
$this->subject = $subject;
|
||||
$this->sender = $sender;
|
||||
public function __construct(JobSendEveMail $mail) {
|
||||
$this->body = $mail->body;
|
||||
$this->recipient = $mail->recipient;
|
||||
$this->recipient_type = $mail->recipient_type;
|
||||
$this->subject = $mail->subject;
|
||||
$this->sender = $mail->sender;
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
@@ -84,6 +84,10 @@ class ProcessSendEveMailJob implements ShouldQueue
|
||||
//Create the ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Attemp to send the mail
|
||||
try {
|
||||
$esi->setBody([
|
||||
|
||||
@@ -13,6 +13,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessStructure;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessStructureJob implements ShouldQueue
|
||||
@@ -43,11 +44,11 @@ class ProcessStructureJob implements ShouldQueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $page)
|
||||
public function __construct(JobProcessStructure $jps)
|
||||
{
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->page = $page;
|
||||
$this->charId = $jps->charId;
|
||||
$this->corpId = $jps->corpId;
|
||||
$this->page = $jps->page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
@@ -40,10 +40,10 @@ class ProcessWalletJournalJob implements ShouldQueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($division, $charId, $page) {
|
||||
$this->division = $division;
|
||||
$this->charId = $charId;
|
||||
$this->page = $page;
|
||||
public function __construct(JobProcessWalletJournal $pwj) {
|
||||
$this->division = $pwj->division;
|
||||
$this->charId = $pwj->charId;
|
||||
$this->page = $pwj->page;
|
||||
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use App\Jobs\Library\JobHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
//Models
|
||||
use App\Models\Jobs\JobProcessAsset;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use Carbon\Carbon;
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
@@ -40,10 +41,14 @@ class Esi {
|
||||
$check = EsiScope::where(['character_id' => $charId, 'scope' => $scope])->count();
|
||||
if($check == 0) {
|
||||
//Compose a mail to send to the user if the scope is not found
|
||||
$subject = 'W4RP Services - Incorrect ESI Scope';
|
||||
$body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||
$mail = new JobSendEveMail;
|
||||
$mail->sender = $config['primary'];
|
||||
$mail->subject = 'W4RP Services - Incorrect ESI Scope';
|
||||
$mail->body = "Please register on https://services.w4rp.space with the scope: " . $scope;
|
||||
$mail->recipient = (int)$charId;
|
||||
$mail->recipient_type = 'character';
|
||||
|
||||
ProcessSendEveMailJob::dispatch($body, (int)$charId, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(5));
|
||||
ProcessSendEveMailJob::dispatch($mail)->onQueue('mail')->delay(5);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ namespace App\Library\Finances\Helper;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Job
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
|
||||
@@ -105,27 +105,6 @@ class LookupHelper {
|
||||
$newItem->save();
|
||||
}
|
||||
|
||||
public function SystemIdToName($systemId) {
|
||||
//Check if the solar system is stored in our database first
|
||||
$solarSystem = $this->LookupSolarSystemId($systemId);
|
||||
|
||||
if($solarSystem != null) {
|
||||
return $solarSystem->name;
|
||||
} else {
|
||||
try {
|
||||
$solar = $this->esi->invoke('get', '/universe/systems/{system_id}/', [
|
||||
'system_id' => $systemId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get system id from /universe/systems in Lookup Helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->StoreSolarSystem($solar);
|
||||
|
||||
return $solar->name;
|
||||
}
|
||||
}
|
||||
|
||||
public function SystemNameToId($system) {
|
||||
//Check if the solar system is stored in our own database first
|
||||
@@ -153,14 +132,6 @@ class LookupHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private function LookupSolarSystemId($systemId) {
|
||||
$solar = SolarSystem::where([
|
||||
'solar_system_id' => $systemId,
|
||||
])->first();
|
||||
|
||||
return $solar;
|
||||
}
|
||||
|
||||
private function LookupSolarSystem($system) {
|
||||
$solar = SolarSystem::where([
|
||||
'name' => $system,
|
||||
@@ -170,22 +141,10 @@ class LookupHelper {
|
||||
}
|
||||
|
||||
private function StoreSolarSystem($system) {
|
||||
if(isset($system->id)) {
|
||||
SolarSystem::insertOrIgnore([
|
||||
'name' => $system->name,
|
||||
'solar_system_id' => $system->id,
|
||||
]);
|
||||
} else if(isset($system->system_id)) {
|
||||
SolarSystem::insertOrIgnore([
|
||||
'name' => $system->name,
|
||||
'solar_system_id' => $system->system_id,
|
||||
]);
|
||||
} else {
|
||||
$solar = new SolarSystem;
|
||||
$solar->name = $system->name;
|
||||
$solar->solar_system_id = $system->id;
|
||||
$solar->save();
|
||||
}
|
||||
$solar = new SolarSystem;
|
||||
$solar->name = $system->name;
|
||||
$solar->solar_system_id = $system->id;
|
||||
$solar->save();
|
||||
}
|
||||
|
||||
public function GetCharacterInfo($charId) {
|
||||
|
||||
73
app/Library/Mail/Helper/EveMailHelper.php
Normal file
73
app/Library/Mail/Helper/EveMailHelper.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*/
|
||||
|
||||
namespace App\Library\Mail\Helper;
|
||||
|
||||
//Internal Library
|
||||
use Log;
|
||||
|
||||
//Job
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
|
||||
//Library
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
|
||||
class EveMailHelper {
|
||||
|
||||
public function SendEveMail($sender, $subject, $body, $recipient, $rType) {
|
||||
//Get the esi config from the environment file
|
||||
$config = config('esi');
|
||||
|
||||
//Declare the ESI Helper
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the correct scope
|
||||
if(!$esiHelper->HaveEsiScope($sender, 'esi-mail.send_mail.v1')) {
|
||||
Log::critical('Could not find correct scope for the token for the mailer.');
|
||||
return null;
|
||||
}
|
||||
|
||||
//Retrieve token from from the database for the sender
|
||||
$token = $esiHelper->GetRefreshToken($sender);
|
||||
|
||||
//Create the ESI authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Set caching to null
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
//Attempt to send the mail
|
||||
try {
|
||||
$esi->setBody([
|
||||
'approved_cost' => 100,
|
||||
'body' => $this->body,
|
||||
'recipients' => [[
|
||||
'recipient_id' => $this->recipient,
|
||||
'recipient_type' => $this->recipient_type,
|
||||
]],
|
||||
'subject' => $this->subject,
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id'=> $this->sender,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning($e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -52,7 +52,7 @@ class MiningLedgerHelper {
|
||||
//Check if the character has the correct ESI Scope. If the character doesn't, then return false, but
|
||||
//also send a notice eve mail to the user. The HaveEsiScope sends a mail for us.
|
||||
if(!$esiHelper->HaveEsiScope($this->charId, 'esi-industry.read_corporation_mining.v1')) {
|
||||
Log::warning('Character: ' . $this->charId . ' did not have the appropriate esi scope for the mining ledger.');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ use DB;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Client;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Moon\Config;
|
||||
@@ -21,14 +20,8 @@ use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\MineralPrice;
|
||||
|
||||
/**
|
||||
* MoonCalc Library
|
||||
*/
|
||||
class MoonCalc {
|
||||
|
||||
/**
|
||||
* Get the ore composition of an ore
|
||||
*/
|
||||
public function GetOreComposition($ore) {
|
||||
$composition = ItemComposition::where([
|
||||
'Name' => $ore,
|
||||
@@ -37,12 +30,10 @@ class MoonCalc {
|
||||
return $composition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the total worth of a moon
|
||||
*/
|
||||
public function SpatialMoonsTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Declare variables
|
||||
$totalPriceMined = 0.00;
|
||||
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
@@ -51,29 +42,38 @@ class MoonCalc {
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the prices from the ores
|
||||
if($firstOre != 'None') {
|
||||
$totalPriceMined += $this->CalcMoonPrice($firstOre, $firstPerc);
|
||||
}
|
||||
if($secondOre != 'None') {
|
||||
$totalPriceMined += $this->CalcMoonPrice($secondOre, $secondPerc);
|
||||
}
|
||||
if($thirdOre != 'None') {
|
||||
$totalPriceMined += $this->CalcMoonPrice($thirdOre, $thirdPerc);
|
||||
}
|
||||
if($fourthOre != 'None') {
|
||||
$totalPriceMined += $this->CalcMoonPrice($fourthOre, $fourthPerc);
|
||||
}
|
||||
$this->CalculateTotalPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $totalPriceMined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the rental price
|
||||
*/
|
||||
public function SpatialMoons($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Declare variables
|
||||
$totalPrice = 0.00;
|
||||
public function SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
|
||||
//Convert the quantities into numbers we want to utilize
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the price of each ore
|
||||
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $totalPriceMined;
|
||||
}
|
||||
|
||||
public function SpatialMoonsOnlyGooMailer($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
@@ -81,31 +81,76 @@ class MoonCalc {
|
||||
//Convert the quantities into numbers we want to utilize
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the prices from the ores
|
||||
if($firstOre != 'None') {
|
||||
$totalPrice += $this->CalcRentalPrice($firstOre, $firstPerc);
|
||||
}
|
||||
if($secondOre != 'None') {
|
||||
$totalPrice += $this->CalcRentalPrice($secondOre, $secondPerc);
|
||||
}
|
||||
if($thirdOre != 'None') {
|
||||
$totalPrice += $this->CalcRentalPrice($thirdOre, $thirdPerc);
|
||||
}
|
||||
if($fourthOre != 'None') {
|
||||
$totalPrice += $this->CalcRentalPrice($fourthOre, $fourthPerc);
|
||||
}
|
||||
//Calculate the price of each ore
|
||||
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
|
||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||
$rentalPrice['alliance'] = $totalPrice * ($config[0]->RentalTax / 100.00);
|
||||
$rentalPrice['outofalliance'] = $totalPrice * ($config[0]->AllyRentalTax / 100.00);
|
||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $rentalPrice;
|
||||
}
|
||||
|
||||
public function SpatialMoonsOnlyGoo($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
|
||||
//Convert the quantities into numbers we want to utilize
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the price of each ore
|
||||
$this->CalculateOnlyGooPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
|
||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
||||
|
||||
//Format the rental price to the appropriate number
|
||||
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
|
||||
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $rentalPrice;
|
||||
}
|
||||
|
||||
public function SpatialMoons($firstOre, $firstQuan, $secondOre, $secondQuan, $thirdOre, $thirdQuan, $fourthOre, $fourthQuan) {
|
||||
//Get the total moon pull in m3
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Get the configuration for pricing calculations
|
||||
$config = DB::table('Config')->get();
|
||||
|
||||
//Convert the quantities into numbers we want to utilize
|
||||
$this->ConvertPercentages($firstPerc, $firstQuan, $secondPerc, $secondQuan, $thirdPerc, $thirdQuan, $fourthPerc, $fourthQuan);
|
||||
|
||||
//Calculate the prices from the ores
|
||||
$this->CalculateTotalPrices($firstOre, $firstPerc, $firstTotal, $secondOre, $secondPerc, $secondTotal, $thirdOre, $thirdPerc, $thirdTotal, $fourthOre, $fourthPerc, $fourthTotal);
|
||||
|
||||
//Calculate the total to price to be mined in one month
|
||||
$totalPriceMined = $firstTotal + $secondTotal + $thirdTotal + $fourthTotal;
|
||||
|
||||
//Calculate the rental price. Refined rate is already included in the price from rental composition
|
||||
$rentalPrice['alliance'] = $totalPriceMined * ($config[0]->RentalTax / 100.00);
|
||||
$rentalPrice['outofalliance'] = $totalPriceMined * ($config[0]->AllyRentalTax / 100.00);
|
||||
|
||||
//Format the rental price to the appropriate number
|
||||
$rentalPrice['alliance'] = number_format($rentalPrice['alliance'], 0, ".", ",");
|
||||
$rentalPrice['outofalliance'] = number_format($rentalPrice['outofalliance'], 0, ".", ",");
|
||||
|
||||
//Return the rental price to the caller
|
||||
return $rentalPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch new prices for items from the market
|
||||
*/
|
||||
public function FetchNewPrices() {
|
||||
//Create the item id array which we will pull data for from Fuzzwork market api
|
||||
$ItemIDs = array(
|
||||
@@ -178,34 +223,6 @@ class MoonCalc {
|
||||
$this->UpdateItemPricing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the ore units
|
||||
*/
|
||||
public function CalcOreUnits($ore, $percentage) {
|
||||
//Specify the total pull amount
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 *30.00);
|
||||
|
||||
//Find the size of the asteroid from the database
|
||||
$item = ItemComposition::where([
|
||||
'Name' => $ore,
|
||||
])->first();
|
||||
|
||||
//Get the m3 size from the item composition
|
||||
$m3Size = $item->m3Size;
|
||||
|
||||
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
||||
$actualm3 = floor($totalPull * $percentage);
|
||||
|
||||
//Calculate the units from the m3 pulled from the moon
|
||||
$units = floor($actualm3 / $m3Size);
|
||||
|
||||
//Return the calculated data
|
||||
return $units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update item pricing after new prices were pulled
|
||||
*/
|
||||
private function UpdateItemPricing() {
|
||||
//Get the configuration from the config table
|
||||
$config = DB::table('Config')->first();
|
||||
@@ -219,42 +236,42 @@ class MoonCalc {
|
||||
$pastTime = Carbon::now()->subDays(30);
|
||||
|
||||
//Get the price of the basic minerals
|
||||
$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');
|
||||
$morphitePrice = MineralPrice::where(['ItemId' => 11399])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$heliumIsotopesPrice = MineralPrice::where(['ItemId' => 16274])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$nitrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17888])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$oxygenIsotopesPrice = MineralPrice::where(['ItemId' => 17887])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$hydrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17889])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$liquidOzonePrice = MineralPrice::where(['ItemId' => 16273])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$heavyWaterPrice = MineralPrice::where(['ItemId' => 16272])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$strontiumClathratesPrice = MineralPrice::where(['ItemId' => 16275])->where('Time', '>', $pastTime)->avg('Price');
|
||||
$tritaniumPrice = MineralPrice::where(['ItemId' => 34])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$pyeritePrice = MineralPrice::where(['ItemId' => 35])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$mexallonPrice = MineralPrice::where(['ItemId' => 36])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$isogenPrice = MineralPrice::where(['ItemId' => 37])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$nocxiumPrice = MineralPrice::where(['ItemId' => 38])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$zydrinePrice = MineralPrice::where(['ItemId' => 39])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$megacytePrice = MineralPrice::where(['ItemId' => 40])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$morphitePrice = MineralPrice::where(['ItemId' => 11399])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$heliumIsotopesPrice = MineralPrice::where(['ItemId' => 16274])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$nitrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17888])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$oxygenIsotopesPrice = MineralPrice::where(['ItemId' => 17887])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$hydrogenIsotopesPrice = MineralPrice::where(['ItemId' => 17889])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$liquidOzonePrice = MineralPrice::where(['ItemId' => 16273])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$heavyWaterPrice = MineralPrice::where(['ItemId' => 16272])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$strontiumClathratesPrice = MineralPrice::where(['ItemId' => 16275])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
//Get the price of the moongoo
|
||||
$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');
|
||||
$atmosphericGasesPrice = MineralPrice::where(['ItemId' => 16634])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$evaporiteDepositsPirce = MineralPrice::where(['ItemId' => 16635])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$hydrocarbonsPrice = MineralPrice::where(['ItemId' => 16633])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$silicatesPrice = MineralPrice::where(['ItemId' => 16636])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$cobaltPrice = MineralPrice::where(['ItemId' => 16640])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$scandiumPrice = MineralPrice::where(['ItemId' => 16639])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$titaniumPrice = MineralPrice::where(['ItemId' => 16638])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$tungstenPrice = MineralPrice::where(['ItemId' => 16637])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$cadmiumPrice = MineralPrice::where(['ItemId' => 16643])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$platinumPrice = MineralPrice::where(['ItemId' => 16644])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$vanadiumPrice = MineralPrice::where(['ItemId' => 16642])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$chromiumPrice = MineralPrice::where(['ItemId' => 16641])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$technetiumPrice = MineralPrice::where(['ItemId' => 16649])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$hafniumPrice = MineralPrice::where(['ItemId' => 16648])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$caesiumPrice = MineralPrice::where(['ItemId' => 16647])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$mercuryPrice = MineralPrice::where(['ItemId' => 16646])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$dysprosiumPrice = MineralPrice::where(['ItemId' => 16650])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$neodymiumPrice = MineralPrice::where(['ItemId' => 16651])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$promethiumPrice = MineralPrice::where(['ItemId' => 16652])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
$thuliumPrice = MineralPrice::where(['ItemId' => 16653])->whereDate('Time', '>', $pastTime)->avg('Price');
|
||||
|
||||
//Get the item compositions
|
||||
$items = DB::select('SELECT Name,ItemId FROM ItemComposition');
|
||||
@@ -333,34 +350,43 @@ class MoonCalc {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the total amount pulled from a moon
|
||||
*/
|
||||
public function CalcOreUnits($ore, $percentage) {
|
||||
//Specify the total pull amount
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 *30.00);
|
||||
|
||||
//Find the size of the asteroid from the database
|
||||
$item = ItemComposition::where([
|
||||
'Name' => $ore,
|
||||
])->first();
|
||||
|
||||
//Get the m3 size from the item composition
|
||||
$m3Size = $item->m3Size;
|
||||
|
||||
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
||||
$actualm3 = floor($totalPull * $percentage);
|
||||
|
||||
//Calculate the units from the m3 pulled from the moon
|
||||
$units = floor($actualm3 / $m3Size);
|
||||
|
||||
//Return the calculated data
|
||||
return $units;
|
||||
}
|
||||
|
||||
private function CalculateTotalMoonPull() {
|
||||
//Always assume a 1 month pull which equates to 5.55m3 per second or 2,592,000 seconds
|
||||
//Total pull size is 14,385,600 m3
|
||||
$totalPull = 5.55 * 3600.00 * 24.00 *30.00;
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 *30.00);
|
||||
|
||||
//Return the total pull
|
||||
return $totalPull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the rental price of a moon ore from the moon
|
||||
*/
|
||||
private function CalcRentalPrice($ore, $percentage) {
|
||||
private function CalcPrice($ore, $percentage) {
|
||||
//Specify the total pull amount
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Setup the total value at 0.00
|
||||
$totalPrice = 0.00;
|
||||
|
||||
//Check to see what type of moon goo the moon is
|
||||
$gasMoonOre = $this->IsGasMoonGoo($ore);
|
||||
$totalPull = 5.55 * (3600.00 * 24.00 * 30.00);
|
||||
|
||||
//Find the size of the asteroid from the database
|
||||
$m3Size = DB::table('ItemComposition')->where('Name', $ore)->value('m3Size');
|
||||
|
||||
|
||||
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
||||
$actualm3 = floor($percentage * $totalPull);
|
||||
|
||||
@@ -369,79 +395,19 @@ class MoonCalc {
|
||||
|
||||
//Look up the unit price from the database
|
||||
$unitPrice = DB::table('ore_prices')->where('Name', $ore)->value('UnitPrice');
|
||||
|
||||
//If the ore is a gas ore, then take only 50% of the price.
|
||||
if($gasMoonOre == true) {
|
||||
$totalPrice = $units * ($unitPrice / 2.00);
|
||||
Log::warning('Found gas ore: ' . $totalPrice);
|
||||
} else {
|
||||
$totalPrice = $units * $unitPrice;
|
||||
}
|
||||
|
||||
//Return the total
|
||||
return $totalPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the moon's total price
|
||||
*/
|
||||
private function CalcMoonPrice($ore, $percentage) {
|
||||
//Specify the total pull amount
|
||||
$totalPull = $this->CalculateTotalMoonPull();
|
||||
|
||||
//Setup the total value at 0.00
|
||||
$totalPrice = 0.00;
|
||||
|
||||
//Find the size of the asteroid from the database
|
||||
$m3Size = DB::table('ItemComposition')->where('Name', $ore)->value('m3Size');
|
||||
|
||||
//Calculate the actual m3 from the total pull amount in m3 using the percentage of the ingredient
|
||||
$actualm3 = floor($percentage * $totalPull);
|
||||
|
||||
//Calculate the units once we have the size and actual m3 value
|
||||
$units = floor($actualm3 / $m3Size);
|
||||
//Calculate the total amount from the units and unit price
|
||||
$total = $units * $unitPrice;
|
||||
|
||||
//Look up the unit price from the database
|
||||
$unitPrice = DB::table('ore_prices')->where('Name', $ore)->value('UnitPrice');
|
||||
|
||||
//Calculate the total amount from the units and the unit price.
|
||||
$totalPrice = $units * $unitPrice;
|
||||
|
||||
//Return the value
|
||||
return $totalPrice;
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a number to a percentage
|
||||
*/
|
||||
private function ConvertToPercentage($quantity) {
|
||||
//Perform the calculation and return the data
|
||||
return $quantity / 100.00;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if a type of ore is a gas moon goo
|
||||
*/
|
||||
private function IsGasMoonGoo($ore) {
|
||||
$ores = [
|
||||
'Zeolites' => 'Gas',
|
||||
'Sylvite' => 'Gas',
|
||||
'Bitumens' => 'Gas',
|
||||
'Coesite' => 'Gas',
|
||||
];
|
||||
|
||||
foreach($ores as $key => $value) {
|
||||
if(strtolower($key) == strtolower($ore)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of ore a particular moon ore is.
|
||||
*/
|
||||
private function IsRMoonGoo($ore) {
|
||||
$ores = [
|
||||
'Zeolites' => 'Gas',
|
||||
@@ -466,44 +432,6 @@ class MoonCalc {
|
||||
'Ytterbite' => 'R64',
|
||||
];
|
||||
|
||||
foreach($ores as $key => $value) {
|
||||
if(strtolower($key) == strtolower($ore)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
//Return false if the ore is not found in an array
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if a moon ore is a moon ore, and false
|
||||
* if the ore is not a moon ore.
|
||||
*/
|
||||
private function IsRMoonOre($ore) {
|
||||
$ores = [
|
||||
'Zeolites' => 'Gas',
|
||||
'Sylvite' => 'Gas',
|
||||
'Bitumens' => 'Gas',
|
||||
'Coesite' => 'Gas',
|
||||
'Cobaltite' => 'R8',
|
||||
'Euxenite' => 'R8',
|
||||
'Titanite' => 'R8',
|
||||
'Scheelite' => 'R8',
|
||||
'Otavite' => 'R16',
|
||||
'Sperrylite' => 'R16',
|
||||
'Vanadinite' => 'R16',
|
||||
'Chromite' => 'R16',
|
||||
'Carnotite' => 'R32',
|
||||
'Zircon' => 'R32',
|
||||
'Pollucite' => 'R32',
|
||||
'Cinnabar' => 'R32',
|
||||
'Xenotime' => 'R64',
|
||||
'Monazite' => 'R64',
|
||||
'Loparite' => 'R64',
|
||||
'Ytterbite' => 'R64',
|
||||
];
|
||||
|
||||
foreach($ores as $key => $value) {
|
||||
|
||||
if(strtolower($key) == strtolower($ore)) {
|
||||
@@ -514,9 +442,44 @@ class MoonCalc {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert percentages from quantities into a normalized percentage
|
||||
*/
|
||||
private function IsRMoon($ore) {
|
||||
$ores = [
|
||||
'Prime Arkonor' => 'Null',
|
||||
'Cubic Bistot' => 'Null',
|
||||
'Pellucid Crokite' => 'Null',
|
||||
'Jet Ochre' => 'Null',
|
||||
'Zeolites' => 'Gas',
|
||||
'Sylvite' => 'Gas',
|
||||
'Bitumens' => 'Gas',
|
||||
'Coesite' => 'Gas',
|
||||
'Cobaltite' => 'R8',
|
||||
'Euxenite' => 'R8',
|
||||
'Titanite' => 'R8',
|
||||
'Scheelite' => 'R8',
|
||||
'Otavite' => 'R16',
|
||||
'Sperrylite' => 'R16',
|
||||
'Vanadinite' => 'R16',
|
||||
'Chromite' => 'R16',
|
||||
'Carnotite' => 'R32',
|
||||
'Zircon' => 'R32',
|
||||
'Pollucite' => 'R32',
|
||||
'Cinnabar' => 'R32',
|
||||
'Xenotime' => 'R64',
|
||||
'Monazite' => 'R64',
|
||||
'Loparite' => 'R64',
|
||||
'Ytterbite' => 'R64',
|
||||
];
|
||||
|
||||
foreach($ores as $key => $value) {
|
||||
|
||||
if(strtolower($key) == strtolower($ore)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function ConvertPercentages(&$firstPerc, $firstQuan, &$secondPerc, $secondQuan, &$thirdPerc, $thirdQuan, &$fourthPerc, $fourthQuan) {
|
||||
//Set the base percentages for the if statements
|
||||
$firstPerc = 0.00;
|
||||
@@ -576,4 +539,68 @@ class MoonCalc {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function CalculateTotalPrices($firstOre, $firstPerc, &$firstTotal, $secondOre, $secondPerc, &$secondTotal, $thirdOre, $thirdPerc, &$thirdTotal, $fourthOre, $fourthPerc, &$fourthTotal) {
|
||||
//Calculate the prices from the ores
|
||||
if($firstOre != "None") {
|
||||
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
||||
} else {
|
||||
$firstTotal = 0.00;
|
||||
}
|
||||
if($secondOre != "None") {
|
||||
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
||||
} else {
|
||||
$secondTotal = 0.00;
|
||||
}
|
||||
if($thirdOre != "None") {
|
||||
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
||||
} else {
|
||||
$thirdTotal = 0.00;
|
||||
}
|
||||
if($fourthOre != "None") {
|
||||
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
||||
} else {
|
||||
$fourthTotal = 0.00;
|
||||
}
|
||||
}
|
||||
|
||||
private function CalculateOnlyGooPrices($firstOre, $firstPerc, &$firstTotal, $secondOre, $secondPerc, &$secondTotal, $thirdOre, $thirdPerc, &$thirdTotal, $fourthOre, $fourthPerc, &$fourthTotal) {
|
||||
//Calculate the price of each ore
|
||||
if($firstOre != "None") {
|
||||
if($this->IsRMoonGoo($firstOre)) {
|
||||
$firstTotal = $this->CalcPrice($firstOre, $firstPerc);
|
||||
} else {
|
||||
$firstTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$firstTotal = 0.00;
|
||||
}
|
||||
if($secondOre != "None") {
|
||||
if($this->IsRMoonGoo($secondOre)) {
|
||||
$secondTotal = $this->CalcPrice($secondOre, $secondPerc);
|
||||
} else {
|
||||
$secondTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$secondTotal = 0.00;
|
||||
}
|
||||
if($thirdOre != "None") {
|
||||
if($this->IsRMoonGoo($thirdOre)) {
|
||||
$thirdTotal = $this->CalcPrice($thirdOre, $thirdPerc);
|
||||
} else {
|
||||
$thirdTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$thirdTotal = 0.00;
|
||||
}
|
||||
if($fourthOre != "None") {
|
||||
if($this->IsRMoonGoo($fourthOre)) {
|
||||
$fourthTotal = $this->CalcPrice($fourthOre, $fourthPerc);
|
||||
} else {
|
||||
$fourthTotal = 0.00;
|
||||
}
|
||||
} else {
|
||||
$fourthTotal = 0.00;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -13,6 +13,10 @@ use App\Models\SRP\SrpShipType;
|
||||
|
||||
class SRPHelper {
|
||||
|
||||
public function __contruct() {
|
||||
//
|
||||
}
|
||||
|
||||
public function GetAllianceSRPActual($start, $end) {
|
||||
$actual = 0.00;
|
||||
|
||||
@@ -35,6 +39,75 @@ class SRPHelper {
|
||||
return $loss;
|
||||
}
|
||||
|
||||
public function GetLossesByFC($start, $end) {
|
||||
$losses = array();
|
||||
$fcs = null;
|
||||
|
||||
$fcs = SRPShip::whereBetween('created_at', [$start, $end])
|
||||
->pluck('fleet_commander_name')
|
||||
->toArray();
|
||||
|
||||
foreach($fcs as $fc) {
|
||||
$tempLosses = SRPShip::where(['fleet_commander_name' => $fc])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum('loss_value');
|
||||
|
||||
$losses[$fc] = $tempLosses;
|
||||
}
|
||||
|
||||
return $losses;
|
||||
}
|
||||
|
||||
public function GetUnderReview($start, $end) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Under Review'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum('loss_value');
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetApprovedValue($start, $end) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Approved'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum('paid_value');
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetApproved($start, $end, $type) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Approved'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum($type);
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetDeniedValue($start, $end) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Denied'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
->sum('paid_value');
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetDenied($start, $end, $type) {
|
||||
$requests = 0.00;
|
||||
|
||||
$requests = SRPShip::where(['approved' => 'Denied'])
|
||||
->whereBetween('created_at', [$start, $end])
|
||||
-sum($type);
|
||||
|
||||
return $requests;
|
||||
}
|
||||
|
||||
public function GetTimeFrame($months) {
|
||||
$start = Carbon::now()->startOfMonth();
|
||||
$start->hour = 23;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
/**
|
||||
* W4RP Services
|
||||
* GNU Public License
|
||||
*
|
||||
* Finally works in it's current state. Need to move to a job process.
|
||||
*/
|
||||
|
||||
namespace App\Library\Structures;
|
||||
@@ -14,9 +16,9 @@ use Log;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobProcessStructure;
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
@@ -29,28 +31,24 @@ class StructureHelper {
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
private $esi;
|
||||
|
||||
public function __construct($char, $corp, $esi = null) {
|
||||
public function __construct($char, $corp) {
|
||||
$this->charId = $char;
|
||||
$this->corpId = $corp;
|
||||
$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);
|
||||
}
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Create the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Try to get the ESI data
|
||||
try {
|
||||
$structures = $this->esi->page($page)
|
||||
$structures = $esi->page($page)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
@@ -69,7 +67,7 @@ class StructureHelper {
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Setup the esi authentication container
|
||||
$this->esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Get the structure information
|
||||
$info = $this->GetStructureInfo($structure->structure_id);
|
||||
@@ -81,42 +79,45 @@ class StructureHelper {
|
||||
} else {
|
||||
$this->UpdateExistingStructure($structure, $info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function GetSolarSystemName($systemId) {
|
||||
//Declare some variables
|
||||
$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);
|
||||
//Get the refresh token
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
$solar = $lookup->SystemIdToName($systemId);
|
||||
|
||||
if($solar != null) {
|
||||
return $solar;
|
||||
return $solar->name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetStructureInfo($structureId) {
|
||||
private function GetStructureInfo($structureId) {
|
||||
//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);
|
||||
}
|
||||
//Get the refresh token
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Setup the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$info = $this->esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
$info = $esi->invoke('get', '/universe/structures/{structure_id}/', [
|
||||
'structure_id' => $structureId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
|
||||
@@ -44,11 +44,7 @@ class WikiHelper {
|
||||
|
||||
//Set the alliance id
|
||||
$corp = $lookup->GetCorporationInfo($corpId);
|
||||
if(isset($corp->alliance_id)) {
|
||||
$allianceId = $corp->alliance_id;
|
||||
} else {
|
||||
$allianceId = 0;
|
||||
}
|
||||
$allianceId = $corp->alliance_id;
|
||||
|
||||
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
|
||||
$purge = false;
|
||||
@@ -67,7 +63,8 @@ class WikiHelper {
|
||||
$groups = DokuGroupNames::all();
|
||||
|
||||
//Check if the user already belongs to the group
|
||||
if(DokuMember::where(['gid' => $groupId, 'uid' => $userId])->count() > 0) {
|
||||
$userGroups = DokuMember::where(['gid' => $groupId])->count();
|
||||
if($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;
|
||||
@@ -133,11 +130,15 @@ class WikiHelper {
|
||||
* 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,
|
||||
]);
|
||||
//Check if the user group already exists
|
||||
DokuGroupNames::where(['gname' => $groupName])->count();
|
||||
|
||||
if($count == 0) {
|
||||
DokuGroupNames::insert([
|
||||
'gname' => $groupName,
|
||||
'description' => $description,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,11 +153,4 @@ class WikiHelper {
|
||||
//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();
|
||||
}
|
||||
}
|
||||
30
app/Models/Contracts/AcceptedBid.php
Normal file
30
app/Models/Contracts/AcceptedBid.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AcceptedBid extends Model
|
||||
{
|
||||
// Table Name
|
||||
public $table = 'accepted_bids';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'contract_id',
|
||||
'bid_id',
|
||||
'bid_amount',
|
||||
'notes',
|
||||
];
|
||||
|
||||
public function Contract() {
|
||||
return $this->belongsTo(Contract::class);
|
||||
}
|
||||
}
|
||||
39
app/Models/Contracts/Bid.php
Normal file
39
app/Models/Contracts/Bid.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Bid extends Model
|
||||
{
|
||||
// Table Name
|
||||
public $table = 'contract_bids';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'contract_id',
|
||||
'bid_amount',
|
||||
'character_name',
|
||||
'character_id',
|
||||
'corporation_name',
|
||||
'corporation_id',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function ContractId() {
|
||||
return $this->hasOne('App\Models\Contracts\Contract', 'id', 'contract_id');
|
||||
}
|
||||
|
||||
public function Contract() {
|
||||
return $this->belongsTo(Contract::class);
|
||||
}
|
||||
}
|
||||
38
app/Models/Contracts/Contract.php
Normal file
38
app/Models/Contracts/Contract.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Contract extends Model
|
||||
{
|
||||
// Table Name
|
||||
public $table = 'contracts';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'type',
|
||||
'end_date',
|
||||
'body',
|
||||
'final_cost',
|
||||
'finished',
|
||||
];
|
||||
|
||||
//One-to-Many relationship for the bids on a contract
|
||||
public function Bids() {
|
||||
return $this->hasMany('App\Models\Contracts\Bid', 'contract_id', 'id');
|
||||
}
|
||||
|
||||
//One-to-One relationship for the accepted bid.
|
||||
public function AcceptedBid() {
|
||||
return $this->hasOne('App\Models\Contracts\AcceptedBid', 'contract_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupplyChainBid extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'supply_chain_bids';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'contract_id',
|
||||
'bid_amount',
|
||||
'entity_id',
|
||||
'entity_name',
|
||||
'entity_type',
|
||||
'bid_type',
|
||||
'bid_note',
|
||||
];
|
||||
|
||||
//Relationships
|
||||
public function ContractId() {
|
||||
return $this->hasOne('App\Models\Contracts\SupplyChainContract', 'contract_id', 'contract_id');
|
||||
}
|
||||
|
||||
public function Contract() {
|
||||
return $this->belongsTo(SupplyChainContract::class);
|
||||
}
|
||||
|
||||
//Model functions
|
||||
public function getContractId() {
|
||||
return $this->contract_id;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupplyChainContract extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'supply_chain_contracts';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'issuer_id',
|
||||
'issuer_name',
|
||||
'title',
|
||||
'end_date',
|
||||
'delivery_by',
|
||||
'body',
|
||||
'state',
|
||||
'final_cost',
|
||||
];
|
||||
|
||||
//Relationship
|
||||
public function Bids() {
|
||||
return $this->hasMany('App\Models\Contracts\SupplyChainBid', 'contract_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Eve;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EveRegion extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'eve_regions';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Variables which are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'region_id',
|
||||
'region_name',
|
||||
];
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceBond extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'alliance_bonds';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes which are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'full_bond_amount',
|
||||
'remaining_bond_amount',
|
||||
'bond_id',
|
||||
'character_id',
|
||||
];
|
||||
|
||||
public function bonders() {
|
||||
return $this->hasMany('App\Models\Finances\Bondee', 'character_id', 'character_id');
|
||||
}
|
||||
|
||||
public function getBondId() {
|
||||
return $this->bond_id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Finances;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Bondee extends Model
|
||||
{
|
||||
protected $table = 'alliance_bondees';
|
||||
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'character_name',
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'bond_id',
|
||||
];
|
||||
|
||||
public function allianceBond() {
|
||||
return $this->belongsTo(AllianceBond::class);
|
||||
}
|
||||
}
|
||||
20
app/Models/Jobs/JobProcessAsset.php
Normal file
20
app/Models/Jobs/JobProcessAsset.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Jobs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessAsset extends Model
|
||||
{
|
||||
//no table name is needed
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'charId',
|
||||
'corpId',
|
||||
'page',
|
||||
'esi',
|
||||
];
|
||||
}
|
||||
20
app/Models/Jobs/JobProcessCorpJournal.php
Normal file
20
app/Models/Jobs/JobProcessCorpJournal.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessCorpJournal extends Model
|
||||
{
|
||||
//No table name is needed
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'division',
|
||||
'charId',
|
||||
'corpId',
|
||||
'page',
|
||||
];
|
||||
}
|
||||
25
app/Models/Jobs/JobProcessStructure.php
Normal file
25
app/Models/Jobs/JobProcessStructure.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Jobs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessStructure extends Model
|
||||
{
|
||||
//Table Name - Not Needed for a Job
|
||||
//public $table = null;
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'charId',
|
||||
'corpId',
|
||||
'page',
|
||||
];
|
||||
}
|
||||
27
app/Models/Jobs/JobProcessWalletJournal.php
Normal file
27
app/Models/Jobs/JobProcessWalletJournal.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Jobs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobProcessWalletJournal extends Model
|
||||
{
|
||||
//Table Name
|
||||
//public $table = 'job_process_wallet_journal';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'charId',
|
||||
'division',
|
||||
'page',
|
||||
];
|
||||
}
|
||||
|
||||
?>
|
||||
19
app/Models/Jobs/JobSendEveMail.php
Normal file
19
app/Models/Jobs/JobSendEveMail.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Jobs;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class JobSendEveMail extends Model
|
||||
{
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'sender',
|
||||
'recipient',
|
||||
'recipient_type',
|
||||
'subject',
|
||||
'body',
|
||||
];
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Market;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MarketRegionOrder extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'market_region_orders';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* Items which are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'region_id',
|
||||
'duration',
|
||||
'is_buy_order',
|
||||
'issued',
|
||||
'location_id',
|
||||
'min_volume',
|
||||
'order_id',
|
||||
'price',
|
||||
'range',
|
||||
'system_id',
|
||||
'type_id',
|
||||
'volume_remain',
|
||||
'volume_total',
|
||||
];
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Moon;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorpMoonLedger extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'corp_moon_ledgers';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'character_id',
|
||||
'character_name',
|
||||
'observer_id',
|
||||
'observer_name',
|
||||
'type_id',
|
||||
'ore',
|
||||
'quantity',
|
||||
'recorded_corporation_id',
|
||||
'recorded_corporation_name',
|
||||
'last_updated',
|
||||
];
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Moon;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorpMoonObserver extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'corp_mining_observers';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* Attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'observer_id',
|
||||
'observer_name',
|
||||
'observer_type',
|
||||
'observer_owner_id',
|
||||
'solar_system_id',
|
||||
'observer_type_id',
|
||||
'last_updated',
|
||||
];
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Moon;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RentalMoonInvoice extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'alliance_moon_rental_invoices';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* Items which are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'character_name',
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'rental_moons',
|
||||
'invoice_amount',
|
||||
'due_date',
|
||||
'paid',
|
||||
];
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Moon;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RentalMoonLedger extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'alliance_rental_moon_ledgers';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'character_id',
|
||||
'character_name',
|
||||
'observer_id',
|
||||
'observer_name',
|
||||
'type_id',
|
||||
'ore',
|
||||
'quantity',
|
||||
'recorded_corporation_id',
|
||||
'recorded_corporation_name',
|
||||
'last_updated',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the observer this belongs to
|
||||
*/
|
||||
public function observer() {
|
||||
return $this->belongsTo('App\Models\Moon\RentalMoonObserver', 'observer_id', 'observer_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Moon;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RentalMoonObserver extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'alliance_mining_observers';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
'corporation_name',
|
||||
'observer_id',
|
||||
'observer_name',
|
||||
'observer_type',
|
||||
'last_updated',
|
||||
];
|
||||
|
||||
public function ledger() {
|
||||
return $this->hasMany('App\Models\Moon\RentalMoonLedger', 'observer_id', 'observer_id');
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user