diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index c82678cdfe6..93a04a4f809 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -450,12 +450,12 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer)
$mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
';
}
- if (! $_POST['fac_replacement'] > 0)
+ if (! ($_POST['fac_replacement'] > 0))
{
$error=1;
$mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("ReplaceInvoice")).'
';
}
-
+
if (! $error)
{
// Si facture remplacement
@@ -2792,16 +2792,33 @@ else
if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier
&& ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0))
{
- print ''.$langs->trans('Modify').'';
+ if (! $facidnext)
+ {
+ print ''.$langs->trans('Modify').'';
+ }
+ else
+ {
+ print ''.$langs->trans('Modify').'';
+ }
}
}
// Reopen a classified invoice
- if ($fac->statut == 3 && ($fac->close_code == 'badcustomer' || $fac->close_code == 'abandon'))
+ if ($fac->statut == 3 && // A abandonned invoice
+ $fac->getIdReplacingInvoice() == 0 && // Not replaced by another invoice
+ ($fac->close_code == 'badcustomer' || $fac->close_code == 'abandon'))
{
- print ''.$langs->trans('ReOpen').'';
+ if (! $facidnext)
+ {
+ print ''.$langs->trans('ReOpen').'';
+ }
+ else
+ {
+ print ''.$langs->trans('ReOpen').'';
+ }
}
- // Récurrente
+
+ // Récurrente
if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0)
{
if (! $facidnext)
@@ -2844,7 +2861,7 @@ else
{
if ($facidnext)
{
- print ''.$langs->trans('SendByMail').'';
+ print ''.$langs->trans('SendByMail').'';
}
else
{
@@ -2857,7 +2874,7 @@ else
{
if ($facidnext)
{
- print ''.$langs->trans('SendRemindByMail').'';
+ print ''.$langs->trans('SendRemindByMail').'';
}
else
{
@@ -2870,13 +2887,13 @@ else
{
if ($facidnext)
{
- print ''.$langs->trans('DoPayment').'';
+ print ''.$langs->trans('DoPayment').'';
}
else
{
if ($resteapayer == 0)
{
- print ''.$langs->trans('DoPayment').'';
+ print ''.$langs->trans('DoPayment').'';
}
else
{
@@ -2919,7 +2936,7 @@ else
{
if ($facidnext)
{
- print ''.$langs->trans('ClassifyCanceled').'';
+ print ''.$langs->trans('ClassifyCanceled').'';
}
else
{
@@ -2933,7 +2950,7 @@ else
{
if ($facidnext)
{
- print ''.$langs->trans('Delete').'';
+ print ''.$langs->trans('Delete').'';
}
else
{
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index d697f8a0876..87054929e8b 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -1724,7 +1724,7 @@ class Facture extends CommonObject
/**
* \brief Renvoie l'id de la facture qui la remplace
* \param option filtre sur statut ('', 'validated', ...)
- * \return int <0 si ko, 0 si aucune facture ne remplace, id facture sinon
+ * \return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon
*/
function getIdReplacingInvoice($option='')
{