mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-11-04 02:53:06 +00:00 
			
		
		
		
	second patch on eboutic
This commit is contained in:
		@@ -23,56 +23,56 @@
 | 
			
		||||
    <h1 id="eboutic-title">{% trans %}Eboutic{% endtrans %}</h1>
 | 
			
		||||
    <div id="eboutic" x-data="basket">
 | 
			
		||||
        <div id="basket">
 | 
			
		||||
                <h3>Panier</h3>
 | 
			
		||||
                {% if errors %}
 | 
			
		||||
                    <div class="error-message">
 | 
			
		||||
                        {% for error in errors %}
 | 
			
		||||
                            <p>{{ error }}</p>
 | 
			
		||||
                        {% endfor %}
 | 
			
		||||
            <h3>Panier</h3>
 | 
			
		||||
            {% if errors %}
 | 
			
		||||
                <div class="error-message">
 | 
			
		||||
                    {% for error in errors %}
 | 
			
		||||
                        <p>{{ error }}</p>
 | 
			
		||||
                    {% endfor %}
 | 
			
		||||
                    {% trans %}Your basket has been cleaned accordingly to those errors.{% endtrans %}
 | 
			
		||||
                    </div>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
                <ul class="item-list">
 | 
			
		||||
                    {# Starting money #}
 | 
			
		||||
                    <li>
 | 
			
		||||
                        <span class="item-name">
 | 
			
		||||
                            <strong>{% trans %}Current account amount: {% endtrans %}</strong>
 | 
			
		||||
                        </span>
 | 
			
		||||
                        <span class="item-price">
 | 
			
		||||
                            <strong>{{ "%0.2f"|format(customer_amount) }} €</strong>
 | 
			
		||||
                        </span>
 | 
			
		||||
                    </li>
 | 
			
		||||
                    <template x-for="item in items" :key="item.id">
 | 
			
		||||
                        <li class="item-row" x-show="item.quantity > 0">
 | 
			
		||||
                            <span class="item-name" x-text="item.name"></span>
 | 
			
		||||
                            <div class="item-quantity">
 | 
			
		||||
                                <i class="fa fa-minus fa-xs" @click="remove(item.id)"></i>
 | 
			
		||||
                                <span x-text="item.quantity"></span>
 | 
			
		||||
                                <i class="fa fa-plus" @click="add(item)"></i>
 | 
			
		||||
                            </div>
 | 
			
		||||
                            <span class="item-price" x-text="(item.unit_price * item.quantity).toFixed(2) + ' €'"></span>
 | 
			
		||||
                        </li>
 | 
			
		||||
                    </template>
 | 
			
		||||
                    {# Total price #}
 | 
			
		||||
                    <li style="margin-top: 20px">
 | 
			
		||||
                        <span class="item-name"><strong>{% trans %}Basket amount: {% endtrans %}</strong></span>
 | 
			
		||||
                        <span x-text="get_total().toFixed(2) + ' €'" class="item-price"></span>
 | 
			
		||||
                    </li>
 | 
			
		||||
                </ul>
 | 
			
		||||
                <div class="catalog-buttons">
 | 
			
		||||
                    <button @click="clear_basket()" class="clear">
 | 
			
		||||
                        <i class="fa fa-trash"></i>
 | 
			
		||||
                        {% trans %}Clear{% endtrans %}
 | 
			
		||||
                    </button>
 | 
			
		||||
                    <form method="post" action="{{ url('eboutic:command') }}">
 | 
			
		||||
                        {% csrf_token %}
 | 
			
		||||
                        <button class="validate">
 | 
			
		||||
                            <i class="fa fa-check"></i>
 | 
			
		||||
                            <input type="submit" value="{% trans %}Validate{% endtrans %}"/>
 | 
			
		||||
                        </button>
 | 
			
		||||
                    </form>
 | 
			
		||||
                </div>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
            <ul class="item-list">
 | 
			
		||||
                {# Starting money #}
 | 
			
		||||
                <li>
 | 
			
		||||
                    <span class="item-name">
 | 
			
		||||
                        <strong>{% trans %}Current account amount: {% endtrans %}</strong>
 | 
			
		||||
                    </span>
 | 
			
		||||
                    <span class="item-price">
 | 
			
		||||
                        <strong>{{ "%0.2f"|format(customer_amount) }} €</strong>
 | 
			
		||||
                    </span>
 | 
			
		||||
                </li>
 | 
			
		||||
                <template x-for="item in items" :key="item.id">
 | 
			
		||||
                    <li class="item-row" x-show="item.quantity > 0">
 | 
			
		||||
                        <span class="item-name" x-text="item.name"></span>
 | 
			
		||||
                        <div class="item-quantity">
 | 
			
		||||
                            <i class="fa fa-minus fa-xs" @click="remove(item.id)"></i>
 | 
			
		||||
                            <span x-text="item.quantity"></span>
 | 
			
		||||
                            <i class="fa fa-plus" @click="add(item)"></i>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <span class="item-price" x-text="(item.unit_price * item.quantity).toFixed(2) + ' €'"></span>
 | 
			
		||||
                    </li>
 | 
			
		||||
                </template>
 | 
			
		||||
                {# Total price #}
 | 
			
		||||
                <li style="margin-top: 20px">
 | 
			
		||||
                    <span class="item-name"><strong>{% trans %}Basket amount: {% endtrans %}</strong></span>
 | 
			
		||||
                    <span x-text="get_total().toFixed(2) + ' €'" class="item-price"></span>
 | 
			
		||||
                </li>
 | 
			
		||||
            </ul>
 | 
			
		||||
            <div class="catalog-buttons">
 | 
			
		||||
                <button @click="clear_basket()" class="clear">
 | 
			
		||||
                    <i class="fa fa-trash"></i>
 | 
			
		||||
                    {% trans %}Clear{% endtrans %}
 | 
			
		||||
                </button>
 | 
			
		||||
                <form method="post" action="{{ url('eboutic:command') }}">
 | 
			
		||||
                    {% csrf_token %}
 | 
			
		||||
                    <button class="validate">
 | 
			
		||||
                        <i class="fa fa-check"></i>
 | 
			
		||||
                        <input type="submit" value="{% trans %}Validate{% endtrans %}"/>
 | 
			
		||||
                    </button>
 | 
			
		||||
                </form>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div id="catalog">
 | 
			
		||||
            {% if not request.user.date_of_birth %}
 | 
			
		||||
                <div class="alert" x-data="{show_alert: true}" x-show="show_alert" x-transition>
 | 
			
		||||
@@ -88,35 +88,37 @@
 | 
			
		||||
                </div>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
 | 
			
		||||
            {% for category, items in products|groupby('category') %}
 | 
			
		||||
                {% if items|count > 0 %}
 | 
			
		||||
                    <section>
 | 
			
		||||
                        {# I would have wholeheartedly directly used the header element instead
 | 
			
		||||
                        but it has already been made messy in core/style.scss #}
 | 
			
		||||
                        <div class="category-header">
 | 
			
		||||
                            <h3>{{ category }}</h3>
 | 
			
		||||
                            {% if category.comment %}
 | 
			
		||||
                                <p>{{ category.comment }}</p>
 | 
			
		||||
                            {% endif %}
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="product-group">
 | 
			
		||||
                            {% for p in items %}
 | 
			
		||||
                                <button class="product-button"
 | 
			
		||||
                                        @click='add_from_catalog({{ p.id }}, {{ p.name|tojson }}, {{ p.selling_price }})'>
 | 
			
		||||
                                    {% if p.icon %}
 | 
			
		||||
                                        <img src="{{ p.icon.url }}" alt="image de {{ p.name }}"
 | 
			
		||||
                                             width="40px" height="40px">
 | 
			
		||||
                                    {% else %}
 | 
			
		||||
                                        <i class="fa fa-2x fa-picture-o"></i>
 | 
			
		||||
                                    {% endif %}
 | 
			
		||||
                                    <p><strong>{{ p.name }}</strong></p>
 | 
			
		||||
                                    <p>{{ p.selling_price }} €</p>
 | 
			
		||||
                                </button>
 | 
			
		||||
                            {% endfor %}
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </section>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
                {% else %}
 | 
			
		||||
            {% for priority_groups in products|groupby('priority')|reverse %}
 | 
			
		||||
                {% for category, items in priority_groups.list|groupby('category') %}
 | 
			
		||||
                    {% if items|count > 0 %}
 | 
			
		||||
                        <section>
 | 
			
		||||
                            {# I would have wholeheartedly directly used the header element instead
 | 
			
		||||
                            but it has already been made messy in core/style.scss #}
 | 
			
		||||
                            <div class="category-header">
 | 
			
		||||
                                <h3>{{ category }}</h3>
 | 
			
		||||
                                {% if items[0].category_comment %}
 | 
			
		||||
                                    <p><i>{{ items[0].category_comment }}</i></p>
 | 
			
		||||
                                {% endif %}
 | 
			
		||||
                            </div>
 | 
			
		||||
                            <div class="product-group">
 | 
			
		||||
                                {% for p in items %}
 | 
			
		||||
                                    <button class="product-button"
 | 
			
		||||
                                            @click='add_from_catalog({{ p.id }}, {{ p.name|tojson }}, {{ p.selling_price }})'>
 | 
			
		||||
                                        {% if p.icon %}
 | 
			
		||||
                                            <img src="{{ p.icon.url }}" alt="image de {{ p.name }}"
 | 
			
		||||
                                                 width="40px" height="40px">
 | 
			
		||||
                                        {% else %}
 | 
			
		||||
                                            <i class="fa fa-2x fa-picture-o"></i>
 | 
			
		||||
                                        {% endif %}
 | 
			
		||||
                                        <p><strong>{{ p.name }}</strong></p>
 | 
			
		||||
                                        <p>{{ p.selling_price }} €</p>
 | 
			
		||||
                                    </button>
 | 
			
		||||
                                {% endfor %}
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </section>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                {% endfor %}
 | 
			
		||||
            {% else %}
 | 
			
		||||
                <p>{% trans %}There are no items available for sale{% endtrans %}</p>
 | 
			
		||||
            {% endfor %}
 | 
			
		||||
        </div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user