From 24e89df213153b80c01e449af79ee9553405af96 Mon Sep 17 00:00:00 2001
From: slerena <slerena@gmail.com>
Date: Mon, 6 Nov 2006 15:15:34 +0000
Subject: [PATCH] 2006-11-05 Sancho Lerena  <slerena@artica.es>

	* images/outlimits.png: Static image for progress bar out of limits.

	* reporting/fgraph.php: Progress bar now show static image if there is
	  out of limits before calculating (faster).


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@249 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/images/outlimits.png | Bin 0 -> 321 bytes
 pandora_console/reporting/fgraph.php |  79 +++++++++++++++------------
 2 files changed, 43 insertions(+), 36 deletions(-)
 create mode 100644 pandora_console/images/outlimits.png

diff --git a/pandora_console/images/outlimits.png b/pandora_console/images/outlimits.png
new file mode 100644
index 0000000000000000000000000000000000000000..5083a4af36283eeaff273e5174b5fdbf6707f0d5
GIT binary patch
literal 321
zcmV-H0lxl;P)<h;3K|Lk000e1NJLTq003G5000sM0{{R3DUH-H0000aP)t-s|Ns90
z0093yODs{A|5RcB&eH$p=>MIi|AmhKwY&dpc>jKgrZc~M0002kNkl<ZD3N0jBn2=C
zDG?78DNwEAM1pFSu&^Q^r3L0hDrwD{1Y)ez!me7aNhKUexq&%JN?Mb^R;jpQSKSI!
zxm>Ag!X%}(bWKj6*(H_fr6J2FOqv#jMRhsQ_?=3#+?2FZR2Kowo;54Qp($deo5rM-
z_*APmX%vA~2dODltaQ`LaKhn|l_1rcO&XJsR4Xmd#Oh0>@RdqgZb}-HG@FoAYcwff
z3&GTBMQ&506pEBWLzNJ!6{<2Lv8Yy3S)!!01QbUo(WK(!h0War!C+ENQf>eM96F6<
T-58sF00000NkvXXu0mjfVSI+5

literal 0
HcmV?d00001

diff --git a/pandora_console/reporting/fgraph.php b/pandora_console/reporting/fgraph.php
index 4504cc4711..122dad7ea5 100644
--- a/pandora_console/reporting/fgraph.php
+++ b/pandora_console/reporting/fgraph.php
@@ -1376,46 +1376,53 @@ function progress_bar($progress,$width,$height) {
    // With some adds from sdonie at lgc dot com
    // Get from official documentation PHP.net website. Thanks guys :-)
    // Code ripped from Babel Project :-)
-   function drawRating($rating,$width,$height) {
-	include ("../include/config.php");
-	require ("../include/languages/language_".$language_code.".php");
-	if ($width == 0) {
-		$width = 150;
-	}
-	if ($height == 0) {
-		$height = 20;
-	}
-	
-	//$rating = $_GET['rating'];
-	$ratingbar = (($rating/100)*$width)-2;
-	
-	$image = imagecreate($width,$height);
-	//colors
-	$back = ImageColorAllocate($image,255,255,255);
-	$border = ImageColorAllocate($image,0,0,0);
-	$red = ImageColorAllocate($image,255,60,75);
-	$fill = ImageColorAllocate($image,44,81,150);
+	function drawRating($rating,$width,$height) {
+		include ("../include/config.php");
+		require ("../include/languages/language_".$language_code.".php");
+		if ($width == 0) {
+			$width = 150;
+		}
+		if ($height == 0) {
+			$height = 20;
+		}
+		
+		//$rating = $_GET['rating'];
+		$ratingbar = (($rating/100)*$width)-2;
+		$image = imagecreate($width,$height);
+		//colors
+		$back = ImageColorAllocate($image,255,255,255);
+		$border = ImageColorAllocate($image,0,0,0);
+		$red = ImageColorAllocate($image,255,60,75);
+		$fill = ImageColorAllocate($image,44,81,150);
 
-	ImageFilledRectangle($image,0,0,$width-1,$height-1,$back);
-	ImageRectangle($image,0,0,$width-1,$height-1,$border);
+		ImageFilledRectangle($image,0,0,$width-1,$height-1,$back);
+		ImageRectangle($image,0,0,$width-1,$height-1,$border);
 
 
-	if (($rating > 100) || ($rating < 0)){
-		ImageFilledRectangle($image,1,1,$width-1,$height-1,$red);
-		ImageTTFText($image, 8, 0, ($width/3)-($width/10), ($height/2)+($height/5), $back, $config_fontpath,$lang_label["out_of_limits"]);
+		if (($rating > 100) || ($rating < 0)){
+			ImageFilledRectangle($image,1,1,$width-1,$height-1,$red);
+			ImageTTFText($image, 8, 0, ($width/3)-($width/10), ($height/2)+($height/5), $back, $config_fontpath,$lang_label["out_of_limits"]);
+		}
+		else {
+			ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill);
+			if ($rating > 50) 
+					ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $config_fontpath, $rating."%");
+			else 
+				ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $border, $config_fontpath, $rating."%");
+		}
+		imagePNG($image);
+		imagedestroy($image);
 	}
-	else {
-		ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill);
-		if ($rating > 50) 
-				ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $config_fontpath, $rating."%");
-		else 
-			ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $border, $config_fontpath, $rating."%");
-	}
-	imagePNG($image);
-	imagedestroy($image);
-   }
-   Header("Content-type: image/png");
-   drawRating($progress,$width,$height);
+	// Show header
+	Header("Content-type: image/png");
+	// If progress is out limits, show static image, beware of image size!
+	if ($progress > 100 || $progress < 0){
+		$imgPng = imageCreateFromPng("../images/outlimits.png");
+		imageAlphaBlending($imgPng, true);
+		imageSaveAlpha($imgPng, true);
+		imagePng($imgPng);
+	} else
+		drawRating($progress,$width,$height);   
 }