diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 8268fc40670..dc9771b6ca9 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -788,6 +788,24 @@ if (empty($reshook))
}
}
+ // Delete payment
+ elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $user->rights->facture->creer)
+ {
+ $object->fetch($id);
+ if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0)
+ {
+ $paiement = new Paiement($db);
+ $result=$paiement->fetch(GETPOST('paiement_id'));
+ if ($result > 0) {
+ $result=$paiement->delete(); // If fetch ok and found
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
+ }
+ if ($result < 0) {
+ setEventMessages($paiement->error, $paiement->errors, 'errors');
+ }
+ }
+ }
+
/*
* Insert new invoice in database
*/
@@ -3148,6 +3166,13 @@ else if ($id > 0 || ! empty($ref))
}
}
+ if ($action == 'deletepaiement')
+ {
+ $payment_id = GETPOST('paiement_id');
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&paiement_id='.$payment_id, $langs->trans('DeletePayment'), $langs->trans('ConfirmDeletePayment'), 'confirm_delete_paiement', '', 0, 1);
+
+ }
+
// Confirmation de la suppression d'une ligne produit
if ($action == 'ask_deleteline') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
@@ -3791,6 +3816,7 @@ else if ($id > 0 || ! empty($ref))
// List of payments already done
+
print '
';
print '
';
@@ -3862,7 +3888,15 @@ else if ($id > 0 || ! empty($ref))
print '';
}
print '| ' . price($sign * $objp->amount) . ' | ';
- print ' | ';
+ // TODO Add link to delete payment
+ print '';
+ if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
+ {
+ print 'id.'&action=deletepaiement&paiement_id='.$objp->rowid.'">';
+ print img_delete();
+ print '';
+ }
+ print ' | ';
print '';
$i ++;
}
diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index da38e9fb47a..3ec17c2521d 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -42,6 +42,7 @@ $id=GETPOST('id','int');
$ref=GETPOST('ref', 'alpha');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
+$backtopage=GETPOST('backtopage','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@@ -82,8 +83,17 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->
if ($result > 0)
{
$db->commit();
- header("Location: list.php");
- exit;
+
+ if ($backtopage)
+ {
+ header("Location: ".$backtopage);
+ exit;
+ }
+ else
+ {
+ header("Location: list.php");
+ exit;
+ }
}
else
{
@@ -263,7 +273,7 @@ if (! empty($conf->banque->enabled))
print '';
print '';
- if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0)
+ if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0)
{
dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php');
$bordereau = new RemiseCheque($db);
@@ -303,14 +313,14 @@ if ($resql)
$i = 0;
$total = 0;
-
+
$moreforfilter='';
-
+
print '
';
-
+
print '';
print '
';
-
+
print '';
print '| '.$langs->trans('Bill').' | ';
print ''.$langs->trans('Company').' | ';
@@ -327,7 +337,7 @@ if ($resql)
while ($i < $num)
{
$objp = $db->fetch_object($resql);
-
+
print '
';
$invoice=new Facture($db);
@@ -372,11 +382,11 @@ if ($resql)
$i++;
}
}
-
+
print "
\n";
print '
';
-
+
$db->free($resql);
}
else
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 312fc4b5acc..595c9e868dc 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -148,8 +148,7 @@ else
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
}
- $sql.= " WHERE ";
- $sql.= " AND p.entity IN (" . getEntity('facture') . ")";
+ $sql.= " WHERE p.entity IN (" . getEntity('facture') . ")";
if (! $user->rights->societe->client->voir && ! $socid)
{
$sql.= " AND sc.fk_user = " .$user->id;