@extends('layouts.app')
@section('title', 'Reports')
@section('content')
<h4 class="mb-4">Reports & Ledger Download</h4>

<div class="row g-4">
    {{-- Daily Summary --}}
    <div class="col-md-4">
        <div class="card h-100">
            <div class="card-header"><i class="bi bi-calendar-day"></i> Daily Summary</div>
            <div class="card-body">
                <p class="text-muted small">Download all orders for a specific day.</p>
                <form action="{{ route('reports.daily') }}" method="GET">
                    <div class="mb-3">
                        <label for="daily_date" class="form-label">Date</label>
                        <input type="date" name="date" id="daily_date" class="form-control" value="{{ date('Y-m-d') }}" required>
                    </div>
                    <button class="btn btn-primary btn-sm"><i class="bi bi-download"></i> Download PDF</button>
                </form>
            </div>
        </div>
    </div>

    {{-- Sales Ledger --}}
    <div class="col-md-4">
        <div class="card h-100">
            <div class="card-header"><i class="bi bi-journal-text"></i> Sales Ledger</div>
            <div class="card-body">
                <p class="text-muted small">Download sales report for a date range.</p>
                <form action="{{ route('reports.sales') }}" method="GET">
                    <div class="mb-2">
                        <label class="form-label">From</label>
                        <input type="date" name="from" class="form-control" value="{{ now()->startOfMonth()->format('Y-m-d') }}" required>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">To</label>
                        <input type="date" name="to" class="form-control" value="{{ date('Y-m-d') }}" required>
                    </div>
                    <button class="btn btn-primary btn-sm"><i class="bi bi-download"></i> Download PDF</button>
                </form>
            </div>
        </div>
    </div>

    {{-- Supplier Ledger --}}
    <div class="col-md-6">
        <div class="card h-100">
            <div class="card-header"><i class="bi bi-truck"></i> Supplier Ledger</div>
            <div class="card-body">
                <p class="text-muted small">Download purchase & payment ledger for a supplier.</p>
                <form action="{{ route('reports.supplier') }}" method="GET">
                    <div class="mb-2">
                        <label class="form-label">Supplier</label>
                        <select name="supplier_id" class="form-select" required>
                            <option value="">Select Supplier</option>
                            @foreach($suppliers as $s)
                                <option value="{{ $s->id }}">{{ $s->name }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="mb-2">
                        <label class="form-label">From</label>
                        <input type="date" name="from" class="form-control" value="{{ now()->startOfMonth()->format('Y-m-d') }}" required>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">To</label>
                        <input type="date" name="to" class="form-control" value="{{ date('Y-m-d') }}" required>
                    </div>
                    <button class="btn btn-success btn-sm"><i class="bi bi-download"></i> Download PDF</button>
                </form>
            </div>
        </div>
    </div>

    {{-- Customer Ledger --}}
    <div class="col-md-6">
        <div class="card h-100">
            <div class="card-header"><i class="bi bi-people"></i> Customer Ledger (B2B)</div>
            <div class="card-body">
                <p class="text-muted small">Download order & payment ledger for a B2B customer.</p>
                <form action="{{ route('reports.customer') }}" method="GET">
                    <div class="mb-2">
                        <label class="form-label">Customer</label>
                        <select name="customer_id" class="form-select" required>
                            <option value="">Select Customer</option>
                            @foreach($customers as $c)
                                <option value="{{ $c->id }}">{{ $c->name }}{{ $c->shop_name ? ' (' . $c->shop_name . ')' : '' }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="mb-2">
                        <label class="form-label">From</label>
                        <input type="date" name="from" class="form-control" value="{{ now()->startOfMonth()->format('Y-m-d') }}" required>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">To</label>
                        <input type="date" name="to" class="form-control" value="{{ date('Y-m-d') }}" required>
                    </div>
                    <button class="btn btn-success btn-sm"><i class="bi bi-download"></i> Download PDF</button>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
