['label' => 'All', 'icon' => 'fa-list', 'where' => '1 = 1'], 'soon' => ['label' => 'Renewing soon', 'icon' => 'fa-hourglass-half', 'where' => 'software_expire BETWEEN CURDATE() AND CURDATE() + INTERVAL 30 DAY'], 'expired' => ['label' => 'Expired', 'icon' => 'fa-calendar-times', 'where' => 'software_expire < CURDATE()'], ]; $where = "software_client_id = $session_client_id AND software_archived_at IS NULL"; if ($q !== '') { $q_sql = escapeSql($q); $where .= " AND (software_name LIKE '%$q_sql%' OR software_type LIKE '%$q_sql%' OR vendor_name LIKE '%$q_sql%')"; } $from = "FROM software LEFT JOIN vendors ON vendor_id = software_vendor_id WHERE $where"; $count_sql = []; foreach ($tabs as $key => $t) { $count_sql[] = "COALESCE(SUM({$t['where']}), 0) AS `$key`"; } $counts = array_map('intval', mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT " . implode(', ', $count_sql) . " $from"))); $tab = isset($tabs[$_GET['tab'] ?? '']) ? $_GET['tab'] : 'all'; $licenses = mysqli_query($mysqli, "SELECT software_id, software_name, software_version, software_type, software_license_type, software_seats, software_expire, vendor_name, " . softwareSeatsUsedSql('software.software_id') . " AS seats_used $from AND {$tabs[$tab]['where']} ORDER BY software_name ASC"); /** This page's address with some of its settings changed. */ function licensesUrl(array $changes) { global $tab, $q; $params = array_merge(['tab' => $tab !== 'all' ? $tab : null, 'q' => $q !== '' ? $q : null], $changes); $params = array_filter($params, function ($v) { return $v !== null && $v !== ''; }); return 'licenses.php' . ($params ? '?' . http_build_query($params) : ''); } ?>

Licenses

The software you are licensed for, and when it renews

'licenses', 'filtered' => true, 'match_text' => 'No license has “' . escapeHtml($q) . '” in its name, kind or vendor.', 'clear_url' => licensesUrl(['q' => null])]) ?> 'Nothing renewing soon', 'text' => 'Licenses renewing in the next 30 days show here.', 'icon' => 'fa-check', 'filtered' => false]) ?> 'Nothing has run out', 'text' => '', 'icon' => 'fa-check', 'filtered' => false]) ?> 'No licenses yet', 'text' => 'The software we manage for you shows here.', 'icon' => 'fa-cube', 'filtered' => false]) ?>