month.php 2.5 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/reception/stats/month.php
  20. * \ingroup commande
  21. * \brief Page des stats receptions par mois
  22. */
  23. // Load Dolibarr environment
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/reception/class/receptionstats.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
  28. $year = GETPOST("year", 'int');
  29. $socid = GETPOST("socid", 'int');
  30. $userid = GETPOST("userid", 'int');
  31. // Security check
  32. if ($user->socid) {
  33. $socid = $user->socid;
  34. }
  35. $result = restrictedArea($user, 'reception', 0, '');
  36. /*
  37. * View
  38. */
  39. llxHeader();
  40. $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
  41. $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
  42. $mesg = '';
  43. print load_fiche_titre($langs->trans("StatisticsOfReceptions").' '.GETPOST("year", 'int'), $mesg);
  44. $stats = new ReceptionStats($db, $socid, '', ($userid > 0 ? $userid : 0));
  45. $data = $stats->getNbByMonth($year);
  46. dol_mkdir($conf->reception->dir_temp);
  47. $filename = $conf->reception->dir_temp."/reception".$year.".png";
  48. $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=receptionstats&file=reception'.$year.'.png';
  49. $px = new DolGraph();
  50. $mesg = $px->isGraphKo();
  51. if (!$mesg) {
  52. $px->SetData($data);
  53. $px->SetMaxValue($px->GetCeilMaxValue());
  54. $px->SetWidth($WIDTH);
  55. $px->SetHeight($HEIGHT);
  56. $px->SetYLabel($langs->trans("NbOfOrders"));
  57. $px->SetShading(3);
  58. $px->SetHorizTickIncrement(1);
  59. $px->draw($filename, $fileurl);
  60. }
  61. print '<table class="border centpercent">';
  62. print '<tr><td class="center">Nombre d reception par mois</td>';
  63. print '<td class="center">';
  64. print $px->show();
  65. print '</td></tr>';
  66. print '</table>';
  67. llxFooter();
  68. $db->close();