Merge pull request #4371 from frederic34/patch-7

Always show remove button and why we can't remove
This commit is contained in:
Laurent Destailleur 2016-01-10 11:37:56 +01:00
commit c07cb5a72e
3 changed files with 25 additions and 6 deletions

View File

@ -226,6 +226,7 @@ print '<tr><td class="tdtop">'.$form->editfieldkey("Note",'note',$object->note,$
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->facture->paiement,'textarea');
print '</td></tr>';
$disable_delete = 0;
// Bank account
if (! empty($conf->banque->enabled))
{
@ -233,6 +234,11 @@ if (! empty($conf->banque->enabled))
{
$bankline=new AccountLine($db);
$bankline->fetch($object->bank_line);
if ($bankline->rappro)
{
$disable_delete = 1;
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
}
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
@ -274,7 +280,6 @@ print '</table>';
* List of invoices
*/
$disable_delete = 0;
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.total_ttc, f.paye, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
$sql.= ' WHERE pf.fk_facture = f.rowid';
@ -344,6 +349,7 @@ if ($resql)
if ($objp->paye == 1) // If at least one invoice is paid, disable delete
{
$disable_delete = 1;
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemovePaymentWithOneInvoicePaid"));
}
$total = $total + $objp->amount;
$i++;
@ -389,7 +395,7 @@ if ($user->societe_id == 0 && $action == '')
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
print '<a class="butActionRefused" href="#" title="'.$title_button.'">'.$langs->trans('Delete').'</a>';
}
}
}

View File

@ -202,6 +202,7 @@ if ($result > 0)
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer,'textarea');
print '</td></tr>';
$allow_delete = 1 ;
// Bank account
if (! empty($conf->banque->enabled))
{
@ -209,6 +210,11 @@ if ($result > 0)
{
$bankline=new AccountLine($db);
$bankline->fetch($object->bank_line);
if ($bankline->rappro)
{
$allow_delete=0;
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
}
print '<tr>';
print '<td colspan="2">'.$langs->trans('BankTransactionLine').'</td>';
@ -236,7 +242,6 @@ if ($result > 0)
/**
* Liste des factures
*/
$allow_delete = 1 ;
$sql = 'SELECT f.rowid, f.ref, f.ref_supplier, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom as name, s.rowid as socid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
@ -288,6 +293,7 @@ if ($result > 0)
if ($objp->paye == 1)
{
$allow_delete = 0;
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemovePaymentWithOneInvoicePaid"));
}
$total = $total + $objp->amount;
$i++;
@ -323,12 +329,18 @@ if ($result > 0)
}
}
}
if ($user->societe_id == 0 && $allow_delete && $object->statut == 0 && $action == '')
if ($user->societe_id == 0 && $action == '')
{
if ($user->rights->fournisseur->facture->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
if ($allow_delete)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.$title_button.'">'.$langs->trans('Delete').'</a>';
}
}
}
print '</div>';

View File

@ -396,6 +396,7 @@ Reported=Delayed
DisabledBecausePayments=Not possible since there are some payments
CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least one invoice classified paid
ExpectedToPay=Expected payment
CantRemoveConciliatedPayment=Can't remove conciliated payment
PayedByThisPayment=Paid by this payment
ClosePaidInvoicesAutomatically=Classify "Paid" all standard, situation or replacement invoices entirely paid.
ClosePaidCreditNotesAutomatically=Classify "Paid" all credit notes entirely paid back.