30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
42$langs->loadLangs(array(
"users"));
44$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
45$massaction =
GETPOST(
'massaction',
'alpha');
47$confirm =
GETPOST(
'confirm',
'alpha');
48$cancel =
GETPOST(
'cancel',
'alpha');
49$toselect =
GETPOST(
'toselect',
'array');
50$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
51$backtopage =
GETPOST(
'backtopage',
'alpha');
52$optioncss =
GETPOST(
'optioncss',
'aZ');
55$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
56$search_group =
GETPOST(
'search_group');
61$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
68$offset = $limit * $page;
76$hookmanager->initHooks(array($contextpage));
79$extrafields->fetch_name_optionals_label(
$object->table_element);
82$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
91$arrayfields = array();
94$fieldstosearchall = array();
95foreach (
$object->fields as $key => $val) {
96 if (!empty($val[
'searchall'])) {
97 $fieldstosearchall[
't.'.$key] = $val[
'label'];
102 if (!$user->hasRight(
"user",
"group_advance",
"read") && !$user->admin) {
107if (!$user->hasRight(
"user",
"user",
"read") && !$user->admin) {
112$caneditperms = (isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write")));
113$permissiontodelete = $caneditperms;
116 $caneditperms = (isModEnabled(
'multicompany') && !empty($user->entity) &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') ? false : ($user->admin || $user->hasRight(
"user",
"group_advance",
"write")));
124if (
GETPOST(
'cancel',
'alpha')) {
128if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
132$parameters = array(
'arrayfields' => &$arrayfields);
133$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
138if (empty($reshook)) {
140 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
143 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
144 foreach (
$object->fields as $key => $val) {
146 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
147 $search[$key.
'_dtstart'] =
'';
148 $search[$key.
'_dtend'] =
'';
153 $search_array_options = array();
155 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
156 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
161 $objectclass =
'UserGroup';
162 $objectlabel =
'UserGroup';
163 $uploaddir =
$conf->user->dir_output;
164 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
172$form =
new Form($db);
176$title = $langs->trans(
"UserGroups");
183$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";
187$sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
188$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
189$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
190if (isModEnabled(
'multicompany') &&
$conf->entity == 1 && (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) {
191 $sql .=
" WHERE g.entity IS NOT NULL";
193 $sql .=
" WHERE g.entity IN (0,".$conf->entity.
")";
195if (!empty($search_group)) {
201$sql .=
" GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
204$nbtotalofrecords =
'';
207 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(DISTINCT g.rowid) as nbtotalofrecords', $sql);
208 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
209 $resql = $db->query($sqlforcount);
211 $objforcount = $db->fetch_object($resql);
212 $nbtotalofrecords = $objforcount->nbtotalofrecords;
217 if (($page * $limit) > $nbtotalofrecords) {
225$sql .= $db->order($sortfield, $sortorder);
227 $sql .= $db->plimit($limit + 1, $offset);
229$resql = $db->query($sql);
235$num = $db->num_rows($resql);
243llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist mod-user page-group_list');
245$arrayofselected = is_array($toselect) ? $toselect : array();
247$param =
"&search_group=".urlencode($search_group).
"&search_all=".urlencode($search_all);
249 $param .=
'&mode='.urlencode($mode);
251if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
252 $param .=
'&contextpage='.urlencode($contextpage);
254if ($limit > 0 && $limit !=
$conf->liste_limit) {
255 $param .=
'&limit='.((int) $limit);
257if ($optioncss !=
'') {
258 $param .=
'&optioncss='.urlencode($optioncss);
261foreach ($search as $key => $val) {
262 if (is_array($search[$key])) {
263 foreach ($search[$key] as $skey) {
265 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
268 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
269 $param .=
'&search_'.$key.
'month='.
GETPOSTINT(
'search_'.$key.
'month');
270 $param .=
'&search_'.$key.
'day='.
GETPOSTINT(
'search_'.$key.
'day');
271 $param .=
'&search_'.$key.
'year='.
GETPOSTINT(
'search_'.$key.
'year');
272 } elseif ($search[$key] !=
'') {
273 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
277include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
279$parameters = array(
'param' => &$param);
280$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
281$param .= $hookmanager->resPrint;
284$arrayofmassactions = array(
290if (!empty($permissiontodelete)) {
291 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
293if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
294 $arrayofmassactions = array();
296$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
298print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
299if ($optioncss !=
'') {
300 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
302print
'<input type="hidden" name="token" value="'.newToken().
'">';
303print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
304print
'<input type="hidden" name="action" value="list">';
305print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
306print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
307print
'<input type="hidden" name="page" value="'.$page.
'">';
308print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
309print
'<input type="hidden" name="page_y" value="">';
310print
'<input type="hidden" name="mode" value="'.$mode.
'">';
313$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'));
314$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'));
318 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewGroup'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/group/card.php?action=create&leftmenu=',
'', $caneditperms ? 1 : 0);
321print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'object_'.
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
324$topicmail =
"SendGroup";
327$trackid =
'grp'.$object->id;
328include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
333 foreach ($fieldstosearchall as $key => $val) {
334 $fieldstosearchall[$key] = $langs->trans($val);
335 $setupstring .= $key.
"=".$val.
";";
337 print
'<!-- Search done like if GROUP_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
338 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
343$parameters = array();
344$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
345if (empty($reshook)) {
346 $moreforfilter .= $hookmanager->resPrint;
348 $moreforfilter = $hookmanager->resPrint;
351if (!empty($moreforfilter)) {
352 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
353 print $moreforfilter;
357$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
358$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
359$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
360$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
362print
'<div class="div-table-responsive">';
363print
'<table class="tagtable nobottomiftotal noborder liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
366$totalarray = array();
367$totalarray[
'nbfield'] = 0;
371print
'<tr class="liste_titre_filter">';
373if (
$conf->main_checkbox_left_column) {
374 print
'<td class="liste_titre center maxwidthsearch">';
375 $searchpicto = $form->showFilterButtons(
'left');
380$totalarray[
'nbfield']++;
382if (isModEnabled(
'multicompany') && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1) {
383 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
"g.entity", $param,
"",
'', $sortfield, $sortorder,
'center ');
384 $totalarray[
'nbfield']++;
386print_liste_field_titre(
"NbOfUsers", $_SERVER[
"PHP_SELF"],
"nb", $param,
"",
'', $sortfield, $sortorder,
'center ');
387$totalarray[
'nbfield']++;
388print_liste_field_titre(
"NbOfPermissions", $_SERVER[
"PHP_SELF"],
"nbpermissions", $param,
"",
'', $sortfield, $sortorder,
'center ');
389$totalarray[
'nbfield']++;
390print_liste_field_titre(
"DateCreationShort", $_SERVER[
"PHP_SELF"],
"g.datec", $param,
"",
'', $sortfield, $sortorder,
'center ');
391$totalarray[
'nbfield']++;
392print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"g.tms", $param,
"",
'', $sortfield, $sortorder,
'center ');
393$totalarray[
'nbfield']++;
395include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
397$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
398$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
399print $hookmanager->resPrint;
405if (!
$conf->main_checkbox_left_column) {
406 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
407 $totalarray[
'nbfield']++;
415$savnbfield = $totalarray[
'nbfield'];
416$totalarray = array();
417$totalarray[
'nbfield'] = 0;
418$imaxinloop = ($limit ? min($num, $limit) : $num);
419while ($i < $imaxinloop) {
420 $obj = $db->fetch_object($resql);
426 $object->setVarsFromFetchObj($obj);
430 $object->nb_rights = $obj->nbpermissions;
433 if ($mode ==
'kanban') {
435 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
436 print
'<div class="box-flex-container kanban">';
440 if ($massactionbutton || $massaction) {
442 if (in_array(
$object->id, $arrayofselected)) {
446 print
$object->getKanbanView(
'', array(
'selected' => $selected));
447 if ($i == ($imaxinloop - 1)) {
454 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
456 if (
$conf->main_checkbox_left_column) {
457 print
'<td class="nowrap center">';
458 if ($massactionbutton || $massaction) {
460 if (in_array(
$object->id, $arrayofselected)) {
463 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
467 $totalarray[
'nbfield']++;
471 print
'<td class="tdoverflowmax125">';
473 if (isModEnabled(
'multicompany') && !$obj->entity) {
474 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
478 $totalarray[
'nbfield']++;
481 if (isModEnabled(
'multicompany') && is_object($mc) && !
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1) {
482 $mc->getInfo($obj->entity);
483 print
'<td class="center">'.dol_escape_htmltag($mc->label).
'</td>';
485 $totalarray[
'nbfield']++;
488 print
'<td class="center">'.dol_escape_htmltag($obj->nb).
'</td>';
490 $totalarray[
'nbfield']++;
492 print
'<td class="center">';
493 print
'<a href="'.DOL_URL_ROOT.
'/user/group/perms.php?id='.$obj->rowid.
'">'.
dol_escape_htmltag($obj->nbpermissions).
'</a>';
496 $totalarray[
'nbfield']++;
498 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec),
"dayhour").
'</td>';
500 $totalarray[
'nbfield']++;
502 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->tms),
"dayhour").
'</td>';
504 $totalarray[
'nbfield']++;
507 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
509 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
510 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
511 print $hookmanager->resPrint;
513 if (empty(
$conf->main_checkbox_left_column)) {
514 print
'<td class="nowrap center">';
515 if ($massactionbutton || $massaction) {
517 if (in_array(
$object->id, $arrayofselected)) {
520 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
524 $totalarray[
'nbfield']++;
534include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
544 $colspan = $savnbfield;
545 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
550$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
551$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
552print $hookmanager->resPrint;
554print
'</table>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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, $allowothertags=array())
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.