<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 0.9.9

Copyright (C) 2006-2009  Sylvain FATOME
This program 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.

This program 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 this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr

Web : http://smitst.homelinux.com
****************************************************************************************/

session_start(); 
if (!isset($_SESSION["lng"])) $_SESSION["lng"]="fr";
include_once("../lng/".$_SESSION["lng"].".inc.php"); // Paramètres de language
include_once("../inc/config.inc.php");
include_once("../inc/func_log.inc.php");
if (CheckURLLog(TRUE)==FALSE) header("Location: ../index.php");
if (CheckNivLog("9")==FALSE) header("Location: ../index.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");

// Variables Formulaire
$td = strip_tags(trim($_GET['td']));

$date1="";
$date2="";
if (isset($_POST["date1f"]))
{
	if (strip_tags(trim(@$_POST["date1f"]))<>"")
	{
		$date1f = strip_tags(trim(@$_POST["date1f"]));
		$date1 = datefrang($date1f);
	}
}
if (isset($_POST["date2f"]))
{
	if (strip_tags(trim(@$_POST["date2f"]))<>"")
	{
		$date2f = strip_tags(trim(@$_POST["date2f"]));
		$date2 = datefrang($date2f);
	}
}

$retourliste = TRUE;

if ($td == "del")
{
	$msg = "";

	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);

	// Vérification de l'existence de la fourchette de dates

	if ($date1!="") // Date remplie = purge sur fourchette
		$rech = "SELECT * FROM `" .TBFICLOG. "` WHERE `ficlog_date` >= '$date1' AND `ficlog_date` <= '$date2'";
	else
		$rech = "SELECT * FROM `" .TBFICLOG. "`";
	$rs = mysql_query($rech) or die(mysql_error());
	if (mysql_num_rows($rs) <> 0)
	{
		// SUPPRESSION des logs
		if ($date1!="") // Date remplie = purge sur fourchette
			$rech = "DELETE FROM `" .TBFICLOG. "` WHERE `ficlog_date` >= '$date1' AND `ficlog_date` <= '$date2'";
		else
			$rech = "TRUNCATE TABLE `" .TBFICLOG. "`";
		$rs = mysql_query($rech) or die(mysql_error());

		if ($date1!="") // Date remplie = purge sur fourchette
			$msg = $txt_div_logpurg1.$date1f.$txt_div_to.$date2f;
		else
			$msg = $txt_div_logpurg2;
	}
	else
	{
		if ($date1!="") // Date remplie = purge sur fourchette
			$msg = $alert_nolog1;
		else
			$msg = $alert_nolog2;
		$retourliste = FALSE;
	}
	mysql_close($conn);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SMI - <?PHP echo $title_esp_prive; ?> : <?PHP echo $title_flog_edit; ?></title>

<!-- Feuille de style pour les affichages courants -->
<link href="../css/smi.css" rel="stylesheet" type="text/css">

<!-- Feuille de style & Script pour le menu -->
<script language="JavaScript" src="../jscript/coolmenus/coolmenus4.js"></script>

</head>
<body>

<?php 
include_once("../inc/entete.inc.php"); 
?>
<p align="center"><span class="titrepage"><?PHP echo $titlein_flog_maj_edit; ?></span></p>
<p align="center">&nbsp;</p>
<p align="center">
<?PHP if ($retourliste==FALSE)
	echo '<span class="alerte1">';
else
	echo '<span class="annot_std_gras">';
?>
<?PHP echo $msg ?>
</span>
</p>
<?PHP 
if ($retourliste == FALSE)
	aff_ret_idx_man($td,"flog_lst.php?ord=DES&tri=Date",$txt_lnk_ret_liste,TRUE);
else
	aff_ret_lst_auto("flog_lst.php?ord=DES&tri=Date",2000);
include_once("pied.php");
?>
