-- MSIN-4470 — Corrections de l'interface des dossards
-- Prérequis : MSIN-4424-bib-allow-inter-epr.sql et MSIN-4467-refonte-visuelle-dossards.sql.
-- Idempotent. Exécuter avant le déploiement PHP/CSS/JS.

UPDATE info
SET info_texte = 'Autoriser les mêmes numéros de dossard entre épreuves (doublons)',
    info_description = 'MSIN-4470'
WHERE info_clef = 'bib_v4_allow_inter_epr'
  AND info_langue = 'fr'
  AND info_prg = 'compte.php';

UPDATE info
SET info_texte = 'Allow the same bib numbers across races (duplicates)',
    info_description = 'MSIN-4470'
WHERE info_clef = 'bib_v4_allow_inter_epr'
  AND info_langue = 'en'
  AND info_prg = 'compte.php';

INSERT INTO info (
    info_clef,
    info_langue,
    info_texte,
    info_aide,
    info_prg,
    info_description,
    info_trie,
    info_actif,
    info_option1,
    info_option2,
    info_option3,
    info_creation
)
SELECT
    src.info_clef,
    src.info_langue,
    src.info_texte,
    '',
    'compte.php',
    'MSIN-4470',
    0,
    1,
    '',
    '',
    '',
    NOW()
FROM (
    SELECT
        'bib_v4_allow_inter_epr' AS info_clef,
        'fr' AS info_langue,
        'Autoriser les mêmes numéros de dossard entre épreuves (doublons)' AS info_texte
    UNION ALL
    SELECT
        'bib_v4_allow_inter_epr',
        'en',
        'Allow the same bib numbers across races (duplicates)'
) src
WHERE NOT EXISTS (
    SELECT 1
    FROM info current_info
    WHERE current_info.info_clef = src.info_clef
      AND current_info.info_langue = src.info_langue
      AND current_info.info_prg = 'compte.php'
);

INSERT INTO info (
    info_clef,
    info_langue,
    info_texte,
    info_aide,
    info_prg,
    info_description,
    info_trie,
    info_actif,
    info_option1,
    info_option2,
    info_option3,
    info_creation
)
SELECT
    src.info_clef,
    src.info_langue,
    src.info_texte,
    '',
    'compte.php',
    'MSIN-4470',
    0,
    1,
    '',
    '',
    '',
    NOW()
FROM (
    SELECT
        'bib_v4_dist_print_page' AS info_clef,
        'fr' AS info_langue,
        'Page %s / %s' AS info_texte
    UNION ALL
    SELECT
        'bib_v4_dist_print_page',
        'en',
        'Page %s / %s'
) src
WHERE NOT EXISTS (
    SELECT 1
    FROM info current_info
    WHERE current_info.info_clef = src.info_clef
      AND current_info.info_langue = src.info_langue
      AND current_info.info_prg = 'compte.php'
);
