New: support sellist in modulebuilder

This commit is contained in:
patrick Delcroix
2018-05-22 22:00:20 +02:00
parent b68b66edcb
commit 2ccaf1ad95
2 changed files with 92 additions and 85 deletions

View File

@@ -63,7 +63,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
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');
return -2;
@@ -253,10 +253,12 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
foreach($object->fields as $key => $val)
{
$i++;
$type = $val['type'];
$type = $val['type'];
$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;
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
@@ -265,7 +267,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
if ($val['default'] != '')
{
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']:'');
}
}