29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
33$langs->loadLangs(array(
"users"));
35$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
36$massaction =
GETPOST(
'massaction',
'alpha');
37$show_files =
GETPOST(
'show_files',
'int');
38$confirm =
GETPOST(
'confirm',
'alpha');
39$cancel =
GETPOST(
'cancel',
'alpha');
40$toselect =
GETPOST(
'toselect',
'array');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$optioncss =
GETPOST(
'optioncss',
'aZ');
46$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
47$search_group =
GETPOST(
'search_group');
51$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
52$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
55if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
59$offset = $limit * $page;
67$hookmanager->initHooks(array($contextpage));
70$extrafields->fetch_name_optionals_label($object->table_element);
73$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
83$fieldstosearchall = array();
84foreach ($object->fields as $key => $val) {
85 if (!empty($val[
'searchall'])) {
86 $fieldstosearchall[
't.'.$key] = $val[
'label'];
90if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
91 if (!$user->hasRight(
"user",
"group_advance",
"read") && !$user->admin) {
97if (isModEnabled(
'multicompany') && $conf->entity > 1 &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
101if (!$user->hasRight(
"user",
"user",
"read") && !$user->admin) {
106$caneditperms = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
107$permissiontodelete = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
109if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
110 $caneditperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"write"));
118if (
GETPOST(
'cancel',
'alpha')) {
122if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
126$parameters = array();
127$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
132if (empty($reshook)) {
134 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
137 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
138 foreach ($object->fields as $key => $val) {
140 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
141 $search[$key.
'_dtstart'] =
'';
142 $search[$key.
'_dtend'] =
'';
146 $search_array_options = array();
148 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
149 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
154 $objectclass =
'UserGroup';
155 $objectlabel =
'UserGroup';
156 $uploaddir = $conf->user->dir_output;
157 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
165$form =
new Form($db);
169$title = $langs->trans(
"UserGroups");
176$sql =
"SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions";
180$sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
181$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
182$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
183if (isModEnabled(
'multicompany') && $conf->entity == 1 && (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) {
184 $sql .=
" WHERE g.entity IS NOT NULL";
186 $sql .=
" WHERE g.entity IN (0,".$conf->entity.
")";
188if (!empty($search_group)) {
194$sql .=
" GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
197$nbtotalofrecords =
'';
200 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
201 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
202 $resql = $db->query($sqlforcount);
204 $objforcount = $db->fetch_object($resql);
205 $nbtotalofrecords = $objforcount->nbtotalofrecords;
210 if (($page * $limit) > $nbtotalofrecords) {
218$sql .= $db->order($sortfield, $sortorder);
220$resql = $db->query($sql);
226$num = $db->num_rows($resql);
234llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist');
236$arrayofselected = is_array($toselect) ? $toselect : array();
238$param =
"&search_group=".urlencode($search_group).
"&search_all=".urlencode($search_all);
240 $param .=
'&mode='.urlencode($mode);
242if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
243 $param .=
'&contextpage='.urlencode($contextpage);
245if ($limit > 0 && $limit != $conf->liste_limit) {
246 $param .=
'&limit='.((int) $limit);
248foreach ($search as $key => $val) {
249 if (is_array($search[$key])) {
250 foreach ($search[$key] as $skey) {
252 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
255 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
256 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
257 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
258 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
259 } elseif ($search[$key] !=
'') {
260 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
263if ($optioncss !=
'') {
264 $param .=
'&optioncss='.urlencode($optioncss);
267include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
269$parameters = array();
270$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
271$param .= $hookmanager->resPrint;
274$arrayofmassactions = array(
280if (!empty($permissiontodelete)) {
281 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
283if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
284 $arrayofmassactions = array();
286$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
288print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
289if ($optioncss !=
'') {
290 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
292print
'<input type="hidden" name="token" value="'.newToken().
'">';
293print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
294print
'<input type="hidden" name="action" value="list">';
295print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
296print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
297print
'<input type="hidden" name="page" value="'.$page.
'">';
298print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
299print
'<input type="hidden" name="page_y" value="">';
300print
'<input type="hidden" name="mode" value="'.$mode.
'">';
303$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
304$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
308 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewGroup'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/group/card.php?action=create&leftmenu=');
311print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
314$topicmail =
"SendGroup";
317$trackid =
'grp'.$object->id;
318include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
322 foreach ($fieldstosearchall as $key => $val) {
323 $fieldstosearchall[$key] = $langs->trans($val);
324 $setupstring .= $key.
"=".$val.
";";
326 print
'<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
327 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
332$parameters = array();
333$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
334if (empty($reshook)) {
335 $moreforfilter .= $hookmanager->resPrint;
337 $moreforfilter = $hookmanager->resPrint;
340if (!empty($moreforfilter)) {
341 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
342 print $moreforfilter;
343 $parameters = array();
344 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
345 print $hookmanager->resPrint;
349$varpage=empty($contextpage)?$_SERVER[
"PHP_SELF"]:$contextpage;
350$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
351$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
353print
'<div class="div-table-responsive">';
354print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
360$totalarray = array();
361$totalarray[
'nbfield'] = 0;
365print
'<tr class="liste_titre">';
367 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
368 $totalarray[
'nbfield']++;
371$totalarray[
'nbfield']++;
373if (isModEnabled(
'multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
374 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
"g.entity", $param,
"",
'', $sortfield, $sortorder,
'center ');
375 $totalarray[
'nbfield']++;
377print_liste_field_titre(
"NbOfUsers", $_SERVER[
"PHP_SELF"],
"nb", $param,
"",
'', $sortfield, $sortorder,
'center ');
378$totalarray[
'nbfield']++;
379print_liste_field_titre(
"NbOfPermissions", $_SERVER[
"PHP_SELF"],
"nbpermissions", $param,
"",
'', $sortfield, $sortorder,
'center ');
380$totalarray[
'nbfield']++;
381print_liste_field_titre(
"DateCreationShort", $_SERVER[
"PHP_SELF"],
"g.datec", $param,
"",
'', $sortfield, $sortorder,
'center ');
382$totalarray[
'nbfield']++;
383print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"g.tms", $param,
"",
'', $sortfield, $sortorder,
'center ');
384$totalarray[
'nbfield']++;
386include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
388$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
389$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
390print $hookmanager->resPrint;
397 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
398 $totalarray[
'nbfield']++;
406$savnbfield = $totalarray[
'nbfield'];
407$totalarray = array();
408$totalarray[
'nbfield'] = 0;
409$imaxinloop = ($limit ? min($num, $limit) : $num);
410while ($i < $imaxinloop) {
411 $obj = $db->fetch_object($resql);
417 $object->setVarsFromFetchObj($obj);
419 $object->name = $obj->name;
420 $object->note = $obj->note;
421 $object->nb_rights = $obj->nbpermissions;
422 $object->nb_users = $obj->nb;
424 if ($mode ==
'kanban') {
426 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
427 print
'<div class="box-flex-container kanban">';
430 if ($massactionbutton || $massaction) {
432 if (in_array($object->id, $arrayofselected)) {
436 print $object->getKanbanView(
'', array(
'selected' => in_array($object->id, $arrayofselected)));
437 if ($i == ($imaxinloop - 1)) {
444 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
447 print
'<td class="nowrap center">';
448 if ($massactionbutton || $massaction) {
450 if (in_array($object->id, $arrayofselected)) {
453 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
457 $totalarray[
'nbfield']++;
461 print
'<td class="tdoverflowmax125">';
462 print $object->getNomUrl(1);
463 if (isModEnabled(
'multicompany') && !$obj->entity) {
464 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
468 $totalarray[
'nbfield']++;
471 if (isModEnabled(
'multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
472 $mc->getInfo($obj->entity);
473 print
'<td class="center">'.dol_escape_htmltag($mc->label).
'</td>';
475 $totalarray[
'nbfield']++;
478 print
'<td class="center">'.dol_escape_htmltag($obj->nb).
'</td>';
480 $totalarray[
'nbfield']++;
482 print
'<td class="center">';
483 print
'<a href="'.DOL_URL_ROOT.
'/user/group/perms.php?id='.$obj->rowid.
'">'.
dol_escape_htmltag($obj->nbpermissions).
'</a>';
486 $totalarray[
'nbfield']++;
488 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec),
"dayhour").
'</td>';
490 $totalarray[
'nbfield']++;
492 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->tms),
"dayhour").
'</td>';
494 $totalarray[
'nbfield']++;
497 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
499 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
500 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
501 print $hookmanager->resPrint;
504 print
'<td class="nowrap center">';
505 if ($massactionbutton || $massaction) {
507 if (in_array($object->id, $arrayofselected)) {
510 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
514 $totalarray[
'nbfield']++;
524include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
534 $colspan = $savnbfield;
535 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
540print
'</table>'.
"\n";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage user groups.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.