diff --git a/app/Http/Controllers/Moons/MoonsAdminController.php b/app/Http/Controllers/Moons/MoonsAdminController.php
index 185aeaa5d..e817ccd7f 100644
--- a/app/Http/Controllers/Moons/MoonsAdminController.php
+++ b/app/Http/Controllers/Moons/MoonsAdminController.php
@@ -56,469 +56,6 @@ class MoonsAdminController extends Controller
$this->middleware('role:Admin');
}
- /**
- * Function to display moon requests
- */
- public function displayMoonRequests() {
- $requests = AllianceMoonRequest::where([
- 'status' => 'Pending',
- ])->get();
-
- return view('moons.admin.moonrequest')->with('requests', $requests);
- }
-
- /**
- * Function to approve a moon request
- */
- public function storeApprovedMoonRequest(Request $request) {
- //Validate the input request
- $this->validate($request, [
- 'id' => 'required',
- 'status' => 'required',
- 'system' => 'required',
- 'planet' => 'required',
- 'moon' => 'required',
- ]);
-
-
- //Get the request data which holds all of the information for the request user
- $moon = AllianceMoonRequest::where([
- 'id' => $request->id,
- ])->first();
-
- //Get the configuration data to use later in the function
- $config = config('esi');
-
- //If the request is approved, then update everything.
- if($request->status == 'Approved') {
- //Update the alliance moon request to either approved or denied
- AllianceMoonRequest::where([
- 'id' => $request->id,
- ])->update([
- 'status' => $request->status,
- 'approver_name' => auth()->user()->getName(),
- 'approver_id' => auth()->user()->getId(),
- ]);
-
- //Update the alliance moon in the table to the correct status
- AllianceMoon::where([
- 'System' => $request->system,
- 'Planet' => $request->planet,
- 'Moon' => $request->moon,
- ])->update([
- 'Corporation' => $moon->corporation_ticker,
- 'Availability' => 'Deployed',
- ]);
-
- //Send an eve mail to the requestor stating they can set a moon up.
- //Setup the mail body
- $body = 'The moon request for ' . $request->system . ' - ' . $request->planet . ' - ' . $request->moon . ' has changed status.
';
- $body .= 'The request has been ' . $request->status . '.
';
- $body .= 'Please contact the FC Team should it be necessary to arrange a fleet to cover the structure drop.
';
- $body .= 'Sincerely,
';
- $body .= 'Warped Intentions Leadership
';
-
-
- } else {
- //If the status was Denied, then update the request, and mark the moon available again.
- AllianceMoonRequest::where([
- 'id' => $request->id,
- ])->update([
- 'status' => $request->status,
- 'approver_name' => auth()->user()->getName(),
- 'approver_id' => auth()->user()->getId(),
- ]);
-
- //Update the alliance moon in the table to the correct status
- AllianceMoon::where([
- 'System' => (string)$request->system,
- 'Planet' => (string)$request->planet,
- 'Moon' => (string)$request->moon,
- ])->update([
- 'Availability' => 'Available',
- ]);
-
- //Send an eve mail to the requestor stating they can set a moon up.
- //Setup the mail body
- $body = 'The moon request for ' . $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon . ' has changed status.
';
- $body .= 'The request has been ' . $request->status . '.
';
- $body .= 'Should you have questions please contact alliance leadership for further clarification.
';
- $body .= 'Sincerely,
';
- $body .= 'Warped Intentions Leadership
';
-
- }
-
- //Setup the mail model
- ProcessSendEveMailJob::dispatch($body, (int)$moon->requestor_id, 'character', 'Warped Intentions Moon Request', $config['primary'])->onQueue('mail')->delay(Carbon::now()->addSeconds(30));
-
- return redirect('/moons/admin/display/request')->with('success', 'Moon has been processed, and mail has been sent out.');
- }
-
- /**
- * Function to display the ability for the admins to update moons with who is renting,
- * and when it ends
- */
- public function updateMoon() {
- $this->middleware('role:Admin');
-
- //Declare the variables we need
- $system = null;
- $planet = null;
- $moon = null;
- $name = null;
- $spmnTemp = array();
- $spmn = array();
-
- //Get the moons and put in order by System, Planet, Moon number
- $moons = AllianceRentalMoon::orderBy('System', 'ASC')
- ->orderBy('Planet', 'ASC')
- ->orderBy('Moon', 'ASC')
- ->get();
-
- //Push our default value onto the stack
- array_push($spmn, 'N/A');
-
- //Form our array of strings for each system, planet, and moon combination
- foreach($moons as $m) {
- $temp = $m->system . " - " . $m->planet . " - " . $m->moon . " - " . $m->structure_name;
- array_push($spmnTemp, $temp);
- }
-
- //From the temporary array, build the final array
- foreach($spmnTemp as $key => $value) {
- $spmn[$value] = $value;
- }
-
- //Pass the data to the blade display
- return view('moons.admin.updatemoon')->with('spmn', $spmn);
- }
-
- /**
- * Function to remove a renter from a moon
- * New function based on new table. Will
- * update description in a future update.
- */
- public function storeMoonRemoval(Request $request) {
- //Check for the correct role for the user to utilize this function
- $this->middleware('role:Admin');
-
- //Validate the request
- $this->validate($request, [
- 'remove' => 'required',
- ]);
-
- //Explode the remove request to an array of strings
- $str_array = explode(" - ", $request->remove);
-
- //Decode the value for the SPM into a system, planet, and moon
- $system = $str_array[0];
- $planet = $str_array[1];
- $moon = $str_array[2];
-
- //Update the moon rental
- AllianceRentalMoon::where([
- 'system' => $system,
- 'planet' => $planet,
- 'moon' => $moon,
- ])->update([
- 'rental_type' => 'Not Rented',
- 'rental_until' => null,
- 'rental_contact_id' => 0,
- 'rental_contact_type' => 'Not Rented',
- 'paid' => 'Not Rented',
- 'paid_until' => null,
- 'alliance_use_until' => null,
- ]);
-
- //Once the action is completed, redirect to the original page
- return redirect('/moons/admin/display/rentals')->with('success', 'Renter removed from the moon.');
- }
-
- /**
- * Function to display the moons to admins
- * New function based on new table. Will
- * update description in a future update.
- */
- public function displayRentalMoonsAdmin() {
- //Declare variables for the function
- $lookupHelper = new LookupHelper;
- $moonCalc = new MoonCalc;
- $contactId = null;
- $contactType = null;
- $paid = null;
- $paidUntil = null;
- $corpTicker = null;
- $table = array();
- //Setup the carbon date using Carbon\Carbon
- $lastMonth = Carbon::now()->subMonth();
- $today = Carbon::now();
-
- //Get the moon rentals from the database
- $rentalMoons = AllianceRentalMoon::orderBy('system', 'asc')->get();
-
- //For each of the moons compile different data for the view for formatting
- foreach($rentalMoons as $moon) {
-
- //Check if a current rental for the moon is on going
- if(($moon->rental_type == 'In Alliance' || $moon->rental_type == 'Out of Alliance')) {
- $paid = $moon->paid;
- $paidUntil = new Carbon($moon->paid_until);
- $paidUntil = $paidUntil->format('m-d');
-
- //Set the rental date up
- $rentalTemp = new Carbon($moon->rental_until);
- $rentalEnd = $rentalTemp->format('m-d');
-
- //Set the correct color for the table
- if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
- $color = 'table-warning';
- } else if($today->lessThan($rentalTemp)) {
- $color = 'table-danger';
- } else {
- $color = 'table-primary';
- }
-
- //Set the contact name based on the contact type
- if($moon->rental_contact_type == 'Alliance') {
- $allianceInfo = $lookupHelper->GetAllianceInfo($moon->rental_contact_id);
- //Set the contact name and ticker
- $contact = $allianceInfo->name;
- $ticker = $allianceInfo->ticker;
-
- } else if($moon->rental_contact_type == 'Corporation') {
- $corporationInfo = $lookupHelper->GetCorporationInfo($moon->rental_contact_id);
- //Set the contact name and ticker
- $contact = $corporationInfo->name;
- $ticker = $corporationInfo->ticker;
-
- } else if($moon->rental_contact_type == 'Character') {
- $characterInfo = $lookupHelper->GetCharacterInfo($moon->rental_contact_id);
- //Set the contact name
- $contact = $characterInfo->name;
- //Get the ticker for the character from the corporation he belongs to
- $corpInfo = $lookupHelper->GetCorporationInfo($characterInfo->corporation_id);
- $ticker = $corpInfo->ticker;
-
- } else {
- $contact = 'N/A';
- $ticker = 'N/A';
- $type = 'N/A';
- $color = 'table-primary';
- }
-
- //Check if the moon is currently being utilized by the alliance
- } else if($moon->rental_type == 'Alliance') {
- //If the moon is in use by the alliance then the moon isn't paid for
- $paid = 'No';
-
- //Setup the rental end time as the end of the month
- $rentalTemp = Carbon::now()->endOfMonth();
- $rentalEnd = $rentalTemp->format('m-d');
- //Set the color of the table
- $color = 'table-info';
-
- //Setup the paid time as the same as the rental end
- $paidUntiltemp = $rentalTemp;
- $paidUntil = $rentalEnd;
-
- //Set the other information for the spreadsheet
- $contact = 'Spatial Forces';
- $renter = 'SP3C';
- $ticker = 'SP3C';
- $type = 'Alliance';
-
- //The last case is the moon is not utilized by the Alliance or is not being rented
- } else {
- //If the moon is not being rented, or being utilized by the alliance then set paid to No
- $paid = 'No';
-
- //Setup the rental time to end as last month to show it's free
- $rentalTemp = $lastMonth;
- $rentalEnd = $rentalTemp->format('m-d');
-
- //Setup the paid until as last month to show it's free
- $paidUntilTemp = $lastMonth;
- $paidUntil = $lastMonth->format('m-d');
-
- //Setup the other variables with the correct information
- $contact = 'None';
- $renter = 'None';
- $ticker = 'N/A';
- $type = 'N/A';
-
- //Set the color of the table
- $color = 'table-primary';
- }
-
- //Set up the moon rental type
- if($moon->rental_type == 'In Alliance') {
- $type = 'IA';
- //Setup the row color
- if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
- $color = 'table-warning';
- } else if($today->lessThan($rentalTemp)) {
- $color = 'table-danger';
- } else {
- $color = 'table-primary';
- }
- } else if($moon->rental_type == 'Out of Alliance') {
- $type = 'OOA';
- //Setup the row color
- if($rentalTemp->diffInDays(Carbon::now()) < 3 && $today->lessThan($rentalTemp)) {
- $color = 'table-warning';
- } else if($today->lessThan($rentalTemp)) {
- $color = 'table-danger';
- } else {
- $color = 'table-primary';
- }
- } else if($moon->rental_type == 'Alliance') {
- $type = 'W4RP';
- //Set the row color
- $color = 'table-info';
- } else {
- $type = 'N/A';
- //Set the row color
- $color = 'table-primary';
- }
-
- //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->structure_name,
- 'AlliancePrice' => $moon->alliance_rental_price,
- 'OutOfAlliancePrice' => $moon->out_of_alliance_rental_price,
- 'RentalEnd' => $rentalEnd,
- 'RowColor' => $color,
- 'Paid' => $moon->paid,
- 'PaidUntil' => $paidUntil,
- 'Contact' => $contact,
- 'Type' => $moon->rental_type,
- 'Renter' => $type,
- ]);
- }
-
- return view('moons.admin.adminmoon')->with('table', $table);
- }
-
- /**
- * Function to store the updates from the moons.
- * New function based on new table. Will update
- * the description in a future update
- */
- public function storeUpdateMoon(Request $request) {
- //Require the site administration role
- $this->middleware('role:Admin');
-
- //Declare some variables we will need
- $moonCalc = new MoonCalc;
- $lookup = new LookupHelper;
- $paid = false;
- $system = null;
- $planet = null;
- $mn = null;
-
- //Validate our request from the html form
- $this->validate($request, [
- 'spmn' => 'required',
- 'contact' => 'required',
- 'contact_type' => 'required',
- 'paid_until' => 'required',
- 'rental_end' => 'required',
- ]);
-
- //Decode the spmn
- $str_array = explode(" - ", $request->spmn);
- $system = $str_array[0];
- $planet = $str_array[1];
- $mn = $str_array[2];
- $name = $str_array[3];
-
- //Update the paid value from the request value
- if($request->paid == 'Yes') {
- $paid = 'Yes';
- } else {
- $paid = 'No';
- }
-
- //Setup the rental end and paid until variables
- $rentalEnd = $request->rental_end . " 23:59:59";
- $paidUntil = $request->paid_until . " 23:59:59";
-
- //Check if the alliance is renting the moon for itself
- if($request->contact_type == 'Corporation' && $request->contact == 'Spatial Forces') {
- AllianceRentalMoon::where([
- 'system' => $str_array[0],
- 'planet' => $str_array[1],
- 'moon' => $str_array[2],
- ])->update([
- 'rental_type' => 'Alliance',
- 'rental_until' => $request->rental_end . " 23:59:59",
- 'rental_contact_id' => 98287666,
- 'rental_contact_type' => 'Alliance',
- 'paid' => 'No',
- 'paid_until' => null,
- 'alliance_use_until' => $request->rental_end . " 23:59:59",
- ]);
- } else if($request->contact_type == 'Character') {
- //Get the character id from the lookup helper
- $charId = $lookup->CharacterNameToId($request->contact);
- //Get the character information including the corporation from the lookup tables
- $char = $lookup->GetCharacterInfo($charId);
- //Get the corporation id from the lookup helper, followed by the alliance id
- //so we can determine if it's in alliance or out of alliance
- $corp = $lookup->GetCorporationInfo($char->corporation_id);
-
- if($corp->alliance_id == 99004116) {
- $type = 'In Alliance';
- } else {
- $type = 'Out of Alliance';
- }
-
- AllianceRentalMoon::where([
- 'system' => $str_array[0],
- 'planet' => $str_array[1],
- 'moon' => $str_array[2],
- ])->update([
- 'rental_type' => $type,
- 'rental_until' => $request->rental_end . " 23:59:59",
- 'rental_contact_id' => $charId,
- 'rental_contact_type' => 'Character',
- 'paid' => $paid,
- 'paid_until' => $request->paid_until . " 23:59:59",
- 'alliance_use_until' => null,
- ]);
-
- } else if($request->contact_type == 'Corporation') {
- //Get the corporation id from the lookup helper
- $corpId = $lookup->CorporationNameToId($request->contact);
- //Get the corporation information to determine if they are in Warped Intentions or not.
- $corporation = $lookup->GetCorporationInfo($request->contact);
-
- if($corp->alliance_id == 99004116) {
- $type = 'In Alliance';
- } else {
- $type = 'Out of Alliance';
- }
-
- AllianceMoonRental::where([
- 'system' => $str_array[0],
- 'planet' => $str_array[1],
- 'moon' => $str_array[2],
- ])->update([
- 'rental_type' => $type,
- 'rental_until' => $request->rental_end . " 23:59:59",
- 'rental_contact_id' => $corpId,
- 'rental_contact_type' => 'Corporation',
- 'paid' => $paid,
- 'paid_until' => $request->paid_until . " 23:59:59",
- 'alliance_use_until' => null,
- ]);
- }
-
- //Redirect to the previous screen.
- return redirect('/moons/admin/updatemoon')->with('success', 'Moon Rental updated.');
- }
-
public function ImportMoonSurveyData(Request $request) {
//Declare variables
$added = 0;
diff --git a/app/Http/Controllers/SystemRentals/RentalAdminController.php b/app/Http/Controllers/SystemRentals/RentalAdminController.php
deleted file mode 100644
index d62f4c3b3..000000000
--- a/app/Http/Controllers/SystemRentals/RentalAdminController.php
+++ /dev/null
@@ -1,156 +0,0 @@
-middleware('auth');
- $this->middleware('role:Admin');
- }
-
- /**
- * Function to display all active rental systems and
- * the information regarding the rental systems
- */
- public function displayRentalSystems() {
- //Get the rental systems from the database
- $rentals = RentalSystem::all();
-
- foreach($rentals as $rental) {
- //Format the rental cost
- if($rental->rental_cost > 1000000000.00) {
- $rental->rental_cost = $rental->rental_cost / 1000000000.00;
- $rental->rental_cost = $rental->rental_cost . "B";
- } else if($rental->rental_cost > 1000000.00 && $rental->rental_cost < 999999999.99) {
- $rental->rental_cost = $rental->rental_cost / 1000000.00;
- $rental->rental_cost = $rental->rental_cost . "M";
- }
-
- //Format the date
- $rental->paid_until = Carbon::parse($rental->paid_until)->format('Y-m-d');
- }
-
- //Return the view with the data
- return view('rental.list')->with('rentals', $rentals);
- }
-
- /**
- * Function to display form for adding new rental system
- */
- public function displayAddRentalSystem() {
- return view('rental.add');
- }
-
- /**
- * Function to add new rental system to the database
- */
- public function addRentalSystem(Request $request) {
- $this->validate($request, [
- 'contact_name' => 'required',
- 'contact_corp_name' => 'required',
- 'system' => 'required',
- 'rental_cost' => 'required',
- 'paid_until' => 'required',
- ]);
-
- //Declare the variables and classes needed
- $lookup = new LookupHelper;
-
- //From the character name find the character id
- $charId = $lookup->CharacterNameToId($request->contact_name);
-
- //From the corporation name find the corporation id
- $corpId = $lookup->CorporationNameToId($request->contact_corp_name);
-
- //From the system name find the system id
- $systemId = $lookup->SystemNameToId($request->system);
-
- //Sanitize the bid amount
- if(preg_match('(m|M|b|B)', $request->rental_cost) === 1) {
- if(preg_match('(m|M)', $request->rental_cost) === 1) {
- $cStringSize = strlen($request->rental_cost);
- $tempCol = str_split($request->rental_cost, $cStringSize - 1);
- $rentalCost = $tempCol[0];
- $rentalCost = $rentalCost * 1000000.00;
- } else if(preg_match('(b|B)', $request->rental_cost) === 1) {
- $cStringSize = strlen($request->rental_cost);
- $tempCol = str_split($request->rental_cost, $cStringSize - 1);
- $rentalCost = $tempCol[0];
- $rentalCost = $rentalCost * 1000000000.00;
- }
- } else {
- $rentalCost = $request->rental_cost;
- }
-
- //Create the database model
- $rental = new RentalSystem;
- $rental->contact_id = $charId;
- $rental->contact_name = $request->contact_name;
- $rental->corporation_id = $corpId;
- $rental->corporation_name = $request->contact_corp_name;
- $rental->system_id = $systemId;
- $rental->system_name = $request->system;
- $rental->rental_cost = $rentalCost;
- $rental->paid_until = $request->paid_until;
- $rental->save();
-
- return redirect('/system/rental/dashboard')->with('success', 'Rental System Added.');
- }
-
- /**
- * Function to update paid until section of the rental system in the database
- */
- public function updateRentalSystem(Request $request) {
- $this->validate($request, [
- 'paid_until' => 'required',
- 'contact_id' => 'required',
- 'corporation_id' => 'required',
- 'system_id' => 'required',
- ]);
-
- RentalSystem::where([
- 'contact_id' => $request->contact_id,
- 'corporation_id' => $request->corporation_id,
- 'system_id' => $request->system_id,
- ])->update([
- 'paid_until' => $request->paid_until,
- ]);
-
- return redirect('/system/rental/dashboard')->with('success', 'Rental System updated.');
- }
-
- /**
- * Function to remove rental system from the database
- */
- public function removeRentalSystem(Request $request) {
- $this->validate($request, [
- 'contact_id' => 'required',
- 'corporation_id' => 'required',
- 'system_id' => 'required',
- ]);
-
- RentalSystem::where([
- 'contact_id' => $request->contact_id,
- 'corporation_id' => $request->corporation_id,
- 'system_id' => $request->system_id,
- ])->delete();
-
- return redirect('/system/rental/dashboard')->with('success', 'Removed renter from database.');
- }
-}