Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(ui): improve count of items in tabs (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
btry authored and ajsb85 committed Jun 9, 2017
1 parent 1f087c7 commit ba9bbd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions inc/agent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
if (!$withtemplate) {
$nb = 0;
$fleetId = $item->getID();
$pluralNumber = Session::getPluralNumber();
if ($_SESSION['glpishow_count_on_tabs']) {
if (version_compare(GLPI_VERSION, '9.2') < 0) {

$nb = countElementsInTable(static::getTable(), "`plugin_flyvemdm_fleets_id` = '$fleetId'");
} else {
$nb = countElementsInTable(static::getTable(), ['plugin_flyvemdm_fleets_id' => $fleetId]);
}
}
return self::createTabEntry(self::getTypeName(1), $nb);
return self::createTabEntry(self::getTypeName($pluralNumber), $nb);
}
break;
}
Expand Down
13 changes: 11 additions & 2 deletions inc/fleet_policy.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,17 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
if (static::canView()) {
switch ($item->getType()) {
case PluginFlyvemdmFleet::class:
$tab = array(1 => __('Policies'));
return $tab;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = 0;
$fleetId = $item->getID();
$pluralNumber = Session::getPluralNumber();
if (version_compare(GLPI_VERSION, '9.2') < 0) {
$nb = countElementsInTable(static::getTable(), "`plugin_flyvemdm_fleets_id` = '$fleetId'");
} else {
$nb = countElementsInTable(static::getTable(), ['plugin_flyvemdm_fleets_id' => $fleetId]);
}
}
return self::createTabEntry(PluginFlyvemdmPolicy::getTypeName($pluralNumber), $nb);
}
}
}
Expand Down

0 comments on commit ba9bbd0

Please sign in to comment.