/** * 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; }