You are not logged in.
Pages: 1
Hi,
I would like to add a search option on the name field of the plugin example.
There is no foreign key in the glpi_plugin_example_examples table, but I was thinking of linking the serial field in this table to the serial field in the glpi_computers table. Below is the code I have written so far, but it hasn't worked.
Could you please provide any suggestions or ideas? Thank you!
function plugin_example_getAddSearchOptions($itemtype) {
$sopt = [];
// Vérifie si l'option de recherche concerne les "Computers"
if ($itemtype == 'Computer') {
// ID unique de l'option de recherche
$sopt[1001]['table'] = 'glpi_plugin_example_examples'; // Table cible
$sopt[1001]['field'] = 'name'; // Champ de recherche
$sopt[1001]['name'] = __('Name', 'example'); // Nom affiché
$sopt[1001]['datatype'] = 'string'; // Type de données
// Définir les paramètres de jointure avec beforejoin
$sopt[1001]['beforejoin'] = [
'table' => 'glpi_computers', // Table glpi_computers ?| joindre avant
'joinparams' => [
//'jointype' => 'standard', // Type de jointure (standard ici)
'nolink' => true, // Désactive les clés étrangères
'condition' => ['glpi_computers.serial = glpi_plugin_example_examples.serial'] // Condition de jointure
]
];
}
return $sopt;
}
Offline
Pages: 1