@extends('layouts.dashboard') @section('page_title', 'STATISTICS') @php $rows = [ ['key' => 'loads', 'label' => 'Loads', 'color' => '#ffe14d', 'type' => 'int'], ['key' => 'miles', 'label' => 'Miles', 'color' => '#9ec5ff', 'type' => 'num'], ['key' => 'gross_rev', 'label' => 'Gross Rev.', 'color' => '#f4a6b0', 'type' => 'money'], ['key' => 'sales_comm', 'label' => 'Sales Comm.', 'color' => '#86e58b', 'type' => 'money'], ['key' => 'carrier_fee', 'label' => 'Carrier Fee', 'color' => '#e2a3e6', 'type' => 'money'], ['key' => 'driver_fee', 'label' => 'Driver Fee', 'color' => '#c9ccd1', 'type' => 'money'], ['key' => 'net_profit', 'label' => 'Net Profit', 'color' => '#9aa0a6', 'type' => 'money'], ['key' => 'percent', 'label' => 'Percent', 'color' => '#ffe14d', 'type' => 'pct'], ]; $fmt = function ($value, $type) { if ($type === 'pct') { return $value == 0 ? '-' : round($value).'%'; } if ($type === 'int') { return $value == 0 ? '-' : number_format($value); } if ($value == 0) { return '-'; } if (abs($value) >= 1000) { return number_format($value / 1000, 1).'K'; } return number_format($value); }; $pct = fn ($net, $gross) => $gross != 0 ? round($net / $gross * 100) : 0; @endphp @section('content')
Back
Advanced Statistics
Manage Reports
Report:
Show:
Filter By:
@foreach ($months as $label) @endforeach @foreach ($rows as $row) @foreach ($months as $key => $label) @php $value = $row['type'] === 'pct' ? $pct($buckets[$key]['net_profit'], $buckets[$key]['gross_rev']) : $buckets[$key][$row['key']]; @endphp @endforeach @php $totalValue = $row['type'] === 'pct' ? $pct($totals['net_profit'], $totals['gross_rev']) : $totals[$row['key']]; @endphp @endforeach
Breakdown {{ $label }}Totals
{{ $row['label'] }} {{ $fmt($value, $row['type']) }}{{ $fmt($totalValue, $row['type']) }}
@push('scripts') @endpush @endsection