-
Notifications
You must be signed in to change notification settings - Fork 3
/
AccountOpportunitiesChart.php
74 lines (60 loc) · 2.14 KB
/
AccountOpportunitiesChart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/*********************************************************************************
* This code was developed by:
* Audox Ingeniería Ltda.
* You can contact us at:
* Web: www.audox.cl
* Email: [email protected]
* Skype: audox.ingenieria
********************************************************************************/
if(!defined('sugarEntry')) define('sugarEntry', true);
global $app_strings, $app_list_strings;
$account = new Account();
if(!is_null($account->retrieve($_REQUEST['account_id']))){
$account->load_relationship('opportunities');
$sales_stage = array();
foreach($app_list_strings['sales_stage_dom'] as $key => $value){
$sales_stage[$key] = 0;
}
$cols = array();
$cols[] = array("id" => "", "label" => "Proyecto", "pattern" => "", "type" => "string");
$cols[] = array("id" => "", "label" => "Total Abiertos", "pattern" => "", "type" => "number");
foreach($account->opportunities->getBeans() as $opportunity){
$sales_stage[$opportunity->sales_stage] = $sales_stage[$opportunity->sales_stage] + $opportunity->amount_usdollar;
}
$rows = array();
foreach($sales_stage as $key => $value){
$rows[] = array("c" => array(
array("v" => $key, "f" => null),
array("v" => $value, "f" => null),
));
}
}
$sales_stage = array();
$sales_stage['cols'] = $cols;
$sales_stage['rows'] = $rows;
$sales_stage = json_encode($sales_stage);
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable(<?php echo $sales_stage; ?>);
var options = {
// title: '<?php echo $app_strings['LBL_OPPORTUNITIES']; ?>',
pieHole: 0.4,
legend: 'none',
chartArea:{left:5,top:5,width:'75%',height:'75%'},
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="donutchart" style="width: 400px; height: 350px;"></div>
</body>
</html>