You are not logged in.
Hello,
We are trying to add a new element to the existing Software page using a plugin.
We created a new table in the database called 'glpi_plugin_softplg_softtime' which we use to store total usage time for all existing software.
Our objective is to add this data to every element in the Assets -> Software list, how do we go about this?
We have tried to do this for a few days now without much success, here's how we expect it to look after we're done, marked in red.
(pic)
This is the code we use to create the table in the database:
if (!$DB->tableExists('glpi_plugin_softplg_softtime')) {
$query = "CREATE TABLE `glpi_plugin_softplg_softtime` (
`id` int {$default_key_sign} NOT NULL auto_increment,
`softwares_id` int {$default_key_sign} NOT NULL,
`util_time` time NOT NULL DEFAULT '00:00:00',
PRIMARY KEY (`id`),
KEY `softwares_id` (`softwares_id`)
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->queryOrDie($query, $DB->error());
$query = "SELECT `id` from glpi_softwares";
$available_ids = $DB->queryOrDie($query, $DB->error());
while ($row = $available_ids->fetch_assoc()) {
$software_id = $row['id'];
$query = "INSERT INTO `glpi_plugin_softplg_softtime` (`softwares_id`, `util_time`) VALUES ('".$software_id."', '00:00:00')";
$DB->queryOrDie($query, $DB->error());
}
}
Last edited by KinMar100 (2024-08-16 14:35:18)
Offline
Have you already checked the GLPI developer documentation? Specifically, the sections regarding plugin hooks and the search engine?
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Yes, we read the appropriate documentation for the codes, but we managed to solve the problem based on other plugins in the system
Offline