dolibarr  21.0.0-alpha
annuel.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013-2023 Charlene BENKE <charlene@patas-monkey.com>
6  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 // Load Dolibarr environment
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array('banks', 'categories'));
36 
37 $WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380); // Large for one graph in a smarpthone.
38 $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160);
39 
40 $id = GETPOST('account') ? GETPOST('account', 'alpha') : GETPOST('id');
41 $ref = GETPOST('ref');
42 
43 // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
44 $hookmanager->initHooks(array('bankannualreport', 'globalcard'));
45 
46 // Security check
47 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
48 $fieldtype = (!empty($ref) ? 'ref' : 'rowid');
49 if ($user->socid) {
50  $socid = $user->socid;
51 }
52 $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype);
53 
54 $year_start = GETPOST('year_start');
55 //$year_current = strftime("%Y", time());
56 $year_current = dol_print_date(time(), "%Y");
57 if (!$year_start) {
58  $year_start = $year_current - 2;
59  $year_end = $year_current;
60 } else {
61  $year_end = $year_start + 2;
62 }
63 
64 
65 
66 /*
67  * View
68  */
69 
70 $form = new Form($db);
71 
72 // Get account information
73 $object = new Account($db);
74 if ($id > 0 && !preg_match('/,/', $id)) { // if for a particular account and not a list
75  $result = $object->fetch($id);
76  $id = $object->id;
77 }
78 if (!empty($ref)) {
79  $result = $object->fetch(0, $ref);
80  $id = $object->id;
81 }
82 
83 $annee = '';
84 $totentrees = array();
85 $totsorties = array();
86 
87 $title = $object->ref.' - '.$langs->trans("IOMonthlyReporting");
88 $helpurl = "";
89 llxHeader('', $title, $helpurl);
90 
91 // Ce rapport de tresorerie est base sur llx_bank (car doit inclure les transactions sans facture)
92 // plutot que sur llx_paiement + llx_paiementfourn
93 
94 $sql = "SELECT SUM(b.amount)";
95 $sql .= ", date_format(b.dateo,'%Y-%m') as dm";
96 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
97 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
98 $sql .= " WHERE b.fk_account = ba.rowid";
99 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
100 $sql .= " AND b.amount >= 0";
101 if (!empty($id)) {
102  $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")";
103 }
104 $sql .= " GROUP BY dm";
105 
106 $resql = $db->query($sql);
107 $encaiss = array();
108 $decaiss = array();
109 if ($resql) {
110  $num = $db->num_rows($resql);
111  $i = 0;
112  while ($i < $num) {
113  $row = $db->fetch_row($resql);
114  $encaiss[$row[1]] = $row[0];
115  $i++;
116  }
117 } else {
118  dol_print_error($db);
119 }
120 
121 $sql = "SELECT SUM(b.amount)";
122 $sql .= ", date_format(b.dateo,'%Y-%m') as dm";
123 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
124 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
125 $sql .= " WHERE b.fk_account = ba.rowid";
126 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
127 $sql .= " AND b.amount <= 0";
128 if (!empty($id)) {
129  $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")";
130 }
131 $sql .= " GROUP BY dm";
132 
133 $resql = $db->query($sql);
134 if ($resql) {
135  $num = $db->num_rows($resql);
136  $i = 0;
137  while ($i < $num) {
138  $row = $db->fetch_row($resql);
139  $decaiss[$row[1]] = -$row[0];
140  $i++;
141  }
142 } else {
143  dol_print_error($db);
144 }
145 
146 
147 // Onglets
148 $head = bank_prepare_head($object);
149 print dol_get_fiche_head($head, 'annual', $langs->trans("FinancialAccount"), 0, 'account');
150 
151 $title = $langs->trans("FinancialAccount")." : ".$object->label;
152 $link = ($year_start ? '<a href="'.$_SERVER["PHP_SELF"].'?account='.$object->id.'&year_start='.($year_start - 1).'">'.img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Year").' <a href="'.$_SERVER["PHP_SELF"].'?account='.$object->id.'&year_start='.($year_start + 1).'">'.img_next('', 'class="valignbottom"').'</a>' : '');
153 
154 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
155 
156 $morehtmlref = '';
157 
158 if (!empty($id)) {
159  if (!preg_match('/,/', $id)) {
160  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
161  } else {
162  $bankaccount = new Account($db);
163  $listid = explode(',', $id);
164  foreach ($listid as $key => $aId) {
165  $bankaccount->fetch($aId);
166  $bankaccount->label = $bankaccount->ref;
167  print $bankaccount->getNomUrl(1);
168  if ($key < (count($listid) - 1)) {
169  print ', ';
170  }
171  }
172  }
173 } else {
174  print $langs->trans("AllAccounts");
175 }
176 
177 print dol_get_fiche_end();
178 
179 
180 // Affiche tableau
181 print load_fiche_titre('', $link, '');
182 
183 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
184 print '<table class="noborder centpercent">';
185 
186 print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
187 for ($annee = $year_start; $annee <= $year_end; $annee++) {
188  print '<td align="center" width="20%" colspan="2" class="liste_titre borderrightlight">'.$annee.'</td>';
189 }
190 print '</tr>';
191 
192 print '<tr class="liste_titre">';
193 print '<td class="liste_titre">&nbsp;</td>';
194 for ($annee = $year_start; $annee <= $year_end; $annee++) {
195  print '<td class="liste_titre" align="center">'.$langs->trans("Debit").'</td><td class="liste_titre" align="center">'.$langs->trans("Credit").'</td>';
196 }
197 print '</tr>';
198 
199 for ($annee = $year_start; $annee <= $year_end; $annee++) {
200  $totsorties[$annee] = 0;
201  $totentrees[$annee] = 0;
202 }
203 
204 for ($mois = 1; $mois < 13; $mois++) {
205  print '<tr class="oddeven">';
206  print "<td>".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B")."</td>";
207 
208  for ($annee = $year_start; $annee <= $year_end; $annee++) {
209  $case = sprintf("%04d-%02d", $annee, $mois);
210 
211  print '<td class="right" width="10%">&nbsp;';
212  if (isset($decaiss[$case]) && $decaiss[$case] > 0) {
213  print price($decaiss[$case]);
214  $totsorties[$annee] += $decaiss[$case];
215  }
216  print "</td>";
217 
218  print '<td class="right borderrightlight" width="10%">&nbsp;';
219  if (isset($encaiss[$case]) && $encaiss[$case] > 0) {
220  print price($encaiss[$case]);
221  $totentrees[$annee] += $encaiss[$case];
222  }
223  print "</td>";
224  }
225  print '</tr>';
226 }
227 
228 // Total debit-credit
229 print '<tr class="liste_total"><td><b>'.$langs->trans("Total")."</b></td>";
230 for ($annee = $year_start; $annee <= $year_end; $annee++) {
231  print '<td class="right nowraponall"><b>'. (isset($totsorties[$annee]) ? price($totsorties[$annee]) : '') .'</b></td>';
232  print '<td class="right nowraponall"><b>'. (isset($totentrees[$annee]) ? price($totentrees[$annee]) : '') .'</b></td>';
233 }
234 print "</tr>\n";
235 
236 print "</table>";
237 print "</div>";
238 
239 print '<br>';
240 
241 
242 // Current balance
243 $balance = 0;
244 
245 $sql = "SELECT SUM(b.amount) as total";
246 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
247 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
248 $sql .= " WHERE b.fk_account = ba.rowid";
249 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
250 if (!empty($id)) {
251  $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")";
252 }
253 
254 $resql = $db->query($sql);
255 if ($resql) {
256  $obj = $db->fetch_object($resql);
257  if ($obj) {
258  $balance = $obj->total;
259  }
260 } else {
261  dol_print_error($db);
262 }
263 
264 print '<table class="noborder centpercent">';
265 
266 $nbcol = '';
267 print '<tr class="liste_total"><td><b>'.$langs->trans("CurrentBalance")."</b></td>";
268 print '<td colspan="'.($nbcol).'" class="right">'.price($balance).'</td>';
269 print "</tr>\n";
270 
271 print "</table>";
272 
273 // BUILDING GRAPHICS
274 
275 $year = $year_end;
276 
277 $result = dol_mkdir($conf->bank->dir_temp);
278 if ($result < 0) {
279  $langs->load("errors");
280  $error++;
281  setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors');
282 } else {
283  // Calcul de $min et $max
284  $sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max";
285  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
286  $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
287  $sql .= " WHERE b.fk_account = ba.rowid";
288  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
289  if ($id && GETPOST("option") != 'all') {
290  $sql .= " AND b.fk_account IN (".$db->sanitize($id).")";
291  }
292 
293  $resql = $db->query($sql);
294  if ($resql) {
295  $num = $db->num_rows($resql);
296  $obj = $db->fetch_object($resql);
297  $min = $db->jdate($obj->min);
298  $max = $db->jdate($obj->max);
299  } else {
300  dol_print_error($db);
301  }
302  $log = "graph.php: min=".$min." max=".$max;
303  dol_syslog($log);
304 
305  // CRED PART
306  // Chargement du tableau des années
307  $tblyear = array();
308  $tblyear[0] = array();
309  $tblyear[1] = array();
310  $tblyear[2] = array();
311 
312  for ($annee = 0; $annee < 3; $annee++) {
313  $sql = "SELECT date_format(b.datev,'%m')";
314  $sql .= ", SUM(b.amount)";
315  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
316  $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
317  $sql .= " WHERE b.fk_account = ba.rowid";
318  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
319  $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'";
320  $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'";
321  $sql .= " AND b.amount > 0";
322  if ($id && GETPOST("option") != 'all') {
323  $sql .= " AND b.fk_account IN (".$db->sanitize($id).")";
324  }
325  $sql .= " GROUP BY date_format(b.datev,'%m');";
326 
327  $resql = $db->query($sql);
328  if ($resql) {
329  $num = $db->num_rows($resql);
330  $i = 0;
331  while ($i < $num) {
332  $row = $db->fetch_row($resql);
333  $tblyear[$annee][$row[0]] = $row[1];
334  $i++;
335  }
336  $db->free($resql);
337  } else {
338  dol_print_error($db);
339  }
340  }
341  // Chargement de labels et data_xxx pour tableau 4 Movements
342  $labels = array();
343  $data_year_0 = array();
344  $data_year_1 = array();
345  $data_year_2 = array();
346  $datamin = array();
347 
348  for ($i = 0; $i < 12; $i++) {
349  $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0;
350  $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0;
351  $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0;
352  $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1));
353  $datamin[$i] = 0;
354  }
355 
356  // Fabrication tableau 4b
357  $file = $conf->bank->dir_temp."/credmovement".$id."-".$year.".png";
358  $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png";
359  $title = $langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year;
360  $graph_datas = array();
361  for ($i = 0; $i < 12; $i++) {
362  $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
363  }
364 
365  $px1 = new DolGraph();
366  $px1->SetData($graph_datas);
367  $px1->SetLegend(array(($year), ($year - 1), ($year - 2)));
368  $px1->SetLegendWidthMin(180);
369  $px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue());
370  $px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue());
371  $px1->SetTitle($title);
372  $px1->SetWidth($WIDTH);
373  $px1->SetHeight($HEIGHT);
374  $px1->SetType(array('line', 'line', 'line'));
375  $px1->SetShading(3);
376  $px1->setBgColor('onglet');
377  $px1->setBgColorGrid(array(255, 255, 255));
378  $px1->SetHorizTickIncrement(1);
379  $px1->draw($file, $fileurl);
380 
381  $show1 = $px1->show();
382 
383  unset($graph_datas);
384  unset($px1);
385  unset($tblyear[0]);
386  unset($tblyear[1]);
387  unset($tblyear[2]);
388 
389  // DEDBT PART
390  // Chargement du tableau des années
391  $tblyear[0] = array();
392  $tblyear[1] = array();
393  $tblyear[2] = array();
394 
395  for ($annee = 0; $annee < 3; $annee++) {
396  $sql = "SELECT date_format(b.datev,'%m')";
397  $sql .= ", SUM(b.amount)";
398  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
399  $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
400  $sql .= " WHERE b.fk_account = ba.rowid";
401  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
402  $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'";
403  $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'";
404  $sql .= " AND b.amount < 0";
405  if ($id && GETPOST("option") != 'all') {
406  $sql .= " AND b.fk_account IN (".$db->sanitize($id).")";
407  }
408  $sql .= " GROUP BY date_format(b.datev,'%m');";
409 
410  $resql = $db->query($sql);
411  if ($resql) {
412  $num = $db->num_rows($resql);
413  $i = 0;
414  while ($i < $num) {
415  $row = $db->fetch_row($resql);
416  $tblyear[$annee][$row[0]] = abs($row[1]);
417  $i++;
418  }
419  $db->free($resql);
420  } else {
421  dol_print_error($db);
422  }
423  }
424  // Chargement de labels et data_xxx pour tableau 4 Movements
425  $labels = array();
426  $data_year_0 = array();
427  $data_year_1 = array();
428  $data_year_2 = array();
429 
430  for ($i = 0; $i < 12; $i++) {
431  $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0;
432  $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0;
433  $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0;
434  $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1));
435  $datamin[$i] = 0;
436  }
437 
438  $file = $conf->bank->dir_temp."/debmovement".$id."-".$year.".png";
439  $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png";
440  $title = $langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year;
441  $graph_datas = array();
442  for ($i = 0; $i < 12; $i++) {
443  $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
444  }
445 
446  $px2 = new DolGraph();
447  $px2->SetData($graph_datas);
448  $px2->SetLegend(array(($year), ($year - 1), ($year - 2)));
449  $px2->SetLegendWidthMin(180);
450  $px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue());
451  $px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue());
452  $px2->SetTitle($title);
453  $px2->SetWidth($WIDTH);
454  $px2->SetHeight($HEIGHT);
455  $px2->SetType(array('line', 'line', 'line'));
456  $px2->SetShading(3);
457  $px2->setBgColor('onglet');
458  $px2->setBgColorGrid(array(255, 255, 255));
459  $px2->SetHorizTickIncrement(1);
460  $px2->draw($file, $fileurl);
461 
462  $show2 = $px2->show();
463 
464  unset($graph_datas);
465  unset($px2);
466  unset($tblyear[0]);
467  unset($tblyear[1]);
468  unset($tblyear[2]);
469 
470  print '<div class="fichecenter"><div class="fichehalfleft"><div align="center">'; // do not use class="center" here, it will have no effect for the js graph inside.
471  print $show1;
472  print '</div></div><div class="fichehalfright"><div align="center">'; // do not use class="center" here, it will have no effect for the js graph inside.
473  print $show2;
474  print '</div></div></div>';
475  print '<div class="clearboth"></div>';
476 }
477 
478 
479 print "\n</div><br>\n";
480 
481 // End of page
482 llxFooter();
483 $db->close();
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()
Empty header.
Definition: wrapper.php:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Definition: bank.lib.php:39
Class to manage bank accounts.
Class to build graphs.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage generation of HTML components Only common components must be here.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:751
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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).
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
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.