dolibarr 21.0.0-alpha
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 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
34require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
35require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
36require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
37
38// Load translation files required by the page
39$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
40
41$type = GETPOST('type', 'aZ09');
42
43// Get supervariables
44$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
45$sortorder = GETPOST('sortorder', 'aZ09comma');
46$sortfield = GETPOST('sortfield', 'aZ09comma');
47$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
48if (empty($page) || $page == -1) {
49 $page = 0;
50} // If $page is not defined, or '' or -1
51$offset = $limit * $page;
52$pageprev = $page - 1;
53$pagenext = $page + 1;
54
55// Security check
56$socid = GETPOSTINT('socid');
57if ($user->socid) {
58 $socid = $user->socid;
59}
60
61// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
62$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
63
64if ($type == 'bank-transfer') {
65 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
66} else {
67 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
68}
69
70
71/*
72 * View
73 */
74
75$form = new Form($db);
76
77$title = $langs->trans("WithdrawsRefused");
78if ($type == 'bank-transfer') {
79 $title = $langs->trans("CreditTransfersRefused");
80}
81
82llxHeader('', $title);
83
84if ($sortorder == "") {
85 $sortorder = "DESC";
86}
87if ($sortfield == "") {
88 $sortfield = "p.datec";
89}
90
91$rej = new RejetPrelevement($db, $user, $type);
92$line = new LignePrelevement($db);
93$thirdpartystatic = new Societe($db);
94$userstatic = new User($db);
95
96// List of invoices
97
98$sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,";
99$sql .= " s.rowid as socid, s.nom as name, p.datec";
100$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
101$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
102$sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
103$sql .= " , ".MAIN_DB_PREFIX."societe as s";
104$sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
105$sql .= " AND pl.fk_prelevement_bons = p.rowid";
106$sql .= " AND pl.fk_soc = s.rowid";
107$sql .= " AND p.entity = ".((int) $conf->entity);
108if ($type == 'bank-transfer') {
109 $sql .= " AND p.type = 'bank-transfer'";
110} else {
111 $sql .= " AND p.type = 'debit-order'";
112}
113if ($socid > 0) {
114 $sql .= " AND s.rowid = ".((int) $socid);
115}
116// Add list for salaries
117if ($type == 'bank-transfer') {
118 $sql .= " UNION";
119 $sql .= " SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,";
120 $sql .= " u.rowid as socid, CONCAT(u.firstname,' ', u.lastname) as name, p.datec";
121 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
122 $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
123 $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
124 $sql .= " , ".MAIN_DB_PREFIX."user as u";
125 $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
126 $sql .= " AND pl.fk_prelevement_bons = p.rowid";
127 $sql .= " AND pl.fk_user = u.rowid";
128 $sql .= " AND p.entity = ".((int) $conf->entity);
129 $sql .= " AND p.type = 'bank-transfer'";
130 if ($socid) {
131 $sql .= " AND s.rowid = ".((int) $socid);
132 }
133}
134if ($type == 'bank-transfer') {
135 $sortfield = 'datec';
136}
137$sql .= $db->order($sortfield, $sortorder);
138$sql .= $db->plimit($limit + 1, $offset);
139
140$result = $db->query($sql);
141if ($result) {
142 $num = $db->num_rows($result);
143
144 $param = '';
145
146 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
147 print"\n<!-- debut table -->\n";
148 print '<table class="noborder tagtable liste" width="100%" cellpadding="4">';
149 print '<tr class="liste_titre">';
150 print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $param);
151 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param);
152 print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param);
153 print "</tr>\n";
154
155 $bon = new BonPrelevement($db);
156 if ($num) {
157 $i = 0;
158 $maxlim = min($num, $limit);
159 while ($i < $maxlim) {
160 $obj = $db->fetch_object($result);
161 $bon->fetch($obj->bonId);
162
163 print '<tr class="oddeven">';
164
165 print '<td>';
166 print $line->LibStatut($obj->statut, 2).'&nbsp;';
167 print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
168 print substr('000000'.$obj->rowid, -6)."</a></td>";
169
170 if ($bon->checkIfSalaryBonPrelevement()) {
171 print '<td><a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$obj->socid.'">'.$obj->name."</a></td>\n";
172 } else {
173 $thirdpartystatic->id = $obj->socid;
174 $thirdpartystatic->name = $obj->name;
175
176 print '<td class="tdoverflowmax200"><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$thirdpartystatic->getNomUrl(1)."</a></td>\n";
177 }
178
179 print '<td>'.$rej->motifs[$obj->motif].'</td>';
180
181 print "</tr>\n";
182
183 $i++;
184 }
185 } else {
186 print '<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
187 }
188
189 print "</table>";
190 $db->free($result);
191} else {
192 dol_print_error($db);
193}
194
195// End of page
196llxFooter();
197$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:70
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...
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.