-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelpers.php
More file actions
186 lines (170 loc) · 6.18 KB
/
Copy pathhelpers.php
File metadata and controls
186 lines (170 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
use \App\Models\Enums\AircraftState;
use \App\Models\Enums\AircraftStatus;
use \App\Models\Enums\PirepState;
use \App\Models\Enums\UserState;
use \Nwidart\Modules\Facades\Module;
// Check Disposable Modules
// Return boolean
if (!function_exists('Dispo_Modules')) {
function Dispo_Modules($module)
{
$module_enabled = false;
$dispo_module = Module::find($module);
if($dispo_module) {
$module_enabled = $dispo_module->isEnabled();
}
return $module_enabled;
}
}
// Below Functions Will Be Used If DisposableTools Module Is Not Installed or Disabled
// Same functions are defined there, this is just a safety backup
// If you need to edit any of these functions, please use the main module helper file instead of this
// If it gets uninstalled or disabled, this module will work as expected with the functions below
if(!Dispo_Modules('DisposableTools'))
{
// Format Pirep State Badge
// Return formatted string (with html tags)
if (!function_exists('Dispo_PirepBadge')) {
function Dispo_PirepBadge($pirepstate)
{
$color = 'primary';
if($pirepstate === 0 || $pirepstate === 5) { $color = 'info'; }
elseif($pirepstate === 1) { $color = 'secondary'; }
elseif($pirepstate === 2) { $color = 'success'; }
elseif($pirepstate === 3) { $color = 'warning'; }
elseif($pirepstate === 4 || $pirepstate === 6) { $color = 'danger'; }
$result = "<span class='badge badge-".$color."'>".PirepState::label($pirepstate)."</span>";
return $result;
}
}
// Format User State Badge
// Return formatted string (with html tags)
if (!function_exists('Dispo_UserStateBadge')) {
function Dispo_UserStateBadge($state)
{
$color = 'primary';
if($state === 0) { $color = 'secondary'; }
elseif($state === 1) { $color = 'success'; }
elseif($state === 3) { $color = 'warning'; }
elseif($state === 2 || $state === 4 || $state === 5) { $color = 'danger'; }
$result = "<span class='badge badge-".$color."'>".UserState::label($state)."</span>";
return $result;
}
}
// Format Aircraft State Badge
// return formatted string (with html tags)
if (!function_exists('Dispo_AcStateBadge')) {
function Dispo_AcStateBadge($state)
{
$color = 'primary';
if($state === 0) { $color = 'success'; }
elseif($state === 1) { $color = 'info'; }
elseif($state === 2) { $color = 'warning'; }
$result = "<span class='badge badge-".$color."'>".AircraftState::label($state)."</span>";
return $result;
}
}
// Format Aircraft Status Badge
// return formatted string (with html tags)
if (!function_exists('Dispo_AcStatusBadge')) {
function Dispo_AcStatusBadge($status)
{
$color = 'primary';
if($status === 'A') { $color = 'success'; }
elseif($status === 'S' || $status === 'R') { $color = 'warning'; }
elseif($status === 'C' || $status === 'W') { $color = 'danger'; }
$result = "<span class='badge badge-".$color."'>".AircraftStatus::label($status)."</span>";
return $result;
}
}
// Format RouteCode
// Return string
if (!function_exists('Dispo_RouteCode')) {
function Dispo_RouteCode($route_code)
{
if(Dispo_Modules('DisposableTours'))
{
$route_code = Dsp_TourName($route_code);
return $route_code;
}
if($route_code === 'H'){ $route_code = 'Historic' ;}
// You can add more text for your own codes like below
// elseif($route_code === 'AJ'){ $route_code = 'AnadoluJet' ;}
return $route_code;
}
}
// Generic Value Rounder with Weight Converter
// Conversion part designed for SimBrief Briefing Blade
// Return Numeric String
if (!function_exists('Dispo_Round')) {
function Dispo_Round($value, $round, $conv = null)
{
if($conv === 'lbs') { $value = $value * 2.20462262185; }
elseif($conv === 'kg') { $value = $value / 2.20462262185; }
elseif($conv === 'kgs') { $value = $value / 2.20462262185; }
$value = floatval($value);
$rmv = fmod($value,$round);
$rmv = $round - $rmv;
$rounded = $value + $rmv;
return $rounded;
}
}
// Generic Fuel Cost Converter
// Return formatted string
if (!function_exists('Dispo_FuelCost')) {
function Dispo_FuelCost($cost)
{
$unit = setting('units.fuel');
$currency = setting('units.currency');
if($unit === 'kg') { $cost = $cost / 2.20462262185; }
$cost = number_format($cost,3)." ".$currency."/".$unit;
return $cost;
}
}
// Generic Fuel Weight Converter
// Return formatted string
if (!function_exists('Dispo_Fuel')) {
function Dispo_Fuel($fuel)
{
$unit = setting('units.fuel');
if($unit === 'kg') { $fuel = $fuel / 2.20462262185; }
$fuel = number_format($fuel)." ".setting('units.fuel');
return $fuel;
}
}
// Generic Weight Converter
// Return formatted string
if (!function_exists('Dispo_Weight')) {
function Dispo_Weight($weight)
{
$unit = setting('units.weight');
if($unit === 'kg') { $weight = $weight / 2.20462262185; }
$weight = number_format($weight)." ".setting('units.weight');
return $weight;
}
}
// Generic Distance Converter
// Return formatted string
if (!function_exists('Dispo_Distance')) {
function Dispo_Distance($distance)
{
$unit = setting('units.distance');
if($unit === 'km') { $distance = $distance * 1.852; }
elseif($unit === 'mi') { $distance = $distance * 1.15078; }
$distance = number_format($distance)." ".$unit;
return $distance;
}
}
// Generic Altitude Converter
// Return formatted string
if (!function_exists('Dispo_Altitude')) {
function Dispo_Altitude($altitude)
{
$unit = setting('units.altitude');
if($unit === 'm') { $altitude = $altitude / 3.280840; }
$altitude = number_format($altitude)." ".$unit;
return $altitude;
}
}
}