29 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
33 $langs->load(
"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',
'aZ09');
46 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
47 $search_group =
GETPOST(
'search_group');
50 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
51 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
58 $offset = $limit * $page;
59 $pageprev = $page - 1;
60 $pagenext = $page + 1;
69 $extrafields->fetch_name_optionals_label($object->table_element);
72 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
82 $fieldstosearchall = array(
87 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
88 if (!$user->hasRight(
"user",
"group_advance",
"read") && !$user->admin) {
94 if (
isModEnabled(
'multicompany') && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) {
98 if (!$user->hasRight(
"user",
"user",
"read") && !$user->admin) {
103 $caneditperms = ($user->admin || $user->hasRight(
"user",
"user",
"write"));
105 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
106 $caneditperms = ($user->admin || $user->hasRight(
"user",
"group_advance",
"write"));
114 if (
GETPOST(
'cancel',
'alpha')) {
118 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
122 $parameters = array();
123 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
128 if (empty($reshook)) {
130 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
133 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
134 foreach ($object->fields as $key => $val) {
136 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
137 $search[$key.
'_dtstart'] =
'';
138 $search[$key.
'_dtend'] =
'';
142 $search_array_options = array();
144 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
145 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
156 $title = $langs->trans(
"UserGroups");
161 $sql =
"SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms as datem, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions";
162 $sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as g";
163 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
164 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_rights as ugr ON ugr.fk_usergroup = g.rowid";
165 if (
isModEnabled(
'multicompany') && $conf->entity == 1 && (
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') || ($user->admin && !$user->entity))) {
166 $sql .=
" WHERE g.entity IS NOT NULL";
168 $sql .=
" WHERE g.entity IN (0,".$conf->entity.
")";
170 if (!empty($search_group)) {
176 $sql .=
" GROUP BY g.rowid, g.nom, g.note, g.entity, g.datec, g.tms";
179 $sql .= $db->order($sortfield, $sortorder);
181 $sql .= $db->plimit($limit + 1, $offset);
184 $resql = $db->query($sql);
190 $num = $db->num_rows(
$resql);
203 $arrayofselected = is_array($toselect) ? $toselect : array();
205 $param =
"&search_group=".urlencode($search_group).
"&search_all=".urlencode($search_all);
207 $param .=
'&mode='.urlencode($mode);
209 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
210 $param .=
'&contextpage='.urlencode($contextpage);
212 if ($limit > 0 && $limit != $conf->liste_limit) {
213 $param .=
'&limit='.urlencode($limit);
215 foreach ($search as $key => $val) {
216 if (is_array($search[$key])) {
217 foreach ($search[$key] as $skey) {
219 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
222 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
223 $param .=
'&search_'.$key.
'month='.((int)
GETPOST(
'search_'.$key.
'month',
'int'));
224 $param .=
'&search_'.$key.
'day='.((int)
GETPOST(
'search_'.$key.
'day',
'int'));
225 $param .=
'&search_'.$key.
'year='.((int)
GETPOST(
'search_'.$key.
'year',
'int'));
226 } elseif ($search[$key] !=
'') {
227 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
230 if ($optioncss !=
'') {
231 $param .=
'&optioncss='.urlencode($optioncss);
234 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
235 if ($optioncss !=
'') {
236 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
238 print
'<input type="hidden" name="token" value="'.newToken().
'">';
239 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
240 print
'<input type="hidden" name="action" value="list">';
241 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
242 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
243 print
'<input type="hidden" name="page" value="'.$page.
'">';
244 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
245 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
248 $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'));
249 $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'));
252 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewGroup'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/user/group/card.php?action=create&leftmenu=');
256 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'object_group', 0, $newcardbutton,
'', $limit, 0, 0, 1);
260 foreach ($fieldstosearchall as $key => $val) {
261 $fieldstosearchall[$key] = $langs->trans($val);
262 $setupstring .= $key.
"=".$val.
";";
264 print
'<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
265 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
273 print
'<div class="div-table-responsive">';
274 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
282 print
'<tr class="liste_titre">';
283 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
284 print
getTitleFieldOfList(($mode !=
'kanban' ? $selectedfields :
''), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
287 $totalarray[
'nbfield']++;
289 if (
isModEnabled(
'multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
290 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
"g.entity", $param,
"",
'', $sortfield, $sortorder,
'center ');
291 $totalarray[
'nbfield']++;
293 print_liste_field_titre(
"NbOfUsers", $_SERVER[
"PHP_SELF"],
"nb", $param,
"",
'', $sortfield, $sortorder,
'center ');
294 $totalarray[
'nbfield']++;
295 print_liste_field_titre(
"NbOfPermissions", $_SERVER[
"PHP_SELF"],
"nbpermissions", $param,
"",
'', $sortfield, $sortorder,
'center ');
296 $totalarray[
'nbfield']++;
297 print_liste_field_titre(
"DateCreationShort", $_SERVER[
"PHP_SELF"],
"g.datec", $param,
"",
'', $sortfield, $sortorder,
'center ');
298 $totalarray[
'nbfield']++;
299 print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"g.tms", $param,
"",
'', $sortfield, $sortorder,
'center ');
300 $totalarray[
'nbfield']++;
302 $totalarray[
'nbfield']++;
308 $savnbfield = $totalarray[
'nbfield'];
309 $totalarray = array();
310 $totalarray[
'nbfield'] = 0;
311 $imaxinloop = ($limit ? min($num, $limit) : $num);
312 while ($i < $imaxinloop) {
313 $obj = $db->fetch_object(
$resql);
319 $object->setVarsFromFetchObj($obj);
321 $object->name = $obj->name;
322 $object->note = $obj->note;
323 $object->members = $obj->nb;
324 $object->nb_rights = $obj->nbpermissions;
326 if ($mode ==
'kanban') {
328 print
'<tr><td colspan="'.$savnbfield.
'">';
329 print
'<div class="box-flex-container">';
332 print $object->getKanbanView(
'');
333 if ($i == ($imaxinloop - 1)) {
340 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
342 if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
343 print
'<td class="nowrap center">';
344 if ($massactionbutton || $massaction) {
346 if (in_array($object->id, $arrayofselected)) {
349 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
355 print $object->getNomUrl(1);
357 print
img_picto($langs->trans(
"GlobalGroup"),
'redstar');
361 if (
isModEnabled(
'multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
362 $mc->getInfo($obj->entity);
363 print
'<td class="center">'.dol_escape_htmltag($mc->label).
'</td>';
365 print
'<td class="center">'.$obj->nb.
'</td>';
366 print
'<td class="center">';
367 print
'<a href="'.DOL_URL_ROOT.
'/user/group/perms.php?id='.$obj->rowid.
'">'.$obj->nbpermissions.
'</a>';
369 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->datec),
"dayhour").
'</td>';
370 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->datem),
"dayhour").
'</td>';
372 if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
373 print
'<td class="nowrap center">';
374 if ($massactionbutton || $massaction) {
376 if (in_array($object->id, $arrayofselected)) {
379 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
384 $totalarray[
'nbfield']++;
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.