diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c2dae06ad2147c15aac65192f3d3c89fa67459e2..524c58e656c83e59f6058300f72e6ea0e79109aa 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1595,6 +1595,9 @@ else $author->fetch(); } + $facidnext=$fac->getIdReplacingInvoice(); + + $head = facture_prepare_head($fac); dolibarr_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer')); @@ -1673,8 +1676,24 @@ else */ if ($_GET['action'] == 'canceled') { - $html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$fac->ref),'confirm_canceled'); - print '<br />'; + // Si il y a une facture de remplacement pas encore valid�e (etat brouillon), + // on ne permet pas de classer abandonner la facture + if ($facidnext) + { + $facturereplacement=new Facture($db); + $facturereplacement->fetch($facidnext); + $statusreplacement=$facturereplacement->statut; + } + print "x".$statusreplacement; + if ($facidnext && $statusreplacement == 0) + { + print '<div class="error">'.$langs->trans("ErrorCantCancelIfReplacementInvoiceNotValidated").'</div>'; + } + else + { + $html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$fac->ref),'confirm_canceled'); + print '<br />'; + } } /* @@ -1761,7 +1780,6 @@ else } print ')'; } - $facidnext=$fac->getIdReplacingInvoice(); if ($facidnext > 0) { $facthatreplace=new Facture($db); diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index e5f6e310a1e137032ff356bf55c29f20a173815f..c3147eaf43fa2ec20ee5853146ebe3f7810377e2 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1013,7 +1013,7 @@ class Facture extends CommonObject // Controle que facture source non deja remplacee par une autre $idreplacement=$facreplaced->getIdReplacingInvoice(); - if ($idreplacement != $rowid) + if ($idreplacement && $idreplacement != $rowid) { $facreplacement=new Facture($this->db); $facreplacement->fetch($idreplacement); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 9d725bfacbb39fb10351b86eaaa6397168d7e615..654f9c836c78b7143609aa9a05556a30f68d8dae 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -90,10 +90,11 @@ ErrorVATIntraNotConfigured=Intracommunautary VAT number not yet defined ErrorNoPaiementModeConfigured=No paiment mode yet defined ErrorCreateBankAccount=Creat a bank account then go to Setup panel of Invoice module to define paiement modes ErrorBillNotFound=Invoice %s does not exists -ErrorInvoiceAlreadyReplaced=Error, invoice %s has already been replaced by invoice %s +ErrorInvoiceAlreadyReplaced=Error, you try to validate an invoice to replace invoice %s. But this one has already been replaced by invoice %s. ErrorDiscountAlreadyUsed=Error, discount already used ErrorInvoiceAvoirMustBeNegative=Error, correct invoice must have a negative amount ErrorInvoiceOfThisTypeMustBePositive=Error, this type of invoice must have a positive amount +ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice that has been replaced by another invoice that is still in draft status BillFrom=From BillTo=Bill to ActionsOnBill=Actions on invoice diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index d927efc9c9ecf0ccf04d00d3d4145ff16ef7819b..11dca0f602e18891249f569233b84af4d5429d98 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -90,10 +90,11 @@ ErrorVATIntraNotConfigured=Num ErrorNoPaiementModeConfigured=Aucun mode de r�glement d�fini ErrorCreateBankAccount=Cr�er un compte bancaire puis aller dans la configuration du module facture pour d�finir les modes de r�glement ErrorBillNotFound=Facture %s inexistante -ErrorInvoiceAlreadyReplaced=Erreur, la facture %s a d�j� �t� remplac�e par la facture %s +ErrorInvoiceAlreadyReplaced=Erreur, vous voulez valider une facture qui doit remplacer la facture %s. Mais cette derni�re a d�j� �t� remplac�e par une autre facture %s. ErrorDiscountAlreadyUsed=Erreur, la remise a d�j� �t� attribu�e ErrorInvoiceAvoirMustBeNegative=Erreur, une facture de type Avoir doit avoir un montant n�gatif ErrorInvoiceOfThisTypeMustBePositive=Erreur, une facture de ce type doit avoir un montant positif +ErrorCantCancelIfReplacementInvoiceNotValidated=Erreur, il n'est pas possible d'annuler une facture qui a �t� remplac�e par une autre qui se trouve toujours � l'�tat 'brouillon'. BillFrom=�metteur BillTo=Adress� � ActionsOnBill=Actions sur la facture