}
    if ($op && isset($search) && $search != "") {
        $query = CentreonUtils::conditionBuilder($query, "name1 " . CentreonUtils::operandToMysqlFormat($op) . " '" . $dbb->escape($search) . "' ");
    }
}
if (!$centreon->user->admin) {
    $query = CentreonUtils::conditionBuilder($query, "name1 IN (" . $aclObj->getServiceGroupsString("NAME") . ")");
}
$orderby = "name ASC";
if (isset($preferences['order_by']) && $preferences['order_by'] != "") {
    $orderby = $preferences['order_by'];
}
$query .= "ORDER BY {$orderby}";
$query .= " LIMIT " . $page * $preferences['entries'] . "," . $preferences['entries'];
$res = $dbb->query($query);
$nbRows = $dbb->numberRows();
$data = array();
$detailMode = false;
if (isset($preferences['enable_detailed_mode']) && $preferences['enable_detailed_mode']) {
    $detailMode = true;
}
while ($row = $res->fetchRow()) {
    foreach ($row as $key => $value) {
        $data[$row['name']][$key] = $value;
        $data[$row['name']]['host_state'] = $sgMonObj->getHostStates($row['name'], $detailMode, $centreon->user->admin, $aclObj, $preferences, true, $ndoPrefix);
        $data[$row['name']]['service_state'] = $sgMonObj->getServiceStates($row['name'], $detailMode, $centreon->user->admin, $aclObj, $preferences, true, $ndoPrefix);
    }
}
$template->assign('preferences', $preferences);
$template->assign('hostStateLabels', $hostStateLabels);
$template->assign('hostStateColors', $hostStateColors);