Compare commits

..

2 Commits

Author SHA1 Message Date
Nabeel S
5450691a99 Merge branch 'dev' into snyk-fix-3063bc2ce3e22bfa7c04326e8f320d76 2021-01-17 12:43:20 -05:00
snyk-bot
828319035b fix: package.json & package-lock.json to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-CACHEBASE-1054631
2020-12-29 02:26:04 +00:00
110 changed files with 4182 additions and 19526 deletions

View File

@@ -1,3 +1,7 @@
<?php
exit();
?>
APP_ENV="dev"
APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY="
APP_URL="http://localhost"

View File

@@ -33,4 +33,4 @@ echo "FILE_NAME=${FILE_NAME}" >> $GITHUB_ENV
echo "TAR_NAME=${TAR_NAME}" >> $GITHUB_ENV
echo "ZIP_NAME=${ZIP_NAME}" >> $GITHUB_ENV
echo "BASE_DIR=${BASE_DIR}" >> $GITHUB_ENV
echo "DISCORD_MSG=Version ${FULL_VERSION} is available, download: [zip](http://downloads.phpvms.net/$ZIP_NAME) | [tar](http://downloads.phpvms.net/$TAR_NAME)" >> $GITHUB_ENV
echo "DISCORD_MSG=A new build is available at http://downloads.phpvms.net/$TAR_NAME (${FULL_VERSION})" >> $GITHUB_ENV

View File

@@ -71,6 +71,7 @@ jobs:
php --version
mysql --version
# Downgrade composer version to 1.x
composer self-update --1
composer install --dev --no-interaction --verbose
cp .github/scripts/env.php env.php
cp .github/scripts/phpunit.xml phpunit.xml
@@ -118,6 +119,7 @@ jobs:
run: |
rm -rf vendor
sudo npm i tar-to-zip -g
composer self-update --1
composer install --no-dev --prefer-dist --no-interaction --verbose
sudo chmod +x ./.github/scripts/*
@@ -181,6 +183,7 @@ jobs:
run: |
rm -rf vendor
sudo npm i tar-to-zip -g
composer self-update --1
composer install --no-dev --prefer-dist --no-interaction --verbose
sudo chmod +x ./.github/scripts/*

View File

@@ -36,7 +36,7 @@ A full development environment can be brought up using Docker:
```bash
composer install
npm install
yarn install
docker-compose build
docker-compose up
```

View File

@@ -13,11 +13,7 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule. How this works... according to the command
* time, an event gets send out with the appropriate time (e.g, hourly sends an hourly event)
*
* Then the CronServiceProvider has the list of cronjobs which then run according to the events
* and then calls those at the proper times.
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
@@ -31,13 +27,10 @@ class Kernel extends ConsoleKernel
$schedule->command(Hourly::class)->hourly();
// When spatie-backups runs
/*if (config('backup.backup.enabled', false) === true) {
$schedule->command('backup:clean')->daily()->at('01:00');
$schedule->command('backup:run')->daily()->at('02:00');
}*/
$schedule->command('backup:clean')->daily()->at('01:00');
$schedule->command('backup:run')->daily()->at('02:00');
// Update the last time the cron was run
/** @var CronService $cronSvc */
$cronSvc = app(CronService::class);
$cronSvc->updateLastRunTime();
}

View File

@@ -12,24 +12,13 @@ abstract class Metar
{
/**
* Implement retrieving the METAR - return the METAR string. Needs to be protected,
* since this shouldn't be directly called. Call `metar($icao)`. If not implemented,
* return a blank string
* since this shouldn't be directly called. Call `get_metar($icao)` instead
*
* @param $icao
*
* @return mixed
*/
abstract protected function get_metar($icao): string;
/**
* Implement retrieving the TAF - return the string. Call `taf($icao)`. If not implemented,
* return a blank string
*
* @param $icao
*
* @return mixed
*/
abstract protected function get_taf($icao): string;
abstract protected function metar($icao): string;
/**
* Download the METAR, wrap in caching
@@ -38,9 +27,9 @@ abstract class Metar
*
* @return string
*/
public function metar($icao): string
public function get_metar($icao): string
{
$cache = config('cache.keys.METAR_WEATHER_LOOKUP');
$cache = config('cache.keys.WEATHER_LOOKUP');
$key = $cache['key'].$icao;
if (Cache::has($key)) {
@@ -51,7 +40,7 @@ abstract class Metar
}
try {
$raw_metar = $this->get_metar($icao);
$raw_metar = $this->metar($icao);
} catch (\Exception $e) {
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
return '';
@@ -63,37 +52,4 @@ abstract class Metar
return $raw_metar;
}
/**
* Download the TAF, wrap in caching
*
* @param $icao
*
* @return string
*/
public function taf($icao): string
{
$cache = config('cache.keys.TAF_WEATHER_LOOKUP');
$key = $cache['key'].$icao;
if (Cache::has($key)) {
$taf = Cache::get($key);
if ($taf !== '') {
return $taf;
}
}
try {
$taf = $this->get_taf($icao);
} catch (\Exception $e) {
Log::error('Error getting TAF: '.$e->getMessage(), $e->getTrace());
return '';
}
if ($taf !== '') {
Cache::put($key, $taf, $cache['time']);
}
return $taf;
}
}

View File

@@ -1,52 +0,0 @@
<?php
namespace App\Cron\Hourly;
use App\Contracts\Listener;
use App\Events\CronHourly;
use App\Models\Enums\PirepState;
use App\Models\Pirep;
use App\Services\PirepService;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
/**
* Remove cancelled/deleted PIREPs. Look for PIREPs that were created before the setting time
* (e.g, 12 hours ago) and are marked with the
*/
class DeletePireps extends Listener
{
/**
* Remove expired bids
*
* @param CronHourly $event
*
* @throws \Exception
*/
public function handle(CronHourly $event): void
{
$this->deletePireps(setting('pireps.delete_rejected_hours'), PirepState::REJECTED);
$this->deletePireps(setting('pireps.delete_cancelled_hours'), PirepState::CANCELLED);
}
/**
* Look for and delete PIREPs which match the criteria
*
* @param int $expire_time_hours The time in hours to look for PIREPs
* @param int $state The PirepState enum value
*/
protected function deletePireps(int $expire_time_hours, int $state)
{
$dt = Carbon::now()->subHours($expire_time_hours);
$pireps = Pirep::whereDate('created_at', '<', $dt)->where(['state' => $state])->get();
/** @var PirepService $pirepSvc */
$pirepSvc = app(PirepService::class);
/** @var Pirep $pirep */
foreach ($pireps as $pirep) {
Log::info('Cron: Deleting PIREP id='.$pirep->id.', state='.PirepState::label($state));
$pirepSvc->delete($pirep);
}
}
}

View File

@@ -6,7 +6,6 @@ use App\Contracts\Listener;
use App\Events\CronMonthly;
use App\Models\Enums\ExpenseType;
use App\Services\Finance\RecurringFinanceService;
use Illuminate\Support\Facades\Log;
/**
* Go through and apply any finances that are daily
@@ -36,7 +35,6 @@ class ApplyExpenses extends Listener
*/
public function handle(CronMonthly $event): void
{
Log::info('Monthly: Applying monthly expenses');
$this->financeSvc->processExpenses(ExpenseType::MONTHLY);
}
}

View File

@@ -6,7 +6,6 @@ use App\Contracts\Listener;
use App\Events\CronNightly;
use App\Models\Enums\ExpenseType;
use App\Services\Finance\RecurringFinanceService;
use Illuminate\Support\Facades\Log;
/**
* Go through and apply any finances that are daily
@@ -36,7 +35,6 @@ class ApplyExpenses extends Listener
*/
public function handle(CronNightly $event): void
{
Log::info('Nightly: Applying daily expenses');
$this->financeSvc->processExpenses(ExpenseType::DAILY);
}
}

View File

@@ -5,7 +5,6 @@ namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly;
use App\Services\SimBriefService;
use Illuminate\Support\Facades\Log;
/**
* Clear any expired SimBrief flight briefs that aren't attached to a PIREP
@@ -24,7 +23,6 @@ class ClearExpiredSimbrief extends Listener
*/
public function handle(CronNightly $event): void
{
Log::info('Nightly: Removing expired Simbrief entries');
$this->simbriefSvc->removeExpiredEntries();
}
}

View File

@@ -5,7 +5,6 @@ namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly;
use App\Services\VersionService;
use Illuminate\Support\Facades\Log;
/**
* Determine if any pilots should be set to ON LEAVE status
@@ -29,7 +28,6 @@ class NewVersionCheck extends Listener
*/
public function handle(CronNightly $event): void
{
Log::info('Nightly: Checking for new version');
$this->versionSvc->isNewVersionAvailable();
}
}

View File

@@ -4,8 +4,10 @@ namespace App\Cron\Nightly;
use App\Contracts\Listener;
use App\Events\CronNightly;
use App\Models\Enums\UserState;
use App\Models\User;
use App\Services\UserService;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon;
/**
* Determine if any pilots should be set to ON LEAVE status
@@ -16,8 +18,6 @@ class PilotLeave extends Listener
/**
* PilotLeave constructor.
*
* @param UserService $userSvc
*/
public function __construct(UserService $userSvc)
{
@@ -34,9 +34,13 @@ class PilotLeave extends Listener
*/
public function handle(CronNightly $event): void
{
Log::info('Cron: Running pilot leave check');
$users = $this->userSvc->findUsersOnLeave();
Log::info('Found '.count($users).' users on leave');
if (setting('pilots.auto_leave_days') === 0) {
return;
}
$date = Carbon::now()->subDay(setting('pilots.auto_leave_days'));
$users = User::where('status', UserState::ACTIVE)
->whereDate('updated_at', '<', $date);
foreach ($users as $user) {
Log::info('Setting user '.$user->ident.' to ON LEAVE status');

View File

@@ -35,7 +35,7 @@ class RecalculateBalances extends Listener
*/
public function handle(CronNightly $event): void
{
Log::info('Nightly: Recalculating balances');
Log::info('Recalculating balances');
$journals = Journal::all();
foreach ($journals as $journal) {

View File

@@ -32,10 +32,10 @@ class RecalculateStats extends Listener
*/
public function handle(CronNightly $event): void
{
Log::info('Nightly: Recalculating user stats');
Log::info('Recalculating user stats');
$this->userSvc->recalculateAllUserStats();
Log::info('Nightly: Recalcuating aircraft status');
Log::info('Recalcuating aircraft status');
$this->aircraftSvc->recalculateStats();
}
}

View File

@@ -19,8 +19,6 @@ class SetActiveFlights extends Listener
*/
public function handle(CronNightly $event): void
{
Log::info('Nightly: Setting active flights');
$this->checkFlights();
}
@@ -44,18 +42,23 @@ class SetActiveFlights extends Listener
continue;
}
// Set to visible by default
$flight->visible = true;
// dates aren't set, so just save if there were any changes above
// and move onto the next one
if ($flight->start_date === null || $flight->end_date === null) {
if ($flight->days !== null && $flight->days > 0) {
$flight->visible = Days::isToday($flight->days);
if (!$flight->visible) {
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
$visible = Days::isToday($flight->days);
if ($flight->visible !== $visible) {
Log::info('Flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden'));
$flight->visible = $visible;
if ($visible === false) {
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
}
}
} else {
Log::info('Toggling flight '.$flight->ident.' to visible');
$flight->visible = true;
}
$flight->save();
@@ -68,11 +71,20 @@ class SetActiveFlights extends Listener
// and then make sure if days of the week are specified, check that too
if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) {
if ($flight->days !== null && $flight->days > 0) {
$flight->visible = Days::isToday($flight->days);
if (!$flight->visible) {
Log::info('Today='.date('N').', start=no, mask='.$flight->days.', in='
$visible = Days::isToday($flight->days);
if ($flight->visible !== $visible) {
Log::info('Toggling flight '.$flight->ident.' to '.($visible ? 'shown' : 'hidden').'');
$flight->visible = $visible;
if ($visible === false) {
Log::info('Today='.date('N').', start='.$flight->start_date
.', end='.$flight->end_date.', mask='.$flight->days.', in='
.Days::in($flight->days, Days::$isoDayMap[(int) date('N')]));
}
}
} else {
Log::info('Toggling flight '.$flight->ident.' to visible');
$flight->visible = true;
}
} else {
$flight->visible = false;

View File

@@ -1,18 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Change the vertical speed for the acars table to a double
*/
class ChangeAcarsVsType extends Migration
{
public function up()
{
Schema::table('acars', function (Blueprint $table) {
$table->float('vs')->change()->default(0.0)->nullable();
});
}
}

View File

@@ -1,19 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Bring the sessions table in line with the latest
*/
class UpdateSessionsTable extends Migration
{
public function up()
{
Schema::table('sessions', function (Blueprint $table) {
$table->index('user_id');
$table->index('last_activity');
});
}
}

View File

@@ -1,21 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a `fuel_onboard` column for recording what is left in tanks
*/
class AircraftAddFuelonboard extends Migration
{
public function up()
{
Schema::table('aircraft', function (Blueprint $table) {
$table->unsignedDecimal('fuel_onboard')
->nullable()
->default(0.0)
->after('zfw');
});
}
}

View File

@@ -1,20 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a SimBrief Type to subfleet
*/
class AddSbtypeToSubfleets extends Migration
{
public function up()
{
Schema::table('subfleets', function (Blueprint $table) {
$table->string('simbrief_type', 20)
->nullable()
->after('type');
});
}
}

View File

@@ -1,24 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a hub to the subfleet is
*/
class AddAircraftToSimbrief extends Migration
{
public function up()
{
Schema::table('simbrief', function (Blueprint $table) {
$table->unsignedInteger('aircraft_id')
->nullable()
->after('pirep_id');
// Temp column to hold the calculated fare data for the API
// Remove this once the prefile to acars feature is completed
$table->mediumText('fare_data')->nullable()->after('ofp_xml');
});
}
}

View File

@@ -1,19 +0,0 @@
<?php
use App\Contracts\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Add a hub to the subfleet is
*/
class AddKvpTable extends Migration
{
public function up()
{
Schema::create('kvp', function (Blueprint $table) {
$table->string('key')->index();
$table->string('value');
});
}
}

View File

@@ -119,8 +119,8 @@ aircraft:
-
id: 1
subfleet_id: 1
icao: B744
iata: 744
icao: null
iata: null
airport_id: KJFK
landing_time: '2020-10-23 07:50:16'
name: 'Boeing 747-438'
@@ -136,8 +136,8 @@ aircraft:
-
id: 2
subfleet_id: 2
icao: B777
iata: 777
icao: null
iata: null
airport_id: LGRP
landing_time: null
name: 'Boeing 777-200'
@@ -153,8 +153,8 @@ aircraft:
-
id: 3
subfleet_id: 1
icao: B744
iata: 744
icao: null
iata: null
airport_id: KAUS
landing_time: '2020-10-24 08:50:13'
name: 'Boeing 747-412'
@@ -170,8 +170,8 @@ aircraft:
-
id: 4
subfleet_id: 1
icao: B744
iata: 744
icao: null
iata: null
airport_id: KAUS
landing_time: null
name: 'Boeing 747-436 RETIRED'
@@ -187,7 +187,7 @@ aircraft:
-
id: 5
subfleet_id: 4
icao: 'A320'
icao: A320
iata: '320'
airport_id: EGLL
landing_time: null

View File

@@ -180,12 +180,12 @@
type: number
description: 'How much the load factor can vary per-flight'
- key: simbrief.api_key
name: 'Simbrief API Key'
name: 'SimBrief API Key'
group: simbrief
value: ''
options: ''
type: string
description: 'Your Simbrief API key'
description: 'Your SimBrief API key'
- key: simbrief.only_bids
name: 'Only allow for bids'
group: simbrief
@@ -194,47 +194,12 @@
type: boolean
description: 'Only allow briefs to be created for bidded flights'
- key: simbrief.expire_days
name: 'Simbrief Expire Time'
name: 'SimBrief Expire Time'
group: simbrief
value: 5
options: ''
type: number
description: 'Days after how long to remove unused briefs'
- key: simbrief.noncharter_pax_weight
name: 'Non-Charter Passenger Weight'
group: simbrief
value: 185
options: ''
type: number
description: 'Passenger weight for non-charter flights excluding baggage (lbs)'
- key: simbrief.noncharter_baggage_weight
name: 'Non-Charter Baggage Weight'
group: simbrief
value: 35
options: ''
type: number
description: 'Passenger baggage weight for non-charter flights (lbs)'
- key: simbrief.charter_pax_weight
name: 'Charter Passenger Weight'
group: simbrief
value: 168
options: ''
type: number
description: 'Passenger weight for charter flights excluding baggage (lbs)'
- key: simbrief.charter_baggage_weight
name: 'Charter Baggage Weight'
group: simbrief
value: 28
options: ''
type: number
description: 'Passenger baggage weight for charter flights (lbs)'
- key: simbrief.callsign
name: 'Use ATC Callsign'
group: simbrief
value: false
options: ''
type: boolean
description: 'Use pilot ident as Simbrief ATC Callsign'
- key: pireps.duplicate_check_time
name: 'PIREP duplicate time check'
group: pireps
@@ -263,27 +228,6 @@
options: ''
type: boolean
description: 'When a PIREP is accepted, remove the bid, if it exists'
- key: pireps.advanced_fuel
name: 'Advanced Fuel Calculations'
group: pireps
value: false
options: ''
type: boolean
description: 'Enables remaining fuel amounts to be considered for fuel expenses'
- key: pireps.delete_cancelled_hours
name: 'Delete cancelled PIREPs'
group: pireps
value: 12
options: ''
type: int
description: 'The time in hours to delete a cancelled PIREP'
- key: pireps.delete_rejected_hours
name: 'Delete rejected PIREPs'
group: pireps
value: 12
options: ''
type: int
description: 'The time in hours to delete a rejected PIREP'
- key: pilots.id_length
name: 'Pilot ID Length'
group: pilots
@@ -361,9 +305,3 @@
options: ''
type: 'text'
description: 'Discord public channel ID for broadcasat notifications'
- key: 'cron.random_id'
name: 'Cron Randomized ID'
group: 'cron'
value: ''
type: 'hidden'
description: ''

View File

@@ -1,37 +0,0 @@
<?php
namespace App\Exceptions;
class CronInvalid extends AbstractHttpException
{
public const MESSAGE = 'Cron ID is disabled or invalid';
public function __construct()
{
parent::__construct(400, static::MESSAGE);
}
/**
* Return the RFC 7807 error type (without the URL root)
*/
public function getErrorType(): string
{
return 'cron-invalid';
}
/**
* Get the detailed error string
*/
public function getErrorDetails(): string
{
return $this->getMessage();
}
/**
* Return an array with the error details, merged with the RFC7807 response
*/
public function getErrorMetadata(): array
{
return [];
}
}

View File

@@ -186,13 +186,13 @@ class AwardController extends Controller
{
$award = $this->awardRepository->findWithoutFail($id);
if (empty($award)) {
Flash::error('Award not found');
Flash::error('Fare not found');
return redirect(route('admin.awards.index'));
}
$this->awardRepository->delete($id);
Flash::success('Award deleted successfully.');
Flash::success('Fare deleted successfully.');
return redirect(route('admin.awards.index'));
}

View File

@@ -6,7 +6,6 @@ use App\Contracts\Controller;
use App\Repositories\KvpRepository;
use App\Services\CronService;
use App\Services\VersionService;
use App\Support\Utils;
use Codedge\Updater\UpdaterManager;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
@@ -35,12 +34,7 @@ class MaintenanceController extends Controller
public function index()
{
// Get the cron URL
$cron_id = setting('cron.random_id');
$cron_url = empty($cron_id) ? 'Not enabled' : url(route('api.maintenance.cron', $cron_id));
return view('admin.maintenance.index', [
'cron_url' => $cron_url,
'cron_path' => $this->cronSvc->getCronExecString(),
'cron_problem_exists' => $this->cronSvc->cronProblemExists(),
'new_version' => $this->kvpRepo->get('new_version_available', false),
@@ -123,33 +117,4 @@ class MaintenanceController extends Controller
return redirect('/update/downloader');
}
/**
* Enable the cron, or if it's enabled, change the ID that is used
*
* @param Request $request
*/
public function cron_enable(Request $request)
{
$id = Utils::generateNewId(24);
setting_save('cron.random_id', $id);
Flash::success('Web cron refreshed!');
return redirect(route('admin.maintenance.index'));
}
/**
* Disable the web cron
*
* @param Request $request
*
* @return mixed
*/
public function cron_disable(Request $request)
{
setting_save('cron.random_id', '');
Flash::success('Web cron disabled!');
return redirect(route('admin.maintenance.index'));
}
}

View File

@@ -394,10 +394,10 @@ class PirepController extends Controller
return redirect(route('admin.pireps.index'));
}
$this->pirepSvc->delete($pirep);
$this->pirepRepo->delete($id);
Flash::success('Pirep deleted successfully.');
return redirect()->back();
return redirect(route('admin.pireps.index'));
}
/**

View File

@@ -62,7 +62,7 @@ class SettingsController extends Controller
*/
public function index()
{
$settings = Setting::where('type', '!=', 'hidden')->orderBy('order')->get();
$settings = Setting::orderBy('order', 'asc')->get();
$settings = $settings->groupBy('group');
return view('admin.settings.index', [

View File

@@ -7,7 +7,6 @@ use App\Exceptions\AssetNotFound;
use App\Http\Resources\Flight as FlightResource;
use App\Http\Resources\Navdata as NavdataResource;
use App\Models\SimBrief;
use App\Models\User;
use App\Repositories\Criteria\WhereCriteria;
use App\Repositories\FlightRepository;
use App\Services\FareService;
@@ -153,25 +152,20 @@ class FlightController extends Controller
*
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
*/
public function briefing(string $id)
public function briefing($id)
{
/** @var User $user */
$user = Auth::user();
$w = [
'id' => $id,
'user_id' => $user->id,
'flight_id' => $id,
];
/** @var SimBrief $simbrief */
$simbrief = SimBrief::where($w)->first();
if ($simbrief === null) {
throw new AssetNotFound(new Exception('Flight briefing not found'));
}
/*if ($simbrief->user_id !== $user->id) {
throw new Unauthorized(new Exception('User cannot access another user\'s simbrief'));
}*/
return response($simbrief->acars_xml, 200, [
'Content-Type' => 'application/xml',
]);

View File

@@ -1,35 +0,0 @@
<?php
namespace App\Http\Controllers\Api;
use App\Contracts\Controller;
use App\Exceptions\CronInvalid;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
class MaintenanceController extends Controller
{
/**
* Run the cron job from the web
*
* @param Request $request
* @param string $id The ID passed in for the cron
*
* @return mixed
*/
public function cron(Request $request, string $id)
{
$cron_id = setting('cron.random_id');
if (empty($cron_id) || $id !== $cron_id) {
throw new CronInvalid();
}
$output = '';
Artisan::call('schedule:run');
$output .= trim(Artisan::output());
return response([
'content' => $output,
]);
}
}

View File

@@ -22,6 +22,8 @@ use App\Models\Acars;
use App\Models\Enums\AcarsType;
use App\Models\Enums\PirepFieldSource;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Models\Pirep;
use App\Models\PirepComment;
use App\Repositories\AcarsRepository;
@@ -36,6 +38,9 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
/**
* Class PirepController
*/
class PirepController extends Controller
{
private $acarsRepo;
@@ -88,10 +93,6 @@ class PirepController extends Controller
$attrs['created_at'] = Carbon::createFromTimeString($attrs['created_at']);
}
if (array_key_exists('submitted_at', $attrs)) {
$attrs['submitted_at'] = Carbon::createFromTimeString($attrs['submitted_at']);
}
if (array_key_exists('updated_at', $attrs)) {
$attrs['updated_at'] = Carbon::createFromTimeString($attrs['updated_at']);
}
@@ -305,8 +306,14 @@ class PirepController extends Controller
}
}
$attrs['state'] = PirepState::PENDING;
$attrs['status'] = PirepStatus::ARRIVED;
$attrs['submitted_at'] = Carbon::now('UTC');
$pirep = $this->pirepRepo->update($attrs, $pirep_id);
try {
$pirep = $this->pirepSvc->file($pirep, $attrs);
$pirep = $this->pirepSvc->create($pirep);
$this->updateFields($pirep, $request);
$this->updateFares($pirep, $request);
} catch (\Exception $e) {

View File

@@ -106,8 +106,7 @@ class UserController extends Controller
*/
public function bids(Request $request)
{
$user_id = $this->getUserId($request);
$user = $this->userSvc->getUser($user_id);
$user = $this->userSvc->getUser($this->getUserId($request));
// Add a bid
if ($request->isMethod('PUT') || $request->isMethod('POST')) {

View File

@@ -28,10 +28,7 @@ class DashboardController extends Controller
*/
public function index()
{
//dd(config('backup'));
$last_pirep = null;
/** @var \App\Models\User $user */
$user = Auth::user();
try {

View File

@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Frontend;
use App\Contracts\Controller;
use App\Models\Bid;
use App\Models\Enums\FlightType;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use App\Repositories\Criteria\WhereCriteria;
@@ -106,13 +105,7 @@ class FlightController extends Controller
}
$flights = $this->flightRepo->searchCriteria($request)
->with([
'dpt_airport',
'arr_airport',
'airline',
'simbrief' => function ($query) use ($user) {
$query->where('user_id', $user->id);
}, ])
->with(['dpt_airport', 'arr_airport', 'airline'])
->orderBy('flight_number', 'asc')
->orderBy('route_leg', 'asc')
->paginate();
@@ -121,14 +114,12 @@ class FlightController extends Controller
->pluck('flight_id')->toArray();
return view('flights.index', [
'user' => $user,
'airlines' => $this->airlineRepo->selectBoxList(true),
'airports' => $this->airportRepo->selectBoxList(true),
'flights' => $flights,
'saved' => $saved_flights,
'subfleets' => $this->subfleetRepo->selectBoxList(true),
'flight_number' => $request->input('flight_number'),
'flight_types' => FlightType::select(true),
'flight_type' => $request->input('flight_type'),
'arr_icao' => $request->input('arr_icao'),
'dep_icao' => $request->input('dep_icao'),
@@ -154,18 +145,11 @@ class FlightController extends Controller
$flights = collect();
$saved_flights = [];
foreach ($user->bids as $bid) {
// Remove any invalid bids (flight doesn't exist or something)
if (!$bid->flight) {
$bid->delete();
continue;
}
$flights->add($bid->flight);
$saved_flights[] = $bid->flight->id;
}
return view('flights.bids', [
'user' => $user,
'airlines' => $this->airlineRepo->selectBoxList(true),
'airports' => $this->airportRepo->selectBoxList(true),
'flights' => $flights,

View File

@@ -7,7 +7,7 @@ use App\Http\Requests\CreatePirepRequest;
use App\Http\Requests\UpdatePirepRequest;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Models\Fare;
use App\Models\Enums\PirepStatus;
use App\Models\Pirep;
use App\Models\SimBrief;
use App\Models\User;
@@ -253,48 +253,23 @@ class PirepController extends Controller
/**
* They have a SimBrief ID, load that up and figure out the flight that it's from
*/
$fare_values = [];
$simbrief = null;
$simbrief_id = null;
$aircraft = null;
if ($request->has('sb_id')) {
$simbrief_id = $request->input('sb_id');
$simbrief = SimBrief::find($simbrief_id);
$pirep = Pirep::fromSimBrief($simbrief);
$aircraft = $simbrief->aircraft;
$aircraft_list[$aircraft->subfleet->name] = [];
$aircraft_list[$aircraft->subfleet->name][$aircraft->id] = $aircraft->name.' - '.$aircraft->registration;
// Convert the fare data into the expected output format
if (!empty($simbrief->fare_data)) {
$fare_values = json_decode($simbrief->fare_data, true);
$fares = [];
$fare_data = json_decode($simbrief->fare_data, true);
foreach ($fare_data as $fare) {
$fares[] = new Fare($fare);
}
$aircraft->subfleet->fares = collect($fares);
}
// TODO: Set more fields from the Simbrief to the PIREP form
} else {
$aircraft_list = $this->aircraftList(true);
$brief = SimBrief::find($simbrief_id);
$pirep = Pirep::fromSimBrief($brief);
}
return view('pireps.create', [
'aircraft' => $aircraft,
'aircraft' => null,
'pirep' => $pirep,
'read_only' => false,
'airline_list' => $this->airlineRepo->selectBoxList(true),
'aircraft_list' => $aircraft_list,
'aircraft_list' => $this->aircraftList(true),
'airport_list' => $this->airportRepo->selectBoxList(true),
'pirep_fields' => $this->pirepFieldRepo->all(),
'field_values' => [],
'fare_values' => $fare_values,
'simbrief_id' => $simbrief_id,
'simbrief' => $simbrief,
]);
}
@@ -518,8 +493,12 @@ class PirepController extends Controller
$this->pirepSvc->submit($pirep);
Flash::success('PIREP submitted!');
} elseif ($attrs['submit'] === 'delete' || $attrs['submit'] === 'cancel') {
$this->pirepSvc->delete($pirep);
Flash::success('PIREP deleted!');
$this->pirepRepo->update([
'state' => PirepState::CANCELLED,
'status' => PirepStatus::CANCELLED,
], $pirep->id);
Flash::success('PIREP cancelled!');
return redirect(route('frontend.pireps.index'));
}

View File

@@ -52,7 +52,7 @@ class ProfileController extends Controller
{
// Is the ACARS module enabled?
$acars_enabled = false;
$acars = Module::find('VMSAcars');
$acars = Module::find('VMSACARS');
if ($acars) {
$acars_enabled = $acars->isEnabled();
}
@@ -95,7 +95,6 @@ class ProfileController extends Controller
'user' => $user,
'userFields' => $userFields,
'airports' => $airports,
'acars' => $this->acarsEnabled(),
]);
}
@@ -122,7 +121,7 @@ class ProfileController extends Controller
$airlines = $this->airlineRepo->selectBoxList();
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
$userFields = $this->userRepo->getUserFields($user, true);
$userFields = $this->userRepo->getUserFields($user, false);
return view('profile.edit', [
'user' => $user,

View File

@@ -3,38 +3,22 @@
namespace App\Http\Controllers\Frontend;
use App\Exceptions\AssetNotFound;
use App\Models\Aircraft;
use App\Models\Enums\FareType;
use App\Models\Enums\FlightType;
use App\Models\Fare;
use App\Models\Flight;
use App\Models\SimBrief;
use App\Models\User;
use App\Repositories\FlightRepository;
use App\Services\FareService;
use App\Services\SimBriefService;
use App\Services\UserService;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class SimBriefController
{
private $fareSvc;
private $flightRepo;
private $simBriefSvc;
private $userSvc;
public function __construct(
FareService $fareSvc,
FlightRepository $flightRepo,
SimBriefService $simBriefSvc,
UserService $userSvc
) {
$this->fareSvc = $fareSvc;
public function __construct(FlightRepository $flightRepo, SimBriefService $simBriefSvc)
{
$this->flightRepo = $flightRepo;
$this->simBriefSvc = $simBriefSvc;
$this->userSvc = $userSvc;
}
/**
@@ -48,15 +32,8 @@ class SimBriefController
*/
public function generate(Request $request)
{
/** @var \App\Models\User $user */
$user = Auth::user();
$flight_id = $request->input('flight_id');
$aircraft_id = $request->input('aircraft_id');
/** @var Flight $flight */
$flight = $this->flightRepo->with(['fares', 'subfleets'])->find($flight_id);
$flight = $this->flightRepo->find($flight_id);
if (!$flight) {
flash()->error('Unknown flight');
return redirect(route('frontend.flights.index'));
@@ -68,22 +45,7 @@ class SimBriefController
return redirect(route('frontend.flights.index'));
}
// No aircraft selected, show selection form
if (!$aircraft_id) {
// If no subfleets defined for flight get them from user
if ($flight->subfleets->count() > 0) {
$subfleets = $flight->subfleets;
} else {
$subfleets = $this->userSvc->getAllowableSubfleets($user);
}
return view('flights.simbrief_aircraft', [
'flight' => $flight,
'subfleets' => $subfleets,
]);
}
// Check if a Simbrief profile already exists
$user = Auth::user();
$simbrief = SimBrief::select('id')->where([
'flight_id' => $flight_id,
'user_id' => $user->id,
@@ -93,119 +55,8 @@ class SimBriefController
return redirect(route('frontend.simbrief.briefing', [$simbrief->id]));
}
// SimBrief profile does not exists and everything else is ok
// Select aircraft which will be used for calculations and details
/** @var Aircraft $aircraft */
$aircraft = Aircraft::where('id', $aircraft_id)->first();
// Figure out the proper fares to use for this flight/aircraft
$all_fares = $this->fareSvc->getFareWithOverrides($aircraft->subfleet->fares, $flight->fares);
// TODO: Reconcile the fares for this aircraft w/ proper for the flight/subfleet
// Get passenger and baggage weights with failsafe defaults
if ($flight->flight_type === FlightType::CHARTER_PAX_ONLY) {
$pax_weight = setting('simbrief.charter_pax_weight', 168);
$bag_weight = setting('simbrief.charter_baggage_weight', 28);
} else {
$pax_weight = setting('simbrief.noncharter_pax_weight', 185);
$bag_weight = setting('simbrief.noncharter_baggage_weight', 35);
}
// Get the load factors with failsafe for loadmax if nothing is defined
$lfactor = $flight->load_factor ?? setting('flights.default_load_factor');
$lfactorv = $flight->load_factor_variance ?? setting('flights.load_factor_variance');
$loadmin = $lfactor - $lfactorv;
$loadmin = $loadmin < 0 ? 0 : $loadmin;
$loadmax = $lfactor + $lfactorv;
$loadmax = $loadmax > 100 ? 100 : $loadmax;
if ($loadmax === 0) {
$loadmax = 100;
}
// Load fares for passengers
$loaddist = []; // The load distribution string
$pax_load_sheet = [];
$tpaxfig = 0;
/** @var Fare $fare */
foreach ($all_fares as $fare) {
if ($fare->type !== FareType::PASSENGER || empty($fare->capacity)) {
continue;
}
$count = floor(($fare->capacity * rand($loadmin, $loadmax)) / 100);
$tpaxfig += $count;
$pax_load_sheet[] = [
'id' => $fare->id,
'code' => $fare->code,
'name' => $fare->name,
'type' => $fare->type,
'capacity' => (int) $fare->capacity,
'count' => $count,
];
$loaddist[] = $fare->code.' '.$count;
}
// Calculate total weights
if (setting('units.weight') === 'kg') {
$tpaxload = round(($pax_weight * $tpaxfig) / 2.205);
$tbagload = round(($bag_weight * $tpaxfig) / 2.205);
} else {
$tpaxload = round($pax_weight * $tpaxfig);
$tbagload = round($bag_weight * $tpaxfig);
}
// Load up fares for cargo
$tcargoload = 0;
$cargo_load_sheet = [];
foreach ($all_fares as $fare) {
if ($fare->type !== FareType::CARGO || empty($fare->capacity)) {
continue;
}
$count = ceil((($fare->capacity - $tbagload) * rand($loadmin, $loadmax)) / 100);
$tcargoload += $count;
$cargo_load_sheet[] = [
'id' => $fare->id,
'code' => $fare->code,
'name' => $fare->name,
'type' => $fare->type,
'capacity' => $fare->capacity,
'count' => $count,
];
$loaddist[] = $fare->code.' '.$count;
}
$tpayload = $tpaxload + $tbagload + $tcargoload;
$request->session()->put('simbrief_fares', array_merge($pax_load_sheet, $cargo_load_sheet));
// Show the main simbrief form
return view('flights.simbrief_form', [
'user' => Auth::user(),
'flight' => $flight,
'aircraft' => $aircraft,
'pax_weight' => $pax_weight,
'bag_weight' => $bag_weight,
'loadmin' => $loadmin,
'loadmax' => $loadmax,
'pax_load_sheet' => $pax_load_sheet,
'cargo_load_sheet' => $cargo_load_sheet,
'tpaxfig' => $tpaxfig,
'tpaxload' => $tpaxload,
'tbagload' => $tbagload,
'tpayload' => $tpayload,
'tcargoload' => $tcargoload,
'loaddist' => implode(' ', $loaddist),
'flight' => $flight,
]);
}
@@ -224,18 +75,8 @@ class SimBriefController
return redirect(route('frontend.flights.index'));
}
$str = $simbrief->xml->aircraft->equip;
$wc = stripos($str, '-');
$tr = stripos($str, '/');
$wakecat = substr($str, 0, $wc);
$equipment = substr($str, $wc + 1, $tr - 2);
$transponder = substr($str, $tr + 1);
return view('flights.simbrief_briefing', [
'simbrief' => $simbrief,
'wakecat' => $wakecat,
'equipment' => $equipment,
'transponder' => $transponder,
'simbrief' => $simbrief,
]);
}
@@ -245,30 +86,21 @@ class SimBriefController
*
* @param \Illuminate\Http\Request $request
*
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function generate_new(Request $request)
public function remove(Request $request)
{
$simbrief = SimBrief::find($request->id);
// Invalid Simbrief ID/profile, go back to the main flight index
if (!$simbrief) {
return redirect(route('frontend.flights.index'));
$sb_pack = SimBrief::find($request->id);
if ($sb_pack) {
if (!$sb_pack->pirep_id) {
$sb_pack->delete();
} else {
$sb_pack->flight_id = null;
$sb_pack->save();
}
}
// Cleanup the current Simbrief entry and redirect to the new generation form
// If there isn't a PIREP ID, then delete the entry, otherwise, remove the flight
$flight_id = $simbrief->flight_id;
if (!$simbrief->pirep_id) {
$simbrief->delete();
} else {
$simbrief->flight_id = null;
$simbrief->save();
}
return redirect(route('frontend.simbrief.generate').'?flight_id='.$flight_id);
return redirect(route('frontend.flights.index'));
}
/**
@@ -310,7 +142,6 @@ class SimBriefController
/**
* Check whether the OFP was generated. Pass in two items, the flight_id and ofp_id
* This does the actual "attachment" of the Simbrief to the flight
*
* @param \Illuminate\Http\Request $request
*
@@ -318,14 +149,10 @@ class SimBriefController
*/
public function check_ofp(Request $request)
{
/** @var User $user */
$user = Auth::user();
$ofp_id = $request->input('ofp_id');
$flight_id = $request->input('flight_id');
$aircraft_id = $request->input('aircraft_id');
$fares = $request->session()->get('simbrief_fares', []);
$simbrief = $this->simBriefSvc->downloadOfp($user->id, $ofp_id, $flight_id, $aircraft_id, $fares);
$simbrief = $this->simBriefSvc->checkForOfp(Auth::user()->id, $ofp_id, $flight_id);
if ($simbrief === null) {
$error = new AssetNotFound(new Exception('Simbrief OFP not found'));
return $error->getResponse();

View File

@@ -39,7 +39,7 @@ class ApiAuth implements Middleware
return $this->unauthorized('User not found with key "'.$api_key.'"');
}
if ($user->state !== UserState::ACTIVE && $user->state !== UserState::ON_LEAVE) {
if ($user->state !== UserState::ACTIVE) {
return $this->unauthorized('User is not ACTIVE, please contact an administrator');
}

View File

@@ -17,7 +17,6 @@ class Fare extends Resource
'name' => $this->name,
'capacity' => $this->capacity,
'cost' => $this->cost,
'count' => $this->count ?? 0,
'price' => $this->price,
'type' => $this->type,
'notes' => $this->notes,

View File

@@ -27,7 +27,6 @@ class Pirep extends Resource
{
$res = parent::toArray($request);
$res['ident'] = $this->ident;
$res['phase'] = $this->status;
$res['status_text'] = PirepStatus::label($this->status);
// Set these to the response units
@@ -38,13 +37,6 @@ class Pirep extends Resource
$distance = new Distance($res['distance'], config('phpvms.internal_units.distance'));
$res['distance'] = $distance->getResponseUnits();
if (!array_key_exists('block_fuel', $res)) {
$res['block_fuel'] = 0;
}
$block_fuel = new Fuel($res['block_fuel'], config('phpvms.internal_units.fuel'));
$res['block_fuel'] = $block_fuel->getResponseUnits();
if (!array_key_exists('fuel_used', $res)) {
$res['fuel_used'] = 0;
}

View File

@@ -11,27 +11,9 @@ class SimBrief extends Resource
{
public function toArray($request)
{
$data = [
return [
'id' => $this->id,
'url' => url(route('api.flights.briefing', ['id' => $this->id])),
'url' => url(route('api.flights.briefing', ['id' => $this->flight_id])),
];
try {
if (!empty($this->fare_data)) {
$fares = [];
$fare_data = json_decode($this->fare_data, true);
foreach ($fare_data as $fare) {
$fares[] = new \App\Models\Fare($fare);
}
$this->aircraft->subfleet->fares = collect($fares);
}
} catch (\Exception $e) {
// Invalid fare data
}
$data['subfleet'] = new Subfleet($this->aircraft->subfleet);
return $data;
}
}

View File

@@ -15,8 +15,9 @@ class User extends Resource
'id' => $this->id,
'pilot_id' => $this->pilot_id,
'ident' => $this->ident,
'name' => $this->name_private,
'name' => $this->name,
'name_private' => $this->name_private,
'email' => $this->email,
'avatar' => $this->resolveAvatarUrl(),
'rank_id' => $this->rank_id,
'home_airport' => $this->home_airport_id,
@@ -24,7 +25,6 @@ class User extends Resource
'last_pirep_id' => $this->last_pirep_id,
'flights' => $this->flights,
'flight_time' => $this->flight_time,
'transfer_time' => $this->transfer_time,
'timezone' => $this->timezone,
'state' => $this->state,
];

View File

@@ -20,14 +20,12 @@ class Fare extends Model
public $table = 'fares';
protected $fillable = [
'id',
'code',
'name',
'type',
'price',
'cost',
'capacity',
'count',
'notes',
'active',
];
@@ -36,7 +34,6 @@ class Fare extends Model
'price' => 'float',
'cost' => 'float',
'capacity' => 'integer',
'count' => 'integer',
'type' => 'integer',
'active' => 'boolean',
];

View File

@@ -1,23 +0,0 @@
<?php
namespace App\Models;
use App\Contracts\Model;
/**
* @property string key
* @property string value
*/
class Kvp extends Model
{
public $table = 'kvp';
public $timestamps = false;
public $incrementing = false;
protected $keyType = 'string';
public $fillable = [
'key',
'value',
];
}

View File

@@ -305,9 +305,7 @@ class Pirep extends Model
public function getFieldsAttribute()
{
$custom_fields = PirepField::all();
$field_values = PirepFieldValue::where('pirep_id', $this->id)
->orderBy('created_at', 'asc')
->get();
$field_values = PirepFieldValue::where('pirep_id', $this->id)->get();
// Merge the field values into $fields
foreach ($custom_fields as $field) {
@@ -323,23 +321,7 @@ class Pirep extends Model
}
}
return $field_values;
}
/**
* Set the amount of block fuel
*
* @param $value
*/
public function setBlockFuelAttribute($value): void
{
if ($value instanceof Fuel) {
$this->attributes['block_fuel'] = $value->toUnit(
config('phpvms.internal_units.fuel')
);
} else {
$this->attributes['block_fuel'] = $value;
}
return $field_values->sortBy('source');
}
/**

View File

@@ -4,14 +4,6 @@ namespace App\Models;
use App\Contracts\Model;
/**
* @property int id
* @property string pirep_id
* @property int fare_id
* @property int count
* @property Pirep pirep
* @property Fare fare
*/
class PirepFare extends Model
{
public $table = 'pirep_fares';

View File

@@ -10,17 +10,14 @@ use Illuminate\Support\Collection;
* @property int $user_id The user that generated this
* @property string $flight_id Optional, if attached to a flight, removed if attached to PIREP
* @property string $pirep_id Optional, if attached to a PIREP, removed if attached to flight
* @property string $aircraft_id The aircraft this is for
* @property string $acars_xml
* @property string $ofp_xml
* @property string $ofp_html
* @property string $fare_data JSON string of the fare data that was generated
* @property Collection $images
* @property Collection $files
* @property Flight $flight
* @property User $user
* @property SimBriefXML $xml
* @property Aircraft $aircraft
* @property string $acars_flightplan_url
*/
class SimBrief extends Model
@@ -32,11 +29,9 @@ class SimBrief extends Model
'id',
'user_id',
'flight_id',
'aircraft_id',
'pirep_id',
'acars_xml',
'ofp_xml',
'fare_data',
'created_at',
'updated_at',
];
@@ -85,11 +80,6 @@ class SimBrief extends Model
* Relationships
*/
public function aircraft()
{
return $this->belongsTo(Aircraft::class, 'aircraft_id');
}
public function flight()
{
if (!empty($this->attributes['flight_id'])) {

View File

@@ -10,7 +10,6 @@ use App\Models\Traits\FilesTrait;
/**
* @property int id
* @property string type
* @property string simbrief_type
* @property string name
* @property int airline_id
* @property int hub_id
@@ -30,7 +29,6 @@ class Subfleet extends Model
'airline_id',
'hub_id',
'type',
'simbrief_type',
'name',
'fuel_type',
'cost_block_hour',

View File

@@ -4,7 +4,6 @@ namespace App\Providers;
use App\Services\ModuleService;
use App\Support\Utils;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
@@ -14,7 +13,6 @@ class AppServiceProvider extends ServiceProvider
public function boot(): void
{
Schema::defaultStringLength(191);
Paginator::useBootstrap();
View::share('moduleSvc', app(ModuleService::class));
}

View File

@@ -2,7 +2,6 @@
namespace App\Providers;
use App\Cron\Hourly\DeletePireps;
use App\Cron\Hourly\RemoveExpiredBids;
use App\Cron\Hourly\RemoveExpiredLiveFlights;
use App\Cron\Nightly\ApplyExpenses;
@@ -42,7 +41,6 @@ class CronServiceProvider extends ServiceProvider
],
CronHourly::class => [
DeletePireps::class,
RemoveExpiredBids::class,
RemoveExpiredLiveFlights::class,
],

View File

@@ -19,9 +19,5 @@ class DirectiveServiceProvider extends ServiceProvider
Blade::directive('minutestohours', function ($expr) {
return "<?php echo \App\Support\Units\Time::minutesToHours($expr); ?>";
});
Blade::directive('secstohhmm', function ($expr) {
return "<?php echo secstohhmm($expr); ?>";
});
}
}

View File

@@ -147,7 +147,7 @@ class RouteServiceProvider extends ServiceProvider
Route::get('simbrief/{id}', 'SimBriefController@briefing')->name('simbrief.briefing');
Route::get('simbrief/{id}/prefile', 'SimBriefController@prefile')->name('simbrief.prefile');
Route::get('simbrief/{id}/cancel', 'SimBriefController@cancel')->name('simbrief.cancel');
Route::get('simbrief/{id}/generate_new', 'SimBriefController@generate_new')->name('simbrief.generate_new');
Route::get('simbrief/{id}/remove', 'SimBriefController@remove')->name('simbrief.remove');
});
Route::group([
@@ -392,12 +392,6 @@ class RouteServiceProvider extends ServiceProvider
Route::match(['post'], 'maintenance/forcecheck', 'MaintenanceController@forcecheck')
->name('maintenance.forcecheck')->middleware('ability:admin,maintenance');
Route::match(['post'], 'maintenance/cron_enable', 'MaintenanceController@cron_enable')
->name('maintenance.cron_enable')->middleware('ability:admin,maintenance');
Route::match(['post'], 'maintenance/cron_disable', 'MaintenanceController@cron_disable')
->name('maintenance.cron_disable')->middleware('ability:admin,maintenance');
// subfleet
Route::get('subfleets/export', 'SubfleetController@export')
->name('subfleets.export')->middleware('ability:admin,fleet');
@@ -465,7 +459,7 @@ class RouteServiceProvider extends ServiceProvider
Route::group([
'as' => 'modules.',
'prefix' => 'modules',
'middleware' => ['ability:admin,modules'],
'middleware' => ['ability:admin, modules'],
], function () {
//Modules Index
@@ -514,8 +508,6 @@ class RouteServiceProvider extends ServiceProvider
Route::get('pireps/{pirep_id}', 'PirepController@get');
Route::get('pireps/{pirep_id}/acars/geojson', 'AcarsController@acars_geojson');
Route::get('cron/{id}', 'MaintenanceController@cron')->name('maintenance.cron');
Route::get('news', 'NewsController@index');
Route::get('status', 'StatusController@status');
Route::get('version', 'StatusController@status');

View File

@@ -94,7 +94,7 @@ class FlightRepository extends Repository implements CacheableInterface
$where['flight_number'] = $request->input('flight_number');
}
if ($request->filled('flight_type') && $request->input('flight_type') !== '0') {
if ($request->filled('flight_type')) {
$where['flight_type'] = $request->input('flight_type');
}

View File

@@ -46,32 +46,12 @@ class AirportService extends Service
return;
}
$raw_metar = $this->metarProvider->metar($icao);
$raw_metar = $this->metarProvider->get_metar($icao);
if ($raw_metar && $raw_metar !== '') {
return new Metar($raw_metar);
}
}
/**
* Return the METAR for a given airport
*
* @param $icao
*
* @return Metar|null
*/
public function getTaf($icao)
{
$icao = trim($icao);
if ($icao === '') {
return;
}
$raw_taf = $this->metarProvider->taf($icao);
if ($raw_taf && $raw_taf !== '') {
return new Metar($raw_taf, true);
}
}
/**
* Lookup an airport's information from a remote provider. This handles caching
* the data internally

View File

@@ -50,10 +50,7 @@ class BidService extends Service
$bids = Bid::with([
'flight',
'flight.fares',
'flight.simbrief' => function ($query) use ($user) {
$query->where('user_id', $user->id);
},
'flight.simbrief.aircraft',
'flight.simbrief',
'flight.subfleets',
'flight.subfleets.aircraft',
'flight.subfleets.fares',

View File

@@ -92,6 +92,6 @@ class CronService extends Service
// More than 5 minutes... there's a problem
$diff = $dt_now->diff($dt);
return $diff->i > 60 * 12; // Hasn't run for 12 hours
return $diff->i > 5;
}
}

View File

@@ -172,24 +172,6 @@ class FareService extends Service
return $fare;
}
/**
* Return all the fares for an aircraft. check the pivot
* table to see if the price/cost/capacity has been overridden
* and return the correct amounts.
*
* @param Subfleet $subfleet
*
* @return Collection
*/
public function getForSubfleet(Subfleet $subfleet)
{
$fares = $subfleet->fares->map(function ($fare) {
return $this->getFares($fare);
});
return $fares;
}
/**
* Attach a fare to an flight
*
@@ -258,6 +240,24 @@ class FareService extends Service
return $subfleet;
}
/**
* return all the fares for an aircraft. check the pivot
* table to see if the price/cost/capacity has been overridden
* and return the correct amounts.
*
* @param Subfleet $subfleet
*
* @return Collection
*/
public function getForSubfleet(Subfleet $subfleet)
{
$fares = $subfleet->fares->map(function ($fare) {
return $this->getFares($fare);
});
return $fares;
}
/**
* Delete the fare from a subfleet
*
@@ -286,7 +286,9 @@ class FareService extends Service
*/
public function getForPirep(Pirep $pirep)
{
return PirepFare::where('pirep_id', $pirep->id)->get();
$found_fares = PirepFare::where('pirep_id', $pirep->id)->get();
return $found_fares;
}
/**
@@ -311,8 +313,6 @@ class FareService extends Service
$fare['pirep_id'] = $pirep->id;
// other fields: ['fare_id', 'count']
Log::info('Saving fare pirep='.$pirep->id.', fare='.$fare['count']);
$field = new PirepFare($fare);
$field->save();
}

View File

@@ -152,29 +152,10 @@ class PirepFinanceService extends Service
public function payFuelCosts(Pirep $pirep): void
{
$ap = $pirep->dpt_airport;
if (setting('pireps.advanced_fuel', false)) {
$ac = $pirep->aircraft;
// Reading second row by skip(1) to reach the previous accepted pirep. Current pirep is at the first row
$prev_flight = Pirep::where('aircraft_id', $ac->id)->where('state', 2)->where('status', 'ONB')->orderby('submitted_at', 'desc')->skip(1)->first();
if ($prev_flight) {
// If there is a pirep use its values to calculate the remaining fuel
// and calculate the uplifted fuel amount for this pirep
$fuel_amount = $pirep->block_fuel - ($prev_flight->block_fuel - $prev_flight->fuel_used);
// Aircraft has more than enough fuel in its tanks, no uplift necessary
if ($fuel_amount < 0) {
$fuel_amount = 0;
}
} else {
// No pirep found for aircraft, debit full block fuel
$fuel_amount = $pirep->block_fuel;
}
} else {
// Setting is false, switch back to basic calculation
$fuel_amount = $pirep->fuel_used;
}
$fuel_used = $pirep->fuel_used;
$debit = Money::createFromAmount($fuel_amount * $ap->fuel_jeta_cost);
Log::info('Finance: Fuel cost, (fuel='.$fuel_amount.', cost='.$ap->fuel_jeta_cost.') D='
$debit = Money::createFromAmount($fuel_used * $ap->fuel_jeta_cost);
Log::info('Finance: Fuel cost, (fuel='.$fuel_used.', cost='.$ap->fuel_jeta_cost.') D='
.$debit->getAmount());
$this->financeSvc->debitFromJournal(

View File

@@ -66,10 +66,6 @@ class RecurringFinanceService extends Service
$obj = $expense->getReferencedObject();
}
if (empty($obj)) {
return [null, null];
}
if ($klass === 'Airport') {
$memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})";
$transaction_group = "Airport: {$expense->ref_model_id}";
@@ -132,9 +128,6 @@ class RecurringFinanceService extends Service
}
[$memo, $ta_group] = $this->getMemoAndGroup($expense);
if (empty($memo) || empty($ta_group)) {
continue;
}
$this->financeSvc->debitFromJournal(
$journal,

View File

@@ -137,13 +137,6 @@ class FlightService extends Service
{
/** @var \Illuminate\Support\Collection $subfleets */
$subfleets = $flight->subfleets;
// If no subfleets assigned to a flight get users allowed subfleets
if ($subfleets === null || $subfleets->count() === 0) {
$subfleets = $this->userSvc->getAllowableSubfleets($user);
}
// If subfleets are still empty return the flight
if ($subfleets === null || $subfleets->count() === 0) {
return $flight;
}

View File

@@ -150,7 +150,7 @@ class SeederService extends Service
'order' => $order,
'name' => '',
'group' => $group,
'value' => $attrs['value'],
'value' => '',
'default' => $attrs['value'],
'options' => '',
'type' => 'hidden',

View File

@@ -9,16 +9,13 @@ use Exception;
use Illuminate\Support\Facades\Log;
/**
* Return the raw METAR/TAF string from the NOAA Aviation Weather Service
* Return the raw METAR string from the NOAA Aviation Weather Service
*/
class AviationWeather extends Metar
{
private const METAR_URL =
'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=';
private const TAF_URL =
'https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=tafs&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=';
private $httpClient;
public function __construct(HttpClient $httpClient)
@@ -36,7 +33,7 @@ class AviationWeather extends Metar
*
* @return string
*/
protected function get_metar($icao): string
protected function metar($icao): string
{
if ($icao === '') {
return '';
@@ -70,53 +67,7 @@ class AviationWeather extends Metar
return $xml->data->METAR->raw_text->__toString();
} catch (Exception $e) {
Log::error('Error reading METAR: '.$e->getMessage());
return '';
}
}
/**
* Do the actual retrieval of the TAF
*
* @param $icao
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return string
*/
protected function get_taf($icao): string
{
if ($icao === '') {
return '';
}
$tafurl = static::TAF_URL.$icao;
try {
$tafres = $this->httpClient->get($tafurl, []);
$tafxml = simplexml_load_string($tafres);
$tafattrs = $tafxml->data->attributes();
if (!isset($tafattrs['num_results'])) {
return '';
}
$tafnum_results = $tafattrs['num_results'];
if (empty($tafnum_results)) {
return '';
}
$tafnum_results = (int) $tafnum_results;
if ($tafnum_results === 0) {
return '';
}
if (count($tafxml->data->TAF->raw_text) === 0) {
return '';
}
return $tafxml->data->TAF->raw_text->__toString();
} catch (Exception $e) {
Log::error('Error reading TAF: '.$e->getMessage());
return '';
}
}

View File

@@ -23,10 +23,7 @@ use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Models\Navdata;
use App\Models\Pirep;
use App\Models\PirepComment;
use App\Models\PirepFare;
use App\Models\PirepFieldValue;
use App\Models\SimBrief;
use App\Models\User;
use App\Repositories\AircraftRepository;
use App\Repositories\AirportRepository;
@@ -43,16 +40,17 @@ class PirepService extends Service
private $airportSvc;
private $geoSvc;
private $pirepRepo;
private $simBriefSvc;
private $userSvc;
/**
* @param AircraftRepository $aircraftRepo
* @param GeoService $geoSvc
* @param PirepRepository $pirepRepo
* @param UserService $userSvc
* @param AirportRepository $airportRepo
* @param AirportService $airportSvc
* @param GeoService $geoSvc
* @param PirepRepository $pirepRepo
* @param SimBriefService $simBriefSvc
* @param UserService $userSvc
*/
public function __construct(
@@ -61,16 +59,14 @@ class PirepService extends Service
AircraftRepository $aircraftRepo,
GeoService $geoSvc,
PirepRepository $pirepRepo,
SimBriefService $simBriefSvc,
UserService $userSvc
) {
$this->airportRepo = $airportRepo;
$this->airportSvc = $airportSvc;
$this->aircraftRepo = $aircraftRepo;
$this->geoSvc = $geoSvc;
$this->pirepRepo = $pirepRepo;
$this->simBriefSvc = $simBriefSvc;
$this->userSvc = $userSvc;
$this->pirepRepo = $pirepRepo;
}
/**
@@ -119,7 +115,7 @@ class PirepService extends Service
// See if this user is at the current airport
/* @noinspection NotOptimalIfConditionsInspection */
if (setting('pilots.only_flights_from_current', false)
if (setting('pilots.only_flights_from_current')
&& $user->curr_airport_id !== $pirep->dpt_airport_id) {
throw new UserNotAtAirport($user, $pirep->dpt_airport);
}
@@ -210,72 +206,6 @@ class PirepService extends Service
return $pirep;
}
/**
* Finalize a PIREP (meaning it's been filed)
*
* @param Pirep $pirep
* @param array $attrs
* @param array PirepFieldValue[] $field_values
*
* @throws \Exception
*
* @return Pirep
*/
public function file(Pirep $pirep, array $attrs = [], array $field_values = []): Pirep
{
if (empty($field_values)) {
$field_values = [];
}
$attrs['state'] = PirepState::PENDING;
$attrs['status'] = PirepStatus::ARRIVED;
$attrs['submitted_at'] = Carbon::now('UTC');
$this->pirepRepo->update($attrs, $pirep->id);
$pirep->refresh();
// Check if there is a simbrief_id, change it to be set to the PIREP
// at the end of the flight when it's been filed
if (array_key_exists('simbrief_id', $attrs)) {
/** @var SimBrief $simbrief */
$simbrief = SimBrief::find($attrs['simbrief_id']);
if ($simbrief) {
$this->simBriefSvc->attachSimbriefToPirep($pirep, $simbrief);
}
}
// Check the block times. If a block on (arrival) time isn't
// specified, then use the time that it was submitted. It won't
// be the most accurate, but that might be OK
if (!$pirep->block_on_time) {
if ($pirep->submitted_at) {
$pirep->block_on_time = $pirep->submitted_at;
} else {
$pirep->block_on_time = Carbon::now('UTC');
}
}
// Check that there's a submit time
if (!$pirep->submitted_at) {
$pirep->submitted_at = Carbon::now('UTC');
}
// Copy some fields over from Flight if we have it
if ($pirep->flight) {
$pirep->planned_distance = $pirep->flight->distance;
$pirep->planned_flight_time = $pirep->flight->flight_time;
}
$pirep->save();
$pirep->refresh();
if (count($field_values) > 0) {
$this->updateCustomFields($pirep->id, $field_values);
}
return $pirep;
}
/**
* Find if there are duplicates to a given PIREP. Ideally, the passed
* in PIREP hasn't been saved or gone through the create() method
@@ -376,6 +306,18 @@ class PirepService extends Service
return $pirep;
}
/**
* Alias to submit()
*
* @param \App\Models\Pirep $pirep
*
* @throws \Exception
*/
public function file(Pirep $pirep)
{
return $this->submit($pirep);
}
/**
* Submit the PIREP. Figure out its default state
*
@@ -438,29 +380,6 @@ class PirepService extends Service
return $pirep;
}
/**
* Delete the PIREP and all of the associated data. Does a force delete to make sure that we
* don't run into problems with foreign keys. Models/tables affected:
*
* acars
* bids
* pirep_comments
* pirep_fares
* pirep_field_values
* simbrief
*
* @param Pirep $pirep
*/
public function delete(Pirep $pirep): void
{
$w = ['pirep_id' => $pirep->id];
PirepComment::where($w)->forceDelete();
PirepFare::where($w)->forceDelete();
PirepFieldValue::where($w)->forceDelete();
SimBrief::where($w)->forceDelete();
$pirep->forceDelete();
}
/**
* Update any custom PIREP fields
*
@@ -564,7 +483,6 @@ class PirepService extends Service
$pirep->aircraft->flight_time = $pirep->aircraft->flight_time + $pirep->flight_time;
$pirep->aircraft->airport_id = $pirep->arr_airport_id;
$pirep->aircraft->landing_time = $pirep->updated_at;
$pirep->aircraft->fuel_onboard = $pirep->block_fuel - $pirep->fuel_used;
$pirep->aircraft->save();
$pirep->refresh();

View File

@@ -29,18 +29,11 @@ class SimBriefService extends Service
* @param string $user_id User who generated this
* @param string $ofp_id The SimBrief OFP ID
* @param string $flight_id The flight ID
* @param string $ac_id The aircraft ID
* @param array $fares Full list of fares for the flightß
*
* @return SimBrief|null
*/
public function downloadOfp(
string $user_id,
string $ofp_id,
string $flight_id,
string $ac_id,
array $fares = []
) {
public function checkForOfp(string $user_id, string $ofp_id, string $flight_id)
{
$uri = str_replace('{id}', $ofp_id, config('phpvms.simbrief_url'));
$opts = [
@@ -64,17 +57,11 @@ class SimBriefService extends Service
$ofp = simplexml_load_string($body, SimBriefXML::class);
$attrs = [
'user_id' => $user_id,
'flight_id' => $flight_id,
'aircraft_id' => $ac_id,
'ofp_xml' => $ofp->asXML(),
'user_id' => $user_id,
'flight_id' => $flight_id,
'ofp_xml' => $ofp->asXML(),
];
// encode the fares data to JSONß
if (!empty($fares)) {
$attrs['fare_data'] = json_encode($fares);
}
// Try to download the XML file for ACARS. If it doesn't work, try to modify the main OFP
$acars_xml = $this->getAcarsOFP($ofp);
if (empty($acars_xml)) {

View File

@@ -21,7 +21,6 @@ use App\Repositories\SubfleetRepository;
use App\Repositories\UserRepository;
use App\Support\Units\Time;
use App\Support\Utils;
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use function is_array;
@@ -255,41 +254,6 @@ class UserService extends Service
return $user;
}
/**
* Return all of the users that are determined to be on leave. Only goes through the
* currently active users. If the user doesn't have a PIREP, then the creation date
* of the user record is used to determine the difference
*/
public function findUsersOnLeave(): array
{
$leave_days = setting('pilots.auto_leave_days');
if ($leave_days === 0) {
return [];
}
$return_users = [];
$date = Carbon::now('UTC');
$users = User::with(['last_pirep'])->where('state', UserState::ACTIVE)->get();
/** @var User $user */
foreach ($users as $user) {
// If they haven't submitted a PIREP, use the date that the user was created
if (!$user->last_pirep) {
$diff_date = $user->created_at;
} else {
$diff_date = $user->last_pirep->submitted_at;
}
// See if the difference is larger than what the setting calls for
if ($date->diffInDays($diff_date) > $leave_days) {
$return_users[] = $user;
}
}
return $return_users;
}
/**
* Return the subfleets this user is allowed access to,
* based on their current rank
@@ -462,7 +426,7 @@ class UserService extends Service
$user->state = UserState::ON_LEAVE;
$user->save();
event(new UserStateChanged($user, UserState::ON_LEAVE));
event(new UserStateChanged($user, UserState::ACTIVE));
$user->refresh();
return $user;

View File

@@ -1772,7 +1772,7 @@ class Metar implements \ArrayAccess
*/
private function calculate_wind_chill($temperature_f): void
{
if ($temperature_f < 51 && $this->result['wind_speed'] && $this->result['wind_speed'] !== 0) {
if ($temperature_f < 51 && $this->result['wind_speed'] !== 0) {
$windspeed = $this->result['wind_speed']->toUnit('mph');
if ($windspeed > 3) {
$chill_f = 35.74 + 0.6215 * $temperature_f - 35.75 * ($windspeed ** 0.16);

View File

@@ -5,8 +5,9 @@ namespace App\Support;
use App\Contracts\Model;
use Hashids\Hashids;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Str;
use LayerShifter\TLDExtract\Extract;
use Nwidart\Modules\Facades\Module;
use Pdp\Rules;
/**
* Global utilities
@@ -109,36 +110,22 @@ class Utils
*/
public static function getRootDomain(string $url): string
{
if (!str_starts_with($url, 'http')) {
$url = 'http://'.$url;
if (Str::contains($url, ['https://', 'http://'])) {
$url = str_replace('https://', '', $url);
$url = str_replace('http://', '', $url);
}
$parsed_url = parse_url($url, PHP_URL_HOST);
if (empty($parsed_url)) {
return '';
}
$extract = new Extract();
$result = $extract->parse($url);
if (str_ends_with($parsed_url, 'localhost')) {
return 'localhost';
}
if (str_ends_with($parsed_url, '/')) {
$parsed_url = substr($parsed_url, 0, strlen($parsed_url) - 1);
}
$rules = Rules::createFromPath(resource_path('tld/public_suffix_list.dat'));
$domain = $rules->resolve($parsed_url);
$val = $domain->getRegistrableDomain();
$val = $result->getRegistrableDomain();
if (!empty($val)) {
return $val;
}
// Couldn't validate a domain, see if this is an IP address?
if (filter_var($parsed_url, FILTER_VALIDATE_IP)) {
return $parsed_url;
if (filter_var($url, FILTER_VALIDATE_IP)) {
return $url;
}
return '';
}
}

View File

@@ -11,8 +11,7 @@ use App\Services\AirportService;
class Weather extends Widget
{
protected $config = [
'icao' => null,
'raw_only' => null,
'icao' => null,
];
/**
@@ -23,12 +22,10 @@ class Weather extends Widget
/** @var \App\Services\AirportService $airportSvc */
$airportSvc = app(AirportService::class);
$metar = $airportSvc->getMetar($this->config['icao']);
$taf = $airportSvc->getTaf($this->config['icao']);
return view('widgets.weather', [
'config' => $this->config,
'metar' => $metar,
'taf' => $taf,
'unit_alt' => setting('units.altitude'),
'unit_dist' => setting('units.distance'),
'unit_temp' => setting('units.temperature'),

View File

@@ -161,7 +161,6 @@ if (!function_exists('setting')) {
*/
function setting($key, $default = null)
{
/** @var \App\Repositories\SettingRepository $settingRepo */
$settingRepo = app(SettingRepository::class);
try {
@@ -182,7 +181,6 @@ if (!function_exists('setting')) {
if (!function_exists('setting_save')) {
function setting_save($key, $value)
{
/** @var \App\Repositories\SettingRepository $settingRepo */
$settingRepo = app(SettingRepository::class);
$settingRepo->save($key, $value);
return $value;
@@ -357,20 +355,6 @@ if (!function_exists('show_datetime_format')) {
}
}
if (!function_exists('secstohhmm')) {
/**
* Convert seconds to hhmm format
*
* @param $seconds
*/
function secstohhmm($seconds)
{
$seconds = round($seconds);
$hhmm = sprintf('%02d%02d', ($seconds / 3600), ($seconds / 60 % 60));
echo $hhmm;
}
}
if (!function_exists('_fmt')) {
/**
* Replace strings

View File

@@ -14,65 +14,63 @@
"ext-simplexml": "*",
"ext-bcmath": "*",
"ext-pdo": "*",
"ext-intl": "*",
"composer/composer": "~1.0",
"composer/installers": "~1.0",
"laravel/framework": "~8.0",
"laravel/framework": "~7.0",
"akaunting/money": "^1.0",
"anhskohbo/no-captcha": "^3.0",
"appstract/laravel-opcache": "^4.0",
"arrilot/laravel-widgets": "~3.13.0",
"codedge/laravel-selfupdater": "~3.2.0",
"doctrine/dbal": "^3.0.0",
"facade/ignition": "^2.5",
"fideloper/proxy": "^4.4",
"codedge/laravel-selfupdater": "~3.0.0",
"doctrine/dbal": "~2.9.2",
"facade/ignition": "^2.0",
"fideloper/proxy": "^4.3",
"guzzlehttp/guzzle": "~6.5",
"hashids/hashids": "^4.1.0",
"hashids/hashids": "^2.0.0",
"igaster/laravel-theme": "^2.0",
"intervention/image": "2.4.*",
"irazasyed/laravel-gamp": "^1.8",
"irazasyed/laravel-gamp": "^1.6",
"jmikola/geojson": "1.0.*",
"joshbrw/laravel-module-installer": "^2.0",
"joshbrw/laravel-module-installer": "0.1.*",
"laracasts/flash": "^3.1",
"laravel/helpers": "^1.4",
"laravel/helpers": "^1.2",
"laravelcollective/html": "~6.2.0",
"jeremykendall/php-domain-parser": "~5.7.2",
"layershifter/tld-extract": "^2.0",
"league/csv": "9.2.*",
"league/geotools": "0.8.*",
"league/iso3166": "^3.0.0",
"markrogoyski/math-php": "^1.10",
"myclabs/deep-copy": "~1.10.0",
"league/iso3166": "2.1.*",
"markrogoyski/math-php": "^0.38.0",
"myclabs/deep-copy": "~1.9.0",
"nabeel/vacentral": "~2.0",
"nwidart/laravel-modules": "^8.2",
"nwidart/laravel-modules": "^8.0",
"php-units-of-measure/php-units-of-measure": "~2.1.0",
"phpvms/sample-module": "^1.0",
"pragmarx/version": ">=v1.2.3",
"prettus/l5-repository": "~2.7.0",
"santigarcor/laratrust": "~6.3",
"sebastiaanluca/laravel-helpers": "~6.0",
"pragmarx/version": "^1.2.2",
"prettus/l5-repository": "~2.6.0",
"santigarcor/laratrust": "~6.0",
"sebastiaanluca/laravel-helpers": "~5.0",
"semver/semver": "~1.1.0",
"spatie/valuestore": "~1.2",
"symfony/polyfill-iconv": "~1.22.0",
"spatie/laravel-backup": "~6.9.0",
"spatie/valuestore": "~1.2.3",
"symfony/polyfill-iconv": "~1.17.0",
"tivie/php-os-detector": "~1.1.0",
"vlucas/phpdotenv": "^5.3.0",
"webpatser/laravel-uuid": "~4.0",
"oomphinc/composer-installers-extender": "^2.0",
"laravel/ui": "^3.2.0",
"madnest/madzipper": "^1.1.0",
"elcobvg/laravel-opcache": "^0.4.1",
"laravel/legacy-factories": "^1.1",
"fakerphp/faker": "^1.13",
"wildbit/swiftmailer-postmark": "^3.3"
"vlucas/phpdotenv": "v4.0",
"webpatser/laravel-uuid": "~3.0",
"oomphinc/composer-installers-extender": "^1.1",
"laravel/ui": "^2.0",
"madnest/madzipper": "^1.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.5",
"barryvdh/laravel-ide-helper": "^2.9",
"bpocallaghan/generators": "~7.0",
"barryvdh/laravel-debugbar": "^3.0",
"barryvdh/laravel-ide-helper": "^2.6",
"bpocallaghan/generators": "~6.0",
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.9.0",
"friendsofphp/php-cs-fixer": "^2.16",
"mockery/mockery": "^1.4.0",
"nunomaduro/collision": "^5.3.0",
"mockery/mockery": "0.9.*",
"nunomaduro/collision": "^4.0",
"phpunit/phpunit": "~9.0",
"squizlabs/php_codesniffer": "3.*",
"sempro/phpunit-pretty-print": "^1.2"
},
"autoload": {

4737
composer.lock generated

File diff suppressed because it is too large Load Diff

204
config/backup.php Normal file
View File

@@ -0,0 +1,204 @@
<?php
use App\Notifications\Notifiables\Backups;
use Spatie\Backup\Notifications\Notifications\BackupHasFailed;
use Spatie\Backup\Notifications\Notifications\BackupWasSuccessful;
use Spatie\Backup\Notifications\Notifications\CleanupHasFailed;
use Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful;
use Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound;
use Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound;
use Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy;
use Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumAgeInDays;
use Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumStorageInMegabytes;
return [
'backup' => [
'name' => config('app.name', 'phpvms-backup'),
'source' => [
'files' => [
'include' => [
base_path(),
],
'exclude' => [
base_path('vendor'),
base_path('node_modules'),
],
'follow_links' => false,
],
/*
* The names of the connections to the databases that should be backed up
* MySQL, PostgreSQL, SQLite and Mongo databases are supported.
*
* The content of the database dump may be customized for each connection
* by adding a 'dump' key to the connection settings in config/database.php.
* E.g.
* 'mysql' => [
* ...
* 'dump' => [
* 'excludeTables' => [
* 'table_to_exclude_from_backup',
* 'another_table_to_exclude'
* ]
* ],
* ],
*
* If you are using only InnoDB tables on a MySQL server, you can
* also supply the useSingleTransaction option to avoid table locking.
*
* E.g.
* 'mysql' => [
* ...
* 'dump' => [
* 'useSingleTransaction' => true,
* ],
* ],
*
* For a complete list of available customization options, see https://github.com/spatie/db-dumper
*/
'databases' => [
'mysql',
],
],
/*
* The database dump can be compressed to decrease diskspace usage.
*
* Out of the box Laravel-backup supplies
* Spatie\DbDumper\Compressors\GzipCompressor::class.
*
* You can also create custom compressor. More info on that here:
* https://github.com/spatie/db-dumper#using-compression
*
* If you do not want any compressor at all, set it to null.
*/
'database_dump_compressor' => null,
'destination' => [
/*
* The filename prefix used for the backup zip file.
*/
'filename_prefix' => '',
/*
* The disk names on which the backups will be stored.
*/
'disks' => [
'local',
],
],
/*
* The directory where the temporary files will be stored.
*/
'temporary_directory' => storage_path('app/backup-temp'),
],
/*
* You can get notified when specific events occur. Out of the box you can use 'mail' and 'slack'.
* For Slack you need to install guzzlehttp/guzzle and laravel/slack-notification-channel.
*
* You can also use your own notification classes, just make sure the class is named after one of
* the `Spatie\Backup\Events` classes.
*/
'notifications' => [
'notifications' => [
BackupHasFailed::class => ['mail'],
UnhealthyBackupWasFound::class => ['mail'],
CleanupHasFailed::class => ['mail'],
BackupWasSuccessful::class => ['mail'],
HealthyBackupWasFound::class => ['mail'],
CleanupWasSuccessful::class => ['mail'],
],
/*
* Here you can specify the notifiable to which the notifications should be sent. The default
* notifiable will use the variables specified in this config file.
*/
'notifiable' => Backups::class,
'slack' => [
'webhook_url' => '',
/*
* If this is set to null the default channel of the webhook will be used.
*/
'channel' => null,
'username' => null,
'icon' => null,
],
],
/*
* Here you can specify which backups should be monitored.
* If a backup does not meet the specified requirements the
* UnHealthyBackupWasFound event will be fired.
*/
'monitor_backups' => [
[
'name' => config(config('app.name'), 'phpvms-backup'),
'disks' => ['local'],
'health_checks' => [
MaximumAgeInDays::class => 1,
MaximumStorageInMegabytes::class => 5000,
],
],
/*
[
'name' => 'name of the second app',
'disks' => ['local', 's3'],
'health_checks' => [
\Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumAgeInDays::class => 1,
\Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumStorageInMegabytes::class => 5000,
],
],
*/
],
'cleanup' => [
/*
* The strategy that will be used to cleanup old backups. The default strategy
* will keep all backups for a certain amount of days. After that period only
* a daily backup will be kept. After that period only weekly backups will
* be kept and so on.
*
* No matter how you configure it the default strategy will never
* delete the newest backup.
*/
'strategy' => DefaultStrategy::class,
'default_strategy' => [
/*
* The number of days for which backups must be kept.
*/
'keep_all_backups_for_days' => 7,
/*
* The number of days for which daily backups must be kept.
*/
'keep_daily_backups_for_days' => 7,
/*
* The number of weeks for which one weekly backup must be kept.
*/
'keep_weekly_backups_for_weeks' => 4,
/*
* The number of months for which one monthly backup must be kept.
*/
'keep_monthly_backups_for_months' => 4,
/*
* The number of years for which one yearly backup must be kept.
*/
'keep_yearly_backups_for_years' => 2,
/*
* After cleaning up the backups remove the oldest backup until
* this amount of megabytes has been reached.
*/
'delete_oldest_backups_when_using_more_megabytes_than' => 5000,
],
],
];

View File

@@ -9,18 +9,14 @@ return [
'key' => 'airports.lookup:',
'time' => 60 * 30,
],
'METAR_WEATHER_LOOKUP' => [
'key' => 'airports.weather.metar.', // append icao
'WEATHER_LOOKUP' => [
'key' => 'airports.weather.', // append icao
'time' => 60 * 60, // Cache for 60 minutes
],
'RANKS_PILOT_LIST' => [
'key' => 'ranks.pilot_list',
'time' => 60 * 10,
],
'TAF_WEATHER_LOOKUP' => [
'key' => 'airports.weather.taf.', // append icao
'time' => 60 * 60, // Cache for 60 minutes
],
'USER_API_KEY' => [
'key' => 'user.apikey',
'time' => 60 * 5, // 5 min

View File

@@ -1,7 +1,5 @@
<?php
use Facade\Ignition\SolutionProviders\MissingPackageSolutionProvider;
return [
/*
|--------------------------------------------------------------------------
@@ -56,7 +54,7 @@ return [
*/
'ignored_solution_providers' => [
MissingPackageSolutionProvider::class,
//
],
/*
@@ -70,7 +68,7 @@ return [
|
*/
'enable_runnable_solutions' => false,
'enable_runnable_solutions' => env('IGNITION_ENABLE_RUNNABLE_SOLUTIONS', null),
/*
|--------------------------------------------------------------------------

View File

@@ -19,12 +19,10 @@ return [
'fileinfo',
'openssl',
'pdo',
'intl',
'mbstring',
'tokenizer',
'json',
'curl',
'dom',
],
// Make sure these are writable

View File

@@ -15,7 +15,8 @@ return [
|
*/
'default' => env('MAIL_DRIVER', 'smtp'),
'driver' => env('MAIL_DRIVER', 'smtp'),
'mailers' => [
'smtp' => [
'transport' => 'smtp',
@@ -70,21 +71,4 @@ return [
'address' => env('MAIL_FROM_ADDRESS', 'no-reply@phpvms.net'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];

View File

@@ -20,7 +20,7 @@ return [
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => 'mysql',
'connection' => null,
'table' => 'sessions',
'store' => null,
'lottery' => [1, 100],

26
index.php Executable file
View File

@@ -0,0 +1,26 @@
<?php
/**
* phpVMS (root folder)
*/
$path_to_phpvms_folder = __DIR__;
require $path_to_phpvms_folder.'/bootstrap/autoload.php';
$app = require_once $path_to_phpvms_folder.'/bootstrap/app.php';
$app->setPublicPath(__DIR__.'/public');
$app->setPublicUrlPath(env('APP_PUBLIC_URL', '/'));
// Uncomment this line if you're having issues with the redirecting not working properly
//$app->setPublicUrlPath(env('APP_PUBLIC_URL', '/public'));
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);

View File

@@ -42,7 +42,7 @@ class PilotHoursAwards extends Award
*/
public function check($flight_minutes = null): bool
{
if (!is_numeric($flight_minutes)) {
if (!is_int($flight_minutes)) {
Log::error('PilotHourAwards: Flight time "'.$flight_minutes.'" is not a valid flight time');
return false;
}

954
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -46,7 +46,7 @@
"select2": "^4.0.13",
"ssri": "^5.3.0",
"tar": ">=4.4.2",
"webpack": "^4.44.2",
"webpack": "^5.0.0",
"webpack-cli": "^3.3.12",
"x-editable": "1.5.1"
},

View File

@@ -1,44 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap/autoload.php" colors="true" processIsolation="false" stopOnFailure="true" convertErrorsToExceptions="false" convertNoticesToExceptions="false" convertWarningsToExceptions="false" beStrictAboutOutputDuringTests="false" beStrictAboutTestsThatDoNotTestAnything="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<extensions>
<extension class="Tests\Bootstrap"/>
</extensions>
<!--<listeners>
<phpunit bootstrap="bootstrap/autoload.php"
colors="true"
processIsolation="false"
stopOnFailure="true"
convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
beStrictAboutOutputDuringTests="false"
beStrictAboutTestsThatDoNotTestAnything="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<extensions>
<extension class="Tests\Bootstrap"/>
</extensions>
<!--<listeners>
<listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/>
</listeners>-->
<php>
<env name="PHPUNIT_PRETTY_PRINT_PROGRESS" value="true"/>
<ini name="error_reporting" value="E_ALL"/>
<ini name="display_errors" value="On"/>
<ini name="display_startup_errors" value="On"/>
<server name="APP_ENV" value="testing"/>
<server name="APP_KEY" value="base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI="/>
<server name="APP_DEBUG" value="true"/>
<server name="APP_LOG_LEVEL" value="error"/>
<server name="APP_URL" value="http://localhost"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="memory"/>
<server name="DB_PREFIX" value="vmstest_"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_DRIVER" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
<server name="APP_CONFIG_CACHE" value="bootstrap/cache/config.phpunit.php"/>
<server name="APP_SERVICES_CACHE" value="bootstrap/cache/services.phpunit.php"/>
<server name="APP_PACKAGES_CACHE" value="bootstrap/cache/packages.phpunit.php"/>
<server name="APP_ROUTES_CACHE" value="bootstrap/cache/routes.phpunit.php"/>
<server name="APP_EVENTS_CACHE" value="bootstrap/cache/events.phpunit.php"/>
</php>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="PHPUNIT_PRETTY_PRINT_PROGRESS" value="true" />
<ini name="error_reporting" value="E_ALL"/>
<ini name="display_errors" value="On"/>
<ini name="display_startup_errors" value="On"/>
<server name="APP_ENV" value="testing"/>
<server name="APP_KEY" value="base64:ve66Z5Kt/zTN3p++0zOPu854PHfZkwJE5VuoFAlzHtI="/>
<server name="APP_DEBUG" value="true"/>
<server name="APP_LOG_LEVEL" value="error"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="none"/>
<server name="DB_CONNECTION" value="memory"/>
<server name="DB_PREFIX" value="vmstest_"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_DRIVER" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
<server name="APP_CONFIG_CACHE" value="bootstrap/cache/config.phpunit.php"/>
<server name="APP_SERVICES_CACHE" value="bootstrap/cache/services.phpunit.php"/>
<server name="APP_PACKAGES_CACHE" value="bootstrap/cache/packages.phpunit.php"/>
<server name="APP_ROUTES_CACHE" value="bootstrap/cache/routes.phpunit.php"/>
<server name="APP_EVENTS_CACHE" value="bootstrap/cache/events.phpunit.php"/>
</php>
</phpunit>

View File

@@ -130,11 +130,3 @@
border-radius: 5px;
width: 250px;
}
/*
* fix the dropdown menu on mobile view
*/
.dropdown-menu:not(.show) {
display: none;
}

File diff suppressed because it is too large Load Diff

View File

@@ -6,9 +6,6 @@
* https://docs.phpvms.net
*/
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
/**
* NOTE!!
*
@@ -19,12 +16,14 @@ use Illuminate\Http\Request;
*/
$path_to_phpvms_folder = __DIR__.'/../';
if (file_exists($path_to_phpvms_folder.'bootstrap/autoload.php')) {
// noop
require $path_to_phpvms_folder.'bootstrap/autoload.php';
$app = require_once $path_to_phpvms_folder.'bootstrap/app.php';
}
// Look up one more folder up (outside of the Laravel root) and in the `phpvms` subfolder
elseif (file_exists($path_to_phpvms_folder.'phpvms/bootstrap/autoload.php')) {
$path_to_phpvms_folder = $path_to_phpvms_folder.'phpvms';
require $path_to_phpvms_folder.'phpvms/bootstrap/autoload.php';
$app = require_once $path_to_phpvms_folder.'phpvms/bootstrap/app.php';
}
// Bail out
@@ -33,30 +32,14 @@ else {
exit();
}
require $path_to_phpvms_folder.'/bootstrap/autoload.php';
$app = require_once $path_to_phpvms_folder.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Check If Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is maintenance / demo mode via the "down" command we
| will require this file so that any prerendered template can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists($path_to_phpvms_folder.'/storage/framework/maintenance.php')) {
require $path_to_phpvms_folder.'/storage/framework/maintenance.php';
}
$app->setPublicPath(__DIR__);
$kernel = $app->make(Kernel::class);
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);

View File

@@ -80,7 +80,7 @@ return [
// Overrides config/mail.php
'mail' => [
'default' => 'mail', # Default is to use the mail() fn
'driver' => 'mail', # Default is to use the mail() fn
'mailers' => [
'smtp' => [
'transport' => 'smtp',
@@ -107,8 +107,7 @@ return [
// Overrides config/session.php
'session' => [
'driver' => 'file',
'connection' => 'mysql',
'default' => 'file',
'lifetime' => 60 * 24, # 24 hours
],
];

View File

@@ -1,8 +1,3 @@
#
# THIS FILE MUST BE KEPT SECRET! IT IS BLOCKED IN THE HTACCESS FILE
# HOWEVER, THIS DIRECTORY SHOULDN'T BE EXPOSED TO THE PUBLIC AT ALL
# SEE THE DOCS FOR PROPER (SECURE) INSTALLATION:
# https://docs.phpvms.net/installation/uploading
#
<?php exit(); ?>
APP_KEY=base64:$APP_KEY$

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
<div class="content">
@if($cron_problem_exists)
<div class="alert alert-danger" role="alert">
The cron has not run in more than 12 hours; make sure it's setup and check logs at
There was a problem running the cron; make sure it's setup and check logs at
<span class="text-monospace bg-gradient-dark">storage/logs/cron.log</span>.
<a href="{{ docs_link('cron') }}" target="_blank">See the docs</a>
</div>

View File

@@ -6,8 +6,7 @@
</h6>
<div class="row" style="padding-top: 5px">
<div class="col-sm-12">
<p>A cron must be created that runs every minute calling artisan. An example is below.
<strong><a href="{{ docs_link('cron') }}" target="_blank">See the docs</a></strong></p>
<p>A cron must be created that runs every minute calling artisan. Example:</p>
<label style="width: 100%">
<input type="text" value="{{ $cron_path }}" class="form-control" style="width: 100%"/>
</label>
@@ -21,45 +20,6 @@
@endif
</div>
</div>
<hr>
<div class="row" style="padding-top: 5px">
<div class="col-sm-12">
<h5>Web Cron</h5>
</div>
<div class="col-sm-6">
<p>
If you don't have cron access on your server, you can use a web-cron service to
access this URL every minute. Keep it disabled if you're not using it. It's a
unique ID that can be reset/changed if needed for security.
</p>
</div>
<div class="col-sm-6 pull-right">
<table class="table-condensed">
<tr class="text-right">
<td style="padding-right: 10px;" class="text-right">
{{ Form::open(['url' => route('admin.maintenance.cron_enable'),
'method' => 'post']) }}
{{ Form::button('Enable/Change ID', ['type' => 'submit', 'class' => 'btn btn-success']) }}
{{ Form::close() }}
</td>
<td class="text-right">
{{ Form::open(['url' => route('admin.maintenance.cron_disable'),
'method' => 'post']) }}
{{ Form::button('Disable', ['type' => 'submit', 'class' => 'btn btn-warning']) }}
{{ Form::close() }}
</td>
</tr>
</table>
</div>
<div class="col-sm-12">
<label style="width: 100%">
<input type="text" value="{{ $cron_url }}" class="form-control" style="width: 100%"/>
</label>
</div>
</div>
</div>
</div>
</div>

View File

@@ -23,19 +23,11 @@
'pirep_id' => $pirep->id,
'new_status' => PirepState::REJECTED,
'class' => $on_edit_page ? 'pirep_change_status': 'pirep_submit_status']) }}
{{ Form::button('Reject', ['type' => 'submit', 'class' => 'btn btn-warning']) }}
{{ Form::button('Reject', ['type' => 'submit', 'class' => 'btn btn-danger']) }}
{{ Form::close() }}
@endif
</td>
<td>
{{ Form::open(['url' => route('admin.pireps.destroy', [$pirep->id]),
'method' => 'delete',
'name' => 'delete_'.$pirep->id,
'id' => $pirep->id.'_delete'
]) }}
{{ Form::button('Delete', ['type' => 'submit', 'class' => 'btn btn-danger']) }}
{{ Form::close() }}
</td>
<td>&nbsp;</td>
@if ($on_edit_page === false)
<td>
<form action="{{ route('admin.pireps.edit', [$pirep->id]) }}">

View File

@@ -24,19 +24,13 @@
<p class="text-danger">{{ $errors->first('hub_id') }}</p>
</div>
<div class="form-group col-sm-2">
<div class="form-group col-sm-3">
{{ Form::label('type', 'Type:') }}
{{ Form::text('type', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('type') }}</p>
</div>
<div class="form-group col-sm-2">
{{ Form::label('simbrief_type', 'SimBrief Type:') }}
{{ Form::text('simbrief_type', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('simbrief_type') }}</p>
</div>
<div class="form-group col-sm-2">
<div class="form-group col-sm-3">
{{ Form::label('name', 'Name:') }}
{{ Form::text('name', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('name') }}</p>

View File

@@ -1,6 +1,7 @@
<div class="text-right">
<div class="form-group text-right">
<a href="{{ route('frontend.flights.bids') }}"
class="btn btn-outline-primary">{{ trans_choice('flights.mybid', 2) }}</a>
<div class="card">
<div class="card-block" style="min-height: 0px; display: flex; justify-content: center; align-items: center;">
<div class="form-group text-right">
<a href="{{ route('frontend.flights.bids') }}" class="btn btn-outline-primary">{{ trans_choice('flights.mybid', 2) }}</a>
</div>
</div>
</div>

View File

@@ -1,25 +1,40 @@
<h4 class="description">@lang('flights.search')</h4>
<div class="row">
<div class="col-12">
<h3 class="description">@lang('flights.search')</h3>
<div class="card border-blue-bottom">
<div class="card-body ml-1 mr-1" style="min-height: 0px; display: flex; justify-content: center; align-items: center;">
<div class="form-group search-form">
{{ Form::open([
'route' => 'frontend.flights.search',
'method' => 'GET',
'class'=>'form-inline'
]) }}
<div class="mt-1">
<div class="form-group">
<p>@lang('common.airline')</p>
{{ Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) }}
</div>
<p>@lang('common.airline')</p>
{{ Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) }}
</div>
<div class="mt-1">
<p>@lang('flights.flighttype')</p>
{{ Form::select('flight_type', $flight_types, null , ['class' => 'form-control select2']) }}
<div class="form-group">
<label>@lang('flights.flighttype')</label>
<select id="flight_type" name="flight_type" class="custom-select select2">
<option value=""></option>
<option value="J">@lang('flights.type.pass_scheduled')</option>
<option value="G">@lang('flights.type.pass_addtl')</option>
<option value="C">@lang('flights.type.charter_pass_only')</option>
<option value="O">@lang('flights.type.charter_special')</option>
<option value="E">@lang('flights.type.special_vip')</option>
<option value="F">@lang('flights.type.cargo_scheduled')</option>
<option value="A">@lang('flights.type.addtl_cargo_mail')</option>
<option value="H">@lang('flights.type.charter_cargo')</option>
<option value="M">@lang('flights.type.mail_service')</option>
<option value="I">@lang('flights.type.ambulance')</option>
<option value="K">@lang('flights.type.training_flight')</option>
<option value="P">@lang('flights.type.positioning')</option>
<option value="T">@lang('flights.type.technical_test')</option>
<option value="X">@lang('flights.type.technical_stop')</option>
<option value="W">@lang('flights.type.military')</option>
</select>
</div>
<div class="mt-1">
<div>
<p>@lang('flights.flightnumber')</p>
{{ Form::text('flight_number', null, ['class' => 'form-control']) }}
</div>

View File

@@ -1,47 +0,0 @@
@extends('app')
@section('title', 'SimBrief Flight Planning')
@section('content')
<div class="row">
<div class="col-md-12">
<h2>Select Aircraft for Flight</h2>
</div>
</div>
<div class="row">
<div class="col-md-12">
<select id="aircraftselection" class="form-control select2" onchange="checkacselection()">
<option value="ZZZZZ">Please Select An Aircraft</option>
@foreach($subfleets as $subfleet)
@foreach($subfleet->aircraft as $ac)
<option value="{{ $ac->id }}">[ {{ $ac->icao }} ] {{ $ac->registration }}</option>
@endforeach
@endforeach
</select>
</div>
<div class="col-md-12 text-right">
<a id="generate_link" style="visibility: hidden"
href="{{ route('frontend.simbrief.generate') }}?flight_id={{ $flight->id }}"
class="btn btn-primary">Proceed To Flight Planning</a>
</div>
</div>
@endsection
@section('scripts')
<script type="text/javascript">
// Simple Aircraft Selection With Dropdown Change
// Also keep Generate button hidden until a valid AC selection
const $oldlink = document.getElementById("generate_link").href;
function checkacselection() {
if (document.getElementById("aircraftselection").value === "ZZZZZ") {
document.getElementById('generate_link').style.visibility = 'hidden';
} else {
document.getElementById('generate_link').style.visibility = 'visible';
}
const selectedac = document.getElementById("aircraftselection").value;
const newlink = "&aircraft_id=".concat(selectedac);
document.getElementById("generate_link").href = $oldlink.concat(newlink);
}
</script>
@endsection

View File

@@ -10,14 +10,14 @@
<div class="col-sm-3">
@if (empty($simbrief->pirep_id))
<a class="btn btn-outline-info pull-right btn-lg"
style="margin-top: -10px; margin-bottom: 5px"
style="margin-top: -10px;margin-bottom: 5px"
href="{{ url(route('frontend.simbrief.prefile', [$simbrief->id])) }}">Prefile PIREP</a>
@endif
</div>
<div class="col-sm-3">
<a class="btn btn-primary pull-right btn-lg"
style="margin-top: -10px; margin-bottom: 5px"
href="{{ url(route('frontend.simbrief.generate_new', [$simbrief->id])) }}">Generate New OFP</a>
<a class="btn btn-primary pull-right btn-lg"
style="margin-top: -10px;margin-bottom: 5px"
href="{{ url(route('frontend.simbrief.remove', [$simbrief->id])) }}">Generate New OFP</a>
</div>
</div>
@@ -72,9 +72,9 @@
</div>
<div class="col-4 text-center">
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Est. Enroute Time</p>
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Enroute Time</p>
<p class="border border-dark rounded p-1 small text-monospace">
@minutestotime($simbrief->xml->times->est_time_enroute / 60)</p>
@minutestotime($simbrief->xml->times->sched_time_enroute / 60)</p>
</div>
</div>
@@ -134,30 +134,24 @@
<div class="row">
<div class="col-12">
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Departure METAR</p>
<p
class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->orig_metar }}</p>
<p class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->orig_metar }}</p>
</div>
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Departure TAF</p>
<p
class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->orig_taf }}</p>
<p class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->orig_taf }}</p>
</div>
<hr/>
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Destination METAR</p>
<p
class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->dest_metar }}</p>
<p class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->dest_metar }}</p>
</div>
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Destination TAF</p>
<p
class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->dest_taf }}</p>
<p class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->dest_taf }}</p>
</div>
<hr/>
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Alternate METAR</p>
<p
class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->altn_metar }}</p>
<hr/>
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Alternate METAR</p>
<p class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->altn_metar }}</p>
</div>
<div><p class="small text-uppercase pb-sm-0 mb-sm-1">Alternate TAF</p>
<p
class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->altn_taf }}</p>
<p class="border border-dark rounded p-1 small text-monospace">{{ $simbrief->xml->weather->altn_taf }}</p>
</div>
</div>
</div>
@@ -187,55 +181,66 @@
</div>
</div>
</div>
<div class="form-container">
<h6><i class="fas fa-info-circle"></i>&nbsp;Prefile ATC Flight Plan</h6>
<div class="form-container-body">
<div class="row">
<div class="col-4" align="center">
<form action="https://fpl.ivao.aero/api/fp/load" method="POST" target="_blank">
<input type="hidden" name="CALLSIGN" value="{{ $simbrief->xml->atc->callsign }}"/>
<input type="hidden" name="RULES" value="I"/>
<input type="hidden" name="FLIGHTTYPE" value="N"/>
<input type="hidden" name="NUMBER" value="1"/>
<input type="hidden" name="ACTYPE" value="{{ $simbrief->xml->aircraft->icaocode }}"/>
<input type="hidden" name="WAKECAT" value="{{ $wakecat }}"/>
<input type="hidden" name="EQUIPMENT" value="{{ $equipment }}"/>
<input type="hidden" name="TRANSPONDER" value="{{ $transponder }}"/>
<input type="hidden" name="DEPICAO" value="{{ $simbrief->xml->origin->icao_code}}"/>
<input type="hidden" name="DEPTIME" value="{{ date('Hi', $simbrief->xml->times->est_out->__toString()) }}"/>
<input type="hidden" name="SPEEDTYPE" value="{{ $simbrief->xml->atc->initial_spd_unit }}"/>
<input type="hidden" name="SPEED" value="{{ $simbrief->xml->atc->initial_spd }}"/>
<input type="hidden" name="LEVELTYPE" value="{{ $simbrief->xml->atc->initial_alt_unit }}"/>
<input type="hidden" name="LEVEL" value="{{ $simbrief->xml->atc->initial_alt }}"/>
<input type="hidden" name="ROUTE" value="{{ $simbrief->xml->general->route_ifps }}"/>
<input type="hidden" name="DESTICAO" value="{{ $simbrief->xml->destination->icao_code }}"/>
<input type="hidden" name="EET" value="@secstohhmm($simbrief->xml->times->est_time_enroute)"/>
<input type="hidden" name="ALTICAO" value="{{ $simbrief->xml->alternate->icao_code}}"/>
<input type="hidden" name="ALTICAO2" value="{{ $simbrief->xml->alternate2->icao_code}}"/>
<input type="hidden" name="OTHER" value="{{ $simbrief->xml->atc->section18 }}"/>
<input type="hidden" name="ENDURANCE" value="@secstohhmm($simbrief->xml->times->endurance)"/>
<input type="hidden" name="POB" value="{{ $simbrief->xml->weights->pax_count }}"/>
<input id="ivao_prefile" type="submit" class="btn btn-primary" value="File ATC on IVAO"/>
</form>
</div>
<div class="col-4" align="center">
<form action="https://my.vatsim.net/pilots/flightplan" method="GET" target="_blank">
<input type="hidden" name="raw" value="{{ $simbrief->xml->atc->flightplan_text }}">
<input type="hidden" name="fuel_time" value="@secstohhmm($simbrief->xml->times->endurance)">
<input type="hidden" name="speed" value="@if(substr($simbrief->xml->atc->initial_spd,0,1) === '0') {{ substr($simbrief->xml->atc->initial_spd,1) }} @else {{ $simbrief->xml->atc->initial_spd }} @endif">
<input type="hidden" name="altitude" value="{{ $simbrief->xml->general->initial_altitude }}">
<input id="vatsim_prefile" type="submit" class="btn btn-primary" value="File ATC on VATSIM"/>
</form>
</div>
<div class="col-4" align="center">
<a
href="http://skyvector.com/?chart=304&amp;fpl={{ $simbrief->xml->origin->icao_code}} {{ $simbrief->xml->general->route }} {{ $simbrief->xml->destination->icao_code}}"
target="_blank" class="btn btn-info">View Route At SkyVector</a>
</div>
</div>
@php
$str = $simbrief->xml->aircraft->equip ;
$wc = stripos($str,"-");
$tr = stripos($str,"/");
$wakecat = substr($str,0,$wc);
$equipment = substr($str,$wc+1,$tr-2);
$transponder = substr($str,$tr+1);
function secstohhmm($seconds) {
$seconds = round($seconds);
$hhmm = sprintf('%02d%02d', ($seconds/ 3600),($seconds/ 60 % 60));
echo $hhmm ;
}
@endphp
<form action="https://fpl.ivao.aero/api/fp/load" method="POST" target="_blank">
<input type="hidden" name="CALLSIGN" value="{{ $simbrief->xml->atc->callsign }}" />
<input type="hidden" name="RULES" value="I" />
<input type="hidden" name="FLIGHTTYPE" value="N" />
<input type="hidden" name="NUMBER" value="1" />
<input type="hidden" name="ACTYPE" value="{{ $simbrief->xml->aircraft->icaocode }}" />
<input type="hidden" name="WAKECAT" value="{{ $wakecat }}" />
<input type="hidden" name="EQUIPMENT" value="{{ $equipment }}" />
<input type="hidden" name="TRANSPONDER" value="{{ $transponder }}" />
<input type="hidden" name="DEPICAO" value="{{ $simbrief->xml->origin->icao_code}}" />
<input type="hidden" name="DEPTIME" value="{{ date('Hi', $simbrief->xml->times->est_out->__toString())."" }}" />
<input type="hidden" name="SPEEDTYPE" value="{{ $simbrief->xml->atc->initial_spd_unit }}" />
<input type="hidden" name="SPEED" value="{{ $simbrief->xml->atc->initial_spd }}" />
<input type="hidden" name="LEVELTYPE" value="{{ $simbrief->xml->atc->initial_alt_unit }}" />
<input type="hidden" name="LEVEL" value="{{ $simbrief->xml->atc->initial_alt }}" />
<input type="hidden" name="ROUTE" value="{{ $simbrief->xml->general->route_ifps }}" />
<input type="hidden" name="DESTICAO" value="{{ $simbrief->xml->destination->icao_code }}" />
<input type="hidden" name="EET" value="@php secstohhmm($simbrief->xml->times->est_time_enroute) @endphp" />
<input type="hidden" name="ALTICAO" value="{{ $simbrief->xml->alternate->icao_code}}" />
<input type="hidden" name="ALTICAO2" value="{{ $simbrief->xml->alternate2->icao_code}}" />
<input type="hidden" name="OTHER" value="{{ $simbrief->xml->atc->section18 }}" />
<input type="hidden" name="ENDURANCE" value="@php secstohhmm($simbrief->xml->times->endurance) @endphp" />
<input type="hidden" name="POB" value="{{ $simbrief->xml->weights->pax_count }}" />
<input id="ivao_prefile" type="submit" class="btn btn-primary" value="File ATC on IVAO" />
</form>
</div>
<div class="col-4" align="center">
<form action="https://my.vatsim.net/pilots/flightplan" method="GET" target="_blank">
<input type="hidden" name="raw" value="{{ $simbrief->xml->atc->flightplan_text }}">
<input type="hidden" name="fuel_time" value="@php secstohhmm($simbrief->xml->times->endurance) @endphp">
<input type="hidden" name="speed" value="{{ $simbrief->xml->atc->initial_spd }}">
<input type="hidden" name="altitude" value="{{ $simbrief->xml->atc->initial_alt }}">
<input id="vatsim_prefile" type="submit" class="btn btn-primary" value="File ATC on VATSIM"/>
</form>
</div>
</div>
<div class="col-4" align="center">
<a href="http://skyvector.com/?chart=304&amp;fpl={{ $simbrief->xml->origin->icao_code}} {{ $simbrief->xml->general->route }} {{ $simbrief->xml->destination->icao_code}}" target="_blank" class="btn btn-info">View Route At SkyVector</a>
</div>
</div>
</div>
</div>
<div class="form-container">
<h6><i class="fas fa-info-circle"></i>
&nbsp;OFP

View File

@@ -1,377 +1,269 @@
@extends('app')
@section('title', 'SimBrief Flight Planning')
@section('title', 'Generate OFP')
@section('content')
<form id="sbapiform">
<div class="row">
<h2>Create Simbrief Briefing</h2>
<div class="card">
<div class="col-md-12">
<div class="row">
<div class="col-8">
<div class="form-container">
<div class="col-md-12">
<h2>Create Flight Briefing</h2>
<div class="row">
<div class="col-8">
<div class="form-container">
<h6><i class="fas fa-info-circle"></i>
&nbsp;@lang('pireps.flightinformations')
</h6>
<div class="form-container-body">
<div class="row">
<div class="col-sm-4">
<label for="orig">Departure Airport</label>
<input id="orig"
name="orig"
type="text"
class="form-control"
placeholder="ZZZZ"
maxlength="4"
value="{{ $flight->dpt_airport_id }}"/>
</div>
<div class="form-container-body">
<h6><i class="fas fa-info-circle"></i>&nbsp;Aircraft Details</h6>
<div class="row">
<div class="col-sm-4">
<label for="type">Type</label>
<input type="text" class="form-control" value="{{ $aircraft->icao }}" maxlength="4" disabled>
<input type="hidden" name="type" value="{{ $aircraft->subfleet->simbrief_type ?? $aircraft->icao }}">
</div>
<div class="col-sm-4">
<label for="reg">Registration</label>
<input type="text" class="form-control" value="{{ $aircraft->registration }}" maxlength="6" disabled>
<input type="hidden" name="reg" value="{{ $aircraft->registration }}">
</div>
<div class="col-sm-4">
<label for="dest">Arrival Airport</label>
<input id="dest"
name="dest"
type="text"
class="form-control"
placeholder=""
maxlength="4"
value="{{ $flight->arr_airport_id }}"/>
</div>
<br>
</div>
<div class="form-container-body">
<h6><i class="fas fa-info-circle"></i>&nbsp;@lang('pireps.flightinformations') For
<b>{{ $flight->airline->icao }}{{ $flight->flight_number }} ({{ \App\Models\Enums\FlightType::label($flight->flight_type) }})</b></h6>
<div class="row">
<div class="col-sm-4">
<label for="dorig">Departure Airport</label>
<input id="dorig" type="text" class="form-control" maxlength="4" value="{{ $flight->dpt_airport_id }}" disabled>
<input name="orig" type="hidden" maxlength="4" value="{{ $flight->dpt_airport_id }}">
</div>
<div class="col-sm-4">
<label for="ddest">Arrival Airport</label>
<input id="ddest" type="text" class="form-control" maxlength="4" value="{{ $flight->arr_airport_id }}" disabled>
<input name="dest" type="hidden" maxlength="4" value="{{ $flight->arr_airport_id }}">
</div>
<div class="col-sm-4">
<label for="altn">Alternate Airport</label>
<input name="altn" type="text" class="form-control" maxlength="4" value="{{ $flight->alt_airport_id ?? 'AUTO' }}">
</div>
</div>
<br>
<div class="row">
<div class="col-sm-8">
<label for="route">Preferred Company Route</label>
<input name="route" type="text" class="form-control" value="{{ $flight->route }}">
</div>
<div class="col-sm-4">
<label for="fl">Preferred Flight Level</label>
<input id="fl" name="fl" type="text" class="form-control" maxlength="5" value="{{ $flight->level }}">
</div>
</div>
<br>
<div class="row">
<div class="col-sm-4">
@if($flight->dpt_time)
<label for="std">Scheduled Departure Time (UTC)</label>
<input id="std" type="text" class="form-control" maxlength="4" value="{{ $flight->dpt_time }}" disabled>
@endif
</div>
<div class="col-sm-4">
<label for="etd">Estimated Departure Time (UTC)</label>
<input id="etd" type="text" class="form-control" maxlength="4" disabled>
</div>
<div class="col-sm-4">
<label for="dof">Date Of Flight (UTC)</label>
<input id="dof" type="text" class="form-control" maxlength="4" disabled>
</div>
</div>
<br>
</div>
<div class="form-container-body">
<h6><i class="fas fa-info-circle"></i>&nbsp;Configuration And Load Information For
<b>{{ $aircraft->registration }} ({{ $aircraft->subfleet->name }})</b></h6>
<div class="row">
@foreach($pax_load_sheet as $fare)
<div class="col-sm-3">
<label for="LoadFare{{ $fare['id'] }}">{{ $fare['name'] }} [Max: {{ $fare['capacity'] }}]</label>
<input id="LoadFare{{ $fare['id'] }}" type="text" class="form-control" value="{{ $fare['count'] }}" disabled>
</div>
@endforeach
{{-- Generate Load Figures For Cargo Fares --}}
@foreach($cargo_load_sheet as $fare)
<div class="col-sm-3">
<label for="LoadFare{{ $fare['id'] }}">{{ $fare['name'] }} [Max: {{ number_format($fare['capacity'] - $tbagload) }} {{ setting('units.weight') }}]</label>
<input id="LoadFare{{ $fare['id'] }}" type="text" class="form-control" value="{{ number_format($fare['count']) }}" disabled>
</div>
@endforeach
</div>
@if(isset($tpayload) && $tpayload > 0)
{{-- Display The Weights Generated --}}
<br>
<div class="row">
@if($tpaxload)
<div class="col-sm-3">
<label for="tdPaxLoad">Pax Weight</label>
<input id="tdPaxLoad" type="text" class="form-control" value="{{ number_format($tpaxload) }} {{ setting('units.weight') }}" disabled>
</div>
<div class="col-sm-3">
<label for="tBagLoad">Baggage Weight</label>
<input id="tBagLoad" type="text" class="form-control" value="{{ number_format($tbagload) }} {{ setting('units.weight') }}" disabled>
</div>
@endif
@if($tpaxload && $tcargoload)
<div class="col-sm-3">
<label for="tCargoload">Cargo Weight</label>
<input id="tCargoload" type="text" class="form-control" value="{{ number_format($tcargoload) }} {{ setting('units.weight') }}" disabled>
</div>
@endif
<div class="col-sm-3">
<label for="tPayload">Total Payload</label>
<input id="tPayload" type="text" class="form-control" value="{{ number_format($tpayload) }} {{ setting('units.weight') }}" disabled>
</div>
</div>
@endif
</div>
</div>
{{-- Prepare Form Fields For SimBrief --}}
<input type="hidden" name="acdata" value="{'paxwgt':{{ round($pax_weight + $bag_weight) }}}">
@if($tpaxfig)
<input type="hidden" name="pax" value="{{ $tpaxfig }}">
@elseif(!$tpaxfig && $tcargoload)
<input type="hidden" name="pax" value="0">
@endif
@if($tcargoload)
<input type='hidden' name='cargo' value="{{ number_format(($tcargoload / 1000),1) }}">
@endif
@if(isset($tpayload) && $tpayload > 0)
<input type="hidden" name="manualrmk" value="Load Distribution {{ $loaddist }}">
@endif
<input type="hidden" name="airline" value="{{ $flight->airline->icao }}">
<input type="hidden" name="fltnum" value="{{ $flight->flight_number }}">
@if(setting('simbrief.callsign', true))
<input type="hidden" name="callsign" value="{{ $user->ident }}">
@endif
<input type="hidden" id="steh" name="steh" maxlength="2">
<input type="hidden" id="stem" name="stem" maxlength="2">
<input type="hidden" id="date" name="date" maxlength="9">
<input type="hidden" id="deph" name="deph" maxlength="2">
<input type="hidden" id="depm" name="depm" maxlength="2">
<input type="hidden" name="selcal" value="BK-FS">
<input type="hidden" name="planformat" value="lido">
<input type="hidden" name="omit_sids" value="0">
<input type="hidden" name="omit_stars" value="0">
<input type="hidden" name="cruise" value="CI">
<input type="hidden" name="civalue" value="AUTO">
{{-- For more info about form fields and their details check SimBrief Forum / API Support --}}
</div>
<div class="col-4">
<div class="form-container">
<div class="form-container-body">
<h6><i class="fas fa-info-circle"></i>&nbsp;Planning Options</h6>
<table class="table table-sm table-striped">
<tr>
<td>Cont Fuel:</td>
<td>
<select name="contpct" class="form-control">
<option value="0">None</option>
<option value="auto">AUTO</option>
<option value="easa">EASA</option>
<option value="0.03/5">3% or 05 MIN</option>
<option value="0.03/10">3% or 10 MIN</option>
<option value="0.03/15">3% or 15 MIN</option>
<option value="0.05/5" selected>5% or 05 MIN</option>
<option value="0.05/10">5% or 10 MIN</option>
<option value="0.05/15">5% or 15 MIN</option>
<option value="0.03">3%</option>
<option value="0.05">5%</option>
<option value="0.1">10%</option>
<option value="0.15">15%</option>
<option value="3">03 MIN</option>
<option value="5">05 MIN</option>
<option value="10">10 MIN</option>
<option value="15">15 MIN</option>
</select>
</td>
</tr>
<tr>
<td>Reserve Fuel:</td>
<td>
<select name="resvrule" class="form-control">
<option value="auto">AUTO</option>
<option value="0">0 MIN</option>
<option value="15">15 MIN</option>
<option value="30" selected>30 MIN</option>
<option value="45">45 MIN</option>
<option value="60">60 MIN</option>
<option value="75">75 MIN</option>
<option value="90">90 MIN</option>
</select>
</td>
</tr>
<tr>
<td>SID/STAR Type:</td>
<td>
<select name="find_sidstar" class="form-control">
<option value="C">Conventional</option>
<option value="R" selected>RNAV</option>
</select>
</td>
</tr>
<tr>
<td>Plan Stepclimbs:</td>
<td>
<select id="stepclimbs" name="stepclimbs" class="form-control" onchange="DisableFL()">
<option value="0" selected>Disabled</option>
<option value="1">Enabled</option>
</select>
</td>
</tr>
<tr>
<td>ETOPS Planning:</td>
<td>
<select name="etops" class="form-control">
<option value="0" selected>Disabled</option>
<option value="1">Enabled</option>
</select>
</td>
</tr>
</table>
</div>
<br>
<div class="form-container-body">
<h6><i class="fas fa-info-circle"></i>&nbsp;Briefing Options</h6>
<table class="table table-sm table-striped">
<tr>
<td>Units:</td>
<td>
<select id="kgslbs" name="units" class="form-control">
@if(setting('units.weight') === 'kg')
<option value="KGS" selected>KGS</option>
<option value="LBS">LBS</option>
@else
<option value="KGS">KGS</option>
<option value="LBS" selected>LBS</option>
@endif
</select>
</td>
</tr>
<tr>
<td>Detailed Navlog:</td>
<td>
<select name="navlog" class="form-control">
<option value="0">Disabled</option>
<option value="1" selected>Enabled</option>
</select>
</td>
</tr>
<tr>
<td>Runway Analysis:</td>
<td>
<select name="tlr" class="form-control">
<option value="0">Disabled</option>
<option value="1" selected>Enabled</option>
</select>
</td>
</tr>
<tr>
<td>Include NOTAMS:</td>
<td>
<select name="notams" class="form-control">
<option value="0">Disabled</option>
<option value="1" selected>Enabled</option>
</select>
</td>
</tr>
<tr>
<td>FIR NOTAMS:</td>
<td>
<select name="firnot" class="form-control">
<option value="0" selected>Disabled</option>
<option value="1">Enabled</option>
</select>
</td>
</tr>
<tr>
<td>Flight Maps:</td>
<td>
<select name="maps" class="form-control">
<option value="detail" selected>Detailed</option>
<option value="simple">Simple</option>
<option value="none">None</option>
</select>
</td>
</tr>
</table>
</div>
<br>
<div class="form-container-body">
<div class="float-right">
<div class="form-group">
<input type="button"
onclick="simbriefsubmit('{{ $flight->id }}', '{{ $aircraft->id }}', '{{ url(route('frontend.simbrief.briefing', [''])) }}');"
class="btn btn-primary" value="Generate">
</div>
<div class="col-sm-4">
<label for="type">Aircraft</label>
<select id="type" name="type" class="custom-select select2">
<option value="A306" title="A306">A306 - A300F4-600</option>
<option value="A310" title="A310 / CF6-80C2A2">A310 - A310-304</option>
<option value="A318" title="A318 / CFM56-5B9/P">A318 - A318-100</option>
<option value="A319" title="A319 / CFM56-5B6/2P">A319 - A319-100</option>
<option value="A320" title="A320 / CFM56-5B4/P">A320 - A320-200</option>
<option value="A321" title="A321 / CFM56-5B3/P">A321 - A321-200</option>
<option value="A332" title="A332 / CF6-80E1A4">A332 - A330-200</option>
<option value="A333" title="A333 / RR Trent 772B">A333 - A330-300</option>
<option value="A342" title="A342 / CFM56-5C2">A342 - A340-200</option>
<option value="A343" title="A343 / CFM56-5C4">A343 - A340-300</option>
<option value="A345" title="A345 / RB211 Trent 556-61">A345 - A340-500</option>
<option value="A346" title="A346 / RB211 Trent 556-61">A346 - A340-600</option>
<option value="A359" title="A359 / TRENT XWB-84">A359 - A350-900</option>
<option value="A35K" title="A35K / TRENT XWB-97">A35K - A350-1000</option>
<option value="A388" title="A388">A388 - A380-800</option>
<option value="AT72" title="AT72">AT72 - ATR72-500</option>
<option value="B190" title="B190 / PT6A-67D">B190 - B1900D</option>
<option value="B350" title="B350">B350 - KINGAIR</option>
<option value="B463" title="B463">B463 - BAE-146</option>
<option value="B703" title="B703">B703 - B707-320B</option>
<option value="B712" title="B712 / BR715-C1-30">B712 - B717-200</option>
<option value="B722" title="B722">B722 - B727-200</option>
<option value="B732" title="B732 / JT8D-15A">B732 - B737-200</option>
<option value="B733" title="B733 / CFM56-3C-1">B733 - B737-300</option>
<option value="B734" title="B734">B734 - B737-400</option>
<option value="B735" title="B735">B735 - B737-500</option>
<option value="B736" title="B736 / CFM56-7B22">B736 - B737-600</option>
<option value="BBJ1" title="B737 / CFM56-7B27">BBJ1 - B737 BBJ</option>
<option value="B737" title="B737 / CFM56-7B24">B737 - B737-700</option>
<option value="BBJ2" title="B738 / CFM56-7B27">BBJ2 - B737 BBJ2</option>
<option value="B738" title="B738 / CFM56-7B26">B738 - B737-800</option>
<option value="BBJ3" title="B739 / CFM56-7B27">BBJ3 - B737 BBJ3</option>
<option value="B739" title="B739 / CFM56-7B26">B739 - B737-900</option>
<option value="B742" title="B742 / JT9D-7F">B742 - B747-200B</option>
<option value="B744" title="B744 / RB211-524G/H">B744 - B747-400</option>
<option value="B74F" title="B744 / RB211-524G/H">B74F - B747-400F</option>
<option value="B748" title="B748 / GENX-2B67">B748 - B747-8</option>
<option value="B48F" title="B748 / GENX-2B67">B48F - B747-8F</option>
<option value="B752" title="B752 / PW2037">B752 - B757-200</option>
<option value="B75F" title="B752 / PW2037">B75F - B757-200PF</option>
<option value="B753" title="B753 / PW2037">B753 - B757-300</option>
<option value="B762" title="B762 / CF6-80C2-B2">B762 - B767-200ER</option>
<option value="B763" title="B763 / CF6-80C2B6F">B763 - B767-300ER</option>
<option value="B76F" title="B763 / CF6-80C2B6F">B76F - B767-300F</option>
<option value="B764" title="B764">B764 - B767-400ER</option>
<option value="B772" title="B772 / GE90-94B">B772 - B777-200ER</option>
<option value="B77L" title="B77L / GE90-110B1">B77L - B777-200LR</option>
<option value="B77F" title="B77L / GE90-110B1">B77F - B777-F</option>
<option value="B77W" title="B77W / GE90-115BL2">B77W - B777-300ER</option>
<option value="B788" title="B788 / GENX-1B70">B788 - B787-8</option>
<option value="B789" title="B789 / GENX-1B74">B789 - B787-9</option>
<option value="B78X" title="B78X / GENX-1B76">B78X - B787-10</option>
<option value="BE20" title="BE20">BE20 - KINGAIR</option>
<option value="C172" title="C172 / IO-360-L2A">C172 - CESSNA 172R</option>
<option value="C208" title="C208">C208 - CESSNA 208</option>
<option value="C25A" title="C25A / FJ44-2C">C25A - CITATION CJ2</option>
<option value="C404" title="C404">C404 - C404 TITAN</option>
<option value="C510" title="C510">C510 - C510 MUSTANG</option>
<option value="C550" title="C550">C550 - CITATION</option>
<option value="C56X" title="C56X / PW545A">C56X - CITATION 560XL</option>
<option value="C750" title="C750">C750 - CITATION X</option>
<option value="CL30" title="CL30 / HTF7350">CL30 - CHALLENGER</option>
<option value="CRJ2" title="CRJ2 / CF34-3B1">CRJ2 - CRJ-200</option>
<option value="CRJ7" title="CRJ7 / CF34-8C1">CRJ7 - CRJ-700</option>
<option value="CRJ9" title="CRJ9 / CF34-8C5">CRJ9 - CRJ-900</option>
<option value="CRJX" title="CRJX / CF34-8C5A1">CRJX - CRJ-1000</option>
<option value="DC10" title="DC10">DC10 - DC-10-30</option>
<option value="DC6" title="DC6 / R2800-CB16">DC6&nbsp; - DC-6</option>
<option value="DC85" title="DC85 / JT3D-3B">DC85 - DC-8-55</option>
<option value="DH8A" title="DH8A / PW120A">DH8A - DHC8-102</option>
<option value="DH8B" title="DH8B / PW123C">DH8B - DHC8-200</option>
<option value="DH8C" title="DH8C / PW123B">DH8C - DHC8-311</option>
<option value="DH8D" title="DH8D / PW150A">DH8D - DHC8-402</option>
<option value="DHC2" title="DHC2">DHC2 - BEAVER</option>
<option value="DHC6" title="DHC6">DHC6 - TWIN OTTER</option>
<option value="E13L" title="E135">E13L - EMB-135BJ</option>
<option value="E135" title="E135 / AE3007-A1/3">E135 - EMB-135LR</option>
<option value="E140" title="E135 / AE3007-A1/3">E140 - ERJ-140LR</option>
<option value="E145" title="E145 / AE3007-A1">E145 - EMB-145LR</option>
<option value="E170" title="E170 / CF34-8E5">E170 - EMB-170</option>
<option value="E175" title="E170 / CF34-8E5">E175 - EMB-175</option>
<option value="E190" title="E190 / CF34-10E6">E190 - EMB-190</option>
<option value="E195" title="E190 / CF34-10E7">E195 - EMB-195</option>
<option value="E50P" title="E50P / PW617F1-E">E50P - PHENOM 100</option>
<option value="E55P" title="E55P / PW535E">E55P - PHENOM 300</option>
<option value="EA50" title="EA50 / PW610F">EA50 - ECLIPSE 550</option>
<option value="F50" title="F50">F50&nbsp; - FOKKER F50</option>
<option value="FA50" title="FA50 / TFE 731-40">FA50 - FALCON 50EX</option>
<option value="GLF4" title="GLF4">GLF4 - GULFSTREAM</option>
<option value="H25B" title="H25B">H25B - HAWKER 800A</option>
<option value="JS41" title="JS41">JS41 - BAE JS-41</option>
<option value="L101" title="L101 / RB211-524B">L101 - L1011-500</option>
<option value="LJ25" title="LJ25 / CJ-610-8A">LJ25 - LEARJET 25</option>
<option value="LJ45" title="LJ45">LJ45 - LEARJET 45</option>
<option value="MD11" title="MD11 / CF6-80C2D1F">MD11 - MD-11</option>
<option value="MD1F" title="MD11 / CF6-80C2D1F">MD1F - MD-11F</option>
<option value="MD82" title="MD82 / JT8D-217">MD82 - DC-9-82</option>
<option value="MD83" title="MD83 / JT8D-219">MD83 - DC-9-83</option>
<option value="MD88" title="MD88 / JT8D-219">MD88 - MD-88</option>
<option value="MD90" title="MD90">MD90 - MD-90-30</option>
<option value="PC12" title="PC12 / PT6A-66D">PC12 - PILATUS PC12</option>
<option value="RJ1H" title="RJ1H">RJ1H - AVRO RJ100</option>
<option value="RJ70" title="RJ70">RJ70 - AVRO RJ70</option>
<option value="RJ85" title="RJ85">RJ85 - AVRO RJ85</option>
<option value="SF34" title="SF34 / GE CT7-9B">SF34 - SAAB 340B</option>
<option value="SF50" title="SF50 / FJ33-5A">SF50 - VISION JET</option>
<option value="SW4" title="SW4 / TPE-331">SW4&nbsp; - METROLINER</option>
<option value="T154" title="T154">T154 - TU-154B2</option>
<option value="TBM9" title="TBM9 / PT6A-66D">TBM9 - TBM 900</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="col-4">
<div class="form-container">
<h6><i class="fas fa-info-circle"></i>
&nbsp;Briefing Options
</h6>
<table class="table table-hover table-striped">
<tr>
<td>Units:</td>
<td><select name="units">
<option value="KGS">KGS</option>
<option value="LBS" selected>LBS</option>
</select></td>
</tr>
<tr>
<td>Cont Fuel:</td>
<td><select name="contpct">
<option value="auto" selected>AUTO</option>
<option value="0">0 PCT</option>
<option value="0.02">2 PCT</option>
<option value="0.03">3 PCT</option>
<option value="0.05">5 PCT</option>
<option value="0.1">10 PCT</option>
<option value="0.15">15 PCT</option>
<option value="0.2">20 PCT</option>
</select></td>
</tr>
<tr>
<td>Reserve Fuel:</td>
<td><select name="resvrule">
<option value="auto">AUTO</option>
<option value="0">0 MIN</option>
<option value="15">15 MIN</option>
<option value="30">30 MIN</option>
<option value="45" selected>45 MIN</option>
<option value="60">60 MIN</option>
<option value="75">75 MIN</option>
<option value="90">90 MIN</option>
</select></td>
</tr>
<tr>
<td>Detailed Navlog:</td>
<td><input type="hidden" name="navlog" value="0"><input type="checkbox" name="navlog" value="1"
checked>
</td>
</tr>
<tr>
<td>ETOPS Planning:</td>
<td><input type="hidden" name="etops" value="0"><input type="checkbox" name="etops" value="1"></td>
</tr>
<tr>
<td>Plan Stepclimbs:</td>
<td><input type="hidden" name="stepclimbs" value="0"><input type="checkbox" name="stepclimbs"
value="1"
checked>
</td>
</tr>
<tr>
<td>Runway Analysis:</td>
<td><input type="hidden" name="tlr" value="0"><input type="checkbox" name="tlr" value="1" checked>
</td>
</tr>
<tr>
<td>Include NOTAMS:</td>
<td><input type="hidden" name="notams" value="0"><input type="checkbox" name="notams" value="1"
checked>
</td>
</tr>
<tr>
<td>FIR NOTAMS:</td>
<td><input type="hidden" name="firnot" value="0"><input type="checkbox" name="firnot" value="1"></td>
</tr>
<tr>
<td>Flight Maps:</td>
<td><select name="maps">
<option value="detail">Detailed</option>
<option value="simple">Simple</option>
<option value="none">None</option>
</select></td>
</tr>
</table>
</div>
</div>
</div>
<input type="hidden" name="airline" value="{{ $flight->airline->icao }}">
<input type="hidden" name="fltnum" value="{{ $flight->flight_number }}">
<input type="hidden" name="date" value="01JAN14">
<input type="hidden" name="deph" value="12">
<input type="hidden" name="depm" value="30">
<input type="hidden" name="steh" value="2">
<input type="hidden" name="stem" value="15">
{{--<input type="hidden" name="reg" value="N123SB">
<input type="hidden" name="selcal" value="GR-FS">--}}
<input type="hidden" name="planformat" value="lido">
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="float-right">
<div class="form-group">
<input type="button"
onclick="simbriefsubmit('{{ $flight->id }}', '{{ url(route('frontend.simbrief.briefing', [''])) }}');"
class="btn btn-outline-primary"
value="Generate">
</div>
</div>
</div>
</div>
</form>
@endsection
@section('scripts')
<script src="{{public_asset('/assets/global/js/simbrief.apiv1.js')}}"></script>
<script type="text/javascript">
// ******
// Disable Submitting a fixed flight level for Stepclimb option to work
// Script is related to Plan Step Climbs selection
function DisableFL() {
let climb = document.getElementById("stepclimbs").value;
if (climb === "0") {
document.getElementById("fl").disabled = false
}
if (climb === "1") {
document.getElementById("fl").disabled = true
}
}
</script>
<script type="text/javascript">
// ******
// Get current UTC time, add 45 minutes to it and format according to Simbrief API
// Script also rounds the minutes to nearest 5 to avoid a Departure time like 1538 ;)
// If you need to reduce the margin of 45 mins, change value below
let d = new Date();
const months = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
d.setMinutes(d.getMinutes() + 45); // Change the value here
let deph = ("0" + d.getUTCHours(d)).slice(-2);
let depm = d.getUTCMinutes(d);
if (depm < 55) {
depm = Math.ceil(depm / 5) * 5;
}
if (depm > 55) {
depm = Math.floor(depm / 5) * 5;
}
depm = ("0" + depm).slice(-2);
dept = deph + ":" + depm;
let dof = ("0" + d.getUTCDate()).slice(-2) + months[d.getUTCMonth()] + d.getUTCFullYear();
document.getElementById("dof").setAttribute('value', dof);
document.getElementById("etd").setAttribute('value', dept);
document.getElementById("date").setAttribute('value', dof); // Sent to Simbrief
document.getElementById("deph").setAttribute('value', deph); // Sent to SimBrief
document.getElementById("depm").setAttribute('value', depm); // Sent to SimBrief
</script>
<script type="text/javascript">
// ******
// Calculate the Scheduled Enroute Time for Simbrief API
// Your PHPVMS flight_time value must be from BLOCK to BLOCK
// Including departure and arrival taxi times
// If this value is not correctly calculated and configured
// Simbrief CI (Cost Index) calculation will not provide realistic results
let num = {{ $flight->flight_time }};
let hours = (num / 60);
let rhours = Math.floor(hours);
let minutes = (hours - rhours) * 60;
let rminutes = Math.round(minutes);
document.getElementById("steh").setAttribute('value', rhours.toString()); // Sent to Simbrief
document.getElementById("stem").setAttribute('value', rminutes.toString()); // Sent to Simbrief
</script>
<script src="{{public_asset('/assets/global/js/simbrief.apiv1.js')}}"></script>
@endsection

View File

@@ -70,22 +70,12 @@
</div>
<div class="row">
<div class="col-sm-12 text-right">
<!-- Simbrief enabled -->
@if ($simbrief !== false)
<!-- If this flight has a briefing, show the link to view it-->
@if ($flight->simbrief && $flight->simbrief->user_id === $user->id)
<a href="{{ route('frontend.simbrief.briefing', $flight->simbrief->id) }}"
@if ($simbrief_bids === false || ($simbrief_bids === true && in_array($flight->id, $saved, true)))
<a href="{{ route('frontend.simbrief.generate') }}?flight_id={{ $flight->id }}"
class="btn btn-sm btn-outline-primary">
View Simbrief Flight Plan
Create SimBrief Flight Plan
</a>
@else
<!-- Show button if the bids-only is disable, or if bids-only is enabled, they've saved it -->
@if ($simbrief_bids === false || ($simbrief_bids === true && in_array($flight->id, $saved, true)))
<a href="{{ route('frontend.simbrief.generate') }}?flight_id={{ $flight->id }}"
class="btn btn-sm btn-outline-primary">
Create Simbrief Flight Plan
</a>
@endif
@endif
@endif

View File

@@ -9,7 +9,7 @@
<div class="col">
{{Form::label('fare_'.$fare->id, $fare->name.' ('. \App\Models\Enums\FareType::label($fare->type).', code '.$fare->code.')')}}
<div class="input-group form-group">
{{ Form::number('fare_'.$fare->id, $fare->count, ['class' => 'form-control', 'min' => 0]) }}
{{ Form::number('fare_'.$fare->id, null, ['class' => 'form-control', 'min' => 0]) }}
</div>
</div>
</div>

View File

@@ -133,11 +133,11 @@
<div class="text-right">
@if (isset($acars) && $acars === true)
<a href="{{ route('frontend.profile.acars') }}" class="btn btn-primary"
onclick="alert('Copy or Save to \'My Documents/phpVMS\'')">ACARS Config</a>
onclick="alert('Save to \'My Documents/phpVMS\'')">ACARS Config</a>
&nbsp;
@endif
<a href="{{ route('frontend.profile.regen_apikey') }}" class="btn btn-warning"
onclick="return confirm('Are you sure? This will reset your API key!')">@lang('profile.newapikey')</a>
onclick="return confirm({{ __('Are you sure? This will reset your API key.') }})">@lang('profile.newapikey')</a>
&nbsp;
<a href="{{ route('frontend.profile.edit', [$user->id]) }}"
class="btn btn-primary">@lang('common.edit')</a>
@@ -171,7 +171,7 @@
<div class="col-sm-12">
<table class="table table-full-width">
@foreach($userFields as $field)
@if(!$field->private)
@if($field->public === true)
<tr>
<td>{{ $field->name }}</td>
<td>{{ $field->value }}</td>

Some files were not shown because too many files have changed in this diff Show More