@php
$year = request('year');
@endphp
Trucks P & L Report ({{!empty($year) ? $year : date('Y') }})
{{ getAuthCompanyName() }}
{{ getAuthCarrierInfo()->BILL_TO }}
|
{{ date('m/d/Y h:i A') }}
|
Grand Total:
${{ number_format($gtotal, 2) }}
|
| UNIT ID |
@for ($month = 1; $month <= 12; $month++)
{{ \Carbon\Carbon::createFromDate($cur_year, $month, 1)->format('M') }}
|
@endfor
Total |
@php
$monthlyTotals = array_fill(1, 12, 0);
$gtotal = 0;
@endphp
@foreach ($profitAmounts as $key => $profits)
@php
[$type, $id] = explode('-', $key);
$isTrailer = $type === 'Trailer';
$isDriver = $type === 'Driver';
$isMisc = $type === 'Misc';
$rowTotal = array_sum($profits); // Calculate row-wise total
$gtotal += $rowTotal; // Add to Grand Total
@endphp
|
@if ($isTrailer)
Trailer {{ $id }}
@elseif($isDriver)
Driver {{ $id }}
@elseif($isMisc)
MISC Expenses
@else
{{ $id }}
@endif
|
@for ($month = 1; $month <= 12; $month++)
@php
$profit = $profits[$month] ?? 0;
$monthlyTotals[$month] += $profit; // Sum monthly profits for the total row
@endphp
${{ number_format($profit, 2) }}
|
@endfor
${{ number_format($rowTotal, 2) }}
|
@endforeach
| Total |
@for ($month = 1; $month <= 12; $month++)
${{ number_format($monthlyTotals[$month], 2) }}
|
@endfor
${{ number_format($gtotal, 2) }}
|
Grand Total Profit: ${{ number_format($gtotal, 2) }}
|
@if(!empty($chartImage))
@else
@endif
@php
$monthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
$chartSeries = [];
foreach ($profitAmounts as $key => $profits) {
[$type, $id] = explode('-', $key);
if ($type === 'Trailer') {
$label = "Trailer $id";
} elseif ($type === 'Driver') {
$label = "Driver $id";
} elseif ($type === 'Misc') {
$label = "Misc Expenses";
} else {
$label = $id; // Truck / Unit
}
$dataPoints = [];
for ($m = 1; $m <= 12; $m++) {
$val = $profits[$m] ?? 0;
$dataPoints[] = [
'label' => $monthNames[$m-1],
'y' => round($val, 2)
];
}
$chartSeries[] = [
'type' => 'stackedColumn',
'name' => $label,
'showInLegend' => true,
'dataPoints' => $dataPoints
];
}
@endphp