| " . __s("Model") . " | ";
- if (class_exists($type) && is_a($type, CommonDBTM::class, true)) {
+ $item = getItemForItemtype($type);
+ $supported = $item instanceof CommonDBTM;
- $item = new $type();
+ $model_dropdown = '';
+ $location_html = '';
+ $onselect_js = '';
+
+ if ($supported) {
$item->getFromDB($ID);
- $rand = self::dropdownUninstallModels(
- "model_id",
- $_SESSION["glpiID"],
- $item->fields["entities_id"],
- );
- echo " |
";
+ $entities_id = $item->fields["entities_id"];
+
+ if ($templates_id == 0) {
+ $rand = mt_rand();
+ $model_dropdown = self::dropdownUninstallModels(
+ "model_id",
+ $_SESSION["glpiID"],
+ $entities_id,
+ ['display' => false, 'rand' => $rand],
+ );
- $params = ['templates_id' => '__VALUE__',
- 'entity' => $item->fields["entities_id"],
- 'users_id' => $_SESSION["glpiID"],
- ];
+ $params = [
+ 'templates_id' => '__VALUE__',
+ 'entity' => $entities_id,
+ 'users_id' => $_SESSION["glpiID"],
+ ];
+
+ $onselect_js = Ajax::updateItemOnSelectEvent(
+ 'dropdown_model_id' . $rand,
+ "show_objects",
+ $CFG_GLPI['root_doc'] . "/plugins/uninstall/ajax/locations.php",
+ $params,
+ false,
+ );
- Ajax::updateItemOnSelectEvent(
- 'dropdown_model_id' . $rand,
- "show_objects",
- $CFG_GLPI['root_doc'] . "/plugins/uninstall/ajax/locations.php",
- $params,
- );
+ $location_html = "