but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with GLPI; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  ------------------------------------------------------------------------
*/
// Original Author of file: David DURIEUX
// Purpose of file:
// ----------------------------------------------------------------------
$NEEDED_ITEMS = array("setup", "rulesengine", "fusioninventory", "search");
define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
$ptcd = new PluginFusioninventoryConstructDevice();
commonHeader($LANG['plugin_fusioninventory']["title"][0], $_SERVER["PHP_SELF"], "plugins", "fusioninventory", "constructdevice");
PluginFusioninventoryDisplay::mini_menu();
if (isset($_GET['vlan_update'])) {
    $query_update = "UPDATE `glpi_plugin_fusioninventory_construct_mibs`\n         SET vlan=0\n      WHERE construct_device_id=" . $_GET['ID'] . "\n         AND mib_oid_id=" . $_GET['vlan_update'];
    $DB->query($query_update);
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["add"])) {
        $query = "SELECT * FROM glpi_plugin_fusioninventory_construct_device\n      WHERE sysdescr='" . $_POST['sysdescr'] . "' ";
        $result = $DB->query($query);
        if ($DB->numrows($result) == '0') {
            $ptcd->add($_POST);
        } else {
            $_SESSION["MESSAGE_AFTER_REDIRECT"] = "Déjà existant";
        }
    $ptcd = new PluginFusioninventoryConstructDevice();
    $ptcd->generatemodels();
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_GET['generatediscover']) and $_GET['generatediscover'] == '1') {
        $ptcd = new PluginFusioninventoryConstructDevice();
        $ptcd->generateDiscovery();
        glpi_header($_SERVER['HTTP_REFERER']);
    } else {
        if (isset($_GET['cleanmodels']) and $_GET['cleanmodels'] == '1') {
            $ptcd = new PluginFusioninventoryConstructDevice();
            $ptcd->cleanmodels();
            glpi_header($_SERVER['HTTP_REFERER']);
        } else {
            if (isset($_GET['exportmodels']) and $_GET['exportmodels'] == '1') {
                $ptcd = new PluginFusioninventoryConstructDevice();
                $ptcd->exportmodels();
                glpi_header($_SERVER['HTTP_REFERER']);
            }
        }
    }
}
echo "<a href='" . $_SERVER["PHP_SELF"] . "?generatemodels=1'>Creation automatique des modèles</a>";
echo " | ";
echo "<a href='" . $_SERVER["PHP_SELF"] . "?generatediscover=1'>Générer le fichier de découverte</a>";
echo " | ";
echo "<a href='" . $_SERVER["PHP_SELF"] . "?cleanmodels=1'>Supprimer modèles non utilisés</a>";
echo " | ";
echo "<a href='" . $_SERVER["PHP_SELF"] . "?exportmodels=1'>Exporter tous les modèles</a>";
searchForm(PLUGIN_FUSIONINVENTORY_CONSTRUCT_DEVICE, $_GET);
showList(PLUGIN_FUSIONINVENTORY_CONSTRUCT_DEVICE, $_GET);