@extends('admin.layouts.app')
@section('title','Branch-wise Stock')
@section('content')
<div class="page-head"><div><h1 class="page-title">Branch-wise Stock</h1><div class="page-subtitle">Branch product stock, price and reorder level</div></div></div>

<form method="GET" class="card panel-tight grid-4"><div><label>Branch</label><select name="branch_id"><option value="">All</option>@foreach($branches as $branch)<option value="{{ $branch->id }}" @selected($branchId==$branch->id)>{{ $branch->name }}</option>@endforeach</select></div><div class="form-actions"><button class="btn primary">Filter</button><a class="btn" href="{{ route('admin.branches.stocks') }}">Reset</a></div></form>
<form method="POST" action="{{ route('admin.branches.stocks.save') }}" class="card panel-tight grid-3">@csrf<div><label>Branch</label><select name="branch_id" required>@foreach($branches as $branch)<option value="{{ $branch->id }}">{{ $branch->name }}</option>@endforeach</select></div><div><label>Product</label><select name="product_id" required>@foreach($products as $product)<option value="{{ $product->id }}">{{ $product->product_name }}</option>@endforeach</select></div><div><label>Stock Qty</label><input type="number" step="0.01" name="stock_qty" required></div><div><label>Reorder Qty</label><input type="number" step="0.01" name="reorder_qty"></div><div><label>Selling Price</label><input type="number" step="0.01" name="selling_price"></div><div><label>Wholesale Price</label><input type="number" step="0.01" name="wholesale_price"></div><div class="form-actions" style="grid-column:1/-1"><button class="btn primary">Save Branch Stock</button></div></form>
<div class="card panel-tight table-wrap"><table class="table"><thead><tr><th>Branch ID</th><th>Product ID</th><th>Stock</th><th>Reorder</th><th>Sell Price</th><th>Wholesale</th></tr></thead><tbody>@forelse($stocks as $row)<tr><td>{{ $row->branch_id }}</td><td>{{ $row->product_id }}</td><td>{{ $row->stock_qty }}</td><td>{{ $row->reorder_qty }}</td><td>{{ $row->selling_price }}</td><td>{{ $row->wholesale_price }}</td></tr>@empty<tr><td colspan="6">No stock rows found.</td></tr>@endforelse</tbody></table>{{ $stocks->links() }}</div>

@endsection
