* Copyright (c) 2004-2010 Laurent Destailleur * * 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, see . */ /** * \file htdocs/compta/deplacement/stats/month.php * \ingroup facture * \brief Page des stats notes de frais par mois * \version $Id: month.php,v 1.4 2011/08/03 00:46:28 eldy Exp $ */ require("../../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/class/deplacementstats.class.php"); $langs->load("trips"); $GRAPHWIDTH=500; $GRAPHHEIGHT=200; // Check security access if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } $year = isset($_GET["year"])?$_GET["year"]:date("Y",time()); $mode='customer'; if (isset($_GET["mode"])) $mode=$_GET["mode"]; /* * View */ llxHeader(); $title=$langs->trans("TripsAndExpensesStatistics"); $dir=$conf->deplacement->dir_temp; $mesg = ''.img_previous().' '; $mesg.= $langs->trans("Year")." $year"; $mesg.= ' '.img_next().''; print_fiche_titre($title, $mesg); create_exdir($dir); $stats = new DeplacementStats($db, $socid); $data = $stats->getNbByMonth($year); $filename = $dir."/tripsexpensesnb-".$year.".png"; $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesnb-'.$year.'.png'; $px = new DolGraph(); $mesg = $px->isGraphKo(); if (! $mesg) { $px->SetData($data); $px->SetMaxValue($px->GetCeilMaxValue()); $px->SetMinValue($px->GetFloorMinValue()); $px->SetWidth($GRAPHWIDTH); $px->SetHeight($GRAPHHEIGHT); $px->SetShading(3); $px->SetHorizTickIncrement(1); $px->SetPrecisionY(0); $px->draw($filename); } $data = $stats->getAmountByMonth($year); $filename_amount = $dir."/tripsexpensesamount-".$year.".png"; $fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesamount-'.$year.'.png'; $px = new DolGraph(); $mesg = $px->isGraphKo(); if (! $mesg) { $px->SetData($data); $px->SetYLabel($langs->trans("AmountTotal")); $px->SetMaxValue($px->GetCeilMaxValue()); $px->SetMinValue($px->GetFloorMinValue()); $px->SetWidth($GRAPHWIDTH); $px->SetHeight($GRAPHHEIGHT); $px->SetShading(3); $px->SetHorizTickIncrement(1); $px->SetPrecisionY(0); $px->draw($filename_amount); } $res = $stats->getAverageByMonth($year); $data = array(); for ($i = 1 ; $i < 13 ; $i++) { $data[$i-1] = array(ucfirst(substr(dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b"),0,3)), $res[$i]); } $filename_avg = $dir."/tripsexpensesaverage-".$year.".png"; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesaverage-'.$year.'.png'; $px = new DolGraph(); $mesg = $px->isGraphKo(); if (! $mesg) { $px->SetData($data); $px->SetYLabel($langs->trans("AmountAverage")); $px->SetMaxValue($px->GetCeilMaxValue()); $px->SetMinValue($px->GetFloorMinValue()); $px->SetWidth($GRAPHWIDTH); $px->SetHeight($GRAPHHEIGHT); $px->SetShading(3); $px->SetHorizTickIncrement(1); $px->SetPrecisionY(0); $px->draw($filename_avg); } print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("NumberByMonth").''; if ($mesg) { print $mesg; } else { print ''; } print '
'.$langs->trans("AmountTotal").''; if ($mesg) { print $mesg; } else { print ''; } print '
'.$langs->trans("AmountAverage").''; if ($mesg) { print $mesg; } else { print ''; } print '
'; $db->close(); llxFooter('$Date: 2011/08/03 00:46:28 $ - $Revision: 1.4 $'); ?>