From 40e421c6de17177228cce710c8dc26e6a94beab2 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 7 Nov 2003 16:50:07 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/admin/system/gen-commande.php | 79 ++++++++++++++++++++ htdocs/product/stats/month.php | 108 +++++++++++++++++++++++++++ htdocs/product/stats/pre.inc.php | 18 +---- 3 files changed, 188 insertions(+), 17 deletions(-) create mode 100644 htdocs/admin/system/gen-commande.php create mode 100644 htdocs/product/stats/month.php diff --git a/htdocs/admin/system/gen-commande.php b/htdocs/admin/system/gen-commande.php new file mode 100644 index 00000000000..ed1b37d8b57 --- /dev/null +++ b/htdocs/admin/system/gen-commande.php @@ -0,0 +1,79 @@ + + * + * 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(); + +$sql = "SELECT rowid FROM llx_product"; $productsid = array(); +if ($db->query($sql)) { + $num = $db->num_rows(); $i = 0; + while ($i < $num) { $row = $db->fetch_row($i); $productsid[$i] = $row[0]; $i++; } } + +$sql = "SELECT idp FROM llx_societe"; $societesid = array(); +if ($db->query($sql)) { $num = $db->num_rows(); $i = 0; +while ($i < $num) { $row = $db->fetch_row($i); $societesid[$i] = $row[0]; $i++; } } else { print "err"; } + +$dates = array (mktime(12,0,0,1,3,2003), + mktime(12,0,0,1,9,2003), + mktime(12,0,0,2,13,2003), + mktime(12,0,0,2,23,2003), + mktime(12,0,0,3,30,2003), + mktime(12,0,0,4,3,2003), + mktime(12,0,0,4,3,2003), + mktime(12,0,0,5,9,2003), + mktime(12,0,0,5,1,2003), + mktime(12,0,0,5,13,2003), + mktime(12,0,0,5,19,2003), + mktime(12,0,0,5,23,2003), + mktime(12,0,0,6,3,2003), + mktime(12,0,0,6,19,2003), + mktime(12,0,0,6,24,2003), + mktime(12,0,0,7,3,2003), + mktime(12,0,0,7,9,2003), + mktime(12,0,0,7,23,2003), + mktime(12,0,0,7,30,2003), + mktime(12,0,0,8,9,2003), + mktime(12,0,0,9,23,2003), + mktime(12,0,0,10,3,2003) + ); + +require DOL_DOCUMENT_ROOT."/commande/commande.class.php"; + +$com = new Commande($db); + +$com->soc_id = 4; +$com->date_commande = $dates[rand(1, sizeof($dates)-1)]; +$com->note = $HTTP_POST_VARS["note"]; +$com->source = 1; +$com->projetid = 0; +$com->remise_percent = 0; + +$pidrand = rand(1, sizeof($productsid)-1); +$com->add_product($productsid[rand(1, sizeof($productsid)-1)],rand(1,11),rand(1,6),rand(0,20)); + +print $com->create($user) . " " . $com->date_commande; + + + + + +llxFooter(); +?> diff --git a/htdocs/product/stats/month.php b/htdocs/product/stats/month.php new file mode 100644 index 00000000000..91f3890dcf9 --- /dev/null +++ b/htdocs/product/stats/month.php @@ -0,0 +1,108 @@ + + * + * 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"); +require("../commande.class.php"); +require("../../graph.class.php"); +require("./commandestats.class.php"); + +llxHeader(); + +$mesg = ''; + +/* + * + * + */ + +$stats = new CommandeStats($db); + +$year = $_GET["year"]; + +print_fiche_titre('Statistiques commandes '.$year, $mesg); + +$dir = DOL_DOCUMENT_ROOT; + +//////////////////////// + +$res = $stats->getNbCommandeByMonth($year); + +$data = array(); + +for ($i = 1 ; $i < 13 ; $i++) +{ + $data[$i-1] = array(strftime("%b",mktime(12,12,12,$i,1,$year)), $res[$i]); +} + +$filev = "/document/images/commande.png"; + +$px = new Graph(); +$px->SetYLabel("Nombre de commande"); +$px->draw($dir.$filev, $data, $year); + +$res = $stats->getCommandeAmountByMonth($year); + +$data = array(); + +for ($i = 1 ; $i < 13 ; $i++) +{ + $data[$i-1] = array(strftime("%b",mktime(12,12,12,$i,1,$year)), $res[$i]); +} + +$file_amount = "/document/images/commandeamount.png"; + +$px = new Graph(); +$px->SetYLabel("Montant des commande"); +$px->draw($dir.$file_amount, $data, $year); + +$res = $stats->getCommandeAverageByMonth($year); + +$data = array(); + +for ($i = 1 ; $i < 13 ; $i++) +{ + $data[$i-1] = array(strftime("%b",mktime(12,12,12,$i,1,$year)), $res[$i]); +} +$file_avg = "/document/images/commandeaverage.png"; +$px = new Graph(); +$px->SetYLabel("Montant moyen des commande"); +$px->draw($dir.$file_avg, $data, $year); + + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print '
Nombre de commande par mois'; +print ''; +print '
Sommes des commandes'; +print ''; +print '
Montant moyen des commande'; +print ''; +print '
'; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/product/stats/pre.inc.php b/htdocs/product/stats/pre.inc.php index 3eb4d2b5ef4..c9207460fca 100644 --- a/htdocs/product/stats/pre.inc.php +++ b/htdocs/product/stats/pre.inc.php @@ -21,33 +21,17 @@ */ require("../../main.inc.php"); -$types[0] = "produit"; -$types[1] = "service"; - function llxHeader($head = "", $urlp = "") { - global $user, $conf; - - /* - * - * - */ top_menu($head); $menu = new Menu(); - $menu->add(DOL_URL_ROOT."/product/index.php?type=0", "Produits"); - $menu->add_submenu("../liste.php?type=0","Liste"); - $menu->add_submenu("../fiche.php?action=create&type=0","Nouveau produit"); - - $menu->add(DOL_URL_ROOT."/product/index.php?amp;type=1", "Services"); - $menu->add_submenu("../liste.php?type=1","Liste"); - $menu->add_submenu("../fiche.php?action=create&type=1","Nouveau service"); + $menu->add(DOL_URL_ROOT."/commande/", "Commandes"); $menu->add("./", "Statistiques"); - $menu->add_submenu("../popuprop.php", "Popularité"); left_menu($menu->liste); /*