From 26befa3b93f2f2fb51d03296f1e9ac7cbb64ce17 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 13 Apr 2020 15:38:50 +0200 Subject: [PATCH] New fields on usergroup object + card uses common tpl --- htdocs/user/class/usergroup.class.php | 10 ++ htdocs/user/group/card.php | 135 ++++++++++++-------------- 2 files changed, 70 insertions(+), 75 deletions(-) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 1f8040a83ea..9c48c321196 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -100,6 +100,16 @@ class UserGroup extends CommonObject public $oldcopy; // To contains a clone of this when we need to save old properties of object + public $fields = array( + '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,), + '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), + ); + /** * Constructor de la classe diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 335b66ebdd2..f3ae62beed8 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -54,6 +54,7 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'groupcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); $userid = GETPOST('user', 'int'); @@ -91,19 +92,20 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { + + $backurlforlist = DOL_URL_ROOT.'/user/group/list.php'; + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/user/group/card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + } + } + if ($cancel) { - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } - else - { - header("Location: ".DOL_URL_ROOT.'/user/group/list.php'); - exit; - } - $action = ''; + header("Location: ".$backtopage); + exit; } // Action remove group @@ -215,7 +217,7 @@ if (empty($reshook)) { $object->oldcopy = clone $object; - $object->name = trim(GETPOST("group", 'nohtml')); + $object->name = trim(GETPOST("nom", 'nohtml')); $object->nom = $object->name; // For backward compatibility $object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'none'))); @@ -273,14 +275,11 @@ if ($action == 'create') print '
'; print ''; print ''; + print ''; dol_fiche_head('', '', '', 0, ''); - print ''; - - print ""; - print ''; - print ''; + print '
'.$langs->trans("Name").'
'; // Multicompany if (!empty($conf->multicompany->enabled) && is_object($mc)) @@ -297,27 +296,18 @@ if ($action == 'create') } } - print "".'\n"; + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; // Other attributes - $parameters = array('object' => $object); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - print "
'.$langs->trans("Description").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', '', '', 240, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%'); - $doleditor->Create(); - print "
\n"; + print "\n"; dol_fiche_end(); print '
'; - print ''; + print ''; print '   '; print ''; print '
'; @@ -359,6 +349,7 @@ else dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin); print '
'; + print '
'; print '
'; print ''; @@ -384,19 +375,18 @@ else print "\n"; } - // Note - print ''; - print ''; - print "\n"; + // Common attributes + $keyforbreak = ''; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Other attributes - $parameters = array('colspan' => ' colspan="2"'); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - print "
'.$langs->trans("Description").''; - print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note)); - print '
\n"; - print '
'; + print ''; + print '
'; + print ''; + + print '
'; dol_fiche_end(); @@ -407,6 +397,10 @@ else print '
'; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($caneditperms) { print ''.$langs->trans("Modify").''; @@ -421,7 +415,7 @@ else // List users in group - print load_fiche_titre($langs->trans("ListOfUsersInGroup"), '', ''); + print load_fiche_titre($langs->trans("ListOfUsersInGroup"), '', 'user'); // On selectionne les users qui ne sont pas deja dans le groupe $exclude = array(); @@ -485,7 +479,7 @@ else print ''; print ''.$useringroup->lastname.''; print ''.$useringroup->firstname.''; - print ''.$useringroup->getLibStatut(3).''; + print ''.$useringroup->getLibStatut(5).''; print ''; if (!empty($user->admin)) { print ''; @@ -542,53 +536,44 @@ else if ($action == 'edit' && $caneditperms) { - print ''; + print ''; print ''; print ''; + print ''; + print ''; dol_fiche_head($head, 'group', $title, 0, 'group'); - print ''; - print ''; - print '\n"; + print '
'.$langs->trans("Name").''; - print "
'."\n"; - // Multicompany - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) - { - print "".''; - print "\n"; - } - else - { + // Multicompany + if (!empty($conf->multicompany->enabled) && is_object($mc)) + { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) + { + print "".''; + print "\n"; + } + else + { print ''; } - } + } + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - print ''; - print ''; - print "\n"; // Other attributes - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - print "
'.$langs->trans("Entity").'".$mc->select_entities($object->entity); - print "
'.$langs->trans("Entity").'".$mc->select_entities($object->entity); + print "
'.$langs->trans("Description").''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('note', $object->note, '', 240, 'dolibarr_notes', '', true, false, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%'); - $doleditor->Create(); - print '
\n"; + print ''; dol_fiche_end(); - print '
'; + print '
'; + print '   '; + print '
'; print ''; }