<?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_time.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);

$codec = strip_tags(trim($_GET['cc'])); // Récupération code connecté

$code_ok=TRUE;

if ($codec <> "")
{
	// Récupération du niveau utilisateur
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM `" .TBPW. "` WHERE `pw_code` = '" .$codec. "'";
	$rs = mysql_query($rech) or die(mysql_error());
	if (mysql_num_rows($rs) == 1)
	{
		if ($row = mysql_fetch_array($rs))
		{
			extract ($row);
		}
	}
	else
		$code_ok = FALSE;
	mysql_close($conn);

	// Récupération des informations
	if ($code_ok==TRUE)
	{
		if ($pw_actif==0)
			$actif=$cnx_comptedes;
		else
			$actif=$cnx_compteact;
		$ste="";
		$ctact="";
		$txt_adr="";
		$tel="";
		$fax="";
		$email="";
		switch ($pw_level)
		{
			// Client
			case 1 :
				$row = lit_enr_cli($codec,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$titre=$titlein_det_log_cli;
					$type_u=$txt_div_cli;
					$ste=$cli_ste;
					$ctact=$cli_civilite." ".$cli_prenom." ".$cli_nom;
					$txt_adr=$cli_adr1."\n";
					if ($cli_adr2<>"")
						$txt_adr.=$cli_adr2."\n";
					$txt_adr.=Retournecp_openId($cli_ville,TRUE)." ".Retourneville_openId($cli_ville,TRUE);
					$tel=$cli_telf;
					$fax=$cli_fax;
					$email=$cli_email;
				}
				else
					$code_ok = FALSE;
				break;

			// Opérateur
			case 2 :
				$row = lit_enr_cli($codec,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$titre=$titlein_det_log_ope;
					$type_u=$txt_div_ope;
					$ctact=$ope_civilite." ".$ope_prenom." ".$ope_nom;
					$txt_adr=$ope_adr1."\n";
					if ($ope_adr2<>"")
						$txt_adr.=$ope_adr2."\n";
					$txt_adr.=Retournecp_openId($ope_ville,TRUE)." ".Retourneville_openId($ope_ville,TRUE);
					$tel=$ope_telf;
					$email=$cli_email;
				}
				else
					$code_ok = FALSE;
				break;
			
			// Technicien
			case 3 :
			case 7 :
			case 11 :
				$row = lit_enr_tec($codec,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$titre=$titlein_det_log_tec;
					$type_u=$txt_div_tec;
					$ctact=$tec_civilite." ".$tec_prenom." ".$tec_nom;
					$txt_adr=$tec_adr1."\n";
					if ($tec_adr2<>"")
						$txt_adr.=$tec_adr2."\n";
					$txt_adr.=Retournecp_openId($tec_ville,TRUE)." ".Retourneville_openId($tec_ville,TRUE);
					$tel=$tec_telf;
					$email=$tec_email;
				}
				else
					$code_ok = FALSE;
				break;
			
			// Agence
			case 4 :
				$row = lit_enr_age($codec,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$titre=$titlein_det_log_age;
					$type_u=$txt_div_age;
					$ste=$age_nom;
					$ctact=$age_resp_civilite." ".$age_resp_prenom." ".$age_resp_nom;
					$txt_adr=$age_adr1."\n";
					if ($age_adr2<>"")
						$txt_adr.=$age_adr2."\n";
					$txt_adr.=Retournecp_openId($age_ville,TRUE)." ".Retourneville_openId($age_ville,TRUE);
					$tel=$age_telf;
					$fax=$age_fax;
					$email=$age_email;
				}
				else
					$code_ok = FALSE;
				break;

			// Centre gestion
			case 5 :
				$row = lit_enr_age($codec,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$titre=$titlein_det_log_cge;
					$type_u=$txt_div_cge;
					$ste=$age_nom;
					$txt_adr=$age_adr1."\n";
					if ($age_adr2<>"")
						$txt_adr.=$age_adr2."\n";
					$txt_adr.=Retournecp_openId($age_ville,TRUE)." ".Retourneville_openId($age_ville,TRUE);
					$tel=$age_telf;
					$fax=$age_fax;
					$email=$age_email;
				}
				else
					$code_ok = FALSE;
				break;
			
			// Donneur d'ordres
			case 6 :
				$row = lit_enr_do($codec,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$titre=$titlein_det_log_do;
					$type_u=$txt_div_do;
					$ste=$do_nom;
					$txt_adr=$do_adr1."\n";
					if ($do_adr2<>"")
						$txt_adr.=$do_adr2."\n";
					$txt_adr.=Retournecp_openId($do_ville,TRUE)." ".Retourneville_openId($do_ville,TRUE);
					$tel=$do_telf;
					$fax=$do_fax;
					$email=$do_email;
				}
				else
					$code_ok = FALSE;
				break;
			
			// Administrateur
			case 9 :
				$titre=$titlein_det_log_admin;
				$type_u=$txt_div_admin;
				break;
			
			// Sous-traitant
			case 10 :
				$row = lit_enr_st($codec,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$titre=$titlein_det_log_st;
					$type_u=$txt_div_st;
					$ste=$st_nom;
					$txt_adr=$st_adr1."\n";
					if ($st_adr2<>"")
						$txt_adr.=$st_adr2."\n";
					$txt_adr.=Retournecp_openId($st_ville,TRUE)." ".Retourneville_openId($st_ville,TRUE);
					$tel=$st_telf;
					$fax=$st_fax;
					$email=$st_email;
				}
				else
					$code_ok = FALSE;
				break;
			
			default :
				$code_ok = FALSE;
				break;
		}
	}
	
}
else
	$code_ok = FALSE;
?>
<!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_detlog; ?></title>

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

<!-- Feuille de style pour les affichages du menu -->

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

</head>
<body>
<?PHP
if ($code_ok == TRUE)
{
?>
	
	<p align="center" class="titrepage"><?PHP echo $titre; ?></p>
	<p align="center" class="titre_gras">Code : <?PHP echo $codec; ?></p>
	<br>
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_typu" align="right"><?PHP echo $txt_chp_typutil; ?></td>
		<td>
			<input name="typu" type="text" id="typu" value="<?PHP echo $type_u ?>" size="50" readonly="1">
		</td>
	</tr>
	<tr>
		<td width="160" class="rubfrm" id="f_actif" align="right"><?PHP echo $txt_chp_actinact; ?></td>
		<td>
			<input name="actif" type="text" id="actif" value="<?PHP echo $actif ?>" size="50" readonly="1">
		</td>
	</tr>
	<?PHP if ($ste<>"") { ?>
	<tr>
		<td width="160" class="rubfrm" id="f_ste" align="right"><?PHP echo $txt_chp_ste; ?></td>
		<td>
			<input name="ste" type="text" id="ste" value="<?PHP echo $ste ?>" size="110" readonly="1">
		</td>
	</tr>
	<?PHP } ?>
	<?PHP if ($ctact<>"") { ?>
	<tr>
		<td width="160" class="rubfrm" id="f_ctact" align="right"><?PHP echo $txt_chp_ctactp; ?></td>
		<td>
			<input name="ctact" type="text" id="ctact" value="<?PHP echo $ctact ?>" size="110" readonly="1">
		</td>
	</tr>
	<?PHP } ?>
	<?PHP if ($txt_adr<>"") { ?>
	<tr>
		<td width="160" class="rubfrm" id="f_adr" align="right"><?PHP echo $txt_chp_adr; ?></td>
		<td>
			<textarea name="adr" id="adr" rows="3" readonly="readonly"><?PHP echo $txt_adr; ?></textarea>
		</td>
	</tr>		
	<?PHP } ?>
	<?PHP if ($tel<>"") { ?>
	<tr>
		<td width="160" class="rubfrm" id="f_tel" align="right"><?PHP echo $txt_chp_tel; ?></td>
		<td>
			<input name="tel" type="text" id="tel" value="<?PHP echo $tel ?>" size="25" readonly="1">
		</td>
	</tr>
	<?PHP } ?>
	<?PHP if ($fax<>"") { ?>
	<tr>
		<td width="160" class="rubfrm" id="f_fax" align="right"><?PHP echo $txt_chp_fax; ?></td>
		<td>
			<input name="fax" type="text" id="fax" value="<?PHP echo $fax ?>" size="25" readonly="1">
		</td>
	</tr>
	<?PHP } ?>
	<?PHP if ($email<>"") { ?>
	<tr>
		<td width="160" class="rubfrm" id="f_mail" align="right"><?PHP echo $txt_chp_email;?></td>
		<td>
			<input name="mail" type="text" id="mail" value="<?PHP echo $email ?>" size="50"readonly="1">
		</td>
	</tr>
	<?PHP } ?>
	</table>

	<!-- bouton de fermeture de la fenêtre -->
	<p align="center">
		<input name="ferm" type="button" class="bton_std" id="ferm" value="<?PHP echo $but_quit; ?>" onclick="javascript:; window.self.close('');">
	</p>
<?PHP
}
else
{
?>
	<script type="text/javascript">
	<!--
	window.self.close('');
	//-->
	</script>
<?PHP
}
?>

</body>
</html>
