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