Clean code and comment to have code easier to undestand.

This commit is contained in:
Laurent Destailleur 2021-01-14 10:56:24 +01:00
parent 77a094007f
commit d76aab4d08
3 changed files with 22 additions and 17 deletions

View File

@ -595,7 +595,8 @@ if ($action == 'create')
print '<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.'">'."\n";
print '<input type="hidden" name="mode" value="'.$mode.'">'."\n";
print "<table class=\"noborder\" width=\"100%\">";
print '<table class="noborder centpercent">';
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 '<!-- td columns in edit mode -->';
print '<td>';
print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, '');
print '</td>';
print '<td>';
// 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 '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">';
}
// TODO Add also the label
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'"></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'"></td>';
@ -672,18 +676,21 @@ if ($action == 'create')
if ($action == "" || $action == 'add') {
print '<tr class="oddeven">';
print '<!-- td columns in add mode -->';
print '<td>';
print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, '');
print '</td>';
print '<td>';
// 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 '<input type="text" class="maxwidth150" name="subledger_account" value="">';
}
// TODO Add also the label
print '</td>';
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.$label_operation.'"/></td>';
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';

View File

@ -6421,8 +6421,7 @@ class Form
$value = $tmpvalue;
$disabled = ''; $style = '';
}
if (!empty($disablebademail))
{
if (!empty($disablebademail)) {
if (($disablebademail == 1 && !preg_match('/&lt;.+@.+&gt;/', $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 {

View File

@ -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.' <span class="opacitymedium">('.$obj->nom.')</span>';
}
}
} 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.' <span class="opacitymedium">('.$obj->nom.')</span>';
}
}
} 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.' <span class="opacitymedium">('.dolGetFirstLastname($obj->firstname, $obj->lastname).')</span>';
}
}
} else {