$group) { $count_sql[] = "COALESCE(SUM({$group['where']}), 0) AS `$key`"; } $counts = array_map('intval', mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT " . implode(', ', $count_sql) . " $from"))); $tab = isset($groups[$_GET['tab'] ?? '']) ? $_GET['tab'] : 'all'; $total = $counts[$tab]; $pages = max(1, (int) ceil($total / $per_page)); $page = min(max(1, intval($_GET['page'] ?? 1)), $pages); $offset = ($page - 1) * $per_page; $assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, asset_type, asset_make, asset_model, asset_status, asset_warranty_expire, asset_contact_id, contact_name, location_name $from AND {$groups[$tab]['where']} ORDER BY asset_name ASC LIMIT $per_page OFFSET $offset"); /** This page's address with some of its settings changed. */ function assetsUrl(array $changes) { global $tab, $q, $mine; $params = array_merge(['tab' => $tab !== 'all' ? $tab : null, 'scope' => $mine ? 'mine' : null, 'q' => $q !== '' ? $q : null], $changes); $params = array_filter($params, function ($v) { return $v !== null && $v !== ''; }); return 'assets.php' . ($params ? '?' . http_build_query($params) : ''); } ?>
= $mine ? 'The ones you use' : 'Everything we look after at ' . escapeHtml($session_client_name) ?>