prepare("
SELECT p.*, a.nom AS formule
FROM paiement p
JOIN abonnement a ON p.abonnement_id = a.id
WHERE p.id = ? AND p.praticien_id = ?
");
$stmt->execute([$paiement_id, $_SESSION['reference_id']]);
$paiement = $stmt->fetch();
if (!$paiement) {
die(htmlspecialchars($translations['facture_introuvable']));
}
$methodeMap = [
'cb' => $translations['methode_carte'] ?? 'CB',
'virement' => $translations['methode_virement'] ?? 'Virement',
'paypal' => $translations['methode_paypal'] ?? 'PayPal',
'stripe' => $translations['methode_stripe'] ?? 'Stripe',
];
$statutMap = [
'paye' => $translations['statut_paye'] ?? 'Payé',
'payé' => $translations['statut_paye'] ?? 'Payé',
'succeeded' => $translations['statut_paye'] ?? 'Payé',
'pending' => $translations['statut_en_attente'] ?? 'En attente',
'en_attente' => $translations['statut_en_attente'] ?? 'En attente',
'failed' => $translations['statut_echoue'] ?? 'Échoué',
'echoue' => $translations['statut_echoue'] ?? 'Échoué',
'échoué' => $translations['statut_echoue'] ?? 'Échoué',
'refunded' => $translations['statut_rembourse'] ?? 'Remboursé',
'rembourse' => $translations['statut_rembourse'] ?? 'Remboursé',
'remboursé' => $translations['statut_rembourse'] ?? 'Remboursé',
];
$methode = strtolower($paiement['methode'] ?? '');
$translationKey = 'methode_' . $methode;
$libMethode = $translations[$translationKey] ?? ucfirst($methode);
$libStatut = $statutMap[strtolower($paiement['statut'] ?? '')] ?? ($paiement['statut'] ?? '');
$numero = str_pad((string)$paiement['id'], 6, '0', STR_PAD_LEFT);
$datePaiement = !empty($paiement['date_paiement']) ? date('d/m/Y', strtotime($paiement['date_paiement'])) : '';
$montant = number_format((float)$paiement['montant'], 2, ',', ' ') . ' €';
$formuleKey = trim((string)($paiement['formule'] ?? ''));
$formuleTxt = $formuleKey !== '' ? ($translations[$formuleKey] ?? $formuleKey) : '';
$statutLower = strtolower((string)($paiement['statut'] ?? ''));
$badgeClass =
in_array($statutLower, ['paye','payé','succeeded'], true) ? 'badge--paid' :
(in_array($statutLower, ['pending','en_attente'], true) ? 'badge--pending' :
(in_array($statutLower, ['failed','echoue','échoué'], true) ? 'badge--failed' :
(in_array($statutLower, ['refunded','rembourse','remboursé'], true) ? 'badge--refunded' : 'badge--neutral')));
?>
= htmlspecialchars($translations['titre_facture']) ?> #= htmlspecialchars($numero) ?>
= htmlspecialchars($translations['titre_facture']) ?>
= htmlspecialchars($translations['facture_prefix'] ?? 'Reçu') ?>
#= htmlspecialchars($numero) ?> —
= htmlspecialchars($translations['facture_date'] ?? 'Date') ?> : = htmlspecialchars($datePaiement) ?>
= htmlspecialchars($translations['facture_date']) ?>
= htmlspecialchars($datePaiement) ?>
= htmlspecialchars($translations['facture_formule']) ?>
= htmlspecialchars($formuleTxt) ?>
= htmlspecialchars($translations['facture_methode']) ?>
= htmlspecialchars($libMethode) ?>
= htmlspecialchars($translations['facture_statut']) ?>
= htmlspecialchars($libStatut) ?>
= htmlspecialchars($translations['facture_montant']) ?>
= htmlspecialchars($montant) ?>