copanier/copanier/templates/includes/delivery_table.html

101 lines
6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% if not producers and referent %}
{% set producers = delivery.get_producers_for_referent(referent) %}
{% elif not producers %}
{% set producers = delivery.producers %}
{% endif %}
{% for producer in producers %}
{% set producer_obj = delivery.producers[producer] %}
{% if edit_mode or producer_obj.has_active_products(delivery) %}
<h3>{{ producer_obj.name }}
{% if producer_obj.needs_price_update(delivery) %}*{% endif %}
{% if edit_mode or request.user.is_staff or producer_obj.referent == request.user.email %}
<span class="edit">
<a class="button" href="{{ url_for('edit_producer', delivery_id=delivery.id, producer_id=producer_obj.id) }}"><i class="icon-ribbon"></i>&nbsp; Gérer les produits</a>
</span>
{% endif %}
</h3>
<h5>{% if producer_obj.description %}{{ producer_obj.description }}. {% endif %}Référent⋅e : <a href="mailto:{{ producer_obj.referent }}">{{ producer_obj.referent_name }}</a> / <a href="tel:{{ producer_obj.referent_tel }}">{{ producer_obj.referent_tel }}</a>
</h5>
{% if not delivery.get_products_by(producer) %}
😔 Aucun produit. Voulez vous <a href="{{ url_for('create_product', delivery_id=delivery.id, producer_id=producer_obj.id) }}">en rajouter un ?</a>
{% else %}
<table class="delivery pure-table">
<thead>
<tr>
<th class="product">Produit</th>
<th class="price">Prix</th>
{% if delivery.has_packing %}
<th class="packing">Conditionnement</th>
{% endif %}
<th class="amount">Total</th>
{% if not list_only %}
{% for orderer, order in delivery.orders.items() %}
{% set orderer_name = request.groups.groups[orderer].name if request.groups.groups[orderer] else orderer %}
<th class="person">
{% if request.user and (request.user.is_staff or request.user.is_referent(delivery)) %}
<a class="underline" href="{{ url_for('place_order', id=delivery.id) }}?orderer={{ orderer }}" title="{{ orderer }}">{{ orderer_name }} <i class="icon-pencil"></i></a>
{% else %}
<span title="{{ orderer }}">{{ orderer_name }}</span>
{% endif %}
</th>
{% endfor %}
{% endif %}
</tr>
</thead>
<tbody>
{% for product in delivery.get_products_by(producer) %}
<tr {% if product.rupture %}class="rupture"{% endif %}>
<th class="product">{% if edit_mode %}<a href="{{ url_for('edit_product', delivery_id=delivery.id, producer_id=producer_obj.id, product_ref=product.ref) }}">{% endif %}{% if edit_mode %}<i class="icon-pencil"></i>&nbsp;{% endif %}{% if product.rupture %}{% endif %} {{ product }}{% if edit_mode %}</a>{% endif %}
<td>{{ product.price | round(2) }} €</td>
{% if delivery.has_packing %}
<td class="packing">{% if product.packing %}{{ product.packing }} x {% endif %} {{ product.unit }}</td>
{% endif %}
<th{% if delivery.status == delivery.ADJUSTMENT and delivery.product_missing(product) %} class="missing" title="Les commandes individuelles ne correspondent pas aux conditionnements"{% endif %}>
{{ delivery.product_wanted(product) }}
{% if delivery.status == delivery.ADJUSTMENT and delivery.product_missing(product) %} ({{ delivery.product_missing(product) }})
{% if request.user.is_staff %}<a href="{{ url_for('adjust_product', id=delivery.id, ref=product.ref) }}" class="button" title="ajuster le produit">ajuster</a>{% endif %}
{% endif %}
</th>
{% if not list_only %}
{% for email, order in delivery.orders.items() %}
<td title="Commandé: {{ order[product.ref].wanted }} — Ajusté: {{ "%+d"|format(order[product.ref].adjustment) }}">{{ order[product.ref].quantity or "—" }}</td>
{% endfor %}
{% endif %}
</tr>
{% endfor %}
{% if delivery.shipping.get(producer) %}
<tr>
<th class="shipping"><i class="icon-map"></i>Frais de livraison</th>
<td></td>
{% if delivery.has_packing %}
<td></td>
{% endif %}
<th class="shipping">{{ delivery.shipping[producer] }} €</th>
{% if not list_only %}
{% for email, order in delivery.orders.items() %}
<td>{{ delivery.shipping_for(email, producer)|round(2) }} €</td>
{% endfor %}
{% endif %}
</tr>
{% endif %}
<tr>
<th class="total"><i class="icon-pricetags"></i> Total</th><td></td>
{% if delivery.has_packing %}
<td></td>
{% endif %}
<th class="total">{{ delivery.total_for_producer(producer) }} €</th>
{% if not list_only %}
{% for email, order in delivery.orders.items() %}
<td>{{ order.total(delivery.get_products_by(producer), delivery, email) }} €</td>
{% endfor %}
{% endif %}
</tr>
</tbody>
</table>
{% endif %}
<br />
{%- endif %}
{% endfor %}