From 612caf7d8504569fe412063233bd3fbb49a742d1 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 11 Dec 2006 15:32:36 +0000 Subject: [PATCH] Ne graph que si il y a des donnees --- scripts/cron/product-graph.php | 46 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/scripts/cron/product-graph.php b/scripts/cron/product-graph.php index 502030bb7f7..6f5166b29ba 100644 --- a/scripts/cron/product-graph.php +++ b/scripts/cron/product-graph.php @@ -98,7 +98,7 @@ foreach ( $products as $id => $fdir) $num[$i] = 0; $ca[$i] = 0; } - + $sql = "SELECT date_format(f.datef,'%b'), sum(fd.qty), sum(fd.total_ht), date_format(f.datef,'%m')"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " WHERE f.rowid = fd.fk_facture AND date_format(f.datef,'%Y')='".$year."'"; @@ -115,8 +115,7 @@ foreach ( $products as $id => $fdir) { $legends[($row[3] - 1)] = $row[0]; $num[($row[3] - 1)] = $row[1]; - $ca[($row[3] - 1)] = $row[2]; - + $ca[($row[3] - 1)] = $row[2]; $i++; } $db->free($resql); @@ -126,17 +125,19 @@ foreach ( $products as $id => $fdir) print $sql; } - $graph = new DolGraph(); + if ($i > 0) + { + $graph = new DolGraph(); - $file = $fdir ."ventes-".$year."-".$id.".png"; - $title = "Ventes"; - - $graph->SetTitle($title); - $graph->BarLineOneYearArtichow($file, $ca, $num, $legends); + $file = $fdir ."ventes-".$year."-".$id.".png"; + $title = "Ventes"; + + $graph->SetTitle($title); + $graph->BarLineOneYearArtichow($file, $ca, $num, $legends); - - if ($verbose) - print "$file\n"; + if ($verbose) + print "$file\n"; + } } /* * Ventes annuelles @@ -174,16 +175,19 @@ foreach ( $products as $id => $fdir) print $sql; } - $graph = new DolGraph(); + if ($i > 0) + { + $graph = new DolGraph(); - $file = $fdir ."ventes-".$id.".png"; - $title = "Ventes"; - - $graph->SetTitle($title); - $graph->BarLineAnnualArtichow($file, $ca, $num, $legends); - - if ($verbose) - print "$file\n"; + $file = $fdir ."ventes-".$id.".png"; + $title = "Ventes"; + + $graph->SetTitle($title); + $graph->BarLineAnnualArtichow($file, $ca, $num, $legends); + + if ($verbose) + print "$file\n"; + } }