Merge pull request #8562 from ATM-Marc/FIX_modulebuilder
FIX: various modulebuilder-related issues
This commit is contained in:
commit
3df873ee06
@ -47,8 +47,17 @@ if ($action == 'add' && ! empty($permissiontoadd))
|
|||||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
|
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
|
||||||
|
|
||||||
// Set value to insert
|
// Set value to insert
|
||||||
if (in_array($object->fields[$key]['type'], array('text', 'html'))) $value = GETPOST($key,'none');
|
if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
|
||||||
else $value = GETPOST($key,'alpha');
|
$value = GETPOST($key,'none');
|
||||||
|
} elseif ($object->fields[$key]['type']=='date') {
|
||||||
|
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
|
||||||
|
} elseif ($object->fields[$key]['type']=='datetime') {
|
||||||
|
$value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
|
||||||
|
} elseif ($object->fields[$key]['type']=='price') {
|
||||||
|
$value = price2num(GETPOST($key));
|
||||||
|
} else {
|
||||||
|
$value = GETPOST($key,'alpha');
|
||||||
|
}
|
||||||
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field
|
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field
|
||||||
if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field
|
if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field
|
||||||
|
|
||||||
@ -95,11 +104,12 @@ if ($action == 'update' && ! empty($permissiontoadd))
|
|||||||
// Set value to update
|
// Set value to update
|
||||||
if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
|
if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
|
||||||
$value = GETPOST($key,'none');
|
$value = GETPOST($key,'none');
|
||||||
}
|
} elseif ($object->fields[$key]['type']=='date') {
|
||||||
elseif ($object->fields[$key]['type']=='date') {
|
|
||||||
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
|
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
|
||||||
} elseif ($object->fields[$key]['type']=='datetime') {
|
} elseif ($object->fields[$key]['type']=='datetime') {
|
||||||
$value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
|
$value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
|
||||||
|
} elseif ($object->fields[$key]['type']=='price') {
|
||||||
|
$value = price2num(GETPOST($key));
|
||||||
} else {
|
} else {
|
||||||
$value = GETPOST($key,'alpha');
|
$value = GETPOST($key,'alpha');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5293,7 +5293,8 @@ class Form
|
|||||||
$sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX .$objecttmp->table_element." as t";
|
$sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX .$objecttmp->table_element." as t";
|
||||||
if ($objecttmp->ismultientitymanaged == 2)
|
if ($objecttmp->ismultientitymanaged == 2)
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE t.entity IN (".getEntity($objecttmp->table_element).")";
|
$sql.= " WHERE 1=1";
|
||||||
|
if(! empty($objecttmp->ismultientitymanaged)) $sql.= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
|
||||||
if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->societe_id))
|
if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->societe_id))
|
||||||
{
|
{
|
||||||
if ($objecttmp->element == 'societe') $sql.= " AND t.rowid = ".$user->societe_id;
|
if ($objecttmp->element == 'societe') $sql.= " AND t.rowid = ".$user->societe_id;
|
||||||
|
|||||||
@ -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('/^(integer|date|timestamp|varchar|double|html|price)/', $addfieldentry['type']))
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
|
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
|
||||||
return -2;
|
return -2;
|
||||||
@ -257,6 +257,7 @@ 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'; // html modulebuilder type is a text type in database
|
||||||
|
if ($type == 'price') $type = 'double'; // 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';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user