mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
export parcel summary
This commit is contained in:
@@ -20,7 +20,7 @@ class ExportsParcel implements WithMultipleSheets
|
||||
$sheets = [];
|
||||
|
||||
$sheets[] = new ContainersSheet();
|
||||
$sheets[] = new PackingListsSheet();
|
||||
// $sheets[] = new PackingListsSheet();
|
||||
|
||||
return $sheets;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class ContainersSheet implements WithHeadings, WithHeadingRow, WithMapping, Shou
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Container::query();
|
||||
return Container::limit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,8 +55,8 @@ class ContainersSheet implements WithHeadings, WithHeadingRow, WithMapping, Shou
|
||||
*/
|
||||
public function map($container): array
|
||||
{
|
||||
$transport = $container->transports()->where('status', ApprovalStatus::APPROVED)->first();
|
||||
$currentSchedule = $transport ? $transport->schedules()->where('status', ApprovalStatus::APPROVED)->first() : null;
|
||||
$transport = $container->transports()->first();
|
||||
$currentSchedule = $transport ? $transport->schedules()->where('status', '!=', ApprovalStatus::EXPIRED)->first() : null;
|
||||
$scheduleHistory = $transport ? $transport->schedules()->where('status', ApprovalStatus::EXPIRED)->get() : null;
|
||||
|
||||
$status = 'Loaded';
|
||||
@@ -74,7 +74,7 @@ class ContainersSheet implements WithHeadings, WithHeadingRow, WithMapping, Shou
|
||||
$status = 'Pending deliveries';
|
||||
}
|
||||
|
||||
if(!$container->packinglists()->whereDoesntHave('transports')){
|
||||
if(!$container->packinglists()->whereDoesntHave('transports')->get()){
|
||||
$status = 'Complete';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ class PackingListsSheet implements WithHeadings, WithHeadingRow, WithMapping, Sh
|
||||
'Total CBM',
|
||||
'Container No.',
|
||||
'Delivery Date',
|
||||
'Supplier',
|
||||
'Warehouse No.',
|
||||
'Warehouse',
|
||||
'Warehouse District',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -53,14 +53,15 @@ class PackingListsSheet implements WithHeadings, WithHeadingRow, WithMapping, Sh
|
||||
public function collection()
|
||||
{
|
||||
$packingLists = PackingList::where('status', '=', 2)->whereIn('type', [PackingListType::WAREHOUSE_RECEIVE_LIST, PackingListType::SHIPPING_PACKING_LIST])->get();
|
||||
|
||||
return $packingLists->filter(function ($packingList) {
|
||||
|
||||
if($packingList->type === PackingListType::SHIPPING_PACKING_LIST){
|
||||
$warehouseArrival = PackingList::where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->where('reference', $packingList->reference)->get();
|
||||
return $warehouseArrival ? true : false;
|
||||
return $warehouseArrival ? false : true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ class PackingListsSheet implements WithHeadings, WithHeadingRow, WithMapping, Sh
|
||||
{
|
||||
|
||||
$warehouseArrivalList = $packingList;
|
||||
$shippingList = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->where('reference', $packingList->reference)->get();
|
||||
$shippingList = PackingList::where('type', PackingListType::SHIPPING_PACKING_LIST)->where('reference', $packingList->reference)->first();
|
||||
|
||||
if($packingList->type === PackingListType::SHIPPING_PACKING_LIST) {
|
||||
$warehouseArrivalList = null;
|
||||
@@ -81,6 +82,7 @@ class PackingListsSheet implements WithHeadings, WithHeadingRow, WithMapping, Sh
|
||||
}
|
||||
|
||||
$arrivalTransport = null;
|
||||
|
||||
if($warehouseArrivalList){
|
||||
$arrivalTransport = $warehouseArrivalList->transports()->first();
|
||||
}
|
||||
@@ -109,12 +111,12 @@ class PackingListsSheet implements WithHeadings, WithHeadingRow, WithMapping, Sh
|
||||
$packingList->reference,
|
||||
$packingList->packages()->sum('quantity'),
|
||||
$cbm,
|
||||
$overWeight,
|
||||
$overWeight ? $overWeight : 0,
|
||||
$cbm + $overWeight,
|
||||
$container ? $container->reference : null,
|
||||
$delivery ? $delivery->drop_date : null,
|
||||
strlen($packingList->reference) > 8 ? 'YD' : 'VT',
|
||||
$order ? $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee : null,
|
||||
$order ? $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee->name : null,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class ExportArrivedParcelController
|
||||
}
|
||||
|
||||
public function summary(Request $request) {
|
||||
$exportsParcelsSummary = new ExportsParcel($request);
|
||||
$exportsParcelsSummary = new ExportsParcel();
|
||||
$response = $exportsParcelsSummary->download('parcel-summary.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
|
||||
Reference in New Issue
Block a user