From d76aab4d08fa19588be3b5efaf906793472487ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jan 2021 10:56:24 +0100 Subject: [PATCH] Clean code and comment to have code easier to undestand. --- htdocs/accountancy/bookkeeping/card.php | 25 ++++++++++++------- htdocs/core/class/html.form.class.php | 6 ++--- .../core/class/html.formaccounting.class.php | 8 +++--- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index d9da5b02aef..21077dececd 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -595,7 +595,8 @@ if ($action == 'create') print ''."\n"; print ''."\n"; - print ""; + print '
'; + if (count($object->linesmvt) > 0) { $total_debit = 0; $total_credit = 0; @@ -617,18 +618,21 @@ if ($action == 'create') $total_credit += $line->credit; if ($action == 'update' && $line->id == $id) { + print ''; print ''; print ''; print ''; print ''; @@ -672,18 +676,21 @@ if ($action == 'create') if ($action == "" || $action == 'add') { print ''; + print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8a96877a35b..2b61078fd89 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6421,8 +6421,7 @@ class Form $value = $tmpvalue; $disabled = ''; $style = ''; } - if (!empty($disablebademail)) - { + if (!empty($disablebademail)) { if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) || ($disablebademail == 2 && preg_match('/---/', $value))) { @@ -6431,8 +6430,7 @@ class Form } } - if ($key_in_label) - { + if ($key_in_label) { if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value)); else $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value); } else { diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index d6f7b269da1..d8d365cf433 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -347,7 +347,7 @@ class FormAccounting extends Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of auxilary thirdparty accounts + * Return list of auxilary accounts. Cumulate list from customers, suppliers and users. * * @param string $selectid Preselected pcg_type * @param string $htmlname Name of field in html form @@ -372,7 +372,7 @@ class FormAccounting extends Form if ($resql) { while ($obj = $this->db->fetch_object($resql)) { if (!empty($obj->code_compta)) { - $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')'; + $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')'; } } } else { @@ -392,7 +392,7 @@ class FormAccounting extends Form if ($resql) { while ($obj = $this->db->fetch_object($resql)) { if ($obj->code_compta_fournisseur != "") { - $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')'; + $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')'; } } } else { @@ -412,7 +412,7 @@ class FormAccounting extends Form if ($resql) { while ($obj = $this->db->fetch_object($resql)) { if (!empty($obj->accountancy_code)) { - $aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')'; + $aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')'; } } } else {
'; print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, ''); print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not - // use setup of keypress to select thirdparty and this hang browser on large database. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) - { + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1); } else { print 'subledger_account).'">'; } + // TODO Add also the label print 'label_operation).'">debit)).'">
'; print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not - // use setup of keypress to select thirdparty and this hang browser on large database. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) - { + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount('', 'subledger_account', 1); } else { print ''; } + // TODO Add also the label print '