Skip to content

Commit

Permalink
FIX: default addupdatedelete actions: uniformize add/update value checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ATM-Marc committed Apr 11, 2018
1 parent 2f75bfc commit bbc12cf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions htdocs/core/actions_addupdatedelete.inc.php
Expand Up @@ -47,8 +47,15 @@
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'));
} 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

Expand Down Expand Up @@ -95,8 +102,7 @@
// 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'));
Expand Down

0 comments on commit bbc12cf

Please sign in to comment.