. * * ------------------------------------------------------------------------ * * This file is used to manage the extended information of a computer. * * ------------------------------------------------------------------------ * * @package FusionInventory * @author David Durieux * @copyright Copyright (c) 2010-2016 FusionInventory team * @license AGPL License 3.0 or (at your option) any later version * http://www.gnu.org/licenses/agpl-3.0-standalone.html * @link http://www.fusioninventory.org/ * @link https://github.com/fusioninventory/fusioninventory-for-glpi * */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access directly to this file"); } /** * Manage the extended information of a computer. */ class PluginFusioninventoryInventoryComputerComputer extends PluginFusioninventoryItem { /** * The right name for this class * * @var string */ static $rightname = 'computer'; public $itemtype = 'Computer'; /** * Get name of this type by language of the user connected * * @param integer $nb number of elements * @return string name of this type */ static function getTypeName($nb = 0) { return ""; } /** * Display information about computer (bios, last contact...) * * @global array $CFG_GLPI * @param object $item * @return true */ static function showAgentInfo($item) { global $CFG_GLPI; $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer(); $a_computerextend = current($pfInventoryComputerComputer->find(['computers_id' => $item->getID()], [], 1)); if (empty($a_computerextend)) { return; } echo ''; $pfAgent = new PluginFusioninventoryAgent(); $pfAgent->showInfoForComputer($item); if ($a_computerextend['bios_date'] != '') { echo ''; echo ''; echo ''; echo ''; } if ($a_computerextend['bios_version'] != '') { echo ''; echo ''; echo ''; echo ''; } if ($a_computerextend['bios_manufacturers_id'] > 0) { echo ''; echo ''; echo ''; echo ''; } if ($a_computerextend['operatingsystem_installationdate'] != '') { echo ''; echo ""; echo ''; echo ''; } if ($a_computerextend['winowner'] != '') { echo ''; echo ''; echo ''; echo ''; } if ($a_computerextend['wincompany'] != '') { echo ''; echo ''; echo ''; echo ''; } return true; } /** * Display information about computer that is linked to an agent but * has no inventory * * @since 9.2 * @param object $item * @return true */ static function showFormForAgentWithNoInventory($item) { $id = $item->getID(); $pfComputer = new self(); if ($item->isNewItem() || !empty($pfComputer->hasAutomaticInventory($id))) { return true; } else { $pfAgent = new PluginFusioninventoryAgent(); if ($pfAgent->getAgentWithComputerid($id)) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $pfAgent->showInfoForComputer($item, 4); } return true; } } /** * Display information about a computer operating system * has no inventory * * @since 9.2 * @param object $item * @return true */ static function showFormOS($item) { $pfComputer = new self(); $a_computerextend = current( $pfComputer->find(['computers_id' => $item->fields['items_id']], [], 1) ); if (empty($a_computerextend)) { return; } echo ''; echo ""; echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ""; echo ''; echo ""; echo ''; echo ""; echo ""; echo ""; echo ""; return true; } /** * Display information about computer (bios, last contact...) * * @global array $CFG_GLPI * @param object $item * @return true */ static function showComputerInfo($item) { $fi_path = Plugin::getWebDir('fusioninventory'); // Manage locks pictures PluginFusioninventoryLock::showLockIcon('Computer'); $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer(); $a_computerextend = $pfInventoryComputerComputer->hasAutomaticInventory($item->getID()); if (empty($a_computerextend)) { return true; } echo '
'.__('BIOS date', 'fusioninventory').''.Html::convDate($a_computerextend['bios_date']).'
'.__('BIOS version', 'fusioninventory').''.$a_computerextend['bios_version'].'
'.Manufacturer::getTypeName(1).' :'; echo Dropdown::getDropdownName("glpi_manufacturers", $a_computerextend['bios_manufacturers_id']); echo '
".OperatingSystem::getTypeName(1)." - ".__('Installation')." (". strtolower(_n('Date', 'Dates', 1)).")'.Html::convDate($a_computerextend['operatingsystem_installationdate']).'
'.__('Owner', 'fusioninventory').''.$a_computerextend['winowner'].'
'.__('Company', 'fusioninventory').''.$a_computerextend['wincompany'].'
'.__('FusionInventory', 'fusioninventory').'
'.__('Company', 'fusioninventory').''.$a_computerextend['wincompany'].''.__('Owner', 'fusioninventory').''.$a_computerextend['winowner'].'
".__('Comments')."'.$a_computerextend['oscomment'].'".__("Installation date")."'.Html::convDate($a_computerextend['operatingsystem_installationdate']).'
".__('HostID', 'fusioninventory').""; echo $a_computerextend['hostid']; echo "
'; echo ''; echo ''; echo ''; $pfAgent = new PluginFusioninventoryAgent(); $pfAgent->showInfoForComputer($item, 4); echo ''; if ($a_computerextend['remote_addr'] != '') { echo ''; echo ''; } else { echo ""; } echo ''; echo ''; echo ''; echo ''; // Display automatic entity transfer if (Session::isMultiEntitiesMode()) { echo ''; echo ''; } else { echo ""; } echo ''; echo ''; echo ''; $pfRemoteManagement = new PluginFusioninventoryComputerRemoteManagement(); $pfRemoteManagement->showInformation($item->getID()); echo '
'.__('FusionInventory', 'fusioninventory').'
'.__('Public contact address', 'fusioninventory').''.$a_computerextend['remote_addr'].''; echo __('Last inventory', 'fusioninventory'); echo ''; echo Html::convDateTime($a_computerextend['last_fusioninventory_update']); echo '
'.__('Automatic entity transfer', 'fusioninventory').''; $pfEntity = new PluginFusioninventoryEntity(); if ($pfEntity->getValue('transfers_id_auto', $item->fields['entities_id']) == 0) { echo __('No, locked (by entity configuration)', 'fusioninventory'); } else { if ($a_computerextend['is_entitylocked'] == 1) { echo __('No, locked manually', 'fusioninventory'); echo " [ ".__('Unlock it', 'fusioninventory')." ]"; } else { echo __('Yes'); echo " [ ".__('Lock it', 'fusioninventory')." ]"; } } echo ''; echo __('Last boot', 'fusioninventory'); echo ''; echo Html::convDateTime($a_computerextend['last_boot']); echo '
'; return true; } /** * Delete extended information of computer * * @param integer $computers_id */ static function cleanComputer($computers_id) { $pfComputer = new self(); $pfComputer->deleteByCriteria(['computers_id' => $computers_id], true, false); } /** * Get entity lock. If true, computer can't be transfered to another entity * by agent inventory (so in automatic) * * @param integer $computers_id * @return boolean */ function getLock($computers_id) { $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer(); $a_computerextend = current($pfInventoryComputerComputer->find( ['computers_id' => $computers_id], [], 1)); if (empty($a_computerextend)) { return false; } return $a_computerextend['is_entitylocked']; } }