diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index c5a074d0e71..2d97a73667b 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -33,26 +33,44 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; -$langs->load('users'); -$langs->load('holidays'); -$langs->load('hrm'); +$langs->loadLangs(array('users', 'holidays', 'hrm')); // Protection if external user if ($user->societe_id > 0) accessforbidden(); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); -$page = is_numeric($page) ? $page : 0; -$page = $page == -1 ? 0 : $page; +$action = GETPOST('action','alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm','alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') -if (! $sortfield) $sortfield="cp.rowid"; -if (! $sortorder) $sortorder="DESC"; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +// Initialize technical objects +$object=new Holiday($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array +// Fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('holiday'); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (! $sortfield) $sortfield="cp.rowid"; +if (! $sortorder) $sortorder="DESC"; + $id = GETPOST('id','int'); $sall = GETPOST('sall', 'alphanohtml'); @@ -81,27 +99,60 @@ $fieldstosearchall = array( * Actions */ -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers +if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $search_ref=""; - $month_create=""; - $year_create=""; - $month_start=""; - $year_start=""; - $month_end=""; - $year_end=""; - $search_employee=""; - $search_valideur=""; - $search_statut=""; - $search_type=''; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + $search_ref=""; + $month_create=""; + $year_create=""; + $month_start=""; + $year_start=""; + $month_end=""; + $year_end=""; + $search_employee=""; + $search_valideur=""; + $search_statut=""; + $search_type=''; + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass='Holiday'; + $objectlabel='Holiday'; + $permtoread = $user->rights->holiday->read; + $permtodelete = $user->rights->holiday->delete; + $uploaddir = $conf->holiday->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } + /* * View */ +$form = new Form($db); +$formother = new FormOther($db); + $holiday = new Holiday($db); $holidaystatic=new Holiday($db); $fuser = new User($db); @@ -231,23 +282,32 @@ if ($result == '-1') // Show table of vacations -$var=true; $num = count($holiday->holiday); -$form = new Form($db); -$formother = new FormOther($db); + +$arrayofselected=is_array($toselect)?$toselect:array(); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($optioncss != '') $param.='&optioncss='.$optioncss; -print '