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 '
'; - 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 ''; - print ''.$langs->trans('TotalTTC').':'; + print ''.$langs->trans('TotalTTC').':'; print ''.price($total_ttc).''; print ''.price($totalrecu).''; print ''.price($total_ttc - $totalrecu).'';