Categories, keeping a retired value that is still set $type_options = []; $sql = mysqli_query($mysqli, "SELECT category_name FROM categories WHERE category_type = 'software_type' AND category_archived_at IS NULL ORDER BY category_order ASC, category_name ASC"); while ($row = mysqli_fetch_assoc($sql)) { $type_options[] = $row['category_name']; } $software_type_raw = html_entity_decode($software_type, ENT_QUOTES, 'UTF-8'); if ($software_type_raw !== '' && !in_array($software_type_raw, $type_options, true)) { $type_options[] = $software_type_raw; } // License types - the usual ones, keeping whatever this one already has $license_type_options = array_keys(SOFTWARE_LICENSE_TYPES); $software_license_type_raw = html_entity_decode($software_license_type, ENT_QUOTES, 'UTF-8'); if ($software_license_type_raw !== '' && !in_array($software_license_type_raw, $license_type_options, true)) { $license_type_options[] = $software_license_type_raw; } // The client's own lists - only once the client is known $vendor_options = $asset_options = $contact_options = []; if ($client_id) { $sql = mysqli_query($mysqli, "SELECT vendor_archived_at, vendor_id, vendor_name, vendor_description FROM vendors WHERE vendor_client_id = $client_id AND (vendor_archived_at IS NULL OR vendor_id = $software_vendor_id) ORDER BY vendor_favorite DESC, vendor_name ASC"); while ($row = mysqli_fetch_assoc($sql)) { $vendor_options[] = $row; } $sql = mysqli_query($mysqli, "SELECT asset_id, asset_name, asset_type, asset_make, asset_model, contact_name FROM assets LEFT JOIN contacts ON contact_id = asset_contact_id WHERE asset_client_id = $client_id AND asset_archived_at IS NULL ORDER BY asset_name ASC"); while ($row = mysqli_fetch_assoc($sql)) { $asset_options[] = $row; } $sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_title, contact_photo, contact_client_id FROM contacts WHERE contact_client_id = $client_id AND contact_archived_at IS NULL ORDER BY contact_name ASC"); while ($row = mysqli_fetch_assoc($sql)) { $contact_options[] = $row; } } else { $client_options = []; $sql = mysqli_query($mysqli, "SELECT client_id, client_name, client_abbreviation FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC"); while ($row = mysqli_fetch_assoc($sql)) { $client_options[] = $row; } } // Templates (Admin > License Templates) to start a new license from $template_options = []; if ($software_form_mode === 'add') { $sql = mysqli_query($mysqli, "SELECT software_template_id, software_template_name, software_template_version, software_template_description, software_template_type, software_template_license_type, software_template_notes FROM software_templates WHERE software_template_archived_at IS NULL ORDER BY software_template_name ASC"); while ($row = mysqli_fetch_assoc($sql)) { $template_options[intval($row['software_template_id'])] = [ 'name' => $row['software_template_name'], 'version' => (string) $row['software_template_version'], 'description' => (string) $row['software_template_description'], 'type' => $row['software_template_type'], 'license_type' => (string) $row['software_template_license_type'], 'notes' => (string) $row['software_template_notes'], ]; } } $software_type_style = softwareTypeStyle($software_type); $form_id = 'softwareForm' . ($software_form_mode === 'edit' ? $software_id : 'New'); ?>
License ID = $software_id ?>
Pick the devices and users once it's saved - they come from the client.