dolibarr  7.0.0-beta
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 <http://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 $langs->loadLangs(array("banks","categories",'withdrawals','bills'));
33 
34 // Security check
35 if ($user->societe_id > 0) accessforbidden();
36 
37 // Get supervariables
38 $prev_id = GETPOST('id','int');
39 $ref = GETPOST('ref', 'alpha');
40 
41 // Load variable for pagination
42 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
43 $sortfield = GETPOST('sortfield','alpha');
44 $sortorder = GETPOST('sortorder','alpha');
45 $page = GETPOST('page','int');
46 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
47 $offset = $limit * $page;
48 $pageprev = $page - 1;
49 $pagenext = $page + 1;
50 
51 
52 $object = new BonPrelevement($db,"");
53 
54 
55 /*
56  * View
57  */
58 
59 llxHeader('',$langs->trans("WithdrawalsReceipts"));
60 
61 if ($prev_id > 0 || $ref)
62 {
63  if ($object->fetch($prev_id, $ref) >= 0)
64  {
65  $head = prelevement_prepare_head($object);
66  dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
67 
68  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php">'.$langs->trans("BackToList").'</a>';
69 
70  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
71 
72  print '<div class="fichecenter">';
73  print '<div class="underbanner clearboth"></div>';
74  print '<table class="border centpercent">'."\n";
75 
76  //print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
77  print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec,'day').'</td></tr>';
78  print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
79 
80  // Status
81  /*
82  print '<tr><td>'.$langs->trans('Status').'</td>';
83  print '<td>'.$object->getLibStatut(1).'</td>';
84  print '</tr>';
85  */
86 
87  if($object->date_trans <> 0)
88  {
89  $muser = new User($db);
90  $muser->fetch($object->user_trans);
91 
92  print '<tr><td>'.$langs->trans("TransData").'</td><td>';
93  print dol_print_date($object->date_trans,'day');
94  print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
95  print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
96  print $object->methodes_trans[$object->method_trans];
97  print '</td></tr>';
98  }
99  if($object->date_credit <> 0)
100  {
101  print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
102  print dol_print_date($object->date_credit,'day');
103  print '</td></tr>';
104  }
105 
106  print '</table>';
107 
108  print '<br>';
109 
110  print '<div class="underbanner clearboth"></div>';
111  print '<table class="border" width="100%">';
112 
113  $acc = new Account($db);
114  $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
115 
116  print '<tr><td class="titlefield">';
117  print $langs->trans("BankToReceiveWithdraw");
118  print '</td>';
119  print '<td>';
120  if ($acc->id > 0)
121  print $acc->getNomUrl(1);
122  print '</td>';
123  print '</tr>';
124 
125  print '<tr><td class="titlefield">';
126  print $langs->trans("WithdrawalFile").'</td><td>';
127  $relativepath = 'receipts/'.$object->ref.'.xml';
128  print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
129  print '</td></tr></table>';
130 
131  print '</div>';
132 
133  dol_fiche_end();
134 
135  }
136  else
137  {
138  $langs->load("errors");
139  print $langs->trans("Error");
140  }
141 
142  /*
143  * Stats
144  */
145  $ligne=new LignePrelevement($db,$user);
146 
147  $sql = "SELECT sum(pl.amount), pl.statut";
148  $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
149  $sql.= " WHERE pl.fk_prelevement_bons = ".$object->id;
150  $sql.= " GROUP BY pl.statut";
151 
152  $resql=$db->query($sql);
153  if ($resql)
154  {
155  $num = $db->num_rows($resql);
156  $i = 0;
157 
158  print load_fiche_titre($langs->trans("StatisticsByLineStatus"),'','');
159 
160  print"\n<!-- debut table -->\n";
161  print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
162  print '<tr class="liste_titre">';
163  print '<td>'.$langs->trans("Status").'</td><td align="right">'.$langs->trans("Amount").'</td><td align="right">%</td></tr>';
164 
165  while ($i < $num)
166  {
167  $row = $db->fetch_row($resql);
168 
169  print '<tr class="oddeven"><td>';
170 
171  print $ligne->LibStatut($row[1],1);
172 
173  print '</td><td align="right">';
174  print price($row[0]);
175 
176  print '</td><td align="right">';
177  if ($object->amount) print round($row[0]/$object->amount*100,2)." %";
178  print '</td>';
179 
180  print "</tr>\n";
181 
182 
183  $i++;
184  }
185 
186  print "</table>";
187  $db->free($resql);
188  }
189  else
190  {
191  print $db->error() . ' ' . $sql;
192  }
193 }
194 
195 llxFooter();
196 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
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
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 ...
Class to manage withdrawal receipts.
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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 withdrawals.