diff --git a/addon/controllers/management/contacts/index.js b/addon/controllers/management/contacts/index.js
index f698e490..8dc3e4ca 100644
--- a/addon/controllers/management/contacts/index.js
+++ b/addon/controllers/management/contacts/index.js
@@ -317,7 +317,8 @@ export default class ManagementContactsIndexController extends BaseController {
* @void
*/
@action exportContacts() {
- this.crud.export('contact');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('contact', { params: { selections } });
}
/**
diff --git a/addon/controllers/management/drivers/index.js b/addon/controllers/management/drivers/index.js
index a7edc926..3a0c18a9 100644
--- a/addon/controllers/management/drivers/index.js
+++ b/addon/controllers/management/drivers/index.js
@@ -508,7 +508,8 @@ export default class ManagementDriversIndexController extends BaseController {
* @void
*/
@action exportDrivers() {
- this.crud.export('driver');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('driver', { params: { selections } });
}
/**
diff --git a/addon/controllers/management/fleets/index.js b/addon/controllers/management/fleets/index.js
index 48f9f7c8..e4798417 100644
--- a/addon/controllers/management/fleets/index.js
+++ b/addon/controllers/management/fleets/index.js
@@ -405,7 +405,8 @@ export default class ManagementFleetsIndexController extends BaseController {
* @void
*/
@action exportFleets() {
- this.crud.export('fleet');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('fleet', { params: { selections } });
}
/**
diff --git a/addon/controllers/management/issues/index.js b/addon/controllers/management/issues/index.js
index c5157fa3..7b4c440d 100644
--- a/addon/controllers/management/issues/index.js
+++ b/addon/controllers/management/issues/index.js
@@ -391,7 +391,8 @@ export default class ManagementIssuesIndexController extends BaseController {
* @void
*/
@action exportIssues() {
- this.crud.export('issue');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('issue', { params: { selections } });
}
/**
diff --git a/addon/controllers/management/places/index.js b/addon/controllers/management/places/index.js
index d221e5c2..770104bb 100644
--- a/addon/controllers/management/places/index.js
+++ b/addon/controllers/management/places/index.js
@@ -350,7 +350,8 @@ export default class ManagementPlacesIndexController extends BaseController {
* @void
*/
@action exportPlaces() {
- this.crud.export('place');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('place', { params: { selections } });
}
/**
diff --git a/addon/controllers/management/vehicles/index.js b/addon/controllers/management/vehicles/index.js
index f0367131..8345db89 100644
--- a/addon/controllers/management/vehicles/index.js
+++ b/addon/controllers/management/vehicles/index.js
@@ -467,7 +467,8 @@ export default class ManagementVehiclesIndexController extends BaseController {
* @void
*/
@action exportVehicles() {
- this.crud.export('vehicle');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('vehicle', { params: { selections } });
}
/**
diff --git a/addon/controllers/management/vendors/index.js b/addon/controllers/management/vendors/index.js
index 3ca5b9ac..6f8278aa 100644
--- a/addon/controllers/management/vendors/index.js
+++ b/addon/controllers/management/vendors/index.js
@@ -365,7 +365,8 @@ export default class ManagementVendorsIndexController extends BaseController {
* @void
*/
@action exportVendors() {
- this.crud.export('vendor');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('vendor', { params: { selections } });
}
/**
diff --git a/addon/controllers/operations/orders/index.js b/addon/controllers/operations/orders/index.js
index 8f0af035..0d41d8cf 100644
--- a/addon/controllers/operations/orders/index.js
+++ b/addon/controllers/operations/orders/index.js
@@ -822,7 +822,8 @@ export default class OperationsOrdersIndexController extends BaseController {
* @memberof OperationsOrdersIndexController
*/
@action exportOrders() {
- this.crud.export('order');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('order', { params: { selections } });
}
/**
diff --git a/addon/controllers/operations/service-rates/index.js b/addon/controllers/operations/service-rates/index.js
index a062c296..a6de92c2 100644
--- a/addon/controllers/operations/service-rates/index.js
+++ b/addon/controllers/operations/service-rates/index.js
@@ -249,7 +249,8 @@ export default class OperationsServiceRatesIndexController extends BaseControlle
* @void
*/
@action exportServiceRates() {
- this.crud.export('service-rate');
+ const selections = this.table.selectedRows.map((_) => _.id);
+ this.crud.export('service-rate', { params: { selections } });
}
/**
diff --git a/addon/templates/operations/service-rates/index.hbs b/addon/templates/operations/service-rates/index.hbs
index 04b62774..79a354bb 100644
--- a/addon/templates/operations/service-rates/index.hbs
+++ b/addon/templates/operations/service-rates/index.hbs
@@ -1,13 +1,6 @@
-
+
{{#if (safe-has this.table "selectedRows")}}
@@ -21,7 +14,7 @@
{{/if}}
-
+
diff --git a/composer.json b/composer.json
index 6d7e07d6..6eab47e9 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "fleetbase/fleetops-api",
- "version": "0.4.28",
+ "version": "0.4.29",
"description": "Fleet & Transport Management Extension for Fleetbase",
"keywords": [
"fleetbase-extension",
@@ -22,7 +22,7 @@
],
"require": {
"php": "^8.0",
- "fleetbase/core-api": "^1.4.23",
+ "fleetbase/core-api": "^1.4.24",
"barryvdh/laravel-dompdf": "^2.0",
"brick/geo": "0.7.2",
"cknow/laravel-money": "^7.1",
diff --git a/extension.json b/extension.json
index 6499bd8d..67aa2dee 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
{
"name": "Fleet-Ops",
- "version": "0.4.28",
+ "version": "0.4.29",
"description": "Fleet & Transport Management Extension for Fleetbase",
"repository": "https://github.com/fleetbase/fleetops",
"license": "MIT",
diff --git a/package.json b/package.json
index a99ae283..d5b5f628 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/fleetops-engine",
- "version": "0.4.28",
+ "version": "0.4.29",
"description": "Fleet & Transport Management Extension for Fleetbase",
"fleetbase": {
"route": "fleet-ops"
@@ -42,8 +42,8 @@
},
"dependencies": {
"@babel/core": "^7.23.2",
- "@fleetbase/ember-core": "^0.2.9",
- "@fleetbase/ember-ui": "^0.2.14",
+ "@fleetbase/ember-core": "^0.2.10",
+ "@fleetbase/ember-ui": "^0.2.15",
"@fleetbase/fleetops-data": "^0.1.15",
"@fleetbase/leaflet-routing-machine": "^3.2.16",
"@fortawesome/ember-fontawesome": "^0.4.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a65fbf05..bd4f2aaf 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -5,11 +5,11 @@ dependencies:
specifier: ^7.23.2
version: 7.23.2
'@fleetbase/ember-core':
- specifier: ^0.2.9
- version: 0.2.9(@ember/test-helpers@3.2.0)(ember-source@5.4.0)(webpack@5.89.0)
+ specifier: ^0.2.10
+ version: 0.2.10(@ember/test-helpers@3.2.0)(ember-source@5.4.0)(webpack@5.89.0)
'@fleetbase/ember-ui':
- specifier: ^0.2.14
- version: 0.2.14(@ember/test-helpers@3.2.0)(@glimmer/component@1.1.2)(@glimmer/tracking@1.1.2)(ember-source@5.4.0)(postcss@8.4.35)(rollup@4.12.0)(tracked-built-ins@3.3.0)(webpack@5.89.0)
+ specifier: ^0.2.15
+ version: 0.2.15(@ember/test-helpers@3.2.0)(@glimmer/component@1.1.2)(@glimmer/tracking@1.1.2)(ember-source@5.4.0)(postcss@8.4.35)(rollup@4.12.0)(tracked-built-ins@3.3.0)(webpack@5.89.0)
'@fleetbase/fleetops-data':
specifier: ^0.1.15
version: 0.1.15
@@ -1997,7 +1997,7 @@ packages:
'@ember/edition-utils': 1.2.0
'@ember/string': 3.1.1
'@embroider/macros': 1.13.5
- ember-auto-import: 2.6.3(webpack@5.89.0)
+ ember-auto-import: 2.7.2(webpack@5.89.0)
ember-cli-babel: 7.26.11
transitivePeerDependencies:
- '@glint/template'
@@ -2496,8 +2496,8 @@ packages:
- supports-color
dev: false
- /@fleetbase/ember-core@0.2.9(@ember/test-helpers@3.2.0)(ember-source@5.4.0)(webpack@5.89.0):
- resolution: {integrity: sha512-Z4XU5QydqP4dqzyncYW1vKxsUn9VjPiJ/R7l/L+jHuJTMr2AbbkZV5LtoQ0nP+Ib2euhlLMgLuxwlVRWUv/C+g==}
+ /@fleetbase/ember-core@0.2.10(@ember/test-helpers@3.2.0)(ember-source@5.4.0)(webpack@5.89.0):
+ resolution: {integrity: sha512-K1k7+vNdYoJmJdViUj5tMJFpIfGA/a2SBmUk2QuFhk8PlHARhM8S8U7RxtgAIBA8C9VsQyO0Ekgr5WN3WU6aVQ==}
engines: {node: '>= 18'}
dependencies:
'@babel/core': 7.23.2
@@ -2529,8 +2529,8 @@ packages:
- webpack
dev: false
- /@fleetbase/ember-ui@0.2.14(@ember/test-helpers@3.2.0)(@glimmer/component@1.1.2)(@glimmer/tracking@1.1.2)(ember-source@5.4.0)(postcss@8.4.35)(rollup@4.12.0)(tracked-built-ins@3.3.0)(webpack@5.89.0):
- resolution: {integrity: sha512-31FAddlqt9M4Gcnzsgot/2I+/yWg+iWOuRef0zKTOh58BBKE5mrPP9UaK+er6SShgPRyLDAirIwttha1AMXuNg==}
+ /@fleetbase/ember-ui@0.2.15(@ember/test-helpers@3.2.0)(@glimmer/component@1.1.2)(@glimmer/tracking@1.1.2)(ember-source@5.4.0)(postcss@8.4.35)(rollup@4.12.0)(tracked-built-ins@3.3.0)(webpack@5.89.0):
+ resolution: {integrity: sha512-nYuyN3ird4lCRUwozFQY3AK8NAnS1pdZB/SGD2vg8SOIr7CjfG7MjixmDbK+d9Vdt2t2QyhbUgzYHleLUAD4qw==}
engines: {node: '>= 18'}
dependencies:
'@babel/core': 7.23.2
@@ -2640,8 +2640,8 @@ packages:
osrm-text-instructions: 0.13.4
dev: false
- /@floating-ui/core@1.6.1:
- resolution: {integrity: sha512-42UH54oPZHPdRHdw6BgoBD6cg/eVTmVrFcgeRDM3jbO7uxSoipVcmcIGFcA5jmOHO5apcyvBhkSKES3fQJnu7A==}
+ /@floating-ui/core@1.6.2:
+ resolution: {integrity: sha512-+2XpQV9LLZeanU4ZevzRnGFg2neDeKHgFLjP6YLW+tly0IvrhqT4u8enLGjLH3qeh85g19xY5rsAusfwTdn5lg==}
dependencies:
'@floating-ui/utils': 0.2.2
dev: false
@@ -2649,7 +2649,7 @@ packages:
/@floating-ui/dom@1.6.5:
resolution: {integrity: sha512-Nsdud2X65Dz+1RHjAIP0t8z5e2ff/IRbei6BqFrl1urT8sDVzM1HMQ+R0XcU5ceRfyO3I6ayeqIfh+6Wb8LGTw==}
dependencies:
- '@floating-ui/core': 1.6.1
+ '@floating-ui/core': 1.6.2
'@floating-ui/utils': 0.2.2
dev: false
@@ -4309,7 +4309,7 @@ packages:
postcss: ^8.1.0
dependencies:
browserslist: 4.23.0
- caniuse-lite: 1.0.30001618
+ caniuse-lite: 1.0.30001620
fraction.js: 4.3.7
normalize-range: 0.1.2
picocolors: 1.0.0
@@ -4507,7 +4507,7 @@ packages:
glob: 8.1.0
pkg-up: 3.1.0
reselect: 4.1.8
- resolve: 1.22.2
+ resolve: 1.22.8
dev: false
/babel-plugin-polyfill-corejs2@0.4.8(@babel/core@7.23.2):
@@ -5663,7 +5663,7 @@ packages:
resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==}
dependencies:
browserslist: 4.23.0
- caniuse-lite: 1.0.30001618
+ caniuse-lite: 1.0.30001620
lodash.memoize: 4.1.2
lodash.uniq: 4.5.0
dev: false
@@ -5671,8 +5671,8 @@ packages:
/caniuse-lite@1.0.30001588:
resolution: {integrity: sha512-+hVY9jE44uKLkH0SrUTqxjxqNTOWHsbnQDIKjwkZ3lNTzUUVdBLBGXtj/q5Mp5u98r3droaZAewQuEDzjQdZlQ==}
- /caniuse-lite@1.0.30001618:
- resolution: {integrity: sha512-p407+D1tIkDvsEAPS22lJxLQQaG8OTBEqo0KhzfABGk0TU4juBNDSfH0hyAp/HRyx+M8L17z/ltyhxh27FTfQg==}
+ /caniuse-lite@1.0.30001620:
+ resolution: {integrity: sha512-WJvYsOjd1/BYUY6SNGUosK9DUidBPDTnOARHp3fSmFO1ekdxaY6nKRttEVrfMmYi80ctS0kz1wiWmm14fVc3ew==}
dev: false
/capture-exit@2.0.0:
@@ -7028,7 +7028,6 @@ packages:
- '@glint/template'
- supports-color
- webpack
- dev: false
/ember-basic-dropdown@7.3.0(@babel/core@7.23.2)(@ember/string@3.1.1)(ember-source@5.4.0)(webpack@5.89.0):
resolution: {integrity: sha512-XzLd1noCrHjG7O35HpZ+ljj7VwPPqon7svbvNJ2U7421e00eXBUVcCioGJFo1NnnPkjc14FTDc5UwktbGSbJdQ==}
@@ -7493,7 +7492,7 @@ packages:
debug: 4.3.4
execa: 4.1.0
fs-extra: 9.1.0
- resolve: 1.22.2
+ resolve: 1.22.8
rsvp: 4.8.5
semver: 7.6.0
stagehand: 1.0.1
@@ -10322,7 +10321,7 @@ packages:
heimdalljs: 0.2.6
heimdalljs-logger: 0.1.10
path-root: 0.1.1
- resolve: 1.22.2
+ resolve: 1.22.8
resolve-package-path: 1.2.7
transitivePeerDependencies:
- supports-color
@@ -13641,7 +13640,7 @@ packages:
resolution: {integrity: sha512-fVEKHGeK85bGbVFuwO9o1aU0n3vqQGrezPc51JGu9UTXpFQfWq5qCeKxyaRUSvephs+06c5j5rPq/dzHGEo8+Q==}
dependencies:
path-root: 0.1.1
- resolve: 1.22.2
+ resolve: 1.22.8
/resolve-package-path@2.0.0:
resolution: {integrity: sha512-/CLuzodHO2wyyHTzls5Qr+EFeG6RcW4u6//gjYvUfcfyuplIX1SSccU+A5A9A78Gmezkl3NBkFAMxLbzTY9TJA==}
@@ -13765,7 +13764,7 @@ packages:
'@types/resolve': 0.0.8
builtin-modules: 3.3.0
is-module: 1.0.0
- resolve: 1.22.2
+ resolve: 1.22.8
rollup: 4.12.0
rollup-pluginutils: 2.8.2
dev: false
diff --git a/server/src/Exports/ContactExport.php b/server/src/Exports/ContactExport.php
index 33a8abf6..bcd254a9 100644
--- a/server/src/Exports/ContactExport.php
+++ b/server/src/Exports/ContactExport.php
@@ -4,23 +4,31 @@
use Fleetbase\FleetOps\Models\Contact;
use Maatwebsite\Excel\Concerns\FromCollection;
+use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
-use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-class ContactExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting
+class ContactExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize
{
+ protected array $selections = [];
+
+ public function __construct(array $selections = [])
+ {
+ $this->selections = $selections;
+ }
+
public function map($contact): array
{
return [
$contact->public_id,
$contact->internal_id,
$contact->name,
+ $contact->address ? $contact->address->address : null,
$contact->email,
$contact->phone,
- Date::dateTimeToExcel($contact->created_at),
+ $contact->created_at,
];
}
@@ -33,15 +41,14 @@ public function headings(): array
'Address',
'Email',
'Phone',
- 'Created',
+ 'Date Created',
];
}
public function columnFormats(): array
{
return [
- 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ 'F' => '+#',
'G' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
@@ -51,6 +58,10 @@ public function columnFormats(): array
*/
public function collection()
{
+ if ($this->selections) {
+ return Contact::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get();
+ }
+
return Contact::where('company_uuid', session('company'))->get();
}
}
diff --git a/server/src/Exports/DriverExport.php b/server/src/Exports/DriverExport.php
index ed404585..c73a3187 100644
--- a/server/src/Exports/DriverExport.php
+++ b/server/src/Exports/DriverExport.php
@@ -4,13 +4,13 @@
use Fleetbase\FleetOps\Models\Driver;
use Maatwebsite\Excel\Concerns\FromCollection;
+use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
-use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-class DriverExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting
+class DriverExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize
{
protected array $selections = [];
@@ -30,7 +30,7 @@ public function map($driver): array
$driver->phone,
$driver->drivers_license_number,
$driver->country,
- Date::dateTimeToExcel($driver->created_at),
+ $driver->created_at,
];
}
@@ -45,16 +45,15 @@ public function headings(): array
'Phone',
'License #',
'Country',
- 'Created',
+ 'Date Created',
];
}
public function columnFormats(): array
{
return [
- 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'G' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ 'F' => '+#',
+ 'I' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
diff --git a/server/src/Exports/FleetExport.php b/server/src/Exports/FleetExport.php
index 3b354058..aa7096c0 100644
--- a/server/src/Exports/FleetExport.php
+++ b/server/src/Exports/FleetExport.php
@@ -4,22 +4,31 @@
use Fleetbase\FleetOps\Models\Fleet;
use Maatwebsite\Excel\Concerns\FromCollection;
+use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
-use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-class FleetExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting
+class FleetExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize
{
+ protected array $selections = [];
+
+ public function __construct(array $selections = [])
+ {
+ $this->selections = $selections;
+ }
+
public function map($fleet): array
{
return [
$fleet->public_id,
$fleet->internal_id,
$fleet->name,
+ $fleet->drivers_count,
+ $fleet->vehicles_count,
$fleet->zone_uuid,
- Date::dateTimeToExcel($fleet->created_at),
+ $fleet->created_at,
];
}
@@ -29,16 +38,16 @@ public function headings(): array
'ID',
'Internal ID',
'Name',
+ 'Drivers Count',
+ 'Vehicles Count',
'Zone Assigned',
- 'Created',
+ 'Date Created',
];
}
public function columnFormats(): array
{
return [
- 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
'G' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
@@ -48,6 +57,10 @@ public function columnFormats(): array
*/
public function collection()
{
+ if ($this->selections) {
+ return Fleet::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get();
+ }
+
return Fleet::where('company_uuid', session('company'))->get();
}
}
diff --git a/server/src/Exports/FuelReportExport.php b/server/src/Exports/FuelReportExport.php
new file mode 100644
index 00000000..b392a424
--- /dev/null
+++ b/server/src/Exports/FuelReportExport.php
@@ -0,0 +1,70 @@
+selections = $selections;
+ }
+
+ public function map($fuelReport): array
+ {
+ return [
+ $fuelReport->public_id,
+ $fuelReport->reporter,
+ $fuelReport->driver_name,
+ $fuelReport->vehicle_name,
+ $fuelReport->status,
+ $fuelReport->volume,
+ $fuelReport->odometer,
+ $fuelReport->created_at,
+ ];
+ }
+
+ public function headings(): array
+ {
+ return [
+ 'ID',
+ 'Reporter',
+ 'Driver',
+ 'Vehicle',
+ 'Status',
+ 'Volume',
+ 'Odometer',
+ 'Date Created',
+ ];
+ }
+
+ public function columnFormats(): array
+ {
+ return [
+ 'H' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ ];
+ }
+
+ /**
+ * @return \Illuminate\Support\Collection
+ */
+ public function collection()
+ {
+ if ($this->selections) {
+ return FuelReport::where('company_uuid', session('company'))
+ ->whereIn('uuid', $this->selections)
+ ->get();
+ }
+
+ return FuelReport::where('company_uuid', session('company'))->get();
+ }
+}
diff --git a/server/src/Exports/IssueExport.php b/server/src/Exports/IssueExport.php
new file mode 100644
index 00000000..4795405a
--- /dev/null
+++ b/server/src/Exports/IssueExport.php
@@ -0,0 +1,72 @@
+selections = $selections;
+ }
+
+ public function map($issue): array
+ {
+ return [
+ $issue->public_id,
+ $issue->priority,
+ $issue->type,
+ $issue->category,
+ $issue->reporter_name,
+ $issue->assignee_name,
+ $issue->driver_name,
+ $issue->vehicle_name,
+ $issue->status,
+ $issue->created_at,
+ ];
+ }
+
+ public function headings(): array
+ {
+ return [
+ 'ID',
+ 'Priority',
+ 'Type',
+ 'Category',
+ 'Reporter',
+ 'Assignee',
+ 'Driver',
+ 'Vehicle',
+ 'Status',
+ 'Date Created',
+ ];
+ }
+
+ public function columnFormats(): array
+ {
+ return [
+ 'J' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ ];
+ }
+
+ /**
+ * @return \Illuminate\Support\Collection
+ */
+ public function collection()
+ {
+ if (!empty($this->selections)) {
+ return Issue::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get();
+ }
+
+ return Issue::where('company_uuid', session('company'))->get();
+ }
+}
diff --git a/server/src/Exports/OrderExport.php b/server/src/Exports/OrderExport.php
new file mode 100644
index 00000000..c37b784e
--- /dev/null
+++ b/server/src/Exports/OrderExport.php
@@ -0,0 +1,75 @@
+selections = $selections;
+ }
+
+ public function map($order): array
+ {
+ return [
+ $order->public_id,
+ $order->internal_id,
+ $order->driver_name,
+ $order->vehicle_name,
+ $order->customer_name,
+ $order->pickup_name,
+ $order->dropoff_name,
+ $order->scheduled_at,
+ $order->trackingNumber ? $order->trackingNumber->tracking_number : null,
+ $order->status,
+ $order->created_at,
+ ];
+ }
+
+ public function headings(): array
+ {
+ return [
+ 'ID',
+ 'Internal ID',
+ 'Driver',
+ 'Vehicle',
+ 'Customer',
+ 'Pick Up',
+ 'Drop Off',
+ 'Date Scheduled',
+ 'Tracking Number',
+ 'Status',
+ 'Date Created',
+ ];
+ }
+
+ public function columnFormats(): array
+ {
+ return [
+ 'H' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ 'K' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ ];
+ }
+
+ /**
+ * @return \Illuminate\Support\Collection
+ */
+ public function collection()
+ {
+ if (!empty($this->selections)) {
+ return Order::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->with(['trackingNumber', 'customer', 'driverAssigned', 'payload'])->get();
+ }
+
+ return Order::where('company_uuid', session('company'))->get();
+ }
+}
diff --git a/server/src/Exports/PlaceExport.php b/server/src/Exports/PlaceExport.php
index e25ead02..57328a21 100644
--- a/server/src/Exports/PlaceExport.php
+++ b/server/src/Exports/PlaceExport.php
@@ -4,23 +4,32 @@
use Fleetbase\FleetOps\Models\Place;
use Maatwebsite\Excel\Concerns\FromCollection;
+use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
-use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-class PlaceExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting
+class PlaceExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize
{
+ protected array $selections = [];
+
+ public function __construct(array $selections = [])
+ {
+ $this->selections = $selections;
+ }
+
public function map($place): array
{
return [
$place->public_id,
- $place->internal_id,
- $place->display_name,
- $place->address,
- $place->country_name,
- Date::dateTimeToExcel($place->created_at),
+ $place->name,
+ $place->phone,
+ strtoupper($place->address),
+ strtoupper($place->city),
+ $place->postal_code,
+ strtoupper($place->country_name),
+ $place->created_at,
];
}
@@ -28,20 +37,22 @@ public function headings(): array
{
return [
'ID',
- 'Internal ID',
'Name',
+ 'Phone',
'Address',
+ 'City',
+ 'Postal Code',
'Country',
- 'Created',
+ 'Date Created',
];
}
public function columnFormats(): array
{
return [
- 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'G' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ 'C' => '+#',
+ 'F' => NumberFormat::FORMAT_GENERAL,
+ 'H' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
@@ -50,6 +61,10 @@ public function columnFormats(): array
*/
public function collection()
{
+ if ($this->selections) {
+ return Place::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get();
+ }
+
return Place::where('company_uuid', session('company'))->get();
}
}
diff --git a/server/src/Exports/ServiceAreaExport.php b/server/src/Exports/ServiceAreaExport.php
index e38b3c1f..a81836ac 100644
--- a/server/src/Exports/ServiceAreaExport.php
+++ b/server/src/Exports/ServiceAreaExport.php
@@ -3,27 +3,33 @@
namespace Fleetbase\FleetOps\Exports;
use Fleetbase\FleetOps\Models\ServiceArea;
+use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromCollection;
+use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
-use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-class ServiceAreaExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting
+class ServiceAreaExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize
{
- public function map($service_area): array
+ protected array $selections = [];
+
+ public function __construct(array $selections = [])
+ {
+ $this->selections = $selections;
+ }
+
+ public function map($servicArea): array
{
return [
- $service_area->public_id,
- $service_area->internal_id,
- $service_area->name,
- $service_area->vendor_name,
- $service_area->vehicle_name,
- $service_area->phone,
- $service_area->drivers_license_number,
- $service_area->country,
- Date::dateTimeToExcel($service_area->created_at),
+ $servicArea->public_id,
+ $servicArea->name,
+ $servicArea->zones instanceof Collection ? $servicArea->zones->map(function ($zone) {
+ return $zone->name;
+ })->join(', ') : null,
+ $servicArea->status,
+ $servicArea->created_at,
];
}
@@ -31,11 +37,10 @@ public function headings(): array
{
return [
'ID',
- 'Internal ID',
- 'Service',
- 'Service Area',
- 'Zone',
- 'Created',
+ 'Name',
+ 'Zones',
+ 'Status',
+ 'Date Created',
];
}
@@ -43,16 +48,18 @@ public function columnFormats(): array
{
return [
'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'G' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
/**
- * @return \Illuminate\Support\Collection
+ * @return Collection
*/
public function collection()
{
- return ServiceArea::where('company_uuid', session('company'))->get();
+ if ($this->selections) {
+ return ServiceArea::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->with(['zones'])->get();
+ }
+
+ return ServiceArea::where('company_uuid', session('company'))->with(['zones'])->get();
}
}
diff --git a/server/src/Exports/ServiceRateExport.php b/server/src/Exports/ServiceRateExport.php
new file mode 100644
index 00000000..b96698da
--- /dev/null
+++ b/server/src/Exports/ServiceRateExport.php
@@ -0,0 +1,72 @@
+selections = $selections;
+ }
+
+ public function map($serviceRate): array
+ {
+ return [
+ $serviceRate->public_id,
+ $serviceRate->service_name,
+ Str::title($serviceRate->service_type),
+ Utils::moneyFormat($serviceRate->base_fee, $serviceRate->currency),
+ $serviceRate->rate_calculation_method,
+ $serviceRate->service_area_name,
+ $serviceRate->zone_name,
+ $serviceRate->currency,
+ $serviceRate->created_at,
+ ];
+ }
+
+ public function headings(): array
+ {
+ return [
+ 'ID',
+ 'Service',
+ 'Type',
+ 'Base Fee',
+ 'Calculation Method',
+ 'Service Area',
+ 'Zone',
+ 'Currency',
+ 'Date Created',
+ ];
+ }
+
+ public function columnFormats(): array
+ {
+ return [
+ 'I' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ ];
+ }
+
+ /**
+ * @return \Illuminate\Support\Collection
+ */
+ public function collection()
+ {
+ if ($this->selections) {
+ return ServiceRate::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get();
+ }
+
+ return ServiceRate::where('company_uuid', session('company'))->get();
+ }
+}
diff --git a/server/src/Exports/VehicleExport.php b/server/src/Exports/VehicleExport.php
index be78058c..5b465c55 100644
--- a/server/src/Exports/VehicleExport.php
+++ b/server/src/Exports/VehicleExport.php
@@ -4,14 +4,21 @@
use Fleetbase\FleetOps\Models\Vehicle;
use Maatwebsite\Excel\Concerns\FromCollection;
+use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
-use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-class VehicleExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting
+class VehicleExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize
{
+ protected array $selections = [];
+
+ public function __construct(array $selections = [])
+ {
+ $this->selections = $selections;
+ }
+
public function map($vehicle): array
{
return [
@@ -19,8 +26,10 @@ public function map($vehicle): array
$vehicle->internal_id,
$vehicle->display_name,
$vehicle->driver_name,
- $vehicle->model_data,
- Date::dateTimeToExcel($vehicle->created_at),
+ $vehicle->make,
+ $vehicle->model,
+ $vehicle->year,
+ $vehicle->created_at,
];
}
@@ -34,16 +43,14 @@ public function headings(): array
'Make',
'Model',
'Year',
- 'Created',
+ 'Date Created',
];
}
public function columnFormats(): array
{
return [
- 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'G' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ 'H' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
@@ -52,6 +59,10 @@ public function columnFormats(): array
*/
public function collection()
{
- return Vehicle::where('company_uuid', session('company'))->get();
+ if ($this->selections) {
+ return Vehicle::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->with(['driver'])->get();
+ }
+
+ return Vehicle::where('company_uuid', session('company'))->with(['driver'])->get();
}
}
diff --git a/server/src/Exports/VendorExport.php b/server/src/Exports/VendorExport.php
index 78e37c47..edd177e7 100644
--- a/server/src/Exports/VendorExport.php
+++ b/server/src/Exports/VendorExport.php
@@ -4,24 +4,31 @@
use Fleetbase\FleetOps\Models\Vendor;
use Maatwebsite\Excel\Concerns\FromCollection;
+use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
-use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-class VendorExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting
+class VendorExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize
{
+ protected array $selections = [];
+
+ public function __construct(array $selections = [])
+ {
+ $this->selections = $selections;
+ }
+
public function map($vendor): array
{
return [
$vendor->public_id,
$vendor->internal_id,
$vendor->name,
- $vendor->place_uuid,
+ $vendor->address,
$vendor->email,
$vendor->phone,
- Date::dateTimeToExcel($vendor->created_at),
+ $vendor->created_at,
];
}
@@ -34,15 +41,14 @@ public function headings(): array
'Address',
'Email',
'Phone',
- 'Created',
+ 'Date Created',
];
}
public function columnFormats(): array
{
return [
- 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
- 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
+ 'F' => '+#',
'G' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
@@ -52,6 +58,10 @@ public function columnFormats(): array
*/
public function collection()
{
+ if ($this->selections) {
+ return Vendor::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get();
+ }
+
return Vendor::where('company_uuid', session('company'))->get();
}
}
diff --git a/server/src/Http/Controllers/Internal/v1/ContactController.php b/server/src/Http/Controllers/Internal/v1/ContactController.php
index b6c140b9..54495264 100644
--- a/server/src/Http/Controllers/Internal/v1/ContactController.php
+++ b/server/src/Http/Controllers/Internal/v1/ContactController.php
@@ -61,9 +61,10 @@ public function getAsCustomer($id)
*/
public static function export(ExportRequest $request)
{
- $format = $request->input('format', 'xlsx');
- $fileName = trim(Str::slug('contacts-' . date('Y-m-d-H:i')) . '.' . $format);
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('contacts-' . date('Y-m-d-H:i')) . '.' . $format);
- return Excel::download(new ContactExport(), $fileName);
+ return Excel::download(new ContactExport($selections), $fileName);
}
}
diff --git a/server/src/Http/Controllers/Internal/v1/DriverController.php b/server/src/Http/Controllers/Internal/v1/DriverController.php
index 67bef43f..a8faa350 100644
--- a/server/src/Http/Controllers/Internal/v1/DriverController.php
+++ b/server/src/Http/Controllers/Internal/v1/DriverController.php
@@ -334,10 +334,11 @@ public function avatars()
*/
public static function export(ExportRequest $request)
{
- $format = $request->input('format', 'xlsx');
- $fileName = trim(Str::slug('drivers-' . date('Y-m-d-H:i')) . '.' . $format);
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('drivers-' . date('Y-m-d-H:i')) . '.' . $format);
- return Excel::download(new DriverExport(), $fileName);
+ return Excel::download(new DriverExport($selections), $fileName);
}
/**
diff --git a/server/src/Http/Controllers/Internal/v1/FleetController.php b/server/src/Http/Controllers/Internal/v1/FleetController.php
index e275c837..da0d7810 100644
--- a/server/src/Http/Controllers/Internal/v1/FleetController.php
+++ b/server/src/Http/Controllers/Internal/v1/FleetController.php
@@ -30,10 +30,11 @@ class FleetController extends FleetOpsController
*/
public static function export(ExportRequest $request)
{
- $format = $request->input('format', 'xlsx');
- $fileName = trim(Str::slug('fleets-' . date('Y-m-d-H:i')) . '.' . $format);
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('fleets-' . date('Y-m-d-H:i')) . '.' . $format);
- return Excel::download(new FleetExport(), $fileName);
+ return Excel::download(new FleetExport($selections), $fileName);
}
/**
diff --git a/server/src/Http/Controllers/Internal/v1/FuelReportController.php b/server/src/Http/Controllers/Internal/v1/FuelReportController.php
index 49e9de4c..09a2ea10 100644
--- a/server/src/Http/Controllers/Internal/v1/FuelReportController.php
+++ b/server/src/Http/Controllers/Internal/v1/FuelReportController.php
@@ -2,7 +2,11 @@
namespace Fleetbase\FleetOps\Http\Controllers\Internal\v1;
+use Fleetbase\FleetOps\Exports\FuelReportExport;
use Fleetbase\FleetOps\Http\Controllers\FleetOpsController;
+use Fleetbase\Http\Requests\ExportRequest;
+use Illuminate\Support\Str;
+use Maatwebsite\Excel\Facades\Excel;
class FuelReportController extends FleetOpsController
{
@@ -12,4 +16,18 @@ class FuelReportController extends FleetOpsController
* @var string
*/
public $resource = 'fuel_report';
+
+ /**
+ * Export the fleets to excel or csv.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function export(ExportRequest $request)
+ {
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('fuel_report-' . date('Y-m-d-H:i')) . '.' . $format);
+
+ return Excel::download(new FuelReportExport($selections), $fileName);
+ }
}
diff --git a/server/src/Http/Controllers/Internal/v1/IssueController.php b/server/src/Http/Controllers/Internal/v1/IssueController.php
index 50127492..25fa00a2 100644
--- a/server/src/Http/Controllers/Internal/v1/IssueController.php
+++ b/server/src/Http/Controllers/Internal/v1/IssueController.php
@@ -2,7 +2,11 @@
namespace Fleetbase\FleetOps\Http\Controllers\Internal\v1;
+use Fleetbase\FleetOps\Exports\IssueExport;
use Fleetbase\FleetOps\Http\Controllers\FleetOpsController;
+use Fleetbase\Http\Requests\ExportRequest;
+use Illuminate\Support\Str;
+use Maatwebsite\Excel\Facades\Excel;
class IssueController extends FleetOpsController
{
@@ -12,4 +16,18 @@ class IssueController extends FleetOpsController
* @var string
*/
public $resource = 'issue';
+
+ /**
+ * Export the issue to excel or csv.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function export(ExportRequest $request)
+ {
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('issue-' . date('Y-m-d-H:i')) . '.' . $format);
+
+ return Excel::download(new IssueExport($selections), $fileName);
+ }
}
diff --git a/server/src/Http/Controllers/Internal/v1/OrderController.php b/server/src/Http/Controllers/Internal/v1/OrderController.php
index dfcd23dc..871023c7 100644
--- a/server/src/Http/Controllers/Internal/v1/OrderController.php
+++ b/server/src/Http/Controllers/Internal/v1/OrderController.php
@@ -6,6 +6,7 @@
use Fleetbase\FleetOps\Events\OrderDispatchFailed;
use Fleetbase\FleetOps\Events\OrderReady;
use Fleetbase\FleetOps\Events\OrderStarted;
+use Fleetbase\FleetOps\Exports\OrderExport;
use Fleetbase\FleetOps\Flow\Activity;
use Fleetbase\FleetOps\Http\Controllers\FleetOpsController;
use Fleetbase\FleetOps\Http\Requests\CancelOrderRequest;
@@ -20,6 +21,7 @@
use Fleetbase\FleetOps\Models\TrackingStatus;
use Fleetbase\FleetOps\Models\Waypoint;
use Fleetbase\FleetOps\Support\Utils;
+use Fleetbase\Http\Requests\ExportRequest;
use Fleetbase\Http\Requests\Internal\BulkDeleteRequest;
use Fleetbase\Models\CustomFieldValue;
use Fleetbase\Models\File;
@@ -658,4 +660,18 @@ public function label(string $publicId, Request $request)
return response()->error('Unable to render label.');
}
+
+ /**
+ * Export the issue to excel or csv.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public function export(ExportRequest $request)
+ {
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('order-' . date('Y-m-d-H:i')) . '.' . $format);
+
+ return Excel::download(new OrderExport($selections), $fileName);
+ }
}
diff --git a/server/src/Http/Controllers/Internal/v1/PlaceController.php b/server/src/Http/Controllers/Internal/v1/PlaceController.php
index 8f5e9d6f..a10f188b 100644
--- a/server/src/Http/Controllers/Internal/v1/PlaceController.php
+++ b/server/src/Http/Controllers/Internal/v1/PlaceController.php
@@ -123,10 +123,11 @@ public function geocode(ExportRequest $request)
*/
public function export(ExportRequest $request)
{
- $format = $request->input('format', 'xlsx');
- $fileName = trim(Str::slug('places-' . date('Y-m-d-H:i')) . '.' . $format);
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('places-' . date('Y-m-d-H:i')) . '.' . $format);
- return Excel::download(new PlaceExport(), $fileName);
+ return Excel::download(new PlaceExport($selections), $fileName);
}
/**
diff --git a/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php b/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php
index 9c22301f..6746c1c0 100644
--- a/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php
+++ b/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php
@@ -24,9 +24,10 @@ class ServiceAreaController extends FleetOpsController
*/
public static function export(ExportRequest $request)
{
- $format = $request->input('format', 'xlsx');
- $fileName = trim(Str::slug('service-areas-' . date('Y-m-d-H:i')) . '.' . $format);
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('service-areas-' . date('Y-m-d-H:i')) . '.' . $format);
- return Excel::download(new ServiceAreaExport(), $fileName);
+ return Excel::download(new ServiceAreaExport($selections), $fileName);
}
}
diff --git a/server/src/Http/Controllers/Internal/v1/ServiceRateController.php b/server/src/Http/Controllers/Internal/v1/ServiceRateController.php
index 91277be3..fb90f555 100644
--- a/server/src/Http/Controllers/Internal/v1/ServiceRateController.php
+++ b/server/src/Http/Controllers/Internal/v1/ServiceRateController.php
@@ -3,9 +3,13 @@
namespace Fleetbase\FleetOps\Http\Controllers\Internal\v1;
use Brick\Geo\Point;
+use Fleetbase\FleetOps\Exports\ServiceRateExport;
use Fleetbase\FleetOps\Http\Controllers\FleetOpsController;
use Fleetbase\FleetOps\Models\ServiceRate;
+use Fleetbase\Http\Requests\ExportRequest;
use Illuminate\Http\Request;
+use Illuminate\Support\Str;
+use Maatwebsite\Excel\Facades\Excel;
class ServiceRateController extends FleetOpsController
{
@@ -47,4 +51,18 @@ function ($query) use ($request) {
return response()->json($applicableServiceRates);
}
+
+ /**
+ * Export the service rate to excel or csv.
+ *
+ * @return \Illuminate\Http\Response
+ */
+ public static function export(ExportRequest $request)
+ {
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('contacts-' . date('Y-m-d-H:i')) . '.' . $format);
+
+ return Excel::download(new ServiceRateExport($selections), $fileName);
+ }
}
diff --git a/server/src/Http/Controllers/Internal/v1/VehicleController.php b/server/src/Http/Controllers/Internal/v1/VehicleController.php
index 4864e082..384bb78a 100644
--- a/server/src/Http/Controllers/Internal/v1/VehicleController.php
+++ b/server/src/Http/Controllers/Internal/v1/VehicleController.php
@@ -57,9 +57,10 @@ public function avatars()
*/
public static function export(ExportRequest $request)
{
- $format = $request->input('format', 'xlsx');
- $fileName = trim(Str::slug('vehicles-' . date('Y-m-d-H:i')) . '.' . $format);
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('vehicles-' . date('Y-m-d-H:i')) . '.' . $format);
- return Excel::download(new VehicleExport(), $fileName);
+ return Excel::download(new VehicleExport($selections), $fileName);
}
}
diff --git a/server/src/Http/Controllers/Internal/v1/VendorController.php b/server/src/Http/Controllers/Internal/v1/VendorController.php
index 5791c0d6..d2a68882 100644
--- a/server/src/Http/Controllers/Internal/v1/VendorController.php
+++ b/server/src/Http/Controllers/Internal/v1/VendorController.php
@@ -63,10 +63,11 @@ public function getAsCustomer($id)
*/
public static function export(ExportRequest $request)
{
- $format = $request->input('format', 'xlsx');
- $fileName = trim(Str::slug('vendors-' . date('Y-m-d-H:i')) . '.' . $format);
+ $format = $request->input('format', 'xlsx');
+ $selections = $request->array('selections');
+ $fileName = trim(Str::slug('vendors-' . date('Y-m-d-H:i')) . '.' . $format);
- return Excel::download(new VendorExport(), $fileName);
+ return Excel::download(new VendorExport($selections), $fileName);
}
/**
diff --git a/server/src/Models/Order.php b/server/src/Models/Order.php
index 0c14536f..72b9ca57 100644
--- a/server/src/Models/Order.php
+++ b/server/src/Models/Order.php
@@ -439,6 +439,16 @@ public function getDriverNameAttribute()
return data_get($this, 'driverAssigned.name');
}
+ /**
+ * The assigned vehicle name.
+ *
+ * @return string
+ */
+ public function getVehicleNameAttribute()
+ {
+ return data_get($this, 'vehicleAssigned.display_name');
+ }
+
/**
* The tracking number for the order.
*
diff --git a/server/src/routes.php b/server/src/routes.php
index bdc9ace4..e598c5d0 100644
--- a/server/src/routes.php
+++ b/server/src/routes.php
@@ -280,7 +280,7 @@ function ($router) {
$router->fleetbaseRoutes(
'contacts',
function ($router, $controller) {
- $router->get('export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->get('facilitators/{id}', $controller('getAsFacilitator'));
$router->get('customers/{id}', $controller('getAsCustomer'));
$router->delete('bulk-delete', $controller('bulkDelete'));
@@ -291,7 +291,7 @@ function ($router, $controller) {
function ($router, $controller) {
$router->get('statuses', $controller('statuses'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->get('avatars', $controller('avatars'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
- $router->get('export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->delete('bulk-delete', $controller('bulkDelete'));
}
);
@@ -303,21 +303,21 @@ function ($router, $controller) {
$router->post('remove-driver', $controller('removeDriver'));
$router->post('assign-vehicle', $controller('assignVehicle'));
$router->post('remove-vehicle', $controller('removeVehicle'));
- $router->get('export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->delete('bulk-delete', $controller('bulkDelete'));
}
);
$router->fleetbaseRoutes(
'fuel-reports',
function ($router, $controller) {
- $router->get('export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->delete('bulk-delete', $controller('bulkDelete'));
}
);
$router->fleetbaseRoutes(
'issues',
function ($router, $controller) {
- $router->get('export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->delete('bulk-delete', $controller('bulkDelete'));
}
);
@@ -344,6 +344,7 @@ function ($router, $controller) {
$router->patch('dispatch', $controller('dispatchOrder'));
$router->patch('start', $controller('start'));
$router->delete('bulk-delete', $controller('bulkDelete'));
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
}
);
$router->fleetbaseRoutes('order-configs');
@@ -354,7 +355,7 @@ function ($router, $controller) {
$router->get('search', $controller('search'))->middleware(['cache.headers:private;max_age=3600', Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->get('lookup', $controller('geocode'))->middleware(['cache.headers:private;max_age=3600', Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->get('avatars', $controller('avatars'));
- $router->get('export', $controller('export'));
+ $router->match(['get', 'post'], 'export', $controller('export'));
$router->delete('bulk-delete', $controller('bulkDelete'));
}
);
@@ -364,7 +365,7 @@ function ($router, $controller) {
$router->fleetbaseRoutes(
'service-areas',
function ($router, $controller) {
- $router->get('export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->delete('bulk-delete', $controller('bulkDelete'));
}
);
@@ -378,6 +379,8 @@ function ($router, $controller) {
$router->fleetbaseRoutes(
'service-rates',
function ($router, $controller) {
+ $router->get('for-route', $controller('getServicesForRoute'));
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->get('for-route', $controller('getServicesForRoute'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
}
);
@@ -388,7 +391,7 @@ function ($router, $controller) {
function ($router, $controller) {
$router->get('statuses', $controller('statuses'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->get('avatars', $controller('avatars'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
- $router->get('export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->delete('bulk-delete', $controller('bulkDelete'));
}
);
@@ -397,7 +400,7 @@ function ($router, $controller) {
'vendors',
function ($router, $controller) {
$router->get('statuses', $controller('statuses'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
- $router->get('export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
+ $router->match(['get', 'post'], 'export', $controller('export'))->middleware([Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class]);
$router->get('facilitators/{id}', $controller('getAsFacilitator'));
$router->get('customers/{id}', $controller('getAsCustomer'));
$router->delete('bulk-delete', $controller('bulkDelete'));