public function itemtypeDropdown()
 {
     global $CFG_GLPI;
     $itemtypes = PluginCustomTab::getTypes();
     echo "<select name='itemtype' id='tabsitemtype'>";
     echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n";
     foreach ($itemtypes as $key => $value) {
         if ($this->fields['id'] > 0 && $this->fields['itemtype'] == $key) {
             echo "<option value='{$key}' selected='selected'>{$value}</option>";
         } else {
             echo "<option value='{$key}'>{$value}</option>";
         }
     }
     echo "</select>";
     $params = array('itemtype' => '__VALUE__', 'myname' => 'tabstab', 'value' => $this->fields['tab'], 'id' => $this->fields['id']);
     Ajax::updateItemOnSelectEvent('tabsitemtype', 'tabstab', $CFG_GLPI["root_doc"] . "/plugins/custom/ajax/dropdowntab.php", $params);
 }
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu['page'] = "/plugins/custom/front/config.php";
     $menu['title'] = self::getTypeName();
     $menu['options']['tab']['page'] = "/plugins/custom/front/tab.php";
     $menu['options']['tab']['title'] = __("Color or delete tabs", 'custom');
     $menu['options']['tab']['links']['add'] = PluginCustomTab::getFormURL(false);
     if (PluginCustomTab::canCreate()) {
         $menu['options']['tab']['links']['search'] = PluginCustomTab::getSearchURL(false);
     }
     $menu['options']['defaulttab']['page'] = "/plugins/custom/front/defaulttab.php";
     $menu['options']['defaulttab']['title'] = __("default Tab", 'custom');
     $menu['options']['defaulttab']['links']['add'] = PluginCustomDefaulttab::getFormURL(false);
     if (PluginCustomDefaulttab::canCreate()) {
         $menu['options']['defaulttab']['links']['search'] = PluginCustomDefaulttab::getSearchURL(false);
     }
     $menu['options']['style']['page'] = "/plugins/custom/front/style.form.php";
     $menu['options']['style']['title'] = __("Customise GLPI style", 'custom');
     return $menu;
 }
$itemtype = $_POST['itemtype'];
$obj = new $itemtype();
$obj->fields['id'] = 1;
if ($itemtype == "ticket") {
    $obj->fields['status'] = "closed";
}
$tabs = $obj->defineTabs();
/*$tmp_plug_tabs = Plugin::getTabs('', $obj, false);
$plug_tabs = array();
foreach($tmp_plug_tabs as $key => $tab) {
   $plug_tabs[$key] = $tab['title'];
}
$tabs += $plug_tabs;*/
$tabs_used = -1;
if ($_POST['id'] > 0) {
    $colortabs = new PluginCustomTab();
    $colortabs->getFromDB($_POST['id']);
    $tabs_used = $colortabs->getField('tab');
}
// remove previously used tabs
$query = "SELECT tab FROM glpi_plugin_custom_tabs\n   WHERE itemtype = '{$itemtype}' AND tab != '{$tabs_used}'";
$res = $DB->query($query);
$usedTabs = array();
while ($data = $DB->fetch_array($res)) {
    unset($tabs[$data['tab']]);
}
// display select tab of itemtype
echo "<select name='tab' id='tabstab'>";
echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n";
foreach ($tabs as $key => $value) {
    if ($selected_value == $key) {
    $query = "SELECT * FROM glpi_plugin_custom_tabs WHERE itemtype = '{$itemtype}'";
    $res = $DB->query($query);
    while ($data = $DB->fetch_array($res)) {
        $color = $data['color'];
        $tab = PluginCustomTab::escapeTabName($data['tab']);
        if ($color != "deleted") {
            echo "\$('li[role=tab]:has(a[href*={$tab}])').addClass('{$color}');";
        } else {
            echo "\$('li[role=tab]:has(a[href*={$tab}])').remove();";
        }
    }
    /*** Default Tabs ***/
    $query = "SELECT * FROM glpi_plugin_custom_defaulttabs WHERE itemtype = '{$itemtype}'";
    $res = $DB->query($query);
    $data = $DB->fetch_array($res);
    $default_tab = PluginCustomTab::escapeTabName($data['tab']);
    echo "}";
    $path = dirname(dirname(dirname($_SERVER['REQUEST_URI'])));
    $login_locale = __("Login");
    $JS = <<<JAVASCRIPT

      starVIP = function() {
         \$('a[id*=tooltiplink] img').each(function (index) {
            var tip = \$(this).qtip();
            if (tip && "options" in tip) {
               var ttip_content = tip.options.content.text[0].innerHTML;
               if (ttip_content
                  && ttip_content.indexOf('VIP') > 0
                  && ttip_content.indexOf('{$login_locale}') > 0
                  && \$(this).parent()[0].innerHTML.indexOf('vip.png') == -1) {
                  \$(this).after("<img src='{$path}/plugins/custom/pics/vip.png' alt='VIP' title='VIP' />");
    //get object tabs
    $tabs = $obj->defineTabs();
    /*//get object plugins tabs
      $tmp_plug_tabs = Plugin::getTabs('', $obj, false);
      $plug_tabs = array();
      foreach($tmp_plug_tabs as $key => $tab) {
         $plug_tabs[$key] = $tab['title'];
      }
      $tabs += $plug_tabs;*/
    //construct name field
    $tabs = $tabs[$_POST['tab']];
    $types = PluginCustomTab::getTypes();
    $itemtype = $types[$_POST['itemtype']];
    $_POST['name'] = $itemtype . "-" . $tabs . "-" . ucfirst(__($_POST['color'], 'custom'));
}
$tabs = new PluginCustomTab();
if (isset($_POST["add"])) {
    $newID = $tabs->add($_POST);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/custom/front/tab.form.php");
} elseif (isset($_POST["delete"])) {
    $ok = $tabs->delete($_POST);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/custom/front/tab.php");
} elseif (isset($_REQUEST["purge"])) {
    $tabs->delete($_REQUEST, 1);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/custom/front/tab.php");
} elseif (isset($_POST["update"])) {
    $tabs->update($_POST);
    Html::back();
} else {
    Html::header(__('Custom', 'custom'), $_SERVER['PHP_SELF'], "config", "PluginCustomConfig", "tab");
    $tabs->display(array('id' => $_GET["id"]));
include "../../../inc/includes.php";
if (empty($_GET["id"])) {
    $_GET["id"] = "";
}
if (isset($_POST['itemtype']) && isset($_POST['tab']) && (isset($_POST["add"]) || isset($_POST["update"]))) {
    $itemtype = $_POST['itemtype'];
    $obj = new $_POST['itemtype']();
    $obj->fields['id'] = 1;
    if ($itemtype == "ticket") {
        $obj->fields['status'] = "closed";
    }
    //get object tabs
    $tabs = $obj->defineTabs();
    //construct name field
    $tabs = $tabs[$_POST['tab']];
    $types = PluginCustomTab::getTypes();
    $itemtype = $types[$_POST['itemtype']];
    $_POST['name'] = $itemtype . "-" . $tabs;
}
$tabs = new PluginCustomDefaulttab();
if (isset($_POST["add"])) {
    $newID = $tabs->add($_POST);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/custom/front/defaulttab.form.php");
} elseif (isset($_POST["delete"])) {
    $ok = $tabs->delete($_POST);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/custom/front/defaulttab.php");
} elseif (isset($_REQUEST["purge"])) {
    $tabs->delete($_REQUEST, 1);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/custom/front/defaulttab.php");
} elseif (isset($_POST["update"])) {
    $tabs->update($_POST);