Skip to content

Commit

Permalink
Delete of payment
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 3, 2017
1 parent 9f1eba6 commit 11286de
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 13 deletions.
36 changes: 35 additions & 1 deletion htdocs/compta/facture/card.php
Expand Up @@ -788,6 +788,24 @@
}
}

// 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
*/
Expand Down Expand Up @@ -3148,6 +3166,13 @@
}
}

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);
Expand Down Expand Up @@ -3791,6 +3816,7 @@


// List of payments already done

print '<div class="div-table-responsive-no-min">';
print '<table class="noborder paymenttable" width="100%">';

Expand Down Expand Up @@ -3862,7 +3888,15 @@
print '</td>';
}
print '<td align="right">' . price($sign * $objp->amount) . '</td>';
print '<td>&nbsp;</td>';
// TODO Add link to delete payment
print '<td align="center">';
if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deletepaiement&paiement_id='.$objp->rowid.'">';
print img_delete();
print '</a>';
}
print '</td>';
print '</tr>';
$i ++;
}
Expand Down
30 changes: 20 additions & 10 deletions htdocs/compta/paiement/card.php
Expand Up @@ -42,6 +42,7 @@
$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;
Expand Down Expand Up @@ -82,8 +83,17 @@
if ($result > 0)
{
$db->commit();
header("Location: list.php");
exit;

if ($backtopage)
{
header("Location: ".$backtopage);
exit;
}
else
{
header("Location: list.php");
exit;
}
}
else
{
Expand Down Expand Up @@ -263,7 +273,7 @@
print '</td>';
print '</tr>';

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);
Expand Down Expand Up @@ -303,14 +313,14 @@

$i = 0;
$total = 0;

$moreforfilter='';

print '<br>';

print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">';

print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Bill').'</td>';
print '<td>'.$langs->trans('Company').'</td>';
Expand All @@ -327,7 +337,7 @@
while ($i < $num)
{
$objp = $db->fetch_object($resql);

print '<tr class="oddeven">';

$invoice=new Facture($db);
Expand Down Expand Up @@ -372,11 +382,11 @@
$i++;
}
}


print "</table>\n";
print '</div>';

$db->free($resql);
}
else
Expand Down
3 changes: 1 addition & 2 deletions htdocs/compta/paiement/list.php
Expand Up @@ -148,8 +148,7 @@
{
$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;
Expand Down

0 comments on commit 11286de

Please sign in to comment.