NEW: deposit payment terms: prefill deposit parameters if coming from an origin with the corresponding payment conditions

This commit is contained in:
Marc de Lima Lucio
2021-09-30 11:48:32 +02:00
parent b0aa502ed4
commit 8cb6cdf1bc

View File

@@ -3256,10 +3256,21 @@ if ($action == 'create') {
'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')),
'variablealllines' => $langs->transnoentitiesnoconv('VarAmountAllLines')
);
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit', 'aZ09'), 0, 0, 0, '', 1);
$typedeposit = GETPOST('typedeposit', 'aZ09');
$valuedeposit = GETPOST('valuedeposit', 'int');
if (empty($typedeposit) && ! empty($objectsrc->deposit_percent)) {
$origin_payment_conditions_deposit_percent = getDictvalue(MAIN_DB_PREFIX . 'c_payment_term', 'deposit_percent', $objectsrc->cond_reglement_id);
if (! empty($origin_payment_conditions_deposit_percent)) {
$typedeposit = 'variable';
}
}
if (empty($valuedeposit) && $typedeposit == 'variable' && ! empty($objectsrc->deposit_percent)) {
$valuedeposit = $objectsrc->deposit_percent;
}
print $form->selectarray('typedeposit', $arraylist, $typedeposit, 0, 0, 0, '', 1);
print '</td>';
print '<td class="nowrap" style="padding-left: 5px">';
print '<span class="opacitymedium paddingleft">'.$langs->trans("AmountOrPercent").'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="'.GETPOST('valuedeposit', 'int').'"/>';
print '<span class="opacitymedium paddingleft">'.$langs->trans("AmountOrPercent").'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="'.$valuedeposit.'"/>';
print '</td>';
}
print '</tr></table>';