diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index eb4a6958045..3ecd77fdf63 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -59,6 +59,7 @@ $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", $datesp = dol_mktime(12, 0, 0, GETPOST("datespmonth", 'int'), GETPOST("datespday", 'int'), GETPOST("datespyear", 'int')); $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday", 'int'), GETPOST("dateepyear", 'int')); $label = GETPOST('label'); +$fk_user = GETPOST('userid', 'int'); // Security check $socid = GETPOST("socid", "int"); @@ -98,6 +99,18 @@ if ($action == 'confirm_paid' && $user->rights->salaries->write && $confirm == ' $result = $object->set_paid($user); } +if($action == 'setfk_user' && $user->rights->salaries->write) { + $result = $object->fetch($id); + if ($result > 0){ + $object->fk_user = $fk_user; + $object->update($user); + } else { + dol_print_error($db); + exit; + } + +} + if ($action == 'reopen' && $user->rights->salaries->write) { $result = $object->fetch($id); if ($object->paye) @@ -626,11 +639,30 @@ if ($id) $morehtmlref .= ''; $morehtmlref .= ''; } - - // Employee - $userstatic = new User($db); - $userstatic->fetch($object->fk_user); - $morehtmlref .= '
' .$langs->trans('Employee').' : '.$userstatic->getNomUrl(1); + + //Employee + if($action != 'editfk_user') { + $morehtmlref .= '
' . $form->editfieldkey("Employee", 'fk_user', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1); + + if(!empty($object->fk_user)) { + $userstatic = new User($db); + $result = $userstatic->fetch($object->fk_user); + if ($result > 0){ + $morehtmlref .= $userstatic->getNomUrl(1); + } else { + dol_print_error($db); + exit(); + } + } + } else { + $morehtmlref .= '
'.$langs->trans('Employee').' : '; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $form->select_dolusers($object->fk_user, 'userid', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } // Project if (!empty($conf->projet->enabled))