Files
Ferme/templates/case_weights_report.html.twig
tristan 5552d98935
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
feat : amélioration du tableau bovin
2026-05-07 08:39:39 +02:00

422 lines
15 KiB
Twig

<!doctype html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<style>
/* =========================
DOMPDF FRIENDLY SETTINGS
========================= */
@page { size: A4 landscape; }
html, body {
margin: 0;
padding: 6mm;
font-family: Helvetica, sans-serif;
font-size: 8px;
}
body {
/* DejaVu Sans est très bien géré par dompdf (accents, stabilité) */
font-family: Helvetica, sans-serif;
font-size: 10px;
color: #111;
}
.sheet { width: auto; }
h1 {
margin: 0 0 8px 0;
padding: 0;
line-height: 1;
text-transform: uppercase;
}
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
th, td {
border: 2px solid #2b2b2b;
padding: 2px 3px;
text-align: center;
vertical-align: middle;
line-height: 1.1;
white-space: nowrap; /* important pour dompdf */
overflow: hidden; /* évite les débordements */
text-overflow: clip;
}
/* =========================
HEADER (mise en page)
========================= */
.header-layout,
.header-layout td {
border: 0;
padding: 0;
}
.header-left td,
.header-right td {
border: 2px solid #2b2b2b;
font-weight: 700;
padding: 0;
}
/* Bloc CASE */
.header-left td {
height: 34px;
font-size: 10px;
}
.header-left .case-label {
width: 34%;
letter-spacing: 0.2px;
}
.header-left .case-number {
width: 66%;
font-size: 18px; /* volontairement compact pour dompdf */
line-height: 1;
}
/* Bloc PROVENANCE / RACE */
.header-right .label {
font-size: 11px;
height: 18px;
letter-spacing: 0;
}
.header-right .mini {
height: 18px;
font-size: 10px;
}
.header-right .mini-empty {
height: 18px;
font-size: 9px;
}
.header-right .race {
height: 24px;
font-size: 11px;
letter-spacing: 0;
}
.header-right .breed {
font-size: 9px;
font-weight: 700;
padding: 0 2px;
}
/* =========================
TABLEAU PRINCIPAL
========================= */
.main {
margin-top: 2px;
}
.main th {
background: #ffffff;
font-weight: 700;
padding: 2px 1px;
}
.main .head-big {
font-size: 14px;
font-weight: 700;
white-space: normal; /* permet les <br> */
line-height: 1.15;
}
.main .month {
font-size: 12px;
}
.main .days {
font-size: 12px;
}
.main .sub-title {
font-size: 13px;
font-weight: 700;
letter-spacing: 0;
padding: 4px;
}
.main .base {
font-size: 12px;
}
/* Hauteurs de lignes d'en-tête (stables en dompdf) */
.main thead tr:nth-child(1) th { height: 24px; }
.main thead tr:nth-child(2) th { height: 18px; }
.main thead tr:nth-child(3) th { height: 18px; }
.main thead tr:nth-child(4) th { height: 18px; }
/* Lignes data */
.data-row td {
height: 18px;
font-size: 14px;
}
.row-work {
text-align: center;
font-size: 18px !important;
font-weight: 700;
line-height: 1;
}
.row-weight,
.row-birth,
.row-month {
font-size: 9px;
line-height: 1;
}
/* =========================
FOOTER VACCINS / NOTES
========================= */
.footer {
font-size: 12px;
}
/* Header droit sans bordures par défaut */
.header-right-free,
.header-right-free td {
padding: 0;
width: 6.25%;
}
</style>
</head>
<body>
{% set firstArrivalDate = rows is not empty ? rows[0].arrivalDate : null %}
{% set monthCount = ((monthHeaders|default([]))|length) > 0 ? ((monthHeaders|default([]))|length) : 12 %}
<div class="sheet">
<!-- =========================
EN-TÊTE (CASE / PROVENANCE / RACE)
========================= -->
<h1 style="color: red; text-align: center; width: 100%; font-size: 36px">
Arrivage du {{ firstArrivalDate ?? '-' }}
</h1>
<table style="width:100%; border-collapse:collapse; table-layout:fixed; margin-bottom: 4px">
<colgroup>
{# 28 colonnes ≈ 3.571% chacune #}
{% for _ in 0..27 %}<col style="width:3.571%">{% endfor %}
</colgroup>
<tr>
<td style="border:0; text-align:left; font-weight:700; font-size: 18px;" colspan="4">PROVENANCE</td>
{# Paire 1 : chiffre + case vide #}
<td style="border:1px solid #2b2b2b; text-align:center; font-weight:700; font-size: 11px; padding:0;">1</td>
<td style="border:1px solid #2b2b2b;"></td>
<td style="border:0;"></td>
{# Paire 2 #}
<td style="border:1px solid #2b2b2b; text-align:center; font-weight:700; font-size: 11px; padding:0;">2</td>
<td style="border:1px solid #2b2b2b;"></td>
<td style="border:0;"></td>
{# Paire 3 #}
<td style="border:1px solid #2b2b2b; text-align:center; font-weight:700; font-size: 11px; padding:0;">3</td>
<td style="border:1px solid #2b2b2b;"></td>
<td style="border:0;"></td>
{# Paire 4 #}
<td style="border:1px solid #2b2b2b; text-align:center; font-weight:700; font-size: 11px; padding:0;">4</td>
<td style="border:1px solid #2b2b2b;"></td>
{# Espacement entre PROVENANCE et RACE (1 col, RACE commence plus tôt) #}
<td style="border:0;"></td>
{# Bloc RACE #}
<td style="border:0; text-align:left; font-weight:700; font-size: 18px;" colspan="2">RACE</td>
<td style="border:1px solid #2b2b2b; text-align:center; font-weight:700;" colspan="2">LIMOUSIN</td>
<td style="border:1px solid #2b2b2b;"></td>
<td style="border:0;"></td>
<td style="border:1px solid #2b2b2b; text-align:center; font-weight:700;" colspan="2">CHAROLAIS</td>
<td style="border:1px solid #2b2b2b;"></td>
<td style="border:0;"></td>
<td style="border:1px solid #2b2b2b; text-align:center; font-weight:700;">AUTRE</td>
<td style="border:1px solid #2b2b2b;"></td>
</tr>
</table>
<table style="width:auto; border-collapse:collapse; margin-bottom: 8px; margin-top: 8px">
<tr>
<td style="border:0; text-align:left; font-weight:700; font-size: 18px; padding-right: 8px;">BATIMENT N°</td>
<td style="border:1px solid #2b2b2b; width: 22px; height: 22px;"></td>
<td style="border:0; width: 22px;"></td>
<td style="border:1px solid #2b2b2b; width: 22px; height: 22px;"></td>
<td style="border:0; width: 22px;"></td>
<td style="border:1px solid #2b2b2b; width: 22px; height: 22px;"></td>
<td style="border:0; width: 32px;"></td>
<td style="border:0; text-align:left; font-weight:700; font-size: 18px; padding-right: 8px;">CASE N°</td>
<td style="border:1px solid #2b2b2b; width: 22px; height: 22px;"></td>
<td style="border:0; width: 22px;"></td>
<td style="border:1px solid #2b2b2b; width: 22px; height: 22px;"></td>
<td style="border:0; width: 22px;"></td>
<td style="border:1px solid #2b2b2b; width: 22px; height: 22px;"></td>
</tr>
</table>
<!-- =========================
TABLEAU PRINCIPAL
========================= -->
<table class="main">
<thead>
<tr>
{% for month in monthHeaders|default([])|reverse %}
<th class="month" style="width:6.58%">{{ month.name }}</th>
{% endfor %}
<th rowspan="4" class="head-big" style="width:7%">Date de<br>naissance</th>
<th rowspan="4" class="head-big head-big-weight" style="width:4%">Poids<br>(kg)</th>
<th rowspan="4" class="head-big" style="width:5%">N° de<br>travail</th>
<th rowspan="4" class="head-big" style="width:5%">N° de<br>travail</th>
</tr>
<tr>
{% for month in monthHeaders|default([])|reverse %}
<th class="days">{{ month.days }}</th>
{% endfor %}
</tr>
<tr>
<th colspan="{{ monthHeaders|length -2 }}" class="sub-title">POIDS PAR MOIS</th>
<th class="days">Foin</th>
<th class="days">Foin</th>
</tr>
<tr>
{% for month in monthHeaders|default([])|reverse %}
<th class="base">
{% if month.baseValue is defined %}
{{ month.baseValue|round(0, 'common') }} kg
{% elseif month.base is defined %}
{{ month.base }}
{% endif %}
</th>
{% endfor %}
</tr>
</thead>
<tbody>
{# 13 lignes comme dans ton code (0..12) #}
{% for i in 0..12 %}
{% set row = rows[i] ?? null %}
{% set baseWeight = row ? (row.receivedWeight ?? null) : null %}
<tr class="data-row">
{% for idx in 0..(monthCount > 0 ? monthCount - 1 : 0) %}
{% set reversedIdx = (monthCount - 1) - idx %}
{% set projectedWeight = row and row.projectedWeights is defined ? (row.projectedWeights[reversedIdx] ?? null) : null %}
<td class="row-month"{% if reversedIdx < 4 %} style="background:#e0e0e0;"{% endif %}>
{{ projectedWeight is not null ? projectedWeight|round(0, 'common') : '' }}
</td>
{% endfor %}
<td class="row-birth">
{% if row and row.birthDate %}
{% set birthParts = row.birthDate|split('/') %}
{{ birthParts|length == 3 ? birthParts[1] ~ '/' ~ birthParts[2] : row.birthDate }}
{% endif %}
</td>
<td class="row-weight">{{ baseWeight ?? '' }}</td>
<td class="row-work">{{ row ? (row.workNumber ?? '') : '' }}</td>
<td class="row-work"></td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- =========================
FOOTER (traitements / vaccins)
========================= -->
<table style="width:100%; border:0; border-collapse:collapse; table-layout:fixed; margin-top: 12px">
<tr>
<td style="border:0; padding:0; width:49%; vertical-align:top;">
<table class="footer" style="border-collapse:collapse; width:100%; table-layout:fixed;">
<tr>
<td style="font-weight: 700; height: 20px" colspan="10">Traitements</td>
</tr>
<tr>
<td style="height: 20px" colspan="2">Date</td>
<td colspan="2"></td>
<td>Dose</td>
<td colspan="5">Observation</td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td colspan="2">Grippe</td>
<td></td>
<td colspan="5"></td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td colspan="2">Antéro</td>
<td></td>
<td colspan="5"></td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td colspan="2">Antibiotiques</td>
<td></td>
<td colspan="5"></td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td colspan="2">Déparasitage</td>
<td></td>
<td colspan="5"></td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td colspan="2"></td>
<td></td>
<td colspan="5"></td>
</tr>
</table>
</td>
<td style="border:0; padding:0; width:2%;"></td>
<td style="border:0; padding:0; width:49%; vertical-align:top;">
<table class="footer" style="border-collapse:collapse; width:100%; table-layout:fixed;">
<tr>
<td style="font-weight: 700; height: 20px" colspan="10">Rappel</td>
</tr>
<tr>
<td style="height: 20px" colspan="2">Date</td>
<td>Dose</td>
<td colspan="7">Observation</td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td></td>
<td colspan="7"></td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td></td>
<td colspan="7"></td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td></td>
<td colspan="7"></td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td></td>
<td colspan="7"></td>
</tr>
<tr>
<td style="height: 20px" colspan="2"></td>
<td></td>
<td colspan="7"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>