Enhance script

This commit is contained in:
Laurent Destailleur 2013-03-13 18:27:05 +01:00
parent ed5d1196b2
commit a47616cb95
3 changed files with 42 additions and 15 deletions

View File

@ -389,6 +389,7 @@ ClosePaidCreditNotesAutomatically=Classify "Payed" all credit notes entierely pa
AllCompletelyPayedInvoiceWillBeClosed=All invoice with no remain to pay will be automatically closed to status "Payed". AllCompletelyPayedInvoiceWillBeClosed=All invoice with no remain to pay will be automatically closed to status "Payed".
ToMakePayment=Pay ToMakePayment=Pay
ToMakePaymentBack=Pay back ToMakePaymentBack=Pay back
ListOfYourUnpaidInvoices=List of unpaid invoices
##### Types de contacts ##### ##### Types de contacts #####
TypeContact_facture_internal_SALESREPFOLL=Representative following-up customer invoice TypeContact_facture_internal_SALESREPFOLL=Representative following-up customer invoice
TypeContact_facture_external_BILLING=Customer invoice contact TypeContact_facture_external_BILLING=Customer invoice contact

View File

@ -386,6 +386,7 @@ ClosePaidCreditNotesAutomatically=Classer automatiquement à "Payé" les facture
AllCompletelyPayedInvoiceWillBeClosed=Toutes les factures avec un reste à payer nul seront automatiquement fermées au statut "Payé". AllCompletelyPayedInvoiceWillBeClosed=Toutes les factures avec un reste à payer nul seront automatiquement fermées au statut "Payé".
ToMakePayment=Payer ToMakePayment=Payer
ToMakePaymentBack=Rembourser ToMakePaymentBack=Rembourser
ListOfYourUnpaidInvoices=Liste des factures impayées
##### Types de contacts ##### ##### Types de contacts #####
TypeContact_facture_internal_SALESREPFOLL=Responsable suivi facture client TypeContact_facture_internal_SALESREPFOLL=Responsable suivi facture client
TypeContact_facture_external_BILLING=Contact client facturation TypeContact_facture_external_BILLING=Contact client facturation

View File

@ -51,6 +51,7 @@ require($path."../../htdocs/master.inc.php");
require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"); require_once (DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
/* /*
* Main * Main
*/ */
@ -141,20 +142,23 @@ else
/** /**
* Send email * Send email
* *
* @param string $oldemail Old email * @param string $mode Mode (test | confirm)
* @param string $oldemail Old email
* @param string $message Message to send * @param string $message Message to send
* @param string $total Total amount of unpayed invoices * @param string $total Total amount of unpayed invoices
* @param string $userlang Code lang to use for email output.
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function envoi_mail($mode,$oldemail,$message,$total,$userlang) function envoi_mail($mode,$oldemail,$message,$total,$userlang)
{ {
global $conf,$langs; global $conf,$langs;
global $db;
$newlangs=new Translate($db,$conf); $newlangs=new Translate('',$conf);
$newlangs->setDefaultLang($userlang); $newlangs->setDefaultLang($userlang);
$newlangs->load("main");
$newlangs->load("bills");
$subject = "[".($conf->global->MAIN_APPLICATION_TITLE)."] ".$newlangs->trans("ListOfYourUnpaidInvoices"); $subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$newlangs->trans("ListOfYourUnpaidInvoices");
$sendto = $oldemail; $sendto = $oldemail;
$from = $conf->global->MAIN_EMAIL_FROM; $from = $conf->global->MAIN_EMAIL_FROM;
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
@ -163,12 +167,28 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang)
print "Send email for ".$oldemail.", total: ".$total."\n"; print "Send email for ".$oldemail.", total: ".$total."\n";
dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to ".$oldemail); dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to ".$oldemail);
$allmessage = "List of unpaid invoices\n"; $usehtml=0;
$allmessage.= "This list contains only invoices for third parties you are linked to as a sales representative.\n"; if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_FOOTER)) $usehtml+=1;
$allmessage.= "\n"; if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_HEADER)) $usehtml+=1;
$allmessage.= $message;
$allmessage.= "\n"; $allmessage='';
$allmessage.= $langs->trans("Total")." = ".price($total)."\n"; if (! empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_HEADER))
{
$allmessage.=$conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_HEADER;
}
else
{
$allmessage.= "List of unpaid invoices\n\n";
$allmessage.= "This list contains only invoices for third parties you are linked to as a sales representative.\n";
$allmessage.= "\n";
}
$allmessage.= $message.($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total).($usehtml?"<br>\n":"\n");
if (! empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_FOOTER))
{
$allmessage.=$conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_FOOTER;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_FOOTER)) $usehtml+=1;
}
$mail = new CMailFile( $mail = new CMailFile(
$subject, $subject,
@ -186,11 +206,16 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang)
$mail->errors_to = $errorsto; $mail->errors_to = $errorsto;
// Send or not email
if ($mode == 'confirm') if ($mode == 'confirm')
{ {
$result=$mail->sendfile(); $result=$mail->sendfile();
} }
else $result=1; else
{
$mail->dump_mail();
$result=1;
}
if ($result) if ($result)
{ {