diff --git a/inc/helper.class.php b/inc/helper.class.php
index 7934551..0af6b3a 100644
--- a/inc/helper.class.php
+++ b/inc/helper.class.php
@@ -793,9 +793,9 @@ public static function manageCriterias($params)
$crit['crit']['status'] = $status;
}
}
- //ITILCATEGORY
+ //ITILCATEGORY_LVL1
$opt['itilcategorielvl1'] = 0;
- $crit['crit']['itilcategorielvl1'] = "AND 1 = 1";
+ $crit['crit']['itilcategorielvl1'] = " AND 1 = 1 ";
if (in_array("itilcategorielvl1", $criterias)) {
if (isset($params['preferences']['prefered_category'])
&& $params['preferences']['prefered_category'] > 0 && !isset($params['opt']['itilcategorielvl1'])) {
@@ -818,6 +818,27 @@ public static function manageCriterias($params)
$crit['crit']['itilcategorielvl1'] = " AND `glpi_tickets`.`itilcategories_id` IN ( " . $categories . ") ";
}
+ //ITILCATEGORY
+ $opt['itilcategory'] = 0;
+ $crit['crit']['itilcategory'] = " AND 1 = 1";
+ if (in_array("itilcategory", $criterias)) {
+ if (isset($params['preferences']['prefered_category'])
+ && $params['preferences']['prefered_category'] > 0 && !isset($params['opt']['itilcategory'])) {
+ $opt['itilcategory'] = $params['preferences']['prefered_category'];
+ } else if (isset($params['opt']["itilcategory"])
+ && $params['opt']["itilcategory"] > 0) {
+ $opt['itilcategory'] = $params['opt']['itilcategory'];
+ }
+ if ($opt['itilcategory'] > 0) {
+ $category = new ITILCategory();
+ if ($category->getFromDB($opt['itilcategory'])) {
+ $crit['crit']['itilcategory'] = " AND `glpi_tickets`.`itilcategories_id` = " . $opt['itilcategory'] . " ";
+ }
+ } else {
+ $crit['crit']['itilcategory'] = " AND 1 = 1 ";
+ }
+ }
+
//TAG
$opt['tag'] = 0;
$crit['crit']['tag'] = "AND 1 = 1";
@@ -980,6 +1001,10 @@ public static function getFormHeader($widgetId, $gsid, $onsubmit = false, $opt =
$form .= " / " . __("Category", 'mydashobard') . " : " . Dropdown::getDropdownName('glpi_itilcategories', $opt['itilcategorielvl1']);
}
+ if (isset($opt['itilcategory']) && $opt['itilcategory'] > 0) {
+ $form .= " / " . __("Category", 'mydashobard') . " : " . Dropdown::getDropdownName('glpi_itilcategories', $opt['itilcategory']);
+ }
+
$form .= "";
$form .= "";
$form .= "
";
@@ -1097,7 +1122,6 @@ public static function getForm($widgetId, $opt, $criterias, $onsubmit = false)
$dropdown = Dropdown::showFromArray("multiple_locations_id", $temp, $params);
$form .= $dropdown;
-
$form .= "";
if ($count > 1) {
$form .= "";
@@ -1753,11 +1777,34 @@ public static function getForm($widgetId, $opt, $criterias, $onsubmit = false)
}
}
+ //ITILCATEGORY LVL1
if (in_array("itilcategorielvl1", $criterias)) {
$form .= "";
+ $form .= __('Category', 'mydashboard');
+ $form .= " ";
+ $dbu = new DbUtils();
+ if (isset($_POST["params"]['entities_id'])) {
+ $restrict = $dbu->getEntitiesRestrictCriteria('glpi_entities', '', $_POST["params"]['entities_id'], $_POST["params"]['sons']);
+ } else {
+ $restrict = $dbu->getEntitiesRestrictCriteria('glpi_entities', '', $opt['entities_id'], $opt['sons']);
+ }
- //
+ $dropdown = ITILCategory::dropdown(['name' => 'itilcategorielvl1', 'value' => $opt['itilcategorielvl1'], 'display' => false, 'condition' => ['level' => 1, ['OR' => ['is_request' => 1, 'is_incident' => 1]]]] + $restrict);
+
+ $form .= $dropdown;
+
+ $form .= "";
+
+
+ if ($count > 1) {
+ $form .= "";
+ }
+ }
+
+ //ITILCATEGORY
+ if (in_array("itilcategory", $criterias)) {
+ $form .= "";
$form .= __('Category', 'mydashboard');
$form .= " ";
@@ -1768,7 +1815,7 @@ public static function getForm($widgetId, $opt, $criterias, $onsubmit = false)
$restrict = $dbu->getEntitiesRestrictCriteria('glpi_entities', '', $opt['entities_id'], $opt['sons']);
}
- $dropdown = ITILCategory::dropdown(['name' => 'itilcategorielvl1', 'value' => $opt['itilcategorielvl1'], 'display' => false, 'condition' => ['level' => 1, ['OR' => ['is_request' => 1, 'is_incident' => 1]]]] + $restrict);
+ $dropdown = ITILCategory::dropdown(['name' => 'itilcategory', 'value' => $opt['itilcategory'], 'display' => false, 'condition' => ['OR' => ['is_request' => 1, 'is_incident' => 1]]] + $restrict);
$form .= $dropdown;
diff --git a/inc/preference.class.php b/inc/preference.class.php
index 230e914..85842bf 100644
--- a/inc/preference.class.php
+++ b/inc/preference.class.php
@@ -222,7 +222,7 @@ public function showPreferencesForm($user_id)
'width' => '200px',
'entity' => $_SESSION['glpiactiveentities'],
'display_emptychoice' => true,
- 'condition' => ['level' => 1, ['OR' => ['is_request' => 1, 'is_incident' => 1]]]
+ 'condition' => [['OR' => ['is_request' => 1, 'is_incident' => 1]]]
];
$dropdownCategory = ITILCategory::dropdown($params);
diff --git a/reports/alert.class.php b/reports/alert.class.php
index 9e23b60..76a3cf2 100644
--- a/reports/alert.class.php
+++ b/reports/alert.class.php
@@ -2969,6 +2969,24 @@ public static function displayIndicator($id, $type, $params = [], $iswidget = fa
$category_criteria = " AND `glpi_tickets`.`itilcategories_id` = " . $params['itilcategorielvl1'];
}
}
+
+ if(!isset($params['ititlcategory'])){
+ $params['ititlcategory'] = "";
+ if(isset($preferences['prefered_category'])){
+ if($preferences['prefered_category'] != 0){
+ $params['ititlcategory'] = $preferences['prefered_category'];
+ $category_criteria = " AND `glpi_tickets`.`itilcategories_id` = " . $preferences['prefered_category'];
+ } else {
+ $category_criteria = " AND 1=1";
+ }
+ }
+ } else {
+ if($params['ititlcategory'] == 0){
+ $category_criteria = " AND 1=1";
+ } else {
+ $category_criteria = " AND `glpi_tickets`.`itilcategories_id` = " . $params['ititlcategory'];
+ }
+ }
}
$params['entities_id'] = $_SESSION['glpiactive_entity'];
$params['sons'] = 0;
diff --git a/reports/reports_bar.class.php b/reports/reports_bar.class.php
index 1cec5a8..f7365d6 100644
--- a/reports/reports_bar.class.php
+++ b/reports/reports_bar.class.php
@@ -850,7 +850,7 @@ public function getWidgetContentForItem($widgetId, $opt = [])
'technicians_groups_id',
'group_is_recursive',
'group_is_recursive',
- 'itilcategorielvl1'];
+ 'itilcategory'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
@@ -874,7 +874,7 @@ public function getWidgetContentForItem($widgetId, $opt = [])
$js_ancestors = $crit['ancestors'];
$technician_group = $opt['technicians_groups_id'];
$technician_groups_criteria = $crit['technicians_groups_id'];
- $categories_criteria = $crit['itilcategorielvl1'];
+ $categories_criteria = $crit['itilcategory'];
$is_deleted = "`glpi_tickets`.`is_deleted` = 0";
@@ -1024,7 +1024,7 @@ public function getWidgetContentForItem($widgetId, $opt = [])
'type',
'technicians_groups_id',
'group_is_recursive',
- 'itilcategorielvl1'];
+ 'itilcategory'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
@@ -1047,7 +1047,7 @@ public function getWidgetContentForItem($widgetId, $opt = [])
$is_deleted = "`glpi_tickets`.`is_deleted` = 0";
$technician_group = $opt['technicians_groups_id'];
$technician_groups_criteria = $crit['technicians_groups_id'];
- $categories_criteria = $crit['itilcategorielvl1'];
+ $categories_criteria = $crit['itilcategory'];
$query = "SELECT DISTINCT
`priority`,
@@ -1127,7 +1127,7 @@ public function getWidgetContentForItem($widgetId, $opt = [])
'type',
'technicians_groups_id',
'group_is_recursive',
- 'itilcategorielvl1'];
+ 'itilcategory'];
$onclick = 1;
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
@@ -1150,7 +1150,7 @@ public function getWidgetContentForItem($widgetId, $opt = [])
$is_deleted = "`glpi_tickets`.`is_deleted` = 0";
$technician_group = $opt['technicians_groups_id'];
$technician_groups_criteria = $crit['technicians_groups_id'];
- $categories_criteria = $crit['itilcategorielvl1'];
+ $categories_criteria = $crit['itilcategory'];
$query = "SELECT `glpi_tickets`.`status` AS status, COUNT(`glpi_tickets`.`id`) AS Total
FROM glpi_tickets
diff --git a/reports/reports_table.class.php b/reports/reports_table.class.php
index 85d8689..84edc35 100644
--- a/reports/reports_table.class.php
+++ b/reports/reports_table.class.php
@@ -578,7 +578,7 @@ public function getWidgetContentForItem($widgetId, $opt = [])
'is_recursive',
'technicians_groups_id',
'group_is_recursive',
- 'itilcategorielvl1'];
+ 'itilcategory'];
}
if (isset($_SESSION['glpiactiveprofile']['interface'])
&& Session::getCurrentInterface() != 'central') {
@@ -592,7 +592,7 @@ public function getWidgetContentForItem($widgetId, $opt = [])
$options = PluginMydashboardHelper::manageCriterias($params);
$crit = $options['crit'];
$opt = $options['opt'];
- $category_criteria = $crit['itilcategorielvl1'];
+ $category_criteria = $crit['itilcategory'];
$groups_sql_criteria = "";
$entities_criteria = $crit['entities_id'];
$technician_group = $opt['technicians_groups_id'];