{% extends "base.html" %}
{% block title %}Expired Stock Report{% endblock %}
{% block content %}
<div class="space-y-4">
  <h1 class="text-2xl font-bold">Expired Stock Report</h1>
  <form method="get" class="flex flex-wrap gap-2 items-end">
    <label class="form-control w-64">
      <span class="label-text">Branch</span>
      <select name="branch" class="select select-bordered">
        <option value="">All Branches</option>
        {% for branch in branches %}
          <option value="{{ branch.id }}" {% if current_branch == branch.id|stringformat:"s" %}selected{% endif %}>{{ branch.name }}</option>
        {% endfor %}
      </select>
    </label>
    <button class="btn btn-primary btn-sm">Filter</button>
    {% if current_branch %}
      <a href="{% url 'inventory:expired_stock_report' %}" class="btn btn-ghost btn-sm">Clear</a>
    {% endif %}
  </form>
  <div class="card bg-base-100 border border-base-200">
    <div class="overflow-x-auto">
      <table class="table table-zebra">
        <thead><tr><th>Product</th><th>Batch</th><th>Branch</th><th>Location</th><th>Expiry Date</th><th>Qty</th></tr></thead>
        <tbody>
          {% for batch in batches %}
          <tr>
            <td>{{ batch.product }}</td>
            <td>{{ batch.batch_number }}</td>
            <td>{{ batch.location.branch.name|default:"-" }}</td>
            <td>{{ batch.location|default:"-" }}</td>
            <td>{{ batch.expiry_date }}</td>
            <td>{{ batch.quantity }}</td>
          </tr>
          {% empty %}
          <tr><td colspan="6" class="text-center opacity-70">No expired stock.</td></tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %}
