Skip to content

Commit 06db375

Browse files
author
p.ernst
committed
Fix SuiteCRM#5557 Make dashlet drilldown use the correct key
1 parent e115fab commit 06db375

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

include/SuiteGraphs/RGraphIncludes.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ function opportunitiesByLeadSourceDashletClick(e,bar)
143143
var searchFormTab = $(divHolder).find(".searchFormTab").val();
144144
145145
var labels = bar["object"]["properties"]["chart.labels"];
146-
var clicked = encodeURI(labels[bar[5]]);
146+
147+
var keys = window["chartHBarKeys"+graphId];
148+
var clicked = encodeURI(keys[bar[5]]);
147149
148150
window.open('index.php?module='+module+'&action='+action+'&query='+query+'&searchFormTab='+searchFormTab+'&lead_source='+clicked,'_self');
149151
}

modules/Charts/Dashlets/OpportunitiesByLeadSourceDashlet/OpportunitiesByLeadSourceDashlet.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function display()
9999
$chartHeight = 500;
100100

101101
$jsonData = json_encode($chartReadyData['data']);
102+
$jsonKeys = json_encode($chartReadyData['keys']);
102103
$jsonLabels = json_encode($chartReadyData['labels']);
103104
$jsonLabelsAndValues = json_encode($chartReadyData['labelsAndValues']);
104105

@@ -128,6 +129,7 @@ public function display()
128129
<input type='hidden' class='searchFormTab' value='$searchFormTab' />
129130
$autoRefresh
130131
<script>
132+
window["chartHBarKeys$canvasId"] = $jsonKeys;
131133
var pie = new RGraph.Pie({
132134
id: '$canvasId',
133135
data: $jsonData,
@@ -203,13 +205,14 @@ public function display()
203205
function getChartData($query)
204206
{
205207
global $app_list_strings, $db;
206-
$dataSet = array();
208+
$dataSet = [];
207209
$result = $db->query($query);
208210

209211
$row = $db->fetchByAssoc($result);
210212

211-
while ($row != null){
212-
if(isset($row['lead_source']) && $app_list_strings['lead_source_dom'][$row['lead_source']] ) {
213+
while ($row != null) {
214+
if (isset($row['lead_source']) && $app_list_strings['lead_source_dom'][$row['lead_source']]) {
215+
$row['lead_source_key'] = $row['lead_source'];
213216
$row['lead_source'] = $app_list_strings['lead_source_dom'][$row['lead_source']];
214217
}
215218
$dataSet[] = $row;
@@ -218,21 +221,22 @@ function getChartData($query)
218221
return $dataSet;
219222
}
220223

221-
protected function prepareChartData($data,$currency_symbol, $thousands_symbol)
224+
protected function prepareChartData($data, $currency_symbol, $thousands_symbol)
222225
{
223226
//return $data;
224-
$chart['labels']=array();
225-
$chart['data']=array();
227+
$chart['labels'] = [];
228+
$chart['data'] = [];
229+
$chart['keys'] = [];
226230
$total = 0;
227-
foreach($data as $i)
228-
{
229-
$chart['labelsAndValues'][]=$i['lead_source'].' ('.$currency_symbol.(int)$i['total'].$thousands_symbol.')';
231+
foreach ($data as $i) {
232+
$chart['labelsAndValues'][] = $i['lead_source'] . ' (' . $currency_symbol . (int)$i['total'] . $thousands_symbol . ')';
230233
//$chart['labelsAndValues'][]=$currency_symbol.(int)$i['total'].$thousands_symbol;
231-
$chart['labels'][]=$i['lead_source'];
232-
$chart['data'][]=(int)$i['total'];
233-
$total+=(int)$i['total'];
234+
$chart['labels'][] = $i['lead_source'];
235+
$chart['keys'][] = $i['lead_source_key'];
236+
$chart['data'][] = (int)$i['total'];
237+
$total += (int)$i['total'];
234238
}
235-
$chart['total']=$total;
239+
$chart['total'] = $total;
236240
return $chart;
237241
}
238242

0 commit comments

Comments
 (0)