function plugin_custom_install()
{
    global $DB;
    $version = plugin_version_custom();
    $migration = new Migration($version['version']);
    // VERSION 1.0
    if (!TableExists('glpi_plugin_custom_tabs')) {
        $query = "CREATE TABLE `glpi_plugin_custom_tabs` (\n         `id` INT(11) NOT NULL AUTO_INCREMENT,\n         `name` VARCHAR(255)  collate utf8_unicode_ci NOT NULL,\n         `itemtype` VARCHAR(255) NOT NULL DEFAULT 0,\n         `tab` VARCHAR(255) NOT NULL DEFAULT 0,\n         `color` VARCHAR(255) NOT NULL DEFAULT 0,\n         PRIMARY KEY (`id`)\n      ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query);
    }
    if (!TableExists('glpi_plugin_custom_defaulttabs')) {
        $query = "CREATE TABLE `glpi_plugin_custom_defaulttabs` (\n         `id` INT(11) NOT NULL AUTO_INCREMENT,\n         `name` VARCHAR(255)  collate utf8_unicode_ci NOT NULL,\n         `itemtype` VARCHAR(255) NOT NULL DEFAULT 0,\n         `tab` VARCHAR(255) NOT NULL DEFAULT 0,\n         PRIMARY KEY (`id`)\n      ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query);
    }
    if (!TableExists('glpi_plugin_custom_styles')) {
        $query = "CREATE TABLE `glpi_plugin_custom_styles` (\n         `id` INT(11) NOT NULL AUTO_INCREMENT,\n         `body` VARCHAR(7) NOT NULL DEFAULT '#dfdfdf',\n         `button_bg_color` VARCHAR(7) NOT NULL DEFAULT '#e1cc7b',\n         `button_border` VARCHAR(7) NOT NULL DEFAULT '#8B8468',\n         `button_color` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `button_bg_color_hover` VARCHAR(7) NOT NULL DEFAULT '#ffffff',\n         `button_border_hover` VARCHAR(7) NOT NULL DEFAULT '#8B8468',\n         `button_color_hover` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `text_color` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `link_color` VARCHAR(7) NOT NULL DEFAULT '#659900',\n         `link_hover_color` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `menu_link` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `ssmenu1_link` VARCHAR(7) NOT NULL DEFAULT '#666666',\n         `ssmenu2_link` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `link_topright` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `menu_border` VARCHAR(7) NOT NULL DEFAULT '#9BA563',\n         `menu_item_bg` VARCHAR(7) NOT NULL DEFAULT '#f1e7c2',\n         `menu_item_link` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `menu_item_border` VARCHAR(7) NOT NULL DEFAULT '#CC9900',\n         `menu_item_bg_hover` VARCHAR(7) NOT NULL DEFAULT '#d0d99d',\n         `table_bg_color` VARCHAR(7) NOT NULL DEFAULT '#F2F2F2',\n         `th` VARCHAR(7) NOT NULL DEFAULT '#e1cc7b',\n         `th_text_color` VARCHAR(7) NOT NULL DEFAULT '#000000',\n         `tab_bg_1` VARCHAR(7) NOT NULL DEFAULT '#f2f2f2',\n         `tab_bg_1_2` VARCHAR(7) NOT NULL DEFAULT '#cf9b9b',\n         `tab_bg_2` VARCHAR(7) NOT NULL DEFAULT '#f2f2f2',\n         `tab_bg_2_2` VARCHAR(7) NOT NULL DEFAULT '#cf9b9b',\n         `tab_bg_3` VARCHAR(7) NOT NULL DEFAULT '#e7e7e2',\n         `tab_bg_4` VARCHAR(7) NOT NULL DEFAULT '#e4e4e2',\n         `tab_bg_5` VARCHAR(7) NOT NULL DEFAULT '#f2f2f2',\n         `header_bg1` VARCHAR(7) NOT NULL DEFAULT '#FFFFFF',\n         `header_bg2` VARCHAR(7) NOT NULL DEFAULT '#f5efd6',\n         `header_bg3` VARCHAR(7) NOT NULL DEFAULT '#d6bc53',\n         `header_bg4` VARCHAR(7) NOT NULL DEFAULT '#c0cc7b',\n         `header_bg5` VARCHAR(7) NOT NULL DEFAULT '#d0d99d',\n         `header_bg6` VARCHAR(7) NOT NULL DEFAULT '#f1f4e3',\n         `header_shadow_color` VARCHAR(7) NOT NULL DEFAULT '#011E3A',\n         `page_shadow_color` VARCHAR(7) NOT NULL DEFAULT '#011E3A',\n         `footer_shadow_color` VARCHAR(7) NOT NULL DEFAULT '#011E3A',\n         `footer_bg1` VARCHAR(7) NOT NULL DEFAULT '#FFFFFF',\n         `footer_bg2` VARCHAR(7) NOT NULL DEFAULT '#e2cf83',\n         `cadre_central_bg1` VARCHAR(7) NOT NULL DEFAULT '#e8dab0',\n         `cadre_central_bg2` VARCHAR(7) NOT NULL DEFAULT '#FFFFFF',\n         `tabs_bg1` VARCHAR(7) NOT NULL DEFAULT '#fcfcfa',\n         `tabs_bg2` VARCHAR(7) NOT NULL DEFAULT '#ddddc8',\n         `tabs_bg3` VARCHAR(7) NOT NULL DEFAULT '#cfcfb2',\n         `tabs_border` VARCHAR(7) NOT NULL DEFAULT '#909058',\n         `tabs_title_color` VARCHAR(7) NOT NULL DEFAULT '#659900',\n         PRIMARY KEY (`id`)\n      ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query);
    }
    if (!TableExists('glpi_plugin_custom_profiles')) {
        $query = "CREATE TABLE `glpi_plugin_custom_profiles` (\n         `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\n         `profiles_id` VARCHAR(45) NOT NULL,\n         `add_tabs` CHAR(1),\n         `add_defaulttabs` CHAR(1),\n         `edit_style` CHAR(1),\n         PRIMARY KEY (`id`)\n      )\n      ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query);
    }
    if (!FieldExists('glpi_plugin_custom_styles', 'text_color')) {
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `text_color` VARCHAR(7) NOT NULL DEFAULT '#000000'";
        $DB->query($query);
    }
    if (!FieldExists('glpi_plugin_custom_styles', 'th_text_color')) {
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `th_text_color` VARCHAR(7) NOT NULL DEFAULT '#000000'";
        $DB->query($query);
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `table_bg_color` VARCHAR(7) NOT NULL DEFAULT '#F2F2F2'";
        $DB->query($query);
    }
    if (!FieldExists('glpi_plugin_custom_styles', 'link_topright')) {
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `link_topright` VARCHAR(7) NOT NULL DEFAULT '#000000'";
        $DB->query($query);
    }
    if (!FieldExists('glpi_plugin_custom_styles', 'button_bg_color')) {
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `button_bg_color` VARCHAR(7) NOT NULL DEFAULT '#e1cc7b'";
        $DB->query($query);
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `button_border` VARCHAR(7) NOT NULL DEFAULT '#8B8468'";
        $DB->query($query);
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `button_color` VARCHAR(7) NOT NULL DEFAULT '#000000'";
        $DB->query($query);
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `button_bg_color_hover` VARCHAR(7) NOT NULL DEFAULT '#FFFFFF'";
        $DB->query($query);
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `button_border_hover` VARCHAR(7) NOT NULL DEFAULT '#8B8468'";
        $DB->query($query);
        $query = "ALTER TABLE `glpi_plugin_custom_styles` ADD COLUMN `button_color_hover` VARCHAR(7) NOT NULL DEFAULT '#000000'";
        $DB->query($query);
    }
    //create plugin file dir
    if (!is_dir(CUSTOM_FILES_DIR)) {
        mkdir(CUSTOM_FILES_DIR);
    }
    touch(CUSTOM_FILES_DIR . "glpi_style.css");
    //create config style
    require_once "style.class.php";
    $style = new PluginCustomStyle();
    $found = $style->find();
    if (empty($found)) {
        $style->add(array('id' => 0));
    }
    //Version 1.1
    if (!TableExists('glpi_plugin_custom_tabprofiles')) {
        $query = "CREATE TABLE     `glpi_plugin_custom_tabprofiles` (\n         `id`                    INT(11) NOT NULL AUTO_INCREMENT,\n         `plugin_custom_tabs_id` INT(11),\n         `profiles_id`           INT(11),\n         PRIMARY KEY             (`id`),\n         KEY                     (`plugin_custom_tabs_id`),\n         KEY                     (`profiles_id`)\n      ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query);
    }
    if (!FieldExists('glpi_plugin_custom_styles', 'text_color')) {
        $migration->addField('glpi_plugin_custom_styles', 'text_color', "VARCHAR(7) NOT NULL DEFAULT '#000000'", array('after' => 'body'));
        $migration->migrationOneTable('glpi_plugin_custom_styles');
    }
    return true;
}
<?php

include "../../../inc/includes.php";
Html::header(__('Custom', 'custom'), $_SERVER['PHP_SELF'], "config", "PluginCustomConfig", "style");
$style = new PluginCustomStyle();
if (isset($_POST['add'])) {
    $style->add($_POST);
    Html::back();
} elseif (isset($_POST['update'])) {
    $style->update($_POST);
    Html::back();
} elseif (isset($_POST['purge'])) {
    $style->delete($_POST);
    $css_file = GLPI_ROOT . "/files/_plugins/custom/glpi_style.css";
    if (file_exists($css_file)) {
        unlink($css_file);
    }
    Html::back();
}
$ID = isset($_POST['id']) ? $_POST['id'] : PluginCustomStyle::getSingle();
$style->showForm($ID);
Html::footer();