@extends('layouts.app')
@section('title', 'Purchases')
@section('content')
<div class="d-flex justify-content-between align-items-center mb-3">
    <h4>Purchases (From Flour Mill)</h4>
    <a href="{{ route('purchases.create') }}" class="btn btn-primary btn-sm"><i class="bi bi-plus"></i> New Purchase</a>
</div>
<div class="card">
    <div class="card-body p-0">
        <table class="table table-hover mb-0">
            <thead><tr><th>#</th><th>Supplier</th><th>Date</th><th>Total</th><th>Paid</th><th>Actions</th></tr></thead>
            <tbody>
            @forelse($purchases as $purchase)
                <tr>
                    <td>{{ $purchase->id }}</td>
                    <td>{{ $purchase->supplier->name }}</td>
                    <td>{{ $purchase->date->format('d M Y') }}</td>
                    <td>Rs. {{ number_format($purchase->total_amount, 2) }}</td>
                    <td>Rs. {{ number_format($purchase->paid_amount, 2) }}</td>
                    <td><a href="{{ route('purchases.show', $purchase) }}" class="btn btn-sm btn-outline-info">View</a></td>
                </tr>
            @empty
                <tr><td colspan="6" class="text-center text-muted">No purchases yet</td></tr>
            @endforelse
            </tbody>
        </table>
    </div>
</div>
<div class="mt-3">{{ $purchases->links() }}</div>
@endsection
