dolibarr  17.0.4
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 Charles-Fr BENKE <charles.fr@benke.fr>
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 <https://www.gnu.org/licenses/>.
19  */
20 
27 // Load Dolibarr environment
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array('banks', 'categories'));
35 
36 $WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380); // Large for one graph in a smarpthone.
37 $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160);
38 
39 $id = GETPOST('account') ?GETPOST('account', 'alpha') : GETPOST('id');
40 $ref = GETPOST('ref');
41 
42 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
43 $hookmanager->initHooks(array('bankannualreport', 'globalcard'));
44 
45 // Security check
46 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
47 $fieldtype = (!empty($ref) ? 'ref' : 'rowid');
48 if ($user->socid) {
49  $socid = $user->socid;
50 }
51 $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype);
52 
53 $year_start = GETPOST('year_start');
54 $year_current = strftime("%Y", time());
55 if (!$year_start) {
56  $year_start = $year_current - 2;
57  $year_end = $year_current;
58 } else {
59  $year_end = $year_start + 2;
60 }
61 
62 
63 
64 /*
65  * View
66  */
67 
68 $form = new Form($db);
69 
70 // Get account informations
71 $object = new Account($db);
72 if ($id > 0 && !preg_match('/,/', $id)) { // if for a particular account and not a list
73  $result = $object->fetch($id);
74  $id = $object->id;
75 }
76 if (!empty($ref)) {
77  $result = $object->fetch(0, $ref);
78  $id = $object->id;
79 }
80 
81 $annee = '';
82 $totentrees = array();
83 $totsorties = array();
84 
85 $title = $object->ref.' - '.$langs->trans("IOMonthlyReporting");
86 $helpurl = "";
87 llxHeader('', $title, $helpurl);
88 
89 // Ce rapport de tresorerie est base sur llx_bank (car doit inclure les transactions sans facture)
90 // plutot que sur llx_paiement + llx_paiementfourn
91 
92 $sql = "SELECT SUM(b.amount)";
93 $sql .= ", date_format(b.dateo,'%Y-%m') as dm";
94 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
95 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
96 $sql .= " WHERE b.fk_account = ba.rowid";
97 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
98 $sql .= " AND b.amount >= 0";
99 if (!empty($id)) {
100  $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")";
101 }
102 $sql .= " GROUP BY dm";
103 
104 $resql = $db->query($sql);
105 if ($resql) {
106  $num = $db->num_rows($resql);
107  $i = 0;
108  while ($i < $num) {
109  $row = $db->fetch_row($resql);
110  $encaiss[$row[1]] = $row[0];
111  $i++;
112  }
113 } else {
114  dol_print_error($db);
115 }
116 
117 $sql = "SELECT SUM(b.amount)";
118 $sql .= ", date_format(b.dateo,'%Y-%m') as dm";
119 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
120 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
121 $sql .= " WHERE b.fk_account = ba.rowid";
122 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
123 $sql .= " AND b.amount <= 0";
124 if (!empty($id)) {
125  $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")";
126 }
127 $sql .= " GROUP BY dm";
128 
129 $resql = $db->query($sql);
130 if ($resql) {
131  $num = $db->num_rows($resql);
132  $i = 0;
133  while ($i < $num) {
134  $row = $db->fetch_row($resql);
135  $decaiss[$row[1]] = -$row[0];
136  $i++;
137  }
138 } else {
139  dol_print_error($db);
140 }
141 
142 
143 // Onglets
144 $head = bank_prepare_head($object);
145 print dol_get_fiche_head($head, 'annual', $langs->trans("FinancialAccount"), 0, 'account');
146 
147 $title = $langs->trans("FinancialAccount")." : ".$object->label;
148 $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>' : '');
149 
150 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
151 
152 $morehtmlref = '';
153 
154 if (!empty($id)) {
155  if (!preg_match('/,/', $id)) {
156  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
157  } else {
158  $bankaccount = new Account($db);
159  $listid = explode(',', $id);
160  foreach ($listid as $key => $aId) {
161  $bankaccount->fetch($aId);
162  $bankaccount->label = $bankaccount->ref;
163  print $bankaccount->getNomUrl(1);
164  if ($key < (count($listid) - 1)) {
165  print ', ';
166  }
167  }
168  }
169 } else {
170  print $langs->trans("AllAccounts");
171 }
172 
173 print dol_get_fiche_end();
174 
175 
176 // Affiche tableau
177 print load_fiche_titre('', $link, '');
178 
179 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
180 print '<table class="noborder centpercent">';
181 
182 print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
183 for ($annee = $year_start; $annee <= $year_end; $annee++) {
184  print '<td align="center" width="20%" colspan="2" class="liste_titre borderrightlight">'.$annee.'</td>';
185 }
186 print '</tr>';
187 
188 print '<tr class="liste_titre">';
189 print '<td class="liste_titre">&nbsp;</td>';
190 for ($annee = $year_start; $annee <= $year_end; $annee++) {
191  print '<td class="liste_titre" align="center">'.$langs->trans("Debit").'</td><td class="liste_titre" align="center">'.$langs->trans("Credit").'</td>';
192 }
193 print '</tr>';
194 
195 for ($mois = 1; $mois < 13; $mois++) {
196  print '<tr class="oddeven">';
197  print "<td>".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B")."</td>";
198 
199  for ($annee = $year_start; $annee <= $year_end; $annee++) {
200  $totsorties[$annee] = isset($totsorties[$annee]) ? $totsorties[$annee] : 0;
201  $totentrees[$annee] = isset($totentrees[$annee]) ? $totentrees[$annee] : 0;
202 
203  $case = sprintf("%04s-%02s", $annee, $mois);
204 
205  print '<td class="right" width="10%">&nbsp;';
206  if (isset($decaiss[$case]) && $decaiss[$case] > 0) {
207  print price($decaiss[$case]);
208  $totsorties[$annee] += $decaiss[$case];
209  }
210  print "</td>";
211 
212  print '<td class="right borderrightlight" width="10%">&nbsp;';
213  if (isset($encaiss[$case]) && $encaiss[$case] > 0) {
214  print price($encaiss[$case]);
215  $totentrees[$annee] += $encaiss[$case];
216  }
217  print "</td>";
218  }
219  print '</tr>';
220 }
221 
222 // Total debit-credit
223 print '<tr class="liste_total"><td><b>'.$langs->trans("Total")."</b></td>";
224 for ($annee = $year_start; $annee <= $year_end; $annee++) {
225  print '<td class="right nowraponall"><b>'. (isset($totsorties[$annee]) ? price($totsorties[$annee]) : '') .'</b></td>';
226  print '<td class="right nowraponall"><b>'. (isset($totentrees[$annee]) ? price($totentrees[$annee]) : '') .'</b></td>';
227 }
228 print "</tr>\n";
229 
230 print "</table>";
231 print "</div>";
232 
233 print '<br>';
234 
235 
236 // Current balance
237 $balance = 0;
238 
239 $sql = "SELECT SUM(b.amount) as total";
240 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
241 $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
242 $sql .= " WHERE b.fk_account = ba.rowid";
243 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
244 if (!empty($id)) {
245  $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")";
246 }
247 
248 $resql = $db->query($sql);
249 if ($resql) {
250  $obj = $db->fetch_object($resql);
251  if ($obj) {
252  $balance = $obj->total;
253  }
254 } else {
255  dol_print_error($db);
256 }
257 
258 print '<table class="noborder centpercent">';
259 
260 $nbcol = '';
261 print '<tr class="liste_total"><td><b>'.$langs->trans("CurrentBalance")."</b></td>";
262 print '<td colspan="'.($nbcol).'" class="right">'.price($balance).'</td>';
263 print "</tr>\n";
264 
265 print "</table>";
266 
267 // BUILDING GRAPHICS
268 
269 $year = $year_end;
270 
271 $result = dol_mkdir($conf->bank->dir_temp);
272 if ($result < 0) {
273  $langs->load("errors");
274  $error++;
275  setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors');
276 } else {
277  // Calcul de $min et $max
278  $sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max";
279  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
280  $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
281  $sql .= " WHERE b.fk_account = ba.rowid";
282  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
283  if ($id && GETPOST("option") != 'all') {
284  $sql .= " AND b.fk_account IN (".$db->sanitize($id).")";
285  }
286 
287  $resql = $db->query($sql);
288  if ($resql) {
289  $num = $db->num_rows($resql);
290  $obj = $db->fetch_object($resql);
291  $min = $db->jdate($obj->min);
292  $max = $db->jdate($obj->max);
293  } else {
294  dol_print_error($db);
295  }
296  $log = "graph.php: min=".$min." max=".$max;
297  dol_syslog($log);
298 
299  // CRED PART
300  // Chargement du tableau des années
301  $tblyear[0] = array();
302  $tblyear[1] = array();
303  $tblyear[2] = array();
304 
305  for ($annee = 0; $annee < 3; $annee++) {
306  $sql = "SELECT date_format(b.datev,'%m')";
307  $sql .= ", SUM(b.amount)";
308  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
309  $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
310  $sql .= " WHERE b.fk_account = ba.rowid";
311  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
312  $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'";
313  $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'";
314  $sql .= " AND b.amount > 0";
315  if ($id && GETPOST("option") != 'all') {
316  $sql .= " AND b.fk_account IN (".$db->sanitize($id).")";
317  }
318  $sql .= " GROUP BY date_format(b.datev,'%m');";
319 
320  $resql = $db->query($sql);
321  if ($resql) {
322  $num = $db->num_rows($resql);
323  $i = 0;
324  while ($i < $num) {
325  $row = $db->fetch_row($resql);
326  $tblyear[$annee][$row[0]] = $row[1];
327  $i++;
328  }
329  $db->free($resql);
330  } else {
331  dol_print_error($db);
332  }
333  }
334  // Chargement de labels et data_xxx pour tableau 4 Mouvements
335  $labels = array();
336  $data_year_0 = array();
337  $data_year_1 = array();
338  $data_year_2 = array();
339 
340  for ($i = 0; $i < 12; $i++) {
341  $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0;
342  $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0;
343  $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0;
344  $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1));
345  $datamin[$i] = 0;
346  }
347 
348  // Fabrication tableau 4b
349  $file = $conf->bank->dir_temp."/credmovement".$id."-".$year.".png";
350  $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png";
351  $title = $langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year;
352  $graph_datas = array();
353  for ($i = 0; $i < 12; $i++) {
354  $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
355  }
356 
357  $px1 = new DolGraph();
358  $px1->SetData($graph_datas);
359  $px1->SetLegend(array(($year), ($year - 1), ($year - 2)));
360  $px1->SetLegendWidthMin(180);
361  $px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue());
362  $px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue());
363  $px1->SetTitle($title);
364  $px1->SetWidth($WIDTH);
365  $px1->SetHeight($HEIGHT);
366  $px1->SetType(array('line', 'line', 'line'));
367  $px1->SetShading(3);
368  $px1->setBgColor('onglet');
369  $px1->setBgColorGrid(array(255, 255, 255));
370  $px1->SetHorizTickIncrement(1);
371  $px1->draw($file, $fileurl);
372 
373  $show1 = $px1->show();
374 
375  unset($graph_datas);
376  unset($px1);
377  unset($tblyear[0]);
378  unset($tblyear[1]);
379  unset($tblyear[2]);
380 
381  // DEDBT PART
382  // Chargement du tableau des années
383  $tblyear[0] = array();
384  $tblyear[1] = array();
385  $tblyear[2] = array();
386 
387  for ($annee = 0; $annee < 3; $annee++) {
388  $sql = "SELECT date_format(b.datev,'%m')";
389  $sql .= ", SUM(b.amount)";
390  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
391  $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
392  $sql .= " WHERE b.fk_account = ba.rowid";
393  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
394  $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'";
395  $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'";
396  $sql .= " AND b.amount < 0";
397  if ($id && GETPOST("option") != 'all') {
398  $sql .= " AND b.fk_account IN (".$db->sanitize($id).")";
399  }
400  $sql .= " GROUP BY date_format(b.datev,'%m');";
401 
402  $resql = $db->query($sql);
403  if ($resql) {
404  $num = $db->num_rows($resql);
405  $i = 0;
406  while ($i < $num) {
407  $row = $db->fetch_row($resql);
408  $tblyear[$annee][$row[0]] = abs($row[1]);
409  $i++;
410  }
411  $db->free($resql);
412  } else {
413  dol_print_error($db);
414  }
415  }
416  // Chargement de labels et data_xxx pour tableau 4 Mouvements
417  $labels = array();
418  $data_year_0 = array();
419  $data_year_1 = array();
420  $data_year_2 = array();
421 
422  for ($i = 0; $i < 12; $i++) {
423  $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0;
424  $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0;
425  $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0;
426  $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1));
427  $datamin[$i] = 0;
428  }
429 
430  $file = $conf->bank->dir_temp."/debmovement".$id."-".$year.".png";
431  $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png";
432  $title = $langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year;
433  $graph_datas = array();
434  for ($i = 0; $i < 12; $i++) {
435  $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]);
436  }
437 
438  $px2 = new DolGraph();
439  $px2->SetData($graph_datas);
440  $px2->SetLegend(array(($year), ($year - 1), ($year - 2)));
441  $px2->SetLegendWidthMin(180);
442  $px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue());
443  $px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue());
444  $px2->SetTitle($title);
445  $px2->SetWidth($WIDTH);
446  $px2->SetHeight($HEIGHT);
447  $px2->SetType(array('line', 'line', 'line'));
448  $px2->SetShading(3);
449  $px2->setBgColor('onglet');
450  $px2->setBgColorGrid(array(255, 255, 255));
451  $px2->SetHorizTickIncrement(1);
452  $px2->draw($file, $fileurl);
453 
454  $show2 = $px2->show();
455 
456  unset($graph_datas);
457  unset($px2);
458  unset($tblyear[0]);
459  unset($tblyear[1]);
460  unset($tblyear[2]);
461 
462  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.
463  print $show1;
464  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.
465  print $show2;
466  print '</div></div></div>';
467  print '<div style="clear:both"></div>';
468 }
469 
470 
471 print "\n</div><br>\n";
472 
473 // End of page
474 llxFooter();
475 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Definition: bank.lib.php:37
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('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $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='')
Show tabs of a record.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.
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.