+ 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) {