@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $sapi_type = php_sapi_name(); |
| 36 | 36 | $script_file = basename(__FILE__); |
| 37 | -$path = __DIR__ . '/'; |
|
| 37 | +$path = __DIR__.'/'; |
|
| 38 | 38 | |
| 39 | 39 | // Test if batch mode |
| 40 | 40 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 41 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 41 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 42 | 42 | exit(-1); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". |
| 47 | 47 | |
| 48 | 48 | // Include and load Dolibarr environment variables |
| 49 | -require_once $path . "../../htdocs/master.inc.php"; |
|
| 50 | -require_once DOL_DOCUMENT_ROOT . "/user/class/user.class.php"; |
|
| 51 | -require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; |
|
| 49 | +require_once $path."../../htdocs/master.inc.php"; |
|
| 50 | +require_once DOL_DOCUMENT_ROOT."/user/class/user.class.php"; |
|
| 51 | +require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; |
|
| 52 | 52 | // After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). |
| 53 | 53 | // $user is created but empty. |
| 54 | 54 | |
@@ -67,30 +67,30 @@ discard block |
||
| 67 | 67 | * Main |
| 68 | 68 | */ |
| 69 | 69 | |
| 70 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 71 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 70 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 71 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 72 | 72 | |
| 73 | 73 | if (!isset($argv[1]) || $argv[1] != 'user') { |
| 74 | 74 | print "Usage: $script_file user\n"; |
| 75 | 75 | exit(-1); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | -print '--- start' . "\n"; |
|
| 78 | +print '--- start'."\n"; |
|
| 79 | 79 | |
| 80 | 80 | // Case to migrate products path |
| 81 | 81 | if ($argv[1] == 'user') { |
| 82 | 82 | $u = new User($db); |
| 83 | 83 | |
| 84 | - $sql = "SELECT rowid as uid from " . MAIN_DB_PREFIX . "user"; // Get list of all products |
|
| 84 | + $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all products |
|
| 85 | 85 | $resql = $db->query($sql); |
| 86 | 86 | if ($resql) { |
| 87 | 87 | while ($obj = $db->fetch_object($resql)) { |
| 88 | 88 | $u->fetch($obj->uid); |
| 89 | - print " migrating user id=" . $u->id . " ref=" . $u->ref . "\n"; |
|
| 89 | + print " migrating user id=".$u->id." ref=".$u->ref."\n"; |
|
| 90 | 90 | migrate_user_filespath($u); |
| 91 | 91 | } |
| 92 | 92 | } else { |
| 93 | - print "\n sql error " . $sql; |
|
| 93 | + print "\n sql error ".$sql; |
|
| 94 | 94 | exit(); |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | // Les fichiers joints des users sont toujours sur l'entité 1 |
| 114 | 114 | $dir = $conf->user->dir_output; |
| 115 | - $origin = $dir . '/' . get_exdir($u->id, 2, 0, 0, $u, 'user'); |
|
| 116 | - $destin = $dir . '/' . $u->id; |
|
| 115 | + $origin = $dir.'/'.get_exdir($u->id, 2, 0, 0, $u, 'user'); |
|
| 116 | + $destin = $dir.'/'.$u->id; |
|
| 117 | 117 | |
| 118 | 118 | $error = 0; |
| 119 | 119 | |
@@ -125,18 +125,18 @@ discard block |
||
| 125 | 125 | $handle = opendir($origin_osencoded); |
| 126 | 126 | if (is_resource($handle)) { |
| 127 | 127 | while (($file = readdir($handle)) !== false) { |
| 128 | - if ($file != '.' && $file != '..' && is_dir($origin_osencoded . '/' . $file)) { |
|
| 129 | - $thumbs = opendir($origin_osencoded . '/' . $file); |
|
| 128 | + if ($file != '.' && $file != '..' && is_dir($origin_osencoded.'/'.$file)) { |
|
| 129 | + $thumbs = opendir($origin_osencoded.'/'.$file); |
|
| 130 | 130 | if (is_resource($thumbs)) { |
| 131 | - dol_mkdir($destin . '/' . $file); |
|
| 131 | + dol_mkdir($destin.'/'.$file); |
|
| 132 | 132 | while (($thumb = readdir($thumbs)) !== false) { |
| 133 | - dol_move($origin . '/' . $file . '/' . $thumb, $destin . '/' . $file . '/' . $thumb); |
|
| 133 | + dol_move($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb); |
|
| 134 | 134 | } |
| 135 | 135 | // dol_delete_dir($origin.'/'.$file); |
| 136 | 136 | } |
| 137 | 137 | } else { |
| 138 | - if (dol_is_file($origin . '/' . $file)) { |
|
| 139 | - dol_move($origin . '/' . $file, $destin . '/' . $file); |
|
| 138 | + if (dol_is_file($origin.'/'.$file)) { |
|
| 139 | + dol_move($origin.'/'.$file, $destin.'/'.$file); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $sapi_type = php_sapi_name(); |
| 37 | 37 | $script_file = basename(__FILE__); |
| 38 | -$path = __DIR__ . '/'; |
|
| 38 | +$path = __DIR__.'/'; |
|
| 39 | 39 | |
| 40 | 40 | // Test si mode batch |
| 41 | 41 | $sapi_type = php_sapi_name(); |
| 42 | 42 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 43 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 43 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 44 | 44 | exit(-1); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | $mode = $argv[1]; |
| 57 | 57 | $targettype = $argv[2]; |
| 58 | 58 | |
| 59 | -require $path . "../../htdocs/master.inc.php"; |
|
| 60 | -require_once DOL_DOCUMENT_ROOT . "/core/class/CMailFile.class.php"; |
|
| 59 | +require $path."../../htdocs/master.inc.php"; |
|
| 60 | +require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; |
|
| 61 | 61 | |
| 62 | 62 | $langs->load('main'); |
| 63 | 63 | |
@@ -73,15 +73,15 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | |
| 75 | 75 | @set_time_limit(0); |
| 76 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 77 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 76 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 77 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 78 | 78 | |
| 79 | 79 | $now = dol_now('tzserver'); |
| 80 | 80 | $duration_value = isset($argv[3]) ? $argv[3] : 'none'; |
| 81 | 81 | $duration_value2 = isset($argv[4]) ? $argv[4] : 'none'; |
| 82 | 82 | |
| 83 | 83 | $error = 0; |
| 84 | -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"; |
|
| 84 | +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"; |
|
| 85 | 85 | |
| 86 | 86 | if ($mode != 'confirm') { |
| 87 | 87 | $conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
@@ -97,17 +97,17 @@ discard block |
||
| 97 | 97 | if ($targettype == 'contacts') { |
| 98 | 98 | $sql .= ", sp.rowid as cid, sp.firstname as cfirstname, sp.lastname as clastname, sp.email as cemail"; |
| 99 | 99 | } |
| 100 | -$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f, " . MAIN_DB_PREFIX . "societe as s"; |
|
| 100 | +$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; |
|
| 101 | 101 | if ($targettype == 'contacts') { |
| 102 | - $sql .= ", " . MAIN_DB_PREFIX . "socpeople as sp"; |
|
| 102 | + $sql .= ", ".MAIN_DB_PREFIX."socpeople as sp"; |
|
| 103 | 103 | } |
| 104 | 104 | $sql .= " WHERE f.fk_statut = 1 AND f.paye = 0"; |
| 105 | 105 | $sql .= " AND f.fk_soc = s.rowid"; |
| 106 | 106 | if (is_numeric($duration_value2)) { |
| 107 | - $sql .= " AND f.date_lim_reglement >= '" . $db->idate(dol_time_plus_duree($now, $duration_value2, "d")) . "'"; |
|
| 107 | + $sql .= " AND f.date_lim_reglement >= '".$db->idate(dol_time_plus_duree($now, $duration_value2, "d"))."'"; |
|
| 108 | 108 | } |
| 109 | 109 | if (is_numeric($duration_value)) { |
| 110 | - $sql .= " AND f.date_lim_reglement < '" . $db->idate(dol_time_plus_duree($now, $duration_value, "d")) . "'"; |
|
| 110 | + $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'"; |
|
| 111 | 111 | } |
| 112 | 112 | if ($targettype == 'contacts') { |
| 113 | 113 | $sql .= " AND s.rowid = sp.fk_soc"; |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | $foundtoprocess = 0; |
| 132 | 132 | $trackthirdpartiessent = array(); |
| 133 | 133 | |
| 134 | - print "We found " . $num . " couples (unpayed validated invoices-" . $targettype . ") qualified\n"; |
|
| 135 | - dol_syslog("We found " . $num . " couples (unpayed validated invoices-" . $targettype . ") qualified"); |
|
| 134 | + print "We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified\n"; |
|
| 135 | + dol_syslog("We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified"); |
|
| 136 | 136 | $message = ''; |
| 137 | 137 | $oldtarget = ''; |
| 138 | 138 | |
@@ -158,15 +158,15 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | if ($startbreak) { |
| 160 | 160 | // Break onto sales representative (new email or cid) |
| 161 | - if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid . '|' . $oldemail])) { |
|
| 161 | + if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { |
|
| 162 | 162 | envoi_mail($mode, $oldemail, $message, $total, $oldlang, $oldtarget); |
| 163 | - $trackthirdpartiessent[$oldsid . '|' . $oldemail] = 'contact id ' . $oldcid; |
|
| 163 | + $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid; |
|
| 164 | 164 | } else { |
| 165 | 165 | if ($oldemail != 'none') { |
| 166 | - if (empty($trackthirdpartiessent[$oldsid . '|' . $oldemail])) { |
|
| 167 | - print "- No email sent for '" . $oldtarget . "', total: " . $total . "\n"; |
|
| 166 | + if (empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { |
|
| 167 | + print "- No email sent for '".$oldtarget."', total: ".$total."\n"; |
|
| 168 | 168 | } else { |
| 169 | - print "- No email sent for '" . $oldtarget . "', total: " . $total . " (already sent to " . $trackthirdpartiessent[$oldsid . '|' . $oldemail] . ")\n"; |
|
| 169 | + print "- No email sent for '".$oldtarget."', total: ".$total." (already sent to ".$trackthirdpartiessent[$oldsid.'|'.$oldemail].")\n"; |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $oldcid = $obj->cid; |
| 177 | 177 | } |
| 178 | 178 | $oldlang = $obj->default_lang; |
| 179 | - $oldtarget = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname . " " . $obj->cfirstname); |
|
| 179 | + $oldtarget = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname); |
|
| 180 | 180 | $message = ''; |
| 181 | 181 | $total = 0; |
| 182 | 182 | $foundtoprocess = 0; |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | $outputlangs->loadLangs(array("main", "bills")); |
| 192 | 192 | |
| 193 | 193 | if (dol_strlen($newemail)) { |
| 194 | - $message .= $outputlangs->trans("Invoice") . " " . $obj->ref . " : " . price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) . "\n"; |
|
| 195 | - dol_syslog("email_unpaid_invoices_to_customers.php: " . $newemail . " " . $message); |
|
| 194 | + $message .= $outputlangs->trans("Invoice")." ".$obj->ref." : ".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency)."\n"; |
|
| 195 | + dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message); |
|
| 196 | 196 | $foundtoprocess++; |
| 197 | 197 | } |
| 198 | - 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 . ": "; |
|
| 198 | + 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.": "; |
|
| 199 | 199 | if (dol_strlen($newemail)) { |
| 200 | 200 | print "qualified."; |
| 201 | 201 | } else { |
@@ -212,15 +212,15 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | // Si il reste des envois en buffer |
| 214 | 214 | if ($foundtoprocess) { |
| 215 | - if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid . '|' . $oldemail])) { // Break onto email (new email) |
|
| 215 | + if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { // Break onto email (new email) |
|
| 216 | 216 | envoi_mail($mode, $oldemail, $message, $total, $oldlang, $oldtarget); |
| 217 | - $trackthirdpartiessent[$oldsid . '|' . $oldemail] = 'contact id ' . $oldcid; |
|
| 217 | + $trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid; |
|
| 218 | 218 | } else { |
| 219 | 219 | if ($oldemail != 'none') { |
| 220 | - if (empty($trackthirdpartiessent[$oldsid . '|' . $oldemail])) { |
|
| 221 | - print "- No email sent for '" . $oldtarget . "', total: " . $total . "\n"; |
|
| 220 | + if (empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { |
|
| 221 | + print "- No email sent for '".$oldtarget."', total: ".$total."\n"; |
|
| 222 | 222 | } else { |
| 223 | - print "- No email sent for '" . $oldtarget . "', total: " . $total . " (already sent to " . $trackthirdpartiessent[$oldsid . '|' . $oldemail] . ")\n"; |
|
| 223 | + print "- No email sent for '".$oldtarget."', total: ".$total." (already sent to ".$trackthirdpartiessent[$oldsid.'|'.$oldemail].")\n"; |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | $errorsto = Functions::getDolGlobalString('MAIN_MAIL_ERRORS_TO'); |
| 268 | 268 | $msgishtml = -1; |
| 269 | 269 | |
| 270 | - print "- Send email to '" . $oldtarget . "' (" . $oldemail . "), total: " . $total . "\n"; |
|
| 271 | - dol_syslog("email_unpaid_invoices_to_customers.php: send mail to " . $oldemail); |
|
| 270 | + print "- Send email to '".$oldtarget."' (".$oldemail."), total: ".$total."\n"; |
|
| 271 | + dol_syslog("email_unpaid_invoices_to_customers.php: send mail to ".$oldemail); |
|
| 272 | 272 | |
| 273 | 273 | $usehtml = 0; |
| 274 | 274 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER') && dol_textishtml(Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER'))) { |
@@ -282,12 +282,12 @@ discard block |
||
| 282 | 282 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER')) { |
| 283 | 283 | $allmessage .= $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER; |
| 284 | 284 | } else { |
| 285 | - $allmessage .= "Dear customer" . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n"); |
|
| 286 | - $allmessage .= "Please, find a summary of the bills with pending payments from you." . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n"); |
|
| 287 | - $allmessage .= "Note: This list contains only unpaid invoices." . ($usehtml ? "<br>\n" : "\n"); |
|
| 285 | + $allmessage .= "Dear customer".($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n"); |
|
| 286 | + $allmessage .= "Please, find a summary of the bills with pending payments from you.".($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n"); |
|
| 287 | + $allmessage .= "Note: This list contains only unpaid invoices.".($usehtml ? "<br>\n" : "\n"); |
|
| 288 | 288 | } |
| 289 | - $allmessage .= $message . ($usehtml ? "<br>\n" : "\n"); |
|
| 290 | - $allmessage .= $langs->trans("Total") . " = " . price($total, 0, $userlang, 0, 0, -1, $conf->currency) . ($usehtml ? "<br>\n" : "\n"); |
|
| 289 | + $allmessage .= $message.($usehtml ? "<br>\n" : "\n"); |
|
| 290 | + $allmessage .= $langs->trans("Total")." = ".price($total, 0, $userlang, 0, 0, -1, $conf->currency).($usehtml ? "<br>\n" : "\n"); |
|
| 291 | 291 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER')) { |
| 292 | 292 | $allmessage .= Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER'); |
| 293 | 293 | if (dol_textishtml(Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER'))) { |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | if ($mode == 'confirm') { |
| 304 | 304 | $result = $mail->sendfile(); |
| 305 | 305 | if (!$result) { |
| 306 | - print "Error sending email " . $mail->error . "\n"; |
|
| 307 | - dol_syslog("Error sending email " . $mail->error . "\n"); |
|
| 306 | + print "Error sending email ".$mail->error."\n"; |
|
| 307 | + dol_syslog("Error sending email ".$mail->error."\n"); |
|
| 308 | 308 | } |
| 309 | 309 | } else { |
| 310 | 310 | print "No email sent (test mode)\n"; |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $sapi_type = php_sapi_name(); |
| 37 | 37 | $script_file = basename(__FILE__); |
| 38 | -$path = __DIR__ . '/'; |
|
| 38 | +$path = __DIR__.'/'; |
|
| 39 | 39 | |
| 40 | 40 | // Test si mode batch |
| 41 | 41 | $sapi_type = php_sapi_name(); |
| 42 | 42 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 43 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 43 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 44 | 44 | exit(-1); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | $mode = $argv[1]; |
| 56 | 56 | |
| 57 | -require $path . "../../htdocs/master.inc.php"; |
|
| 58 | -require_once DOL_DOCUMENT_ROOT . "/core/class/CMailFile.class.php"; |
|
| 57 | +require $path."../../htdocs/master.inc.php"; |
|
| 58 | +require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; |
|
| 59 | 59 | |
| 60 | 60 | $langs->load('main'); |
| 61 | 61 | |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | |
| 73 | 73 | @set_time_limit(0); |
| 74 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 75 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 74 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 75 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 76 | 76 | |
| 77 | 77 | $now = dol_now('tzserver'); |
| 78 | 78 | $duration_value = isset($argv[2]) ? $argv[2] : 'none'; |
| 79 | 79 | |
| 80 | -print $script_file . " launched with mode " . $mode . " default lang=" . $langs->defaultlang . (is_numeric($duration_value) ? " delay=" . $duration_value : "") . "\n"; |
|
| 80 | +print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "")."\n"; |
|
| 81 | 81 | |
| 82 | 82 | if ($mode != 'confirm') { |
| 83 | 83 | $conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, s.email, s.default_lang,"; |
| 92 | 92 | $sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang"; |
| 93 | -$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; |
|
| 94 | -$sql .= " , " . MAIN_DB_PREFIX . "societe as s"; |
|
| 95 | -$sql .= " , " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; |
|
| 96 | -$sql .= " , " . MAIN_DB_PREFIX . "user as u"; |
|
| 93 | +$sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; |
|
| 94 | +$sql .= " , ".MAIN_DB_PREFIX."societe as s"; |
|
| 95 | +$sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
| 96 | +$sql .= " , ".MAIN_DB_PREFIX."user as u"; |
|
| 97 | 97 | $sql .= " WHERE f.fk_statut = 1 AND f.paye = 0"; |
| 98 | 98 | $sql .= " AND f.fk_soc = s.rowid"; |
| 99 | 99 | if (is_numeric($duration_value)) { |
| 100 | - $sql .= " AND f.date_lim_reglement < '" . $db->idate(dol_time_plus_duree($now, $duration_value, "d")) . "'"; |
|
| 100 | + $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'"; |
|
| 101 | 101 | } |
| 102 | 102 | $sql .= " AND sc.fk_soc = s.rowid"; |
| 103 | 103 | $sql .= " AND sc.fk_user = u.rowid"; |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | $total = 0; |
| 115 | 115 | $foundtoprocess = 0; |
| 116 | 116 | |
| 117 | - print "We found " . $num . " couples (unpayed validated invoice - sale representative) qualified\n"; |
|
| 118 | - dol_syslog("We found " . $num . " couples (unpayed validated invoice - sale representative) qualified"); |
|
| 117 | + print "We found ".$num." couples (unpayed validated invoice - sale representative) qualified\n"; |
|
| 118 | + dol_syslog("We found ".$num." couples (unpayed validated invoice - sale representative) qualified"); |
|
| 119 | 119 | $message = ''; |
| 120 | 120 | $oldsalerepresentative = 0; |
| 121 | 121 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | envoi_mail($mode, $oldemail, $message, $total, $oldlang, $oldsalerepresentative); |
| 130 | 130 | } else { |
| 131 | 131 | if ($oldemail != 'none') { |
| 132 | - print "- No email sent for " . $oldsalerepresentative . ", total: " . $total . "\n"; |
|
| 132 | + print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | $oldemail = $obj->email; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $foundtoprocess = 0; |
| 142 | 142 | $salerepresentative = dolGetFirstLastname($obj->firstname, $obj->lastname); |
| 143 | 143 | if (empty($obj->email)) { |
| 144 | - print "Warning: Sale representative " . $salerepresentative . " has no email. Notice disabled.\n"; |
|
| 144 | + print "Warning: Sale representative ".$salerepresentative." has no email. Notice disabled.\n"; |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | $outputlangs->loadLangs(array("main", "bills")); |
| 154 | 154 | |
| 155 | 155 | if (dol_strlen($obj->email)) { |
| 156 | - $message .= $outputlangs->trans("Invoice") . " " . $obj->ref . " : " . price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) . " : " . $obj->name . "\n"; |
|
| 157 | - dol_syslog("email_unpaid_invoices_to_representatives.php: " . $obj->email); |
|
| 156 | + $message .= $outputlangs->trans("Invoice")." ".$obj->ref." : ".price($obj->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency)." : ".$obj->name."\n"; |
|
| 157 | + dol_syslog("email_unpaid_invoices_to_representatives.php: ".$obj->email); |
|
| 158 | 158 | $foundtoprocess++; |
| 159 | 159 | } |
| 160 | - print "Unpaid invoice " . $obj->ref . ", price " . price2num($obj->total_ttc) . ", due date " . dol_print_date($db->jdate($obj->due_date), 'day') . " (linked to company " . $obj->name . ", sale representative " . dolGetFirstLastname($obj->firstname, $obj->lastname) . ", email " . $obj->email . ", lang " . $outputlangs->defaultlang . "): "; |
|
| 160 | + print "Unpaid invoice ".$obj->ref.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date), 'day')." (linked to company ".$obj->name.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email.", lang ".$outputlangs->defaultlang."): "; |
|
| 161 | 161 | if (dol_strlen($obj->email)) { |
| 162 | 162 | print "qualified."; |
| 163 | 163 | } else { |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | envoi_mail($mode, $oldemail, $message, $total, $oldlang, $oldsalerepresentative); |
| 178 | 178 | } else { |
| 179 | 179 | if ($oldemail != 'none') { |
| 180 | - print "- No email sent for " . $oldsalerepresentative . ", total: " . $total . "\n"; |
|
| 180 | + print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | $errorsto = Functions::getDolGlobalString('MAIN_MAIL_ERRORS_TO'); |
| 224 | 224 | $msgishtml = -1; |
| 225 | 225 | |
| 226 | - print "- Send email for " . $oldtarget . " (" . $oldemail . "), total: " . $total . "\n"; |
|
| 227 | - dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to " . $oldemail); |
|
| 226 | + print "- Send email for ".$oldtarget." (".$oldemail."), total: ".$total."\n"; |
|
| 227 | + dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to ".$oldemail); |
|
| 228 | 228 | |
| 229 | 229 | $usehtml = 0; |
| 230 | 230 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER') && dol_textishtml(Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER'))) { |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER')) { |
| 239 | 239 | $allmessage .= Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER'); |
| 240 | 240 | } else { |
| 241 | - $allmessage .= $newlangs->transnoentities("ListOfYourUnpaidInvoices") . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n"); |
|
| 242 | - $allmessage .= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices") . ($usehtml ? "<br>\n" : "\n"); |
|
| 241 | + $allmessage .= $newlangs->transnoentities("ListOfYourUnpaidInvoices").($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n"); |
|
| 242 | + $allmessage .= $newlangs->transnoentities("NoteListOfYourUnpaidInvoices").($usehtml ? "<br>\n" : "\n"); |
|
| 243 | 243 | } |
| 244 | - $allmessage .= $message . ($usehtml ? "<br>\n" : "\n"); |
|
| 245 | - $allmessage .= $langs->trans("Total") . " = " . price($total, 0, $newlangs, 0, 0, -1, $conf->currency) . ($usehtml ? "<br>\n" : "\n"); |
|
| 244 | + $allmessage .= $message.($usehtml ? "<br>\n" : "\n"); |
|
| 245 | + $allmessage .= $langs->trans("Total")." = ".price($total, 0, $newlangs, 0, 0, -1, $conf->currency).($usehtml ? "<br>\n" : "\n"); |
|
| 246 | 246 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER')) { |
| 247 | 247 | $allmessage .= Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER'); |
| 248 | 248 | if (dol_textishtml(Functions::getDolGlobalString('SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER'))) { |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | if ($mode == 'confirm') { |
| 259 | 259 | $result = $mail->sendfile(); |
| 260 | 260 | if (!$result) { |
| 261 | - print "Error sending email " . $mail->error . "\n"; |
|
| 262 | - dol_syslog("Error sending email " . $mail->error . "\n"); |
|
| 261 | + print "Error sending email ".$mail->error."\n"; |
|
| 262 | + dol_syslog("Error sending email ".$mail->error."\n"); |
|
| 263 | 263 | } |
| 264 | 264 | } else { |
| 265 | 265 | print "No email sent (test mode)\n"; |
@@ -34,18 +34,18 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $sapi_type = php_sapi_name(); |
| 36 | 36 | $script_file = basename(__FILE__); |
| 37 | -$path = __DIR__ . '/'; |
|
| 37 | +$path = __DIR__.'/'; |
|
| 38 | 38 | |
| 39 | 39 | // Test if batch mode |
| 40 | 40 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 41 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 41 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 42 | 42 | exit(-1); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -require_once $path . "../../htdocs/master.inc.php"; |
|
| 46 | -require_once DOL_DOCUMENT_ROOT . "/contact/class/contact.class.php"; |
|
| 47 | -require_once DOL_DOCUMENT_ROOT . "/user/class/user.class.php"; |
|
| 48 | -require_once DOL_DOCUMENT_ROOT . "/core/class/ldap.class.php"; |
|
| 45 | +require_once $path."../../htdocs/master.inc.php"; |
|
| 46 | +require_once DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"; |
|
| 47 | +require_once DOL_DOCUMENT_ROOT."/user/class/user.class.php"; |
|
| 48 | +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; |
|
| 49 | 49 | |
| 50 | 50 | // Global variables |
| 51 | 51 | $version = DOL_VERSION; |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | 62 | @set_time_limit(0); |
| 63 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 64 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 63 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 64 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 65 | 65 | |
| 66 | 66 | if (!isset($argv[1]) || !$argv[1]) { |
| 67 | 67 | print "Usage: $script_file now [-y]\n"; |
@@ -85,19 +85,19 @@ discard block |
||
| 85 | 85 | $conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails |
| 86 | 86 | print "\n"; |
| 87 | 87 | print "----- Synchronize all records from Dolibarr database:\n"; |
| 88 | -print "type=" . $conf->db->type . "\n"; |
|
| 89 | -print "host=" . $conf->db->host . "\n"; |
|
| 90 | -print "port=" . $conf->db->port . "\n"; |
|
| 91 | -print "login=" . $conf->db->user . "\n"; |
|
| 88 | +print "type=".$conf->db->type."\n"; |
|
| 89 | +print "host=".$conf->db->host."\n"; |
|
| 90 | +print "port=".$conf->db->port."\n"; |
|
| 91 | +print "login=".$conf->db->user."\n"; |
|
| 92 | 92 | // print "pass=".preg_replace('/./i','*',$conf->db->password)."\n"; // Not defined for security reasons |
| 93 | -print "database=" . $conf->db->name . "\n"; |
|
| 93 | +print "database=".$conf->db->name."\n"; |
|
| 94 | 94 | print "\n"; |
| 95 | 95 | print "----- To LDAP database:\n"; |
| 96 | -print "host=" . Functions::getDolGlobalString('LDAP_SERVER_HOST') . "\n"; |
|
| 97 | -print "port=" . Functions::getDolGlobalString('LDAP_SERVER_PORT') . "\n"; |
|
| 98 | -print "login=" . Functions::getDolGlobalString('LDAP_ADMIN_DN') . "\n"; |
|
| 99 | -print "pass=" . preg_replace('/./i', '*', Functions::getDolGlobalString('LDAP_ADMIN_PASS')) . "\n"; |
|
| 100 | -print "DN target=" . Functions::getDolGlobalString('LDAP_CONTACT_DN') . "\n"; |
|
| 96 | +print "host=".Functions::getDolGlobalString('LDAP_SERVER_HOST')."\n"; |
|
| 97 | +print "port=".Functions::getDolGlobalString('LDAP_SERVER_PORT')."\n"; |
|
| 98 | +print "login=".Functions::getDolGlobalString('LDAP_ADMIN_DN')."\n"; |
|
| 99 | +print "pass=".preg_replace('/./i', '*', Functions::getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; |
|
| 100 | +print "DN target=".Functions::getDolGlobalString('LDAP_CONTACT_DN')."\n"; |
|
| 101 | 101 | print "\n"; |
| 102 | 102 | |
| 103 | 103 | if (!$confirmed) { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | |
| 119 | 119 | $sql = "SELECT rowid"; |
| 120 | -$sql .= " FROM " . MAIN_DB_PREFIX . "socpeople"; |
|
| 120 | +$sql .= " FROM ".MAIN_DB_PREFIX."socpeople"; |
|
| 121 | 121 | |
| 122 | 122 | $resql = $db->query($sql); |
| 123 | 123 | if ($resql) { |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $contact->id = $obj->rowid; |
| 137 | 137 | $contact->fetch($contact->id); |
| 138 | 138 | |
| 139 | - print $langs->trans("UpdateContact") . " rowid=" . $contact->id . " " . $contact->getFullName($langs); |
|
| 139 | + print $langs->trans("UpdateContact")." rowid=".$contact->id." ".$contact->getFullName($langs); |
|
| 140 | 140 | |
| 141 | 141 | $oldobject = $contact; |
| 142 | 142 | |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | $result = $ldap->add($dn, $info, $user); // Will fail if already exists |
| 150 | 150 | $result = $ldap->update($dn, $info, $user, $olddn); |
| 151 | 151 | if ($result > 0) { |
| 152 | - print " - " . $langs->trans("OK"); |
|
| 152 | + print " - ".$langs->trans("OK"); |
|
| 153 | 153 | } else { |
| 154 | 154 | $error++; |
| 155 | - print " - " . $langs->trans("KO") . ' - ' . $ldap->error; |
|
| 155 | + print " - ".$langs->trans("KO").' - '.$ldap->error; |
|
| 156 | 156 | } |
| 157 | 157 | print "\n"; |
| 158 | 158 | |
@@ -35,24 +35,24 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $sapi_type = php_sapi_name(); |
| 37 | 37 | $script_file = basename(__FILE__); |
| 38 | -$path = __DIR__ . '/'; |
|
| 38 | +$path = __DIR__.'/'; |
|
| 39 | 39 | |
| 40 | 40 | // Test if batch mode |
| 41 | 41 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 42 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 42 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 43 | 43 | exit(-1); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | if (!isset($argv[1]) || !$argv[1]) { |
| 47 | - print "Usage: " . $script_file . " now\n"; |
|
| 47 | + print "Usage: ".$script_file." now\n"; |
|
| 48 | 48 | exit(-1); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $now = $argv[1]; |
| 52 | 52 | |
| 53 | -require_once $path . "../../htdocs/master.inc.php"; |
|
| 54 | -require_once DOL_DOCUMENT_ROOT . "/core/class/ldap.class.php"; |
|
| 55 | -require_once DOL_DOCUMENT_ROOT . "/adherents/class/adherent_type.class.php"; |
|
| 53 | +require_once $path."../../htdocs/master.inc.php"; |
|
| 54 | +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; |
|
| 55 | +require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; |
|
| 56 | 56 | |
| 57 | 57 | // Global variables |
| 58 | 58 | $version = constant('DOL_VERSION'); |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | |
| 68 | 68 | @set_time_limit(0); |
| 69 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 70 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 69 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 70 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 71 | 71 | |
| 72 | 72 | /* |
| 73 | 73 | * if (Functions::getDolGlobalString('LDAP_SYNCHRO_ACTIVE')) { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | $sql = "SELECT rowid"; |
| 86 | -$sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type"; |
|
| 86 | +$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type"; |
|
| 87 | 87 | |
| 88 | 88 | $resql = $db->query($sql); |
| 89 | 89 | if ($resql) { |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $membertype->id = $obj->rowid; |
| 104 | 104 | $membertype->fetch($membertype->id); |
| 105 | 105 | |
| 106 | - print $langs->trans("UpdateMemberType") . " rowid=" . $membertype->id . " " . $membertype->label; |
|
| 106 | + print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype->label; |
|
| 107 | 107 | |
| 108 | 108 | $oldobject = $membertype; |
| 109 | 109 | |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | $result = $ldap->add($dn, $info, $user); // Will fail if already exists |
| 117 | 117 | $result = $ldap->update($dn, $info, $user, $olddn); |
| 118 | 118 | if ($result > 0) { |
| 119 | - print " - " . $langs->trans("OK"); |
|
| 119 | + print " - ".$langs->trans("OK"); |
|
| 120 | 120 | } else { |
| 121 | 121 | $error++; |
| 122 | - print " - " . $langs->trans("KO") . ' - ' . $ldap->error; |
|
| 122 | + print " - ".$langs->trans("KO").' - '.$ldap->error; |
|
| 123 | 123 | } |
| 124 | 124 | print "\n"; |
| 125 | 125 | |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $sapi_type = php_sapi_name(); |
| 36 | 36 | $script_file = basename(__FILE__); |
| 37 | -$path = __DIR__ . '/'; |
|
| 37 | +$path = __DIR__.'/'; |
|
| 38 | 38 | |
| 39 | 39 | // Test if batch mode |
| 40 | 40 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 41 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 41 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 42 | 42 | exit(-1); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -require_once $path . "../../htdocs/master.inc.php"; |
|
| 46 | -require_once DOL_DOCUMENT_ROOT . "/core/lib/date.lib.php"; |
|
| 47 | -require_once DOL_DOCUMENT_ROOT . "/core/class/ldap.class.php"; |
|
| 48 | -require_once DOL_DOCUMENT_ROOT . "/adherents/class/adherent.class.php"; |
|
| 49 | -require_once DOL_DOCUMENT_ROOT . "/adherents/class/subscription.class.php"; |
|
| 45 | +require_once $path."../../htdocs/master.inc.php"; |
|
| 46 | +require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; |
|
| 47 | +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; |
|
| 48 | +require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"; |
|
| 49 | +require_once DOL_DOCUMENT_ROOT."/adherents/class/subscription.class.php"; |
|
| 50 | 50 | |
| 51 | 51 | $langs->loadLangs(array("main", "errors")); |
| 52 | 52 | |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | |
| 66 | 66 | @set_time_limit(0); |
| 67 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 68 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 67 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 68 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 69 | 69 | |
| 70 | 70 | // List of fields to get from LDAP |
| 71 | 71 | $required_fields = array( |
@@ -122,34 +122,34 @@ discard block |
||
| 122 | 122 | $conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails |
| 123 | 123 | print "\n"; |
| 124 | 124 | print "----- Synchronize all records from LDAP database:\n"; |
| 125 | -print "host=" . Functions::getDolGlobalString('LDAP_SERVER_HOST') . "\n"; |
|
| 126 | -print "port=" . Functions::getDolGlobalString('LDAP_SERVER_PORT') . "\n"; |
|
| 127 | -print "login=" . Functions::getDolGlobalString('LDAP_ADMIN_DN') . "\n"; |
|
| 128 | -print "pass=" . preg_replace('/./i', '*', Functions::getDolGlobalString('LDAP_ADMIN_PASS')) . "\n"; |
|
| 129 | -print "DN to extract=" . Functions::getDolGlobalString('LDAP_MEMBER_DN') . "\n"; |
|
| 125 | +print "host=".Functions::getDolGlobalString('LDAP_SERVER_HOST')."\n"; |
|
| 126 | +print "port=".Functions::getDolGlobalString('LDAP_SERVER_PORT')."\n"; |
|
| 127 | +print "login=".Functions::getDolGlobalString('LDAP_ADMIN_DN')."\n"; |
|
| 128 | +print "pass=".preg_replace('/./i', '*', Functions::getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; |
|
| 129 | +print "DN to extract=".Functions::getDolGlobalString('LDAP_MEMBER_DN')."\n"; |
|
| 130 | 130 | if (Functions::getDolGlobalString('LDAP_MEMBER_FILTER')) { |
| 131 | - print 'Filter=(' . Functions::getDolGlobalString('LDAP_MEMBER_FILTER') . ')' . "\n"; // Note: filter is defined into function getRecords |
|
| 131 | + print 'Filter=('.Functions::getDolGlobalString('LDAP_MEMBER_FILTER').')'."\n"; // Note: filter is defined into function getRecords |
|
| 132 | 132 | } else { |
| 133 | - print 'Filter=(' . Functions::getDolGlobalString('LDAP_KEY_MEMBERS') . '=*)' . "\n"; |
|
| 133 | + print 'Filter=('.Functions::getDolGlobalString('LDAP_KEY_MEMBERS').'=*)'."\n"; |
|
| 134 | 134 | } |
| 135 | 135 | print "----- To Dolibarr database:\n"; |
| 136 | -print "type=" . $conf->db->type . "\n"; |
|
| 137 | -print "host=" . $conf->db->host . "\n"; |
|
| 138 | -print "port=" . $conf->db->port . "\n"; |
|
| 139 | -print "login=" . $conf->db->user . "\n"; |
|
| 140 | -print "database=" . $conf->db->name . "\n"; |
|
| 136 | +print "type=".$conf->db->type."\n"; |
|
| 137 | +print "host=".$conf->db->host."\n"; |
|
| 138 | +print "port=".$conf->db->port."\n"; |
|
| 139 | +print "login=".$conf->db->user."\n"; |
|
| 140 | +print "database=".$conf->db->name."\n"; |
|
| 141 | 141 | print "----- Options:\n"; |
| 142 | -print "commitiferror=" . $forcecommit . "\n"; |
|
| 143 | -print "Mapped LDAP fields=" . join(',', $required_fields) . "\n"; |
|
| 142 | +print "commitiferror=".$forcecommit."\n"; |
|
| 143 | +print "Mapped LDAP fields=".join(',', $required_fields)."\n"; |
|
| 144 | 144 | print "\n"; |
| 145 | 145 | |
| 146 | 146 | // Check parameters |
| 147 | 147 | if (!Functions::getDolGlobalString('LDAP_MEMBER_DN')) { |
| 148 | - print $langs->trans("Error") . ': ' . $langs->trans("LDAP setup for members not defined inside Dolibarr") . "\n"; |
|
| 148 | + print $langs->trans("Error").': '.$langs->trans("LDAP setup for members not defined inside Dolibarr")."\n"; |
|
| 149 | 149 | exit(-1); |
| 150 | 150 | } |
| 151 | 151 | if ($typeid <= 0) { |
| 152 | - print $langs->trans("Error") . ': Parameter id_member_type is not a valid ref of an existing member type' . "\n"; |
|
| 152 | + print $langs->trans("Error").': Parameter id_member_type is not a valid ref of an existing member type'."\n"; |
|
| 153 | 153 | exit(-2); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $hashlib2rowid = array(); |
| 168 | 168 | $countries = array(); |
| 169 | 169 | $sql = "SELECT rowid, code, label, active"; |
| 170 | -$sql .= " FROM " . MAIN_DB_PREFIX . "c_country"; |
|
| 170 | +$sql .= " FROM ".MAIN_DB_PREFIX."c_country"; |
|
| 171 | 171 | $sql .= " WHERE active = 1"; |
| 172 | 172 | $sql .= " ORDER BY code ASC"; |
| 173 | 173 | $resql = $db->query($sql); |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | $member->typeid = $typeid; |
| 247 | 247 | |
| 248 | 248 | // Creation membre |
| 249 | - print $langs->transnoentities("MemberCreate") . ' # ' . $key . ': login=' . $member->login . ', fullname=' . $member->getFullName($langs); |
|
| 250 | - print ', datec=' . $member->datec; |
|
| 249 | + print $langs->transnoentities("MemberCreate").' # '.$key.': login='.$member->login.', fullname='.$member->getFullName($langs); |
|
| 250 | + print ', datec='.$member->datec; |
|
| 251 | 251 | $member_id = $member->create($user); |
| 252 | 252 | if ($member_id > 0) { |
| 253 | - print ' --> Created member id=' . $member_id . ' login=' . $member->login; |
|
| 253 | + print ' --> Created member id='.$member_id.' login='.$member->login; |
|
| 254 | 254 | } else { |
| 255 | 255 | $error++; |
| 256 | - print ' --> ' . $member->error; |
|
| 256 | + print ' --> '.$member->error; |
|
| 257 | 257 | } |
| 258 | 258 | print "\n"; |
| 259 | 259 | |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | if (!$error || $forcecommit) { |
| 302 | 302 | if (!$error) { |
| 303 | - print $langs->transnoentities("NoErrorCommitIsDone") . "\n"; |
|
| 303 | + print $langs->transnoentities("NoErrorCommitIsDone")."\n"; |
|
| 304 | 304 | } else { |
| 305 | - print $langs->transnoentities("ErrorButCommitIsDone") . "\n"; |
|
| 305 | + print $langs->transnoentities("ErrorButCommitIsDone")."\n"; |
|
| 306 | 306 | } |
| 307 | 307 | $db->commit(); |
| 308 | 308 | } else { |
| 309 | - print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error) . "\n"; |
|
| 309 | + print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; |
|
| 310 | 310 | $db->rollback(); |
| 311 | 311 | } |
| 312 | 312 | print "\n"; |
@@ -36,18 +36,18 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $sapi_type = php_sapi_name(); |
| 38 | 38 | $script_file = basename(__FILE__); |
| 39 | -$path = __DIR__ . '/'; |
|
| 39 | +$path = __DIR__.'/'; |
|
| 40 | 40 | |
| 41 | 41 | // Test if batch mode |
| 42 | 42 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 43 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 43 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 44 | 44 | exit(-1); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -require_once $path . "../../htdocs/master.inc.php"; |
|
| 48 | -require_once DOL_DOCUMENT_ROOT . "/core/lib/date.lib.php"; |
|
| 49 | -require_once DOL_DOCUMENT_ROOT . "/core/class/ldap.class.php"; |
|
| 50 | -require_once DOL_DOCUMENT_ROOT . "/adherents/class/adherent_type.class.php"; |
|
| 47 | +require_once $path."../../htdocs/master.inc.php"; |
|
| 48 | +require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; |
|
| 49 | +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; |
|
| 50 | +require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; |
|
| 51 | 51 | |
| 52 | 52 | $langs->loadLangs(array("main", "errors")); |
| 53 | 53 | |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | |
| 67 | 67 | @set_time_limit(0); |
| 68 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 69 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 68 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 69 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 70 | 70 | |
| 71 | 71 | // List of fields to get from LDAP |
| 72 | 72 | $required_fields = array(Functions::getDolGlobalString('LDAP_KEY_MEMBERS_TYPES'), Functions::getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_FULLNAME'), Functions::getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION'), Functions::getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS')); |
@@ -104,21 +104,21 @@ discard block |
||
| 104 | 104 | $conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails |
| 105 | 105 | print "\n"; |
| 106 | 106 | print "----- Synchronize all records from LDAP database:\n"; |
| 107 | -print "host=" . Functions::getDolGlobalString('LDAP_SERVER_HOST') . "\n"; |
|
| 108 | -print "port=" . Functions::getDolGlobalString('LDAP_SERVER_PORT') . "\n"; |
|
| 109 | -print "login=" . Functions::getDolGlobalString('LDAP_ADMIN_DN') . "\n"; |
|
| 110 | -print "pass=" . preg_replace('/./i', '*', Functions::getDolGlobalString('LDAP_ADMIN_PASS')) . "\n"; |
|
| 111 | -print "DN to extract=" . Functions::getDolGlobalString('LDAP_MEMBER_TYPE_DN') . "\n"; |
|
| 112 | -print 'Filter=(' . Functions::getDolGlobalString('LDAP_KEY_MEMBERS_TYPES') . '=*)' . "\n"; |
|
| 107 | +print "host=".Functions::getDolGlobalString('LDAP_SERVER_HOST')."\n"; |
|
| 108 | +print "port=".Functions::getDolGlobalString('LDAP_SERVER_PORT')."\n"; |
|
| 109 | +print "login=".Functions::getDolGlobalString('LDAP_ADMIN_DN')."\n"; |
|
| 110 | +print "pass=".preg_replace('/./i', '*', Functions::getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; |
|
| 111 | +print "DN to extract=".Functions::getDolGlobalString('LDAP_MEMBER_TYPE_DN')."\n"; |
|
| 112 | +print 'Filter=('.Functions::getDolGlobalString('LDAP_KEY_MEMBERS_TYPES').'=*)'."\n"; |
|
| 113 | 113 | print "----- To Dolibarr database:\n"; |
| 114 | -print "type=" . $conf->db->type . "\n"; |
|
| 115 | -print "host=" . $conf->db->host . "\n"; |
|
| 116 | -print "port=" . $conf->db->port . "\n"; |
|
| 117 | -print "login=" . $conf->db->user . "\n"; |
|
| 118 | -print "database=" . $conf->db->name . "\n"; |
|
| 114 | +print "type=".$conf->db->type."\n"; |
|
| 115 | +print "host=".$conf->db->host."\n"; |
|
| 116 | +print "port=".$conf->db->port."\n"; |
|
| 117 | +print "login=".$conf->db->user."\n"; |
|
| 118 | +print "database=".$conf->db->name."\n"; |
|
| 119 | 119 | print "----- Options:\n"; |
| 120 | -print "commitiferror=" . $forcecommit . "\n"; |
|
| 121 | -print "Mapped LDAP fields=" . join(',', $required_fields) . "\n"; |
|
| 120 | +print "commitiferror=".$forcecommit."\n"; |
|
| 121 | +print "Mapped LDAP fields=".join(',', $required_fields)."\n"; |
|
| 122 | 122 | print "\n"; |
| 123 | 123 | |
| 124 | 124 | if (!$confirmed) { |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | if (!Functions::getDolGlobalString('LDAP_MEMBER_TYPE_DN')) { |
| 130 | - print $langs->trans("Error") . ': ' . $langs->trans("LDAP setup for members types not defined inside Dolibarr"); |
|
| 130 | + print $langs->trans("Error").': '.$langs->trans("LDAP setup for members types not defined inside Dolibarr"); |
|
| 131 | 131 | exit(-1); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -154,25 +154,25 @@ discard block |
||
| 154 | 154 | // print_r($ldapgroup); |
| 155 | 155 | |
| 156 | 156 | if ($membertype->id > 0) { // Member type update |
| 157 | - print $langs->transnoentities("MemberTypeUpdate") . ' # ' . $key . ': name=' . $membertype->label; |
|
| 157 | + print $langs->transnoentities("MemberTypeUpdate").' # '.$key.': name='.$membertype->label; |
|
| 158 | 158 | $res = $membertype->update($user); |
| 159 | 159 | |
| 160 | 160 | if ($res > 0) { |
| 161 | - print ' --> Updated member type id=' . $membertype->id . ' name=' . $membertype->label; |
|
| 161 | + print ' --> Updated member type id='.$membertype->id.' name='.$membertype->label; |
|
| 162 | 162 | } else { |
| 163 | 163 | $error++; |
| 164 | - print ' --> ' . $res . ' ' . $membertype->error; |
|
| 164 | + print ' --> '.$res.' '.$membertype->error; |
|
| 165 | 165 | } |
| 166 | 166 | print "\n"; |
| 167 | 167 | } else { // Member type creation |
| 168 | - print $langs->transnoentities("MemberTypeCreate") . ' # ' . $key . ': name=' . $membertype->label; |
|
| 168 | + print $langs->transnoentities("MemberTypeCreate").' # '.$key.': name='.$membertype->label; |
|
| 169 | 169 | $res = $membertype->create($user); |
| 170 | 170 | |
| 171 | 171 | if ($res > 0) { |
| 172 | - print ' --> Created member type id=' . $membertype->id . ' name=' . $membertype->label; |
|
| 172 | + print ' --> Created member type id='.$membertype->id.' name='.$membertype->label; |
|
| 173 | 173 | } else { |
| 174 | 174 | $error++; |
| 175 | - print ' --> ' . $res . ' ' . $membertype->error; |
|
| 175 | + print ' --> '.$res.' '.$membertype->error; |
|
| 176 | 176 | } |
| 177 | 177 | print "\n"; |
| 178 | 178 | } |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | if (!$error || $forcecommit) { |
| 184 | 184 | if (!$error) { |
| 185 | - print $langs->transnoentities("NoErrorCommitIsDone") . "\n"; |
|
| 185 | + print $langs->transnoentities("NoErrorCommitIsDone")."\n"; |
|
| 186 | 186 | } else { |
| 187 | - print $langs->transnoentities("ErrorButCommitIsDone") . "\n"; |
|
| 187 | + print $langs->transnoentities("ErrorButCommitIsDone")."\n"; |
|
| 188 | 188 | } |
| 189 | 189 | $db->commit(); |
| 190 | 190 | } else { |
| 191 | - print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error) . "\n"; |
|
| 191 | + print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; |
|
| 192 | 192 | $db->rollback(); |
| 193 | 193 | } |
| 194 | 194 | print "\n"; |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $sapi_type = php_sapi_name(); |
| 36 | 36 | $script_file = basename(__FILE__); |
| 37 | -$path = __DIR__ . '/'; |
|
| 37 | +$path = __DIR__.'/'; |
|
| 38 | 38 | |
| 39 | 39 | // Test if batch mode |
| 40 | 40 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 41 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 41 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 42 | 42 | exit(-1); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -require_once $path . "../../htdocs/master.inc.php"; |
|
| 46 | -require_once DOL_DOCUMENT_ROOT . "/core/class/ldap.class.php"; |
|
| 47 | -require_once DOL_DOCUMENT_ROOT . "/adherents/class/adherent.class.php"; |
|
| 45 | +require_once $path."../../htdocs/master.inc.php"; |
|
| 46 | +require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; |
|
| 47 | +require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"; |
|
| 48 | 48 | |
| 49 | 49 | $langs->load("main"); |
| 50 | 50 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | |
| 63 | 63 | @set_time_limit(0); |
| 64 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 65 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 64 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 65 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 66 | 66 | |
| 67 | 67 | if (!isset($argv[1]) || !$argv[1]) { |
| 68 | 68 | print "Usage: $script_file now [-y]\n"; |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | $conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails |
| 87 | 87 | print "\n"; |
| 88 | 88 | print "----- Synchronize all records from Dolibarr database:\n"; |
| 89 | -print "type=" . $conf->db->type . "\n"; |
|
| 90 | -print "host=" . $conf->db->host . "\n"; |
|
| 91 | -print "port=" . $conf->db->port . "\n"; |
|
| 92 | -print "login=" . $conf->db->user . "\n"; |
|
| 89 | +print "type=".$conf->db->type."\n"; |
|
| 90 | +print "host=".$conf->db->host."\n"; |
|
| 91 | +print "port=".$conf->db->port."\n"; |
|
| 92 | +print "login=".$conf->db->user."\n"; |
|
| 93 | 93 | // print "pass=".preg_replace('/./i','*',$conf->db->password)."\n"; // Not defined for security reasons |
| 94 | -print "database=" . $conf->db->name . "\n"; |
|
| 94 | +print "database=".$conf->db->name."\n"; |
|
| 95 | 95 | print "\n"; |
| 96 | 96 | print "----- To LDAP database:\n"; |
| 97 | -print "host=" . Functions::getDolGlobalString('LDAP_SERVER_HOST') . "\n"; |
|
| 98 | -print "port=" . Functions::getDolGlobalString('LDAP_SERVER_PORT') . "\n"; |
|
| 99 | -print "login=" . Functions::getDolGlobalString('LDAP_ADMIN_DN') . "\n"; |
|
| 100 | -print "pass=" . preg_replace('/./i', '*', Functions::getDolGlobalString('LDAP_ADMIN_PASS')) . "\n"; |
|
| 101 | -print "DN target=" . Functions::getDolGlobalString('LDAP_MEMBER_DN') . "\n"; |
|
| 97 | +print "host=".Functions::getDolGlobalString('LDAP_SERVER_HOST')."\n"; |
|
| 98 | +print "port=".Functions::getDolGlobalString('LDAP_SERVER_PORT')."\n"; |
|
| 99 | +print "login=".Functions::getDolGlobalString('LDAP_ADMIN_DN')."\n"; |
|
| 100 | +print "pass=".preg_replace('/./i', '*', Functions::getDolGlobalString('LDAP_ADMIN_PASS'))."\n"; |
|
| 101 | +print "DN target=".Functions::getDolGlobalString('LDAP_MEMBER_DN')."\n"; |
|
| 102 | 102 | print "\n"; |
| 103 | 103 | |
| 104 | 104 | if (!$confirmed) { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | |
| 120 | 120 | $sql = "SELECT rowid"; |
| 121 | -$sql .= " FROM " . MAIN_DB_PREFIX . "adherent"; |
|
| 121 | +$sql .= " FROM ".MAIN_DB_PREFIX."adherent"; |
|
| 122 | 122 | |
| 123 | 123 | $resql = $db->query($sql); |
| 124 | 124 | if ($resql) { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | exit(-1); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - print $langs->transnoentities("UpdateMember") . " rowid=" . $member->id . " " . $member->getFullName($langs); |
|
| 148 | + print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->getFullName($langs); |
|
| 149 | 149 | |
| 150 | 150 | $oldobject = $member; |
| 151 | 151 | |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | $result = $ldap->add($dn, $info, $user); // Will fail if already exists |
| 159 | 159 | $result = $ldap->update($dn, $info, $user, $olddn); |
| 160 | 160 | if ($result > 0) { |
| 161 | - print " - " . $langs->transnoentities("OK"); |
|
| 161 | + print " - ".$langs->transnoentities("OK"); |
|
| 162 | 162 | } else { |
| 163 | 163 | $error++; |
| 164 | - print " - " . $langs->transnoentities("KO") . ' - ' . $ldap->error; |
|
| 164 | + print " - ".$langs->transnoentities("KO").' - '.$ldap->error; |
|
| 165 | 165 | } |
| 166 | 166 | print "\n"; |
| 167 | 167 | |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $sapi_type = php_sapi_name(); |
| 37 | 37 | $script_file = basename(__FILE__); |
| 38 | -$path = __DIR__ . '/'; |
|
| 38 | +$path = __DIR__.'/'; |
|
| 39 | 39 | |
| 40 | 40 | // Test si mode batch |
| 41 | 41 | $sapi_type = php_sapi_name(); |
| 42 | 42 | if (substr($sapi_type, 0, 3) == 'cgi') { |
| 43 | - echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; |
|
| 43 | + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; |
|
| 44 | 44 | exit(-1); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | $mode = $argv[1]; |
| 56 | 56 | |
| 57 | -require $path . "../../htdocs/master.inc.php"; |
|
| 58 | -require_once DOL_DOCUMENT_ROOT . "/core/class/CMailFile.class.php"; |
|
| 57 | +require $path."../../htdocs/master.inc.php"; |
|
| 58 | +require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; |
|
| 59 | 59 | |
| 60 | 60 | $langs->loadLangs(array('main', 'contracts')); |
| 61 | 61 | |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | |
| 73 | 73 | @set_time_limit(0); |
| 74 | -print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; |
|
| 75 | -dol_syslog($script_file . " launched with arg " . join(',', $argv)); |
|
| 74 | +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; |
|
| 75 | +dol_syslog($script_file." launched with arg ".join(',', $argv)); |
|
| 76 | 76 | |
| 77 | 77 | $now = dol_now('tzserver'); |
| 78 | 78 | $duration_value = isset($argv[2]) ? $argv[2] : 'none'; |
| 79 | 79 | |
| 80 | -print $script_file . " launched with mode " . $mode . " default lang=" . $langs->defaultlang . (is_numeric($duration_value) ? " delay=" . $duration_value : "") . "\n"; |
|
| 80 | +print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "")."\n"; |
|
| 81 | 81 | |
| 82 | 82 | if ($mode != 'confirm') { |
| 83 | 83 | $conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $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,"; |
| 87 | 87 | $sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang"; |
| 88 | -$sql .= " FROM " . MAIN_DB_PREFIX . "societe AS s, " . MAIN_DB_PREFIX . "contrat AS c, " . MAIN_DB_PREFIX . "contratdet AS cd"; |
|
| 89 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product AS p ON p.rowid = cd.fk_product, " . MAIN_DB_PREFIX . "societe_commerciaux AS sc, " . MAIN_DB_PREFIX . "user AS u"; |
|
| 88 | +$sql .= " FROM ".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."contrat AS c, ".MAIN_DB_PREFIX."contratdet AS cd"; |
|
| 89 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product, ".MAIN_DB_PREFIX."societe_commerciaux AS sc, ".MAIN_DB_PREFIX."user AS u"; |
|
| 90 | 90 | $sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5"; |
| 91 | 91 | if (is_numeric($duration_value)) { |
| 92 | - $sql .= " AND cd.date_fin_validite < '" . $db->idate(dol_time_plus_duree($now, $duration_value, "d")) . "'"; |
|
| 92 | + $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'"; |
|
| 93 | 93 | } |
| 94 | 94 | $sql .= " AND sc.fk_soc = s.rowid AND sc.fk_user = u.rowid"; |
| 95 | 95 | $sql .= " ORDER BY u.email ASC, s.rowid ASC, c.ref ASC"; // Order by email to allow one message per email |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | $oldlang = ''; |
| 106 | 106 | $total = 0; |
| 107 | 107 | $foundtoprocess = 0; |
| 108 | - print "We found " . $num . " couples (services to expire - sale representative) qualified\n"; |
|
| 109 | - dol_syslog("We found " . $num . " couples (services to expire - sale representative) qualified"); |
|
| 108 | + print "We found ".$num." couples (services to expire - sale representative) qualified\n"; |
|
| 109 | + dol_syslog("We found ".$num." couples (services to expire - sale representative) qualified"); |
|
| 110 | 110 | $message = ''; |
| 111 | 111 | |
| 112 | 112 | if ($num) { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldsalerepresentative, $duration_value); |
| 120 | 120 | } else { |
| 121 | 121 | if ($oldemail != 'none') { |
| 122 | - print "- No email sent for " . $oldsalerepresentative . ", total: " . $total . "\n"; |
|
| 122 | + print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | $oldemail = $obj->email; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $foundtoprocess = 0; |
| 132 | 132 | $salerepresentative = dolGetFirstLastname($obj->firstname, $obj->lastname); |
| 133 | 133 | if (empty($obj->email)) { |
| 134 | - print "Warning: Sale representative " . $salerepresentative . " has no email. Notice disabled.\n"; |
|
| 134 | + print "Warning: Sale representative ".$salerepresentative." has no email. Notice disabled.\n"; |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | $outputlangs->loadLangs(array("main", "contracts", "bills", "products")); |
| 144 | 144 | |
| 145 | 145 | if (dol_strlen($obj->email)) { |
| 146 | - $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"; |
|
| 147 | - dol_syslog("email_expire_services_to_representatives.php: " . $obj->email); |
|
| 146 | + $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"; |
|
| 147 | + dol_syslog("email_expire_services_to_representatives.php: ".$obj->email); |
|
| 148 | 148 | $foundtoprocess++; |
| 149 | 149 | } |
| 150 | - 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') . " (linked to company " . $obj->name . ", sale representative " . dolGetFirstLastname($obj->firstname, $obj->lastname) . ", email " . $obj->email . "): "; |
|
| 150 | + 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')." (linked to company ".$obj->name.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email."): "; |
|
| 151 | 151 | if (dol_strlen($obj->email)) { |
| 152 | 152 | print "qualified."; |
| 153 | 153 | } else { |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldsalerepresentative, $duration_value); |
| 168 | 168 | } else { |
| 169 | 169 | if ($oldemail != 'none') { |
| 170 | - print "- No email sent for " . $oldsalerepresentative . ", total: " . $total . "\n"; |
|
| 170 | + print "- No email sent for ".$oldsalerepresentative.", total: ".$total."\n"; |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | $errorsto = Functions::getDolGlobalString('MAIN_MAIL_ERRORS_TO'); |
| 225 | 225 | $msgishtml = -1; |
| 226 | 226 | |
| 227 | - print "- Send email for " . $oldtarget . " (" . $oldemail . "), total: " . $total . "\n"; |
|
| 228 | - dol_syslog("email_expire_services_to_representatives.php: send mail to " . $oldemail); |
|
| 227 | + print "- Send email for ".$oldtarget." (".$oldemail."), total: ".$total."\n"; |
|
| 228 | + dol_syslog("email_expire_services_to_representatives.php: send mail to ".$oldemail); |
|
| 229 | 229 | |
| 230 | 230 | $usehtml = 0; |
| 231 | 231 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER') && dol_textishtml(Functions::getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER'))) { |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER')) { |
| 240 | 240 | $allmessage .= Functions::getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER'); |
| 241 | 241 | } else { |
| 242 | - $allmessage .= $title . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n"); |
|
| 243 | - $allmessage .= $newlangs->transnoentities("NoteListOfYourExpiredServices") . ($usehtml ? "<br>\n" : "\n") . ($usehtml ? "<br>\n" : "\n"); |
|
| 242 | + $allmessage .= $title.($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n"); |
|
| 243 | + $allmessage .= $newlangs->transnoentities("NoteListOfYourExpiredServices").($usehtml ? "<br>\n" : "\n").($usehtml ? "<br>\n" : "\n"); |
|
| 244 | 244 | } |
| 245 | - $allmessage .= $message . ($usehtml ? "<br>\n" : "\n"); |
|
| 246 | - $allmessage .= $langs->trans("Total") . " = " . price($total, 0, $userlang, 0, 0, -1, $conf->currency) . ($usehtml ? "<br>\n" : "\n"); |
|
| 245 | + $allmessage .= $message.($usehtml ? "<br>\n" : "\n"); |
|
| 246 | + $allmessage .= $langs->trans("Total")." = ".price($total, 0, $userlang, 0, 0, -1, $conf->currency).($usehtml ? "<br>\n" : "\n"); |
|
| 247 | 247 | if (Functions::getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER')) { |
| 248 | 248 | $allmessage .= Functions::getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER'); |
| 249 | 249 | if (dol_textishtml(Functions::getDolGlobalString('SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER'))) { |
@@ -259,8 +259,8 @@ discard block |
||
| 259 | 259 | if ($mode == 'confirm') { |
| 260 | 260 | $result = $mail->sendfile(); |
| 261 | 261 | if (!$result) { |
| 262 | - print "Error sending email " . $mail->error . "\n"; |
|
| 263 | - dol_syslog("Error sending email " . $mail->error . "\n"); |
|
| 262 | + print "Error sending email ".$mail->error."\n"; |
|
| 263 | + dol_syslog("Error sending email ".$mail->error."\n"); |
|
| 264 | 264 | } |
| 265 | 265 | } else { |
| 266 | 266 | print "No email sent (test mode)\n"; |