Compare commits
111
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5a1a1f7aa | ||
|
|
ec6cb42bfd | ||
|
|
14d0e99a37 | ||
|
|
f8c7bc31f5 | ||
|
|
2545328233 | ||
|
|
61739ce266 | ||
|
|
bffc4f911c | ||
|
|
d18925f473 | ||
|
|
f5e83461a3 | ||
|
|
bfddb2c84d | ||
|
|
7e9eb08135 | ||
|
|
3d55336823 | ||
|
|
68ed2355ad | ||
|
|
fdab4ee530 | ||
|
|
648e7a261d | ||
|
|
9cb0a0cf36 | ||
|
|
2c8372d484 | ||
|
|
498d5bfaf0 | ||
|
|
2202c5b479 | ||
|
|
ac64a5db75 | ||
|
|
6c3992e781 | ||
|
|
344edde0fb | ||
|
|
7502c053bf | ||
|
|
dbfaed0ecc | ||
|
|
ff255c999b | ||
|
|
8c065a44cf | ||
|
|
8e9ba3b922 | ||
|
|
677d30883f | ||
|
|
ede71e6927 | ||
|
|
3f84f84309 | ||
|
|
50e8f2e52b | ||
|
|
96fff0248d | ||
|
|
9c4aced837 | ||
|
|
ed146b2c70 | ||
|
|
1e320835c2 | ||
|
|
d4c301a36c | ||
|
|
c2b0b69eb2 | ||
|
|
43c33adcfe | ||
|
|
be6332936f | ||
|
|
8f38fc2dec | ||
|
|
65015cbce2 | ||
|
|
3cc5ca2c32 | ||
|
|
30e88ac6bc | ||
|
|
61ee4254fc | ||
|
|
f9f0ee826d | ||
|
|
4394487392 | ||
|
|
1287766a46 | ||
|
|
11824c9f8b | ||
|
|
bbd02bf5c7 | ||
|
|
9bb192b97f | ||
|
|
2cede04b1e | ||
|
|
7072428218 | ||
|
|
1d83b85d8b | ||
|
|
63eef59060 | ||
|
|
0152ff6045 | ||
|
|
e45bd66388 | ||
|
|
b9e7a2efc9 | ||
|
|
73f88fce0c | ||
|
|
e70ee5aa6f | ||
|
|
f1c54bcc7c | ||
|
|
d94d754961 | ||
|
|
9abfbd6c8c | ||
|
|
97fc1dd43d | ||
|
|
edc37f40fa | ||
|
|
950c7788be | ||
|
|
b3af50ac5a | ||
|
|
8a9b68d9ec | ||
|
|
70a4cf9f90 | ||
|
|
c3465851b2 | ||
|
|
b13c4df338 | ||
|
|
c736a9b639 | ||
|
|
d2e1004e08 | ||
|
|
3800c01d94 | ||
|
|
922e754c9e | ||
|
|
936cd2efd3 | ||
|
|
e22d6d5996 | ||
|
|
efcb7e8895 | ||
|
|
43fbe9e943 | ||
|
|
8fc0aec800 | ||
|
|
bb84fa82a4 | ||
|
|
4fe323a763 | ||
|
|
e3b4a0ed2e | ||
|
|
a4c431d39f | ||
|
|
a52e0410a7 | ||
|
|
baf63361a0 | ||
|
|
b4d5c0fbcd | ||
|
|
6b7eab05e2 | ||
|
|
4c8e31ac6f | ||
|
|
fe41e61c02 | ||
|
|
bd85a04530 | ||
|
|
cbb7d6e274 | ||
|
|
8907527872 | ||
|
|
942c060c99 | ||
|
|
68a9421445 | ||
|
|
4e652c91ae | ||
|
|
a6f62045c4 | ||
|
|
3f3b63da6f | ||
|
|
dd7812e5c5 | ||
|
|
447d02bd4f | ||
|
|
be9b698f14 | ||
|
|
d110c2d951 | ||
|
|
4d20998368 | ||
|
|
4a20b41b25 | ||
|
|
8c2513eb3d | ||
|
|
2dbd58e59e | ||
|
|
bf77f7dd96 | ||
|
|
5a570989de | ||
|
|
6b3207377a | ||
|
|
ac1d5e1555 | ||
|
|
0d45fc287b | ||
|
|
4911f6799d |
@@ -1,7 +1,3 @@
|
|||||||
<?php
|
|
||||||
exit();
|
|
||||||
?>
|
|
||||||
|
|
||||||
APP_ENV="dev"
|
APP_ENV="dev"
|
||||||
APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY="
|
APP_KEY="base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY="
|
||||||
APP_URL="http://localhost"
|
APP_URL="http://localhost"
|
||||||
@@ -12,7 +8,7 @@ APP_LOCALE="en"
|
|||||||
PHPVMS_INSTALLED="true"
|
PHPVMS_INSTALLED="true"
|
||||||
|
|
||||||
APP_LOG="daily"
|
APP_LOG="daily"
|
||||||
APP_LOG_LEVEL="debug"
|
LOG_LEVEL="debug"
|
||||||
APP_LOG_MAX_FILES="3"
|
APP_LOG_MAX_FILES="3"
|
||||||
|
|
||||||
DB_CONNECTION="mysql"
|
DB_CONNECTION="mysql"
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ jobs:
|
|||||||
php --version
|
php --version
|
||||||
mysql --version
|
mysql --version
|
||||||
# Downgrade composer version to 1.x
|
# Downgrade composer version to 1.x
|
||||||
composer self-update --1
|
|
||||||
composer install --dev --no-interaction --verbose
|
composer install --dev --no-interaction --verbose
|
||||||
cp .github/scripts/env.php env.php
|
cp .github/scripts/env.php env.php
|
||||||
cp .github/scripts/phpunit.xml phpunit.xml
|
cp .github/scripts/phpunit.xml phpunit.xml
|
||||||
@@ -119,7 +118,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
rm -rf vendor
|
rm -rf vendor
|
||||||
sudo npm i tar-to-zip -g
|
sudo npm i tar-to-zip -g
|
||||||
composer self-update --1
|
|
||||||
composer install --no-dev --prefer-dist --no-interaction --verbose
|
composer install --no-dev --prefer-dist --no-interaction --verbose
|
||||||
sudo chmod +x ./.github/scripts/*
|
sudo chmod +x ./.github/scripts/*
|
||||||
|
|
||||||
@@ -183,7 +181,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
rm -rf vendor
|
rm -rf vendor
|
||||||
sudo npm i tar-to-zip -g
|
sudo npm i tar-to-zip -g
|
||||||
composer self-update --1
|
|
||||||
composer install --no-dev --prefer-dist --no-interaction --verbose
|
composer install --no-dev --prefer-dist --no-interaction --verbose
|
||||||
sudo chmod +x ./.github/scripts/*
|
sudo chmod +x ./.github/scripts/*
|
||||||
|
|
||||||
|
|||||||
@@ -74,4 +74,5 @@ error_log
|
|||||||
.sass-cache
|
.sass-cache
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/config.php
|
/config.php
|
||||||
|
/config.bak.php
|
||||||
/VERSION
|
/VERSION
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ RedirectMatch 403 ^/composer.phar
|
|||||||
RedirectMatch 403 ^/env.php.*?$
|
RedirectMatch 403 ^/env.php.*?$
|
||||||
RedirectMatch 403 ^/env.php
|
RedirectMatch 403 ^/env.php
|
||||||
RedirectMatch 403 ^/env.php$
|
RedirectMatch 403 ^/env.php$
|
||||||
|
RedirectMatch 403 ^/config.php$
|
||||||
|
RedirectMatch 403 ^/config.bak.php$
|
||||||
RedirectMatch 403 ^/Makefile
|
RedirectMatch 403 ^/Makefile
|
||||||
RedirectMatch 403 ^/package.json
|
RedirectMatch 403 ^/package.json
|
||||||
RedirectMatch 403 ^/package-lock.json
|
RedirectMatch 403 ^/package-lock.json
|
||||||
|
|||||||
+2
-1
@@ -2,7 +2,7 @@ FROM php:7.4-fpm-alpine
|
|||||||
|
|
||||||
WORKDIR /var/www/
|
WORKDIR /var/www/
|
||||||
|
|
||||||
RUN apk add gmp-dev
|
RUN apk add gmp-dev icu-dev
|
||||||
RUN curl --silent --show-error https://getcomposer.org/installer | php
|
RUN curl --silent --show-error https://getcomposer.org/installer | php
|
||||||
|
|
||||||
# Copy any config files in
|
# Copy any config files in
|
||||||
@@ -12,6 +12,7 @@ RUN ln -sf /dev/stderr /var/log/fpm-error.log
|
|||||||
|
|
||||||
RUN docker-php-ext-install \
|
RUN docker-php-ext-install \
|
||||||
calendar \
|
calendar \
|
||||||
|
intl \
|
||||||
pdo_mysql \
|
pdo_mysql \
|
||||||
gmp \
|
gmp \
|
||||||
opcache && \
|
opcache && \
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ A full development environment can be brought up using Docker:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer install
|
composer install
|
||||||
yarn install
|
npm install
|
||||||
docker-compose build
|
docker-compose build
|
||||||
docker-compose up
|
docker-compose up
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use App;
|
use App;
|
||||||
use App\Contracts\Command;
|
use App\Contracts\Command;
|
||||||
|
use App\Services\Installer\ConfigService;
|
||||||
use App\Services\Installer\SeederService;
|
use App\Services\Installer\SeederService;
|
||||||
use DatabaseSeeder;
|
use DatabaseSeeder;
|
||||||
use Modules\Installer\Services\ConfigService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the config files
|
* Create the config files
|
||||||
@@ -81,13 +81,13 @@ class CreateConfigs extends Command
|
|||||||
|
|
||||||
$this->info('Regenerating the config files');
|
$this->info('Regenerating the config files');
|
||||||
$cfgSvc->createConfigFiles([
|
$cfgSvc->createConfigFiles([
|
||||||
'APP_ENV' => 'dev',
|
'APP_ENV' => 'dev',
|
||||||
'SITE_NAME' => $this->argument('name'),
|
'SITE_NAME' => $this->argument('name'),
|
||||||
'DB_CONN' => 'mysql',
|
'DB_CONNECTION' => 'mysql',
|
||||||
'DB_HOST' => $this->argument('db_host'),
|
'DB_HOST' => $this->argument('db_host'),
|
||||||
'DB_NAME' => $this->argument('db_name'),
|
'DB_DATABASE' => $this->argument('db_name'),
|
||||||
'DB_USER' => $this->argument('db_user'),
|
'DB_USERNAME' => $this->argument('db_user'),
|
||||||
'DB_PASS' => $this->argument('db_pass'),
|
'DB_PASSWORD' => $this->argument('db_pass'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->info('Config files generated!');
|
$this->info('Config files generated!');
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ class DevInstall extends Command
|
|||||||
|
|
||||||
$this->info('Regenerating the config files');
|
$this->info('Regenerating the config files');
|
||||||
$cfgSvc->createConfigFiles([
|
$cfgSvc->createConfigFiles([
|
||||||
'APP_ENV' => 'dev',
|
'APP_ENV' => 'dev',
|
||||||
'SITE_NAME' => 'phpvms test',
|
'SITE_NAME' => 'phpvms test',
|
||||||
'DB_CONN' => 'sqlite',
|
'DB_CONNECTION' => 'sqlite',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->info('Config files generated!');
|
$this->info('Config files generated!');
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Contracts\Command;
|
||||||
|
use App\Services\Installer\ConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command to rewrite the config files
|
||||||
|
*/
|
||||||
|
class RewriteConfigs extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'phpvms:rewrite-configs';
|
||||||
|
protected $description = 'Rewrite the config files';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run dev related commands
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
/** @var ConfigService $configSvc */
|
||||||
|
$configSvc = app(ConfigService::class);
|
||||||
|
$configSvc->rewriteConfigFiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-3
@@ -13,7 +13,11 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Define the application's command schedule.
|
* 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.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
*
|
*
|
||||||
@@ -27,10 +31,13 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->command(Hourly::class)->hourly();
|
$schedule->command(Hourly::class)->hourly();
|
||||||
|
|
||||||
// When spatie-backups runs
|
// When spatie-backups runs
|
||||||
$schedule->command('backup:clean')->daily()->at('01:00');
|
/*if (config('backup.backup.enabled', false) === true) {
|
||||||
$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
|
// Update the last time the cron was run
|
||||||
|
/** @var CronService $cronSvc */
|
||||||
$cronSvc = app(CronService::class);
|
$cronSvc = app(CronService::class);
|
||||||
$cronSvc->updateLastRunTime();
|
$cronSvc->updateLastRunTime();
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-5
@@ -12,13 +12,24 @@ abstract class Metar
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Implement retrieving the METAR - return the METAR string. Needs to be protected,
|
* Implement retrieving the METAR - return the METAR string. Needs to be protected,
|
||||||
* since this shouldn't be directly called. Call `get_metar($icao)` instead
|
* since this shouldn't be directly called. Call `metar($icao)`. If not implemented,
|
||||||
|
* return a blank string
|
||||||
*
|
*
|
||||||
* @param $icao
|
* @param $icao
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
abstract protected function metar($icao): string;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download the METAR, wrap in caching
|
* Download the METAR, wrap in caching
|
||||||
@@ -27,9 +38,9 @@ abstract class Metar
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_metar($icao): string
|
public function metar($icao): string
|
||||||
{
|
{
|
||||||
$cache = config('cache.keys.WEATHER_LOOKUP');
|
$cache = config('cache.keys.METAR_WEATHER_LOOKUP');
|
||||||
$key = $cache['key'].$icao;
|
$key = $cache['key'].$icao;
|
||||||
|
|
||||||
if (Cache::has($key)) {
|
if (Cache::has($key)) {
|
||||||
@@ -40,7 +51,7 @@ abstract class Metar
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$raw_metar = $this->metar($icao);
|
$raw_metar = $this->get_metar($icao);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
|
Log::error('Error getting METAR: '.$e->getMessage(), $e->getTrace());
|
||||||
return '';
|
return '';
|
||||||
@@ -52,4 +63,37 @@ abstract class Metar
|
|||||||
|
|
||||||
return $raw_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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Delete old rejected PIREPs
|
||||||
|
*
|
||||||
|
* @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('UTC')->subHours($expire_time_hours);
|
||||||
|
$pireps = Pirep::where('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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ class RemoveExpiredBids extends Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = Carbon::now()->subHours(setting('bids.expire_time'));
|
$date = Carbon::now('UTC')->subHours(setting('bids.expire_time'));
|
||||||
Bid::whereDate('created_at', '<', $date)->delete();
|
Bid::where('created_at', '<', $date)->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ class RemoveExpiredLiveFlights extends Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = Carbon::now()->subHours(setting('acars.live_time'));
|
$date = Carbon::now('UTC')->subHours(setting('acars.live_time'));
|
||||||
Pirep::whereDate('updated_at', '<', $date)
|
Pirep::where('updated_at', '<', $date)
|
||||||
->where('state', PirepState::IN_PROGRESS)
|
->where('state', PirepState::IN_PROGRESS)
|
||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Contracts\Listener;
|
|||||||
use App\Events\CronMonthly;
|
use App\Events\CronMonthly;
|
||||||
use App\Models\Enums\ExpenseType;
|
use App\Models\Enums\ExpenseType;
|
||||||
use App\Services\Finance\RecurringFinanceService;
|
use App\Services\Finance\RecurringFinanceService;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go through and apply any finances that are daily
|
* Go through and apply any finances that are daily
|
||||||
@@ -35,6 +36,7 @@ class ApplyExpenses extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronMonthly $event): void
|
public function handle(CronMonthly $event): void
|
||||||
{
|
{
|
||||||
|
Log::info('Monthly: Applying monthly expenses');
|
||||||
$this->financeSvc->processExpenses(ExpenseType::MONTHLY);
|
$this->financeSvc->processExpenses(ExpenseType::MONTHLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Contracts\Listener;
|
|||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
use App\Models\Enums\ExpenseType;
|
use App\Models\Enums\ExpenseType;
|
||||||
use App\Services\Finance\RecurringFinanceService;
|
use App\Services\Finance\RecurringFinanceService;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go through and apply any finances that are daily
|
* Go through and apply any finances that are daily
|
||||||
@@ -35,6 +36,7 @@ class ApplyExpenses extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
|
Log::info('Nightly: Applying daily expenses');
|
||||||
$this->financeSvc->processExpenses(ExpenseType::DAILY);
|
$this->financeSvc->processExpenses(ExpenseType::DAILY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Cron\Nightly;
|
|||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
use App\Services\SimBriefService;
|
use App\Services\SimBriefService;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear any expired SimBrief flight briefs that aren't attached to a PIREP
|
* Clear any expired SimBrief flight briefs that aren't attached to a PIREP
|
||||||
@@ -23,6 +24,7 @@ class ClearExpiredSimbrief extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
|
Log::info('Nightly: Removing expired Simbrief entries');
|
||||||
$this->simbriefSvc->removeExpiredEntries();
|
$this->simbriefSvc->removeExpiredEntries();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Cron\Nightly;
|
|||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
use App\Services\VersionService;
|
use App\Services\VersionService;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if any pilots should be set to ON LEAVE status
|
* Determine if any pilots should be set to ON LEAVE status
|
||||||
@@ -28,6 +29,7 @@ class NewVersionCheck extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
|
Log::info('Nightly: Checking for new version');
|
||||||
$this->versionSvc->isNewVersionAvailable();
|
$this->versionSvc->isNewVersionAvailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ namespace App\Cron\Nightly;
|
|||||||
|
|
||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\CronNightly;
|
use App\Events\CronNightly;
|
||||||
use App\Models\Enums\UserState;
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
use Carbon\Carbon;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if any pilots should be set to ON LEAVE status
|
* Determine if any pilots should be set to ON LEAVE status
|
||||||
@@ -18,6 +16,8 @@ class PilotLeave extends Listener
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* PilotLeave constructor.
|
* PilotLeave constructor.
|
||||||
|
*
|
||||||
|
* @param UserService $userSvc
|
||||||
*/
|
*/
|
||||||
public function __construct(UserService $userSvc)
|
public function __construct(UserService $userSvc)
|
||||||
{
|
{
|
||||||
@@ -34,13 +34,9 @@ class PilotLeave extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
if (setting('pilots.auto_leave_days') === 0) {
|
Log::info('Cron: Running pilot leave check');
|
||||||
return;
|
$users = $this->userSvc->findUsersOnLeave();
|
||||||
}
|
Log::info('Found '.count($users).' users on leave');
|
||||||
|
|
||||||
$date = Carbon::now()->subDay(setting('pilots.auto_leave_days'));
|
|
||||||
$users = User::where('status', UserState::ACTIVE)
|
|
||||||
->whereDate('updated_at', '<', $date);
|
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
Log::info('Setting user '.$user->ident.' to ON LEAVE status');
|
Log::info('Setting user '.$user->ident.' to ON LEAVE status');
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class RecalculateBalances extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Recalculating balances');
|
Log::info('Nightly: Recalculating balances');
|
||||||
|
|
||||||
$journals = Journal::all();
|
$journals = Journal::all();
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ class RecalculateStats extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
Log::info('Recalculating user stats');
|
Log::info('Nightly: Recalculating user stats');
|
||||||
$this->userSvc->recalculateAllUserStats();
|
$this->userSvc->recalculateAllUserStats();
|
||||||
|
|
||||||
Log::info('Recalcuating aircraft status');
|
Log::info('Nightly: Recalcuating aircraft status');
|
||||||
$this->aircraftSvc->recalculateStats();
|
$this->aircraftSvc->recalculateStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class SetActiveFlights extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(CronNightly $event): void
|
public function handle(CronNightly $event): void
|
||||||
{
|
{
|
||||||
|
Log::info('Nightly: Setting active flights');
|
||||||
|
|
||||||
$this->checkFlights();
|
$this->checkFlights();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Journal;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
use Ramsey\Uuid\Uuid;
|
||||||
|
|
||||||
$factory->define(App\Models\JournalTransactions::class, function (Faker $faker) {
|
$factory->define(App\Models\JournalTransaction::class, function (Faker $faker) {
|
||||||
return [
|
return [
|
||||||
'transaction_group' => \Ramsey\Uuid\Uuid::uuid4()->toString(),
|
'transaction_group' => Uuid::uuid4()->toString(),
|
||||||
'journal_id' => function () {
|
'journal_id' => function () {
|
||||||
return factory(\App\Models\Journal::class)->create()->id;
|
return factory(Journal::class)->create()->id;
|
||||||
},
|
},
|
||||||
'credit' => $faker->numberBetween(100, 10000),
|
'credit' => $faker->numberBetween(100, 10000),
|
||||||
'debit' => $faker->numberBetween(100, 10000),
|
'debit' => $faker->numberBetween(100, 10000),
|
||||||
'currency' => 'USD',
|
'currency' => 'USD',
|
||||||
'memo' => $faker->sentence(6),
|
'memo' => $faker->sentence(6),
|
||||||
'post_date' => \Carbon\Carbon::now(),
|
'post_date' => Carbon::now('UTC'),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(App\Models\Role::class, function (Faker $faker) {
|
||||||
|
return [
|
||||||
|
'id' => null,
|
||||||
|
'name' => $faker->name,
|
||||||
|
'display_name' => $faker->name,
|
||||||
|
'read_only' => false,
|
||||||
|
'disable_activity_checks' => $faker->boolean(),
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddDisableactivitychecksToRoles extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('roles', function (Blueprint $table) {
|
||||||
|
$table->boolean('disable_activity_checks')
|
||||||
|
->default(false)
|
||||||
|
->after('read_only');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('roles', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('disable_activity_checks');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class RemoveSettingRemoveBidOnAccept extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::table('settings')
|
||||||
|
->where(['key' => 'pireps.remove_bid_on_accept'])
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Contracts\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a `anumeric_callsign` column for Alphanumeric Callsign to be assigned for a flight
|
||||||
|
* Exp DLH78BF, THY8EA, OGE1978
|
||||||
|
* According to FAA and EASA, callsigns must be maximum 7 chars in which first 3 chars is
|
||||||
|
* airline ICAO code remaining rest can be used freely according to airline's choices
|
||||||
|
*/
|
||||||
|
class FlightsAddAlphanumericCallsign extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('flights', function (Blueprint $table) {
|
||||||
|
$table->string('callsign', 4)
|
||||||
|
->nullable()
|
||||||
|
->after('flight_number');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('flights', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('callsign');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Contracts\Migration;
|
||||||
|
use App\Services\Installer\ConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrate the configuration files
|
||||||
|
*/
|
||||||
|
class MigrateConfigs extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
/** @var ConfigService $configSvc */
|
||||||
|
$configSvc = app(ConfigService::class);
|
||||||
|
$configSvc->rewriteConfigFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -119,8 +119,8 @@ aircraft:
|
|||||||
-
|
-
|
||||||
id: 1
|
id: 1
|
||||||
subfleet_id: 1
|
subfleet_id: 1
|
||||||
icao: null
|
icao: B744
|
||||||
iata: null
|
iata: 744
|
||||||
airport_id: KJFK
|
airport_id: KJFK
|
||||||
landing_time: '2020-10-23 07:50:16'
|
landing_time: '2020-10-23 07:50:16'
|
||||||
name: 'Boeing 747-438'
|
name: 'Boeing 747-438'
|
||||||
@@ -136,8 +136,8 @@ aircraft:
|
|||||||
-
|
-
|
||||||
id: 2
|
id: 2
|
||||||
subfleet_id: 2
|
subfleet_id: 2
|
||||||
icao: null
|
icao: B777
|
||||||
iata: null
|
iata: 777
|
||||||
airport_id: LGRP
|
airport_id: LGRP
|
||||||
landing_time: null
|
landing_time: null
|
||||||
name: 'Boeing 777-200'
|
name: 'Boeing 777-200'
|
||||||
@@ -153,8 +153,8 @@ aircraft:
|
|||||||
-
|
-
|
||||||
id: 3
|
id: 3
|
||||||
subfleet_id: 1
|
subfleet_id: 1
|
||||||
icao: null
|
icao: B744
|
||||||
iata: null
|
iata: 744
|
||||||
airport_id: KAUS
|
airport_id: KAUS
|
||||||
landing_time: '2020-10-24 08:50:13'
|
landing_time: '2020-10-24 08:50:13'
|
||||||
name: 'Boeing 747-412'
|
name: 'Boeing 747-412'
|
||||||
@@ -170,8 +170,8 @@ aircraft:
|
|||||||
-
|
-
|
||||||
id: 4
|
id: 4
|
||||||
subfleet_id: 1
|
subfleet_id: 1
|
||||||
icao: null
|
icao: B744
|
||||||
iata: null
|
iata: 744
|
||||||
airport_id: KAUS
|
airport_id: KAUS
|
||||||
landing_time: null
|
landing_time: null
|
||||||
name: 'Boeing 747-436 RETIRED'
|
name: 'Boeing 747-436 RETIRED'
|
||||||
@@ -187,7 +187,7 @@ aircraft:
|
|||||||
-
|
-
|
||||||
id: 5
|
id: 5
|
||||||
subfleet_id: 4
|
subfleet_id: 4
|
||||||
icao: A320
|
icao: 'A320'
|
||||||
iata: '320'
|
iata: '320'
|
||||||
airport_id: EGLL
|
airport_id: EGLL
|
||||||
landing_time: null
|
landing_time: null
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -180,12 +180,12 @@
|
|||||||
type: number
|
type: number
|
||||||
description: 'How much the load factor can vary per-flight'
|
description: 'How much the load factor can vary per-flight'
|
||||||
- key: simbrief.api_key
|
- key: simbrief.api_key
|
||||||
name: 'SimBrief API Key'
|
name: 'Simbrief API Key'
|
||||||
group: simbrief
|
group: simbrief
|
||||||
value: ''
|
value: ''
|
||||||
options: ''
|
options: ''
|
||||||
type: string
|
type: string
|
||||||
description: 'Your SimBrief API key'
|
description: 'Your Simbrief API key'
|
||||||
- key: simbrief.only_bids
|
- key: simbrief.only_bids
|
||||||
name: 'Only allow for bids'
|
name: 'Only allow for bids'
|
||||||
group: simbrief
|
group: simbrief
|
||||||
@@ -194,12 +194,54 @@
|
|||||||
type: boolean
|
type: boolean
|
||||||
description: 'Only allow briefs to be created for bidded flights'
|
description: 'Only allow briefs to be created for bidded flights'
|
||||||
- key: simbrief.expire_days
|
- key: simbrief.expire_days
|
||||||
name: 'SimBrief Expire Time'
|
name: 'Simbrief Expire Time'
|
||||||
group: simbrief
|
group: simbrief
|
||||||
value: 5
|
value: 5
|
||||||
options: ''
|
options: ''
|
||||||
type: number
|
type: number
|
||||||
description: 'Days after how long to remove unused briefs'
|
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: simbrief.name_private
|
||||||
|
name: 'Use Privatized Name at OFPs'
|
||||||
|
group: simbrief
|
||||||
|
value: false
|
||||||
|
options: ''
|
||||||
|
type: boolean
|
||||||
|
description: 'Use privatized user name as SimBrief OFP captain name'
|
||||||
- key: pireps.duplicate_check_time
|
- key: pireps.duplicate_check_time
|
||||||
name: 'PIREP duplicate time check'
|
name: 'PIREP duplicate time check'
|
||||||
group: pireps
|
group: pireps
|
||||||
@@ -221,13 +263,27 @@
|
|||||||
options: ''
|
options: ''
|
||||||
type: boolean
|
type: boolean
|
||||||
description: 'Only allow aircraft that are at the departure airport'
|
description: 'Only allow aircraft that are at the departure airport'
|
||||||
- key: pireps.remove_bid_on_accept
|
- key: pireps.advanced_fuel
|
||||||
name: 'Remove bid on accept'
|
name: 'Advanced Fuel Calculations'
|
||||||
group: pireps
|
group: pireps
|
||||||
value: false
|
value: false
|
||||||
options: ''
|
options: ''
|
||||||
type: boolean
|
type: boolean
|
||||||
description: 'When a PIREP is accepted, remove the bid, if it exists'
|
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
|
- key: pilots.id_length
|
||||||
name: 'Pilot ID Length'
|
name: 'Pilot ID Length'
|
||||||
group: pilots
|
group: pilots
|
||||||
@@ -305,3 +361,9 @@
|
|||||||
options: ''
|
options: ''
|
||||||
type: 'text'
|
type: 'text'
|
||||||
description: 'Discord public channel ID for broadcasat notifications'
|
description: 'Discord public channel ID for broadcasat notifications'
|
||||||
|
- key: 'cron.random_id'
|
||||||
|
name: 'Cron Randomized ID'
|
||||||
|
group: 'cron'
|
||||||
|
value: ''
|
||||||
|
type: 'hidden'
|
||||||
|
description: ''
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefile Error
|
||||||
|
*
|
||||||
|
* If listening to the prefile event message, use `throw new PrefileError("message message");`
|
||||||
|
* to abort the prefile process and send the message up to ACARS
|
||||||
|
*/
|
||||||
|
class PrefileError extends AbstractHttpException
|
||||||
|
{
|
||||||
|
private $error;
|
||||||
|
|
||||||
|
public function __construct(string $error)
|
||||||
|
{
|
||||||
|
$this->error = $error;
|
||||||
|
parent::__construct(400, $error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the RFC 7807 error type (without the URL root)
|
||||||
|
*/
|
||||||
|
public function getErrorType(): string
|
||||||
|
{
|
||||||
|
return 'prefile-error';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
class UserNotFound extends AbstractHttpException
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct(
|
||||||
|
404,
|
||||||
|
'User not found'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the RFC 7807 error type (without the URL root)
|
||||||
|
*/
|
||||||
|
public function getErrorType(): string
|
||||||
|
{
|
||||||
|
return 'user-not-found';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -186,13 +186,13 @@ class AwardController extends Controller
|
|||||||
{
|
{
|
||||||
$award = $this->awardRepository->findWithoutFail($id);
|
$award = $this->awardRepository->findWithoutFail($id);
|
||||||
if (empty($award)) {
|
if (empty($award)) {
|
||||||
Flash::error('Fare not found');
|
Flash::error('Award not found');
|
||||||
|
|
||||||
return redirect(route('admin.awards.index'));
|
return redirect(route('admin.awards.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->awardRepository->delete($id);
|
$this->awardRepository->delete($id);
|
||||||
Flash::success('Fare deleted successfully.');
|
Flash::success('Award deleted successfully.');
|
||||||
|
|
||||||
return redirect(route('admin.awards.index'));
|
return redirect(route('admin.awards.index'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class FlightController extends Controller
|
|||||||
$avail_fleets = $all_aircraft->except($flight->subfleets->modelKeys());
|
$avail_fleets = $all_aircraft->except($flight->subfleets->modelKeys());
|
||||||
|
|
||||||
foreach ($avail_fleets as $ac) {
|
foreach ($avail_fleets as $ac) {
|
||||||
$retval[$ac->id] = $ac->type.' - '.$ac->name;
|
$retval[$ac->id] = '['.$ac->airline->icao.'] '.$ac->type.' - '.$ac->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Contracts\Controller;
|
|||||||
use App\Repositories\KvpRepository;
|
use App\Repositories\KvpRepository;
|
||||||
use App\Services\CronService;
|
use App\Services\CronService;
|
||||||
use App\Services\VersionService;
|
use App\Services\VersionService;
|
||||||
|
use App\Support\Utils;
|
||||||
use Codedge\Updater\UpdaterManager;
|
use Codedge\Updater\UpdaterManager;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
@@ -34,7 +35,12 @@ class MaintenanceController extends Controller
|
|||||||
|
|
||||||
public function index()
|
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', [
|
return view('admin.maintenance.index', [
|
||||||
|
'cron_url' => $cron_url,
|
||||||
'cron_path' => $this->cronSvc->getCronExecString(),
|
'cron_path' => $this->cronSvc->getCronExecString(),
|
||||||
'cron_problem_exists' => $this->cronSvc->cronProblemExists(),
|
'cron_problem_exists' => $this->cronSvc->cronProblemExists(),
|
||||||
'new_version' => $this->kvpRepo->get('new_version_available', false),
|
'new_version' => $this->kvpRepo->get('new_version_available', false),
|
||||||
@@ -117,4 +123,33 @@ class MaintenanceController extends Controller
|
|||||||
|
|
||||||
return redirect('/update/downloader');
|
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'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -394,10 +394,10 @@ class PirepController extends Controller
|
|||||||
return redirect(route('admin.pireps.index'));
|
return redirect(route('admin.pireps.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->pirepRepo->delete($id);
|
$this->pirepSvc->delete($pirep);
|
||||||
|
|
||||||
Flash::success('Pirep deleted successfully.');
|
Flash::success('Pirep deleted successfully.');
|
||||||
return redirect(route('admin.pireps.index'));
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class SettingsController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$settings = Setting::orderBy('order', 'asc')->get();
|
$settings = Setting::where('type', '!=', 'hidden')->orderBy('order')->get();
|
||||||
$settings = $settings->groupBy('group');
|
$settings = $settings->groupBy('group');
|
||||||
|
|
||||||
return view('admin.settings.index', [
|
return view('admin.settings.index', [
|
||||||
|
|||||||
@@ -252,15 +252,12 @@ class UserController extends Controller
|
|||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$user = $this->userRepo->findWithoutFail($id);
|
$user = $this->userRepo->findWithoutFail($id);
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
Flash::error('User not found');
|
Flash::error('User not found');
|
||||||
|
|
||||||
return redirect(route('admin.users.index'));
|
return redirect(route('admin.users.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->userRepo->delete($id);
|
$this->userSvc->removeUser($user);
|
||||||
|
|
||||||
Flash::success('User deleted successfully.');
|
Flash::success('User deleted successfully.');
|
||||||
|
|
||||||
return redirect(route('admin.users.index'));
|
return redirect(route('admin.users.index'));
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Api;
|
|||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
use App\Exceptions\AssetNotFound;
|
use App\Exceptions\AssetNotFound;
|
||||||
use App\Exceptions\Unauthorized;
|
|
||||||
use App\Http\Resources\Flight as FlightResource;
|
use App\Http\Resources\Flight as FlightResource;
|
||||||
use App\Http\Resources\Navdata as NavdataResource;
|
use App\Http\Resources\Navdata as NavdataResource;
|
||||||
use App\Models\SimBrief;
|
use App\Models\SimBrief;
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
use App\Events\PirepPrefiled;
|
|
||||||
use App\Events\PirepUpdated;
|
use App\Events\PirepUpdated;
|
||||||
use App\Exceptions\AircraftPermissionDenied;
|
use App\Exceptions\AircraftPermissionDenied;
|
||||||
use App\Exceptions\PirepCancelled;
|
use App\Exceptions\PirepCancelled;
|
||||||
@@ -219,8 +218,6 @@ class PirepController extends Controller
|
|||||||
$this->updateFields($pirep, $request);
|
$this->updateFields($pirep, $request);
|
||||||
$this->updateFares($pirep, $request);
|
$this->updateFares($pirep, $request);
|
||||||
|
|
||||||
event(new PirepPrefiled($pirep));
|
|
||||||
|
|
||||||
return $this->get($pirep->id);
|
return $this->get($pirep->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
|
use App\Exceptions\UserNotFound;
|
||||||
use App\Http\Resources\Bid as BidResource;
|
use App\Http\Resources\Bid as BidResource;
|
||||||
use App\Http\Resources\Pirep as PirepResource;
|
use App\Http\Resources\Pirep as PirepResource;
|
||||||
use App\Http\Resources\Subfleet as SubfleetResource;
|
use App\Http\Resources\Subfleet as SubfleetResource;
|
||||||
@@ -91,6 +92,10 @@ class UserController extends Controller
|
|||||||
public function get($id)
|
public function get($id)
|
||||||
{
|
{
|
||||||
$user = $this->userSvc->getUser($id);
|
$user = $this->userSvc->getUser($id);
|
||||||
|
if ($user === null) {
|
||||||
|
throw new UserNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
return new UserResource($user);
|
return new UserResource($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +111,11 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function bids(Request $request)
|
public function bids(Request $request)
|
||||||
{
|
{
|
||||||
$user = $this->userSvc->getUser($this->getUserId($request));
|
$user_id = $this->getUserId($request);
|
||||||
|
$user = $this->userSvc->getUser($user_id);
|
||||||
|
if ($user === null) {
|
||||||
|
throw new UserNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
// Add a bid
|
// Add a bid
|
||||||
if ($request->isMethod('PUT') || $request->isMethod('POST')) {
|
if ($request->isMethod('PUT') || $request->isMethod('POST')) {
|
||||||
@@ -145,6 +154,10 @@ class UserController extends Controller
|
|||||||
public function fleet(Request $request)
|
public function fleet(Request $request)
|
||||||
{
|
{
|
||||||
$user = $this->userRepo->find($this->getUserId($request));
|
$user = $this->userRepo->find($this->getUserId($request));
|
||||||
|
if ($user === null) {
|
||||||
|
throw new UserNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
||||||
|
|
||||||
return SubfleetResource::collection($subfleets);
|
return SubfleetResource::collection($subfleets);
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ class DashboardController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
//dd(config('backup'));
|
||||||
$last_pirep = null;
|
$last_pirep = null;
|
||||||
|
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Frontend;
|
namespace App\Http\Controllers\Frontend;
|
||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
|
use App\Models\Airline;
|
||||||
use App\Models\File;
|
use App\Models\File;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Flash;
|
use Flash;
|
||||||
@@ -18,6 +19,7 @@ class DownloadController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$airlines = Airline::where('active', 1)->count();
|
||||||
$files = File::orderBy('ref_model', 'asc')->get();
|
$files = File::orderBy('ref_model', 'asc')->get();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,10 +44,14 @@ class DownloadController extends Controller
|
|||||||
$category = explode('\\', $class);
|
$category = explode('\\', $class);
|
||||||
$category = end($category);
|
$category = end($category);
|
||||||
|
|
||||||
if ($category == 'Aircraft') {
|
if ($category == 'Aircraft' && $airlines > 1) {
|
||||||
|
$group_name = $category.' > '.$obj->subfleet->airline->name.' '.$obj->icao.' '.$obj->registration;
|
||||||
|
} elseif ($category == 'Aircraft') {
|
||||||
$group_name = $category.' > '.$obj->icao.' '.$obj->registration;
|
$group_name = $category.' > '.$obj->icao.' '.$obj->registration;
|
||||||
} elseif ($category == 'Airport') {
|
} elseif ($category == 'Airport') {
|
||||||
$group_name = $category.' > '.$obj->icao.' : '.$obj->name.' ('.$obj->country.')';
|
$group_name = $category.' > '.$obj->icao.' : '.$obj->name.' ('.$obj->country.')';
|
||||||
|
} elseif ($category == 'Subfleet' && $airlines > 1) {
|
||||||
|
$group_name = $category.' > '.$obj->airline->name.' '.$obj->name;
|
||||||
} else {
|
} else {
|
||||||
$group_name = $category.' > '.$obj->name;
|
$group_name = $category.' > '.$obj->name;
|
||||||
}
|
}
|
||||||
@@ -53,13 +59,15 @@ class DownloadController extends Controller
|
|||||||
$regrouped_files[$group_name] = $files;
|
$regrouped_files[$group_name] = $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ksort($regrouped_files, SORT_STRING);
|
||||||
|
|
||||||
return view('downloads.index', [
|
return view('downloads.index', [
|
||||||
'grouped_files' => $regrouped_files,
|
'grouped_files' => $regrouped_files,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the application dashboard.
|
* Show the application dashboard
|
||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -106,7 +106,13 @@ class FlightController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$flights = $this->flightRepo->searchCriteria($request)
|
$flights = $this->flightRepo->searchCriteria($request)
|
||||||
->with(['dpt_airport', 'arr_airport', 'airline'])
|
->with([
|
||||||
|
'dpt_airport',
|
||||||
|
'arr_airport',
|
||||||
|
'airline',
|
||||||
|
'simbrief' => function ($query) use ($user) {
|
||||||
|
$query->where('user_id', $user->id);
|
||||||
|
}, ])
|
||||||
->orderBy('flight_number', 'asc')
|
->orderBy('flight_number', 'asc')
|
||||||
->orderBy('route_leg', 'asc')
|
->orderBy('route_leg', 'asc')
|
||||||
->paginate();
|
->paginate();
|
||||||
@@ -115,6 +121,7 @@ class FlightController extends Controller
|
|||||||
->pluck('flight_id')->toArray();
|
->pluck('flight_id')->toArray();
|
||||||
|
|
||||||
return view('flights.index', [
|
return view('flights.index', [
|
||||||
|
'user' => $user,
|
||||||
'airlines' => $this->airlineRepo->selectBoxList(true),
|
'airlines' => $this->airlineRepo->selectBoxList(true),
|
||||||
'airports' => $this->airportRepo->selectBoxList(true),
|
'airports' => $this->airportRepo->selectBoxList(true),
|
||||||
'flights' => $flights,
|
'flights' => $flights,
|
||||||
@@ -147,11 +154,18 @@ class FlightController extends Controller
|
|||||||
$flights = collect();
|
$flights = collect();
|
||||||
$saved_flights = [];
|
$saved_flights = [];
|
||||||
foreach ($user->bids as $bid) {
|
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);
|
$flights->add($bid->flight);
|
||||||
$saved_flights[] = $bid->flight->id;
|
$saved_flights[] = $bid->flight->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('flights.bids', [
|
return view('flights.bids', [
|
||||||
|
'user' => $user,
|
||||||
'airlines' => $this->airlineRepo->selectBoxList(true),
|
'airlines' => $this->airlineRepo->selectBoxList(true),
|
||||||
'airports' => $this->airportRepo->selectBoxList(true),
|
'airports' => $this->airportRepo->selectBoxList(true),
|
||||||
'flights' => $flights,
|
'flights' => $flights,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use App\Http\Requests\CreatePirepRequest;
|
|||||||
use App\Http\Requests\UpdatePirepRequest;
|
use App\Http\Requests\UpdatePirepRequest;
|
||||||
use App\Models\Enums\PirepSource;
|
use App\Models\Enums\PirepSource;
|
||||||
use App\Models\Enums\PirepState;
|
use App\Models\Enums\PirepState;
|
||||||
use App\Models\Enums\PirepStatus;
|
use App\Models\Fare;
|
||||||
use App\Models\Pirep;
|
use App\Models\Pirep;
|
||||||
use App\Models\SimBrief;
|
use App\Models\SimBrief;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -211,6 +211,7 @@ class PirepController extends Controller
|
|||||||
return view('pireps.show', [
|
return view('pireps.show', [
|
||||||
'pirep' => $pirep,
|
'pirep' => $pirep,
|
||||||
'map_features' => $map_features,
|
'map_features' => $map_features,
|
||||||
|
'user' => Auth::user(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,23 +254,48 @@ class PirepController extends Controller
|
|||||||
/**
|
/**
|
||||||
* They have a SimBrief ID, load that up and figure out the flight that it's from
|
* They have a SimBrief ID, load that up and figure out the flight that it's from
|
||||||
*/
|
*/
|
||||||
|
$fare_values = [];
|
||||||
|
$simbrief = null;
|
||||||
$simbrief_id = null;
|
$simbrief_id = null;
|
||||||
|
$aircraft = null;
|
||||||
if ($request->has('sb_id')) {
|
if ($request->has('sb_id')) {
|
||||||
$simbrief_id = $request->input('sb_id');
|
$simbrief_id = $request->input('sb_id');
|
||||||
$brief = SimBrief::find($simbrief_id);
|
$simbrief = SimBrief::find($simbrief_id);
|
||||||
$pirep = Pirep::fromSimBrief($brief);
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('pireps.create', [
|
return view('pireps.create', [
|
||||||
'aircraft' => null,
|
'aircraft' => $aircraft,
|
||||||
'pirep' => $pirep,
|
'pirep' => $pirep,
|
||||||
'read_only' => false,
|
'read_only' => false,
|
||||||
'airline_list' => $this->airlineRepo->selectBoxList(true),
|
'airline_list' => $this->airlineRepo->selectBoxList(true),
|
||||||
'aircraft_list' => $this->aircraftList(true),
|
'aircraft_list' => $aircraft_list,
|
||||||
'airport_list' => $this->airportRepo->selectBoxList(true),
|
'airport_list' => $this->airportRepo->selectBoxList(true),
|
||||||
'pirep_fields' => $this->pirepFieldRepo->all(),
|
'pirep_fields' => $this->pirepFieldRepo->all(),
|
||||||
'field_values' => [],
|
'field_values' => [],
|
||||||
|
'fare_values' => $fare_values,
|
||||||
'simbrief_id' => $simbrief_id,
|
'simbrief_id' => $simbrief_id,
|
||||||
|
'simbrief' => $simbrief,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,12 +429,18 @@ class PirepController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
|
/** @var Pirep $pirep */
|
||||||
$pirep = $this->pirepRepo->findWithoutFail($id);
|
$pirep = $this->pirepRepo->findWithoutFail($id);
|
||||||
if (empty($pirep)) {
|
if (empty($pirep)) {
|
||||||
Flash::error('Pirep not found');
|
Flash::error('Pirep not found');
|
||||||
return redirect(route('frontend.pireps.index'));
|
return redirect(route('frontend.pireps.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($pirep->user_id !== Auth::id()) {
|
||||||
|
Flash::error('Cannot edit someone else\'s PIREP!');
|
||||||
|
return redirect(route('admin.pireps.index'));
|
||||||
|
}
|
||||||
|
|
||||||
// Eager load the subfleet and fares under it
|
// Eager load the subfleet and fares under it
|
||||||
if ($pirep->aircraft) {
|
if ($pirep->aircraft) {
|
||||||
$pirep->aircraft->load('subfleet.fares');
|
$pirep->aircraft->load('subfleet.fares');
|
||||||
@@ -461,12 +493,21 @@ class PirepController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update($id, UpdatePirepRequest $request)
|
public function update($id, UpdatePirepRequest $request)
|
||||||
{
|
{
|
||||||
|
/** @var User $user */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
/** @var Pirep $pirep */
|
||||||
$pirep = $this->pirepRepo->findWithoutFail($id);
|
$pirep = $this->pirepRepo->findWithoutFail($id);
|
||||||
if (empty($pirep)) {
|
if (empty($pirep)) {
|
||||||
Flash::error('Pirep not found');
|
Flash::error('Pirep not found');
|
||||||
return redirect(route('admin.pireps.index'));
|
return redirect(route('admin.pireps.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($user->id !== $pirep->user_id) {
|
||||||
|
Flash::error('Cannot edit someone else\'s PIREP!');
|
||||||
|
return redirect(route('admin.pireps.index'));
|
||||||
|
}
|
||||||
|
|
||||||
$orig_route = $pirep->route;
|
$orig_route = $pirep->route;
|
||||||
$attrs = $request->all();
|
$attrs = $request->all();
|
||||||
$attrs['submit'] = strtolower($attrs['submit']);
|
$attrs['submit'] = strtolower($attrs['submit']);
|
||||||
@@ -493,12 +534,8 @@ class PirepController extends Controller
|
|||||||
$this->pirepSvc->submit($pirep);
|
$this->pirepSvc->submit($pirep);
|
||||||
Flash::success('PIREP submitted!');
|
Flash::success('PIREP submitted!');
|
||||||
} elseif ($attrs['submit'] === 'delete' || $attrs['submit'] === 'cancel') {
|
} elseif ($attrs['submit'] === 'delete' || $attrs['submit'] === 'cancel') {
|
||||||
$this->pirepRepo->update([
|
$this->pirepSvc->delete($pirep);
|
||||||
'state' => PirepState::CANCELLED,
|
Flash::success('PIREP deleted!');
|
||||||
'status' => PirepStatus::CANCELLED,
|
|
||||||
], $pirep->id);
|
|
||||||
|
|
||||||
Flash::success('PIREP cancelled!');
|
|
||||||
return redirect(route('frontend.pireps.index'));
|
return redirect(route('frontend.pireps.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,6 +560,11 @@ class PirepController extends Controller
|
|||||||
return redirect(route('admin.pireps.index'));
|
return redirect(route('admin.pireps.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($pirep->user_id !== Auth::id()) {
|
||||||
|
Flash::error('Cannot edit someone else\'s PIREP!');
|
||||||
|
return redirect(route('admin.pireps.index'));
|
||||||
|
}
|
||||||
|
|
||||||
$this->pirepSvc->submit($pirep);
|
$this->pirepSvc->submit($pirep);
|
||||||
return redirect(route('frontend.pireps.show', [$pirep->id]));
|
return redirect(route('frontend.pireps.show', [$pirep->id]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class ProfileController extends Controller
|
|||||||
{
|
{
|
||||||
// Is the ACARS module enabled?
|
// Is the ACARS module enabled?
|
||||||
$acars_enabled = false;
|
$acars_enabled = false;
|
||||||
$acars = Module::find('VMSACARS');
|
$acars = Module::find('VMSAcars');
|
||||||
if ($acars) {
|
if ($acars) {
|
||||||
$acars_enabled = $acars->isEnabled();
|
$acars_enabled = $acars->isEnabled();
|
||||||
}
|
}
|
||||||
@@ -95,6 +95,7 @@ class ProfileController extends Controller
|
|||||||
'user' => $user,
|
'user' => $user,
|
||||||
'userFields' => $userFields,
|
'userFields' => $userFields,
|
||||||
'airports' => $airports,
|
'airports' => $airports,
|
||||||
|
'acars' => $this->acarsEnabled(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ class ProfileController extends Controller
|
|||||||
|
|
||||||
$airlines = $this->airlineRepo->selectBoxList();
|
$airlines = $this->airlineRepo->selectBoxList();
|
||||||
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
$airports = $this->airportRepo->selectBoxList(false, setting('pilots.home_hubs_only'));
|
||||||
$userFields = $this->userRepo->getUserFields($user, false);
|
$userFields = $this->userRepo->getUserFields($user, true);
|
||||||
|
|
||||||
return view('profile.edit', [
|
return view('profile.edit', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
|
|||||||
@@ -4,8 +4,14 @@ namespace App\Http\Controllers\Frontend;
|
|||||||
|
|
||||||
use App\Exceptions\AssetNotFound;
|
use App\Exceptions\AssetNotFound;
|
||||||
use App\Models\Aircraft;
|
use App\Models\Aircraft;
|
||||||
|
use App\Models\Enums\AircraftState;
|
||||||
|
use App\Models\Enums\AircraftStatus;
|
||||||
|
use App\Models\Enums\FareType;
|
||||||
use App\Models\Enums\FlightType;
|
use App\Models\Enums\FlightType;
|
||||||
|
use App\Models\Fare;
|
||||||
|
use App\Models\Flight;
|
||||||
use App\Models\SimBrief;
|
use App\Models\SimBrief;
|
||||||
|
use App\Models\User;
|
||||||
use App\Repositories\FlightRepository;
|
use App\Repositories\FlightRepository;
|
||||||
use App\Services\FareService;
|
use App\Services\FareService;
|
||||||
use App\Services\SimBriefService;
|
use App\Services\SimBriefService;
|
||||||
@@ -49,8 +55,9 @@ class SimBriefController
|
|||||||
|
|
||||||
$flight_id = $request->input('flight_id');
|
$flight_id = $request->input('flight_id');
|
||||||
$aircraft_id = $request->input('aircraft_id');
|
$aircraft_id = $request->input('aircraft_id');
|
||||||
$flight = $this->flightRepo->with(['subfleets'])->find($flight_id);
|
|
||||||
$flight = $this->fareSvc->getReconciledFaresForFlight($flight);
|
/** @var Flight $flight */
|
||||||
|
$flight = $this->flightRepo->with(['fares', 'subfleets'])->find($flight_id);
|
||||||
|
|
||||||
if (!$flight) {
|
if (!$flight) {
|
||||||
flash()->error('Unknown flight');
|
flash()->error('Unknown flight');
|
||||||
@@ -63,6 +70,43 @@ class SimBriefController
|
|||||||
return redirect(route('frontend.flights.index'));
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build an array of subfleet id's from the subfleets collection
|
||||||
|
$sf_ids = $subfleets->map(function ($subfleets) {
|
||||||
|
return collect($subfleets->toArray())
|
||||||
|
->only(['id'])
|
||||||
|
->all();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Now we can build a proper aircrafts collection
|
||||||
|
// Contents will be either members of flight->subfleets
|
||||||
|
// or members of user's allowable subfleets
|
||||||
|
$aircrafts = Aircraft::whereIn('subfleet_id', $sf_ids)
|
||||||
|
->where('state', AircraftState::PARKED)
|
||||||
|
->where('status', AircraftStatus::ACTIVE)
|
||||||
|
->orderby('icao')
|
||||||
|
->orderby('registration')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (setting('pireps.only_aircraft_at_dpt_airport')) {
|
||||||
|
$aircrafts = $aircrafts->where('airport_id', $flight->dpt_airport_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('flights.simbrief_aircraft', [
|
||||||
|
'flight' => $flight,
|
||||||
|
'aircrafts' => $aircrafts,
|
||||||
|
'subfleets' => $subfleets,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if a Simbrief profile already exists
|
// Check if a Simbrief profile already exists
|
||||||
$simbrief = SimBrief::select('id')->where([
|
$simbrief = SimBrief::select('id')->where([
|
||||||
'flight_id' => $flight_id,
|
'flight_id' => $flight_id,
|
||||||
@@ -73,34 +117,26 @@ class SimBriefController
|
|||||||
return redirect(route('frontend.simbrief.briefing', [$simbrief->id]));
|
return redirect(route('frontend.simbrief.briefing', [$simbrief->id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simbrief Profile doesn't exist; prompt the user to create a new one
|
// SimBrief profile does not exists and everything else is ok
|
||||||
$aircraft = Aircraft::select('registration', 'name', 'icao', 'iata', 'subfleet_id')
|
// Select aircraft which will be used for calculations and details
|
||||||
->where('id', $aircraft_id)
|
/** @var Aircraft $aircraft */
|
||||||
->get();
|
$aircraft = Aircraft::where('id', $aircraft_id)->first();
|
||||||
|
|
||||||
if ($flight->subfleets->count() > 0) {
|
// Figure out the proper fares to use for this flight/aircraft
|
||||||
$subfleets = $flight->subfleets;
|
$all_fares = $this->fareSvc->getFareWithOverrides($aircraft->subfleet->fares, $flight->fares);
|
||||||
} else {
|
|
||||||
$subfleets = $this->userSvc->getAllowableSubfleets($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 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) {
|
if ($flight->flight_type === FlightType::CHARTER_PAX_ONLY) {
|
||||||
$pax_weight = 197;
|
$pax_weight = setting('simbrief.charter_pax_weight', 168);
|
||||||
|
$bag_weight = setting('simbrief.charter_baggage_weight', 28);
|
||||||
} else {
|
} else {
|
||||||
$pax_weight = 208;
|
$pax_weight = setting('simbrief.noncharter_pax_weight', 185);
|
||||||
|
$bag_weight = setting('simbrief.noncharter_baggage_weight', 35);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No aircraft selected, show that form
|
// Get the load factors with failsafe for loadmax if nothing is defined
|
||||||
if (!$aircraft_id) {
|
|
||||||
return view('flights.simbrief_aircraft', [
|
|
||||||
'flight' => $flight,
|
|
||||||
'aircraft' => $aircraft,
|
|
||||||
'subfleets' => $subfleets,
|
|
||||||
'pax_weight' => $pax_weight,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the correct load factors
|
|
||||||
$lfactor = $flight->load_factor ?? setting('flights.default_load_factor');
|
$lfactor = $flight->load_factor ?? setting('flights.default_load_factor');
|
||||||
$lfactorv = $flight->load_factor_variance ?? setting('flights.load_factor_variance');
|
$lfactorv = $flight->load_factor_variance ?? setting('flights.load_factor_variance');
|
||||||
|
|
||||||
@@ -110,14 +146,90 @@ class SimBriefController
|
|||||||
$loadmax = $lfactor + $lfactorv;
|
$loadmax = $lfactor + $lfactorv;
|
||||||
$loadmax = $loadmax > 100 ? 100 : $loadmax;
|
$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
|
// Show the main simbrief form
|
||||||
return view('flights.simbrief_form', [
|
return view('flights.simbrief_form', [
|
||||||
'flight' => $flight,
|
'user' => Auth::user(),
|
||||||
'aircraft' => $aircraft,
|
'flight' => $flight,
|
||||||
'subfleets' => $subfleets,
|
'aircraft' => $aircraft,
|
||||||
'pax_weight' => $pax_weight,
|
'pax_weight' => $pax_weight,
|
||||||
'loadmin' => $loadmin,
|
'bag_weight' => $bag_weight,
|
||||||
'loadmax' => $loadmax,
|
'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),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +334,7 @@ class SimBriefController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the OFP was generated. Pass in two items, the flight_id and ofp_id
|
* 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
|
* @param \Illuminate\Http\Request $request
|
||||||
*
|
*
|
||||||
@@ -229,10 +342,14 @@ class SimBriefController
|
|||||||
*/
|
*/
|
||||||
public function check_ofp(Request $request)
|
public function check_ofp(Request $request)
|
||||||
{
|
{
|
||||||
|
/** @var User $user */
|
||||||
|
$user = Auth::user();
|
||||||
$ofp_id = $request->input('ofp_id');
|
$ofp_id = $request->input('ofp_id');
|
||||||
$flight_id = $request->input('flight_id');
|
$flight_id = $request->input('flight_id');
|
||||||
|
$aircraft_id = $request->input('aircraft_id');
|
||||||
|
$fares = $request->session()->get('simbrief_fares', []);
|
||||||
|
|
||||||
$simbrief = $this->simBriefSvc->downloadOfp(Auth::user()->id, $ofp_id, $flight_id);
|
$simbrief = $this->simBriefSvc->downloadOfp($user->id, $ofp_id, $flight_id, $aircraft_id, $fares);
|
||||||
if ($simbrief === null) {
|
if ($simbrief === null) {
|
||||||
$error = new AssetNotFound(new Exception('Simbrief OFP not found'));
|
$error = new AssetNotFound(new Exception('Simbrief OFP not found'));
|
||||||
return $error->getResponse();
|
return $error->getResponse();
|
||||||
|
|||||||
@@ -203,21 +203,21 @@ class InstallerController extends Controller
|
|||||||
Log::error('Testing db before writing configs failed');
|
Log::error('Testing db before writing configs failed');
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
|
||||||
Flash::error($e->getMessage());
|
flash()->error($e->getMessage());
|
||||||
return redirect(route('installer.step2'))->withInput();
|
return redirect(route('installer.step2'))->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now write out the env file
|
// Now write out the env file
|
||||||
$attrs = [
|
$attrs = [
|
||||||
'SITE_NAME' => $request->post('site_name'),
|
'SITE_NAME' => $request->post('site_name'),
|
||||||
'SITE_URL' => $request->post('site_url'),
|
'APP_URL' => $request->post('app_url'),
|
||||||
'DB_CONN' => $request->post('db_conn'),
|
'DB_CONNECTION' => $request->post('db_conn'),
|
||||||
'DB_HOST' => $request->post('db_host'),
|
'DB_HOST' => $request->post('db_host'),
|
||||||
'DB_PORT' => $request->post('db_port'),
|
'DB_PORT' => $request->post('db_port'),
|
||||||
'DB_NAME' => $request->post('db_name'),
|
'DB_DATABASE' => $request->post('db_name'),
|
||||||
'DB_USER' => $request->post('db_user'),
|
'DB_USERNAME' => $request->post('db_user'),
|
||||||
'DB_PASS' => $request->post('db_pass'),
|
'DB_PASSWORD' => $request->post('db_pass'),
|
||||||
'DB_PREFIX' => $request->post('db_prefix'),
|
'DB_PREFIX' => $request->post('db_prefix'),
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -231,7 +231,7 @@ class InstallerController extends Controller
|
|||||||
Log::error('Config files failed to write');
|
Log::error('Config files failed to write');
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
|
||||||
Flash::error($e->getMessage());
|
flash()->error($e->getMessage());
|
||||||
return redirect(route('installer.step2'))->withInput();
|
return redirect(route('installer.step2'))->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ class InstallerController extends Controller
|
|||||||
Log::error('Error on db setup: '.$e->getMessage());
|
Log::error('Error on db setup: '.$e->getMessage());
|
||||||
//dd($e);
|
//dd($e);
|
||||||
$this->envSvc->removeConfigFiles();
|
$this->envSvc->removeConfigFiles();
|
||||||
Flash::error($e->getMessage());
|
flash()->error($e->getMessage());
|
||||||
return redirect(route('installer.step2'))->withInput();
|
return redirect(route('installer.step2'))->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class ApiAuth implements Middleware
|
|||||||
return $this->unauthorized('User not found with key "'.$api_key.'"');
|
return $this->unauthorized('User not found with key "'.$api_key.'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->state !== UserState::ACTIVE) {
|
if ($user->state !== UserState::ACTIVE && $user->state !== UserState::ON_LEAVE) {
|
||||||
return $this->unauthorized('User is not ACTIVE, please contact an administrator');
|
return $this->unauthorized('User is not ACTIVE, please contact an administrator');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class SetActiveTheme implements Middleware
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$theme = setting('general.theme');
|
$theme = setting('general.theme', 'default');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
$theme = 'default';
|
$theme = 'default';
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Bid extends Resource
|
|||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
$res = parent::toArray($request);
|
$res = parent::toArray($request);
|
||||||
$res['flight'] = new Flight($this->flight);
|
$res['flight'] = new BidFlight($this->flight);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use App\Http\Resources\SimBrief as SimbriefResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin \App\Models\Flight
|
||||||
|
*/
|
||||||
|
class BidFlight extends Flight
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
*
|
||||||
|
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||||
|
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$res = parent::toArray($request);
|
||||||
|
|
||||||
|
if ($this->whenLoaded('simbrief')) {
|
||||||
|
unset($res['subfleets']);
|
||||||
|
$res['simbrief'] = new SimbriefResource($this->simbrief);
|
||||||
|
} else {
|
||||||
|
unset($res['simbrief']);
|
||||||
|
$res['subfleets'] = Subfleet::collection($this->whenLoaded('subfleets'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$res['fields'] = $this->setFields();
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
class BidSubfleet extends Subfleet
|
||||||
|
{
|
||||||
|
protected $aircraft;
|
||||||
|
protected $fares;
|
||||||
|
|
||||||
|
public function __construct($resource, $aircraft, $fares)
|
||||||
|
{
|
||||||
|
parent::__construct($resource);
|
||||||
|
|
||||||
|
$this->aircraft = $aircraft;
|
||||||
|
$this->fares = $fares;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$res = [];
|
||||||
|
$res['airline_id'] = $this->airline_id;
|
||||||
|
$res['hub_id'] = $this->hub_id;
|
||||||
|
$res['type'] = $this->type;
|
||||||
|
$res['simbrief_type'] = $this->simbrief_type;
|
||||||
|
$res['name'] = $this->name;
|
||||||
|
$res['fuel_type'] = $this->fuel_type;
|
||||||
|
$res['cost_block_hour'] = $this->cost_block_hour;
|
||||||
|
$res['cost_delay_minute'] = $this->cost_delay_minute;
|
||||||
|
$res['ground_handling_multiplier'] = $this->ground_handling_multiplier;
|
||||||
|
$res['cargo_capacity'] = $this->cargo_capacity;
|
||||||
|
$res['fuel_capacity'] = $this->fuel_capacity;
|
||||||
|
$res['gross_weight'] = $this->gross_weight;
|
||||||
|
|
||||||
|
$res['fares'] = Fare::collection($this->fares);
|
||||||
|
|
||||||
|
// There should only be one aircraft tied to a bid subfleet, wrap in a collection
|
||||||
|
$res['aircraft'] = Aircraft::collection([$this->aircraft]);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ class Fare extends Resource
|
|||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'capacity' => $this->capacity,
|
'capacity' => $this->capacity,
|
||||||
'cost' => $this->cost,
|
'cost' => $this->cost,
|
||||||
|
'count' => $this->count ?? 0,
|
||||||
'price' => $this->price,
|
'price' => $this->price,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'notes' => $this->notes,
|
'notes' => $this->notes,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Flight extends Resource
|
|||||||
/**
|
/**
|
||||||
* Set the fields on the flight object
|
* Set the fields on the flight object
|
||||||
*/
|
*/
|
||||||
private function setFields()
|
protected function setFields()
|
||||||
{
|
{
|
||||||
/** @var \Illuminate\Support\Collection $field_values */
|
/** @var \Illuminate\Support\Collection $field_values */
|
||||||
$return_values = new stdClass();
|
$return_values = new stdClass();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class Pirep extends Resource
|
|||||||
{
|
{
|
||||||
$res = parent::toArray($request);
|
$res = parent::toArray($request);
|
||||||
$res['ident'] = $this->ident;
|
$res['ident'] = $this->ident;
|
||||||
|
$res['phase'] = $this->status;
|
||||||
$res['status_text'] = PirepStatus::label($this->status);
|
$res['status_text'] = PirepStatus::label($this->status);
|
||||||
|
|
||||||
// Set these to the response units
|
// Set these to the response units
|
||||||
@@ -37,6 +38,13 @@ class Pirep extends Resource
|
|||||||
$distance = new Distance($res['distance'], config('phpvms.internal_units.distance'));
|
$distance = new Distance($res['distance'], config('phpvms.internal_units.distance'));
|
||||||
$res['distance'] = $distance->getResponseUnits();
|
$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)) {
|
if (!array_key_exists('fuel_used', $res)) {
|
||||||
$res['fuel_used'] = 0;
|
$res['fuel_used'] = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,29 @@ class SimBrief extends Resource
|
|||||||
{
|
{
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
return [
|
$data = [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'url' => url(route('api.flights.briefing', ['id' => $this->id])),
|
'aircraft_id' => $this->aircraft_id,
|
||||||
|
'url' => url(route('api.flights.briefing', ['id' => $this->id])),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$fares = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!empty($this->fare_data)) {
|
||||||
|
$fare_data = json_decode($this->fare_data, true);
|
||||||
|
foreach ($fare_data as $fare) {
|
||||||
|
$fares[] = new \App\Models\Fare($fare);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fares = collect($fares);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Invalid fare data
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['subfleet'] = new BidSubfleet($this->aircraft->subfleet, $this->aircraft, $fares);
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ class User extends Resource
|
|||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'pilot_id' => $this->pilot_id,
|
'pilot_id' => $this->pilot_id,
|
||||||
'ident' => $this->ident,
|
'ident' => $this->ident,
|
||||||
'name' => $this->name,
|
'name' => $this->name_private,
|
||||||
'name_private' => $this->name_private,
|
'name_private' => $this->name_private,
|
||||||
'email' => $this->email,
|
|
||||||
'avatar' => $this->resolveAvatarUrl(),
|
'avatar' => $this->resolveAvatarUrl(),
|
||||||
'rank_id' => $this->rank_id,
|
'rank_id' => $this->rank_id,
|
||||||
'home_airport' => $this->home_airport_id,
|
'home_airport' => $this->home_airport_id,
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\PirepAccepted;
|
use App\Events\PirepFiled;
|
||||||
use App\Events\PirepRejected;
|
|
||||||
use App\Services\BidService;
|
use App\Services\BidService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,8 +12,7 @@ use App\Services\BidService;
|
|||||||
class BidEventHandler extends Listener
|
class BidEventHandler extends Listener
|
||||||
{
|
{
|
||||||
public static $callbacks = [
|
public static $callbacks = [
|
||||||
PirepAccepted::class => 'onPirepAccept',
|
PirepFiled::class => 'onPirepFiled',
|
||||||
PirepRejected::class => 'onPirepReject',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
private $bidSvc;
|
private $bidSvc;
|
||||||
@@ -25,29 +23,15 @@ class BidEventHandler extends Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a PIREP is accepted, remove any bids
|
* When a PIREP is filed, remove any bids
|
||||||
*
|
*
|
||||||
* @param PirepAccepted $event
|
* @param PirepFiled $event
|
||||||
*
|
*
|
||||||
* @throws \UnexpectedValueException
|
* @throws \UnexpectedValueException
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function onPirepAccept(PirepAccepted $event): void
|
public function onPirepFiled(PirepFiled $event): void
|
||||||
{
|
|
||||||
$this->bidSvc->removeBidForPirep($event->pirep);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When a PIREP is accepted, remove any bids
|
|
||||||
*
|
|
||||||
* @param PirepRejected $event
|
|
||||||
*
|
|
||||||
* @throws \UnexpectedValueException
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function onPirepReject(PirepRejected $event): void
|
|
||||||
{
|
{
|
||||||
$this->bidSvc->removeBidForPirep($event->pirep);
|
$this->bidSvc->removeBidForPirep($event->pirep);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Contracts\Listener;
|
||||||
|
use App\Events\PirepPrefiled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look for and run any of the award classes. Don't modify this.
|
||||||
|
* See the documentation on creating awards:
|
||||||
|
*
|
||||||
|
* @url http://docs.phpvms.net/customizing/awards
|
||||||
|
*/
|
||||||
|
class PirepEventsHandler extends Listener
|
||||||
|
{
|
||||||
|
/** The events and the callback */
|
||||||
|
public static $callbacks = [
|
||||||
|
PirepPrefiled::class => 'onPirepPrefile',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a PIREP is prefiled
|
||||||
|
*
|
||||||
|
* @param PirepPrefiled $event
|
||||||
|
*/
|
||||||
|
public function onPirepPrefile(PirepPrefiled $event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ use Carbon\Carbon;
|
|||||||
* @property int status
|
* @property int status
|
||||||
* @property int state
|
* @property int state
|
||||||
* @property Carbon landing_time
|
* @property Carbon landing_time
|
||||||
|
* @property float fuel_onboard
|
||||||
*/
|
*/
|
||||||
class Aircraft extends Model
|
class Aircraft extends Model
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class Airport extends Model
|
|||||||
'lon',
|
'lon',
|
||||||
'hub',
|
'hub',
|
||||||
'timezone',
|
'timezone',
|
||||||
|
'tz',
|
||||||
'ground_handling_cost',
|
'ground_handling_cost',
|
||||||
'fuel_100ll_cost',
|
'fuel_100ll_cost',
|
||||||
'fuel_jeta_cost',
|
'fuel_jeta_cost',
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class UserState extends Enum
|
|||||||
public const REJECTED = 2;
|
public const REJECTED = 2;
|
||||||
public const ON_LEAVE = 3;
|
public const ON_LEAVE = 3;
|
||||||
public const SUSPENDED = 4;
|
public const SUSPENDED = 4;
|
||||||
|
public const DELETED = 5;
|
||||||
|
|
||||||
protected static $labels = [
|
protected static $labels = [
|
||||||
self::PENDING => 'user.state.pending',
|
self::PENDING => 'user.state.pending',
|
||||||
@@ -18,5 +19,6 @@ class UserState extends Enum
|
|||||||
self::REJECTED => 'user.state.rejected',
|
self::REJECTED => 'user.state.rejected',
|
||||||
self::ON_LEAVE => 'user.state.on_leave',
|
self::ON_LEAVE => 'user.state.on_leave',
|
||||||
self::SUSPENDED => 'user.state.suspended',
|
self::SUSPENDED => 'user.state.suspended',
|
||||||
|
self::DELETED => 'user.state.deleted',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ class Fare extends Model
|
|||||||
public $table = 'fares';
|
public $table = 'fares';
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
'id',
|
||||||
'code',
|
'code',
|
||||||
'name',
|
'name',
|
||||||
'type',
|
'type',
|
||||||
'price',
|
'price',
|
||||||
'cost',
|
'cost',
|
||||||
'capacity',
|
'capacity',
|
||||||
|
'count',
|
||||||
'notes',
|
'notes',
|
||||||
'active',
|
'active',
|
||||||
];
|
];
|
||||||
@@ -34,6 +36,7 @@ class Fare extends Model
|
|||||||
'price' => 'float',
|
'price' => 'float',
|
||||||
'cost' => 'float',
|
'cost' => 'float',
|
||||||
'capacity' => 'integer',
|
'capacity' => 'integer',
|
||||||
|
'count' => 'integer',
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'active' => 'boolean',
|
'active' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use Illuminate\Support\Collection;
|
|||||||
* @property Airline airline
|
* @property Airline airline
|
||||||
* @property int airline_id
|
* @property int airline_id
|
||||||
* @property mixed flight_number
|
* @property mixed flight_number
|
||||||
|
* @property mixed callsign
|
||||||
* @property mixed route_code
|
* @property mixed route_code
|
||||||
* @property int route_leg
|
* @property int route_leg
|
||||||
* @property bool has_bid
|
* @property bool has_bid
|
||||||
@@ -60,6 +61,7 @@ class Flight extends Model
|
|||||||
'id',
|
'id',
|
||||||
'airline_id',
|
'airline_id',
|
||||||
'flight_number',
|
'flight_number',
|
||||||
|
'callsign',
|
||||||
'route_code',
|
'route_code',
|
||||||
'route_leg',
|
'route_leg',
|
||||||
'dpt_airport_id',
|
'dpt_airport_id',
|
||||||
@@ -104,6 +106,7 @@ class Flight extends Model
|
|||||||
public static $rules = [
|
public static $rules = [
|
||||||
'airline_id' => 'required|exists:airlines,id',
|
'airline_id' => 'required|exists:airlines,id',
|
||||||
'flight_number' => 'required',
|
'flight_number' => 'required',
|
||||||
|
'callsign' => 'string|max:4|nullable',
|
||||||
'route_code' => 'nullable',
|
'route_code' => 'nullable',
|
||||||
'route_leg' => 'nullable',
|
'route_leg' => 'nullable',
|
||||||
'dpt_airport_id' => 'required|exists:airports,id',
|
'dpt_airport_id' => 'required|exists:airports,id',
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class Journal extends Model
|
|||||||
*/
|
*/
|
||||||
public function getCurrentBalance()
|
public function getCurrentBalance()
|
||||||
{
|
{
|
||||||
return $this->getBalanceOn(Carbon::now());
|
return $this->getBalanceOn(Carbon::now('UTC'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?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',
|
||||||
|
];
|
||||||
|
}
|
||||||
+20
-2
@@ -305,7 +305,9 @@ class Pirep extends Model
|
|||||||
public function getFieldsAttribute()
|
public function getFieldsAttribute()
|
||||||
{
|
{
|
||||||
$custom_fields = PirepField::all();
|
$custom_fields = PirepField::all();
|
||||||
$field_values = PirepFieldValue::where('pirep_id', $this->id)->get();
|
$field_values = PirepFieldValue::where('pirep_id', $this->id)
|
||||||
|
->orderBy('created_at', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
// Merge the field values into $fields
|
// Merge the field values into $fields
|
||||||
foreach ($custom_fields as $field) {
|
foreach ($custom_fields as $field) {
|
||||||
@@ -321,7 +323,23 @@ class Pirep extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $field_values->sortBy('source');
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,6 +4,14 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Contracts\Model;
|
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
|
class PirepFare extends Model
|
||||||
{
|
{
|
||||||
public $table = 'pirep_fares';
|
public $table = 'pirep_fares';
|
||||||
|
|||||||
+9
-1
@@ -5,6 +5,12 @@ namespace App\Models;
|
|||||||
use Laratrust\Models\LaratrustRole;
|
use Laratrust\Models\LaratrustRole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @property int id
|
||||||
|
* @property string name
|
||||||
|
* @property string display_name
|
||||||
|
* @property bool read_only
|
||||||
|
* @property bool disable_activity_checks
|
||||||
|
*
|
||||||
* @mixin \Illuminate\Database\Eloquent\Builder
|
* @mixin \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
class Role extends LaratrustRole
|
class Role extends LaratrustRole
|
||||||
@@ -14,10 +20,12 @@ class Role extends LaratrustRole
|
|||||||
'name',
|
'name',
|
||||||
'display_name',
|
'display_name',
|
||||||
'read_only',
|
'read_only',
|
||||||
|
'disable_activity_checks',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'read_only' => 'boolean',
|
'read_only' => 'boolean',
|
||||||
|
'disable_activity_checks' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+11
-1
@@ -10,14 +10,17 @@ use Illuminate\Support\Collection;
|
|||||||
* @property int $user_id The user that generated this
|
* @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 $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 $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 $acars_xml
|
||||||
* @property string $ofp_xml
|
* @property string $ofp_xml
|
||||||
* @property string $ofp_html
|
* @property string $ofp_html
|
||||||
|
* @property string $fare_data JSON string of the fare data that was generated
|
||||||
* @property Collection $images
|
* @property Collection $images
|
||||||
* @property Collection $files
|
* @property Collection $files
|
||||||
* @property Flight $flight
|
* @property Flight $flight
|
||||||
* @property User $user
|
* @property User $user
|
||||||
* @property SimBriefXML $xml
|
* @property SimBriefXML $xml
|
||||||
|
* @property Aircraft $aircraft
|
||||||
* @property string $acars_flightplan_url
|
* @property string $acars_flightplan_url
|
||||||
*/
|
*/
|
||||||
class SimBrief extends Model
|
class SimBrief extends Model
|
||||||
@@ -29,9 +32,11 @@ class SimBrief extends Model
|
|||||||
'id',
|
'id',
|
||||||
'user_id',
|
'user_id',
|
||||||
'flight_id',
|
'flight_id',
|
||||||
|
'aircraft_id',
|
||||||
'pirep_id',
|
'pirep_id',
|
||||||
'acars_xml',
|
'acars_xml',
|
||||||
'ofp_xml',
|
'ofp_xml',
|
||||||
|
'fare_data',
|
||||||
'created_at',
|
'created_at',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
];
|
];
|
||||||
@@ -44,7 +49,7 @@ class SimBrief extends Model
|
|||||||
*
|
*
|
||||||
* @return \App\Models\SimBriefXML|null
|
* @return \App\Models\SimBriefXML|null
|
||||||
*/
|
*/
|
||||||
public function getXmlAttribute(): SimBriefXML
|
public function getXmlAttribute(): ?SimBriefXML
|
||||||
{
|
{
|
||||||
if (empty($this->attributes['ofp_xml'])) {
|
if (empty($this->attributes['ofp_xml'])) {
|
||||||
return null;
|
return null;
|
||||||
@@ -80,6 +85,11 @@ class SimBrief extends Model
|
|||||||
* Relationships
|
* Relationships
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public function aircraft()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Aircraft::class, 'aircraft_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function flight()
|
public function flight()
|
||||||
{
|
{
|
||||||
if (!empty($this->attributes['flight_id'])) {
|
if (!empty($this->attributes['flight_id'])) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use App\Models\Traits\FilesTrait;
|
|||||||
/**
|
/**
|
||||||
* @property int id
|
* @property int id
|
||||||
* @property string type
|
* @property string type
|
||||||
|
* @property string simbrief_type
|
||||||
* @property string name
|
* @property string name
|
||||||
* @property int airline_id
|
* @property int airline_id
|
||||||
* @property int hub_id
|
* @property int hub_id
|
||||||
@@ -29,6 +30,7 @@ class Subfleet extends Model
|
|||||||
'airline_id',
|
'airline_id',
|
||||||
'hub_id',
|
'hub_id',
|
||||||
'type',
|
'type',
|
||||||
|
'simbrief_type',
|
||||||
'name',
|
'name',
|
||||||
'fuel_type',
|
'fuel_type',
|
||||||
'cost_block_hour',
|
'cost_block_hour',
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ use Laratrust\Traits\LaratrustUserTrait;
|
|||||||
* @property string last_pirep_id
|
* @property string last_pirep_id
|
||||||
* @property Pirep last_pirep
|
* @property Pirep last_pirep
|
||||||
* @property UserFieldValue[] fields
|
* @property UserFieldValue[] fields
|
||||||
|
* @property Role[] roles
|
||||||
|
* @property Subfleet[] subfleets
|
||||||
*
|
*
|
||||||
* @mixin \Illuminate\Database\Eloquent\Builder
|
* @mixin \Illuminate\Database\Eloquent\Builder
|
||||||
* @mixin \Illuminate\Notifications\Notifiable
|
* @mixin \Illuminate\Notifications\Notifiable
|
||||||
|
|||||||
@@ -46,14 +46,20 @@ class EventHandler extends Listener
|
|||||||
*
|
*
|
||||||
* @param \App\Contracts\Notification $notification
|
* @param \App\Contracts\Notification $notification
|
||||||
*/
|
*/
|
||||||
protected function notifyAdmins($notification)
|
protected function notifyAdmins(\App\Contracts\Notification $notification)
|
||||||
{
|
{
|
||||||
$admin_users = User::whereRoleIs('admin')->get();
|
$admin_users = User::whereRoleIs('admin')->get();
|
||||||
|
|
||||||
try {
|
foreach ($admin_users as $user) {
|
||||||
Notification::send($admin_users, $notification);
|
if (empty($user->email)) {
|
||||||
} catch (Exception $e) {
|
continue;
|
||||||
Log::emergency('Error emailing admins, malformed email='.$e->getMessage());
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Notification::send([$user], $notification);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::emergency('Error emailing admin ('.$user->email.'). Error='.$e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,12 +67,16 @@ class EventHandler extends Listener
|
|||||||
* @param User $user
|
* @param User $user
|
||||||
* @param \App\Contracts\Notification $notification
|
* @param \App\Contracts\Notification $notification
|
||||||
*/
|
*/
|
||||||
protected function notifyUser($user, $notification)
|
protected function notifyUser(User $user, \App\Contracts\Notification $notification)
|
||||||
{
|
{
|
||||||
|
if ($user->state === UserState::DELETED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$user->notify($notification);
|
$user->notify($notification);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::emergency('Error emailing admins, malformed email='.$e->getMessage());
|
Log::emergency('Error emailing user, '.$user->ident.'='.$user->email.', error='.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,17 +94,15 @@ class EventHandler extends Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var Collection $users */
|
/** @var Collection $users */
|
||||||
$users = User::where($where)->get();
|
$users = User::where($where)->where('state', '<>', UserState::DELETED)->get();
|
||||||
if (empty($users) || $users->count() === 0) {
|
if (empty($users) || $users->count() === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info('Sending notification to '.$users->count().' users');
|
Log::info('Sending notification to '.$users->count().' users');
|
||||||
|
|
||||||
try {
|
foreach ($users as $user) {
|
||||||
Notification::send($users, $notification);
|
$this->notifyUser($user, $notification);
|
||||||
} catch (Exception $e) {
|
|
||||||
Log::emergency('Error emailing admins, malformed email='.$e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class NewsAdded extends Notification
|
|||||||
$this->news = $news;
|
$this->news = $news;
|
||||||
$this->setMailable(
|
$this->setMailable(
|
||||||
$news->subject,
|
$news->subject,
|
||||||
'notifications.mail.news',
|
'notifications.mail.news.news',
|
||||||
['news' => $news]
|
['news' => $news]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Services\ModuleService;
|
use App\Services\ModuleService;
|
||||||
|
use App\Support\ThemeViewFinder;
|
||||||
use App\Support\Utils;
|
use App\Support\Utils;
|
||||||
|
use Illuminate\Pagination\Paginator;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Facades\View;
|
use Illuminate\Support\Facades\View;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
@@ -13,6 +15,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Schema::defaultStringLength(191);
|
Schema::defaultStringLength(191);
|
||||||
|
Paginator::useBootstrap();
|
||||||
View::share('moduleSvc', app(ModuleService::class));
|
View::share('moduleSvc', app(ModuleService::class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,6 +24,14 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
|
$this->app->singleton('view.finder', function ($app) {
|
||||||
|
return new ThemeViewFinder(
|
||||||
|
$app['files'],
|
||||||
|
$app['config']['view.paths'],
|
||||||
|
null
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// Only load the IDE helper if it's included and enabled
|
// Only load the IDE helper if it's included and enabled
|
||||||
if (config('app.debug') === true) {
|
if (config('app.debug') === true) {
|
||||||
/* @noinspection NestedPositiveIfStatementsInspection */
|
/* @noinspection NestedPositiveIfStatementsInspection */
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Cron\Hourly\DeletePireps;
|
||||||
use App\Cron\Hourly\RemoveExpiredBids;
|
use App\Cron\Hourly\RemoveExpiredBids;
|
||||||
use App\Cron\Hourly\RemoveExpiredLiveFlights;
|
use App\Cron\Hourly\RemoveExpiredLiveFlights;
|
||||||
use App\Cron\Nightly\ApplyExpenses;
|
use App\Cron\Nightly\ApplyExpenses;
|
||||||
@@ -41,6 +42,7 @@ class CronServiceProvider extends ServiceProvider
|
|||||||
],
|
],
|
||||||
|
|
||||||
CronHourly::class => [
|
CronHourly::class => [
|
||||||
|
DeletePireps::class,
|
||||||
RemoveExpiredBids::class,
|
RemoveExpiredBids::class,
|
||||||
RemoveExpiredLiveFlights::class,
|
RemoveExpiredLiveFlights::class,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Listeners\AwardHandler;
|
|||||||
use App\Listeners\BidEventHandler;
|
use App\Listeners\BidEventHandler;
|
||||||
use App\Listeners\ExpenseListener;
|
use App\Listeners\ExpenseListener;
|
||||||
use App\Listeners\FinanceEventHandler;
|
use App\Listeners\FinanceEventHandler;
|
||||||
|
use App\Listeners\PirepEventsHandler;
|
||||||
use App\Listeners\UserStateListener;
|
use App\Listeners\UserStateListener;
|
||||||
use App\Notifications\EventHandler;
|
use App\Notifications\EventHandler;
|
||||||
use Codedge\Updater\Events\UpdateAvailable;
|
use Codedge\Updater\Events\UpdateAvailable;
|
||||||
@@ -45,5 +46,6 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
FinanceEventHandler::class,
|
FinanceEventHandler::class,
|
||||||
EventHandler::class,
|
EventHandler::class,
|
||||||
AwardHandler::class,
|
AwardHandler::class,
|
||||||
|
PirepEventsHandler::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,6 +392,12 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
Route::match(['post'], 'maintenance/forcecheck', 'MaintenanceController@forcecheck')
|
Route::match(['post'], 'maintenance/forcecheck', 'MaintenanceController@forcecheck')
|
||||||
->name('maintenance.forcecheck')->middleware('ability:admin,maintenance');
|
->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
|
// subfleet
|
||||||
Route::get('subfleets/export', 'SubfleetController@export')
|
Route::get('subfleets/export', 'SubfleetController@export')
|
||||||
->name('subfleets.export')->middleware('ability:admin,fleet');
|
->name('subfleets.export')->middleware('ability:admin,fleet');
|
||||||
@@ -459,7 +465,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
Route::group([
|
Route::group([
|
||||||
'as' => 'modules.',
|
'as' => 'modules.',
|
||||||
'prefix' => 'modules',
|
'prefix' => 'modules',
|
||||||
'middleware' => ['ability:admin, modules'],
|
'middleware' => ['ability:admin,modules'],
|
||||||
], function () {
|
], function () {
|
||||||
|
|
||||||
//Modules Index
|
//Modules Index
|
||||||
@@ -508,6 +514,8 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
Route::get('pireps/{pirep_id}', 'PirepController@get');
|
Route::get('pireps/{pirep_id}', 'PirepController@get');
|
||||||
Route::get('pireps/{pirep_id}/acars/geojson', 'AcarsController@acars_geojson');
|
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('news', 'NewsController@index');
|
||||||
Route::get('status', 'StatusController@status');
|
Route::get('status', 'StatusController@status');
|
||||||
Route::get('version', 'StatusController@status');
|
Route::get('version', 'StatusController@status');
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class JournalRepository extends Repository implements CacheableInterface
|
|||||||
$journal->refresh();
|
$journal->refresh();
|
||||||
|
|
||||||
if (!$date) {
|
if (!$date) {
|
||||||
$date = Carbon::now();
|
$date = Carbon::now('UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
$credit = $this->getCreditBalanceBetween($date, $journal);
|
$credit = $this->getCreditBalanceBetween($date, $journal);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SubfleetRepository extends Repository implements CacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($items as $i) {
|
foreach ($items as $i) {
|
||||||
$retval[$i->id] = $i->name;
|
$retval[$i->id] = $i->name.' | '.$i->airline->icao;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class VaCentralLookup extends AirportLookup
|
|||||||
try {
|
try {
|
||||||
$airport = $this->client->getAirport($icao);
|
$airport = $this->client->getAirport($icao);
|
||||||
$airport->location = $airport->city;
|
$airport->location = $airport->city;
|
||||||
|
$airport->timezone = $airport->tz;
|
||||||
|
|
||||||
return $airport;
|
return $airport;
|
||||||
} catch (HttpException $e) {
|
} catch (HttpException $e) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Contracts\AirportLookup as AirportLookupProvider;
|
use App\Contracts\AirportLookup;
|
||||||
use App\Contracts\Metar as MetarProvider;
|
use App\Contracts\Metar as MetarProvider;
|
||||||
use App\Contracts\Service;
|
use App\Contracts\Service;
|
||||||
use App\Exceptions\AirportNotFound;
|
use App\Exceptions\AirportNotFound;
|
||||||
@@ -23,7 +23,7 @@ class AirportService extends Service
|
|||||||
private $metarProvider;
|
private $metarProvider;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AirportLookupProvider $lookupProvider,
|
AirportLookup $lookupProvider,
|
||||||
AirportRepository $airportRepo,
|
AirportRepository $airportRepo,
|
||||||
MetarProvider $metarProvider
|
MetarProvider $metarProvider
|
||||||
) {
|
) {
|
||||||
@@ -46,12 +46,32 @@ class AirportService extends Service
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$raw_metar = $this->metarProvider->get_metar($icao);
|
$raw_metar = $this->metarProvider->metar($icao);
|
||||||
if ($raw_metar && $raw_metar !== '') {
|
if ($raw_metar && $raw_metar !== '') {
|
||||||
return new 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
|
* Lookup an airport's information from a remote provider. This handles caching
|
||||||
* the data internally
|
* the data internally
|
||||||
@@ -101,7 +121,7 @@ class AirportService extends Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't lookup the airport, so just add in something generic
|
// Don't lookup the airport, so just add in something generic
|
||||||
if (!setting('general.auto_airport_lookup', false)) {
|
if (!setting('general.auto_airport_lookup')) {
|
||||||
$airport = new Airport([
|
$airport = new Airport([
|
||||||
'id' => $icao,
|
'id' => $icao,
|
||||||
'icao' => $icao,
|
'icao' => $icao,
|
||||||
|
|||||||
@@ -47,19 +47,26 @@ class BidService extends Service
|
|||||||
*/
|
*/
|
||||||
public function findBidsForUser(User $user)
|
public function findBidsForUser(User $user)
|
||||||
{
|
{
|
||||||
$bids = Bid::with([
|
$with = [
|
||||||
'flight',
|
'flight',
|
||||||
'flight.fares',
|
'flight.fares',
|
||||||
'flight.simbrief',
|
'flight.simbrief' => function ($query) use ($user) {
|
||||||
|
$query->where('user_id', $user->id);
|
||||||
|
},
|
||||||
|
'flight.simbrief.aircraft',
|
||||||
|
'flight.simbrief.aircraft.subfleet',
|
||||||
'flight.subfleets',
|
'flight.subfleets',
|
||||||
'flight.subfleets.aircraft',
|
'flight.subfleets.aircraft',
|
||||||
'flight.subfleets.fares',
|
'flight.subfleets.fares',
|
||||||
])
|
];
|
||||||
->where(['user_id' => $user->id])->get();
|
|
||||||
|
$bids = Bid::with($with)->where(['user_id' => $user->id])->get();
|
||||||
|
|
||||||
foreach ($bids as $bid) {
|
foreach ($bids as $bid) {
|
||||||
|
// if (empty($bid->flight->simbrief)) {
|
||||||
$bid->flight = $this->flightSvc->filterSubfleets($user, $bid->flight);
|
$bid->flight = $this->flightSvc->filterSubfleets($user, $bid->flight);
|
||||||
$bid->flight = $this->fareSvc->getReconciledFaresForFlight($bid->flight);
|
$bid->flight = $this->fareSvc->getReconciledFaresForFlight($bid->flight);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bids;
|
return $bids;
|
||||||
@@ -162,10 +169,6 @@ class BidService extends Service
|
|||||||
*/
|
*/
|
||||||
public function removeBidForPirep(Pirep $pirep)
|
public function removeBidForPirep(Pirep $pirep)
|
||||||
{
|
{
|
||||||
if (!setting('pireps.remove_bid_on_accept')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$flight = $pirep->flight;
|
$flight = $pirep->flight;
|
||||||
if (!$flight) {
|
if (!$flight) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -92,6 +92,6 @@ class CronService extends Service
|
|||||||
|
|
||||||
// More than 5 minutes... there's a problem
|
// More than 5 minutes... there's a problem
|
||||||
$diff = $dt_now->diff($dt);
|
$diff = $dt_now->diff($dt);
|
||||||
return $diff->i > 5;
|
return $diff->i > 60 * 12; // Hasn't run for 12 hours
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,6 +172,24 @@ class FareService extends Service
|
|||||||
return $fare;
|
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
|
* Attach a fare to an flight
|
||||||
*
|
*
|
||||||
@@ -240,24 +258,6 @@ class FareService extends Service
|
|||||||
return $subfleet;
|
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
|
* Delete the fare from a subfleet
|
||||||
*
|
*
|
||||||
@@ -286,9 +286,7 @@ class FareService extends Service
|
|||||||
*/
|
*/
|
||||||
public function getForPirep(Pirep $pirep)
|
public function getForPirep(Pirep $pirep)
|
||||||
{
|
{
|
||||||
$found_fares = PirepFare::where('pirep_id', $pirep->id)->get();
|
return PirepFare::where('pirep_id', $pirep->id)->get();
|
||||||
|
|
||||||
return $found_fares;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -313,6 +311,8 @@ class FareService extends Service
|
|||||||
$fare['pirep_id'] = $pirep->id;
|
$fare['pirep_id'] = $pirep->id;
|
||||||
// other fields: ['fare_id', 'count']
|
// other fields: ['fare_id', 'count']
|
||||||
|
|
||||||
|
Log::info('Saving fare pirep='.$pirep->id.', fare='.$fare['count']);
|
||||||
|
|
||||||
$field = new PirepFare($fare);
|
$field = new PirepFare($fare);
|
||||||
$field->save();
|
$field->save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,17 +152,43 @@ class PirepFinanceService extends Service
|
|||||||
public function payFuelCosts(Pirep $pirep): void
|
public function payFuelCosts(Pirep $pirep): void
|
||||||
{
|
{
|
||||||
$ap = $pirep->dpt_airport;
|
$ap = $pirep->dpt_airport;
|
||||||
$fuel_used = $pirep->fuel_used;
|
// Get Airport Fuel Cost or revert back to settings
|
||||||
|
if (empty($ap->fuel_jeta_cost)) {
|
||||||
|
$fuel_cost = setting('airports.default_jet_a_fuel_cost');
|
||||||
|
} else {
|
||||||
|
$fuel_cost = $ap->fuel_jeta_cost;
|
||||||
|
}
|
||||||
|
|
||||||
$debit = Money::createFromAmount($fuel_used * $ap->fuel_jeta_cost);
|
if (setting('pireps.advanced_fuel', false)) {
|
||||||
Log::info('Finance: Fuel cost, (fuel='.$fuel_used.', cost='.$ap->fuel_jeta_cost.') D='
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$debit = Money::createFromAmount($fuel_amount * $fuel_cost);
|
||||||
|
Log::info('Finance: Fuel cost, (fuel='.$fuel_amount.', cost='.$fuel_cost.') D='
|
||||||
.$debit->getAmount());
|
.$debit->getAmount());
|
||||||
|
|
||||||
$this->financeSvc->debitFromJournal(
|
$this->financeSvc->debitFromJournal(
|
||||||
$pirep->airline->journal,
|
$pirep->airline->journal,
|
||||||
$debit,
|
$debit,
|
||||||
$pirep,
|
$pirep,
|
||||||
'Fuel Cost ('.$ap->fuel_jeta_cost.'/'.config('phpvms.internal_units.fuel').')',
|
'Fuel Cost ('.$fuel_cost.'/'.config('phpvms.internal_units.fuel').')',
|
||||||
'Fuel',
|
'Fuel',
|
||||||
'fuel'
|
'fuel'
|
||||||
);
|
);
|
||||||
@@ -396,14 +422,26 @@ class PirepFinanceService extends Service
|
|||||||
*/
|
*/
|
||||||
public function payGroundHandlingForPirep(Pirep $pirep): void
|
public function payGroundHandlingForPirep(Pirep $pirep): void
|
||||||
{
|
{
|
||||||
$ground_handling_cost = $this->getGroundHandlingCost($pirep);
|
$ground_handling_cost = $this->getGroundHandlingCost($pirep, $pirep->dpt_airport);
|
||||||
Log::info('Finance: PIREP: '.$pirep->id.'; ground handling: '.$ground_handling_cost);
|
Log::info('Finance: PIREP: '.$pirep->id.'; dpt ground handling: '.$ground_handling_cost);
|
||||||
|
|
||||||
$this->financeSvc->debitFromJournal(
|
$this->financeSvc->debitFromJournal(
|
||||||
$pirep->airline->journal,
|
$pirep->airline->journal,
|
||||||
Money::createFromAmount($ground_handling_cost),
|
Money::createFromAmount($ground_handling_cost),
|
||||||
$pirep,
|
$pirep,
|
||||||
|
'Ground Handling (Departure)',
|
||||||
'Ground Handling',
|
'Ground Handling',
|
||||||
|
'ground_handling'
|
||||||
|
);
|
||||||
|
|
||||||
|
$ground_handling_cost = $this->getGroundHandlingCost($pirep, $pirep->arr_airport);
|
||||||
|
Log::info('Finance: PIREP: '.$pirep->id.'; arr ground handling: '.$ground_handling_cost);
|
||||||
|
|
||||||
|
$this->financeSvc->debitFromJournal(
|
||||||
|
$pirep->airline->journal,
|
||||||
|
Money::createFromAmount($ground_handling_cost),
|
||||||
|
$pirep,
|
||||||
|
'Ground Handling (Arrival)',
|
||||||
'Ground Handling',
|
'Ground Handling',
|
||||||
'ground_handling'
|
'ground_handling'
|
||||||
);
|
);
|
||||||
@@ -506,23 +544,26 @@ class PirepFinanceService extends Service
|
|||||||
* Return the costs for the ground handling, with the multiplier
|
* Return the costs for the ground handling, with the multiplier
|
||||||
* being applied from the subfleet
|
* being applied from the subfleet
|
||||||
*
|
*
|
||||||
* @param Pirep $pirep
|
* @param Pirep $pirep
|
||||||
|
* @param Airport $airport
|
||||||
*
|
*
|
||||||
* @return float|null
|
* @return float|null
|
||||||
*/
|
*/
|
||||||
public function getGroundHandlingCost(Pirep $pirep)
|
public function getGroundHandlingCost(Pirep $pirep, Airport $airport): ?float
|
||||||
{
|
{
|
||||||
if (filled($pirep->aircraft->subfleet->ground_handling_multiplier)) {
|
if (empty($airport->ground_handling_cost)) {
|
||||||
// force into percent mode
|
$gh_cost = setting('airports.default_ground_handling_cost');
|
||||||
$multiplier = $pirep->aircraft->subfleet->ground_handling_multiplier.'%';
|
} else {
|
||||||
|
$gh_cost = $airport->ground_handling_cost;
|
||||||
return Math::applyAmountOrPercent(
|
|
||||||
$pirep->arr_airport->ground_handling_cost,
|
|
||||||
$multiplier
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pirep->arr_airport->ground_handling_cost;
|
if (!filled($pirep->aircraft->subfleet->ground_handling_multiplier)) {
|
||||||
|
return $gh_cost;
|
||||||
|
}
|
||||||
|
|
||||||
|
// force into percent mode
|
||||||
|
$multiplier = $pirep->aircraft->subfleet->ground_handling_multiplier.'%';
|
||||||
|
return Math::applyAmountOrPercent($gh_cost, $multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ class RecurringFinanceService extends Service
|
|||||||
$obj = $expense->getReferencedObject();
|
$obj = $expense->getReferencedObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($obj)) {
|
||||||
|
return [null, null];
|
||||||
|
}
|
||||||
|
|
||||||
if ($klass === 'Airport') {
|
if ($klass === 'Airport') {
|
||||||
$memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})";
|
$memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})";
|
||||||
$transaction_group = "Airport: {$expense->ref_model_id}";
|
$transaction_group = "Airport: {$expense->ref_model_id}";
|
||||||
@@ -128,6 +132,9 @@ class RecurringFinanceService extends Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
[$memo, $ta_group] = $this->getMemoAndGroup($expense);
|
[$memo, $ta_group] = $this->getMemoAndGroup($expense);
|
||||||
|
if (empty($memo) || empty($ta_group)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$this->financeSvc->debitFromJournal(
|
$this->financeSvc->debitFromJournal(
|
||||||
$journal,
|
$journal,
|
||||||
|
|||||||
@@ -135,8 +135,18 @@ class FlightService extends Service
|
|||||||
*/
|
*/
|
||||||
public function filterSubfleets(User $user, Flight $flight)
|
public function filterSubfleets(User $user, Flight $flight)
|
||||||
{
|
{
|
||||||
|
// Eager load some of the relationships needed
|
||||||
|
//$flight->load(['flight.subfleets', 'flight.subfleets.aircraft', 'flight.subfleets.fares']);
|
||||||
|
|
||||||
/** @var \Illuminate\Support\Collection $subfleets */
|
/** @var \Illuminate\Support\Collection $subfleets */
|
||||||
$subfleets = $flight->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) {
|
if ($subfleets === null || $subfleets->count() === 0) {
|
||||||
return $flight;
|
return $flight;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,13 +51,8 @@ class FlightImporter extends ImportExport
|
|||||||
'fields' => 'nullable',
|
'fields' => 'nullable',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var AirportService */
|
|
||||||
private $airportSvc;
|
private $airportSvc;
|
||||||
|
|
||||||
/** @var FareService */
|
|
||||||
private $fareSvc;
|
private $fareSvc;
|
||||||
|
|
||||||
/** @var FlightService */
|
|
||||||
private $flightSvc;
|
private $flightSvc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +209,7 @@ class FlightImporter extends ImportExport
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
$subfleets = $this->parseMultiColumnValues($col);
|
$subfleets = $this->parseMultiColumnValues($col);
|
||||||
foreach ($subfleets as $subfleet_type) {
|
foreach ($subfleets as $subfleet_type) {
|
||||||
$subfleet = Subfleet::updateOrCreate(
|
$subfleet = Subfleet::firstOrCreate(
|
||||||
['type' => $subfleet_type],
|
['type' => $subfleet_type],
|
||||||
['name' => $subfleet_type]
|
['name' => $subfleet_type]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -118,7 +118,11 @@ class ImportService extends Service
|
|||||||
// turn it into a collection and run some filtering
|
// turn it into a collection and run some filtering
|
||||||
$row = collect($row)->map(function ($val, $index) {
|
$row = collect($row)->map(function ($val, $index) {
|
||||||
$val = trim($val);
|
$val = trim($val);
|
||||||
return empty($val) ? null : $val;
|
if ($val === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $val;
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
// Try to validate
|
// Try to validate
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user