mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-22 05:54:08 +00:00
customer report
This commit is contained in:
+21
-5
@@ -133,19 +133,35 @@ Route::get('/report', function(){
|
||||
$containers = Container::whereMonth('loading_date', '=', '09')->whereYear('loading_date', '=', '2021')->get();
|
||||
|
||||
$total = 0;
|
||||
$customers = [];
|
||||
|
||||
foreach ($containers as $container){
|
||||
$cbm = $container->packingLists->sum(function($packing_list){
|
||||
return $packing_list->packages->sum(function ($package){
|
||||
foreach($container->packingLists as $packingList){
|
||||
$cbm = $packingList->packages->sum(function ($package){
|
||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100));
|
||||
});
|
||||
});
|
||||
|
||||
$total += $cbm;
|
||||
$total += $cbm;
|
||||
if(!array_key_exists($packingList->owner->id, $customers)){
|
||||
$marking = $packingList->owner->companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
$customers[$packingList->owner->id] = [
|
||||
'marking' => $marking,
|
||||
'cbm' => $cbm,
|
||||
'packages' => $packingList->packages->sum('quantity')
|
||||
];
|
||||
|
||||
echo $container->reference.': '.$cbm.'<br><br>';
|
||||
continue;
|
||||
}
|
||||
|
||||
$customers[$packingList->owner->id]['cbm'] += $cbm;
|
||||
$customers[$packingList->owner->id]['packages'] += $packingList->packages->sum('quantity');
|
||||
}
|
||||
}
|
||||
|
||||
dd($customers);
|
||||
|
||||
echo '<br><br><br>total cbm: '. $total;
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user