Merge pull request #17396 from atm-gauthier/fix_disable_delete_if_payments
FIX : We must not be able to delete sociale charge, vat or salary if there are payments
This commit is contained in:
commit
fde4beb3b6
@ -134,12 +134,17 @@ if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
|
||||
// Delete social contribution
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') {
|
||||
$object->fetch($id);
|
||||
$result = $object->delete($user);
|
||||
if ($result > 0) {
|
||||
header("Location: list.php");
|
||||
exit;
|
||||
$totalpaye = $object->getSommePaiement();
|
||||
if (empty($totalpaye)) {
|
||||
$result = $object->delete($user);
|
||||
if ($result > 0) {
|
||||
header("Location: list.php");
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -771,8 +776,10 @@ if ($id > 0) {
|
||||
}
|
||||
|
||||
// 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>';
|
||||
} 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>";
|
||||
|
||||
@ -589,7 +589,7 @@ class Salary extends CommonObject
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author';
|
||||
$sql = 'SELECT ps.rowid, ps.datec, ps.tms, ps.fk_user_author, ps.fk_user_modif';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'salary as ps';
|
||||
$sql .= ' WHERE ps.rowid = '.((int) $id);
|
||||
|
||||
@ -605,7 +605,14 @@ class Salary extends CommonObject
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_modif) {
|
||||
$muser = new User($this->db);
|
||||
$muser->fetch($obj->fk_user_modif);
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = $this->db->jdate($obj->tms);
|
||||
}
|
||||
$this->db->free($result);
|
||||
} else {
|
||||
|
||||
@ -195,7 +195,6 @@ if ($resql) {
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Salary').'</td>';
|
||||
print '<td>'.$langs->trans('Type').'</td>';
|
||||
print '<td>'.$langs->trans('Label').'</td>';
|
||||
print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
|
||||
print '<td class="center">'.$langs->trans('Status').'</td>';
|
||||
@ -212,11 +211,6 @@ if ($resql) {
|
||||
$salary->fetch($objp->scid);
|
||||
print $salary->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
// Type
|
||||
print '<td>';
|
||||
print $salary->type_label;
|
||||
/*print $salary->type;*/
|
||||
print "</td>\n";
|
||||
// Label
|
||||
print '<td>'.$objp->label.'</td>';
|
||||
// Expected to pay
|
||||
|
||||
Loading…
Reference in New Issue
Block a user