@extends('admin.layouts.app')
@section('title', 'Supplier Return')
@section('content')
<div class="page-head"><div><h1 class="page-title">Supplier Return</h1><div class="page-subtitle">Choose purchase items carefully. The system now protects against over-return.</div></div></div>
<div class="card card-body">
    <form method="POST" action="{{ route('admin.supplier-returns.store') }}">@csrf
        <div class="row g-3 mb-3">
            <div class="col-md-4"><label>Supplier Name</label><input class="form-control" name="supplier_name" value="{{ old('supplier_name') }}" required></div>
            <div class="col-md-4"><label>Return Date</label><input class="form-control" type="date" name="return_date" value="{{ old('return_date', now()->toDateString()) }}" required></div>
            <div class="col-md-4"><label>Refund Method</label><select class="form-select" name="refund_method"><option>Cash</option><option>Bank</option><option>Mobile Banking</option><option>Adjustment</option></select></div>
        </div>
        <div class="table-responsive"><table class="table table-bordered"><thead><tr><th>Purchase Item</th><th>Qty Return</th></tr></thead><tbody>@for($i=0;$i<5;$i++)<tr><td><select class="form-select" name="rows[{{ $i }}][purchase_item_id]"><option value="">Select Purchase Item</option>@foreach($purchaseItems as $item)<option value="{{ $item->id }}">{{ $item->product_name }} ({{ $item->product_code }}) Qty: {{ $item->qty }}</option>@endforeach</select></td><td><input class="form-control" type="number" step="0.01" min="0.01" name="rows[{{ $i }}][qty]" value="{{ $i===0 ? 1 : '' }}"></td></tr>@endfor</tbody></table></div>
        <div><label>Notes</label><textarea class="form-control" rows="4" name="notes">{{ old('notes') }}</textarea></div>
        <div class="mt-3"><button class="btn btn-primary">Save Return</button></div>
    </form>
</div>
@endsection