From 42698142146d47d67d89efd46e420536288a5e3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sat, 5 Feb 2011 17:25:56 +0000 Subject: [PATCH] New: If there is only one back account and value is mandatory, then value is preselected. --- htdocs/compta/paiement.php | 2 +- htdocs/core/class/html.form.class.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index d420675adcc..f08afd0ae50 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -266,7 +266,7 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P if ($facture->type != 2) print '<td><span class="fieldrequired">'.$langs->trans('AccountToCredit').'</span></td>'; if ($facture->type == 2) print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>'; print '<td>'; - $html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1); + $html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',2); print '</td>'; } else diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 843b120b7be..f87d7a64d6e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -838,7 +838,7 @@ class Form /** * Return list of products for customer in Ajax if Ajax activated or go to select_produits_do - * + * * @param selected Preselected products * @param htmlname Name of HTML seletc field (must be unique in page) * @param filtertype Filter on product type (''=nofilter, 0=product, 1=service) @@ -951,7 +951,7 @@ class Form $outselect.='<select class="flat" name="'.$htmlname.'">'; $outselect.='<option value="0" selected="selected"> </option>'; - + $i = 0; while ($num && $i < $num) { @@ -1655,7 +1655,7 @@ class Form * @param htmlname Name of select zone * @param statut Status of searched accounts (0=open, 1=closed) * @param filtre To filter list - * @param useempty Add an empty value in list + * @param useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. */ function select_comptes($selected='',$htmlname='accountid',$statut=0,$filtre='',$useempty=0) { @@ -1679,7 +1679,7 @@ class Form if ($num) { print '<select id="select'.$htmlname.'" class="flat selectbankaccount" name="'.$htmlname.'">'; - if ($useempty) + if ($useempty == 1 || ($useempty == 2 && $num > 1)) { print '<option value="'.$obj->rowid.'"> </option>'; } -- GitLab