@extends('layouts.franchise', ['heading' => 'Product Wise Report'])

@section('content')
    <form method="GET" class="mb-4 flex flex-wrap gap-2">
        <input type="date" name="from" value="{{ $from }}" class="rounded border p-2 text-sm">
        <input type="date" name="to" value="{{ $to }}" class="rounded border p-2 text-sm">
        <button class="rounded bg-slate-900 px-4 py-2 text-sm text-white">Filter</button>
        <a href="{{ request()->fullUrlWithQuery(['export' => 'excel']) }}" class="rounded border px-3 py-2 text-sm">Excel</a>
        <a href="{{ request()->fullUrlWithQuery(['export' => 'pdf']) }}" class="rounded border px-3 py-2 text-sm">PDF</a>
    </form>

    <div class="grid grid-cols-1 gap-3">
        @forelse($rows as $row)
            <div class="rounded-2xl bg-white p-4 shadow">
                <div class="font-semibold">{{ $row->product_name }}</div>
                <div class="text-sm text-slate-600">Qty: {{ $row->total_qty }} | Sales: ? {{ number_format((float) $row->total_sales, 2) }} | BV: {{ number_format((float) $row->total_bv, 2) }}</div>
            </div>
        @empty
            <div class="rounded-2xl bg-white p-4 text-center text-slate-500">No product data.</div>
        @endforelse
    </div>
@endsection

