diff --git a/ChangeLog b/ChangeLog
index 90b6922d60b..22a2884e5fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,9 @@ Fix: Page load not ending when large number of thirdparies. We
combo feature that is root cause of problem.
Fix: [ bug #1231 ] PDF always generated in interventions
Fix: Be sure there is no duplicate default rib.
+Fix: Enable extrafields for customer order, proposal and invoice lines. This feature
+ was developed for 3.5 but was disabled (hidden) because of a bug not possible to
+ fix enough quickly for 3.5.0 release.
***** ChangeLog for 3.5 compared to 3.4.* *****
For users:
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index ef37fa534bd..48cd8531a69 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -665,7 +665,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
//Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
+ $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline,$predef);
//Unset extrafield
if (is_array($extralabelsline))
{
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 4c400f37a7f..7a5b74165bb 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -599,7 +599,7 @@ else if ($action == 'addline' && $user->rights->commande->creer)
//Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
+ $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline,$predef);
//Unset extrafield
if (is_array($extralabelsline))
{
@@ -613,12 +613,12 @@ else if ($action == 'addline' && $user->rights->commande->creer)
if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0))
{
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
- $error = true;
+ $error++;
}
if (empty($idprod) && GETPOST('type') < 0)
{
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
- $error = true;
+ $error++;
}
if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
{
@@ -628,12 +628,12 @@ else if ($action == 'addline' && $user->rights->commande->creer)
if ($qty == '')
{
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
- $error = true;
+ $error++;
}
if (empty($idprod) && empty($product_desc))
{
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
- $error = true;
+ $error++;
}
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod)))
@@ -2484,7 +2484,7 @@ else
}
// Create bill and Classify billed
- // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed"
+ // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed"
if ($object->statut > 0 && ! $object->billed)
{
if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER))
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index a03dddfc515..9a665578c28 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1157,13 +1157,13 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
//Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline);
+ $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline,$predef);
//Unset extrafield
if (is_array($extralabelsline))
{
// Get extra fields
foreach ($extralabelsline as $key => $value) {
- unset($_POST["options_".$key]);
+ unset($_POST["options_".$key.$predef]);
}
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 8f45a53e059..2581151a649 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2236,13 +2236,14 @@ abstract class CommonObject
/**
* Function to show lines of extrafields with output datas
*
- * @param object $extrafields extrafield Object
+ * @param object $extrafields Extrafield Object
* @param string $mode Show output (view) or input (edit) for extrafield
- * @param array $params optionnal parameters
+ * @param array $params Optionnal parameters
+ * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
*
* @return string
*/
- function showOptionals($extrafields,$mode='view',$params=0)
+ function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='')
{
global $_POST;
@@ -2310,7 +2311,7 @@ abstract class CommonObject
$out .= $extrafields->showOutputField($key,$value);
break;
case "edit":
- $out .= $extrafields->showInputField($key,$value);
+ $out .= $extrafields->showInputField($key,$value,'',$keyprefix);
break;
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 8227bfbc0e7..399a87d30af 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -571,14 +571,15 @@ 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 $value Value to show (for date type it must be in timestamp format)
- * @param string $moreparam To add more parametes on html input tag
- * @return void
+ * @param string $key Key of attribute
+ * @param string $value Value to show (for date type it must be in timestamp format)
+ * @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)
+ * @return void
*/
- function showInputField($key,$value,$moreparam='')
+ function showInputField($key,$value,$moreparam='',$keyprefix='')
{
global $conf,$langs;
@@ -620,23 +621,23 @@ class ExtraFields
if(!$required && $value == '')
$value = '-1';
- $out = $formstat->select_date($value, 'options_'.$key, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
- //$out='';
+ $out = $formstat->select_date($value, 'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
+ // TODO Missing to add $moreparam
}
elseif (in_array($type,array('int')))
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
- $out='';
+ $out='';
}
elseif ($type == 'varchar')
{
- $out='';
+ $out='';
}
elseif ($type == 'text')
{
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor('options_'.$key,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100);
+ $doleditor=new DolEditor('options_'.$key.$keyprefix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100);
$out=$doleditor->Create(1);
}
elseif ($type == 'boolean')
@@ -647,30 +648,30 @@ class ExtraFields
} else {
$checked=' value="1" ';
}
- $out='';
+ $out='';
}
elseif ($type == 'mail')
{
- $out='';
+ $out='';
}
elseif ($type == 'phone')
{
- $out='';
+ $out='';
}
elseif ($type == 'price')
{
- $out=' '.$langs->getCurrencySymbol($conf->currency);
+ $out=' '.$langs->getCurrencySymbol($conf->currency);
}
elseif ($type == 'double')
{
if (!empty($value)) {
$value=price($value);
}
- $out=' ';
+ $out=' ';
}
elseif ($type == 'select')
{
- $out='