gest366/modules/articoli/grafico_magazzini.php

41 lines
1.3 KiB
PHP
Raw Normal View History

2021-02-24 20:40:04 +00:00
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["piechart"]});
google.setOnLoadCallback(drawChart);
function drawChart()
{
var data = new google.visualization.DataTable();
data.addColumn('string', 'Task');
data.addColumn('number', 'Hours per Day');
data.addRows([
<?php
$rsa = $dbo->fetchArray("SELECT qta, (SELECT nome FROM mg_magazzini WHERE id=idmagazzino) AS nome, (SELECT sigla FROM mg_magazzini WHERE id=idmagazzino) AS sigla FROM mg_articoli_magazzini WHERE idarticolo='".$id_record."'");
if( sizeof($rsa)>0 ){
for( $i=0; $i<sizeof($rsa); $i++ ){
echo "['".$rsa[$i]['nome']."', ".$rsa[$i]['qta']."],";
}
}
echo "['Principale', ".$records[0]['qta']."]";
?>
]);
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {
width: 400,
height: 240,
is3D: true,
title: 'Ripartizione Magazzini',
titleFontSize: 14,
legend: 'right',
legendBackgroundColor: {stroke:'black', fill:'#eee', strokeSize: 1}
});
}
</script>
<div class="panel-body">
<div id="chart_div"></div>
</div>