dolibarr/htdocs/compta/prelevement/rejets.php

159 lines
4.8 KiB
PHP
Raw Normal View History

2012-08-22 23:27:53 +02:00
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
2012-08-05 14:37:45 +02:00
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
2005-01-24 16:36:05 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2005-01-24 16:36:05 +01:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2008-11-04 17:58:26 +01:00
*/
/**
2012-08-05 14:37:45 +02:00
* \file htdocs/compta/prelevement/rejets.php
* \ingroup prelevement
* \brief Reject page
2005-01-24 16:36:05 +01:00
*/
2018-07-26 11:57:25 +02:00
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
2018-05-27 09:27:09 +02:00
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
2008-11-04 17:58:26 +01:00
$type = GETPOST('type', 'aZ09');
2011-05-12 17:57:38 +02:00
// Get supervariables
2020-04-20 15:06:27 +02:00
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
2020-09-17 14:31:25 +02:00
$sortorder = GETPOST('sortorder', 'aZ09comma');
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST('sortfield', 'aZ09comma');
2020-04-20 15:06:27 +02:00
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
2021-02-23 21:09:01 +01:00
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
2020-04-20 15:06:27 +02:00
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) {
$socid = $user->socid;
}
if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
} else {
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
}
2008-11-04 17:58:26 +01:00
/*
* View
*/
2020-06-08 11:43:20 +02:00
$title = $langs->trans("WithdrawsRefused");
if ($type == 'bank-transfer') {
$title = $langs->trans("CreditTransfersRefused");
}
llxHeader('', $title);
2005-01-24 16:36:05 +01:00
2021-02-23 21:09:01 +01:00
if ($sortorder == "") {
$sortorder = "DESC";
}
if ($sortfield == "") {
$sortfield = "p.datec";
}
2020-10-22 21:29:33 +02:00
$rej = new RejetPrelevement($db, $user, $type);
2020-05-07 12:14:45 +02:00
$line = new LignePrelevement($db);
$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
2005-01-24 16:36:05 +01:00
/*
* Liste des factures
*
*/
$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut";
$sql .= " , s.rowid as socid, s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND pl.fk_soc = s.rowid";
$sql .= " AND p.entity = ".$conf->entity;
2020-06-08 11:43:20 +02:00
if ($type == 'bank-transfer') {
$sql .= " AND p.type = 'bank-transfer'";
} else {
$sql .= " AND p.type = 'debit-order'";
}
2021-02-23 21:09:01 +01:00
if ($socid) {
2021-04-24 20:18:11 +02:00
$sql .= " AND s.rowid = ".((int) $socid);
2021-02-23 21:09:01 +01:00
}
2020-06-08 11:43:20 +02:00
$sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset);
2005-01-24 16:36:05 +01:00
$result = $db->query($sql);
2021-02-23 21:09:01 +01:00
if ($result) {
2010-11-18 18:10:31 +01:00
$num = $db->num_rows($result);
$i = 0;
2010-03-27 15:40:39 +01:00
2020-06-08 11:43:20 +02:00
$param = '';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
2010-11-18 18:10:31 +01:00
print"\n<!-- debut table -->\n";
2021-04-30 15:22:17 +02:00
print '<table class="noborder tagtable liste" width="100%" cellpadding="4">';
2010-11-18 18:10:31 +01:00
print '<tr class="liste_titre">';
2020-06-08 11:43:20 +02:00
print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $param);
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param);
print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param);
2015-06-26 06:23:29 +02:00
print "</tr>\n";
2005-01-24 16:36:05 +01:00
2020-06-08 11:43:20 +02:00
if ($num) {
2021-02-23 21:09:01 +01:00
while ($i < min($num, $limit)) {
2020-06-08 11:43:20 +02:00
$obj = $db->fetch_object($result);
2005-01-24 16:36:05 +01:00
2020-06-08 11:43:20 +02:00
print '<tr class="oddeven">';
2005-01-24 16:36:05 +01:00
2020-06-08 11:43:20 +02:00
print '<td>';
print $line->LibStatut($obj->statut, 2).'&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
print substr('000000'.$obj->rowid, -6)."</a></td>";
2005-01-24 16:36:05 +01:00
2020-06-08 11:43:20 +02:00
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->nom."</a></td>\n";
2005-01-24 16:36:05 +01:00
2020-06-08 11:43:20 +02:00
print '<td>'.$rej->motifs[$obj->motif].'</td>';
2005-01-24 16:36:05 +01:00
2020-06-08 11:43:20 +02:00
print "</tr>\n";
2020-06-08 11:43:20 +02:00
$i++;
}
} else {
2021-10-04 04:14:31 +02:00
print '<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
2010-11-18 18:10:31 +01:00
}
2005-01-24 16:36:05 +01:00
2010-11-18 18:10:31 +01:00
print "</table>";
$db->free($result);
2020-05-21 15:05:19 +02:00
} else {
2010-11-18 18:10:31 +01:00
dol_print_error($db);
2005-01-24 16:36:05 +01:00
}
2018-08-08 12:29:36 +02:00
// End of page
llxFooter();
$db->close();