From bc407a7c2003249e939ef52f6d4e1d5934f85d18 Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 26 Jun 2026 14:45:09 -0400 Subject: [PATCH] Add refund functionality to mobile event management This commit introduces a new refund feature in the mobile event management system. It includes an AJAX-based refund form that allows users to request refunds directly from the event management interface. The refund button is conditionally displayed based on user permissions, and the form is dynamically loaded to enhance user experience. Additionally, the refund processing logic is integrated with existing PayPal functions to ensure seamless transaction handling. This update improves the overall usability and functionality of the event management system. --- ajax_inscr_mobile.php | 42 +++++++++++++++++ inc_footer_scripts.php | 74 ++++++++++++++++++++++++++++++ php/inc_fx_inscriptions_mobile.php | 20 +++++++- superadm/php/inc_fx_paypal.php | 12 ++++- 4 files changed, 144 insertions(+), 4 deletions(-) diff --git a/ajax_inscr_mobile.php b/ajax_inscr_mobile.php index 6ed1e9f..8650e3b 100644 --- a/ajax_inscr_mobile.php +++ b/ajax_inscr_mobile.php @@ -39,6 +39,48 @@ switch ($strAction) { $tabRetour = fxSetParStatutCourse($intParId, $strStatut, $strLangue); break; + case 'refund_form': + // Charge le formulaire de remboursement mutualise pour la fiche de gestion (panneau repliable). + $strNoPanier = trim((string)($_REQUEST['no_panier'] ?? '')); + if ($strNoPanier === '') { + $tabRetour = array('state' => 'error', 'message' => 'no_panier_manquant'); + break; + } + + // Meme source que le Super Admin : la commande vient de inscriptions_panier_acheteurs. + $sqlCmd = "SELECT *, IF(a.com_id <> 0, (SELECT c.com_login FROM inscriptions_comptes c WHERE a.com_id = c.com_id), '') AS usager" + . " FROM inscriptions_panier_acheteurs a, inscriptions_panier_statuts s" + . " WHERE s.sta_id = a.sta_id AND a.no_panier = '" . $objDatabase->fxEscape($strNoPanier) . "'"; + $recCommandes = $objDatabase->fxGetRow($sqlCmd); + if (!$recCommandes) { + $tabRetour = array('state' => 'error', 'message' => 'commande_introuvable'); + break; + } + + // L'eve_id fait foi cote serveur (jamais le client) pour le controle d'acces a l'evenement. + $intEveId = intval($recCommandes['eve_id']); + if ($intEveId <= 0 || !fxInscrMobileCanDo($intComId, $intEveId, 'inscriptions_gestion.refund')) { + $tabRetour = array('state' => 'error', 'message' => 'unauthorized'); + break; + } + + // Module mutualise (ne tire jamais inc_functions.php "U") : voir superadm/php/inc_fx_paypal.php + require_once $_SERVER['DOCUMENT_ROOT'] . '/superadm/php/inc_fx_paypal.php'; + + $strRefundToken = fxRefundEnsureToken(); + $arrRefundCtx = fxRefundComputeContext($recCommandes); + + // Auteur = promoteur connecte (alimente l'encart "Ajoute par" du formulaire). + $strAuteur = trim((string)($_SESSION['com_info']['com_prenom'] ?? '') . ' ' + . (string)($_SESSION['com_info']['com_nom'] ?? '')); + + // Markup seul (sans +