FIX: deposit payment terms: don't show percentage input on lists
This commit is contained in:
parent
337531f832
commit
54782f5d4c
@ -3881,10 +3881,12 @@ class Form
|
|||||||
* @param int $addempty Add an empty entry
|
* @param int $addempty Add an empty entry
|
||||||
* @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
|
* @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
|
||||||
* @param string $morecss Add more CSS on select tag
|
* @param string $morecss Add more CSS on select tag
|
||||||
* @param float $deposit_percent % of deposit if needed by payment conditions
|
* @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
|
||||||
|
* 0 : use default deposit percentage from entry
|
||||||
|
* > 0 : force deposit percentage (for example, from company object)
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '', $deposit_percent = null)
|
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '', $deposit_percent = -1)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs, $user, $conf;
|
global $langs, $user, $conf;
|
||||||
@ -3910,7 +3912,7 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($selected == $id) {
|
if ($selected == $id) {
|
||||||
$selectedDepositPercent = ! empty($deposit_percent) ? $deposit_percent : $arrayconditions['deposit_percent'];
|
$selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions['deposit_percent'];
|
||||||
print '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '" selected>';
|
print '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '" selected>';
|
||||||
} else {
|
} else {
|
||||||
print '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '">';
|
print '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '">';
|
||||||
@ -3919,7 +3921,7 @@ class Form
|
|||||||
$label = $arrayconditions['label'];
|
$label = $arrayconditions['label'];
|
||||||
|
|
||||||
if (! empty($arrayconditions['deposit_percent'])) {
|
if (! empty($arrayconditions['deposit_percent'])) {
|
||||||
$label = sprintf($label, ! empty($deposit_percent) ? $deposit_percent : $arrayconditions['deposit_percent']);
|
$label = sprintf($label, $deposit_percent > 0 ? $deposit_percent : $arrayconditions['deposit_percent']);
|
||||||
}
|
}
|
||||||
|
|
||||||
print $label;
|
print $label;
|
||||||
@ -3931,27 +3933,30 @@ class Form
|
|||||||
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
}
|
}
|
||||||
print ajax_combobox($htmlname);
|
print ajax_combobox($htmlname);
|
||||||
print ' <span id="'.$htmlname.'_deposit_percent_container"' . (empty($selectedDepositPercent) ? ' style="display: none"' : '') . '>';
|
|
||||||
print $langs->trans('DepositPercent') . ' : ';
|
|
||||||
print '<input id="'.$htmlname.'_deposit_percent" name="'.$htmlname.'_deposit_percent" class="maxwidth50" value="' . floatval($deposit_percent) . '" />';
|
|
||||||
print '</span>';
|
|
||||||
print '
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
$("#' . $htmlname . '").change(function () {
|
|
||||||
let $selected = $(this).find("option:selected");
|
|
||||||
let depositPercent = $selected.attr("data-deposit_percent");
|
|
||||||
|
|
||||||
if (depositPercent.length > 0) {
|
if ($deposit_percent >= 0) {
|
||||||
$("#'.$htmlname.'_deposit_percent_container").show().find("#'.$htmlname.'_deposit_percent").val(depositPercent);
|
print ' <span id="'.$htmlname.'_deposit_percent_container"' . (empty($selectedDepositPercent) ? ' style="display: none"' : '') . '>';
|
||||||
} else {
|
print $langs->trans('DepositPercent') . ' : ';
|
||||||
$("#'.$htmlname.'_deposit_percent_container").hide();
|
print '<input id="'.$htmlname.'_deposit_percent" name="'.$htmlname.'_deposit_percent" class="maxwidth50" value="' . floatval($deposit_percent) . '" />';
|
||||||
}
|
print '</span>';
|
||||||
|
print '
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$("#' . $htmlname . '").change(function () {
|
||||||
|
let $selected = $(this).find("option:selected");
|
||||||
|
let depositPercent = $selected.attr("data-deposit_percent");
|
||||||
|
|
||||||
return true;
|
if (depositPercent.length > 0) {
|
||||||
|
$("#'.$htmlname.'_deposit_percent_container").show().find("#'.$htmlname.'_deposit_percent").val(depositPercent);
|
||||||
|
} else {
|
||||||
|
$("#'.$htmlname.'_deposit_percent_container").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
</script>';
|
||||||
</script>';
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5142,9 +5147,12 @@ class Form
|
|||||||
* @param int $addempty Add empty entry
|
* @param int $addempty Add empty entry
|
||||||
* @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
|
* @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
|
||||||
* @param float $deposit_percent % of deposit if needed by payment conditions
|
* @param float $deposit_percent % of deposit if needed by payment conditions
|
||||||
|
* @param float $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
|
||||||
|
* 0 : use default deposit percentage from entry
|
||||||
|
* > 0 : force deposit percentage (for example, from company object)
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $filtertype = -1, $deposit_percent = null)
|
public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $filtertype = -1, $deposit_percent = -1)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs;
|
global $langs;
|
||||||
@ -5162,7 +5170,7 @@ class Form
|
|||||||
$label = $this->cache_conditions_paiements[$selected]['label'];
|
$label = $this->cache_conditions_paiements[$selected]['label'];
|
||||||
|
|
||||||
if (! empty($this->cache_conditions_paiements[$selected]['deposit_percent'])) {
|
if (! empty($this->cache_conditions_paiements[$selected]['deposit_percent'])) {
|
||||||
$label = sprintf($label, ! empty($deposit_percent) ? $deposit_percent : $this->cache_conditions_paiements[$selected]['deposit_percent']);
|
$label = sprintf($label, $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected]['deposit_percent']);
|
||||||
}
|
}
|
||||||
|
|
||||||
print $label;
|
print $label;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user