From 3f882b5dba35a447666bb7b875f7a039782c9ad9 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Tue, 14 May 2024 16:33:16 +0800 Subject: [PATCH 01/12] created issue, rate export --- server/src/Exports/IssueExport.php | 63 +++++++++++++++++++ server/src/Exports/ServiceRate.php | 54 ++++++++++++++++ .../Internal/v1/IssueController.php | 17 +++++ .../Internal/v1/ServiceRateController.php | 35 +++++++++++ server/src/routes.php | 1 + 5 files changed, 170 insertions(+) create mode 100644 server/src/Exports/IssueExport.php create mode 100644 server/src/Exports/ServiceRate.php diff --git a/server/src/Exports/IssueExport.php b/server/src/Exports/IssueExport.php new file mode 100644 index 00000000..fb187f69 --- /dev/null +++ b/server/src/Exports/IssueExport.php @@ -0,0 +1,63 @@ +public_id, + $issue->priority, + $issue->type, + $issue->category, + $issue->reporter_name, + $issue->assignee_name, + $issue->driver_uuid, + $issue->vehicle_name, + $issue->status, + Date::dateTimeToExcel($issue->created_at), + ]; + } + + public function headings(): array + { + return [ + 'ID', + 'Priority', + 'Type', + 'Category', + 'Reporter', + 'Assignee', + 'Driver', + 'Vehicle', + 'Status', + 'Created', + ]; + } + + public function columnFormats(): array + { + return [ + 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY, + 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY, + 'G' => NumberFormat::FORMAT_DATE_DDMMYYYY, + ]; + } + + /** + * @return \Illuminate\Support\Collection + */ + public function collection() + { + return Issue::where('company_uuid', session('company'))->get(); + } +} diff --git a/server/src/Exports/ServiceRate.php b/server/src/Exports/ServiceRate.php new file mode 100644 index 00000000..110fd347 --- /dev/null +++ b/server/src/Exports/ServiceRate.php @@ -0,0 +1,54 @@ +public_id, + $service_rate->name, + $service_rate->vendor_name, + $service_rate->vehicle_name, + $service_rate->country, + Date::dateTimeToExcel($service_rate->created_at), + ]; + } + + public function headings(): array + { + return [ + 'ID', + 'Service', + 'Service Area', + 'Zone', + 'Created', + ]; + } + + public function columnFormats(): array + { + return [ + 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY, + 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY, + 'G' => NumberFormat::FORMAT_DATE_DDMMYYYY, + ]; + } + + /** + * @return \Illuminate\Support\Collection + */ + public function collection() + { + return ServiceRate::where('company_uuid', session('company'))->get(); + } +} diff --git a/server/src/Http/Controllers/Internal/v1/IssueController.php b/server/src/Http/Controllers/Internal/v1/IssueController.php index 50127492..b3560924 100644 --- a/server/src/Http/Controllers/Internal/v1/IssueController.php +++ b/server/src/Http/Controllers/Internal/v1/IssueController.php @@ -2,6 +2,10 @@ namespace Fleetbase\FleetOps\Http\Controllers\Internal\v1; +use Fleetbase\Http\Requests\ExportRequest; +use Fleetbase\FleetOps\Exports\IssueExport; +use Illuminate\Support\Str; +use Maatwebsite\Excel\Facades\Excel; use Fleetbase\FleetOps\Http\Controllers\FleetOpsController; class IssueController extends FleetOpsController @@ -12,4 +16,17 @@ class IssueController extends FleetOpsController * @var string */ public $resource = 'issue'; + + /** + * Export the issue to excel or csv. + * + * @return \Illuminate\Http\Response + */ + public static function export(ExportRequest $request) + { + $format = $request->input('format', 'xlsx'); + $fileName = trim(Str::slug('issue-' . date('Y-m-d-H:i')) . '.' . $format); + + return Excel::download(new IssueExport(), $fileName); + } } diff --git a/server/src/Http/Controllers/Internal/v1/ServiceRateController.php b/server/src/Http/Controllers/Internal/v1/ServiceRateController.php index 91277be3..661c3f2c 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\Support\Str; use Illuminate\Http\Request; +use Maatwebsite\Excel\Facades\Excel; class ServiceRateController extends FleetOpsController { @@ -16,6 +20,14 @@ class ServiceRateController extends FleetOpsController */ public $resource = 'service_rate'; + + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + /** * Creates a record with request payload. * @@ -47,4 +59,27 @@ function ($query) use ($request) { return response()->json($applicableServiceRates); } + + 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(); + } + + /** + * 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/routes.php b/server/src/routes.php index 5b40ae08..dc3ce006 100644 --- a/server/src/routes.php +++ b/server/src/routes.php @@ -374,6 +374,7 @@ function ($router, $controller) { 'service-rates', function ($router, $controller) { $router->get('for-route', $controller('getServicesForRoute')); + $router->get('export', $controller('export')); } ); $router->fleetbaseRoutes('tracking-numbers'); From f51a24153db3358452993451f9c398aa17f10b3b Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Tue, 14 May 2024 17:58:56 +0800 Subject: [PATCH 02/12] added selection in issue --- server/src/Exports/IssueExport.php | 2 +- .../Internal/v1/IssueController.php | 25 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/server/src/Exports/IssueExport.php b/server/src/Exports/IssueExport.php index fb187f69..d0f32dba 100644 --- a/server/src/Exports/IssueExport.php +++ b/server/src/Exports/IssueExport.php @@ -21,7 +21,7 @@ public function map($issue): array $issue->category, $issue->reporter_name, $issue->assignee_name, - $issue->driver_uuid, + $issue->driver_name, $issue->vehicle_name, $issue->status, Date::dateTimeToExcel($issue->created_at), diff --git a/server/src/Http/Controllers/Internal/v1/IssueController.php b/server/src/Http/Controllers/Internal/v1/IssueController.php index b3560924..7cdcd5cd 100644 --- a/server/src/Http/Controllers/Internal/v1/IssueController.php +++ b/server/src/Http/Controllers/Internal/v1/IssueController.php @@ -5,6 +5,7 @@ use Fleetbase\Http\Requests\ExportRequest; use Fleetbase\FleetOps\Exports\IssueExport; use Illuminate\Support\Str; +use Fleetbase\FleetOps\Models\Issue; use Maatwebsite\Excel\Facades\Excel; use Fleetbase\FleetOps\Http\Controllers\FleetOpsController; @@ -17,16 +18,36 @@ class IssueController extends FleetOpsController */ public $resource = 'issue'; + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + + public function collection() + { + if ($this->selections) { + return Issue::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get(); + } + + return Issue::where('company_uuid', session('company'))->get(); + } + /** * Export the issue to excel or csv. * + * @param ExportRequest $request * @return \Illuminate\Http\Response */ - public static function export(ExportRequest $request) + public function export(ExportRequest $request) { $format = $request->input('format', 'xlsx'); + $selections = $request->input('selections', []); $fileName = trim(Str::slug('issue-' . date('Y-m-d-H:i')) . '.' . $format); - return Excel::download(new IssueExport(), $fileName); + return Excel::download(new IssueExport($selections), $fileName); } + } + From 9631af4fb01b3d39d39220b31f76140dd5f5d352 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Wed, 15 May 2024 16:01:30 +0800 Subject: [PATCH 03/12] added selection --- server/src/Exports/ContactExport.php | 15 +++++++++++- server/src/Exports/DriverExport.php | 15 +++++++++++- server/src/Exports/FleetExport.php | 15 +++++++++++- server/src/Exports/IssueExport.php | 24 +++++++++++++++++-- server/src/Exports/PlaceExport.php | 15 +++++++++++- server/src/Exports/ServiceAreaExport.php | 15 +++++++++++- server/src/Exports/ServiceRate.php | 15 +++++++++++- server/src/Exports/VehicleExport.php | 15 +++++++++++- server/src/Exports/VendorExport.php | 15 +++++++++++- .../Internal/v1/IssueController.php | 22 ++--------------- 10 files changed, 136 insertions(+), 30 deletions(-) diff --git a/server/src/Exports/ContactExport.php b/server/src/Exports/ContactExport.php index 33a8abf6..a12c54d7 100644 --- a/server/src/Exports/ContactExport.php +++ b/server/src/Exports/ContactExport.php @@ -12,6 +12,13 @@ class ContactExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($contact): array { return [ @@ -51,6 +58,12 @@ public function columnFormats(): array */ public function collection() { - return Contact::where('company_uuid', session('company'))->get(); + 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 55786989..8e5b7cd8 100644 --- a/server/src/Exports/DriverExport.php +++ b/server/src/Exports/DriverExport.php @@ -12,6 +12,13 @@ class DriverExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($driver): array { return [ @@ -56,6 +63,12 @@ public function columnFormats(): array */ public function collection() { - return Driver::where('company_uuid', session('company'))->get(); + if ($this->selections) { + return Driver::where("company_uuid", session("company")) + ->whereIn("uuid", $this->selections) + ->get(); + } + + return Driver::where("company_uuid", session("company"))->get(); } } diff --git a/server/src/Exports/FleetExport.php b/server/src/Exports/FleetExport.php index 3b354058..0c7702da 100644 --- a/server/src/Exports/FleetExport.php +++ b/server/src/Exports/FleetExport.php @@ -12,6 +12,13 @@ class FleetExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($fleet): array { return [ @@ -48,6 +55,12 @@ public function columnFormats(): array */ public function collection() { - return Fleet::where('company_uuid', session('company'))->get(); + 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/IssueExport.php b/server/src/Exports/IssueExport.php index d0f32dba..18a8724f 100644 --- a/server/src/Exports/IssueExport.php +++ b/server/src/Exports/IssueExport.php @@ -10,8 +10,19 @@ use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; -class IssueExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting +class IssueExport implements + FromCollection, + WithHeadings, + WithMapping, + WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($issue): array { return [ @@ -58,6 +69,15 @@ public function columnFormats(): array */ public function collection() { - return Issue::where('company_uuid', session('company'))->get(); + info("Selections:", [$this->selections]); + info("Session company:", [session("company")]); + + 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/PlaceExport.php b/server/src/Exports/PlaceExport.php index e25ead02..8cbd44ab 100644 --- a/server/src/Exports/PlaceExport.php +++ b/server/src/Exports/PlaceExport.php @@ -12,6 +12,13 @@ class PlaceExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($place): array { return [ @@ -50,6 +57,12 @@ public function columnFormats(): array */ public function collection() { - return Place::where('company_uuid', session('company'))->get(); + 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..8d0f0bbc 100644 --- a/server/src/Exports/ServiceAreaExport.php +++ b/server/src/Exports/ServiceAreaExport.php @@ -12,6 +12,13 @@ class ServiceAreaExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($service_area): array { return [ @@ -53,6 +60,12 @@ public function columnFormats(): array */ 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) + ->get(); + } + + return ServiceArea::where("company_uuid", session("company"))->get(); } } diff --git a/server/src/Exports/ServiceRate.php b/server/src/Exports/ServiceRate.php index 110fd347..e951fa55 100644 --- a/server/src/Exports/ServiceRate.php +++ b/server/src/Exports/ServiceRate.php @@ -12,6 +12,13 @@ class ServiceRateExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($service_rate): array { return [ @@ -49,6 +56,12 @@ public function columnFormats(): array */ public function collection() { - return ServiceRate::where('company_uuid', session('company'))->get(); + 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..32a6d282 100644 --- a/server/src/Exports/VehicleExport.php +++ b/server/src/Exports/VehicleExport.php @@ -12,6 +12,13 @@ class VehicleExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($vehicle): array { return [ @@ -52,6 +59,12 @@ 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) + ->get(); + } + + return Vehicle::where("company_uuid", session("company"))->get(); } } diff --git a/server/src/Exports/VendorExport.php b/server/src/Exports/VendorExport.php index 78e37c47..69c9435c 100644 --- a/server/src/Exports/VendorExport.php +++ b/server/src/Exports/VendorExport.php @@ -12,6 +12,13 @@ class VendorExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { + protected array $selections = []; + + public function __construct(array $selections = []) + { + $this->selections = $selections; + } + public function map($vendor): array { return [ @@ -52,6 +59,12 @@ public function columnFormats(): array */ public function collection() { - return Vendor::where('company_uuid', session('company'))->get(); + 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/IssueController.php b/server/src/Http/Controllers/Internal/v1/IssueController.php index 7cdcd5cd..1c8d0693 100644 --- a/server/src/Http/Controllers/Internal/v1/IssueController.php +++ b/server/src/Http/Controllers/Internal/v1/IssueController.php @@ -18,22 +18,6 @@ class IssueController extends FleetOpsController */ public $resource = 'issue'; - protected array $selections = []; - - public function __construct(array $selections = []) - { - $this->selections = $selections; - } - - public function collection() - { - if ($this->selections) { - return Issue::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get(); - } - - return Issue::where('company_uuid', session('company'))->get(); - } - /** * Export the issue to excel or csv. * @@ -44,10 +28,8 @@ public function export(ExportRequest $request) { $format = $request->input('format', 'xlsx'); $selections = $request->input('selections', []); + info("format:::::",[$selections]); $fileName = trim(Str::slug('issue-' . date('Y-m-d-H:i')) . '.' . $format); - return Excel::download(new IssueExport($selections), $fileName); } - -} - +} \ No newline at end of file From 675980516dc90bb26764234323302586bfc09253 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Wed, 15 May 2024 17:01:13 +0800 Subject: [PATCH 04/12] fixed issue file export --- addon/controllers/management/issues/index.js | 5 +++-- server/src/Exports/IssueExport.php | 3 --- .../Internal/v1/IssueController.php | 3 +-- server/src/routes.php | 20 +++++++++---------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/addon/controllers/management/issues/index.js b/addon/controllers/management/issues/index.js index c5157fa3..d561d52b 100644 --- a/addon/controllers/management/issues/index.js +++ b/addon/controllers/management/issues/index.js @@ -390,8 +390,9 @@ export default class ManagementIssuesIndexController extends BaseController { * * @void */ - @action exportIssues() { - this.crud.export('issue'); + @action exportIssues() { + const selections = this.table.selectedRows.map((_) => _.id); + this.crud.export('issue', { params: { selections } }); } /** diff --git a/server/src/Exports/IssueExport.php b/server/src/Exports/IssueExport.php index 18a8724f..5862d49f 100644 --- a/server/src/Exports/IssueExport.php +++ b/server/src/Exports/IssueExport.php @@ -69,9 +69,6 @@ public function columnFormats(): array */ public function collection() { - info("Selections:", [$this->selections]); - info("Session company:", [session("company")]); - if (!empty($this->selections)) { return Issue::where("company_uuid", session("company")) ->whereIn("uuid", $this->selections) diff --git a/server/src/Http/Controllers/Internal/v1/IssueController.php b/server/src/Http/Controllers/Internal/v1/IssueController.php index 1c8d0693..084eb9dc 100644 --- a/server/src/Http/Controllers/Internal/v1/IssueController.php +++ b/server/src/Http/Controllers/Internal/v1/IssueController.php @@ -27,8 +27,7 @@ class IssueController extends FleetOpsController public function export(ExportRequest $request) { $format = $request->input('format', 'xlsx'); - $selections = $request->input('selections', []); - info("format:::::",[$selections]); + $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/routes.php b/server/src/routes.php index dc3ce006..bdd2a065 100644 --- a/server/src/routes.php +++ b/server/src/routes.php @@ -275,7 +275,7 @@ function ($router) { $router->fleetbaseRoutes( 'contacts', function ($router, $controller) { - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->get('facilitators/{id}', $controller('getAsFacilitator')); $router->get('customers/{id}', $controller('getAsCustomer')); $router->delete('bulk-delete', $controller('bulkDelete')); @@ -286,7 +286,7 @@ function ($router, $controller) { function ($router, $controller) { $router->get('statuses', $controller('statuses')); $router->get('avatars', $controller('avatars')); - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->delete('bulk-delete', $controller('bulkDelete')); } ); @@ -298,21 +298,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')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->delete('bulk-delete', $controller('bulkDelete')); } ); $router->fleetbaseRoutes( 'fuel-reports', function ($router, $controller) { - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->delete('bulk-delete', $controller('bulkDelete')); } ); $router->fleetbaseRoutes( 'issues', function ($router, $controller) { - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->delete('bulk-delete', $controller('bulkDelete')); } ); @@ -349,7 +349,7 @@ function ($router, $controller) { $router->get('search', $controller('search'))->middleware('cache.headers:private;max_age=3600'); $router->get('lookup', $controller('geocode'))->middleware('cache.headers:private;max_age=3600'); $router->get('avatars', $controller('avatars')); - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->delete('bulk-delete', $controller('bulkDelete')); } ); @@ -359,7 +359,7 @@ function ($router, $controller) { $router->fleetbaseRoutes( 'service-areas', function ($router, $controller) { - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->delete('bulk-delete', $controller('bulkDelete')); } ); @@ -374,7 +374,7 @@ function ($router, $controller) { 'service-rates', function ($router, $controller) { $router->get('for-route', $controller('getServicesForRoute')); - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); } ); $router->fleetbaseRoutes('tracking-numbers'); @@ -384,7 +384,7 @@ function ($router, $controller) { function ($router, $controller) { $router->get('statuses', $controller('statuses')); $router->get('avatars', $controller('avatars')); - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->delete('bulk-delete', $controller('bulkDelete')); } ); @@ -393,7 +393,7 @@ function ($router, $controller) { 'vendors', function ($router, $controller) { $router->get('statuses', $controller('statuses')); - $router->get('export', $controller('export')); + $router->match(['get', 'post'], 'export', $controller('export')); $router->get('facilitators/{id}', $controller('getAsFacilitator')); $router->get('customers/{id}', $controller('getAsCustomer')); $router->delete('bulk-delete', $controller('bulkDelete')); From 0b4a21d31bbde04143f8c9b12f6002c6e9146172 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Wed, 15 May 2024 17:36:06 +0800 Subject: [PATCH 05/12] added selection export in controllers --- .../controllers/management/contacts/index.js | 3 +- addon/controllers/management/drivers/index.js | 3 +- addon/controllers/management/fleets/index.js | 3 +- addon/controllers/management/places/index.js | 3 +- .../controllers/management/vehicles/index.js | 3 +- addon/controllers/management/vendors/index.js | 3 +- addon/controllers/operations/orders/index.js | 2 +- .../operations/service-rates/index.js | 3 +- server/src/Exports/FuelReportExport.php | 72 +++++++++++++++++++ .../Internal/v1/ContactController.php | 4 +- .../Internal/v1/DriverController.php | 3 +- .../Internal/v1/FleetController.php | 3 +- .../Internal/v1/FuelReportController.php | 18 +++++ .../Internal/v1/PlaceController.php | 3 +- .../Internal/v1/ServiceAreaController.php | 3 +- .../Internal/v1/ServiceRateController.php | 17 ----- .../Internal/v1/VehicleController.php | 3 +- .../Internal/v1/VendorController.php | 3 +- 18 files changed, 119 insertions(+), 33 deletions(-) create mode 100644 server/src/Exports/FuelReportExport.php 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/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 57c78a6e..52be762d 100644 --- a/addon/controllers/operations/orders/index.js +++ b/addon/controllers/operations/orders/index.js @@ -790,7 +790,7 @@ export default class OperationsOrdersIndexController extends BaseController { * @memberof OperationsOrdersIndexController */ @action exportOrders() { - this.crud.export('order'); + 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/server/src/Exports/FuelReportExport.php b/server/src/Exports/FuelReportExport.php new file mode 100644 index 00000000..02304c61 --- /dev/null +++ b/server/src/Exports/FuelReportExport.php @@ -0,0 +1,72 @@ +selections = $selections; + } + + public function map($fleet): array + { + return [ + $fleet->public_id, + $fleet->reporter, + $fleet->driver_name, + $fleet->vehicle_name, + $fleet->status, + $fleet->volume, + $fleet->odometer, + Date::dateTimeToExcel($fleet->created_at), + ]; + } + + public function headings(): array + { + return [ + 'ID', + 'Reporter', + 'Driver', + 'Vehicle', + 'Status', + 'Volume', + 'Odometer', + 'Created', + ]; + } + + public function columnFormats(): array + { + return [ + 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY, + 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY, + 'G' => 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/Http/Controllers/Internal/v1/ContactController.php b/server/src/Http/Controllers/Internal/v1/ContactController.php index b6c140b9..868453a1 100644 --- a/server/src/Http/Controllers/Internal/v1/ContactController.php +++ b/server/src/Http/Controllers/Internal/v1/ContactController.php @@ -62,8 +62,8 @@ public function getAsCustomer($id) 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 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..f33f33fa 100644 --- a/server/src/Http/Controllers/Internal/v1/DriverController.php +++ b/server/src/Http/Controllers/Internal/v1/DriverController.php @@ -335,9 +335,10 @@ public function avatars() public static function export(ExportRequest $request) { $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..f6b44ad5 100644 --- a/server/src/Http/Controllers/Internal/v1/FleetController.php +++ b/server/src/Http/Controllers/Internal/v1/FleetController.php @@ -31,9 +31,10 @@ class FleetController extends FleetOpsController public static function export(ExportRequest $request) { $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..b379b83d 100644 --- a/server/src/Http/Controllers/Internal/v1/FuelReportController.php +++ b/server/src/Http/Controllers/Internal/v1/FuelReportController.php @@ -3,6 +3,11 @@ namespace Fleetbase\FleetOps\Http\Controllers\Internal\v1; use Fleetbase\FleetOps\Http\Controllers\FleetOpsController; +use Fleetbase\Http\Requests\ExportRequest; +use Illuminate\Support\Str; +use Fleetbase\FleetOps\Exports\FuelReportExport; +use Maatwebsite\Excel\Facades\Excel; + class FuelReportController extends FleetOpsController { @@ -12,4 +17,17 @@ 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/PlaceController.php b/server/src/Http/Controllers/Internal/v1/PlaceController.php index 1ffb0074..69fb4618 100644 --- a/server/src/Http/Controllers/Internal/v1/PlaceController.php +++ b/server/src/Http/Controllers/Internal/v1/PlaceController.php @@ -124,9 +124,10 @@ public function geocode(ExportRequest $request) public function export(ExportRequest $request) { $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..e8399f43 100644 --- a/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php +++ b/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php @@ -25,8 +25,9 @@ class ServiceAreaController extends FleetOpsController public static function export(ExportRequest $request) { $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 661c3f2c..341615e9 100644 --- a/server/src/Http/Controllers/Internal/v1/ServiceRateController.php +++ b/server/src/Http/Controllers/Internal/v1/ServiceRateController.php @@ -20,14 +20,6 @@ class ServiceRateController extends FleetOpsController */ public $resource = 'service_rate'; - - protected array $selections = []; - - public function __construct(array $selections = []) - { - $this->selections = $selections; - } - /** * Creates a record with request payload. * @@ -60,15 +52,6 @@ function ($query) use ($request) { return response()->json($applicableServiceRates); } - 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(); - } - /** * Export the service rate to excel or csv. * diff --git a/server/src/Http/Controllers/Internal/v1/VehicleController.php b/server/src/Http/Controllers/Internal/v1/VehicleController.php index 4864e082..eb224f68 100644 --- a/server/src/Http/Controllers/Internal/v1/VehicleController.php +++ b/server/src/Http/Controllers/Internal/v1/VehicleController.php @@ -58,8 +58,9 @@ public function avatars() public static function export(ExportRequest $request) { $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..ad8bc515 100644 --- a/server/src/Http/Controllers/Internal/v1/VendorController.php +++ b/server/src/Http/Controllers/Internal/v1/VendorController.php @@ -64,9 +64,10 @@ public function getAsCustomer($id) public static function export(ExportRequest $request) { $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); } /** From a221ce509d47c186467fcdc3237e38cce68cb456 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 17 May 2024 11:23:14 +0800 Subject: [PATCH 06/12] preparing next release --- composer.json | 2 +- extension.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 6d7e07d6..72a252c2 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", 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..24360991 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" From 0be31beaff22cff1e9be25510f204defd33d1ff3 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 17 May 2024 11:42:47 +0800 Subject: [PATCH 07/12] fix orders export bug, ran linter --- addon/controllers/management/issues/index.js | 2 +- addon/controllers/operations/orders/index.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/controllers/management/issues/index.js b/addon/controllers/management/issues/index.js index d561d52b..7b4c440d 100644 --- a/addon/controllers/management/issues/index.js +++ b/addon/controllers/management/issues/index.js @@ -390,7 +390,7 @@ export default class ManagementIssuesIndexController extends BaseController { * * @void */ - @action exportIssues() { + @action exportIssues() { const selections = this.table.selectedRows.map((_) => _.id); this.crud.export('issue', { params: { selections } }); } diff --git a/addon/controllers/operations/orders/index.js b/addon/controllers/operations/orders/index.js index 68bd3df4..0d41d8cf 100644 --- a/addon/controllers/operations/orders/index.js +++ b/addon/controllers/operations/orders/index.js @@ -822,6 +822,7 @@ export default class OperationsOrdersIndexController extends BaseController { * @memberof OperationsOrdersIndexController */ @action exportOrders() { + const selections = this.table.selectedRows.map((_) => _.id); this.crud.export('order', { params: { selections } }); } From efffe6a258a76bfaed905a9a9f382591627828a1 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Fri, 17 May 2024 12:19:44 +0800 Subject: [PATCH 08/12] created order import --- server/src/Exports/OrderExport.php | 78 +++++++++++++++++++ .../Internal/v1/IssueController.php | 1 - .../Internal/v1/OrderController.php | 16 ++++ server/src/routes.php | 1 + 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 server/src/Exports/OrderExport.php diff --git a/server/src/Exports/OrderExport.php b/server/src/Exports/OrderExport.php new file mode 100644 index 00000000..805be54b --- /dev/null +++ b/server/src/Exports/OrderExport.php @@ -0,0 +1,78 @@ +selections = $selections; + } + + public function map($order): array + { + return [ + $order->public_id, + $order->driver_name, + $order->pickup_name, + $order->dropoff_name, + $order->customer_name, + $order->scheduled_at, + data_get($this, 'trackingNumber.tracking_number'), + $order->status, + Date::dateTimeToExcel($order->created_at), + ]; + } + + public function headings(): array + { + return [ + 'ID', + 'Driver', + 'PickUp', + 'DropOff', + 'Customer', + 'ScheduledAt', + 'TrackingNumber', + 'Status', + 'Created', + ]; + } + + public function columnFormats(): array + { + return [ + 'E' => NumberFormat::FORMAT_DATE_DDMMYYYY, + 'F' => NumberFormat::FORMAT_DATE_DDMMYYYY, + 'G' => 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) + ->get(); + } + + return Order::where("company_uuid", session("company"))->get(); + } +} diff --git a/server/src/Http/Controllers/Internal/v1/IssueController.php b/server/src/Http/Controllers/Internal/v1/IssueController.php index 084eb9dc..11f34143 100644 --- a/server/src/Http/Controllers/Internal/v1/IssueController.php +++ b/server/src/Http/Controllers/Internal/v1/IssueController.php @@ -5,7 +5,6 @@ use Fleetbase\Http\Requests\ExportRequest; use Fleetbase\FleetOps\Exports\IssueExport; use Illuminate\Support\Str; -use Fleetbase\FleetOps\Models\Issue; use Maatwebsite\Excel\Facades\Excel; use Fleetbase\FleetOps\Http\Controllers\FleetOpsController; diff --git a/server/src/Http/Controllers/Internal/v1/OrderController.php b/server/src/Http/Controllers/Internal/v1/OrderController.php index dfcd23dc..becc7f3c 100644 --- a/server/src/Http/Controllers/Internal/v1/OrderController.php +++ b/server/src/Http/Controllers/Internal/v1/OrderController.php @@ -25,6 +25,8 @@ use Fleetbase\Models\File; use Fleetbase\Models\Type; use Illuminate\Http\Request; +use Fleetbase\FleetOps\Exports\OrderExport; +use Fleetbase\Http\Requests\ExportRequest; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; @@ -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. + * + * @param ExportRequest $request + * @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/routes.php b/server/src/routes.php index 3e72013a..e598c5d0 100644 --- a/server/src/routes.php +++ b/server/src/routes.php @@ -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'); From 77a105f849308995196c9e4b6476f99261323eac Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 17 May 2024 13:14:29 +0800 Subject: [PATCH 09/12] ran linter and made minor tweaks to exports --- server/src/Exports/ContactExport.php | 11 +++---- server/src/Exports/DriverExport.php | 3 +- server/src/Exports/FleetExport.php | 9 +++-- server/src/Exports/FuelReportExport.php | 9 +++-- server/src/Exports/IssueExport.php | 15 +++------ server/src/Exports/OrderExport.php | 33 +++++++++---------- server/src/Exports/PlaceExport.php | 11 +++---- server/src/Exports/ServiceAreaExport.php | 11 +++---- server/src/Exports/ServiceRate.php | 9 +++-- server/src/Exports/VehicleExport.php | 11 +++---- server/src/Exports/VendorExport.php | 11 +++---- .../Internal/v1/ContactController.php | 5 +-- .../Internal/v1/DriverController.php | 4 +-- .../Internal/v1/FleetController.php | 4 +-- .../Internal/v1/FuelReportController.php | 8 ++--- .../Internal/v1/IssueController.php | 12 +++---- .../Internal/v1/OrderController.php | 12 +++---- .../Internal/v1/PlaceController.php | 4 +-- .../Internal/v1/ServiceAreaController.php | 4 +-- .../Internal/v1/ServiceRateController.php | 6 ++-- .../Internal/v1/VehicleController.php | 6 ++-- .../Internal/v1/VendorController.php | 4 +-- server/src/Models/Order.php | 10 ++++++ 23 files changed, 103 insertions(+), 109 deletions(-) diff --git a/server/src/Exports/ContactExport.php b/server/src/Exports/ContactExport.php index a12c54d7..f0cf3dbf 100644 --- a/server/src/Exports/ContactExport.php +++ b/server/src/Exports/ContactExport.php @@ -7,7 +7,6 @@ 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 @@ -27,7 +26,7 @@ public function map($contact): array $contact->name, $contact->email, $contact->phone, - Date::dateTimeToExcel($contact->created_at), + $contact->created_at, ]; } @@ -58,12 +57,12 @@ public function columnFormats(): array */ public function collection() { - if ($this->selections) { - return Contact::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + if ($this->selections) { + return Contact::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return Contact::where("company_uuid", session("company"))->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..7f45abc4 100644 --- a/server/src/Exports/DriverExport.php +++ b/server/src/Exports/DriverExport.php @@ -7,7 +7,6 @@ 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 @@ -30,7 +29,7 @@ public function map($driver): array $driver->phone, $driver->drivers_license_number, $driver->country, - Date::dateTimeToExcel($driver->created_at), + $driver->created_at, ]; } diff --git a/server/src/Exports/FleetExport.php b/server/src/Exports/FleetExport.php index 0c7702da..213c9aff 100644 --- a/server/src/Exports/FleetExport.php +++ b/server/src/Exports/FleetExport.php @@ -7,7 +7,6 @@ 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 @@ -26,7 +25,7 @@ public function map($fleet): array $fleet->internal_id, $fleet->name, $fleet->zone_uuid, - Date::dateTimeToExcel($fleet->created_at), + $fleet->created_at, ]; } @@ -56,11 +55,11 @@ public function columnFormats(): array public function collection() { if ($this->selections) { - return Fleet::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + return Fleet::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return Fleet::where("company_uuid", session("company"))->get(); + return Fleet::where('company_uuid', session('company'))->get(); } } diff --git a/server/src/Exports/FuelReportExport.php b/server/src/Exports/FuelReportExport.php index 02304c61..415ea58e 100644 --- a/server/src/Exports/FuelReportExport.php +++ b/server/src/Exports/FuelReportExport.php @@ -7,7 +7,6 @@ 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 FuelReportExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting @@ -29,7 +28,7 @@ public function map($fleet): array $fleet->status, $fleet->volume, $fleet->odometer, - Date::dateTimeToExcel($fleet->created_at), + $fleet->created_at, ]; } @@ -62,11 +61,11 @@ public function columnFormats(): array public function collection() { if ($this->selections) { - return FuelReport::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + return FuelReport::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return FuelReport::where("company_uuid", session("company"))->get(); + return FuelReport::where('company_uuid', session('company'))->get(); } } diff --git a/server/src/Exports/IssueExport.php b/server/src/Exports/IssueExport.php index 5862d49f..09424f91 100644 --- a/server/src/Exports/IssueExport.php +++ b/server/src/Exports/IssueExport.php @@ -7,14 +7,9 @@ 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 IssueExport implements - FromCollection, - WithHeadings, - WithMapping, - WithColumnFormatting +class IssueExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { protected array $selections = []; @@ -35,7 +30,7 @@ public function map($issue): array $issue->driver_name, $issue->vehicle_name, $issue->status, - Date::dateTimeToExcel($issue->created_at), + $issue->created_at, ]; } @@ -70,11 +65,11 @@ public function columnFormats(): array public function collection() { if (!empty($this->selections)) { - return Issue::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + return Issue::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return Issue::where("company_uuid", session("company"))->get(); + return Issue::where('company_uuid', session('company'))->get(); } } diff --git a/server/src/Exports/OrderExport.php b/server/src/Exports/OrderExport.php index 805be54b..c769cbaa 100644 --- a/server/src/Exports/OrderExport.php +++ b/server/src/Exports/OrderExport.php @@ -7,14 +7,9 @@ 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 OrderExport implements - FromCollection, - WithHeadings, - WithMapping, - WithColumnFormatting +class OrderExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting { protected array $selections = []; @@ -27,14 +22,16 @@ 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->customer_name, $order->scheduled_at, data_get($this, 'trackingNumber.tracking_number'), - $order->status, - Date::dateTimeToExcel($order->created_at), + $order->status, + $order->created_at, ]; } @@ -42,14 +39,16 @@ public function headings(): array { return [ 'ID', + 'Internal ID', 'Driver', - 'PickUp', - 'DropOff', + 'Vehicle', 'Customer', - 'ScheduledAt', - 'TrackingNumber', + 'Pick Up', + 'Drop Off', + 'Date Scheduled', + 'Tracking Number', 'Status', - 'Created', + 'Date Created', ]; } @@ -68,11 +67,9 @@ public function columnFormats(): array public function collection() { if (!empty($this->selections)) { - return Order::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) - ->get(); + 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(); + return Order::where('company_uuid', session('company'))->get(); } } diff --git a/server/src/Exports/PlaceExport.php b/server/src/Exports/PlaceExport.php index 8cbd44ab..c8211912 100644 --- a/server/src/Exports/PlaceExport.php +++ b/server/src/Exports/PlaceExport.php @@ -7,7 +7,6 @@ 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 @@ -27,7 +26,7 @@ public function map($place): array $place->display_name, $place->address, $place->country_name, - Date::dateTimeToExcel($place->created_at), + $place->created_at, ]; } @@ -57,12 +56,12 @@ public function columnFormats(): array */ public function collection() { - if ($this->selections) { - return Place::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + if ($this->selections) { + return Place::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return Place::where("company_uuid", session("company"))->get(); + return Place::where('company_uuid', session('company'))->get(); } } diff --git a/server/src/Exports/ServiceAreaExport.php b/server/src/Exports/ServiceAreaExport.php index 8d0f0bbc..137a5857 100644 --- a/server/src/Exports/ServiceAreaExport.php +++ b/server/src/Exports/ServiceAreaExport.php @@ -7,7 +7,6 @@ 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 @@ -30,7 +29,7 @@ public function map($service_area): array $service_area->phone, $service_area->drivers_license_number, $service_area->country, - Date::dateTimeToExcel($service_area->created_at), + $service_area->created_at, ]; } @@ -60,12 +59,12 @@ public function columnFormats(): array */ public function collection() { - if ($this->selections) { - return ServiceArea::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + if ($this->selections) { + return ServiceArea::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return ServiceArea::where("company_uuid", session("company"))->get(); + return ServiceArea::where('company_uuid', session('company'))->get(); } } diff --git a/server/src/Exports/ServiceRate.php b/server/src/Exports/ServiceRate.php index e951fa55..e7ca5733 100644 --- a/server/src/Exports/ServiceRate.php +++ b/server/src/Exports/ServiceRate.php @@ -7,7 +7,6 @@ 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 ServiceRateExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting @@ -27,7 +26,7 @@ public function map($service_rate): array $service_rate->vendor_name, $service_rate->vehicle_name, $service_rate->country, - Date::dateTimeToExcel($service_rate->created_at), + $service_rate->created_at, ]; } @@ -57,11 +56,11 @@ public function columnFormats(): array public function collection() { if ($this->selections) { - return ServiceRate::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + return ServiceRate::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return ServiceRate::where("company_uuid", session("company"))->get(); + return ServiceRate::where('company_uuid', session('company'))->get(); } } diff --git a/server/src/Exports/VehicleExport.php b/server/src/Exports/VehicleExport.php index 32a6d282..dd761e85 100644 --- a/server/src/Exports/VehicleExport.php +++ b/server/src/Exports/VehicleExport.php @@ -7,7 +7,6 @@ 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 @@ -27,7 +26,7 @@ public function map($vehicle): array $vehicle->display_name, $vehicle->driver_name, $vehicle->model_data, - Date::dateTimeToExcel($vehicle->created_at), + $vehicle->created_at, ]; } @@ -59,12 +58,12 @@ public function columnFormats(): array */ public function collection() { - if ($this->selections) { - return Vehicle::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + if ($this->selections) { + return Vehicle::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return Vehicle::where("company_uuid", session("company"))->get(); + return Vehicle::where('company_uuid', session('company'))->get(); } } diff --git a/server/src/Exports/VendorExport.php b/server/src/Exports/VendorExport.php index 69c9435c..4569971c 100644 --- a/server/src/Exports/VendorExport.php +++ b/server/src/Exports/VendorExport.php @@ -7,7 +7,6 @@ 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 @@ -28,7 +27,7 @@ public function map($vendor): array $vendor->place_uuid, $vendor->email, $vendor->phone, - Date::dateTimeToExcel($vendor->created_at), + $vendor->created_at, ]; } @@ -59,12 +58,12 @@ public function columnFormats(): array */ public function collection() { - if ($this->selections) { - return Vendor::where("company_uuid", session("company")) - ->whereIn("uuid", $this->selections) + if ($this->selections) { + return Vendor::where('company_uuid', session('company')) + ->whereIn('uuid', $this->selections) ->get(); } - return Vendor::where("company_uuid", session("company"))->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 868453a1..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'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('contacts-' . date('Y-m-d-H:i')) . '.' . $format); + $fileName = trim(Str::slug('contacts-' . date('Y-m-d-H:i')) . '.' . $format); + 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 f33f33fa..a8faa350 100644 --- a/server/src/Http/Controllers/Internal/v1/DriverController.php +++ b/server/src/Http/Controllers/Internal/v1/DriverController.php @@ -334,9 +334,9 @@ public function avatars() */ public static function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('drivers-' . date('Y-m-d-H:i')) . '.' . $format); + $fileName = trim(Str::slug('drivers-' . date('Y-m-d-H:i')) . '.' . $format); 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 f6b44ad5..da0d7810 100644 --- a/server/src/Http/Controllers/Internal/v1/FleetController.php +++ b/server/src/Http/Controllers/Internal/v1/FleetController.php @@ -30,9 +30,9 @@ class FleetController extends FleetOpsController */ public static function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('fleets-' . date('Y-m-d-H:i')) . '.' . $format); + $fileName = trim(Str::slug('fleets-' . date('Y-m-d-H:i')) . '.' . $format); 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 b379b83d..09a2ea10 100644 --- a/server/src/Http/Controllers/Internal/v1/FuelReportController.php +++ b/server/src/Http/Controllers/Internal/v1/FuelReportController.php @@ -2,13 +2,12 @@ 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 Fleetbase\FleetOps\Exports\FuelReportExport; use Maatwebsite\Excel\Facades\Excel; - class FuelReportController extends FleetOpsController { /** @@ -25,9 +24,10 @@ class FuelReportController extends FleetOpsController */ public function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('fuel_report-' . date('Y-m-d-H:i')) . '.' . $format); + $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 11f34143..25fa00a2 100644 --- a/server/src/Http/Controllers/Internal/v1/IssueController.php +++ b/server/src/Http/Controllers/Internal/v1/IssueController.php @@ -2,11 +2,11 @@ namespace Fleetbase\FleetOps\Http\Controllers\Internal\v1; -use Fleetbase\Http\Requests\ExportRequest; 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; -use Fleetbase\FleetOps\Http\Controllers\FleetOpsController; class IssueController extends FleetOpsController { @@ -20,14 +20,14 @@ class IssueController extends FleetOpsController /** * Export the issue to excel or csv. * - * @param ExportRequest $request * @return \Illuminate\Http\Response */ public function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('issue-' . date('Y-m-d-H:i')) . '.' . $format); + $fileName = trim(Str::slug('issue-' . date('Y-m-d-H:i')) . '.' . $format); + return Excel::download(new IssueExport($selections), $fileName); } -} \ No newline at end of file +} diff --git a/server/src/Http/Controllers/Internal/v1/OrderController.php b/server/src/Http/Controllers/Internal/v1/OrderController.php index becc7f3c..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,13 +21,12 @@ 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; use Fleetbase\Models\Type; use Illuminate\Http\Request; -use Fleetbase\FleetOps\Exports\OrderExport; -use Fleetbase\Http\Requests\ExportRequest; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; @@ -661,17 +661,17 @@ public function label(string $publicId, Request $request) return response()->error('Unable to render label.'); } - /** + /** * Export the issue to excel or csv. * - * @param ExportRequest $request * @return \Illuminate\Http\Response */ public function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('order-' . date('Y-m-d-H:i')) . '.' . $format); + $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 706d1e30..a10f188b 100644 --- a/server/src/Http/Controllers/Internal/v1/PlaceController.php +++ b/server/src/Http/Controllers/Internal/v1/PlaceController.php @@ -123,9 +123,9 @@ public function geocode(ExportRequest $request) */ public function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('places-' . date('Y-m-d-H:i')) . '.' . $format); + $fileName = trim(Str::slug('places-' . date('Y-m-d-H:i')) . '.' . $format); 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 e8399f43..6746c1c0 100644 --- a/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php +++ b/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php @@ -24,9 +24,9 @@ class ServiceAreaController extends FleetOpsController */ public static function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('service-areas-' . date('Y-m-d-H:i')) . '.' . $format); + $fileName = trim(Str::slug('service-areas-' . date('Y-m-d-H:i')) . '.' . $format); 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 341615e9..fb90f555 100644 --- a/server/src/Http/Controllers/Internal/v1/ServiceRateController.php +++ b/server/src/Http/Controllers/Internal/v1/ServiceRateController.php @@ -7,8 +7,8 @@ use Fleetbase\FleetOps\Http\Controllers\FleetOpsController; use Fleetbase\FleetOps\Models\ServiceRate; use Fleetbase\Http\Requests\ExportRequest; -use Illuminate\Support\Str; use Illuminate\Http\Request; +use Illuminate\Support\Str; use Maatwebsite\Excel\Facades\Excel; class ServiceRateController extends FleetOpsController @@ -59,9 +59,9 @@ function ($query) use ($request) { */ public static function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('contacts-' . date('Y-m-d-H:i')) . '.' . $format); + $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 eb224f68..384bb78a 100644 --- a/server/src/Http/Controllers/Internal/v1/VehicleController.php +++ b/server/src/Http/Controllers/Internal/v1/VehicleController.php @@ -57,10 +57,10 @@ public function avatars() */ public static function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('vehicles-' . date('Y-m-d-H:i')) . '.' . $format); + $fileName = trim(Str::slug('vehicles-' . date('Y-m-d-H:i')) . '.' . $format); - return Excel::download(new VehicleExport( $selections), $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 ad8bc515..d2a68882 100644 --- a/server/src/Http/Controllers/Internal/v1/VendorController.php +++ b/server/src/Http/Controllers/Internal/v1/VendorController.php @@ -63,9 +63,9 @@ public function getAsCustomer($id) */ public static function export(ExportRequest $request) { - $format = $request->input('format', 'xlsx'); + $format = $request->input('format', 'xlsx'); $selections = $request->array('selections'); - $fileName = trim(Str::slug('vendors-' . date('Y-m-d-H:i')) . '.' . $format); + $fileName = trim(Str::slug('vendors-' . date('Y-m-d-H:i')) . '.' . $format); 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. * From 2e4578316467b9836123a0339664e3db63c1dddc Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 17 May 2024 13:17:14 +0800 Subject: [PATCH 10/12] fix tracking number in orders export --- server/src/Exports/OrderExport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/Exports/OrderExport.php b/server/src/Exports/OrderExport.php index c769cbaa..c3918a3c 100644 --- a/server/src/Exports/OrderExport.php +++ b/server/src/Exports/OrderExport.php @@ -29,7 +29,7 @@ public function map($order): array $order->pickup_name, $order->dropoff_name, $order->scheduled_at, - data_get($this, 'trackingNumber.tracking_number'), + $order->trackingNumber ? $order->trackingNumber->tracking_number : null, $order->status, $order->created_at, ]; From 724386ae6f3da36dfc5310f9cafa3b9bd4b52a10 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 17 May 2024 14:39:51 +0800 Subject: [PATCH 11/12] fix all export formating, values, and implementation --- .../operations/service-rates/index.hbs | 11 +---- server/src/Exports/ContactExport.php | 13 +++--- server/src/Exports/DriverExport.php | 10 ++--- server/src/Exports/FleetExport.php | 15 +++---- server/src/Exports/FuelReportExport.php | 27 ++++++------ server/src/Exports/IssueExport.php | 13 +++--- server/src/Exports/OrderExport.php | 8 ++-- server/src/Exports/PlaceExport.php | 29 +++++++------ server/src/Exports/ServiceAreaExport.php | 41 ++++++++----------- ...{ServiceRate.php => ServiceRateExport.php} | 36 +++++++++------- server/src/Exports/VehicleExport.php | 19 ++++----- server/src/Exports/VendorExport.php | 14 +++---- 12 files changed, 113 insertions(+), 123 deletions(-) rename server/src/Exports/{ServiceRate.php => ServiceRateExport.php} (56%) 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 @@