@extends('layouts.app')
@section('title','Vendor Bills')
@section('page_title','Vendor Bills')
@section('content')
<div class="page-head"><div><h1>Vendor Bills</h1><p>Record subcontractor, fuel, maintenance and operating supplier invoices.</p></div>@if(auth()->user()->hasPermission('vendor_bills.create'))<a class="btn btn-primary" href="{{ route('bills.create') }}">+ New Vendor Bill</a>@endif</div>
<div class="card"><div class="toolbar"><form class="search"><input class="control" name="search" value="{{ request('search') }}" placeholder="Bill, vendor invoice or vendor"><select class="control" name="status" style="max-width:180px"><option value="">All statuses</option>@foreach(\App\Enums\DocumentStatus::cases() as $status)<option value="{{ $status->value }}" @selected(request('status')===$status->value)>{{ ucwords(str_replace('_',' ',$status->value)) }}</option>@endforeach</select><button class="btn btn-secondary">Filter</button></form><span class="muted">{{ $bills->total() }} bills</span></div><div class="table-wrap"><table class="table"><thead><tr><th>Internal Bill</th><th>Vendor Invoice</th><th>Date</th><th>Vendor</th><th>Total</th><th>Paid / Allocated</th><th>Balance</th><th>Status</th><th>Actions</th></tr></thead><tbody>
@forelse($bills as $bill)@php($status=$bill->status instanceof \App\Enums\DocumentStatus?$bill->status->value:$bill->status)<tr><td><strong>{{ $bill->bill_number }}</strong></td><td>{{ $bill->vendor_invoice_number }}</td><td>{{ $bill->invoice_date->format('d M Y') }}</td><td>{{ $bill->party?->legal_name }}</td><td>{{ $bill->currency_code }} {{ number_format((float)$bill->grand_total,2) }}</td><td>{{ number_format((float)$bill->allocated_total,2) }}</td><td>{{ number_format((float)$bill->grand_total-(float)$bill->allocated_total,2) }}</td><td><span class="badge status-{{ $status }}">{{ ucwords(str_replace('_',' ',$status)) }}</span></td><td><div class="actions"><a class="btn btn-secondary btn-sm" href="{{ route('bills.show',$bill) }}">Open</a><a class="btn btn-secondary btn-sm" target="_blank" href="{{ route('bills.print',$bill) }}">Print</a></div></td></tr>@empty<tr><td colspan="9" class="empty">No vendor bills found.</td></tr>@endforelse</tbody></table></div>{{ $bills->links() }}</div>
@endsection
