From 4294dc6c2242bd3079b7b66a854f3bc0cc31b889 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 2 Mar 2011 10:41:34 +0100 Subject: [PATCH] Creates csv for payments (Closes #1398). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- ChangeLog | 3 +++ modules/payment.php | 38 ++++++++++++++++++++++++++++++++++++++ templates/payment/xnet.tpl | 5 ++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b262a4d..51a1b29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ Bug/Wish: - #1399: Displays all similar entreprises only on demand -JAC - #1403: Displays grade if any in medal validation process -JAC + * Payments: + - #1398: Creates csv for payments -JAC + * Profile: - #1324,1352: Adds jobs to vcards -JAC - #1380: Allows multiple entries for some medals -JAC diff --git a/modules/payment.php b/modules/payment.php index f068aff..0005e13 100644 --- a/modules/payment.php +++ b/modules/payment.php @@ -111,6 +111,7 @@ class PaymentModule extends PLModule 'payment/paypal_return' => $this->make_hook('paypal_return', AUTH_PUBLIC, 'user', NO_HTTPS), '%grp/paiement' => $this->make_hook('xnet_payment', AUTH_MDP), '%grp/payment' => $this->make_hook('xnet_payment', AUTH_MDP), + '%grp/payment/csv' => $this->make_hook('payment_csv', AUTH_MDP, 'groupadmin'), '%grp/payment/cyber_return' => $this->make_hook('cyber_return', AUTH_PUBLIC, 'user', NO_HTTPS), '%grp/payment/cyber2_return' => $this->make_hook('cyber2_return', AUTH_PUBLIC, 'user', NO_HTTPS), '%grp/payment/paypal_return' => $this->make_hook('paypal_return', AUTH_PUBLIC, 'user', NO_HTTPS), @@ -589,6 +590,43 @@ class PaymentModule extends PLModule $page->assign('event', $event); } + function handler_payment_csv($page, $pid = null) + { + if (is_null($pid)) { + pl_redirect('payment'); + } + if (substr($pid, -4) == '.vcf') { + $pid = substr($pid, 0, strlen($pid) - 4); + } + + $res = XDB::fetchAllAssoc('SELECT uid, IF(timestamp = \'0000-00-00\', 0, timestamp) AS date, comment, amount + FROM payment_transactions + WHERE ref = {?} + ORDER BY timestamp', + $pid); + if (is_null($res)) { + pl_redirect('payment'); + } + + $users = User::getBulkUsersWithUIDs($res, 'uid', 'user'); + $sum = 0; + + pl_cached_content_headers('text/x-csv', 1); + $csv = fopen('php://output', 'w'); + fputcsv($csv, array('Date', 'Nom', 'Prénom', 'Sexe', 'Promotion', 'Email', 'Commentaire', 'Montant'), ';'); + foreach ($users as $item) { + $user = $item['user']; + $sum += strtr(substr($item['amount'], 0, strpos($item['amount'], 'EUR')), ',', '.'); + fputcsv($csv, array(format_datetime($item['date'], '%d/%m/%y'), $user->lastName(), $user->firstName(), + ($user->isFemale()) ? 'F' : 'M', $user->promo(), $user->ForlifeEmail(), + $item['comment'], str_replace('EUR', '€', $item['amount'])), ';'); + } + fputcsv($csv, array(date('d/m/y'), 'Total', '', '', '' , '', '', strtr($sum, '.', ',') . ' €'), ';'); + + fclose($csv); + exit; + } + function handler_admin($page, $action = 'list', $id = null) { $page->setTitle('Administration - Paiements'); $page->assign('title', 'Gestion des télépaiements'); diff --git a/templates/payment/xnet.tpl b/templates/payment/xnet.tpl index b50b959..89dddb1 100644 --- a/templates/payment/xnet.tpl +++ b/templates/payment/xnet.tpl @@ -79,7 +79,10 @@ il suffit de cliquer sur le titre de la colonne concernée. {/if} {if $is_admin && $trans[$p.id]} -

Liste des personnes ayant payé (pour les administrateurs uniquement) :

+

+ Liste des personnes ayant payé (pour les administrateurs uniquement) :
+ {icon name=page_excel title="Fichier Excel"} Obtenir au format Excel +

-- 2.1.4