Skip to content

Commit

Permalink
Fix: Missing currency into email content. Must also use language of
Browse files Browse the repository at this point in the history
target.
  • Loading branch information
eldy committed Jun 21, 2013
1 parent b477272 commit feef164
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
11 changes: 9 additions & 2 deletions scripts/contracts/email_expire_services_to_customers.php
Expand Up @@ -124,9 +124,16 @@
if (empty($obj->email)) print "Warning: Customer ".$customer." 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
$outputlangs->load("bills");
$outputlangs->load("main");
$outputlangs->load("contracts");

if (dol_strlen($oldemail))
{
$message .= $langs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".$obj->label." (".price($obj->total_ttc)."), ".$langs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n";
$message .= $langs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".$obj->label." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency)."), ".$langs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n";
dol_syslog("email_expire_services_to_customers.php: ".$obj->email);
$foundtoprocess++;
}
Expand Down Expand Up @@ -222,7 +229,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura
$allmessage.= "Note: This list contains only services to expire.".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
}
$allmessage.= $message.($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total).($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");
if (! empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER))
{
$allmessage.=$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER;
Expand Down
10 changes: 8 additions & 2 deletions scripts/contracts/email_expire_services_to_representatives.php
Expand Up @@ -125,9 +125,15 @@
if (empty($obj->email)) print "Warning: Sale 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
$outputlangs->load("bills");
$outputlangs->load("main");

if (dol_strlen($obj->email))
{
$message .= $langs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".$obj->label." (".price($obj->total_ttc).") ".$obj->nom.", ".$langs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n";
$message .= $langs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".$obj->label." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency).") ".$obj->nom.", ".$langs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n";
dol_syslog("email_expire_services_to_representatives.php: ".$obj->email);
$foundtoprocess++;
}
Expand Down Expand Up @@ -221,7 +227,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
$allmessage.= "Note: This list contains only services of contracts for third parties you are linked to as a sale representative.".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
}
$allmessage.= $message.($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total).($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");
if (! empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER))
{
$allmessage.=$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER;
Expand Down
4 changes: 2 additions & 2 deletions scripts/invoices/email_unpaid_invoices_to_customers.php
Expand Up @@ -152,7 +152,7 @@

if (dol_strlen($newemail))
{
$message .= $outputlangs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc,0,$outputlangs)."\n";
$message .= $outputlangs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency)."\n";
dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message);
$foundtoprocess++;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget)
$allmessage.= "Note: This list contains only unpaid invoices.".($usehtml?"<br>\n":"\n");
}
$allmessage.= $message.($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total).($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");
if (! empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER))
{
$allmessage.=$conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER;
Expand Down
4 changes: 2 additions & 2 deletions scripts/invoices/email_unpaid_invoices_to_representatives.php
Expand Up @@ -135,7 +135,7 @@

if (dol_strlen($obj->email))
{
$message .= $outputlangs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc,0,$outputlangs)." : ".$obj->name."\n";
$message .= $outputlangs->trans("Invoice")." ".$obj->facnumber." : ".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency)." : ".$obj->name."\n";
dol_syslog("email_unpaid_invoices_to_representatives.php: ".$obj->email);
$foundtoprocess++;
}
Expand Down Expand Up @@ -225,7 +225,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
$allmessage.= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices").($usehtml?"<br>\n":"\n");
}
$allmessage.= $message.($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total).($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");
if (! empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER))
{
$allmessage.=$conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER;
Expand Down

0 comments on commit feef164

Please sign in to comment.