Clean code

This commit is contained in:
Laurent Destailleur
2025-11-18 11:48:33 +01:00
parent 8d459e469d
commit bba8884d13
10 changed files with 59 additions and 61 deletions

View File

@@ -1016,7 +1016,7 @@ class AccountancyExport
$tab['affaire'] = str_repeat(' ', 10);
$tab['quantity1'] = str_repeat(' ', 10);
$tab['num_piece2'] = str_pad(self::trunc((string) $line->piece_num, 8), 8);
$tab['devis'] = str_pad($conf->currency, 3);
$tab['devis'] = str_pad(getDolCurrency(), 3);
$tab['code_journal2'] = str_pad(self::trunc($line->code_journal, 3), 3);
$tab['filler3'] = str_repeat(' ', 3);

View File

@@ -194,7 +194,7 @@ if ($resql) {
$outputlangs->loadLangs(array("main", "contracts", "bills", "products"));
if (dol_strlen($newemail)) {
$message .= $outputlangs->trans("Contract")." ".$obj->ref.": ".$outputlangs->trans("Service")." ".dol_concatdesc($obj->plabel, $obj->description)." (".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency)."), ".$outputlangs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite), 'day')."\n\n";
$message .= $outputlangs->trans("Contract")." ".$obj->ref.": ".$outputlangs->trans("Service")." ".dol_concatdesc($obj->plabel, $obj->description)." (".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, getDolCurrency())."), ".$outputlangs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite), 'day')."\n\n";
dol_syslog("email_expire_services_to_customers.php: ".$newemail." ".$message);
$foundtoprocess++;
}
@@ -300,7 +300,6 @@ function sendEmailToCustomer($mode, $oldemail, $message, $total, $userlang, $old
$allmessage .= "Please, find a summary of the services contracted by you that are about to expire.".($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n");
}
$allmessage .= $message.($usehtml ? "<br>\n" : "\n");
// $allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");
if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER')) {
$allmessage .= getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER');
if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER'))) {

View File

@@ -150,7 +150,7 @@ if ($resql) {
$outputlangs->loadLangs(array("main", "contracts", "bills", "products"));
if (dol_strlen($obj->email)) {
$message .= $outputlangs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".dol_concatdesc($obj->plabel, $obj->description)." (".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency).") ".$obj->name.", ".$outputlangs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite), 'day')."\n\n";
$message .= $outputlangs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".dol_concatdesc($obj->plabel, $obj->description)." (".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, getDolCurrency()).") ".$obj->name.", ".$outputlangs->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++;
}
@@ -250,7 +250,7 @@ function sendEmailToRepresentative($mode, $oldemail, $message, $total, $userlang
$allmessage .= $newlangs->transnoentities("NoteListOfYourExpiredServices").($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n");
}
$allmessage .= $message.($usehtml ? "<br>\n" : "\n");
$allmessage .= $langs->trans("Total")." = ".price($total, 0, $userlang, 0, 0, -1, $conf->currency).($usehtml ? "<br>\n" : "\n");
$allmessage .= $langs->trans("Total")." = ".price($total, 0, $userlang, 0, 0, -1, getDolCurrency()).($usehtml ? "<br>\n" : "\n");
if (getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER')) {
$allmessage .= getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER');
if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER'))) {

View File

@@ -197,7 +197,7 @@ if ($resql) {
$outputlangs->loadLangs(array("main", "bills"));
if (dol_strlen($newemail)) {
$message .= $outputlangs->trans("Invoice")." ".$obj->ref." : ".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency)."\n";
$message .= $outputlangs->trans("Invoice")." ".$obj->ref." : ".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, getDolCurrency())."\n";
dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message);
$foundtoprocess++;
}
@@ -286,14 +286,14 @@ function sendMailCustomerUnpaid($mode, $oldemail, $message, $total, $userlang, $
$allmessage = '';
if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER')) {
$allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER;
$allmessage .= getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER');
} else {
$allmessage .= "Dear customer".($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n");
$allmessage .= "Please, find a summary of the bills with pending payments from you.".($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n");
$allmessage .= "Note: This list contains only unpaid invoices.".($usehtml ? "<br>\n" : "\n");
}
$allmessage .= $message.($usehtml ? "<br>\n" : "\n");
$allmessage .= $langs->trans("Total")." = ".price($total, 0, $userlang, 0, 0, -1, $conf->currency).($usehtml ? "<br>\n" : "\n");
$allmessage .= $langs->trans("Total")." = ".price($total, 0, $userlang, 0, 0, -1, getDolCurrency()).($usehtml ? "<br>\n" : "\n");
if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER')) {
$allmessage .= getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER');
if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER'))) {

View File

@@ -157,7 +157,7 @@ if ($resql) {
$outputlangs->loadLangs(array("main", "bills"));
if (dol_strlen($obj->email)) {
$message .= $outputlangs->trans("Invoice")." ".$obj->ref." : ".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency)." : ".$obj->name."\n";
$message .= $outputlangs->trans("Invoice")." ".$obj->ref." : ".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, getDolCurrency())." : ".$obj->name."\n";
dol_syslog("email_unpaid_invoices_to_representatives.php: ".$obj->email);
$foundtoprocess++;
}
@@ -246,7 +246,7 @@ function sendMailRepresentativeUnpaid($mode, $oldemail, $message, $total, $userl
$allmessage .= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices").($usehtml ? "<br>\n" : "\n");
}
$allmessage .= $message.($usehtml ? "<br>\n" : "\n");
$allmessage .= $langs->trans("Total")." = ".price($total, 0, $newlangs, 0, 0, -1, $conf->currency).($usehtml ? "<br>\n" : "\n");
$allmessage .= $langs->trans("Total")." = ".price($total, 0, $newlangs, 0, 0, -1, getDolCurrency()).($usehtml ? "<br>\n" : "\n");
if (getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER')) {
$allmessage .= getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER');
if (dol_textishtml(getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER'))) {

View File

@@ -91,7 +91,7 @@ if (!empty($dolibarr_main_db_readonly)) {
$now = $argv[1];
print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // We block email sending
print "\n";
print "----- Synchronize all records from Dolibarr database:\n";
print "type=".$conf->db->type."\n";

View File

@@ -84,32 +84,32 @@ dol_syslog($script_file." launched with arg ".implode(',', $argv));
// List of fields to get from LDAP
$required_fields = array(
$conf->global->LDAP_KEY_MEMBERS,
$conf->global->LDAP_FIELD_FULLNAME,
$conf->global->LDAP_FIELD_LOGIN,
$conf->global->LDAP_FIELD_LOGIN_SAMBA,
$conf->global->LDAP_FIELD_PASSWORD,
$conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
$conf->global->LDAP_FIELD_NAME,
$conf->global->LDAP_FIELD_FIRSTNAME,
$conf->global->LDAP_FIELD_MAIL,
$conf->global->LDAP_FIELD_PHONE,
$conf->global->LDAP_FIELD_PHONE_PERSO,
$conf->global->LDAP_FIELD_MOBILE,
$conf->global->LDAP_FIELD_FAX,
$conf->global->LDAP_FIELD_ADDRESS,
$conf->global->LDAP_FIELD_ZIP,
$conf->global->LDAP_FIELD_TOWN,
$conf->global->LDAP_FIELD_COUNTRY,
$conf->global->LDAP_FIELD_DESCRIPTION,
$conf->global->LDAP_FIELD_BIRTHDATE,
$conf->global->LDAP_FIELD_MEMBER_STATUS,
$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION,
getDolGlobalString('LDAP_KEY_MEMBERS'),
getDolGlobalString('LDAP_FIELD_FULLNAME'),
getDolGlobalString('LDAP_FIELD_LOGIN'),
getDolGlobalString('LDAP_FIELD_LOGIN_SAMBA'),
getDolGlobalString('LDAP_FIELD_PASSWORD'),
getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED'),
getDolGlobalString('LDAP_FIELD_NAME'),
getDolGlobalString('LDAP_FIELD_FIRSTNAME'),
getDolGlobalString('LDAP_FIELD_MAIL'),
getDolGlobalString('LDAP_FIELD_PHONE'),
getDolGlobalString('LDAP_FIELD_PHONE_PERSO'),
getDolGlobalString('LDAP_FIELD_MOBILE'),
getDolGlobalString('LDAP_FIELD_FAX'),
getDolGlobalString('LDAP_FIELD_ADDRESS'),
getDolGlobalString('LDAP_FIELD_ZIP'),
getDolGlobalString('LDAP_FIELD_TOWN'),
getDolGlobalString('LDAP_FIELD_COUNTRY'),
getDolGlobalString('LDAP_FIELD_DESCRIPTION'),
getDolGlobalString('LDAP_FIELD_BIRTHDATE'),
getDolGlobalString('LDAP_FIELD_MEMBER_STATUS'),
getDolGlobalString('LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION'),
// Subscriptions
$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE,
$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT,
$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE,
$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE'),
getDolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT'),
getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE'),
getDolGlobalString('LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')
);
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
@@ -125,6 +125,7 @@ foreach ($argv as $key => $val) {
if ($val == 'commitiferror') {
$forcecommit = 1;
}
$reg = array();
if (preg_match('/--server=([^\s]+)$/', $val, $reg)) {
$conf->global->LDAP_SERVER_HOST = $reg[1];
}

View File

@@ -110,7 +110,7 @@ if (!empty($dolibarr_main_db_readonly)) {
}
print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // We block email sending
print "\n";
print "----- Synchronize all records from LDAP database:\n";
print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n";

View File

@@ -103,7 +103,7 @@ foreach ($argv as $key => $val) {
}
print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // We block email sending
print "\n";
print "----- Synchronize all records from LDAP database:\n";
print "host=" . getDolGlobalString('LDAP_SERVER_HOST')."\n";

View File

@@ -76,25 +76,25 @@ dol_syslog($script_file." launched with arg ".implode(',', $argv));
// List of fields to get from LDAP
$required_fields = array(
$conf->global->LDAP_KEY_USERS,
$conf->global->LDAP_FIELD_FULLNAME,
$conf->global->LDAP_FIELD_NAME,
$conf->global->LDAP_FIELD_FIRSTNAME,
$conf->global->LDAP_FIELD_LOGIN,
$conf->global->LDAP_FIELD_LOGIN_SAMBA,
$conf->global->LDAP_FIELD_PASSWORD,
$conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
$conf->global->LDAP_FIELD_PHONE,
$conf->global->LDAP_FIELD_FAX,
$conf->global->LDAP_FIELD_MOBILE,
// $conf->global->LDAP_FIELD_ADDRESS,
// $conf->global->LDAP_FIELD_ZIP,
// $conf->global->LDAP_FIELD_TOWN,
// $conf->global->LDAP_FIELD_COUNTRY,
$conf->global->LDAP_FIELD_MAIL,
$conf->global->LDAP_FIELD_TITLE,
$conf->global->LDAP_FIELD_DESCRIPTION,
$conf->global->LDAP_FIELD_SID
getDolGlobalString('LDAP_KEY_USERS'),
getDolGlobalString('LDAP_FIELD_FULLNAME'),
getDolGlobalString('LDAP_FIELD_NAME'),
getDolGlobalString('LDAP_FIELD_FIRSTNAME'),
getDolGlobalString('LDAP_FIELD_LOGIN'),
getDolGlobalString('LDAP_FIELD_LOGIN_SAMBA'),
getDolGlobalString('LDAP_FIELD_PASSWORD'),
getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED'),
getDolGlobalString('LDAP_FIELD_PHONE'),
getDolGlobalString('LDAP_FIELD_FAX'),
getDolGlobalString('LDAP_FIELD_MOBILE'),
// getDolGlobalString('LDAP_FIELD_ADDRESS'),
// getDolGlobalString('LDAP_FIELD_ZIP'),
// getDolGlobalString('LDAP_FIELD_TOWN'),
// getDolGlobalString('LDAP_FIELD_COUNTRY'),
getDolGlobalString('LDAP_FIELD_MAIL'),
getDolGlobalString('LDAP_FIELD_TITLE'),
getDolGlobalString('LDAP_FIELD_DESCRIPTION'),
getDolGlobalString('LDAP_FIELD_SID')
);
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
@@ -186,8 +186,6 @@ if ($resql) {
$ldap = new Ldap();
$result = $ldap->connectBind();
if ($result >= 0) {
$justthese = array();
// We disable synchro Dolibarr-LDAP
$conf->global->LDAP_SYNCHRO_ACTIVE = 0;
@@ -245,8 +243,8 @@ if ($result >= 0) {
// TODO : revoir la gestion du status
/*
* if (isset($ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_STATUS')])) {
* $fuser->datec=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
* $fuser->datevalid=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
* $fuser->datec=dol_stringtotime($ldapuser[getdolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')]);
* $fuser->datevalid=dol_stringtotime($ldapuser[getdolGlobalString('LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')]);
* $fuser->statut=$ldapuser[getDolGlobalString('LDAP_FIELD_MEMBER_STATUS')] ?? null;
* }
*/