dolibarr  13.0.2
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) accessforbidden();
39 
40 // Get supervariables
41 $prev_id = GETPOST('id', 'int');
42 $ref = GETPOST('ref', 'alpha');
43 
44 $type = GETPOST('type', 'aZ09');
45 
46 // Load variable for pagination
47 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
48 $sortfield = GETPOST('sortfield', 'aZ09comma');
49 $sortorder = GETPOST('sortorder', 'aZ09comma');
50 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
51 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
52 $offset = $limit * $page;
53 $pageprev = $page - 1;
54 $pagenext = $page + 1;
55 
56 $object = new BonPrelevement($db);
57 
58 // Load object
59 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
60 
61 if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
63 }
64 if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
66 }
67 
68 
69 
70 /*
71  * View
72  */
73 
74 llxHeader('', $langs->trans("WithdrawalsReceipts"));
75 
76 if ($prev_id > 0 || $ref)
77 {
78  if ($object->fetch($prev_id, $ref) >= 0)
79  {
80  $head = prelevement_prepare_head($object);
81  print dol_get_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
82 
83  $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>';
84 
85  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
86 
87  print '<div class="fichecenter">';
88  print '<div class="underbanner clearboth"></div>';
89  print '<table class="border centpercent tableforfield">'."\n";
90 
91  //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
92  print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
93  print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
94 
95  if ($object->date_trans <> 0)
96  {
97  $muser = new User($db);
98  $muser->fetch($object->user_trans);
99 
100  print '<tr><td>'.$langs->trans("TransData").'</td><td>';
101  print dol_print_date($object->date_trans, 'day');
102  print ' <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getFullName($langs).'</td></tr>';
103  print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
104  print $object->methodes_trans[$object->method_trans];
105  print '</td></tr>';
106  }
107  if ($object->date_credit <> 0)
108  {
109  print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
110  print dol_print_date($object->date_credit, 'day');
111  print '</td></tr>';
112  }
113 
114  print '</table>';
115 
116  print '<br>';
117 
118  print '<div class="underbanner clearboth"></div>';
119  print '<table class="border centpercent tableforfield">';
120 
121  $acc = new Account($db);
122  $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
123 
124  print '<tr><td class="titlefield">';
125  $labelofbankfield = "BankToReceiveWithdraw";
126  if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
127  print $langs->trans($labelofbankfield);
128  print '</td>';
129  print '<td>';
130  if ($acc->id > 0)
131  print $acc->getNomUrl(1);
132  print '</td>';
133  print '</tr>';
134 
135  print '<tr><td class="titlefield">';
136  $labelfororderfield = 'WithdrawalFile';
137  if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
138  print $langs->trans($labelfororderfield).'</td><td>';
139  $relativepath = 'receipts/'.$object->ref.'.xml';
140  $modulepart = 'prelevement';
141  if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
142  print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
143  print '</td></tr></table>';
144 
145  print '</div>';
146 
148  } else {
149  dol_print_error($db);
150  }
151 }
152 
153 
154 $rej = new RejetPrelevement($db, $user, $type);
155 
156 /*
157  * List errors
158  */
159 $sql = "SELECT pl.rowid, pl.amount, pl.statut";
160 $sql .= " , s.rowid as socid, s.nom as name";
161 $sql .= " , pr.motif, pr.afacturer, pr.fk_facture";
162 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
163 $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
164 $sql .= " , ".MAIN_DB_PREFIX."societe as s";
165 $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
166 $sql .= " WHERE p.rowid=".$object->id;
167 $sql .= " AND pl.fk_prelevement_bons = p.rowid";
168 $sql .= " AND p.entity = ".$conf->entity;
169 $sql .= " AND pl.fk_soc = s.rowid";
170 $sql .= " AND pl.statut = 3 ";
171 $sql .= " AND pr.fk_prelevement_lignes = pl.rowid";
172 if ($socid) $sql .= " AND s.rowid = ".$socid;
173 $sql .= " ORDER BY pl.amount DESC";
174 
175 // Count total nb of records
176 $nbtotalofrecords = '';
177 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
178 {
179  $result = $db->query($sql);
180  $nbtotalofrecords = $db->num_rows($result);
181  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
182  {
183  $page = 0;
184  $offset = 0;
185  }
186 }
187 
188 $sql .= $db->plimit($limit + 1, $offset);
189 
190 $resql = $db->query($sql);
191 if ($resql)
192 {
193  $num = $db->num_rows($resql);
194 
195  print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
196 
197  print"\n<!-- debut table -->\n";
198  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
199  print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
200  print '<tr class="liste_titre">';
201  print '<td>'.$langs->trans("Line").'</td><td>'.$langs->trans("ThirdParty").'</td><td class="right">'.$langs->trans("Amount").'</td>';
202  print '<td>'.$langs->trans("Reason").'</td><td align="center">'.$langs->trans("ToBill").'</td><td class="center">'.$langs->trans("Invoice").'</td></tr>';
203 
204  $total = 0;
205 
206  if ($num > 0)
207  {
208  $i = 0;
209  while ($i < $num)
210  {
211  $obj = $db->fetch_object($resql);
212 
213  print '<tr class="oddeven"><td>';
214 
215  print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
216  print img_picto('', 'statut'.$obj->statut).' ';
217  print substr('000000'.$obj->rowid, -6);
218  print '</a></td>';
219  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
220 
221  print '<td class="right">'.price($obj->amount)."</td>\n";
222  print '<td>'.$rej->motifs[$obj->motif].'</td>';
223 
224  print '<td class="center">'.yn($obj->afacturer).'</td>';
225  print '<td class="center">'.$obj->fk_facture.'</td>';
226  print "</tr>\n";
227 
228  $total += $obj->amount;
229 
230  $i++;
231  }
232  } else {
233  print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
234  }
235 
236  if ($num > 0)
237  {
238  print '<tr class="liste_total"><td>&nbsp;</td>';
239  print '<td class="liste_total">'.$langs->trans("Total").'</td>';
240  print '<td class="right">'.price($total)."</td>\n";
241  print '<td colspan="3">&nbsp;</td>';
242  print "</tr>\n";
243  }
244  print "</table>\n";
245  print '</div>';
246 
247  $db->free($resql);
248 } else {
249  dol_print_error($db);
250 }
251 
252 // End of page
253 llxFooter();
254 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
Definition: user.class.php:44
Class to manage bank accounts.
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...
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.
Class to manage withdrawal receipts.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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 ...
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59
Class to manage standing orders rejects.