';
}
}
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 21c4e24caa8..25cd3a251f5 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -223,7 +223,8 @@ if ($action == 'valid')
if ($action == 'set_thirdparty')
{
- $object->setValueFrom('facture',$id,'fk_soc',$socid);
+ $object->fetch($id);
+ $object->setValueFrom('fk_soc',$socid);
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id);
exit;
diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php
index 3f4c3d07560..954067d37ee 100644
--- a/htdocs/core/ajax/saveinplace.php
+++ b/htdocs/core/ajax/saveinplace.php
@@ -51,30 +51,30 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
$fk_element = GETPOST('fk_element');
$value = GETPOST('value');
$type = GETPOST('type');
-
+
$format='text';
$return=array();
$error=0;
-
+
if (preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
-
+
if ($element == 'fichinter') $element = 'ficheinter';
-
+
if ($user->rights->$element->creer || $user->rights->$element->write)
{
$object = new GenericObject($db);
-
+
// Clean parameters
$newvalue = trim($value);
-
+
if ($type == 'numeric')
{
$newvalue = price2num($newvalue);
-
+
// Check parameters
if (! is_numeric($newvalue))
{
@@ -92,7 +92,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
{
$methodname = 'load_cache_'.GETPOST('method');
$cachename = 'cache_'.GETPOST('method');
-
+
$form = new Form($db);
$ret = $form->$methodname();
if ($ret > 0)
@@ -101,15 +101,15 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
$value = $cache[$newvalue];
}
}
-
+
if (! $error)
{
- $ret=$object->setValueFrom($table_element, $fk_element, $field, $newvalue, $format);
+ $ret=$object->setValueFrom($field, $newvalue, $table_element, $fk_element, $format);
if ($ret > 0)
{
if ($type == 'numeric') $value = price($newvalue);
else if ($type == 'textarea') $value = dol_nl2br($newvalue);
-
+
$return['value'] = $value;
}
else
@@ -117,7 +117,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
$return['error'] = $object->error;
}
}
-
+
echo json_encode($return);
}
else
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 22f5a1ae705..17a18a006fa 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -618,17 +618,20 @@ abstract class CommonObject
/**
* Update a specific field from an object
*
- * @param string $table Table element or element line
- * @param int $id Object id
* @param string $field Field to update
* @param mixte $value New value
- * @param string $format Data format
+ * @param string $table To force other table element or element line
+ * @param int $id To force other object id
+ * @param string $format Data format ('text' by default, 'date')
* @return int <0 if KO, >0 if OK
*/
- function setValueFrom($table, $id, $field, $value, $format='text')
+ function setValueFrom($field, $value, $table='', $id='', $format='text')
{
global $conf;
+ if (empty($table)) $table=$this->table_element;
+ if (empty($id)) $id=$this->id;
+
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 1d7f3a89009..08c5afd4b85 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -74,7 +74,7 @@ class Form
* @param string $paramkey Key of parameter for Url (unique if there is several parameter to show). In most cases "id".
* @param string $paramvalue Value of parameter for Url
* @param boolean $perm Permission to allow button to edit parameter
- * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day', ...)
+ * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day' or 'datepicker', ...)
* @return string HTML edit field
* TODO no GET or POST in class file, use a param
*/
@@ -96,9 +96,9 @@ class Form
* @param string $text Text of label (not used in this function)
* @param string $htmlname Name of select field
* @param string $preselected Value to show/edit
- * @param string $paramkey Key of parameter (unique if there is several parameter to show)
+ * @param string $paramkey Key of parameter (unique if there is several parameter to show). In most cases "id".
* @param boolean $perm Permission to allow button to edit parameter
- * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day', ...)
+ * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day' or 'datepicker', ...)
* @param string $editvalue Use this value instead $preselected
* @return string HTML edit field
* TODO no GET or POST in class file, use a param
@@ -124,20 +124,20 @@ class Form
{
$ret.='';
}
- else if ($typeofdata == 'day')
+ else if ($typeofdata == 'day' || $typeofdata == 'datepicker')
{
$html=new Form($db);
$ret.=$html->form_date($_SERVER['PHP_SELF'].($paramkey?'?'.$paramkey.'='.$paramvalue:''),$preselected,$htmlname);
}
$ret.='';
- if ($typeofdata != 'day') $ret.='