diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 684ef337fcd..ba17730831f 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -31,12 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array('compta', 'bills', 'donation', 'salaries')); -$date_startmonth = GETPOST('date_startmonth'); -$date_startday = GETPOST('date_startday'); -$date_startyear = GETPOST('date_startyear'); -$date_endmonth = GETPOST('date_endmonth'); -$date_endday = GETPOST('date_endday'); -$date_endyear = GETPOST('date_endyear'); +$date_startday = GETPOST('date_startday', 'int'); +$date_startmonth = GETPOST('date_startmonth', 'int'); +$date_startyear = GETPOST('date_startyear', 'int'); +$date_endday = GETPOST('date_endday', 'int'); +$date_endmonth = GETPOST('date_endmonth', 'int'); +$date_endyear = GETPOST('date_endyear', 'int'); $nbofyear = 4; @@ -193,15 +193,18 @@ elseif ($modecompta == "BOOKKEEPING") { $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj"; - $sql .= " WHERE b.entity = ".$conf->entity; + $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities $sql .= " AND aj.entity = ".$conf->entity; $sql .= " AND b.code_journal = aj.code AND aj.nature = 2"; // @todo currently count amount in sale journal, but we need to define a category group for turnover } $sql .= " GROUP BY dm"; $sql .= " ORDER BY dm"; +// TODO Add a filter on $date_start and $date_end to reduce quantity on data //print $sql; +$minyearmonth = $maxyearmonth = 0; + $result = $db->query($sql); if ($result) { @@ -214,7 +217,7 @@ if ($result) $cum[$obj->dm] = $obj->amount_ttc; if ($obj->amount_ttc) { - $minyearmonth = ($minyearmonth ?min($minyearmonth, $obj->dm) : $obj->dm); + $minyearmonth = ($minyearmonth ? min($minyearmonth, $obj->dm) : $obj->dm); $maxyearmonth = max($maxyearmonth, $obj->dm); } $i++; @@ -309,9 +312,17 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++) $mois_modulo = $mois; // ajout if ($mois > 12) {$mois_modulo = $mois - 12; } // ajout + if ($year_start == $year_end) { + if ($mois > $date_endmonth && $year_end >= $date_endyear) { + break; + } + } + print ''; + // Month print "".dol_print_date(dol_mktime(12, 0, 0, $mois_modulo, 1, 2000), "%B").""; + for ($annee = $year_start - 1; $annee <= $year_end; $annee++) // We start one year before to have data to be able to make delta { $annee_decalage = $annee; diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index 4649abc474a..979583e8b4d 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -53,16 +53,17 @@ function report_header($reportname, $notused, $period, $periodlink, $description $head[$h][1] = $langs->trans("Report"); $head[$h][2] = 'report'; - print '
'; + print ''."\n"; + print ''."\n"; dol_fiche_head($head, 'report'); foreach($moreparam as $key => $value) { - print ''; + print ''."\n"; } - print ''; + print '
'."\n"; $variante = ($periodlink || $exportlink); @@ -73,7 +74,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print $reportname; print ''; if ($variante) print ''; - print ''; + print ''."\n"; // Calculation mode if ($calcmode) @@ -84,7 +85,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print $calcmode; if ($variante) print ''; print ''; - print ''; + print ''."\n"; } // Ligne de la periode d'analyse du rapport @@ -94,14 +95,14 @@ function report_header($reportname, $notused, $period, $periodlink, $description if ($period) print $period; if ($variante) print ''; print ''; - print ''; + print ''."\n"; // Ligne de description print ''; print ''; print ''; if ($variante) print ''; - print ''; + print ''."\n"; // Ligne d'export print ''; @@ -110,9 +111,9 @@ function report_header($reportname, $notused, $period, $periodlink, $description print dol_print_date($builddate, 'dayhour'); print ''; if ($variante) print ''; - print ''; + print ''."\n"; - print '
'.$periodlink.'
'.$langs->trans("ReportDescription").''.$description.'
'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'
'; + print ''."\n"; dol_fiche_end();