[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/commande/stats/ -> month.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (c) 2004      Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: month.php,v 1.12 2005/08/13 21:23:02 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/commande/stats/month.php,v $
  21   *
  22   */
  23  
  24  /**
  25          \file       htdocs/commande/stats/month.php
  26          \ingroup    commande
  27          \brief      Page des stats commandes par mois
  28          \version    $Revision: 1.12 $
  29  */
  30  
  31  require ("./pre.inc.php");
  32  require (DOL_DOCUMENT_ROOT."/commande/commande.class.php");
  33  require ("./commandestats.class.php");
  34  
  35  /*
  36   * Sécurité accés client
  37   */
  38  if ($user->societe_id > 0) 
  39  {
  40    $action = '';
  41    $socidp = $user->societe_id;
  42  }
  43  
  44  llxHeader();
  45  
  46  $year = isset($_GET["year"])?$_GET["year"]:date("Y",time());
  47  
  48  $mesg = '<a href="month.php?year='.($year - 1).'">'.img_previous().'</a> ';
  49  $mesg.= $langs->trans("Year")." $year";
  50  $mesg.= ' <a href="month.php?year='.($year + 1).'">'.img_next().'</a>';
  51  
  52  $WIDTH=500;
  53  $HEIGHT=250;
  54  
  55  /*
  56   *
  57   *
  58   */
  59  
  60  print_fiche_titre($langs->trans("OrdersStatistics"), $mesg);
  61  
  62  $stats = new CommandeStats($db, $socidp);
  63  $data = $stats->getNbByMonth($year);
  64  
  65  if (! is_dir($conf->commande->dir_images)) { mkdir($conf->commande->dir_images); }
  66  
  67  $filename = $conf->commande->dir_images."/commande".$year.".png";
  68  $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commande'.$year.'.png';
  69  
  70  $px = new BarGraph();
  71  $mesg = $px->isGraphKo();
  72  if (! $mesg) {
  73      $px->SetData($data);
  74      $px->SetMaxValue($px->GetMaxValue());
  75      $px->SetWidth($WIDTH);
  76      $px->SetHeight($HEIGHT);
  77      $px->SetYLabel("Nombre de commande");
  78      $px->draw($filename);
  79  }
  80  
  81  $res = $stats->getAmountByMonth($year);
  82  
  83  $data = array();
  84  
  85  for ($i = 1 ; $i < 13 ; $i++)
  86  {
  87    $data[$i-1] = array(ucfirst(substr(strftime("%b",mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]);
  88  }
  89  
  90  $filename_amount = $conf->commande->dir_images."/commandeamount".$year.".png";
  91  $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeamount'.$year.'.png';
  92  
  93  $px = new BarGraph();
  94  $mesg = $px->isGraphKo();
  95  if (! $mesg) {
  96      $px->SetData($data);
  97      $px->SetMaxValue($px->GetAmountMaxValue());
  98      $px->SetWidth($WIDTH);
  99      $px->SetHeight($HEIGHT);
 100      $px->SetYLabel($langs->trans("AmountTotal"));
 101      $px->draw($filename_amount);
 102  }
 103  $res = $stats->getAverageByMonth($year);
 104  
 105  $data = array();
 106  
 107  for ($i = 1 ; $i < 13 ; $i++)
 108  {
 109    $data[$i-1] = array(ucfirst(substr(strftime("%b",mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]);
 110  }
 111  
 112  $filename_avg = $conf->commande->dir_images."/commandeaverage".$year.".png";
 113  $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeaverage'.$year.'.png';
 114  
 115  $px = new BarGraph();
 116  $mesg = $px->isGraphKo();
 117  if (! $mesg) {
 118      $px->SetData($data);
 119      $px->SetMaxValue($px->GetAmountMaxValue());
 120      $px->SetWidth($WIDTH);
 121      $px->SetHeight($HEIGHT);
 122      $px->SetYLabel($langs->trans("AmountAverage"));
 123      $px->draw($filename_avg);
 124  }
 125  
 126  print '<table class="border" width="100%">';
 127  print '<tr><td align="center">'.$langs->trans("NumberOfOrdersByMonth").'</td>';
 128  print '<td align="center">';
 129  if ($mesg) { print $mesg; }
 130  else { print '<img src="'.$fileurl.'">'; }
 131  print '</td></tr>';
 132  print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>';
 133  print '<td align="center">';
 134  if ($mesg) { print $mesg; }
 135  else { print '<img src="'.$fileurl_amount.'">'; }
 136  print '</td></tr>';
 137  print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>';
 138  print '<td align="center">';
 139  if ($mesg) { print $mesg; }
 140  else { print '<img src="'.$fileurl_avg.'">'; }
 141  print '</td></tr></table>';
 142  
 143  $db->close();
 144  
 145  llxFooter('$Date: 2005/08/13 21:23:02 $ - $Revision: 1.12 $');
 146  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics