<?php
/**
 * ThunderSnarf
 *
 * @author Ricardo H.F. Sette P. <ricardohfsp@gmail.com>
 * @link http://www.freebsdbrasil.com.br/
 * @copyright Copyright &copy; 2010 - FreeBSD Brasil LTDA
 * @license licença GNU/GPL v2.0 http://www.gnu.org/licenses/gpl-2.0.html
 */
?>
	<table>
		<tr>
			<td>
<?php
$trafegoEstaticoInternet = $data->traffic_static+0;
$trafegoEstaticoCache = $data->cache_static+0;
if($trafegoEstaticoInternet==0)$trafegoEstaticoInternet=1;
if($trafegoEstaticoCache==0)$trafegoEstaticoCache=1;

$format_func = <<<EOD
js:function(label, series){
    return '<div style="font-size:12px;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';}
EOD;

$format_label = <<<EOD
js:function(label, series){
    return '<div style="background-color:#000;opacity:0.5;font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';}
EOD;
$this->widget('application.extensions.EFlot.EFlotGraphWidget', 
    array(
    	'idAjax'=>"TrafegoEstatico",
        'data'=>array(
            array('label'=>'Cache', 'data'=>$trafegoEstaticoCache, ),
            array('label'=>'Internet', 'data'=>$trafegoEstaticoInternet, 'color'=>'#AFD8F8'),
        ),
        'options'=>array(
            'series'=> array('pie'=>array(
                'show'=>true,
                'radius'=> 3/4,
                'tilt'=> 0.7,
                'stroke'=>array('width'=>'5'),
                'formatter'=> $format_func,
	            'label'=>array(
	                'show'=>true,
	                'radius'=> 3/4,
	                'formatter'=>$format_label,        
	            	),
                ),
            ),
            'combine'=>array('color'=>'#999', 'threshold'=>0.9),
            'legend'=> array('show'=>false),
        ),
        'htmlOptions'=>array('style'=>'width:250px;height:250px;')
    )
);
?>
			</td>
			<td style='width:70%;vertical-align:top'>
				<table style="border:1px solid #c1c1c1">
					<tr>
						<td style='border:1px solid #c1c1c1;text-align:center;background-color:#f1f1f1' >TRÁFEGO TOTAL</td>
						<td style='border:1px solid #c1c1c1;text-align:center;background-color:#f1f1f1' >TRÁFEGO INTERNET</td>
						<td style='border:1px solid #c1c1c1;text-align:center;background-color:#f1f1f1' >TRÁFEGO CACHE</td>
					</tr>
						<td style="border:1px solid #c1c1c1;text-align:center;" ><?php echo $this->sizeFormat($trafegoEstaticoInternet+$trafegoEstaticoCache);?></td>
						<td style="border:1px solid #c1c1c1;text-align:center;" ><?php echo $this->sizeFormat($trafegoEstaticoInternet);?></td>
						<td style="border:1px solid #c1c1c1;text-align:center;" ><?php echo $this->sizeFormat($trafegoEstaticoCache);?></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>