{% extends '@EasyAdmin/page/content.html.twig' %}
{% block page_title %}
Dashboard {#({{ "now"|date("d/m/Y H:i:s") }})#}
{% endblock %}
{% block content_title %}<h1 class="title">{{ ea.dashboardTitle }}</h1>{% endblock %}
{% block main %}
<div class="form-panel-header ">
<div class="form-panel-title">
<a href="#" class="not-collapsible">
<i class="form-panel-icon fa fa-exclamation-circle"></i>
<em>Pedidos no entregados a la sucursal</em>
</a>
</div>
</div>
<table class="table datagrid with-rounded-top" id="xmlSinEntregar">
<tbody>
{% if cabs %}
{% for cab in cabs %}
{% set url = ea_url()
.setController('App\\Controller\\Admin\\CabeceraCrudController')
.setAction('detail')
.setEntityId(cab.id)
%}
<tr>
<td><i class="fa fa-map"></i> {{ cab.sucursal }}</td>
<td>{{ cab.nombrecliente }}</td>
<td>{{ cab.updatedAt|date("d/m/Y H:i:s") }}</td>
<td>{{ cab.filename }}</td>
<td><a href="{{ url }}">ver</a>
</tr>
{% endfor %}
{% else %}
{# <tr class="empty-row">
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
</tr>
<tr class="empty-row">
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
</tr>
<tr class="no-results">
<td colspan="100">
No se han encontrado resultados.
</td>
</tr>
<tr class="empty-row">
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
</tr>
<tr class="empty-row">
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
</tr> #}
{% endif %}
</tbody>
</table>
{# indicadores #}
<div class="form-panel-header ">
<div class="form-panel-title">
<a href="#" class="not-collapsible">
<i class="form-panel-icon fa fa-truck"></i>
<em>Estado de las sucursales (según capacidad)</em>
</a>
</div>
</div>
<table class="datagrid">
<thead>
<tr>
<th><span><strong>Sucursal</strong></span></th>
<th><span><strong># en preparación (Callcenter)</strong></span></th>
<th><span><strong># en preparación (Ecommerce)</strong></span></th>
<th><span><strong># pedidos en reparto</strong></span></th>
<th><span><strong># TOTAL PEDIDOS</strong></span></th>
<th><span><strong># max de pedidos en reparto</strong></span></th>
</tr>
</thead>
<tbody>
{% for nombreSucursal, datosSucursal in resultadosConsolidados %}
<tr>
<td clasS="text-left">{{ nombreSucursal }}</td>
<td class="text-center">
{% if datosSucursal.detalles.callcenter is defined %}
{% for detalle in datosSucursal.detalles.callcenter %}
{{ detalle.preparacion }}
{% endfor %}
{% else %}
Sin datos
{% endif %}
</td>
<td class="text-center">
{% if datosSucursal.detalles.ecommerce is defined %}
{% for detalle in datosSucursal.detalles.ecommerce %}
{{ detalle.preparacion }}
{% endfor %}
{% else %}
Sin datos
{% endif %}
</td>
<td clasS="text-center">
{% set porcentaje = (70 * datosSucursal.sucursal.getOrderCapacity)/100 %}
{% if datosSucursal.total.reparto < porcentaje|round %}
{% set class = 'badge-success' %}
{% elseif datosSucursal.total.reparto >= porcentaje|round and datosSucursal.total.reparto < datosSucursal.sucursal.getOrderCapacity %}
{% set class = 'badge-warning' %}
{% else %}
{% set class = 'badge-danger' %}
{% endif %}
<span class="badge badge-pill {{ class }}"><strong>{{ datosSucursal.total.reparto }}</strong></span>
</td>
<td clasS="text-center">{{ datosSucursal.total.preparacion + datosSucursal.total.reparto }}</td>
<td clasS="text-center">{{ datosSucursal.sucursal.getOrderCapacity }}</td>
{# <td clasS="text-left">{{ indicator.preparacion }}</td> #}
{# <td clasS="text-left">
{% set porcentaje = (70 * indicator.sucursal.getOrderCapacity)/100 %}
{% if indicator.reparto < porcentaje|round %}
{% set class = 'badge-success' %}
{% elseif indicator.reparto >= porcentaje|round and indicator.reparto < indicator.sucursal.getOrderCapacity %}
{% set class = 'badge-warning' %}
{% else %}
{% set class = 'badge-danger' %}
{% endif %}
<span class="badge badge-pill {{ class }}"><strong>{{ indicator.reparto }}</strong></span>
</td> #}
{# <td clasS="text-left">{{ indicator.preparacion + indicator.reparto }}</td>
<td clasS="text-left">{{ indicator.sucursal.getOrderCapacity }}</td> #}
</tr>
{% endfor %}
</tbody>
<tfoot></tfoot>
</table>
{# <section class="content-header">
<div class="content-header-title">
<h1 class="title">Pedidos no entregados a la sucursal</h1>
</div>
</section> #}
{% block body_custom_javascript %}
<script>
var notification = new Audio('{{ asset('sounds/Notification.mp3') }}');
function xmlSinEntregar() {
var tbl = document.getElementById("xmlSinEntregar");
if (tbl.rows.length == 0) {
// console.log('No hay pedidos');
} else {
// console.log('La tabla tiene ' + tbl.rows.length + ' Pedido(s) sin entregar');
notification.play();
}
alertaXmlSinEntregar();
}
function alertaXmlSinEntregar(){
let tiempo = '{{actualizardashboard}}' * 1000;
setTimeout(function(){
location.reload()
}, tiempo);
}
xmlSinEntregar();
</script>
{% endblock %}
{% endblock %}