diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index f2c2643c2bc..4dac837e45b 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -129,6 +129,11 @@ if ($action == 'add' && $user->hasRight('mailing', 'creer')) { // Add recipient
}
}
if ($result > 0) {
+ // If status of emailing is sent completely, change to to send partially
+ if ($object->status == $object::STATUS_SENTCOMPLETELY) {
+ $object->setStatut($object::STATUS_SENTPARTIALY);
+ }
+
setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs');
$action = '';
}
@@ -400,7 +405,14 @@ if ($object->fetch($id) >= 0) {
print '
';
+ $newcardbutton = '';
$allowaddtarget = ($object->status == $object::STATUS_DRAFT);
+ if (GETPOST('allowaddtarget')) {
+ $allowaddtarget = 1;
+ }
+ if (!$allowaddtarget) {
+ $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&allowaddtarget=1', '', $user->hasRight('mailing', 'creer'));
+ }
// Show email selectors
if ($allowaddtarget && $user->hasRight('mailing', 'creer')) {
@@ -658,14 +670,14 @@ if ($object->fetch($id) >= 0) {
print '';
$morehtmlcenter = '';
- if ($allowaddtarget) {
+ if ($object->status == $object::STATUS_DRAFT) {
$morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").' id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").'';
}
$morehtmlcenter .= ' id.'">'.img_picto('', 'download', 'class="pictofixedwidth"').$langs->trans("Download").'';
$massactionbutton = '';
- print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit, 0, 0, 1);
+ print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1);
print '';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index bc2ce54bc6f..b96df8f998b 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4519,7 +4519,7 @@ abstract class CommonObject
*/
public function setStatut($status, $elementId = null, $elementType = '', $trigkey = '', $fieldstatus = 'fk_statut')
{
- global $user, $langs, $conf;
+ global $user;
$savElementId = $elementId; // To be used later to know if we were using the method using the id of this or not.