= 2; $co_domains = []; if ($co_support) { $co_sql = mysqli_query($mysqli, "SELECT domain_id, domain_name, domain_expire, domain_description FROM domains WHERE domain_client_id = $client_id AND domain_archived_at IS NULL ORDER BY domain_name ASC"); while ($co_domain = mysqli_fetch_assoc($co_sql)) { $co_domains[] = $co_domain; } } // Vendor templates - which the client has, and which it should $co_vendor_templates = []; $co_sql = mysqli_query($mysqli, "SELECT vendor_template_id, vendor_template_name, vendor_template_description, (SELECT COUNT(*) FROM vendors WHERE vendor_client_id = $client_id AND vendor_archived_at IS NULL AND (vendors.vendor_template_id = vendor_templates.vendor_template_id OR LOWER(vendor_name) = LOWER(vendor_template_name))) AS has_it FROM vendor_templates WHERE vendor_template_archived_at IS NULL ORDER BY vendor_template_name ASC"); while ($co_template = mysqli_fetch_assoc($co_sql)) { $co_vendor_templates[intval($co_template['vendor_template_id'])] = $co_template; } $co_vendor_should = vendorTemplatesMissingFor($client_id); $co_license_templates = []; $co_license_should = []; if ($co_support) { $co_sql = mysqli_query($mysqli, "SELECT software_template_id, software_template_name, software_template_type, software_template_license_type, vendor_template_name, (SELECT COUNT(*) FROM software WHERE software_client_id = $client_id AND software_archived_at IS NULL AND software.software_template_id = software_templates.software_template_id) AS has_it FROM software_templates LEFT JOIN vendor_templates ON vendor_templates.vendor_template_id = software_template_vendor_template_id AND vendor_template_archived_at IS NULL WHERE software_template_archived_at IS NULL ORDER BY software_template_name ASC"); while ($co_template = mysqli_fetch_assoc($co_sql)) { $co_license_templates[intval($co_template['software_template_id'])] = $co_template; } $co_license_should = softwareTemplatesMissingFor($client_id); } $co_ticked = function ($name, $id, $should) use ($settings_kept) { if (!empty($settings_kept)) { return in_array((string) $id, array_map('strval', (array) ($_SESSION['co_kept_it'][$name] ?? [])), true); } return $should; }; ?>