<?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_time.inc.php") ?>
<?php require ("../inc/func_date.inc.php") ?>
<?php require ("../inc/func_log.inc.php") ?>
<?php require ("../inc/func_txt.inc.php") ?>
<?php require ("../inc/fic.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$td = strip_tags(trim($_GET['td'])); // Récupération type demande
	$co = strip_tags(trim($_GET['co'])); // Récupération code Contrat
	$cc = strip_tags(trim($_GET['cc'])); // Récupération code Client
	$ca = strip_tags(trim($_GET['ca'])); // Récupération code Agence
	$HTTP_SESSION_VARS["scli_choisis"] = "";

	$nbcontrats = 0;
	$pbm_cocl = FALSE;
	$preavis_mini = preavis_min();


	// Niveau <=3 ne peut que voir les contrats
	if (@$HTTP_SESSION_VARS["niv_log"] <= 3)
		$td = "view";


	if ($ca<> "")
	{
		// Contrôle qu'une agence n'essaye pas de "hacker" un contrat
		if (((@$HTTP_SESSION_VARS["niv_log"] == 4) OR (@$HTTP_SESSION_VARS["niv_log"] == 3)) AND ($ca <> @$HTTP_SESSION_VARS["code_age"]))
			$pbm_cocl = TRUE;
	}
	
	if ($co <> "")
	{
		// Récupération des informations contrat client
		$row = lit_enr_cocl($co);
		if (is_array($row))
		{
			extract ($row);
			
			// Si contrat terminé, force le mode "view"
			if (formatedate($cocl_datefin) <> "")
				$td="view";
			
			if ($td <> "add")
			{
				// Contrôle qu'un client n'essaye pas de "hacker" un contrat
				if ((@$HTTP_SESSION_VARS["niv_log"] == 1) AND ($cocl_codecli <> @$HTTP_SESSION_VARS["code_log"]))
					$pbm_cocl = TRUE;
			// Contrôle qu'une agence n'essaye pas de "hacker" un contrat
				if (((@$HTTP_SESSION_VARS["niv_log"] == 4) OR (@$HTTP_SESSION_VARS["niv_log"] == 3)) AND ($cocl_codeage <> @$HTTP_SESSION_VARS["code_age"]))
					$pbm_cocl = TRUE;
			}
		}
		else
			$pbm_cocl = TRUE;

		if ($pbm_cocl == FALSE)
		{
			// Construction de la chaîne des sites sélectionnés
			$lstsites = "";
			
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT scli_id FROM ".TBSCLI.",".TBSCLIC." WHERE ".TBSCLIC.".sclic_codecocl = '".$co."' AND ".TBSCLI.".scli_id = ".TBSCLIC.".sclic_idscli";
			$rs = mysql_query($rech);
			while ($row = mysql_fetch_assoc($rs)) 
			{
				extract($row);
				$lstsites .= $scli_id."-";
			}
			mysql_free_result($rs);
			mysql_close($conn);

			$HTTP_SESSION_VARS["scli_choisis"] = $lstsites;
	
			// Vérification qu'il existe bien des contrats et nombre de ceux-ci
			$nbcontrats = nb_cocl_in_cli($cocl_codecli);
	
			// Vérification si ce contrat a été signé
			// Si oui, on ne peut plus rien modifier
			$signe = cocl_signed($co);
			if ($signe==TRUE)
				$td="view";
	
			$cocl_datecreaf = formatedate($cocl_datecrea);
			$cocl_datemodf = formatedate($cocl_datemod);
			$cocl_dateenvf = formatedate($cocl_dateenv);
			$cocl_daterecf = formatedate($cocl_daterec);
			$cocl_datesigf = formatedate($cocl_datesig);
			$cocl_datedf = formatedate($cocl_dated);
			$cocl_dateff = formatedate($cocl_datef);
			$cocl_daterelf = formatedate($cocl_daterel);
			$cocl_datefinf = formatedate($cocl_datefin);
	
			if ($td == "edit")
			{
				$cc=$cocl_codecli;
				$ca=$cocl_codeage;
			}

			if ($td == "view")
			{
				$cc=$cocl_codecli;
				$ca=$cocl_codeage;
			}
	
			if ($td == "add")
			{
				$cocl_datecreaf = $datef;
				$cocl_dateenvf = $datef;
				$cocl_daterecf = $datef;
				$cocl_code = $co;
				$cocl_codecli = $cc;
				$cocl_codeage = $ca;
				$cocl_nbs = 3600; // 1 heure...en secondes
				$cocl_preavis = preavis_max();
				$cocl_datedf = $datef;
				$cocl_renouv = 0;
				$cocl_sitep = 1;
			}
		}
	}
	else
	{
		if (($td=="edit") OR ($td=="view") OR ($td=="del"))
			$pbm_cocl=TRUE;
			
		if ($td == "add")
		{
			$cocl_datecreaf = $datef;
			$cocl_dateenvf = $datef;
			$cocl_code = crecodesession("CO");
			$cocl_daterecf = $datef;
			$co = $cocl_code;
			$cocl_nbs = 3600; // 1 heure...en secondes
			$cocl_preavis = preavis_max();
			$cocl_datedf = $datef;
			$cocl_renouv = 0;
			$cocl_sitep = 1;
		}

	}
	
	$nbh = substr(sec_heure($cocl_nbs),0,5);
	$soldeh = substr(sec_heure($cocl_soldes),0,5);
		
	$pbm_cli=FALSE;
		
	if ($cc <>"")
	{
		// Contrôle qu'un client n'essaye pas de "hacker" un contrat
		if ((@$HTTP_SESSION_VARS["niv_log"] == 1) AND ($cc <> @$HTTP_SESSION_VARS["code_log"]))
			$pbm_cli = TRUE;

		$row = lit_enr_cli($cc);
		if (is_array($row))
		{
			extract ($row);

			$cocl_codecli=$cc;

			// Contrôle qu'une agence n'essaye pas de "hacker" un contrat
	
			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 ((@$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;
		}
	}
	
	// Si le délai d'intervention est nul on n'affiche rien
	if ($cocl_delai == 0)
		$cocl_delai = "";

	switch ($td)
	{
		case "add" :
			$titre = "CREATION CONTRAT CLIENT";
			break;
		case "edit" :
			$titre = "MISE A JOUR CONTRAT CLIENT";
			break;
		case "del" :
			$titre = "SUPPRESSION CONTRAT CLIENT";
			break;
		case "view" :
			if (@$HTTP_SESSION_VARS["niv_log"] == 1)
				$titre = "VISUALISATION CONTRAT";
			else
				$titre = "VISUALISATION CONTRAT CLIENT";
			break;
	}
?>

<!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 : Fiche Contrat Client</title>

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

<!-- Feuille de style & Script pour le menu -->
<link href="../inc/menu.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../coolmenus/coolmenus4.js"></script>

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

<!-- Scripts Javascript pour vérifications -->
<script language="JavaScript" src="../inc/verif.js"></script>

<!-- Définition Javascript pour calendrier popup -->

  <!-- Feuille de Style -->
  <link rel="stylesheet" type="text/css" media="all" href="../jscal/skins/aqua/theme.css" title="Aqua" />

  <!-- Script Javascript Principal -->
  <script type="text/javascript" src="../jscal/calendar.js"></script>

  <!-- Choix du langage -->
  <script type="text/javascript" src="../jscal/lang/calendar-fr.js"></script>

  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="../jscal/calendar-setup.js"></script>

<!-- Fin de la définition Javascript pour calendrier popup -->

<!-- Affichage nouvelle fenêtre pour impression -->
<script type="text/javascript">
	function lanceimp(page)
	{
	  window.open(page,'impression','width='+screen.width+' height='+screen.height);
	}
</script>

<!-- Fenêtre avertissement si aucun site sélectionné -->
<script type="text/javascript">
function warnnosite()
{
	var mess='';
	if ((document.cocl_maj.sitesec.value=='') && (!document.cocl_maj.sitep.checked))
	{
		mess='Vous devez au moins choisir un site.';
		alert(mess);
		document.cocl_maj.sitep.checked=true;
	}	
}
</script>

<!-- Scripts Javascript pour contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/vform/vform.js"></script>

<script language="javascript">
var tab1_champ=new Array(
<?PHP
	if ($td == "add")
	{
?>
	"nom:datecreaf ; format:date ; masque:jj-mm-aaaa ; req:Y ; txt:Date création ; stok:frmok ; stbad:frmbad",
<?PHP
		if ((@$HTTP_SESSION_VARS["niv_log"] <> 4) AND (@$HTTP_SESSION_VARS["niv_log"] <> 3))
		{
			if ($cli_prop == NULL) // On affiche la liste uniquement si le client est non affecté
			{
?>
	"nom:codeage ; format:liste ; req:Y ; txt:Agence ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
			}
			else
			{
?>
	"nom:codeage ; format:txt ; req:Y ; txt:Agence ; stok:frmok ; stbad:frmbad",
<?PHP
			}
		}
		else
		{
?>
	"nom:codeage ; format:txt ; req:Y ; txt:Agence ; stok:frmok ; stbad:frmbad",
<?PHP
		}
?>
	"nom:co ; format:liste ; req:Y ; txt:Contrat type ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:cope ; format:liste ; req:Y ; txt:Fréquence ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:delai ; format:unsigned ; req:N ; txt:Délai intervention ; lmx:2 ; stok:frmok ; stbad:frmbad",
	"nom:nbh ; format:dureehhmm ; req:Y ; txt:Nombre d'heures ; stok:frmok ; stbad:frmbad",
	"nom:datedf ; format:date ; masque:jj-mm-aaaa ; req:Y ; txt:Date début ; stok:frmok ; stbad:frmbad",
	"nom:dateff ; format:date ; masque:jj-mm-aaaa ; req:N ; txt:Date fin ; stok:frmok ; stbad:frmbad",
	"nom:preavis ; format:unsigned ; req:Y ; txt:Préavis ; lmx:3; stok:frmok ; stbad:frmbad",
	"nom:matos ; format:txt ; req:Y ; txt:Matériel; stok:frmok ; stbad:frmbad",
	"nom:pu ; format:reel_ns ; req:Y ; txt:Prix de vente hors taxes ; lmx:10 ; stok:frmok ; stbad:frmbad");
<?PHP
	}

	if ($td == "edit")
	{
?>
	"nom:datecreaf ; format:date ; masque:jj-mm-aaaa ; req:Y ; txt:Date création ; stok:frmok ; stbad:frmbad",
	"nom:codeage ; format:txt ; req:Y ; txt:Agence ; stok:frmok ; stbad:frmbad",
	"nom:co ; format:txt ; req:Y ; txt:Contrat type ; stok:frmok ; stbad:frmbad",
	"nom:cope ; format:liste ; req:Y ; txt:Fréquence ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:delai ; format:unsigned ; req:N ; txt:Délai intervention ; lmx:2 ; stok:frmok ; stbad:frmbad",
	"nom:nbh ; format:dureehhmm ; req:Y ; txt:Nombre d'heures ; stok:frmok ; stbad:frmbad",
	"nom:datedf ; format:date ; masque:jj-mm-aaaa ; req:Y ; txt:Date début ; stok:frmok ; stbad:frmbad",
	"nom:dateff ; format:date ; masque:jj-mm-aaaa ; req:N ; txt:Date fin ; stok:frmok ; stbad:frmbad",
	"nom:preavis ; format:unsigned ; req:Y ; txt:Préavis ; lmx:3; stok:frmok ; stbad:frmbad",
	"nom:matos ; format:txt ; req:Y ; txt:Matériel; stok:frmok ; stbad:frmbad",
	"nom:pu ; format:reel_ns ; req:Y ; txt:Prix de vente hors taxes ; lmx:10 ; stok:frmok ; stbad:frmbad",
	"nom:datesig ; format:date ; masque jj-mm-aaa ; req:N ; txt:Signé le ; stok:frmok ; stbad:frmbad",
	"nom:signe ; format:txt ; req:N ; txt:Signé par ; lmx:70 ; stok:frmok ; stbad:frmbad");
<?PHP
	}
?>	
</script>


<!-- Fonction pour valider le formulaire -->
<script type="text/javascript">
function verif_saisie(formulaire,tab_champ,lng,val_delai)
{
	var delai_nul=false;
	if ((val_delai=='') || (val_delai=='0'))
	{
		delai_nul=true;
	}

	var txt_sel = document.cocl_maj.cope.options[document.cocl_maj.cope.selectedIndex].text;
	var exist_str = txt_sel.indexOf('demande',0);
	var delaiok=true;

	if ((exist_str >= 0) && (delai_nul==true))
	{
		alert("Vous devez choisir un délai d\'intervention pour ce type de fréquence");
		delaiok=false;
	}

	if ((exist_str == -1) && (delai_nul==false))
	{
		alert("Vous avez saisi un délai d\'intervention pour une fréquence n\'en ayant pas besoin");
		delaiok=false;
	}

	var formok=VForm(formulaire,tab_champ,lng);
	if ((delaiok==true) && (formok==true))
	{
		return true;
	}
	else
	{
		return false;
	}
}
</script>

</head>

<?PHP if ($td == "del"){ ?>
<body onload=warndel();>
<?PHP } else { ?>
<body>
<?PHP } ?>

<?php 
	include_once ("../inc/entete.php"); 
?>

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<!-- Affiché uniquement s'il y a un code client -->
<?PHP
if (($pbm_cocl==FALSE) AND ($pbm_cli==FALSE))
{
if ($cc <> "")
{
?>
<table width="100%"  border="0">
<tr>
	<td width="33%">
	<p><strong><em><a href="cocl_lst.php?&ord=DES&tri=Code">Retour &agrave; la liste</a></em></strong></p>
    </td>
	<td width="33%" valign="top"><div align="center"><span class="annot_gras_it">(<img src="../img/oblig.gif" width="10" height="11"> : Saisie obligatoire)</span> </div></td>
	<td width="33%" align="right">&nbsp;
	
	</td>
</tr>
	<td width="33%">
	<?PHP if (($td == "edit") OR ($td=="view") AND ($nbcontrats <> 0))
	{
		$url_coclh = "coclhd_lst.php?or=con&cc=".$cocl_codecli."&search=".$cocl_code;
	?>
		<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_coclh; ?>',800,560,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/view.gif" width="22" height="22" border="0" align="absmiddle"></a> <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_coclh; ?>',800,560,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');")> Historique contrat</a><?PHP
	}
	else
		echo "&nbsp;";
	?>
    </td>
	<td width="33%" valign="top">&nbsp;</td>
	<td width="33%" align="right">
		<?PHP
			if (($td == "edit") OR ($td == "view"))
			{
			$urlimp = "cocl_pdf.php?code=".$co;
			?>
			<a href="javascript:;" onclick="lanceimp('<?PHP echo $urlimp; ?>');")><img src="../img/print.gif" title="Imprimer le contrat" width="22" height="22" border="0" align="absmiddle"></a> 
			<a href="javascript:;" onclick="lanceimp('<?PHP echo $urlimp; ?>');")> Imprimer le contrat</a>
		<?PHP
			}
			else
				echo "&nbsp;";
		?>
	</td>
<tr>
</tr>
</table>

<form name="cocl_maj" method="post" action="cocl_enr.php" onSubmit="javascript:; return (verif_saisie(this,tab1_champ,'',document.cocl_maj.delai.value));">
<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
<input name="typdde" type="hidden" id="typdde" value="<?PHP echo $td ?>">
<input name="codecli" type="hidden" id="codecli" value="<?PHP echo $cocl_codecli ?>">
<?PHP if ($td == "add") { ?>
	<input name="code" type="hidden" id="code" value="<?PHP echo $cocl_code ?>">
	<input name="renouv" type="hidden" id="renouv" value="<?PHP echo $cocl_renouv ?>">
	<input name="num" type="hidden" id="num" value="">
	<input name="datefinf" type="hidden" id="datefinf" value="">
<?PHP } ?>

<!-- Détails internes de la fiche intervention -->
<table width="100%"  border="0">
<tr>
	<td width="33%">
	<?PHP if ((($td == "edit") OR ($td == "view")) AND (@$HTTP_SESSION_VARS["niv_log"] >= 3))
	{
		$url_detcocl = "cocld_maj.php?co=".$co;
	?>
		<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_detcocl; ?>',800,300,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/detail.gif" width="16" height="16" border="0" align="absmiddle"></a>
		<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_detcocl; ?>',800,300,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")> Détails</a>
	<?PHP
	}
	else
	{
	?>
		&nbsp;
	<?PHP
	}
	?>
    </td>
	<td width="33%" valign="top">&nbsp;</td>
	<td width="33%">
	<div align="right">
	<?PHP 
	 $echeance_ok = TRUE;
	 if ($cocl_dateff <> "")
	 {
		if (echeance_depassee_date($datea,$cocl_datef) == TRUE)
			$echeance_ok = FALSE;
	 }
	if ((($td == "edit") OR ($td == "view")) AND ($cocl_datefinf == "") AND ($cocl_datesigf <> "") AND ($echeance_ok == TRUE) AND (@$HTTP_SESSION_VARS["niv_log"] >= 3))
	{
		$url_int = "int_maj.php?td=add&ci=&cc=".$cc."&ct=&ca=".$ca."&co=".$co;
	?>
	  <a href="javascript:;" onclick="javascript:; window.location=('<?PHP echo $url_int; ?>');"><img src="../img/int.gif" width="16" height="16" border="0" align="absmiddle"></a>
	  <a href="javascript:;" onclick="javascript:; window.location=('<?PHP echo $url_int; ?>');")> Saisir intervention</a>
	<?PHP
	}
	else
	{
	?>
		&nbsp;
	<?PHP
	}
	?>
	</div>
	</td>
</tr>
</table>

<!-- Date de création -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_datecreaf"><div align="right">Date Cr&eacute;ation </div></td>
	<td>
		<input name="datecreaf" type="text" id="datecreaf" value="<?PHP echo $cocl_datecreaf ?>" size="10" maxlength="10" readonly="1">
		<?PHP if ($td == "add") { ?>
		<img src="../img/calendar.png" id="f_img_datecreaf" title="Choisir votre date" width="16" height="16">
		<img src="../img/oblig.gif" width="10" height="11">
		<?PHP } ?>
	</td>
</tr>
</table>

<!-- Code du contrat client (affiché uniquement si édition ou suppression) -->
<?PHP if ($td <> "add") {?>
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codecocl"><div align="right">Code </div></td>
	<td>
		<input name="code" type="text" id="code" value="<?PHP echo $cocl_code ?>" size="20" maxlength="20" readonly="1">
		<?PHP
		 $echeance_ok = TRUE;
		 if ($cocl_dateff <> "")
		 {
			if (echeance_depassee_date($datea,$cocl_datef) == TRUE)
				$echeance_ok = FALSE;
		 }
		if (($cocl_datesigf == "") OR ($cocl_datefinf <> "") OR ($echeance_ok == FALSE))
		{
			if ($cocl_datesigf == "")
			{
				echo "<span class=\"titre_std_gras_jaune_frouge\" style=\"padding: 2px;\">";
				echo "Non Signé";
				echo "</span>";
				if (($cocl_datefinf <> "") OR ($echeance_ok == FALSE))
				{
					echo "<strong><em>";
					echo " / ";
					echo "</strong></em>";
				}
			}
			if (($cocl_datefinf <> "") OR ($echeance_ok == FALSE))
			{
				echo "<span class=\"titre_std_gras_jaune_frouge\" style=\"padding: 2px;\">";
				echo "Terminé";
				echo "</span>";
			}
		}
		?>
	</td>
</tr>
</table>
<?PHP }  ?>

<!-- Affichage du client -->
<table width="800"  border="0">
<tr>
	<td width="400" class="rubfrm" colspan="2"  id="f_codecli">
		<div align="center">Client</div>
	</td>
	</tr>
</table>

<!-- Détails client -->
<table width="800"  border="0">
<tr>
	<td width="65%" valign="top" bgcolor="#CCFFCC">
	<?PHP
	if (($cli_ste <>"") OR ($cli_nom <> ""))
		echo "<img src=\"../img/".$ico_cpta[$cli_cpta]."\" title =\"".$mess_cpta[$cli_cpta]."\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\">";
	echo "<b>";
	if ($cli_ste <>"") 
	{
		echo $cli_ste."<br>";
		echo "<span class=\"annot_gras_it\">";
	}
	echo $cli_civilite." ".$cli_prenom." ".$cli_nom."<br>";
	if ($cli_ste <>"") 
	{
		echo "</span>";
	}
	echo "</b>";
	echo $cli_adr1."<br>";
	if ($cli_adr2 <>"") 
		echo $cli_adr2."<br>";
	echo Retournecp($cli_ville)." ".Retourneville($cli_ville)."<br>";
	echo "Tel : ".$cli_telf."<br>";
	?>
	</td>
	<td valign="top">
    <?PHP 
	if (@$HTTP_SESSION_VARS["niv_log"] >= 3)
	{
	  $url_affnotesc = "aff_notesc.php?cc=".$cc;
	?>
		  <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_affnotesc; ?>',930,380,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/detail.gif" width="16" height="16" border="0" align="absmiddle"></a>
		  <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_affnotesc; ?>',930,380,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")> Notes</a>
   <?PHP
   }
   ?>
  <?PHP
  if (nb_scli_actifs($cc)>0)
  {
	  $url_choixsitesc = "sites_lst.php?cc=".$cc."&co=".$cocl_code."&td=".$td;
  ?>
		<br>
		<input type="checkbox" name="sitep" value="sitep" onclick="warnnosite()" style="background : #FFFFFF;" <?PHP if ($cocl_sitep==1) echo "checked=\"checked\""; ?> <?PHP if (($signe == TRUE) OR ($td == "view")) echo "disabled=\"disabled\""; ?>>
		<span class="annot_std_gras">Site principal inclus dans le contrat</span>
	    <br>
		<input name="sitesec" type="hidden" id="sitesec" value="<?PHP echo $HTTP_SESSION_VARS["scli_choisis"]; ?>">
	  	<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_choixsitesc; ?>',920,500,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/sites.gif" width="16" height="16" border="0" align="bottom"></a>
	    <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_choixsitesc; ?>',920,500,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")> Sites secondaires couverts</a>
   <?PHP
	}
	else
	{
	?>
		<br>
		<input type="checkbox" name="sitep" value="sitep" style="background : #FFFFFF;" checked="checked" disabled="disabled">
		<span class="annot_std_gras">Site principal inclus dans le contrat</span>
	<?PHP
	}
	?>
        </td>
	</tr>
</table>

<!-- Code de l'agence (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_agence"><div align="right">Agence</div></td>
	<td>
		<?PHP
		if ($td =="add")  // Ajout = zone modifiable (on peut choisir une agence)
		{ 
			if ((@$HTTP_SESSION_VARS["niv_log"] <> 4) AND (@$HTTP_SESSION_VARS["niv_log"] <> 3))
			{
				if ($cli_prop == NULL) // On affiche la liste uniquement si le client est non affecté
				{
					// Création de la liste des agences ouvertes et couvrant le client
					
					$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
					mysql_select_db(DBNAME);
					$rech = "SELECT * FROM ".TBAGE." WHERE `age_ouvert` = '1' ORDER BY age_nom";
					$rs = mysql_query($rech);
		
					if (mysql_num_rows($rs) <> 0)
					{
					?>
					
						<select name="codeage" id="codeage">
			
						<?PHP
							echo "<option>-- Choisissez une agence --</option>";

							while ($resultat = mysql_fetch_array($rs)) 
							{
								extract($resultat);
				
								if (dep_in_zc($cli_dep,$age_zone) == TRUE)
								{
									$age_nomcode = $age_nom." (".$age_code.")";
									if ($cocl_codeage == $age_code)
										echo '<option value="'.$age_code.'" selected>'.$age_nomcode.'</option>';
									else
										echo '<option value="'.$age_code.'">'.$age_nomcode.'</option>';
								}
							}
						?>
						</select>
					<?PHP
					}
					else
					{
					?>
						<select name="codeage" id="codeage">
						<option>-- Pas d'agence --</option>
						</select>
					<?PHP
					}
					mysql_free_result($rs);
					mysql_close($conn);
					?>
					<img src="../img/oblig.gif" width="10" height="11">
				<?PHP
				}
				else
				{
					$row = lit_enr_age($cli_prop);
					extract($row);
					$age_nomcode = $age_nom." (".$age_code.")";
				?>
					<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $age_code ?>">
					<input name="nomage" type="text" id="nomage" value="<?PHP echo $age_nomcode ?>" size="50" maxlength="50" readonly="1">
		<?PHP
				}
			}
			else
			{
				$row = lit_enr_age($HTTP_SESSION_VARS["code_age"]);
				extract($row);
				$age_nomcode = $age_nom." (".$age_code.")";
		?>
				<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $age_code ?>">
				<input name="nomage" type="text" id="nomage" value="<?PHP echo $age_nomcode ?>" size="50" maxlength="50" readonly="1">
		<?PHP
			}
		} 
		else  // Edition ou suppression = zone non modifiable (affichage seul)
		{
			$row = lit_enr_age($cocl_codeage);
			extract($row);
			$age_nomcode = $age_nom." (".$age_code.")";
		?>
		<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $age_code ?>">
		<input name="nomage" type="text" id="nomage" value="<?PHP echo $age_nomcode ?>" size="50" maxlength="50" readonly="1">
		<?PHP 
		} 
		?>
	</td>
</tr>
</table>

<!-- Type de contrat -->
<table width="800"  border="0">
  <tr>
    <td width="160" class="rubfrm" id="f_co"><div align="right">Contrat Type </div></td>
    <td><?PHP
		if ($td =="add")  // Ajout = zone modifiable (on peut choisir un type de contrat)
		{ 
		?>
        <?PHP
			
			// Création de la liste des types de contrats actifs
			
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM ".TBCO."  WHERE co_actif = '1' ORDER BY co_nom";
			$rs = mysql_query($rech) or die(mysql_error());

			if (mysql_num_rows($rs) <> 0)
			{
			?>
        <select name="co" id="co">
          <?PHP
				echo "<option>-- Choisissez un type de contrat --</option>";

				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					if ($cocl_codeco == $co_code)
						echo '<option value="'.$co_code.'" selected>'.$co_nom.'</option>';
					else
						echo '<option value="'.$co_code.'">'.$co_nom.'</option>';
				}
			?>
        </select>
        <?PHP
			}
			else
			{
		?>
				<select name="co" id="co">
				<option>-- Pas de contrat type actif --</option>
				</select>
		<?PHP
			}
			mysql_free_result($rs);
			mysql_close($conn);
			?>
        <img src="../img/oblig.gif" width="10" height="11">
        <?PHP 
		} 
		else  // Edition ou suppression = zone non modifiable (affichage seul)
		{
			$row = lit_enr_co($cocl_codeco);
			extract($row);
		?>
        <input name="co" type="hidden" id="co" value="<?PHP echo $cocl_codeco ?>" size="20">
        <input name="nomco" type="text" id="nomco" value="<?PHP echo $co_nom ?>" size="50" maxlength="50" readonly="1">
        <?PHP 
		} 
		?>
    </td>
  </tr>
</table>

<!-- Périodicité du contrat -->
<table width="800"  border="0">
  <tr>
    <td width="160" class="rubfrm" id="f_cope"><div align="right">Fr&eacute;quence</div></td>
    <td>
		<?PHP
		if (($signe == FALSE) AND ($td <> "view")) // Affichage du choix de périodicité uniquement si pas encore signé
		{ 
			// Création de la liste des types des périodicités
			
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM ".TBPER." ORDER BY cope_nbj";
			$rs = mysql_query($rech);

			if (mysql_num_rows($rs) <> 0)
			{
		?>
        		<select name="cope" id="cope" onChange="verif_delai()">
		<?PHP
				echo "<option value=\"0\">-- Choisissez une fréquence --</option>";

				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					if ($cope_nbj <> 0)
						$txt_nbj = " (tous les ".$cope_nbj." jours)";
					else
						$txt_nbj = " (à la demande)";

					if ($cocl_codecope == $cope_code)
						echo '<option value="'.$cope_code.'" selected>'.$cope_desc.$txt_nbj.'</option>';
					else
						echo '<option value="'.$cope_code.'">'.$cope_desc.$txt_nbj.'</option>';
				}
		?>
        		</select>
        <?PHP
			}
			else
			{
		?>
        		<select name="cope" id="cope">
				<option>-- Pas de fr&eacute;quence à choisir --</option>
        		</select>
		<?PHP
			}
			mysql_free_result($rs);
			mysql_close($conn);
			?>
        	<img src="../img/oblig.gif" width="10" height="11">
		<?PHP
		} 
		else 
		{
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM ".TBPER." WHERE `cope_code` = '".$cocl_codecope."'";
			$rs = mysql_query($rech);
			if ($row = mysql_fetch_array($rs))
				extract ($row);
			mysql_free_result($rs);
			mysql_close($conn);
		?>
        <input name="cope" type="hidden" id="cope" value="<?PHP echo $cocl_codecope ?>">
        <input name="tcope" type="text" id="tcope" value="<?PHP echo $cope_desc ?>" size="20" maxlength="20" readonly="1">
		<?PHP 
		} 
		?>
	 </td>
  </tr>
</table>

<!-- Délai d'intervention -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_delai" align="right">
		D&eacute;lai Interv.
	</td>
    <td>
		<?PHP
		if (($signe == FALSE) AND ($td <> "view")) // Affichage du choix de périodicité uniquement si pas encore signé
		{
		?>
			<input name="delai" type="text" id="delai" value="<?PHP echo $cocl_delai ?>" size="2" maxlength="2" align="right">
			<span class="annot_petit_it">heures ouvr&eacute;es(obligatoire seulement si &agrave; la demande) </span>
		<?PHP
		}
		else // Si c'est signé, on se contente d'afficher le délai d'intervention
		{
		?>
	        <input name="delai" type="text" id="delai" value="<?PHP echo $cocl_delai ?>" size="2" maxlength="2" align="right" readonly="1">
			<span class="annot_petit_it">heures ouvr&eacute;es </span>
		<?PHP
		}
		?> 
	</td>
</tr>
</table>

<!-- Nombre d'heures par contrat -->
<table width="800"  border="0">
  <tr>
    <td width="160" class="rubfrm" id="f_nbheures"><div align="right">Nb heures</div></td>
    <td>
		<?PHP
		if (($signe == FALSE) AND ($td <> "view")) // Affichage du choix de périodicité uniquement si pas encore signé
		{
		?>
			<input name="nbh" type="text" id="nbh" value="<?PHP echo $nbh ?>" size="5" maxlength="5">
			<span class="annot_petit_it"> (format hh:mm. 0 = sans limite de temps)</span>
			<span class="annot_std_gras">,</span>
			<?PHP
			if ($cocl_typh == 0)
			{
			?>
				<select name="typh" id="typh">
				<option value="0" selected>Par intervention</option>
				<option value="1">Quota d'heures</option>
				</select>
			<?PHP
			}
			else
			{
			?>
				<select name="typh" id="typh">
				<option value="0">Par intervention</option>
				<option value="1" selected>Quota d'heures</option>
				</select>
			<?PHP
			}
		}
		else // Si c'est signé, on se contente d'afficher le détail horaire
		{
		?>
	        <input name="nbh" type="text" id="nbh" value="<?PHP echo $nbh ?>" size="5" maxlength="5" readonly="1">
			<span class="annot_std_gras">,</span>
	        <input name="typh" type="text" id="typh" value="<?PHP echo $typ_horaire[$cocl_typh]; ?>" size="20" maxlength="20" readonly="1">
		<?PHP
			if ((($td == "edit") OR ($td == "del") OR ($td == "view")) AND ($cocl_typh == 1))
			{
		?> 
			<br>
			<span class="annot_std_it">Solde :</span>		
			<input name="soldeh" type="text" id="soldeh" value="<?PHP echo $soldeh ?>" size="5" maxlength="5">
		<?PHP
			}
		}
		?>
  </tr>
</table>

<!-- Dates de "vie" du contrat -->
<table width="800"  border="0">
  <tr>
    <td width="160" class="rubfrm" id="f_validite"><div align="right">Validit&eacute;</div></td>
    <td>
		<span class="annot_petit_gras">Du</span>      
		<input name="datedf" type="text" id="datedf" value="<?PHP echo $cocl_datedf ?>" size="10" maxlength="10" readonly="1">
		<?PHP if (($signe == FALSE) AND ($td <> "view")) { // On peut modifier la date de départ uniquement si pas signé ?>
        <img src="../img/calendar.png" id="f_img_datedf" title="Choisir votre date" width="16" height="16"> 
		<img src="../img/oblig.gif" width="10" height="11">
		<?PHP } ?>
		 <span class="annot_petit_gras">au</span>	    
		 <input name="dateff" type="text" id="dateff" value="<?PHP echo $cocl_dateff ?>" size="10" maxlength="10" readonly="1">
		<?PHP if (($signe == FALSE) AND ($td <> "view")) { // On peut modifier la date de fin uniquement si pas signé ?>
        <img src="../img/calendar.png" id="f_img_dateff" title="Choisir votre date" width="16" height="16"> 
		<a href="javascript:;" onclick="document.cocl_maj.dateff.value=''"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a> 
        <span class="annot_petit_it">(ne pas mettre de date de fin pour un contrat 'illimit&eacute;') </span>
		<?PHP } ?>
	</td>
  </tr>
</table>

<!-- Nombre de jours de préavis -->
<table width="800"  border="0">
  <tr>
    <td width="160" class="rubfrm" id="f_preavis"><div align="right">Pr&eacute;avis</div></td>
    <td>
		<?PHP if (($signe == FALSE) AND ($td <> "view")) { // On peut modifier le préavis uniquement si pas signé ?>
		<input name="preavis" type="text" id="preavis" value="<?PHP echo $cocl_preavis ?>" size="3" maxlength="3" align="right"> 
		<span class="annot_std_gras">jours avant date d'&eacute;ch&eacute;ance</span> 
		<?PHP 
			echo "<span class=\"annot_petit_it\">";
			echo "(La valeur doit se trouver entre ".preavis_max()." et ".preavis_min()." jours)";
			echo "</span>";
		?>
			<img src="../img/oblig.gif" width="10" height="11">
		<?PHP		
		} 
		else 
		{?>
		<input name="preavis" type="text" id="preavis" value="<?PHP echo $cocl_preavis ?>" size="3" maxlength="3" align="right" readonly="1"> 
		<span class="annot_std_gras">jours avant date d'&eacute;ch&eacute;ance</span> 
		<?PHP } ?>
	</td>
  </tr>
</table>

<!-- Détail matériel concerné -->
<table width="800"  border="0">
  <tr>
    <td width="160" valign="top" class="rubfrm" id="f_matos"><div align="right">Mat&eacute;riel Concern&eacute; </div></td>
    <td>
	<?PHP 
	// On peut modifier le matériel uniquement si pas signé 
	if (($signe == FALSE) AND ($td <> "view")) 
	{ 
		// On affiche un bouton de récup s'il existe des matériels ou des licences actifs sur relevés
		if ((exist_rlic_actif($cocl_codecli) == TRUE) OR (exist_rpdt_actif($cocl_codecli) == TRUE))
		{
			$url_recuplp = "rlp_lst.php?td=".$td."&cc=".$cocl_codecli."&co=".$cocl_code;
	?>
			<table width="630"  border="0">
			<tr>
				<td>
					<input name="addrlp" type="button" id="addrlp" value="Choisir Mat&eacute;riel/Licences" style="background-color:#FF0000; color:#FFFF00; font-weight:bold;" onClick="fenchoixrel('<?PHP echo $url_recuplp; ?>',1024,600,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');">
					<span class="annot_petit_it">(Cliquer)</span>
				</td>
				<td align="right">
					<input name="modmat" type="button" id="modmat" value="Modifier" onClick="document.cocl_maj.matos.readOnly = false; document.cocl_maj.matos.focus(); this.style.backgroundColor='#00FFFF';">
				</td>
			</tr>
			</table>
			<textarea name="matos" cols="95" rows="20" id="matos" onBlur="document.cocl_majos.mat.readOnly = true; document.cocl_maj.modmat.style.backgroundColor='#CCCCCC';"><?PHP echo $cocl_matos ?></textarea>
			<img src="../img/oblig.gif" width="10" height="11">
	<?PHP 
		}
		else
		{
	?>
			<textarea name="matos" cols="95" rows="20" id="matos"><?PHP echo $cocl_matos ?></textarea>
	<?PHP
		}
	} 
	else
	{
	?>
		<textarea name="matos" cols="95" rows="20" id="matos" readonly="readonly"><?PHP echo $cocl_matos ?></textarea>
	<?PHP 
	} 
	?>
	</td>
  </tr>
</table>

<?PHP if ($td <> "add") { ?>  <!-- Début de zone exclue si création -->
<!-- Signataire du contrat -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_datesig"><div align="right">Sign&eacute; le </div></td>
	<td>
		<input name="datesig" type="text" id="datesig" value="<?PHP echo $cocl_datesigf ?>" size="10" maxlength="10" readonly="1">
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_signe"><div align="right">Sign&eacute; par </div></td>
	<td>
		<input name="signe" type="text" id="signe" value="<?PHP echo $cocl_signe ?>" size="70" maxlength="70" readonly="1">
	</td>
</tr>
</table>

<br>

<!-- Affichage uniquement si le client a été relancé -->
<?PHP if ($cocl_daterelf <> "") { ?>  
<!-- Date de relance du contrat -->
<table width="800"  border="0">
  <tr>
    <td width="160" class="rubfrm" id="f_daterelf"><div align="right">Relanc&eacute; le </div></td>
    <td>
		<input name="daterelf" type="text" id="daterelf" value="<?PHP echo $cocl_daterelf ?>" size="10" maxlength="10" readonly="1">
        <span class="annot_petit_it">
		<?PHP 
			echo "(".$cocl_nivrel." fois)";
		?>
		</span>
	</td>
  </tr>
</table>
<?PHP } ?>

<!-- Affiché uniquement si contrat signé -->
<?PHP if ($cocl_datesigf <> "") { ?>  

<!-- Contrat renouvelé ou pas ? -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_renouv"><div align="right">Renouvel&eacute;</div></td>
	<td>
		<input name="renouv" type="text" id="renouv" value="<?PHP echo $niv_renouv[$cocl_renouv]; ?>" size="3" maxlength="3" readonly="1">
		<span class="annot_std_gras">Nouveau contrat :</span>
		<input name="num" type="text" id="num" value="<?PHP echo $cocl_rnum; ?>" size="20" maxlength="20" readonly="1">
		<?PHP
		$renouv=FALSE;
		if (@$HTTP_SESSION_VARS["niv_log"] >= 4)
		{
			$renouv=TRUE;
			$datemin = nouv_date_moins_jours($cocl_datef,$preavis_mini);
			$datebut = nouv_date_moins_jours($cocl_datef,$cocl_preavis);
			if ($cocl_renouv==0)
			{
				 if (formatedate($cocl_datef) <> "")
				 {
					 // Si non, on ne peut pas proposer le renouvellement
					 if ((comp_date($datemin,$datea) == FALSE) OR (comp_date($datea,$datebut) == FALSE))
						$renouv=FALSE;
				}
			}
			else
			{
				$renouv=FALSE;
			}
		}
				
		if ($renouv==TRUE)
		{
			$url_rencocl="coclren_maj.php?co=".$cocl_code;
		?>
			<a href="<?PHP echo $url_rencocl ?>"><img src="../img/renouv.png" title="Renouveler le contrat" width="22" height="22" border="0" align="absmiddle"></a>
			<a href="<?PHP echo $url_rencocl ?>"> Renouveler le contrat </a>
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- Date de clôture du contrat -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_datefinf"><div align="right">Contrat cl&ocirc;t le </div></td>
	<td>
		<input name="datefinf" type="text" id="datefinf" value="<?PHP echo $cocl_datefinf ?>" size="10" maxlength="10" readonly="1">
	</td>
</tr>
<!-- Fin affiché uniquement si contrat signé -->
<?PHP 
} 
?>  
</table>


<?PHP } ?>  <!-- Fin de zone exclue si création -->

<!-- Montant du contrat -->
<table width="800"  border="0">
<tr>
    <tr>
      <td width="20%" class="rubfrm" id="f_pu"><div align="right">PV HT </div></td>
      <td>
	<?PHP if (($signe == FALSE) AND ($td <> "view")) { // On peut modifier le prix uniquement si pas signé ?>
          <input name="pu" type="text" id="pu" align="right" value="<?PHP echo $cocl_pvht ?>" size="10" maxlength="10"> 
      <img src="../img/oblig.gif" width="10" height="11"><br>
      <span class="annot_std_it">(la d&eacute;cimale doit &ecirc;tre '</span><span class="annot_gras_it">.</span><span class="annot_std_it">' et pas la virgule !)</span> </p>
	<?PHP } else { ?>
          <input name="pu" type="text" id="pu" align="right" value="<?PHP echo $cocl_pvht ?>" size="10" maxlength="10" readonly="1"> 
	<?PHP } ?>
      </td>
    </tr>
</table>


<p align="center">
<?PHP 
if (($td == "edit") or ($td == "add")) // Boutons si en édition ou création
{ 
?>
	<input name="RAZ" type="reset" id="RAZ" value="R&eacute;initialiser">
	<input name="enr" type="submit" id="enr" value="Enregistrer">
	<input name="enrimp" type="submit" id="enrimp" value="Enregistrer &amp; Imprimer">
<?PHP 
} 
?>

<?PHP 
if ($td == "del") // Bouton si en mode suppression
{ 
?>
	<input name="del" type="submit" id="del" value="Supprimer">
<?PHP 
} 
?>
</p>
</form>
	
<?PHP 
if ($td <> "view")
{
	if (($td == "edit") OR ($td == "del"))
	{
		if ($signe <> "")
		{
?>
			<script type="text/javascript">
				Calendar.setup({
					inputField     :    "datefinf",     // id of the input field
					ifFormat       :    "%d-%m-%Y",      // format of the input field
					button         :    "f_img_datefinf",  // trigger for the calendar (button ID)
					align          :    "Ll",           // alignment (defaults to "Bl")
					singleClick    :    true
				});
			</script>
<?PHP
		} 
		else 
		{ 
?>
			<script type="text/javascript">
				Calendar.setup({
					inputField     :    "datedf",     // id of the input field
					ifFormat       :    "%d-%m-%Y",      // format of the input field
					button         :    "f_img_datedf",  // trigger for the calendar (button ID)
					align          :    "Ll",           // alignment (defaults to "Bl")
					singleClick    :    true
				});
				Calendar.setup({
					inputField     :    "dateff",     // id of the input field
					ifFormat       :    "%d-%m-%Y",      // format of the input field
					button         :    "f_img_dateff",  // trigger for the calendar (button ID)
					align          :    "Ll",           // alignment (defaults to "Bl")
					singleClick    :    true
				});
			</script>
<?PHP
		} 
	} 
	else 
	{ 
?>
	  <script type="text/javascript">
		Calendar.setup({
			inputField     :    "datecreaf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_datecreaf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
		Calendar.setup({
			inputField     :    "datedf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_datedf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
		Calendar.setup({
			inputField     :    "dateff",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_dateff",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
	</script>
<?PHP 
	}
} 
?>

<?PHP if ($td == "add") 
{
?>
	<script type="text/javascript">
	warnnbage(<?PHP echo nb_age_actives(); ?>,"cont");
	warnnbtec(<?PHP echo nb_tec_actifs() ?>);
	</script>
<?PHP
}
else
{
	if ($td == "edit")
	{
?>
	<script type="text/javascript">
	warnedit(<?PHP echo $cli_cpta; ?>,"cont");
	</script>
<?PHP
	}
}
?>  

<!-- Fin Affiché uniquement s'il y a un code client -->
<?PHP
}
else
{
?>
	<script type="text/javascript">
	setTimeout("self.location.href=('cli_lst.php');",2000)
	</script>
	<p align="center" class="annot_std_it">Merci de choisir un client...</p>
<?PHP
}
}
else
{
	if ($pbm_cocl==TRUE) 
	{
?>
		<script type="text/javascript">
		setTimeout("self.location.href=('cocl_lst.php?ord=DES&tri=Code');",2000)
		</script>
		<p align="center" class="annot_std_it">Merci de choisir un de vos contrats...</p>
<?PHP
	}
	else
	{
		if (@$HTTP_SESSION_VARS["niv_log"] == 1)
		{
?>
			<script type="text/javascript">
			setTimeout("self.location.href=('index.php');",2000)
			</script>
			<p align="center" class="annot_std_it">Ce n'est pas votre compte...</p>
<?PHP
		}
		if ((@$HTTP_SESSION_VARS["niv_log"] == 4) OR (@$HTTP_SESSION_VARS["niv_log"] == 3))
		{
?>
			<script type="text/javascript">
			setTimeout("self.location.href=('cli_lst.php');",2000)
			</script>
			<p align="center" class="annot_std_it">Merci de choisir un de vos clients...</p>
<?PHP
		}
	}
 }
?>
