dolibarr  20.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  *
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
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
39 
40 $type = GETPOST('type', 'aZ09');
41 
42 // Get supervariables
43 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
44 $sortorder = GETPOST('sortorder', 'aZ09comma');
45 $sortfield = GETPOST('sortfield', 'aZ09comma');
46 $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
47 if (empty($page) || $page == -1) {
48  $page = 0;
49 } // If $page is not defined, or '' or -1
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
53 
54 // Security check
55 $socid = GETPOSTINT('socid');
56 if ($user->socid) {
57  $socid = $user->socid;
58 }
59 if ($type == 'bank-transfer') {
60  $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
61 } else {
62  $result = restrictedArea($user, 'prelevement', '', '', 'bons');
63 }
64 
65 
66 /*
67  * View
68  */
69 
70 $form = new Form($db);
71 
72 $title = $langs->trans("WithdrawsRefused");
73 if ($type == 'bank-transfer') {
74  $title = $langs->trans("CreditTransfersRefused");
75 }
76 
77 llxHeader('', $title);
78 
79 if ($sortorder == "") {
80  $sortorder = "DESC";
81 }
82 if ($sortfield == "") {
83  $sortfield = "p.datec";
84 }
85 
86 $rej = new RejetPrelevement($db, $user, $type);
87 $line = new LignePrelevement($db);
88 $thirdpartystatic = new Societe($db);
89 $userstatic = new User($db);
90 
91 $hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
92 
93 
94 // List of invoices
95 
96 $sql = "SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,";
97 $sql .= " s.rowid as socid, s.nom as name, p.datec";
98 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
99 $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
100 $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
101 $sql .= " , ".MAIN_DB_PREFIX."societe as s";
102 $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
103 $sql .= " AND pl.fk_prelevement_bons = p.rowid";
104 $sql .= " AND pl.fk_soc = s.rowid";
105 $sql .= " AND p.entity = ".((int) $conf->entity);
106 if ($type == 'bank-transfer') {
107  $sql .= " AND p.type = 'bank-transfer'";
108 } else {
109  $sql .= " AND p.type = 'debit-order'";
110 }
111 if ($socid > 0) {
112  $sql .= " AND s.rowid = ".((int) $socid);
113 }
114 // Add list for salaries
115 if ($type == 'bank-transfer') {
116  $sql .= " UNION";
117  $sql .= " SELECT pl.rowid, pr.motif, p.ref, pl.statut, p.rowid as bonId,";
118  $sql .= " u.rowid as socid, CONCAT(u.firstname,' ', u.lastname) as name, p.datec";
119  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
120  $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
121  $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
122  $sql .= " , ".MAIN_DB_PREFIX."user as u";
123  $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid";
124  $sql .= " AND pl.fk_prelevement_bons = p.rowid";
125  $sql .= " AND pl.fk_user = u.rowid";
126  $sql .= " AND p.entity = ".((int) $conf->entity);
127  $sql .= " AND p.type = 'bank-transfer'";
128  if ($socid) {
129  $sql .= " AND s.rowid = ".((int) $socid);
130  }
131 }
132 if ($type == 'bank-transfer') {
133  $sortfield = 'datec';
134 }
135 $sql .= $db->order($sortfield, $sortorder);
136 $sql .= $db->plimit($limit + 1, $offset);
137 
138 $result = $db->query($sql);
139 if ($result) {
140  $num = $db->num_rows($result);
141 
142  $param = '';
143 
144  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
145  print"\n<!-- debut table -->\n";
146  print '<table class="noborder tagtable liste" width="100%" cellpadding="4">';
147  print '<tr class="liste_titre">';
148  print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $param);
149  print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param);
150  print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param);
151  print "</tr>\n";
152 
153  $bon = new BonPrelevement($db);
154  if ($num) {
155  $i = 0;
156  $maxlim = min($num, $limit);
157  while ($i < $maxlim) {
158  $obj = $db->fetch_object($result);
159  $bon->fetch($obj->bonId);
160 
161  print '<tr class="oddeven">';
162 
163  print '<td>';
164  print $line->LibStatut($obj->statut, 2).'&nbsp;';
165  print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
166  print substr('000000'.$obj->rowid, -6)."</a></td>";
167 
168  if ($bon->checkIfSalaryBonPrelevement()) {
169  print '<td><a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$obj->socid.'">'.$obj->name."</a></td>\n";
170  } else {
171  $thirdpartystatic->id = $obj->socid;
172  $thirdpartystatic->name = $obj->name;
173 
174  print '<td class="tdoverlowmax200"><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$thirdpartystatic->getNomUrl(1)."</a></td>\n";
175  }
176 
177  print '<td>'.$rej->motifs[$obj->motif].'</td>';
178 
179  print "</tr>\n";
180 
181  $i++;
182  }
183  } else {
184  print '<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
185  }
186 
187  print "</table>";
188  $db->free($result);
189 } else {
190  dol_print_error($db);
191 }
192 
193 // End of page
194 llxFooter();
195 $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 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.
Definition: user.class.php:50
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:744
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.