{% extends 'base_frontend.html.twig' %}

{% block title %}  Détail Panier  {% endblock %}

{% block content %}
    <div class="breadcrumb">
        <div class="breadcrumb-inner">
            <ul class="list-inline list-unstyled">
                <li><a href="{{ path('frontend_home_index') }}">Accueil</a></li>
                <li><a href="{{ path('frontend_panier_index') }}">Panier</a></li>
            </ul>
        </div>
        <!-- /.breadcrumb-inner -->
    </div>

    <div class="body-content outer-top-xs">
        <div class="row ">
            <div class="shopping-cart">
                <div class="shopping-cart-table ">
                    <div class="table-responsive">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th class="cart-romove item">Supprimer</th>
                                    <th class="cart-description item">Image</th>
                                    <th class="cart-product-name item">Nom d'Article / Service</th>
                                    <th class="cart-qty item">Quantité / Date</th>
                                    <th class="cart-sub-total item">Prix</th>
                                    <th class="cart-total last-item">Avance</th>
                                </tr>
                            </thead>
                            <!-- /thead -->
                            <tbody>
                                {% set TotalAvance = 0 %}
                                {% set FraisService = 0 %}
                                {% for key, panier in paniers %}
                                    
                                    {% if panier['type'] == 'SERVICE' %}
                                        {% set pathUrl = path('frontend_service_detail', {id: panier['id']} ) %}
                                    {% elseif panier['type'] == 'ARTICLE' %}
                                        {% set pathUrl = path('frontend_article_detail', {id: panier['id']} ) %}
                                    {% endif %}

                                    <tr>
                                        <td class="romove-item">
                                            <a href="{{ path('frontend_panier_remove', {idDele: key}) }}" title="annuler" class="icon">
                                                <i class="fa-solid fa-trash-can"></i>
                                            </a>
                                        </td>
                                        <td class="cart-image">
                                            <a class="entry-thumbnail" href="{{ pathUrl }}">
                                                <img src="{{ asset(panier['image']) }}" alt="">
                                            </a>
                                        </td>
                                        <td class="cart-product-name-info">
                                            <h4 class='cart-product-description'>
                                                <a href="{{ pathUrl }}">{{ panier['titre'] }}</a>
                                            </h4>
                                            <div class="row">
                                                <div class="col-sm-12">
                                                    <div class="rating rateit-small"></div>
                                                </div>
                                                <div class="col-sm-12">
                                                    <div class="reviews">
                                                        {% if panier['id'] == 'SERVICE' %}
                                                            {{ panier['data']['nom'] }} {{ panier['data']['prenom'] }}
                                                        {% endif %}
                                                    </div>
                                                </div>
                                            </div>
                                            <!-- /.row -->
                                            <div class="cart-product-info">
                                                <span class="product-color">{{ panier['type'] }}</span>
                                            </div>
                                        </td>
                                        {%  if panier['type'] == 'ARTICLE'  %}
                                            <td class="cart-product-quantity">
                                                <div class="quant-input">
                                                    {{ panier['prix'] }} * {{ panier['qtyRdv']  }}
                                                </div>
                                            </td>
                                            <td class="cart-product-sub-total">
                                                <span class="cart-sub-total-price">{{ panier['prix']* panier['qtyRdv'] }} DT</span>
                                            </td>
                                        {% elseif panier['type'] == 'SERVICE' %}
                                            <td class="cart-product-quantity">
                                                <div class="quant-input">
                                                    {{ panier['qtyRdv'] }}
                                                </div>
                                            </td>
                                            <td class="cart-product-sub-total">
                                                <span class="cart-sub-total-price">{{ panier['prix'] }} DT</span>
                                            </td>
                                        {% endif %}


                                        
                                        <td class="cart-product-grand-total">
                                            <span class="cart-grand-total-price">{{ panier['avance'] }} DT</span>
                                        </td>
                                    </tr>

                                    {% set TotalAvance = TotalAvance + panier['avance'] %}
                                    {% set FraisService = FraisService + panier['frais'] %}
                                {% endfor %}
                            </tbody>
                            <!-- /tbody -->
                            <tfoot>
                                <tr>
                                <td colspan="7">
                                    <div class="shopping-cart-btn">
                                        <span class="">
                                        <a href="{{ path('frontend_home_index') }}" class="btn btn-upper btn-primary outer-left-xs">Continue le navigation</a>
                                        <a href="#" class="btn btn-upper btn-primary pull-right outer-right-xs">Modifier le Panier</a>
                                        </span>
                                    </div>
                                    <!-- /.shopping-cart-btn -->
                                </td>
                                </tr>
                            </tfoot>
                        </table>
                        <!-- /table -->
                    </div>
                </div>
                
                
                <div class="col-md-4 col-sm-12  col-md-offset-8 cart-shopping-total">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>
                                <div class="cart-sub-total">
                                    Total Avance<span class="inner-left-md">{{ TotalAvance }} DT</span>
                                </div>
                                <div class="cart-sub-total">
                                    Frais de service<span class="inner-left-md">{{ FraisService }} DT</span>
                                </div>
                                <div class="cart-grand-total">
                                    Total A Payer<span class="inner-left-md">{{ TotalAvance + FraisService }} DT</span>
                                </div>
                                </th>
                            </tr>
                        </thead>
                        <!-- /thead -->
                        <tbody>
                            <tr>
                                <td>
                                    <div class="cart-checkout-btn pull-right">
                                        <a href="{{ path('frontend_paiement_index') }}" class="btn btn-primary checkout-btn">Payer</a>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                        <!-- /tbody -->
                    </table>
                    <!-- /table -->
                </div>
                <!-- /.cart-shopping-total -->			
            </div>
            <!-- /.shopping-cart -->
        </div>
        <!-- /.row -->
    </div>
    <!-- /.body-content -->
{% endblock %}
