@extends('layouts.client')
@section('title','Invoice')
@section('content')
<h5 class="fw-bold mb-3">Invoice Saya</h5>
<div class="card">
  <div class="table-responsive">
    <table class="table table-hover mb-0">
      <thead><tr><th>No. Invoice</th><th>Periode</th><th>Total</th><th>Status</th><th>Jatuh Tempo</th></tr></thead>
      <tbody>
      @forelse($invoices as $inv)
      <tr>
        <td class="fw-semibold small text-primary">{{ $inv->invoice_number }}</td>
        <td class="small text-muted">@if($inv->billing_month){{ date('M',$inv->billing_month*2629746) }} {{ $inv->billing_year }}@else—@endif</td>
        <td class="fw-semibold small">Rp {{ number_format($inv->total,0,',','.') }}</td>
        <td><span class="badge {{ ['draft'=>'bg-secondary','sent'=>'bg-primary','paid'=>'bg-success','overdue'=>'bg-danger','partial'=>'bg-warning text-dark'][$inv->status]??'bg-secondary' }}">{{ strtoupper($inv->status) }}</span></td>
        <td class="small {{ $inv->status==='overdue'?'text-danger fw-bold':'' }}">{{ $inv->due_date->format('d/m/Y') }}</td>
      </tr>
      @empty<tr><td colspan="5" class="text-center text-muted py-4">Belum ada invoice</td></tr>
      @endforelse
      </tbody>
    </table>
  </div>
  <div class="card-footer">{{ $invoices->links() }}</div>
</div>
@endsection
