diff --git a/routes/web.php b/routes/web.php index 4c3077fe..b8bbed7a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -239,7 +239,7 @@ Route::get('/settings', function () { return view('pages.settings'); })->name('settings'); -Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}', function ($active_start, $active_end, $inactive_start=null, $inactive_end=null) { +Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{inactive_end?}/{with_cbm?}', function ($active_start, $active_end, $inactive_start=null, $inactive_end=null, $with_cbm = false) { $activeCompanies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) { return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) { return $query->where('drop_date', '>=', \Carbon\Carbon::parse($inactive_start))->where('drop_date', '<=', \Carbon\Carbon::parse($inactive_end)->addDay()); @@ -257,7 +257,18 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina $connection = $company->inviters()->withPivot('invitee_reference')->first(); $marking = $connection ? $connection->pivot->invitee_reference:''; - echo $key + 1 .'. '.$marking.'

'; + if($with_cbm){ + $packingList = $company->orderPackingLists()->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get(); + $totalCbm = $packingList->flatMap(function ($packingList) { + return $packingList->packages; + })->sum(function($package){ + return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity; + }); + } + + $totalCbm = ($with_cbm ? '['. $packingList->count().'] ('. $totalCbm .')' : ''); + + echo $key + 1 .'. '.$marking.' '.$totalCbm.'

'; } }); \ No newline at end of file