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

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

session_start(); 
?>
<?php if ((@$HTTP_SESSION_VARS["etat_log"] <> "connecte") or (@$HTTP_SESSION_VARS["niv_log"] <> 1)) header("Location: ../index.php") ?>
<?php include ("../inc/config.inc.php") ?>
<?php require ("../inc/func.inc.php") ?>
<?php require ("../inc/func_log.inc.php") ?>
<?php require ("../inc/lst.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$coderech = strip_tags(trim($_GET['cc']));
	
	if ($coderech <> "")
	{
		// Vérification qu'il existe bien des contacts et nombre de ceux-ci
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM " .TBCCLI. " WHERE ccli_codecli = '$coderech'";
		$rs = mysql_query($rech)or die(mysql_error());
		$nbcontacts = mysql_num_rows($rs);
		mysql_free_result($rs);
		mysql_close($conn);

		// Récupération des informations clients

		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM " .TBCLI. " WHERE cli_code = '$coderech'";
		$rs = mysql_query($rech)or die(mysql_error());
		if (mysql_num_rows($rs) == 0)
		{
			echo "Aucun résultat";
		}
		else
		{
			 while ($row = mysql_fetch_array($rs)) 
			{
				extract ($row);
			}
		}
		mysql_free_result($rs);
		mysql_close($conn);

	}
?>

<!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="../inc/smi.css" rel="stylesheet" type="text/css">

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

</head>

<body>
<?PHP
	entimpfic("FICHE CLIENT");
?>
  <table class="Ftable" width="800"  border="0">
    <tr>
	  <td width="25%" class="rubNormal" id="f_codecli">Code Client</td>
      <td width="75%"><?PHP echo $cli_code ?></td>
    </tr>
    <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)
				{
					while ($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($cli_ville);				
			?>
   	    </td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_ville">Ville</td>
      <td>
          <?PHP
				echo Retourneville($cli_ville);				
			?>
   	    </td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_pays">Pays</td>
      <td>
          <?PHP
				// Affichage du pays

				echo $cli_pays;
			?>
   	    </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>
  </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=\"0\" width=\"800\">\n";     

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

	while ($row = mysql_fetch_assoc($rs)) 
	{         
		echo "<tr>";
        echo "<td class=\"annot_petit\">".$row["ccli_func"]."</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);  
}
?>

	<script type="text/javascript">
	warnimpfic();
	</script>

</body>
</html>
