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


// 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");

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.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");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_rel.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim($_GET['td'])); // Récupération type demande
$tr = intval(strip_tags(trim($_GET['tr']))); // Récupération type Relevé (1 = Licence, 2 = Matériel)
$cr = strip_tags(trim($_GET['cr'])); // Récupération code Relevé
$id = intval(strip_tags(trim($_GET['id']))); // Récupération code ID
$cap = intval(strip_tags(trim($_GET['cap']))); // Code Appelant (0 = Dossier Relevé, 1 = Fiche Relevé)

$pbm_rpbm=FALSE;

if (($cap<>0) AND ($cap<>1))
	$pbm_rpbm=TRUE;
else
{
	if ($cr <> "")
	{
		switch ($tr)
		{
			case 1 :
				// Récupération des informations relevé licence
				$row = lit_enr_rlic($cr);
				if (is_array($row))
				{
					extract ($row);
					
					$datecfich = formatedate($rlic_daterel);
					$coderel = $rlic_coderel;
					$code = $rlic_code;
					$codecli = $rlic_codecli;
					$idsite = $rlic_idsite;
			
					// Récupération de la marque marque et du type de licence
					$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
					mysql_select_db(DBNAME);
					$rech = "SELECT * FROM ".TBMQUE." WHERE `mque_code` = '".$rlic_codema."'";
					$rs = mysql_query($rech)or die(mysql_error());
					if ($row = mysql_fetch_array($rs))
						extract ($row);
					$rech = "SELECT * FROM ".TBRLTL." WHERE `rltl_code` = '".$rlic_codetl."'";
					$rs = mysql_query($rech)or die(mysql_error());
					if ($row = mysql_fetch_array($rs))
						extract ($row);
					mysql_free_result($rs);
					mysql_close($conn);
			
					$descr = "<b>".htmlspecialchars($mque_ste)."</b> : ".htmlspecialchars($rlic_modele)." ver.".htmlspecialchars($rlic_version)." <span class=\"annot_std_it\">(type : ".htmlspecialchars($rltl_desc).")</span>";
				}
				else
					$pbm_rpbm=TRUE;
				break;
				
			case 2 :
				// Récupération des informations relevé produit
				$row = lit_enr_rpdt($cr);
				if (is_array($row))
				{
					extract ($row);
			
					$datecfich = formatedate($rpdt_daterel);
					$coderel = $rpdt_coderel;
					$code = $rpdt_code;
					$codecli = $rpdt_codecli;
					$idsite = $rpdt_idsite;
			
					// Récupération de la catégorie et de la marque
					$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
					mysql_select_db(DBNAME);
					$rech = "SELECT * FROM ".TBRPCAT." WHERE `rpcat_code` = '".$rpdt_codecat."'";
					$rs = mysql_query($rech)or die(mysql_error());
					if ($row = mysql_fetch_array($rs))
						extract ($row);
					$rech = "SELECT * FROM ".TBMQUE." WHERE `mque_code` = '".$rpdt_codema."'";
					$rs = mysql_query($rech)or die(mysql_error());
					if ($row = mysql_fetch_array($rs))
						extract ($row);
					mysql_free_result($rs);
					mysql_close($conn);
			
					$descr = "<b>".htmlspecialchars($rpcat_desc)."</b> : ".htmlspecialchars($mque_ste)." / ".htmlspecialchars($rpdt_modele)." <span class=\"annot_std_it\">(ns : ".htmlspecialchars($rpdt_ns).")<br>code : ".htmlspecialchars($rpdt_codep)." / lieu : ".htmlspecialchars($rpdt_empl)."</span>";
				}
				else
					$pbm_rpbm=TRUE;
				break;
				
			default :
				$pbm_rpbm=TRUE;
				break;
		}
	
		if ($pbm_rpbm==FALSE)
		{
			$row = lit_enr_rel($coderel);
			if (is_array($row))
			{
				extract ($row);
				$datedrel = formatedate($rel_datecrea);

				// Vérification des tentatives de hack
				switch (@$_SESSION["niv_log"])
				{
					// Contrôle qu'un client n'essaye pas de "hacker" un relevé
					case 1 :
						$tab_cli=give_tab_rcli($_SESSION["code_log"],TRUE);
						if (in_array($rel_codecli,$tab_cli)==FALSE)
							$pbm_rpbm=TRUE;
						break;
				// Contrôle qu'une agence n'essaye pas de "hacker" un relevé
					case 3 :
					case 4 :
						if ($rel_codeage <> @$_SESSION["code_age"])
							$pbm_rpbm = TRUE;
						break;
				}
			}
			else
				$pbm_rpbm=TRUE;
		
			if ($pbm_rpbm==FALSE)
			{
				$row = lit_enr_cli($codecli,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$rpbm_codecli = $codecli;
					
					// Vérification des tentatives de hack
					switch (@$_SESSION["niv_log"])
					{
						// Contrôle qu'un client n'essaye pas de "hacker" un relevé
						case 1 :
							$tab_cli=give_tab_rcli($_SESSION["code_log"],TRUE);
							if (in_array($rpbm_codecli,$tab_cli)==FALSE)
								$pbm_rpbm=TRUE;
							break;
					// Contrôle qu'une agence n'essaye pas de "hacker" un relevé
						case 3 :
						case 4 :
							if ($cli_prop <> @$_SESSION["code_age"])
								$pbm_rpbm = TRUE;
							break;
					}
				}
				else
					$pbm_rpbm=TRUE;
	
				if ($pbm_rpbm==FALSE)
				{
					if ($id>0)
					{
						$row = lit_enr_rpbm($id);
						if (is_array($row))
						{
							extract ($row);
							if ($rpbm_codeint <> "")
								$td="view";
								
							if ($rpbm_codecli<>$codecli)
								$pbm_rpbm=TRUE;
					
							if ($rpbm_code<>$cr)
								$pbm_rpbm=TRUE;
						}
						else
							$pbm_rpbm=FALSE;
							
						$datecreaf = formatedate($rpbm_datecrea);
						$datettf = formatedate($rpbm_datett);
					}
					else
						if ($td<>"add")
							$pbm_rpbm=TRUE;
				}
			}
		}
	}
	else
		$pbm_rpbm=TRUE;
}
	
switch ($td)
{
	case "view" :
		$titre = "VOIR DECLARATION DE PROBLEME";
		break;
	case "edit" :
		$titre = "MISE A JOUR DECLARATION DE PROBLEME";
		break;
	case "del" :
		$titre = "SUPPRESSION DECLARATION DE PROBLEME";
		break;
	case "add" :
		$rpbm_idsite=-2;
		$titre = "DECLARATION DE PROBLEME";
		break;
	default :
		$pbm_rpbm=TRUE;
		break;
}
?>
<!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; ?> : D&eacute;claration de Probl&egrave;me</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 vérifications -->
<script language="JavaScript" src="../jscript/verif_field.js"></script>

<!-- Définition Javascript pour calendrier popup -->

  <!-- Feuille de Style -->
  <link rel="stylesheet" type="text/css" media="all" href="../jscript/jscal/skins/aqua/theme.css" title="Aqua" />

  <!-- Script Javascript Principal -->
  <script type="text/javascript" src="../jscript/jscal/calendar.js"></script>

  <!-- Choix du langage -->
  <script type="text/javascript" src="../jscript/jscal/lang/calendar-<?PHP echo $_SESSION["lng"]; ?>.js"></script>

  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="../jscript/jscal/calendar-setup.js"></script>

<!-- Fin de la définition Javascript pour calendrier popup -->

<!-- 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(
<?PHP
if (($idsite==-1) and (td<>"view") and ($td<>"del"))
{
?>
	"nom:site ; format:liste ; req:Y ; txt:Site où le problème a été détecté ; vmn:1; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:site ; format:txt ; req:Y ; txt:Site où le problème a été détecté ; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
	"nom:pbm ; format:txt ; req:Y ; txt:Problème détaillé ; stok:frmok ; stbad:frmbad",
	"nom:datecreaf ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Détecté le ; stok:frmok ; stbad:frmbad",
	"nom:signale; format:txt ; req:Y ; txt:Signalé par ; lmx:50 ; stok:frmok ; stbad:frmbad");
//-->
</script>

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

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

</head>

<?PHP if ($td == "del"){ ?>
<body onload="warndel();metReadonly();">
<?PHP } else { ?>
<body onLoad="metFocus();">
<?PHP } include_once("../inc/entete.inc.php"); ?>
<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<table width="100%"  border="0">
<tr>
	<td width="33%">
	<span class="annot_gras_it">
	<?PHP
	if (@$_SESSION["niv_log"] <> 1)
	{
	?>
		<a href="rel_maj.php?td=edit&cr=<?PHP echo $coderel; ?>">Retour au dossier de relev&eacute;</a></span> <span class="annot_petit_it">ou</span> 
	<?PHP
	}
	else
	{
	?>
		<a href="rel_maj.php?td=view&cr=<?PHP echo $coderel; ?>">Retour au dossier de relev&eacute;</a></span> <span class="annot_petit_it">ou</span> 
	<?PHP 
	}
	if ($tr == 1)
	{
	?>
		<span class="annot_gras_it"><a href="rlic_maj.php?td=<?PHP if (@$_SESSION["niv_log"] <> 1) echo 'edit'; else echo 'view'; ?>&crl=<?PHP echo $code; ?>">&agrave; la fiche licence</a></span>
	<?PHP 
	} 
	else
	{ 
	?>
		<span class="annot_gras_it"><a href="rpdt_maj.php?td=<?PHP if (@$_SESSION["niv_log"] <> 1) echo 'edit'; else echo 'view'; ?>&crp=<?PHP echo $code; ?>">&agrave; la fiche mat&eacute;riel</a></span>
	<?PHP
	} 
	?>
    </td>
	<td width="33%" valign="top" id="oblig" align="center" class="annot_gras_it">(<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> : <?PHP echo $txt_div_saisoblg; ?>)</td>
	<td width="33%">&nbsp;</td>
</tr>
</table>
<br>
<form name="rpbm_maj" method="post" action="rpbm_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,'','<?PHP echo $_SESSION["lng"]; ?>'));">
<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
<input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
<input name="typrel" type="hidden" id="typrel" value="<?PHP echo $tr ?>">
<input name="coderel" type="hidden" id="coderel" value="<?PHP echo $coderel ?>">
<input name="id" type="hidden" id="id" value="<?PHP echo $id ?>">
<input name="code" type="hidden" id="code" value="<?PHP echo $code ?>">
<input name="codecli" type="hidden" id="codecli" value="<?PHP echo $rpbm_codecli ?>">
<input name="cap" type="hidden" id="cap" value="<?PHP echo $cap ?>">

<!-- Code du relevé client (affiché uniquement si édition ou suppression) -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_coderlic" align="right">Code fiche relev&eacute; </td>
	<td>
		<span class="annot_std_gras"><?PHP echo $code; ?></span>
		<span class="annot_petit_it">(Fiche de relev&eacute; cr&eacute;&eacute;e le <?PHP echo $datecfich ?>)</span>
	</td>
</tr>
</table>

<!-- N° Dossier & Date de création -->
<table width="100%"  border="0">
<tr>
	<td class="annot_petit_it">
		Appartient au dossier de relev&eacute; <?PHP echo $coderel; ?>, cr&eacute;&eacute; le <?PHP echo $datedrel; ?>
	</td>
</tr>
</table>

<!-- Affichage du client -->
<table width="100%" border="0">
<tr>
	<td class="rubfrm" id="f_codecli" align="center">Client
	<?PHP
	if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
		echo " <img src=\"../img/".$ico_cpta[$cli_cpta]."\" title =\"".$mess_cpta[$cli_cpta]."\" border=\"0\" align=\"absmiddle\">";
	?>
	</td>
</tr>
</table>

<!-- Détails client -->
<table width="100%"  border="0">
<tr>
	<td valign="top" bgcolor="#C5CED7">
	<?PHP
	echo "<span class=\"annot_std_gras\">";
	if ($cli_ste <>"") 
		echo $cli_ste."<br>";
	else
		echo $cli_civilite." ".$cli_prenom." ".$cli_nom."<br>";
	echo "</span>";
	echo $cli_adr1."<br />";
	if ($cli_adr2 <>"") 
		echo $cli_adr2."<br />";
	echo Retournecp_openId($cli_ville,TRUE)." ".Retourneville_openId($cli_ville,TRUE)."<br />";
	$chemin_imagesco = $chemin_images."/telc.png"; 
	echo "<img src=\"".$chemin_imagesco."\" align=\"bottom\">";
	echo " ".$cli_telf."<br>";
	?>
	</td>
	<td width="60" valign="top">
	<?PHP 
	if (@$_SESSION["niv_log"] >= 3)
	{
	  $url_affnotesc = "aff_notesc.php?cc=".$codecli;
	?>
	  <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_affnotesc; ?>',930,380,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/eye.png" border="0" align="absmiddle"></a>
	  <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_affnotesc; ?>',930,380,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")> Notes</a>
	<?PHP
	}
	else
		echo "&nbsp;";
	?>
	</td>
	</tr>
</table>

<!-- Site de déclaration du problème -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_site" align="right">Site</td>
	<td>
	<?PHP
		// On doit choisir un site précis si la fiche est notée "affectée à tous les sites"
		if (($idsite == -1) and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{
	?>
			<select name="site" id="site">
			<option selected>-- Choisissez le site touché par ce problème --</option>
			<?PHP 
			if ($td =="add") // On ne peut déclarer "Tous les sites" que lors de la 1ère déclaration du problème
			{
			?>
			<option value="-1">Tous les sites</option>
			<?PHP
			}
			?>
			<option value="0" <?PHP if ($rpbm_idsite==0) echo "selected=\"selected\""; ?>>Site principal</option>
			<?PHP
			// Création de la liste des sites actifs
			
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM ".TBSCLI." WHERE `scli_actif` = '1' AND `scli_codecli` = '".$codecli."' ORDER BY scli_ste";
			$rs = mysql_query($rech) or die(mysql_error());
		
			if (mysql_num_rows($rs) <> 0)
			{
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
		
					if ($scli_adr2<>"")
						$nom_site = $scli_ste." (".$scli_adr1.", ".$scli_adr2.", ".Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE).")";
					else
						$nom_site = $scli_ste." (".$scli_adr1.", ".Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE).")";
					if ($rpbm_idsite == $scli_id)
						echo '<option value="'.$scli_id.'" selected>'.$nom_site.'</option>';
					else
						echo '<option value="'.$scli_id.'">'.$nom_site.'</option>';
				}
			}
			mysql_free_result($rs);
			?>
			</select>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
		}
		else
		{
	?>
			<input name="site" type="hidden" id="site" value="<?PHP echo $idsite; ?>">
		<?PHP
			if ($td=="add")
				$site=idsite;
			else
				$site=$rpbm_idsite;
			switch ($site)
			{
			case 0 :
			?>
					<input name="nsite" type="text" id="nsite" value="Site principal" readonly="1">
			<?PHP
				break;
			default :
					$nom_site="";
					$row=lit_enr_scli_id($site,TRUE);
					if (is_array($row))
					{
						extract($row);
						if ($scli_adr2<>"")
							$nom_site = $scli_ste." (".$scli_adr1.", ".$scli_adr2.", ".Retournecp_openId($scli_ville,TRUE)." ".Retourneville_openId($scli_ville,TRUE).")";
						else
							$nom_site = $scli_ste." (".$scli_adr1.", ".Retournecp_openId($scli_ville,TRUE)." ".Retourneville_openId($scli_ville,TRUE).")";
					}
			?>
					<input name="nsite" type="text" id="nsite" value="<?PHP echo $nom_site; ?>" size="100" readonly="1">
			<?PHP
				break;
			}
		}
	?>
	</td>
</tr>
</table>

<!-- Descriptif rapide de la licence ou du produit concerné -->
<table width="100%"  border="0">
<tr>
	<td class="rubfrm" colspan="2"  id="f_codecli" align="center">
		<?PHP if ($tr == 1) { ?>
			Licence Concern&eacute;e
		<?PHP }
			if ($tr == 2) { ?>
			Mat&eacute;riel Concern&eacute;
		<?PHP } ?>
	</td>
	</tr>
</table>

<table width="100%"  border="0">
<tr>
    <td width="160" valign="top" class="rubfrm" align="right">
		<?PHP if ($tr == 1) { ?>
			Licence
		<?PHP }
			if ($tr == 2) { ?>
			Mat&eacute;riel (ns)<br>
			Code - empl.
		<?PHP } ?>
	</td>
	<td>
		<?PHP echo $descr ?>
	</td>
</tr>
</table>

<!-- Délai du problème rencontré -->
<table width="100%"  border="0">
<tr>
	<td class="rubfrm" colspan="2" align="center">
		D&eacute;tail du probl&egrave;me rencontr&eacute;
	</td>
	</tr>
</table>

<!-- Descriptif du problème -->
<table width="100%"  border="0">
  <tr>
    <td width="160" valign="top" class="rubfrm" id="f_pbm" align="right">Probl&egrave;me d&eacute;taill&eacute;</td>
    <td>
	<?PHP if ($td <> "view") { ?>
		<textarea name="pbm" rows="5" id="pbm"><?PHP echo htmlspecialchars($rpbm_pbm) ?></textarea>
	  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"><br>
	  <span class="annot_petit_it">D&eacute;tailler pr&eacute;cis&eacute;mment le probl&egrave;me pour qu'il soit plus facile &agrave; r&eacute;soudre.<br>
	  S'il s'agit d'une licence, indiquer sur quel mat&eacute;riel se produit le probl&egrave;me. </span>
	<?PHP } else { ?>
		<textarea name="pbm" rows="5" id="pbm" readonly><?PHP echo htmlspecialchars($rpbm_pbm) ?></textarea>
	<?PHP } ?>
	</td>
  </tr>
</table>

<!-- Date détection -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_datecreaf" align="right">D&eacute;tect&eacute; le </td>
	<td>
		<input name="datecreaf" type="text" id="datecreaf" value="<?PHP echo $datecreaf ?>" size="10" maxlength="10" readonly="1">
		<?PHP if ($td <> "view") { ?>
		<img src="../img/calendar.png" align="absmiddle" id="f_img_datecreaf" title="<?PHP echo $alt_chxdate; ?>">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<span class="annot_std_it">(
		<a href="javascript:;" onClick="document.rpbm_maj.datecreaf.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
		<a href="javascript:;" onclick="document.rpbm_maj.datecreaf.value=''")> Annuler</a> )</span>
		<?PHP } ?>
	</td>
</tr>
</table>

<!-- Qui a détecté le problème ?-->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_signale" align="right">
		D&eacute;t&eacute;ct&eacute; par
	</td>
    <td>
	<?PHP if ($td <> "view") { ?>
		<input name="signale" type="text" id="signale" value="<?PHP echo htmlspecialchars($rpbm_signale) ?>" size="50"> 
	  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"><br>
	  <span class="annot_petit_it">Entrer le pr&eacute;nom et le nom de personne ayant d&eacute;tect&eacute; le probl&egrave;me. </span>
	<?PHP } else { ?>
		<input name="signale" type="text" id="signale" value="<?PHP echo htmlspecialchars($rpbm_signale) ?>" size="50" readonly="1"> 
	<?PHP } ?>
	</td>
</tr>
</table>

<?PHP 
if ($td <> "add") 
{
?>
<!-- Détail du traitement -->
<table width="100%"  border="0">
<tr>
	<td class="rubfrm" colspan="2"  id="f_operation" align="center">
		Pour info : Op&eacute;ration en cours ou effectu&eacute;e
	</td>
	</tr>
</table>

	<?PHP
	if ($rpbm_codeint<>"")
	{
	?>
	<!-- N° Intervention-->
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_codeint" align="right">N&deg; Intervention </td>
		<td>
			<input name="codeint" type="text" id="codeint" value="<?PHP echo $rpbm_codeint ?>" size="20" maxlength="20" readonly="1">
		</td>
	</tr>
	<!-- Date traitement-->
	<tr>
		<td width="160" class="rubfrm" id="f_datettf" align="right">Trait&eacute; le </td>
		<td>
		<?PHP
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech2="SELECT * FROM ".TBINT." WHERE `int_code`='".$rpbm_codeint."'";
			$rs = mysql_query($rech2) or die(mysql_error());
			if (mysql_num_rows($rs)==1)
			{
				if ($row = mysql_fetch_assoc($rs)) 
				{
					if (formatedate($row["int_datefin"])<>"")
					{
						echo "<span class=\"annot_std_gras\">";
						echo "Termin&eacute;e";
						echo "</span>";
						echo " (close le ".formatedate($row["int_datefin"]).")";
					}
					else
					{
						if (formatedate($row["int_dateprev"])<>"")
						{
							echo "<span class=\"annot_std_gras\">";
							echo "Termin&eacute;e";
							echo "</span>";
							echo " (client appel&eacute; le ".formatedate($row["int_dateprev"]).")";
						}
						else
						{
							echo "<span class=\"annot_std_it\">";
							echo "En cours";
							echo "</span>";
							echo " (derni&egrave;re modif. : ".formatedate($row["int_datemod"]).")";
						}
					}
					mysql_close($conn);  
				}
				else
					echo "&nbsp;";
			}
			else
				echo "&nbsp;";
		?>
		</td>
	</tr>
	<!-- Travail effectué-->
	<tr>
		<td width="160" class="rubfrm" id="f_fait" align="right">Travail effectu&eacute; </td>
		<td>
			<textarea name="fait" rows="5" id="fait" readonly><?PHP echo htmlspecialchars($rpbm_fait) ?></textarea>
		</td>
	</tr>
	</table>
	
	</table>
	<?PHP
	}
	else
	{
	?>
		<table width="100%"  border="0">
		<tr>
			<td colspan="2"  id="f_codeint" align="center">
				<span class="annot_std_it">
					Aucune intervention effectu&eacute;e.
				</span>
			</td>
			</tr>
		</table>
	<?PHP
	} 
}
?>
<p align="center">
<?PHP 
if (($td == "edit") or ($td == "add")) // Boutons si en édition ou création
{ 
?>
	<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
	<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_enr; ?>">
<?PHP 
}
if ($td == "del") // Bouton si en mode suppression
{ 
?>
	<input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo $but_del; ?>">
<?PHP 
} 
?>
</p>
</form>
<?PHP
if ($td == "add")
{
?>
	<script type="text/javascript">
	<!--
		Calendar.setup({
			inputField     :    "datecreaf",     // id of the input field
			ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
			button         :    "f_img_datecreaf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			electric	   :	false,
			singleClick    :    true
		});
	//-->
	</script>
<?PHP
}
?>	
<script type="text/javascript">
<!--
warncpta(<?PHP echo $cli_cpta; ?>,"cont");
//-->
</script>
<?PHP
include_once("pied.php");
?>