removed the flex structure stuff from menus and programming

This commit is contained in:
2021-01-11 01:35:07 +09:00
parent ebbfd1a327
commit 672d555c78
8 changed files with 0 additions and 419 deletions

View File

@@ -1,129 +0,0 @@
<?php
namespace App\Console\Commands\Flex;
//Internal Library
use Illuminate\Console\Command;
use Carbon\Carbon;
//Jobs
use App\Jobs\ProcessSendEveMailJob;
//Library
use Commands\Library\CommandHelper;
//Models
use App\Models\Flex\FlexStructure;
use App\Models\Mail\SentMail;
class FlexStructureCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:FlexStructures';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Mail out reminder for flex structure bills';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//Create the new command helper container
$task = new CommandHelper('FlexStructureMailer');
//Add the entry into the jobs table saying the job has started
$task->SetStartStatus();
//Create other variables
$body = null;
$delay = 5;
//Get today's date
$today = Carbon::now();
$today->second = 2;
$today->minute = 0;
$today->hour = 0;
//Get the esi configuration
$config = config('esi');
//Get all of the contacts for the flex structures
$contacts = FlexStructure::select('requestor_id')->orderBy('requestor_id')->get();
//For each of the contacts, send a reminder mail about the total of the structures they are paying for
foreach($contacts as $contact) {
//Get all of the structures for requestor
$structures = FlexStructure::where([
'requestor_id' => $contact->requestor_id,
])->get();
//Totalize the total cost of everything
$totalCost = $this->TotalizeCost($structures);
//Build the body of the mail
$body = "Flex Structure Overhead Cost is due for the following structures:<br>";
foreach($structures as $structure) {
$body .= "System: " . $structure->system . " - " . $structure->structure_type . ": " . $structure->structure_cost . " ISK<br>";
}
$body .= "Total Cost: " . number_format($totalCost, 2,".", ",");
$body .= "Please remit payment to Spatial Forces by the 3rd of the month.<br>";
$body .= "Sincerely,<br>";
$body .= "Warped Intentions Leadership<br>";
//Dispatch the mail job
$subject = "Warped Intentions Flex Structures Payment Due for " . $today->englishMonth;
ProcessSendEveMailJob::dispatch($body, (int)$structure->requestor_id, 'character', $subject, $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds($delay));
//Increment the delay for the mail to not hit the rate limits
$delay += 60;
//After the mail is dispatched, save the sent mail record
$this->SaveSentRecord($config['primary'], $subject, $body, (int)$structure->requestor_id, 'character');
}
//Mark the job as finished
$task->SetStopStatus();
}
private function TotalizeCost($structures) {
//Declare the total cost
$totalCost = 0.00;
foreach($structures as $structure) {
$totalCost += $structure->structure_cost;
}
return $totalCost;
}
private function SaveSentRecord($sender, $subject, $body, $recipient, $recipientType) {
$sentmail = new SentMail;
$sentmail->sender = $sender;
$sentmail->subject = $subject;
$sentmail->body = $body;
$sentmail->recipient = $recipient;
$sentmail->recipient_type = $recipientType;
$sentmail->save();
}
}

View File

@@ -38,10 +38,6 @@ class Kernel extends ConsoleKernel
*/
Commands\Finances\HoldingFinancesCommand::class,
Commands\Finances\SovBillsCommand::class,
/**
* Flex Commands
*/
Commands\Flex\FlexStructureCommand::class,
/**
* Moon Commands
*/

View File

@@ -1,148 +0,0 @@
<?php
namespace App\Http\Controllers\Flex;
//Internal Library
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Auth;
use DB;
use Carbon\Carbon;
//Models
use App\Models\Flex\FlexStructure;
//Library
use App\Library\Lookups\LookupHelper;
use App\Library\Esi\Esi;
class FlexAdminController extends Controller
{
//Constructor
public function __construct() {
$this->middleware('auth');
$this->middleware('role:Admin');
}
/**
* Function to display all active flex structures and
* the information regarding the flex structure
*/
public function displayFlexStructures() {
//Get the structures from the database
$structures = FlexStructure::all();
//Return the view with the data
return view('flex.list')->with('structures', $structures);
}
/**
* Function to display form for adding new flex structure
*/
public function displayAddFlexStructure() {
return view('flex.add');
}
/**
* Function to add new flex structure to the database
*/
public function addFlexStructure(Request $request) {
$this->validate($request, [
'requestor_name' => 'required',
'requestor_corp_name' => 'required',
'system' => 'required',
'structure_type' => 'required',
'structure_cost' => 'required',
]);
//Delcare variables and classes
$lookup = new LookupHelper;
//From the character name find the character id
$charId = $lookup->CharacterNameToId($request->requestor_name);
//From the corporation name find the corporation id
$corpId = $lookup->CorporationNameToId($request->requestor_corp_name);
//From the system name find the system id
$systemId = $lookup->SystemNameToId($request->system);
//Create the database model
$flex = new FlexStructure;
$flex->requestor_id = $charId;
$flex->requestor_name = $request->requestor_name;
$flex->requestor_corp_id = $corpId;
$flex->requestor_corp_name = $request->requestor_corp_name;
$flex->system_id = $systemId;
$flex->system = $request->system;
$flex->structure_type = $request->structure_type;
$flex->structure_cost = $request->structure_cost;
if(isset($request->paid_until)) {
$flex->paid_until = $request->paid_until;
}
$flex->save();
return redirect('/flex/display')->with('success', 'Flex Structure Added.');
}
/**
* Function to update paid until section of the flex structure in the database
*/
public function updateFlexStructure(Request $request) {
$this->validate($request, [
'paid_until' => 'required',
'requestor_id' => 'required',
'requestor_corp_id' => 'required',
'system_id' => 'required',
'structure_type' => 'required',
]);
FlexStructure::where([
'requestor_id' => $request->requestor_id,
'requestor_corp_id' => $request->requestor_corp_id,
'system_id' => $request->system_id,
'structure_type' => $request->structure_type,
])->update([
'paid_until' => $request->paid_until,
]);
return redirect('/flex/display')->with('success', 'Flex Structure Updated.');
}
/**
* Funciton to remove flex structure from the database
*/
public function removeFlexStructure(Request $request) {
$this->validate($request, [
'requestor_id' => 'required',
'requestor_corp_id' => 'required',
'system_id' => 'required',
'structure_type' => 'required',
]);
$count = FlexStructure::where([
'requestor_id' => $request->requestor_id,
'requestor_corp_id' => $request->requestor_corp_id,
'system_id' => $request->system_id,
'structure_type' => $request->structure_type,
])->count();
if($count > 0) {
FlexStructure::where([
'requestor_id' => $request->requestor_id,
'requestor_corp_id' => $request->requestor_corp_id,
'system_id' => $request->system_id,
'structure_type' => $request->structure_type,
])->delete();
return redirect('/flex/display')->with('success', 'Flex Structure Entry Removed.');
} else {
return redirect('/flex/display')->with('error', 'Could not find flex structure to delete.');
}
}
}

View File

@@ -1,41 +0,0 @@
@extends('layouts.admin.b4')
@section('content')
<div class="container">
<div class="card">
<div class="card-header">
<h2>New Flex Structure Registration</h2>
</div>
<div class="card-body">
{{ Form::open(['action' => 'Flex\FlexAdminController@addFlexStructure', 'method' => 'POST']) }}
<div class="form-group">
{{ Form::label('requestor_name', 'Character Name') }}
{{ Form::text('requestor_name', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('requestor_corp_name', 'Corporation Name') }}
{{ Form::text('requestor_corp_name', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('system', 'System') }}
{{ Form::text('system', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('structure_type', 'Structure Type') }}
{{ Form::select('structure_type', [
'Cyno Jammer' => 'Cyno Jammer',
'Cyno Beacon' => 'Cyno Beacon',
'Jump Bridge' => 'Jump Bridge',
'Super Construction Facilities' => 'Super Construction Facilities',
'Market' => 'Market',
], 'None', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('structure_cost', 'Structure Cost') }}
{{ Form::text('structure_cost', '', ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div>
</div>
@endsection

View File

@@ -1,58 +0,0 @@
@extends('layouts.admin.b4')
@section('content')
<br>
<div class="container">
<div class="card">
<div class="card-header">
<h2>Flex Structures</h2>
</div>
<div class="card-body">
<table class="table table-bordered table-striped">
<thead>
<th>Requestor</th>
<th>Corp</th>
<th>System</th>
<th>Structure Type</th>
<th>Cost</th>
<th>Paid Until</th>
<th>Update</th>
<th>Remove?</th>
</thead>
<tbody>
@foreach($structures as $structure)
<tr>
<td>{{ $structure->requestor_name }}</td>
<td>{{ $structure->requestor_corp_name }}</td>
<td>{{ $structure->system }}</td>
<td>{{ $structure->structure_type }}</td>
<td>{{ number_format($structure->structure_cost, "2", ".", ",") }}</td>
<td>
{{ $structure->paid_until }}
</td>
<td>
{!! Form::open(['action' => 'Flex\FlexAdminController@updateFlexStructure', 'method' => 'POST']) !!}
{{ Form::date('paid_until', \Carbon\Carbon::now()->endOfMonth(), ['class' => 'form-control']) }}
{{ Form::hidden('requestor_id', $structure->requestor_id) }}
{{ Form::hidden('requestor_corp_id', $structure->requestor_corp_id) }}
{{ Form::hidden('system_id', $structure->system_id) }}
{{ Form::hidden('structure_type', $structure->structure_type) }}
{{ Form::submit('Update', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</td>
<td>
{!! Form::open(['action' => 'Flex\FlexAdminController@removeFlexStructure', 'method' => 'POST']) !!}
{{ Form::hidden('structure_type', $structure->structure_type) }}
{{ Form::hidden('requestor_id', $structure->requestor_id) }}
{{ Form::hidden('requestor_corp_id', $structure->requestor_corp_id) }}
{{ Form::hidden('system_id', $structure->system_id) }}
{{ Form::submit('Remove', ['class' => 'btn btn-danger']) }}
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@endsection

View File

@@ -20,9 +20,6 @@
<!-- General Administrative Stuff -->
@include('layouts.admin.sidebarmenu.general')
<!-- End General Administrative Stuff -->
<!-- Flex Structure -->
@include('layouts.admin.sidebarmenu.flex')
<!-- End Flex Structure -->
<!-- Moon Admin -->
@include('layouts.admin.sidebarmenu.moon')
<!-- End Moon Admin -->

View File

@@ -1,27 +0,0 @@
<!-- Flex Structure -->
@if(auth()->user()->hasRole('Admin'))
<li class="nav-item has-treeview">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-tachometer-alt"></i>
<p>
Flex Structures<br>
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="/flex/display" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>Display</p>
</a>
</li>
<li class="nav-item">
<a href="/flex/display/add" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>Add</p>
</a>
</li>
</ul>
</li>
@endif
<!-- End Flex Structure -->

View File

@@ -71,15 +71,6 @@ Route::group(['middleware' => ['auth']], function(){
Route::post('/dashboard/alt/delete', 'Dashboard\DashboardController@removeAlt');
Route::get('/profile', 'Dashboard\DashboardController@profile');
/**
* Flex Admin Controller display pages
*/
Route::get('/flex/display', 'Flex\FlexAdminController@displayFlexStructures');
Route::get('/flex/display/add', 'Flex\FlexAdminController@displayAddFlexStructure');
Route::post('/flex/display/add', 'Flex\FlexAdminController@addFlexStructure');
Route::post('/flex/display/remove', 'Flex\FlexAdminController@removeFlexStructure');
Route::post('/flex/display/update', 'Flex\FlexAdminController@updateFlexStructure');
/**
* Fuel Controller display pages
*/