From d82502beb4208647657315f78d4ddf67878a1a03 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Feb 2009 00:42:22 +0000 Subject: [PATCH] Support paybox payment on members --- ChangeLog | 1 + htdocs/adherents/adherent.class.php | 12 ++-- htdocs/admin/paybox.php | 37 ++++++++---- htdocs/langs/en_US/members.lang | 1 + htdocs/langs/en_US/paybox.lang | 1 + htdocs/langs/fr_FR/members.lang | 1 + htdocs/langs/fr_FR/paybox.lang | 1 + htdocs/paybox/paybox.lib.php | 2 + htdocs/public/paybox/newpayment.php | 88 +++++++++++++++++++++++++++-- 9 files changed, 123 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26d8700b182..813ffc9495c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,7 @@ For users: contract status. - New: Add a first version of a module for Paybox. - New: Can add contact to suppliers orders. +- New: Changements to support the external BitTorrent module. - Fix: Handle correctly the comment in status changing of supplier orders. - Fix: Author, title and topic are correctly encoded in PDF. - Fix: Now HTML output is always UTF8, this solve bad PDF encoding on old users. diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 14a58fee46c..2ce0df03496 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -785,11 +785,12 @@ class Adherent extends CommonObject /** - * \brief Fonction qui recupere l'adherent en donnant son rowid - * \param rowid - * \return int <0 si KO, >0 si OK + * \brief Load member from database + * \param rowid id of object to load + * \param ref Ref of invoice + * \return int >0 if OK, <0 if KO */ - function fetch($rowid) + function fetch($rowid,$ref='') { global $langs; @@ -809,7 +810,8 @@ class Adherent extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; $sql.= " WHERE d.fk_adherent_type = t.rowid"; - $sql.= " AND d.rowid = ".$rowid; + if ($ref) $sql.= " AND d.rowid='".$ref."'"; + else $sql.= " AND d.rowid=".$rowid; dol_syslog("Adherent::fetch sql=".$sql); $resql=$this->db->query($sql); diff --git a/htdocs/admin/paybox.php b/htdocs/admin/paybox.php index 5fb4261e317..e0e63642a2b 100644 --- a/htdocs/admin/paybox.php +++ b/htdocs/admin/paybox.php @@ -162,19 +162,34 @@ $firstpart=$dolibarr_main_url_root; $regex=DOL_URL_ROOT.'$'; $firstpart=eregi_replace($regex,'',$firstpart); print '
'; -print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
'; -print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=order&ref=orderref'."
\n"; -print '
'; -print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':
'; -print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=invoice&ref=invoiceref'."
\n"; -//print $langs->trans("SetupPayBoxToHavePaymentCreatedAutomatically",$langs->transnoentitiesnoconv("FeatureNotYetAvailable"))."
\n"; -print '
'; -print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':
'; -print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=contractline&ref=contractlineref'."
\n"; -print '
'; print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':
'; -print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=9.99&tag=yourfreetag'."
\n"; +print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=9.99&tag=your_free_tag'."
\n"; print '
'; +if ($conf->commande->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':
'; + print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=order&ref=order_ref'."
\n"; + print '
'; +} +if ($conf->facture->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':
'; + print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=invoice&ref=invoice_ref'."
\n"; +// print $langs->trans("SetupPayBoxToHavePaymentCreatedAutomatically",$langs->transnoentitiesnoconv("FeatureNotYetAvailable"))."
\n"; + print '
'; +} +if ($conf->contract->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':
'; + print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=contractline&ref=contractline_ref'."
\n"; + print '
'; +} +if ($conf->adherent->enabled) +{ + print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':
'; + print ''.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=membersubscription&ref=member_ref'."
\n"; + print '
'; +} print $langs->trans("YouCanAddTagOnUrl"); $db->close(); diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index f7c81ece1c7..610c03fd42b 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -63,6 +63,7 @@ MembersStatusNotPayedShort=Out of date MembersStatusResiliated=Resiliated members MembersStatusResiliatedShort=Resiliated members NewCotisation=New contribution +PaymentSubscription=New contribution payment EditMember=Edit member SubscriptionEndDate=Subscription's end date NewAttribute=New attribut diff --git a/htdocs/langs/en_US/paybox.lang b/htdocs/langs/en_US/paybox.lang index c8a2cd39583..5ffde5ded94 100644 --- a/htdocs/langs/en_US/paybox.lang +++ b/htdocs/langs/en_US/paybox.lang @@ -18,5 +18,6 @@ ToOfferALinkForOnlinePaymentOnOrder=URL to offer a %s online payment user interf ToOfferALinkForOnlinePaymentOnInvoice=URL to offer a %s online payment user interface for an invoice ToOfferALinkForOnlinePaymentOnContractLine=URL to offer a %s online payment user interface for a contract line ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user interface for a free amount +ToOfferALinkForOnlinePaymentOnMemberSubscriptionURL to offer a %s online payment user interface for a member subscription YouCanAddTagOnUrl=You can also add url parameter &tag=value to any of those URL (required only for free payment) to add your own payment comment tag. SetupPayBoxToHavePaymentCreatedAutomatically=Setup your PayBox with url %s to have payment created automatically when validated by paybox. \ No newline at end of file diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 9e40fa42f6d..4cca02c19d8 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -63,6 +63,7 @@ MembersStatusNotPayedShort=Non à jour MembersStatusResiliated=Adhérents résiliés MembersStatusResiliatedShort=Adhérents résiliés NewCotisation=Nouvelle adhésion +PaymentSubscription=Paiement cotisation EditMember=Édition adhérent SubscriptionEndDate=Date de fin adhésion NewAttribute=Nouvel attribut diff --git a/htdocs/langs/fr_FR/paybox.lang b/htdocs/langs/fr_FR/paybox.lang index 10d49554662..55ca3df10e5 100644 --- a/htdocs/langs/fr_FR/paybox.lang +++ b/htdocs/langs/fr_FR/paybox.lang @@ -18,6 +18,7 @@ ToOfferALinkForOnlinePaymentOnOrder=URL offrant une interface de paiement en lig ToOfferALinkForOnlinePaymentOnInvoice=URL offrant une interface de paiement en ligne %s sur la base du montant d'une facture ToOfferALinkForOnlinePaymentOnContractLine=URL offrant une interface de paiement en ligne %s sur la base du montant d'une ligne de contrat ToOfferALinkForOnlinePaymentOnFreeAmount=URL offrant une interface de paiement en ligne %s pour un montant libre +ToOfferALinkForOnlinePaymentOnMemberSubscription=URL offrant une interface de paiement en ligne %s sur la base d'une cotisation d'adhérent YouCanAddTagOnUrl=Vous pouvez de plus ajouter le paramètre url &tag=value à n'importe quelles de ces URL (obligatoire pour le paiement libre uniquement) pour ajouter votre propre "code commentaire" du paiement. SetupPayBoxToHavePaymentCreatedAutomatically=Configurez votre url PayBox à %s pour avoir le paiement créé automatiquement si validé. \ No newline at end of file diff --git a/htdocs/paybox/paybox.lib.php b/htdocs/paybox/paybox.lib.php index 6a1c597174c..cda76524cfc 100644 --- a/htdocs/paybox/paybox.lib.php +++ b/htdocs/paybox/paybox.lib.php @@ -236,6 +236,8 @@ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG) */ function html_print_footer($fromcompany,$langs) { + global $conf; + // Juridical status $ligne1=""; if ($fromcompany->forme_juridique_code) diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 543fbb57901..334c52168c3 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -150,6 +150,49 @@ $found=false; $var=false; + +// Free payment +if (is_numeric($_REQUEST["amount"])) +{ + $found=true; + $tag=$_REQUEST["tag"]; + $newtag=$tag; + + // Creditor + $var=!$var; + print ''.$langs->trans("Creditor"); + print ''.$creditor.''."\n"; + + // Amount + $var=!$var; + print ''.$langs->trans("Amount"); + if (empty($amount)) print ' ('.$langs->trans("ToComplete").')'; + print ''; + if (empty($amount) || ! is_numeric($amount)) print ''; + else { + print ''.price($amount).''; + print ''; + } + print ' '.$langs->trans("Currency".$conf->monnaie).''; + print ''; + print ''."\n"; + + // Tag + $var=!$var; + print ''.$langs->trans("PaymentCode"); + print ''.$newtag.''; + print ''; + print ''; + print ''."\n"; + + // EMail + $var=!$var; + print ''.$langs->trans("YourEMail"); + print ' ('.$langs->trans("ToComplete").')'; + print ''."\n"; +} + + // Payment on customer order if ($_REQUEST["amount"] == 'order') { @@ -457,18 +500,51 @@ if ($_REQUEST["amount"] == 'contractline') } -// Free payment -if (is_numeric($_REQUEST["amount"])) +// Payment on member subscription +if ($_REQUEST["amount"] == 'membersubscription') { $found=true; - $tag=$_REQUEST["tag"]; - $newtag=$tag; + $langs->load("members"); + + require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); + require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php"); + + $member=new Adherent($db); + $result=$member->fetch('',$_REQUEST["ref"]); + if ($result < 0) + { + $mesg=$member->error; + } + else + { + $subscription=new Cotisation($db); + //$result=$subscription->fetch(); + } + + $amount=$subscription->total_ttc; + + $newtag='MID='.$member->id.'.M='.strtr($member->fullname,"-"," "); + if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $newtag.='.TAG='.$_REQUEST["tag"]; } + $newtag=dol_string_unaccent($newtag); // Creditor $var=!$var; print ''.$langs->trans("Creditor"); print ''.$creditor.''."\n"; + // Debitor + $var=!$var; + print ''.$langs->trans("Member"); + print ''.$member->fullname.''; + + // Object + $var=!$var; + $text=''.$langs->trans("PaymentSubscription").''; + print ''.$langs->trans("Designation"); + print ''.$text; + print ''; + print ''."\n"; + // Amount $var=!$var; print ''.$langs->trans("Amount"); @@ -499,13 +575,15 @@ if (is_numeric($_REQUEST["amount"])) } + + if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); if ($mesg) print '
'.$mesg.'
'; if ($found) { - print '
'; + print '
'; //print ''.$langs->trans("YouWillBeRedirectedOnPayBox").'...'; }