{% extends "base.html" %}
{% block title %}Tâche planifiée #{{ task.id }} — GMAO Collège{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ url_for('planning.scheduled') }}">Tâches planifiées</a></li>
                    <li class="breadcrumb-item active">Tâche #{{ task.id }}</li>
                </ol>
            </nav>
            <h1 class="h3">
                <i class="bi bi-calendar-check me-2"></i>
                {% if task.lot_task %}
                    {{ task.lot_task.tache }}
                {% else %}
                    Tâche #{{ task.id }}
                {% endif %}
            </h1>
        </div>
    </div>
    
    <div class="row">
        <div class="col-lg-8">
            <div class="card mb-3">
                <div class="card-header">
                    <i class="bi bi-info-circle me-1"></i> Informations
                </div>
                <div class="card-body">
                    <table class="table table-sm">
                        <tr>
                            <th>Numéro</th>
                            <td>{{ task.lot_task.num_tache if task.lot_task else '—' }}</td>
                        </tr>
                        <tr>
                            <th>Description</th>
                            <td>{{ task.lot_task.tache if task.lot_task else '—' }}</td>
                        </tr>
                        <tr>
                            <th>Périodicité</th>
                            <td>{{ task.lot_task.periodicite if task.lot_task else '—' }}</td>
                        </tr>
                        <tr>
                            <th>Date planifiée</th>
                            <td>
                                {% if task.scheduled_date %}
                                    {{ task.scheduled_date.strftime('%d/%m/%Y') }}
                                {% else %}
                                    <span class="text-muted">Non planifiée</span>
                                {% endif %}
                            </td>
                        </tr>
                        <tr>
                            <th>Statut</th>
                            <td>
                                {% if task.status == 'planned' %}
                                    <span class="badge bg-info">Planifiée</span>
                                {% elif task.status == 'completed' %}
                                    <span class="badge bg-success">Terminée</span>
                                {% elif task.status == 'postponed' %}
                                    <span class="badge bg-warning">Reportée</span>
                                {% else %}
                                    <span class="badge bg-secondary">{{ task.status }}</span>
                                {% endif %}
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            
            {% if task.equipment %}
            <div class="card mb-3">
                <div class="card-header">
                    <i class="bi bi-tools me-1"></i> Équipement
                </div>
                <div class="card-body">
                    <table class="table table-sm">
                        <tr>
                            <th>Nom</th>
                            <td>
                                <a href="{{ url_for('equipments.detail', id=task.equipment.id) }}">
                                    {{ task.equipment.name }}
                                </a>
                            </td>
                        </tr>
                        {% if task.equipment.room %}
                        <tr>
                            <th>Localisation</th>
                            <td>{{ task.equipment.room.name }}</td>
                        </tr>
                        {% endif %}
                        {% if task.equipment.lot %}
                        <tr>
                            <th>Lot</th>
                            <td>
                                <a href="{{ url_for('lots.detail', id=task.equipment.lot.id) }}">
                                    {{ task.equipment.lot.name }}
                                </a>
                            </td>
                        </tr>
                        {% endif %}
                    </table>
                </div>
            </div>
            {% endif %}
        </div>
        
        <div class="col-lg-4">
            <div class="card">
                <div class="card-header">
                    <i class="bi bi-gear me-1"></i> Actions
                </div>
                <div class="card-body">
                    <div class="d-grid gap-2">
                        <a href="{{ url_for('planning.scheduled') }}" class="btn btn-outline-secondary">
                            <i class="bi bi-arrow-left me-1"></i> Retour à la liste
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
