From 98a7e9dc645a582adb7219299a24107e6bd1d2a2 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Thu, 30 Nov 2006 10:39:19 +0000 Subject: [PATCH] Integrate payment directly in Xnet Fix some bugs in the calculation of paid amount Backport [1199] git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1205 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/css/xnet.css | 20 ++++ htdocs/images/icons/money.gif | Bin 0 -> 1100 bytes htdocs/xnet.php | 2 +- modules/payment.php | 155 +++++++++++++++++++++++++--- modules/payment/money/cyberpaiement.inc.php | 69 ++++++------- modules/payment/money/paypal.inc.php | 79 +++++++------- modules/xnetevents.php | 5 +- modules/xnetevents/xnetevents.inc.php | 8 +- modules/xnetgrp.php | 75 +------------- templates/payment/index.tpl | 12 ++- templates/payment/xnet.tpl | 146 ++++++++++++++++++++++++++ templates/xnet/groupe/annuaire.tpl | 4 +- templates/xnet/groupe/telepaiement.tpl | 76 -------------- templates/xnetevents/admin.tpl | 4 +- templates/xnetevents/index.tpl | 24 +++-- templates/xnetevents/subscribe.tpl | 18 ++-- 16 files changed, 432 insertions(+), 265 deletions(-) create mode 100644 htdocs/images/icons/money.gif create mode 100644 templates/payment/xnet.tpl delete mode 100644 templates/xnet/groupe/telepaiement.tpl diff --git a/htdocs/css/xnet.css b/htdocs/css/xnet.css index cb4ba7f..3c9889a 100644 --- a/htdocs/css/xnet.css +++ b/htdocs/css/xnet.css @@ -39,6 +39,21 @@ tt,pre { font-size: 10pt; } +fieldset { + border: 1px gray solid; + + margin-top: 1em; + margin-bottom: 1em; +} + +legend { + border: 1px gray solid; + background: #e9e0aa; + color: inherit; + + padding: 2px 4px; +} + a, a:link, a:visited { text-decoration: none ; color: #5c81aa; } a img { border: none; } @@ -238,6 +253,11 @@ th.grayed { color: #666; } +a.popup2 { + color: #4c618a; + background-color: inherit; +} + /*************************************************************************** * Special pages ***************************************************************************/ diff --git a/htdocs/images/icons/money.gif b/htdocs/images/icons/money.gif new file mode 100644 index 0000000000000000000000000000000000000000..1040ec704b6ec2b2021635f67945738fa82dd0a8 GIT binary patch literal 1100 zcmb`GZ%7ky7{{N@>71T5bviYxlS+q7nMyEABDc{t^u?uu%U3&ZYd6q&+)i7)T7Rrz zK}Wslh+bTO*^7wlP29`tMK!_~14)jMSkMb!3PKnu*Y9?P5J?36;Q8I>_dL(<`QAOh z-vz^Gyo012?C=5fLGYmvAId4&tehc)kXRJyd^D?MGIAy&MuY+{sd+}Cvr0B15K%E2 z%|{7=;0wG^Oyr%Rf&Y-z+A8Ug*%a!+!r*&=>6U^z{Rnmq~`1F{663DUL;c zJaTRdx2{4h95h5oD$NWN#OU6VUsnOu23YCQYwex)#|XwEK>(8jMI8x)T{=%2Jf!ml zj^R)ap)*C3F~rEg%}$K@5%Y-mB@7mIo;Fz0d4WpkdlkfziLJiQx zIErCWlKBDR9=!qRi3T?Ua0<1dVtLm$l?HhJ48YmB>vOdLG))4?1G~P>v*o6knwQh( z2T-HYFkwD`%1@fM*$H613$Vj$+V@AAw(}TitN|z~YMxyv=b~)$Ai&?&#>W}ejYH6N zewyz7jn`7;2Ivv+06YuU97UgJAZ4`DI44%KO^<&C+=s@IM8 zdpyU>s&0MOe^{uxb^0FTZMWZk_u70l&>g-xl3tJSfhVKX(#xe2J#S0dqobh;Yi@Yr*ZI=+lXPn5~BKS(+xRtGZjR?04BJdv9Pz+8x!GZS}6st~(Y>Emr54 xwKcmAw_UpKY{YQPS&y}v%mHUdUF#udgEDS8W_4CJjQgzi1E%+Z#o{oW`~m5p^w|Ia literal 0 HcmV?d00001 diff --git a/htdocs/xnet.php b/htdocs/xnet.php index e8fbeef..8e55c69 100644 --- a/htdocs/xnet.php +++ b/htdocs/xnet.php @@ -24,7 +24,7 @@ $GLOBALS['IS_XNET_SITE'] = true; require_once dirname(__FILE__).'/../include/xnet.inc.php'; if (!($path = Env::v('n')) || substr($path, 0, 4) != 'Xnet') { - $platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc'); + $platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc', 'payment'); $platal->run(); exit; diff --git a/modules/payment.php b/modules/payment.php index d105f97..834b818 100644 --- a/modules/payment.php +++ b/modules/payment.php @@ -79,7 +79,12 @@ class PaymentModule extends PLModule 'payment' => $this->make_hook('payment', AUTH_MDP), 'payment/cyber_return' => $this->make_hook('cyber_return', AUTH_PUBLIC), 'payment/paypal_return' => $this->make_hook('paypal_return', AUTH_PUBLIC), + '%grp/paiement' => $this->make_hook('xnet_payment', AUTH_MDP), + '%grp/payment' => $this->make_hook('xnet_payment', AUTH_MDP), + '%grp/payment/cyber_return' => $this->make_hook('cyber_return', AUTH_PUBLIC), + '%grp/payment/paypal_return' => $this->make_hook('paypal_return', AUTH_PUBLIC), 'admin/payments' => $this->make_hook('admin', AUTH_MDP, 'admin'), + ); } @@ -90,8 +95,22 @@ class PaymentModule extends PLModule require_once 'profil.func.inc.php' ; require_once dirname(__FILE__).'/payment/money.inc.php' ; - $page->changeTpl('payment/index.tpl'); - $page->assign('xorg_title','Polytechnique.org - Télépaiements'); + if (!empty($GLOBALS['IS_XNET_SITE'])) { + if (!$globals->asso('id')) { + return PL_NOT_FOUND; + } + $res = XDB::query("SELECT asso_id + FROM paiement.paiements + WHERE asso_id = {?} AND id = {?}", + $globals->asso('id'), $ref); + if (!$res->numRows()) { + return PL_FORBIDDEN; + } + new_group_page('payment/index.tpl'); + } else { + $page->changeTpl('payment/index.tpl'); + $page->assign('xorg_title','Polytechnique.org - Télépaiements'); + } // initialisation $op = Env::v('op', 'select'); @@ -169,8 +188,9 @@ class PaymentModule extends PLModule } echo ($ref = $matches[1]); - $res = XDB::query("SELECT mail,text,confirmation - FROM paiement.paiements WHERE id={?}", $ref); + $res = XDB::query("SELECT mail,text,confirmation + FROM paiement.paiements + WHERE id={?}", $ref); if (!list($conf_mail,$conf_title,$conf_text) = $res->fetchOneRow()) { cb_erreur("référence de commande inconnue"); } @@ -178,9 +198,9 @@ class PaymentModule extends PLModule /* on extrait le code de retour */ if ($champ906 != "0000") { $res = XDB::query("SELECT rcb.text,c.id,c.text - FROM paiement.codeRCB AS rcb - LEFT JOIN paiement.codeC AS c ON rcb.codeC=c.id - WHERE rcb.id='$champ906'"); + FROM paiement.codeRCB AS rcb + LEFT JOIN paiement.codeC AS c ON rcb.codeC=c.id + WHERE rcb.id='$champ906'"); if (list($rcb_text, $c_id, $c_text) = $res->fetchOneRow()) { cb_erreur("erreur lors du paiement : $c_text ($c_id)"); } else{ @@ -190,8 +210,8 @@ class PaymentModule extends PLModule /* on fait l'insertion en base de donnees */ XDB::execute("INSERT INTO paiement.transactions (id,uid,ref,fullref,montant,cle,comment) - VALUES ({?},{?},{?},{?},{?},{?},{?})", - $champ901, $uid, $ref, $champ200, $montant, $champ905,Env::v('comment')); + VALUES ({?},{?},{?},{?},{?},{?},{?})", + $champ901, $uid, $ref, $champ200, $montant, $champ905,Env::v('comment')); /* on genere le mail de confirmation */ $conf_text = str_replace("",$prenom,$conf_text); @@ -212,7 +232,7 @@ class PaymentModule extends PLModule /* on envoie les details de la transaction à telepaiement@ */ $mymail = new HermesMailer(); $mymail->setFrom("webmaster@polytechnique.org"); - $mymail->addTo("telepaiement@polytechnique.org"); + $mymail->addTo("telepaiement@staff.polytechnique.org"); $mymail->setSubject($conf_title); $msg = "utilisateur : $prenom $nom ($uid)\n". "mail : $forlife@polytechnique.org\n\n". @@ -228,7 +248,11 @@ class PaymentModule extends PLModule function handler_paypal_return(&$page, $uid = null) { - $page->changeTpl('payment/retour_paypal.tpl'); + if (!empty($GLOBALS['IS_XNET_SITE'])) { + new_group_open_page('payment/retour_paypal.tpl'); + } else { + $page->changeTpl('payment/retour_paypal.tpl'); + } require_once 'diogenes/diogenes.hermes.inc.php'; /* reference banque (numero de transaction) */ @@ -272,15 +296,16 @@ class PaymentModule extends PLModule $ref = $matches[1]; $res = XDB::query("SELECT mail,text,confirmation - FROM paiement.paiements WHERE id={?}", $ref); + FROM paiement.paiements + WHERE id={?}", $ref); if (!list($conf_mail,$conf_title,$conf_text) = $res->fetchOneRow()) { paypal_erreur("référence de commande inconnue"); } /* on fait l'insertion en base de donnees */ XDB::execute("INSERT INTO paiement.transactions (id,uid,ref,fullref,montant,cle,comment) - VALUES ({?},{?},{?},{?},{?},{?},{?})", - $no_transaction, $uid, $ref, $fullref, $montant, $clef, Env::v('comment')); + VALUES ({?},{?},{?},{?},{?},{?},{?})", + $no_transaction, $uid, $ref, $fullref, $montant, $clef, Env::v('comment')); /* on genere le mail de confirmation */ $conf_text = str_replace("",$prenom,$conf_text); @@ -316,6 +341,108 @@ class PaymentModule extends PLModule $page->assign('texte', $conf_text); $page->assign('erreur', $erreur); } + + function handler_xnet_payment(&$page, $pid = null) + { + global $globals; + + if (!is_null($pid)) { + return $this->handler_payment($page, $pid); + } + new_group_page('payment/xnet.tpl'); + + $res = XDB::query( + "SELECT id, text, url + FROM {$globals->money->mpay_tprefix}paiements + WHERE asso_id = {?} AND NOT FIND_IN_SET(flags, 'old') + ORDER BY id DESC", $globals->asso('id')); + $tit = $res->fetchAllAssoc(); + $page->assign('titres', $tit); + + $order = Env::v('order', 'timestamp'); + $orders = array('timestamp', 'nom', 'promo', 'montant'); + if (!in_array($order, $orders)) { + $order = 'timestamp'; + } + $inv_order = Env::v('order_inv', 0); + $page->assign('order', $order); + $page->assign('order_inv', !$inv_order); + + if ($order == 'timestamp') { + $inv_order = !$inv_order; + } + + if ($inv_order) { + $inv_order = ' DESC'; + } else { + $inv_order = ''; + } + if ($order == 'montant') { + $order = 'LENGTH(montant) '.$inv_order.', montant'; + } + + $orderby = 'ORDER BY '.$order.$inv_order; + if ($order != 'nom') { + $orderby .= ', nom'; $inv_order = ''; + } + $orderby .= ', prenom'.$inv_order; + if ($order != 'timestamp') { + $orderby .= ', timestamp DESC'; + } + + $trans = array(); + $event = array(); + foreach($tit as $foo) { + $pid = $foo['id']; + if (may_update()) { + $res = XDB::query("SELECT IF(u.nom_usage<>'', u.nom_usage, u.nom) AS nom, + u.prenom, u.promo, a.alias, timestamp AS `date`, montant + FROM {$globals->money->mpay_tprefix}transactions AS t + INNER JOIN auth_user_md5 AS u ON ( t.uid = u.user_id ) + INNER JOIN aliases AS a ON ( t.uid = a.id AND a.type='a_vie' ) + WHERE ref = {?} ".$orderby, $pid); + $trans[$pid] = $res->fetchAllAssoc(); + $sum = 0; + foreach ($trans[$pid] as $i => $t) { + $sum += strtr(substr($t['montant'], 0, strpos($t['montant'], 'EUR')), ',', '.'); + $trans[$pid][$i]['montant'] = str_replace('EUR', '¤', $t['montant']); + } + $trans[$pid][] = array('nom' => 'somme totale', + 'montant' => strtr($sum, '.', ',').' ¤'); + } + $res = XDB::iterRow("SELECT e.eid, e.short_name, e.intitule, ep.nb, ei.montant, ep.paid + FROM groupex.evenements AS e + LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = e.eid AND uid = {?}) + INNER JOIN groupex.evenements_items AS ei ON (ep.eid = ei.eid AND ep.item_id = ei.item_id) + WHERE e.paiement_id = {?}", + S::v('uid'), $pid); + $event[$pid] = array(); + $event[$pid]['paid'] = 0; + if ($res->total()) { + $event[$pid]['topay'] = 0; + while(list($eid, $shortname, $title, $nb, $montant, $paid) = $res->next()) { + $event[$pid]['topay'] += ($nb * $montant); + $event[$pid]['eid'] = $eid; + $event[$pid]['shortname'] = $shortname; + $event[$pid]['title'] = $title; + $event[$pid]['ins'] = !is_null($nb); + $event[$pid]['paid'] = $paid; + } + } + $res = XDB::query("SELECT montant + FROM {$globals->money->mpay_tprefix}transactions AS t + WHERE ref = {?} AND uid = {?}", $pid, S::v('uid')); + $montants = $res->fetchColumn(); + + foreach ($montants as $m) { + $p = strtr(substr($m, 0, strpos($m, 'EUR')), ',', '.'); + $event[$pid]['paid'] += trim($p); + } + } + $page->assign('trans', $trans); + $page->assign('event', $event); + } + function handler_admin(&$page, $action = 'list', $id = null) { $page->assign('xorg_title','Polytechnique.org - Administration - Paiements'); $page->assign('title', 'Gestion des télépaiements'); diff --git a/modules/payment/money/cyberpaiement.inc.php b/modules/payment/money/cyberpaiement.inc.php index 9a35d41..d661f21 100644 --- a/modules/payment/money/cyberpaiement.inc.php +++ b/modules/payment/money/cyberpaiement.inc.php @@ -43,49 +43,48 @@ class CyberPayment function prepareform(&$pay) { // toute la doc se trouve sur - // http://www.cyberpaiement.tm.fr/donnees.htm + // http://www.cyberpaiement.tm.fr/donnees.htm - global $globals; + global $globals, $platal; - $roboturl = str_replace("https://","http://",$globals->baseurl) - ."/payment/cyber_return/".S::v('uid')."?comment=".urlencode(Env::v('comment'))."&CHAMPBPX"; - if (Cookie::has(session_name())) { - $returnurl .= "?".SID; - } - $req = XDB::query("SELECT IF(nom_usage!='', nom_usage, nom) AS nom FROM auth_user_md5 WHERE user_id = {?}",S::v('uid')); - $name = $req->fetchOneCell(); + $roboturl = str_replace("https://","http://", $globals->baseurl) + . '/' . $platal->ns . "payment/cyber_return/".S::v('uid')."?comment=".urlencode(Env::v('comment'))."&CHAMPBPX"; + $req = XDB::query("SELECT IF(nom_usage!='', nom_usage, nom) AS nom + FROM auth_user_md5 + WHERE user_id = {?}",S::v('uid')); + $name = $req->fetchOneCell(); // on constuit la reference de la transaction $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id(); $fullref = substr("$prefix-xorg-{$pay->id}",-15); $this->urlform = "https://ecom.cimetz.com/telepaie/cgishell.exe/epaie01.exe"; - $this->infos['commercant'] = Array( - 'CHAMP000' => 510879, - 'CHAMP001' => 5965, - 'CHAMP002' => 5429159012, - 'CHAMP003' => "I", - 'CHAMP004' => "Polytechnique.org", - 'CHAMP005' => $roboturl, - 'CHAMP006' => "Polytechnique.org", - 'CHAMP007' => $globals->baseurl, - 'CHAMP008' => $pay->mail); - $this->infos['client'] = Array( - 'CHAMP100' => $name, - 'CHAMP101' => S::v('prenom'), - 'CHAMP102' => '.', - 'CHAMP103' => '.', - 'CHAMP104' => S::v('bestalias').'@polytechnique.org', - 'CHAMP106' => '.', - 'CHAMP107' => '.', - 'CHAMP108' => '.', - 'CHAMP109' => '.', - 'CHAMP110' => '.'); - $this->infos['commande'] = Array( - 'CHAMP200' => $fullref, - 'CHAMP201' => $this->val, - 'CHAMP202' => "EUR"); - $this->infos['divers'] = Array('CHAMP900' => '01'); + $this->infos['commercant'] = Array( + 'CHAMP000' => 510879, + 'CHAMP001' => 5965, + 'CHAMP002' => 5429159012, + 'CHAMP003' => "I", + 'CHAMP004' => "Polytechnique.org", + 'CHAMP005' => $roboturl, + 'CHAMP006' => "Polytechnique.org", + 'CHAMP007' => $globals->baseurl . '/' . $platal->ns, + 'CHAMP008' => $pay->mail); + $this->infos['client'] = Array( + 'CHAMP100' => $name, + 'CHAMP101' => S::v('prenom'), + 'CHAMP102' => '.', + 'CHAMP103' => '.', + 'CHAMP104' => S::v('bestalias').'@polytechnique.org', + 'CHAMP106' => '.', + 'CHAMP107' => '.', + 'CHAMP108' => '.', + 'CHAMP109' => '.', + 'CHAMP110' => '.'); + $this->infos['commande'] = Array( + 'CHAMP200' => $fullref, + 'CHAMP201' => $this->val, + 'CHAMP202' => "EUR"); + $this->infos['divers'] = Array('CHAMP900' => '01'); } // }}} diff --git a/modules/payment/money/paypal.inc.php b/modules/payment/money/paypal.inc.php index edc5924..0b9237d 100644 --- a/modules/payment/money/paypal.inc.php +++ b/modules/payment/money/paypal.inc.php @@ -44,58 +44,61 @@ class PayPal function prepareform(&$pay) { // toute la doc sur : - // https://www.paypal.com/fr_FR/pdf/integration_guide.pdf - // attention : le renvoi automatique ne fonctionne que si - // on oblige les gens à créer un compte paypal - // nous ne l'utilisons pas ; il faut donc que l'utilisateur - // revienne sur le site - global $globals; + // https://www.paypal.com/fr_FR/pdf/integration_guide.pdf + // attention : le renvoi automatique ne fonctionne que si + // on oblige les gens à créer un compte paypal + // nous ne l'utilisons pas ; il faut donc que l'utilisateur + // revienne sur le site + global $globals, $platal; - $this->urlform = 'https://'.$globals->money->paypal_site.'/cgi-bin/webscr'; - $req = XDB::query("SELECT IF(nom_usage!='', nom_usage, nom) AS nom FROM auth_user_md5 WHERE user_id = {?}",S::v('uid')); - $name = $req->fetchOneCell(); + $this->urlform = 'https://'.$globals->money->paypal_site.'/cgi-bin/webscr'; + $req = XDB::query("SELECT IF(nom_usage!='', nom_usage, nom) AS nom + FROM auth_user_md5 + WHERE user_id = {?}",S::v('uid')); + $name = $req->fetchOneCell(); $roboturl = str_replace("https://","http://",$globals->baseurl) - ."/payment/paypal_return/".S::v('uid')."?comment=".urlencode(Env::v('comment')); + . '/' . $platal->ns . "payment/paypal_return/".S::v('uid')."?comment=".urlencode(Env::v('comment')); - $this->infos = Array(); + $this->infos = Array(); - $this->infos['commercant'] = Array( - 'business' => $globals->money->paypal_compte, - 'rm' => 2, - 'return' => $roboturl, - 'cn' => 'Commentaires', - 'no_shipping' => 1, - 'cbt' => 'Revenir sur polytechnique.org'); + $this->infos['commercant'] = Array( + 'business' => $globals->money->paypal_compte, + 'rm' => 2, + 'return' => $roboturl, + 'cn' => 'Commentaires', + 'no_shipping' => 1, + 'cbt' => empty($GLOBALS['IS_XNET_SITE']) ? + 'Revenir sur polytechnique.org' : + 'Revenir sur polytechnique.net'); - $info_client = Array( - 'first_name' => S::v('prenom'), - 'last_name' => $name, - 'email' => S::v('bestalias').'@polytechnique.org'); + $info_client = Array( + 'first_name' => S::v('prenom'), + 'last_name' => $name, + 'email' => S::v('bestalias').'@polytechnique.org'); - $res = XDB::query( - "SELECT a.adr1 AS address1, a.adr2 AS address2, - a.city, a.postcode AS zip, a.country, - IF(t.tel, t.tel, q.profile_mobile) AS night_phone_b - FROM auth_user_quick AS q - LEFT JOIN adresses AS a ON (q.user_id = a.uid AND FIND_IN_SET('active', a.statut)) - LEFT JOIN tels AS t ON (t.uid = a.uid AND t.adrid = a.adrid) + $res = XDB::query( + "SELECT a.adr1 AS address1, a.adr2 AS address2, + a.city, a.postcode AS zip, a.country, + IF(t.tel, t.tel, q.profile_mobile) AS night_phone_b + FROM auth_user_quick AS q + LEFT JOIN adresses AS a ON (q.user_id = a.uid AND FIND_IN_SET('active', a.statut)) + LEFT JOIN tels AS t ON (t.uid = a.uid AND t.adrid = a.adrid) WHERE q.user_id = {?} - LIMIT 1", S::v('uid')); - $this->infos['client']=array_merge($info_client, $res->fetchOneAssoc()); + LIMIT 1", S::v('uid')); + $this->infos['client'] = array_merge($info_client, $res->fetchOneAssoc()); // on constuit la reference de la transaction $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id(); $fullref = substr("$prefix-xorg-{$pay->id}",-15); - $this->infos['commande'] = Array( - 'item_name' => $pay->text, - 'amount' => $this->val_number, - 'currency_code' => 'EUR', - 'custom' => $fullref); - - $this->infos['divers'] = Array('cmd' => '_xclick'); + $this->infos['commande'] = Array( + 'item_name' => $pay->text, + 'amount' => $this->val_number, + 'currency_code' => 'EUR', + 'custom' => $fullref); + $this->infos['divers'] = Array('cmd' => '_xclick'); } // }}} diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 7afb82e..53c6186 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -140,7 +140,7 @@ class XnetEventsModule extends PLModule while ($e = $evenements->next()) { $e['show_participants'] = ($e['show_participants'] && (is_member() || may_update())); $res = XDB::query( - "SELECT titre, details, montant, ei.item_id, nb + "SELECT titre, details, montant, ei.item_id, nb, ep.paid FROM groupex.evenements_items AS ei LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id AND uid = {?}) @@ -149,6 +149,7 @@ class XnetEventsModule extends PLModule $e['moments'] = $res->fetchAllAssoc(); $e['topay'] = 0; + $e['paid'] = $e['moments'][0]['paid']; foreach ($e['moments'] as $m) { $e['topay'] += $m['nb'] * $m['montant']; } @@ -217,7 +218,7 @@ class XnetEventsModule extends PLModule } // impossible to unsubscribe if you already paid sthing - if (array_sum($subs) && $evt['paid'] != 0) { + if (!array_sum($subs) && $evt['paid'] != 0) { $page->trig("Impossible de te désinscrire complètement ". "parce que tu as fait un paiement par ". "chèque ou par liquide. Contacte un ". diff --git a/modules/xnetevents/xnetevents.inc.php b/modules/xnetevents/xnetevents.inc.php index 8615f8b..ed5794c 100644 --- a/modules/xnetevents/xnetevents.inc.php +++ b/modules/xnetevents/xnetevents.inc.php @@ -68,7 +68,7 @@ function get_event_detail($eid, $item_id = false) } $res = XDB::query( - "SELECT titre, details, montant, ei.item_id, nb + "SELECT titre, details, montant, ei.item_id, nb, ep.paid FROM groupex.evenements_items AS ei LEFT JOIN groupex.evenements_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id AND uid = {?}) @@ -77,10 +77,13 @@ function get_event_detail($eid, $item_id = false) $evt['moments'] = $res->fetchAllAssoc(); $evt['topay'] = 0; + $evt['paid'] = 0; foreach ($evt['moments'] as $m) { $evt['topay'] += $m['nb'] * $m['montant']; - if ($m['montant']) + if ($m['montant']) { $evt['money'] = true; + } + $evt['paid'] = $m['paid']; } $req = XDB::query( @@ -89,7 +92,6 @@ function get_event_detail($eid, $item_id = false) WHERE ref = {?} AND uid = {?}", $evt['paiement_id'], S::v('uid')); $montants = $req->fetchColumn(); - $evt['paid'] = 0; foreach ($montants as $m) { $p = strtr(substr($m, 0, strpos($m, 'EUR')), ',', '.'); $evt['paid'] += trim($p); diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 1b17bf6..af4f6ea 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -82,7 +82,6 @@ class XnetGrpModule extends PLModule '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP), '%grp/trombi' => $this->make_hook('trombi', AUTH_MDP), '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP), - '%grp/paiement' => $this->make_hook('paiement', AUTH_MDP), '%grp/admin/annuaire' => $this->make_hook('admin_annuaire', AUTH_MDP), @@ -566,74 +565,6 @@ class XnetGrpModule extends PLModule } } - function handler_paiement(&$page) - { - global $globals; - - new_group_page('xnet/groupe/telepaiement.tpl'); - - $res = XDB::query( - "SELECT id, text - FROM {$globals->money->mpay_tprefix}paiements - WHERE asso_id = {?} AND NOT FIND_IN_SET(flags, 'old') - ORDER BY id DESC", $globals->asso('id')); - $tit = $res->fetchAllAssoc(); - $page->assign('titres', $tit); - - $order = Env::v('order', 'timestamp'); - $orders = array('timestamp', 'nom', 'promo', 'montant'); - if (!in_array($order, $orders)) { - $order = 'timestamp'; - } - $inv_order = Env::v('order_inv', 0); - $page->assign('order', $order); - $page->assign('order_inv', !$inv_order); - - if ($order == 'timestamp') { - $inv_order = !$inv_order; - } - - if ($inv_order) { - $inv_order = ' DESC'; - } else { - $inv_order = ''; - } - if ($order == 'montant') { - $order = 'LENGTH(montant) '.$inv_order.', montant'; - } - - $orderby = 'ORDER BY '.$order.$inv_order; - if ($order != 'nom') { - $orderby .= ', nom'; $inv_order = ''; - } - $orderby .= ', prenom'.$inv_order; - if ($order != 'timestamp') { - $orderby .= ', timestamp DESC'; - } - - if (may_update()) { - $trans = array(); - foreach($tit as $foo) { - $pid = $foo['id']; - $res = XDB::query( - "SELECT IF(u.nom_usage<>'', u.nom_usage, u.nom) AS nom, - u.prenom, u.promo, a.alias, timestamp AS `date`, montant - FROM {$globals->money->mpay_tprefix}transactions AS t - INNER JOIN auth_user_md5 AS u ON ( t.uid = u.user_id ) - INNER JOIN aliases AS a ON ( t.uid = a.id AND a.type='a_vie' ) - WHERE ref = {?} ".$orderby, $pid); - $trans[$pid] = $res->fetchAllAssoc(); - $sum = 0; - foreach ($trans[$pid] as $i => $t) { - $sum += strtr(substr($t['montant'], 0, strpos($t['montant'], 'EUR')), ',', '.'); - } - $trans[$pid][] = array('nom' => 'somme totale', - 'montant' => strtr($sum, '.', ',').' EUR'); - } - $page->assign('trans', $trans); - } - } - function handler_admin_annuaire(&$page) { global $globals; @@ -942,13 +873,15 @@ class XnetGrpModule extends PLModule INNER JOIN groupex.announces AS a ON ( (a.promo_min = 0 OR a.promo_min <= u.promo) AND (a.promo_max = 0 OR a.promo_max <= u.promo)) INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = a.user_id) - WHERE u.user_id = {?} AND peremption >= NOW()", $uid); + WHERE u.user_id = {?} AND peremption >= NOW() AND a.asso_id = {?}", + $uid, $globals->asso('id')); } else { $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.create_date, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo FROM groupex.announces AS a INNER JOIN auth_user_md5 AS u USING(user_id) - WHERE FIND_IN_SET(a.flags, 'public') AND peremption >= NOW()"); + WHERE FIND_IN_SET(a.flags, 'public') AND peremption >= NOW() AND a.asso_id = {?}", + $globals->asso('id')); } $page->assign('asso', $globals->asso()); $page->assign('rss', $rss); diff --git a/templates/payment/index.tpl b/templates/payment/index.tpl index ae4e189..25c5bec 100644 --- a/templates/payment/index.tpl +++ b/templates/payment/index.tpl @@ -34,8 +34,8 @@ {$pay->text} - Montant (euros) - {$montant} + Montant + {$montant} € {if $comment} @@ -116,10 +116,14 @@ function payment_submit(form) Transaction + {if $asso} + {$pay->text} + {else} + {/if} {if $pay->url}
plus d'informations @@ -135,8 +139,8 @@ function payment_submit(form) - Montant (euros) - + Montant + € Commentaire diff --git a/templates/payment/xnet.tpl b/templates/payment/xnet.tpl new file mode 100644 index 0000000..33dcf40 --- /dev/null +++ b/templates/payment/xnet.tpl @@ -0,0 +1,146 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2006 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +

{$asso.nom} : Gestion des télépaiements

+ +

+Voici la liste des paiements en ligne possible pour le groupe {$asso.nom} +

+ +{foreach from=$titres item=p} + +
+{icon name=money title="Télépaiement"}{$p.text} + +{if $event[$p.id]} +{assign var='ev' value=$event[$p.id]} +

+ {if $p.url} + Plus d'informations sur ce télépaiement sont disponibles sur cette page.
+ {/if} + {if $ev.eid} + Ce paiement est associé à l'événement {$ev.title}.
+ {if $ev.ins} + Tu es inscrit à cet événements. + {if $ev.topay > $ev.paid} + + Tu dois encore payer {math equation="a-b" a=$ev.topay b=$ev.paid}€ + + {elseif $ev.topay eq $ev.paid} + Tu as déjà réglé l'intégralité de ton inscription ({$ev.topay}€) + {else} + Tu as réglé {$ev.paid}€ alors que tu n'en devais que {$ev.topay}€ + {/if} + {else} + Tu peux t'inscire à cet événement. + {/if} + {else} + {if !$ev.paid} + Tu n'as actuellement rien payé sur ce télépaiement + {else} + Tu as déjà payé {$ev.paid}€. + {/if} + {/if} +

+{/if} + +{if $is_admin && $trans[$p.id]} +

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

+ + + + + + + + {assign var="somme" value=0} + {foreach from=$trans[$p.id] item=p name=people} + {if $p.nom neq "somme totale"} + + + + + + + + {elseif $smarty.foreach.people.first} + + + + {else} + + + + + {/if} + {/foreach} +
+ {if $order eq 'timestamp'} + + + {else} + + {/if}Date + + {if $order eq 'nom'} + + + {else} + {/if} + NOM Prénom + + {if $order eq 'promo'} + + + {else} + + {/if}Promo + + {if $order eq 'montant'} + + + {else} + + {/if}Montant +
{$p.date|date_format:"%d/%m/%y"} + + {$p.nom|strtoupper} {$p.prenom} + + + {icon name=email title="mail"} + {$p.promo}{$p.montant}
Personne n'a encore payé pour ce télépaiement
Total {$p.montant}
+{elseif $is_admin} +Aucun versement n'a actuellement été réalisé sur ce télépaiement +{else} +Tu n'as pas payé pour ce télépaiement +{/if} +
+ +{foreachelse} + +

+Pas de télépaiement en cours ... +

+ +{/foreach} + +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/xnet/groupe/annuaire.tpl b/templates/xnet/groupe/annuaire.tpl index f2dcd17..2ee139c 100644 --- a/templates/xnet/groupe/annuaire.tpl +++ b/templates/xnet/groupe/annuaire.tpl @@ -97,9 +97,9 @@ Tu peux {if $m.admin}{/if} {if $m.inscrit} - + {elseif $m.x} - + {/if} {if $m.femme}•{/if}{$m.prenom} {$m.nom|strtoupper} {if $m.x}{/if} diff --git a/templates/xnet/groupe/telepaiement.tpl b/templates/xnet/groupe/telepaiement.tpl deleted file mode 100644 index 3c97e45..0000000 --- a/templates/xnet/groupe/telepaiement.tpl +++ /dev/null @@ -1,76 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2006 Polytechnique.org *} -{* http://opensource.polytechnique.org/ *} -{* *} -{* This program is free software; you can redistribute it and/or modify *} -{* it under the terms of the GNU General Public License as published by *} -{* the Free Software Foundation; either version 2 of the License, or *} -{* (at your option) any later version. *} -{* *} -{* This program is distributed in the hope that it will be useful, *} -{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} -{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} -{* GNU General Public License for more details. *} -{* *} -{* You should have received a copy of the GNU General Public License *} -{* along with this program; if not, write to the Free Software *} -{* Foundation, Inc., *} -{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} -{* *} -{**************************************************************************} - -

{$asso.nom} : Gestion des télépaiements

- -

-Voici la liste des paiements en ligne possible pour le groupe {$asso.nom} -

- -{foreach from=$titres item=p} - -
-

-{$p.text} -

- -{if $trans[$p.id]} - - - - - - - - - - - {assign var="somme" value=0} - {foreach from=$trans[$p.id] item=p} - - {if $p.nom neq "somme totale"} - - - - - {else} - - - {/if} - - {/foreach} -
{$p.text} : détails pour les administrateurs
[{if $order eq 'timestamp'}{else}{/if}Date{if $order eq 'timestamp'}{/if}][{if $order eq 'nom'}{else}{/if}Prénom NOM{if $order eq 'nom'}{/if}][{if $order eq 'promo'}{else}{/if}Promo{if $order eq 'promo'}{/if}][{if $order eq 'montant'}{else}{/if}Montant{if $order eq 'montant'}{/if}]
{$p.date|date_format:"%d/%m/%y"} - {$p.prenom} {$p.nom} - {icon name=user_suit title="fiche"} - {icon name=email title="mail"} - X {$p.promo}{$p.montant}Total {$p.montant}
-{/if} - -{foreachelse} - -

-Pas de télépaiement en cours ... -

- -{/foreach} - -{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/xnetevents/admin.tpl b/templates/xnetevents/admin.tpl index 4177566..9b88393 100644 --- a/templates/xnetevents/admin.tpl +++ b/templates/xnetevents/admin.tpl @@ -68,7 +68,7 @@ function remplitAuto(mail) { Ils ont payé mais ont oublié de s'inscrire :

- +
@@ -76,7 +76,7 @@ Ils ont pay {iterate from=$oubliinscription item=m} - + diff --git a/templates/xnetevents/subscribe.tpl b/templates/xnetevents/subscribe.tpl index ded6c03..a421033 100644 --- a/templates/xnetevents/subscribe.tpl +++ b/templates/xnetevents/subscribe.tpl @@ -105,14 +105,18 @@
Prénom NOM PromoMontant
{$m.prenom} {$m.nom} diff --git a/templates/xnetevents/index.tpl b/templates/xnetevents/index.tpl index 0daa0c1..aed7bd2 100644 --- a/templates/xnetevents/index.tpl +++ b/templates/xnetevents/index.tpl @@ -32,13 +32,13 @@ {if $updated}

La modification de l'inscription a été prise en compte ! - {if $updated.topay} -
N'oublie pas de payer {$updated.topay|replace:'.':','} € + {if $updated.topay > $updated.paid} +
N'oublie pas de payer {math equation="a-b" a=$updated.topay b=$updated.paid} € {if $updated.paid > 0} (tu as déjà payé {$updated.paid|replace:'.':','} €) {/if} {if $updated.paiement_id} - [
+ [ Payer en ligne] {/if} {/if} @@ -155,14 +155,18 @@ {if $e.topay} - Tu dois payer {$e.topay|replace:'.':','} € - {if $e.paid > 0} - (tu as déjà payé {$e.paid|replace:'.':','} €) - {/if} - {if $e.paiement_id} - [ + {if !$e.paid} + Tu dois payer {$e.topay|replace:'.':','} €. + {elseif $e.paid < $e.topay} + Tu dois encore payer {math equation="a-b" a=$e.topay b=$e.paid|replace:'.':','} € + (tu as déjà payé {$e.paid|replace:'.':','} €) + {else} + Tu as déjà payé {$e.paid|replace:'.':','} € pour ton inscription. + {/if} + {if $e.paiement_id && $e.paid < $e.topay} + [ Payer en ligne] - {/if} + {/if} {/if}

{if $event.topay} - Tu dois payer {$event.topay|replace:'.':','} € - {if $event.paid > 0} - (tu as déjà payé {$event.paid|replace:'.':','} €) - {/if}. - {if $event.paiement_id} - [ + {if !$event.paid} + Tu dois payer {$event.topay|replace:'.':','} €. + {elseif $event.paid < $event.topay} + Tu dois encore payer {math equation="a-b" a=$event.topay b=$event.paid|replace:'.':','} € + (tu as déjà payé {$event.paid|replace:'.':','} €) + {else} + Tu as déjà payé {$event.paid|replace:'.':','} € pour ton inscription. + {/if} + {if $event.paiement_id && $event.paid < $event.topay} + [ Payer en ligne] - {/if} + {/if} {else} Rien à payer -- 2.1.4