*
* This program is free software; you can redistribute it and/or modify
@@ -89,7 +89,7 @@ class html_cerfafr extends ModeleDon
$outputlangs->load("donations");
$currency = !empty($currency) ? $currency : $conf->currency;
-
+
if (! empty($conf->don->dir_output))
{
// Definition of the object don (for upward compatibility)
@@ -134,21 +134,21 @@ class html_cerfafr extends ModeleDon
$paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label'];
}
else $paymentmode = '';
-
- if ($don->modepaiementid==7){
+
+ if ($don->modepaymentcode=='CHQ'){
$ModePaiement = '| Remise d\'espèces | Chèque | Virement, prélèvement, carte bancaire | ';
}
- else if ($don->modepaiementid==4){
+ else if ($don->modepaymentcode=='LIQ'){
$ModePaiement = ' Remise d\'espèces | Chèque | Virement, prélèvement, carte bancaire | ';
}
- else if ($don->modepaiementid==2 || $don->modepaiementid==3 || $don->modepaiementid==6){
+ else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){
$ModePaiement = ' Remise d\'espèces | Chèque | Virement, prélèvement, carte bancaire | ';
- }
- else
+ }
+ else
{
$ModePaiement = ' Remise d\'espèces | Chèque | Virement, prélèvement, carte bancaire | ';
}
-
+
/*
if (empty($don->societe))
{
@@ -159,14 +159,14 @@ class html_cerfafr extends ModeleDon
$CodeDon = ' 200 du CGI | 238 bis du CGI | 885-0 V bis A du CGI | ';
}
*/
-
+
// Define contents
$donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html";
$form = implode('', file($donmodel));
$form = str_replace('__REF__',$don->id,$form);
$form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form);
//$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
- $form = str_replace('__AMOUNT__',$don->amount,$form);
+ $form = str_replace('__AMOUNT__', price($don->amount), $form);
$form = str_replace('__AMOUNTLETTERS__',chiffre_en_lettre($don->amount),$form);
$form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form);
$form = str_replace('__CURRENCYCODE__',$conf->currency,$form);
@@ -183,7 +183,6 @@ class html_cerfafr extends ModeleDon
$form = str_replace('__DONATOR_ZIP__',$don->zip,$form);
$form = str_replace('__DONATOR_TOWN__',$don->town,$form);
$form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form);
- $form = str_replace('__ModePaiement__', $ModePaiement,$form);
$form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form);
$form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form);
$form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form);
@@ -204,6 +203,8 @@ class html_cerfafr extends ModeleDon
$form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form);
$form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form);
+ $form = str_replace('__ModePaiement__', $ModePaiement,$form);
+
$frencharticle='';
if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)';
$form = str_replace('__FrenchArticle__',$frencharticle,$form);
@@ -260,7 +261,7 @@ class html_cerfafr extends ModeleDon
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
-
+
return 1;
}
else
@@ -394,34 +395,34 @@ function chiffre_en_lettre($montant, $devise1='', $devise2='')
if($cent[$i]==1) $trio[$i]='cent';
else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents';
}
-
-
+
+
$chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
$secon_c=$chif2[$dix_c];
if($cent_c==1) $trio_c='cent';
else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents';
-
+
if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1))
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million ';
else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!=''))
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
else
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
-
+
if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1))
$somme = $somme.' mille ';
else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!=''))
$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
else
$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
-
+
$somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1];
-
+
$somme = $somme. ' '. $dev1 .' ' ;
-
+
if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c==''))
return $somme. ' et zéro '. $dev2;
else
return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
-
+
}
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index 75557f4ae45..4bc05f6482c 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -98,20 +98,21 @@ if ($action == 'update')
{
$object->fetch($id);
- $object->firstname = GETPOST("firstname");
- $object->lastname = GETPOST("lastname");
- $object->societe = GETPOST("societe");
- $object->address = GETPOST("address");
- $object->amount = price2num(GETPOST("amount"));
- $object->town = GETPOST("town");
- $object->zip = GETPOST("zipcode");
+ $object->firstname = GETPOST("firstname",'alpha');
+ $object->lastname = GETPOST("lastname",'alpha');
+ $object->societe = GETPOST("societe",'alpha');
+ $object->address = GETPOST("address",'alpha');
+ $object->amount = price2num(GETPOST("amount",'alpha'));
+ $object->town = GETPOST("town",'alpha');
+ $object->zip = GETPOST("zipcode",'alpha');
$object->country_id = GETPOST('country_id', 'int');
- $object->email = GETPOST("email");
+ $object->email = GETPOST("email",'alpha');
$object->date = $donation_date;
- $object->public = GETPOST("public");
- $object->fk_project = GETPOST("fk_project");
- $object->note_private= GETPOST("note_private");
- $object->note_public = GETPOST("note_public");
+ $object->public = GETPOST("public",'alpha');
+ $object->fk_project = GETPOST("fk_project",'alpha');
+ $object->note_private= GETPOST("note_private",'none');
+ $object->note_public = GETPOST("note_public",'none');
+ $object->modepaymentid = GETPOST('modepayment','int');
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@@ -151,20 +152,21 @@ if ($action == 'add')
if (! $error)
{
- $object->firstname = GETPOST("firstname");
- $object->lastname = GETPOST("lastname");
- $object->societe = GETPOST("societe");
- $object->address = GETPOST("address");
- $object->amount = price2num(GETPOST("amount"));
- $object->zip = GETPOST("zipcode");
- $object->town = GETPOST("town");
+ $object->firstname = GETPOST("firstname",'alpha');
+ $object->lastname = GETPOST("lastname",'alpha');
+ $object->societe = GETPOST("societe",'alpha');
+ $object->address = GETPOST("address",'alpha');
+ $object->amount = price2num(GETPOST("amount",'alpha'));
+ $object->zip = GETPOST("zipcode",'alpha');
+ $object->town = GETPOST("town",'alpha');
$object->country_id = GETPOST('country_id', 'int');
- $object->email = GETPOST("email");
+ $object->email = GETPOST("email",'alpha');
$object->date = $donation_date;
- $object->note_private= GETPOST("note_private");
- $object->note_public = GETPOST("note_public");
- $object->public = GETPOST("public");
- $object->fk_project = GETPOST("fk_project");
+ $object->note_private= GETPOST("note_private",'none');
+ $object->note_public = GETPOST("note_public",'none');
+ $object->public = GETPOST("public",'alpha');
+ $object->fk_project = GETPOST("fk_project",'alpha');
+ $object->modepaymentid = GETPOST('modepayment','int');
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@@ -348,6 +350,12 @@ if ($action == 'create')
print "".'| '.$langs->trans("EMail").' | |
';
+ // Payment mode
+ print "| ".$langs->trans("PaymentMode")." | \n";
+ $selected = GETPOST('modepayment','int');
+ $form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
+ print " |
\n";
+
// Public note
print '';
print '| ' . $langs->trans('NotePublic') . ' | ';
@@ -480,14 +488,14 @@ if (! empty($id) && $action == 'edit')
print "
".'| '.$langs->trans("EMail").' | |
';
+ // Payment mode
print "| ".$langs->trans("PaymentMode")." | \n";
-
if ($object->modepaymentid) $selected = $object->modepaymentid;
else $selected = '';
-
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
print " |
\n";
+ // Status
print "".'| '.$langs->trans("Status").' | '.$object->getLibStatut(4).' |
';
// Project
diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php
index df298831c22..a9a431d5320 100644
--- a/htdocs/don/class/don.class.php
+++ b/htdocs/don/class/don.class.php
@@ -69,7 +69,7 @@ class Don extends CommonObject
global $langs;
$this->db = $db;
- $this->modepaiementid = 0;
+ $this->modepaymentid = 0;
$langs->load("donations");
$this->labelstatut[-1]=$langs->trans("Canceled");
@@ -338,7 +338,6 @@ class Don extends CommonObject
$sql.= ", address";
$sql.= ", zip";
$sql.= ", town";
- // $sql.= ", country"; -- Deprecated
$sql.= ", fk_country";
$sql.= ", public";
$sql.= ", fk_projet";
@@ -354,7 +353,7 @@ class Don extends CommonObject
$sql.= " '".$this->db->idate($now)."'";
$sql.= ", ".$conf->entity;
$sql.= ", ".price2num($this->amount);
- $sql.= ", ".($this->modepaiementid?$this->modepaiementid:"null");
+ $sql.= ", ".($this->modepaymentid?$this->modepaymentid:"null");
$sql.= ", '".$this->db->escape($this->firstname)."'";
$sql.= ", '".$this->db->escape($this->lastname)."'";
$sql.= ", '".$this->db->escape($this->societe)."'";
@@ -605,9 +604,10 @@ class Don extends CommonObject
$sql = "SELECT d.rowid, d.datec, d.date_valid, d.tms as datem, d.datedon,";
$sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, ";
- $sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, ";
+ $sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, d.email, d.phone, ";
$sql.= " d.phone_mobile, d.fk_projet as fk_project, d.model_pdf,";
$sql.= " p.ref as project_ref,";
+ $sql.= " cp.libelle as payment_label, cp.code as payment_code,";
$sql.= " c.code as country_code, c.label as country";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_projet";
@@ -657,7 +657,8 @@ class Don extends CommonObject
$this->fk_project = $obj->fk_project;
$this->public = $obj->public;
$this->modepaymentid = $obj->fk_payment;
- $this->modepayment = $obj->libelle;
+ $this->modepaymentcode = $obj->payment_code;
+ $this->modepayment = $obj->payment_label;
$this->paid = $obj->paid;
$this->amount = $obj->amount;
$this->note_private = $obj->note_private;
diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql
index 2120f6a5b2b..a2e39f7039c 100644
--- a/htdocs/install/mysql/tables/llx_don.sql
+++ b/htdocs/install/mysql/tables/llx_don.sql
@@ -29,7 +29,7 @@ create table llx_don
fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate
datedon datetime, -- Date of the donation/promise
amount double(24,8) DEFAULT 0,
- fk_payment integer,
+ fk_payment integer, -- Id of payment mode
paid smallint default 0 NOT NULL,
firstname varchar(50),
lastname varchar(50),