dolibarr  13.0.2
fiche-stat.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) 2010-2012 Juanjo Menent <jmenent@2byte.es>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills'));
34 
35 // Security check
36 if ($user->socid > 0) accessforbidden();
37 
38 // Get supervariables
39 $prev_id = GETPOST('id', 'int');
40 $ref = GETPOST('ref', 'alpha');
41 
42 $type = GETPOST('type', 'aZ09');
43 
44 // Load variable for pagination
45 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
46 $sortfield = GETPOST('sortfield', 'aZ09comma');
47 $sortorder = GETPOST('sortorder', 'aZ09comma');
48 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : 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 
55 $object = new BonPrelevement($db);
56 
57 // Load object
58 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
59 
60 if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
62 }
63 if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
65 }
66 
67 
68 
69 /*
70  * View
71  */
72 
73 llxHeader('', $langs->trans("WithdrawalsReceipts"));
74 
75 if ($prev_id > 0 || $ref)
76 {
77  if ($object->fetch($prev_id, $ref) >= 0)
78  {
79  $head = prelevement_prepare_head($object);
80  print dol_get_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
81 
82  $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>';
83 
84  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
85 
86  print '<div class="fichecenter">';
87  print '<div class="underbanner clearboth"></div>';
88  print '<table class="border centpercent tableforfield">'."\n";
89 
90  //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
91  print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
92  print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
93 
94  if ($object->date_trans <> 0)
95  {
96  $muser = new User($db);
97  $muser->fetch($object->user_trans);
98 
99  print '<tr><td>'.$langs->trans("TransData").'</td><td>';
100  print dol_print_date($object->date_trans, 'day');
101  print ' <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getFullName($langs).'</td></tr>';
102  print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
103  print $object->methodes_trans[$object->method_trans];
104  print '</td></tr>';
105  }
106  if ($object->date_credit <> 0)
107  {
108  print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
109  print dol_print_date($object->date_credit, 'day');
110  print '</td></tr>';
111  }
112 
113  print '</table>';
114 
115  print '<br>';
116 
117  print '<div class="underbanner clearboth"></div>';
118  print '<table class="border centpercent tableforfield">';
119 
120  $acc = new Account($db);
121  $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
122 
123  print '<tr><td class="titlefield">';
124  $labelofbankfield = "BankToReceiveWithdraw";
125  if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
126  print $langs->trans($labelofbankfield);
127  print '</td>';
128  print '<td>';
129  if ($acc->id > 0)
130  print $acc->getNomUrl(1);
131  print '</td>';
132  print '</tr>';
133 
134  print '<tr><td class="titlefield">';
135  $labelfororderfield = 'WithdrawalFile';
136  if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
137  print $langs->trans($labelfororderfield).'</td><td>';
138  $relativepath = 'receipts/'.$object->ref.'.xml';
139  $modulepart = 'prelevement';
140  if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
141  print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
142  print '</td></tr></table>';
143 
144  print '</div>';
145 
147  } else {
148  dol_print_error($db);
149  }
150 
151  /*
152  * Stats
153  */
154  $line = new LignePrelevement($db);
155 
156  $sql = "SELECT sum(pl.amount), pl.statut";
157  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
158  $sql .= " WHERE pl.fk_prelevement_bons = ".$object->id;
159  $sql .= " GROUP BY pl.statut";
160 
161  $resql = $db->query($sql);
162  if ($resql)
163  {
164  $num = $db->num_rows($resql);
165  $i = 0;
166 
167  print load_fiche_titre($langs->trans("StatisticsByLineStatus"), '', '');
168 
169  print"\n<!-- debut table -->\n";
170  print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
171  print '<tr class="liste_titre">';
172  print '<td>'.$langs->trans("Status").'</td><td class="right">'.$langs->trans("Amount").'</td><td class="right">%</td></tr>';
173 
174  while ($i < $num)
175  {
176  $row = $db->fetch_row($resql);
177 
178  print '<tr class="oddeven"><td>';
179 
180  print $line->LibStatut($row[1], 1);
181 
182  print '</td><td class="right">';
183  print price($row[0]);
184 
185  print '</td><td class="right">';
186  if ($object->amount) print round($row[0] / $object->amount * 100, 2)." %";
187  print '</td>';
188 
189  print "</tr>\n";
190 
191 
192  $i++;
193  }
194 
195  print "</table>";
196  $db->free($resql);
197  } else {
198  print $db->error().' '.$sql;
199  }
200 }
201 
202 // End of page
203 llxFooter();
204 $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
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage withdrawal receipts.
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.
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 withdrawals.