<?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.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);

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

$pbm_rpbm=FALSE;

if ($ci<>"")
{
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM `" .TBINT. "` WHERE `int_code`= '".$ci."'";
	$rs = mysql_query($rech);
	if (mysql_num_rows($rs)>0)
	{
		if ($row = mysql_fetch_array($rs))
		{
			extract ($row);
			if (formatedate($int_datefin) == "")
			{
				$rech = "SELECT * FROM `" .TBRPBM. "` WHERE `rpbm_codeint`= '".$ci."'";
				$rs = mysql_query($rech);
				$last = mysql_num_rows($rs); // Nombre de résultats à la requête
				if ($page<0)
					$page=last;
				if (($page>last) OR ($page==0))
					$page=1;
			}
			else
				$pbm_rpbm=TRUE;
		}
		else
			$pbm_rpbm=TRUE;
	}
	else
		$pbm_rpbm=TRUE;
	mysql_free_result($rs);
	mysql_close($conn);
}
else
	$pbm_rpbm=TRUE;
?>
<!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>

<!-- 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>

<!-- Scripts Javascript pour fenêtres -->
<script language="JavaScript" src="../jscript/fen.js"></script>

<!-- Scripts Javascript pour contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/vform/vform.js"></script>

<script language="javascript">
var tab1_champ=new Array(
	"nom:fait ; format:txt ; req:N ; txt:Travail effectué ; stok:frmok ; stbad:frmbad");
</script>

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

</head>

<body onLoad="metFocus();">
<?PHP
if ($pbm_rpbm==FALSE)
{
?>
<p align="center"><span class="titrepage">LISTE DES PROBLEMES AFFECTES</span></p>
<p align="center">Merci de d&eacute;tailler les solutions apport&eacute;es aux les probl&egrave;mes affect&eacute;s &agrave; l'intervention <span class="annot_std_gras"><?PHP echo $ci;?></span> </p>
<p align="center" class="annot_gras_it">ATTENTION : apr&egrave;s validation d&eacute;finitive, la zone &quot;travail effectu&eacute;&quot; sera r&eacute;initialis&eacute;e avec les nouvelles valeurs.</p>
<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM `" .TBRPBM. "` WHERE `rpbm_codeint`= '".$ci."' ORDER BY `rpbm_datecrea` LIMIT ".($page-1).",1";
	$rs = mysql_query($rech)or die(mysql_error());
	if ($row = mysql_fetch_array($rs))
	{
		extract ($row);
	}
	mysql_free_result($rs);
	mysql_close($conn);

	$daterpbmf = formatedate($rpbm_datecrea);
?>
<form name="rpbmtt_maj" method="post" action="rpbmtt_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,'',''));">
	<input name="ci" type="hidden" id="ci" value="<?PHP echo $ci; ?>">
	<input name="page" type="hidden" id="page" value="<?PHP echo $page; ?>">
	<input name="last" type="hidden" id="last" value="<?PHP echo $last; ?>">
	<input name="urlcour" type="hidden" id="urlcour" value="<?PHP echo $racine_web.$_SERVER['REQUEST_URI']; ?>">
	<input name="nrpbm" type="hidden" id="nrpbm" value="<?PHP echo $rpbm_id; ?>">
  <table width="890"  border="0" align="center">
	<tr>
	  <td width="33%">
	  <?PHP
			echo ($page)." / ".$last;
	  ?>
	  </td>
	  <?PHP
			$url_deb = $_SERVER["PHP_SELF"]."?ci=".@$_GET["ci"]."&page=1&last=".$last;
			if (($page-1) <=0)
				$npp = $last;
			else
				$npp = $page-1;
			$url_prec = $_SERVER["PHP_SELF"]."?ci=".@$_GET["ci"]."&page=".$npp."&last=".$last;
			if (($page+1) > $last)
				$nps = 1;
			else
				$nps = $page+1;
			$url_suiv = $_SERVER["PHP_SELF"]."?ci=".@$_GET["ci"]."&page=".$nps."&last=".$last;
			$url_fin = $_SERVER["PHP_SELF"]."?ci=".@$_GET["ci"]."&page=".$last."&last=".$last;
	  ?>
	  <td width="33%"><div align="center"><span class="annot_std_it">(<img src="../img/oblig.gif" width="10" height="11" alt="Champ obligatoire"> : Saisie obligatoire) </span></div></td>
	  <td width="33%">
		<div align="right">
		  <a href="<?PHP echo $url_deb; ?>"><img src="../img/deb.gif" width="22" height="22" border="0"></a> 
		  <a href="<?PHP echo $url_prec; ?>"><img src="../img/prec.png" width="22" height="22" border="0"></a>
		  <a href="<?PHP echo $url_suiv; ?>"><img src="../img/suiv.png" width="22" height="22" border="0"></a>
		  <a href="<?PHP echo $url_fin; ?>"><img src="../img/fin.gif" width="22" height="22" border="0"></a>
		</div>
	  </td>
	</tr>
  </table>
  <table width="890"  border="0">
	<tr>
	  <td width="20%" class="rubfrm" id="f_numpbm"><div align="right">Probl&egrave;me N&deg; </div></td>
	  <td>
		<input name="numpbm" type="text" id="numpbm" value="<?PHP echo sprintf("%'010s",$rpbm_id) ?>" size="15" maxlength="10" readonly="1">
	  </td>
	</tr>
	<tr>
	  <td width="20%" class="rubfrm" id="f_signale"><div align="right">Ajout&eacute; le  </div></td>
	  <td>
		<input name="date" type="text" id="date" value="<?PHP echo $daterpbmf ?>" size="10" maxlength="10" readonly="1">
	  </td>
	</tr>
	<tr>
	  <td width="20%" class="rubfrm" id="f_signale"><div align="right">Signal&eacute; par </div></td>
	  <td>
		<input name="signale" type="text" id="signale" value="<?PHP echo htmlspecialchars($rpbm_signale) ?>" size="50" readonly="1">
	  </td>
	</tr>
	<tr>
	  <td width="20%" class="rubfrm" id="f_func"><div align="right">Code Relev&eacute; </div></td>
	  <td>
		<input name="coderel" type="text" id="coderel" value="<?PHP echo $rpbm_coderlp ?>" size="20" maxlength="20" readonly="1">
		<?PHP
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			if ($rpbm_typrel == 1) // C'est une licence
				$rech = "SELECT * FROM `" .TBRLIC. "` WHERE `rlic_code`= '".$rpbm_coderlp."'";
			else // C'est du matériel
				$rech = "SELECT * FROM `" .TBRPDT. "` WHERE `rpdt_code`= '".$rpbm_coderlp."'";
			$rs = mysql_query($rech);
			if ($row = mysql_fetch_array($rs))
			{
				extract ($row);
			}
			mysql_free_result($rs);
			mysql_close($conn);
		?>
		<br>
		<span class="annot_petit_it">
		<?PHP
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			if ($rpbm_typrel == 1) // C'est une licence
			{
				$rech2 = "SELECT * FROM ".TBMQUE." WHERE `mque_code` = '".$rlic_codema."'";
				$rs2 = mysql_query($rech2);
				if ($row2 = mysql_fetch_array($rs2))
				{
					extract ($row2);
				}
				$txtreleve = htmlspecialchars($mque_ste)." ".htmlspecialchars($rlic_modele)." ".htmlspecialchars($rlic_version);
			}
			else // C'est du matériel
			{
				$rech2 = "SELECT * FROM ".TBRPCAT." WHERE `rpcat_code` = '".$rpdt_codecat."'";
				$rs2 = mysql_query($rech2);
				if ($row2 = mysql_fetch_array($rs2))
				{
					extract ($row2);
				}
				$rech2 = "SELECT * FROM ".TBMQUE." WHERE `mque_code` = '".$rpdt_codema."'";
				$rs2 = mysql_query($rech2);
				if ($row2 = mysql_fetch_array($rs2))
				{
					extract ($row2);
				}
				$txtreleve = htmlspecialchars($rpcat_desc)." / ".htmlspecialchars($mque_ste)." ".htmlspecialchars($rpdt_modele)." (".htmlspecialchars($rpdt_codep).")";
			}
			mysql_free_result($rs2);
			mysql_close($conn);
			echo $txtreleve;
		?>
		</span>
	  </td>
	</tr>
	<tr>
	  <td width="20%" class="rubfrm" id="f_pbm"><div align="right">Probl&egrave;me not&eacute; </div></td>
	  <td><textarea name="pbm" cols="100" rows="5" id="pbm" readonly><?PHP echo htmlspecialchars($rpbm_pbm) ?></textarea></td>
	</tr>
	<tr>
	  <td width="20%" class="rubfrm" id="f_fait"><div align="right">Travail effectu&eacute; </div></td>
	  <td>
		<textarea name="fait" cols="100" rows="5" id="fait"><?PHP echo htmlspecialchars($rpbm_fait) ?></textarea>
		<img src="../img/oblig.gif" width="10" height="11" alt="Champ obligatoire">
	  </td>
	</tr>
  </table>
  <p align="center">
	<input name="RAZ" type="reset" class="bton_fmarr_std" id="RAZ" value="R&eacute;initialiser">
	<input name="enr" type="submit" class="bton_fmarr_std" id="enr" value="Valider">
	<input name="fin" type="submit" class="bton_fmarr_std" id="fin" value="Quitter">
  </p>
</form>
<?PHP
}
else
{
?>
	<script type="text/javascript">
	self.close('fscomp');
	</script>
<?PHP
}
?>
</body>
</html>
