diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index 5031a78b4de..99714c1f124 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -521,11 +521,11 @@ if ($id > 0 || $ref) {
print '
';
if ($obj->statut == 3) {
- print ''.$langs->trans("StatusRefused").'';
+ print ''.$langs->trans("StatusRefused").'';
} else {
if ($object->statut == BonPrelevement::STATUS_CREDITED) {
- if ($obj->statut == 2) {
- if ($user->rights->prelevement->bons->credit) {
+ if ($obj->statut == LignePrelevement::STATUS_CREDITED) {
+ if ($user->hasRight('prelevement', 'bons', 'credit')) {
//print ''.$langs->trans("StandingOrderReject").'';
print ''.$langs->trans("StandingOrderReject").'';
} else {
diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php
index 9faafb99d84..71194ef4020 100644
--- a/htdocs/compta/prelevement/class/ligneprelevement.class.php
+++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php
@@ -43,6 +43,12 @@ class LignePrelevement
public $statuts = array();
+ const STATUS_DRAFT = 0;
+ const STATUS_NOT_USED = 1;
+ const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
+ const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
+ const STATUS_REJECTED = 3;
+
/**
* Constructor
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index c539a3893a7..2464aee5b48 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
+$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals', 'suppliers'));
// Get supervariables
$id = GETPOST('id', 'int');
@@ -231,7 +231,7 @@ if ($object->type != 'bank-transfer') {
if ($object->id > 0) {
$sql .= " AND p.rowid = ".((int) $object->id);
}
-if ($socid) {
+if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid);
}
$sql .= $db->order($sortfield, $sortorder);
@@ -312,17 +312,17 @@ if ($resql) {
print ' | ';
- print "| ";
+ print ' | ';
print $invoicetmp->getNomUrl(1);
print " | \n";
if ($object->type == 'bank-transfer') {
- print '';
+ print ' | ';
print dol_escape_htmltag($invoicetmp->ref_supplier);
print " | \n";
}
- print '';
+ print ' | ';
print $thirdpartytmp->getNomUrl(1);
print " | \n";
@@ -344,7 +344,7 @@ if ($resql) {
print $langs->trans("StatusCredited");
}
} elseif ($obj->statut == 3) {
- print ''.$langs->trans("StatusRefused").'';
+ print ''.$langs->trans("StatusRefused").'';
}
print "";
diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php
index 9e88362f7e0..8c4fe1f660f 100644
--- a/htdocs/compta/prelevement/fiche-rejet.php
+++ b/htdocs/compta/prelevement/fiche-rejet.php
@@ -28,6 +28,9 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
@@ -84,6 +87,12 @@ if ($type == 'bank-transfer') {
$form = new Form($db);
+$thirdpartystatic = new Societe($db);
+$invoicestatic = new Facture($db);
+$invoicesupplierstatic = new FactureFournisseur($db);
+$rej = new RejetPrelevement($db, $user, $type);
+
+
llxHeader('', $langs->trans("WithdrawalsReceipts"));
if ($id > 0 || $ref) {
@@ -194,11 +203,8 @@ if ($id > 0 || $ref) {
}
-$rej = new RejetPrelevement($db, $user, $type);
+// List errors
-/*
- * List errors
- */
$sql = "SELECT pl.rowid, pl.amount, pl.statut";
$sql .= " , s.rowid as socid, s.nom as name";
$sql .= " , pr.motif, pr.afacturer, pr.fk_facture";
@@ -208,7 +214,7 @@ $sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
$sql .= " WHERE p.rowid=".((int) $object->id);
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
-$sql .= " AND p.entity = ".$conf->entity;
+$sql .= " AND p.entity IN (".getEntity('facture').")";
$sql .= " AND pl.fk_soc = s.rowid";
$sql .= " AND pl.statut = 3 ";
$sql .= " AND pr.fk_prelevement_lignes = pl.rowid";
@@ -234,14 +240,19 @@ $resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
- print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
+ print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
print"\n\n";
print ''; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '
';
print '';
print '| '.$langs->trans("Line").' | '.$langs->trans("ThirdParty").' | '.$langs->trans("Amount").' | ';
- print ''.$langs->trans("Reason").' | '.$langs->trans("ToBill").' | '.$langs->trans("Invoice").' |
';
+ print ''.$langs->trans("Reason").' | '.$langs->trans("ToBill").' | ';
+ print '';
+ // Invoice to charge the error. No yet implemented.
+ //print $langs->trans("Invoice");
+ print ' | ';
+ print '';
$total = 0;
@@ -250,19 +261,39 @@ if ($resql) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
- print '| ';
+ $thirdpartystatic->id = $obj->socid;
+ $thirdpartystatic->name = $obj->name;
+ if ($obj->fk_facture > 0) {
+ $invoicestatic->fetch($obj->fk_facture);
+ }
+
+ print ' |
';
+ print '| ';
print '';
print img_picto('', 'statut'.$obj->statut).' ';
print substr('000000'.$obj->rowid, -6);
print ' | ';
- print ''.$obj->name." | \n";
+ print '';
+ if ($type != 'bank-transfer') {
+ print $thirdpartystatic->getNomUrl(1, 'customer');
+ } else {
+ print $thirdpartystatic->getNomUrl(1, 'supplier');
+ }
+ print ' | '."\n";
print ''.price($obj->amount)." | \n";
- print ''.$rej->motifs[$obj->motif].' | ';
+ print ''.dol_escape_htmltag($rej->motifs[$obj->motif]).' | ';
print ''.yn($obj->afacturer).' | ';
- print ''.$obj->fk_facture.' | ';
+
+ // Invoice used to charge the error
+ print '';
+ if ($obj->fk_facture > 0) {
+ print $invoicestatic->getNomUrl(1);
+ }
+ print ' | ';
+
print "
\n";
$total += $obj->amount;
diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php
index f1939913c12..e584805d0bd 100644
--- a/htdocs/compta/prelevement/line.php
+++ b/htdocs/compta/prelevement/line.php
@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
-$langs->loadlangs(array('banks', 'categories', 'bills', 'withdrawals'));
+$langs->loadlangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
// Get supervariables
$action = GETPOST('action', 'aZ09');
@@ -69,12 +69,20 @@ if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
}
+if ($type == 'bank-transfer') {
+ $permissiontoadd = $user->hasRight('paymentbybanktransfer', 'create');
+} else {
+ $permissiontoadd = $user->hasRight('prelevement', 'bons', 'creer');
+}
+
+$error = 0;
+
/*
* Actions
*/
-if ($action == 'confirm_rejet') {
+if ($action == 'confirm_rejet' && $permissiontoadd) {
if (GETPOST("confirm") == 'yes') {
if (GETPOST('remonth', 'int')) {
$daterej = mktime(2, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
@@ -119,6 +127,8 @@ if ($action == 'confirm_rejet') {
* View
*/
+$form = new Form($db);
+
if ($type == 'bank-transfer') {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$invoicestatic = new FactureFournisseur($db);
@@ -137,7 +147,7 @@ llxHeader('', $title);
$head = array();
$h = 0;
-$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id.'&type='.$type;
+$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.((int) $id).'&type='.urlencode($type);
$head[$h][1] = $title;
$hselected = $h;
$h++;
@@ -149,7 +159,7 @@ if ($id) {
$bon = new BonPrelevement($db);
$bon->fetch($lipre->bon_rowid);
- print dol_get_fiche_head($head, $hselected, $title);
+ print dol_get_fiche_head($head, $hselected, $title, -1, 'payment');
print '';
@@ -193,8 +203,6 @@ if ($id) {
}
if ($action == 'rejet' && $user->rights->prelevement->bons->credit) {
- $form = new Form($db);
-
$soc = new Societe($db);
$soc->fetch($lipre->socid);
@@ -304,7 +312,9 @@ if ($id) {
print"\n\n";
print '';
print '';
- print '| '.$langs->trans("Invoice").' | '.$langs->trans("ThirdParty").' | '.$langs->trans("Amount").' | '.$langs->trans("Status").' | ';
+ print ''.$langs->trans("Invoice").' | ';
+ print ''.$langs->trans("ThirdParty").' | ';
+ print ''.$langs->trans("Amount").' | '.$langs->trans("Status").' | ';
print '
';
$total = 0;