/**
  * Update an existing preloaded switch with the instance values
  *
  *@return nothing
  **/
 function updateDB()
 {
     if (array_key_exists('model', $this->ptcdUpdates)) {
         $manufacturer = Dropdown::getDropdownName("glpi_dropdown_manufacturer", $this->getValue('FK_glpi_enterprise'));
         $this->ptcdUpdates['model'] = Dropdown::importExternal("NetworkEquipmentModel", $this->ptcdUpdates['model'], 0, array('manufacturer' => $manufacturer));
     }
     if (array_key_exists('firmware', $this->ptcdUpdates)) {
         $this->ptcdUpdates['firmware'] = Dropdown::importExternal("NetworkEquipmentFirmware", $this->ptcdUpdates['firmware']);
     }
     if (array_key_exists('location', $this->ptcdUpdates)) {
         $this->ptcdUpdates['location'] = Dropdown::importExternal("Location", $this->ptcdUpdates['location']);
     }
     parent::updateDB();
     // update last_fusioninventory_update even if no other update
     $this->setValue('last_fusioninventory_update', date("Y-m-d H:i:s"));
     $this->oFusionInventory_networking->updateDB();
     // ports
     $this->savePorts();
 }
 /**
  * Constructor
  **/
 function __construct()
 {
     parent::__construct("glpi_plugin_fusioninventory_networking_ifaddr");
 }
 /**
  * Get cartridges
  *
  *@return Array of cartridges
  **/
 private function getCartridgesDB()
 {
     global $DB;
     $ptc = new PluginFusioninventoryCommonDBTM('glpi_plugin_fusioninventory_printers_cartridges');
     $query = "SELECT `ID`\n                FROM `glpi_plugin_fusioninventory_printers_cartridges`\n                WHERE `FK_printers` = '" . $this->getValue('ID') . "';";
     $cartridgesIds = array();
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result) != 0) {
             while ($cartridge = $DB->fetch_assoc($result)) {
                 $ptc->load($cartridge['ID']);
                 $cartridgesIds[] = clone $ptc;
             }
         }
     }
     return $cartridgesIds;
 }
 /**
  * Delete a loaded port
  *
  *@param $p_id Port ID
  *@return nothing
  **/
 function deleteDB()
 {
     $this->cleanVlan('', $this->getValue('ID'));
     $this->disconnectDB($this->getValue('ID'));
     $this->oFusionInventory_networking_ports->deleteDB();
     // fusioninventory
     parent::deleteDB();
     // core
 }
 /**
  * Import CARTRIDGES
  *@param $p_cartridges CARTRIDGES code to import
  *
  *@return errors string to be alimented if import ko / '' if ok
  **/
 function importCartridges($p_cartridges)
 {
     global $LANG;
     $errors = '';
     foreach ($p_cartridges->children() as $name => $child) {
         switch ($name) {
             case 'TONERBLACK':
             case 'TONERBLACK2':
             case 'TONERCYAN':
             case 'TONERMAGENTA':
             case 'TONERYELLOW':
             case 'WASTETONER':
             case 'CARTRIDGEBLACK':
             case 'CARTRIDGEBLACKPHOTO':
             case 'CARTRIDGECYAN':
             case 'CARTRIDGECYANLIGHT':
             case 'CARTRIDGEMAGENTA':
             case 'CARTRIDGEMAGENTALIGHT':
             case 'CARTRIDGEYELLOW':
             case 'MAINTENANCEKIT':
             case 'DRUMBLACK':
             case 'DRUMCYAN':
             case 'DRUMMAGENTA':
             case 'DRUMYELLOW':
                 $ptc = new PluginFusioninventoryCommonDBTM("glpi_plugin_fusioninventory_printers_cartridges");
                 $cartridgeIndex = $this->ptd->getCartridgeIndex($name);
                 if (is_int($cartridgeIndex)) {
                     $oldCartridge = $this->ptd->getCartridge($cartridgeIndex);
                     //TODO ???
                     $ptc->load($oldCartridge->getValue('ID'));
                 } else {
                     $ptc->addCommon(TRUE);
                     //TODO ???
                     $ptc->setValue('FK_printers', $this->deviceId);
                 }
                 $ptc->setValue('object_name', $name);
                 $ptc->setValue('state', $child, $ptc, 0);
                 $this->ptd->addCartridge($ptc, $cartridgeIndex);
                 break;
             default:
                 $errors .= $LANG['plugin_fusioninventory']["errors"][22] . ' CARTRIDGES : ' . $name . "\n";
         }
     }
     return $errors;
 }