*** empty log message ***
This commit is contained in:
parent
eb3019846d
commit
2b0efb9af9
@ -117,7 +117,6 @@ foreach ($modules as $key => $value)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -171,17 +171,17 @@ class Auteur {
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function delete($user) {
|
||||
Function delete() {
|
||||
|
||||
$sql = "DELETE FROM ".DB_NAME_OSC.".products WHERE products_id = $idosc ";
|
||||
$livres = $this->liste_livre();
|
||||
|
||||
if (sizeof($livres) == 0)
|
||||
{
|
||||
$sql = "DELETE FROM llx_auteur WHERE rowid = $this->id ";
|
||||
$return = $this->db->query($sql) ;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".DB_NAME_OSC.".products_to_categories WHERE products_id = $idosc";
|
||||
|
||||
$sql = "DELETE FROM ".DB_NAME_OSC.".products_description WHERE products_id = $idosc";
|
||||
|
||||
$sql = "DELETE FROM llx_livre WHERE rowid = $id";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,8 +22,6 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
llxHeader();
|
||||
|
||||
$db = new Db();
|
||||
|
||||
if ($action == 'add') {
|
||||
@ -40,6 +38,14 @@ if ($action == 'addga') {
|
||||
$auteur->linkga($id, $ga);
|
||||
}
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] == yes)
|
||||
{
|
||||
$auteur = new Auteur($db);
|
||||
$result = $auteur->fetch($id);
|
||||
$auteur->delete();
|
||||
Header("Location: index.php");
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'update' && !$cancel) {
|
||||
$auteur = new Auteur($db);
|
||||
@ -49,6 +55,10 @@ if ($action == 'update' && !$cancel) {
|
||||
$auteur->update($id, $user);
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
@ -83,6 +93,37 @@ else
|
||||
|
||||
$livres = $auteur->liste_livre();
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression de l'auteur
|
||||
*
|
||||
*/
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
|
||||
print '<form method="post" action="'.$PHP_SELF.'?id='.$id.'">';
|
||||
print '<input type="hidden" name="action" value="confirm_delete">';
|
||||
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
|
||||
|
||||
print '<tr><td colspan="3">Supprimer un auteur</td></tr>';
|
||||
|
||||
print '<tr><td class="delete">Etes-vous sur de vouloir supprimer cet auteur ?</td><td class="delete">';
|
||||
$htmls = new Form($db);
|
||||
|
||||
$htmls->selectyesno("confirm","no");
|
||||
|
||||
print "</td>\n";
|
||||
print '<td class="delete" align="center"><input type="submit" value="Confirmer"</td></tr>';
|
||||
print '</table>';
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Edition
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<div class="titre">Edition de la fiche Auteur : '.$auteur->nom.'</div><br>';
|
||||
@ -107,7 +148,7 @@ else
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td width="20%">Nom</td><td width="30%">'.$auteur->nom.'</td></tr>';
|
||||
print '<td width="20%">Nom</td><td width="80%">'.$auteur->nom.'</td></tr>';
|
||||
|
||||
print '<tr><td>Livres</td><td>';
|
||||
|
||||
@ -142,9 +183,6 @@ else
|
||||
/* ************************************************************************** */
|
||||
|
||||
print '<br><table width="100%" border="1" cellspacing="0" cellpadding="3">';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
@ -154,7 +192,20 @@ else
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=edit&id='.$id.'">Editer</a>]</td>';
|
||||
}
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
if(sizeof($livres)==0 && $id)
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=delete&id='.$id.'">Supprimer</a>]</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="20%" align="center">[Supprimer]</td>';
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
|
||||
|
||||
@ -37,12 +37,10 @@ if ($page == -1) { $page = 0 ; }
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
print_barre_liste("Liste des notifications", $page, $PHP_SELF);
|
||||
print_barre_liste("Liste des clients", $page, $PHP_SELF);
|
||||
|
||||
$sql = "SELECT c.customers_id, c.customers_lastname, c.customers_firstname";
|
||||
$sql .= " FROM ".DB_NAME_OSC.".products_notifications as n,".DB_NAME_OSC.".products_description as p";
|
||||
$sql .= ",".DB_NAME_OSC.".customers as c";
|
||||
$sql .= " WHERE n.customers_id = c.customers_id AND p.products_id=n.products_id";
|
||||
$sql = "SELECT c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, c.customers_newsletter";
|
||||
$sql .= " FROM ".DB_NAME_OSC.".customers as c";
|
||||
$sql .= " ORDER BY $sortfield $sortorder ";
|
||||
$sql .= $db->plimit( $limit ,$offset);
|
||||
|
||||
@ -52,8 +50,10 @@ if ( $db->query($sql) )
|
||||
$i = 0;
|
||||
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
||||
print "<TR class=\"liste_titre\"><td>";
|
||||
print_liste_field_titre("Nom",$PHP_SELF, "e.nom");
|
||||
print "</td>";
|
||||
print_liste_field_titre("Prénom",$PHP_SELF, "c.customers_firstname");
|
||||
print "</td><td>";
|
||||
print_liste_field_titre("Nom",$PHP_SELF, "c.customers_lastname");
|
||||
print '</td><td>Email</td><td align="center">Newsletter</td>';
|
||||
print "</TR>\n";
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
@ -61,7 +61,10 @@ if ( $db->query($sql) )
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<TD width='70%'><a href=\"fiche.php?id=$objp->rowid\">$objp->nom</a></TD>\n";
|
||||
print '<TD><a href="fiche.php?id='.$objp->customers_id.'">'.$objp->customers_firstname."</a></TD>\n";
|
||||
print '<TD><a href="fiche.php?id='.$objp->customers_id.'">'.$objp->customers_lastname."</a></TD>\n";
|
||||
print "<TD>$objp->customers_email_address</TD>\n";
|
||||
print "<TD align=\"center\">$objp->customers_newsletter</TD>\n";
|
||||
print "</TR>\n";
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -130,25 +130,56 @@ class Editeur {
|
||||
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function liste_livre()
|
||||
{
|
||||
$ga = array();
|
||||
|
||||
$sql = "SELECT a.rowid, a.title FROM llx_livre as a";
|
||||
$sql .= " WHERE a.fk_editeur = ".$this->id;
|
||||
$sql .= " ORDER BY a.title";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$nump = $this->db->num_rows();
|
||||
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object($i);
|
||||
|
||||
$ga[$obj->rowid] = $obj->title;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $ga;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function delete($user) {
|
||||
Function delete() {
|
||||
|
||||
$sql = "DELETE FROM ".DB_NAME_OSC.".products WHERE products_id = $idosc ";
|
||||
$livres = $this->liste_livre();
|
||||
|
||||
if (sizeof($livres) == 0)
|
||||
{
|
||||
$sql = "DELETE FROM llx_editeur WHERE rowid = $this->id ";
|
||||
$return = $this->db->query($sql) ;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".DB_NAME_OSC.".products_to_categories WHERE products_id = $idosc";
|
||||
|
||||
$sql = "DELETE FROM ".DB_NAME_OSC.".products_description WHERE products_id = $idosc";
|
||||
|
||||
$sql = "DELETE FROM llx_livre WHERE rowid = $id";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -22,8 +22,6 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
llxHeader();
|
||||
|
||||
$db = new Db();
|
||||
|
||||
if ($action == 'add') {
|
||||
@ -40,8 +38,8 @@ if ($action == 'addga') {
|
||||
$editeur->linkga($id, $ga);
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'update' && !$cancel) {
|
||||
if ($action == 'update' && !$cancel)
|
||||
{
|
||||
$editeur = new Editeur($db);
|
||||
|
||||
$editeur->nom = $nom;
|
||||
@ -49,6 +47,16 @@ if ($action == 'update' && !$cancel) {
|
||||
$editeur->update($id, $user);
|
||||
}
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] == yes)
|
||||
{
|
||||
$editeur = new Editeur($db);
|
||||
$result = $editeur->fetch($id);
|
||||
$editeur->delete();
|
||||
Header("Location: index.php");
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
@ -63,7 +71,7 @@ if ($action == 'create')
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td>Nom</td><td><input name="nom" size="40" value=""></td></tr>';
|
||||
print '<td width="20%">Nom</td><td><input name="nom" size="40" value=""></td></tr>';
|
||||
print '<tr><td> </td><td><input type="submit" value="Créer"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
@ -80,6 +88,39 @@ else
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
$livres = $editeur->liste_livre();
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression de l'editeur
|
||||
*
|
||||
*/
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
|
||||
print '<form method="post" action="'.$PHP_SELF.'?id='.$id.'">';
|
||||
print '<input type="hidden" name="action" value="confirm_delete">';
|
||||
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
|
||||
|
||||
print '<tr><td colspan="3">Supprimer un éditeur</td></tr>';
|
||||
|
||||
print '<tr><td class="delete">Etes-vous sur de vouloir supprimer cet éditeur ?</td><td class="delete">';
|
||||
$htmls = new Form($db);
|
||||
|
||||
$htmls->selectyesno("confirm","no");
|
||||
|
||||
print "</td>\n";
|
||||
print '<td class="delete" align="center"><input type="submit" value="Confirmer"</td></tr>';
|
||||
print '</table>';
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Edition de la fiche
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
print '<div class="titre">Edition de la fiche Editeur : '.$editeur->titre.'</div><br>';
|
||||
@ -89,7 +130,7 @@ else
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td width="20%">Nom</td><td><input name="nom" size="40" value="'.$editeur->nom.'"></td>';
|
||||
print '<td width="20%">Nom</td><td width="80%"><input name="nom" size="40" value="'.$editeur->nom.'"></td>';
|
||||
|
||||
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" value="Enregistrer"> <input type="submit" value="Annuler" name="cancel"></td></tr>';
|
||||
@ -104,7 +145,16 @@ else
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td width="20%">Nom</td><td width="30%">'.$editeur->nom.'</td></tr>';
|
||||
print '<td width="20%">Nom</td><td width="80%">'.$editeur->nom.'</td></tr>';
|
||||
|
||||
print '<tr><td>Livres</td><td>';
|
||||
|
||||
foreach ($livres as $key => $value)
|
||||
{
|
||||
print '<a href="../livre/fiche.php?id='.$key.'">'.$value."<br>\n";
|
||||
}
|
||||
print "</td></tr>";
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
@ -130,9 +180,6 @@ else
|
||||
/* ************************************************************************** */
|
||||
|
||||
print '<br><table width="100%" border="1" cellspacing="0" cellpadding="3">';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
@ -142,7 +189,21 @@ else
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=edit&id='.$id.'">Editer</a>]</td>';
|
||||
}
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
if(sizeof($livres)==0 && $id)
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=delete&id='.$id.'">Supprimer</a>]</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="20%" align="center">[Supprimer]</td>';
|
||||
}
|
||||
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
|
||||
|
||||
@ -293,11 +293,6 @@ else
|
||||
/* ************************************************************************** */
|
||||
|
||||
print '<br><table width="100%" border="1" cellspacing="0" cellpadding="3">';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=updateosc&id='.$id.'">Update Osc</a>]</td>';
|
||||
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
@ -307,6 +302,10 @@ else
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=edit&id='.$id.'">Editer</a>]</td>';
|
||||
}
|
||||
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=updateosc&id='.$id.'">Update Osc</a>]</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '</table><br>';
|
||||
|
||||
|
||||
@ -335,6 +335,7 @@ class Livre {
|
||||
{
|
||||
$sql = "UPDATE ".DB_NAME_OSC.".products ";
|
||||
$sql .= "SET products_model = '".$this->ref."'";
|
||||
$sql .= ", products_image = '".strtolower($this->ref).".jpg'";
|
||||
$sql .= ", products_price = ".$this->price."";
|
||||
|
||||
$sql .= " WHERE products_id = " . $this->oscid;
|
||||
@ -345,7 +346,7 @@ class Livre {
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error() . ' in ' . $sql;
|
||||
print $this->db->error() . ' in <br />' . $sql;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -409,11 +410,14 @@ class Livre {
|
||||
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
|
||||
if ( $this->db->query($sql) ) {
|
||||
return 1;
|
||||
} else {
|
||||
print $this->db->error() . ' in ' . $sql;
|
||||
}
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error() . ' in ' . $sql;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
|
||||
@ -27,7 +27,11 @@ $db = new Db();
|
||||
if ($action == 'add') {
|
||||
$newsletter = new Newsletter($db);
|
||||
|
||||
$newsletter->nom = $nom;
|
||||
$newsletter->email_subject = $HTTP_POST_VARS["email_subject"];
|
||||
$newsletter->email_from_name = $HTTP_POST_VARS["email_from_name"];
|
||||
$newsletter->email_from_email = $HTTP_POST_VARS["email_from_email"];
|
||||
$newsletter->email_replyto = $HTTP_POST_VARS["email_replyto"];
|
||||
$newsletter->email_body = $HTTP_POST_VARS["email_body"];
|
||||
|
||||
$id = $newsletter->create($user);
|
||||
}
|
||||
@ -42,7 +46,11 @@ if ($action == 'update' && !$cancel)
|
||||
{
|
||||
$newsletter = new Newsletter($db);
|
||||
|
||||
$newsletter->nom = $nom;
|
||||
$newsletter->email_subject = $HTTP_POST_VARS["email_subject"];
|
||||
$newsletter->email_from_name = $HTTP_POST_VARS["email_from_name"];
|
||||
$newsletter->email_from_email = $HTTP_POST_VARS["email_from_email"];
|
||||
$newsletter->email_replyto = $HTTP_POST_VARS["email_replyto"];
|
||||
$newsletter->email_body = $HTTP_POST_VARS["email_body"];
|
||||
|
||||
$newsletter->update($id, $user);
|
||||
}
|
||||
@ -55,6 +63,21 @@ if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"]
|
||||
Header("Location: index.php");
|
||||
}
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] == yes)
|
||||
{
|
||||
$newsletter = new Newsletter($db);
|
||||
$result = $newsletter->fetch($id);
|
||||
$newsletter->validate($user);
|
||||
}
|
||||
|
||||
if ($HTTP_POST_VARS["action"] == 'confirm_send' && $HTTP_POST_VARS["confirm"] == yes)
|
||||
{
|
||||
$newsletter = new Newsletter($db);
|
||||
$result = $newsletter->fetch($id);
|
||||
$newsletter->send($user);
|
||||
}
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
/*
|
||||
@ -70,14 +93,13 @@ if ($action == 'create')
|
||||
print '<div class="titre">Nouvelle Newsletter</div><br>';
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td>Emetteur nom</td><td><input name="nom" size="30" value=""></td></tr>';
|
||||
print '<td>Emetteur email</td><td><input name="nom" size="40" value=""></td></tr>';
|
||||
print '<td>Email de réponse</td><td><input name="nom" size="40" value=""></td><td>Si vide, le mail de l\'émetteur est utilisé</tr>';
|
||||
print '<td>Sujet</td><td><input name="nom" size="30" value=""></td></tr>';
|
||||
print '<td>Cible</td><td><input name="nom" size="40" value=""></td></tr>';
|
||||
print '<td>Texte</td><td><textarea name="body" rows="10" cols="60"></textarea></td></tr>';
|
||||
print '<tr><td> </td><td><input type="submit" value="Créer"></td></tr>';
|
||||
print '<tr><td width="20%">Emetteur nom</td><td><input name="email_from_name" size="30" value=""></td></tr>';
|
||||
print '<tr><td width="20%">Emetteur email</td><td><input name="email_from_email" size="40" value=""></td></tr>';
|
||||
print '<tr><td width="20%">Email de réponse</td><td><input name="email_replyto" size="40" value=""> (facultatif)</td></tr>';
|
||||
print '<tr><td width="20%">Sujet</td><td width="80%"><input name="email_subject" size="30" value=""></td></tr>';
|
||||
print '<tr><td width="20%">Cible</td><td><input name="nom" size="40" value=""></td></tr>';
|
||||
print '<tr><td width="20%" valign="top">Texte</td><td width="80%"><textarea name="email_body" rows="10" cols="60"></textarea></td></tr>';
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" value="Créer"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
@ -117,6 +139,41 @@ else
|
||||
print '</table>';
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
*/
|
||||
if ($action == 'valid')
|
||||
{
|
||||
$htmls = new Form($db);
|
||||
$htmls->form_confirm($PHP_SELF.'?id='.$id,
|
||||
"Valider une newsletter",
|
||||
"Etes-vous sûr de vouloir valider cette newsletter ?");
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ($action == 'send')
|
||||
{
|
||||
|
||||
print '<form method="post" action="'.$PHP_SELF.'?id='.$id.'">';
|
||||
print '<input type="hidden" name="action" value="confirm_send">';
|
||||
print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
|
||||
|
||||
print '<tr><td colspan="3">Envoi de newsletter</td></tr>';
|
||||
|
||||
print '<tr><td class="delete">Etes-vous sur de vouloir envoyer cette newsletter ?</td><td class="delete">';
|
||||
$htmls = new Form($db);
|
||||
|
||||
$htmls->selectyesno("confirm","no");
|
||||
|
||||
print "</td>\n";
|
||||
print '<td class="delete" align="center"><input type="submit" value="Confirmer"</td></tr>';
|
||||
print '</table>';
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Edition de la fiche
|
||||
@ -132,9 +189,16 @@ else
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td width="20%">Nom</td><td><input name="nom" size="40" value="'.$newsletter->nom.'"></td>';
|
||||
|
||||
print '<tr><td>Emetteur nom</td><td><input name="email_from_name" size="30" value="'.$newsletter->email_from_name.'"></td></tr>';
|
||||
print '<tr><td>Emetteur email</td><td><input name="email_from_email" size="40" value="'.$newsletter->email_from_email.'"></td></tr>';
|
||||
print '<tr><td>Email de réponse</td><td><input name="email_replyto" size="40" value="'.$newsletter->email_replyto.'"></td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td width="20%">Sujet</td>';
|
||||
print '<td><input name="email_subject" size="40" value="'.$newsletter->email_subject.'"></td>';
|
||||
|
||||
print '<tr><td width="20%" valign="top">Texte</td><td width="80%"><textarea name="email_body" rows="10" cols="60">'.$newsletter->email_body.'</textarea></td></tr>';
|
||||
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" value="Enregistrer"> <input type="submit" value="Annuler" name="cancel"></td></tr>';
|
||||
|
||||
@ -144,23 +208,35 @@ else
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Affichage de la fiche
|
||||
*
|
||||
*/
|
||||
|
||||
print '<div class="titre">Fiche Newsletter : '.$newsletter->titre.'</div><br>';
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print "<tr>";
|
||||
print '<td width="20%">Nom</td><td width="80%">'.$newsletter->nom.'</td></tr>';
|
||||
|
||||
print '<tr><td>Livres</td><td>';
|
||||
|
||||
foreach ($livres as $key => $value)
|
||||
{
|
||||
print '<a href="../livre/fiche.php?id='.$key.'">'.$value."<br>\n";
|
||||
}
|
||||
print "</td></tr>";
|
||||
print '<tr><td width="20%">Emetteur nom</td><td>'.$newsletter->email_from_name.'</td></tr>';
|
||||
print '<tr><td width="20%">Emetteur email</td><td>'.$newsletter->email_from_email.'</td></tr>';
|
||||
print '<tr><td width="20%">Email de réponse</td><td>'.$newsletter->email_replyto.'</td></tr>';
|
||||
print '<tr><td width="20%">Nom</td><td width="80%">'.$newsletter->email_subject.'</td></tr>';
|
||||
print '<tr><td width="20%" valign="top">Texte</td><td width="80%">'.nl2br($newsletter->email_body).'</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
if ($newsletter->status == 3)
|
||||
{
|
||||
print "<br />";
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
|
||||
print '<tr><td width="20%">Début de l\'envoi</td><td width="30%">'.strftime("%d %B %Y %H:%M:%S",$newsletter->date_send_begin).'</td>';
|
||||
print '<td width="20%">Nombre de mails envoyés</td><td width="30%">'.$newsletter->nbsent.'</td></tr>';
|
||||
|
||||
print '<tr><td width="20%">Fin de l\'envoi</td><td width="30%">'.strftime("%d %B %Y %H:%M:%S",$newsletter->date_send_end).'</td>';
|
||||
print '<td width="20%">Nombre de mails en erreur</td><td width="30%">'.$newsletter->nberror.'</td></tr>';
|
||||
print "</table>";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
@ -183,27 +259,47 @@ else
|
||||
/* ************************************************************************** */
|
||||
|
||||
print '<br><table width="100%" border="1" cellspacing="0" cellpadding="3">';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
}
|
||||
else
|
||||
elseif ($newsletter->status == 0)
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=edit&id='.$id.'">Editer</a>]</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
}
|
||||
|
||||
if ($newsletter->status == 0 && $id)
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=valid&id='.$id.'">Valider</a>]</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
}
|
||||
|
||||
if ($newsletter->status == 1)
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=send&id='.$id.'">Envoyer</a>]</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
}
|
||||
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
|
||||
if(sizeof($livres)==0 && $id)
|
||||
if($id && $newsletter->status == 0)
|
||||
{
|
||||
print '<td width="20%" align="center">[<a href="fiche.php?action=delete&id='.$id.'">Supprimer</a>]</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="20%" align="center">[Supprimer]</td>';
|
||||
print '<td width="20%" align="center">-</td>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
217
htdocs/boutique/newsletter/newsletter.class.php
Normal file
217
htdocs/boutique/newsletter/newsletter.class.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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$
|
||||
*
|
||||
*/
|
||||
|
||||
class Newsletter {
|
||||
var $db ;
|
||||
|
||||
var $id ;
|
||||
var $email_from_name;
|
||||
var $email_from_email;
|
||||
var $email_replyto;
|
||||
var $email_body;
|
||||
var $status;
|
||||
|
||||
Function Newsletter($DB, $id=0) {
|
||||
$this->db = $DB;
|
||||
$this->id = $id ;
|
||||
|
||||
$statustext[0] = "Rédaction";
|
||||
$statustext[1] = "Validé";
|
||||
$statustext[2] = "Envoi en cours";
|
||||
$statustext[3] = "Envoyé";
|
||||
$statustext[4] = "Non envoyé (erreur)";
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function create($user) {
|
||||
|
||||
$sql = "INSERT INTO llx_newsletter (fk_user_author, datec, nbsent) VALUES (".$user->id.",now(), 0)";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$id = $this->db->last_insert_id();
|
||||
|
||||
if ( $this->update($id, $user) )
|
||||
{
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function update($id, $user)
|
||||
{
|
||||
|
||||
if (strlen(trim($this->email_replyto))==0)
|
||||
{
|
||||
$this->email_replyto = $this->email_from_email;
|
||||
}
|
||||
$this->target = 1;
|
||||
|
||||
$this->target_sql = $this->build_sql($this->target);
|
||||
|
||||
$sql = "UPDATE llx_newsletter ";
|
||||
$sql .= " SET email_subject = '" . trim($this->email_subject) ."'";
|
||||
$sql .= ", email_from_name = '" . trim($this->email_from_name) ."'";
|
||||
$sql .= ", email_from_email = '" . trim($this->email_from_email) ."'";
|
||||
$sql .= ", email_replyto = '" . trim($this->email_replyto) ."'";
|
||||
$sql .= ", email_body= '" . trim($this->email_body) ."'";
|
||||
$sql .= ", target = ".$this->target;
|
||||
$sql .= ", sql_target = '".$this->target_sql."'";
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
|
||||
if ( $this->db->query($sql) ) {
|
||||
return 1;
|
||||
} else {
|
||||
print $this->db->error() . ' in ' . $sql;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function fetch ($id) {
|
||||
|
||||
$sql = "SELECT rowid, email_subject, email_from_name, email_from_email, email_replyto, email_body, target, sql_target, status, date_send_request,".$this->db->pdate("date_send_begin")." as date_send_begin,".$this->db->pdate("date_send_end")." as date_send_end, nbsent, nberror";
|
||||
$sql .= " FROM llx_newsletter WHERE rowid=$id";
|
||||
|
||||
$result = $this->db->query($sql) ;
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
$result = $this->db->fetch_array();
|
||||
|
||||
$this->id = $result["rowid"];
|
||||
$this->email_subject = stripslashes($result["email_subject"]);
|
||||
$this->email_from_name = stripslashes($result["email_from_name"]);
|
||||
$this->email_from_email = stripslashes($result["email_from_email"]);
|
||||
$this->email_replyto = stripslashes($result["email_replyto"]);
|
||||
$this->email_body = stripslashes($result["email_body"]);
|
||||
$this->status = $result["status"];
|
||||
$this->nbsent = $result["nbsent"];
|
||||
$this->nberror = $result["nberror"];
|
||||
$this->date_send_end = $result["date_send_end"];
|
||||
$this->date_send_begin = $result["date_send_begin"];
|
||||
|
||||
$this->status_text = $statustext[$this->status];
|
||||
|
||||
$this->db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function liste_array ()
|
||||
{
|
||||
$ga = array();
|
||||
|
||||
$sql = "SELECT rowid, nom FROM llx_editeur ORDER BY nom";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$nump = $this->db->num_rows();
|
||||
|
||||
if ($nump)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $nump)
|
||||
{
|
||||
$obj = $this->db->fetch_object($i);
|
||||
|
||||
$ga[$obj->rowid] = $obj->nom;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $ga;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function validate($user) {
|
||||
|
||||
$sql = "UPDATE llx_newsletter SET status=1, fk_user_valid = $user->id WHERE rowid = $this->id";
|
||||
$return = $this->db->query($sql) ;
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function send($user) {
|
||||
|
||||
$sql = "UPDATE llx_newsletter SET status=2, date_send_request=now() WHERE rowid = $this->id";
|
||||
$return = $this->db->query($sql) ;
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function build_sql($target)
|
||||
{
|
||||
if ($target == 1)
|
||||
{
|
||||
|
||||
$sql = "SELECT c.customers_lastname as name, c.customers_firstname as firstname, c.customers_email_address as email";
|
||||
$sql .= " FROM ".DB_NAME_OSC.".customers as c";
|
||||
$sql .= " WHERE c.customers_newsletter=1";
|
||||
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function delete() {
|
||||
|
||||
$sql = "DELETE FROM llx_newsletter WHERE rowid = $this->id ";
|
||||
$return = $this->db->query($sql) ;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -26,7 +26,7 @@ llxHeader();
|
||||
|
||||
$db = new Db();
|
||||
if ($sortfield == "") {
|
||||
$sortfield="lower(e.nom)";
|
||||
$sortfield="lower(c.customers_lastname)";
|
||||
}
|
||||
if ($sortorder == "") {
|
||||
$sortorder="ASC";
|
||||
@ -37,30 +37,37 @@ if ($page == -1) { $page = 0 ; }
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
print_barre_liste("Liste des Editeurs", $page, $PHP_SELF);
|
||||
print_barre_liste("Liste des notifications", $page, $PHP_SELF);
|
||||
|
||||
$sql = "SELECT e.rowid, e.nom FROM llx_editeur as e";
|
||||
|
||||
$sql = "SELECT c.customers_id, c.customers_lastname, c.customers_firstname, p.products_name, p.products_id";
|
||||
$sql .= " FROM ".DB_NAME_OSC.".products_notifications as n,".DB_NAME_OSC.".products_description as p";
|
||||
$sql .= ",".DB_NAME_OSC.".customers as c";
|
||||
$sql .= " WHERE n.customers_id = c.customers_id AND p.products_id=n.products_id";
|
||||
$sql .= " AND p.language_id = ".OSC_LANGUAGE_ID;
|
||||
$sql .= " ORDER BY $sortfield $sortorder ";
|
||||
$sql .= $db->plimit( $limit ,$offset);
|
||||
|
||||
if ( $db->query($sql) ) {
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
||||
print "<TR class=\"liste_titre\"><td>";
|
||||
print_liste_field_titre("Nom",$PHP_SELF, "e.nom");
|
||||
print_liste_field_titre("Client",$PHP_SELF, "c.customers_lastname");
|
||||
print "</td>";
|
||||
print "<td>Produit</td>";
|
||||
print "</TR>\n";
|
||||
$var=True;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<TD width='70%'><a href=\"fiche.php?id=$objp->rowid\">$objp->nom</a></TD>\n";
|
||||
print "</TR>\n";
|
||||
$i++;
|
||||
}
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<TD width='70%'><a href=\"fiche.php?id=$objp->rowid\">$objp->customers_firstname $objp->customers_lastname</a></TD>\n";
|
||||
print '<td><a href="/boutique/livre/fiche.php?oscid='.$objp->products_id.'">'.$objp->products_name."</a></td>";
|
||||
print "</TR>\n";
|
||||
$i++;
|
||||
}
|
||||
print "</TABLE>";
|
||||
$db->free();
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ function print_titre($titre)
|
||||
*
|
||||
*
|
||||
*/
|
||||
function print_barre_liste($titre,$page,$file,$options='')
|
||||
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='')
|
||||
{
|
||||
global $conf;
|
||||
print '<table width="100%" border="0" cellpadding="3" cellspacing="0">';
|
||||
@ -268,6 +268,18 @@ function print_barre_liste($titre,$page,$file,$options='')
|
||||
print '<tr><td><div class="titre">'.$titre.'</div></td>';
|
||||
}
|
||||
print '<td align="right">';
|
||||
|
||||
if (strlen($sortfield))
|
||||
{
|
||||
$options .= "&sortfield=$sortfield";
|
||||
}
|
||||
|
||||
if (strlen($sortorder))
|
||||
{
|
||||
$options .= "&sortorder=$sortorder";
|
||||
}
|
||||
|
||||
|
||||
if ($page > 0)
|
||||
{
|
||||
print '<a href="'.$file.'?page='.($page-1).$options.'"><img alt="Page précédente" src="/theme/'.$conf->theme.'/img/1leftarrow.png" border="0"></a>';
|
||||
|
||||
@ -24,6 +24,7 @@ $SYSLOG_LEVEL = 'local3';
|
||||
use strict;
|
||||
use vars qw($SYSLOG_LEVEL);
|
||||
use DBI;
|
||||
use Net::SMTP;
|
||||
use Text::Wrap;
|
||||
use Getopt::Long;
|
||||
use Sys::Syslog qw(:DEFAULT setlogsock);
|
||||
@ -41,7 +42,7 @@ unless (defined $ENV{"DBI_DSN"}) {
|
||||
}
|
||||
|
||||
|
||||
my($dbh, $sth, $sthi, $i, $sqli, $sql, $stha, $digest, $mesg);
|
||||
my($dbh, $sth, $sthi, $i, $sqli, $sql, $stha, $digest);
|
||||
|
||||
print "Running in verbose mode level $verbose\n" if $verbose>0;
|
||||
|
||||
@ -49,9 +50,9 @@ my $sl = Sys::Syslog::setlogsock('unix');
|
||||
$sl = Sys::Syslog::openlog('send-newsletter.pl', 'pid', $SYSLOG_LEVEL);
|
||||
$sl = Sys::Syslog::syslog('info', 'Start');
|
||||
|
||||
print "Start on " if $verbose>0;
|
||||
print "Start\n" if $verbose>0;
|
||||
|
||||
print "Open DBI connection\n" if $verbose>3;
|
||||
print "DBI connection : open\n" if $verbose>3;
|
||||
$dbh = DBI->connect() || die $DBI::errstr;
|
||||
|
||||
#
|
||||
@ -74,21 +75,19 @@ $dbh = DBI->connect() || die $DBI::errstr;
|
||||
|
||||
my $sqli = "SELECT rowid, email_subject, email_from_name, email_from_email, email_replyto, email_body, target, sql_target, status, date_send_request, date_send_begin, date_send_end, nbsent";
|
||||
|
||||
$sqli .= " FROM llx_newsletter WHERE status=1 AND date_send_request < now()";
|
||||
$sqli .= " FROM llx_newsletter WHERE status=2 AND date_send_request < now()";
|
||||
$sthi = $dbh->prepare($sqli);
|
||||
|
||||
$sthi->execute;
|
||||
|
||||
my ($hsri);
|
||||
while ( $hsri = $sthi->fetchrow_hashref )
|
||||
{
|
||||
while ( $hsri = $sthi->fetchrow_hashref ) {
|
||||
|
||||
#
|
||||
# Update newsletter
|
||||
#
|
||||
if (!$debug)
|
||||
{
|
||||
$stha = $dbh->prepare("UPDATE llx_newsletter SET date_send_begin=now() WHERE rwoid=" . $hsri->{"rowid"});
|
||||
if (!$debug) {
|
||||
$stha = $dbh->prepare("UPDATE llx_newsletter SET status=4,date_send_begin=now() WHERE rowid=" . $hsri->{"rowid"});
|
||||
$stha->execute;
|
||||
$stha->finish;
|
||||
}
|
||||
@ -96,42 +95,62 @@ while ( $hsri = $sthi->fetchrow_hashref )
|
||||
#
|
||||
#
|
||||
#
|
||||
my ($fromemail, $from, $replyto, $subject, $mesg);
|
||||
|
||||
$from = $hsri->{"email_from_name"} . "<" . $hsri->{"email_from_email"} . ">";
|
||||
$replyto = $hsri->{"email_replyto"};
|
||||
$mesg = $hsri->{"email_body"};
|
||||
$subject = $hsri->{"email_subject"};
|
||||
$sql = $hsri->{"sql_target"};
|
||||
$from = $hsri->{"email_from_name"} . " <" . $hsri->{"email_from_email"} . ">";
|
||||
$fromemail = $hsri->{"email_from_email"};
|
||||
$replyto = $hsri->{"email_replyto"};
|
||||
$mesg = $hsri->{"email_body"};
|
||||
$subject = $hsri->{"email_subject"};
|
||||
$sql = $hsri->{"sql_target"};
|
||||
|
||||
print "Message de : $from\n" if $verbose;
|
||||
|
||||
#
|
||||
# Read dest
|
||||
#
|
||||
|
||||
if ($sql)
|
||||
{
|
||||
if ($sql) {
|
||||
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->execute;
|
||||
|
||||
my($nbdest) = (0);
|
||||
my($nbdest, $nberror) = (0,0);
|
||||
|
||||
while ( $hsr = $sth->fetchrow_hashref )
|
||||
while (my $hsr = $sth->fetchrow_hashref )
|
||||
{
|
||||
|
||||
if (length($hsr->{"email"}) > 0)
|
||||
{
|
||||
my $firstname = $hsr->{"prenom"};
|
||||
my $name = $hsr->{"nom"};
|
||||
my $firstname = $hsr->{"firstname"};
|
||||
my $lastname = $hsr->{"name"};
|
||||
my $email = "$firstname $lastname <".$hsr->{"email"}.">";
|
||||
|
||||
my $gm = mail_it($hsr->{"email"},
|
||||
$from,
|
||||
$subject,
|
||||
$mesg,
|
||||
$replyto);
|
||||
|
||||
if (!$debug)
|
||||
{
|
||||
|
||||
if (! mail_it($hsr->{"email"},
|
||||
$email,
|
||||
$fromemail,
|
||||
$from,
|
||||
$subject,
|
||||
$mesg,
|
||||
$replyto))
|
||||
{
|
||||
$nberror++;
|
||||
print $nberror;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print "$nbdest : Mail $from -> ".$email."\n" if $verbose;
|
||||
}
|
||||
}
|
||||
|
||||
$nbdest++;
|
||||
|
||||
$nbdest++;
|
||||
}
|
||||
|
||||
$sth->finish;
|
||||
@ -141,18 +160,22 @@ while ( $hsri = $sthi->fetchrow_hashref )
|
||||
#
|
||||
if (!$debug)
|
||||
{
|
||||
$stha = $dbh->prepare("UPDATE llx_newsletter SET status=3,date_send_end=now(), nbsent=$nbdest WHERE rowid=" . $hsri->{"rowid"});
|
||||
$stha = $dbh->prepare("UPDATE llx_newsletter SET status=3,date_send_end=now(), nbsent=$nbdest, nberror=$nberror WHERE rowid=" . $hsri->{"rowid"});
|
||||
$stha->execute;
|
||||
$stha->finish;
|
||||
}
|
||||
} else {
|
||||
print "No sql request";
|
||||
}
|
||||
|
||||
}
|
||||
$sthi->finish;
|
||||
|
||||
print "Close DBI connection\n" if $verbose>3;
|
||||
print "DBI connection : close\n" if $verbose>3;
|
||||
|
||||
$dbh->disconnect;
|
||||
|
||||
print "End\n" if $verbose>0;
|
||||
#
|
||||
#
|
||||
#
|
||||
@ -162,7 +185,6 @@ $sl = Sys::Syslog::syslog('info', 'End');
|
||||
|
||||
Sys::Syslog::closelog();
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
@ -174,7 +196,7 @@ sub print_help {
|
||||
}
|
||||
|
||||
sub mail_it {
|
||||
my ($to, $from, $subject, $mesg, $replyto) = @_;
|
||||
my ($toemail, $to, $fromemail, $from, $subject, $mesg, $replyto) = @_;
|
||||
my ($smtp);
|
||||
|
||||
$mesg = wrap("","",$mesg);
|
||||
@ -183,24 +205,38 @@ sub mail_it {
|
||||
Hello => 'localhost',
|
||||
Timeout => 30);
|
||||
|
||||
if ($smtp)
|
||||
{
|
||||
$smtp->mail($from);
|
||||
$smtp->to($to);
|
||||
if ($smtp) {
|
||||
|
||||
print "Mail $from -> ".$to."\n" if $verbose;
|
||||
|
||||
if ($smtp->verify($toemail)) {
|
||||
|
||||
$smtp->mail($fromemail);
|
||||
$smtp->to($toemail);
|
||||
|
||||
$smtp->data();
|
||||
$smtp->datasend("From: $from\n");
|
||||
$smtp->datasend("Reply-To: $replyto\n") if $replyto;
|
||||
$smtp->datasend("Content-Type: text/plain; charset=\"iso-8859-1\"\n");
|
||||
$smtp->datasend("To: $to\n");
|
||||
$smtp->datasend("Subject: $subject\n");
|
||||
$smtp->datasend("X-Mailer: Dolibarr\n");
|
||||
$smtp->datasend("\n");
|
||||
$smtp->data();
|
||||
$smtp->datasend("From: $from\n");
|
||||
$smtp->datasend("Reply-To: $replyto\n") if $replyto;
|
||||
$smtp->datasend("Content-Type: text/plain; charset=\"iso-8859-1\"\n");
|
||||
$smtp->datasend("To: $to\n");
|
||||
$smtp->datasend("Subject: $subject\n");
|
||||
$smtp->datasend("X-Mailer: Dolibarr\n");
|
||||
$smtp->datasend("\n");
|
||||
|
||||
$smtp->datasend($mesg);
|
||||
$smtp->datasend($mesg);
|
||||
|
||||
$smtp->dataend();
|
||||
|
||||
return 1;
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$smtp->dataend();
|
||||
$smtp->quit;
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user