diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 9ca08d8a865..a4d36e4cf0a 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -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; + } + } + } diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 719ef7a89f7..54517b9be00 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -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; + } + } + } diff --git a/htdocs/index.php b/htdocs/index.php index 8e341cf30e2..d5d182c2f8b 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -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&mainmenu=members', DOL_URL_ROOT.'/product/liste.php?type=0&mainmenu=products', DOL_URL_ROOT.'/product/liste.php?type=1&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 diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 191619bc1a1..59abcbb53d5 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -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 diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 1d23047ac1b..50c0440d97b 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Éric Seigne - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2006 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -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; + } + } + } diff --git a/htdocs/stats.class.php b/htdocs/stats.class.php deleted file mode 100644 index e3e964a2389..00000000000 --- a/htdocs/stats.class.php +++ /dev/null @@ -1,174 +0,0 @@ - - * - * 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; - } -} - -?> diff --git a/htdocs/stats.php b/htdocs/stats.php deleted file mode 100644 index e3f8bb0c402..00000000000 --- a/htdocs/stats.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * 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 ''; - -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 ""; - print ''; - print ''; - - } - - -} - -print '
'.$titre.''.$nbhv.'
'; - -$db->close(); - -llxFooter("Dernière modification $Date$ révision $Revision$"); -?> diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index 6a041467d0f..e28445aabd6 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -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);