FIX: deposit payment terms: adapt to v16
This commit is contained in:
parent
1993a8d7b1
commit
161edea6f3
@ -3971,42 +3971,45 @@ class Form
|
|||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
* print list of payment modes.
|
* 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.
|
* 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.
|
* See instead to force the default value by the caller.
|
||||||
*
|
*
|
||||||
* @param int $selected Id of payment term to preselect by default
|
* @param int $selected Id of payment term to preselect by default
|
||||||
* @param string $htmlname Nom de la zone select
|
* @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 $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 $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 string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
|
* @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
|
||||||
* 0 : use default deposit percentage from entry
|
* 0 : use default deposit percentage from entry
|
||||||
* > 0 : force deposit percentage (for example, from company object)
|
* > 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 = -1)
|
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '', $deposit_percent = -1)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// 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.
|
* 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.
|
* 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.
|
* See instead to force the default value by the caller.
|
||||||
*
|
*
|
||||||
* @param int $selected Id of payment term to preselect by default
|
* @param int $selected Id of payment term to preselect by default
|
||||||
* @param string $htmlname Nom de la zone select
|
* @param string $htmlname Nom de la zone select
|
||||||
* @param int $filtertype Not used
|
* @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 $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
|
||||||
* @return void
|
* @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;
|
global $langs, $user, $conf;
|
||||||
@ -4024,16 +4027,19 @@ class Form
|
|||||||
if ($addempty) {
|
if ($addempty) {
|
||||||
$out.= '<option value="0"> </option>';
|
$out.= '<option value="0"> </option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectedDepositPercent = null;
|
$selectedDepositPercent = null;
|
||||||
|
|
||||||
foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
|
foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
|
||||||
if ($filtertype <= 0 && ! empty($arrayconditions['deposit_percent'])) {
|
if ($filtertype <= 0 && ! empty($arrayconditions['deposit_percent'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($selected == $id) {
|
if ($selected == $id) {
|
||||||
$selectedDepositPercent = $deposit_percent > 0 ? $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>';
|
$out .= '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '" selected>';
|
||||||
} else {
|
} else {
|
||||||
print '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '">';
|
$out .= '<option value="'.$id.'" data-deposit_percent="' . $arrayconditions['deposit_percent'] . '">';
|
||||||
}
|
}
|
||||||
$label = $arrayconditions['label'];
|
$label = $arrayconditions['label'];
|
||||||
|
|
||||||
@ -4041,20 +4047,21 @@ class Form
|
|||||||
$label = str_replace('__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions['deposit_percent'], $label);
|
$label = str_replace('__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions['deposit_percent'], $label);
|
||||||
}
|
}
|
||||||
|
|
||||||
$out.= $label;
|
$out.= $label;
|
||||||
$out.= '</option>';
|
$out.= '</option>';
|
||||||
}
|
}
|
||||||
$out.= '</select>';
|
$out.= '</select>';
|
||||||
if ($user->admin && empty($noinfoadmin)) {
|
if ($user->admin && empty($noinfoadmin)) {
|
||||||
$out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
$out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
}
|
}
|
||||||
$out.= ajax_combobox($htmlname);
|
$out.= ajax_combobox($htmlname);
|
||||||
|
|
||||||
if ($deposit_percent >= 0) {
|
if ($deposit_percent >= 0) {
|
||||||
print ' <span id="'.$htmlname.'_deposit_percent_container"' . (empty($selectedDepositPercent) ? ' style="display: none"' : '') . '>';
|
$out .= ' <span id="'.$htmlname.'_deposit_percent_container"' . (empty($selectedDepositPercent) ? ' style="display: none"' : '') . '>';
|
||||||
print $langs->trans('DepositPercent') . ' : ';
|
$out .= $langs->trans('DepositPercent') . ' : ';
|
||||||
print '<input id="'.$htmlname.'_deposit_percent" name="'.$htmlname.'_deposit_percent" class="maxwidth50" value="' . strval($deposit_percent) . '" />';
|
$out .= '<input id="'.$htmlname.'_deposit_percent" name="'.$htmlname.'_deposit_percent" class="maxwidth50" value="' . strval($deposit_percent) . '" />';
|
||||||
print '</span>';
|
$out .= '</span>';
|
||||||
print '
|
$out .= '
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#' . $htmlname . '").change(function () {
|
$("#' . $htmlname . '").change(function () {
|
||||||
@ -4072,6 +4079,7 @@ class Form
|
|||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
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
|
-- START GRH/HRM MODULE
|
||||||
|
|
||||||
|
|||||||
@ -273,3 +273,11 @@ ALTER TABLE llx_bank_account ADD COLUMN pti_in_ctti smallint DEFAULT 0 AFTER dom
|
|||||||
|
|
||||||
-- Set default ticket type to OTHER if no default exists
|
-- 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);
|
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');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user