New Add color fields on user group (#35646)

* Add color column to llx_usergroup table

* Add color column to llx_usergroup table

* Add color property to user group class

* Add color attribute to user group card

* Add ColorGroup translation to users.lang

* Add ColorGroup translation in French language file

* Fix SQL syntax for adding color column in llx_usergroup

* Fix SQL syntax for adding color column in llx_usergroup

* Fix color column addition in llx_usergroup table

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Charlène Benke
2025-10-28 02:26:49 +01:00
committed by GitHub
parent 88cf4654b4
commit e69f56acbe
6 changed files with 36 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ ALTER TABLE llx_opensurvey_user_studs ADD COLUMN tms timestamp DEFAULT CURRENT_T
-- V23 migration
ALTER TABLE llx_usergroup ADD color VARCHAR(6) AFTER tms;
UPDATE llx_actioncomm SET elementtype = 'project_task' WHERE elementtype = 'task';

View File

@@ -25,6 +25,7 @@ create table llx_usergroup
entity integer DEFAULT 1 NOT NULL, -- multi company id
datec datetime,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
color varchar(6),
note text,
model_pdf varchar(255) DEFAULT NULL
)ENGINE=innodb;

View File

@@ -151,3 +151,4 @@ TotalAPICall=Total API Calls
TOTP=TOTP (Time-base One-Time Password)
UserRemovedFromGroup=User removed from group
UserSetInGroup=User set in group
ColorGroup=Color of group

View File

@@ -149,3 +149,4 @@ SocialNetworksUser=Réseaux sociaux de l'utilisateur
MyTeam=Mon équipe
TotalAPICall=Nombre total d'appels API
TOTP=TOTP (mot de passe à usage unique basé sur le temps)
ColorGroup=Couleur du groupe

View File

@@ -9,6 +9,7 @@
* Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org>
* Copyright (C) 2023-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -90,6 +91,11 @@ class UserGroup extends CommonObject
*/
public $note;
/**
* @var string Color
*/
public $color;
/**
* @var User[] Array of users
*/
@@ -127,6 +133,7 @@ class UserGroup extends CommonObject
'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,),
'color' => array('type' => 'varchar(6)', 'label' => 'Color', 'enabled' => 1, 'visible' => 1, 'position' => 70, 'notnull' => -1, 'comment' => 'Color for pictogram'),
'model_pdf' => array('type' => 'varchar(255)', 'label' => 'ModelPDF', 'enabled' => 1, 'visible' => 0, 'position' => 100),
);

View File

@@ -7,6 +7,7 @@
* Copyright (C) 2018 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
/**
* @var Conf $conf
@@ -137,6 +139,7 @@ if (empty($reshook)) {
} else {
$object->name = GETPOST("nom", 'alphanohtml');
$object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml')));
$object->color = GETPOST("color", 'alphanohtml');
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
@@ -207,6 +210,7 @@ if (empty($reshook)) {
$object->name = GETPOST("nom", 'alphanohtml');
$object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'restricthtml')));
$object->color = GETPOST("color", 'alphanohtml');
$object->tms = dol_now();
// Fill array 'array_options' with data from add form
@@ -254,6 +258,7 @@ $form = new Form($db);
$fuserstatic = new User($db);
$form = new Form($db);
$formfile = new FormFile($db);
$formother = new FormOther($db);
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewGroup"), '', 'object_group');
@@ -280,9 +285,16 @@ if ($action == 'create') {
}
}
unset($object->fields['color']);
// Common attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
print '<tr><td>'.$langs->trans("ColorGroup").'</td>';
print '<td>';
print $formother->selectColor(GETPOSTISSET('color') ? GETPOST('color', 'alphanohtml') : $object->color, 'color', null, 1, array(), 'hideifnotset');
print '</td></tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
@@ -350,11 +362,17 @@ if ($action == 'create') {
}
unset($object->fields['nom']); // Name already displayed in banner
unset($object->fields['color']);
// Common attributes
$keyforbreak = '';
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
print '<tr><td>'.$langs->trans("ColorGroup").'</td>';
print '<td>';
print $formother->showColor($object->color, '');
print '</td></tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
@@ -533,9 +551,16 @@ if ($action == 'create') {
}
}
unset($object->fields['color']);
// Common attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
print '<tr><td>'.$langs->trans("ColorGroup").'</td>';
print '<td>';
print $formother->selectColor(GETPOSTISSET('color') ? GETPOST('color', 'alphanohtml') : $object->color, 'color', null, 1, array(), 'hideifnotset');
print '</td></tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';