From ee34b6d8f563ea0a3eac3be86d68bcd481f0a055 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Sep 2022 09:39:37 +0200 Subject: [PATCH 01/10] FIXME sql error --- .../accountancy/class/accountingjournal.class.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 9720399fb5e..444198a86a3 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -441,24 +441,29 @@ 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 + /*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') { - $sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "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 $sql .= " AND ad.ref != ''"; // not reversal lines From 36c54a140ff9a5f24a67ff13bc64a12233d69929 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 28 Sep 2022 22:32:55 +0200 Subject: [PATCH 02/10] FIX compatibility with Mysql <= 5.7 --- .../class/accountingjournal.class.php | 22 +++++++++++---- htdocs/accountancy/journal/variousjournal.php | 28 ++++++++++--------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 444198a86a3..20e09a8f6bc 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -449,7 +449,8 @@ class AccountingJournal extends CommonObject } $sql = ""; - // FIXME sql error + + // 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"; @@ -457,15 +458,23 @@ class AccountingJournal extends CommonObject $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') { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid"; - } + // 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')"; + } else if ($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) . "'"; @@ -475,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 ''; + } } } } From 6b4cf5c8d9e40a450561ddb5bbab444ba6545564 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 28 Sep 2022 20:39:47 +0000 Subject: [PATCH 03/10] Fixing style errors. --- htdocs/accountancy/class/accountingjournal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 20e09a8f6bc..3134dfa95ba 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -472,7 +472,7 @@ class AccountingJournal extends CommonObject // 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')"; - } else if ($in_bookkeeping == 'notyet') { + } 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 From 3777b7dffe80ca80ca9f1a3ea28c8f95aab8f111 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 3 Oct 2022 13:38:15 +0200 Subject: [PATCH 04/10] fix: [AdvTargetEmailling] bad table from select and use of dict for prospect status --- .../mailing/class/advtargetemailing.class.php | 18 +++++++++++------- .../class/html.formadvtargetemailing.class.php | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ea6ec241b16..72c9a0e4eb7 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -111,6 +111,8 @@ class AdvanceTargetingMailing extends CommonObject global $langs; $langs->load('customers'); + + $this->db = $db; $this->select_target_type = array( @@ -119,13 +121,15 @@ 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']; + } + } } /** 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"; From 7ac0168397e1a8e911b4f6b10ae4985956cff2ea Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 3 Oct 2022 13:40:33 +0200 Subject: [PATCH 05/10] travais --- htdocs/comm/mailing/class/advtargetemailing.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 72c9a0e4eb7..35412193c50 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -111,8 +111,6 @@ class AdvanceTargetingMailing extends CommonObject global $langs; $langs->load('customers'); - - $this->db = $db; $this->select_target_type = array( @@ -129,6 +127,8 @@ class AdvanceTargetingMailing extends CommonObject foreach ($customerStatic->cacheprospectstatus as $dataProspectSt) { $this->type_statuscommprospect[$dataProspectSt['id']]=$dataProspectSt['label']; } + } else { + $this->type_statuscommprospect = array(); } } From 83fa90eef794a34252897f70893b9c990282136e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 3 Oct 2022 13:41:07 +0200 Subject: [PATCH 06/10] travais --- htdocs/comm/mailing/class/advtargetemailing.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 35412193c50..7b4e06c897f 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -128,7 +128,13 @@ class AdvanceTargetingMailing extends CommonObject $this->type_statuscommprospect[$dataProspectSt['id']]=$dataProspectSt['label']; } } else { - $this->type_statuscommprospect = array(); + $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") + ); } } From 5ccc5c9e1a59939478e53ecb33664f2dc201e6d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Oct 2022 17:30:47 +0200 Subject: [PATCH 07/10] Fix error message --- htdocs/api/index.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/api/index.php b/htdocs/api/index.php index afb0289aa32..a87edf8166c 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -120,7 +120,7 @@ if (empty($conf->global->MAIN_MODULE_API)) { // Test if explorer is not disabled if (preg_match('/api\/index\.php\/explorer/', $url) && !empty($conf->global->API_EXPLORER_DISABLED)) { $langs->load("admin"); - dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + dol_syslog("Call Dolibarr API interfaces with module API REST disabled"); print $langs->trans("WarningAPIExplorerDisabled").'.

'; //session_destroy(); exit(0); @@ -153,6 +153,10 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg); $refreshcache = (empty($conf->global->API_PRODUCTION_DO_NOT_ALWAYS_REFRESH_CACHE) ? true : false); if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) { $refreshcache = true; + if (!is_writable($conf->api->dir_temp)) { + print 'Erreur temp dir api/temp not writable'; + exit(0); + } } $api = new DolibarrApi($db, '', $refreshcache); From 49163de473acc73b5c9d6c3ac4b974edae779b48 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 3 Oct 2022 22:01:04 +0200 Subject: [PATCH 08/10] Fix better fix for php 8 --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From b5c745a573b9b3e99bb9d65f3971e2d8ee858725 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Oct 2022 19:41:04 +0200 Subject: [PATCH 09/10] Fix warnings --- htdocs/cron/class/cronjob.class.php | 11 +++++++++-- htdocs/partnership/class/partnershiputils.class.php | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index a84fa3109df..b18c7146795 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -163,10 +163,16 @@ class Cronjob extends CommonObject public $libname; /** - * @var string A test condition to know if job is visible/qualified + * @var string A test condition to know if job is visible/qualified */ public $test; + /** + * @var string Autodelete + */ + public $autodelete; + + const STATUS_DISABLED = 0; const STATUS_ENABLED = 1; const STATUS_ARCHIVED = 2; @@ -1191,7 +1197,8 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG); // Create Object for the called module - $object = new $this->objectname($this->db); + $nameofclass = $this->objectname; + $object = new $nameofclass($this->db); if ($this->entity > 0) { $object->entity = $this->entity; // We work on a dedicated entity } diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 9ad2e5b7ca2..c73068e17a4 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -41,6 +41,8 @@ class PartnershipUtils public $error; //!< To return error code (or message) public $errors = array(); //!< To return several error codes (or messages) + public $output; // To store output of some cron methods + /** * Constructor From 85a764afc608163499ffead9efdb5789384abcce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Oct 2022 13:50:02 +0200 Subject: [PATCH 10/10] FIX bad closing select --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 1222e9f7ffc..413137ec0b0 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1207,7 +1207,7 @@ if (!empty($arrayfields['customerorsupplier']['checked'])) { print ''; } print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list'); - print ''; + print ''; } // Prospect level if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) {