From 7c88dd595dfcb27cb2adba54259e0b9bc5c06b30 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 29 Jun 2026 11:33:07 -0400 Subject: [PATCH] Implement compact PayPal refund summary feature in registration management This commit introduces a new function, `renderPayPalRefundSummaryHtml`, to provide a concise overview of PayPal refunds within the registration management interface. The summary displays essential information such as status, captured amount, total refunded, and remaining balance, enhancing the user experience by presenting key details in a more accessible format. Additionally, the existing code is updated to utilize this new summary function, improving the overall clarity and usability of transaction information. --- ajax_inscr_gestion.php | 8 +-- superadm/php/inc_fx_paypal.php | 119 +++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 4 deletions(-) diff --git a/ajax_inscr_gestion.php b/ajax_inscr_gestion.php index 19af69f..08d7820 100644 --- a/ajax_inscr_gestion.php +++ b/ajax_inscr_gestion.php @@ -180,15 +180,15 @@ switch ($strAction) { require_once $_SERVER['DOCUMENT_ROOT'] . '/php/inc_fx_panier.php'; $strResume = fxShowPanier($strNoPanier, 0, 'web', 1, $strLangue); - // Detail des remboursements PayPal (meme rendu que Super Admin). N'apparait que - // s'il existe une capture PayPal exploitable ; sinon rien (les cas gratuits/non-PayPal - // sont deja couverts par la facture ci-dessus). + // Sommaire des remboursements PayPal (vue compacte, pas la grande table Super Admin). + // N'apparait que s'il existe une capture PayPal exploitable ; sinon rien (les cas + // gratuits/non-PayPal sont deja couverts par la facture ci-dessus). $strRefunds = ''; require_once $_SERVER['DOCUMENT_ROOT'] . '/superadm/php/inc_fx_paypal.php'; $arrRefundCtx = fxRefundComputeContext($recCommandes); if (!empty($arrRefundCtx['ok'])) { $strRefunds = '
' - . renderPayPalCaptureHtml($arrRefundCtx['paypaldetails']) + . renderPayPalRefundSummaryHtml($arrRefundCtx['paypaldetails']) . '
'; } diff --git a/superadm/php/inc_fx_paypal.php b/superadm/php/inc_fx_paypal.php index bd484f2..a33e67a 100644 --- a/superadm/php/inc_fx_paypal.php +++ b/superadm/php/inc_fx_paypal.php @@ -289,6 +289,125 @@ $html .= '
'; + $html .= '
Remboursements
'; + $html .= '
'; + $cell = static function (string $label, string $value, string $color) use ($h): string { + return '
' + . '
' . $h($label) . '
' + . '
' . $h($value) . '
' + . '
'; + }; + $html .= $cell('Statut', $statNice ?: '—', '#2d6cdf'); + $html .= $cell('Capturé', $fmtMoney($capTotal), '#333'); + $html .= $cell('Remboursé', $fmtMoney($refTotal), '#c0392b'); + $html .= $cell('Solde', $fmtMoney($remaining), '#1e7e34'); + $html .= '
'; + + // --- Lignes de remboursements (compactes) --- + $statusMapRef = [ + 'S' => 'Effectué', 'COMPLETED' => 'Effectué', + 'P' => 'En attente', 'PENDING' => 'En attente', + 'D' => 'Refusé', 'DENIED' => 'Refusé', 'FAILED' => 'Échoué', + 'V' => 'Annulé', 'VOIDED' => 'Annulé', + 'R' => 'Reversé', 'REVERSED' => 'Reversé', + ]; + if (!empty($refundItems)) { + foreach ($refundItems as $rf) { + $rid = $get($rf, ['refund_id']) ?: $get($rf, ['id']); + $amt = $moneyVal(['value' => $get($rf, ['amount'], 0)]); + $cur = $get($rf, ['currency'], $currency); + $srfRaw = (string)$get($rf, ['status'], ''); + $srf = $statusMapRef[$srfRaw] ?? $srfRaw; + $time = $get($rf, ['create_time']) ?: $get($rf, ['time']); + $html .= '
' + . '' . $h($fmtDate($time, $tz)) . '' + . '' . $h(number_format($amt, 2, '.', '') . ($cur ? ' ' . $cur : '')) . '' + . '' . $h($srf) . '' + . '
'; + } + } + + $html .= '
'; + return $html; +} + function money2($v) { return number_format((float)$v, 2, '.', ''); }