From f39fb5187a4f490378d672a88794f254af27c055 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Thu, 15 Jun 2017 20:27:40 +0200 Subject: [PATCH] Fix component to select journal --- htdocs/accountancy/bookkeeping/card.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 6 +++--- htdocs/compta/bank/card.php | 4 ++-- htdocs/core/class/html.formaccounting.class.php | 17 +++++++---------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3ef418e2e20..f40bfda856f 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -256,7 +256,7 @@ if ($action == 'create') { print '<tr>'; print '<td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>'; print '<td>'; - print $formaccountancy->select_journal('', 'code_journal', '', 0, '', 1, 1, 1, 1); + print $formaccountancy->select_journal('', 'code_journal', '', 0, 1, 1, 1, 1); print '</td></tr>'; print '<tr>'; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b6685248ca7..cd93b1142f8 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -322,7 +322,7 @@ if ($action == 'delbookkeepingyear') { $delyear = dol_print_date(dol_now(), '%Y'); } $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); - $journal_array = $formaccounting->selectjournal($deljournal, 'deljournal', '', 1, 'array', 1, 1); + $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); $form_question['delyear'] = array ( 'name' => 'delyear', @@ -333,9 +333,9 @@ if ($action == 'delbookkeepingyear') { ); $form_question['deljournal'] = array ( 'name' => 'deljournal', - 'type' => 'select', + 'type' => 'other', // We don't use select here, the journal_array is already a select html component 'label' => $langs->trans('DelJournal'), - 'values' => $journal_array, + 'value' => $journal_array, 'default' => $deljournal ); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 06918ff2846..1f55698d13f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -524,7 +524,7 @@ if ($action == 'create') { print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>'; print '<td>'; - print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0); + print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '</td></tr>'; } @@ -982,7 +982,7 @@ else { print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>'; print '<td>'; - print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0); + print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0); print '</td></tr>'; } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 2d444c1aefe..e37e1690ca2 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -54,15 +54,14 @@ class FormAccounting extends Form * @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 array $event Event options * @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 */ - function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') + function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='', $disabledajaxcombo=0) { global $conf; @@ -92,8 +91,6 @@ class FormAccounting extends Form return -1; } - $out = ajax_combobox($htmlname, $event); - $selected = 0; while ($obj = $this->db->fetch_object($resql)) { @@ -125,7 +122,7 @@ class FormAccounting extends Form } } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo?0:1)); return $out; } @@ -204,9 +201,9 @@ class FormAccounting extends Form { dol_print_error($db,$db->lasterror()); } - - $out .= ajax_combobox($htmlname, $event); - + + $out .= ajax_combobox($htmlname, array()); + print $out; } @@ -260,7 +257,7 @@ class FormAccounting extends Form require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; $out = ''; - + $options = array(); if ($usecache && ! empty($this->options_cache[$usecache])) { -- GitLab