127 lines
4.8 KiB
PHP
127 lines
4.8 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') {
|
|
// MSIN-4516 — Filet timeout (cPanel 60s) pendant génération Excel imprimeur.
|
|
if (function_exists('set_time_limit')) {
|
|
@set_time_limit(0);
|
|
}
|
|
|
|
// MSIN-4515 — Mémoriser Face/Endos/Info avant de figer le fichier.
|
|
$tabFieldSelections = fxBibProductionParseFieldsFromPost($_POST);
|
|
if (!empty($tabFieldSelections)) {
|
|
$tabSaveFields = fxBibProductionSaveFields($intEveId, $tabFieldSelections, $strLangue);
|
|
if (empty($tabSaveFields['success'])) {
|
|
http_response_code(400);
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
$strMsg = (string)($tabSaveFields['message'] ?? fxBibMsg('bib_v5_production_generation_error'));
|
|
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Erreur</title></head><body>';
|
|
echo '<p>' . htmlspecialchars($strMsg, ENT_QUOTES, 'UTF-8') . '</p>';
|
|
echo '<p><a href="javascript:window.close()">Fermer</a></p>';
|
|
echo '</body></html>';
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$tabResult = fxBibProductionCreateOfficialOrder($intEveId, $strLangue);
|
|
if (empty($tabResult['success']) || empty($tabResult['order'])) {
|
|
http_response_code(400);
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
$strMsg = (string)($tabResult['message'] ?? fxBibMsg('bib_v5_production_generation_error'));
|
|
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Erreur</title></head><body>';
|
|
echo '<p>' . htmlspecialchars($strMsg, ENT_QUOTES, 'UTF-8') . '</p>';
|
|
echo '<p><a href="javascript:window.close()">Fermer</a></p>';
|
|
echo '</body></html>';
|
|
exit;
|
|
}
|
|
$tabOrder = $tabResult['order'];
|
|
} elseif ($strAction === 'download') {
|
|
if (function_exists('set_time_limit')) {
|
|
@set_time_limit(0);
|
|
}
|
|
$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;
|
|
}
|
|
// MSIN-4516 — Si coincé en generating (timeout), reprendre puis servir le fichier.
|
|
if ((string)($tabOrder['bpo_status'] ?? '') === 'generating') {
|
|
$tabResume = fxBibProductionResumeGeneratingOrder($tabOrder, $strLangue);
|
|
if (empty($tabResume['success']) || empty($tabResume['order'])) {
|
|
http_response_code(400);
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
$strMsg = (string)($tabResume['message'] ?? fxBibMsg('bib_v5_production_generation_error'));
|
|
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Erreur</title></head><body>';
|
|
echo '<p>' . htmlspecialchars($strMsg, ENT_QUOTES, 'UTF-8') . '</p>';
|
|
echo '<p><a href="javascript:window.close()">Fermer</a></p>';
|
|
echo '</body></html>';
|
|
exit;
|
|
}
|
|
$tabOrder = $tabResume['order'];
|
|
}
|
|
} 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;
|