diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 570b78f7604..f29b4e79768 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -772,7 +772,19 @@ if (isModEnabled('stock')) { $formproduct = new FormProduct($db); } -if ($object->id > 0) { +if (GETPOSTINT('id') > 0) { + $res = $object->fetch($id, '', '', 1); + if ($res < 0) { + dol_print_error($db, $object->error); + exit; + } + + if ($res == 0) { + $langs->load("errors"); + print($langs->trans('ErrorRecordNotFound')); + exit; + } + $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; $title = $person_name." - ".$langs->trans('Card'); } else { @@ -1380,12 +1392,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ""; } else { // View and edit mode - if ($id > 0) { - $res = $object->fetch($id, '', '', 1); - if ($res < 0) { - dol_print_error($db, $object->error); - exit; - } + if ($object->id > 0) { $res = $object->fetch_optionals(); // Check if user has rights