<?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/>.
 --------------------------------------------------------------------------
 */

define('GLPI_ROOT', '../../..');
include (GLPI_ROOT."/inc/includes.php");

Html::header($LANG['plugin_eventlog']['title'][0],'',"plugins","eventlog");

$eventlog=new PluginEventlogEventlog();
if ($eventlog->canView() || Session::haveRight("config","w")) {

   $yesterday  = date('Y-m-d',mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
	if (isset($_GET)) $_GET = $_GET;
	if (!isset($_GET["id"])) $_GET["id"] = "";
	if (!isset($_GET["acked"])) $_GET["acked"] = 0;
	if (!isset($_GET["start"])) $_GET["start"] = 0;
   if (!isset($_GET["date"])) $_GET["date"] = $yesterday;
  
   $server=new PluginEventlogEventlogServer();
   
   $eventlogservers_id = $server->getEvenlogDBByEntity();
	PluginEventlogEventlog::checkConnection($eventlogservers_id);

	if (!$DBeventLog->error) {

      $eventlog->dateIndex($eventlogservers_id,$_GET["date"],$_GET["acked"]);
		$eventlog->summary($eventlogservers_id,$_GET["date"],$_GET["acked"]);

		if (isset($_GET["computer"]) 
            && !empty($_GET["computer"]) 
               && isset($_GET["date"]) 
                  && !empty($_GET["date"])) {

			$eventlog->showEvents($eventlogservers_id,$_GET);

		}
	} else {
		echo "<div align='center'>";
		echo "<img src=\"".$CFG_GLPI["root_doc"]."/pics/warning.png\" alt=\"warning\"><br><br>";
		echo "<b>".$LANG['plugin_eventlog']['setup'][1]."</b></div>";
	}

} else {
	Html::displayRightError();
}

Html::footer();

?>