@extends('admin.layouts.app')
@section('title','Customers')
@section('content')
<div class="page-shell">
    <div class="page-head"><div><h1 class="page-title">Customer Management</h1><div class="page-subtitle">Customer profile, due and purchase history</div></div><a href="{{ route('admin.customers.create') }}" class="btn primary">Add Customer</a></div>
    <form class="card panel-tight row" method="GET"><div class="col"><label>Search</label><input type="text" name="q" value="{{ request('q') }}" placeholder="name / phone / email"></div><div class="col actions"><button class="btn primary">Filter</button></div></form>
    <div class="card panel-tight table-wrap">
        <table class="table">
            <thead><tr><th>ID</th><th>Name</th><th>Phone</th><th>Group</th><th>Opening Balance</th><th>Points</th><th>Status</th><th>Action</th></tr></thead>
            <tbody>
            @forelse($customers as $customer)
                <tr>
                    <td>{{ $customer->id }}</td><td>{{ $customer->name }}</td><td>{{ $customer->phone_number }}</td><td>{{ $customer->customer_group }}</td><td>{{ number_format($customer->opening_balance,2) }}</td><td>{{ $customer->points }}</td><td><span class="badge">{{ $customer->status }}</span></td>
                    <td>
                        <a class="btn" href="{{ route('admin.customers.show',$customer) }}">View</a>
                        <a class="btn" href="{{ route('admin.customers.edit',$customer) }}">Edit</a>
                        <form action="{{ route('admin.customers.destroy',$customer) }}" method="POST" style="display:inline">@csrf @method('DELETE')<button class="btn btn-danger" onclick="return confirm('Delete this customer?')">Delete</button></form>
                    </td>
                </tr>
            @empty
                <tr><td colspan="8">No customers found.</td></tr>
            @endforelse
            </tbody>
        </table>
    </div>
    {{ $customers->links() }}
</div>
@endsection
