diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 9a2eda2df8e..49cc6fa873c 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -1240,6 +1240,45 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd
}
}
+if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiontoadd) {
+ $db->begin();
+ $supervisortoset=GETPOST('supervisortoset');
+ if (!empty($supervisortoset)) {
+ foreach ($toselect as $toselectid) {
+ $result = $object->fetch($toselectid);
+ //var_dump($contcats);exit;
+ if ($result > 0) {
+ $object->fk_user = $supervisortoset;
+ $res = $object->update($user);
+ if ($res > 0) {
+ $nbok++;
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ } else {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $error++;
+ break;
+ }
+ }
+ } else {
+ setEventMessage('UserNotFound', 'errors');
+ $error++;
+ }
+
+ if (!$error) {
+ if ($nbok > 1) {
+ setEventMessages($langs->trans("RecordsModified", $nbok), null);
+ } else {
+ setEventMessages($langs->trans("RecordsModified", $nbok), null);
+ }
+ $db->commit();
+ $toselect=array();
+ } else {
+ $db->rollback();
+ }
+}
+
if (!$error && ($massaction == 'enable' || ($action == 'enable' && $confirm == 'yes')) && $permissiontoadd) {
$db->begin();
diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php
index 8a8222101ee..f09d7defeb1 100644
--- a/htdocs/core/tpl/massactions_pre.tpl.php
+++ b/htdocs/core/tpl/massactions_pre.tpl.php
@@ -78,6 +78,24 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) {
}
}
+if ($massaction == 'presetsupervisor') {
+ $formquestion = array();
+
+ $valuefield = '
';
+ $valuefield .= img_picto('', 'user').' ';
+ $valuefield .= $form->select_dolusers('', 'supervisortoset', 1, $arrayofselected, 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
+ $valuefield .= '
';
+
+ $formquestion[] = array(
+ 'type' => 'other',
+ 'name' => 'supervisortoset',
+ 'label' => $langs->trans("Supervisor"),
+ 'value' => $valuefield
+ );
+
+ print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmSetSupervisor"), $langs->trans("ConfirmSetSupervisorQuestion", count($toselect)), "setsupervisor", $formquestion, 1, 0, 200, 500, 1);
+}
+
if ($massaction == 'presend') {
$langs->load("mails");
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 2b021f406f3..325e27b6606 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -1146,10 +1146,14 @@ UpdateForAllLines=Update for all lines
OnHold=On hold
Civility=Civility
AffectTag=Affect Tag
+SetSupervisor=Set Supervisor
CreateExternalUser=Create external user
ConfirmAffectTag=Bulk Tag Affect
+ConfirmSetSupervisor=Bulk Supervisor Set
ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)?
+ConfirmSetSupervisorQuestion=Are you sure you want to set supervisor to the %s selected record(s)?
CategTypeNotFound=No tag type found for type of records
+SupervisorNotFound=Supervisor not found
CopiedToClipboard=Copied to clipboard
InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration.
ConfirmCancel=Are you sure you want to cancel
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 3770780df7e..1406a0ddbaa 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -1146,10 +1146,14 @@ UpdateForAllLines=Mise à jour de toutes les lignes
OnHold=En attente
Civility=Civilité
AffectTag=Affecter un tag/catégorie
+SetSupervisor=Choisir un superviseur
CreateExternalUser=Créer utilisateur externe
ConfirmAffectTag=Affecter les tags en masse
+ConfirmSetSupervisor=Choisir un superviseur en masse
ConfirmAffectTagQuestion=Êtes-vous sur de vouloir affecter ces catégories aux %s lignes sélectionnées ?
+ConfirmSetSupervisorQuestion=Êtes-vous sur de vouloir affecter ce superviseur aux %s lignes sélectionnées ?
CategTypeNotFound=Aucun type de tag trouvé pour ce type d'enregistrements
+SupervisorNotFound=Supervisuer non trouvé
CopiedToClipboard=Copié dans le presse-papier
InformationOnLinkToContract=Ce montant n’est que le total de toutes les lignes du contrat. Aucune notion de temps n’est prise en considération.
ConfirmCancel=Êtes-vous sûr de vouloir annuler
diff --git a/htdocs/user/list.php b/htdocs/user/list.php
index 72b00c75577..05d2f88c035 100644
--- a/htdocs/user/list.php
+++ b/htdocs/user/list.php
@@ -604,9 +604,12 @@ if ($permissiontoadd) {
if (isModEnabled('category') && $permissiontoadd) {
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
}
+if ($permissiontoadd) {
+ $arrayofmassactions['presetsupervisor'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("SetSupervisor");
+}
//if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'presetsupervisor'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);