FIX If the replacement invoice has been deleted we can reopen
This commit is contained in:
parent
be695a8e1a
commit
d69b20311b
@ -181,7 +181,8 @@ if (empty($reshook))
|
|||||||
// Change status of invoice
|
// Change status of invoice
|
||||||
else if ($action == 'reopen' && $usercancreate) {
|
else if ($action == 'reopen' && $usercancreate) {
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced') || ($object->statut == 1 && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted
|
|
||||||
|
if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted
|
||||||
$result = $object->set_unpaid($user);
|
$result = $object->set_unpaid($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id);
|
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id);
|
||||||
@ -4690,7 +4691,7 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
&& ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
|
&& ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
|
||||||
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) // A paid invoice (partially or completely)
|
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) // A paid invoice (partially or completely)
|
||||||
{
|
{
|
||||||
if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
|
if ($object->close_code != 'replaced' || (! $objectidnext)) // Not replaced by another invoice or replaced but the replacement invoice has been deleted
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&action=reopen">' . $langs->trans('ReOpen') . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&action=reopen">' . $langs->trans('ReOpen') . '</a></div>';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user