';
}
// Fields from hook
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index d6f7b269da1..373501a7adf 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -59,7 +59,7 @@ class FormAccounting extends Form
/**
* Return list of journals with label by nature
*
- * @param string $selectid Preselected pcg_type
+ * @param string $selectid Preselected journal code
* @param string $htmlname Name of field in html form
* @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
@@ -136,6 +136,86 @@ class FormAccounting extends Form
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return list of journals with label by nature
+ *
+ * @param array $selectids Preselected journal code
+ * @param string $htmlname Name of field in html form
+ * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
+ * @param int $showempty Add an empty field
+ * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
+ * @param int $select_out Set value returned by select. 0=rowid (default), 1=code
+ * @param string $morecss More css non HTML object
+ * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
+ * @param int $disabledajaxcombo Disable ajax combo box.
+ * @return string String with HTML select
+ */
+ public function multi_select_journal($selectedIds=array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0)
+ {
+ // phpcs:enable
+ global $conf, $langs;
+
+ $out = '';
+
+ $options = array();
+ if ($usecache && !empty($this->options_cache[$usecache]))
+ {
+ $options = $this->options_cache[$usecache];
+ $selected = $selectedIds;
+ } else {
+ $sql = "SELECT rowid, code, label, nature, entity, active";
+ $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
+ $sql .= " WHERE active = 1";
+ $sql .= " AND entity = ".$conf->entity;
+ if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature;
+ $sql .= " ORDER BY code";
+
+ dol_syslog(get_class($this)."::multi_select_journal", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+
+ if (!$resql) {
+ $this->error = "Error ".$this->db->lasterror();
+ dol_syslog(get_class($this)."::multi_select_journal ".$this->error, LOG_ERR);
+ return -1;
+ }
+
+ $selected = array();
+ $langs->load('accountancy');
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ $label = $langs->trans($obj->label);
+
+ $select_value_in = $obj->rowid;
+ $select_value_out = $obj->rowid;
+
+ // Try to guess if we have found default value
+ if ($select_in == 1) {
+ $select_value_in = $obj->code;
+ }
+ if ($select_out == 1) {
+ $select_value_out = $obj->code;
+ }
+ // Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid
+ if (!empty($selectedIds) && in_array($select_value_in, $selectedIds)) {
+ //var_dump("Found ".$selectid." ".$select_value_in);
+ $selected[] = $select_value_out;
+ }
+ $options[$select_value_out] = $label;
+ }
+ $this->db->free($resql);
+
+ if ($usecache)
+ {
+ $this->options_cache[$usecache] = $options;
+ }
+ }
+
+ $out .= Form::multiselectarray($htmlname, $options, $selected, $showempty, 0, $morecss, 0, 0, 0, 'code_journal', '',($disabledajaxcombo ? 0 : 1));
+
+ return $out;
+ }
+
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of accounting category.
diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php
index 811dd57544e..7eff70422ee 100644
--- a/htdocs/core/modules/modAccounting.class.php
+++ b/htdocs/core/modules/modAccounting.class.php
@@ -154,6 +154,12 @@ class modAccounting extends DolibarrModules
"csv",
"", 0, 'current', 0
);
+ $this->const[14] = array(
+ "ACCOUNTING_LIMIT_LIST_VENTILATION",
+ "chaine",
+ "50",
+ "", 0, 'current', 0
+ );
// Tabs
$this->tabs = array();
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index 1d75fa153e8..c35d85e7bcb 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -144,7 +144,7 @@ NotVentilatedinAccount=Not bound to the accounting account
XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account
XLineFailedToBeBinded=%s products/services were not bound to any accounting account
-ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended: 50)
+ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to on list and bind shown by page (maximum recommended: 50)
ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the page "Binding to do" by the most recent elements
ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the page "Binding done" by the most recent elements
diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang
index 6381caebbec..5309adfae93 100644
--- a/htdocs/langs/fr_FR/accountancy.lang
+++ b/htdocs/langs/fr_FR/accountancy.lang
@@ -137,7 +137,7 @@ NotVentilatedinAccount=Non lié au compte comptable
XLineSuccessfullyBinded=%s produits/service correctement liés à un compte comptable
XLineFailedToBeBinded=%s produits/services n'ont pu être liés à un compte comptable
-ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre d'éléments à lier représentés par page (maximum recommandé: 50)
+ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre de ligne des listes et d'éléments à lier représentés par page (maximum recommandé: 50)
ACCOUNTING_LIST_SORT_VENTILATION_TODO=Commencez le tri de la page "Lien à réaliser" par les éléments les plus récents
ACCOUNTING_LIST_SORT_VENTILATION_DONE=Commencez le tri de la page "Liens réalisés" par les éléments les plus récents