diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 84bcdfa76f0..4cb6bbaf48d 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3971,42 +3971,45 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * print list of payment modes.
- * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
- * See instead to force the default value by the caller.
+ * print list of payment modes.
+ * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
+ * See instead to force the default value by the caller.
*
- * @param int $selected Id of payment term to preselect by default
- * @param string $htmlname Nom de la zone select
- * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
- * @param int $addempty Add an empty entry
- * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
- * @param string $morecss Add more CSS on select tag
- * @param string $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
+ * @param int $selected Id of payment term to preselect by default
+ * @param string $htmlname Nom de la zone select
+ * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
+ * @param int $addempty Add an empty entry
+ * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
+ * @param string $morecss Add more CSS on select tag
+ * @param string $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
*/
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '', $deposit_percent = -1)
{
// phpcs:enable
- print $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss);
+ print $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss, $deposit_percent = -1);
}
/**
- * Return list of payment modes.
- * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
- * See instead to force the default value by the caller.
+ * Return list of payment modes.
+ * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
+ * See instead to force the default value by the caller.
*
- * @param int $selected Id of payment term to preselect by default
- * @param string $htmlname Nom de la zone select
- * @param int $filtertype Not used
- * @param int $addempty Add an empty entry
- * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
- * @param string $morecss Add more CSS on select tag
- * @return void
+ * @param int $selected Id of payment term to preselect by default
+ * @param string $htmlname Nom de la zone select
+ * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
+ * @param int $addempty Add an empty entry
+ * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
+ * @param string $morecss Add more CSS on select tag
+ * @param string $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 string
*/
- public function getSelectConditionsPaiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '')
+ public function getSelectConditionsPaiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $deposit_percent = -1)
{
global $langs, $user, $conf;
@@ -4024,16 +4027,19 @@ class Form
if ($addempty) {
$out.= '';
}
+
$selectedDepositPercent = null;
+
foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
if ($filtertype <= 0 && ! empty($arrayconditions['deposit_percent'])) {
continue;
}
+
if ($selected == $id) {
$selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions['deposit_percent'];
- print '';
+ $out.= $label;
+ $out.= '';
}
$out.= '';
if ($user->admin && empty($noinfoadmin)) {
$out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
$out.= ajax_combobox($htmlname);
+
if ($deposit_percent >= 0) {
- print ' ';
- print $langs->trans('DepositPercent') . ' : ';
- print '';
- print '';
- print '
+ $out .= ' ';
+ $out .= $langs->trans('DepositPercent') . ' : ';
+ $out .= '';
+ $out .= '';
+ $out .= '
';
}
+
return $out;
}
diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
index 2fc7107e07e..f744abffde4 100644
--- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
+++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
@@ -188,13 +188,6 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (20, '2012', '
ALTER TABLE llx_c_holiday_types ADD COLUMN block_if_negative integer NOT NULL DEFAULT 0 AFTER fk_country;
--- Deposit generation helper with specific payment terms
-ALTER TABLE llx_c_payment_term ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER decalage;
-ALTER TABLE llx_societe ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER cond_reglement;
-ALTER TABLE llx_propal ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER fk_cond_reglement;
-ALTER TABLE llx_commande ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER fk_cond_reglement;
-INSERT INTO llx_c_payment_term(code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values ('DEP30PCTDEL', 13, 0, '__DEPOSIT_PERCENT__% deposit', '__DEPOSIT_PERCENT__% deposit, remainder on delivery', 0, 1, '30');
-
-- START GRH/HRM MODULE
diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql
index 5d838fc8bb1..db1617e8bdd 100644
--- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql
+++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql
@@ -272,4 +272,12 @@ ALTER TABLE llx_reception MODIFY COLUMN ref_supplier varchar(128);
ALTER TABLE llx_bank_account ADD COLUMN pti_in_ctti smallint DEFAULT 0 AFTER domiciliation;
-- Set default ticket type to OTHER if no default exists
-UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1);
\ No newline at end of file
+UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1);
+
+
+-- Deposit generation helper with specific payment terms
+ALTER TABLE llx_c_payment_term ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER decalage;
+ALTER TABLE llx_societe ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER cond_reglement;
+ALTER TABLE llx_propal ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER fk_cond_reglement;
+ALTER TABLE llx_commande ADD COLUMN deposit_percent VARCHAR(63) DEFAULT NULL AFTER fk_cond_reglement;
+INSERT INTO llx_c_payment_term(code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour, deposit_percent) values ('DEP30PCTDEL', 13, 0, '__DEPOSIT_PERCENT__% deposit', '__DEPOSIT_PERCENT__% deposit, remainder on delivery', 0, 1, '30');