@fleetbase/fleetops-engine 0.3.3 → 0.3.4

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.
Files changed (110) hide show
  1. package/addon/components/contact-form-panel.hbs +28 -6
  2. package/addon/components/driver-form-panel.hbs +10 -0
  3. package/addon/components/driver-form-panel.js +51 -0
  4. package/addon/components/driver-panel/details.hbs +1 -5
  5. package/addon/components/driver-panel.hbs +21 -3
  6. package/addon/components/fleet-form-panel.hbs +60 -6
  7. package/addon/components/fleet-panel/details.hbs +1 -1
  8. package/addon/components/fuel-report-form-panel.hbs +84 -8
  9. package/addon/components/fuel-report-form-panel.js +6 -0
  10. package/addon/components/fuel-report-panel/details.hbs +4 -0
  11. package/addon/components/issue-form-panel.hbs +99 -11
  12. package/addon/components/issue-form-panel.js +5 -13
  13. package/addon/components/layout/fleet-ops-sidebar.js +8 -0
  14. package/addon/components/live-map-drawer.hbs +1 -1
  15. package/addon/components/live-map.hbs +1 -1
  16. package/addon/components/modals/driver-assign-vehicle.hbs +2 -11
  17. package/addon/components/modals/driver-assign-vendor.hbs +1 -9
  18. package/addon/components/modals/fuel-report-details.hbs +4 -0
  19. package/addon/components/order/schedule-card.hbs +32 -4
  20. package/addon/components/order/schedule-card.js +155 -5
  21. package/addon/components/place-form-panel.hbs +14 -7
  22. package/addon/components/place-form-panel.js +71 -0
  23. package/addon/components/place-panel/details.hbs +9 -19
  24. package/addon/components/vehicle-form-panel.hbs +67 -7
  25. package/addon/components/vehicle-form-panel.js +37 -0
  26. package/addon/components/vehicle-panel/details.hbs +9 -5
  27. package/addon/components/vehicle-panel.hbs +18 -4
  28. package/addon/components/vendor-form-panel/create-form.hbs +72 -11
  29. package/addon/components/vendor-form-panel/edit-form.hbs +1 -1
  30. package/addon/components/vendor-form-panel.hbs +70 -30
  31. package/addon/components/vendor-form-panel.js +4 -40
  32. package/addon/components/vendor-panel/details.hbs +2 -2
  33. package/addon/components/vendor-panel.hbs +16 -2
  34. package/addon/controllers/management/contacts/index.js +42 -3
  35. package/addon/controllers/management/fleets/index.js +12 -23
  36. package/addon/controllers/management/fuel-reports/index/new.js +1 -1
  37. package/addon/controllers/management/fuel-reports/index.js +73 -20
  38. package/addon/controllers/management/issues/index/new.js +2 -2
  39. package/addon/controllers/management/issues/index.js +65 -45
  40. package/addon/controllers/management/places/index.js +59 -18
  41. package/addon/controllers/management/vehicles/index.js +67 -8
  42. package/addon/controllers/management/vendors/index.js +63 -8
  43. package/addon/controllers/operations/orders/index.js +42 -1
  44. package/addon/routes/management/contacts/index.js +8 -0
  45. package/addon/routes/management/fleets/index.js +8 -2
  46. package/addon/routes/management/fuel-reports/index.js +6 -0
  47. package/addon/routes/management/issues/index.js +9 -1
  48. package/addon/routes/management/places/index.js +11 -1
  49. package/addon/routes/management/vehicles/index.js +3 -3
  50. package/addon/routes/management/vendors/index.js +8 -0
  51. package/addon/routes/operations/scheduler/index.js +1 -1
  52. package/addon/templates/operations/orders/index.hbs +1 -1
  53. package/addon/utils/get-issue-categories.js +30 -0
  54. package/addon/utils/get-issue-types.js +3 -0
  55. package/addon/utils/get-vendor-status-options.js +3 -0
  56. package/addon/utils/get-vendor-type-options.js +41 -0
  57. package/app/utils/get-issue-categories.js +1 -0
  58. package/app/utils/get-issue-types.js +1 -0
  59. package/app/utils/get-vendor-categories.js +1 -0
  60. package/app/utils/get-vendor-status-options.js +1 -0
  61. package/app/utils/get-vendor-type-options.js +1 -0
  62. package/app/utils/get-vendor-types.js +1 -0
  63. package/composer.json +1 -1
  64. package/extension.json +1 -1
  65. package/package.json +4 -4
  66. package/server/migrations/2023_11_09_041807_add_status_column_to_fuel_reports_table.php +32 -0
  67. package/server/migrations/2023_11_15_062814_add_comments_column_and_resolved_at_column_to_vehicle_device_events_table.php +33 -0
  68. package/server/src/Http/Controllers/Api/v1/DriverController.php +2 -2
  69. package/server/src/Http/Controllers/Api/v1/VehicleController.php +2 -2
  70. package/server/src/Http/Controllers/Internal/v1/DriverController.php +5 -13
  71. package/server/src/Http/Controllers/Internal/v1/OrderController.php +1 -3
  72. package/server/src/Http/Filter/ContactFilter.php +10 -0
  73. package/server/src/Http/Filter/FleetFilter.php +8 -6
  74. package/server/src/Http/Filter/FuelReportFilter.php +51 -0
  75. package/server/src/Http/Filter/IssueFilter.php +61 -5
  76. package/server/src/Http/Filter/PlaceFilter.php +48 -6
  77. package/server/src/Http/Filter/VehicleFilter.php +21 -6
  78. package/server/src/Http/Filter/VendorFilter.php +11 -8
  79. package/server/src/Http/Middleware/TransformLocationMiddleware.php +1 -1
  80. package/server/src/Http/Resources/Internal/v1/IntegratedVendorFacilitator.php +17 -18
  81. package/server/src/Http/Resources/v1/Contact.php +16 -19
  82. package/server/src/Http/Resources/v1/CurrentJob.php +13 -16
  83. package/server/src/Http/Resources/v1/Driver.php +59 -57
  84. package/server/src/Http/Resources/v1/Entity.php +30 -33
  85. package/server/src/Http/Resources/v1/FuelReport.php +16 -14
  86. package/server/src/Http/Resources/v1/Order.php +1 -1
  87. package/server/src/Http/Resources/v1/Payload.php +21 -24
  88. package/server/src/Http/Resources/v1/Place.php +27 -30
  89. package/server/src/Http/Resources/v1/Proof.php +13 -16
  90. package/server/src/Http/Resources/v1/PurchaseRate.php +14 -17
  91. package/server/src/Http/Resources/v1/ServiceArea.php +13 -16
  92. package/server/src/Http/Resources/v1/ServiceQuote.php +15 -18
  93. package/server/src/Http/Resources/v1/ServiceRate.php +33 -36
  94. package/server/src/Http/Resources/v1/ServiceRateFee.php +14 -17
  95. package/server/src/Http/Resources/v1/ServiceRateParcelFee.php +9 -12
  96. package/server/src/Http/Resources/v1/TrackingNumber.php +18 -21
  97. package/server/src/Http/Resources/v1/TrackingStatus.php +18 -21
  98. package/server/src/Http/Resources/v1/Vehicle.php +31 -34
  99. package/server/src/Http/Resources/v1/VehicleDevice.php +23 -25
  100. package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +38 -32
  101. package/server/src/Http/Resources/v1/Vendor.php +31 -26
  102. package/server/src/Http/Resources/v1/Zone.php +14 -17
  103. package/server/src/Models/Driver.php +7 -1
  104. package/server/src/Models/FuelReport.php +1 -0
  105. package/server/src/Models/IntegratedVendor.php +6 -1
  106. package/server/src/Models/Order.php +2 -2
  107. package/server/src/Models/Place.php +2 -2
  108. package/server/src/Models/VehicleDeviceEvent.php +1 -0
  109. package/server/src/Models/Vendor.php +1 -1
  110. package/server/src/Observers/DriverObserver.php +15 -0
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
4
 
5
5
  use Fleetbase\Http\Resources\FleetbaseResource;
6
6
  use Fleetbase\Support\Http;
7
+ use Grimzy\LaravelMysqlSpatial\Types\Point;
7
8
 
8
9
  class VehicleWithoutDriver extends FleetbaseResource
9
10
  {
@@ -16,30 +17,35 @@ class VehicleWithoutDriver extends FleetbaseResource
16
17
  */
17
18
  public function toArray($request)
18
19
  {
19
- return array_merge(
20
- $this->getInternalIds(),
21
- [
22
- 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
- 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
- 'internal_id' => $this->internal_id,
26
- 'name' => $this->name,
27
- 'vin' => $this->vin ?? null,
28
- 'photo' => $this->photoUrl ?? null,
29
- 'make' => $this->make ?? null,
30
- 'model' => $this->model ?? null,
31
- 'year' => $this->year ?? null,
32
- 'trim' => $this->trim ?? null,
33
- 'type' => $this->type ?? null,
34
- 'plate_number' => $this->plate_number ?? null,
35
- 'vin_data' => $this->vin_data,
36
- 'status' => $this->status,
37
- 'online' => $this->online,
38
- 'meta' => $this->meta,
39
- 'updated_at' => $this->updated_at,
40
- 'created_at' => $this->created_at,
41
- ]
42
- );
20
+ return [
21
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
22
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
23
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
24
+ 'internal_id' => $this->internal_id,
25
+ 'name' => $this->display_name,
26
+ 'display_name' => $this->when(Http::isInternalRequest(), $this->display_name),
27
+ 'vin' => $this->vin ?? null,
28
+ 'devices' => $this->whenLoaded('devices', $this->devices),
29
+ 'photo_url' => $this->photo_url,
30
+ 'avatar_url' => $this->avatar_url,
31
+ 'make' => $this->make,
32
+ 'model' => $this->model,
33
+ 'year' => $this->year,
34
+ 'trim' => $this->trim,
35
+ 'type' => $this->type,
36
+ 'plate_number' => $this->plate_number,
37
+ 'vin' => $this->vin,
38
+ 'vin_data' => $this->vin_data,
39
+ 'status' => $this->status,
40
+ 'online' => $this->online,
41
+ 'location' => data_get($this, 'location', new Point(0, 0)),
42
+ 'heading' => (int) data_get($this, 'heading', 0),
43
+ 'altitude' => (int) data_get($this, 'altitude', 0),
44
+ 'speed' => (int) data_get($this, 'speed', 0),
45
+ 'meta' => data_get($this, 'meta', []),
46
+ 'updated_at' => $this->updated_at,
47
+ 'created_at' => $this->created_at,
48
+ ];
43
49
  }
44
50
 
45
51
  /**
@@ -53,14 +59,14 @@ class VehicleWithoutDriver extends FleetbaseResource
53
59
  'id' => $this->public_id,
54
60
  'internal_id' => $this->internal_id,
55
61
  'name' => $this->name,
56
- 'vin' => $this->vin ?? null,
57
- 'photo' => $this->photoUrl ?? null,
58
- 'make' => $this->make ?? null,
59
- 'model' => $this->model ?? null,
60
- 'year' => $this->year ?? null,
61
- 'trim' => $this->trim ?? null,
62
- 'type' => $this->type ?? null,
63
- 'plate_number' => $this->plate_number ?? null,
62
+ 'vin' => data_get($this, 'vin'),
63
+ 'photo' => data_get($this, 'photoUrl'),
64
+ 'make' => data_get($this, 'make'),
65
+ 'model' => data_get($this, 'model'),
66
+ 'year' => data_get($this, 'year'),
67
+ 'trim' => data_get($this, 'trim'),
68
+ 'type' => data_get($this, 'type'),
69
+ 'plate_number' => data_get($this, 'plate_number'),
64
70
  'vin_data' => $this->vin_data,
65
71
  'status' => $this->status,
66
72
  'online' => $this->online,
@@ -17,32 +17,33 @@ class Vendor extends FleetbaseResource
17
17
  */
18
18
  public function toArray($request)
19
19
  {
20
- return array_merge(
21
- $this->getInternalIds(),
22
- [
23
- 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
24
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
25
- 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
26
- 'place_uuid' => $this->when(Http::isInternalRequest(), $this->place_uuid),
27
- 'connect_company_uuid' => $this->when(Http::isInternalRequest(), $this->connect_company_uuid),
28
- 'logo_uuid' => $this->when(Http::isInternalRequest(), $this->logo_uuid),
29
- 'type_uuid' => $this->when(Http::isInternalRequest(), $this->type_uuid),
30
- 'internal_id' => $this->internal_id,
31
- 'business_id' => $this->business_id,
32
- 'name' => $this->name,
33
- 'email' => $this->email,
34
- 'phone' => $this->phone,
35
- 'photo_url' => Utils::or($this, ['logo_url', 'photo_url']),
36
- 'place' => $this->whenLoaded('place', new Place($this->place)),
37
- 'address' => $this->when(Http::isInternalRequest(), data_get($this, 'place.address')),
38
- 'address_street' => $this->when(Http::isInternalRequest(), data_get($this, 'place.street1')),
39
- 'type' => $this->type,
40
- 'meta' => $this->meta ?? [],
41
- 'slug' => $this->slug,
42
- 'updated_at' => $this->updated_at,
43
- 'created_at' => $this->created_at,
44
- ]
45
- );
20
+ return [
21
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
22
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
23
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
24
+ 'place_uuid' => $this->when(Http::isInternalRequest(), $this->place_uuid),
25
+ 'connect_company_uuid' => $this->when(Http::isInternalRequest(), $this->connect_company_uuid),
26
+ 'logo_uuid' => $this->when(Http::isInternalRequest(), $this->logo_uuid),
27
+ 'type_uuid' => $this->when(Http::isInternalRequest(), $this->type_uuid),
28
+ 'internal_id' => $this->internal_id,
29
+ 'business_id' => $this->business_id,
30
+ 'name' => $this->name,
31
+ 'email' => $this->email,
32
+ 'phone' => $this->phone,
33
+ 'logo_url' => $this->logo_url,
34
+ 'photo_url' => Utils::or($this, ['logo_url', 'photo_url']),
35
+ 'place' => $this->whenLoaded('place', new Place($this->place)),
36
+ 'address' => $this->when(Http::isInternalRequest(), data_get($this, 'place.address')),
37
+ 'address_street' => $this->when(Http::isInternalRequest(), data_get($this, 'place.street1')),
38
+ 'country' => $this->country,
39
+ 'type' => $this->type,
40
+ 'meta' => $this->meta ?? [],
41
+ 'status' => $this->status,
42
+ 'slug' => $this->slug,
43
+ 'updated_at' => $this->updated_at,
44
+ 'created_at' => $this->created_at,
45
+ 'website_url' => $this->website_url,
46
+ ];
46
47
  }
47
48
 
48
49
  /**
@@ -58,15 +59,19 @@ class Vendor extends FleetbaseResource
58
59
  'name' => $this->name,
59
60
  'email' => $this->email,
60
61
  'phone' => $this->phone,
62
+ 'logo_url' => $this->logo_url,
61
63
  'photo_url' => Utils::or($this, ['logo_url', 'photo_url']),
62
64
  'place' => $this->whenLoaded('place', new Place($this->place)),
63
65
  'address' => data_get($this, 'place.address'),
64
66
  'address_street' => data_get($this, 'place.street1'),
67
+ 'country' => $this->country,
65
68
  'type' => $this->type,
66
69
  'meta' => $this->meta ?? [],
70
+ 'status' => $this->status,
67
71
  'slug' => $this->slug,
68
72
  'updated_at' => $this->updated_at,
69
73
  'created_at' => $this->created_at,
74
+ 'website_url' => $this->website_url,
70
75
  ];
71
76
  }
72
77
  }
@@ -18,23 +18,20 @@ class Zone extends FleetbaseResource
18
18
  */
19
19
  public function toArray($request)
20
20
  {
21
- return array_merge(
22
- $this->getInternalIds(),
23
- [
24
- 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
25
- 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
26
- 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
27
- 'name' => $this->name,
28
- 'description' => $this->description,
29
- 'coordinates' => $this->when($this->border instanceof Polygon, Utils::getCoordinatesFromPolygon($this->border), []),
30
- 'border' => $this->border,
31
- 'color' => $this->color,
32
- 'stroke_color' => $this->stroke_color,
33
- 'status' => $this->status,
34
- 'updated_at' => $this->updated_at,
35
- 'created_at' => $this->created_at,
36
- ]
37
- );
21
+ return [
22
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
+ 'name' => $this->name,
26
+ 'description' => $this->description,
27
+ 'coordinates' => $this->when($this->border instanceof Polygon, Utils::getCoordinatesFromPolygon($this->border), []),
28
+ 'border' => $this->border,
29
+ 'color' => $this->color,
30
+ 'stroke_color' => $this->stroke_color,
31
+ 'status' => $this->status,
32
+ 'updated_at' => $this->updated_at,
33
+ 'created_at' => $this->created_at,
34
+ ];
38
35
  }
39
36
 
40
37
  /**
@@ -88,6 +88,13 @@ class Driver extends Model
88
88
  'status',
89
89
  ];
90
90
 
91
+ /**
92
+ * The attributes that are guarded and not mass assignable.
93
+ *
94
+ * @var array
95
+ */
96
+ protected $guarded = [];
97
+
91
98
  /**
92
99
  * The attributes that are spatial columns.
93
100
  *
@@ -101,7 +108,6 @@ class Driver extends Model
101
108
  * @var array
102
109
  */
103
110
  protected $casts = [
104
- 'meta' => Json::class,
105
111
  'location' => Point::class,
106
112
  'online' => 'boolean',
107
113
  ];
@@ -61,6 +61,7 @@ class FuelReport extends Model
61
61
  'volume',
62
62
  'metric_unit',
63
63
  'meta',
64
+ 'status',
64
65
  ];
65
66
 
66
67
  /**
@@ -69,7 +69,7 @@ class IntegratedVendor extends Model
69
69
  *
70
70
  * @var array
71
71
  */
72
- protected $appends = ['name', 'status', 'type', 'photo_url', 'service_types', 'supported_countries', 'provider_settings'];
72
+ protected $appends = ['name', 'status', 'type', 'photo_url', 'logo_url', 'service_types', 'supported_countries', 'provider_settings'];
73
73
 
74
74
  /**
75
75
  * The attributes excluded from the model's JSON form.
@@ -207,6 +207,11 @@ class IntegratedVendor extends Model
207
207
  return $this->provider()->getLogo();
208
208
  }
209
209
 
210
+ public function getLogoUrlAttribute()
211
+ {
212
+ return $this->provider()->getLogo();
213
+ }
214
+
210
215
  public function getStatusAttribute()
211
216
  {
212
217
  return 'active';
@@ -312,7 +312,7 @@ class Order extends Model
312
312
  */
313
313
  public function driverAssigned()
314
314
  {
315
- return $this->belongsTo(Driver::class)->without(['devices', 'vehicle', 'vendor'])->withoutGlobalScopes();
315
+ return $this->belongsTo(Driver::class)->without(['devices', 'vendor']);
316
316
  }
317
317
 
318
318
  /**
@@ -320,7 +320,7 @@ class Order extends Model
320
320
  */
321
321
  public function driver()
322
322
  {
323
- return $this->belongsTo(Driver::class)->without(['devices', 'vehicle', 'vendor'])->withoutGlobalScopes();
323
+ return $this->belongsTo(Driver::class)->without(['devices', 'vendor']);
324
324
  }
325
325
 
326
326
  /**
@@ -213,7 +213,7 @@ class Place extends Model
213
213
  }
214
214
 
215
215
  if (empty($this->country) && $address) {
216
- $this->setAttribute('country', $address->getCountry()->getCode());
216
+ $this->setAttribute('country', $address->getCountry() instanceof \Geocoder\Model\Country ? $address->getCountry()->getCode() : null);
217
217
  }
218
218
 
219
219
  if ($coordinates = $address->getCoordinates()) {
@@ -243,7 +243,7 @@ class Place extends Model
243
243
  $attributes['neighborhood'] = $address->getNeighborhood();
244
244
  $attributes['city'] = $address->getLocality();
245
245
  $attributes['building'] = $address->getStreetNumber();
246
- $attributes['country'] = $address->getCountry()->getCode();
246
+ $attributes['country'] = $address->getCountry() instanceof \Geocoder\Model\Country ? $address->getCountry()->getCode() : null;
247
247
  $attributes['location'] = new \Grimzy\LaravelMysqlSpatial\Types\Point($coordinates->getLatitude(), $coordinates->getLongitude());
248
248
 
249
249
  return $attributes;
@@ -44,6 +44,7 @@ class VehicleDeviceEvent extends Model
44
44
  'state',
45
45
  'code',
46
46
  'reason',
47
+ 'comment'
47
48
  ];
48
49
  /**
49
50
  * The attributes that should be cast to native types.
@@ -72,7 +72,7 @@ class Vendor extends Model
72
72
  *
73
73
  * @var array
74
74
  */
75
- protected $searchableColumns = ['name', 'email', 'business_id', 'company.name'];
75
+ protected $searchableColumns = ['name', 'email', 'business_id', 'connectCompany.name'];
76
76
 
77
77
  /**
78
78
  * Dynamic attributes that are appended to object.
@@ -3,6 +3,7 @@
3
3
  namespace Fleetbase\FleetOps\Observers;
4
4
 
5
5
  use Fleetbase\FleetOps\Models\Driver;
6
+ use Fleetbase\FleetOps\Models\Order;
6
7
  use Fleetbase\Models\User;
7
8
  use Grimzy\LaravelMysqlSpatial\Types\Point;
8
9
 
@@ -21,6 +22,17 @@ class DriverObserver
21
22
  }
22
23
  }
23
24
 
25
+ /**
26
+ * Handle the Driver "deleting" event.
27
+ *
28
+ * @return void
29
+ */
30
+ public function deleting(Driver $driver)
31
+ {
32
+ // unassign the vehicle from the driver
33
+ $driver->vehicle_uuid = null;
34
+ }
35
+
24
36
  /**
25
37
  * Handle the Driver "deleted" event.
26
38
  *
@@ -30,5 +42,8 @@ class DriverObserver
30
42
  {
31
43
  // if the driver is deleted, delete their user account assosciated as well
32
44
  User::where(['uuid' => $driver->user_uuid, 'type' => 'driver'])->delete();
45
+
46
+ // also unassign them from any order they are assigned to
47
+ Order::where(['driver_assigned_uui' => $driver->uuid])->update(['driver_assigned_uui' => null]);
33
48
  }
34
49
  }