diff --git a/app/Console/Commands/MoonRental/ExecuteSendMoonRentalInvoices.php b/app/Console/Commands/MoonRental/ExecuteSendMoonRentalInvoices.php new file mode 100644 index 000000000..5e29874a3 --- /dev/null +++ b/app/Console/Commands/MoonRental/ExecuteSendMoonRentalInvoices.php @@ -0,0 +1,42 @@ + $rentalAmount, ]); } + */ return 0; } diff --git a/app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php b/app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php index ee9ac44f5..f4a39f832 100644 --- a/app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php +++ b/app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php @@ -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 */ diff --git a/app/Http/Controllers/MiningTaxes/MiningTaxesController.php b/app/Http/Controllers/MiningTaxes/MiningTaxesController.php index 852a81124..ece8ff17e 100644 --- a/app/Http/Controllers/MiningTaxes/MiningTaxesController.php +++ b/app/Http/Controllers/MiningTaxes/MiningTaxesController.php @@ -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, ]); } } diff --git a/app/Jobs/Commands/MoonRental/Invoices/SendMoonRentalInvoices.php b/app/Jobs/Commands/MoonRental/Invoices/SendMoonRentalInvoices.php new file mode 100644 index 000000000..284ff3be1 --- /dev/null +++ b/app/Jobs/Commands/MoonRental/Invoices/SendMoonRentalInvoices.php @@ -0,0 +1,51 @@ +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); + } +} diff --git a/resources/views/miningtax/user/display/moonrentals/form.blade.php b/resources/views/miningtax/user/display/moonrentals/form.blade.php new file mode 100644 index 000000000..f0fce3a1b --- /dev/null +++ b/resources/views/miningtax/user/display/moonrentals/form.blade.php @@ -0,0 +1,38 @@ +@extends('layouts.user.dashb4') +@section('content') +
+
+
+
+

Rental Form for Moon Rental


+ Moon: {{ $moon->moon_name }}
+ @foreach($ores as $ore) + {{ $ore->ore_name }} : {{ number_format(($ore->ore_quantity * 100.00), 2, ".", ",") }}
+ @endforeach +
+
+ {!! Form::open(['action' => 'MiningTaxes\MiningTaxesController@storeMoonRentalForm']) !!} + {{ Form::hideen('moon_id', $moon->moon_id) }} + {{ Form::hidden('moon_name', $moon->moon_name) }} +
+ {{ Form::label('rental_start', Day of Rental Start) }} + {{ Form::date('rental_start', Carbon\Carbon::now(), ['class' => 'form-control']) }} +
+
+ {{ Form::label('rental_end', 'Day of Rental End') }} + {{ Form::date('rental_end', Carbon\Carbon::now()->addMonths(3), ['class' => 'form-control']) }} +
+
+ {{ Form::label('entity_type', 'Select Character or Corporation') }} + {{ Form::select('entity_type', ['Character', 'Corporation'], ['class' => 'form-control']) }} +
+
+ {{ 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.']) }} +
+ {{ Form::submit('Submit', ['class' => 'btn btn-warning']) }} + {!! Form::close() !!} +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/miningtax/user/display/moons/availablemoons.blade.php b/resources/views/miningtax/user/display/moons/availablemoons.blade.php index 6d3fb88fc..b4a8109b7 100644 --- a/resources/views/miningtax/user/display/moons/availablemoons.blade.php +++ b/resources/views/miningtax/user/display/moons/availablemoons.blade.php @@ -29,6 +29,9 @@ Third Quantity Fourth Ore Fourth Quantity + Moon Worth + Rental Cost + Rent? @foreach($moons as $moon) @@ -135,6 +138,17 @@ @endif + {{ number_format($moon->worth_amount, 0, ".", ",") }} + {{ number_format($moon->rental_amount, 0, ".", ",") }} + + {!! 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() !!} + @endif @endforeach diff --git a/routes/web.php b/routes/web.php index bd126dfb0..7b56c8ed2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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