diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 0e9deeade80e6..750ddd8337c19 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4969,8 +4969,7 @@ function updateExtraField($key, $trigger, $userused)
* @param string|int $showsize Value for css to define size. May also be a numeric.
* @return string
*/
- function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0)
- {
+ function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss=0){
global $conf,$langs,$form;
if (! is_object($form))
@@ -4979,38 +4978,36 @@ function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keypr
$form=new Form($this->db);
}
- $objectid = $this->id;
-
- $label= $val['label'];
- $type = $val['type'];
- $size = $val['css'];
-
- // Convert var to be able to share same code than showInputField of extrafields
- if (preg_match('/varchar\((\d+)\)/', $type, $reg))
- {
- $type = 'varchar'; // convert varchar(xx) int varchar
- $size = $reg[1];
- }
- elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar
- if (is_array($val['arrayofkeyval'])) $type='select';
- if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link';
-
- //$elementtype=$this->attribute_elementtype[$key]; // seems to not be used
- $default=$val['default'];
- $computed=$val['computed'];
- $unique=$val['unique'];
- $required=$val['required'];
- $param=$val['param'];
- if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
- if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
- {
- $type='link';
- $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
- }
- $langfile=$val['langfile'];
- $list=$val['list'];
- $hidden=(abs($val['visible'])!=1 ? 1 : 0);
- $help=$val['help'];
+ $out='';
+ $type='';
+ $param['options']=array();
+ $keyprefix = $keyprefix.'options_'; // Because we work on extrafields
+ if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){
+ $param['options']=array($reg[1].':'.$reg[2]=>'N');
+ $type ='link';
+ }else if(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)){
+ $param['options']=array($reg[1].':'.$reg[2]=>'N');
+ $type ='link';
+ }else if(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){
+
+ $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N');
+ $type ='sellist';
+ }else {
+ $param['options']=array();
+ $type =$this->fields[$key]['type'];
+ }
+
+ $label=$this->fields[$key]['label'];
+ $size =$this->fields[$key]['size'];
+ //$elementtype=$this->fields[$key]['elementtype']; // Seems not used
+ $default=$this->fields[$key]['default'];
+ $computed=$this->fields[$key]['computed'];
+ //$unique=$this->fields[$key]['unique'];
+ $required=$this->fields[$key]['required'];
+
+ //$langfile=$this->fields[$key]['label'];
+ //$list=$this->fields[$key]['arrayofkeyval'];
+ $hidden=!$this->fields[$key]['visible'];
if ($computed)
{
@@ -5018,54 +5015,44 @@ function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keypr
else return '';
}
- // Use in priorit showsize from parameters, then $val['css'] then autodefine
- if (empty($showsize) && ! empty($val['css']))
- {
- $showsize = $val['css'];
- }
- if (empty($showsize))
+ if (empty($morecss))
{
if ($type == 'date')
{
- //$showsize=10;
- $showsize = 'minwidth100imp';
+ $morecss = 'minwidth100imp';
}
elseif ($type == 'datetime')
{
- //$showsize=19;
- $showsize = 'minwidth200imp';
+ $morecss = 'minwidth200imp';
}
- elseif (in_array($type,array('int','double','price')))
+ elseif (in_array($type,array('int','integer','double','price')))
{
- //$showsize=10;
- $showsize = 'maxwidth75';
+ $morecss = 'maxwidth75';
}
elseif ($type == 'url')
{
- $showsize='minwidth400';
+ $morecss='minwidth400';
}
elseif ($type == 'boolean')
{
- $showsize='';
+ $morecss='';
}
else
{
if (round($size) < 12)
{
- $showsize = 'minwidth100';
+ $morecss = 'minwidth100';
}
else if (round($size) <= 48)
{
- $showsize = 'minwidth200';
+ $morecss = 'minwidth200';
}
else
{
- //$showsize=48;
- $showsize = 'minwidth400';
+ $morecss = 'minwidth400';
}
}
}
- //var_dump($showsize.' '.$size);
if (in_array($type,array('date','datetime')))
{
@@ -5078,33 +5065,47 @@ function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keypr
if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam
- $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1);
+ $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0, 1);
}
elseif (in_array($type,array('int','integer')))
{
$tmp=explode(',',$size);
$newsize=$tmp[0];
- $out='';
+ $out='';
}
elseif (preg_match('/varchar/', $type))
{
- $out='';
+ $out='';
}
elseif (in_array($type, array('mail', 'phone', 'url')))
{
- $out='';
+ $out='';
}
elseif ($type == 'text')
{
- require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,0,ROWS_5,'90%');
- $out=$doleditor->Create(1);
+ if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+ $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,false,ROWS_5,'90%');
+ $out=$doleditor->Create(1);
+ }
+ else
+ {
+ $out='';
+ }
}
elseif ($type == 'html')
{
- require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
- $out=$doleditor->Create(1);
+ if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+ $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
+ $out=$doleditor->Create(1);
+ }
+ else
+ {
+ $out='';
+ }
}
elseif ($type == 'boolean')
{
@@ -5114,21 +5115,21 @@ function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keypr
} else {
$checked=' value="1" ';
}
- $out='';
+ $out='';
}
elseif ($type == 'price')
{
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);
+ $out=' '.$langs->getCurrencySymbol($conf->currency);
}
elseif ($type == 'double')
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value=price($value);
}
- $out=' ';
+ $out=' ';
}
elseif ($type == 'select')
{
@@ -5139,8 +5140,8 @@ function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keypr
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
}
- $out.='