Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into develop-api

This commit is contained in:
Neil Orley 2017-10-04 16:51:22 +02:00
commit 0202f8d488
3 changed files with 21 additions and 17 deletions

View File

@ -308,7 +308,7 @@ abstract class CommonObject
* @var CommonObjectLine[] * @var CommonObjectLine[]
*/ */
public $lines; public $lines;
/** /**
* @var mixed Contains comments * @var mixed Contains comments
* @see fetchComments() * @see fetchComments()
@ -4644,13 +4644,19 @@ abstract class CommonObject
{ {
$out .= '<tr '.$class.$csstyle.' class="'.$this->element.'_extras_'.$key.'">'; $out .= '<tr '.$class.$csstyle.' class="'.$this->element.'_extras_'.$key.'">';
} }
// 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'))) 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]); $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); $labeltoshow = $langs->trans($label);
if($extrafields->attribute_required[$key]) if($extrafields->attribute_required[$key])
{ {
$labeltoshow = '<span'.($mode != 'view' ? ' class="fieldrequired"':'').'>'.$labeltoshow.'</span>'; $labeltoshow = '<span'.($mode != 'view' ? ' class="fieldrequired"':'').'>'.$labeltoshow.'</span>';
@ -5294,7 +5300,7 @@ abstract class CommonObject
// TODO... // TODO...
} }
/** /**
* Load comments linked with current task * Load comments linked with current task
* @return boolean 1 if ok * @return boolean 1 if ok
@ -5302,12 +5308,12 @@ abstract class CommonObject
public function fetchComments() public function fetchComments()
{ {
require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
$comment = new Comment($this->db); $comment = new Comment($this->db);
$this->comments = Comment::fetchAllFor($this->element, $this->id); $this->comments = Comment::fetchAllFor($this->element, $this->id);
return 1; return 1;
} }
/** /**
* Return nb comments already posted * Return nb comments already posted
* *

View File

@ -804,7 +804,7 @@ class ExtraFields
* Return HTML string to put an input field into a page * Return HTML string to put an input field into a page
* *
* @param string $key Key of attribute * @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 $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 $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) * @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') elseif ($type == 'price')
{ {
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.price2num($value).'" '.($moreparam?$moreparam:'').'> '.$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.='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
} }
elseif ($type == 'double') 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); $value=price($value);
} }
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '; $out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';

View File

@ -2554,15 +2554,10 @@ class SupplierInvoiceLine extends CommonObjectLine
} }
// Clean parameters // Clean parameters
if (empty($this->tva_tx)) { if (empty($this->remise_percent)) $this->remise_percent = 0;
$this->tva_tx = 0; if (empty($this->tva_tx)) $this->tva_tx = 0;
} if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
if (empty($this->localtax1_tx)) { if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
$this->localtax1_tx = 0;
}
if (empty($this->localtax2_tx)) {
$this->localtax2_tx = 0;
}
$this->db->begin(); $this->db->begin();