dolibarr  16.0.5
fiche-rejet.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
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.'/core/lib/prelevement.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.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 
34 // Load translation files required by the page
35 $langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills'));
36 
37 // Security check
38 if ($user->socid > 0) {
40 }
41 
42 // Get supervariables
43 $id = GETPOST('id', 'int');
44 $ref = GETPOST('ref', 'alpha');
45 
46 $type = GETPOST('type', 'aZ09');
47 
48 // Load variable for pagination
49 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
50 $sortfield = GETPOST('sortfield', 'aZ09comma');
51 $sortorder = GETPOST('sortorder', 'aZ09comma');
52 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
53 if (empty($page) || $page == -1) {
54  $page = 0;
55 } // If $page is not defined, or '' or -1
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 
60 $object = new BonPrelevement($db);
61 
62 // Load object
63 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
64 
65 // Security check
66 if ($user->socid > 0) {
68 }
69 
70 $type = $object->type;
71 if ($type == 'bank-transfer') {
72  $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
73 } else {
74  $result = restrictedArea($user, 'prelevement', '', '', 'bons');
75 }
76 
77 
78 
79 /*
80  * View
81  */
82 
83 llxHeader('', $langs->trans("WithdrawalsReceipts"));
84 
85 if ($id > 0 || $ref) {
86  if ($object->fetch($id, $ref) >= 0) {
87  $head = prelevement_prepare_head($object);
88  print dol_get_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
89 
90  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/orders_list.php?restore_lastsearch_values=1'.($object->type != 'bank-transfer' ? '' : '&type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
91 
92  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
93 
94  print '<div class="fichecenter">';
95  print '<div class="underbanner clearboth"></div>';
96  print '<table class="border centpercent tableforfield">'."\n";
97 
98  //print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
99  print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
100  print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
101 
102  if ($object->date_trans <> 0) {
103  $muser = new User($db);
104  $muser->fetch($object->user_trans);
105 
106  print '<tr><td>'.$langs->trans("TransData").'</td><td>';
107  print dol_print_date($object->date_trans, 'day');
108  print ' <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td></tr>';
109  print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
110  print $object->methodes_trans[$object->method_trans];
111  print '</td></tr>';
112  }
113  if ($object->date_credit <> 0) {
114  print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
115  print dol_print_date($object->date_credit, 'day');
116  print '</td></tr>';
117  }
118 
119  print '</table>';
120 
121  print '<br>';
122 
123  print '<div class="underbanner clearboth"></div>';
124  print '<table class="border centpercent tableforfield">';
125 
126  $acc = new Account($db);
127  $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
128 
129  print '<tr><td class="titlefieldcreate">';
130  $labelofbankfield = "BankToReceiveWithdraw";
131  if ($object->type == 'bank-transfer') {
132  $labelofbankfield = 'BankToPayCreditTransfer';
133  }
134  print $langs->trans($labelofbankfield);
135  print '</td>';
136  print '<td>';
137  if ($acc->id > 0) {
138  print $acc->getNomUrl(1);
139  }
140  print '</td>';
141  print '</tr>';
142 
143  print '<tr><td class="titlefieldcreate">';
144  $labelfororderfield = 'WithdrawalFile';
145  if ($object->type == 'bank-transfer') {
146  $labelfororderfield = 'CreditTransferFile';
147  }
148  print $langs->trans($labelfororderfield).'</td><td>';
149  $relativepath = 'receipts/'.$object->ref.'.xml';
150  $modulepart = 'prelevement';
151  if ($object->type == 'bank-transfer') {
152  $modulepart = 'paymentbybanktransfer';
153  }
154  print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
155  print img_picto('', 'download', 'class="paddingleft"');
156  print '</a>';
157  print '</td></tr></table>';
158 
159  print '</div>';
160 
161  print dol_get_fiche_end();
162  } else {
163  dol_print_error($db);
164  }
165 }
166 
167 
168 $rej = new RejetPrelevement($db, $user, $type);
169 
170 /*
171  * List errors
172  */
173 $sql = "SELECT pl.rowid, pl.amount, pl.statut";
174 $sql .= " , s.rowid as socid, s.nom as name";
175 $sql .= " , pr.motif, pr.afacturer, pr.fk_facture";
176 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
177 $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
178 $sql .= " , ".MAIN_DB_PREFIX."societe as s";
179 $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
180 $sql .= " WHERE p.rowid=".((int) $object->id);
181 $sql .= " AND pl.fk_prelevement_bons = p.rowid";
182 $sql .= " AND p.entity = ".$conf->entity;
183 $sql .= " AND pl.fk_soc = s.rowid";
184 $sql .= " AND pl.statut = 3 ";
185 $sql .= " AND pr.fk_prelevement_lignes = pl.rowid";
186 /*if ($socid) {
187  $sql .= " AND s.rowid = ".((int) $socid);
188 }*/
189 $sql .= " ORDER BY pl.amount DESC";
190 
191 // Count total nb of records
192 $nbtotalofrecords = '';
193 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
194  $result = $db->query($sql);
195  $nbtotalofrecords = $db->num_rows($result);
196  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
197  $page = 0;
198  $offset = 0;
199  }
200 }
201 
202 $sql .= $db->plimit($limit + 1, $offset);
203 
204 $resql = $db->query($sql);
205 if ($resql) {
206  $num = $db->num_rows($resql);
207 
208  print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
209 
210  print"\n<!-- debut table -->\n";
211  print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
212  print '<table class="noborder centpercent">';
213  print '<tr class="liste_titre">';
214  print '<td>'.$langs->trans("Line").'</td><td>'.$langs->trans("ThirdParty").'</td><td class="right">'.$langs->trans("Amount").'</td>';
215  print '<td>'.$langs->trans("Reason").'</td><td align="center">'.$langs->trans("ToBill").'</td><td class="center">'.$langs->trans("Invoice").'</td></tr>';
216 
217  $total = 0;
218 
219  if ($num > 0) {
220  $i = 0;
221  while ($i < $num) {
222  $obj = $db->fetch_object($resql);
223 
224  print '<tr class="oddeven"><td>';
225 
226  print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
227  print img_picto('', 'statut'.$obj->statut).' ';
228  print substr('000000'.$obj->rowid, -6);
229  print '</a></td>';
230  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
231 
232  print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
233  print '<td>'.$rej->motifs[$obj->motif].'</td>';
234 
235  print '<td class="center">'.yn($obj->afacturer).'</td>';
236  print '<td class="center">'.$obj->fk_facture.'</td>';
237  print "</tr>\n";
238 
239  $total += $obj->amount;
240 
241  $i++;
242  }
243  } else {
244  print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
245  }
246 
247  if ($num > 0) {
248  print '<tr class="liste_total"><td>&nbsp;</td>';
249  print '<td class="liste_total">'.$langs->trans("Total").'</td>';
250  print '<td class="right"><span class="amount">'.price($total)."</span></td>\n";
251  print '<td colspan="3">&nbsp;</td>';
252  print "</tr>\n";
253  }
254  print "</table>\n";
255  print '</div>';
256 
257  $db->free($resql);
258 } else {
259  dol_print_error($db);
260 }
261 
262 // End of page
263 llxFooter();
264 $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
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
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
BonPrelevement
Class to manage withdrawal receipts.
Definition: bonprelevement.class.php:43
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
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
User
Class to manage Dolibarr users.
Definition: user.class.php:44
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
RejetPrelevement
Class to manage standing orders rejects.
Definition: rejetprelevement.class.php:31
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
price
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
Definition: functions.lib.php:5541
prelevement_prepare_head
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
Definition: prelevement.lib.php:34
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
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
Account
Class to manage bank accounts.
Definition: account.class.php:38