Edit is forbidden if a payment has already be done

This commit is contained in:
Laurent Destailleur 2008-03-06 11:46:00 +00:00
parent a6210bfe78
commit 4b08d2d540
3 changed files with 11 additions and 5 deletions

View File

@ -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)
{

View File

@ -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')
{

View File

@ -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>';