Skip to content

Commit

Permalink
Fix click on graph
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmr committed Oct 8, 2022
1 parent fe23d86 commit e8cf455
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 78 deletions.
59 changes: 34 additions & 25 deletions reports/reports_bar.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) {

case $this->getType() . "24":
$name = 'TicketByTechsBarChart';
$onclick = 0;
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() == 'central') {
$criterias = ['entities_id',
Expand All @@ -664,6 +665,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'begin',
'end',
'limit'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() != 'central') {
Expand Down Expand Up @@ -751,15 +753,16 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'labels' => $tabNamesset,
// 'label' => $ticketsnumber,
];

$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'type' => $type,
// 'year' => $year_criteria,
'begin' => $opt['begin'],
'end' => $opt['end'],
'widget' => $widgetId];

$graph_criterias = [];
if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'type' => $type,
// 'year' => $year_criteria,
'begin' => $opt['begin'],
'end' => $opt['end'],
'widget' => $widgetId];
}
$graph = PluginMydashboardBarChart::launchHorizontalGraph($graph_datas, $graph_criterias);

$params = ["widgetId" => $widgetId,
Expand Down Expand Up @@ -907,13 +910,15 @@ public function getWidgetContentForItem($widgetId, $opt = []) {

case $this->getType() . "36":
$name = 'TicketsByPriorityBarChart';
$onclick = 0;
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() == 'central') {
$criterias = ['entities_id',
'is_recursive',
'type',
'technicians_groups_id',
'group_is_recursive'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() != 'central') {
Expand Down Expand Up @@ -987,14 +992,15 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'ids' => $tabpriorityset,
'data' => $dataset,
'labels' => $labels];

$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'type' => $type,
'widget' => $widgetId];

$graph_criterias = [];
if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'type' => $type,
'widget' => $widgetId];
}
$graph = PluginMydashboardBarChart::launchGraph($graph_datas, $graph_criterias);
$widget->setWidgetHtmlContent($graph);

Expand All @@ -1003,13 +1009,15 @@ public function getWidgetContentForItem($widgetId, $opt = []) {

case $this->getType() . "37":
$name = 'TicketsByStatusBarChart';
$onclick = 0;
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() == 'central') {
$criterias = ['entities_id',
'is_recursive',
'type',
'technicians_groups_id',
'group_is_recursive'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() != 'central') {
Expand Down Expand Up @@ -1138,14 +1146,15 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'ids' => $tabstatusset,
'data' => $dataset,
'labels' => $labels];

$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'type' => $type,
'widget' => $widgetId];

$graph_criterias = [];
if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'type' => $type,
'widget' => $widgetId];
}
$graph = PluginMydashboardBarChart::launchGraph($graph_datas, $graph_criterias);
$widget->setWidgetHtmlContent($graph);

Expand Down
2 changes: 1 addition & 1 deletion reports/reports_line.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
$name = 'TicketStatusBarLineChart';
$onclick = 0;
if (isset($_SESSION['glpiactiveprofile']['interface'])
// && Session::getCurrentInterface() == 'central'
&& Session::getCurrentInterface() == 'central'
) {
$criterias = ['entities_id',
'technicians_groups_id',
Expand Down
112 changes: 60 additions & 52 deletions reports/reports_pie.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
switch ($widgetId) {

case $this->getType() . "2":
$name = 'TicketsByPriorityPieChart';
$onclick = 0;
$name = 'TicketsByPriorityPieChart';
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() == 'central') {
$criterias = ['entities_id',
'is_recursive',
'type',
'technicians_groups_id',
'group_is_recursive'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() != 'central') {
Expand Down Expand Up @@ -191,14 +193,14 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'labels' => $labelsPie,
'label' => $title];

// if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'type' => $type,
'widget' => $widgetId];
// }
if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'type' => $type,
'widget' => $widgetId];
}

$graph = PluginMydashboardPieChart::launchPieGraph($graph_datas, $graph_criterias);

Expand Down Expand Up @@ -494,13 +496,15 @@ public function getWidgetContentForItem($widgetId, $opt = []) {

case $this->getType() . "16":
$name = 'IncidentsByCategoryPieChart';
$onclick + 0;
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() == 'central') {
$criterias = ['entities_id',
'is_recursive',
'technicians_groups_id',
'group_is_recursive',
'requesters_groups_id'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() != 'central') {
Expand Down Expand Up @@ -579,14 +583,15 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'labels' => $labelsPie,
'label' => $title,
];

$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'requester_groups' => $requester_groups,
'widget' => $widgetId];

$graph_criterias = [];
if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'requester_groups' => $requester_groups,
'widget' => $widgetId];
}
$graph = PluginMydashboardPieChart::launchPieGraph($graph_datas, $graph_criterias);

$params = ["widgetId" => $widgetId,
Expand All @@ -608,6 +613,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) {

case $this->getType() . "17":
$name = 'RequestsByCategoryPieChart';
$onclick = 0;
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() == 'central') {
$criterias = ['entities_id',
Expand All @@ -616,6 +622,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'group_is_recursive',
'requesters_groups_id',
'limit'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() != 'central') {
Expand Down Expand Up @@ -693,14 +700,15 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'labels' => $labelsPie,
'label' => $title,
];

$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'requester_groups' => $requester_groups,
'widget' => $widgetId];

$graph_criterias = [];
if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'requester_groups' => $requester_groups,
'widget' => $widgetId];
}
$graph = PluginMydashboardPieChart::launchPieGraph($graph_datas, $graph_criterias);

$params = ["widgetId" => $widgetId,
Expand Down Expand Up @@ -1039,11 +1047,6 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'labels' => $labelsPie,
'label' => $title];

// if ($onclick == 1) {
$graph_criterias = ['type' => $type,
'widget' => $widgetId];
// }

$graph = PluginMydashboardPieChart::launchPieGraph($graph_datas, []);

$params = ["widgetId" => $widgetId,
Expand Down Expand Up @@ -1232,21 +1235,22 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
$tablocationset = json_encode($tablocation);
$js_ancestors = $crit['ancestors'];

$graph_datas = ['title' => $title,
'comment' => $comment,
'name' => $name,
'ids' => $tablocationset,
'data' => $dataPieset,
'labels' => $labelsPie,
'label' => $title];

$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'type' => $type,
'widget' => $widgetId];

$graph_datas = ['title' => $title,
'comment' => $comment,
'name' => $name,
'ids' => $tablocationset,
'data' => $dataPieset,
'labels' => $labelsPie,
'label' => $title];
$graph_criterias = [];
if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'group_is_recursive' => $js_ancestors,
'type' => $type,
'widget' => $widgetId];
}
$graph = PluginMydashboardPieChart::launchPolarAreaGraph($graph_datas, $graph_criterias);

$params = ["widgetId" => $widgetId,
Expand Down Expand Up @@ -1379,7 +1383,8 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
break;

case $this->getType() . "31":
$name = 'TicketsByLocationPolarChart';
$name = 'TicketsByLocationPolarChart';
$onclick = 0;
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() == 'central') {
$criterias = ['entities_id',
Expand All @@ -1388,6 +1393,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'year',
'month',
'technicians_groups_id'];
$onclick = 1;
}
$params = ["preferences" => $this->preferences,
"criterias" => $criterias,
Expand Down Expand Up @@ -1457,12 +1463,14 @@ public function getWidgetContentForItem($widgetId, $opt = []) {
'labels' => $labelsPolar,
'label' => $title];

$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'type' => $type,
'widget' => $widgetId];

$graph_criterias = [];
if ($onclick == 1) {
$graph_criterias = ['entities_id' => $entities_id_criteria,
'sons' => $sons_criteria,
'technician_group' => $technician_group,
'type' => $type,
'widget' => $widgetId];
}
$graph = PluginMydashboardPieChart::launchPolarAreaGraph($graph_datas, $graph_criterias);

$params = ["widgetId" => $widgetId,
Expand Down

0 comments on commit e8cf455

Please sign in to comment.