Add a PIREP flag for ready_only; some more METAR cleanup
This commit is contained in:
parent
4a19f609fc
commit
f54f19100c
@ -292,9 +292,6 @@ class PirepController extends Controller
|
||||
$pirep->hours = $time->hours;
|
||||
$pirep->minutes = $time->minutes;
|
||||
|
||||
# Can we modify?
|
||||
$read_only = $pirep->state !== PirepState::PENDING;
|
||||
|
||||
# set the custom fields
|
||||
foreach ($pirep->fields as $field) {
|
||||
$pirep->{$field->slug} = $field->value;
|
||||
@ -310,7 +307,6 @@ class PirepController extends Controller
|
||||
|
||||
return view('admin.pireps.edit', [
|
||||
'pirep' => $pirep,
|
||||
'read_only' => $read_only,
|
||||
'aircraft' => $pirep->aircraft,
|
||||
'aircraft_list' => $this->aircraftList(),
|
||||
'airports_list' => $this->airportRepo->selectBoxList(),
|
||||
|
@ -313,9 +313,6 @@ class PirepController extends Controller
|
||||
$pirep->hours = $time->hours;
|
||||
$pirep->minutes = $time->minutes;
|
||||
|
||||
# Can we modify?
|
||||
$read_only = $pirep->state !== PirepState::PENDING;
|
||||
|
||||
# set the custom fields
|
||||
foreach ($pirep->fields as $field) {
|
||||
$pirep->{$field->slug} = $field->value;
|
||||
@ -329,7 +326,6 @@ class PirepController extends Controller
|
||||
|
||||
return view('pireps.edit', [
|
||||
'pirep' => $pirep,
|
||||
'read_only' => $read_only,
|
||||
'aircraft' => $pirep->aircraft,
|
||||
'aircraft_list' => $this->aircraftList(),
|
||||
'airline_list' => $this->airlineRepo->selectBoxList(),
|
||||
|
@ -39,6 +39,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
||||
* @property Carbon submitted_at
|
||||
* @property Carbon created_at
|
||||
* @property Carbon updated_at
|
||||
* @property bool state
|
||||
* @package App\Models
|
||||
*/
|
||||
class Pirep extends Model
|
||||
@ -174,6 +175,14 @@ class Pirep extends Model
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if this PIREP can be edited or not
|
||||
*/
|
||||
public function getReadOnlyAttribute(): bool
|
||||
{
|
||||
return $this->state !== PirepState::PENDING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new Fuel unit so conversions can be made
|
||||
* @return int|Fuel
|
||||
|
@ -59,7 +59,6 @@ class Metar implements \ArrayAccess
|
||||
'visibility_nm' => null,
|
||||
'visibility_report' => null,
|
||||
'visibility_min' => null,
|
||||
'visibility_min_nm' => null,
|
||||
'visibility_min_direction' => null,
|
||||
'runways_visual_range' => null,
|
||||
'present_weather' => null,
|
||||
@ -348,7 +347,6 @@ class Metar implements \ArrayAccess
|
||||
$observed_time = strtotime(trim($raw_lines[0]));
|
||||
if ($observed_time !== 0) {
|
||||
$this->set_observed_date($observed_time);
|
||||
//$this->set_debug('Observation date is set from the METAR/TAF in first line of the file content: '.trim($raw_lines[0]));
|
||||
}
|
||||
} else {
|
||||
$raw = trim($raw_lines[0]);
|
||||
@ -495,11 +493,9 @@ class Metar implements \ArrayAccess
|
||||
if ($only_if_null) {
|
||||
if ($this->result[$parameter] === null) {
|
||||
$this->result[$parameter] = $value;
|
||||
//$this->set_debug('Set value "'.$value.'" ('.gettype($value).') for null parameter: '.$parameter);
|
||||
}
|
||||
} else {
|
||||
$this->result[$parameter] = $value;
|
||||
//$this->set_debug('Set value "'.$value.'" ('.gettype($value).') for parameter: '.$parameter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,7 +509,6 @@ class Metar implements \ArrayAccess
|
||||
}
|
||||
|
||||
$this->result[$parameter][] = $group;
|
||||
//$this->set_debug('Add new group value ('.gettype($group).') for parameter: '.$parameter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -528,7 +523,6 @@ class Metar implements \ArrayAccess
|
||||
if ($this->result[$parameter] !== null) {
|
||||
$this->result[$parameter] = ucfirst(ltrim($this->result[$parameter], ' '.$separator));
|
||||
}
|
||||
//$this->set_debug('Add group report value "'.$report.'" for parameter: '.$parameter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -577,7 +571,7 @@ class Metar implements \ArrayAccess
|
||||
*/
|
||||
private function get_station($part)
|
||||
{
|
||||
$r = '@^([A-Z]{1}[A-Z0-9]{3})$@'; // 1
|
||||
$r = '@^([A-Z]{1}'.'[A-Z0-9]{3})$@'; // 1
|
||||
if (!preg_match($r, $part, $found)) {
|
||||
return false;
|
||||
}
|
||||
@ -748,8 +742,8 @@ class Metar implements \ArrayAccess
|
||||
$this->set_result_value('cavok', true);
|
||||
$this->method += 4; // can skip the next 4 methods: visibility_min, runway_vr, present_weather, clouds
|
||||
}
|
||||
} elseif ($found[1] === '////') {
|
||||
} // information not available
|
||||
} /*elseif ($found[1] === '////') {
|
||||
}*/ // information not available
|
||||
|
||||
else {
|
||||
$prefix = '';
|
||||
@ -792,6 +786,9 @@ class Metar implements \ArrayAccess
|
||||
* maximum visibility is given as one of eight compass points (N, SW, ...).
|
||||
* @param $part
|
||||
* @return bool
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
private function get_visibility_min($part)
|
||||
{
|
||||
@ -799,9 +796,8 @@ class Metar implements \ArrayAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
$meters = (int) $found[1];
|
||||
$meters = new Distance((int) $found[1], 'm');
|
||||
$this->set_result_value('visibility_min', $meters);
|
||||
$this->set_result_value('visibility_min_nm', $this->meters_to_nm($meters));
|
||||
|
||||
if (isset($found[2]) && !empty($found[2])) {
|
||||
$this->set_result_value('visibility_min_direction', $found[2]);
|
||||
@ -1088,8 +1084,13 @@ class Metar implements \ArrayAccess
|
||||
*/
|
||||
private function get_runways_report($part)
|
||||
{
|
||||
$r = '@^R?(/?(SNOCLO)|([\d]{2}[LCR]?)/?(CLRD|([\d]{1}|/)'
|
||||
.'([\d]{1}|/)([\d]{2}|//))([\d]{2}|//))$@';
|
||||
$r = '@^R?'
|
||||
.'(/?(SNOCLO)' // 1
|
||||
.'|([\d]{2}[LCR]?)/?' // 2
|
||||
.'(CLRD|([\d]{1}|/)' // 3
|
||||
.'([\d]{1}|/)' // 4
|
||||
.'([\d]{2}|//))' // 5
|
||||
.'([\d]{2}|//))$@'; // 6
|
||||
|
||||
if (!preg_match($r, $part, $found)) {
|
||||
return false;
|
||||
@ -1202,10 +1203,15 @@ class Metar implements \ArrayAccess
|
||||
$this->part += 2; // can skip neext parts with ALL and RWY records
|
||||
} // See one next part for RWYdd record
|
||||
elseif (isset($this->raw_parts[$this->part])) {
|
||||
|
||||
$r = '@^R(WY)?' // 1
|
||||
.'([\d]{2}[LCR]?)$@'; // 2
|
||||
|
||||
$part = $this->raw_parts[$this->part];
|
||||
if (!preg_match('@^R(WY)?([\d]{2}[LCR]?)$@', $part, $found)) {
|
||||
if (!preg_match($r, $part, $found)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((int) $found[2] > 36 || (int) $found[2] < 1) {
|
||||
return false;
|
||||
}
|
||||
@ -1214,6 +1220,7 @@ class Metar implements \ArrayAccess
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1228,21 +1235,26 @@ class Metar implements \ArrayAccess
|
||||
* HH - Forecast hour, i.e. the time(hour) when the temperature is expected
|
||||
* Z - Time Zone indicator, Z=GMT.
|
||||
* @return bool
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
*/
|
||||
private function get_forecast_temperature($part): bool
|
||||
{
|
||||
$r = '@^(TX|TN)(M?[\d]{2})/([\d]{2})?([\d]{2})Z$@';
|
||||
$r = '@^(TX|TN)' // 1
|
||||
.'(M?[\d]{2})' // 2
|
||||
.'/([\d]{2})?' // 3
|
||||
.'([\d]{2})Z$@'; // 4
|
||||
|
||||
if (!preg_match($r, $this->raw_parts[$this->part], $found)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Temperature
|
||||
$temperature_c = (int) str_replace('M', '-', $found[2]);
|
||||
$temperature_f = round(1.8 * $temperature_c + 32);
|
||||
$temperture = new Temperature($temperature_c, 'C');
|
||||
|
||||
$forecast = [
|
||||
'value' => $temperature_c,
|
||||
'value_f' => $temperature_f,
|
||||
'value' => $temperture,
|
||||
'day' => null,
|
||||
'time' => null,
|
||||
];
|
||||
@ -1269,10 +1281,16 @@ class Metar implements \ArrayAccess
|
||||
*/
|
||||
private function get_trends($part)
|
||||
{
|
||||
$r = '@^((NOSIG|BECMG|TEMPO|INTER|CNL|NIL|PROV|(PROB)'
|
||||
.'([\d]{2})|(AT|FM|TL)([\d]{2})'
|
||||
.'?([\d]{2})([\d]{2}))|(([\d]{2})'
|
||||
.'([\d]{2}))/(([\d]{2})([\d]{2})))$@';
|
||||
$r = '@^((NOSIG|BECMG|TEMPO|INTER|CNL|NIL|PROV|(PROB)' // 1
|
||||
.'([\d]{2})|' // 2
|
||||
.'(AT|FM|TL)' // 3
|
||||
.'([\d]{2})?' // 4
|
||||
.'([\d]{2})' // 5
|
||||
.'([\d]{2}))|' // 6
|
||||
.'(([\d]{2})' // 7
|
||||
.'([\d]{2}))/' // 8
|
||||
.'(([\d]{2})' // 9
|
||||
.'([\d]{2})))$@'; // 10
|
||||
|
||||
if (!preg_match($r, $part, $found)) {
|
||||
return false;
|
||||
@ -1291,6 +1309,7 @@ class Metar implements \ArrayAccess
|
||||
$trend = [
|
||||
'flag' => null,
|
||||
'probability' => null,
|
||||
'period_report' => null,
|
||||
'period' => [
|
||||
'flag' => null,
|
||||
'day' => null,
|
||||
@ -1300,10 +1319,10 @@ class Metar implements \ArrayAccess
|
||||
'to_day' => null,
|
||||
'to_time' => null,
|
||||
],
|
||||
'period_report' => null,
|
||||
];
|
||||
|
||||
$raw_parts = [];
|
||||
|
||||
// Get all parts after trend part
|
||||
while ($this->part < \count($this->raw_parts)) {
|
||||
if (preg_match($regexp, $this->raw_parts[$this->part], $found)) {
|
||||
@ -1545,6 +1564,7 @@ class Metar implements \ArrayAccess
|
||||
/**
|
||||
* Calculate Wind Chill Temperature based on temperature in F
|
||||
* and wind speed in miles per hour.
|
||||
* @param $temperature_f
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*/
|
||||
@ -1571,6 +1591,9 @@ class Metar implements \ArrayAccess
|
||||
* 1 knot = 1.852 km/hr = 0.514444 m/s = 1.687809 ft/s = 1.150779 mi/hr
|
||||
* 1 km/hr = 0.539957 knots = 0.277778 m/s = 0.911344 ft/s = 0.621371 mi/hr
|
||||
* 1 m/s = 1.943844 knots = 3.6 km/h = 3.28084 ft/s = 2.236936 mi/hr
|
||||
* @param $speed
|
||||
* @param $unit
|
||||
* @return float|null
|
||||
*/
|
||||
private function convert_speed($speed, $unit)
|
||||
{
|
||||
@ -1594,6 +1617,9 @@ class Metar implements \ArrayAccess
|
||||
* 1 m = 3.28084 ft = 0.00062 mi
|
||||
* 1 ft = 0.3048 m = 0.00019 mi
|
||||
* 1 mi = 5279.99 ft = 1609.34 m
|
||||
* @param $distance
|
||||
* @param $unit
|
||||
* @return float|null
|
||||
*/
|
||||
private function convert_distance($distance, $unit)
|
||||
{
|
||||
@ -1610,24 +1636,6 @@ class Metar implements \ArrayAccess
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $meters
|
||||
* @return float
|
||||
*/
|
||||
private function meters_to_ft($meters)
|
||||
{
|
||||
return round($meters * 3.28084, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $meters
|
||||
* @return float
|
||||
*/
|
||||
private function meters_to_nm($meters)
|
||||
{
|
||||
return round($meters * 0.000539957, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert direction degrees to compass label.
|
||||
*/
|
||||
@ -1640,6 +1648,10 @@ class Metar implements \ArrayAccess
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* These methods below the implementation of the stubs for ArrayAccess
|
||||
*/
|
||||
|
||||
/**
|
||||
* Whether a offset exists
|
||||
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
||||
|
@ -1,214 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use MetarDecoder\MetarDecoder;
|
||||
|
||||
/**
|
||||
* Wrapper around the METAR decoder. Compensate for
|
||||
* errors and have tests around this functionality
|
||||
* @package App\Support
|
||||
*/
|
||||
class MetarWrapper
|
||||
{
|
||||
private $metar,
|
||||
$metar_str;
|
||||
|
||||
/**
|
||||
* Metar constructor.
|
||||
* @param $metar_str
|
||||
*/
|
||||
public function __construct($metar_str)
|
||||
{
|
||||
$decoder = new MetarDecoder();
|
||||
$this->metar = $decoder->parse($metar_str);
|
||||
$this->metar_str = $metar_str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if this is VFR or IFR conditions
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory(): string
|
||||
{
|
||||
$category = 'VFR';
|
||||
|
||||
$visibility = $this->getVisibility(false);
|
||||
$ceiling = $this->getCeiling(false);
|
||||
|
||||
if ($visibility < 3 || $ceiling < 1000) {
|
||||
$category = 'IFR';
|
||||
}
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ceiling
|
||||
* @param bool $convert
|
||||
* @return int
|
||||
*/
|
||||
public function getCeiling($convert = true): int
|
||||
{
|
||||
$ceiling = 1000;
|
||||
$clouds = $this->metar->getClouds();
|
||||
if ($clouds && \count($clouds) > 0) {
|
||||
$ceiling = $clouds[0]->getBaseHeight()->getValue();
|
||||
}
|
||||
|
||||
if(!$convert) {
|
||||
return $ceiling;
|
||||
}
|
||||
|
||||
return $ceiling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the cloud layers
|
||||
*/
|
||||
public function getClouds(): array
|
||||
{
|
||||
if (!$this->metar->getClouds()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$layers = [];
|
||||
$unit = setting('units.altitude');
|
||||
|
||||
foreach($this->metar->getClouds() as $cloud) {
|
||||
if($unit === 'ft') {
|
||||
$base_height = $cloud->getBaseHeight()->getValue();
|
||||
} else {
|
||||
$base_height = $cloud->getBaseHeight()->getConvertedValue('m');
|
||||
}
|
||||
|
||||
$layers[] = [
|
||||
'amount' => $cloud->getAmount(),
|
||||
'base_height' => $base_height,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
return $layers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Last update time
|
||||
* @return string
|
||||
*/
|
||||
public function getLastUpdate(): string
|
||||
{
|
||||
return $this->metar->getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pressure, pass in the unit type
|
||||
* @param string $unit Pass mb for millibars, hg for hg
|
||||
* @return float|null
|
||||
*/
|
||||
public function getPressure($unit = 'mb')
|
||||
{
|
||||
if (!$this->metar->getPressure()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$pressure = $this->metar->getPressure()->getValue();
|
||||
if (strtolower($unit) === 'mb') {
|
||||
return $pressure;
|
||||
}
|
||||
|
||||
return round($pressure * 33.86, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the raw metar string
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRawMetar()
|
||||
{
|
||||
return $this->metar_str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the temperature, if it exists in the METAR
|
||||
* Convert to the units that are set in the VA
|
||||
* @return float|null
|
||||
*/
|
||||
public function getTemperature()
|
||||
{
|
||||
if (!$this->metar->getAirTemperature()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(setting('units.temperature') === 'c') {
|
||||
return $this->metar->getAirTemperature()->getValue();
|
||||
}
|
||||
|
||||
// Convert to F
|
||||
round(($this->metar->getAirTemperature()->getValue() * 9 / 5) + 32, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visibility
|
||||
* @param bool $convert
|
||||
* @return int
|
||||
*/
|
||||
public function getVisibility($convert=true): int
|
||||
{
|
||||
// initially in miles
|
||||
$visibility = 10; // assume it's ok and VFR
|
||||
$vis = $this->metar->getVisibility();
|
||||
if ($vis) {
|
||||
$vis = $vis->getVisibility();
|
||||
if ($vis) {
|
||||
$visibility = (int) $vis->getValue();
|
||||
|
||||
if ($convert && setting('units.distance') === 'km') {
|
||||
return $vis->getConvertedValue('m') / 1000;
|
||||
}
|
||||
|
||||
return $visibility;
|
||||
}
|
||||
}
|
||||
|
||||
if($convert && setting('units.distance') === 'km') {
|
||||
return round($visibility * 1.60934, 2);
|
||||
}
|
||||
|
||||
return $visibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return wind information
|
||||
*/
|
||||
public function getWinds()
|
||||
{
|
||||
$sw = $this->metar->getSurfaceWind();
|
||||
if (!$sw) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ret = [
|
||||
'speed' => null,
|
||||
'direction' => null,
|
||||
'gusts' => null,
|
||||
];
|
||||
|
||||
$mean_speed = $sw->getMeanSpeed();
|
||||
if($mean_speed) {
|
||||
$ret['speed'] = $mean_speed->getConvertedValue('kt');
|
||||
}
|
||||
|
||||
$dir = $sw->getMeanDirection();
|
||||
if($dir) {
|
||||
$ret['direction'] = $dir->getValue();
|
||||
}
|
||||
|
||||
$gusts = $sw->getSpeedVariations();
|
||||
if($gusts) {
|
||||
$ret['gusts'] = $gusts->getConvertedValue('kt');
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
@ -11,14 +11,14 @@
|
||||
<td>{{ $fare->name }} ({{ $fare->code }})</td>
|
||||
<td>
|
||||
<div class="form-group">
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->{'fare_'.$fare->id} }}</p>
|
||||
{{ Form::hidden('fare_'.$fare->id) }}
|
||||
@else
|
||||
{{ Form::number('fare_'.$fare->id, null, [
|
||||
'class' => 'form-control',
|
||||
'min' => 0,
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
|
@ -1,4 +1,4 @@
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
@component('admin.components.info')
|
||||
@ -10,7 +10,7 @@
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-6">
|
||||
{{ Form::label('flight_number', 'Flight Number/Route Code/Leg') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->ident }}
|
||||
{{ Form::hidden('flight_number') }}
|
||||
{{ Form::hidden('flight_code') }}
|
||||
@ -45,7 +45,7 @@
|
||||
\App\Models\Enums\FlightType::select(),
|
||||
null, [
|
||||
'class' => 'form-control select2',
|
||||
'readonly' => $read_only
|
||||
'readonly' => $pirep->read_only
|
||||
])
|
||||
}}
|
||||
<p class="text-danger">{{ $errors->first('flight_type') }}</p>
|
||||
@ -61,46 +61,46 @@
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('airline_id', 'Airline') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->airline->name }}</p>
|
||||
{{ Form::hidden('airline_id') }}
|
||||
@else
|
||||
{{ Form::select('airline_id', $airlines_list, null, [
|
||||
'class' => 'form-control select2',
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('aircraft_id', 'Aircraft:') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->aircraft->name }}</p>
|
||||
{{ Form::hidden('aircraft_id') }}
|
||||
@else
|
||||
{{ Form::select('aircraft_id', $aircraft_list, null, [
|
||||
'id' => 'aircraft_select',
|
||||
'class' => 'form-control select2',
|
||||
'readonly' => $read_only
|
||||
'readonly' => $pirep->read_only
|
||||
]) }}
|
||||
<p class="text-danger">{{ $errors->first('aircraft_id') }}</p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('dpt_airport_id', 'Departure Airport:') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->dpt_airport->id }} - {{ $pirep->dpt_airport->name }}</p>
|
||||
{{ Form::hidden('dpt_airport_id') }}
|
||||
@else
|
||||
{{ Form::select('dpt_airport_id', $airports_list, null, [
|
||||
'class' => 'form-control select2',
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
<p class="text-danger">{{ $errors->first('dpt_airport_id') }}</p>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('arr_airport_id', 'Arrival Airport:') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->arr_airport->id }} - {{ $pirep->arr_airport->name }}</p>
|
||||
{{ Form::hidden('arr_airport_id') }}
|
||||
@else
|
||||
@ -113,7 +113,7 @@
|
||||
<!-- Flight Time Field -->
|
||||
<div class="form-group col-sm-6">
|
||||
{{ Form::label('flight_time', 'Flight Time (hours & minutes):') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>
|
||||
{{ $pirep->hours }} hours, {{ $pirep->minutes }} minutes
|
||||
{{ Form::hidden('hours') }}
|
||||
@ -125,13 +125,13 @@
|
||||
{{ Form::number('hours', null, [
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'hours',
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
{{ Form::number('minutes', null, [
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'minutes',
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
</div>
|
||||
<p class="text-danger">{{ $errors->first('hours') }}</p>
|
||||
<p class="text-danger">{{ $errors->first('minutes') }}</p>
|
||||
|
@ -3,7 +3,7 @@
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h2 class="description">Edit Flight Report</h2>
|
||||
<h2>Edit Flight Report</h2>
|
||||
@include('flash::message')
|
||||
{{ Form::model($pirep, [
|
||||
'route' => ['frontend.pireps.update', $pirep->id],
|
||||
@ -16,4 +16,4 @@
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@include("pireps.scripts")
|
||||
@include('pireps.scripts')
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{{Form::label('fare_'.$fare->id, $fare->name.' ('.$fare->code.')')}}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->{'fare_'.$fare->id} }}</p>
|
||||
{{ Form::hidden('fare_'.$fare->id) }}
|
||||
@else
|
||||
|
@ -8,7 +8,7 @@ an impact on your stats and financials, and will require a recalculation of all
|
||||
flight reports that have been filed. You've been warned!
|
||||
|
||||
--}}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
@component('components.info')
|
||||
@ -19,7 +19,6 @@ flight reports that have been filed. You've been warned!
|
||||
@endif
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
|
||||
<div class="form-container">
|
||||
<h6><i class="fas fa-info-circle"></i>
|
||||
Flight Information
|
||||
@ -28,7 +27,7 @@ flight reports that have been filed. You've been warned!
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
{{ Form::label('airline_id', 'Airline') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->airline->name }}</p>
|
||||
{{ Form::hidden('airline_id') }}
|
||||
@else
|
||||
@ -36,14 +35,14 @@ flight reports that have been filed. You've been warned!
|
||||
{{ Form::select('airline_id', $airline_list, null, [
|
||||
'class' => 'custom-select select2',
|
||||
'style' => 'width: 100%',
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
</div>
|
||||
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
{{ Form::label('flight_number', 'Flight Number/Code/Leg') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->ident }}
|
||||
{{ Form::hidden('flight_number') }}
|
||||
{{ Form::hidden('flight_code') }}
|
||||
@ -54,17 +53,17 @@ flight reports that have been filed. You've been warned!
|
||||
{{ Form::text('flight_number', null, [
|
||||
'placeholder' => 'Flight Number',
|
||||
'class' => 'form-control',
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
|
||||
{{ Form::text('route_code', null, [
|
||||
'placeholder' => 'Code (optional)',
|
||||
'class' => 'form-control',
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
|
||||
{{ Form::text('route_leg', null, [
|
||||
'placeholder' => 'Leg (optional)',
|
||||
'class' => 'form-control',
|
||||
'readonly' => $read_only]) }}
|
||||
'readonly' => $pirep->read_only]) }}
|
||||
</div>
|
||||
<p class="text-danger">{{ $errors->first('flight_number') }}</p>
|
||||
<p class="text-danger">{{ $errors->first('route_code') }}</p>
|
||||
@ -73,7 +72,7 @@ flight reports that have been filed. You've been warned!
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
{{ Form::label('flight_type', 'Flight Type') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ \App\Models\Enums\FlightType::label($pirep->flight_type) }}</p>
|
||||
{{ Form::hidden('flight_type') }}
|
||||
@else
|
||||
@ -82,7 +81,7 @@ flight reports that have been filed. You've been warned!
|
||||
\App\Models\Enums\FlightType::select(), null, [
|
||||
'class' => 'custom-select select2',
|
||||
'style' => 'width: 100%',
|
||||
'readonly' => $read_only
|
||||
'readonly' => $pirep->read_only
|
||||
])
|
||||
}}
|
||||
</div>
|
||||
@ -94,7 +93,7 @@ flight reports that have been filed. You've been warned!
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
{{ Form::label('hours', 'Flight Time') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>
|
||||
{{ $pirep->hours }} hours, {{ $pirep->minutes }} minutes
|
||||
{{ Form::hidden('hours') }}
|
||||
@ -106,14 +105,14 @@ flight reports that have been filed. You've been warned!
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'hours',
|
||||
'min' => '0',
|
||||
'readonly' => $read_only
|
||||
'readonly' => $pirep->read_only
|
||||
]) }}
|
||||
|
||||
{{ Form::number('minutes', null, [
|
||||
'class' => 'form-control',
|
||||
'placeholder' => 'minutes',
|
||||
'min' => 0,
|
||||
'readonly' => $read_only
|
||||
'readonly' => $pirep->read_only
|
||||
]) }}
|
||||
</div>
|
||||
<p class="text-danger">{{ $errors->first('hours') }}</p>
|
||||
@ -127,7 +126,7 @@ flight reports that have been filed. You've been warned!
|
||||
{{ Form::text('submmitted_date', null, [
|
||||
'placeholder' => 'Departure TIme',
|
||||
'class' => 'form-control',
|
||||
'readonly' => $read_only]) }}--}}
|
||||
'readonly' => $pirep->read_only]) }}--}}
|
||||
</div>
|
||||
|
||||
|
||||
@ -136,7 +135,7 @@ flight reports that have been filed. You've been warned!
|
||||
{{ Form::text('departure_time', null, [
|
||||
'placeholder' => 'Departure TIme',
|
||||
'class' => 'form-control',
|
||||
'readonly' => $read_only]) }}--}}
|
||||
'readonly' => $pirep->read_only]) }}--}}
|
||||
</div>
|
||||
|
||||
|
||||
@ -145,7 +144,7 @@ flight reports that have been filed. You've been warned!
|
||||
{{ Form::text('arrival_time', null, [
|
||||
'placeholder' => 'Arrival TIme',
|
||||
'class' => 'form-control',
|
||||
'readonly' => $read_only]) }}--}}
|
||||
'readonly' => $pirep->read_only]) }}--}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -161,7 +160,7 @@ flight reports that have been filed. You've been warned!
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
{{ Form::label('dpt_airport_id', 'Departure Airport') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
{{ $pirep->dpt_airport->name }}
|
||||
(<a href="{{route('frontend.airports.show', [
|
||||
'id' => $pirep->dpt_airport->icao
|
||||
@ -172,7 +171,7 @@ flight reports that have been filed. You've been warned!
|
||||
{{ Form::select('dpt_airport_id', $airport_list, null, [
|
||||
'class' => 'custom-select select2',
|
||||
'style' => 'width: 100%',
|
||||
'readonly' => $read_only
|
||||
'readonly' => $pirep->read_only
|
||||
]) }}
|
||||
</div>
|
||||
<p class="text-danger">{{ $errors->first('dpt_airport_id') }}</p>
|
||||
@ -181,7 +180,7 @@ flight reports that have been filed. You've been warned!
|
||||
|
||||
<div class="col-6">
|
||||
{{ Form::label('arr_airport_id', 'Arrival Airport') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
{{ $pirep->arr_airport->name }}
|
||||
(<a href="{{route('frontend.airports.show', [
|
||||
'id' => $pirep->arr_airport->icao
|
||||
@ -192,7 +191,7 @@ flight reports that have been filed. You've been warned!
|
||||
{{ Form::select('arr_airport_id', $airport_list, null, [
|
||||
'class' => 'custom-select select2',
|
||||
'style' => 'width: 100%',
|
||||
'readonly' => $read_only
|
||||
'readonly' => $pirep->read_only
|
||||
]) }}
|
||||
</div>
|
||||
<p class="text-danger">{{ $errors->first('arr_airport_id') }}</p>
|
||||
@ -210,7 +209,7 @@ flight reports that have been filed. You've been warned!
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{{ Form::label('aircraft_id', 'Aircraft') }}
|
||||
@if($read_only)
|
||||
@if($pirep->read_only)
|
||||
<p>{{ $pirep->aircraft->name }}</p>
|
||||
{{ Form::hidden('aircraft_id') }}
|
||||
@else
|
||||
@ -219,7 +218,7 @@ flight reports that have been filed. You've been warned!
|
||||
{{ Form::select('aircraft_id', $aircraft_list, null, [
|
||||
'id' => 'aircraft_select',
|
||||
'class' => 'custom-select select2',
|
||||
'readonly' => $read_only
|
||||
'readonly' => $pirep->read_only
|
||||
]) }}
|
||||
</div>
|
||||
<p class="text-danger">{{ $errors->first('aircraft_id') }}</p>
|
||||
|
@ -9,8 +9,7 @@
|
||||
</p>
|
||||
<h5>
|
||||
<a href="{{ route('frontend.pireps.show', [$pirep->id]) }}">
|
||||
{{ $pirep->airline->code }}{{ $pirep->ident }}
|
||||
</a>
|
||||
{{ $pirep->airline->code }}{{ $pirep->ident }}</a>
|
||||
-
|
||||
{{ $pirep->dpt_airport->name }}
|
||||
(<a href="{{route('frontend.airports.show', [
|
||||
|
@ -1,2 +1,66 @@
|
||||
@each('pireps.pirep_card', $pireps, 'pirep')
|
||||
{{--@each('pireps.pirep_card', $pireps, 'pirep')--}}
|
||||
|
||||
<table class="table table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Flight</th>
|
||||
<th>Departure</th>
|
||||
<th>Arrival</th>
|
||||
<th>Aircraft</th>
|
||||
<th class="text-center">Flight Time</th>
|
||||
<th class="text-center">Status</th>
|
||||
<th>Submitted</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@foreach($pireps as $pirep)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('frontend.pireps.show', [
|
||||
$pirep->id]) }}">{{ $pirep->airline->code }}{{ $pirep->ident }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ $pirep->dpt_airport->name }}
|
||||
(<a href="{{route('frontend.airports.show', [
|
||||
'id' => $pirep->dpt_airport->icao
|
||||
])}}">{{$pirep->dpt_airport->icao}}</a>)
|
||||
</td>
|
||||
<td>
|
||||
{{ $pirep->arr_airport->name }}
|
||||
(<a href="{{route('frontend.airports.show', [
|
||||
'id' => $pirep->arr_airport->icao
|
||||
])}}">{{$pirep->arr_airport->icao}}</a>)
|
||||
</td>
|
||||
<td>{{ $pirep->aircraft->name }}</td>
|
||||
<td class="text-center">
|
||||
{{ (new \App\Support\Units\Time($pirep->flight_time)) }}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if($pirep->state === PirepState::PENDING)
|
||||
<div class="badge badge-warning">
|
||||
@elseif($pirep->state === PirepState::ACCEPTED)
|
||||
<div class="badge badge-success">
|
||||
@elseif($pirep->state === PirepState::REJECTED)
|
||||
<div class="badge badge-danger">
|
||||
@else
|
||||
<div class="badge badge-info">
|
||||
@endif
|
||||
{{ PirepState::label($pirep->state) }}</div>
|
||||
</td>
|
||||
<td>
|
||||
{{ $pirep->submitted_at->diffForHumans() }}
|
||||
</td>
|
||||
<td>
|
||||
@if(!$pirep->read_only)
|
||||
<a href="{{ route('frontend.pireps.edit', [
|
||||
'id' => $pirep->id,
|
||||
]) }}">edit</a>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -15,17 +15,13 @@ https://api.checkwx.com/#metar-decoded
|
||||
{{ $metar['temperature'][$unit_temp] }}
|
||||
°{{strtoupper($unit_temp)}}
|
||||
@if($metar['visibility'])
|
||||
, visibility {{ $metar['visibility'][$unit_dist] }}
|
||||
, visibility {{ $metar['visibility'][$unit_dist] }} {{$unit_dist}}
|
||||
@endif
|
||||
{{$unit_dist}}
|
||||
|
||||
@if($metar['humidity'])
|
||||
,
|
||||
{{ $metar['humidity'] }}% humidity
|
||||
, {{ $metar['humidity'] }}% humidity
|
||||
@endif
|
||||
|
||||
@if($metar['dew_point'])
|
||||
, dew point
|
||||
, dew point
|
||||
{{ $metar['dew_point'][$unit_temp] }}
|
||||
°{{strtoupper($unit_temp)}}
|
||||
@endif
|
||||
|
Loading…
Reference in New Issue
Block a user