<?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 require ("../inc/func_txt.inc.php") ?>
<?php require ("../inc/lst.inc.php") ?>
<?php require ("../inc/fic.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$coderech = strip_tags(trim($_GET['cc']));
	
	if (@$HTTP_SESSION_VARS["niv_log"] == 1)
		$coderech=@$HTTP_SESSION_VARS["code_log"];

	$pbm_cli=FALSE;

	if ((@$HTTP_SESSION_VARS["niv_log"] == 4) OR (@$HTTP_SESSION_VARS["niv_log"] == 3))
	{
		$row = lit_enr_age($HTTP_SESSION_VARS["code_age"]);
		extract ($row);
		$zc_couverte = $age_zone;
	}
	else
		$zc_couverte = zc_age_actives();

	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
			if ((@$HTTP_SESSION_VARS["niv_log"] == 4) OR (@$HTTP_SESSION_VARS["niv_log"] == 3))
			{
				if (dep_in_zc($cli_dep,$zc_couverte) == TRUE) 
				{
					if (($cli_prop <> @$HTTP_SESSION_VARS["code_age"]) AND ($cli_prop <> NULL))
					{
						$pbm_cli = TRUE;
					}
				}
				else
				{
					$pbm_cli = TRUE;
				}
			}
		}
		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 affichages -->
<script language="JavaScript" src="../inc/aff.js"></script>

</head>

<body>
<?PHP
if ($pbm_cli==FALSE)
{
	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>
	<?PHP
	if (@$HTTP_SESSION_VARS["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)
				{
					while ($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)
				{
					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>
	<?PHP
	if (@$HTTP_SESSION_VARS["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 (@$HTTP_SESSION_VARS["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=\"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);  
}
?>

<?PHP
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=\"800\">\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($row["scli_ville"])." ".Retourneville($row["scli_ville"])."<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_free_result($rs);
	// mysql_close($conn);  
}
?>
	<script type="text/javascript">
	warnimpfic();
	</script>
<?PHP
}
else
{
?>
	<script type="text/javascript">
	setTimeout("self.location.href=('index.php');",2000)
	</script>
<?PHP
}
?>

</body>
</html>
