diff --git a/app/Classes/Modules/Exports/Services/ExportsContainerPackingList.php b/app/Classes/Modules/Exports/Services/ExportsContainerPackingList.php new file mode 100644 index 00000000..2371962b --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsContainerPackingList.php @@ -0,0 +1,92 @@ +id = $id; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + return Container::find($this->id)->packingLists(); + } + + /** + * @param Company $container + * + * @return array + */ + public function map($packing_list): array + { + $order = $packing_list->owner()->first(); + $address = $order->addresses()->first(); + $company = $order->companyModule()->first(); + $connection = $company->inviters()->withPivot('invitee_reference')->first(); + $marking = $connection ? $connection->pivot->invitee_reference:''; + + $quantity = 0; + $cbm = 0; + foreach ($packing_list->packages()->get() as $key => $row) { + $quantity += $row->quantity; + $cbm += (($row->width / 100) * ($row->height / 100) * ($row->length / 100)) * $row->quantity; + } + + $status = ''; + if ($packing_list->transports()->count() > 0) { + $status = 'Delivery'; + } + elseif ($packing_list->status == ApprovalStatus::SUSPENDED) { + $status = 'On Hold'; + } + elseif ($packing_list->status != ApprovalStatus::SUSPENDED) { + $status = 'Release'; + } + + return [ + $marking, + $order->reference, + $quantity, + $cbm, + $status, + $address->contacts()->first() ? $address->contacts()->first()->phone : 'n/a', + $address->contacts()->first() ? $address->contacts()->first()->reference : 'n/a', + $address->street_one . ' ' . $address->street_two . ' ' . $address->district->name . ' ' . $address->post_code . ' ' . $address->state->name . ' ' . $address->country->name, + $address->remarks()->first() ? $address->remarks()->first()->content : 'n/a', + $packing_list->transports()->first() ? $packing_list->transports()->current_schedule->eta : 'n/a' + ]; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Exports/ExportContainerPackingListController.php b/app/Http/Controllers/Exports/ExportContainerPackingListController.php new file mode 100644 index 00000000..6e5d845d --- /dev/null +++ b/app/Http/Controllers/Exports/ExportContainerPackingListController.php @@ -0,0 +1,19 @@ +headers->set('Authorization', 'Bearer '.$token); + $exportsContainerPackingList->setId($request->route('id')); + return $exportsContainerPackingList->download('customer-container-packing-list.csv', Excel::CSV, ['Content-Type' => 'text/csv']); + } +} diff --git a/resources/assets/vue/components/containers/elements/ContainerComponent.vue b/resources/assets/vue/components/containers/elements/ContainerComponent.vue index 098a1c90..0aa0aa45 100644 --- a/resources/assets/vue/components/containers/elements/ContainerComponent.vue +++ b/resources/assets/vue/components/containers/elements/ContainerComponent.vue @@ -72,6 +72,11 @@