function addPrinter($name, $manufacturer, $entity, $comment = '')
{
global $DB, $CFG_GLPI;
$manufacturer_id = 0;
if ($manufacturer != '') {
$manufacturer_id = Dropdown::importExternal('Manufacturer', $manufacturer);
}
//If there's a printer in a parent entity with the same name and manufacturer
$sql = "SELECT `id`\n FROM `glpi_printers`\n WHERE `manufacturers_id` = '{$manufacturer_id}'\n AND `name` = '{$name}' " . getEntitiesRestrictRequest('AND', 'glpi_printers', 'entities_id', $entity, true);
$res_printer = $DB->query($sql);
if ($printer = $DB->fetch_assoc($res_printer)) {
$id = $printer["id"];
} else {
$input["name"] = $name;
$input["manufacturers_id"] = $manufacturer_id;
$input["entities_id"] = $entity;
$id = $this->add($input);
}
return $id;
}