Skip to content

Commit

Permalink
Merge pull request #325 from altairis-noe/hierarchical_workhours
Browse files Browse the repository at this point in the history
NEW full hierarchy can edit someone’s work hours
  • Loading branch information
nicolas-eoxia committed Jul 26, 2023
2 parents fb319a0 + 240d9e2 commit 21bffd4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion view/workinghours_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,22 @@

print '</table>';

if (($user->rights->dolisirh->workinghours->myworkinghours && $usertmp->id == $user->id) || ($user->rights->dolisirh->workinghours->allworkinghours && $usertmp->fk_user == $user->id)){
// Buid current user hierarchy
if ($usertmp->fk_user > 0) {
$usertmphierarchy = array($usertmp->fk_user);
$usertmpboss = new User($object->db);
$usertmpboss->fetch($usertmp->fk_user);
while ($usertmpboss->fk_user > 0) {
$usertmphierarchy[] = $usertmpboss->fk_user;
$usertmpboss->fetch($usertmpboss->fk_user);
// We do not want to loop between two users who would be each other bosses
if (in_array($usertmpboss->id, $usertmphierarchy)) {
break;
}
}
}

if (($user->rights->dolisirh->workinghours->myworkinghours && $usertmp->id == $user->id) || ($user->rights->dolisirh->workinghours->allworkinghours && in_array($user->id, $usertmphierarchy))){
print '<br><div class="center">';
print '<input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
print '</div>';
Expand Down

0 comments on commit 21bffd4

Please sign in to comment.