NEW #22546 : can now set user supervisors using mass action in htdocs/user
This commit is contained in:
parent
62c3d3b2f0
commit
168ea58a07
@ -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();
|
||||
|
||||
|
||||
@ -78,6 +78,24 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($massaction == 'presetsupervisor') {
|
||||
$formquestion = array();
|
||||
|
||||
$valuefield = '<div style="display: flex; align-items: center; justify-content: flex-end; padding-right: 150px">';
|
||||
$valuefield .= img_picto('', 'user').' ';
|
||||
$valuefield .= $form->select_dolusers('', 'supervisortoset', 1, $arrayofselected, 0, '', 0, $object->entity, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
|
||||
$valuefield .= '</div>';
|
||||
|
||||
$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");
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user