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