diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b8f80c23c15..c0c737b2d2a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -308,7 +308,7 @@ abstract class CommonObject * @var CommonObjectLine[] */ public $lines; - + /** * @var mixed Contains comments * @see fetchComments() @@ -4644,13 +4644,19 @@ abstract class CommonObject { $out .= ''; } - // Convert date into timestamp format + // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->db->jdate($this->array_options['options_'.$key]); } + // Convert float submited string into real php numeric (value in memory must be a php numeric) + if (in_array($extrafields->attribute_type[$key],array('price','double'))) + { + $value = isset($_POST["options_".$key])?price2num($_POST["options_".$key]):$this->array_options['options_'.$key]; + } $labeltoshow = $langs->trans($label); + if($extrafields->attribute_required[$key]) { $labeltoshow = ''.$labeltoshow.''; @@ -5294,7 +5300,7 @@ abstract class CommonObject // TODO... } - + /** * Load comments linked with current task * @return boolean 1 if ok @@ -5302,12 +5308,12 @@ abstract class CommonObject public function fetchComments() { require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php'; - + $comment = new Comment($this->db); $this->comments = Comment::fetchAllFor($this->element, $this->id); return 1; } - + /** * Return nb comments already posted * diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c8779b388c0..b4381349aec 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -804,7 +804,7 @@ class ExtraFields * Return HTML string to put an input field into a page * * @param string $key Key of attribute - * @param string $value Preselected value to show (for date type it must be in timestamp format) + * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) * @param string $moreparam To add more parametes on html input tag * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) @@ -927,11 +927,14 @@ class ExtraFields } elseif ($type == 'price') { - $out=' '.$langs->getCurrencySymbol($conf->currency); + if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. + $value=price($value); + } + $out.=' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { - if (!empty($value)) { + if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } $out=' '; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 72d1d232eca..e813268b8b2 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2554,15 +2554,10 @@ class SupplierInvoiceLine extends CommonObjectLine } // Clean parameters - if (empty($this->tva_tx)) { - $this->tva_tx = 0; - } - if (empty($this->localtax1_tx)) { - $this->localtax1_tx = 0; - } - if (empty($this->localtax2_tx)) { - $this->localtax2_tx = 0; - } + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; $this->db->begin();