Fix component to select journal

This commit is contained in:
Laurent Destailleur 2017-06-15 20:27:40 +02:00
parent 097be322a6
commit f39fb5187a
4 changed files with 13 additions and 16 deletions

View File

@ -256,7 +256,7 @@ if ($action == 'create') {
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>'; print '<td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>';
print '<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 '</td></tr>';
print '<tr>'; print '<tr>';

View File

@ -322,7 +322,7 @@ if ($action == 'delbookkeepingyear') {
$delyear = dol_print_date(dol_now(), '%Y'); $delyear = dol_print_date(dol_now(), '%Y');
} }
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); $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 ( $form_question['delyear'] = array (
'name' => 'delyear', 'name' => 'delyear',
@ -333,9 +333,9 @@ if ($action == 'delbookkeepingyear') {
); );
$form_question['deljournal'] = array ( $form_question['deljournal'] = array (
'name' => 'deljournal', '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'), 'label' => $langs->trans('DelJournal'),
'values' => $journal_array, 'value' => $journal_array,
'default' => $deljournal 'default' => $deljournal
); );

View File

@ -524,7 +524,7 @@ if ($action == 'create')
{ {
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>'; print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<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>'; print '</td></tr>';
} }
@ -982,7 +982,7 @@ else
{ {
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>'; print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<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>'; print '</td></tr>';
} }

View File

@ -54,15 +54,14 @@ class FormAccounting extends Form
* @param string $htmlname Name of field in html 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 $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 $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_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 int $select_out Set value returned by select. 0=rowid (default), 1=code
* @param string $morecss More css non HTML object * @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 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 * @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; global $conf;
@ -92,8 +91,6 @@ class FormAccounting extends Form
return -1; return -1;
} }
$out = ajax_combobox($htmlname, $event);
$selected = 0; $selected = 0;
while ($obj = $this->db->fetch_object($resql)) 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; return $out;
} }
@ -204,9 +201,9 @@ class FormAccounting extends Form
{ {
dol_print_error($db,$db->lasterror()); dol_print_error($db,$db->lasterror());
} }
$out .= ajax_combobox($htmlname, $event); $out .= ajax_combobox($htmlname, array());
print $out; print $out;
} }
@ -260,7 +257,7 @@ class FormAccounting extends Form
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$out = ''; $out = '';
$options = array(); $options = array();
if ($usecache && ! empty($this->options_cache[$usecache])) if ($usecache && ! empty($this->options_cache[$usecache]))
{ {