fetchTemplates( $cs->fetchPackageByDbId($vars['productinfo']['pid']) ?? $cs->fetchPackageId($vars['productinfo']['name']) ); if (empty($templates_data)) { return null; } $dropdownOptions = []; foreach ($templates_data['data'] as $osCategory) { foreach ($osCategory['templates'] as $template) { $optionValue = $template['id']; $optionLabel = $template['name'] . " " . $template['version'] . " " . $template['variant']; $dropdownOptions[] = ['id' => $optionValue, 'name' => $optionLabel]; } } // Sort dropdownOptions alphabetically by the 'name' key usort($dropdownOptions, function ($a, $b) { return strcmp($a['name'], $b['name']); }); $sshKeys = $cs->getUserSshKeys($vars['loggedinuser']); $sshKeysOptions = array_map(function ($sshKey) { if ($sshKey['enabled'] === false) { return null; } return [ 'id' => $sshKey['id'], 'name' => $sshKey['name'] ]; }, $sshKeys['data'] ?? []); $osID = array_values(array_filter(array_map(function ($option) { if ($option['textid'] === 'initialoperatingsystem') { return $option['id']; } }, $vars['customfields']))); $sshID = array_values(array_filter(array_map(function ($option) { if ($option['textid'] === 'initialsshkey') { return $option['id']; } }, $vars['customfields']))); // Construct the JavaScript code return " "; });