<?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/func.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/lst.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
Archivelog(@$_SESSION["code_log"]);
$coderech = strip_tags(trim($_GET['cc']));
	
if (@$_SESSION["niv_log"] == 1)
	$coderech=@$_SESSION["code_log"];

$pbm_cli=FALSE;

if ($coderech <> "")
{
	// Vérification qu'il existe bien des contacts et nombre de ceux-ci
	$nbcontacts = nb_ccli_in_cli($coderech);

	// Récupération des informations clients

	// Récupération des informations clients
	$row = lit_enr_cli($coderech);
	if (is_array($row)==TRUE)
	{
		extract ($row);

		// Contrôle qu'une agence n'essaye pas de "hacker" un client
		switch(@$_SESSION["niv_log"])
		{
			case 3 :
			case 4 :
				if (client_age_ok($cli_code,@$_SESSION["code_age"],TRUE)==FALSE)
					$pbm_cli = TRUE;
				break;
			default :
				break;
		}
	}
	else
		$pbm_cli = TRUE;
}
else
	$pbm_cli = 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 : Impression Fiche Client</title>

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

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

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


</head>

<body onLoad="warnimpfic();">

<?PHP
if ($pbm_cli==FALSE)
{
	entimpfic("FICHE CLIENT");
?>
<table class="Ftable" width="100%"  border="0">
<tr>
  <td width="25%" class="rubNormal" id="f_codecli">Code Client</td>
  <td width="75%"><?PHP echo $cli_code ?></td>
</tr>
<?PHP
if (@$_SESSION["niv_log"]>=3)
{
?>
<tr>
  <td class="rubNormal" id="f_cat">Type</td>
  <td>
	  <?PHP
			for ($i=0; $i<3; $i++)
			{
				if ($i == $cli_type)
					echo $typ_client[$i];
			}
		?>
  </td>
</tr>
<tr>
  <td width="16%" class="rubNormal" id="f_cat">Cat&eacute;gorie</span></td>
  <td width="84%">
	  <?PHP
			// Affichage de la catégorie
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rs = mysql_query("SELECT * FROM ".TBCCAT." WHERE cat_code = '".$cli_cat."'");
			if (mysql_num_rows($rs) <> 0)
			{
				if ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
					echo $cat_desc;
				}
			}
			mysql_free_result($rs);
			mysql_close($conn);
		?>
  </td>
</tr>
<?PHP
}
?>
<tr>
  <td width="16%" class="rubNormal" id="f_ste">Soci&eacute;t&eacute;</td>
  <td width="84%"><?PHP echo $cli_ste ?></td>
</tr>
<tr>
  <td class="rubNormal" id="f_rcs">RCS</td>
  <td><?PHP echo $cli_rcs ?></td>
</tr>
<tr>
  <td width="16%" class="rubNormal" id="f_civil">Civilit&eacute;</td>
  <td width="84%">
	  <?PHP
			// Affichage de la civilité
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rs = mysql_query("SELECT * FROM ".TBCIV." WHERE civ_code = '".$cli_civilite."'");
			if (mysql_num_rows($rs) <> 0)
			{
				if ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
					echo $civ_desc;
				}
			}
			mysql_free_result($rs);
			mysql_close($conn);
		?>
  </td>
</tr>
<tr>
  <td class="rubNormal" id="f_prenom">Pr&eacute;nom</td>
  <td><?PHP echo $cli_prenom ?></td>
</tr>
<tr>
  <td class="rubNormal" id="f_nom">Nom</td>
  <td><?PHP echo $cli_nom ?></td>
</tr>
<tr>
  <td class="rubNormal" id="f_adr1">Adresse(1)</td>
  <td><?PHP echo $cli_adr1 ?></td>
</tr>
<tr>
  <td class="rubNormal" id="f_adr2">Adresse(2)</td>
  <td><?PHP echo $cli_adr2 ?></td>
</tr>
<tr>
  <td class="rubNormal" id="f_cp">Code Postal </td>
  <td>
	  <?PHP
			echo Retournecp_openId($cli_ville,TRUE);				
		?>
	</td>
</tr>
<tr>
  <td class="rubNormal" id="f_ville">Ville</td>
  <td>
	  <?PHP
			echo Retourneville_openId($cli_ville,TRUE);				
		?>
	</td>
</tr>
<tr>
  <td class="rubNormal" id="f_pays">Pays</td>
  <td>
	  <?PHP
			// Affichage du pays
			echo Retournepays_open($cli_codepays,TRUE);
		?>
	</td>
</tr>
<tr>
  <td class="rubNormal" id="f_telf">T&eacute;l&eacute;phone Fixe </td>
  <td><?PHP echo $cli_telf ?></td>
</tr>
<tr>
  <td class="rubNormal" id="f_fax">T&eacute;l&eacute;copieur</td>
  <td><?PHP echo $cli_fax ?></td>
</tr>
<tr>
  <td class="rubNormal" id="f_telp">Portable</td>
  <td><?PHP echo $cli_telp ?>
  </td>
</tr>
<tr>
  <td class="rubNormal" id="f_email">Email</td>
  <td><?PHP echo $cli_email ?></td>
</tr>
<tr>
  <td class="rubNormal" id="f_mess">Messagerie</td>
  <td><?PHP echo $cli_mess ?></td>
</tr>
<?PHP
if (@$_SESSION["niv_log"]>=5)
{
?>
<tr>
  <td class="rubNormal" id="f_notaa">Notes Administration</td>
  <td>
	<?PHP
		echo "<span class=\"txtnotes\">";
		echo formatetxt($cli_notaa);
		echo "</span>";
	?>
	</td>
</tr>
<?PHP
}

if (@$_SESSION["niv_log"]>=3)
{
?>
<tr>
  <td height="37" class="rubNormal" id="f_notat">Notes Techniciens </td>
  <td>
	<?PHP
		echo "<span class=\"txtnotes\">";
		echo formatetxt($cli_notat);
		echo "</span>";
	?>
	</td>
</tr>
<tr>
  <td class="rubNormal" id="f_cpta">Comptabilit&eacute;</td>
  <td><p>
	  <?PHP echo $mess_cpta[$cli_cpta]; ?>
</tr>
<?PHP
}
?>
</table>

<?PHP
if ($nbcontacts <> 0)
{
	compimpfic("CONTACTS");

	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBCCLI." WHERE ccli_codecli='".$coderech."' ORDER by ccli_nom";

	$rs = mysql_query($rech) or die(mysql_error());

	// *** Affichage de la table
    echo "<table border=\"1\" width=\"100%\">\n";     

	// Création entête
	titimplst($ccli_titre_col);	

	while ($row = mysql_fetch_assoc($rs)) 
	{         
		echo "<tr>";
        echo "<td class=\"annot_petit\">";
		$rech2 ="SELECT * FROM ".TBFONC." WHERE `fonc_code`= '".$row["ccli_codefonc"]."'";
		$rs2 = mysql_query($rech2);
		if ($resultat = mysql_fetch_array($rs2)) 
		{
			extract($resultat);
			echo $fonc_desc;
		}
		else
			echo "&nbsp;";
		echo "</td>\n";
        echo "<td class=\"annot_petit\">";
		echo $row["ccli_civilite"]." ".$row["ccli_nom"]." ".$row["ccli_prenom"];
		echo "</td>\n";
        echo "<td class=\"annot_petit\">".$row["ccli_telf"]."</td>\n";
        echo "<td class=\"annot_petit\">".$row["ccli_fax"]."</td>\n";
        echo "<td class=\"annot_petit\">".$row["ccli_telp"]."</td>\n";
        echo "<td class=\"annot_petit\">".$row["ccli_email"]."</td>\n";
        echo "<td class=\"annot_petit\">".$row["ccli_mess"]."</td>\n";
		
		 echo "</tr>\n";
	}  

	echo "</table>\n";
	// *** Fin affichage de la table
	
	mysql_free_result($rs);
	mysql_close($conn);
	if (nb_scli($coderech)<> 0)
	{
		compimpfic("SITES");
	
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM ".TBSCLI." WHERE scli_codecli='".$coderech."' ORDER by scli_ste";
	
		$rs = mysql_query($rech) or die(mysql_error());
	
		// *** Affichage de la table
		echo "<table border=\"1\" width=\"100%\">\n";     
	
		// Création entête
		titimplst($scli_titre_col);	
	
		while ($row = mysql_fetch_assoc($rs)) 
		{         
			echo "<tr>";
			echo "<td class=\"annot_petit\">";
			echo "<strong>".$row["scli_ste"]."</strong><br>";
			echo $row["scli_adr1"]."<br>";
			if ($row["scli_adr2"]<>"")
				echo $row["scli_adr2"]."<br>";
			echo Retournecp_openId($row["scli_ville"],FALSE)." ".Retourneville_openId($row["scli_ville"],FALSE)."<br>";
			echo "</td>\n";
			echo "<td class=\"annot_petit\">".$row["scli_telf"]."</td>\n";
			echo "<td class=\"annot_petit\">".$row["scli_fax"]."</td>\n";
			echo "<td class=\"annot_petit\">".$row["scli_email"]."</td>\n";
			echo "<td class=\"annot_petit\">";
			echo $row["scli_rcivil"]." ".$row["scli_rprenom"]." ".$row["scli_rnom"]."<br>";
			echo "Tel. ".$row["scli_rtelf"]." / Fax ".$row["scli_rfax"]."<br>";
			echo "Por. ".$row["scli_rtelp"]." / Mail ".$row["scli_remail"]."<br>";
			echo "</td>\n";
			
			 echo "</tr>\n";
		}  
	
		echo "</table>\n";
		// *** Fin affichage de la table
		mysql_close($conn);  
	}
}
}
else
{
?>
	<script type="text/javascript">
	setTimeout("self.location.href=('index.php');",2000)
	</script>
<?PHP
}
?>
</body>
</html>
