month.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2009 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 3 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, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/expedition/stats/month.php
  20. * \ingroup commande
  21. * \brief Page des stats expeditions par mois
  22. */
  23. // Load Dolibarr environment
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionstats.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
  28. $year = GETPOST('year', 'int');
  29. // Security check
  30. if ($user->socid) {
  31. $socid = $user->socid;
  32. }
  33. restrictedArea($user, 'expedition');
  34. /*
  35. * View
  36. */
  37. llxHeader();
  38. $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
  39. $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
  40. $mesg = '';
  41. $mode = '';
  42. print load_fiche_titre($langs->trans("StatisticsOfSendings").' '.$year, $mesg);
  43. $stats = new ExpeditionStats($db, $socid, $mode);
  44. $data = $stats->getNbByMonth($year);
  45. dol_mkdir($conf->expedition->dir_temp);
  46. $filename = $conf->expedition->dir_temp."/expedition".$year.".png";
  47. $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=expeditionstats&file=expedition'.$year.'.png';
  48. $px = new DolGraph();
  49. $mesg = $px->isGraphKo();
  50. if (!$mesg) {
  51. $px->SetData($data);
  52. $px->SetMaxValue($px->GetCeilMaxValue());
  53. $px->SetWidth($WIDTH);
  54. $px->SetHeight($HEIGHT);
  55. $px->SetYLabel($langs->trans("NbOfSendings"));
  56. $px->SetShading(3);
  57. $px->SetHorizTickIncrement(1);
  58. $px->draw($filename, $fileurl);
  59. }
  60. print '<table class="border centpercent">';
  61. print '<tr><td class="center">'.$langs->trans("NbOfSendingsByMonth").'</td>';
  62. print '<td class="center">';
  63. print $px->show();
  64. print '</td></tr>';
  65. print '</table>';
  66. // End of page
  67. llxFooter();
  68. $db->close();