added logistics manager moons to help with issues

This commit is contained in:
2019-07-04 01:32:59 -05:00
parent a097138299
commit 4e9a289692
5 changed files with 142 additions and 0 deletions

View File

@@ -29,6 +29,83 @@ class MoonsAdminController extends Controller
$this->middleware('role:Admin');
}
/**
* Function to display the moons to logistics personnel
*/
public function displayMoonsLogistics() {
$this->middleware('permissions:logistics.manager');
$lookup = new LookupHelper;
$rentalEnd = '';
$ticker = '';
//Setup calls to the MoonCalc class
$moonCalc = new MoonCalc();
//Get all of the moons from the database
$moons = Moon::orderBy('System', 'asc')->get();
//Declare the html variable and set it to null
$table = array();
//Set carbon dates as needed
$lastMonth = Carbon::now()->subMonth();
$today = Carbon::now();
foreach($moons as $moon) {
//Get the rental data for the moon
$count = MoonRental::where([
'System' => $moon->System,
'Planet' => $moon->Planet,
'Moon' => $moon->Moon,
])->count();
//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';
//If we don't find a rental record, set the rental date as last month
$rentalTemp = $lastMonth;
$rentalEnd = $rentalTemp->format('m-d');
//Set the ticker info
$ticker = 'N/A';
} else {
//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;
//Set the rental date up
$rentalTemp = new Carbon($rental->RentalEnd);
$rentalEnd = $rentalTemp->format('m-d');
}
//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';
}
//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->StructureName,
'RentalEnd' => $rentalEnd,
'RowColor' => $color,
]);
}
return view('moons.logistics.adminmoon')->with('table', $table);
}
/**
* Function to display the moons to admins
*/

View File

@@ -4,6 +4,10 @@ namespace App\Http\Controllers\Stocks;
use Illuminate\Http\Request;
/**
* This class display data related to structures and how much fuel of a given type they hold.
* This will mostly be used for jump gates, cyno beacons, and cyno jammers.
*/
class StockController extends Controller
{
public function __construct() {

View File

@@ -18,6 +18,9 @@
<a class="dropdown-item" href="/moons/admin/updatemoon">Update Moon</a>
<a class="dropdown-item" href="/moons/admin/journal">Journal</a>
@endif
@if(auth()->user()->hasPermission('logistics.manager'))
<a class="dropdown-item" href="/moons/logistics/display">Moons for Logistics</a>
@endif
</div>
</li>
@if(auth()->user()->hasRole('User') || auth()->user()->hasRole('Admin') || auth()->user()->hasRole('Renter'))

View File

@@ -0,0 +1,57 @@
@extends('layouts.b4')
@section('content')
<br>
<div class="container col-md-12">
<table class="table table-striped">
<thead>
<th>System</th>
<th>Name</th>
<th>Rental End</th>
</thead>
<tbody>
@foreach($table as $row)
<tr class="{{ $row['RowColor'] }}">
<td>{{ $row['SPM'] }}</td>
<td>{{ $row['StructureName'] }}</td>
<td>{{ $row['RentalEnd'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<br>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
Legend
</div>
<div class="card-body">
<table class="table table-striped">
<tbody>
<tr class="table-success">
<td>Moon Available</td>
</tr>
<tr class="table-danger">
<td>Moon Rented</td>
</tr>
<tr class="table-warning">
<td>Moon Rent Due</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
</div>
</div>
@endsection

View File

@@ -40,6 +40,7 @@ Route::group(['middleware' => ['auth']], function(){
Route::post('/moons/admin/updatemoon', 'Moons\MoonsAdminController@storeUpdateMoon');
Route::get('/moons/admin/journal', 'Moons\MoonsAdminController@showJournalEntries');
Route::post('/moons/admin/display', 'Moons\MoonsAdminController@storeMoonRemoval');
Route::get('/moons/logistics/display', 'Moons\MoonsAdminController@displayMoonsLogistics');
/**
* Wiki Controller display pages