Merge pull request #20613 from Hystepik/develop#1
NEW #20609 : new massaction to assign a sale representatives on a selection of thirdparties
This commit is contained in:
commit
c4a96957af
@ -1602,6 +1602,44 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm ==
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && ($massaction == 'affectcommercial' || ($action == 'affectcommercial' && $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->setSalesRep(GETPOST("commercial", "alpha"));
|
||||
}
|
||||
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("CommercialsAffected", $nbok), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("CommercialAffected"), null, 'mesgs');
|
||||
}
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
// Approve for leave only
|
||||
if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) {
|
||||
$db->begin();
|
||||
|
||||
@ -217,7 +217,15 @@ if ($massaction == 'preenable') {
|
||||
if ($massaction == 'predisable') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDisabling"), $langs->trans("ConfirmMassDisablingQuestion", count($toselect)), "disable", null, '', 0, 200, 500, 1);
|
||||
}
|
||||
|
||||
if ($massaction == 'presetcommercial') {
|
||||
$formquestion = array();
|
||||
$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1);
|
||||
$formquestion[] = array('type' => 'other',
|
||||
'name' => 'affectedcommercial',
|
||||
'label' => $form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0),
|
||||
'value' => $form->multiselectarray('commercial', $userlist, null, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1));
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAllocateCommercial"), $langs->trans("ConfirmAllocateCommercialQuestion", count($toselect)), "affectcommercial", $formquestion, 1, 0, 200, 500, 1);
|
||||
}
|
||||
if ($massaction == 'preapproveleave') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassLeaveApproval"), $langs->trans("ConfirmMassLeaveApprovalQuestion", count($toselect)), "approveleave", null, 'yes', 0, 200, 500, 1);
|
||||
}
|
||||
|
||||
@ -1169,3 +1169,7 @@ CanceledShown=Canceled shown
|
||||
Terminate=Terminate
|
||||
Terminated=Terminated
|
||||
AddLineOnPosition=Add line on position (at the end if empty)
|
||||
ConfirmAllocateCommercial=Assign sales representative confirmation
|
||||
ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)?
|
||||
CommercialsAffected=Sales representatives affected
|
||||
CommercialAffected=Sales representative affected
|
||||
@ -875,6 +875,9 @@ if ($user->rights->societe->creer) {
|
||||
if ($user->rights->societe->creer) {
|
||||
$arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToDisabled");
|
||||
}
|
||||
if ($user->rights->societe->creer) {
|
||||
$arrayofmassactions['presetcommercial'] = img_picto('', '', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial");
|
||||
}
|
||||
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
|
||||
$arrayofmassactions = array();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user