From 7986c95ce3dc1c9e664bf5316f16f385c97a3fdb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jan 2014 00:25:42 +0100 Subject: [PATCH] Fix: Error management when deleting a payment on supplier invoice. --- htdocs/fourn/class/paiementfourn.class.php | 7 +++++-- htdocs/fourn/facture/fiche.php | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index a2a1d3a79f9..380a16bd129 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -305,8 +305,11 @@ class PaiementFourn extends Paiement if ($bank_line_id) { $accline = new AccountLine($this->db); - $accline->fetch($bank_line_id); - $result=$accline->delete(); + $result=$accline->fetch($bank_line_id); + if ($result > 0) // If result = 0, record not found, we don't try to delete + { + $result=$accline->delete(); + } if ($result < 0) { $this->error=$accline->error; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 21883b8ede6..06c8d9d590d 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -253,14 +253,14 @@ elseif ($action == 'setnote_private' && $user->rights->fournisseur->facture->cre } // Delete payment -elseif ($action == 'deletepaiement') +elseif ($action == 'deletepaiement' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); - if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0) + if ($object->statut == 1 && $object->paye == 0) { - $paiementfourn = new PaiementFourn($db); - $paiementfourn->fetch(GETPOST('paiement_id')); - $result=$paiementfourn->delete(); + $paiementfourn = new PaiementFourn($db); + $result=$paiementfourn->fetch(GETPOST('paiement_id')); + if ($result > 0) $result=$paiementfourn->delete(); // If fetch ok and found if ($result < 0) $mesg='
'.$paiementfourn->error.'
'; } } @@ -1631,7 +1631,7 @@ else $bankaccountstatic->ref=$objp->ref; $bankaccountstatic->label=$objp->ref; print ''; - print $bankaccountstatic->getNomUrl(1,'transactions'); + if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1,'transactions'); print ''; } print ''.price($objp->amount).'';