FIX : We must not be able to delete sociale charge, vat or salary if there are payments
This commit is contained in:
parent
c3d3b79315
commit
ae1586fcc6
@ -134,6 +134,8 @@ if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
|
|||||||
// Delete social contribution
|
// Delete social contribution
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes') {
|
if ($action == 'confirm_delete' && $confirm == 'yes') {
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
|
$totalpaye = $object->getSommePaiement();
|
||||||
|
if (empty($totalpaye)) {
|
||||||
$result = $object->delete($user);
|
$result = $object->delete($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
header("Location: list.php");
|
header("Location: list.php");
|
||||||
@ -141,6 +143,9 @@ if ($action == 'confirm_delete' && $confirm == 'yes') {
|
|||||||
} else {
|
} else {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -771,8 +776,10 @@ if ($id > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if ($user->rights->tax->charges->supprimer) {
|
if ($user->rights->tax->charges->supprimer && empty($totalpaye)) {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
|
||||||
|
} else {
|
||||||
|
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("DisabledBecausePayments"))).'">'.$langs->trans("Delete").'</a></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user