From 10be9248882c4c4ec5f7c22f457bfdfc8123e6b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 14 Mar 2023 10:58:35 +0100 Subject: [PATCH] Look and feel v18 --- .../modulebuilder/template/myobject_list.php | 2 +- htdocs/user/class/usergroup.class.php | 2 +- htdocs/user/group/card.php | 2 +- htdocs/user/group/list.php | 101 ++++++++++++------ 4 files changed, 70 insertions(+), 37 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 7a3aae33d9c..e0cdd1f8ab4 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -547,7 +547,7 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters = array('type'=>$type); + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 9bf322b49b6..7f237b385ad 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -116,7 +116,7 @@ class UserGroup extends CommonObject 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), 'nom'=>array('type'=>'varchar(180)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Group name'), - 'note' => array('type'=>'html', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>-1,), + 'note' => array('type'=>'html', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>50, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>60, 'notnull'=>1,), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>100), diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 7bafaf5aee5..60c1c30e9fb 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -473,7 +473,7 @@ if ($action == 'create') { print "\n"; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; print ''; diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 94331d44d3d..54117de403a 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -30,9 +30,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; // Load translation files required by page -$langs->load("users"); +$langs->loadLangs(array("users")); -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation @@ -40,8 +40,8 @@ $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ09'); // Option for the css output (always '' except when 'print') -$mode = GETPOST('mode', 'aZ'); +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_group = GETPOST('search_group'); @@ -64,7 +64,7 @@ $pagenext = $page + 1; $object = new UserGroup($db); $extrafields = new ExtraFields($db); //$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; -//$hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -80,10 +80,12 @@ if (!$sortorder) { } // List of fields to search into when doing a "search in all" -$fieldstosearchall = array( - 'g.nom'=>"Group", - 'g.note'=>"Note" -); +$fieldstosearchall = array(); +foreach ($object->fields as $key => $val) { + if (!empty($val['searchall'])) { + $fieldstosearchall['t.'.$key] = $val['label']; + } +} if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { if (!$user->hasRight("user", "group_advance", "read") && !$user->admin) { @@ -102,6 +104,7 @@ if (!$user->hasRight("user", "user", "read") && !$user->admin) { // Defini si peux lire/modifier utilisateurs et permisssions $caneditperms = ($user->admin || $user->hasRight("user", "user", "write")); +$permissiontodelete = ($user->admin || $user->hasRight("user", "user", "write")); // Advanced permissions if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $caneditperms = ($user->admin || $user->hasRight("user", "group_advance", "write")); @@ -146,6 +149,12 @@ if (empty($reshook)) { || 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 = 'UserGroup'; + $objectlabel = 'UserGroup'; + $uploaddir = $conf->user->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -155,8 +164,10 @@ if (empty($reshook)) { $form = new Form($db); -$help_url = ''; +$now = dol_now(); + $title = $langs->trans("UserGroups"); +$help_url = ''; $morejs = array(); $morecss = array(); @@ -214,7 +225,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); + $param .= '&limit='.((int) $limit); } foreach ($search as $key => $val) { if (is_array($search[$key])) { @@ -238,7 +249,7 @@ if ($optioncss != '') { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Add $param from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $param .= $hookmanager->resPrint; // List of mass actions available @@ -267,6 +278,7 @@ print ''; print ''; print ''; print ''; +print ''; print ''; $newcardbutton = ''; @@ -274,11 +286,18 @@ $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars i $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')); if ($caneditperms) { + $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('NewGroup'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/group/card.php?action=create&leftmenu='); } +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_group', 0, $newcardbutton, '', $limit, 0, 0, 1); +// Add code for pre mass action (confirmation or email presend form) +$topicmail = "SendGroup"; +$modelmail = "group"; +$objecttmp = new UserGroup($db); +$trackid = 'grp'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { $setupstring = ''; @@ -286,14 +305,14 @@ if ($search_all) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; } - print ''."\n"; + print ''."\n"; print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { @@ -303,16 +322,15 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print '
'; } $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$arrayfields = array(); -$selectedfields = ''; -if (!empty($arrayfields)) { - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields - $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -} +$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''."\n"; @@ -327,8 +345,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; } print_liste_field_titre("Group", $_SERVER["PHP_SELF"], "g.nom", $param, "", "", $sortfield, $sortorder); $totalarray['nbfield']++; @@ -349,17 +368,17 @@ $totalarray['nbfield']++; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { print ''; $totalarray['nbfield']++; }*/ // Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; } -$totalarray['nbfield']++; // For the column action print ''."\n"; @@ -390,6 +409,12 @@ while ($i < $imaxinloop) { print '
'; } // Output Kanban + 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($object->id, $arrayofselected)) { + $selected = 1; + } + } print $object->getKanbanView(''); if ($i == ($imaxinloop - 1)) { print '
'; @@ -400,7 +425,7 @@ while ($i < $imaxinloop) { $j = 0; print ''; // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } print ''; - } - if (!$i) { - $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } print ''."\n"; @@ -485,7 +513,12 @@ if ($num == 0) { $colspan++; } }*/ - $colspan = $savnbfield; + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print ''; }
'.$langs->trans("AnotherField").'
'; 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; @@ -410,6 +435,9 @@ while ($i < $imaxinloop) { print ''; } print ''; @@ -451,10 +479,10 @@ while ($i < $imaxinloop) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; 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; @@ -464,9 +492,9 @@ while ($i < $imaxinloop) { print ''; } print '
'.$langs->trans("NoRecordFound").'