X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fpayment.php;h=08cd05d2a689f2be21d4e138011e6c47b97035c8;hb=fb25f6a6dae580e726b4786c852ab21e9abe22c6;hp=6f8896d416ae87995cf3dd941b604400aa3d2c55;hpb=5e1513f67936a6c6866113d260746711af4ea2ee;p=platal.git diff --git a/modules/payment.php b/modules/payment.php index 6f8896d..08cd05d 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), @@ -124,7 +125,7 @@ class PaymentModule extends PLModule ); } - function handler_payment(&$page, $ref = -1) + function handler_payment($page, $ref = -1) { global $globals; @@ -185,7 +186,7 @@ class PaymentModule extends PLModule $page->assign('sex', S::user()->isFemale()); } - function handler_cyber_return(&$page, $uid = null) + function handler_cyber_return($page, $uid = null) { /* reference banque (numero de transaction) */ $champ901 = Env::s('CHAMP901'); @@ -248,7 +249,7 @@ class PaymentModule extends PLModule if ($eid = $res->fetchOneCell()) { require_once dirname(__FILE__) . '/xnetevents/xnetevents.inc.php'; $evt = get_event_detail($eid); - subscribe_lists_event($uid, $evt, 1, $montant, true); + subscribe_lists_event($uid, $evt['short_name'], 1, $montant, true); } /* on genere le mail de confirmation */ @@ -283,7 +284,7 @@ class PaymentModule extends PLModule exit; } - function handler_cyber2_return(&$page, $uid = null) + function handler_cyber2_return($page, $uid = null) { global $globals, $platal; @@ -345,7 +346,7 @@ class PaymentModule extends PLModule list($eid, $asso_id) = $res->fetchOneRow(); require_once dirname(__FILE__) . '/xnetevents/xnetevents.inc.php'; $evt = get_event_detail($eid, false, $asso_id); - subscribe_lists_event($user->id(), $evt, 1, $amount, true); + subscribe_lists_event($user->id(), $evt['short_name'], 1, $amount, true); } /* on genere le mail de confirmation */ @@ -381,7 +382,7 @@ class PaymentModule extends PLModule exit; } - function handler_paypal_return(&$page, $uid = null) + function handler_paypal_return($page, $uid = null) { $page->changeTpl('payment/retour_paypal.tpl'); @@ -441,14 +442,14 @@ class PaymentModule extends PLModule if ($eid = $res->fetchOneCell()) { require_once dirname(__FILE__) . '/xnetevents/xnetevents.inc.php'; $evt = get_event_detail($eid); - subscribe_lists_event($user->id(), $evt, 1, $montant, true); + subscribe_lists_event($user->id(), $evt['short_name'], 1, $montant, true); } /* on genere le mail de confirmation */ - $conf_text = str_replace(array('', '', '', '', '', ''), + $conf_text = str_replace(array('', '', '', '', '', '', ''), array($user->firstName(), $user->lastName(), $user->promo(), $montant, - $user->isFemale() ? 'Chère' : 'Cher', - $user->isFemale() ? 'Chère' : 'Cher'), $conf_text); + $user->isFemale() ? 'Chère' : 'Cher', $user->isFemale() ? 'Chère' : 'Cher', + Env::v('comment')), $conf_text); global $globals; $mymail = new PlMailer(); @@ -477,7 +478,7 @@ class PaymentModule extends PLModule $page->assign('erreur', $erreur); } - function handler_xnet_payment(&$page, $pid = null) + function handler_xnet_payment($page, $pid = null) { global $globals; @@ -589,7 +590,44 @@ class PaymentModule extends PLModule $page->assign('event', $event); } - function handler_admin(&$page, $action = 'list', $id = null) { + 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'); $table_editor = new PLTableEditor('admin/payments','payments','id'); @@ -612,7 +650,7 @@ class PaymentModule extends PLModule $table_editor->apply($page, $action, $id); } - function handler_adm_transactions(&$page, $payment_id = null, $action = "list", $id = null) { + function handler_adm_transactions($page, $payment_id = null, $action = "list", $id = null) { // show transactions. FIXME: should not be modifiable $page->setTitle('Administration - Paiements - Transactions'); $page->assign('title', "Liste des transactions pour le paiement {$payment_id}"); @@ -626,7 +664,7 @@ class PaymentModule extends PLModule $page->assign('readonly', 'readonly'); // don't show modification features } - function handler_adm_bankaccounts(&$page, $action = 'list', $id = null) { + function handler_adm_bankaccounts($page, $action = "list", $id = null) { // managment of bank account used for money transfert $page->setTitle('Administration - Paiements - RIBs'); $page->assign('title', "Liste des RIBs"); @@ -647,7 +685,7 @@ class PaymentModule extends PLModule $table_editor->apply($page, $action, $id); } - function handler_adm_methods(&$page, $action = 'list', $id = null) { + function handler_adm_methods($page, $action = "list", $id = null) { // show and edit payment methods $page->setTitle('Administration - Paiements - Méthodes'); $page->assign('title', 'Méthodes de paiement'); @@ -655,7 +693,7 @@ class PaymentModule extends PLModule $table_editor->apply($page, $action, $id); } - function handler_adm_reconcile(&$page, $step = 'list', $param = null) { + function handler_adm_reconcile($page, $step = 'list', $param = null) { // reconciles logs with transactions // FIXME: the admin is considered to be fair => he doesn't hack the $step value, nor other params $page->setTitle('Administration - Paiements - Réconciliations'); @@ -722,7 +760,7 @@ class PaymentModule extends PLModule } } - function handler_adm_importlogs(&$page, $step, $param = null) { + function handler_adm_importlogs($page, $step, $param = null) { $page->setTitle('Administration - Paiements - Réconciliations'); $page->changeTpl('payment/reconcile.tpl'); $page->assign('step', $step); @@ -894,7 +932,7 @@ class PaymentModule extends PLModule } } - function handler_adm_transfers(&$page, $action = null, $id = null) { + function handler_adm_transfers($page, $action = null, $id = null) { // list/log all bank transfers and link them to individual transactions if (Post::has('generate')) {