diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 9260d85cd91..cb6461eb5b6 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -144,17 +144,23 @@ if ($resql) //if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n"; } + // Define line content + $outputlangs=new Translate('',$conf); + $outputlangs->setDefaultLang(empty($obj->default_lang)?$langs->defaultlang:$obj->default_lang); // By default language of customer + if (dol_strlen($newemail)) { - $message .= $langs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc)."\n"; + $message .= $outputlangs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc)."\n"; dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message); $foundtoprocess++; } - print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.",":"")." email ".$newemail.": "; + print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc,0,$outputlangs).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.",":"")." email ".$newemail.": "; if (dol_strlen($newemail)) print "qualified."; else print "disqualified (no email)."; print "\n"; + unset($outputlangs); + $total += $obj->total_ttc; $i++; @@ -212,19 +218,19 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget) $newlangs->load("main"); $newlangs->load("bills"); - $subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$newlangs->trans("ListOfYourUnpaidInvoices"); + $subject = (empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT)?$newlangs->trans("ListOfYourUnpaidInvoices"):'['.$conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT.']'); $sendto = $oldemail; $from = $conf->global->MAIN_MAIL_EMAIL_FROM; $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $msgishtml = -1; - print "- Send email for '".$oldtarget."' (".$oldemail."), total: ".$total."\n"; + print "- Send email to '".$oldtarget."' (".$oldemail."), total: ".$total."\n"; dol_syslog("email_unpaid_invoices_to_customers.php: send mail to ".$oldemail); $usehtml=0; if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) $usehtml+=1; if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) $usehtml+=1; - + $allmessage=''; if (! empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) { @@ -278,6 +284,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget) $result=1; } + unset($newlangs); if ($result) { return 1; diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 2c23512cedb..408d05f1d4a 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -74,7 +74,8 @@ print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" d if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1; -$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 = "SELECT f.facnumber, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, s.email, s.default_lang,"; +$sql.= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " , ".MAIN_DB_PREFIX."societe as s"; $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -126,9 +127,13 @@ if ($resql) if (empty($obj->email)) print "Warning: Sal representative ".$salerepresentative." has no email. Notice disabled.\n"; } + // Define line content + $outputlangs=new Translate('',$conf); + $outputlangs->setDefaultLang(empty($obj->lang)?$langs->defaultlang:$obj->lang); // By default language of sale representative + if (dol_strlen($obj->email)) { - $message .= $langs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc)." : ".$obj->name."\n"; + $message .= $outputlangs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc,0,$outputlangs)." : ".$obj->name."\n"; dol_syslog("email_unpaid_invoices_to_representatives.php: ".$obj->email); $foundtoprocess++; } @@ -137,6 +142,8 @@ if ($resql) else print "disqualified (no email)."; print "\n"; + unset($outputlangs); + $total += $obj->total_ttc; $i++; }