<?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"] <> 9) AND (@$HTTP_SESSION_VARS["niv_log"] <> 5))) header("Location: ../index.php") ?>
<?php include ("../inc/config.inc.php") ?>
<?php require ("../inc/func.inc.php") ?>
<?php require ("../inc/func_date.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['ca']));

	if ($coderech <> "")
	{
		// Vérification qu'il existe bien des techniciens et nombre de ceux-ci
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM " .TBTEC. " WHERE tec_codeage = '$coderech'";
		$rs = mysql_query($rech)or die(mysql_error());
		$nbtecs = mysql_num_rows($rs);
		mysql_free_result($rs);
		mysql_close($conn);

		// Récupération des informations agence

		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM " .TBAGE. " WHERE age_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 Agence</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 AGENCE");
?>
  <table class="Ftable" width="740"  border="0">
    <tr>
      <td class="rubNormal" id="f_code"><div align="right">Ouverture ? </div></td>
      <td width="62%">
		  <?PHP
			if ($age_ouvert == 1)
				echo "Ouverte";
			else
				echo "Fermée";
			?>
	  </td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_code"><div align="right">Code</div></td>
      <td>
	  	<?PHP
         	echo $age_code;
		?>
      </td>
    </tr>
    <tr>
      <td height="21" class="rubNormal" id="f_logo"><div align="right">Logo</div></td>
      <td>
		  <?PHP
				$urlimg = $chemin_logos."/log".strtolower($age_code).".png"; 
				echo "<div align=\"left\">";
				echo "<img src=\"".$urlimg."\"><br>";
				echo "</div>";
			?>
	  </td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_nom"><div align="right">Nom</div></td>
      <td><?PHP echo $age_nom; ?></td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_rcs"><div align="right">RCS / APE </div></td>
      <td><?PHP echo $age_rcs ?></td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_tcom"><div align="right">Tribunal com. </div></td>
      <td><?PHP echo $age_tcom ?></td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_adr1"><div align="right">Adresse (1) </div></td>
      <td><?PHP echo $age_adr1 ?></td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_adr2"><div align="right">Adresse (2) </div></td>
      <td><?PHP echo $age_adr2 ?></td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_ville"><div align="right">Code Postal</div></td>
      <td>
          <?PHP
				// Affichage du Code Postal
	
				echo Retournecp($age_ville);
			?>
	  </td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_ville"><div align="right">Ville</div></td>
      <td>
          <?PHP
				// Affichage de la ville
	
				echo Retourneville($age_ville);
			?>
	  </td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_pays"><div align="right">Pays</div></td>
      <td>
          <?PHP
				// Affichage de la ville
	
				echo $age_pays;
			?>
	  </td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_zone" align="right">Zone Chalandise </td>
      <td>
          <?PHP
				echo $age_zone;
			?>
	  </td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_telf"><div align="right">T&eacute;l&eacute;phone Fixe </div></td>
      <td>
	  <?PHP 
		echo $age_telf."<br>";
		echo $age_txttelf;
	  ?>
	  </td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_fax"><div align="right">T&eacute;l&eacute;copieur</div></td>
      <td>
	  <?PHP 
	  	echo $age_fax."<br>";
		echo $age_txtfax;
		?>
		</td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_web"><div align="right">Site Web </div></td>
      <td><?PHP echo $age_web ?></td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_heures"><div align="right">Horaires</div></td>
      <td><?PHP echo $age_heures ?></td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_heures"><div align="right">Ent&ecirc;te</div></td>
      <td>
		<?PHP
			echo formatetxt($age_txtent);
		?>
	  </td>
    </tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="rubNormal" id="f_web"><div align="center"><u>Responsable d'agence </u></div></td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_rcivil"><div align="right">Civilit&eacute;</div></td>
      <td>
          <?PHP
				
				// Affichage de la civilité
	
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rs = mysql_query("SELECT * FROM ".TBCIV." WHERE civ_code = '".$age_resp_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_rprenom"><div align="right">Pr&eacute;nom</div></td>
      <td><?PHP echo $age_resp_prenom ?></td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_rnom"><div align="right">Nom</div></td>
      <td><?PHP echo $age_resp_nom ?></td>
    </tr>
    <tr>
      <td class="rubNormal" id="f_rtelf"><div align="right">Tel. Fixe </div></td>
      <td><?PHP echo $age_resp_telf ?></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="rubNormal"><div align="center"><u>Emails</u></div></td>
      <td width="17%">  
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_email"><div align="right">G&eacute;n&eacute;ral</div></td>
      <td><?PHP echo $age_email ?>
		 <span class="annot_std_it">(Pour contacts clients)</span>
	  </td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_emaild"><div align="right">Direction</div></td>
      <td><?PHP echo $age_emaild ?></td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_emailc"><div align="right">Comptabilit&eacute;</div></td>
      <td><?PHP echo $age_emailc ?></td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_emailt"><div align="right">Technique</div></td>
      <td><?PHP echo $age_emailt ?></td>
    </tr>
    <tr>
      <td width="21%">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_nota"><div align="right">Notes</div></td>
      <td><?PHP 
			echo "<span class=\"txtnotes\">";
			echo formatetxt($age_nota);
			echo "</span>";
 		  ?>
	  </td>
    </tr>
    <tr>
      <td width="21%">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="21%" class="rubNormal" id="f_factures"><div align="right">Emet ses factures </div></td>
      <td><?PHP 
					if ($age_fact == TRUE)
					{
						echo "Oui";
					}
					else
					{
						echo "Non";
					}
				?>
	  </td>
    </tr>
  </table>

<?PHP
if ($nbtecs <> 0)
{
	compimpfic("TECHNICIENS");

	$en_vacances = FALSE;
	$parti = FALSE;

	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBTEC." WHERE tec_codeage='".$coderech."' ORDER by tec_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($teci_titre_col);	

	while ($row = mysql_fetch_assoc($rs)) 
	{         
		$t_en_vacances = FALSE;
		$t_parti = FALSE;

		 echo "<tr>";
		 
		 echo "<td>".$row["tec_code"];
	
		// CREATION d'un code en cas de congés
		 if ((comp_date($row["tec_congd"],$datea) == TRUE) AND (comp_date($datea,$row["tec_congf"]) == TRUE))
		 {
			$en_vacances = TRUE;
			$t_en_vacances = TRUE;
			echo " (V";
		}
	
		// CREATION d'un code si le technicien n'est plus salarié
		 if ($row["tec_out"] == TRUE)
		 {
			$parti = TRUE;
			$t_parti = TRUE;
			if ($t_en_vacances == FALSE)
				echo " (";
			else
				echo "/";
			echo "S";
		}
	
		if (($t_en_vacances == TRUE) OR ($t_parti == TRUE))
			echo ")";
		 echo "</td>\n";
		 echo "<td>".$row["tec_prenom"]."</td>\n";
		 echo "<td>".$row["tec_nom"]."</td>\n";
		 echo "<td>".$row["tec_telf"]."</td>\n";
		 echo "<td>".$row["tec_telp"]."</td>\n";
	
		// CREATION lien dynamique sur email
		 echo "<td>";
		 echo $row["tec_email"];
		 echo "</td>\n";
	
		 echo "</tr>\n";
	}  

	echo "</table>\n";
	// *** Fin affichage de la table
	
	mysql_free_result($rs);
	mysql_close($conn); 
	
	echo "<br>";
	echo "<div align=\"center\">";
	if ($parti == TRUE) 
		echo "S : N'est plus salarié(e)";
	if ($en_vacances == TRUE) 
	{
		if ($parti == TRUE)
		{
			echo " / ";
		}
		echo "V : En vacances";
	}
	echo "</div>";
}
?>

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

<?php 
	include_once ("pied.php")
?>
