Can make a clone of an emailing
This commit is contained in:
parent
658203982c
commit
b693d9ed62
@ -157,7 +157,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
|
||||
$head[$h][1] = $langs->trans("MailHistory");
|
||||
$h++;
|
||||
*/
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing").": ".substr($mil->titre,0,20));
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing"));
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
@ -175,7 +175,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
|
||||
|
||||
$var=!$var;
|
||||
|
||||
// Affiche les listes de sélection
|
||||
// Affiche les listes de s<EFBFBD>lection
|
||||
if ($mil->statut == 0)
|
||||
{
|
||||
print_titre($langs->trans("ToAddRecipientsChooseHere"));
|
||||
@ -222,12 +222,12 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
|
||||
if (! $conf->$key->enabled || (! $user->admin && $obj->require_admin))
|
||||
{
|
||||
$qualified=0;
|
||||
//print "Les prérequis d'activation du module mailing ne sont pas respectés. Il ne sera pas actif";
|
||||
//print "Les pr<EFBFBD>requis d'activation du module mailing ne sont pas respect<63>s. Il ne sera pas actif";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Si le module mailing est qualifié
|
||||
// Si le module mailing est qualifi<EFBFBD>
|
||||
if ($qualified)
|
||||
{
|
||||
$var = !$var;
|
||||
@ -301,7 +301,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0)
|
||||
|
||||
|
||||
|
||||
// Liste des destinataires sélectionnés
|
||||
// Liste des destinataires s<EFBFBD>lectionn<EFBFBD>s
|
||||
print "\n<!-- Liste destinataires selectionnes -->\n";
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
/**
|
||||
\file htdocs/comm/mailing/fiche.php
|
||||
\ingroup mailing
|
||||
\brief Fiche mailing, onglet général
|
||||
\brief Fiche mailing, onglet g<EFBFBD>n<EFBFBD>ral
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
@ -50,12 +50,32 @@ $substitutionarrayfortest=array(
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Action envoi mailing pour tous
|
||||
if ($_POST["action"] == 'confirm_clone')
|
||||
{
|
||||
if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mil=new Mailing($db);
|
||||
$result=$mil->createFromClone($_REQUEST['id'],$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]);
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/comm/mailing/fiche.php?id='.$result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Action envoi mailing pour tous
|
||||
if ($_POST["action"] == 'sendallconfirmed')
|
||||
{
|
||||
if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
|
||||
{
|
||||
// Pour des raisons de sécurité, on ne permet pas cette fonction via l'IHM,
|
||||
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
|
||||
// on affiche donc juste un message
|
||||
$message='<div class="warning">'.$langs->trans("MailingNeedCommand").'</div>';
|
||||
$message.='<br><textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/mailing/mailing-send.php '.$_GET["id"].'</textarea>';
|
||||
@ -64,51 +84,31 @@ if ($_POST["action"] == 'sendallconfirmed')
|
||||
}
|
||||
else
|
||||
{
|
||||
$id=$_GET['id'];
|
||||
|
||||
$error = 0;
|
||||
|
||||
// On récupére données du mail
|
||||
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body";
|
||||
$sql .= " , m.email_from, m.email_replyto, m.email_errorsto";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
|
||||
$sql .= " WHERE m.statut >= 1";
|
||||
$sql .= " AND m.rowid= ".$id;
|
||||
$sql .= " LIMIT 1";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
$mil=new Mailing($db);
|
||||
$result=$mil->fetch($_GET['id']);
|
||||
|
||||
if ($mil->statut == 0)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
if ($num == 1)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
dolibarr_syslog("mailing-send: mailing ".$id, LOG_DEBUG);
|
||||
|
||||
$id = $obj->rowid;
|
||||
$subject = $obj->sujet;
|
||||
$message = $obj->body;
|
||||
$from = $obj->email_from;
|
||||
$errorsto = $obj->email_errorsto;
|
||||
|
||||
// Le message est-il en html
|
||||
$msgishtml=-1; // Unknown by default
|
||||
if (eregi('[ \t]*<html>',$message)) $msgishtml=1;
|
||||
|
||||
$i++;
|
||||
}
|
||||
dolibarr_print_error('','ErrorMailIsNotValidated');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$id = $mil->id;
|
||||
$subject = $mil->sujet;
|
||||
$message = $mil->body;
|
||||
$from = $mil->email_from;
|
||||
$errorsto = $mil->email_errorsto;
|
||||
// Le message est-il en html
|
||||
$msgishtml=-1; // Unknown by default
|
||||
if (eregi('[ \t]*<html>',$message)) $msgishtml=1;
|
||||
|
||||
// Warning, we must not use begin-commit transaction here
|
||||
// because we want to save update for each mail sent.
|
||||
|
||||
$nbok=0; $nbko=0;
|
||||
|
||||
// On choisit les mails non déjà envoyés pour ce mailing (statut=0)
|
||||
// ou envoyés en erreur (statut=-1)
|
||||
// On choisit les mails non deja envoyes pour ce mailing (statut=0)
|
||||
// ou envoyes en erreur (statut=-1)
|
||||
$sql = "SELECT mc.rowid, mc.nom, mc.prenom, mc.email";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id;
|
||||
@ -420,7 +420,7 @@ $mil = new Mailing($db);
|
||||
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
// Mailing en mode création
|
||||
// EMailing in creation mode
|
||||
print '<form action="fiche.php" method="post">'."\n";
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
@ -441,7 +441,7 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
print '</i></td>';
|
||||
print '<td>';
|
||||
// éditeur wysiwyg
|
||||
// Editeur wysiwyg
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
@ -461,7 +461,6 @@ else
|
||||
{
|
||||
if ($mil->fetch($_GET["id"]) >= 0)
|
||||
{
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
|
||||
$head[$h][1] = $langs->trans("MailCard");
|
||||
@ -477,7 +476,7 @@ else
|
||||
$head[$h][1] = $langs->trans("MailHistory");
|
||||
$h++;
|
||||
*/
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing").": ".substr($mil->titre,0,20));
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Mailing"));
|
||||
|
||||
// Confirmation de la validation du mailing
|
||||
if ($_GET["action"] == 'valide')
|
||||
@ -504,7 +503,7 @@ else
|
||||
{
|
||||
if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
|
||||
{
|
||||
// Pour des raisons de sécurité, on ne permet pas cette fonction via l'IHM,
|
||||
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
|
||||
// on affiche donc juste un message
|
||||
$message='<div class="warning">'.$langs->trans("MailingNeedCommand").'</div>';
|
||||
$message.='<br><textarea cols="50" rows="'.ROWS_2.'" wrap="soft">php ./scripts/mailing/mailing-send.php '.$_GET["id"].'</textarea>';
|
||||
@ -561,11 +560,29 @@ else
|
||||
|
||||
print '</table>';
|
||||
|
||||
print "</div>";
|
||||
print "</div>";
|
||||
|
||||
|
||||
// Clone confirmation
|
||||
if ($_GET["action"] == 'clone')
|
||||
{
|
||||
// Crée un tableau formulaire
|
||||
$formquestion=array(
|
||||
'text' => $langs->trans("ConfirmClone"),
|
||||
array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1),
|
||||
array('type' => 'checkbox', 'name' => 'clone_receviers', 'label' => $langs->trans("CloneReceivers").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true)
|
||||
);
|
||||
// Paiement incomplet. On demande si motif = escompte ou autre
|
||||
$html->form_confirm($_SERVER["PHP_SELF"].'?id='.$mil->id,$langs->trans('CloneEMailing'),$langs->trans('ConfirmCloneEMailing',$mil->ref),'confirm_clone',$formquestion,'yes');
|
||||
}
|
||||
|
||||
|
||||
if ($mesg) print $mesg;
|
||||
|
||||
|
||||
if ($_GET["action"] == 'sendall')
|
||||
{
|
||||
// Pour des raisons de sécurité, on ne permet pas cette fonction via l'IHM,
|
||||
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
|
||||
// on affiche donc juste un message
|
||||
$message='<div class="warning">'.$langs->trans("MailingNeedCommand").'</div>';
|
||||
$message.='<br><textarea cols="70" rows="'.ROWS_2.'" wrap="soft">php ./scripts/mailing/mailing-send.php '.$_GET["id"].'</textarea>';
|
||||
@ -599,6 +616,11 @@ else
|
||||
print '<a class="butAction" href="fiche.php?action=sendall&id='.$mil->id.'">'.$langs->trans("SendMailing").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->mailing->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/mailing/fiche.php?action=clone&object=emailing&id='.$mil->id.'">'.$langs->trans("ToClone").'</a>';
|
||||
}
|
||||
|
||||
if ($mil->statut <= 1 && $user->rights->mailing->supprimer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$mil->id.'">'.$langs->trans("DeleteMailing").'</a>';
|
||||
@ -612,7 +634,7 @@ else
|
||||
{
|
||||
print_titre($langs->trans("TestMailing"));
|
||||
|
||||
// Créé l'objet formulaire mail
|
||||
// Create l'objet formulaire mail
|
||||
include_once("../../html.formmail.class.php");
|
||||
$formmail = new FormMail($db);
|
||||
$formmail->fromname = $mil->email_from;
|
||||
@ -630,7 +652,7 @@ else
|
||||
$formmail->withdeliveryreceipt=0;
|
||||
// Tableau des substitutions
|
||||
$formmail->substit=$substitutionarrayfortest;
|
||||
// Tableau des paramètres complémentaires du post
|
||||
// Tableau des parametres complementaires du post
|
||||
$formmail->param["action"]="send";
|
||||
$formmail->param["models"]="body";
|
||||
$formmail->param["mailid"]=$mil->id;
|
||||
@ -670,7 +692,7 @@ else
|
||||
print '__FIRSTNAME__ = '.$langs->trans("Firstname").'<br>';
|
||||
print '</i></td>';
|
||||
print '<td colspan="3">';
|
||||
// éditeur wysiwyg
|
||||
// Editeur wysiwyg
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
|
||||
@ -18,164 +18,157 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/comm/mailing/mailing.class.php
|
||||
\ingroup mailing
|
||||
\brief Fichier de la classe de gestion des mailings
|
||||
\version $Id$
|
||||
*/
|
||||
\file htdocs/comm/mailing/mailing.class.php
|
||||
\ingroup mailing
|
||||
\brief Fichier de la classe de gestion des mailings
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\class Mailing
|
||||
\brief Classe permettant la gestion des mailings
|
||||
*/
|
||||
* \class Mailing
|
||||
* \brief Classe permettant la gestion des mailings
|
||||
*/
|
||||
class Mailing
|
||||
{
|
||||
var $id;
|
||||
var $error;
|
||||
|
||||
var $statut;
|
||||
var $titre;
|
||||
var $sujet;
|
||||
var $body;
|
||||
var $nbemail;
|
||||
|
||||
var $email_from;
|
||||
var $email_replyto;
|
||||
var $email_errorsto;
|
||||
|
||||
var $user_creat;
|
||||
var $user_valid;
|
||||
var $user_appro;
|
||||
|
||||
var $date_creat;
|
||||
var $date_valid;
|
||||
var $date_appro;
|
||||
var $id;
|
||||
var $error;
|
||||
|
||||
var $statut;
|
||||
var $titre;
|
||||
var $sujet;
|
||||
var $body;
|
||||
var $nbemail;
|
||||
|
||||
var $email_from;
|
||||
var $email_replyto;
|
||||
var $email_errorsto;
|
||||
|
||||
var $user_creat;
|
||||
var $user_valid;
|
||||
|
||||
var $date_creat;
|
||||
var $date_valid;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler accès base de données
|
||||
*/
|
||||
function Mailing($DB)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("mails");
|
||||
|
||||
$this->db = $DB ;
|
||||
$this->db_table = MAIN_DB_PREFIX."mailing";
|
||||
|
||||
$this->statuts[0] = $langs->trans("MailingStatusDraft");
|
||||
$this->statuts[1] = $langs->trans("MailingStatusValidated");
|
||||
$this->statuts[2] = $langs->trans("MailingStatusSentPartialy");
|
||||
$this->statuts[3] = $langs->trans("MailingStatusSentCompletely");
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Création du mailing
|
||||
* \param user object utilisateur qui crée
|
||||
* \return -1 si erreur, >0 sinon
|
||||
*
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
dolibarr_syslog("Mailing::Create");
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->titre=trim($this->titre);
|
||||
$this->email_from=trim($this->email_from);
|
||||
|
||||
if (! $this->email_from)
|
||||
{
|
||||
$this->error = $langs->trans("ErrorMailFromRequired");
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".$this->db_table;
|
||||
$sql .= " (date_creat, fk_user_creat)";
|
||||
$sql .= " VALUES (".$this->db->idate(mktime()).", ".$user->id.")";
|
||||
|
||||
if (! $this->titre)
|
||||
{
|
||||
$this->titre = $langs->trans("NoTitle");
|
||||
}
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id($this->db_table);
|
||||
|
||||
if ($this->update() > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$langs->trans("ErrorUnknown");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
|
||||
dolibarr_syslog("Mailing::Create Erreur -1");
|
||||
$this->error=$langs->trans("UnknownError");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Update les infos du mailing
|
||||
* \return < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
dolibarr_syslog("Mailing::Update");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
||||
$sql .= " SET titre = '".addslashes($this->titre)."'";
|
||||
$sql .= " , sujet = '".addslashes($this->sujet)."'";
|
||||
$sql .= " , body = '".addslashes($this->body)."'";
|
||||
$sql .= " , email_from = '".$this->email_from."'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Update Erreur -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Recupére l'objet mailing
|
||||
* \param rowid id du mailing
|
||||
* \return int
|
||||
*/
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler acces base de donnees
|
||||
*/
|
||||
function Mailing($DB)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("mails");
|
||||
|
||||
$this->db = $DB ;
|
||||
$this->db_table = MAIN_DB_PREFIX."mailing";
|
||||
|
||||
$this->statuts[0] = $langs->trans("MailingStatusDraft");
|
||||
$this->statuts[1] = $langs->trans("MailingStatusValidated");
|
||||
$this->statuts[2] = $langs->trans("MailingStatusSentPartialy");
|
||||
$this->statuts[3] = $langs->trans("MailingStatusSentCompletely");
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Create an EMailing
|
||||
* \param user object utilisateur qui cree
|
||||
* \return -1 if error, Id of created object if OK
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->titre=trim($this->titre);
|
||||
$this->email_from=trim($this->email_from);
|
||||
|
||||
if (! $this->email_from)
|
||||
{
|
||||
$this->error = $langs->trans("ErrorMailFromRequired");
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".$this->db_table;
|
||||
$sql .= " (date_creat, fk_user_creat)";
|
||||
$sql .= " VALUES (".$this->db->idate(mktime()).", ".$user->id.")";
|
||||
|
||||
if (! $this->titre)
|
||||
{
|
||||
$this->titre = $langs->trans("NoTitle");
|
||||
}
|
||||
|
||||
dolibarr_syslog("Mailing::Create sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id($this->db_table);
|
||||
|
||||
if ($this->update() > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dolibarr_syslog("Mailing::Create ".$this->error, LOG_ERROR);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Update les infos du mailing
|
||||
* \return < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
||||
$sql .= " SET titre = '".addslashes($this->titre)."'";
|
||||
$sql .= " , sujet = '".addslashes($this->sujet)."'";
|
||||
$sql .= " , body = '".addslashes($this->body)."'";
|
||||
$sql .= " , email_from = '".$this->email_from."'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
dolibarr_syslog("Mailing::Update sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dolibarr_syslog("Mailing::Update ".$this->error, LOG_ERROR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get object from database
|
||||
* \param rowid id du mailing
|
||||
* \return int
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body";
|
||||
$sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
|
||||
$sql .= ", m.statut, m.nbemail";
|
||||
$sql .= ", m.fk_user_creat, m.fk_user_valid, m.fk_user_appro";
|
||||
$sql .= ", m.fk_user_creat, m.fk_user_valid";
|
||||
$sql .= ", ".$this->db->pdate("m.date_creat") . " as date_creat";
|
||||
$sql .= ", ".$this->db->pdate("m.date_valid") . " as date_valid";
|
||||
$sql .= ", ".$this->db->pdate("m.date_envoi") . " as date_envoi";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
|
||||
$sql .= " WHERE m.rowid = ".$rowid;
|
||||
|
||||
|
||||
dolibarr_syslog("Mailing.class::fetch sql=".$sql);
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
@ -183,27 +176,26 @@ class Mailing
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->statut = $obj->statut;
|
||||
$this->nbemail = $obj->nbemail;
|
||||
$this->titre = $obj->titre;
|
||||
$this->sujet = $obj->sujet;
|
||||
$this->body = $obj->body;
|
||||
|
||||
|
||||
$this->email_from = $obj->email_from;
|
||||
$this->email_replyto = $obj->email_replyto;
|
||||
$this->email_errorsto = $obj->email_errorsto;
|
||||
|
||||
|
||||
$this->user_creat = $obj->fk_user_creat;
|
||||
$this->user_valid = $obj->fk_user_valid;
|
||||
$this->user_appro = $obj->fk_user_appro;
|
||||
|
||||
|
||||
$this->date_creat = $obj->date_creat;
|
||||
$this->date_valid = $obj->date_valid;
|
||||
$this->date_appro = $obj->date_appro;
|
||||
$this->date_envoi = $obj->date_envoi;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -220,69 +212,119 @@ class Mailing
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Valide le mailing
|
||||
* \param user objet user qui valide
|
||||
*/
|
||||
function valid($user)
|
||||
{
|
||||
dolibarr_syslog("Mailing::Valid");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
||||
$sql .= " SET statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid=".$user->id;
|
||||
$sql .= " WHERE rowid = ".$this->id." AND statut = 0 ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Valid Erreur -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Approuve le mailing
|
||||
* \param user objet user qui approuve
|
||||
*/
|
||||
function approve($user)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
||||
$sql .= " SET statut = 2, date_appro = ".$this->db->idate(mktime()).", fk_user_appro=".$user->id;
|
||||
$sql .= " WHERE rowid = ".$this->id." AND statut = 1 ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Valid Erreur -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Supprime le mailing
|
||||
* \param rowid id du mailing à supprimer
|
||||
* \return int 1 en cas de succès
|
||||
*/
|
||||
function delete($rowid)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " WHERE rowid = ".$rowid;
|
||||
|
||||
$this->db->query($sql);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne le libellé du statut d'un mailing (brouillon, validée, ...)
|
||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
|
||||
* \brief Get object from database
|
||||
* \param fromid Id of object to clone
|
||||
* \return int New id of clone
|
||||
*/
|
||||
function createFromClone($fromid,$option1,$option2)
|
||||
{
|
||||
global $user,$langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
$object=new Mailing($this->db);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Load source object
|
||||
$object->fetch($fromid);
|
||||
$object->id=0;
|
||||
$object->statut=0;
|
||||
$object->titre=$langs->trans("CopyOf").' '.$object->titre;
|
||||
|
||||
// If no option copy content
|
||||
if (empty($option1))
|
||||
{
|
||||
// Clear values
|
||||
$this->nbemail = 0;
|
||||
$this->titre = $langs->trans("Draft").' '.mktime();
|
||||
$this->sujet = '';
|
||||
$this->body = '';
|
||||
|
||||
$this->email_from = '';
|
||||
$this->email_replyto = '';
|
||||
$this->email_errorsto = '';
|
||||
|
||||
$this->user_creat = $user->id;
|
||||
$this->user_valid = '';
|
||||
|
||||
$this->date_creat = '';
|
||||
$this->date_valid = '';
|
||||
$this->date_envoi = '';
|
||||
}
|
||||
|
||||
// Create clone
|
||||
$result=$object->create($user);
|
||||
|
||||
// Other options
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$object->error;
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// End
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $object->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Valide le mailing
|
||||
* \param user objet user qui valide
|
||||
*/
|
||||
function valid($user)
|
||||
{
|
||||
dolibarr_syslog("Mailing::Valid");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
|
||||
$sql .= " SET statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid=".$user->id;
|
||||
$sql .= " WHERE rowid = ".$this->id." AND statut = 0 ;";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Mailing::Valid Erreur -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Supprime le mailing
|
||||
* \param rowid id du mailing a supprimer
|
||||
* \return int 1 en cas de succes
|
||||
*/
|
||||
function delete($rowid)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing";
|
||||
$sql .= " WHERE rowid = ".$rowid;
|
||||
|
||||
$this->db->query($sql);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne le libell<EFBFBD> du statut d'un mailing (brouillon, valid<EFBFBD>e, ...
|
||||
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> long
|
||||
* \return string Libelle
|
||||
*/
|
||||
function getLibStatut($mode=0)
|
||||
@ -291,10 +333,10 @@ class Mailing
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi le libellé d'un statut donné
|
||||
* \brief Renvoi le libell<EFBFBD> d'un statut donn<EFBFBD>
|
||||
* \param statut Id statut
|
||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
|
||||
* \return string Libellé du statut
|
||||
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> long, 5=Libell<EFBFBD> court + Picto
|
||||
* \return string Libell<EFBFBD> du statut
|
||||
*/
|
||||
function LibStatut($statut,$mode=0)
|
||||
{
|
||||
@ -339,7 +381,7 @@ class Mailing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1947,20 +1947,14 @@ else
|
||||
$i=0;
|
||||
$close[$i]['code']='discount_vat';$i++;
|
||||
$close[$i]['code']='badcustomer';$i++;
|
||||
//$close[$i]['code']='product_returned';$i++;
|
||||
//$close[$i]['code']='abandon';$i++;
|
||||
// Help
|
||||
$i=0;
|
||||
$close[$i]['label']=$langs->trans("HelpEscompte").'<br><br>'.$langs->trans("ConfirmClassifyPayedPartiallyReasonDiscountVatDesc");$i++;
|
||||
$close[$i]['label']=$langs->trans("ConfirmClassifyPayedPartiallyReasonBadCustomerDesc");$i++;
|
||||
//$close[$i]['label']=$langs->trans("ConfirmClassifyPayedPartiallyReasonProductReturned");$i++;
|
||||
//$close[$i]['label']=$langs->trans("ConfirmClassifyPayedPartiallyReasonOtherDesc");$i++;
|
||||
// Texte
|
||||
$i=0;
|
||||
$close[$i]['reason']=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonDiscountVat",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$close[$i]['label'],1);$i++;
|
||||
$close[$i]['reason']=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonBadCustomer",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$close[$i]['label'],1);$i++;
|
||||
//$close[$i]['reason']=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonProductReturned",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$close[$i]['label'],1);$i++;
|
||||
//$close[$i]['reason']=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonOther",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$close[$i]['label'],1);$i++;
|
||||
// arrayreasons[code]=reason
|
||||
foreach($close as $key => $val)
|
||||
{
|
||||
|
||||
@ -1914,14 +1914,15 @@ class Form
|
||||
|
||||
|
||||
/**
|
||||
* \brief Affiche formulaire de demande de confirmation
|
||||
* \param page page
|
||||
* \param title title
|
||||
* \param question question
|
||||
* \param action action
|
||||
* \param formquestion an array with forms complementary inputs
|
||||
* \brief Affiche formulaire de demande de confirmation
|
||||
* \param page page
|
||||
* \param title title
|
||||
* \param question question
|
||||
* \param action action
|
||||
* \param formquestion an array with forms complementary inputs
|
||||
* \param selectedchoice "" or "no" or "yes"
|
||||
*/
|
||||
function form_confirm($page, $title, $question, $action, $formquestion='')
|
||||
function form_confirm($page, $title, $question, $action, $formquestion='', $selectedchoice="")
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@ -1957,6 +1958,7 @@ class Form
|
||||
print '<td valign="top">'.$input['label'].' ';
|
||||
print '<input type="checkbox" class="flat" name="'.$input['name'].'"';
|
||||
if ($input['value'] != 'false') print ' checked="true"';
|
||||
if ($input['disabled']) print ' disabled="true"';
|
||||
print '></td>';
|
||||
print '<td valign="top" align="left"> </td>';
|
||||
print '<td valign="top" align="left"> </td>';
|
||||
@ -1970,7 +1972,9 @@ class Form
|
||||
print '<tr>';
|
||||
if ($i==0) print '<td valign="top">'.$input['label'].'</td>';
|
||||
else print '<td> </td>';
|
||||
print '<td valign="top" width="20"><input type="radio" class="flat" name="'.$input['name'].'" value="'.$selkey.'"></td>';
|
||||
print '<td valign="top" width="20"><input type="radio" class="flat" name="'.$input['name'].'" value="'.$selkey.'"';
|
||||
if ($input['disabled']) print ' disabled="true"';
|
||||
print '></td>';
|
||||
print '<td valign="top" align="left">';
|
||||
print $selval;
|
||||
print '</td></tr>';
|
||||
@ -1988,7 +1992,8 @@ class Form
|
||||
print '<tr class="valid">';
|
||||
print '<td class="valid">'.$question.'</td>';
|
||||
print '<td class="valid">';
|
||||
print $this->selectyesno("confirm","no");
|
||||
$newselectedchoice=empty($selectedchoice)?"no":$selectedchoice;
|
||||
print $this->selectyesno("confirm",$newselectedchoice);
|
||||
print '</td>';
|
||||
print '<td class="valid" align="center"><input class="button" type="submit" value="'.$langs->trans("Validate").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -103,6 +103,14 @@ ToValidate=To validate
|
||||
Save=Save
|
||||
SaveAs=Save As
|
||||
TestConnection=Test connection
|
||||
ToClone=Clone
|
||||
CloneEMailing=Clone Emailing
|
||||
CloneContent=Clone message
|
||||
CloneReceivers=Cloner recipients
|
||||
ConfirmClone=Choose data you want to clone :
|
||||
ConfirmCloneEMailing=Are you sure you want to clone this emailing ?
|
||||
NoCloneOptionsSpecified=No data to clone defined.
|
||||
CopyOf=Copy of
|
||||
Show=Show
|
||||
Search=Search
|
||||
Valid=Valid
|
||||
|
||||
@ -102,6 +102,14 @@ ToValidate=
|
||||
Save=Enregistrer
|
||||
SaveAs=Enregistrer sous
|
||||
TestConnection=Tester la connexion
|
||||
ToClone=Cloner
|
||||
CloneEMailing=Cloner Emailing
|
||||
CloneContent=Cloner message
|
||||
CloneReceivers=Cloner destinataires
|
||||
ConfirmClone=Veuillez choisir votre option de clonage :
|
||||
ConfirmCloneEMailing=Etes-vous sur de vouloir cloner cet emailing ?
|
||||
NoCloneOptionsSpecified=Aucun option de clonage n'a été spécifiée.
|
||||
CopyOf=Copie de
|
||||
Show=Voir
|
||||
Search=Rechercher
|
||||
Valid=Valider
|
||||
|
||||
Loading…
Reference in New Issue
Block a user