Implemente les stats de comptage de facture, propal et commande sur la page accueil des rsum stats, ce qui permet de supprimer la page stats.php qui fait double emploi et qui n'ait pas au norme de dev ni scurise.

This commit is contained in:
Laurent Destailleur 2007-05-04 22:37:06 +00:00
parent 89c8519343
commit 950de6f884
8 changed files with 142 additions and 246 deletions

View File

@ -2266,6 +2266,46 @@ class Commande extends CommonObject
$this->total_ttc = $xnbp*119.6;
}
/**
* \brief Charge indicateurs this->nb de tableau de bord
* \return int <0 si ko, >0 si ok
*/
function load_state_board()
{
global $conf, $user;
$this->nb=array();
$sql = "SELECT count(co.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as co";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = co.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE 1 = 1";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND IFNULL(c.visible,1)=1";
}
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["orders"]=$obj->nb;
}
return 1;
}
else
{
dolibarr_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
}

View File

@ -2649,6 +2649,45 @@ class Facture extends CommonObject
$this->total_ttc = $xnbp*119.6;
}
/**
* \brief Charge indicateurs this->nb de tableau de bord
* \return int <0 si ko, >0 si ok
*/
function load_state_board()
{
global $conf, $user;
$this->nb=array();
$sql = "SELECT count(f.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = f.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE 1 = 1";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND IFNULL(c.visible,1)=1";
}
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["invoices"]=$obj->nb;
}
return 1;
}
else
{
dolibarr_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
}

View File

@ -124,6 +124,9 @@ if ($user->societe_id == 0)
$conf->adherent->enabled && $user->rights->adherent->lire,
$conf->produit->enabled && $user->rights->produit->lire,
$conf->service->enabled && $user->rights->produit->lire,
$conf->propal->enabled && $user->rights->propale->lire,
$conf->commande->enabled && $user->rights->commande->lire,
$conf->facture->enabled && $user->rights->facture->lire,
$conf->telephonie->enabled && $user->rights->telephonie->lire);
// Fichier des classes qui contiennent la methode load_state_board pour chaque ligne
$includes=array(DOL_DOCUMENT_ROOT."/client.class.php",
@ -132,6 +135,9 @@ if ($user->societe_id == 0)
DOL_DOCUMENT_ROOT."/adherents/adherent.class.php",
DOL_DOCUMENT_ROOT."/product.class.php",
DOL_DOCUMENT_ROOT."/service.class.php",
DOL_DOCUMENT_ROOT."/propal.class.php",
DOL_DOCUMENT_ROOT."/commande/commande.class.php",
DOL_DOCUMENT_ROOT."/facture.class.php",
DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
// Nom des classes qui contiennent la methode load_state_board pour chaque ligne
$classes=array('Client',
@ -140,6 +146,9 @@ if ($user->societe_id == 0)
'Adherent',
'Product',
'Service',
'Propal',
'Commande',
'Facture',
'LigneTel');
// Clé de tableau retourné par la methode load_state_bord pour chaque ligne
$keys=array('customers',
@ -148,6 +157,9 @@ if ($user->societe_id == 0)
'members',
'products',
'services',
'proposals',
'orders',
'invoices',
'sign');
// Icon des lignes du tableau de bord
$icons=array('company',
@ -156,6 +168,9 @@ if ($user->societe_id == 0)
'user',
'product',
'service',
'propal',
'order',
'bill',
'phoning');
// Titre des lignes du tableau de bord
$titres=array($langs->trans("Customers"),
@ -164,6 +179,9 @@ if ($user->societe_id == 0)
$langs->trans("Members"),
$langs->trans("Products"),
$langs->trans("Services"),
$langs->trans("Proposals"),
$langs->trans("CustomersOrders"),
$langs->trans("BillsCustomers"),
$langs->trans("Lignes de téléphonie suivis"));
// Lien des lignes du tableau de bord
$links=array(DOL_URL_ROOT.'/comm/clients.php',
@ -172,6 +190,9 @@ if ($user->societe_id == 0)
DOL_URL_ROOT.'/adherents/liste.php?statut=1&amp;mainmenu=members',
DOL_URL_ROOT.'/product/liste.php?type=0&amp;mainmenu=products',
DOL_URL_ROOT.'/product/liste.php?type=1&amp;mainmenu=products',
DOL_URL_ROOT.'/comm/propal.php?mainmenu=commercial',
DOL_URL_ROOT.'/commande/liste.php?mainmenu=commercial',
DOL_URL_ROOT.'/compta/facture.php?mainmenu=accountancy',
DOL_URL_ROOT.'/telephonie/ligne/index.php');
// Boucle et affiche chaque ligne du tableau

View File

@ -2500,8 +2500,8 @@ class Product
$this->error=$this->db->error();
return -1;
}
}
/**
\brief Affecte les valeurs smarty
\remarks Rodolphe : pour l'instant la fonction est vide mais necessaire pour compatibilite

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@ -2028,6 +2028,45 @@ class Propal extends CommonObject
$this->total_ttc = $xnbp*119.6;
}
/**
* \brief Charge indicateurs this->nb de tableau de bord
* \return int <0 si ko, >0 si ok
*/
function load_state_board()
{
global $conf, $user;
$this->nb=array();
$sql = "SELECT count(p.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
}
$sql.= " WHERE 1 = 1";
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
{
$sql.= " AND IFNULL(c.visible,1)=1";
}
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["proposals"]=$obj->nb;
}
return 1;
}
else
{
dolibarr_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
}

View File

@ -1,174 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
class Stats
{
var $db ;
function Stats($DB)
{
$this->db = $DB;
}
function getNbByMonthWithPrevYear($year)
{
$data1 = $this->getNbByMonth($year - 1);
$data2 = $this->getNbByMonth($year);
$data = array();
for ($i = 0 ; $i < 12 ; $i++)
{
$data[$i] = array($data1[$i][0],
$data1[$i][1],
$data2[$i][1]);
}
return $data;
}
/**
* \brief Renvoie le nombre de proposition par mois pour une année donnée
*
*/
function _getNbByMonth($year, $sql)
{
$result = array();
$resql=$this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
$j = $row[0] * 1;
$result[$j] = $row[1];
$i++;
}
$this->db->free($resql);
}
for ($i = 1 ; $i < 13 ; $i++)
{
$res[$i] = $result[$i] + 0;
}
$data = array();
for ($i = 1 ; $i < 13 ; $i++)
{
$data[$i-1] = array(ucfirst(substr(strftime("%b",mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]);
}
return $data;
}
/**
* \brief Renvoie le nombre d'element par année
*
*/
function _getNbByYear($sql)
{
$result = array();
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($i);
$result[$i] = $row;
$i++;
}
$this->db->free();
}
else {
dolibarr_print_error($this->db);
}
return $result;
}
/**
* \brief Renvoie le nombre d'element par mois pour une année donnée
*
*/
function _getAmountByMonth($year, $sql)
{
$result = array();
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($i);
$j = $row[0] * 1;
$result[$j] = $row[1];
$i++;
}
$this->db->free();
}
for ($i = 1 ; $i < 13 ; $i++)
{
$res[$i] = $result[$i] + 0;
}
return $res;
}
/**
*
*
*/
function _getAverageByMonth($year, $sql)
{
$result = array();
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($i);
$j = $row[0] * 1;
$result[$j] = $row[1];
$i++;
}
$this->db->free();
}
for ($i = 1 ; $i < 13 ; $i++)
{
$res[$i] = $result[$i] + 0;
}
return $res;
}
}
?>

View File

@ -1,69 +0,0 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
llxHeader();
$mesg = '';
/*
*
*
*/
$sql = array(
array("Société","SELECT count(*) FROM ".MAIN_DB_PREFIX."societe"),
array("Contacts","SELECT count(*) FROM ".MAIN_DB_PREFIX."socpeople"),
array("Facture","SELECT count(*) FROM ".MAIN_DB_PREFIX."facture"),
array("Proposition commerciales","SELECT count(*) FROM ".MAIN_DB_PREFIX."propal")
);
print_fiche_titre('Statistiques produits et services', $mesg);
print '<table class="liste" width="100%">';
foreach ($sql as $key => $value)
{
$titre = $sql[$key][0];
if ($db->query($sql[$key][1]))
{
$row = $db->fetch_row(0);
$nbhv = $row[0];
$db->free();
print "<tr $bc[1]>";
print '<td width="40%">'.$titre.'</td>';
print '<td>'.$nbhv.'</td></tr>';
}
}
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -211,7 +211,7 @@ insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titr
insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1710, 'accountancy', 'eregi("customers_bills_payments",$leftmenu)', 1708, '/compta/paiement/rapport.php?leftmenu=customers_bills_payments', 'Reportings', 3, 'bills', '$user->rights->facture->lire', '', 2, 1);
insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1711, 'accountancy', '', 6, '/compta/paiement/cheque/index.php?leftmenu=checks', 'MenuChequeDeposits', 0, 'bills', '$user->rights->facture->lire', '', 2, 1);
insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1712, 'accountancy', 'eregi("checks",$leftmenu)', 1711, '/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'bills', '$user->rights->facture->lire', '', 2, 0);
insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1713, 'accountancy', 'eregi("checks",$leftmenu)', 1711, '/compta/paiement/cheque/fiche.php?leftmenu=checks', 'MenuChequesReceipts', 1, 'bills', '$user->rights->facture->lire', '', 2, 1);
insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1713, 'accountancy', 'eregi("checks",$leftmenu)', 1711, '/compta/paiement/cheque/liste.php?leftmenu=checks', 'MenuChequesReceipts', 1, 'bills', '$user->rights->facture->lire', '', 2, 1);
insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1714, 'accountancy', 'eregi("customers_bills",$leftmenu)', 1704, '/compta/facture/stats/index.php?leftmenu=customers_bills', 'Statistics', 2, 'bills', '$user->rights->facture->lire', '', 2, 8);
insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1715, 'accountancy', '', 1700, '/compta/paiement/cheque/index.php', 'CheckReceipt', 1, 'bills', '$user->rights->facture->lire', '', 1, 4);
insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1716, 'accountancy', '', 1704, '/compta/paiement/cheque/fiche.php?action=new', 'New', 2, 'bills', '$user->rights->facture->lire', '', 1, 9);