<?php
/*
 * @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $
 -------------------------------------------------------------------------
 Eventlog plugin for GLPI
 Copyright (C) 2003-2011 by the Eventlog Development Team.

 https://forge.indepnet.net/projects/eventlog
 -------------------------------------------------------------------------

 LICENSE
		
 This file is part of Eventlog.

 Eventlog is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 Eventlog is distributed in the hope that it will be useful,
 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 Eventlog. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 */

if (!defined('GLPI_ROOT')) {
	die("Sorry. You can't access directly to this file");
}

// Class for a Dropdown
class PluginEventlogEventlogType extends CommonDropdown {

   static function getTypeName() {
      global $LANG;

      return $LANG['plugin_eventlog'][6];
   }
   
   function getColor($value) {
   
      switch ($value) {
         case "1" :
            return "#cf9b9b";
            break;
         case "2" :
            return "#FFC65D";
            break;
         case "4" :
            return "#A2BB8D";
            break;
         case "16" :
            return "#CCCCCC";
            break;
            //1024
         default :
            return "";
            break;
      }
  }
  
   function selectType($value,$eventlogservers_id) {
      global $DBeventLog;
    
      PluginEventlogEventlog::checkConnection($eventlogservers_id);

      $query = "SELECT *
        FROM `".$this->getTable()."`
        ORDER BY `name` ASC";
      echo "<select name='types_id'>";
      echo "<option value='0'>".Dropdown::EMPTY_VALUE."</option>\n";
      if ($result = $DBeventLog->query($query)) {
         $numrows =  $DBeventLog->numrows($result);
         while ($data=$DBeventLog->fetch_array($result)) {
            echo "<option value='".$data["id"]."' ".($value=="".$data["id"].""?" selected ":"").">";
            echo $data["name"]."</option>";
         }
      }
      echo "</select>";
   }

   function getDropdownName($value,$eventlogservers_id) {
      global $DBeventLog;

      PluginEventlogEventlog::checkConnection($eventlogservers_id);

      $query = "SELECT `name`
        FROM `".$this->getTable()."`
        WHERE `id` = '".$value."' ";

      if ($result = $DBeventLog->query($query)) {
         $numrows =  $DBeventLog->numrows($result);
         while ($data=$DBeventLog->fetch_array($result)) {
            return $data["name"];
         }
      }
   }
}

?>