Fix: Test on permisions

This commit is contained in:
Laurent Destailleur 2009-05-18 11:39:51 +00:00
parent 6db46b53be
commit 5d47ed6e83

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (c) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,10 +18,10 @@
*/ */
/** /**
\file htdocs/commande/stats/index.php * \file htdocs/commande/stats/index.php
\ingroup commande * \ingroup commande
\brief Page des stats commandes * \brief Page des stats commandes
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
@ -32,10 +32,14 @@ require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
$WIDTH=500; $WIDTH=500;
$HEIGHT=200; $HEIGHT=200;
if (!$user->rights->commande->lire) accessforbidden(); $mode='customer';
if (isset($_GET["mode"])) $mode=$_GET["mode"];
// Sécurité accés client if ($mode == 'customer' && ! $user->rights->commande->lire) accessforbidden();
if ($user->societe_id > 0) if ($mode == 'supplier' && ! $user->rights->fournisseur->commande->lire) accessforbidden();
// Security check
if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
@ -45,21 +49,20 @@ $year = strftime("%Y", time());
$startyear=$year-2; $startyear=$year-2;
$endyear=$year; $endyear=$year;
$mode='customer';
if (isset($_GET["mode"])) $mode=$_GET["mode"];
/* /*
* View * View
*/ */
llxHeader(); llxHeader();
if ($mode == 'customer') if ($mode == 'customer')
{ {
$title=$langs->trans("OrdersStatistics"); $title=$langs->trans("OrdersStatistics");
$dir=$conf->commande->dir_temp; $dir=$conf->commande->dir_temp;
} }
if ($mode == 'supplier') if ($mode == 'supplier')
{ {
$title=$langs->trans("OrdersStatisticsSuppliers"); $title=$langs->trans("OrdersStatisticsSuppliers");
$dir=$conf->fournisseur->commande->dir_temp; $dir=$conf->fournisseur->commande->dir_temp;
@ -114,7 +117,7 @@ if (! $mesg)
$px->mode='depth'; $px->mode='depth';
$px->SetTitle($langs->trans("NumberOfOrdersByMonth")); $px->SetTitle($langs->trans("NumberOfOrdersByMonth"));
$px->draw($filenamenb); $px->draw($filenamenb);
} }
// Build graphic amount of object // Build graphic amount of object
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear); $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
@ -173,7 +176,7 @@ print '<td align="center">'.$langs->trans("NbOfOrders").'</td>';
print '<td align="center">'.$langs->trans("AmountTotal").'</td>'; print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'.$langs->trans("AmountAverage").'</td>'; print '<td align="center">'.$langs->trans("AmountAverage").'</td>';
print '</tr>'; print '</tr>';
$oldyear=0; $oldyear=0;
foreach ($data as $val) foreach ($data as $val)
{ {