From 7ef45b92267af30d2a2ab896548f1f8727d86f7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 20 May 2013 21:04:00 +0200 Subject: [PATCH] Can force out email --- .../contracts/email_expire_services_to_customers.php | 10 ++++++---- .../email_expire_services_to_representatives.php | 10 ++++++---- .../invoices/email_unpaid_invoices_to_customers.php | 10 ++++++---- .../email_unpaid_invoices_to_representatives.php | 8 +++++--- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index 4370314bb9d..75ad4cbfd08 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -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"); diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index b509ecc69a4..683962480a8 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -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"); diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index c631c394366..a98af2f6283 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -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?"
\n":"\n").($usehtml?"
\n":"\n"); - $allmessage.= "Please, find a summary of the bills with pending payments from you, with an attachment of invoices.".($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); + $allmessage.= "Please, find a summary of the bills with pending payments from you.".($usehtml?"
\n":"\n").($usehtml?"
\n":"\n"); $allmessage.= "Note: This list contains only unpaid invoices.".($usehtml?"
\n":"\n"); } $allmessage.= $message.($usehtml?"
\n":"\n"); diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index ca260dd43bc..07b27fd0904 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -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");