admin dashboard updates

This commit is contained in:
2019-03-06 23:20:46 -06:00
parent ea40901761
commit de6891e995
4 changed files with 389 additions and 77 deletions

View File

@@ -5,13 +5,14 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use DB; use DB;
//Libraries
use App\Library\Taxes\TaxesHelper;
//Models
use App\User; use App\User;
use App\Models\User\UserRole; use App\Models\User\UserRole;
use App\Models\User\UserPermission; use App\Models\User\UserPermission;
use App\Models\User\AvailableUserPermission; use App\Models\User\AvailableUserPermission;
use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
use App\Models\Corporation\CorpStructure;
use App\Models\Admin\AllowedLogin; use App\Models\Admin\AllowedLogin;
class AdminController extends Controller class AdminController extends Controller
@@ -22,28 +23,81 @@ class AdminController extends Controller
} }
public function displayDashboard() { public function displayDashboard() {
//Get the users from the database to allow a selection of users for //Declare variables needed for displaying items on the page
//adding and removing roles and permissions $months = 3;
$users = User::pluck('name')->all(); $pi = array();
$permissions = AvailableUserPermission::pluck('permission')->all(); $industry = array();
$reprocessing = array();
$office = array();
$user = array(); $user = array();
$permission = array(); $permission = array();
$corpId = 98287666;
/** Taxes Pane */
//Declare classes needed for displaying items on the page
$tHelper = new TaxesHelper();
//Get the dates for the tab panes
$dates = $tHelper->GetTimeFrameInMonths($months);
//Get the data for the Taxes Pane
foreach($dates as $date) {
//Get the pi taxes for the date range
$pis[] = [
'date' => $date['start']->toFormattedDateString(),
'gross' => number_format($tHelper->GetPIGross($date['start'], $date['end']), 2, ".", ","),
];
//Get the industry taxes for the date range
$industrys[] = [
'date' => $date['start']->toFormattedDateString(),
'gross' => number_format($tHelper->GetIndustryGross($date['start'], $date['end']), 2, ".", ","),
];
//Get the reprocessing taxes for the date range
$reprocessings[] = [
'date' => $date['start']->toFormattedDateString(),
'gross' => number_format($tHelper->GetReprocessingGross($date['start'], $date['end']), 2, ".", ","),
];
//Get the office taxes for the date range
$offices[] = [
'date' => $date['start']->toFormattedDateString(),
'gross' => number_format($tHelper->GetOfficeGross($date['start'], $date['end']), 2, ".", ","),
];
//Get the market taxes for the date range
$markets[] = [
'date' => $date['start']->toFormattedDateString(),
'gross' => number_format($tHelper->GetMarketGross($date['start'], $date['end']), 2, ".", ","),
];
//Get the jump gate taxes for the date range
$jumpgates[] = [
'date' => $date['start']->toFormattedDateString(),
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
];
}
/** Users & Permissions Pane */
//Get the users from the database to allow a selection of users for various parts of the webpage
$users = User::pluck('name')->all();
//Get the available permissions from the database to allow a selection of permissions
$permissions = AvailableUserPermission::pluck('permission')->all();
//Create the user key value pairs
foreach($users as $key => $value) { foreach($users as $key => $value) {
$user[$value] = $value; $user[$value] = $value;
} }
//Create the permission key value pairs
foreach($permissions as $key => $value) { foreach($permissions as $key => $value) {
$permission[$value] = $value; $permission[$value] = $value;
} }
//Create the data array
$data = [ $data = [
'users' => $user, 'users' => $user,
'permissions' => $permission, 'permissions' => $permission,
]; ];
return view('admin.dashboard')->with('data', $data); return view('admin.dashboard')->with('data', $data)
->with('pis', $pis)
->with('industrys', $industrys)
->with('offices', $offices)
->with('markets', $markets)
->with('jumpgates', $jumpgates)
->with('entities', $entities);
} }
public function addPermission(Request $request) { public function addPermission(Request $request) {
@@ -100,33 +154,33 @@ class AdminController extends Controller
public function addAllowedLogin(Request $request) { public function addAllowedLogin(Request $request) {
//Set the parameters to validate the form //Set the parameters to validate the form
$this->validate($request, [ $this->validate($request, [
'entity_id' => 'required', 'allowedEntityId' => 'required',
'entity_type' => 'required', 'allowedEntityType' => 'required',
'entity_name' => 'required', 'allowedEntityName' => 'required',
'login_type' => 'required', 'allowedLoginType' => 'required',
]); ]);
//Check to see if the entity exists in the database already //Check to see if the entity exists in the database already
$found = AllowedLogin::where([ $found = AllowedLogin::where([
'entity_type' => $request->entityType, 'entity_type' => $request->allowedentityType,
'entity_name' => $request->entityName, 'entity_name' => $request->allowedEntityName,
])->get(); ])->get();
if($found != null) { if($found != null) {
AllowedLogin::where([ AllowedLogin::where([
'entity_type' => $request->entityType, 'entity_type' => $request->allowedEntityType,
'entity_name' => $request->entityName, 'entity_name' => $request->allowedEntityName,
])->update([ ])->update([
'entity_id' => $request->entityId, 'entity_id' => $request->allowedEntityId,
'entity_type' => $request->entityType, 'entity_type' => $request->allowedEntityType,
'entity_name' => $request->entityName, 'entity_name' => $request->allowedEntityName,
'login_type' => $request->loginType, 'login_type' => $request->allowedLoginType,
]); ]);
} else { } else {
$login = new AllowedLogin; $login = new AllowedLogin;
$login->entity_id = $request->entityId; $login->entity_id = $request->allowedEntityId;
$login->entity_name = $request->entityName; $login->entity_name = $request->allowedEntityName;
$login->entity_type = $request->entityType; $login->entity_type = $request->allowedEntityType;
$login->login_type = $request->loginType; $login->login_type = $request->allowedLoginType;
} }
return redirect('/admin/dashboard')->with('success', 'Entity added to allowed login list.'); return redirect('/admin/dashboard')->with('success', 'Entity added to allowed login list.');
@@ -135,17 +189,11 @@ class AdminController extends Controller
public function removeAllowedLogin(Request $request) { public function removeAllowedLogin(Request $request) {
//Set the parameters to validate the form //Set the parameters to validate the form
$this->validate($request, [ $this->validate($request, [
'entity_id' => 'required', 'removeAllowedLogin' => 'required',
'entity_type' => 'required',
'entity_name' => 'required',
'login_type' => 'required',
]); ]);
AllowedLogin::where([ AllowedLogin::where([
'entity_id' => $request->entityId, 'entity_name' => $request->removeAllowedLogin,
'entity_type' => $request->entityType,
'entity_name' => $request->entityName,
'login_type' => $request->loginType,
])->delete(); ])->delete();
return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.'); return redirect('/admin/dashboard')->with('success', 'Entity removed from allowed login list.');

View File

@@ -8,10 +8,6 @@ use Auth;
use DB; use DB;
use Carbon\Carbon; use Carbon\Carbon;
use App\Library\Esi\Esi;
use App\Library\Lookups\LookupHelper;
use App\Library\Structures\StructureTaxHelper;
use App\Library\Taxes\TaxesHelper; use App\Library\Taxes\TaxesHelper;
class TaxesController extends Controller class TaxesController extends Controller
@@ -19,7 +15,7 @@ class TaxesController extends Controller
public function __construct() { public function __construct() {
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('role:Admin'); $this->middleware('role:Admin');
$this->middleware('permission:structure.operator'); $this->middleware('permission:admin.finance');
} }
public function displayTaxSummary() { public function displayTaxSummary() {

View File

@@ -2,14 +2,19 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
//Laravel libraries
use Illuminate\Http\Request; use Illuminate\Http\Request;
use DB; use DB;
use Auth; use Auth;
//User Libraries
use App\Library\Lookups\LookupHelper;
//Models
use App\Models\Doku\DokuGroupNames; use App\Models\Doku\DokuGroupNames;
use App\Models\Doku\DokuMember; use App\Models\Doku\DokuMember;
use App\Models\Doku\DokuUser; use App\Models\Doku\DokuUser;
use App\Models\Admin\AllowedLogin;
class WikiController extends Controller class WikiController extends Controller
{ {
@@ -17,6 +22,32 @@ class WikiController extends Controller
$this->middleware('auth'); $this->middleware('auth');
$this->middleware('role:User'); $this->middleware('role:User');
} }
public function purgeUsers() {
//Declare helper classes
$helper = new LookupHelper;
//Get all the users from the database
$users = DokuUser::pluck('name')->all();
$legacy = AllowedLogin::where(['login_type' => 'Legacy'])->pluck('entity_id')->toArray();
$renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray();
//Search the names and verify against the lookup table
//to find the corporation and / or alliance they belong to.
foreach($users as $user) {
$charId = $helper->CharacterNameToId($user);
$corpId = $helper->LookupCharacter($charId);
$allianceId = $helper->LookupCorporation($corpId);
if(in_array($allianceId, $legacy) || in_array($allianceId, $renter) || $allianceId == 99004116) {
//Do nothing
} else {
DokuUser::where(['name' => $user])->delete();
}
}
return view('/admin/dashboard')->with('success', 'Wiki has been purged.');
}
public function displayRegister() { public function displayRegister() {
//make user name syntax like we want it. //make user name syntax like we want it.

View File

@@ -1,46 +1,283 @@
@extends('layouts.b4') @extends('layouts.b4')
@section('content') @section('content')
<div class="container"> <div class="container">
<br> <h2> Admin Dashboard</h2>
<h2>Admin Dashboard</h2>
<br>
</div> </div>
<div class="container">
<div class="row"> <ul class="nav nav-tabs">
<div class="col-md-6 card"> <li class="active"><a data-toggle="tab" href="#user">User</a></li>
<div class="card-header"> <li><a data-toggle="tab" href="#permissions">Permissions</a></li>
Add Permission for User <li><a data-toggle="tab" href="#roles">Roles</a></li>
</div> <li><a data-toggle="tab" href="#logins">Login</a></li>
<div class="card-body"> <li><a data-toggle="tab" href="#wiki">Wiki</a></li>
{!! Form::open(['action' => 'AdminController@addPermission', 'method' => 'POST']) !!} <li><a data-toggle="tab" href="#taxes">Taxes</a></li>
<div class="form-group"> </ul>
{{ Form::label('user', 'User') }}
{{ Form::select('user', $data['users'], null, ['class' => 'form-control']) }} <div class="tab-content">
{{ Form::select('permission', $data['permissions'], null, ['class' => 'form-control']) }} <div id="user" class="tab-pane fade in active">
<div class="container">
<div class="row">
<div class="col-md-6 card">
<div class="card-header">
Remove User
</div>
<div class="card-body">
{!! Form::open(['action' => 'AdminController@removeUser', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('user', 'User') }}
{{ Form::select('user', $data['users'], null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<div id="permissions" class="tab-pane fade">
<div class="container">
<div class="row">
<div class="col-md-6 card">
<div class="card-header">
Add Permission for User
</div>
<div class="card-body">
{!! Form::open(['action' => 'AdminController@addPermission', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('user', 'User') }}
{{ Form::select('user', $data['users'], null, ['class' => 'form-control']) }}
{{ Form::select('permission', $data['permissions'], null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<div id="roles" class="tab-pane fade">
<div class="container">
<div class="row">
<div class="col-md-6 card">
<div class="card-header">
Modify User Role
</div>
<div class="card-body">
{!! Form::open(['action' => 'AdminController@modifyRole', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('user', 'User') }}
{{ Form::select('user', $data['users'], null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<div id="logins" class="tab-pane fade">
<div class="container">
<div class="row">
<div class="col-md-6 card">
<div class="card-header">
Add Allowed Login
</div>
<div class="card-body">
{!! Form::open(['action' => 'AdminController@addAllowedLogin', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('allowedEntityId', 'Allowed Entity ID') }}
{{ Form::text('allowedEntityId', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('allowedEntityType', 'Allowed Entity Type') }}
{{ Form::select('allowedEtntityType', ['Corporation' => 'Corporation', 'Alliance' => 'Alliance'], null, ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('allowedEntityName', 'Allowed Entity Name') }}
{{ Form::text('allowedEntityName', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('allowedLoginType', 'Allowed Login Type') }}
{{ Form::select('allowedLoginType', ['Legacy' => 'Legacy', 'Renter' => 'Renter'], null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-6 card">
<div class="card-header">
Remove Allowed Login
</div>
<div class="card-body">
{!! Form::open(['action' => 'AdminController@removeAllowedLogin', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('removeAllowedLogin', 'Remove Entity') }}
{{ Form::select('removeAllowedLogin', $entities, null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
<div id="wiki" class="tab-pane fade">
Placeholder for when a button is available
</div>
<div id="taxes" class="tab-pane fade">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
PI Taxes
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<th>Month</th>
<th>PI Taxes</th>
</thead>
<tbody>
@foreach($pis as $pi)
<tr>
<td>{{ $pi['date'] }}</td>
<td>{{ $pi['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Office Taxes
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<th>Month</th>
<th>Office Taxes</th>
</thead>
<tbody>
@foreach($offices as $office)
<tr>
<td>{{ $office['date'] }}</td>
<td>{{ $office['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Industry Taxes
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<th>Month</th>
<th>Industry Taxes</th>
</thead>
<tbody>
@foreach($industrys as $industry)
<tr>
<td>{{ $industry['date'] }}</td>
<td>{{ $industry['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
Reprocessing Taxes
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<th>Month</th>
<th>Reprocessing Taxes</th>
</thead>
<tbody>
@foreach($reprocessings as $reprocessing)
<tr>
<td>{{ $reprocessing['date'] }}</td>
<td>{{ $reprocessing['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Market Taxes
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<th>Month</th>
<th>Market Taxes</th>
</thead>
<tbody>
@foreach($markets as $market)
<tr>
<td>{{ $market['date'] }}</td>
<td>{{ $market['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="card-header">
Jump Gate Taxes
</div>
<div class="card-body">
<table class="table table-striped">
<thead>
<th>Month</th>
<th>Jump Gate Taxes</th>
</thead>
<tbody>
@foreach($jumpgates as $jumpgate)
<tr>
<td>{{ $jumpgate['date'] }}</td>
<td>{{ $jumpgate['gross'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div> </div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
</div>
<br>
<div class="container">
<div class="row">
<div class="col-md-6 card">
<div class="card-header">
Remove User
</div>
<div class="card-body">
{!! Form::open(['action' => 'AdminController@removeUser', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('user', 'User') }}
{{ Form::select('user', $data['users'], null, ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@endsection @endsection