customer report

This commit is contained in:
omair saleh
2021-10-01 21:14:33 +08:00
parent 557d85ef8d
commit feb04e8498
+5 -1
View File
@@ -151,6 +151,7 @@ Route::get('/report', function(){
if(!$customers->has($marking)){
$customers->put($marking, collect([
'cbm' => $cbm,
'orders' => 1,
'packages' => $packingList->packages->sum('quantity')
]));
@@ -158,6 +159,7 @@ Route::get('/report', function(){
}
$customers[$marking]['cbm'] += $cbm;
$customers[$marking]['orders'] += 1;
$customers[$marking]['packages'] += $packingList->packages->sum('quantity');
}
}
@@ -165,10 +167,12 @@ Route::get('/report', function(){
echo '<h1><b>total cbm:</b> '. $total . '</h1>';
echo '<h1><b>active customers:</b> '. count($customers) . '</h1><br><br>';
$i = 1;
foreach ($customers->sortByDesc(function($customer){
return $customer['cbm'];
}) as $marking => $customer) {
echo '<b>'.$marking.': </b>'.$customer['cbm'].' CBM ( '.$customer['packages'].' ) CTNS <br><br>';
echo '<b>'.$i.'. '.$marking.': </b>'.$customer['cbm'].' CBM ('. $customer['orders'] .' - '.$customer['packages'].' ) CTNS <br><br>';
$i++;
}