{% extends "base.html" %}
{% load static %}
{% block title %}Edit Service Request{% endblock %}

{% block content %}
<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
    <div class="breadcrumb-title pe-3">Edit Service Request</div>
    <div class="ps-3">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-0 p-0">
                <li class="breadcrumb-item"><a href="{% url 'service-request-management' %}"><i class="bx bx-home-alt"></i></a></li>
                <li class="breadcrumb-item"><a href="{% url 'service-request-detail' service_request.pk %}">{{ service_request.request_id }}</a></li>
                <li class="breadcrumb-item active" aria-current="page">Edit</li>
            </ol>
        </nav>
    </div>
</div>

<div class="row">
    <div class="col-lg-8 mx-auto">
        <div class="card">
            <div class="card-body">
                <h5 class="card-title mb-4">Edit Request Details</h5>
                <form method="post">
                    {% csrf_token %}
                    
                    {% if form.non_field_errors %}
                        <div class="alert alert-danger">
                            {{ form.non_field_errors }}
                        </div>
                    {% endif %}

                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label class="form-label">Service Date</label>
                            {{ form.service_date }}
                            {% if form.service_date.errors %}
                                <div class="text-danger small">{{ form.service_date.errors }}</div>
                            {% endif %}
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">Service Time</label>
                            {{ form.service_time }}
                            {% if form.service_time.errors %}
                                <div class="text-danger small">{{ form.service_time.errors }}</div>
                            {% endif %}
                        </div>
                    </div>

                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label class="form-label">Contact Name</label>
                            {{ form.contact_name }}
                            {% if form.contact_name.errors %}
                                <div class="text-danger small">{{ form.contact_name.errors }}</div>
                            {% endif %}
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">Contact Mobile</label>
                            {{ form.contact_mobile }}
                            {% if form.contact_mobile.errors %}
                                <div class="text-danger small">{{ form.contact_mobile.errors }}</div>
                            {% endif %}
                        </div>
                    </div>

                    <div class="mb-3">
                        <label class="form-label">Status</label>
                        {{ form.status }}
                        {% if form.status.errors %}
                            <div class="text-danger small">{{ form.status.errors }}</div>
                        {% endif %}
                    </div>

                    <div class="mb-3">
                        <label class="form-label">Total Price</label>
                        {{ form.total_price }}
                        {% if form.total_price.errors %}
                            <div class="text-danger small">{{ form.total_price.errors }}</div>
                        {% endif %}
                    </div>

                    <div class="mb-3">
                        <label class="form-label">Notes</label>
                        {{ form.notes }}
                        {% if form.notes.errors %}
                            <div class="text-danger small">{{ form.notes.errors }}</div>
                        {% endif %}
                    </div>

                    <div class="d-flex gap-2">
                        <button type="submit" class="btn btn-primary px-4">Save Changes</button>
                        <a href="{% url 'service-request-detail' service_request.pk %}" class="btn btn-light px-4">Cancel</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}
