mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-16 14:31:29 +01:00
New: support sellist in modulebuilder
This commit is contained in:
@@ -4969,8 +4969,7 @@ abstract class CommonObject
|
|||||||
* @param string|int $showsize Value for css to define size. May also be a numeric.
|
* @param string|int $showsize Value for css to define size. May also be a numeric.
|
||||||
* @return string
|
* @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;
|
global $conf,$langs,$form;
|
||||||
|
|
||||||
if (! is_object($form))
|
if (! is_object($form))
|
||||||
@@ -4979,38 +4978,36 @@ abstract class CommonObject
|
|||||||
$form=new Form($this->db);
|
$form=new Form($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objectid = $this->id;
|
$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)){
|
||||||
|
|
||||||
$label= $val['label'];
|
$param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N');
|
||||||
$type = $val['type'];
|
$type ='sellist';
|
||||||
$size = $val['css'];
|
}else {
|
||||||
|
$param['options']=array();
|
||||||
// Convert var to be able to share same code than showInputField of extrafields
|
$type =$this->fields[$key]['type'];
|
||||||
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
|
$label=$this->fields[$key]['label'];
|
||||||
$default=$val['default'];
|
$size =$this->fields[$key]['size'];
|
||||||
$computed=$val['computed'];
|
//$elementtype=$this->fields[$key]['elementtype']; // Seems not used
|
||||||
$unique=$val['unique'];
|
$default=$this->fields[$key]['default'];
|
||||||
$required=$val['required'];
|
$computed=$this->fields[$key]['computed'];
|
||||||
$param=$val['param'];
|
//$unique=$this->fields[$key]['unique'];
|
||||||
if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
|
$required=$this->fields[$key]['required'];
|
||||||
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
|
|
||||||
{
|
//$langfile=$this->fields[$key]['label'];
|
||||||
$type='link';
|
//$list=$this->fields[$key]['arrayofkeyval'];
|
||||||
$param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
|
$hidden=!$this->fields[$key]['visible'];
|
||||||
}
|
|
||||||
$langfile=$val['langfile'];
|
|
||||||
$list=$val['list'];
|
|
||||||
$hidden=(abs($val['visible'])!=1 ? 1 : 0);
|
|
||||||
$help=$val['help'];
|
|
||||||
|
|
||||||
if ($computed)
|
if ($computed)
|
||||||
{
|
{
|
||||||
@@ -5018,54 +5015,44 @@ abstract class CommonObject
|
|||||||
else return '';
|
else return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use in priorit showsize from parameters, then $val['css'] then autodefine
|
if (empty($morecss))
|
||||||
if (empty($showsize) && ! empty($val['css']))
|
|
||||||
{
|
|
||||||
$showsize = $val['css'];
|
|
||||||
}
|
|
||||||
if (empty($showsize))
|
|
||||||
{
|
{
|
||||||
if ($type == 'date')
|
if ($type == 'date')
|
||||||
{
|
{
|
||||||
//$showsize=10;
|
$morecss = 'minwidth100imp';
|
||||||
$showsize = 'minwidth100imp';
|
|
||||||
}
|
}
|
||||||
elseif ($type == 'datetime')
|
elseif ($type == 'datetime')
|
||||||
{
|
{
|
||||||
//$showsize=19;
|
$morecss = 'minwidth200imp';
|
||||||
$showsize = 'minwidth200imp';
|
|
||||||
}
|
}
|
||||||
elseif (in_array($type,array('int','double','price')))
|
elseif (in_array($type,array('int','integer','double','price')))
|
||||||
{
|
{
|
||||||
//$showsize=10;
|
$morecss = 'maxwidth75';
|
||||||
$showsize = 'maxwidth75';
|
|
||||||
}
|
}
|
||||||
elseif ($type == 'url')
|
elseif ($type == 'url')
|
||||||
{
|
{
|
||||||
$showsize='minwidth400';
|
$morecss='minwidth400';
|
||||||
}
|
}
|
||||||
elseif ($type == 'boolean')
|
elseif ($type == 'boolean')
|
||||||
{
|
{
|
||||||
$showsize='';
|
$morecss='';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (round($size) < 12)
|
if (round($size) < 12)
|
||||||
{
|
{
|
||||||
$showsize = 'minwidth100';
|
$morecss = 'minwidth100';
|
||||||
}
|
}
|
||||||
else if (round($size) <= 48)
|
else if (round($size) <= 48)
|
||||||
{
|
{
|
||||||
$showsize = 'minwidth200';
|
$morecss = 'minwidth200';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//$showsize=48;
|
$morecss = 'minwidth400';
|
||||||
$showsize = 'minwidth400';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//var_dump($showsize.' '.$size);
|
|
||||||
|
|
||||||
if (in_array($type,array('date','datetime')))
|
if (in_array($type,array('date','datetime')))
|
||||||
{
|
{
|
||||||
@@ -5078,34 +5065,48 @@ abstract class CommonObject
|
|||||||
if (!$required && $value == '') $value = '-1';
|
if (!$required && $value == '') $value = '-1';
|
||||||
|
|
||||||
// TODO Must also support $moreparam
|
// 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')))
|
elseif (in_array($type,array('int','integer')))
|
||||||
{
|
{
|
||||||
$tmp=explode(',',$size);
|
$tmp=explode(',',$size);
|
||||||
$newsize=$tmp[0];
|
$newsize=$tmp[0];
|
||||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
|
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
|
||||||
}
|
}
|
||||||
elseif (preg_match('/varchar/', $type))
|
elseif (preg_match('/varchar/', $type))
|
||||||
{
|
{
|
||||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
|
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
|
||||||
}
|
}
|
||||||
elseif (in_array($type, array('mail', 'phone', 'url')))
|
elseif (in_array($type, array('mail', 'phone', 'url')))
|
||||||
{
|
{
|
||||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
|
||||||
}
|
}
|
||||||
elseif ($type == 'text')
|
elseif ($type == 'text')
|
||||||
|
{
|
||||||
|
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';
|
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%');
|
$doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,false,ROWS_5,'90%');
|
||||||
$out=$doleditor->Create(1);
|
$out=$doleditor->Create(1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
|
||||||
|
}
|
||||||
|
}
|
||||||
elseif ($type == 'html')
|
elseif ($type == 'html')
|
||||||
|
{
|
||||||
|
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';
|
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%');
|
$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);
|
$out=$doleditor->Create(1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
|
||||||
|
}
|
||||||
|
}
|
||||||
elseif ($type == 'boolean')
|
elseif ($type == 'boolean')
|
||||||
{
|
{
|
||||||
$checked='';
|
$checked='';
|
||||||
@@ -5114,21 +5115,21 @@ abstract class CommonObject
|
|||||||
} else {
|
} else {
|
||||||
$checked=' value="1" ';
|
$checked=' value="1" ';
|
||||||
}
|
}
|
||||||
$out='<input type="checkbox" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
|
$out='<input type="checkbox" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
|
||||||
}
|
}
|
||||||
elseif ($type == 'price')
|
elseif ($type == 'price')
|
||||||
{
|
{
|
||||||
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
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="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
|
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
|
||||||
}
|
}
|
||||||
elseif ($type == 'double')
|
elseif ($type == 'double')
|
||||||
{
|
{
|
||||||
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
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="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
|
$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
|
||||||
}
|
}
|
||||||
elseif ($type == 'select')
|
elseif ($type == 'select')
|
||||||
{
|
{
|
||||||
@@ -5139,8 +5140,8 @@ abstract class CommonObject
|
|||||||
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
|
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
|
$out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
|
||||||
if ((! isset($val['default'])) || ($val['notnull'] != 1)) $out.='<option value="0"> </option>';
|
$out.='<option value="0"> </option>';
|
||||||
foreach ($param['options'] as $key => $val)
|
foreach ($param['options'] as $key => $val)
|
||||||
{
|
{
|
||||||
if ((string) $key == '') continue;
|
if ((string) $key == '') continue;
|
||||||
@@ -5161,11 +5162,13 @@ abstract class CommonObject
|
|||||||
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
|
$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$out.='<select class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
|
$out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
|
||||||
if (is_array($param['options']))
|
if (is_array($param['options']))
|
||||||
{
|
{
|
||||||
$param_list=array_keys($param['options']);
|
$param_list=array_keys($param['options']);
|
||||||
$InfoFieldList = explode(":", $param_list[0]);
|
$InfoFieldList = explode(":", $param_list[0]);
|
||||||
|
$parentName='';
|
||||||
|
$parentField='';
|
||||||
// 0 : tableName
|
// 0 : tableName
|
||||||
// 1 : label field name
|
// 1 : label field name
|
||||||
// 2 : key fields name (if differ of rowid)
|
// 2 : key fields name (if differ of rowid)
|
||||||
@@ -5250,8 +5253,9 @@ abstract class CommonObject
|
|||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
// Several field into label (eq table:code|libelle:rowid)
|
// Several field into label (eq table:code|libelle:rowid)
|
||||||
|
$notrans = false;
|
||||||
$fields_label = explode('|',$InfoFieldList[1]);
|
$fields_label = explode('|',$InfoFieldList[1]);
|
||||||
if(is_array($fields_label))
|
if (is_array($fields_label))
|
||||||
{
|
{
|
||||||
$notrans = true;
|
$notrans = true;
|
||||||
foreach ($fields_label as $field_toshow)
|
foreach ($fields_label as $field_toshow)
|
||||||
@@ -5265,7 +5269,7 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
$labeltoshow=dol_trunc($labeltoshow,45);
|
$labeltoshow=dol_trunc($labeltoshow,45);
|
||||||
|
|
||||||
if ($value==$obj->rowid)
|
if ($value == $obj->rowid)
|
||||||
{
|
{
|
||||||
foreach ($fields_label as $field_toshow)
|
foreach ($fields_label as $field_toshow)
|
||||||
{
|
{
|
||||||
@@ -5280,7 +5284,7 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!$notrans)
|
if (! $notrans)
|
||||||
{
|
{
|
||||||
$translabel=$langs->trans($obj->{$InfoFieldList[1]});
|
$translabel=$langs->trans($obj->{$InfoFieldList[1]});
|
||||||
if ($translabel!=$obj->{$InfoFieldList[1]}) {
|
if ($translabel!=$obj->{$InfoFieldList[1]}) {
|
||||||
@@ -5296,7 +5300,7 @@ abstract class CommonObject
|
|||||||
$out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
|
$out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($InfoFieldList[3]))
|
if (!empty($InfoFieldList[3]) && $parentField)
|
||||||
{
|
{
|
||||||
$parent = $parentName.':'.$obj->{$parentField};
|
$parent = $parentName.':'.$obj->{$parentField};
|
||||||
}
|
}
|
||||||
@@ -5327,7 +5331,7 @@ abstract class CommonObject
|
|||||||
$out='';
|
$out='';
|
||||||
foreach ($param['options'] as $keyopt => $val)
|
foreach ($param['options'] as $keyopt => $val)
|
||||||
{
|
{
|
||||||
$out.='<input class="flat '.$showsize.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'');
|
$out.='<input class="flat '.$morecss.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'');
|
||||||
$out.=' value="'.$keyopt.'"';
|
$out.=' value="'.$keyopt.'"';
|
||||||
$out.=' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"';
|
$out.=' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"';
|
||||||
$out.= ($value==$keyopt?'checked':'');
|
$out.= ($value==$keyopt?'checked':'');
|
||||||
@@ -5346,6 +5350,8 @@ abstract class CommonObject
|
|||||||
if (is_array($param['options'])) {
|
if (is_array($param['options'])) {
|
||||||
$param_list = array_keys($param['options']);
|
$param_list = array_keys($param['options']);
|
||||||
$InfoFieldList = explode(":", $param_list[0]);
|
$InfoFieldList = explode(":", $param_list[0]);
|
||||||
|
$parentName='';
|
||||||
|
$parentField='';
|
||||||
// 0 : tableName
|
// 0 : tableName
|
||||||
// 1 : label field name
|
// 1 : label field name
|
||||||
// 2 : key fields name (if differ of rowid)
|
// 2 : key fields name (if differ of rowid)
|
||||||
@@ -5419,6 +5425,7 @@ abstract class CommonObject
|
|||||||
$labeltoshow = '';
|
$labeltoshow = '';
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
$notrans = false;
|
||||||
// Several field into label (eq table:code|libelle:rowid)
|
// Several field into label (eq table:code|libelle:rowid)
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
if (is_array($fields_label)) {
|
if (is_array($fields_label)) {
|
||||||
@@ -5459,7 +5466,7 @@ abstract class CommonObject
|
|||||||
$data[$obj->rowid]=$labeltoshow;
|
$data[$obj->rowid]=$labeltoshow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($InfoFieldList[3])) {
|
if (! empty($InfoFieldList[3]) && $parentField) {
|
||||||
$parent = $parentName . ':' . $obj->{$parentField};
|
$parent = $parentName . ':' . $obj->{$parentField};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5476,18 +5483,17 @@ abstract class CommonObject
|
|||||||
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
|
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out .= '</select>';
|
|
||||||
}
|
}
|
||||||
elseif ($type == 'link')
|
elseif ($type == 'link')
|
||||||
{
|
{
|
||||||
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
|
$param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
|
||||||
$showempty=(($val['notnull'] == 1 && $val['default'] != '')?0:1);
|
$showempty=(($required && $default != '')?0:1);
|
||||||
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty);
|
$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty);
|
||||||
}
|
}
|
||||||
elseif ($type == 'password')
|
elseif ($type == 'password')
|
||||||
{
|
{
|
||||||
// If prefix is 'search_', field is used as a filter, we use a common text field.
|
// If prefix is 'search_', field is used as a filter, we use a common text field.
|
||||||
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
||||||
}
|
}
|
||||||
if (!empty($hidden)) {
|
if (!empty($hidden)) {
|
||||||
$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
|
$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
|
||||||
@@ -5499,7 +5505,6 @@ abstract class CommonObject
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return HTML string to show a field into a page
|
* Return HTML string to show a field into a page
|
||||||
* Code very similar with showOutputField of extra fields
|
* Code very similar with showOutputField of extra fields
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
|||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
if (! preg_match('/^(integer|date|timestamp|varchar|double)/', $addfieldentry['type']))
|
if (! preg_match('/^(boolean|sellist|integer|date|timestamp|varchar|double)/', $addfieldentry['type']))
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
|
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
|
||||||
return -2;
|
return -2;
|
||||||
@@ -256,7 +256,9 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
|
|||||||
|
|
||||||
$type = $val['type'];
|
$type = $val['type'];
|
||||||
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
|
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
|
||||||
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
|
if ($type == 'html') $type = 'text';
|
||||||
|
else if ($type=='link'||$type=='sellist')$type='integer';
|
||||||
|
// html modulebuilder type is a text type in database
|
||||||
$texttoinsert.= "\t".$key." ".$type;
|
$texttoinsert.= "\t".$key." ".$type;
|
||||||
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
|
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
|
||||||
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
|
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
|
||||||
@@ -265,7 +267,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
|
|||||||
if ($val['default'] != '')
|
if ($val['default'] != '')
|
||||||
{
|
{
|
||||||
if (preg_match('/^null$/i', $val['default'])) $texttoinsert.= " DEFAULT NULL";
|
if (preg_match('/^null$/i', $val['default'])) $texttoinsert.= " DEFAULT NULL";
|
||||||
else if (preg_match('/varchar/', $val['type'])) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'";
|
else if (preg_match('/varchar/', $type )) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'";
|
||||||
else $texttoinsert.= (($val['default'] > 0)?' DEFAULT '.$val['default']:'');
|
else $texttoinsert.= (($val['default'] > 0)?' DEFAULT '.$val['default']:'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user