diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 59ef610588af0e4906e75e78a5f22f5a74195ec0..6a942f67f5fef2d89f067d9f06d0297d505fa9a4 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 b34a9b2fbb5b754309fd25e84493882c1fb12bc3..0ff94262eca1aba2e774d5830a09d366d68d5b39 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 903ad786d5c557a867262b6f0846575cd361fcef..f061b6315354e215aca850a30315638ae1b35790 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>';