dolibarr 18.0.6
rejets.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
30require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
33
34// Load translation files required by the page
35$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
36
37$type = GETPOST('type', 'aZ09');
38
39// Get supervariables
40$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
41$sortorder = GETPOST('sortorder', 'aZ09comma');
42$sortfield = GETPOST('sortfield', 'aZ09comma');
43$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
44if (empty($page) || $page == -1) {
45 $page = 0;
46} // If $page is not defined, or '' or -1
47$offset = $limit * $page;
48$pageprev = $page - 1;
49$pagenext = $page + 1;
50
51// Security check
52$socid = GETPOST('socid', 'int');
53if ($user->socid) {
54 $socid = $user->socid;
55}
56if ($type == 'bank-transfer') {
57 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
58} else {
59 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
60}
61
62
63/*
64 * View
65 */
66
67$form = new Form($db);
68
69$title = $langs->trans("WithdrawsRefused");
70if ($type == 'bank-transfer') {
71 $title = $langs->trans("CreditTransfersRefused");
72}
73
74llxHeader('', $title);
75
76if ($sortorder == "") {
77 $sortorder = "DESC";
78}
79if ($sortfield == "") {
80 $sortfield = "p.datec";
81}
82
83$rej = new RejetPrelevement($db, $user, $type);
84$line = new LignePrelevement($db);
85
86$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
87
88
89// List of invoices
90
91$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut";
92$sql .= " , s.rowid as socid, s.nom";
93$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
94$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
95$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
96$sql .= " , ".MAIN_DB_PREFIX."societe as s";
97$sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
98$sql .= " AND pl.fk_prelevement_bons = p.rowid";
99$sql .= " AND pl.fk_soc = s.rowid";
100$sql .= " AND p.entity = ".$conf->entity;
101if ($type == 'bank-transfer') {
102 $sql .= " AND p.type = 'bank-transfer'";
103} else {
104 $sql .= " AND p.type = 'debit-order'";
105}
106if ($socid) {
107 $sql .= " AND s.rowid = ".((int) $socid);
108}
109$sql .= $db->order($sortfield, $sortorder);
110$sql .= $db->plimit($limit + 1, $offset);
111
112$result = $db->query($sql);
113if ($result) {
114 $num = $db->num_rows($result);
115 $i = 0;
116
117 $param = '';
118
119 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
120 print"\n<!-- debut table -->\n";
121 print '<table class="noborder tagtable liste" width="100%" cellpadding="4">';
122 print '<tr class="liste_titre">';
123 print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $param);
124 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param);
125 print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param);
126 print "</tr>\n";
127
128 if ($num) {
129 while ($i < min($num, $limit)) {
130 $obj = $db->fetch_object($result);
131
132 print '<tr class="oddeven">';
133
134 print '<td>';
135 print $line->LibStatut($obj->statut, 2).'&nbsp;';
136 print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
137 print substr('000000'.$obj->rowid, -6)."</a></td>";
138
139 print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->nom."</a></td>\n";
140
141 print '<td>'.$rej->motifs[$obj->motif].'</td>';
142
143 print "</tr>\n";
144
145 $i++;
146 }
147 } else {
148 print '<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
149 }
150
151 print "</table>";
152 $db->free($result);
153} else {
154 dol_print_error($db);
155}
156
157// End of page
158llxFooter();
159$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
Class to manage withdrawals.
Class to manage standing orders rejects.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.