From ae60f452cc8c5d909be58d26d74d0ec918fc2bc3 Mon Sep 17 00:00:00 2001 From: x Date: Wed, 3 Mar 2021 16:36:21 +0100 Subject: [PATCH 1/2] FIX : pencil to update employee field on card view --- htdocs/salaries/card.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 91330cf318e..76a37382a45 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,12 @@ if ($action == 'confirm_paid' && $user->rights->salaries->write && $confirm == ' $result = $object->set_paid($user); } +if($action == 'setfk_user' && $user->rights->salaries->write) { + $object->fetch($id); + $object->fk_user = $fk_user; + $object->update($user); +} + if ($action == 'reopen' && $user->rights->salaries->write) { $result = $object->fetch($id); if ($object->paye) @@ -627,11 +634,25 @@ 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); + $userstatic->fetch($object->fk_user); + $morehtmlref .= $userstatic->getNomUrl(1); + } + } 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)) From 55e9908601db3248e4c579c0719a02b1e77501fd Mon Sep 17 00:00:00 2001 From: x Date: Mon, 8 Mar 2021 10:09:38 +0100 Subject: [PATCH 2/2] FIX : PR returns --- htdocs/salaries/card.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 76a37382a45..3c4ea63160a 100755 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -100,9 +100,15 @@ if ($action == 'confirm_paid' && $user->rights->salaries->write && $confirm == ' } if($action == 'setfk_user' && $user->rights->salaries->write) { - $object->fetch($id); - $object->fk_user = $fk_user; - $object->update($user); + $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) { @@ -641,8 +647,13 @@ if ($id) if(!empty($object->fk_user)) { $userstatic = new User($db); - $userstatic->fetch($object->fk_user); - $morehtmlref .= $userstatic->getNomUrl(1); + $result = $userstatic->fetch($object->fk_user); + if ($result > 0){ + $morehtmlref .= $userstatic->getNomUrl(1); + } else { + dol_print_error($db); + exit(); + } } } else { $morehtmlref .= '
'.$langs->trans('Employee').' : ';