2005-01-05 16:26:05 +01:00
|
|
|
|
<?PHP
|
|
|
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2005-01-14 20:24:00 +01:00
|
|
|
|
* Copyright (C) 2005 Laurent Destailleur <eldy@uers.sourceforge.net>
|
2005-01-05 16:26:05 +01:00
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
*
|
|
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
/** \file htdocs/comm/mailing/fiche.php
|
|
|
|
|
|
\brief Fiche mailing, onglet g<EFBFBD>n<EFBFBD>ral
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-01-05 16:26:05 +01:00
|
|
|
|
require("./pre.inc.php");
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
$langs->load("mails");
|
|
|
|
|
|
|
2005-01-05 16:26:05 +01:00
|
|
|
|
$mesg = '';
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
|
2005-01-05 16:26:05 +01:00
|
|
|
|
if ($_POST["action"] == 'add')
|
|
|
|
|
|
{
|
|
|
|
|
|
$mil = new Mailing($db);
|
|
|
|
|
|
|
|
|
|
|
|
$mil->titre = $_POST["titre"];
|
|
|
|
|
|
$mil->sujet = $_POST["sujet"];
|
|
|
|
|
|
$mil->body = $_POST["body"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( $mil->create($user) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Header("Location: fiche.php?id=".$mil->id);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
|
2005-01-05 16:26:05 +01:00
|
|
|
|
if ($_POST["action"] == 'update')
|
|
|
|
|
|
{
|
|
|
|
|
|
$mil = new Mailing($db);
|
|
|
|
|
|
|
|
|
|
|
|
$mil->id = $_GET["id"];
|
|
|
|
|
|
$mil->titre = $_POST["titre"];
|
|
|
|
|
|
$mil->sujet = $_POST["sujet"];
|
|
|
|
|
|
$mil->body = $_POST["body"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( $mil->update() == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Header("Location: fiche.php?id=".$mil->id);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
|
2005-01-05 16:26:05 +01:00
|
|
|
|
if ($_POST["action"] == 'confirm_valide')
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if ($_POST["confirm"] == 'yes')
|
|
|
|
|
|
{
|
|
|
|
|
|
$mil = new Mailing($db);
|
|
|
|
|
|
|
|
|
|
|
|
if ($mil->fetch($_GET["id"]) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$mil->valid($user);
|
|
|
|
|
|
|
|
|
|
|
|
Header("Location: fiche.php?id=".$mil->id);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-01-14 20:24:00 +01:00
|
|
|
|
dolibarr_print_error($db);
|
2005-01-05 16:26:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Header("Location: fiche.php?id=".$_GET["id"]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($_POST["action"] == 'confirm_approve')
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if ($_POST["confirm"] == 'yes')
|
|
|
|
|
|
{
|
|
|
|
|
|
$mil = new Mailing($db);
|
|
|
|
|
|
|
|
|
|
|
|
if ($mil->fetch($_GET["id"]) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$mil->approve($user);
|
|
|
|
|
|
|
|
|
|
|
|
Header("Location: fiche.php?id=".$mil->id);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-01-14 20:24:00 +01:00
|
|
|
|
dolibarr_print_error($db);
|
2005-01-05 16:26:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Header("Location: fiche.php?id=".$_GET["id"]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-01-05 16:26:05 +01:00
|
|
|
|
llxHeader("","","Fiche Mailing");
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
2005-01-05 16:26:05 +01:00
|
|
|
|
{
|
|
|
|
|
|
$action = '';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Cr<EFBFBD>ation
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
$mil = new Mailing($db);
|
|
|
|
|
|
|
|
|
|
|
|
if ($_GET["action"] == 'create')
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<form action="fiche.php" method="post">'."\n";
|
|
|
|
|
|
print '<input type="hidden" name="action" value="add">';
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print_titre($langs->trans("NewMailing"));
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<table class="border" width="100%">';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("MailTitle").'</td><td><input name="titre" size="30" value=""></td></tr>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("MailTopic").'</td><td><input name="sujet" size="40" value=""></td></tr>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td width="20%" valign="top">'.$langs->trans("MailMessage").'</td><td><textarea cols="30" rows="8" name="body"></textarea></td></tr>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("CreateMailing").'"></td></tr>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
print '</table>';
|
|
|
|
|
|
print '</form>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
$html = new Form($db);
|
|
|
|
|
|
if ($mil->fetch($_GET["id"]) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$h=0;
|
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id;
|
2005-01-14 20:24:00 +01:00
|
|
|
|
$head[$h][1] = $langs->trans("MailCard");
|
2005-01-05 16:26:05 +01:00
|
|
|
|
$hselected = $h;
|
|
|
|
|
|
$h++;
|
|
|
|
|
|
|
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$mil->id;
|
2005-01-14 20:24:00 +01:00
|
|
|
|
$head[$h][1] = $langs->trans('MailTargets');
|
2005-01-05 16:26:05 +01:00
|
|
|
|
$h++;
|
|
|
|
|
|
|
|
|
|
|
|
dolibarr_fiche_head($head, $hselected, substr($mil->titre,0,20));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Confirmation de la validation du mailing
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
if ($_GET["action"] == 'valide')
|
|
|
|
|
|
{
|
|
|
|
|
|
$html->form_confirm("fiche.php?id=".$mil->id,
|
|
|
|
|
|
"Valider le mailing",
|
|
|
|
|
|
"Confirmez-vous la validation du mailing ?",
|
|
|
|
|
|
"confirm_valide");
|
|
|
|
|
|
}
|
2005-01-14 20:24:00 +01:00
|
|
|
|
|
2005-01-05 16:26:05 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Confirmation de l'approbation du mailing
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
if ($_GET["action"] == 'approve')
|
|
|
|
|
|
{
|
|
|
|
|
|
$html->form_confirm("fiche.php?id=".$mil->id,
|
|
|
|
|
|
"Approuver le mailing",
|
|
|
|
|
|
"Confirmez-vous l'approbation du mailing ?",
|
|
|
|
|
|
"confirm_approve");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<table class="border" width="100%">';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$mil->titre.'</td></tr>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
2005-01-14 20:30:06 +01:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("MailFrom").'</td><td>'.htmlentities($mil->email_from).'</td>';
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<td>'.$langs->trans("EMail").'</td><td>'.htmlentities($mil->email_from).'</td></tr>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
|
|
|
|
|
//print '<tr><td width="20%">R<>ponse</td><td>'.htmlentities($mil->email_replyto).'</td></tr>';
|
|
|
|
|
|
//print '<tr><td width="20%">Retour Erreur</td><td>'.htmlentities($mil->email_errorsto).'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
if ($mil->statut > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<tr><td width="20%">Nb destinataires</td><td colspan="3">'.$mil->nbemail.'</td></tr>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">'.$mil->statuts[$mil->statut].'</td></tr>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
|
|
|
|
|
$uc = new User($db, $mil->user_creat);
|
|
|
|
|
|
$uc->fetch();
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("CreatedBy").'</td><td>'.$uc->fullname.'</td>';
|
|
|
|
|
|
print '<td>'.$langs->trans("DateCreation").'</td>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_creat).'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
if ($mil->statut > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$uv = new User($db, $mil->user_valid);
|
|
|
|
|
|
$uv->fetch();
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("ValidatedBy").'</td><td>'.$uv->fullname.'</td>';
|
|
|
|
|
|
print '<td>'.$langs->trans("Date").'</td>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_valid).'</td></tr>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($mil->statut > 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
$ua = new User($db, $mil->user_appro);
|
|
|
|
|
|
$ua->fetch();
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("ApprovedBy").'</td><td>'.$ua->fullname.'</td>';
|
|
|
|
|
|
print '<td>'.$langs->trans("Date").'</td>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
print '<td>'.strftime("%d %b %Y %H:%M", $mil->date_appro).'</td></tr>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
// Contenu du mail
|
|
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("MailTopic").'</td><td colspan="3">'.$mil->sujet.'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
print '<tr><td width="20%" valign="top">'.$langs->trans("MailMessage").'</td><td colspan="3">';
|
|
|
|
|
|
print nl2br($mil->body).'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print '</table><br>';
|
|
|
|
|
|
|
|
|
|
|
|
print "</div>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Boutons d'action
|
|
|
|
|
|
*/
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
|
|
|
|
|
print "\n\n<div class=\"tabsAction\">\n";
|
|
|
|
|
|
|
|
|
|
|
|
if ($_GET["action"] == '')
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<a class="tabAction" href="fiche.php?action=test&id='.$mil->id.'">'.$langs->trans("TestMailing").'</a>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
|
|
|
|
|
|
if ($mil->statut == 0)
|
|
|
|
|
|
{
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<a class="tabAction" href="fiche.php?action=valide&id='.$mil->id.'">'.$langs->trans("ValidMailing").'</a>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($mil->statut == 1 && $mil->nbemail > 0)
|
|
|
|
|
|
{
|
2005-01-14 20:24:00 +01:00
|
|
|
|
print '<a class="tabAction" href="fiche.php?action=approve&id='.$mil->id.'">'.$langs->trans("ApproveMailing").'</a>';
|
2005-01-05 16:26:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
print '<br /><br /></div>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
|
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
|
|
|
|
|
?>
|