/**
  * Add a new field in DB
  * @param table the table
  * @param field the field to delete
  * @return nothing
  */
 public static function addNewField($table, $field, $after = false)
 {
     global $DB;
     _log("add", $field, "from", $table);
     $itemtype = getItemTypeForTable($table);
     //Toolbox::logDebug("Will add field '".$field."' to table '".$table."'");
     if (!FieldExists($table, $field, false)) {
         $options = self::getFieldOptions($field, $itemtype);
         //Toolbox::logDebug($options);
         $query = "ALTER TABLE `{$table}` ADD `{$field}` ";
         switch ($options['input_type']) {
             case 'dropdown_yesno':
             case 'dropdown_global':
             case 'bool':
                 $query .= "TINYINT (1) NOT NULL DEFAULT '0'";
                 break;
             case 'text':
                 $query .= "VARCHAR ( 255 ) collate utf8_unicode_ci NOT NULL DEFAULT ''";
                 break;
             case 'multitext':
                 $query .= "TEXT NULL";
                 break;
             case 'dropdown':
             case 'integer':
                 $query .= "INT ( 11 ) NOT NULL DEFAULT '0'";
                 break;
             case 'date':
                 $query .= "DATE DEFAULT NULL";
                 break;
             case 'datetime':
                 $query .= "DATETIME DEFAULT NULL";
                 break;
             case 'float':
                 $query .= "FLOAT NOT NULL DEFAULT '0'";
                 break;
             case 'decimal':
                 $query .= "DECIMAL(20,4) NOT NULL DEFAULT '0.0000'";
                 break;
         }
         if ($after) {
             $query .= " AFTER `{$after}`";
         }
         $DB->query($query);
         //Reload list of fields for this itemtype in the singleton
         $recursive = $entity_assign = $tree = false;
         $table = getTableNameForForeignKeyField($field);
         if ($table != '' && !TableExists($table)) {
             //Cannot use standard methods because class doesn't exists yet !
             $name = str_replace("glpi_plugin_genericobject_", "", $table);
             $name = getSingular($name);
             $options['linked_itemtype'] = $itemtype;
             PluginGenericobjectType::addNewDropdown($name, 'PluginGenericobject' . ucfirst($name), $options);
         }
         PluginGenericobjectSingletonObjectField::getInstance($itemtype, true);
     }
 }