Files
BEYOND/addons/beyond_reports/static/src/tablero/tablero.xml
T

297 lines
17 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<!-- Los dos botones de descarga de un bloque. Se llama con la sección:
<t t-call="beyond_reports.Descargas"><t t-set="seccion" t-value="'equipo'"/></t> -->
<t t-name="beyond_reports.Descargas">
<div class="btn-group btn-group-sm beyond_descargas">
<button class="btn btn-outline-secondary" t-att-disabled="state.descargando"
t-att-title="'Descargar ' + etiqueta + ' en Excel'"
t-on-click="() => this.descargar(seccion, 'xlsx')">
<i class="fa fa-file-excel-o me-1"/>Excel
</button>
<button class="btn btn-outline-secondary" t-att-disabled="state.descargando"
t-att-title="'Descargar ' + etiqueta + ' en PDF'"
t-on-click="() => this.descargar(seccion, 'pdf')">
<i class="fa fa-file-pdf-o me-1"/>PDF
</button>
</div>
</t>
<t t-name="beyond_reports.Tablero">
<div class="o_beyond_tablero p-3">
<div class="d-flex flex-wrap align-items-baseline gap-2 mb-3">
<h2 class="mb-0">
<t t-if="esGerente" t-esc="state.datos?.sucursal"/>
<t t-else="">Tablero del director</t>
</h2>
<span class="text-muted" t-if="esGerente">· tu sucursal</span>
<div class="ms-auto d-flex align-items-center gap-2">
<span class="text-muted small" t-if="state.descargando">Preparando…</span>
<t t-call="beyond_reports.Descargas">
<t t-set="seccion" t-value="'todo'"/>
<t t-set="etiqueta" t-value="'el tablero completo'"/>
</t>
</div>
</div>
<!-- Filtros GLOBALES: afectan a todo lo de abajo, incluida la
curva. Si se filtra un servicio, la curva es de ese servicio. -->
<div class="beyond_filtros card card-body flex-row flex-wrap gap-3 align-items-end mb-3">
<div>
<label class="form-label mb-1">Periodo</label>
<div class="btn-group d-block">
<t t-foreach="[['hoy','Hoy'],['semana','Semana'],['mes','Mes'],['anio','Año']]"
t-as="atajo" t-key="atajo[0]">
<button class="btn btn-sm"
t-att-class="state.filtros.atajo === atajo[0] ? 'btn-primary' : 'btn-outline-secondary'"
t-on-click="() => this.aplicarAtajo(atajo[0])"
t-esc="atajo[1]"/>
</t>
</div>
</div>
<div>
<label class="form-label mb-1">Desde</label>
<input type="date" class="form-control form-control-sm"
t-att-value="state.filtros.desde"
t-on-change="(ev) => this.cambiarFecha('desde', ev)"/>
</div>
<div>
<label class="form-label mb-1">Hasta</label>
<input type="date" class="form-control form-control-sm"
t-att-value="state.filtros.hasta"
t-on-change="(ev) => this.cambiarFecha('hasta', ev)"/>
</div>
<div t-if="!esGerente">
<label class="form-label mb-1">Sucursales</label>
<div class="d-flex flex-wrap gap-1">
<t t-foreach="state.datos?.opciones?.sucursales or []" t-as="suc" t-key="suc.id">
<button class="btn btn-sm"
t-att-class="state.filtros.branch_ids.includes(suc.id) ? 'btn-primary' : 'btn-outline-secondary'"
t-on-click="() => this.alternarSucursal(suc.id)"
t-esc="suc.nombre"/>
</t>
<button class="btn btn-sm btn-link"
t-if="state.filtros.branch_ids.length"
t-on-click="() => { state.filtros.branch_ids.length = 0; this.cargar(); }">
Todas
</button>
</div>
</div>
<div>
<label class="form-label mb-1">Catálogo</label>
<select class="form-select form-select-sm" t-on-change="cambiarCatalogo">
<option value="todo">Todo</option>
<option value="service">Solo servicios</option>
<option value="consu">Solo productos</option>
</select>
</div>
</div>
<t t-if="state.cargando"><div class="text-muted">Cargando…</div></t>
<t t-elif="state.datos">
<!-- 1 · Métricas -->
<div class="row g-3 mb-3">
<div class="col-6 col-lg-3">
<div class="card card-body beyond_metrica">
<span class="beyond_metrica_titulo">Ventas del periodo</span>
<b t-esc="dinero(state.datos.metricas.ventas)"/>
<small t-if="state.datos.metricas.variacion !== null"
t-att-class="state.datos.metricas.variacion >= 0 ? 'text-success' : 'text-danger'">
<t t-esc="state.datos.metricas.variacion >= 0 ? '▲' : '▼'"/>
<t t-esc="Math.abs(state.datos.metricas.variacion)"/>% vs periodo anterior
</small>
<small t-else="" class="text-muted">sin datos del periodo anterior</small>
</div>
</div>
<div class="col-6 col-lg-3">
<div class="card card-body beyond_metrica">
<span class="beyond_metrica_titulo">Tickets</span>
<b t-esc="numero(state.datos.metricas.tickets)"/>
<small class="text-muted">
<t t-esc="numero(state.datos.metricas.tickets_hoy)"/> hoy
</small>
</div>
</div>
<div class="col-6 col-lg-3">
<div class="card card-body beyond_metrica">
<span class="beyond_metrica_titulo">Ticket promedio</span>
<b t-esc="dinero(state.datos.metricas.ticket_promedio)"/>
<small class="text-muted">IVA incluido</small>
</div>
</div>
<div class="col-6 col-lg-3" t-if="esGerente">
<div class="card card-body beyond_metrica"
t-att-class="state.datos.metricas.sin_checar ? 'border-warning' : ''">
<span class="beyond_metrica_titulo">Sin checar hoy</span>
<b t-esc="numero(state.datos.metricas.sin_checar)"/>
<small class="text-muted">
de <t t-esc="numero(state.datos.metricas.activos)"/> activos
</small>
</div>
</div>
</div>
<!-- 2 · Evolución -->
<div class="card card-body mb-3">
<h5>
<t t-if="esGerente">Evolución de ventas</t>
<t t-else="">Comparativo entre sucursales</t>
<small class="text-muted ms-2">
por <t t-esc="{'day':'día','week':'semana','month':'mes'}[state.datos.evolucion.grano]"/>
</small>
</h5>
<p t-if="!state.datos.evolucion.hay_tendencia" class="text-muted small mb-2">
Hace falta más historial para ver una tendencia: con un
solo periodo se muestra el total en barras. Amplía el
rango de fechas cuando haya más semanas registradas.
</p>
<div class="beyond_lienzo"><canvas t-ref="evolucion"/></div>
</div>
<!-- 2b · Tabla: la curva da la tendencia, la tabla los números -->
<div class="card card-body mb-3" t-if="!esGerente">
<div class="d-flex align-items-center mb-2">
<h5 class="mb-0 me-auto">Por sucursal</h5>
<t t-call="beyond_reports.Descargas">
<t t-set="seccion" t-value="'sucursales'"/>
<t t-set="etiqueta" t-value="'el comparativo entre sucursales'"/>
</t>
</div>
<table class="table table-sm table-hover mb-0">
<thead><tr>
<th>Sucursal</th><th class="text-end">Ventas</th>
<th class="text-end">Tickets</th><th class="text-end">Ticket promedio</th>
<th class="text-end">Personal activo</th>
</tr></thead>
<tbody>
<tr t-foreach="state.datos.sucursales" t-as="fila" t-key="fila.id"
class="beyond_clicable" t-on-click="() => this.verSucursal(fila)"
title="Filtrar el tablero a esta sucursal">
<td t-esc="fila.nombre"/>
<td class="text-end" t-esc="dinero(fila.ventas)"/>
<td class="text-end" t-esc="numero(fila.tickets)"/>
<td class="text-end" t-esc="dinero(fila.ticket_promedio)"/>
<td class="text-end" t-esc="numero(fila.personal)"/>
</tr>
<tr t-if="!state.datos.sucursales.length">
<td colspan="5" class="text-muted">Sin ventas en el periodo.</td>
</tr>
</tbody>
</table>
</div>
<div class="card card-body mb-3">
<div class="d-flex align-items-center mb-2">
<h5 class="mb-0 me-auto">
<t t-if="esGerente">Tu equipo</t>
<t t-else="">Personas por productividad</t>
</h5>
<t t-call="beyond_reports.Descargas">
<t t-set="seccion" t-value="'equipo'"/>
<t t-set="etiqueta" t-value="'las personas por productividad'"/>
</t>
</div>
<table class="table table-sm table-hover mb-0">
<thead><tr>
<th>Persona</th>
<th t-if="!esGerente">Sucursal</th>
<th class="text-end">Ventas atribuidas</th>
<th class="text-end">Servicios</th><th class="text-end">Ticket promedio</th>
<th class="text-end">Horas</th>
</tr></thead>
<tbody>
<tr t-foreach="state.datos.equipo" t-as="fila" t-key="fila.id"
class="beyond_clicable" t-on-click="() => this.verPersona(fila)"
title="Abrir su ficha">
<td t-esc="fila.nombre"/>
<td t-if="!esGerente" class="text-muted" t-esc="fila.sucursal"/>
<td class="text-end" t-esc="dinero(fila.ventas)"/>
<td class="text-end" t-esc="numero(fila.servicios)"/>
<td class="text-end" t-esc="dinero(fila.ticket_promedio)"/>
<td class="text-end" t-esc="horas(fila.horas)"/>
</tr>
<tr t-if="!state.datos.equipo.length">
<td colspan="6" class="text-muted">Sin actividad en el periodo.</td>
</tr>
</tbody>
</table>
</div>
<div class="row g-3">
<!-- 3 · Lo más vendido -->
<div class="col-12 col-lg-7">
<div class="card card-body h-100">
<div class="d-flex align-items-center mb-2">
<h5 class="mb-0 me-auto">Lo más vendido</h5>
<div class="btn-group btn-group-sm">
<button class="btn" t-att-class="state.orden === 'monto' ? 'btn-primary' : 'btn-outline-secondary'"
t-on-click="() => this.state.orden = 'monto'">Por monto</button>
<button class="btn" t-att-class="state.orden === 'cantidad' ? 'btn-primary' : 'btn-outline-secondary'"
t-on-click="() => this.state.orden = 'cantidad'">Por cantidad</button>
</div>
<t t-call="beyond_reports.Descargas">
<t t-set="seccion" t-value="'top'"/>
<t t-set="etiqueta" t-value="'lo más vendido'"/>
</t>
</div>
<div class="beyond_lienzo"><canvas t-ref="top"/></div>
</div>
</div>
<!-- 4 · Lo que requiere acción -->
<div class="col-12 col-lg-5">
<div class="card card-body h-100">
<t t-if="!esGerente">
<div class="d-flex align-items-center mb-2">
<h5 class="mb-0 me-auto">Alertas de inventario</h5>
<t t-call="beyond_reports.Descargas">
<t t-set="seccion" t-value="'inventario'"/>
<t t-set="etiqueta" t-value="'las alertas de inventario'"/>
</t>
</div>
<t t-if="state.datos.inventario.length">
<table class="table table-sm mb-0">
<tbody>
<tr t-foreach="state.datos.inventario" t-as="alerta"
t-key="alerta.producto + alerta.sucursal">
<td t-esc="alerta.producto"/>
<td class="text-muted" t-esc="alerta.sucursal"/>
<td class="text-end fw-bold"
t-att-class="alerta.negativo ? 'text-danger' : ''"
t-esc="numero(alerta.cantidad)"/>
</tr>
</tbody>
</table>
<small class="text-muted mt-2">
En rojo, existencia negativa: se vendió algo que
nunca se registró como recibido.
</small>
</t>
<p t-else="" class="text-muted mb-0">Todo en orden.</p>
</t>
<t t-else="">
<h5>Requiere tu atención</h5>
<t t-if="state.datos.atencion.jornadas_revision or state.datos.atencion.solicitudes">
<ul class="list-unstyled mb-0">
<li t-if="state.datos.atencion.jornadas_revision"
class="beyond_clicable" t-on-click="verJornadasEnRevision">
<b t-esc="state.datos.atencion.jornadas_revision"/>
jornada(s) en revisión sin resolver
</li>
<li t-if="state.datos.atencion.solicitudes">
<b t-esc="state.datos.atencion.solicitudes"/>
solicitud(es) pendiente(s)
</li>
</ul>
</t>
<p t-else="" class="text-muted mb-0">Nada pendiente.</p>
</t>
</div>
</div>
</div>
</t>
</div>
</t>
</templates>