Fix deletion of line on replacement invoice

This commit is contained in:
Laurent Destailleur 2021-07-01 13:36:04 +02:00
parent 5b34ea6c22
commit 9392624e54

View File

@ -315,6 +315,15 @@ if ($outputalsopricetotalwithtax) {
}
if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines') {
$situationinvoicelinewithparent = 0;
if ($line->fk_prev_id != null && in_array($object->element, array('facture', 'facturedet'))) {
if ($object->type == $object::TYPE_SITUATION) { // The constant TYPE_SITUATION exists only for object invoice
// Set constant to disallow editing during a situation cycle
$situationinvoicelinewithparent = 1;
}
}
print '<td class="linecoledit center">';
$coldisplay++;
if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
@ -326,7 +335,7 @@ if ($this->statut == 0 && ($object_rights->creer) && $action != 'selectlines') {
print '<td class="linecoldelete center">';
$coldisplay++;
if (($line->fk_prev_id == null) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation
if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company.
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=ask_deleteline&amp;lineid='.$line->id.'">';
print img_delete();
print '</a>';