From 4b08d2d540177864deba60696d10bacd8bcc4c4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Thu, 6 Mar 2008 11:46:00 +0000 Subject: [PATCH] Edit is forbidden if a payment has already be done --- htdocs/facture.class.php | 11 +++++++++-- htdocs/fourn/facture/fiche.php | 3 +-- htdocs/fourn/facture/paiement.php | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 59ef610588a..6a942f67f5f 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1725,11 +1725,18 @@ class Facture extends CommonObject function getSommePaiement() { $table='paiement_facture'; - if ($element == 'facture_fourn') $table='paiementfourn_facturefourn'; + $field='fk_facture'; + if ($this->element == 'facture_fourn') + { + $table='paiementfourn_facturefourn'; + $field='fk_facturefourn'; + } $sql = 'SELECT sum(amount) as amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.$table; - $sql.= ' WHERE fk_facture = '.$this->id; + $sql.= ' WHERE '.$field.' = '.$this->id; + + dolibarr_syslog("Facture::getSommePaiement sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index b34a9b2fbb5..0ff94262eca 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -849,10 +849,9 @@ else /* * Boutons actions */ - print '<div class="tabsAction">'; - if ($fac->statut <= 1 && $user->rights->fournisseur->facture->creer) + if ($fac->statut <= 1 && $fac->getSommePaiement() <= 0 && $user->rights->fournisseur->facture->creer) { if ($_GET['action'] != 'edit') { diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 903ad786d5c..f061b631535 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -319,7 +319,7 @@ if ($action == 'create' || $action == 'add_paiement') { // Print total print '<tr class="liste_total">'; - print '<td colspan="2" align="left">'.$langs->trans('TotalTTC').':</td>'; + print '<td colspan="3" align="left">'.$langs->trans('TotalTTC').':</td>'; print '<td align="right"><b>'.price($total_ttc).'</b></td>'; print '<td align="right"><b>'.price($totalrecu).'</b></td>'; print '<td align="right"><b>'.price($total_ttc - $totalrecu).'</b></td>'; -- GitLab