@fleetbase/fleetops-engine 0.4.19 → 0.4.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/components/activity-event-selector.js +1 -1
- package/addon/components/activity-form-panel.js +2 -2
- package/addon/components/activity-logic-builder.js +1 -1
- package/addon/components/admin/navigator-app.hbs +77 -1
- package/addon/components/admin/navigator-app.js +65 -12
- package/addon/components/contact-form-panel.js +2 -2
- package/addon/components/contact-panel.js +2 -2
- package/addon/components/custom-field-form-panel.js +2 -2
- package/addon/components/driver-form-panel.js +2 -2
- package/addon/components/driver-panel.js +2 -2
- package/addon/components/edit-order-route-panel.js +2 -2
- package/addon/components/fleet-form-panel.js +2 -2
- package/addon/components/fleet-panel/driver-listing.js +1 -1
- package/addon/components/fleet-panel/vehicle-listing.js +1 -1
- package/addon/components/fleet-panel.js +2 -2
- package/addon/components/fuel-report-form-panel.js +2 -2
- package/addon/components/fuel-report-panel.js +2 -2
- package/addon/components/issue-form-panel.js +2 -2
- package/addon/components/issue-panel.js +2 -2
- package/addon/components/live-map-drawer.js +2 -2
- package/addon/components/order-config-manager/activity-flow.js +1 -1
- package/addon/components/order-config-manager/custom-fields.js +1 -1
- package/addon/components/order-config-manager/entities.js +1 -1
- package/addon/components/order-config-manager-overlay.js +1 -1
- package/addon/components/order-config-manager.js +2 -2
- package/addon/components/place-form-panel.js +2 -2
- package/addon/components/place-panel.js +2 -2
- package/addon/components/vehicle-form-panel.js +2 -2
- package/addon/components/vehicle-panel.js +2 -2
- package/addon/components/vendor-form-panel/create-form.js +1 -1
- package/addon/components/vendor-form-panel.js +2 -2
- package/addon/components/vendor-panel.js +2 -2
- package/composer.json +2 -2
- package/extension.json +1 -1
- package/package.json +2 -2
- package/server/config/fleetops.php +19 -0
- package/server/src/Console/Commands/DispatchAdhocOrders.php +44 -30
- package/server/src/Console/Commands/DispatchOrders.php +27 -21
- package/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php +96 -0
- package/server/src/Console/Commands/TrackOrderDistanceAndTime.php +30 -15
- package/server/src/Http/Controllers/Api/v1/DriverController.php +0 -1
- package/server/src/Http/Controllers/Api/v1/OrderController.php +49 -2
- package/server/src/Http/Controllers/Internal/v1/SettingController.php +20 -0
- package/server/src/Http/Filter/ContactFilter.php +5 -0
- package/server/src/Http/Filter/DriverFilter.php +5 -0
- package/server/src/Http/Filter/EntityFilter.php +18 -0
- package/server/src/Http/Filter/FleetFilter.php +5 -0
- package/server/src/Http/Filter/FuelReportFilter.php +5 -0
- package/server/src/Http/Filter/IssueFilter.php +5 -0
- package/server/src/Http/Filter/OrderConfigFilter.php +5 -0
- package/server/src/Http/Filter/OrderFilter.php +5 -0
- package/server/src/Http/Filter/PayloadFilter.php +18 -0
- package/server/src/Http/Filter/PlaceFilter.php +5 -0
- package/server/src/Http/Filter/PurchaseRateFilter.php +18 -0
- package/server/src/Http/Filter/ServiceAreaFilter.php +5 -0
- package/server/src/Http/Filter/ServiceQuoteFilter.php +5 -0
- package/server/src/Http/Filter/ServiceRateFilter.php +5 -0
- package/server/src/Http/Filter/TrackingNumberFilter.php +18 -0
- package/server/src/Http/Filter/TrackingStatusFilter.php +5 -0
- package/server/src/Http/Filter/VehicleFilter.php +5 -0
- package/server/src/Http/Filter/VendorFilter.php +5 -0
- package/server/src/Http/Filter/ZoneFilter.php +5 -0
- package/server/src/Http/Resources/v1/Order.php +1 -0
- package/server/src/Models/Driver.php +1 -1
- package/server/src/Models/Order.php +2 -4
- package/server/src/Providers/FleetOpsServiceProvider.php +4 -3
- package/server/src/Support/Algo.php +0 -24
- package/server/src/Support/DistanceMatrix.php +9 -1
- package/server/src/Support/OSRM.php +7 -0
- package/server/src/Support/Utils.php +216 -169
- package/server/src/routes.php +3 -3
- package/translations/en-us.yaml +3 -0
- package/addon/utils/apply-context-component-arguments.js +0 -33
- package/addon/utils/context-component-callback.js +0 -16
- package/app/utils/apply-context-component-arguments.js +0 -1
- package/app/utils/context-component-callback.js +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Filter;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Filter\Filter;
|
|
6
|
+
|
|
7
|
+
class TrackingNumberFilter extends Filter
|
|
8
|
+
{
|
|
9
|
+
public function queryForInternal()
|
|
10
|
+
{
|
|
11
|
+
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public function queryForPublic()
|
|
15
|
+
{
|
|
16
|
+
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -11,6 +11,11 @@ class TrackingStatusFilter extends Filter
|
|
|
11
11
|
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
public function queryForPublic()
|
|
15
|
+
{
|
|
16
|
+
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
public function trackingNumber(string $trackingNumber)
|
|
15
20
|
{
|
|
16
21
|
$this->builder->whereHas('trackingNumber', function ($query) use ($trackingNumber) {
|
|
@@ -12,6 +12,11 @@ class VehicleFilter extends Filter
|
|
|
12
12
|
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
public function queryForPublic()
|
|
16
|
+
{
|
|
17
|
+
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
public function query(?string $query)
|
|
16
21
|
{
|
|
17
22
|
$this->builder->search($query);
|
|
@@ -12,6 +12,11 @@ class VendorFilter extends Filter
|
|
|
12
12
|
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
public function queryForPublic()
|
|
16
|
+
{
|
|
17
|
+
$this->builder->where('company_uuid', $this->session->get('company'));
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
public function query(?string $searchQuery)
|
|
16
21
|
{
|
|
17
22
|
$this->builder->search($searchQuery);
|
|
@@ -39,6 +39,7 @@ class Order extends FleetbaseResource
|
|
|
39
39
|
'service_quote_uuid' => $this->when(Http::isInternalRequest(), $this->service_quote_uuid),
|
|
40
40
|
'has_driver_assigned' => $this->when(Http::isInternalRequest(), $this->has_driver_assigned),
|
|
41
41
|
'is_scheduled' => $this->when(Http::isInternalRequest(), $this->is_scheduled),
|
|
42
|
+
'order_config_id' => $this->when(Http::isInternalRequest(), $this->order_config_id),
|
|
42
43
|
'order_config' => $this->when(Http::isInternalRequest(), $this->whenLoaded('orderConfig', $this->orderConfig), data_get($this->orderConfig, 'public_id')),
|
|
43
44
|
'custom_field_values' => $this->when(Http::isInternalRequest(), $this->customFieldValues),
|
|
44
45
|
'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
|
|
@@ -157,7 +157,7 @@ class Driver extends Model
|
|
|
157
157
|
*
|
|
158
158
|
* @var array
|
|
159
159
|
*/
|
|
160
|
-
protected $filterParams = ['vendor', 'facilitator', 'customer', 'fleet', 'photo_uuid', 'avatar_uuid'];
|
|
160
|
+
protected $filterParams = ['vendor', 'facilitator', 'customer', 'fleet', 'photo_uuid', 'avatar_uuid', 'avatar_value'];
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* Get the activity log options for the model.
|
|
@@ -1505,13 +1505,11 @@ class Order extends Model
|
|
|
1505
1505
|
*
|
|
1506
1506
|
* @return Order the updated Order instance
|
|
1507
1507
|
*/
|
|
1508
|
-
public function setDistanceAndTime(): Order
|
|
1508
|
+
public function setDistanceAndTime($options = []): Order
|
|
1509
1509
|
{
|
|
1510
1510
|
$origin = $this->getCurrentOriginPosition();
|
|
1511
1511
|
$destination = $this->getDestinationPosition();
|
|
1512
|
-
|
|
1513
|
-
$matrix = Utils::getDrivingDistanceAndTime($origin, $destination);
|
|
1514
|
-
|
|
1512
|
+
$matrix = Utils::getDrivingDistanceAndTime($origin, $destination, $options);
|
|
1515
1513
|
if ($origin === null || $destination === null) {
|
|
1516
1514
|
return $this;
|
|
1517
1515
|
}
|
|
@@ -48,6 +48,7 @@ class FleetOpsServiceProvider extends CoreServiceProvider
|
|
|
48
48
|
\Fleetbase\FleetOps\Console\Commands\TrackOrderDistanceAndTime::class,
|
|
49
49
|
\Fleetbase\FleetOps\Console\Commands\FixDriverCompanies::class,
|
|
50
50
|
\Fleetbase\FleetOps\Console\Commands\FixLegacyOrderConfigs::class,
|
|
51
|
+
\Fleetbase\FleetOps\Console\Commands\FixInvalidPolymorphicRelationTypeNamespaces::class,
|
|
51
52
|
];
|
|
52
53
|
|
|
53
54
|
/**
|
|
@@ -80,9 +81,9 @@ class FleetOpsServiceProvider extends CoreServiceProvider
|
|
|
80
81
|
$this->registerObservers();
|
|
81
82
|
$this->registerCommands();
|
|
82
83
|
$this->scheduleCommands(function ($schedule) {
|
|
83
|
-
$schedule->command('fleetops:dispatch-orders')->everyMinute();
|
|
84
|
-
$schedule->command('fleetops:dispatch-adhoc')->everyMinute();
|
|
85
|
-
$schedule->command('fleetops:update-estimations')->
|
|
84
|
+
$schedule->command('fleetops:dispatch-orders')->everyMinute()->withoutOverlapping()->storeOutputInDb();
|
|
85
|
+
$schedule->command('fleetops:dispatch-adhoc')->everyMinute()->withoutOverlapping()->storeOutputInDb();
|
|
86
|
+
$schedule->command('fleetops:update-estimations')->everyFiveMinutes()->withoutOverlapping();
|
|
86
87
|
});
|
|
87
88
|
$this->registerNotifications();
|
|
88
89
|
$this->registerExpansionsFrom(__DIR__ . '/../Expansions');
|
|
@@ -28,28 +28,4 @@ class Algo
|
|
|
28
28
|
|
|
29
29
|
return $result;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Calculates driving distance and time using Google distance matric.
|
|
34
|
-
*
|
|
35
|
-
* @return array
|
|
36
|
-
*/
|
|
37
|
-
public static function calculateDrivingDistanceAndTime($lat1, $long1, $lat2, $long2)
|
|
38
|
-
{
|
|
39
|
-
$url =
|
|
40
|
-
'https://maps.googleapis.com/maps/api/distancematrix/json?origins=' . $lat1 . ',' . $long1 . '&destinations=' . $lat2 . ',' . $long2 . '&mode=driving&key=' . config('services.google.key');
|
|
41
|
-
$ch = curl_init();
|
|
42
|
-
curl_setopt($ch, CURLOPT_URL, $url);
|
|
43
|
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
44
|
-
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
|
|
45
|
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
46
|
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
47
|
-
$response = curl_exec($ch);
|
|
48
|
-
curl_close($ch);
|
|
49
|
-
$response_a = json_decode($response, true);
|
|
50
|
-
$dist = $response_a['rows'][0]['elements'][0]['distance']['value'];
|
|
51
|
-
$time = $response_a['rows'][0]['elements'][0]['duration']['value'];
|
|
52
|
-
|
|
53
|
-
return ['distance' => $dist, 'time' => $time];
|
|
54
|
-
}
|
|
55
31
|
}
|
|
@@ -14,7 +14,7 @@ namespace Fleetbase\FleetOps\Support;
|
|
|
14
14
|
* @license https://opensource.org/licenses/MIT MIT License
|
|
15
15
|
* @author Ronald A. Richardson
|
|
16
16
|
*/
|
|
17
|
-
class DistanceMatrix
|
|
17
|
+
class DistanceMatrix implements \JsonSerializable
|
|
18
18
|
{
|
|
19
19
|
public ?float $distance;
|
|
20
20
|
public ?float $time;
|
|
@@ -24,4 +24,12 @@ class DistanceMatrix
|
|
|
24
24
|
$this->distance = $distance;
|
|
25
25
|
$this->time = $time;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
public function jsonSerialize()
|
|
29
|
+
{
|
|
30
|
+
return [
|
|
31
|
+
'distance' => $this->distance,
|
|
32
|
+
'time' => $this->time,
|
|
33
|
+
];
|
|
34
|
+
}
|
|
27
35
|
}
|
|
@@ -35,6 +35,13 @@ class OSRM
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
$coordinates = "{$start->getLng()},{$start->getLat()};{$end->getLng()},{$end->getLat()}";
|
|
38
|
+
|
|
39
|
+
return static::getRouteFromCoordinatesString($coordinates, $queryParameters);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static function getRouteFromCoordinatesString(string $coordinates, array $queryParameters = [])
|
|
43
|
+
{
|
|
44
|
+
$cacheKey = 'getRouteFromCoordinatesString:' . md5($coordinates . serialize($queryParameters));
|
|
38
45
|
$url = self::$baseUrl . "/route/v1/driving/{$coordinates}";
|
|
39
46
|
$response = Http::get($url, $queryParameters);
|
|
40
47
|
$data = $response->json();
|