[ 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/compta/facture/stats/ -> month.php (source)

   1  <?php
   2  /* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (c) 2004-2005 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/07/16 14:56:25 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/facture/stats/month.php,v $
  21   *
  22   */
  23  
  24  /**
  25          \file       htdocs/compta/facture/stats/month.php
  26          \ingroup    facture
  27          \brief      Page des stats factures par mois
  28          \version    $Revision: 1.12 $
  29  */
  30  
  31  require ("./pre.inc.php");
  32  
  33  $GRAPHHEIGHT=250;
  34  $GRAPHWIDTH=500;
  35  
  36  /*
  37   * Sécurité accés client
  38   */
  39  if ($user->societe_id > 0) 
  40  {
  41    $action = '';
  42    $socidp = $user->societe_id;
  43  }
  44  
  45  llxHeader();
  46  
  47  $year = isset($_GET["year"])?$_GET["year"]:date("Y",time());
  48  
  49  $mesg = '<a href="month.php?year='.($year - 1).'">'.img_previous().'</a> ';
  50  $mesg.= $langs->trans("Year")." $year";
  51  $mesg.= ' <a href="month.php?year='.($year + 1).'">'.img_next().'</a>';
  52  
  53  print_fiche_titre($langs->trans("BillsStatistics"), $mesg);
  54  
  55  $stats = new FactureStats($db, $socidp);
  56  $data = $stats->getNbByMonth($year);
  57  
  58  if (! is_dir($conf->facture->dir_images)) { mkdir($conf->facture->dir_images); }
  59  
  60  $filename = $conf->facture->dir_images."/facture".$year.".png";
  61  $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=facture'.$year.'.png';
  62  
  63  $px = new BarGraph();
  64  $mesg = $px->isGraphKo();
  65  if (! $mesg) {
  66      $px->SetData($data);
  67      $px->SetMaxValue($px->GetMaxValue());
  68      $px->SetWidth($GRAPHWIDTH);
  69      $px->SetHeight($GRAPHHEIGHT);
  70      $px->draw($filename);
  71  }
  72  
  73  $res = $stats->getAmountByMonth($year);
  74  
  75  $data = array();
  76  
  77  for ($i = 1 ; $i < 13 ; $i++)
  78  {
  79    $data[$i-1] = array(ucfirst(substr(strftime("%b",mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]);
  80  }
  81  
  82  $filename_amount = $conf->facture->dir_images."/factureamount".$year.".png";
  83  $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=factureamount'.$year.'.png';
  84  
  85  $px = new BarGraph();
  86  $mesg = $px->isGraphKo();
  87  if (! $mesg) {
  88      $px->SetData($data);
  89      $px->SetYLabel($langs->trans("AmountTotal"));
  90      $px->SetMaxValue($px->GetAmountMaxValue());
  91      $px->SetWidth($GRAPHWIDTH);
  92      $px->SetHeight($GRAPHHEIGHT);
  93      $px->draw($filename_amount);
  94  }
  95  $res = $stats->getAverageByMonth($year);
  96  
  97  $data = array();
  98  
  99  for ($i = 1 ; $i < 13 ; $i++)
 100  {
 101    $data[$i-1] = array(ucfirst(substr(strftime("%b",mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]);
 102  }
 103  
 104  $filename_avg = $conf->facture->dir_images."/factureaverage".$year.".png";
 105  $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=factureaverage'.$year.'.png';
 106  
 107  $px = new BarGraph();
 108  $mesg = $px->isGraphKo();
 109  if (! $mesg) {
 110      $px->SetData($data);
 111      $px->SetYLabel($langs->trans("AmountAverage"));
 112      $px->SetMaxValue($px->GetAmountMaxValue());
 113      $px->SetWidth($GRAPHWIDTH);
 114      $px->SetHeight($GRAPHHEIGHT);
 115      $px->draw($filename_avg);
 116  }
 117  
 118  print '<table class="border" width="100%">';
 119  print '<tr><td align="center">'.$langs->trans("NumberOfBillsByMonth").'</td>';
 120  print '<td align="center">';
 121  if ($mesg) { print $mesg; }
 122  else { print '<img src="'.$fileurl.'">'; }
 123  print '</td></tr>';
 124  print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>';
 125  print '<td align="center">';
 126  if ($mesg) { print $mesg; }
 127  else { print '<img src="'.$fileurl_amount.'">'; }
 128  print '</td></tr>';
 129  print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>';
 130  print '<td align="center">';
 131  if ($mesg) { print $mesg; }
 132  else { print '<img src="'.$fileurl_avg.'">'; }
 133  print '</td></tr></table>';
 134  
 135  $db->close();
 136  
 137  llxFooter('$Date: 2005/07/16 14:56:25 $ - $Revision: 1.12 $');
 138  ?>


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