{% extends "base.html" %}

{% block title %}All Jobs - AIS Portal{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h2">Job Inventory</h1>
    <a href="{% url 'job_create' %}" class="btn btn-primary">+ New Job</a>
</div>

<div class="card p-4">
    <div class="table-responsive">
        <table class="table table-hover align-middle">
            <thead class="table-light">
                <tr>
                    <th>Job ID</th>
                    <th>Client Name</th>
                    <th>Status</th>
                    <th>Date Created</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                {% for job in jobs %}
                <tr>
                    <td class="fw-bold text-primary">{{ job.job_number }}</td>
                    <td>{{ job.client_name }}</td>
                    <td>
                        <span class="badge rounded-pill {% if job.status == 'active' %}bg-success{% elif job.status == 'draft' %}bg-warning text-dark{% else %}bg-secondary{% endif %}">
                            {{ job.get_status_display }}
                        </span>
                    </td>
                    <td>{{ job.created_at|date:"M d, Y" }}</td>
                    <td>
                        <div class="btn-group">
                            <a href="{% url 'job_detail' job.pk %}" class="btn btn-sm btn-outline-primary">View</a>
                            <a href="{% url 'agreement_print' job.pk %}" class="btn btn-sm btn-outline-secondary">Print</a>
                        </div>
                    </td>
                </tr>
                {% empty %}
                <tr>
                    <td colspan="5" class="text-center py-5 text-muted">No jobs available.</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}
