New: Gros avancements sur l'outil de mailing. Il est possible maintenant de crer un mailing, le supprimer, editer, valider et de choisir les destinataires parmi des listes prdfinis dans des modules.

Qual: Les modules poire et cerise de slection de destinataire ont t revue pour respoecter la norme objet.
This commit is contained in:
Laurent Destailleur 2005-02-12 18:56:49 +00:00
parent 45eff57d37
commit 13d8eaf4ce
4 changed files with 80 additions and 65 deletions

View File

@ -110,72 +110,72 @@ if ($mil->fetch($_GET["id"]) == 0)
// Affiche les listes de sélection
print '<table class="noborder" width=\"100%\">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RecipientSelectionModules").'</td>';
print '<td align="center">'.$langs->trans("NbOfRecipients").'</td>';
print '<td align="center" width="120">';
if ($mil->statut == 0) {
print $langs->trans("Actions");
}
print '</td>';
print "</tr>\n";
clearstatcache();
$handle=opendir($dir);
$var=True;
while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
if (eregi("(.*)\.(.*)\.(.*)",$file,$reg)) {
$var = !$var;
$modulename=$reg[1];
// Chargement de la classe
$file = $dir."/".$modulename.".modules.php";
$classname = "mailing_".$modulename;
require_once($file);
print '<tr '.$bc[$var].'>';
print '<td>';
$obj = new $classname($db);
print $obj->getDesc();
print '</td>';
/*
print '<td width=\"100\">';
print $modulename;
print "</td>";
*/
print '<td align="center">'.$obj->getNbOfRecipients().'</td>';
print '<td align="center">';
if ($mil->statut == 0) {
print '<form action="cibles.php?action=add&rowid='.$mil->id.'&module='.$modulename.'" method="POST"><input type="submit" value="'.$langs->trans("Add").'"></form>';
}
else {
//print $langs->trans("MailNoChangePossible");
print "&nbsp;";
}
print '</td>';
}
print "</tr>\n";
print '<table class="noborder" width=\"100%\">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RecipientSelectionModules").'</td>';
print '<td align="center">'.$langs->trans("NbOfRecipients").'</td>';
print '<td align="center" width="120">';
if ($mil->statut == 0) {
print $langs->trans("Actions");
}
}
closedir($handle);
print '</td>';
print "</tr>\n";
clearstatcache();
$handle=opendir($dir);
$var=True;
while (($file = readdir($handle))!==false)
{
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
if (eregi("(.*)\.(.*)\.(.*)",$file,$reg)) {
$var = !$var;
$modulename=$reg[1];
// Chargement de la classe
$file = $dir."/".$modulename.".modules.php";
$classname = "mailing_".$modulename;
require_once($file);
print '<tr '.$bc[$var].'>';
print '<td>';
$obj = new $classname($db);
print $obj->getDesc();
print '</td>';
/*
print '<td width=\"100\">';
print $modulename;
print "</td>";
*/
print '<td align="center">'.$obj->getNbOfRecipients().'</td>';
print '<td align="center">';
if ($mil->statut == 0) {
print '<form action="cibles.php?action=add&rowid='.$mil->id.'&module='.$modulename.'" method="POST"><input type="submit" value="'.$langs->trans("Add").'"></form>';
}
else {
//print $langs->trans("MailNoChangePossible");
print "&nbsp;";
}
print '</td>';
}
print "</tr>\n";
}
}
closedir($handle);
if ($mil->statut == 0) {
print '<tr>';
print '<td>&nbsp;</td><td>&nbsp;</td><td align="center"><form action="cibles.php?action=clear&rowid='.$mil->id.'" method="POST"><input type="submit" value="'.$langs->trans("Clear").'"></form></td>';
print '</tr>';
print '</table><br>';
}
print '</table><br>';
// Liste des destinataires électionnés
$NBMAX=100;

View File

@ -86,12 +86,12 @@ if ($_POST["action"] == 'add')
{
$mil = new Mailing($db);
$mil->from = $_POST["from"];
$mil->email_from = $_POST["from"];
$mil->titre = $_POST["titre"];
$mil->sujet = $_POST["sujet"];
$mil->body = $_POST["body"];
if ($mil->create($user))
if ($mil->create($user) >= 0)
{
Header("Location: fiche.php?id=".$mil->id);
}

View File

@ -145,7 +145,7 @@ class Mailing
$sql .= " SET titre = '".addslashes($this->titre)."'";
$sql .= " , sujet = '".addslashes($this->sujet)."'";
$sql .= " , body = '".addslashes($this->body)."'";
$sql .= " , email_from = '".$this->from."'";
$sql .= " , email_from = '".$this->email_from."'";
$sql .= " WHERE rowid = ".$this->id;
$result=$this->db->query($sql);

View File

@ -44,7 +44,7 @@ class FormMail
var $replytomail;
var $toname;
var $tomail;
var $withfrom;
var $withto;
var $withtocc;
@ -83,6 +83,7 @@ class FormMail
$this->withtoreadonly=0;
$this->withtoccreadonly=0;
$this->withtopicreadonly=0;
$this->withbodyreadonly=0;
return 1;
}
@ -167,7 +168,14 @@ class FormMail
print "<tr>";
print "<td width=\"180\">".$langs->trans("MailTopic")."</td>";
print "<td>";
print "<input type=\"text\" size=\"60\" name=\"subject\" value=\"\">";
if ($this->withtopicreadonly) {
print $this->withtopic;
print "<input type=\"hidden\" size=\"60\" name=\"subject\" value=\"".$this->withtopic."\">";
}
else
{
print "<input type=\"text\" size=\"60\" name=\"subject\" value=\"".$this->withtopic."\">";
}
print "</td></tr>\n";
}
@ -187,6 +195,7 @@ class FormMail
$defaultmessage="";
// \todo A partir du type, proposer liste de messages dans table llx_models
if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; }
if ($this->param["models"]=='facture_send') { $defaultmessage="Veuillez trouver ci-joint la facture __FACREF__\n\nCordialement\n\n"; }
if ($this->param["models"]=='facture_relance') { $defaultmessage="Nous apportons à votre connaissance que la facture __FACREF__ ne semble toujours pas avoir été réglée. La voici donc, pour rappel, en pièce jointe.\n\nCordialement\n\n"; }
@ -196,9 +205,15 @@ class FormMail
print "<tr>";
print "<td width=\"180\" valign=\"top\">".$langs->trans("MailText")."</td>";
print "<td>";
print "<textarea rows=\"8\" cols=\"72\" name=\"message\">";
if (! $this->withbodyreadonly) {
print '<textarea cols="72" rows="8" name="message">';
}
print $defaultmessage;
print "</textarea>";
if (! $this->withbodyreadonly) {
print '</textarea>';
} else {
print '<input type="hidden" name="message" value="'.$defaultmessage.'">';
}
print "</td></tr>\n";
}