Merge branch 'develop' of github.com:Dolibarr/dolibarr into NEW_manage_multicompany_for_invoice

This commit is contained in:
atm-quentin
2019-01-16 10:52:46 +01:00
3346 changed files with 207598 additions and 49980 deletions

View File

@@ -186,7 +186,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0))
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now))
{
echo " - qualified\n";
echo " - qualified";
dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc'));
@@ -194,7 +194,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0))
$result=$cronjob->fetch($line->id);
if ($result < 0)
{
echo "Error cronjob->fetch: ".$cronjob->error."\n";
echo "Error cronjobid: ".$line->id." cronjob->fetch: ".$cronjob->error."\n";
echo "Failed to fetch job ".$line->id."\n";
dol_syslog("cron_run_jobs.php::fetch Error ".$cronjob->error, LOG_ERR);
exit(-1);
@@ -203,7 +203,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0))
$result=$cronjob->run_jobs($userlogin);
if ($result < 0)
{
echo "Error cronjob->run_job: ".$cronjob->error."\n";
echo "Error cronjobid: ".$line->id." cronjob->run_job: ".$cronjob->error."\n";
echo "At least one job failed. Go on menu Home-Setup-Admin tools to see result for each job.\n";
echo "You can also enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n";
dol_syslog("cron_run_jobs.php::run_jobs Error ".$cronjob->error, LOG_ERR);
@@ -214,15 +214,19 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0))
$nbofjobslaunchedok++;
}
echo " - result of run_jobs = ".$result;
// we re-program the next execution and stores the last execution time for this job
$result=$cronjob->reprogram_jobs($userlogin, $now);
if ($result<0)
{
echo "Error cronjob->reprogram_job: ".$cronjob->error."\n";
echo "Error cronjobid: ".$line->id." cronjob->reprogram_job: ".$cronjob->error."\n";
echo "Enable module Log if not yet enabled, run again and take a look into dolibarr.log file\n";
dol_syslog("cron_run_jobs.php::reprogram_jobs Error ".$cronjob->error, LOG_ERR);
exit(-1);
}
echo " - reprogrammed\n";
}
else
{

View File

@@ -78,7 +78,7 @@ print $script_file." launched with mode ".$mode." default lang=".$langs->default
if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1;
$sql = "SELECT f.facnumber, 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";
if ($targettype == 'contacts') $sql.= ", sp.rowid as cid, sp.firstname as cfirstname, sp.lastname as clastname, sp.email as cemail";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
@@ -90,7 +90,7 @@ if (is_numeric($duration_value)) $sql.= " AND f.date_lim_reglement < '".$db->ida
if ($targettype == 'contacts') $sql.= " AND s.rowid = sp.fk_soc";
$sql.= " ORDER BY";
if ($targettype == 'contacts') $sql.= " sp.email, sp.rowid,";
$sql.= " s.email ASC, s.rowid ASC, f.facnumber ASC"; // Order by email to allow one message per email
$sql.= " s.email ASC, s.rowid ASC, f.ref ASC"; // Order by email to allow one message per email
//print $sql;
$resql=$db->query($sql);
@@ -157,11 +157,11 @@ if ($resql)
if (dol_strlen($newemail))
{
$message .= $outputlangs->trans("Invoice")." ".$obj->facnumber." : ".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,$conf->currency)."\n";
dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message);
$foundtoprocess++;
}
print "Unpaid invoice ".$obj->facnumber.", 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.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", ":"")."email ".$newemail.", lang ".$outputlangs->defaultlang.": ";
if (dol_strlen($newemail)) print "qualified.";
else print "disqualified (no email).";
print "\n";

View File

@@ -75,7 +75,7 @@ print $script_file." launched with mode ".$mode." default lang=".$langs->default
if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1;
$sql = "SELECT f.facnumber, 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 .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
@@ -86,7 +86,7 @@ $sql .= " AND f.fk_soc = s.rowid";
if (is_numeric($duration_value)) $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
$sql .= " AND sc.fk_soc = s.rowid";
$sql .= " AND sc.fk_user = u.rowid";
$sql .= " ORDER BY u.email ASC, s.rowid ASC, f.facnumber ASC"; // Order by email to allow one message per email
$sql .= " ORDER BY u.email ASC, s.rowid ASC, f.ref ASC"; // Order by email to allow one message per email
//print $sql;
$resql=$db->query($sql);
@@ -137,11 +137,11 @@ if ($resql)
if (dol_strlen($obj->email))
{
$message .= $outputlangs->trans("Invoice")." ".$obj->facnumber." : ".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,$conf->currency)." : ".$obj->name."\n";
dol_syslog("email_unpaid_invoices_to_representatives.php: ".$obj->email);
$foundtoprocess++;
}
print "Unpaid invoice ".$obj->facnumber.", 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."): ";
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."): ";
if (dol_strlen($obj->email)) print "qualified.";
else print "disqualified (no email).";
print "\n";