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');
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');
52$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
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'];
91 if (!$user->hasRight(
"user",
"group_advance",
"read") && !$user->admin) {
96if (!$user->hasRight(
"user",
"user",
"read") && !$user->admin) {
101$caneditperms = (isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write")));
102$permissiontodelete = $caneditperms;
105 $caneditperms = (isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight(
"user",
"group_advance",
"write")));
113if (
GETPOST(
'cancel',
'alpha')) {
117if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
121$parameters = array();
122$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
127if (empty($reshook)) {
129 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
132 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
133 foreach (
$object->fields as $key => $val) {
135 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
136 $search[$key.
'_dtstart'] =
'';
137 $search[$key.
'_dtend'] =
'';
141 $search_array_options = array();
143 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
144 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
149 $objectclass =
'UserGroup';
150 $objectlabel =
'UserGroup';
151 $uploaddir = $conf->user->dir_output;
152 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
160$form =
new Form($db);
164$title = $langs->trans(
"UserGroups");
171$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";
175$sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
176$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
177$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
178if (isModEnabled(
'multicompany') && $conf->entity == 1 && (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) {
179 $sql .=
" WHERE g.entity IS NOT NULL";
181 $sql .=
" WHERE g.entity IN (0,".$conf->entity.
")";
183if (!empty($search_group)) {
189$sql .=
" GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
192$nbtotalofrecords =
'';
195 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
196 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
197 $resql = $db->query($sqlforcount);
199 $objforcount = $db->fetch_object($resql);
200 $nbtotalofrecords = $objforcount->nbtotalofrecords;
205 if (($page * $limit) > $nbtotalofrecords) {
213$sql .= $db->order($sortfield, $sortorder);
215$resql = $db->query($sql);
221$num = $db->num_rows($resql);
229llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist mod-user page-group_list');
231$arrayofselected = is_array($toselect) ? $toselect : array();
233$param =
"&search_group=".urlencode($search_group).
"&search_all=".urlencode($search_all);
235 $param .=
'&mode='.urlencode($mode);
237if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
238 $param .=
'&contextpage='.urlencode($contextpage);
240if ($limit > 0 && $limit != $conf->liste_limit) {
241 $param .=
'&limit='.((int) $limit);
243foreach ($search as $key => $val) {
244 if (is_array($search[$key])) {
245 foreach ($search[$key] as $skey) {
247 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
250 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
251 $param .=
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
252 $param .=
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
253 $param .=
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
254 } elseif ($search[$key] !=
'') {
255 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
258if ($optioncss !=
'') {
259 $param .=
'&optioncss='.urlencode($optioncss);
262include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
264$parameters = array(
'param' => &$param);
265$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
266$param .= $hookmanager->resPrint;
269$arrayofmassactions = array(
275if (!empty($permissiontodelete)) {
276 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
278if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
279 $arrayofmassactions = array();
281$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
283print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
284if ($optioncss !=
'') {
285 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
287print
'<input type="hidden" name="token" value="'.newToken().
'">';
288print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
289print
'<input type="hidden" name="action" value="list">';
290print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
291print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
292print
'<input type="hidden" name="page" value="'.$page.
'">';
293print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
294print
'<input type="hidden" name="page_y" value="">';
295print
'<input type="hidden" name="mode" value="'.$mode.
'">';
298$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'));
299$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'));
303 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewGroup'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/group/card.php?action=create&leftmenu=',
'', $caneditperms ? 1 : 0);
306print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
309$topicmail =
"SendGroup";
312$trackid =
'grp'.$object->id;
313include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
317 foreach ($fieldstosearchall as $key => $val) {
318 $fieldstosearchall[$key] = $langs->trans($val);
319 $setupstring .= $key.
"=".$val.
";";
321 print
'<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
322 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
327$parameters = array();
328$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
329if (empty($reshook)) {
330 $moreforfilter .= $hookmanager->resPrint;
332 $moreforfilter = $hookmanager->resPrint;
335if (!empty($moreforfilter)) {
336 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
337 print $moreforfilter;
341$varpage=empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
342$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
343$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
344$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
346print
'<div class="div-table-responsive">';
347print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
353$totalarray = array();
354$totalarray[
'nbfield'] = 0;
358print
'<tr class="liste_titre">';
360 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
361 $totalarray[
'nbfield']++;
364$totalarray[
'nbfield']++;
366if (isModEnabled(
'multicompany') && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
367 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
"g.entity", $param,
"",
'', $sortfield, $sortorder,
'center ');
368 $totalarray[
'nbfield']++;
370print_liste_field_titre(
"NbOfUsers", $_SERVER[
"PHP_SELF"],
"nb", $param,
"",
'', $sortfield, $sortorder,
'center ');
371$totalarray[
'nbfield']++;
372print_liste_field_titre(
"NbOfPermissions", $_SERVER[
"PHP_SELF"],
"nbpermissions", $param,
"",
'', $sortfield, $sortorder,
'center ');
373$totalarray[
'nbfield']++;
374print_liste_field_titre(
"DateCreationShort", $_SERVER[
"PHP_SELF"],
"g.datec", $param,
"",
'', $sortfield, $sortorder,
'center ');
375$totalarray[
'nbfield']++;
376print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"g.tms", $param,
"",
'', $sortfield, $sortorder,
'center ');
377$totalarray[
'nbfield']++;
379include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
381$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
382$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
383print $hookmanager->resPrint;
390 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
391 $totalarray[
'nbfield']++;
399$savnbfield = $totalarray[
'nbfield'];
400$totalarray = array();
401$totalarray[
'nbfield'] = 0;
402$imaxinloop = ($limit ? min($num, $limit) : $num);
403while ($i < $imaxinloop) {
404 $obj = $db->fetch_object($resql);
410 $object->setVarsFromFetchObj($obj);
414 $object->nb_rights = $obj->nbpermissions;
417 if ($mode ==
'kanban') {
419 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
420 print
'<div class="box-flex-container kanban">';
424 if ($massactionbutton || $massaction) {
426 if (in_array(
$object->id, $arrayofselected)) {
430 print
$object->getKanbanView(
'', array(
'selected' => $selected));
431 if ($i == ($imaxinloop - 1)) {
438 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
441 print
'<td class="nowrap center">';
442 if ($massactionbutton || $massaction) {
444 if (in_array(
$object->id, $arrayofselected)) {
447 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
451 $totalarray[
'nbfield']++;
455 print
'<td class="tdoverflowmax125">';
457 if (isModEnabled(
'multicompany') && !$obj->entity) {
458 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
462 $totalarray[
'nbfield']++;
465 if (isModEnabled(
'multicompany') && is_object($mc) && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
466 $mc->getInfo($obj->entity);
467 print
'<td class="center">'.dol_escape_htmltag($mc->label).
'</td>';
469 $totalarray[
'nbfield']++;
472 print
'<td class="center">'.dol_escape_htmltag($obj->nb).
'</td>';
474 $totalarray[
'nbfield']++;
476 print
'<td class="center">';
477 print
'<a href="'.DOL_URL_ROOT.
'/user/group/perms.php?id='.$obj->rowid.
'">'.
dol_escape_htmltag($obj->nbpermissions).
'</a>';
480 $totalarray[
'nbfield']++;
482 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec),
"dayhour").
'</td>';
484 $totalarray[
'nbfield']++;
486 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->tms),
"dayhour").
'</td>';
488 $totalarray[
'nbfield']++;
491 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
493 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
494 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
495 print $hookmanager->resPrint;
498 print
'<td class="nowrap center">';
499 if ($massactionbutton || $massaction) {
501 if (in_array(
$object->id, $arrayofselected)) {
504 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
508 $totalarray[
'nbfield']++;
518include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
528 $colspan = $savnbfield;
529 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
534print
'</table>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage user groups.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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 a Dolibarr global constant int value.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a 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.