$ptcm = new PluginFusioninventoryConfigModules();
 $a_agent = $pta->InfosByKey($pxml->DEVICEID);
 $a_tasks = $ptt->find("`agent_id`='" . $a_agent['ID'] . "'", "date");
 $single = 0;
 $_SESSION['glpi_plugin_fusioninventory_addagentprocess'] = '0';
 foreach ($a_tasks as $task_id => $datas) {
     if ($a_tasks[$task_id]['action'] == 'INVENTORY' and $ptcm->isActivated('inventoryocs') and $a_agent['module_inventory'] == '1') {
         $ptc->addInventory();
         $input['ID'] = $task_id;
         $ptt->delete($input);
         $ocsinventory = '0';
         $single = 1;
     }
     if ($a_tasks[$task_id]['action'] == 'NETDISCOVERY' and $ptcm->isActivated('netdiscovery') and $a_agent['module_netdiscovery'] == '1') {
         $single = 1;
         $ptc->addDiscovery($pxml, 1);
         $input['ID'] = $task_id;
         $ptt->delete($input);
     }
     if ($a_tasks[$task_id]['action'] == 'SNMPQUERY' and $ptcm->isActivated('snmp') and $a_agent['module_snmpquery'] == '1') {
         $single = 1;
         $ptc->addQuery($pxml, 1);
         $input['ID'] = $task_id;
         $ptt->delete($input);
     }
     if ($a_tasks[$task_id]['action'] == 'WAKEONLAN' and $ptcm->isActivated('wol') and $a_agent['module_wakeonlan'] == '1') {
         $single = 1;
         $ptc->addWakeonlan($pxml);
         $input['ID'] = $task_id;
         $ptt->delete($input);
     }