diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php
index 9720399fb5e..3134dfa95ba 100644
--- a/htdocs/accountancy/class/accountingjournal.class.php
+++ b/htdocs/accountancy/class/accountingjournal.class.php
@@ -441,26 +441,40 @@ class AccountingJournal extends CommonObject
$langs->loadLangs(array("assets"));
// Clean parameters
- if (empty($type)) $type = 'view';
- if (empty($in_bookkeeping)) $in_bookkeeping = 'notyet';
+ if (empty($type)) {
+ $type = 'view';
+ }
+ if (empty($in_bookkeeping)) {
+ $in_bookkeeping = 'notyet';
+ }
$sql = "";
- if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
+
+ // FIXME sql error with Mysql 5.7
+ /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
$sql .= "WITH in_accounting_bookkeeping(fk_docdet) AS (";
$sql .= " SELECT DISTINCT fk_docdet";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping";
$sql .= " WHERE doc_type = 'asset'";
$sql .= ")";
- }
+ }*/
+
$sql .= "SELECT ad.fk_asset AS rowid, a.ref AS asset_ref, a.label AS asset_label, a.acquisition_value_ht AS asset_acquisition_value_ht";
$sql .= ", a.disposal_date AS asset_disposal_date, a.disposal_amount_ht AS asset_disposal_amount_ht, a.disposal_subject_to_vat AS asset_disposal_subject_to_vat";
$sql .= ", ad.rowid AS depreciation_id, ad.depreciation_mode, ad.ref AS depreciation_ref, ad.depreciation_date, ad.depreciation_ht, ad.accountancy_code_debit, ad.accountancy_code_credit";
$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation as ad";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON a.rowid = ad.fk_asset";
- if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
+ // FIXME sql error with Mysql 5.7
+ /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
$sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
- }
+ }*/
$sql .= " WHERE a.entity IN (" . getEntity('asset', 0) . ')'; // We don't share object for accountancy, we use source object sharing
+ // Compatibility with Mysql 5.7
+ if ($in_bookkeeping == 'already') {
+ $sql .= " AND EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')";
+ } elseif ($in_bookkeeping == 'notyet') {
+ $sql .= " AND NOT EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')";
+ }
$sql .= " AND ad.ref != ''"; // not reversal lines
if ($date_start && $date_end) {
$sql .= " AND ad.depreciation_date >= '" . $this->db->idate($date_start) . "' AND ad.depreciation_date <= '" . $this->db->idate($date_end) . "'";
@@ -470,9 +484,10 @@ class AccountingJournal extends CommonObject
$sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'";
}
// Already in bookkeeping or not
- if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
+ // FIXME sql error with Mysql 5.7
+ /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') {
$sql .= " AND iab.fk_docdet IS" . ($in_bookkeeping == 'already' ? " NOT" : "") . " NULL";
- }
+ }*/
$sql .= " ORDER BY ad.depreciation_date";
dol_syslog(__METHOD__, LOG_DEBUG);
diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php
index d737925f2c3..32a4adb3569 100644
--- a/htdocs/accountancy/journal/variousjournal.php
+++ b/htdocs/accountancy/journal/variousjournal.php
@@ -289,19 +289,21 @@ print '
' . $langs->trans("Debit") . ' | ';
print '' . $langs->trans("Credit") . ' | ';
print "\n";
-foreach ($journal_data as $element_id => $element) {
- foreach ($element['blocks'] as $lines) {
- foreach ($lines as $line) {
- print '';
- print '| ' . $line['date'] . ' | ';
- print '' . $line['piece'] . ' | ';
- print '' . $line['account_accounting'] . ' | ';
- print '' . $line['subledger_account'] . ' | ';
- print '' . $line['label_operation'] . ' | ';
- if ($object->nature == 4) print '' . $line['payment_mode'] . ' | ';
- print '' . $line['debit'] . ' | ';
- print '' . $line['credit'] . ' | ';
- print '
';
+if (is_array($journal_data) && !empty($journal_data)) {
+ foreach ($journal_data as $element_id => $element) {
+ foreach ($element['blocks'] as $lines) {
+ foreach ($lines as $line) {
+ print '';
+ print '| ' . $line['date'] . ' | ';
+ print '' . $line['piece'] . ' | ';
+ print '' . $line['account_accounting'] . ' | ';
+ print '' . $line['subledger_account'] . ' | ';
+ print '' . $line['label_operation'] . ' | ';
+ if ($object->nature == 4) print '' . $line['payment_mode'] . ' | ';
+ print '' . $line['debit'] . ' | ';
+ print '' . $line['credit'] . ' | ';
+ print '
';
+ }
}
}
}
diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php
index ea6ec241b16..7b4e06c897f 100644
--- a/htdocs/comm/mailing/class/advtargetemailing.class.php
+++ b/htdocs/comm/mailing/class/advtargetemailing.class.php
@@ -119,13 +119,23 @@ class AdvanceTargetingMailing extends CommonObject
'3' => $langs->trans('ThirdParty'),
'4' => $langs->trans('ContactsWithThirdpartyFilter')
);
- $this->type_statuscommprospect = array(
- -1 => $langs->trans("StatusProspect-1"),
- 0 => $langs->trans("StatusProspect0"),
- 1 => $langs->trans("StatusProspect1"),
- 2 => $langs->trans("StatusProspect2"),
- 3 => $langs->trans("StatusProspect3")
- );
+
+ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
+ $customerStatic = new Client($this->db);
+ $customerStatic->loadCacheOfProspStatus();
+ if (!empty($customerStatic->cacheprospectstatus)) {
+ foreach ($customerStatic->cacheprospectstatus as $dataProspectSt) {
+ $this->type_statuscommprospect[$dataProspectSt['id']]=$dataProspectSt['label'];
+ }
+ } else {
+ $this->type_statuscommprospect = array(
+ -1 => $langs->trans("StatusProspect-1"),
+ 0 => $langs->trans("StatusProspect0"),
+ 1 => $langs->trans("StatusProspect1"),
+ 2 => $langs->trans("StatusProspect2"),
+ 3 => $langs->trans("StatusProspect3")
+ );
+ }
}
/**
diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
index 9e10d51031e..50169438baa 100644
--- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
+++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
@@ -355,7 +355,7 @@ class FormAdvTargetEmailing extends Form
$out = '';
$sql = "SELECT c.rowid, c.name, c.fk_element";
- $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as c";
+ $sql .= " FROM ".MAIN_DB_PREFIX."mailing_advtarget as c";
$sql .= " WHERE type_element = '".$this->db->escape($type_element)."'";
$sql .= " ORDER BY c.name";
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 5fb9ba38588..2f3eb754b48 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -4812,7 +4812,7 @@ class Product extends CommonObject
$sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens
$sql.= " ORDER BY pa.rang";
- dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level. ' parents='.implode(',', $parents), LOG_DEBUG);
+ dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level. ' parents='.(is_array($parents)?implode(',', $parents):$parents), LOG_DEBUG);
if ($level == 1) {
$alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly