report.lib.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  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. * or see https://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/core/lib/report.lib.php
  21. * \brief Set of functions for reporting
  22. */
  23. /**
  24. * Show header of a report
  25. *
  26. * @param string $reportname Name of report
  27. * @param string $notused Not used
  28. * @param string $period Period of report
  29. * @param string $periodlink Link to switch period
  30. * @param string $description Description
  31. * @param integer $builddate Date generation
  32. * @param string $exportlink Link for export or ''
  33. * @param array $moreparam Array with list of params to add into form
  34. * @param string $calcmode Calculation mode
  35. * @param string $varlink Add a variable into the address of the page
  36. * @return void
  37. */
  38. function report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '')
  39. {
  40. global $langs;
  41. print "\n\n<!-- start banner of report -->\n";
  42. if (!empty($varlink)) {
  43. $varlink = '?'.$varlink;
  44. }
  45. $head = array();
  46. $h = 0;
  47. $head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
  48. $head[$h][1] = $langs->trans("Report");
  49. $head[$h][2] = 'report';
  50. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">'."\n";
  51. print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
  52. print dol_get_fiche_head($head, 'report');
  53. foreach ($moreparam as $key => $value) {
  54. print '<input type="hidden" name="'.$key.'" value="'.$value.'">'."\n";
  55. }
  56. print '<table class="border tableforfield centpercent">'."\n";
  57. $variante = ($periodlink || $exportlink);
  58. // Ligne de titre
  59. print '<tr>';
  60. print '<td width="150">'.$langs->trans("ReportName").'</td>';
  61. print '<td>';
  62. print $reportname;
  63. print '</td>';
  64. if ($variante) {
  65. print '<td></td>';
  66. }
  67. print '</tr>'."\n";
  68. // Calculation mode
  69. if ($calcmode) {
  70. print '<tr>';
  71. print '<td width="150">'.$langs->trans("CalculationMode").'</td>';
  72. print '<td>';
  73. print $calcmode;
  74. if ($variante) {
  75. print '<td></td>';
  76. }
  77. print '</td>';
  78. print '</tr>'."\n";
  79. }
  80. // Ligne de la periode d'analyse du rapport
  81. print '<tr>';
  82. print '<td>'.$langs->trans("ReportPeriod").'</td>';
  83. print '<td>';
  84. if ($period) {
  85. print $period;
  86. }
  87. if ($variante) {
  88. print '<td class="nowraponall">'.$periodlink.'</td>';
  89. }
  90. print '</td>';
  91. print '</tr>'."\n";
  92. // Ligne de description
  93. print '<tr>';
  94. print '<td>'.$langs->trans("ReportDescription").'</td>';
  95. print '<td>'.$description.'</td>';
  96. if ($variante) {
  97. print '<td></td>';
  98. }
  99. print '</tr>'."\n";
  100. // Ligne d'export
  101. print '<tr>';
  102. print '<td>'.$langs->trans("GeneratedOn").'</td>';
  103. print '<td>';
  104. print dol_print_date($builddate, 'dayhour');
  105. print '</td>';
  106. if ($variante) {
  107. print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>';
  108. }
  109. print '</tr>'."\n";
  110. print '</table>'."\n";
  111. print dol_get_fiche_end();
  112. print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
  113. print '</form>';
  114. print '<br>';
  115. print "\n<!-- end banner of report -->\n\n";
  116. }