Can force out email

This commit is contained in:
Laurent Destailleur 2013-05-20 21:04:00 +02:00
parent 0a5bb491d3
commit 7ef45b9226
4 changed files with 23 additions and 15 deletions

View File

@ -68,9 +68,9 @@ $error=0;
print "***** ".$script_file." (".$version.") *****\n";
$now=dol_now('tzserver');
$duration_value=$argv[2];
$duration_value=isset($argv[2])?$argv[2]:'none';
print $script_file." launched with mode ".$mode.($duration_value?" delay=".$duration_value:"")."\n";
print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n";
$sql = "SELECT DISTINCT s.nom as name, c.ref, cd.date_fin_validite, cd.total_ttc, p.label label, s.email, s.default_lang";
$sql .= " FROM ".MAIN_DB_PREFIX."societe AS s";
@ -79,7 +79,7 @@ $sql .= ", ".MAIN_DB_PREFIX."contratdet AS cd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product";
$sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5";
if ($duration_value) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
if (is_numeric($duration_value)) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
$sql .= " ORDER BY cd.date_fin_validite ASC, s.rowid ASC";
@ -179,8 +179,10 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura
{
global $conf,$langs;
if (getenv('DOL_FORCE_EMAIL_TO')) $oldemail=getenv('DOL_FORCE_EMAIL_TO');
$newlangs=new Translate('',$conf);
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
$newlangs->load("main");
$newlangs->load("contracts");

View File

@ -68,9 +68,9 @@ $error=0;
print "***** ".$script_file." (".$version.") *****\n";
$now=dol_now('tzserver');
$duration_value=$argv[2];
$duration_value=isset($argv[2])?$argv[2]:'none';
print $script_file." launched with mode ".$mode.($duration_value?" delay=".$duration_value:"")."\n";
print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n";
$sql = "SELECT DISTINCT s.nom, c.ref, cd.date_fin_validite, cd.total_ttc, p.label label, c.fk_soc,u.rowid AS uid, u.lastname, u.firstname, u.email, u.lang";
$sql .= " FROM ".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."contrat AS c, ".MAIN_DB_PREFIX."contratdet AS cd";
@ -78,7 +78,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product, "
$sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5";
if ($duration_value) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
if (is_numeric($duration_value)) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
$sql .= " AND sc.fk_soc = s.rowid AND sc.fk_user = u.rowid";
$sql .= " ORDER BY cd.date_fin_validite ASC, s.rowid ASC";
@ -179,8 +179,10 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
{
global $conf,$langs;
if (getenv('DOL_FORCE_EMAIL_TO')) $oldemail=getenv('DOL_FORCE_EMAIL_TO');
$newlangs=new Translate('',$conf);
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
$newlangs->load("main");
$newlangs->load("contracts");

View File

@ -68,10 +68,10 @@ $error=0;
print "***** ".$script_file." (".$version.") *****\n";
$now=dol_now('tzserver');
$duration_value=isset($argv[3])?$argv[3]:-1;
$duration_value=isset($argv[3])?$argv[3]:'none';
$error = 0;
print $script_file." launched with mode ".$mode.($duration_value>=0?" delay=".$duration_value:"")."\n";
print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n";
$sql = "SELECT f.facnumber, f.total_ttc, f.date_lim_reglement as due_date,";
$sql.= " s.rowid as sid, s.nom as name, s.email, s.default_lang";
@ -80,7 +80,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
if ($targettype == 'contacts') $sql.= ", ".MAIN_DB_PREFIX."socpeople as sp";
$sql.= " WHERE f.fk_statut != 0 AND f.paye = 0";
$sql.= " AND f.fk_soc = s.rowid";
if ($duration_value>=0) $sql.= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
if (is_numeric($duration_value)) $sql.= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
if ($targettype == 'contacts') $sql.= " AND s.rowid = sp.fk_soc";
$sql.= " ORDER BY";
if ($targettype == 'contacts') $sql.= " sp.email, sp.rowid,";
@ -203,6 +203,8 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget)
{
global $conf,$langs;
if (getenv('DOL_FORCE_EMAIL_TO')) $oldemail=getenv('DOL_FORCE_EMAIL_TO');
$newlangs=new Translate('',$conf);
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
$newlangs->load("main");
@ -229,7 +231,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget)
else
{
$allmessage.= "Dear customer".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
$allmessage.= "Please, find a summary of the bills with pending payments from you, with an attachment of invoices.".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
$allmessage.= "Please, find a summary of the bills with pending payments from you.".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
$allmessage.= "Note: This list contains only unpaid invoices.".($usehtml?"<br>\n":"\n");
}
$allmessage.= $message.($usehtml?"<br>\n":"\n");

View File

@ -68,9 +68,9 @@ $error=0;
print "***** ".$script_file." (".$version.") *****\n";
$now=dol_now('tzserver');
$duration_value=isset($argv[2])?$argv[2]:-1;
$duration_value=isset($argv[2])?$argv[2]:'none';
print $script_file." launched with mode ".$mode.($duration_value>=0?" delay=".$duration_value:"")."\n";
print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n";
$sql = "SELECT f.facnumber, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, u.rowid as uid, u.lastname, u.firstname, u.email, u.lang";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
@ -79,7 +79,7 @@ $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE f.fk_statut != 0 AND f.paye = 0";
$sql .= " AND f.fk_soc = s.rowid";
if ($duration_value>=0) $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
if (is_numeric($duration_value)) $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
$sql .= " AND sc.fk_soc = s.rowid";
$sql .= " AND sc.fk_user = u.rowid";
$sql .= " ORDER BY u.email ASC, s.rowid ASC, f.facnumber ASC"; // Order by email to allow one message per email
@ -179,6 +179,8 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
{
global $conf,$langs;
if (getenv('DOL_FORCE_EMAIL_TO')) $oldemail=getenv('DOL_FORCE_EMAIL_TO');
$newlangs=new Translate('',$conf);
$newlangs->setDefaultLang(empty($userlang)?(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT):$userlang);
$newlangs->load("main");