diff --git a/ChangeLog b/ChangeLog index c81af41cfa2..030a0f68c4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,6 +52,7 @@ For users: - Fix: Price min of composition is not supplier price min by quantity - Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers - New: Add categories translation +- New: Enable option "clone target emailing" TODO - New: Predefined product and free product use same form. diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index a0094c2f3f6..a6db4738bb5 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -305,8 +305,55 @@ class Mailing extends CommonObject if (! $error) { - - + //Clone target + if (!empty($option2)) { + + require_once DOL_DOCUMENT_ROOT .'/core/modules/mailings/modules_mailings.php'; + + $mailing_target = new MailingTargets($this->db); + + $target_array=array(); + + $sql = "SELECT fk_contact, "; + $sql.=" lastname, "; + $sql.=" firstname,"; + $sql.=" email,"; + $sql.=" other,"; + $sql.=" source_url,"; + $sql.=" source_id ,"; + $sql.=" source_type "; + $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles "; + $sql.= " WHERE fk_mailing = ".$fromid; + + dol_syslog(get_class($this)."::createFromClone sql=".$sql); + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + while ($obj = $this->db->fetch_object($result)) { + + $target_array[]=array('fk_contact'=>$obj->fk_contact, + 'lastname'=>$obj->lastname, + 'firstname'=>$obj->firstname, + 'email'=>$obj->email, + 'other'=>$obj->other, + 'source_url'=>$obj->source_url, + 'source_id'=>$obj->source_id, + 'source_type'=>$obj->source_type); + } + + } + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog("Mailing::createFromClone ".$this->error, LOG_ERR); + return -1; + } + + $mailing_target->add_to_target($object->id, $target_array); + } } diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 03caf79d9d5..9d6a31cdfac 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -822,7 +822,7 @@ else $formquestion=array( 'text' => $langs->trans("ConfirmClone"), array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), - array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true) + array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers"), 'value' => 0) ); // Paiement incomplet. On demande si motif = escompte ou autre print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$object->ref),'confirm_clone',$formquestion,'yes',2,240); diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 98874ba4804..08f3bb2c062 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -711,7 +711,7 @@ else if (! empty($conf->mailing->enabled)) { $langs->load("mails"); - print ''.$langs->trans("NbOfEMailingsReceived").''; + print ''.$langs->trans("NbOfEMailingsSend").''; print ''.$object->getNbOfEMailings().''; } else @@ -936,7 +936,7 @@ else if (! empty($conf->mailing->enabled)) { $langs->load("mails"); - print ''.$langs->trans("NbOfEMailingsReceived").''; + print ''.$langs->trans("NbOfEMailingsSend").''; print ''.$object->getNbOfEMailings().''; } else diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 4f0599bfb3b..6f4a573ccfc 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -168,7 +168,7 @@ class MailingTargets // This can't be abstract as it is used for some method $sql.= "'".$this->db->escape($targetarray['other'])."',"; $sql.= "'".$this->db->escape($targetarray['source_url'])."',"; $sql.= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").","; - $sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; + $sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; $sql .= "'".$this->db->escape($targetarray['source_type'])."')"; $result=$this->db->query($sql); if ($result) diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 78d59e4c93d..2fd9c09c534 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -119,6 +119,7 @@ TargetsReset=Clear list ToClearAllRecipientsClickHere=Click here to clear the recipient list for this emailing ToAddRecipientsChooseHere=Add recipients by choosing from the lists NbOfEMailingsReceived=Mass emailings received +NbOfEMailingsSend=Mass emailings sent IdRecord=ID record DeliveryReceipt=Delivery Receipt YouCanUseCommaSeparatorForSeveralRecipients=You can use the comma separator to specify several recipients. diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 80f159ffa26..2fad3fb790e 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -121,6 +121,7 @@ TargetsReset=Vider liste ToClearAllRecipientsClickHere=Pour vider la liste des destinataires de cet emailing, cliquez sur le bouton ToAddRecipientsChooseHere=Pour ajouter des destinataires, choisir dans les listes ci-dessous NbOfEMailingsReceived=Emailings de masse reçus +NbOfEMailingsSend=Emailings de masse envoyé(s) IdRecord=ID enregistrement DeliveryReceipt=Accusé de réception YouCanUseCommaSeparatorForSeveralRecipients=Vous pouvez utiliser le caractère de séparation virgule pour spécifier plusieurs destinataires.