Skip to content

Commit

Permalink
Can see rest of available leaves request in read only mode if we don't
Browse files Browse the repository at this point in the history
have permission to edit.
  • Loading branch information
eldy committed Mar 14, 2016
1 parent d4c6c4c commit 77ae5c6
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions htdocs/holiday/define_holiday.php
Expand Up @@ -214,6 +214,16 @@
}
else
{
$canedit=0;
if (! empty($user->rights->holiday->define_holiday)) $canedit=1;

// Get array of ids of all childs
$userchilds=array();
if (empty($user->rights->holiday->read_all))
{
$userchilds=$user->getAllChildIds();
}

print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
print '<input type="hidden" name="action" value="update" />';

Expand All @@ -231,23 +241,18 @@
{
print '<td>'.$langs->trans("NoLeaveWithCounterDefined").'</td>';
}
print '<td width="20%" style="text-align:center">'.$langs->trans('Note').'</td>';
print '<td width="20%" style="text-align:center">';
if ($canedit) print $langs->trans('Note');
print '</td>';
print '<td></td>';
print '</tr>';

// Get array of ids of all childs
$userchilds=array();
if (empty($user->rights->holiday->define_holiday))
{
$userchilds=$user->getAllChildIds();
}

foreach($listUsers as $users)
{
$var=!$var;

// If user has not permission to edit/read all, we must see only subordinates
if (empty($user->rights->holiday->define_holiday))
if (empty($user->rights->holiday->read_all))
{
if (($users['rowid'] != $user->id) && (! in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it.
}
Expand All @@ -267,7 +272,8 @@
$nbtoshow='';
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow=price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
print '<td style="text-align:center">';
print '<input type="text" value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
else print $nbtoshow;
//print ' '.$langs->trans('days');
print '</td>'."\n";
}
Expand All @@ -276,8 +282,15 @@
{
print '<td></td>';
}
print '<td style="text-align:center"><input type="text" value="" name="note_holiday['.$users['rowid'].']" size="30"/></td>';
print '<td><input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Update")).'" class="button"/></td>'."\n";
print '<td style="text-align:center">';
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
print '</td>';
print '<td>';
if (! empty($user->rights->holiday->define_holiday))
{
print '<input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Update")).'" class="button"/>';
}
print '</td>'."\n";
print '</tr>';

$i++;
Expand Down

0 comments on commit 77ae5c6

Please sign in to comment.