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

Version 0.9.7

Copyright (C) 2006-2007  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
****************************************************************************************/


// Vérification des tentatives de hack
$pos=strpos($_SERVER['PHP_SELF'],"inc.php");
if ($pos===FALSE)
	$ok_inc=TRUE;
else
	$ok_inc=FALSE;
if ($ok_inc==FALSE) header("Location: ../index.php");

include_once("../inc/config.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_int.inc.php");
Archivelog(@$_SESSION["code_log"]);

$ci = strip_tags(trim(@$_POST["ci"])); // Récupération code Intervention
$page = strip_tags(trim(@$_POST["page"])); // Récupération du numéro de page actuel
$last = strip_tags(trim(@$_POST["last"])); // Récupération du dernier numéro de page

// "Valider" : On valide simplement la fiche en cours
if (strip_tags(trim(@$_POST["enr"])) ==  "Valider")
{
	$fait = str_escape(trim(@$_POST["fait"]));

	// On valide la fiche courante
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "UPDATE `" .TBRPBM. "` SET `rpbm_datemod`= '".$datea."', `rpbm_codemod`= '".$codeuser."', `rpbm_fait`= '".$fait."' WHERE `rpbm_id`= '".@$_POST["nrpbm"]."'";
	$rs = mysql_query($rech) or die(mysql_error());
	mysql_close($conn); 

	header("Location: ".$_POST["urlcour"]);
}

$quitter=FALSE;

// "Quitter" : on a fini de saisir tous les traitements
if (strip_tags(trim(@$_POST["fin"])) ==  "Quitter")
{
	$quitter=TRUE;
	$fait = str_escape(trim(@$_POST["fait"]));
	$tab_txtfait=array();

	// On valide d'abord la fiche courante
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "UPDATE `" .TBRPBM. "` SET `rpbm_datemod`= '".$datea."', `rpbm_codemod`= '".$codeuser."', `rpbm_fait`= '".$fait."' WHERE `rpbm_id`= '".@$_POST["nrpbm"]."'";
	$rs = mysql_query($rech) or die(mysql_error());
	mysql_close($conn);  
	
	$txtfait="";
	if (@$_SESSION["pbm_choisis"]<>"")
	{
		$txtfait=htmlspecialchars(cree_txt_fait_int(@$_SESSION["pbm_choisis"]),ENT_QUOTES);
	}
}
?>
<!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 - ESPACE PRIVE : Traitement Probl&egrave;mes</title>

<!-- Scripts Javascript divers -->
<script language="JavaScript" src="../jscript/divers.js"></script>

</head>

<body>

<?PHP
// Si le formulaire a été validé en entier, on transfère dans la fiche intervention
if ($quitter==TRUE)
{
?>
<script type="text/javascript">
var valfait=window.opener.document.int_maj.fait.value;
<?PHP
// On génère la variable qui va permettre de comparer
echo "var valtxtfait='".@$_SESSION["txtfaitlst"]."';\n";
// Une fois que c'est fait, on réaffecte le nouveau texte généré
$_SESSION["txtfaitlst"]=$txtfait;
// On génère la variable du nouveau texte
echo "var txtfait ='".$txtfait."';\n";
?>
var fait=update_txt_in_txt(valfait,valtxtfait,txtfait);
window.opener.document.int_maj.fait.value=fait;
self.close();
</script>
<?PHP
}
?>
</body>
</html>
