/**
  * @test
  */
 public function AddPrinter()
 {
     global $DB;
     $DB->connect();
     $this->update_time = date('Y-m-d H:i:s');
     $a_inventory = array('PluginFusioninventoryPrinter' => array('sysdescr' => 'HP ETHERNET MULTI-ENVIRONMENT', 'last_fusioninventory_update' => $this->update_time), 'networkport' => array(), 'cartridge' => array('63' => 60, '71' => 40, '79' => 80, '75' => 100), 'itemtype' => 'Printer');
     $a_inventory['Printer'] = array('name' => 'ARC12-B09-N', 'id' => 54, 'serial' => 'VRG5XUT5', 'manufacturers_id' => 10, 'locations_id' => 102, 'printermodels_id' => 15, 'memory_size' => 64, 'is_dynamic' => 1, 'have_ethernet' => 1);
     $a_inventory['pagecounters'] = array('pages_total' => 15134, 'pages_n_b' => 10007, 'pages_color' => 5127, 'pages_recto_verso' => 0, 'pages_total_copy' => 0, 'scanned' => 0, 'pages_total_print' => 0, 'pages_n_b_print' => 0, 'pages_color_print' => 0, 'pages_n_b_copy' => 0, 'pages_color_copy' => 0, 'pages_total_fax' => 0);
     $pfiPrinterLib = new PluginFusioninventoryInventoryPrinterLib();
     $printer = new Printer();
     $this->items_id = $printer->add(array('serial' => 'VRG5XUT5', 'entities_id' => 0));
     $this->assertGreaterThan(0, $this->items_id);
     $pfiPrinterLib->updatePrinter($a_inventory, $this->items_id);
     // To be sure not have 2 sme informations
     $pfiPrinterLib->updatePrinter($a_inventory, $this->items_id);
 }
 /**
  * Import one device
  *
  * @param type $itemtype
  * @param type $items_id
  *
  * @return errors string to be alimented if import ko / '' if ok
  */
 function importDevice($itemtype, $items_id, $a_inventory)
 {
     global $PLUGIN_FUSIONINVENTORY_XML;
     PluginFusioninventoryCommunication::addLog('Function PluginFusioninventoryCommunicationNetworkInventory->importDevice().');
     $pfFormatconvert = new PluginFusioninventoryFormatconvert();
     $a_inventory = $pfFormatconvert->replaceids($a_inventory);
     // Write XML file
     if (count($a_inventory) > 0) {
         $xml = $PLUGIN_FUSIONINVENTORY_XML->CONTENT->DEVICE[$_SESSION['plugin_fusioninventory_xmlnum']]->asXML();
         PluginFusioninventoryToolbox::writeXML($items_id, $xml, $itemtype);
         //         $folder = substr($items_id, 0, -1);
         //         if (empty($folder)) {
         //            $folder = '0';
         //         }
         //         if (!file_exists(GLPI_PLUGIN_DOC_DIR."/fusioninventory/".$itemtype."/".$folder)) {
         //            mkdir(GLPI_PLUGIN_DOC_DIR."/fusioninventory/".$itemtype."/".$folder, 0777, TRUE);
         //         }
         //         $fileopen = fopen(GLPI_PLUGIN_DOC_DIR."/fusioninventory/".$itemtype."/".$folder."/".
         //                           $items_id, 'w');
         //         fwrite($fileopen, print_r($a_inventory, TRUE));
         //         fclose($fileopen);
     }
     $errors = '';
     $this->deviceId = $items_id;
     $serialized = gzcompress(serialize($a_inventory));
     if (isset($a_inventory['name']) && $a_inventory['name'] == '') {
         unset($a_inventory['name']);
     }
     if (isset($a_inventory['serial']) && $a_inventory['serial'] == '') {
         unset($a_inventory['serial']);
     }
     switch ($itemtype) {
         case 'Printer':
             $pfiPrinterLib = new PluginFusioninventoryInventoryPrinterLib();
             $a_inventory['PluginFusioninventoryPrinter']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
             $pfiPrinterLib->updatePrinter($a_inventory, $items_id);
             break;
         case 'NetworkEquipment':
             $pfiNetworkEquipmentLib = new PluginFusioninventoryInventoryNetworkEquipmentLib();
             $a_inventory['PluginFusioninventoryNetworkEquipment']['serialized_inventory'] = Toolbox::addslashes_deep($serialized);
             $pfiNetworkEquipmentLib->updateNetworkEquipment($a_inventory, $items_id);
             break;
         default:
             $errors .= __('Unattended element in', 'fusioninventory') . ' TYPE : ' . $a_inventory['itemtype'] . "\n";
     }
 }