MSIN-4471 — Update image handling and SQL documentation for bib distribution. Enhance image insertion function to support optional maximum width and centering. Modify SQL to include specific image references and improve clarity in participant instructions. Increment version code.

This commit is contained in:
2026-07-22 08:00:47 -04:00
parent b97fa8a337
commit a8c588f41f
3 changed files with 87 additions and 46 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -9607,15 +9607,16 @@ function fxBibDistPrintResolveDocImagePath($strSrc) {
return $strPath;
}
/** MSIN-4471 — Insère une image doc (largeur max = page utile). */
function fxBibDistPrintWriteImage($pdf, $strPath) {
/** MSIN-4471 — Insère une image doc (largeur max = page utile, ou $fltMaxWMm si fourni). */
function fxBibDistPrintWriteImage($pdf, $strPath, $fltMaxWMm = 0, $blnCenter = false) {
if ($strPath === '' || !is_file($strPath)) {
return;
}
$fltLeft = method_exists($pdf, 'GetLeftMargin') ? $pdf->GetLeftMargin() : 10;
$fltRight = method_exists($pdf, 'GetRightMargin') ? $pdf->GetRightMargin() : 10;
$fltBottom = method_exists($pdf, 'GetBreakMargin') ? $pdf->GetBreakMargin() : 14;
$fltMaxW = $pdf->GetPageWidth() - $fltLeft - $fltRight;
$fltPageMax = $pdf->GetPageWidth() - $fltLeft - $fltRight;
$fltMaxW = ($fltMaxWMm > 0) ? min($fltMaxWMm, $fltPageMax) : $fltPageMax;
$tabSize = @getimagesize($strPath);
$fltW = $fltMaxW;
if (is_array($tabSize) && !empty($tabSize[0]) && !empty($tabSize[1])) {
@ -9624,15 +9625,16 @@ function fxBibDistPrintWriteImage($pdf, $strPath) {
$fltW = $fltNatW;
}
}
if ($pdf->GetY() + 10 > $pdf->GetPageHeight() - $fltBottom) {
$pdf->AddPage();
}
$pdf->Image($strPath, $pdf->GetX(), $pdf->GetY(), $fltW);
$fltH = 0;
if (is_array($tabSize) && !empty($tabSize[0]) && !empty($tabSize[1])) {
$fltH = $fltW * ($tabSize[1] / $tabSize[0]);
}
$pdf->Ln(max(8, $fltH + 2));
if ($pdf->GetY() + max(10, $fltH) > $pdf->GetPageHeight() - $fltBottom) {
$pdf->AddPage();
}
$fltX = $blnCenter ? (($pdf->GetPageWidth() - $fltW) / 2) : $pdf->GetX();
$pdf->Image($strPath, $fltX, $pdf->GetY(), $fltW);
$pdf->Ln(max(8, $fltH + 3));
}
/**
@ -9821,7 +9823,19 @@ function fxBibDistPrintWriteIntroFlyer($pdf, $strHtml) {
continue;
}
// Autres blocs (ul/ol/img…) : rendu classique.
// Image doc (ex. position du dossard) — centrée, largeur limitée.
if ($strTag === 'img') {
$strSrc = $el->getAttribute('src');
$strPath = fxBibDistPrintResolveDocImagePath($strSrc);
if ($strPath !== '') {
$pdf->Ln(1);
fxBibDistPrintWriteImage($pdf, $strPath, 85, true);
}
$i++;
continue;
}
// Autres blocs (ul/ol…) : rendu classique.
if ($strTag === 'p') {
// p après les cartes (rare) : texte simple.
$pdf->SetFont('Arial', '', 10);
@ -9983,8 +9997,9 @@ function fxBibDistPrintWriteHtml($pdf, $strHtml) {
/**
* MSIN-4471 — Dessine le QR résultats événement (kc.php?t=eve) centré.
* Affiche ms1.ca sous le QR (pas l'URL technique).
*/
function fxBibDistPrintDrawEventQr($pdf, $int_eve_id) {
function fxBibDistPrintDrawEventQr($pdf, $int_eve_id, $strCaption = '') {
$int_eve_id = (int)$int_eve_id;
if ($int_eve_id <= 0 || !function_exists('fxKcEveResultatsQrPngBinary')) {
return;
@ -10002,19 +10017,34 @@ function fxBibDistPrintDrawEventQr($pdf, $int_eve_id) {
if (@file_put_contents($strTmpPng, $binPng) === false) {
return;
}
$fltSize = 70;
$fltX = ($pdf->GetPageWidth() - $fltSize) / 2;
$pdf->Ln(4);
$fltBottom = method_exists($pdf, 'GetBreakMargin') ? $pdf->GetBreakMargin() : 14;
if ($pdf->GetY() + $fltSize > $pdf->GetPageHeight() - $fltBottom) {
$fltBottom = method_exists($pdf, 'GetBreakMargin') ? $pdf->GetBreakMargin() : 18;
$fltSize = 95;
$strCaption = trim((string)$strCaption);
if ($strCaption !== '') {
$pdf->Ln(6);
$pdf->SetFont('Arial', 'B', 13);
$pdf->SetTextColor(25, 40, 70);
$pdf->MultiCell(0, 7, fxBibDistPrintPdfText($strCaption), 0, 'C');
$pdf->SetTextColor(0, 0, 0);
$pdf->Ln(4);
} else {
$pdf->Ln(10);
}
if ($pdf->GetY() + $fltSize + 16 > $pdf->GetPageHeight() - $fltBottom) {
$pdf->AddPage();
}
$fltX = ($pdf->GetPageWidth() - $fltSize) / 2;
$pdf->Image($strTmpPng, $fltX, $pdf->GetY(), $fltSize, $fltSize);
$pdf->Ln($fltSize + 4);
if (function_exists('fxKcEveResultatsQrUrl')) {
$pdf->SetFont('Arial', '', 8);
$pdf->MultiCell(0, 4, fxBibDistPrintPdfText(fxKcEveResultatsQrUrl($int_eve_id)), 0, 'C');
}
$pdf->Ln($fltSize + 6);
$pdf->SetFont('Arial', 'B', 16);
$pdf->SetTextColor(47, 95, 208);
$pdf->MultiCell(0, 8, fxBibDistPrintPdfText('ms1.ca'), 0, 'C');
$pdf->SetTextColor(0, 0, 0);
@unlink($strTmpPng);
}
@ -10049,10 +10079,15 @@ function fxBibOutputDistPrintIntroPages($pdf, $int_eve_id, $strLangue = 'fr') {
$pdf->documentTitle = ($strTitre !== '') ? $strTitre : $strClef;
$pdf->documentSubtitle = $strSous;
$pdf->AddPage();
fxBibDistPrintWriteIntroFlyer($pdf, $strHtml);
// Page QR : en-tête + invite + gros QR + ms1.ca (pas de cartes flyer).
if ($strClef === 'bib_dist_print_qr') {
fxBibDistPrintDrawEventQr($pdf, $int_eve_id);
$strCaption = trim(html_entity_decode(strip_tags($strHtml), ENT_QUOTES, 'UTF-8'));
fxBibDistPrintDrawEventQr($pdf, $int_eve_id, $strCaption);
continue;
}
fxBibDistPrintWriteIntroFlyer($pdf, $strHtml);
}
$pdf->blnIntroMode = false;
@ -10060,7 +10095,7 @@ function fxBibOutputDistPrintIntroPages($pdf, $int_eve_id, $strLangue = 'fr') {
$pdf->documentSubtitle = '';
$pdf->eprTitle = '';
$pdf->SetMargins(10, 12, 10);
$pdf->SetAutoPageBreak(true, 16);
$pdf->SetAutoPageBreak(true, 18);
}
/** MSIN-4433 — Génère et envoie le PDF (format lettre). */
@ -10171,30 +10206,36 @@ function fxBibOutputDistPrintPdf($int_eve_id, $strLangue = 'fr', $strPrintedBy =
function Footer() {
$strLogo = function_exists('fxBibDistPrintMs1LogoPath') ? fxBibDistPrintMs1LogoPath() : '';
$fltLogoW = 20;
$fltLogoReserve = ($strLogo !== '') ? ($fltLogoW + 6) : 0;
$fltPageW = $this->GetPageWidth();
$fltPageH = $this->GetPageHeight();
$fltLogoW = 22;
$fltLogoH = $fltLogoW * (101 / 355); // ~6.3 mm (ratio logo MS1)
$fltGap = 4;
$fltPageNumW = 32;
$fltLogoX = $fltPageW - $this->rMargin - $fltLogoW;
$fltLogoY = $fltPageH - 9.5;
$fltPageNumX = ($strLogo !== '')
? ($fltLogoX - $fltGap - $fltPageNumW)
: ($fltPageW - $this->rMargin - $fltPageNumW);
$fltTextW = max(30, $fltPageNumX - $this->lMargin - 2);
// Logo : fond noir pour garder le contraste (logo blanc sur noir).
if ($strLogo !== '') {
// Petit logo bas droite (toutes les pages).
$this->Image(
$strLogo,
$fltPageW - $this->rMargin - $fltLogoW,
$this->GetPageHeight() - 11,
$fltLogoW
);
$this->SetFillColor(0, 0, 0);
$this->Rect($fltLogoX - 0.8, $fltLogoY - 0.8, $fltLogoW + 1.6, $fltLogoH + 1.6, 'F');
$this->Image($strLogo, $fltLogoX, $fltLogoY, $fltLogoW);
}
$this->SetY(-12);
$this->SetY(-11);
$this->SetFont('Arial', 'I', 7);
$this->SetTextColor(90, 90, 90);
$fltTextW = $fltPageW - $this->lMargin - $this->rMargin - $fltLogoReserve - 22;
if ($fltTextW < 40) {
$fltTextW = 40;
}
$this->SetX($this->lMargin);
$this->Cell($fltTextW, 4, fxBibDistPrintPdfText($this->footerText), 0, 0, 'L');
$strPage = sprintf($this->pageText, $this->PageNo(), '{nb}');
$this->Cell(22, 4, fxBibDistPrintPdfText($strPage), 0, 0, 'R');
$this->SetXY($fltPageNumX, -11);
$this->Cell($fltPageNumW, 4, fxBibDistPrintPdfText($strPage), 0, 0, 'R');
$this->SetTextColor(0, 0, 0);
}
}
@ -10206,7 +10247,7 @@ function fxBibOutputDistPrintPdf($int_eve_id, $strLangue = 'fr', $strPrintedBy =
$pdf->eventTitle = fxBibDistPrintTruncate($strEventTitle, 80);
$pdf->documentTitle = fxBibTexte('bib_v4_dist_print_title', 0);
$pdf->SetMargins(10, 12, 10);
$pdf->SetAutoPageBreak(true, 16);
$pdf->SetAutoPageBreak(true, 18);
$pdf->AliasNbPages();
// MSIN-4471 — Pages d'explication (doc) avant les tableaux d'épreuves.

View File

@ -1,7 +1,7 @@
-- MSIN-4471 — Pages intro PDF distribution des dossards
-- Prérequis : tables doc_mod / doc_page / doc_anchor (MSIN-doc-module.sql)
-- Idempotent : DELETE puis INSERT du module bib_dist_print
-- Images optionnelles : déposer sous images/doc/ (ex. /images/doc/exemple.png)
-- Images : images/doc/dossardposition.png (page table participants)
SET NAMES utf8mb4;
@ -22,11 +22,11 @@ INSERT INTO `doc_page` (`doc_mod_clef`, `doc_page_clef`, `doc_langue`, `doc_titr
('bib_dist_print', 'bib_dist_print_reco', 'fr', 'Conseils à la distribution', 'Pour une remise de dossards sans erreur',
'<article class="ms1-doc-article"><p><em>À lire avant de commencer.</em> Quelques secondes à chaque remise évitent les échanges, les erreurs de chronométrage et les résultats incorrects.</p><h3>1. Familles et groupes — plusieurs dossards</h3><p>Lorsque vous remettez plusieurs dossards à une même famille ou à un groupe, assurez-vous que le prénom figure sur chaque dossard. S''il n''y est pas déjà, <strong>écrivez-le au verso</strong>. Ainsi, chacun part avec le bon numéro : un échange entre proches fausse le chronométrage et les résultats.</p><h3>2. Ne pas céder son dossard</h3><p>Un dossard inscrit à un nom <strong>ne doit pas</strong> être remis à une autre personne. Si un échange a déjà eu lieu, <strong>avisez immédiatement les organisateurs</strong> afin qu''ils corrigent la base de données avant la course.</p><h3>3. Dossard bien visible à l''avant</h3><p>Rappelez au participant d''épingler son dossard <strong>bien visible à l''avant du torse</strong>. C''est essentiel pour un chronométrage fiable et un bon temps officiel.</p><h3>4. Vérifier ses infos avant la course (code QR)</h3><p>Invitez les participants à scanner le code QR de l''événement pour consulter les résultats en ligne <strong>avant le départ</strong>. Ils pourront confirmer que leur nom, leur âge et leur numéro de dossard sont correctement associés à leur inscription.</p></article>',
'compte.php', 10, 1, NOW()),
('bib_dist_print', 'bib_dist_print_table', 'fr', 'Affiche table — participants', 'À placer sur la table de distribution',
'<article class="ms1-doc-article"><p><strong>Texte provisoire</strong> — Page destinée à être lue par les participants à la table.</p><h3>À faire avant de vous présenter</h3><ul><li>Ayez votre confirmation d''inscription ou une pièce d''identité.</li><li>Connaissez le nom de votre épreuve (ex. 10 km, demi-marathon).</li><li>Si vous êtes en équipe, présentez-vous ensemble si possible.</li></ul><h3>À la table</h3><ol><li>Donnez votre nom de famille clairement.</li><li>Vérifiez le numéro de dossard avant de quitter la table.</li><li>Épinglez le dossard bien visible à l''avant.</li></ol><p>Vous pouvez ajouter une image d''exemple ici, par ex. :</p><p><img src="/images/doc/exemple-table.png" alt="Exemple d''affichage"></p></article>',
('bib_dist_print', 'bib_dist_print_table', 'fr', 'Votre dossard', 'À placer sur la table — pour les participants',
'<article class="ms1-doc-article"><p><em>Vous venez de recevoir votre dossard.</em> Prenez un moment pour vérifier ces points avant le départ.</p><h3>1. Vérifiez vos informations (code QR)</h3><p>Scannez le code QR de l''événement pour consulter les résultats en ligne. Vérifiez que <strong>votre nom est bien orthographié</strong>, que vous êtes dans la <strong>bonne catégorie</strong> et la <strong>bonne distance</strong>. En cas d''erreur, revenez voir l''organisation pour corriger <strong>avant la course</strong>.</p><h3>2. Portez votre dossard correctement</h3><p>Épinglez votre dossard <strong>bien visible à l''avant du torse</strong>, aux quatre coins. Un dossard mal placé ou caché peut compromettre votre chronométrage.</p><img src="/images/doc/dossardposition.png" alt="Position correcte du dossard à l''avant"><h3>3. Courez avec le bon dossard</h3><p>Assurez-vous de courir avec le dossard qui vous a été remis — celui inscrit à votre nom. Un mauvais numéro fausse les résultats.</p><h3>4. Ne cédez pas votre dossard</h3><p>Ne remettez pas votre dossard à une autre personne. Si un échange a déjà eu lieu, <strong>avisez immédiatement les organisateurs</strong> pour qu''ils corrigent la base de données.</p></article>',
'compte.php', 20, 1, NOW()),
('bib_dist_print', 'bib_dist_print_qr', 'fr', 'Code QR de l''événement', 'À afficher / découper pour l''événement',
'<article class="ms1-doc-article"><p><strong>Texte provisoire</strong> — Le code QR ci-dessous pointe vers les résultats (ou le lien configuré) de cet événement.</p><p>Vous pouvez le photocopier, le découper et le coller partout sur le site de l''événement.</p><h3>Comment l''utiliser</h3><ul><li>Affichez-le près de la ligne d''arrivée et des tableaux d''affichage.</li><li>Les participants scannent pour ouvrir le lien résultats de l''événement.</li></ul><p>Le QR est généré automatiquement à l''impression — inutile de l''insérer en image dans ce texte.</p></article>',
'<p>Utilisez ce code pour consulter vos résultats en ligne pendant la course.</p>',
'compte.php', 30, 1, NOW());
-- ---------------------------------------------------------------------------
@ -36,9 +36,9 @@ INSERT INTO `doc_page` (`doc_mod_clef`, `doc_page_clef`, `doc_langue`, `doc_titr
('bib_dist_print', 'bib_dist_print_reco', 'en', 'Distribution tips', 'For a smooth, error-free bib handout',
'<article class="ms1-doc-article"><p><em>Read before you start.</em> A few seconds at each handout prevent swaps, timing errors, and incorrect results.</p><h3>1. Families and groups — multiple bibs</h3><p>When handing out several bibs to the same family or group, make sure each bib shows a first name. If it is not already there, <strong>write it on the back</strong>. This way everyone leaves with the right number: a swap between relatives will skew timing and results.</p><h3>2. Do not give away your bib</h3><p>A bib registered under one name <strong>must not</strong> be given to someone else. If a swap has already happened, <strong>notify the organizers immediately</strong> so they can correct the database before the race.</p><h3>3. Bib clearly visible on the front</h3><p>Remind the participant to pin the bib <strong>clearly visible on the front of the torso</strong>. This is essential for reliable timing and an accurate official time.</p><h3>4. Check details before the race (QR code)</h3><p>Invite participants to scan the event QR code and view results online <strong>before the start</strong>. They can confirm that their name, age, and bib number are correctly linked to their registration.</p></article>',
'compte.php', 10, 1, NOW()),
('bib_dist_print', 'bib_dist_print_table', 'en', 'Table sign — participants', 'Place on the distribution table',
'<article class="ms1-doc-article"><p><strong>Placeholder</strong> — Page meant to be read by participants at the table.</p><h3>Before you come up</h3><ul><li>Have your registration confirmation or ID ready.</li><li>Know your race name (e.g. 10K, half marathon).</li><li>If you are a team, come together if possible.</li></ul><h3>At the table</h3><ol><li>Say your last name clearly.</li><li>Check the bib number before leaving the table.</li><li>Pin the bib clearly on the front.</li></ol><p>You can add a sample image here, e.g.:</p><p><img src="/images/doc/exemple-table.png" alt="Sample display"></p></article>',
('bib_dist_print', 'bib_dist_print_table', 'en', 'Your bib', 'Place on the table — for participants',
'<article class="ms1-doc-article"><p><em>You just received your bib.</em> Take a moment to check these points before the start.</p><h3>1. Check your details (QR code)</h3><p>Scan the event QR code to view results online. Confirm that <strong>your name is spelled correctly</strong>, and that you are in the <strong>right category</strong> and <strong>right distance</strong>. If anything is wrong, see the organizers to correct it <strong>before the race</strong>.</p><h3>2. Wear your bib correctly</h3><p>Pin your bib <strong>clearly visible on the front of your torso</strong>, at all four corners. A hidden or poorly placed bib can compromise your timing.</p><img src="/images/doc/dossardposition.png" alt="Correct bib placement on the front"><h3>3. Run with the correct bib</h3><p>Make sure you run with the bib that was handed to you — the one registered under your name. The wrong number will skew results.</p><h3>4. Do not give away your bib</h3><p>Do not give your bib to someone else. If a swap has already happened, <strong>notify the organizers immediately</strong> so they can correct the database.</p></article>',
'compte.php', 20, 1, NOW()),
('bib_dist_print', 'bib_dist_print_qr', 'en', 'Event QR code', 'Display / cut out for the event',
'<article class="ms1-doc-article"><p><strong>Placeholder</strong> — The QR code below points to this event''s results (or configured link).</p><p>You can photocopy, cut and post it around the event site.</p><h3>How to use it</h3><ul><li>Display it near the finish and result boards.</li><li>Participants scan to open the event results link.</li></ul><p>The QR is generated automatically when printing — no need to embed it as an image in this text.</p></article>',
'<p>Use this code to view your results online during the race.</p>',
'compte.php', 30, 1, NOW());