moon rental pages

This commit is contained in:
2021-07-09 01:06:40 -05:00
parent 1a44be502a
commit b310799bf0
8 changed files with 252 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class ExecuteSendMoonRentalInvoices extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mr:invoice';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Execute command to send moon rental invoices job';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
return 0;
}
}

View File

@@ -51,8 +51,9 @@ class ExecuteUpdateAllianceMoonRentalWorth extends Command
*/
public function handle()
{
//UpdateAllianceMoonRentalWorth::dispatch();
UpdateAllianceMoonRentalWorth::dispatch();
/*
//Declare variables
$lookup = new LookupHelper;
$mHelper = new MoonCalc;
@@ -102,6 +103,7 @@ class ExecuteUpdateAllianceMoonRentalWorth extends Command
'rental_amount' => $rentalAmount,
]);
}
*/
return 0;
}

View File

@@ -109,6 +109,20 @@ class MiningTaxesAdminController extends Controller
return redirect('/admin/dashboard')->with('success', 'Operation added successfully.');
}
/**
* Display the page to approve corporation moon rentals
*/
public function DisplayMoonRentalRequests() {
}
/**
* Approve a moon rental from the form
*/
public function storeApproveMoonRentalRequest() {
}
/**
* Display the page to setup the form for corporations to rent a moon
*/

View File

@@ -31,6 +31,7 @@ use App\Models\Esi\EsiScope;
use App\Models\User\User;
use App\Models\MoonRental\AllianceMoon;
use App\Models\MoonRental\AllianceMoonOre;
use App\Models\MoonRental\AllianceMoonRental;
class MiningTaxesController extends Controller
{
@@ -42,6 +43,85 @@ class MiningTaxesController extends Controller
$this->middleware('role:User');
}
/**
* Display the page with the moon rental form
*/
public function DisplayMoonRentalForm(Request $request) {
$this->validate($request, [
'moon_id' => 'required',
'moon_name' => 'required',
'worth_amount' => 'required',
'rental_amount' => 'required',
]);
$moon = AllianceMoon::where([
'moon_id' => $request->moon_id,
])->first();
$ores = AllianceMoonOre::where([
'moon_id' => $request->moon_id,
])->get();
return view('minintax.user.moonrentals.form')->with('moon', $moon)
->with('ores', $ores);
}
/**
* Store the information from the moon rental form
*/
public function storeMoonRentalForm(Request $request) {
$this->validate($request, [
'moon_id' => 'required',
'moon_name' => 'required',
'rental_start' => 'required',
'rental_end' => 'required',
'entity_name' => 'required',
'entity_type' => 'reuqired',
]);
$lookup = new LookupHelper;
$entityId = null;
//From the name and type of the entity get the entity id.
if($request->entity_type == 'Character') {
$entityId = $lookup->CharacterNameToId();
} else if($request->entity_type == 'Corporation') {
$entityId = $lookup->CorporationNameToId();
} else if($request->entity_type == 'Alliance') {
$entityId = $lookup->AllianceNameToId();
} else {
return redirect('error', 'Moon Rental error. Please contact the site admin.');
}
//Create the next billing date from a Carbon date 3 months from the rental start
$nextBillingDate = Carbon::create($request->rental_end)->addMonths(3);
//Create the uniqid for the billing cycle.
$invoiceId = "MR" . uniqid();
//Update the data on the Alliance Moon
AllianceMoon::where([
'moon_id' => $request->moon_id,
])->update([
'rented' => 'Yes',
]);
//Insert a new moon rental into the database
AllianceMoonRental::insert([
'moon_id' => $request->moon_id,
'moon_name' => $request->moon_name,
'rental_amount' => $rentalAmount,
'rental_start' => $request->rental_start,
'rental_end' => $request->rental_end,
'next_billing_date' => $nextBillingDate,
'entity_id' => $entityId,
'entity_name' => $request->entity_name,
'entity_type' => $request->entity_type,
]);
return redirect('/dashboard')->with('success', 'Before placing a structure please send the ISK to the holding corp with the description of ' . $invoiceId);
}
public function displayAvailableMoons() {
//Declare variables
$moons = new Collection;
@@ -106,6 +186,9 @@ class MiningTaxesController extends Controller
'system' => $moon->system_name,
'moon_name' => $moon->name,
'ores' => $ores,
'worth_amount' => $moon->worth_amount,
'rental_amount' => $moon->rental_amount,
'moon_id' => $moon->moon_id,
]);
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Jobs\Commands\MoonRental\Invoices;
//Application Library
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Log;
use Carbon\Carbon;
//Internal Library
use App\Library\Helpers\LookupHelper;
//Models
use App\Models\MoonRental\AllianceMoon;
use App\Models\MoonRental\AllianceMoonOre;
use App\Models\MoonRental\AllianceMoonRental;
class SendMoonRentalInvoices implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
$this->connection = 'redis';
$this->onQueue('miningtaxes');
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare variables
$lookup = new LookupHelper;
$months = 3;
$today = Carbon::now();
$future = Carbon::now()->addMonths(3);
}
}

View File

@@ -0,0 +1,38 @@
@extends('layouts.user.dashb4')
@section('content')
<br>
<div class="container">
<div class="card">
<div class="card-header">
<h2>Rental Form for Moon Rental</h2><br>
Moon: {{ $moon->moon_name }}<br>
@foreach($ores as $ore)
{{ $ore->ore_name }} : {{ number_format(($ore->ore_quantity * 100.00), 2, ".", ",") }}<br>
@endforeach
</div>
<div class="card-body">
{!! Form::open(['action' => 'MiningTaxes\MiningTaxesController@storeMoonRentalForm']) !!}
{{ Form::hideen('moon_id', $moon->moon_id) }}
{{ Form::hidden('moon_name', $moon->moon_name) }}
<div class="form-group">
{{ Form::label('rental_start', Day of Rental Start) }}
{{ Form::date('rental_start', Carbon\Carbon::now(), ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('rental_end', 'Day of Rental End') }}
{{ Form::date('rental_end', Carbon\Carbon::now()->addMonths(3), ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('entity_type', 'Select Character or Corporation') }}
{{ Form::select('entity_type', ['Character', 'Corporation'], ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('entity_name', 'Enter Name for Rental') }}
{{ Form::text('entity_name', '', ['class' => 'form-control', 'placeholder' => 'Enter your character name or corporation name to follow the previous selection.']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-warning']) }}
{!! Form::close() !!}
</div>
</div>
</div>
@endsection

View File

@@ -29,6 +29,9 @@
<th>Third Quantity</th>
<th>Fourth Ore</th>
<th>Fourth Quantity</th>
<th>Moon Worth</th>
<th>Rental Cost</th>
<th>Rent?</th>
</thead>
<tbody>
@foreach($moons as $moon)
@@ -135,6 +138,17 @@
<td></td>
<td></td>
@endif
<td>{{ number_format($moon->worth_amount, 0, ".", ",") }}</td>
<td>{{ number_format($moon->rental_amount, 0, ".", ",") }}</td>
<td>
{!! Form::open(['action' => 'MiningTaxes\MiningTaxesController@DisplayMoonRentalForm', 'method' => 'POST']) !!}
{{ Form::hidden('moon_id', $moon->moon_id) }}
{{ Form::hidden('moon_name', $moon->moon_name) }}
{{ Form::hidden('worth_amount', $moon->worth_amount) }}
{{ Form::hidden('rental_amount', $moon->rental_amount) }}
{{ Form::submit('Rent', ['class' => 'btn btn-danger']) }}
{!! Form::close() !!}
</td>
</tr>
@endif
@endforeach

View File

@@ -98,6 +98,12 @@ Route::group(['middleware' => ['auth']], function(){
Route::any('/miningtax/admin/display/unpaid/search', 'MiningTaxes\MiningTaxesAdminController@SearchUnpaidInvoice');
Route::get('/miningtax/admin/display/form/operations', 'MiningTaxes\MiningTaxesAdminController@displayMiningOperationForm');
Route::post('/miningtax/admin/display/form/operations', 'MiningTaxes\MiningTaxesAdminController@storeMiningOperationForm');
/**
* Moon Rental Tax display pages
*/
Route::post('/moonrental/display/form', 'MiningTaxes\MiningTaxesController@DisplayMoonRentalForm');
Route::post('/moonrental/display/form/store', 'MiningTaxes\MiningTaxesController@storeMoonRentalForm');
/**
* Scopes Controller display pages