{% extends "base.html" %}
{% block title %}Assets{% endblock %}
{% block content %}
<div class="space-y-4">
  <div class="flex justify-between items-center">
    <h1 class="text-2xl font-bold">Assets</h1>
    <a href="{% url 'inventory:asset_create' %}" class="btn btn-primary btn-sm">New Asset</a>
  </div>
  <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:asset_list' %}" 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>Code</th><th>Name</th><th>Category</th><th>Status</th><th>Location</th><th></th></tr></thead>
        <tbody>
          {% for asset in assets %}
          <tr>
            <td>{{ asset.code }}</td>
            <td>{{ asset.name }}</td>
            <td>{{ asset.category|default:"-" }}</td>
            <td>{{ asset.get_status_display }}</td>
            <td>{{ asset.location|default:"-" }}</td>
            <td><a class="btn btn-ghost btn-xs" href="{% url 'inventory:asset_detail' asset.pk %}">View</a></td>
          </tr>
          {% empty %}
          <tr><td colspan="6" class="text-center opacity-70">No assets.</td></tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %}
