NEW Bulk delete actions available on leave requests
This commit is contained in:
parent
20b91a8d5f
commit
46698192b4
@ -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/functions2.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||||
|
|
||||||
$langs->load('users');
|
$langs->loadLangs(array('users', 'holidays', 'hrm'));
|
||||||
$langs->load('holidays');
|
|
||||||
$langs->load('hrm');
|
|
||||||
|
|
||||||
// Protection if external user
|
// Protection if external user
|
||||||
if ($user->societe_id > 0) accessforbidden();
|
if ($user->societe_id > 0) accessforbidden();
|
||||||
|
|
||||||
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
|
$action = GETPOST('action','alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||||
$sortfield = GETPOST("sortfield",'alpha');
|
$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists)
|
||||||
$sortorder = GETPOST("sortorder",'alpha');
|
$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ?
|
||||||
$page = GETPOST("page",'int');
|
$confirm = GETPOST('confirm','alpha'); // Result of a confirmation
|
||||||
$page = is_numeric($page) ? $page : 0;
|
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
|
||||||
$page = $page == -1 ? 0 : $page;
|
$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";
|
// Load variable for pagination
|
||||||
if (! $sortorder) $sortorder="DESC";
|
$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;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $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');
|
$id = GETPOST('id','int');
|
||||||
|
|
||||||
$sall = GETPOST('sall', 'alphanohtml');
|
$sall = GETPOST('sall', 'alphanohtml');
|
||||||
@ -81,6 +99,19 @@ $fieldstosearchall = array(
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
// 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
|
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="";
|
$search_ref="";
|
||||||
@ -94,7 +125,24 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
|||||||
$search_valideur="";
|
$search_valideur="";
|
||||||
$search_statut="";
|
$search_statut="";
|
||||||
$search_type='';
|
$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';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -102,6 +150,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
$formother = new FormOther($db);
|
||||||
|
|
||||||
$holiday = new Holiday($db);
|
$holiday = new Holiday($db);
|
||||||
$holidaystatic=new Holiday($db);
|
$holidaystatic=new Holiday($db);
|
||||||
$fuser = new User($db);
|
$fuser = new User($db);
|
||||||
@ -231,23 +282,32 @@ if ($result == '-1')
|
|||||||
|
|
||||||
// Show table of vacations
|
// Show table of vacations
|
||||||
|
|
||||||
$var=true;
|
|
||||||
$num = count($holiday->holiday);
|
$num = count($holiday->holiday);
|
||||||
$form = new Form($db);
|
|
||||||
$formother = new FormOther($db);
|
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||||
|
|
||||||
$param='';
|
$param='';
|
||||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||||
|
|
||||||
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
// List of mass actions available
|
||||||
|
$arrayofmassactions = array(
|
||||||
|
//'presend'=>$langs->trans("SendByMail"),
|
||||||
|
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||||
|
);
|
||||||
|
if ($user->rights->holiday->delete) $arrayofmassactions['delete']=$langs->trans("Delete");
|
||||||
|
//if ($massaction == 'presend') $arrayofmassactions=array();
|
||||||
|
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="list">';
|
print '<input type="hidden" name="action" value="list">';
|
||||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||||
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||||
if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
|
if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
|
||||||
|
|
||||||
if ($id > 0) // For user tab
|
if ($id > 0) // For user tab
|
||||||
@ -273,9 +333,10 @@ if ($id > 0) // For user tab
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$nbtotalofrecords = count($holiday->holiday);
|
||||||
//print $num;
|
//print $num;
|
||||||
//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"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, '', '', $limit);
|
||||||
|
|
||||||
/*if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
|
/*if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
|
||||||
{
|
{
|
||||||
@ -287,36 +348,6 @@ else
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
|
|
||||||
$out='';
|
|
||||||
$nb_holiday=0;
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($id > 0) print '<br>';
|
if ($id > 0) print '<br>';
|
||||||
|
|
||||||
if ($sall)
|
if ($sall)
|
||||||
@ -325,6 +356,10 @@ if ($sall)
|
|||||||
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||||
|
$selectedfields=''; // $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
|
$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||||
|
|
||||||
@ -424,7 +459,7 @@ print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],'','',$pram,'align="righ
|
|||||||
print_liste_field_titre("DateDebCP",$_SERVER["PHP_SELF"],"cp.date_debut","",$param,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre("DateDebCP",$_SERVER["PHP_SELF"],"cp.date_debut","",$param,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre("DateFinCP",$_SERVER["PHP_SELF"],"cp.date_fin","",$param,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre("DateFinCP",$_SERVER["PHP_SELF"],"cp.date_fin","",$param,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"cp.statut","",$param,'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"cp.statut","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder,'maxwidthsearch ');
|
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
// Lines
|
// Lines
|
||||||
@ -474,7 +509,17 @@ if (! empty($holiday->holiday))
|
|||||||
print '<td align="center">'.dol_print_date($infos_CP['date_debut'],'day').'</td>';
|
print '<td align="center">'.dol_print_date($infos_CP['date_debut'],'day').'</td>';
|
||||||
print '<td align="center">'.dol_print_date($infos_CP['date_fin'],'day').'</td>';
|
print '<td align="center">'.dol_print_date($infos_CP['date_fin'],'day').'</td>';
|
||||||
print '<td align="right">'.$holidaystatic->LibStatut($infos_CP['statut'],5).'</td>';
|
print '<td align="right">'.$holidaystatic->LibStatut($infos_CP['statut'],5).'</td>';
|
||||||
print '<td></td>';
|
|
||||||
|
// Action column
|
||||||
|
print '<td class="nowrap" align="center">';
|
||||||
|
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||||
|
{
|
||||||
|
$selected=0;
|
||||||
|
if (in_array($infos_CP['rowid'], $arrayofselected)) $selected=1;
|
||||||
|
print '<input id="cb'.$infos_CP['rowid'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$infos_CP['rowid'].'"'.($selected?' checked="checked"':'').'>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -504,3 +549,33 @@ print '</form>';
|
|||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
|
||||||
|
$out='';
|
||||||
|
$nb_holiday=0;
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user