Merge pull request #18140 from Hystepik/develop#2

Close #18131 : new massaction for thirdparty
This commit is contained in:
Laurent Destailleur 2021-07-13 11:45:47 +02:00 committed by GitHub
commit e5ed5edeab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 1 deletions

View File

@ -1470,6 +1470,80 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd
}
}
if (!$error && ($massaction == 'enable' || ($action == 'enable' && $confirm == 'yes')) && $permissiontoadd) {
$db->begin();
$objecttmp = new $objectclass($db);
$nbok = 0;
foreach ($toselect as $toselectid) {
$result = $objecttmp->fetch($toselectid);
if ($result>0) {
if (in_array($objecttmp->element, array('societe'))) {
$result =$objecttmp->setStatut(1);
}
if ($result <= 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
} else {
$nbok++;
}
} else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
}
}
if (!$error) {
if ($nbok > 1) {
setEventMessages($langs->trans("RecordsEnabled", $nbok), null, 'mesgs');
} else {
setEventMessages($langs->trans("RecordEnabled"), null, 'mesgs');
}
$db->commit();
} else {
$db->rollback();
}
}
if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == 'yes')) && $permissiontoadd) {
$db->begin();
$objecttmp = new $objectclass($db);
$nbok = 0;
foreach ($toselect as $toselectid) {
$result = $objecttmp->fetch($toselectid);
if ($result>0) {
if (in_array($objecttmp->element, array('societe'))) {
$result =$objecttmp->setStatut(0);
}
if ($result <= 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
} else {
$nbok++;
}
} else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
}
}
if (!$error) {
if ($nbok > 1) {
setEventMessages($langs->trans("RecordsDisabled", $nbok), null, 'mesgs');
} else {
setEventMessages($langs->trans("RecordDisabled"), null, 'mesgs');
}
$db->commit();
} else {
$db->rollback();
}
}
$parameters['toselect'] = $toselect;
$parameters['uploaddir'] = $uploaddir;
$parameters['massaction'] = $massaction;

View File

@ -194,6 +194,14 @@ if ($massaction == 'presend') {
print dol_get_fiche_end();
}
if ($massaction == 'preenable') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassEnabling"), $langs->trans("ConfirmMassEnablingQuestion", count($toselect)), "enable", null, '', 0, 200, 500, 1);
}
if ($massaction == 'predisable') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDisabling"), $langs->trans("ConfirmMassDisablingQuestion", count($toselect)), "disable", null, '', 0, 200, 500, 1);
}
// Allow Pre-Mass-Action hook (eg for confirmation dialog)
$parameters = array(
'toselect' => $toselect,

View File

@ -1137,3 +1137,13 @@ 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
EmailMsgID=Email MsgID
SetToEnabled=Set to enabled
SetToDisabled=Set to disabled
ConfirmMassEnabling=mass enabling confirmation
ConfirmMassEnablingQuestion=Are you sure you want to enable the %s selected record(s)?
ConfirmMassDisabling=mass disabling confirmation
ConfirmMassDisablingQuestion=Are you sure you want to disable the %s selected record(s)?
RecordsEnabled=%s record(s) enabled
RecordsDisabled=%s record(s) disabled
RecordEnabled=Record enabled
RecordDisabled=Record disabled

View File

@ -1137,3 +1137,13 @@ CopiedToClipboard=Copié dans le presse-papier
InformationOnLinkToContract=Ce montant nest que le total de toutes les lignes du contrat. Aucune notion de temps nest prise en considération.
ConfirmCancel=Êtes-vous sûr de vous annuler
EmailMsgID=E-mail MsgID
SetToEnabled=Activer
SetToDisabled=Désactiver
ConfirmMassEnabling=Confirmation d'activation en masse
ConfirmMassEnablingQuestion=Êtes-vous sur de vouloir activer les %s enregistrement(s) sélectionné(s) ?
ConfirmMassDisabling=Confirmation de desactivation en masse
ConfirmMassDisablingQuestion=Êtes-vous sur de vouloir desactiver les %s enregistrement(s) sélectionné(s) ?
RecordsEnabled=%s enregistrement(s) activé(s)
RecordsDisabled=%s enregistrement(s) désactivé(s)
RecordEnabled=Enregistrement activé
RecordDisabled=Enregistrement désactivé

View File

@ -865,7 +865,13 @@ if ($user->rights->societe->supprimer) {
if ($user->rights->societe->creer) {
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
if ($user->rights->societe->creer) {
$arrayofmassactions['preenable'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("SetToEnabled");
}
if ($user->rights->societe->creer) {
$arrayofmassactions['predisable'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("SetToDisabled");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);