diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 1f3ea7cd46f..7cf90691655 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1104,22 +1104,9 @@ else if ($action == 'down' && $user->rights->propal->creer)
}
else if ($action == 'update_extras')
{
- // Get extra fields
- foreach ($extralabels as $key => $value)
- {
- $key_type = $extrafields->attribute_type[$key];
-
- if (in_array($key_type,array('date','datetime')))
- {
- // Clean parameters
- $value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
- }
- else
- {
- $value_key=GETPOST("options_".$key);
- }
- $object->array_options["options_".$key]=$value_key;
- }
+ // Fill array 'array_options' with data from update form
+ $extralabels=$extrafields->fetch_name_optionals_label('propal');
+ $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
@@ -1875,6 +1862,13 @@ else
print '
| attribute_required[$key])) print ' class="fieldrequired"';
print '>'.$label.' | ';
+
+ // Convert date into timestamp format
+ 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"]):$object->array_options['options_'.$key];
+ }
+
if ($action == 'edit_extras' && $user->rights->propal->creer)
{
print $extrafields->showInputField($key,$value);
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 233ebaa4f32..935d475bb9e 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1738,14 +1738,10 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture-
if ($action == 'update_extras')
{
- // Get extra fields
- foreach($_POST as $key => $value)
- {
- if (preg_match("/^options_/",$key))
- {
- $object->array_options[$key]=$_POST[$key];
- }
- }
+ // Fill array 'array_options' with data from add form
+ $extralabels=$extrafields->fetch_name_optionals_label('facture');
+ $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('invoicedao'));
@@ -3125,7 +3121,6 @@ else if ($id > 0 || ! empty($ref))
print '';
}
-
foreach($extrafields->attribute_label as $key=>$label)
{
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
@@ -3138,6 +3133,12 @@ else if ($id > 0 || ! empty($ref))
print ' |
| attribute_required[$key])) print ' class="fieldrequired"';
print '>'.$label.' | ';
+ // Convert date into timestamp format
+ 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"]):$object->array_options['options_'.$key];
+ }
+
if ($action == 'edit_extras' && $user->rights->facture->creer)
{
print $extrafields->showInputField($key,$value);
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index e28f1a12443..0972d93f26a 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -169,22 +169,9 @@ if (empty($reshook))
$object->commercial_id = GETPOST('commercial_id');
$object->default_lang = GETPOST('default_lang');
- // Get extra fields
- foreach ($extralabels as $key => $value)
- {
- $key_type = $extrafields->attribute_type[$key];
-
- if (in_array($key_type,array('date','datetime')))
- {
- // Clean parameters
- $value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
- }
- else
- {
- $value_key=GETPOST("options_".$key);
- }
- $object->array_options["options_".$key]=$value_key;
- }
+ // Fill array 'array_options' with data from add form
+ $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+
if (GETPOST('deletephoto')) $object->logo = '';
else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
|