dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
34require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
35require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
36require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
37require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
38
47// Load translation files required by the page
48$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
49
50$type = GETPOST('type', 'aZ09');
51
52// Get supervariables
53$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
54$sortorder = GETPOST('sortorder', 'aZ09comma');
55$sortfield = GETPOST('sortfield', 'aZ09comma');
56$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
57if (empty($page) || $page == -1) {
58 $page = 0;
59} // If $page is not defined, or '' or -1
60$offset = $limit * $page;
61$pageprev = $page - 1;
62$pagenext = $page + 1;
63
64// Security check
65$socid = GETPOSTINT('socid');
66if ($user->socid) {
67 $socid = $user->socid;
68}
69
70// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
71$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
72
73if ($type == 'bank-transfer') {
74 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
75} else {
76 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
77}
78
79
80/*
81 * View
82 */
83
84$form = new Form($db);
85
86$title = $langs->trans("WithdrawsRefused");
87if ($type == 'bank-transfer') {
88 $title = $langs->trans("CreditTransfersRefused");
89}
90
91llxHeader('', $title);
92
93if ($sortorder == "") {
94 $sortorder = "DESC";
95}
96if ($sortfield == "") {
97 $sortfield = "p.datec";
98}
99
100$rej = new RejetPrelevement($db, $user, $type);
101$line = new LignePrelevement($db);
102$thirdpartystatic = new Societe($db);
103$userstatic = new User($db);
104
105// List of invoices
106
107$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,";
108$sql .= " s.rowid as socid, s.nom as name, p.datec";
109$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
110$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
111$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
112$sql .= " , ".MAIN_DB_PREFIX."societe as s";
113$sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
114$sql .= " AND pl.fk_prelevement_bons = p.rowid";
115$sql .= " AND pl.fk_soc = s.rowid";
116$sql .= " AND p.entity = ".((int) $conf->entity);
117if ($type == 'bank-transfer') {
118 $sql .= " AND p.type = 'bank-transfer'";
119} else {
120 $sql .= " AND p.type = 'debit-order'";
121}
122if ($socid > 0) {
123 $sql .= " AND s.rowid = ".((int) $socid);
124}
125// Add list for salaries
126if ($type == 'bank-transfer') {
127 $sql .= " UNION";
128 $sql .= " SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,";
129 $sql .= " u.rowid as socid, CONCAT(u.firstname,' ', u.lastname) as name, p.datec";
130 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
131 $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
132 $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
133 $sql .= " , ".MAIN_DB_PREFIX."user as u";
134 $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
135 $sql .= " AND pl.fk_prelevement_bons = p.rowid";
136 $sql .= " AND pl.fk_user = u.rowid";
137 $sql .= " AND p.entity = ".((int) $conf->entity);
138 $sql .= " AND p.type = 'bank-transfer'";
139 if ($socid) {
140 $sql .= " AND s.rowid = ".((int) $socid);
141 }
142}
143if ($type == 'bank-transfer') {
144 $sortfield = 'datec';
145}
146$sql .= $db->order($sortfield, $sortorder);
147$sql .= $db->plimit($limit + 1, $offset);
148
149$result = $db->query($sql);
150if ($result) {
151 $num = $db->num_rows($result);
152
153 $param = '';
154
155 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
156 print"\n<!-- debut table -->\n";
157 print '<table class="noborder tagtable liste" width="100%" cellpadding="4">';
158 print '<tr class="liste_titre">';
159 print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $param);
160 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param);
161 print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param);
162 print "</tr>\n";
163
164 $bon = new BonPrelevement($db);
165 if ($num) {
166 $i = 0;
167 $maxlim = min($num, $limit);
168 while ($i < $maxlim) {
169 $obj = $db->fetch_object($result);
170 $bon->fetch($obj->bonId);
171
172 print '<tr class="oddeven">';
173
174 print '<td>';
175 print $line->LibStatut($obj->statut, 2).'&nbsp;';
176 print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
177 print substr('000000'.$obj->rowid, -6)."</a></td>";
178
179 if ($bon->checkIfSalaryBonPrelevement()) {
180 print '<td><a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$obj->socid.'">'.$obj->name."</a></td>\n";
181 } else {
182 $thirdpartystatic->id = $obj->socid;
183 $thirdpartystatic->name = $obj->name;
184
185 print '<td class="tdoverflowmax200"><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$thirdpartystatic->getNomUrl(1)."</a></td>\n";
186 }
187
188 print '<td>'.$rej->motifs[$obj->motif].'</td>';
189
190 print "</tr>\n";
191
192 $i++;
193 }
194 } else {
195 print '<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
196 }
197
198 print "</table>";
199 $db->free($result);
200} else {
201 dol_print_error($db);
202}
203
204// End of page
205llxFooter();
206$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage withdrawal receipts.
Class to manage generation of HTML components Only common components must be here.
Class to manage withdrawals.
Class to manage standing orders rejects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.