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

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

include ("../inc/config.inc.php");
?>
<?php require ("../inc/func.inc.php") ?>
<?php require ("../inc/func_log.inc.php") ?>
<?php include ("../inc/func_txt.inc.php") ?>
<?php require ("../inc/fic.inc.php") ?>
<?PHP include("../inc/geoip.inc"); ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$coderech = strip_tags(trim($_GET['ct']));
	$tec_dep = strip_tags(trim($_GET['dep']));
	$tec_ndep = strip_tags(trim($_GET['ndep']));
	$tec_npays = pays_connect($_SERVER['REMOTE_ADDR']);
	
	if ($coderech <> "")
	{
		// Récupération des informations technicien
		$row = lit_enr_tec($coderech);
		extract ($row);


		$titre = "DEMENAGEMENT DE TECHNICIEN";
	}
?>

<!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 : D&eacute;m&eacute;nagement Technicien</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 -->
<link href="../inc/menu.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour affichages -->
<script language="JavaScript" src="../inc/aff.js"></script>

<!-- Affichage nouvelle fenêtre pour impression -->
<script type="text/javascript">
	function lanceimp(page)
	{
	  window.open(page,'impression','width='+screen.width+' height='+screen.height);
	}
</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:ndep ; format:liste ; req:Y ; txt:Département ; vmn:1 ; stok:frmok ; stbad:frmbad");
var tab2_champ=new Array(
	"nom:nadr1 ; format:txt ; req:Y ; txt:Nouvelle adresse(1); lmx:50; stok:frmok ; stbad:frmbad",
	"nom:nadr2 ; format:txt ; req:N ; txt:Nouvelle adresse(2); lmx:50; stok:frmok ; stbad:frmbad",
	"nom:nville ; format:liste ; req:Y ; txt:Nouvelle ville; vmn:1; stok:frmok ; stbad:frmbad",
	"nom:npays ; format:liste ; req:Y ; txt:Nouveau pays; vmn:1; stok:frmok ; stbad:frmbad",
	"nom:ntelf ; format:tel_fr ; req:Y ; txt:Nouveau téléphone Fixe; stok:frmok ; stbad:frmbad",
	"nom:nfax ; format:tel_fr ; req:N ; txt:Nouveau télécopieur; stok:frmok ; stbad:frmbad",
	"nom:ntelp ; format:telp_fr ; req:N ; txt:Nouveau téléphone portable; stok:frmok ; stbad:frmbad");
</script>
  
</head>

<body>

<?php 
	include_once ("entete.php"); 
?>

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>

<!-- Formulaire de demande du numéro de département (uniquement si n'existe pas) -->
<?PHP if ($tec_ndep == "") { ?>
<form name="dde_dep" id="dde_dep" method="GET" action="tecdem_maj.php" onSubmit="javascript:; return (VForm(this,tab1_champ,''));">
<p>
	  <input name="ct" type="hidden" id="ct" value="<?PHP echo $coderech ?>">
	  <input name="dep" type="hidden" id="dep" value="<?PHP echo $tec_dep ?>">
</p>
	<p align="center">Merci de choisir le d&eacute;partement o&ugrave; ce technicien a d&eacute;m&eacute;nag&eacute;.</p>
	<table width="100%"  border="0">
<tr>
	<td width="20%" class="rubfrm" id="f_ndep"><div align="right">D&eacute;partement</div></td>
	<td>
		<select name="ndep" size="1" id="ndep">
		<?PHP
		
		// Création de la liste des départements
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rs = mysql_query("SELECT * FROM ".TBDEP." ORDER BY dep_num");
		
		$i=0;
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);

			if ($i == 0)
			{
				echo "<option value=\"\" selected>-- Choisissez un département --</option>";
			}
			$chaine_dep = $dep_num." (".$dep_nom.")";
			echo "<option value=\"".$dep_num."\">".$chaine_dep."</option>";
			
			$i++;
		}

		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
          <img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
</table>
<p align="center">
    <input name="RAZ" type="button" id="RAZ" value="Annuler" onclick="self.location.href='tec_lst.php'">
	<input type="submit" name="Submit" value="Valider">
</p>
</form>

<?PHP } ?>
<!-- Fin de formulaire de demande du numéro de département (uniquement si n'existe pas) -->

<!-- Affichage uniquement si numéro de département saisi -->
<?PHP 
if (($tec_ndep <> "") AND ($tec_dep <> ""))
{ 
?>
<table width="100%"  border="0">
  <tr>
    <td width="33%">
		<strong><a href="tec_lst.php">Retour &agrave; la liste</a> </strong>
	</td>
    <td width="33%" bgcolor="#FF0000"><div align="center"><span class="titrerubrique1">Coordonn&eacute;es</span></div></td>
    <td width="33%">&nbsp;</td>
  </tr>
</table>
<table width="100%"  border="0">
<tr>
	<td width="31%">&nbsp;
	
	</td>
	<td width="39%" valign="top">
		<div align="center">
		<span class="annot_gras_it">
		(<img src="../img/oblig.gif" width="10" height="11"> : Saisie obligatoire)
		</span>
		</div>
	</td>
	<td width="30%">&nbsp;
	
	</td>
</tr>
</table>


<form name="tec_dem" method="post" action="tecdem_enr.php" onSubmit="javascript:; return (VForm(this,tab2_champ,''));">
	<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
	<input name="ndep" type="hidden" id="ndep" value="<?PHP echo $tec_ndep ?>">

<table width="800"  border="0">
<tr>
	<td width="20%" class="rubfrm" id="f_codecli"><div align="right">Code Technicien </div></td>
	<td width="84%">
		<input name="code" type="text" id="code" value="<?PHP echo $tec_code ?>" readonly="1">
	</td>
</tr>
</table>

<table width="800"  border="0">
<tr>
	<td width="20%" class="rubfrm" id="f_civil"><div align="right">Civilit&eacute;</div></td>
	<td width="84%">
		<?PHP
		
		// Récupération du libellé civilité
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM `".TBCIV."` WHERE `civ_code` = '".$tec_civilite."'";
		$rs = mysql_query($rech) or die(mysql_error());
		if ($resultat = mysql_fetch_array($rs))
		{
			extract($resultat);
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		<input name="civil" type="text" id="civil" value="<?PHP echo $civ_desc ?>" size="50" readonly="1">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_prenom"><div align="right">Pr&eacute;nom</div></td>
	<td>
		<input name="prenom" type="text" id="prenom" value="<?PHP echo $tec_prenom ?>" size="50" readonly="1">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_nom"><div align="right">Nom</div></td>
	<td>
		<input name="nom" type="text" id="nom" value="<?PHP echo $tec_nom ?>" size="50" readonly="1">
	</td>
</tr>
</table>

<table width="800"  border="0">
<tr>
	<td class="rubfrm"><div align="center">Anciennes Coordonn&eacute;es</div></td>
</tr>
</table>

<table width="800"  border="0">
<tr>
	<td width="20%" class="rubfrm" id="f_adr1"><div align="right">Adresse(1)</div></td>
	<td>
		<input name="adr1" type="text" id="adr1" value="<?PHP echo $tec_adr1 ?>" size="50" readonly="1">
	</td>
</tr>
<tr>
	<td width="16%" class="rubfrm" id="f_adr2"><div align="right">Adresse(2)</div></td>
	<td>
		<input name="adr2" type="text" id="adr2" value="<?PHP echo $tec_adr2 ?>" size="50" readonly="1">
	</td>
</tr>
<tr>
	<td width="16%" class="rubfrm" id="f_dep"><div align="right">D&eacute;partement</div></td>
	<td>
		<input name="dep" type="text" id="dep" value="<?PHP echo $tec_dep ?>" size="3" readonly="1">
	</td>
</tr>
<tr>
	<td width="16%" class="rubfrm" id="f_ville"><div align="right">Ville</div></td>
	<td>
		<input name="ville" type="text" id="ville" value="<?PHP echo Retourneville($tec_ville)." (".Retournecp($tec_ville).")"; ?>" size="50" readonly="1">
	</td>
</tr>
<tr>
	<td width="16%" class="rubfrm" id="f_pays"><div align="right">Pays</div></td>
	<td>
		<input name="pays" type="text" id="pays" value="<?PHP echo $tec_pays; ?>" size="50" readonly="1">
	</td>
</tr>
<tr>
	<td width="16%" class="rubfrm" id="f_telf"><div align="right">T&eacute;l&eacute;phone Fixe </div></td>
	<td>
		<input name="telf" type="text" id="telf" value="<?PHP echo $tec_telf ?>" size="20" readonly="1">
	</td>
</tr>
<tr>
	<td width="16%" class="rubfrm" id="f_fax"><div align="right">T&eacute;l&eacute;copieur</div></td>
	<td>
		<input name="fax" type="text" id="fax" value="<?PHP echo $tec_fax ?>" size="20"readonly="1">
	</td>
</tr>
<tr>
	<td width="16%" class="rubfrm" id="f_telp"><div align="right">Portable</div></td>
	<td>
		<input name="telp" type="text" id="telp" value="<?PHP echo $tec_telp ?>" size="20"readonly="1">
	</td>
</tr>
</table>

<br>
<table width="800"  border="0">
<tr>
	<td class="rubfrm"><div align="center">Nouvelles Coordonn&eacute;es</div></td>
</tr>
</table>

<table width="800"  border="0">
<tr>
	<td width="20%" class="rubfrm" id="f_nadr1"><div align="right">Adresse(1)</div></td>
	<td>
		<input name="nadr1" type="text" id="nadr1" size="50" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_nadr2"><div align="right">Adresse(2)</div></td>
	<td>
		<input name="nadr2" type="text" id="nadr2" value="" size="50" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_ndep"><div align="right">D&eacute;partement</div></td>
	<td>
		<input name="ndep" type="text" id="ndep" value="<?PHP echo $tec_ndep ?>" size="3" maxlength="3" readonly="1">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_nville"><div align="right">Ville</div></td>
	<td>
		<select name="nville" size="1" id="nville">
		<?PHP
		
		// Création de la liste des villes
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$filtre = $tec_ndep;
		if (($filtre == "2A") OR ($filtre == "2B"))
			$filtre = "20";
		$rs = mysql_query("SELECT * FROM ".TBVILLES." WHERE `villes_cp` LIKE '".$filtre."%' ORDER BY villes_nom");
		
		echo "<option value=\"\" selected>-- Choisissez une ville --</option>";
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);

			echo '<option value="'.$villes_insee.'">'.str_majuscules($villes_nom).' ('.$villes_cp.')</option>';
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_npays"><div align="right">Pays</div></td>
	<td>
		<select name="npays" size="1" id="npays">
	<?PHP
		
		// Création de la liste des pays
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rs = mysql_query("SELECT * FROM ".TBPAYS." ORDER BY pays_nom");
		
		echo "<option value=\"\" selected>-- Choisissez un pays --</option>";

		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);

			if ($tec_npays == $pays_nom)
			{
				echo '<option value="'.$pays_nom.'" selected>'.$pays_nom.'</option>';
			}
			else
			{
				echo '<option value="'.$pays_nom.'">'.$pays_nom.'</option>';
			}
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_ntelf"><div align="right">T&eacute;l&eacute;phone Fixe </div></td>
	<td>
		<input name="ntelf" type="text" id="ntelf" value="" size="20" maxlength="20">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_nfax"><div align="right">T&eacute;l&eacute;copieur</div></td>
	<td>
		<input name="nfax" type="text" id="nfax" value="" size="20" maxlength="20">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_ntelp"><div align="right">Portable</div></td>
	<td>
		<input name="ntelp" type="text" id="ntelp" value="" size="20" maxlength="20">
	</td>
</tr>
</table>

<p align="center">
    <input name="RAZ" type="button" id="RAZ" value="Annuler" onclick="self.location.href='tec_lst.php'">
	<input name="submit" type="submit" id="submit" value="Enregistrer">
</p>
</form>

<?PHP 
}?>
<!-- Fin affichage uniquement si numéro de département saisi -->
