{% extends 'base.html.twig' %}
{% block title %}{% endblock %}
{% block body %}
<style>
body{
font-family: Poppins
}
.main-content{
background: #fff;
height: auto;
}
.bouttonfilltre{
margin-top: 30px;
background: #C64864;
color: #fff;
}
.page-content {
padding: 0px 10px;
}
</style>
{% if app.user.stringRole == 'Admin' %}
{{ form_start(filterForm) }}
<div class="row" style="
background: #c3e2e2;
border: 1px dotted;
padding: 32px;
">
<div class="col-4">
{{ form_row(filterForm.startDate, {'attr': {'class': 'form-control'}}) }}
</div>
<div class="col-4">
{{ form_row(filterForm.endDate, {'attr': {'class': 'form-control'}}) }}
</div>
<div class="col-4">
{% if filterForm.user is defined %}
{{ form_row(filterForm.user, {'attr': {'class': 'form-control'}}) }}
{% endif %}
</div>
<div class="col-12" style="text-align: center">
{{ form_row(filterForm.filter, {'attr': {'class': 'form-control bouttonfilltre'}})}}
</div>
</div>
{{ form_end(filterForm) }}
{% elseif app.user.stringRole != 'Admin' %}
{{ form_start(filterForm) }}
<div class="row" style="
background: #c3e2e2;
border: 1px dotted;
padding: 32px;
">
<div class="col-6">
{{ form_row(filterForm.startDate, {'attr': {'class': 'form-control'}}) }}
</div>
<div class="col-6">
{{ form_row(filterForm.endDate, {'attr': {'class': 'form-control'}}) }}
</div>
<div class="col-6" style="text-align: center">
{{ form_row(filterForm.filter, {'attr': {'class': 'form-control bouttonfilltre'}})}}
</div>
</div>
{{ form_end(filterForm) }}
{% endif %}
<h2 style=" font-family: Poppins; text-align: center ; color: #1bbc9b;margin: 30px 0px">Rapports pour {{ monthName }}</h2>
{% if app.user.stringRole == 'Admin'%}
<div class="row">
<div class="col-lg-6">
<div class="card">
<div class="card-header" style="background: #8d2a8a ; color: #fff ; text-align: center">Total des commandes </div>
<div class="card-body">
<h4 class="mb-0 text-center text-dark">
{{ totalOrdersAmount }} DH
</h4>
</div>
</div>
</div><!-- end col -->
<div class="col-lg-6">
<div class="card">
<div class="card-header" style="background: #78DEC7; text-align: center">Total des commissions</div>
<div class="card-body">
<h4 class="mb-0 text-center text-dark"> {{ totalCommissionsAmount }} DH</h4>
</div>
</div>
</div><!-- end col -->
</div>
{% endif %}
{% if orders is not empty %}
<h5 style="color: #fff ; background:#028080 ; padding: 10px">1 : Total de mes commandes : {{ totalAmount }} DH</h5> {# Affichez le total ici #}
<div class="table-bordered">
<table class="table">
<thead>
<tr>
<th>N° commande</th>
<th>Montant</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for order in orders %}
<tr>
<td>{{ order.numerocommande }}</td>
<td>{{ order.total }}</td>
<td>{{ order.date|date('Y-m-d') }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>Aucune commande trouvée pour les critères spécifiés.</p>
{% endif %}
</div>
<h5 style="color: #fff ; margin-top: 30px ; background:#028080 ; padding: 10px">2 : Récapitulatif des commandes et des commissions de mon réseau </h5>
<table class="table" id="table">
<thead>
<tr>
<th>Génération</th>
<th>Total Commandes (Dh)</th>
<th>Total Commissions (Dh)</th>
</tr>
</thead>
<tbody>
{% set totalCommissions = 0 %}
{% set totalOrders = 0 %}
{% for data in commissionsByLevel %}
{% set orderAmount = totalOrdersByLevel[data.level]|default(0) %}
{% set commissionAmount = data.totalCommissions|default(0) %}
{% set totalCommissions = totalCommissions + commissionAmount %}
{% set totalOrders = totalOrders + orderAmount %}
<tr>
<td>G {{ data.level }}</td>
<td>{{ orderAmount }}</td>
<td>{{ commissionAmount }}</td>
</tr>
{% endfor %}
<tr >
<th style="background: #ff00ff ; color: #ffffff ; font-weight: 800;"> Total</th>
<td style="background: #ff00ff ; color: #ffffff ; font-weight: 800;">{{ totalOrders }} DH </td>
<td style="background: #ff00ff ; color: #ffffff ; font-weight: 800;">{{ totalCommissions }} DH </td>
</tr>
</tbody>
</table>
<h5 style="color: #fff ; margin-top: 30px ; background:#028080 ; padding: 10px">3 : Détail des commandes et des commissions de mon réseau </h5>
{% for generation, details in detailsByGeneration %}
<h5 style=" background: aquamarine;
padding: 5px;">Génération {{ generation }}</h3>
<div style="overflow-x: auto; /* Active le défilement horizontal si le contenu déborde */
width: 100%;
margin-bottom: 100px/* Vo">
<table class="table" id="tableo" >
<thead>
<tr>
<th>Agent</th>
<th>Code</th>
<th>N° Commande</th>
<th>Mt Commande</th>
<th>Commission</th>
</tr>
</thead>
<tbody>
{% for detail in details %}
<tr>
<td>{{ detail.userLastName }} {{ detail.userfirstname }}</td>
<td>{{ detail.userMatricule }}</td>
<td>{{ detail.orderNumber }}</td>
<td>{{ detail.orderAmount }}</td>
<td>{{ detail.commission }}</td>
</tr>
{% else %}
<tr>
<td colspan="5">Aucune donnée disponible</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
$(document).ready( function () {
$('#table')({
scrollX: true,
language: {
url: '//cdn.datatables.net/plug-ins/1.10.20/i18n/French.json'
}
});
} );
</script>
<script type="text/javascript">
$(document).ready( function () {
$('#tableo')({
scrollX: true,
language: {
url: '//cdn.datatables.net/plug-ins/1.10.20/i18n/French.json'
}
});
} );
</script>
{% endblock %}