You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2024-08-16 14:33:06

KinMar100
Member
Registered: 2024-08-14
Posts: 2

Adding new parameters to software list using a plugin

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)
image

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

#2 2024-08-20 00:32:13

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,809
Website

Re: Adding new parameters to software list using a plugin

Have you already checked the GLPI developer documentation? Specifically, the sections regarding plugin hooks and the search engine?

https://glpi-developer-documentation.re … en/master/


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

#3 2024-08-21 09:07:16

KinMar100
Member
Registered: 2024-08-14
Posts: 2

Re: Adding new parameters to software list using a plugin

Yes, we read the appropriate documentation for the codes, but we managed to solve the problem based on other plugins in the system

Offline

Board footer

Powered by FluxBB