loko/streetup/stock/templates/stock/request_for_quote_detail.html
2026-07-22 14:48:40 +02:00

220 lines
13 KiB
HTML

{% extends "base.html" %}
{% load i18n %}
{% block content %}
<div class="container-fluid mt-3">
<div class="row">
<div class="col-12">
<!-- En-tête -->
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h3>
<i class="bi bi-file-earmark-text"></i> {% translate "Demande d'offre" %} {{ rfq.code }}
</h3>
<p class="text-muted mb-0">
{% translate "Créé le" %}: {{ rfq.date_created|date:"d/m/Y" }}
</p>
</div>
<div>
<a href="{% url 'stock:stock_purchases' %}" class="btn btn-secondary">
<i class="bi bi-arrow-left"></i> {% translate "Retour" %}
</a>
<a href="{% url 'stock:request_for_quote_pdf' rfq.pk %}" class="btn btn-outline-secondary" target="_blank">
<i class="bi bi-file-earmark-pdf"></i> {% translate "PDF" %}
</a>
<a href="{% url 'stock:request_for_quote_xlsx' rfq.pk %}" class="btn btn-outline-success">
<i class="bi bi-file-earmark-excel"></i> {% translate "Excel" %}
</a>
{% if can_manage %}
{% if rfq.status == 'draft' %}
<a href="{% url 'stock:request_for_quote_edit' rfq.pk %}" class="btn btn-warning">
<i class="bi bi-pencil"></i> {% translate "Modifier" %}
</a>
{% endif %}
{% if rfq.status == 'draft' %}
<form method="post" action="{% url 'stock:request_for_quote_ordered' rfq.pk %}" class="d-inline">
{% csrf_token %}
<button type="submit" class="btn btn-info text-white">
<i class="bi bi-send"></i> {% translate "Marquer comme envoyée" %}
</button>
</form>
{% endif %}
{% if rfq.status == 'draft' or rfq.status == 'sent' %}
<a href="{% url 'stock:purchase_order_new' %}?rfq={{ rfq.pk }}" class="btn btn-success">
<i class="bi bi-cart-plus"></i> {% translate "Créer un bon de commande" %}
</a>
<form method="post" action="{% url 'stock:request_for_quote_cancel' rfq.pk %}" class="d-inline">
{% csrf_token %}
<button type="submit" class="btn btn-danger" onclick="return confirm('{% translate "Annuler cette demande d'offre ?" %}');">
<i class="bi bi-x-circle"></i> {% translate "Annuler" %}
</button>
</form>
{% endif %}
{% endif %}
</div>
</div>
<div class="row">
<!-- Informations générales -->
<div class="col-md-4 mb-4">
<div class="card shadow-sm">
<div class="card-header bg-primary text-white">
<h5 class="mb-0">
<i class="bi bi-info-circle"></i> {% translate "Informations" %}
</h5>
</div>
<div class="card-body">
<div class="mb-3">
<strong>{% translate "Code" %}:</strong><br>
<span class="fs-5 font-monospace">{{ rfq.code }}</span>
</div>
<div class="mb-3">
<strong>{% translate "Statut" %}:</strong><br>
<span class="badge bg-{% if rfq.status == 'completed' %}success{% elif rfq.status == 'sent' %}info{% elif rfq.status == 'cancelled' %}secondary{% else %}warning text-dark{% endif %} fs-6 mt-1">
{{ rfq.get_status_display }}
</span>
</div>
<div class="mb-3">
<strong>{% translate "Entrepôt de livraison" %}:</strong><br>
<span class="fs-5">{{ rfq.warehouse.name }}</span>
</div>
<div class="mb-3">
<strong>{% translate "Créé par" %}:</strong><br>
<span class="fs-6">{{ rfq.created_by.get_full_name|default:rfq.created_by.username }}</span>
</div>
<div class="mb-3">
<strong>{% translate "Date de création" %}:</strong><br>
{{ rfq.date_created|date:"d/m/Y" }}
</div>
<div class="mb-3">
<strong>{% translate "Fournisseurs sollicités" %}:</strong><br>
{% for supplier in rfq.suppliers.all %}
<span class="badge bg-light text-dark border d-inline-block m-1">{{ supplier.name }}</span>
{% empty %}
<span class="text-muted">—</span>
{% endfor %}
</div>
{% if rfq.notes %}
<div class="mb-0">
<strong>{% translate "Notes" %}:</strong><br>
<p class="mb-0 text-muted whitespace-pre-wrap">{{ rfq.notes }}</p>
</div>
{% endif %}
<hr>
<div class="text-center">
<small class="text-muted">UUID: {{ rfq.uuid }}</small>
</div>
</div>
</div>
</div>
<!-- Articles de la demande d'offre -->
<div class="col-md-8 mb-4">
<div class="card shadow-sm">
<div class="card-header bg-info text-white">
<h5 class="mb-0">
<i class="bi bi-box-seam"></i> {% translate "Articles souhaités" %}
</h5>
</div>
<div class="card-body">
{% if rfq.items.all %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>{% translate "Code" %}</th>
<th>{% translate "Produit" %}</th>
<th>{% translate "Unité" %}</th>
<th class="text-center">{% translate "Quantité demandée" %}</th>
</tr>
</thead>
<tbody>
{% for item in rfq.items.all %}
<tr>
<td>
<code>{{ item.product.code }}</code>
</td>
<td>
<strong>{{ item.product.name }}</strong>
</td>
<td>
<span class="badge bg-light text-dark border">{{ item.product.get_unit_display }}</span>
</td>
<td class="text-center">
{% if item.num_articles and item.quantity_per_article %}
<span class="badge bg-primary" title="{{ item.num_articles }} &times; {{ item.quantity_per_article }} {{ item.product.get_unit_display }}">
{{ item.num_articles }} &times; {{ item.quantity_per_article }} {{ item.product.unit }}
</span>
<br>
<small class="text-muted">= {{ item.quantity }} {{ item.product.unit }}</small>
{% else %}
<span class="badge bg-primary">{{ item.quantity }} {{ item.product.unit }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center text-muted py-4">
<i class="bi bi-inbox" style="font-size: 2rem;"></i>
<p class="mb-0">{% translate "Aucun article dans cette demande d'offre" %}</p>
</div>
{% endif %}
</div>
</div>
{% if rfq.purchase_orders.exists %}
<div class="card shadow-sm mt-4">
<div class="card-header bg-success text-white">
<h5 class="mb-0">
<i class="bi bi-cart-check"></i> {% translate "Bons de commande associés" %}
</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-sm align-middle mb-0">
<thead>
<tr>
<th>{% translate "Code" %}</th>
<th>{% translate "Fournisseur" %}</th>
<th>{% translate "Date" %}</th>
<th>{% translate "Statut" %}</th>
</tr>
</thead>
<tbody>
{% for po in rfq.purchase_orders.all %}
<tr>
<td>
<a href="{% url 'stock:purchase_order_detail' po.pk %}">{{ po.code }}</a>
</td>
<td>{{ po.supplier.name }}</td>
<td>{{ po.date_ordered|date:"d/m/Y" }}</td>
<td>
<span class="badge bg-{% if po.status == 'received' %}success{% elif po.status == 'partial' %}warning text-dark{% elif po.status == 'ordered' %}info{% elif po.status == 'cancelled' %}secondary{% else %}warning text-dark{% endif %}">
{{ po.get_status_display }}
</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endblock content %}