From 8d64f8617cfb86748874ef27ec861a10a0968df7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Dec 2022 01:52:41 +0100 Subject: [PATCH] Clean code --- .../class/accountingjournal.class.php | 22 +------------------ htdocs/comm/action/class/actioncomm.class.php | 4 ++-- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 4accf66e154..f56932d4985 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -454,27 +454,12 @@ class AccountingJournal extends CommonObject } $sql = ""; - - // 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"; - // 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') { @@ -488,11 +473,6 @@ class AccountingJournal extends CommonObject if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'"; } - // Already in bookkeeping or not - // 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); @@ -755,7 +735,7 @@ class AccountingJournal extends CommonObject } } - $journal_data[$pre_data_id] = $element; + $journal_data[(int) $pre_data_id] = $element; } unset($pre_data); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index efe9374a748..244b3df9405 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -477,8 +477,8 @@ class ActionComm extends CommonObject $this->elementtype = 'contract'; } - if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead fo array - $tmpid = $this->userassigned; + if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead of an array + $tmpid = (int) $this->userassigned; $this->userassigned = array(); $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); }