Fix duplicate code

This commit is contained in:
Laurent Destailleur 2017-08-29 17:52:10 +02:00
parent dabd882056
commit 044feab00f

View File

@ -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);
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<br>'; print '<br>';
showMyBalance($holiday, $user_id);
}
dol_fiche_end();
} }
else else
{ {
@ -270,8 +277,28 @@ 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);
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
dol_fiche_head(''); dol_fiche_head('');
showMyBalance($holiday, $user_id);
dol_fiche_end();
} }
}
/**
* 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)
{
global $conf, $langs;
$alltypeleaves=$holiday->getTypes(1,-1); // To have labels $alltypeleaves=$holiday->getTypes(1,-1); // To have labels
@ -285,8 +312,8 @@ foreach($typeleaves as $key => $val)
} }
print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'<br>'; print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'<br>';
print $out; print $out;
}
dol_fiche_end();
if ($id > 0) print '<br>'; if ($id > 0) print '<br>';