Skip to content
Snippets Groups Projects
Commit 044feab0 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix duplicate code

parent dabd8820
No related branches found
No related tags found
No related merge requests found
...@@ -260,9 +260,16 @@ if ($id > 0) ...@@ -260,9 +260,16 @@ if ($id > 0)
dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin); dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin);
print '<div class="underbanner clearboth"></div>'; if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<br>'; showMyBalance($holiday, $user_id);
}
dol_fiche_end();
} }
else else
{ {
...@@ -270,23 +277,43 @@ else ...@@ -270,23 +277,43 @@ else
//print count($holiday->holiday); //print count($holiday->holiday);
print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num, count($holiday->holiday), 'title_hrm.png', 0, '', '', $limit); print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num, count($holiday->holiday), 'title_hrm.png', 0, '', '', $limit);
dol_fiche_head(''); if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
dol_fiche_head('');
showMyBalance($holiday, $user_id);
dol_fiche_end();
}
} }
$alltypeleaves=$holiday->getTypes(1,-1); // To have labels
$out='';
$typeleaves=$holiday->getTypes(1,1); /**
foreach($typeleaves as $key => $val) * Show balance of user
*
* @param Holiday $holiday Object $holiday
* @param int $user_id User id
* @return string Html code with balance
*/
function showMyBalance($holiday, $user_id)
{ {
$nb_type = $holiday->getCPforUser($user_id, $val['rowid']); global $conf, $langs;
$nb_holiday += $nb_type;
$out .= ' - '.$val['label'].': <strong>'.($nb_type?price2num($nb_type):0).'</strong><br>'; $alltypeleaves=$holiday->getTypes(1,-1); // To have labels
$out='';
$typeleaves=$holiday->getTypes(1,1);
foreach($typeleaves as $key => $val)
{
$nb_type = $holiday->getCPforUser($user_id, $val['rowid']);
$nb_holiday += $nb_type;
$out .= ' - '.$val['label'].': <strong>'.($nb_type?price2num($nb_type):0).'</strong><br>';
}
print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'<br>';
print $out;
} }
print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'<br>';
print $out;
dol_fiche_end();
if ($id > 0) print '<br>'; if ($id > 0) print '<br>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment