This commit is contained in:
2021-05-24 22:12:37 +09:00
parent fbcd7dd957
commit 0107f24de8
3 changed files with 22 additions and 49 deletions

View File

@@ -36,6 +36,7 @@ class TestController extends Controller
public function DebugMiningTaxesInvoices() {
$lookup = new LookupHelper;
$ledgers = new Collection;
$perms = new Collection;
//Get all of the users in the database
@@ -44,59 +45,27 @@ class TestController extends Controller
//Get a list of the alts for each character, then process the ledgers and combine them to send one mail out
//in this first part
foreach($users as $char) {
$alts = $char->userAlts();
$altCount = $char->altCount();
if($altCount > 0) {
$alts = $char->userAlts();
$mainLedgers = Ledger::where([
'character_id' => $char->character_id,
'invoiced' => 'Yes',
])->get();
if(Ledger::where([
'character_id' => $char->character_id,
])->count() > 0) {
foreach($mainLedgers as $row) {
$ledgers->push([
'main_id' => $row->character_id,
'character_id' => $row->character_id,
'character_name' => $row->character_name,
'observer_id' => $row->observer_id,
'last_updated' => $row->last_updated,
'type_id' => $row->type_id,
'ore_name' => $row->ore_name,
'quantity' => $row->quantity,
'amount' => $row->amount,
'invoiced' => $row->invoiced,
'invoice_id' => $row->invoice_id,
foreach($alts as $alt) {
$perms->push([
'main_id' => $char->character_id,
'alt_id' => $alt->character_id,
'count' => $altCount,
]);
}
}
foreach($alts as $alt) {
if($alt->character_id != $char->character_id) {
$ledgerRows = Ledger::where([
'character_id' => $alt->character_id,
'invoiced' => 'Yes',
])->get();
if($ledgerRows->count() > 0) {
$ledgers->push([
'main_id' => $char->character_id,
'character_id' => $alt->character_id,
'observer_id' => $row->observer_id,
'last_updated' => $row->last_updated,
'type_id' => $row->type_id,
'ore_name' => $row->ore_name,
'quantity' => $row->quantity,
'amount' => $row->amount,
'invoiced' => $row->invoiced,
'invoice_id' => $row->invoice_id,
]);
}
}
} else {
$perms->push([
'main_id' => $char->character_id,
'alt_id' => null,
'count' => 0,
])
}
}
return view('test.miningtax.invoice')->with('ledgers', $ledgers);
return view('test.miningtax.invoice')->with('perms', $perms);
}
public function DebugMiningObservers() {

View File

@@ -63,6 +63,10 @@ class User extends Authenticatable
return $this->hasMany('App\Models\User\UserAlt', 'character_id', 'main_id');
}
public function altCount() {
return $this->hasMany('App\Models\User\UserAlt', 'character_id', 'main_id')->count();
}
public function hasPermission($permission) {
$found = UserPermission::where(['character_id' => $this->character_id, 'permission' => $permission])->get(['permission']);
foreach($found as $foo) {

View File

@@ -1,4 +1,4 @@
@extends('layouts.user.dashb4');
@section('content')
{{ var_dump($ledgers) }}
{{ var_dump($perms) }}
@endsection