@extends('layouts.dashboard') @php $searchFields = [ 'load_number' => 'Load Number', 'wo_reference' => 'W/O #', 'customer' => 'Customer', 'shipper' => 'Shipper', 'shipper_city' => 'Shipper City', 'consignee' => 'Consignee', 'consignee_city' => 'Consignee City', 'truck' => 'Truck', 'trailer' => 'Trailer', 'driver' => 'Driver', 'carrier' => 'Carrier', 'po_numbers' => 'P.O. Numbers', ]; $columns = [ 'status' => 'Status', 'load' => 'Load #', 'wo' => 'Work Order #', 'ship_date' => 'Ship Date', 'del_date' => 'Del Date', 'customer' => 'Customer', 'shipper' => 'Shipper', 'shipper_city' => 'Shipper City', 'shipper_st' => 'Shipper St.', 'consignee' => 'Consignee', 'consignee_city' => 'Consignee City', 'consignee_st' => 'Consignee St.', 'truck' => 'Truck', 'trailer' => 'Trailer', 'equipment' => 'Equipment Type', 'invoice_no' => 'Invoice #', 'invoice_date' => 'Invoice Date', 'dispatcher' => 'Dispatcher', 'sales_reps' => 'Sales Reps', 'user_id' => 'User Id', 'billing' => 'Billing', 'shipper_po' => 'Shipper PO Numbers', 'consignee_po' => 'Consignee PO Numbers', 'carrier_driver' => 'Carrier/Driver', 'carrier_driver_city' => 'Carrier/Driver City', 'carrier_driver_state' => 'Carrier/Driver State', 'customer_id' => 'Customer Id', 'customer_mc' => 'Customer MC #', 'carrier_mc' => 'Carrier MC #', 'carrier_fee' => 'Carrier Fee', 'line_haul' => 'Line Haul', 'driver_pay' => 'Driver Pay', 'gross_margin' => 'Gross Margin', 'weight' => 'Weight', 'promiles' => 'ProMiles', 'empty_miles' => 'Empty Miles', 'total_billing_rate' => 'Total Billing Rate', 'type' => 'Type', 'quantity' => 'Quantity', ]; $excludedColumns = \App\Support\Settings\SystemSettings::loadFinderExcludedFields(); $columns = collect($columns)->except($excludedColumns)->all(); $defaultVisible = [ 'status', 'load', 'wo', 'ship_date', 'del_date', 'customer', 'shipper', 'shipper_city', 'shipper_st', 'consignee', 'consignee_city', 'consignee_st', 'truck', 'trailer', 'equipment', ]; $num = function ($value) { if ($value === null || $value === '') { return '—'; } return rtrim(rtrim(number_format((float) $value, 3, '.', ','), '0'), '.'); }; $money = function ($value, ?string $currency = null) { if ($value === null || $value === '') { return '—'; } return '$'.number_format((float) $value, 2).($currency ? ' '.$currency : ''); }; $dash = fn ($value) => ($value === null || $value === '') ? '—' : $value; $cellsFor = function ($load) use ($num, $money, $dash) { $shipper = $load->shippers->first(); $consignee = $load->consignees->last(); $assignment = $load->assignments->first(); $isDriver = $assignment && $assignment->assignment_type === 'driver'; $carrierAddr = $assignment?->carrierCompany?->addresses?->first(); $currency = $load->currency_code ?: 'USD'; $rate = $load->rate !== null ? (float) $load->rate : null; $fin = \App\Support\Dispatch\LoadFinancials::compute($load); $carrierFee = $fin['carrier_pay']; $grossMargin = $fin['gross_margin']; $totalBilling = $fin['revenue']; $salesReps = collect([$load->salesRep1?->name, $load->salesRep2?->name]) ->filter() ->implode(', '); return [ 'load' => $load->load_number, 'status' => $load->status?->name ?? '—', 'ship_date' => $shipper?->displayScheduledAt() ?? '—', 'del_date' => $consignee?->displayScheduledAt() ?? '—', 'customer' => $load->customerCompany?->display_name ?? '—', 'shipper' => $shipper?->location_name ?: ($shipper?->company?->display_name ?? '—'), 'shipper_city' => $shipper?->city ?? '—', 'shipper_st' => $shipper?->stateProvince?->code ?? ($shipper?->stateProvince?->name ?? '—'), 'consignee' => $consignee?->location_name ?: ($consignee?->company?->display_name ?? '—'), 'consignee_city' => $consignee?->city ?? '—', 'consignee_st' => $consignee?->stateProvince?->code ?? ($consignee?->stateProvince?->name ?? '—'), 'truck' => $assignment?->truck?->truck_number ?? '—', 'trailer' => $assignment?->trailer?->trailer_number ?? '—', 'equipment' => $assignment?->equipmentType?->name ?? ($load->equipmentType?->name ?? '—'), 'wo' => $dash($load->wo_reference), 'invoice_no' => $dash($load->accountingRecord?->invoice_number), 'invoice_date' => $load->accountingRecord?->invoiced_at?->format('Y-m-d') ?? '—', 'dispatcher' => $dash($load->dispatcher?->name), 'sales_reps' => $dash($salesReps), 'user_id' => $dash($load->dispatcher?->id), 'billing' => $dash($load->billToCompany?->display_name), 'shipper_po' => $dash($shipper?->po_numbers), 'consignee_po' => $dash($consignee?->po_numbers), 'carrier_driver' => $dash($isDriver ? $assignment?->driver?->full_name : $assignment?->carrierCompany?->display_name), 'carrier_driver_city' => $dash($isDriver ? $assignment?->driver?->city : $carrierAddr?->city), 'carrier_driver_state' => $dash($isDriver ? $assignment?->driver?->stateProvince?->code : $carrierAddr?->stateProvince?->code), 'customer_id' => $dash($load->customerCompany?->company_code ?? $load->customerCompany?->id), 'customer_mc' => $dash($load->customerCompany?->mc_number), 'carrier_mc' => $dash($assignment?->carrierCompany?->mc_number), 'carrier_fee' => $money($carrierFee, $currency), 'line_haul' => $money($assignment?->flat_rate ?? $carrierFee, $currency), 'driver_pay' => $isDriver ? $money($assignment?->flat_rate, $currency) : '—', 'gross_margin' => $money($grossMargin, $currency), 'weight' => $shipper?->weight_lbs !== null ? $num($shipper->weight_lbs).' lbs' : '—', 'promiles' => $num($assignment?->pro_miles), 'empty_miles' => $num($assignment?->driver_miles), 'total_billing_rate' => $money($totalBilling, $currency), 'type' => $dash($load->mode?->name), 'quantity' => $num($shipper?->quantity), ]; }; @endphp @push('styles') @endpush @section('content')

Load Finder

Search every load by number, customer, stops, equipment and dates.

AND
AND
Displaying {{ $loads->total() }} Loads
@foreach ($columns as $key => $label) @endforeach @forelse ($loads as $load) @php $cells = $cellsFor($load); $statusCode = $load->status?->code ?? ''; @endphp @foreach ($columns as $key => $label) @endforeach @empty @endforelse
{{ $label }}
@if ($key === 'load') {{ $cells['load'] }} @elseif ($key === 'status') {{ $cells['status'] }} @else {{ $cells[$key] }} @endif
No loads found for the selected filters.
Showing {{ $loads->firstItem() ?? 0 }}–{{ $loads->lastItem() ?? 0 }} of {{ $loads->total() }}
{{ $loads->links('pagination::bootstrap-5') }}
@endsection @push('scripts') @endpush