Merge branch 'NEW/12.0_new_payments_on_salaries' of github.com:ATM-Consulting/dolibarr into NEW/add_real_payments_on_salaries

This commit is contained in:
Gauthier PC portable 024 2021-03-03 14:35:38 +01:00
commit 845b1c6c94
4 changed files with 52 additions and 43 deletions

View File

@ -2,6 +2,7 @@
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Accounting account used for user third parties
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accounting account on user is not defined. SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=The dedicated accounting account defined on user card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated user accounting account on user is not defined.
SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage payments SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Accounting account by default for wage payments
CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT=By default, leave empty the option "Automatically create a total payment" when creating a Salary
Salary=Salary Salary=Salary
Salaries=Salaries Salaries=Salaries
NewSalaryPayment=New salary card NewSalaryPayment=New salary card

View File

@ -2,6 +2,7 @@
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Compte comptable utilisé pour les utilisateurs SALARIES_ACCOUNTING_ACCOUNT_PAYMENT=Compte comptable utilisé pour les utilisateurs
SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=Le compte comptable défini sur la fiche utilisateur sera utilisé uniquement pour la comptabilité auxiliaire. Celui-ci sera utilisé pour le grand livre et comme valeur par défaut de la comptabilité auxiliaire si le compte dédié de l'utilisateur n'est pas défini. SALARIES_ACCOUNTING_ACCOUNT_PAYMENT_Desc=Le compte comptable défini sur la fiche utilisateur sera utilisé uniquement pour la comptabilité auxiliaire. Celui-ci sera utilisé pour le grand livre et comme valeur par défaut de la comptabilité auxiliaire si le compte dédié de l'utilisateur n'est pas défini.
SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Compte comptable par défaut pour les paiements de salaires SALARIES_ACCOUNTING_ACCOUNT_CHARGE=Compte comptable par défaut pour les paiements de salaires
CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT=Par défaut, laisser vide l’option « Créer automatiquement un règlement total » lors de la création d'un Salaire
Salary=Salaire Salary=Salaire
Salaries=Salaires Salaries=Salaires
NewSalaryPayment=Nouveau règlement de salaire NewSalaryPayment=Nouveau règlement de salaire

View File

@ -68,6 +68,13 @@ if ($action == 'update') {
} }
} }
// 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);
}
}
/* /*
* View * View
*/ */
@ -121,6 +128,9 @@ foreach ($list as $key) {
print '</tr>'; print '</tr>';
$key = 'CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT';
echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
print "</table>\n"; print "</table>\n";
//print dol_get_fiche_end(); //print dol_get_fiche_end();
@ -129,6 +139,8 @@ print '<div class="center"><input type="submit" class="button" value="'.$langs->
print '</form>'; print '</form>';
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();

81
htdocs/salaries/card.php Normal file → Executable file
View File

@ -49,7 +49,11 @@ $cancel = GETPOST('cancel', 'aZ09');
$accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0; $accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0;
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
$confirm = GETPOST('confirm'); $confirm = GETPOST('confirm');
$auto_create_paiement = GETPOST("auto_create_paiement", "int"); if (GETPOSTISSET('auto_create_paiement') || $action === 'add') {
$auto_create_paiement = GETPOST("auto_create_paiement", "int");
} else {
$auto_create_paiement = empty($conf->global->CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT);
}
$datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int'));
$datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int'));
@ -395,15 +399,10 @@ if ($action == 'create') {
if (!empty($conf->use_javascript_ajax)) { if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () { print /** @lang JavaScript */'
$("#radiopayment").click(function() { $(document).ready(function () {
$("#label").val($(this).data("label")); let onAutoCreatePaiementChange = function () {
}); if($("#auto_create_paiement").is(":checked")) {
$("#radiorefund").click(function() {
$("#label").val($(this).data("label"));
});
$("#auto_create_paiement").click(function() {
if($(this).is(":checked")) {
$("#label_fk_account").find("span").addClass("fieldrequired"); $("#label_fk_account").find("span").addClass("fieldrequired");
$("#label_type_payment").find("span").addClass("fieldrequired"); $("#label_type_payment").find("span").addClass("fieldrequired");
$(".hide_if_no_auto_create_payment").show(); $(".hide_if_no_auto_create_payment").show();
@ -412,21 +411,19 @@ if ($action == 'create') {
$("#label_type_payment").find("span").removeClass("fieldrequired"); $("#label_type_payment").find("span").removeClass("fieldrequired");
$(".hide_if_no_auto_create_payment").hide(); $(".hide_if_no_auto_create_payment").hide();
} }
});'; };
$("#radiopayment").click(function() {
if ($_REQUEST['action'] === 'add') { // form has been send but there is at least one error $("#label").val($(this).data("label"));
if (empty($auto_create_paiement)) { });
print '$("#label_fk_account").find("span").removeClass("fieldrequired"); $("#radiorefund").click(function() {
$("#label_type_payment").find("span").removeClass("fieldrequired"); $("#label").val($(this).data("label"));
$(".hide_if_no_auto_create_payment").hide();'; });
} else { $("#auto_create_paiement").click(function () {
print '$("#label_fk_account").find("span").addClass("fieldrequired"); onAutoCreatePaiementChange();
$("#label_type_payment").find("span").addClass("fieldrequired"); });
$(".hide_if_no_auto_create_payment").show();'; onAutoCreatePaiementChange();
} });
} ';
print '});';
print '</script>'."\n"; print '</script>'."\n";
} }
@ -490,7 +487,7 @@ if ($action == 'create') {
// Auto create payment // Auto create payment
print '<tr><td>'.$langs->trans('AutomaticCreationPayment').'</td>'; 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_paiement) ? '' : '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_paiement) ? '' : 'checked="checked"') . ' value="1"></td></tr>'."\n"; // Date payment
// Date payment // Date payment
print '<tr class="hide_if_no_auto_create_payment"><td>'; print '<tr class="hide_if_no_auto_create_payment"><td>';
@ -590,10 +587,24 @@ if ($id) {
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
// Label
if ($action != 'editlabel') {
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
$morehtmlref .= $object->label;
} else {
$morehtmlref .= '<br>'.$langs->trans('Label').' :&nbsp;';
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
}
// Employee // Employee
$userstatic = new User($db); $userstatic = new User($db);
$userstatic->fetch($object->fk_user); $userstatic->fetch($object->fk_user);
$morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1); $morehtmlref .= '<br>' .$langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
// Project // Project
if (!empty($conf->projet->enabled)) { if (!empty($conf->projet->enabled)) {
@ -626,22 +637,6 @@ if ($id) {
} }
} }
// Label
if ($action != 'editlabel') {
$morehtmlref .= '<br>' . $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
$morehtmlref .= $object->label;
} else {
$morehtmlref .= '<br>'.$langs->trans('Label').' :&nbsp;';
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
}
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
$totalpaye = $object->getSommePaiement(); $totalpaye = $object->getSommePaiement();