dolibarr  16.0.5
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 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
35 
36 $type = GETPOST('type', 'aZ09');
37 
38 // Get supervariables
39 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
40 $sortorder = GETPOST('sortorder', 'aZ09comma');
41 $sortfield = GETPOST('sortfield', 'aZ09comma');
42 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
43 if (empty($page) || $page == -1) {
44  $page = 0;
45 } // If $page is not defined, or '' or -1
46 $offset = $limit * $page;
47 $pageprev = $page - 1;
48 $pagenext = $page + 1;
49 
50 // Security check
51 $socid = GETPOST('socid', 'int');
52 if ($user->socid) {
53  $socid = $user->socid;
54 }
55 if ($type == 'bank-transfer') {
56  $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
57 } else {
58  $result = restrictedArea($user, 'prelevement', '', '', 'bons');
59 }
60 
61 
62 /*
63  * View
64  */
65 
66 $title = $langs->trans("WithdrawsRefused");
67 if ($type == 'bank-transfer') {
68  $title = $langs->trans("CreditTransfersRefused");
69 }
70 
71 llxHeader('', $title);
72 
73 if ($sortorder == "") {
74  $sortorder = "DESC";
75 }
76 if ($sortfield == "") {
77  $sortfield = "p.datec";
78 }
79 
80 $rej = new RejetPrelevement($db, $user, $type);
81 $line = new LignePrelevement($db);
82 
83 $hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
84 
85 
86 /*
87  * Liste des factures
88  *
89  */
90 $sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut";
91 $sql .= " , s.rowid as socid, s.nom";
92 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
93 $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
94 $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
95 $sql .= " , ".MAIN_DB_PREFIX."societe as s";
96 $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
97 $sql .= " AND pl.fk_prelevement_bons = p.rowid";
98 $sql .= " AND pl.fk_soc = s.rowid";
99 $sql .= " AND p.entity = ".$conf->entity;
100 if ($type == 'bank-transfer') {
101  $sql .= " AND p.type = 'bank-transfer'";
102 } else {
103  $sql .= " AND p.type = 'debit-order'";
104 }
105 if ($socid) {
106  $sql .= " AND s.rowid = ".((int) $socid);
107 }
108 $sql .= $db->order($sortfield, $sortorder);
109 $sql .= $db->plimit($limit + 1, $offset);
110 
111 $result = $db->query($sql);
112 if ($result) {
113  $num = $db->num_rows($result);
114  $i = 0;
115 
116  $param = '';
117 
118  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
119  print"\n<!-- debut table -->\n";
120  print '<table class="noborder tagtable liste" width="100%" cellpadding="4">';
121  print '<tr class="liste_titre">';
122  print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $param);
123  print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param);
124  print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param);
125  print "</tr>\n";
126 
127  if ($num) {
128  while ($i < min($num, $limit)) {
129  $obj = $db->fetch_object($result);
130 
131  print '<tr class="oddeven">';
132 
133  print '<td>';
134  print $line->LibStatut($obj->statut, 2).'&nbsp;';
135  print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
136  print substr('000000'.$obj->rowid, -6)."</a></td>";
137 
138  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->nom."</a></td>\n";
139 
140  print '<td>'.$rej->motifs[$obj->motif].'</td>';
141 
142  print "</tr>\n";
143 
144  $i++;
145  }
146  } else {
147  print '<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
148  }
149 
150  print "</table>";
151  $db->free($result);
152 } else {
153  dol_print_error($db);
154 }
155 
156 // End of page
157 llxFooter();
158 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
LignePrelevement
Class to manage withdrawals.
Definition: ligneprelevement.class.php:32
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
print_barre_liste
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.
Definition: functions.lib.php:5257
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
RejetPrelevement
Class to manage standing orders rejects.
Definition: rejetprelevement.class.php:31
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59