From aa3f9063709bdb53c3bf02617a12ce8b8320ae4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Sep 2020 04:53:43 +0200 Subject: [PATCH] Standardize code --- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/holiday/card.php | 49 ++++++++++++++----------- htdocs/holiday/document.php | 30 ++++++++++++--- htdocs/holiday/list.php | 4 +- 5 files changed, 56 insertions(+), 31 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 8d4a033efb3..b5f96655ed7 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -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__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a76a4839242..f721d7d4c5c 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -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); diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index a1956d72ecb..3bacf8d6d6a 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -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 '
'."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { @@ -1008,8 +1009,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ // Date start print ''; print ''; - print $langs->trans("DateDebCP"); - print ' ('.$langs->trans("FirstDayOfHoliday").')'; + print $form->textwithpicto($langs->trans("DateDebCP"), $langs->trans("FirstDayOfHoliday")); print ''; print ''; // 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 ''; print ''; - print $langs->trans("DateFinCP"); - print ' ('.$langs->trans("LastDayOfHoliday").')'; + print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday")); print ''; print ''; // 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 ''; - print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + print ''; + print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday")); + print ''; print ''.dol_print_date($object->date_debut, 'day'); print '     '; print ''.$langs->trans($listhalfday[$starthalfday]).''; @@ -1205,7 +1206,9 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ print ''; } else { print ''; - print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + print ''; + print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday")); + print ''; print ''; print $form->selectDate($object->date_debut, 'date_debut_'); print '     '; @@ -1217,7 +1220,9 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ if (!$edit) { print ''; - print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + print ''; + print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday")); + print ''; print ''.dol_print_date($object->date_fin, 'day'); print '     '; print ''.$langs->trans($listhalfday[$endhalfday]).''; @@ -1225,7 +1230,9 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ print ''; } else { print ''; - print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + print ''; + print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday")); + print ''; print ''; print $form->selectDate($object->date_fin, 'date_fin_'); print '     '; @@ -1236,7 +1243,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ // Nb of days print ''; - print ''; + print ''; $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); diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 717c71dda29..9fd7f7b45b8 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -130,7 +130,8 @@ if ($object->id) print ''.$langs->trans("Type").''; print ''; $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 ''; print ''; @@ -140,7 +141,9 @@ if ($object->id) if (!$edit) { print ''; - print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + print ''; + print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday")); + print ''; print ''.dol_print_date($object->date_debut, 'day'); print '     '; print ''.$langs->trans($listhalfday[$starthalfday]).''; @@ -148,7 +151,9 @@ if ($object->id) print ''; } else { print ''; - print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + print ''; + print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday")); + print ''; print ''; print $form->selectDate($object->date_debut, 'date_debut_'); print '     '; @@ -160,7 +165,9 @@ if ($object->id) if (!$edit) { print ''; - print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + print ''; + print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday")); + print ''; print ''.dol_print_date($object->date_fin, 'day'); print '     '; print ''.$langs->trans($listhalfday[$endhalfday]).''; @@ -168,7 +175,9 @@ if ($object->id) print ''; } else { print ''; - print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + print ''; + print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday")); + print ''; print ''; print $form->selectDate($object->date_fin, 'date_fin_'); print '     '; @@ -176,8 +185,17 @@ if ($object->id) print ''; print ''; } + + // Nb days consumed print ''; - print ''.$langs->trans('NbUseDaysCP').''; + print ''; + $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 .= '
'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday")); + if ($includesunday) $htmlhelp .= '
'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday")); + print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp); + print ''; print ''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).''; print ''; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 02874815022..50de7121833 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -425,7 +425,7 @@ if ($resql) if ($canedit) { - print ''.$langs->trans("AddCP").''; + print ''.$langs->trans("AddCP").''; } print ''; @@ -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);