dolibarr 21.0.0-alpha
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// Load Dolibarr environment
27require '../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
32require_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// Get supervariables
38$id = GETPOSTINT('id');
39$ref = GETPOST('ref', 'alpha');
40
41$type = GETPOST('type', 'aZ09');
42
43// Load variable for pagination
44$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
45$sortfield = GETPOST('sortfield', 'aZ09comma');
46$sortorder = GETPOST('sortorder', 'aZ09comma');
47$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
48if (empty($page) || $page == -1) {
49 $page = 0;
50} // If $page is not defined, or '' or -1
51$offset = $limit * $page;
52$pageprev = $page - 1;
53$pagenext = $page + 1;
54
55
56$object = new BonPrelevement($db);
57
58// Load object
59include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
60
61// Security check
62if ($user->socid > 0) {
64}
65
66$type = $object->type;
67if ($type == 'bank-transfer') {
68 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
69} else {
70 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
71}
72
73
74
75/*
76 * View
77 */
78
79$form = new Form($db);
80
81llxHeader('', $langs->trans("WithdrawalsReceipts"));
82
83if ($id > 0 || $ref) {
84 if ($object->fetch($id, $ref) >= 0) {
85 $head = prelevement_prepare_head($object);
86 print dol_get_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
87
88 $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>';
89
90 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
91
92 print '<div class="fichecenter">';
93 print '<div class="underbanner clearboth"></div>';
94 print '<table class="border centpercent tableforfield">'."\n";
95
96 //print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
97 print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
98 print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
99
100 if (!empty($object->date_trans)) {
101 $muser = new User($db);
102 $muser->fetch($object->user_trans);
103
104 print '<tr><td>'.$langs->trans("TransData").'</td><td>';
105 print dol_print_date($object->date_trans, 'day');
106 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td></tr>';
107 print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
108 print $object->methodes_trans[$object->method_trans];
109 print '</td></tr>';
110 }
111 if (!empty($object->date_credit)) {
112 print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
113 print dol_print_date($object->date_credit, 'day');
114 print '</td></tr>';
115 }
116
117 print '</table>';
118
119 print '<br>';
120
121 print '<div class="underbanner clearboth"></div>';
122 print '<table class="border centpercent tableforfield">';
123
124 // Get bank account for the payment
125 $acc = new Account($db);
126 $fk_bank_account = $object->fk_bank_account;
127 if (empty($fk_bank_account)) {
128 $fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT'));
129 }
130 if ($fk_bank_account > 0) {
131 $result = $acc->fetch($fk_bank_account);
132 }
133
134 $labelofbankfield = "BankToReceiveWithdraw";
135 if ($object->type == 'bank-transfer') {
136 $labelofbankfield = 'BankToPayCreditTransfer';
137 }
138
139 print '<tr><td class="titlefieldcreate">';
140 print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
141 print '</td>';
142 print '<td>';
143 if ($acc->id > 0) {
144 print $acc->getNomUrl(1);
145 }
146 print '</td>';
147 print '</tr>';
148
149 $modulepart = 'prelevement';
150 if ($object->type == 'bank-transfer') {
151 $modulepart = 'paymentbybanktransfer';
152 }
153
154 print '<tr><td class="titlefieldcreate">';
155 $labelfororderfield = 'WithdrawalFile';
156 if ($object->type == 'bank-transfer') {
157 $labelfororderfield = 'CreditTransferFile';
158 }
159 print $langs->trans($labelfororderfield).'</td><td>';
160
161 if (isModEnabled('multicompany')) {
162 $labelentity = $conf->entity;
163 $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml';
164
165 if ($type != 'bank-transfer') {
166 $dir = $conf->prelevement->dir_output;
167 } else {
168 $dir = $conf->paymentbybanktransfer->dir_output;
169 }
170 if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility
171 $relativepath = 'receipts/'.$object->ref.'.xml';
172 }
173 } else {
174 $relativepath = 'receipts/'.$object->ref.'.xml';
175 }
176
177 print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
178 print img_picto('', 'download', 'class="paddingleft"');
179 print '</a>';
180 print '</td></tr></table>';
181
182 print '</div>';
183
184 print dol_get_fiche_end();
185 } else {
186 dol_print_error($db);
187 }
188
189 /*
190 * Stats
191 */
192 $line = new LignePrelevement($db);
193
194 $sql = "SELECT sum(pl.amount), pl.statut";
195 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
196 $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $object->id);
197 $sql .= " GROUP BY pl.statut";
198
199 $resql = $db->query($sql);
200 if ($resql) {
201 $num = $db->num_rows($resql);
202 $i = 0;
203
204 print load_fiche_titre($langs->trans("StatisticsByLineStatus"), '', '');
205
206 print"\n<!-- debut table -->\n";
207 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
208 print '<table class="noborder centpercent">';
209 print '<tr class="liste_titre">';
210 print '<td>'.$langs->trans("Status").'</td><td class="right">'.$langs->trans("Amount").'</td><td class="right">%</td></tr>';
211
212 while ($i < $num) {
213 $row = $db->fetch_row($resql);
214
215 print '<tr class="oddeven"><td>';
216
217 print $line->LibStatut($row[1], 1);
218
219 print '</td>';
220
221 print '<td class="right"><span class="amount">';
222 print price($row[0]);
223 print '</span></td>';
224
225 print '<td class="right">';
226 if ($object->amount) {
227 print round($row[0] / $object->amount * 100, 2)." %";
228 }
229 print '</td>';
230
231 print "</tr>\n";
232
233
234 $i++;
235 }
236
237 print "</table>";
238 print "</div>";
239
240 $db->free($resql);
241 } else {
242 print $db->error().' '.$sql;
243 }
244}
245
246// End of page
247llxFooter();
248$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage bank accounts.
Class to manage withdrawal receipts.
Class to manage generation of HTML components Only common components must be here.
Class to manage withdrawals.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
dol_is_file($pathoffile)
Return if path is a file.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.