Files
ms1inscription-v5/bib_production_excel.php

84 lines
2.5 KiB
PHP

<?php
// MSIN-4469 — Génération et retéléchargement du fichier officiel de production.
session_start();
$_SERVER['PHP_SELF'] = '/compte.php';
$_SERVER['SCRIPT_NAME'] = '/compte.php';
require_once('php/inc_fonctions.php');
require_once('php/inc_fx_promoteur.php');
require_once('php/inc_fx_eve_acces.php');
$strLangue = $_SESSION['lang'] ?? 'fr';
$strReqLang = $_REQUEST['lang'] ?? '';
if (in_array($strReqLang, ['fr', 'en'], true)) {
$strLangue = $strReqLang;
}
$vPage = 'compte.php';
$vtexte_page = obtenirTextepage($vPage, $strLangue, 2);
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
exit;
}
$intEveId = (int)($_POST['eve_id'] ?? 0);
$strAction = (string)($_POST['action'] ?? '');
fxBibRequireDistPrintAccess();
if (!fxBibProductionUserCanManageEvent($intEveId)) {
http_response_code(403);
header('Content-Type: text/plain; charset=utf-8');
echo fxBibMsg('bib_v4_ajax_unauthorized');
exit;
}
if ($strAction === 'generate') {
$tabResult = fxBibProductionCreateOfficialOrder($intEveId, $strLangue);
if (empty($tabResult['success']) || empty($tabResult['order'])) {
http_response_code(400);
header('Content-Type: text/plain; charset=utf-8');
echo $tabResult['message'] ?? fxBibMsg('bib_v5_production_generation_error');
exit;
}
$tabOrder = $tabResult['order'];
} elseif ($strAction === 'download') {
$intOrderId = (int)($_POST['order_id'] ?? 0);
$tabOrder = fxBibProductionGetOrder($intOrderId, $intEveId);
if (!$tabOrder || (int)($tabOrder['bpo_active_key'] ?? 0) !== 1) {
http_response_code(404);
header('Content-Type: text/plain; charset=utf-8');
echo fxBibMsg('bib_v5_production_file_missing');
exit;
}
} elseif ($strAction === 'development_unlock') {
$tabResult = fxBibProductionDevelopmentUnlock($intEveId);
if (empty($tabResult['success'])) {
http_response_code(403);
header('Content-Type: text/plain; charset=utf-8');
echo $tabResult['message'] ?? fxBibMsg('bib_v4_ajax_unauthorized');
exit;
}
$strAccountPage = $strLangue === 'en' ? '/account' : '/compte';
header(
'Location: ' . $strAccountPage
. '/inc_tableau_gestion_epreuves?promoteur_eve_id='
. urlencode(base64_encode($intEveId))
);
exit;
} else {
http_response_code(400);
exit;
}
if (!fxBibProductionStreamOrder($tabOrder)) {
http_response_code(404);
header('Content-Type: text/plain; charset=utf-8');
echo fxBibMsg('bib_v5_production_file_missing');
exit;
}
exit;