Standardize code

This commit is contained in:
Laurent Destailleur 2020-09-18 04:53:43 +02:00
parent 534846c5c7
commit aa3f906370
5 changed files with 56 additions and 31 deletions

View File

@ -405,7 +405,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->hrm->enabled', __HANDLER__, 'left', 4602__+MAX_llx_menu__, 'hrm', '', 4600__+MAX_llx_menu__, '/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee&contextpage=employeelist', 'List', 1, 'hrm', '$user->rights->hrm->employee->read', '', 0, 2, __ENTITY__);
-- HRM - Holiday
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?mainmenu=hrm&action=request', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?mainmenu=hrm&action=create', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5002__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&leftmenu=hrm', 'List', 1, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?mainmenu=hrm&search_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5004__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?mainmenu=hrm&action=request', 'MenuConfCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 2, __ENTITY__);

View File

@ -1773,7 +1773,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$langs->loadLangs(array("holiday", "trips"));
$newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm');
$newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("New"), 1, $user->rights->holiday->write);
$newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->rights->holiday->write);
$newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=hrm", $langs->trans("List"), 1, $user->rights->holiday->read);
if ($usemenuhider || empty($leftmenu) || $leftmenu == "hrm") {
$newmenu->add("/holiday/list.php?search_statut=1&mainmenu=hrm&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read);

View File

@ -114,15 +114,15 @@ if (empty($reshook))
$action = '';
}
// If create a request
if ($action == 'create')
// Add leave request
if ($action == 'add')
{
// If no right to create a request
if (!$cancreate)
{
$error++;
setEventMessages($langs->trans('CantCreateCP'), null, 'errors');
$action = 'request';
$action = 'create';
}
if (!$error)
@ -151,7 +151,7 @@ if (empty($reshook))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error++;
$action = 'create';
$action = 'add';
}
// If no start date
@ -159,21 +159,21 @@ if (empty($reshook))
{
setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
$error++;
$action = 'create';
$action = 'add';
}
// If no end date
if (empty($date_fin))
{
setEventMessages($langs->trans("NoDateFin"), null, 'errors');
$error++;
$action = 'create';
$action = 'add';
}
// If start date after end date
if ($date_debut > $date_fin)
{
setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
$error++;
$action = 'create';
$action = 'add';
}
// Check if there is already holiday for this period
@ -182,7 +182,7 @@ if (empty($reshook))
{
setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
$error++;
$action = 'create';
$action = 'add';
}
// If there is no Business Days within request
@ -191,7 +191,7 @@ if (empty($reshook))
{
setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors');
$error++;
$action = 'create';
$action = 'add';
}
// If no validator designated
@ -275,7 +275,8 @@ if (empty($reshook))
// If no right to modify a request
if (!$user->rights->holiday->write)
{
header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=CantUpdate');
setEventMessages($langs->trans("CantUpdate"), null, 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?action=create');
exit;
}
@ -863,7 +864,7 @@ $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->t
llxHeader('', $langs->trans('CPTitreMenu'));
if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $action == 'create')
if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add')
{
// Si l'utilisateur n'a pas le droit de faire une demande
if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all)))
@ -943,7 +944,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
// Formulaire de demande
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" onsubmit="return valider()" name="demandeCP">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'" />'."\n";
print '<input type="hidden" name="action" value="create" />'."\n";
print '<input type="hidden" name="action" value="add" />'."\n";
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
@ -1008,8 +1009,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
// Date start
print '<tr>';
print '<td class="fieldrequired">';
print $langs->trans("DateDebCP");
print ' ('.$langs->trans("FirstDayOfHoliday").')';
print $form->textwithpicto($langs->trans("DateDebCP"), $langs->trans("FirstDayOfHoliday"));
print '</td>';
print '<td>';
// Si la demande ne vient pas de l'agenda
@ -1027,8 +1027,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
// Date end
print '<tr>';
print '<td class="fieldrequired">';
print $langs->trans("DateFinCP");
print ' ('.$langs->trans("LastDayOfHoliday").')';
print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday"));
print '</td>';
print '<td>';
// Si la demande ne vient pas de l'agenda
@ -1197,7 +1196,9 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
if (!$edit)
{
print '<tr>';
print '<td class="nowrap">'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td class="nowrap">';
print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
print '</td>';
print '<td>'.dol_print_date($object->date_debut, 'day');
print ' &nbsp; &nbsp; ';
print '<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
@ -1205,7 +1206,9 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
print '</tr>';
} else {
print '<tr>';
print '<td class="nowrap">'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td class="nowrap">';
print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
print '</td>';
print '<td>';
print $form->selectDate($object->date_debut, 'date_debut_');
print ' &nbsp; &nbsp; ';
@ -1217,7 +1220,9 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
if (!$edit)
{
print '<tr>';
print '<td class="nowrap">'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td class="nowrap">';
print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
print '</td>';
print '<td>'.dol_print_date($object->date_fin, 'day');
print ' &nbsp; &nbsp; ';
print '<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
@ -1225,7 +1230,9 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
print '</tr>';
} else {
print '<tr>';
print '<td class="nowrap">'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td class="nowrap">';
print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
print '</td>';
print '<td>';
print $form->selectDate($object->date_fin, 'date_fin_');
print ' &nbsp; &nbsp; ';
@ -1236,7 +1243,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
// Nb of days
print '<tr>';
print '<td class="nowrap">';
print '<td>';
$htmlhelp = $langs->trans('NbUseDaysCPHelp');
$includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
$includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);

View File

@ -130,7 +130,8 @@ if ($object->id)
print '<td>'.$langs->trans("Type").'</td>';
print '<td>';
$typeleaves = $object->getTypes(1, -1);
print empty($typeleaves[$object->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $typeleaves[$object->fk_type]['label'];
$labeltoshow = (($typeleaves[$object->fk_type]['code'] && $langs->trans($typeleaves[$object->fk_type]['code']) != $typeleaves[$object->fk_type]['code']) ? $langs->trans($typeleaves[$object->fk_type]['code']) : $typeleaves[$object->fk_type]['label']);
print empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow;
print '</td>';
print '</tr>';
@ -140,7 +141,9 @@ if ($object->id)
if (!$edit)
{
print '<tr>';
print '<td>'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td>';
print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
print '</td>';
print '<td>'.dol_print_date($object->date_debut, 'day');
print ' &nbsp; &nbsp; ';
print '<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
@ -148,7 +151,9 @@ if ($object->id)
print '</tr>';
} else {
print '<tr>';
print '<td>'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
print '<td>';
print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
print '</td>';
print '<td>';
print $form->selectDate($object->date_debut, 'date_debut_');
print ' &nbsp; &nbsp; ';
@ -160,7 +165,9 @@ if ($object->id)
if (!$edit)
{
print '<tr>';
print '<td>'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td>';
print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
print '</td>';
print '<td>'.dol_print_date($object->date_fin, 'day');
print ' &nbsp; &nbsp; ';
print '<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
@ -168,7 +175,9 @@ if ($object->id)
print '</tr>';
} else {
print '<tr>';
print '<td>'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
print '<td>';
print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
print '</td>';
print '<td>';
print $form->selectDate($object->date_fin, 'date_fin_');
print ' &nbsp; &nbsp; ';
@ -176,8 +185,17 @@ if ($object->id)
print '</td>';
print '</tr>';
}
// Nb days consumed
print '<tr>';
print '<td>'.$langs->trans('NbUseDaysCP').'</td>';
print '<td>';
$htmlhelp = $langs->trans('NbUseDaysCPHelp');
$includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
$includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
if ($includesaturday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
if ($includesunday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
print '</td>';
print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>';
print '</tr>';

View File

@ -425,7 +425,7 @@ if ($resql)
if ($canedit)
{
print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=request&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>';
print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=create&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>';
}
print '</div>';
@ -435,7 +435,7 @@ if ($resql)
$newcardbutton = '';
if ($user->rights->holiday->write)
{
$newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=request');
$newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create');
}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm', 0, $newcardbutton, '', $limit, 0, 0, 1);