$_POST['FK_printers'] = $_POST['ID']; unset($_POST['ID']); $query = "SELECT * \n FROM `glpi_plugin_fusioninventory_printers`\n WHERE `FK_printers`='" . $_POST['FK_printers'] . "' "; $result = $DB->query($query); $data = $DB->fetch_assoc($result); $_POST['ID'] = $data['ID']; $plugin_fusioninventory_printers->update($_POST); } else { if (isset($_POST["GetRightModel"]) && isset($_POST['ID'])) { $plugin_fusioninventory_model_infos = new PluginFusioninventoryModelInfos(); $plugin_fusioninventory_model_infos->getrightmodel($_POST['ID'], PRINTER_TYPE); } } if (isset($_POST['update_cartridges']) && isset($_POST['ID'])) { PluginFusioninventoryAuth::checkRight("snmp_printers", "w"); $plugin_fusioninventory_printers_cartridges = new PluginFusioninventoryPrintersCartridges(); $query = "SELECT * \n FROM `glpi_plugin_fusioninventory_printers_cartridges`\n WHERE `FK_printers`='" . $_POST['ID'] . "'\n AND `object_name`='" . $_POST['object_name'] . "' "; $result = $DB->query($query); if ($DB->numrows($result) == "0") { $_POST['FK_printers'] = $_POST['ID']; unset($_POST['ID']); $plugin_fusioninventory_printers_cartridges->add($_POST); } else { $data = $DB->fetch_assoc($result); $plugin_fusioninventory_printers_cartridges->update($_POST); } } $arg = ""; for ($i = 1; $i <= 5; $i++) { switch ($i) { case 1:
static function clean_db() { global $DB; $ptp = new PluginFusioninventoryPort(); $pti = new PluginFusioninventoryIfaddr(); $ptn = new PluginFusioninventoryNetworking2(); $ptpr = new PluginFusioninventoryPrinters(); $ptpc = new PluginFusioninventoryPrintersCartridges(); $ptph = new PluginFusioninventoryPrintersHistory(); // * Clean glpi_plugin_fusioninventory_networking_ports $query_select = "SELECT `glpi_plugin_fusioninventory_networking_ports`.`ID`\n FROM `glpi_plugin_fusioninventory_networking_ports`\n LEFT JOIN `glpi_networking_ports`\n ON `glpi_networking_ports`.`ID` = `FK_networking_ports`\n LEFT JOIN `glpi_networking` ON `glpi_networking`.`ID` = `on_device`\n WHERE `glpi_networking`.`ID` IS NULL"; $result = $DB->query($query_select); while ($data = $DB->fetch_array($result)) { $ptp->deleteFromDB($data["ID"], 1); } // * Clean glpi_plugin_fusioninventory_networking_ifaddr $query_select = "SELECT `glpi_plugin_fusioninventory_networking_ifaddr`.`ID`\n FROM `glpi_plugin_fusioninventory_networking_ifaddr`\n LEFT JOIN `glpi_networking` ON `glpi_networking`.`ID` = `FK_networking`\n WHERE `glpi_networking`.`ID` IS NULL"; $result = $DB->query($query_select); while ($data = $DB->fetch_array($result)) { $pti->deleteFromDB($data["ID"], 1); } // * Clean glpi_plugin_fusioninventory_networking $query_select = "SELECT `glpi_plugin_fusioninventory_networking`.`ID`\n FROM `glpi_plugin_fusioninventory_networking`\n LEFT JOIN `glpi_networking` ON `glpi_networking`.`ID` = `FK_networking`\n WHERE `glpi_networking`.`ID` IS NULL"; $result = $DB->query($query_select); while ($data = $DB->fetch_array($result)) { $ptn->deleteFromDB($data["ID"], 1); } // * Clean glpi_plugin_fusioninventory_printers $query_select = "SELECT `glpi_plugin_fusioninventory_printers`.`ID`\n FROM `glpi_plugin_fusioninventory_printers`\n LEFT JOIN `glpi_printers` ON `glpi_printers`.`ID` = `FK_printers`\n WHERE `glpi_printers`.`ID` IS NULL"; $result = $DB->query($query_select); while ($data = $DB->fetch_array($result)) { $ptpr->deleteFromDB($data["ID"], 1); } // * Clean glpi_plugin_fusioninventory_printers_cartridges $query_select = "SELECT `glpi_plugin_fusioninventory_printers_cartridges`.`ID`\n FROM `glpi_plugin_fusioninventory_printers_cartridges`\n LEFT JOIN `glpi_printers` ON `glpi_printers`.`ID` = `FK_printers`\n WHERE `glpi_printers`.`ID` IS NULL"; $result = $DB->query($query_select); while ($data = $DB->fetch_array($result)) { $ptpc->deleteFromDB($data["ID"], 1); } // * Clean glpi_plugin_fusioninventory_printers_history $query_select = "SELECT `glpi_plugin_fusioninventory_printers_history`.`ID`\n FROM `glpi_plugin_fusioninventory_printers_history`\n LEFT JOIN `glpi_printers` ON `glpi_printers`.`ID` = `FK_printers`\n WHERE `glpi_printers`.`ID` IS NULL"; $result = $DB->query($query_select); while ($data = $DB->fetch_array($result)) { $ptph->deleteFromDB($data["ID"], 1); } }