Merge branch 'NEW/12.0_new_payments_on_vat' of github.com:ATM-Consulting/dolibarr into NEW/14.0_new_payments_on_vat_default_checkbox_value

This commit is contained in:
Florian Mortgat 2021-02-16 16:28:14 +01:00
commit 186dcab1b7
3 changed files with 45 additions and 27 deletions

View File

@ -110,7 +110,12 @@ if ($action == 'update') {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
// Set boolean (on/off) constants
elseif (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
dol_print_error($db);
}
}
/*
@ -248,11 +253,26 @@ print "<br>\n";
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="button">';
print '<br/><br/>';
print '</div>';
print '</form>';
// Options
echo '<div>';
echo '<table class="noborder centpercent">';
echo '<thead>';
echo '<tr class="liste_titre"><th>' . $langs->trans('Parameter') . '</th><th>' . $langs->trans('Value') . '</th></tr>';
echo '</thead>';
echo '<tbody>';
$key = 'CREATE_NEW_VAT_WITHOUT_AUTO_PAYMENT';
echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
echo '</tbody>';
echo '</table>';
echo '</div>';
if (!empty($conf->accounting->enabled))

View File

@ -43,7 +43,11 @@ $id = GETPOST("id", 'int');
$action = GETPOST("action", "alpha");
$confirm = GETPOST('confirm');
$refund = GETPOST("refund", "int");
$auto_create_payment = GETPOST("auto_create_paiement", "int");
if (GETPOSTISSET('auto_create_paiement') || $action === 'add') {
$auto_create_payment = GETPOST("auto_create_paiement", "int");
} else {
$auto_create_payment = empty($conf->global->CREATE_NEW_VAT_WITHOUT_AUTO_PAYMENT);
}
if (empty($refund)) $refund = 0;
@ -377,17 +381,10 @@ if ($action == 'create')
if (!empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
$("#radiopayment").click(function() {
$("#label").val($(this).data("label"));
});
$("#radiorefund").click(function() {
$("#label").val($(this).data("label"));
});
$("#auto_create_paiement").click(function() {
if($(this).is(":checked")) {
print /** @lang JavaScript */'
$(document).ready(function () {
let onAutoCreatePaiementChange = function () {
if($("#auto_create_paiement").is(":checked")) {
$("#label_fk_account").addClass("fieldrequired");
$("#label_type_payment").addClass("fieldrequired");
$(".hide_if_no_auto_create_payment").show();
@ -396,21 +393,21 @@ if ($action == 'create')
$("#label_type_payment").removeClass("fieldrequired");
$(".hide_if_no_auto_create_payment").hide();
}
});';
};
$("#radiopayment").click(function() {
$("#label").val($(this).data("label"));
});
$("#radiorefund").click(function() {
$("#label").val($(this).data("label"));
if ($_REQUEST['action'] === 'add') { // form has been send but there is at least one error
if (empty($auto_create_payment)) {
print '$("#label_fk_account").removeClass("fieldrequired");
$("#label_type_payment").removeClass("fieldrequired");
$(".hide_if_no_auto_create_payment").hide();';
} else {
print '$("#label_fk_account").addClass("fieldrequired");
$("#label_type_payment").addClass("fieldrequired");
$(".hide_if_no_auto_create_payment").show();';
}
}
});
$("#auto_create_paiement").click(function () {
onAutoCreatePaiementChange();
});
onAutoCreatePaiementChange();
});
';
print '});';
print '</script>'."\n";
}
@ -475,7 +472,7 @@ if ($action == 'create')
// Auto create payment
print '<tr><td>'.$langs->trans('AutomaticCreationPayment').'</td>';
print '<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" '.($_REQUEST['action'] === 'add' ? (empty($auto_create_payment) ? '' : 'checked="checked"') : 'checked="checked"').' value="1"></td></tr>'."\n";
print '<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_payment) ? '' : 'checked="checked"') . ' value="1"></td></tr>'."\n";
// Number
print '<tr class="hide_if_no_auto_create_payment"><td>'.$langs->trans('Numero');

View File

@ -1742,6 +1742,7 @@ YourCompanyDoesNotUseVAT=Your company has been defined to not use VAT (Home - Se
AccountancyCode=Accounting Code
AccountancyCodeSell=Sale account. code
AccountancyCodeBuy=Purchase account. code
CREATE_NEW_VAT_WITHOUT_AUTO_PAYMENT=By default, leave the checkbox “Automatically create a total payment” empty when creating a new tax object
##### Agenda #####
AgendaSetup=Events and agenda module setup
PasswordTogetVCalExport=Key to authorize export link