FIX Payment mode not correctly set in donation and document

This commit is contained in:
Laurent Destailleur 2018-03-02 12:32:49 +01:00
parent a01287b211
commit 8d11f1efa1
4 changed files with 63 additions and 53 deletions

View File

@ -135,13 +135,13 @@ class html_cerfafr extends ModeleDon
} }
else $paymentmode = ''; else $paymentmode = '';
if ($don->modepaiementid==7){ if ($don->modepaymentcode=='CHQ'){
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
} }
else if ($don->modepaiementid==4){ else if ($don->modepaymentcode=='LIQ'){
$ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>'; $ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
} }
else if ($don->modepaiementid==2 || $don->modepaiementid==3 || $don->modepaiementid==6){ else if ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>'; $ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>';
} }
else else
@ -166,7 +166,7 @@ class html_cerfafr extends ModeleDon
$form = str_replace('__REF__',$don->id,$form); $form = str_replace('__REF__',$don->id,$form);
$form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$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('__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('__AMOUNTLETTERS__',chiffre_en_lettre($don->amount),$form);
$form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form); $form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form);
$form = str_replace('__CURRENCYCODE__',$conf->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_ZIP__',$don->zip,$form);
$form = str_replace('__DONATOR_TOWN__',$don->town,$form); $form = str_replace('__DONATOR_TOWN__',$don->town,$form);
$form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$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('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form);
$form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form); $form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form);
$form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$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('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form);
$form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form); $form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form);
$form = str_replace('__ModePaiement__', $ModePaiement,$form);
$frencharticle=''; $frencharticle='';
if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>'; if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
$form = str_replace('__FrenchArticle__',$frencharticle,$form); $form = str_replace('__FrenchArticle__',$frencharticle,$form);

View File

@ -98,20 +98,21 @@ if ($action == 'update')
{ {
$object->fetch($id); $object->fetch($id);
$object->firstname = GETPOST("firstname"); $object->firstname = GETPOST("firstname",'alpha');
$object->lastname = GETPOST("lastname"); $object->lastname = GETPOST("lastname",'alpha');
$object->societe = GETPOST("societe"); $object->societe = GETPOST("societe",'alpha');
$object->address = GETPOST("address"); $object->address = GETPOST("address",'alpha');
$object->amount = price2num(GETPOST("amount")); $object->amount = price2num(GETPOST("amount",'alpha'));
$object->town = GETPOST("town"); $object->town = GETPOST("town",'alpha');
$object->zip = GETPOST("zipcode"); $object->zip = GETPOST("zipcode",'alpha');
$object->country_id = GETPOST('country_id', 'int'); $object->country_id = GETPOST('country_id', 'int');
$object->email = GETPOST("email"); $object->email = GETPOST("email",'alpha');
$object->date = $donation_date; $object->date = $donation_date;
$object->public = GETPOST("public"); $object->public = GETPOST("public",'alpha');
$object->fk_project = GETPOST("fk_project"); $object->fk_project = GETPOST("fk_project",'alpha');
$object->note_private= GETPOST("note_private"); $object->note_private= GETPOST("note_private",'none');
$object->note_public = GETPOST("note_public"); $object->note_public = GETPOST("note_public",'none');
$object->modepaymentid = GETPOST('modepayment','int');
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -151,20 +152,21 @@ if ($action == 'add')
if (! $error) if (! $error)
{ {
$object->firstname = GETPOST("firstname"); $object->firstname = GETPOST("firstname",'alpha');
$object->lastname = GETPOST("lastname"); $object->lastname = GETPOST("lastname",'alpha');
$object->societe = GETPOST("societe"); $object->societe = GETPOST("societe",'alpha');
$object->address = GETPOST("address"); $object->address = GETPOST("address",'alpha');
$object->amount = price2num(GETPOST("amount")); $object->amount = price2num(GETPOST("amount",'alpha'));
$object->zip = GETPOST("zipcode"); $object->zip = GETPOST("zipcode",'alpha');
$object->town = GETPOST("town"); $object->town = GETPOST("town",'alpha');
$object->country_id = GETPOST('country_id', 'int'); $object->country_id = GETPOST('country_id', 'int');
$object->email = GETPOST("email"); $object->email = GETPOST("email",'alpha');
$object->date = $donation_date; $object->date = $donation_date;
$object->note_private= GETPOST("note_private"); $object->note_private= GETPOST("note_private",'none');
$object->note_public = GETPOST("note_public"); $object->note_public = GETPOST("note_public",'none');
$object->public = GETPOST("public"); $object->public = GETPOST("public",'alpha');
$object->fk_project = GETPOST("fk_project"); $object->fk_project = GETPOST("fk_project",'alpha');
$object->modepaymentid = GETPOST('modepayment','int');
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -348,6 +350,12 @@ if ($action == 'create')
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" value="'.dol_escape_htmltag(GETPOST("email")).'" class="maxwidth200"></td></tr>'; print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" value="'.dol_escape_htmltag(GETPOST("email")).'" class="maxwidth200"></td></tr>';
// Payment mode
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
$selected = GETPOST('modepayment','int');
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
print "</td></tr>\n";
// Public note // Public note
print '<tr>'; print '<tr>';
print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>'; print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>';
@ -480,14 +488,14 @@ if (! empty($id) && $action == 'edit')
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" class="maxwidth200" value="'.dol_escape_htmltag($object->email).'"></td></tr>'; print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" class="maxwidth200" value="'.dol_escape_htmltag($object->email).'"></td></tr>';
// Payment mode
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n"; print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
if ($object->modepaymentid) $selected = $object->modepaymentid; if ($object->modepaymentid) $selected = $object->modepaymentid;
else $selected = ''; else $selected = '';
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1); $form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
print "</td></tr>\n"; print "</td></tr>\n";
// Status
print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>'; print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Project // Project

View File

@ -69,7 +69,7 @@ class Don extends CommonObject
global $langs; global $langs;
$this->db = $db; $this->db = $db;
$this->modepaiementid = 0; $this->modepaymentid = 0;
$langs->load("donations"); $langs->load("donations");
$this->labelstatut[-1]=$langs->trans("Canceled"); $this->labelstatut[-1]=$langs->trans("Canceled");
@ -338,7 +338,6 @@ class Don extends CommonObject
$sql.= ", address"; $sql.= ", address";
$sql.= ", zip"; $sql.= ", zip";
$sql.= ", town"; $sql.= ", town";
// $sql.= ", country"; -- Deprecated
$sql.= ", fk_country"; $sql.= ", fk_country";
$sql.= ", public"; $sql.= ", public";
$sql.= ", fk_projet"; $sql.= ", fk_projet";
@ -354,7 +353,7 @@ class Don extends CommonObject
$sql.= " '".$this->db->idate($now)."'"; $sql.= " '".$this->db->idate($now)."'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ", ".price2num($this->amount); $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->firstname)."'";
$sql.= ", '".$this->db->escape($this->lastname)."'"; $sql.= ", '".$this->db->escape($this->lastname)."'";
$sql.= ", '".$this->db->escape($this->societe)."'"; $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 = "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.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.= " d.phone_mobile, d.fk_projet as fk_project, d.model_pdf,";
$sql.= " p.ref as project_ref,"; $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.= " c.code as country_code, c.label as country";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_projet"; $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->fk_project = $obj->fk_project;
$this->public = $obj->public; $this->public = $obj->public;
$this->modepaymentid = $obj->fk_payment; $this->modepaymentid = $obj->fk_payment;
$this->modepayment = $obj->libelle; $this->modepaymentcode = $obj->payment_code;
$this->modepayment = $obj->payment_label;
$this->paid = $obj->paid; $this->paid = $obj->paid;
$this->amount = $obj->amount; $this->amount = $obj->amount;
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;

View File

@ -29,7 +29,7 @@ create table llx_don
fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate
datedon datetime, -- Date of the donation/promise datedon datetime, -- Date of the donation/promise
amount double(24,8) DEFAULT 0, amount double(24,8) DEFAULT 0,
fk_payment integer, fk_payment integer, -- Id of payment mode
paid smallint default 0 NOT NULL, paid smallint default 0 NOT NULL,
firstname varchar(50), firstname varchar(50),
lastname varchar(50), lastname varchar(50),