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

Version 0.9.9

Copyright (C) 2006-2009  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/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_loc.inc.php");
include_once("../inc/fic_hum.inc.php");
include_once("../inc/fic_st.inc.php");
include_once("../inc/fic_tac.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/fic_zc.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim($_GET['td'])); // Récupération type demande
$tc = intval(strip_tags(trim($_GET['tc']))); // Récupération type client
$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

$nbcontrats = 0;
$pbm_coloc = FALSE;
$coloc_idsite = 0;
$okadd=TRUE;

if (($tc<0) OR ($tc>4))
	$pbm_coloc=TRUE;
	
if ($pbm_coloc==FALSE)
{
	// Niveau <=2 ne peut que voir les contrats
	if (@$_SESSION["niv_log"] <= 2)
		$td = "view";
	
	if ($ca<> "")
	{
		// Contrôle qu'une agence n'essaye pas de "hacker" un contrat
		if (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) AND ($ca <> @$_SESSION["code_age"]))
			$pbm_coloc = TRUE;
	}
	else
	{
		if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
			$ca = @$_SESSION["code_age"];
	}
	
	if ($co <> "")
	{
		// Récupération des informations contrat client
		$row = lit_enr_coloc($co);
		if (is_array($row))
		{
			extract ($row);
			
			// Contrôle si contrat soldé (si tous les produits sont revenus, on force la clôture)
			if (formatedate($coloc_datefin) == "")
			{
				if (all_pdtloc_ret_in_coloc($co,TRUE)==TRUE)
				{
					$coloc_dateclos=lastdate_ret_in_coloc($co,TRUE);
					clot_coloc($co,$coloc_dateclos,TRUE);
				}
			}
				
	
			// Si contrat terminé, force le mode "view"
			if (formatedate($coloc_dateclos) <> "")
				$td="view";
			
			if ($td <> "add")
			{
				// Contrôle qu'un client n'essaye pas de "hacker" un contrat
				if (@$_SESSION["niv_log"] == 1)
				{
					$tab_cli=give_tab_rcli($_SESSION["code_log"],TRUE);
					if (in_array($coloc_codecli,$tab_cli)==FALSE)
						$pbm_coloc = TRUE;
				}
				// Contrôle qu'une agence n'essaye pas de "hacker" un contrat
				if (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) AND ($coloc_codeage <> @$_SESSION["code_age"]))
					$pbm_coloc = TRUE;
			}
		}
		else
			$pbm_coloc = TRUE;
	
		if ($pbm_coloc == FALSE)
		{
			$coloc_datecreaf = formatedate($coloc_datecrea);
			$coloc_datedebf = formatedate($coloc_datedeb);
			$coloc_datefinf = formatedate($coloc_datefin);
			$coloc_dateclosf = formatedate($coloc_dateclos);
	
			if ($td == "edit")
			{
				$cc=$coloc_codecli;
				$ca=$coloc_codeage;
			}
	
			if ($td == "view")
			{
				$cc=$coloc_codecli;
				$ca=$coloc_codeage;
			}
	
			if ($td == "add")
			{
				$coloc_datecreaf = $datef;
				$coloc_datedebf = $datef;
				$coloc_datefinf = "";
				$coloc_dateclosf = "";
				$coloc_code = $co;
				$coloc_codecli = $cc;
				$coloc_codeage = $ca;
				$coloc_sitep = 1;
			}
		}
	}
	else
	{
		if ($td == "add")
		{
			$coloc_datecreaf = $datef;
			$coloc_datedebf = $datef;
			$coloc_datefinf = "";
			$coloc_dateclosf = "";
			$coloc_code = crecodesession("CO");
			$co = $coloc_code;
			$coloc_sitep = 1;
		}
		else
			$pbm_coloc=TRUE;
	}
	
	$pbm_cli=FALSE;
		
	if ($cc <>"")
	{
		// Contrôle qu'un client n'essaye pas de "hacker" un contrat
		if (@$_SESSION["niv_log"] == 1)
		{
			$tab_cli=give_tab_rcli($_SESSION["code_log"],TRUE);
			if (in_array($cc,$tab_cli)==FALSE)
				$pbm_coloc = TRUE;
		}

		switch ($tc)
		{
			case 0 :	
				$row = lit_enr_cli($cc,TRUE);
				if (is_array($row))
				{
					extract ($row);
			
					$coloc_codecli=$cc;
			
					// Contrôle qu'une agence n'essaye pas de "hacker" un contrat
					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;
				break;
			case 1 :	
				$row = lit_enr_age($cc,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$coloc_codecli=$cc;
				}
				else
					$pbm_cli = TRUE;
				break;
			case 2 :	
			case 4 :	
				$row = lit_enr_tec($cc,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$coloc_codecli=$cc;
				}
				else
					$pbm_cli = TRUE;
				break;
			case 3 :	
				$row = lit_enr_st($cc,TRUE);
				if (is_array($row))
				{
					extract ($row);
					$coloc_codecli=$cc;
				}
				else
					$pbm_cli = TRUE;
				break;
			default :
				$pbm_cli = TRUE;
				break;
		}
	}
}

switch ($td)
{
	case "add" :
		$titre = "CREATION CONTRAT LOCATION";
		break;
	case "edit" :
		$titre = "MISE A JOUR CONTRAT LOCATION";
		if (exist_pdt_in_coloc($co)==FALSE) $okadd=FALSE;
		break;
	case "del" :
		$titre = "SUPPRESSION CONTRAT LOCATION";
		break;
	case "view" :
		$titre = "VISUALISATION CONTRAT LOCATION";
		break;
	default :
		$pbm_coloc=TRUE;
		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 - <?PHP echo $title_esp_prive; ?> : Fiche Contrat Location</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 -->

<script language="JavaScript" src="../jscript/coolmenus/coolmenus4.js"></script>

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

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

<!-- Définition Javascript pour calendrier popup -->
  <!-- Feuille de Style -->
  <link rel="stylesheet" type="text/css" media="all" href="../jscript/jscal/skins/aqua/theme.css" title="Aqua" />

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

  <!-- Choix du langage -->
  <script type="text/javascript" src="../jscript/jscal/lang/calendar-<?PHP echo $_SESSION["lng"]; ?>.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="../jscript/jscal/calendar-setup.js"></script>
<!-- Fin de la définition Javascript pour calendrier popup -->

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

<?PHP
if (($td == "add") OR ($td == "edit"))
{
?>
<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:datedebf ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date début ; vmn:<?PHP echo $coloc_datecreaf; ?> ; stok:frmok ; stbad:frmbad",
	"nom:datefinf ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date fin ; vmn:<?PHP echo $coloc_datecreaf; ?> ; stok:frmok ; stbad:frmbad",
<?PHP
		if ((@$_SESSION["niv_log"] <> 4) AND (@$_SESSION["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:<?PHP echo html_entity_decode($txt_chp_age); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
			}
			else
			{
?>
	"nom:codeage ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_age); ?> ; stok:frmok ; stbad:frmbad",
<?PHP
			}
		}
		else
		{
?>
	"nom:codeage ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_age); ?> ; stok:frmok ; stbad:frmbad",
<?PHP
		}
?>
	"nom:ddeur ; format:liste ; req:<?PHP if (($tc==0) OR ($tc==1) OR ($tc==3)) echo "Y"; else echo "N"; ?> ; txt:Contact client ; <?PHP if (($tc==0) OR ($tc==1) OR ($tc==3)) echo "vmn:1;"; ?> stok:frmok ; stbad:frmbad");
var txtval = '<?PHP if ($okadd==TRUE) echo ''; else echo $but_choixprea; ?>';
//-->
</script>
<?PHP
}
?>

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

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

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

<?PHP cre_js_pdtincloc($td,$co,""); ?>

</head>

<?PHP if ($td == "del"){ ?>
<body onload="pdtincloc();warndel();metReadonly();">
<?PHP }
	if ($td == "view"){ ?>
<body onload="pdtincloc();metReadonly();">
<?PHP }
	if ($td == "edit") { ?>
<body onLoad="putvalue_in_id('enr',txtval,false);pdtincloc();metFocus();">
<?PHP }
	if ($td == "add") { ?>
<body onLoad="pdtincloc();metFocus();">
<?PHP }
include_once("../inc/entete.inc.php"); 
?>

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<!-- Affiché uniquement s'il y a un code client -->
<?PHP
if (($pbm_coloc==FALSE) AND ($pbm_cli==FALSE))
{
if ($cc <> "")
{
if (nb_pdtloc()>0)
{
?>
<table width="100%"  border="0">
<tr>
	<td width="33%">
	<p><strong><em><a href="coloc_lst.php?ord=DES&tri=Code"><?PHP echo $txt_lnk_ret_liste; ?></a></em></strong></p>
    </td>
	<td width="33%" valign="top"><div id="oblig" align="center" class="annot_petit_it">(<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> : <?PHP echo $txt_div_saisoblg; ?>)</td>
	<td width="33%" align="right">&nbsp;
	
	</td>
</tr>
	<td width="33%">&nbsp;</td>
	<td width="33%" valign="top">&nbsp;</td>
	<td width="33%" align="right">
		<?PHP
		if ((($td == "edit") OR ($td == "view")) AND ($_SESSION["niv_log"]<>1))
		{
		?>
		<span id="affsel" style="visibility:visible">
		<select name="etats" size="1" id="etats" onChange="javascript:; lanceimp(this.value); this.value='';" class="annot_petit">
		<option value="" selected>&raquo; Etats &laquo;</option>
		<?PHP
		if (@$_SESSION["niv_log"]<>2)
		{
			$urlimp = "coloc_pdf.php?cl=".$coloc_code;
			echo "<option value=\"".$urlimp."\"  class=\"icone\" style=\"background-image: url(../img/sel_coloc.gif);\">Contrat</option>\n";
		}
		?>		
		</select>
		</span>
		<?PHP } else { ?>
		&nbsp;
		<?PHP } ?>
	</td>
<tr>
</tr>
</table>

<form name="coloc_maj" method="post" action="coloc_enr.php" onSubmit="javascript:; return (verif_coloc(this,tab1_champ,'','<?PHP echo $_SESSION["lng"]; ?>'));">
<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
<input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
<input name="tc" type="hidden" id="tc" value="<?PHP echo $tc ?>">
<input name="codecli" type="hidden" id="codecli" value="<?PHP echo $coloc_codecli ?>">
<input name="prev" type="hidden" id="prev" value="<?PHP echo $cli_prev ?>">
<input name="idsite" type="hidden" id="idsite" value="<?PHP echo $coloc_idsite ?>">
<input name="dateclosf" type="hidden" id="dateclosf" value="<?PHP echo formatedate($coloc_dateclos); ?>">
<?PHP if ($td == "add") { ?>
	<input name="code" type="hidden" id="code" value="<?PHP echo $coloc_code ?>">
	<input name="num" type="hidden" id="num" value="">
<?PHP } ?>

<!-- Code du contrat client (affiché uniquement si édition ou suppression) -->
<?PHP if ($td <> "add") {?>
<table width="100%"  border="0">
<tr>
	<td width="250" class="rubfrm" id="f_codecocl" align="right">Code </td>
	<td>
		<input name="code" type="text" id="code" value="<?PHP echo $coloc_code ?>" size="20" maxlength="20" readonly="1">
		<?PHP
		if ($coloc_dateclosf <> "")
		{
			echo '<span class="alerte1">';
			echo 'Termin&eacute;';
			echo '</span>';
		}
		?>
	</td>
	<td align="right">
	<?PHP
	if (((@$_SESSION["niv_log"] ==5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) AND ($td=="edit"))
	{
		echo '<span id="strtac" style="visibility:visible">';
		$nb_tac=nb_tac(3,$coloc_code,TRUE);
		if ($nb_tac>0)
		{
			echo "<span class=\"annot_petit_it\">";
			echo "( ".$nb_tac." t&acirc;che";
			if ($nb_ot>1)
				echo"s";
			$nb_tac_actives=nb_tac_actives(3,$coloc_code,TRUE);
			if ($nb_tac_actives>0)
				echo ", dont ".$nb_tac_actives." non termin&eacute;e";
			if ($nb_tac_actives>1)
				echo "s";
			echo")";
			echo "</span>";
		}
		else
		{
			echo "<span class=\"annot_petit_gras\">";
			echo "T&acirc;ches : ";
			echo "</span>";
		}
		echo '</span>';

	?>
		<select class="annot_petit" name="tac" size="1" id="tac" onChange="javascript:; document.location.href=this.value">
		<option value="" class="annot_petit">--- Faites votre choix ---</option>
		<?PHP if ($nb_tac>0) { ?>
		<option value="<?PHP echo "tac_lst.php?ord=DES&tri=Code&fi=5&search=".$coloc_code;?>" class="annot_petit">Voir les tâches</option>
		<?PHP } ?>
		<option value="<?PHP echo "tac_maj.php?td=add&tr=3&cr=".$coloc_code;?>" class="annot_petit">Ajouter tâche</option>
		</select>
	<?PHP
	}
	else
		echo "&nbsp;";
	?>
	</td>
</tr>
</table>
<?PHP }  ?>

<!-- Date de création -->
<table width="100%"  border="0">
<tr>
	<td width="250" class="rubfrm" id="f_datecreaf" align="right">Date Cr&eacute;ation </td>
	<td>
		<input name="datecreaf" type="text" id="datecreaf" value="<?PHP echo $coloc_datecreaf ?>" size="10" maxlength="10" readonly="1">
	</td>
</tr>
</table>

<?PHP if ($td<>"add") {
$tab_pn=prenom_nom_compte($coloc_codecrea,TRUE);
?>
<!-- Créé par...-->
<table width="100%"  border="0">
<tr>
	<td width="250" class="rubfrm" id="f_codecrea" align="right">Cr&eacute;&eacute; par </td>
	<td>
		<input name="codecrea" type="text" id="codecrea" value="<?PHP echo $tab_pn["prenom"]." ".$tab_pn["nom"]." (".$tab_niv_full[$tab_pn["level"]].")" ?>" size="100"readonly="1">
	</td>
</tr>
</table>
<?PHP } ?>
<!-- Date de début du contrat -->
<table width="100%"  border="0">
<tr>
	<td width="250" class="rubfrm" id="f_datefinf" align="right">D&eacute;but  le </td>
	<td>
		<input name="datedebf" type="text" id="datedebf" value="<?PHP echo $coloc_datedebf ?>" size="10" maxlength="10" readonly="1">
		<?PHP if ($td == "add")  { ?>
		<span id="affchxdd" style="visibility:visible">
		<img src="../img/calendar.png" align="absmiddle" id="f_img_datedebf" title="<?PHP echo $alt_chxdate; ?>">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<br /><span class="annot_petit_it">(Au moins date de cr&eacute;ation)</span>
		</span>
		<?PHP } ?>
	</td>
</tr>
</table>

<!-- Date de fin du contrat -->
<table width="100%"  border="0">
<tr>
	<td width="250" class="rubfrm" id="f_datefinf" align="right">Fin pr&eacute;vue le</td>
	<td>
		<input name="datefinf" type="text" id="datefinf" value="<?PHP echo $coloc_datefinf ?>" size="10" maxlength="10" readonly="1">
		<?PHP if ($td == "add") { ?>
		<span id="affchxdf" style="visibility:visible">
		<img src="../img/calendar.png" align="absmiddle" id="f_img_datefinf" title="<?PHP echo $alt_chxdate; ?>">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<br /><span class="annot_petit_it">(Au moins date de d&eacute;but)</span>
		</span>
		<?PHP } ?>
	</td>
</tr>
</table>
<!-- Affichage du client -->
<table width="100%" border="0">
<tr>
	<td class="rubfrm" id="f_codecli" align="center">
	<?PHP
	switch ($tc)
	{
		case 0 :
			echo "Client";
			if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
				echo " <img src=\"../img/".$ico_cpta[$cli_cpta]."\" title =\"".$mess_cpta[$cli_cpta]."\" border=\"0\" align=\"absmiddle\">";
			break;
		case 1 :
			echo "Agence";
			break;
		case 2 :
			echo "Technicien agence";
			break;
		case 3 :
			echo "Sous-traitant";
			break;
		case 4 :
			echo "Technicien sous-traitant";
			break;
		default :
			echo "&nbsp;";
			break;
	}
	?>
	</td>
</tr>
</table>

<!-- Détails client -->
<table width="100%"  border="0">
<tr>
	<td class="rubfrm" width="45%" align="center" valign="bottom" class="ent_clisite">
	<?PHP
	switch ($tc)
	{
		case 0 :
			echo "Compte client";
			break;
		case 1 :
			echo "Compte agence";
			break;
		case 2 :
		case 4 :
			echo "Compte technicien";
			break;
		case 3 :
			echo "Compte sous-traitant";
			break;
		default :
			echo "&nbsp;";
			break;
	}
	?>
	</td>
	<?PHP
	$tab_td='<td align="center" valign="bottom" class="ent_clisite"';
	switch ($tc)
	{
		case 0 :
			if (($td=="add") AND ($cli_ste<>"") AND (@$_SESSION["niv_log"] <> 2))
			{
				if (nb_scli_actifs($coloc_codecli,"",TRUE)>0) 
				{
					$tab_td.= ' onclick="javascript:; fen_sites_coloc(document.coloc_maj.codecli.value,document.coloc_maj.td.value,document.coloc_maj.code.value,document.coloc_maj.idsite.value);"';
					$tab_td.= ' onMouseOver="this.style.cursor=\'pointer\'"';
				}
			}
			break;
		default :
			break;
	}
	$tab_td.='>';
	echo $tab_td;
	switch ($tc)
	{
		case 0 :
			echo "Site qui loue";
			if (($td=="add") AND ($cli_ste<>"") AND (@$_SESSION["niv_log"] <> 2))
			{
				if (nb_scli_actifs($coloc_codecli,"",TRUE)>0)
				{
					echo '<div id="choixsiteoui" style="display:block">';
					echo '<div id="choixsitenon" style="display:none">';
				}
				else
				{
					echo '<div id="choixsiteoui" style="display:none">';
					echo '<div id="choixsitenon" style="display:block">';
				}
				echo '<img src="../img/sites.png" title="Choisir un site" border="0" align="bottom">';
				echo '</div>';
			}
			break;
		default :
			echo "&nbsp;";
			break;
	}
	?>
	</td>
	<td width="30" valign="top">&nbsp;</td>
</tr>
<tr>
	<td width="45%" valign="top" bgcolor="#C5CED7">
	<?PHP
	echo "<span class=\"annot_std_gras\">";
	switch ($tc)
	{
		case 0 :
			if ($cli_ste <>"") 
				echo $cli_ste."<br>";
			else
				echo $cli_civilite." ".$cli_prenom." ".$cli_nom."<br>";
			echo "</span>";
			echo $cli_adr1."<br />";
			if ($cli_adr2 <>"") 
				echo $cli_adr2."<br />";
			echo Retournecp_openId($cli_ville,TRUE)." ".Retourneville_openId($cli_ville,TRUE)."<br />";
			$chemin_imagesco = $chemin_images."/telc.png"; 
			echo "<img src=\"".$chemin_imagesco."\" align=\"bottom\">";
			echo " ".$cli_telf."<br>";
			break;
		case 1 :
			echo $age_nom."<br>";
			echo "</span>";
			echo $age_adr1."<br />";
			if ($age_adr2 <>"") 
				echo $age_adr2."<br />";
			echo Retournecp_openId($age_ville,TRUE)." ".Retourneville_openId($age_ville,TRUE)."<br />";
			$chemin_imagesco = $chemin_images."/telc.png"; 
			echo "<img src=\"".$chemin_imagesco."\" align=\"bottom\">";
			echo " ".$age_telf."<br>";
			break;
		case 2 :
		case 4 :
			echo $tec_civilite." ".$tec_prenom." ".$tec_nom."<br>";
			echo "</span>";
			echo $tec_adr1."<br />";
			if ($tec_adr2 <>"") 
				echo $tec_adr2."<br />";
			echo Retournecp_openId($tec_ville,TRUE)." ".Retourneville_openId($tec_ville,TRUE)."<br />";
			$chemin_imagesco = $chemin_images."/telc.png"; 
			echo "<img src=\"".$chemin_imagesco."\" align=\"bottom\">";
			echo " ".$tec_telf."<br>";
			break;
		case 3 :
			echo $st_nom."<br>";
			echo "</span>";
			echo $st_adr1."<br />";
			if ($st_adr2 <>"") 
				echo $st_adr2."<br />";
			echo Retournecp_openId($st_ville,TRUE)." ".Retourneville_openId($st_ville,TRUE)."<br />";
			$chemin_imagesco = $chemin_images."/telc.png"; 
			echo "<img src=\"".$chemin_imagesco."\" align=\"bottom\">";
			echo " ".$st_telf."<br>";
			break;
		default :
			echo "&nbsp;";
			break;
	}
	?>
	</td>
	<?PHP
	echo '<td valign="top" bgcolor="#C5CED7"';
	switch ($tc)
	{
		case 0 :
			if (($td=="add") AND ($cli_ste<>"") AND (@$_SESSION["niv_log"] <> 2))
			{
				if (nb_scli_actifs($coloc_codecli,"",TRUE)>0)
				{
					echo 'onclick="javascript:; fen_sites_coloc(document.coloc_maj.codecli.value,document.coloc_maj.td.value,document.coloc_maj.code.value,document.coloc_maj.idsite.value);"';
					echo 'onMouseOver="this.style.cursor=\'pointer\'"';
				}
			}
			break;
		default :
			break;
	}
	echo '>';
	switch ($tc)
	{
		case 0 :
			echo '<div id="nomsite">';
			echo nom_scli($coloc_idsite,TRUE,TRUE,FALSE);
			echo '</div>';
			break;
		default :
			echo "&nbsp;";
			break;
	}
	?>
	</td>
	<td width="30" valign="top">
	<?PHP
	switch ($tc)
	{
		case 0 :
			if (@$_SESSION["niv_log"] >= 3)
			{
				$url_affnotesc = "aff_notesc.php?cc=".$cc;
				echo '<a href="javascript:;" onclick="fensaisie(\''.$url_affnotesc.'\',930,380,\'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no\');")>';
				echo '<img src="../img/eye.png" border="0" align="absmiddle">';
				echo ' Notes</a>';
				
			}
			else
				echo "&nbsp;";
			break;
		default :
			echo "&nbsp;";
			break;
	}
	?>
	</td>
</tr>
</table>

<?PHP if (($tc==0) OR ($tc==1) OR ($tc==3)) { ?>
<!-- Demandeur -->
<table width="100%"  border="0">
<tr>
	<td width="250" class="rubfrm" id="f_ddeur" align="right">
	<?PHP
	switch ($tc)
	{
		case 0 :
			echo "Contact client";
			break;
		case 1 :
			echo "Contact agence";
			break;
		case 3 :
			echo "Contact sous-traitant";
			break;
		default :
			echo "&nbsp;";
			break;
	}
	?>	
	</td>
	<td>
		<?PHP
		if (($td =="add") OR ($td =="edit"))  // Ajout ou édition = zone modifiable (on peut choisir un contact)
		{ 
			if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
			{
				switch ($tc)
				{
					case 0 :
						if ($cli_ste <>"")
						{
							// Création de la liste des contacts du client
							echo '<select name="ddeur" id="ddeur">';
							echo "<option>-- Choisissez un  contact --</option>";
							$txt_ccli = $cli_nom." ".$cli_prenom." (Contact principal";
							$txt_ccli.= " - ".$cli_telf.")";
							echo '<option value="-1"';
							if (intval($coloc_ddeur) == -1)
								echo ' selected';
							echo '>'.$txt_ccli.'</option>';
							$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
							mysql_select_db(DBNAME);
		
							// Données site client
							if (intval($coloc_idsite)>0)
							{
								$rech = "SELECT * FROM `" .TBSCLI. "` WHERE `scli_id` = '$coloc_idsite'";
								$rs = mysql_query($rech)or die(mysql_error());
								if ($resultat = mysql_fetch_array($rs)) 
								{
									extract($resultat);
									$txt_ccli = $scli_rnom." ".$scli_rprenom." (Contact site";
									$txt_ccli = " - ".$scli_telf.")";
									echo '<option value="0"';
									if (intval($coloc_ddeur) == 0)
										echo ' selected';
									echo '>'.$txt_ccli.'</option>';
								}
								mysql_free_result($rs);
							}
							// Filtre sur client
							$rech = "SELECT * FROM ".TBCCLI." WHERE `ccli_codecli` = '".$cli_code."' ORDER BY ccli_nom";
							$rs = mysql_query($rech) or die(mysql_error());
							if (mysql_num_rows($rs) <> 0)
							{
								while ($resultat = mysql_fetch_array($rs)) 
								{
									extract($resultat);
					
									$txt_ccli = $ccli_nom." ".$ccli_prenom;
									$row2=lit_enr_fonc($ccli_codefonc,FALSE);
									if (is_array($row2))
									{
										extract($row2);
										$txt_fonc=$fonc_desc;
									}
									else
										$txt_fonc=$ccli_codefonc;
									$txt_ccli.=" (".$txt_fonc;
									$txt_ccli.= " - ".$ccli_telf.")";
									echo '<option value="'.$ccli_id.'"';
									if ($coloc_ddeur == $ccli_id)
										echo ' selected';
									echo '>'.$txt_ccli.'</option>';
								}
							}
							mysql_free_result($rs);
							mysql_close($conn);
							echo '</select>';
							echo '<img src="../img/oblig.png" align="absmiddle" alt="'.$alt_chp_oblig.'">';
						?>
							<a href="javascript:;" onclick="fen_ccli_coloc('<?PHP echo $cli_code; ?>');"><img src="../img/ctacts.png" border="0" align="absmiddle"></a>
							<a href="javascript:;" onclick="fen_ccli_coloc('<?PHP echo $cli_code; ?>');"> Ajouter un contact </a>
						<?PHP
						}
						else
						{
							$txt_ccli="";
							$row = lit_enr_ccli_id_in_cli($coloc_ddeur,$cli_code);
							if (is_array($row))
							{
								extract ($row);
								$txt_ccli = $ccli_nom." ".$ccli_prenom;
								$row2=lit_enr_fonc($ccli_codefonc,FALSE);
								if (is_array($row2))
								{
									extract($row2);
									$txt_fonc=$fonc_desc;
								}
								else
									$txt_fonc=$ccli_codefonc;
								$txt_ccli.=" (".$txt_fonc;
								$txt_ccli.= " - ".$ccli_telf.")";
							}
							else
								$txt_ccli="Pas de contact";
						?>
						<input name="ddeur" type="hidden" id="ddeur" value="<?PHP echo $coloc_ddeur; ?>">
						<input name="nddeur" type="text" id="nddeur" value="<?PHP echo $txt_ccli; ?>" size="100" maxlength="100" readonly="1">
					<?PHP
						}
						break;
					case 1 :
						// Création de la liste des contacts de l'agence
						echo '<select name="ddeur" id="ddeur">';
						echo "<option>-- Choisissez un  contact --</option>";
						$txt_ccli = $age_resp_nom." ".$age_resp_prenom." (Contact principal";
						$txt_ccli.= " - ".$age_resp_telf.")";
						echo '<option value="-1"';
						if (intval($coloc_ddeur) == -1)
							echo ' selected';
						echo '>'.$txt_ccli.'</option>';
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
	
						// Filtre sur client
						$rech = "SELECT * FROM ".TBCAGE." WHERE `cage_codeage` = '".$cc."' ORDER BY cage_nom";
						$rs = mysql_query($rech) or die(mysql_error());
						if (mysql_num_rows($rs) <> 0)
						{
							while ($resultat = mysql_fetch_array($rs)) 
							{
								extract($resultat);
				
								$txt_ccli = $cage_nom." ".$cage_prenom;
								$row2=lit_enr_fonc($cage_codefonc,FALSE);
								if (is_array($row2))
								{
									extract($row2);
									$txt_fonc=$fonc_desc;
								}
								else
									$txt_fonc=$cage_codefonc;
								$txt_ccli.=" (".$txt_fonc;
								$txt_ccli.= " - ".$cage_telf.")";
								echo '<option value="'.$cage_id.'"';
								if ($coloc_ddeur == $cage_id)
									echo ' selected';
								echo '>'.$txt_ccli.'</option>';
							}
						}
						mysql_free_result($rs);
						mysql_close($conn);
						echo '</select>';
						echo '<img src="../img/oblig.png" align="absmiddle" alt="'.$alt_chp_oblig.'">';
						break;
					case 3 :
						// Création de la liste des contacts du sous-traitant
						echo '<select name="ddeur" id="ddeur">';
						echo "<option>-- Choisissez un  contact --</option>";
						$txt_ccli = $st_resp_nom." ".$st_resp_prenom." (Contact principal";
						$txt_ccli.= " - ".$st_resp_telf.")";
						echo '<option value="-1"';
						if (intval($coloc_ddeur) == -1)
							echo ' selected';
						echo '>'.$txt_ccli.'</option>';
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
	
						// Filtre sur sous-traitant
						$rech = "SELECT * FROM ".TBCST." WHERE `cst_codest` = '".$cc."' ORDER BY cst_nom";
						$rs = mysql_query($rech) or die(mysql_error());
						if (mysql_num_rows($rs) <> 0)
						{
							while ($resultat = mysql_fetch_array($rs)) 
							{
								extract($resultat);
				
								$txt_ccli = $cst_nom." ".$cst_prenom;
								$row2=lit_enr_fonc($cst_codefonc,FALSE);
								if (is_array($row2))
								{
									extract($row2);
									$txt_fonc=$fonc_desc;
								}
								else
									$txt_fonc=$cst_codefonc;
								$txt_ccli.=" (".$txt_fonc;
								$txt_ccli.= " - ".$cst_telf.")";
								echo '<option value="'.$cst_id.'"';
								if ($coloc_ddeur == $cst_id)
									echo ' selected';
								echo '>'.$txt_ccli.'</option>';
							}
						}
						mysql_free_result($rs);
						mysql_close($conn);
						echo '</select>';
						echo '<img src="../img/oblig.png" align="absmiddle" alt="'.$alt_chp_oblig.'">';
						break;
				}
			}
			else
			{
				$txt_ccli="Pas de contact";
				switch ($tc)
				{
					case 0 :
						$row = lit_enr_ccli_id_in_cli($coloc_ddeur,$cli_code);
						if (is_array($row))
						{
							extract ($row);
							$row2=lit_enr_fonc($ccli_codefonc,TRUE);
							if (is_array($row2))
							{
								extract($row2);
								$txt_fonc=$fonc_desc;
							}
							else
								$txt_fonc=$ccli_codefonc;
							$txt_ccli = $ccli_nom." ".$ccli_prenom." (".$txt_fonc;
							$txt_ccli.= " - ".$ccli_telf.")";
						}
						break;
					case 1 :
						$row = lit_enr_cage_id_in_age($coloc_ddeur,$cc);
						if (is_array($row))
						{
							extract ($row);
							$row2=lit_enr_fonc($cage_codefonc,TRUE);
							if (is_array($row2))
							{
								extract($row2);
								$txt_fonc=$fonc_desc;
							}
							else
								$txt_fonc=$cage_codefonc;
							$txt_ccli = $cage_nom." ".$cage_prenom." (".$txt_fonc;
							$txt_ccli.= " - ".$cage_telf.")";
						}
						break;
					case 3 :
						$row = lit_enr_cst_id_in_st($coloc_ddeur,$cc);
						if (is_array($row))
						{
							extract ($row);
							$row2=lit_enr_fonc($cst_codefonc,TRUE);
							if (is_array($row2))
							{
								extract($row2);
								$txt_fonc=$fonc_desc;
							}
							else
								$txt_fonc=$cst_codefonc;
							$txt_ccli = $cst_nom." ".$cst_prenom." (".$txt_fonc;
							$txt_ccli.= " - ".$cst_telf.")";
						}
						break;
				}
			?>
				<input name="nddeur" type="text" id="nddeur" value="<?PHP echo $txt_ccli; ?>" size="100" maxlength="100" readonly="1">
			<?PHP
			}	
		} 
		else  // Vue ou suppression = zone non modifiable (affichage seul)
		{
			$txt_ccli="Pas de contact";
			switch ($tc)
			{
				case 0 :
					$row = lit_enr_ccli_id_in_cli($coloc_ddeur,$cli_code);
					if (is_array($row))
					{
						extract ($row);
						$row2=lit_enr_fonc($ccli_codefonc,TRUE);
						if (is_array($row2))
						{
							extract($row2);
							$txt_fonc=$fonc_desc;
						}
						else
							$txt_fonc=$ccli_codefonc;
						$txt_ccli = $ccli_nom." ".$ccli_prenom." (".$txt_fonc;
						$txt_ccli.= " - ".$ccli_telf.")";
					}
					break;
				case 1 :
					$row = lit_enr_cage_id_in_age($coloc_ddeur,$cc);
					if (is_array($row))
					{
						extract ($row);
						$row2=lit_enr_fonc($cage_codefonc,TRUE);
						if (is_array($row2))
						{
							extract($row2);
							$txt_fonc=$fonc_desc;
						}
						else
							$txt_fonc=$cage_codefonc;
						$txt_ccli = $cage_nom." ".$cage_prenom." (".$txt_fonc;
						$txt_ccli.= " - ".$cage_telf.")";
					}
					break;
				case 3 :
					$row = lit_enr_cst_id_in_st($coloc_ddeur,$cc);
					if (is_array($row))
					{
						extract ($row);
						$row2=lit_enr_fonc($cst_codefonc,TRUE);
						if (is_array($row2))
						{
							extract($row2);
							$txt_fonc=$fonc_desc;
						}
						else
							$txt_fonc=$cst_codefonc;
						$txt_ccli = $cst_nom." ".$cst_prenom." (".$txt_fonc;
						$txt_ccli.= " - ".$cst_telf.")";
					}
					break;
			}
		?>
		<input name="nddeur" type="text" id="nddeur" value="<?PHP echo $txt_ccli; ?>" size="100" maxlength="100" readonly="1">
		<?PHP 
		} 
		?>
		<br /><span class="annot_petit_it">(Celui qui prend le mat&eacute;riel)</span>
	</td>
</tr>
</table>
<?PHP } else
	echo '<input name="ddeur" type="hidden" id="ddeur" value="">';
?>

<!-- Code de l'agence (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
<table width="100%"  border="0">
<tr>
	<td width="250" class="rubfrm" id="f_agence" align="right">Agence qui loue</td>
	<td>
		<?PHP
		if ($td =="add")  // Ajout = zone modifiable (on peut choisir une agence)
		{ 
			if ((@$_SESSION["niv_log"] <> 4) AND (@$_SESSION["niv_log"] <> 3))
			{
				switch ($tc)
				{
					case 0 :
						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' AND `age_codepays` = '".$cli_codepays."' ORDER BY age_nom";
							$rs = mysql_query($rech) or die(mysql_error());
							if (mysql_num_rows($rs) <> 0)
							{
							?>
								<select name="codeage" id="codeage">
								<?PHP
									echo "<option value=\"\">".$sel_lst_age."</option>";
									while ($resultat = mysql_fetch_array($rs)) 
									{
										extract($resultat);
										if (dep_in_zcc_age_open($cli_dep,$cli_codepays,$age_code,FALSE))
										{
											$age_nomcode = $age_nom." (".$age_code.")";
											if ($coloc_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.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
						<?PHP
						}
						else
						{
							$row = lit_enr_age($cli_prop,TRUE);
							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
						}
						break;
					case 1 :
						// Création de la liste des agences ouvertes (sauf celle qui est demandeuse)
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
						$rech = "SELECT * FROM ".TBAGE." WHERE `age_ouvert` = '1' AND `age_code` <> '".$cc."' ORDER BY age_nom";
						$rs = mysql_query($rech) or die(mysql_error());
						if (mysql_num_rows($rs) <> 0)
						{
						?>
							<select name="codeage" id="codeage">
							<?PHP
								echo "<option value=\"\">".$sel_lst_age."</option>";
								while ($resultat = mysql_fetch_array($rs)) 
								{
									extract($resultat);
									$age_nomcode = $age_nom." (".$age_code.")";
									if ($coloc_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.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
						<?PHP
						break;
					case 2 :
					case 3 :
					case 4 :
						// Création de la liste des agences ouvertes
						$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) or die(mysql_error());
						if (mysql_num_rows($rs) <> 0)
						{
						?>
							<select name="codeage" id="codeage">
							<?PHP
								echo "<option value=\"\">".$sel_lst_age."</option>";
								while ($resultat = mysql_fetch_array($rs)) 
								{
									extract($resultat);
									$age_nomcode = $age_nom." (".$age_code.")";
									if ($coloc_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.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
						<?PHP
						break;
				}
			}
			else
			{
				$row = lit_enr_age($_SESSION["code_age"],TRUE);
				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($coloc_codeage,TRUE);
			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>

<?PHP if ($td <> "add") { ?>
<table width="100%"  border="0">
<tr>
	<td colspan="2" class="rubfrm">
	<div align="center">Articles r&eacute;serv&eacute;s ou lou&eacute;s</div>
	</td>
</tr>
</table>
<?PHP } ?>
<div id="pdtincloc"></div>

<!-- Lien d'ajout d'article -->
<?PHP
if (($td == "edit") AND (@$_SESSION["niv_log"] <> 1) AND (formatedate($coloc_dateclos)==""))
{
	$urlchoixart = "pdtloc_lst.php?ta=l&td=".$td."&tc=".$tc."&cc=".$coloc_codecli."&cl=".$coloc_code."&ca=".$coloc_codeage."&dd=".$coloc_datedebf."&df=".$coloc_datefinf."&fi=1";

?>
	<table border="0" width="100%">
	<tr>
		<td width="50%">
			<a href="javascript:;" onclick="fensaisie('<?PHP echo $urlchoixart; ?>',900,500,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/add.png" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="fensaisie('<?PHP echo $urlchoixart; ?>',900,500,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');")> Ajouter un article</a>
		</td>
		<td width="50%">&nbsp;
		
		</td>
	</tr>
	</table>			
<?PHP
}
?>

<p align="center">
<?PHP 
if (($td == "edit") or ($td == "add")) // Boutons si en édition ou création
{ 
?>
	<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
<?PHP if ($td=="edit") { ?>
	<input name="enr" type="submit" <?PHP if ($okadd==FALSE) echo 'class="bton_fmarr_dis"'; else echo 'class="bton_std"'; ?> id="enr" value="<?PHP echo $but_enr; ?>" <?PHP if ($okadd==FALSE) echo 'disabled="disabled"'; ?>>
	<input name="enrimp" type="submit"  <?PHP if ($okadd==FALSE) echo 'class="bton_fmarr_dis"'; else echo 'class="bton_std"'; ?> id="enrimp" value="<?PHP echo $but_enrimp; ?>"  <?PHP if ($okadd==FALSE) echo 'disabled="disabled"'; ?>>
<?PHP } else { ?>
	<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_enr; ?>">
<?PHP 
	}
}
if ($td == "del") // Bouton si en mode suppression
{ 
?>
	<input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo $but_del; ?>">
<?PHP 
} 
?>
</p>
</form>
	
<script type="text/javascript">
<!--
<?PHP
if ($td == "add")
{
?>
Calendar.setup({
	inputField     :    "datedebf",     // id of the input field
	ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
	button         :    "f_img_datedebf",  // trigger for the calendar (button ID)
	align          :    "Br",           // alignment (defaults to "Bl")
	electric	   :	false,
	singleClick    :    true
});
Calendar.setup({
	inputField     :    "datefinf",     // id of the input field
	ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
	button         :    "f_img_datefinf",  // trigger for the calendar (button ID)
	align          :    "Br",           // alignment (defaults to "Bl")
	electric	   :	false,
	singleClick    :    true
});
<?PHP
}
?>
//-->
</script>

<?PHP
if ($td == "add") 
{
?>
	<script type="text/javascript">
	<!--
	warnnbage(<?PHP echo nb_age_actives(); ?>,"loc");
	//-->
	</script>
<?PHP
}
else
{
	if (($td == "edit") AND ($tc==0))
	{
?>
	<script type="text/javascript">
	<!--
	warncpta(<?PHP echo $cli_cpta; ?>,"loc");
	//-->
	</script>
<?PHP
	}
}
}
else
{
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('<?PHP if (@$_SESSION["niv_log"] == 3) echo "index.php"; else echo "pdtloc_lst.php?ta=m"; ?>');",2000)
	//-->
	</script>
	<p align="center" class="annot_std_it">Aucun produit &agrave; louer n'a &eacute;t&eacute; cr&eacute;&eacute;...</p>
<?PHP
}
?>  

<!-- Fin Affiché uniquement s'il y a un code client -->
<?PHP
}
else
{
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('cli_lst.php&td=loc');",2000)
	//-->
	</script>
	<p align="center" class="annot_std_it">Merci de choisir un client...</p>
<?PHP
}
}
else
	aff_ret_pbm_auto("coloc_lst.php?ord=DES&tri=Code",2000);
include_once("pied.php");
?>
