diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index b8ede4d7d14..6e1ddf8a796 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -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 // Set value to insert - if (in_array($object->fields[$key]['type'], array('text', 'html'))) $value = GETPOST($key,'none'); - else $value = GETPOST($key,'alpha'); + if (in_array($object->fields[$key]['type'], array('text', 'html'))) { + $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 (! 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 if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $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')); } 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'); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4daf78ad52e..c1602066ee6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5293,7 +5293,8 @@ class Form $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX .$objecttmp->table_element." as t"; if ($objecttmp->ismultientitymanaged == 2) 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->element == 'societe') $sql.= " AND t.rowid = ".$user->societe_id; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 8e2cba43097..185e3a3b4a1 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -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('/^(integer|date|timestamp|varchar|double|html|price)/', $addfieldentry['type'])) { setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors'); return -2; @@ -257,6 +257,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $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 == 'price') $type = 'double'; // 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';