136 lines
5.5 KiB
PHP
136 lines
5.5 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/init_praticien.php';
|
|
|
|
|
|
$praticien_id = $_SESSION['reference_id'];
|
|
|
|
$stmt = $pdo->prepare("SELECT * FROM paiement WHERE praticien_id = ? ORDER BY date_paiement DESC");
|
|
$stmt->execute([$praticien_id]);
|
|
$paiements = $stmt->fetchAll();
|
|
|
|
// Mappings d'affichage
|
|
$methodeMap = [
|
|
'cb' => $translations['methode_cb'] ?? '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é',
|
|
];
|
|
|
|
// helper badge
|
|
function badgeClassForStatus(string $raw): string {
|
|
$s = mb_strtolower($raw, 'UTF-8');
|
|
if (in_array($s, ['paye','payé','succeeded'], true)) return 'bg-success';
|
|
if (in_array($s, ['pending','en_attente'], true)) return 'bg-warning text-dark';
|
|
if (in_array($s, ['failed','echoue','échoué'], true)) return 'bg-danger';
|
|
if (in_array($s, ['refunded','rembourse','remboursé'], true)) return 'bg-secondary';
|
|
return 'bg-secondary';
|
|
}
|
|
require_once '../includes/header.php';
|
|
?>
|
|
<div class="main1">
|
|
<div class="container py-5">
|
|
<div class="shadow p-4 rounded bg-light">
|
|
<h3 class="mb-4 text-center"><?= htmlspecialchars($translations['h3_mes_factures']) ?></h3>
|
|
|
|
<?php if (empty($paiements)): ?>
|
|
<div class="alert alert-info">
|
|
<?= htmlspecialchars($translations['aucune_facture']) ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered table-hover align-middle mobile-cards" id="table_rdv">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th scope="col"><?= htmlspecialchars($translations['th_numero']) ?></th>
|
|
<th scope="col"><?= htmlspecialchars($translations['th_date']) ?></th>
|
|
<th scope="col"><?= htmlspecialchars($translations['th_montant']) ?></th>
|
|
<th scope="col"><?= htmlspecialchars($translations['th_methode']) ?></th>
|
|
<th scope="col" class="text-center"><?= htmlspecialchars($translations['th_statut']) ?></th>
|
|
<th scope="col" class="text-center"><?= htmlspecialchars($translations['th_actions']) ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($paiements as $p):
|
|
$methodeRaw = mb_strtolower(trim((string)($p['methode'] ?? '')), 'UTF-8');
|
|
$methodeNorm = match ($methodeRaw) {
|
|
'cb' => 'carte',
|
|
default => $methodeRaw,
|
|
};
|
|
$libMethode = $translations['methode_' . $methodeNorm]?? ucfirst($methodeNorm);
|
|
$libStatut = $statutMap[mb_strtolower($p['statut'] ?? '', 'UTF-8')] ?? ($p['statut'] ?? '');
|
|
$badgeClass = badgeClassForStatus($p['statut'] ?? '');
|
|
?>
|
|
<tr>
|
|
<td class="text-start"><?= htmlspecialchars($translations['facture_prefix']) ?><?= str_pad((string)$p['id'], 3, '0', STR_PAD_LEFT) ?></td>
|
|
<td class="text-start"><?= date('d/m/Y', strtotime($p['date_paiement'])) ?></td>
|
|
<td class="text-start"><?= number_format((float)$p['montant'], 2, ',', ' ') ?> €</td>
|
|
<td class="text-start"><?= htmlspecialchars($libMethode) ?></td>
|
|
<td>
|
|
<span class="badge <?= $badgeClass ?>">
|
|
<?= htmlspecialchars($libStatut) ?>
|
|
</span>
|
|
</td>
|
|
<td class="text-center">
|
|
<a href="/public/praticien/factures_details.php?id=<?= (int)$p['id'] ?>" target="_blank" class="btn btn-outline-secondary btn-sm btn-table">
|
|
<?= htmlspecialchars($translations['btn_voir']) ?>
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script defer>
|
|
(function(){
|
|
function initMobileCards(tbl){
|
|
if (!tbl) return;
|
|
const heads = Array.from(tbl.querySelectorAll('thead th')).map(th => th.textContent.trim());
|
|
tbl.querySelectorAll('tbody tr').forEach(tr => {
|
|
Array.from(tr.children).forEach((td, i) => {
|
|
if (!td.hasAttribute('data-label')) {
|
|
td.setAttribute('data-label', heads[i] || '');
|
|
}
|
|
});
|
|
});
|
|
// ✅ une seule source de vérité
|
|
document.documentElement.classList.add('mc-ready');
|
|
}
|
|
|
|
function ready(fn){
|
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', fn);
|
|
else fn();
|
|
}
|
|
|
|
ready(function(){
|
|
const tbl = document.getElementById('table_rdv') || document.querySelector('table.mobile-cards');
|
|
initMobileCards(tbl);
|
|
});
|
|
})();
|
|
</script>
|
|
<!--*****************************FIN Affichage mobile************************-->
|
|
<footer class="site-footer">
|
|
<div class="container">
|
|
<p><?= $translations['copyr'] ?></p>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|