From e2c50daf112b673443e7f12e039d819964e793b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sat, 11 Nov 2006 14:46:30 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Corrige=20quelques=20probl=E8mes=20avec?= =?UTF-8?q?=20factures=20de=20remplacement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/facture.php | 24 +++++++++++++++++++++--- htdocs/facture.class.php | 2 +- htdocs/langs/en_US/bills.lang | 3 ++- htdocs/langs/fr_FR/bills.lang | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c2dae06ad21..524c58e656c 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 e5f6e310a1e..c3147eaf43f 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 9d725bfacbb..654f9c836c7 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 d927efc9c9e..11dca0f602e 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 -- GitLab