229 lines
13 KiB
HTML
229 lines
13 KiB
HTML
{% extends "base.html" %}
|
||
{% load i18n %}
|
||
|
||
{% block content %}
|
||
<div class="container-fluid mt-3">
|
||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||
<h1 class="h3">{% translate "Gestion des achats" %}</h1>
|
||
{% if can_create_purchase_order %}
|
||
<div class="d-flex gap-2">
|
||
<a href="{% url 'stock:request_for_quote_new' %}" class="btn btn-outline-primary">
|
||
<i class="bi bi-plus-circle"></i> {% translate "Nouvelle demande d'offre" %}
|
||
</a>
|
||
<a href="{% url 'stock:purchase_order_new' %}" class="btn btn-primary">
|
||
<i class="bi bi-plus-circle"></i> {% translate "Nouvelle commande" %}
|
||
</a>
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
|
||
<!-- Onglets -->
|
||
<ul class="nav nav-tabs mb-3" id="purchaseTabs" role="tablist">
|
||
<li class="nav-item" role="presentation">
|
||
<button class="nav-link active" id="orders-tab" data-bs-toggle="tab" data-bs-target="#orders" type="button" role="tab" aria-controls="orders" aria-selected="true">
|
||
<i class="bi bi-cart"></i> {% translate "Commandes" %}
|
||
<span class="badge bg-primary ms-1">{{ purchase_orders.count }}</span>
|
||
</button>
|
||
</li>
|
||
<li class="nav-item" role="presentation">
|
||
<button class="nav-link" id="rfqs-tab" data-bs-toggle="tab" data-bs-target="#rfqs" type="button" role="tab" aria-controls="rfqs" aria-selected="false">
|
||
<i class="bi bi-file-earmark-text"></i> {% translate "Demandes d'offre" %}
|
||
<span class="badge bg-secondary ms-1">{{ request_for_quotes.count }}</span>
|
||
</button>
|
||
</li>
|
||
{% if is_stock_manager %}
|
||
<li class="nav-item" role="presentation">
|
||
<button class="nav-link" id="suppliers-tab" data-bs-toggle="tab" data-bs-target="#suppliers" type="button" role="tab" aria-controls="suppliers" aria-selected="false">
|
||
<i class="bi bi-building"></i> {% translate "Fournisseurs" %}
|
||
<span class="badge bg-secondary ms-1">{{ suppliers.count }}</span>
|
||
</button>
|
||
</li>
|
||
{% endif %}
|
||
</ul>
|
||
|
||
<!-- Contenu des onglets -->
|
||
<div class="tab-content" id="purchaseTabsContent">
|
||
<!-- Onglet Commandes -->
|
||
<div class="tab-pane fade show active" id="orders" role="tabpanel" aria-labelledby="orders-tab">
|
||
<div class="table-responsive">
|
||
<table class="table table-striped align-middle">
|
||
<thead>
|
||
<tr>
|
||
<th>{% translate "Commande" %}</th>
|
||
<th>{% translate "Fournisseur" %}</th>
|
||
<th>{% translate "Entrepôt" %}</th>
|
||
<th>{% translate "Date" %}</th>
|
||
<th>{% translate "Statut" %}</th>
|
||
<th>{% translate "Articles" %}</th>
|
||
<th class="text-end">{% translate "Actions" %}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for order in purchase_orders %}
|
||
<tr>
|
||
<td>
|
||
<a href="{% url 'stock:purchase_order_detail' order.pk %}">{{ order.code }}</a>
|
||
</td>
|
||
<td>{{ order.supplier.name }}</td>
|
||
<td>{{ order.warehouse.name }}</td>
|
||
<td>{{ order.date_ordered }}</td>
|
||
<td>
|
||
<span class="badge bg-{% if order.status == 'received' %}success{% elif order.status == 'ordered' %}info{% elif order.status == 'cancelled' %}secondary{% else %}warning text-dark{% endif %}">
|
||
{{ order.get_status_display }}
|
||
</span>
|
||
</td>
|
||
<td>
|
||
<ul class="mb-0">
|
||
{% for item in order.items.all %}
|
||
<li>{{ item.quantity }} × {{ item.product.name }} ({{ item.location.name }})</li>
|
||
{% empty %}
|
||
<li class="text-muted">{% translate "Aucun article" %}</li>
|
||
{% endfor %}
|
||
</ul>
|
||
</td>
|
||
<td class="text-end">
|
||
{% if order.status != 'received' and order.status != 'cancelled' and order.can_receive %}
|
||
<form method="post" action="{% url 'stock:purchase_order_receive' order.pk %}">
|
||
{% csrf_token %}
|
||
<button type="submit" class="btn btn-sm btn-success">{% translate "Marquer reçue" %}</button>
|
||
</form>
|
||
{% else %}
|
||
<span class="text-muted">—</span>
|
||
{% endif %}
|
||
</td>
|
||
</tr>
|
||
{% empty %}
|
||
<tr>
|
||
<td colspan="7" class="text-center text-muted py-4">{% translate "Aucune commande pour le moment." %}</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Onglet Demandes d'offre -->
|
||
<div class="tab-pane fade" id="rfqs" role="tabpanel" aria-labelledby="rfqs-tab">
|
||
<div class="table-responsive">
|
||
<table class="table table-striped align-middle">
|
||
<thead>
|
||
<tr>
|
||
<th>{% translate "Demande d'offre" %}</th>
|
||
<th>{% translate "Entrepôt" %}</th>
|
||
<th>{% translate "Date" %}</th>
|
||
<th>{% translate "Statut" %}</th>
|
||
<th>{% translate "Articles" %}</th>
|
||
<th>{% translate "Fournisseurs sollicités" %}</th>
|
||
<th class="text-end">{% translate "Actions" %}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for rfq in request_for_quotes %}
|
||
<tr>
|
||
<td>
|
||
<a href="{% url 'stock:request_for_quote_detail' rfq.pk %}">{{ rfq.code }}</a>
|
||
</td>
|
||
<td>{{ rfq.warehouse.name }}</td>
|
||
<td>{{ rfq.date_created|date:"d/m/Y" }}</td>
|
||
<td>
|
||
<span class="badge bg-{% if rfq.status == 'completed' %}success{% elif rfq.status == 'sent' %}info{% elif rfq.status == 'cancelled' %}secondary{% else %}warning text-dark{% endif %}">
|
||
{{ rfq.get_status_display }}
|
||
</span>
|
||
</td>
|
||
<td>
|
||
<ul class="mb-0">
|
||
{% for item in rfq.items.all %}
|
||
<li>{{ item.quantity }} × {{ item.product.name }}</li>
|
||
{% empty %}
|
||
<li class="text-muted">{% translate "Aucun article" %}</li>
|
||
{% endfor %}
|
||
</ul>
|
||
</td>
|
||
<td>
|
||
{% for supplier in rfq.suppliers.all %}
|
||
<span class="badge bg-light text-dark border">{{ supplier.name }}</span>
|
||
{% empty %}
|
||
<span class="text-muted">—</span>
|
||
{% endfor %}
|
||
</td>
|
||
<td class="text-end">
|
||
<div class="d-flex gap-1 justify-content-end">
|
||
<a href="{% url 'stock:request_for_quote_pdf' rfq.pk %}" class="btn btn-sm btn-outline-secondary" target="_blank" title="{% translate 'Télécharger PDF' %}">
|
||
<i class="bi bi-file-earmark-pdf"></i>
|
||
</a>
|
||
<a href="{% url 'stock:request_for_quote_xlsx' rfq.pk %}" class="btn btn-sm btn-outline-success" title="{% translate 'Télécharger Excel' %}">
|
||
<i class="bi bi-file-earmark-excel"></i>
|
||
</a>
|
||
{% if rfq.status == 'draft' or rfq.status == 'sent' %}
|
||
<a href="{% url 'stock:purchase_order_new' %}?rfq={{ rfq.pk }}" class="btn btn-sm btn-success">
|
||
<i class="bi bi-cart-plus"></i> {% translate "Créer BC" %}
|
||
</a>
|
||
{% endif %}
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
{% empty %}
|
||
<tr>
|
||
<td colspan="7" class="text-center text-muted py-4">{% translate "Aucune demande d'offre pour le moment." %}</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Onglet Fournisseurs -->
|
||
{% if is_stock_manager %}
|
||
<div class="tab-pane fade" id="suppliers" role="tabpanel" aria-labelledby="suppliers-tab">
|
||
{% if can_create_supplier %}
|
||
<div class="mb-3">
|
||
<a href="{% url 'stock:supplier_create' %}" class="btn btn-success">
|
||
<i class="bi bi-plus-circle"></i> {% translate "Nouveau fournisseur" %}
|
||
</a>
|
||
</div>
|
||
{% endif %}
|
||
<div class="table-responsive">
|
||
<table class="table table-striped align-middle">
|
||
<thead>
|
||
<tr>
|
||
<th>{% translate "Nom" %}</th>
|
||
<th>{% translate "Numéro d'entreprise" %}</th>
|
||
<th>{% translate "Email" %}</th>
|
||
<th>{% translate "Téléphone" %}</th>
|
||
<th>{% translate "Statut" %}</th>
|
||
<th class="text-end">{% translate "Actions" %}</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for supplier in suppliers %}
|
||
<tr>
|
||
<td><strong>{{ supplier.name }}</strong></td>
|
||
<td>{{ supplier.enterprise_number|default:"—" }}</td>
|
||
<td>{{ supplier.contact_email|default:"—" }}</td>
|
||
<td>{{ supplier.phone_number|default:"—" }}</td>
|
||
<td>
|
||
{% if supplier.is_active %}
|
||
<span class="badge bg-success">{% translate "Actif" %}</span>
|
||
{% else %}
|
||
<span class="badge bg-secondary">{% translate "Inactif" %}</span>
|
||
{% endif %}
|
||
</td>
|
||
<td class="text-end">
|
||
<a href="{% url 'stock:supplier_detail' supplier.pk %}" class="btn btn-sm btn-primary">
|
||
<i class="bi bi-eye"></i> {% translate "Voir" %}
|
||
</a>
|
||
</td>
|
||
</tr>
|
||
{% empty %}
|
||
<tr>
|
||
<td colspan="6" class="text-center text-muted py-4">{% translate "Aucun fournisseur enregistré." %}</td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
{% endblock content %}
|