dolibarr  7.0.0-beta
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@capnetworks.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 $langs->loadLangs(array("banks","categories",'withdrawals','bills'));
35 
36 // Securite acces client
37 if ($user->societe_id > 0) accessforbidden();
38 
39 // Get supervariables
40 $prev_id = GETPOST('id','int');
41 $ref = GETPOST('ref', 'alpha');
42 
43 // Load variable for pagination
44 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
45 $sortfield = GETPOST('sortfield','alpha');
46 $sortorder = GETPOST('sortorder','alpha');
47 $page = 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 $object = new BonPrelevement($db,"");
54 
55 
56 
57 
58 /*
59  * View
60  */
61 
62 llxHeader('',$langs->trans("WithdrawalsReceipts"));
63 
64 if ($prev_id > 0 || $ref)
65 {
66  if ($object->fetch($prev_id, $ref) >= 0)
67  {
68  $head = prelevement_prepare_head($object);
69  dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
70 
71  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php">'.$langs->trans("BackToList").'</a>';
72 
73  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
74 
75  print '<div class="fichecenter">';
76  print '<div class="underbanner clearboth"></div>';
77  print '<table class="border centpercent">'."\n";
78 
79  //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
80  print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec,'day').'</td></tr>';
81  print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
82 
83  // Status
84  /*
85  print '<tr><td>'.$langs->trans('Status').'</td>';
86  print '<td>'.$object->getLibStatut(1).'</td>';
87  print '</tr>';
88  */
89 
90  if($object->date_trans <> 0)
91  {
92  $muser = new User($db);
93  $muser->fetch($object->user_trans);
94 
95  print '<tr><td>'.$langs->trans("TransData").'</td><td>';
96  print dol_print_date($object->date_trans,'day');
97  print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
98  print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
99  print $object->methodes_trans[$object->method_trans];
100  print '</td></tr>';
101  }
102  if($object->date_credit <> 0)
103  {
104  print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
105  print dol_print_date($object->date_credit,'day');
106  print '</td></tr>';
107  }
108 
109  print '</table>';
110 
111  print '<br>';
112 
113  print '<div class="underbanner clearboth"></div>';
114  print '<table class="border" width="100%">';
115 
116  $acc = new Account($db);
117  $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
118 
119  print '<tr><td class="titlefield">';
120  print $langs->trans("BankToReceiveWithdraw");
121  print '</td>';
122  print '<td>';
123  if ($acc->id > 0)
124  print $acc->getNomUrl(1);
125  print '</td>';
126  print '</tr>';
127 
128  print '<tr><td class="titlefield">';
129  print $langs->trans("WithdrawalFile").'</td><td>';
130  $relativepath = 'receipts/'.$object->ref.'.xml';
131  print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
132  print '</td></tr></table>';
133 
134  print '</div>';
135 
136  dol_fiche_end();
137 
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 }
173 
174 $sql.= $db->plimit($limit+1, $offset);
175 
176 $resql = $db->query($sql);
177 if ($resql)
178 {
179  $num = $db->num_rows($resql);
180 
181  print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
182 
183  print"\n<!-- debut table -->\n";
184  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
185  print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
186  print '<tr class="liste_titre">';
187  print '<td>'.$langs->trans("Line").'</td><td>'.$langs->trans("ThirdParty").'</td><td align="right">'.$langs->trans("Amount").'</td>';
188  print '<td>'.$langs->trans("Reason").'</td><td align="center">'.$langs->trans("ToBill").'</td><td align="center">'.$langs->trans("Invoice").'</td></tr>';
189 
190  $total = 0;
191 
192  if ($num > 0)
193  {
194  $i = 0;
195  while ($i < $num)
196  {
197  $obj = $db->fetch_object($resql);
198 
199  print '<tr class="oddeven"><td>';
200 
201  print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/ligne.php?id='.$obj->rowid.'">';
202  print img_picto('', 'statut'.$obj->statut).' ';
203  print substr('000000'.$obj->rowid, -6);
204  print '</a></td>';
205  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
206 
207  print '<td align="right">'.price($obj->amount)."</td>\n";
208  print '<td>'.$rej->motifs[$obj->motif].'</td>';
209 
210  print '<td align="center">'.yn($obj->afacturer).'</td>';
211  print '<td align="center">'.$obj->fk_facture.'</td>';
212  print "</tr>\n";
213 
214  $total += $obj->amount;
215 
216  $i++;
217  }
218  }
219  else
220  {
221  print '<tr><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
222  }
223 
224  if ($num > 0)
225  {
226  print '<tr class="liste_total"><td>&nbsp;</td>';
227  print '<td class="liste_total">'.$langs->trans("Total").'</td>';
228  print '<td align="right">'.price($total)."</td>\n";
229  print '<td colspan="3">&nbsp;</td>';
230  print "</tr>\n";
231  }
232  print "</table>\n";
233  print '</div>';
234 
235  $db->free($resql);
236 }
237 else
238 {
239  dol_print_error($db);
240 }
241 
242 llxFooter();
243 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header 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.
Class to manage Dolibarr users.
Definition: user.class.php:39
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.
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:46
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).
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:1013
Class to manage standing orders rejects.