Fix warnings

This commit is contained in:
Laurent Destailleur 2021-01-02 17:43:02 +01:00
parent 2d1121031a
commit 821ef72d48
4 changed files with 57 additions and 33 deletions

View File

@ -74,8 +74,9 @@ $duration_value2 = isset($argv[4]) ? $argv[4] : 'none';
$error = 0; $error = 0;
print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "").(is_numeric($duration_value2) ? " after=".$duration_value2 : "")."\n"; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "").(is_numeric($duration_value2) ? " after=".$duration_value2 : "")."\n";
if ($mode != 'confirm') if ($mode != 'confirm') {
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; $conf->global->MAIN_DISABLE_ALL_MAILS = 1;
}
$sql = "SELECT c.ref, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel,"; $sql = "SELECT c.ref, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel,";
$sql .= " s.rowid as sid, s.nom as name, s.email, s.default_lang"; $sql .= " s.rowid as sid, s.nom as name, s.email, s.default_lang";
@ -115,6 +116,7 @@ if ($resql) {
print "We found ".$num." couples (services to expire-".$targettype.") qualified\n"; print "We found ".$num." couples (services to expire-".$targettype.") qualified\n";
dol_syslog("We found ".$num." couples (services to expire-".$targettype.") qualified"); dol_syslog("We found ".$num." couples (services to expire-".$targettype.") qualified");
$message = ''; $message = '';
$oldtarget = '';
if ($num) { if ($num) {
while ($i < $num) { while ($i < $num) {
@ -124,12 +126,17 @@ if ($resql) {
// Check if this record is a break after previous one // Check if this record is a break after previous one
$startbreak = false; $startbreak = false;
if ($newemail != $oldemail || $oldemail == 'none') if ($newemail != $oldemail || $oldemail == 'none') {
$startbreak = true; $startbreak = true;
if ($obj->sid && $obj->sid != $oldsid) }
if ($obj->sid && $obj->sid != $oldsid) {
$startbreak = true; $startbreak = true;
if ($obj->cid && $obj->cid != $oldcid) }
if ($targettype == 'contacts') {
if ($obj->cid && $obj->cid != $oldcid) {
$startbreak = true; $startbreak = true;
}
}
if ($startbreak) { if ($startbreak) {
// Break onto sales representative (new email or cid) // Break onto sales representative (new email or cid)
@ -145,13 +152,14 @@ if ($resql) {
} }
$oldemail = $newemail; $oldemail = $newemail;
$oldsid = $obj->sid; $oldsid = $obj->sid;
if ($targettype == 'contacts') {
$oldcid = $obj->cid; $oldcid = $obj->cid;
}
$oldlang = $obj->lang; $oldlang = $obj->lang;
$oldtarget = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname); $oldtarget = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname);
$message = ''; $message = '';
$total = 0; $total = 0;
$foundtoprocess = 0; $foundtoprocess = 0;
$target = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname);
// if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n"; // if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n";
} }
@ -167,7 +175,7 @@ if ($resql) {
dol_syslog("email_expire_services_to_customers.php: ".$newemail." ".$message); dol_syslog("email_expire_services_to_customers.php: ".$newemail." ".$message);
$foundtoprocess++; $foundtoprocess++;
} }
print "Service to expire ".$obj->ref.", label ".dol_concatdesc($obj->plabel, $obj->description).", due date ".dol_print_date($db->jdate($obj->date_fin_validite), 'day').", customer id ".$obj->sid." ".$obj->name.", ".($obj->cid ? "contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", " : "")."email ".$newemail.", lang ".$outputlangs->defaultlang.": "; print "Service to expire ".$obj->ref.", label ".dol_concatdesc($obj->plabel, $obj->description).", due date ".dol_print_date($db->jdate($obj->date_fin_validite), 'day').", customer id ".$obj->sid." ".$obj->name.", ".(isset($obj->cid) ? "contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", " : "")."email ".$newemail.", lang ".$outputlangs->defaultlang.": ";
if (dol_strlen($newemail)) if (dol_strlen($newemail))
print "qualified."; print "qualified.";
else print "disqualified (no email)."; else print "disqualified (no email).";

View File

@ -70,8 +70,9 @@ $duration_value = isset($argv[2]) ? $argv[2] : 'none';
print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "")."\n"; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "")."\n";
if ($mode != 'confirm') if ($mode != 'confirm') {
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; $conf->global->MAIN_DISABLE_ALL_MAILS = 1;
}
$sql = "SELECT DISTINCT c.ref, c.fk_soc, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel, s.rowid, s.nom as name, s.email, s.default_lang,"; $sql = "SELECT DISTINCT c.ref, c.fk_soc, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel, s.rowid, s.nom as name, s.email, s.default_lang,";
$sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang"; $sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang";
@ -192,25 +193,31 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldsalerepre
$newlangs->load("contracts"); $newlangs->load("contracts");
if ($duration_value) { if ($duration_value) {
if ($duration_value > 0) if ($duration_value > 0) {
$title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value); $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value);
else $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value); } else {
} else $title = $newlangs->transnoentities("ListOfServicesToExpire"); $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value);
}
} else {
$title = $newlangs->transnoentities("ListOfServicesToExpire");
}
$subject = (empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT) ? $title : $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT); $subject = (empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT) ? $title : $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT);
$sendto = $oldemail; $sendto = $oldemail;
$from = $conf->global->MAIN_MAIL_EMAIL_FROM; $from = empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM;
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $errorsto = empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '' : $conf->global->MAIN_MAIL_ERRORS_TO;
$msgishtml = - 1; $msgishtml = - 1;
print "- Send email for ".$oldsalerepresentative." (".$oldemail."), total: ".$total."\n"; print "- Send email for ".$oldsalerepresentative." (".$oldemail."), total: ".$total."\n";
dol_syslog("email_expire_services_to_representatives.php: send mail to ".$oldemail); dol_syslog("email_expire_services_to_representatives.php: send mail to ".$oldemail);
$usehtml = 0; $usehtml = 0;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER)) if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER) && dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER)) {
$usehtml += 1; $usehtml += 1;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER)) }
if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER) && dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER)) {
$usehtml += 1; $usehtml += 1;
}
$allmessage = ''; $allmessage = '';
if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER)) { if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER)) {

View File

@ -74,8 +74,9 @@ $duration_value2 = isset($argv[4]) ? $argv[4] : 'none';
$error = 0; $error = 0;
print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "").(is_numeric($duration_value2) ? " after=".$duration_value2 : "")."\n"; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "").(is_numeric($duration_value2) ? " after=".$duration_value2 : "")."\n";
if ($mode != 'confirm') if ($mode != 'confirm') {
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; $conf->global->MAIN_DISABLE_ALL_MAILS = 1;
}
$sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date,"; $sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date,";
$sql .= " s.rowid as sid, s.nom as name, s.email, s.default_lang"; $sql .= " s.rowid as sid, s.nom as name, s.email, s.default_lang";
@ -113,6 +114,7 @@ if ($resql) {
print "We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified\n"; print "We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified\n";
dol_syslog("We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified"); dol_syslog("We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified");
$message = ''; $message = '';
$oldtarget = '';
if ($num) { if ($num) {
while ($i < $num) { while ($i < $num) {
@ -122,12 +124,17 @@ if ($resql) {
// Check if this record is a break after previous one // Check if this record is a break after previous one
$startbreak = false; $startbreak = false;
if ($newemail != $oldemail || $oldemail == 'none') if ($newemail != $oldemail || $oldemail == 'none') {
$startbreak = true; $startbreak = true;
if ($obj->sid && $obj->sid != $oldsid) }
if ($obj->sid && $obj->sid != $oldsid) {
$startbreak = true; $startbreak = true;
if ($obj->cid && $obj->cid != $oldcid) }
if ($targettype == 'contacts') {
if ($obj->cid && $obj->cid != $oldcid) {
$startbreak = true; $startbreak = true;
}
}
if ($startbreak) { if ($startbreak) {
// Break onto sales representative (new email or cid) // Break onto sales representative (new email or cid)
@ -143,13 +150,14 @@ if ($resql) {
} }
$oldemail = $newemail; $oldemail = $newemail;
$oldsid = $obj->sid; $oldsid = $obj->sid;
if ($targettype == 'contacts') {
$oldcid = $obj->cid; $oldcid = $obj->cid;
}
$oldlang = $obj->lang; $oldlang = $obj->lang;
$oldtarget = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname); $oldtarget = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname);
$message = ''; $message = '';
$total = 0; $total = 0;
$foundtoprocess = 0; $foundtoprocess = 0;
$target = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname);
// if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n"; // if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n";
} }
@ -165,7 +173,7 @@ if ($resql) {
dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message); dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message);
$foundtoprocess++; $foundtoprocess++;
} }
print "Unpaid invoice ".$obj->ref.", 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.", lang ".$outputlangs->defaultlang.": "; print "Unpaid invoice ".$obj->ref.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date), 'day').", customer id ".$obj->sid." ".$obj->name.", ".(isset($obj->cid) ? "contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", " : "")."email ".$newemail.", lang ".$outputlangs->defaultlang.": ";
if (dol_strlen($newemail)) if (dol_strlen($newemail))
print "qualified."; print "qualified.";
else print "disqualified (no email)."; else print "disqualified (no email).";
@ -229,17 +237,17 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget)
$subject = (empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT); $subject = (empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT);
$sendto = $oldemail; $sendto = $oldemail;
$from = $conf->global->MAIN_MAIL_EMAIL_FROM; $from = empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM;
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $errorsto = empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '' : $conf->global->MAIN_MAIL_ERRORS_TO;
$msgishtml = - 1; $msgishtml = - 1;
print "- Send email to '".$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); dol_syslog("email_unpaid_invoices_to_customers.php: send mail to ".$oldemail);
$usehtml = 0; $usehtml = 0;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER) && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER))
$usehtml += 1; $usehtml += 1;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER) && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER))
$usehtml += 1; $usehtml += 1;
$allmessage = ''; $allmessage = '';

View File

@ -70,8 +70,9 @@ $duration_value = isset($argv[2]) ? $argv[2] : 'none';
print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "")."\n"; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "")."\n";
if ($mode != 'confirm') if ($mode != 'confirm') {
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; $conf->global->MAIN_DISABLE_ALL_MAILS = 1;
}
$sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, s.email, s.default_lang,"; $sql = "SELECT f.ref, 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 .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang";
@ -196,17 +197,17 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldsalerepre
$subject = (empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT); $subject = (empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT);
$sendto = $oldemail; $sendto = $oldemail;
$from = $conf->global->MAIN_MAIL_EMAIL_FROM; $from = empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM;
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $errorsto = empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '' : $conf->global->MAIN_MAIL_ERRORS_TO;
$msgishtml = - 1; $msgishtml = - 1;
print "- Send email for ".$oldsalerepresentative." (".$oldemail."), total: ".$total."\n"; print "- Send email for ".$oldsalerepresentative." (".$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);
$usehtml = 0; $usehtml = 0;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER) && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER))
$usehtml += 1; $usehtml += 1;
if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER)) if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER) && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER))
$usehtml += 1; $usehtml += 1;
$allmessage = ''; $allmessage = '';