migrations, and updates to Admin panel

This commit is contained in:
2018-12-12 19:45:20 -06:00
parent 2bd095d805
commit 181d5188d8
9 changed files with 157 additions and 111 deletions
@@ -15,7 +15,7 @@ use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
class GetLogisticContracts extends Command
class GetLogisticsContracts extends Command
{
/**
* The name and signature of the console command.
+1 -1
View File
@@ -20,7 +20,7 @@ use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
class sendMail extends Command
class SendMail extends Command
{
/**
* The name and signature of the console command.
+3 -3
View File
@@ -14,12 +14,12 @@ class Kernel extends ConsoleKernel
*/
protected $commands = [
Commands\CorpJournal::class,
Commands\getCorps::class,
Commands\sendMail::class,
Commands\GetCorps::class,
Commands\SendMail::class,
Commands\UpdateMoonPricing::class,
Commands\DumpFleets::class,
Commands\CalculateMarketTax::class,
Commands\GetLogisticsContracts::class,
//Commands\GetLogisticsContracts::class,
];
/**
+6 -1
View File
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\User;
use App\Models\User\UserRole;
use App\Models\User\UserPermission;
@@ -16,7 +17,11 @@ class AdminController extends Controller
}
public function displayDashboard() {
return view('admin.dashboard');
//Get the users from the database to allow a selection of users for
//adding and removing roles and permissions
$users = User::orderBy('name')->all('name');
return view('admin.dashboard')->with('users', $users);
}
public function addPermission(Request $request) {
@@ -23,32 +23,6 @@ class StructureController extends Controller
$this->middleware('permission:structure.operator');
}
public function displayTaxHistory() {
//Make the helper esi class
$helper = new Esi();
//Get the character's corporation from esi
$corpId = $helper->FindCorporationId(Auth::user()->character_id);
//Get the dates we are working with
$dates = $this->GetLongTimeFrame();
//Create the totalTaxes array
$totalTaxes = array();
//Create the array for totalTaxes in order to send in the data to the view
for($i = 0; $i < 12; $i++) {
$totalTaxes[$i] = [
'MarketTax' => number_format($this->GetTaxes($corpId, 'Market', $dates[$i]['start'], $dates[$i]['end']), 2, '.', ','),
'MarketRevenue' => number_format($this->GetRevenue($corpId, 'Market', $dates[$i]['start'], $dates[$i]['end']), 2, '.', ','),
'RefineryTax' => number_format($this->GetTaxes($corpId, 'Refinery', $dates[$i]['start'], $dates[$i]['end']), 2, '.', ','),
'RefineryRevenue' => number_format($this->GetRevenue($corpId, 'Refinery', $dates[$i]['start'], $dates[$i]['end']), 2, '.', ','),
'start' => $dates[$i]['start']->toFormattedDateString(),
];
}
return view('structures.taxhistory')->with('totalTaxes', $totalTaxes);
}
public function displayTaxes() {
//Make the helper esi class
$helper = new Esi();
@@ -158,32 +132,6 @@ class StructureController extends Controller
return $cost;
}
private function GetLongTimeFrame() {
$start = Carbon::now()->startOfMonth();
$end = Carbon::now()->endOfMonth();
$end->hour = 23;
$end->minute = 59;
$end->second = 59;
$dates = array();
$dates[0] = [
'start' => $start,
'end' => $end,
];
//Cycle through the for loop and build the array
for($i = 1; $i < 12; $i++) {
$start->subMonth();
$end->subMonth();
$dates[$i] = [
'start' => $start,
'end' => $end,
];
}
return $dates;
}
private function GetTimeFrame() {
$start = Carbon::now()->startOfMonth();
$end = Carbon::now()->endOfMonth();
+85 -41
View File
@@ -72,7 +72,10 @@ class FinanceHelper {
//The PutWalletJournal function checks to see if it's already in the database.
foreach($wallet as $entry) {
if($entry['amount'] > 0) {
if($entry['ref_type'] == 'brokers_fee' || $entry['ref_type'] == 'reprocessing_tax' || $entry['ref_type'] == 'jumpgate_fee') {
if($entry['ref_type'] == 'brokers_fee' ||
$entry['ref_type'] == 'reprocessing_tax' ||
$entry['ref_type'] == 'jumpgate_fee' ||
$entry['ref_type'] == 'player_donation') {
$this->PutWalletJournal($entry, $corpId, $division);
}
}
@@ -134,46 +137,87 @@ class FinanceHelper {
$esiHelper = new Esi;
$date = $esiHelper->DecodeDate($journal['date']);
$check = DB::table('CorpJournals')->where('id', $journal['id'])->get();
//if we don't find the journal entry, add the journal entry to the database
if($check->count() === 0) {
$entry = new CorpJournal;
$entry->id = $journal['id'];
$entry->corporation_id = $corpId;
$entry->division = $division;
if(isset($journal['amount'])) {
$entry->amount = $journal['amount'];
}
if(isset($journal['balance'])) {
$entry->balance = $journal['balance'];
}
if(isset($journal['context_id'])) {
$entry->context_id = $journal['context_id'];
}
if(isset($journal['context_id_type'])) {
$entry->context_id_type = $journal['context_id_type'];
}
$entry->date = $date;
$entry->description = $journal['description'];
if(isset($journal['first_party_id'])) {
$entry->first_party_id = $journal['first_party_id'];
}
if(isset($journal['reason'])) {
$entry->reason = $journal['reason'];
}
$entry->ref_type = $journal['ref_type'];
if(isset($journal['second_party_id'])) {
$entry->second_party_id = $journal['second_party_id'];
}
if(isset($journal['tax'])) {
$entry->tax = $journal['tax'];
}
if(isset($journal['tax_receiver_id'])) {
$entry->tax_receiver_id = $journal['tax_receiver_id'];
}
$entry->save();
}
if($journal['ref_type'] == 'player_donation') {
$check = DB::table('PlayerDonationJournals')->where('id', $journal['id'])->get();
//if we don't find the journal entry, add the journal entry to the database
if($check->count() === 0) {
$entry = new CorpJournal;
$entry->id = $journal['id'];
$entry->corporation_id = $corpId;
$entry->division = $division;
if(isset($journal['amount'])) {
$entry->amount = $journal['amount'];
}
if(isset($journal['balance'])) {
$entry->balance = $journal['balance'];
}
if(isset($journal['context_id'])) {
$entry->context_id = $journal['context_id'];
}
if(isset($journal['context_id_type'])) {
$entry->context_id_type = $journal['context_id_type'];
}
$entry->date = $date;
$entry->description = $journal['description'];
if(isset($journal['first_party_id'])) {
$entry->first_party_id = $journal['first_party_id'];
}
if(isset($journal['reason'])) {
$entry->reason = $journal['reason'];
}
$entry->ref_type = $journal['ref_type'];
if(isset($journal['second_party_id'])) {
$entry->second_party_id = $journal['second_party_id'];
}
if(isset($journal['tax'])) {
$entry->tax = $journal['tax'];
}
if(isset($journal['tax_receiver_id'])) {
$entry->tax_receiver_id = $journal['tax_receiver_id'];
}
$entry->save();
}
} else {
$check = DB::table('CorpJournals')->where('id', $journal['id'])->get();
//if we don't find the journal entry, add the journal entry to the database
if($check->count() === 0) {
$entry = new CorpJournal;
$entry->id = $journal['id'];
$entry->corporation_id = $corpId;
$entry->division = $division;
if(isset($journal['amount'])) {
$entry->amount = $journal['amount'];
}
if(isset($journal['balance'])) {
$entry->balance = $journal['balance'];
}
if(isset($journal['context_id'])) {
$entry->context_id = $journal['context_id'];
}
if(isset($journal['context_id_type'])) {
$entry->context_id_type = $journal['context_id_type'];
}
$entry->date = $date;
$entry->description = $journal['description'];
if(isset($journal['first_party_id'])) {
$entry->first_party_id = $journal['first_party_id'];
}
if(isset($journal['reason'])) {
$entry->reason = $journal['reason'];
}
$entry->ref_type = $journal['ref_type'];
if(isset($journal['second_party_id'])) {
$entry->second_party_id = $journal['second_party_id'];
}
if(isset($journal['tax'])) {
$entry->tax = $journal['tax'];
}
if(isset($journal['tax_receiver_id'])) {
$entry->tax_receiver_id = $journal['tax_receiver_id'];
}
$entry->save();
}
}
}
}
@@ -0,0 +1,47 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class PlayerDonationJournals extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(!Schema::hasTable('PlayerDonationJournals')) {
Schema::create('PlayerDonationJournals', function(Blueprint $table) {
$table->integer('id')->unique();
$table->integer('corporation_id')->nullabe();
$table->integer('division')->default(0);
$table->decimal('amount', 20, 2)->nullable();
$table->decimal('balance', 20, 2)->nullable();
$table->integer('context_id')->nullable();
$table->string('context_id_type')->nullable();
$table->dateTime('date')->nullabe();
$table->string('description')->nullabe();
$table->integer('first_party_id')->nullable();
$table->string('reason')->nullabe();
$table->string('ref_type')->nullabe();
$table->integer('second_party_id')->nullable();
$table->decimal('tax', 20, 2)->default(0.00);
$table->integer('tax_receiver_id')->nullable();
$table->timestamps();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('PlayerDonationJournals');
}
}
+7 -6
View File
@@ -6,13 +6,13 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'App\\Console\\Commands\\CorpJournal' => $baseDir . '/app/Console/Commands/corpJournal.php',
'App\\Console\\Commands\\DumpFleets' => $baseDir . '/app/Console/Commands/dumpFleets.php',
'App\\Console\\Commands\\GetCorps' => $baseDir . '/app/Console/Commands/getCorps.php',
'App\\Console\\Commands\\CalculateMarketTax' => $baseDir . '/app/Console/Commands/CalculateMarketTax.php',
'App\\Console\\Commands\\CorpJournal' => $baseDir . '/app/Console/Commands/CorpJournal.php',
'App\\Console\\Commands\\DumpFleets' => $baseDir . '/app/Console/Commands/DumpFleets.php',
'App\\Console\\Commands\\GetCorps' => $baseDir . '/app/Console/Commands/GetCorps.php',
'App\\Console\\Commands\\GetLogisticsContracts' => $baseDir . '/app/Console/Commands/GetLogisticContracts.php',
'App\\Console\\Commands\\SendMail' => $baseDir . '/app/Console/Commands/SendMail.php',
'App\\Console\\Commands\\UpdateMoonPricing' => $baseDir . '/app/Console/Commands/UpdateMoonPricing.php',
'App\\Console\\Commands\\calculatemarkettax' => $baseDir . '/app/Console/Commands/calculatemarkettax.php',
'App\\Console\\Commands\\getLogisticContracts' => $baseDir . '/app/Console/Commands/getLogisticContracts.php',
'App\\Console\\Commands\\sendMail' => $baseDir . '/app/Console/Commands/sendmail.php',
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\AdminController' => $baseDir . '/app/Http/Controllers/AdminController.php',
@@ -65,6 +65,7 @@ return array(
'App\\Models\\Fleet\\FleetActivity' => $baseDir . '/app/Models/Fleet/FleetActivity.php',
'App\\Models\\Logistics\\Contract' => $baseDir . '/app/Models/Logistics/Contract.php',
'App\\Models\\Market\\MarketOrder' => $baseDir . '/app/Models/Market/MarketOrder.php',
'App\\Models\\Market\\MonthlyMarketTax' => $baseDir . '/app/Models/Market/MonthlyMarketTax.php',
'App\\Models\\Moon\\ItemComposition' => $baseDir . '/app/Models/Moon/ItemComposition.php',
'App\\Models\\Moon\\Moon' => $baseDir . '/app/Models/Moon/Moon.php',
'App\\Models\\Moon\\OrePrice' => $baseDir . '/app/Models/Moon/OrePrice.php',
+7 -6
View File
@@ -401,13 +401,13 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
);
public static $classMap = array (
'App\\Console\\Commands\\CorpJournal' => __DIR__ . '/../..' . '/app/Console/Commands/corpJournal.php',
'App\\Console\\Commands\\DumpFleets' => __DIR__ . '/../..' . '/app/Console/Commands/dumpFleets.php',
'App\\Console\\Commands\\GetCorps' => __DIR__ . '/../..' . '/app/Console/Commands/getCorps.php',
'App\\Console\\Commands\\CalculateMarketTax' => __DIR__ . '/../..' . '/app/Console/Commands/CalculateMarketTax.php',
'App\\Console\\Commands\\CorpJournal' => __DIR__ . '/../..' . '/app/Console/Commands/CorpJournal.php',
'App\\Console\\Commands\\DumpFleets' => __DIR__ . '/../..' . '/app/Console/Commands/DumpFleets.php',
'App\\Console\\Commands\\GetCorps' => __DIR__ . '/../..' . '/app/Console/Commands/GetCorps.php',
'App\\Console\\Commands\\GetLogisticsContracts' => __DIR__ . '/../..' . '/app/Console/Commands/GetLogisticContracts.php',
'App\\Console\\Commands\\SendMail' => __DIR__ . '/../..' . '/app/Console/Commands/SendMail.php',
'App\\Console\\Commands\\UpdateMoonPricing' => __DIR__ . '/../..' . '/app/Console/Commands/UpdateMoonPricing.php',
'App\\Console\\Commands\\calculatemarkettax' => __DIR__ . '/../..' . '/app/Console/Commands/calculatemarkettax.php',
'App\\Console\\Commands\\getLogisticContracts' => __DIR__ . '/../..' . '/app/Console/Commands/getLogisticContracts.php',
'App\\Console\\Commands\\sendMail' => __DIR__ . '/../..' . '/app/Console/Commands/sendmail.php',
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\AdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/AdminController.php',
@@ -460,6 +460,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Models\\Fleet\\FleetActivity' => __DIR__ . '/../..' . '/app/Models/Fleet/FleetActivity.php',
'App\\Models\\Logistics\\Contract' => __DIR__ . '/../..' . '/app/Models/Logistics/Contract.php',
'App\\Models\\Market\\MarketOrder' => __DIR__ . '/../..' . '/app/Models/Market/MarketOrder.php',
'App\\Models\\Market\\MonthlyMarketTax' => __DIR__ . '/../..' . '/app/Models/Market/MonthlyMarketTax.php',
'App\\Models\\Moon\\ItemComposition' => __DIR__ . '/../..' . '/app/Models/Moon/ItemComposition.php',
'App\\Models\\Moon\\Moon' => __DIR__ . '/../..' . '/app/Models/Moon/Moon.php',
'App\\Models\\Moon\\OrePrice' => __DIR__ . '/../..' . '/app/Models/Moon/OrePrice.php',