From e8cf4554718e7df599621117a212576561b255af Mon Sep 17 00:00:00 2001 From: tsmr Date: Sat, 8 Oct 2022 17:19:53 +0200 Subject: [PATCH] Fix click on graph --- reports/reports_bar.class.php | 59 +++++++++-------- reports/reports_line.class.php | 2 +- reports/reports_pie.class.php | 112 ++++++++++++++++++--------------- 3 files changed, 95 insertions(+), 78 deletions(-) diff --git a/reports/reports_bar.class.php b/reports/reports_bar.class.php index c261b22..7ea53e1 100644 --- a/reports/reports_bar.class.php +++ b/reports/reports_bar.class.php @@ -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', @@ -664,6 +665,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { 'begin', 'end', 'limit']; + $onclick = 1; } if (isset($_SESSION['glpiactiveprofile']['interface']) && Session::getCurrentInterface() != 'central') { @@ -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, @@ -907,6 +910,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { case $this->getType() . "36": $name = 'TicketsByPriorityBarChart'; + $onclick = 0; if (isset($_SESSION['glpiactiveprofile']['interface']) && Session::getCurrentInterface() == 'central') { $criterias = ['entities_id', @@ -914,6 +918,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { 'type', 'technicians_groups_id', 'group_is_recursive']; + $onclick = 1; } if (isset($_SESSION['glpiactiveprofile']['interface']) && Session::getCurrentInterface() != 'central') { @@ -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); @@ -1003,6 +1009,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { case $this->getType() . "37": $name = 'TicketsByStatusBarChart'; + $onclick = 0; if (isset($_SESSION['glpiactiveprofile']['interface']) && Session::getCurrentInterface() == 'central') { $criterias = ['entities_id', @@ -1010,6 +1017,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { 'type', 'technicians_groups_id', 'group_is_recursive']; + $onclick = 1; } if (isset($_SESSION['glpiactiveprofile']['interface']) && Session::getCurrentInterface() != 'central') { @@ -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); diff --git a/reports/reports_line.class.php b/reports/reports_line.class.php index ba1b801..c7217f3 100644 --- a/reports/reports_line.class.php +++ b/reports/reports_line.class.php @@ -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', diff --git a/reports/reports_pie.class.php b/reports/reports_pie.class.php index 4a9a3e5..f9c2981 100644 --- a/reports/reports_pie.class.php +++ b/reports/reports_pie.class.php @@ -119,7 +119,8 @@ 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', @@ -127,6 +128,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { 'type', 'technicians_groups_id', 'group_is_recursive']; + $onclick = 1; } if (isset($_SESSION['glpiactiveprofile']['interface']) && Session::getCurrentInterface() != 'central') { @@ -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); @@ -494,6 +496,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { case $this->getType() . "16": $name = 'IncidentsByCategoryPieChart'; + $onclick + 0; if (isset($_SESSION['glpiactiveprofile']['interface']) && Session::getCurrentInterface() == 'central') { $criterias = ['entities_id', @@ -501,6 +504,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { 'technicians_groups_id', 'group_is_recursive', 'requesters_groups_id']; + $onclick = 1; } if (isset($_SESSION['glpiactiveprofile']['interface']) && Session::getCurrentInterface() != 'central') { @@ -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, @@ -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', @@ -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') { @@ -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, @@ -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, @@ -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, @@ -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', @@ -1388,6 +1393,7 @@ public function getWidgetContentForItem($widgetId, $opt = []) { 'year', 'month', 'technicians_groups_id']; + $onclick = 1; } $params = ["preferences" => $this->preferences, "criterias" => $criterias, @@ -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,