<?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_mque.inc.php");
include_once("../inc/fic_ret.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
$ce = strip_tags(trim($_GET['ce'])); // Récupération code Envoi
$cm = strip_tags(trim($_GET['cm'])); // Récupération code Marque
$ca = strip_tags(trim($_GET['ca'])); // Récupération code Agence

$pbm_rete = FALSE;
$nbartrete = 0;

if ($ca<> "")
{
	// Contrôle qu'une agence n'essaye pas de "hacker" un contrat
	if ((@$_SESSION["niv_log"] == 4) AND ($ca <> @$_SESSION["code_age"]))
		$pbm_rete = TRUE;
	$rete_codeage=$ca;
}

if ($ce <> "")
{
	// Vérification qu'il existe bien des articles dans l'intervention
	$nbartrete = nb_art_in_envoi($ce,TRUE);

	// Récupération des informations envoi
	$row = lit_enr_rete($ce,TRUE);
	if (is_array($row))
	{
		extract ($row);
		
		$row=lit_enr_mque($rete_codemque,TRUE);
		if (is_array($row))
		{
			extract ($row);
			
			if ($td <> "add")
			{
				// Contrôle qu'une agence n'essaye pas de "hacker" un envoi
				if ((@$_SESSION["niv_log"] == 4) AND ($rete_codeage <> @$_SESSION["code_age"]))
					$pbm_rete = TRUE;
			}
	
			// Formatage des dates en français
			$rete_datecreaf = formatedate($rete_datecrea);
			$rete_dateenvf = formatedate($rete_dateenv);
			
			// Si envoi soldé, on force le mode "view"
			if ((envoi_solde($rete_code,TRUE)==TRUE) OR ($rete_clos==1))
				$td="view";
	
			if ($td == "edit")
			{
				$cm=$rete_codemque;
				$ca=$rete_codeage;
			}
	
			if ($td == "add")
			{
				$rete_datecreaf = $datef;
				$rete_dateenvf = $datef;
				$rete_code = $ce;
				$rete_codemque = $cm;
				$rete_codeage = $ca;
				$rete_nbcol = 1;
			}
		}
		else
			$pbm_rete = TRUE;
	}
	else
		$pbm_rete = TRUE;
}
else
{
	if ($td == "add")
	{
		$row=lit_enr_mque($cm,TRUE);
		if (is_array($row))
		{
			extract ($row);
			
			$rete_datecreaf = $datef;
			$rete_dateenvf = $datef;
			$rete_code = crecodesession("ER");
			$rete_codemque = $cm;
			$rete_nbcol = 1;
			$ce = $rete_code;
		}
		else
			$pbm_rete=TRUE;
	}
	else
		$pbm_rete=TRUE;
}

switch ($td)
{
	case "add" :
		$titre = "SAISIE FICHE DE RENVOI";
		break;
	case "edit" :
		$titre = "MISE A JOUR FICHE DE RENVOI";
		break;
	case "view" :
		$titre = "VISUALISATION FICHE DE RENVOI";
		break;
	case "del":
		$titre = "SUPPRESSION FICHE DE RENVOI";
		break;
	default:
		$titre = "PROBLEME";
		$pbm_rete=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 envoi de produits</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>

<!-- Scripts Javascript pour vérifications de formulaire -->
<script language="JavaScript" src="../jscript/verif_form.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 == "edit")  OR ($td=="add"))
{
?>
<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:datecreaf ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date demande ; stok:frmok ; stbad:frmbad",
	"nom:dateenvf ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date demande ; stok:frmok ; stbad:frmbad",
	"nom:codemque; format:liste ; req:Y ; txt:Destinataire ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
	if ((@$_SESSION["niv_log"] <> 4) AND (@$_SESSION["niv_log"] <> 3))
	{
?>
	"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
	}
?>
	"nom:codeme; format:liste ; req:Y ; txt:Moyen d'expédition ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:bord; format:txt ; req:N ; txt:Numéro de bordereau ; stok:frmok ; stbad:frmbad",
	"nom:nbcol; format:unsigned ; req:Y ; txt:Nombre de colis ; vmn:1 ; stok:frmok ; stbad:frmbad");
//-->
</script>
<?PHP
}
?>

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

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

<!-- Scripts Javascript pour contrôle de champs -->
<script	type="text/javascript" src="../jscript/verif_field.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_pdte($td,$ce,""); ?>

</head>

<?PHP
switch ($td)
{
	case "del" :
		echo "<body onload=\"updatenv();warndel();\">";
		break;
	case "view" :
		echo "<body onload=\"updatenv();metReadonly();\">";
		break;
	case "add" :
		echo "<body onLoad=\"metFocus();\">";
		break;
	case "edit" :
		echo "<body onLoad=\"metFocus();updatenv();\">";
		break;
}

include_once("../inc/entete.inc.php"); 
?>
<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<!-- Affiché uniquement s'il y a au moins une marque, une agence active -->
<?PHP
if ($pbm_rete == FALSE)
{
	if ((nb_marques("") <>0) AND (nb_age_actives() <> 0))
	{
	?>
	<table width="100%"  border="0">
	<tr>
		<td width="40%"><strong><em><a href="rete_lst.php?ord=DES&tri=Code"><?PHP echo $txt_lnk_ret_liste; ?></a></em></strong></td>
		<td width="160" 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; ?>)
	</div>
	</td>
		<td width="40%">
		<div id="imp" align="right" <?PHP if (nb_art_in_envoi($rete_code,TRUE)==0) echo 'style="display:none"'; else echo 'style="display:block"'; ?>>
		<?PHP
		if (($td == "edit") OR ($td == "view"))
		{
		$urlimp = "rete_pdf.php?ce=".$ce;
		?>
		<a href="javascript:;" onclick="lanceimp('<?PHP echo $urlimp; ?>');")><img src="../img/print.png" title="Imprimer" border="0" align="absmiddle"></a> 
		<a href="javascript:;" onclick="lanceimp('<?PHP echo $urlimp; ?>');")> Imprimer</a> 
		<?PHP } ?>
		</td>
	</tr>
	</table>
	<form name="rete_maj" method="post" action="rete_enr.php" onSubmit="javascript:; return (verif_rete(this,tab1_champ,'',''));">
	<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
	<input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
	<input name="codemque" type="hidden" id="codemque" value="<?PHP echo $rete_codemque ?>">
	<?PHP if ($td == "add") { ?>
		<input name="code" type="hidden" id="code" value="<?PHP echo $rete_code ?>">
		<input name="clos" type="hidden" id="clos" value="">
	<?PHP } if (($td == "edit") OR ($td == "del")) { ?>
		<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $rete_codeage ?>">	
	<?PHP
	 } ?>
	
	<!-- Code de l'envoi(affiché uniquement si édition ou suppression) -->
	<?PHP if ($td <> "add") {?>
	<table width="900"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_code" align="right">Code </td>
		<td>
			<input name="code" type="text" id="code" value="<?PHP echo $rete_code ?>" size="20" maxlength="20" readonly="1">
			<?PHP if ($rete_clos==1)
			{
				echo "<span class=\"alerte1\">";
				echo "Envoy&eacute;";
				echo "</span>";
			} 
			?>
		</td>
	</tr>
	</table>
	<?PHP }  ?>
	
	<!-- Date création -->
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_datecreaf" align="right">Cr&eacute;&eacute;e le</td>
		<td>
			<input name="datecreaf" type="text" id="datecreaf" value="<?PHP echo $rete_datecreaf ?>" size="10" maxlength="10" readonly="1">
		</td>
	</tr>
	</table>
	
	<!-- Affichage du destinataire -->
	<table width="100%"  border="0">
	<tr>
		<td class="rubfrm" id="f_codemque">
		<div align="center">Destinataire</div>
		</td>
	</tr>
	</table>
	
	<!-- Détails destinataire -->
	<table width="100%"  border="0">
	<tr>
		<td valign="top" bgcolor="#C5CED7">
		<?PHP
		echo "<span class=\"annot_gras_it\">";
		echo $mque_ste."<br />";
		echo "</span>";
		echo $mque_adr1."<br />";
		if ($mque_adr2 <>"") 
			echo $mque_adr2."<br />";
		echo Retournecp_openId($mque_ville,TRUE)." ".Retourneville_openId($mque_ville,TRUE)."<br>";
		$chemin_imagesco = $chemin_images."/telc.png"; 
		echo "<img src=\"".$chemin_imagesco."\" align=\"bottom\">";
		echo " ".$mque_telf."<br>";
		?>
		</td>
	</tr>
	</table>
	
	<!-- Code de l'agence (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_agence" align="right">Agence</td>
		<td>
			<?PHP
			if ($td =="add")  // Ajout = zone modifiable (on peut choisir une agence)
			{ 
				if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
				{
					// Création de la liste des agences ouvertes
					$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
					mysql_select_db(DBNAME);
					// Filtre sur agences ouvertes
					$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 ($rete_codeage == $age_code)
									echo '<option value="'.$age_code.'" selected>'.$age_nomcode.'</option>';
								else
									echo '<option value="'.$age_code.'">'.$age_nomcode.'</option>';
							}
						?>
						</select>
						<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
				<?PHP
					}
					else
					{
				?>
						<select name="codeage" id="codeage">
						<option>-- Pas d'agence active --</option>
						</select>
				<?PHP
					}
					mysql_free_result($rs);
					mysql_close($conn);
				}
				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 $_SESSION["code_age"]; ?>">
					<input name="nagence" type="text" id="nagence" 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($rete_codeage,TRUE);
				extract($row);
				$age_nomcode = $age_nom." (".$age_code.")";
			?>
			<input name="nomage" type="text" id="nomage" value="<?PHP echo $age_nomcode ?>" size="50" maxlength="50" readonly="1">
			<?PHP 
			} 
			?>
		</td>
	</tr>
	</table>
	
	<!-- Date envoi -->
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_dateenvf" align="right">Date Envoi</td>
		<td>
			<input name="dateenvf" type="text" id="dateenvf" value="<?PHP echo $rete_dateenvf ?>" size="10" maxlength="10" readonly="1">
			<?PHP if (($td <> "view") AND ($td<>"del")) {?>
			<img src="../img/calendar.png" align="absmiddle" id="f_img_dateenvf" title="<?PHP echo $alt_chxdate; ?>">
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
			<?PHP } ?>
		</td>
	</tr>
	</table>
	
	<!-- Mode d'envoi -->
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_codeme" align="right">Mode d'envoi</td>
		<td>
			<?PHP
			if (($td =="add") OR ($td=="edit"))  // Ajout/Edition = zone modifiable (on peut choisir un mode)
			{ 
				// Création de la liste des mode d'envoi
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rech = "SELECT * FROM ".TBME." ORDER BY me_nom";
				$rs = mysql_query($rech) or die(mysql_error());
	
				echo '<select name="codeme" id="codeme" onChange="verif_bord1(this.value);">';
				echo '<option>-- Choisissez un mode --</option>';
				echo "<option value=\"-1\"";
				if ($rete_codeme == "-1")
					echo ' selected';
				echo ">Sans objet";
				echo "</option>";
				if (mysql_num_rows($rs) <> 0)
				{
					while ($resultat = mysql_fetch_array($rs)) 
					{
						extract($resultat);
		
						echo '<option value="'.$me_code.'"';
						if ($rete_codeme == $me_code)
							echo ' selected';
						echo '>'.$me_nom.'</option>';
					}
				}
				echo '</select>';
				echo '<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">';
				mysql_free_result($rs);
				mysql_close($conn);
				$urlcreeme = "me_maj.php?td=add&tx=r";
			?>
			<a href="javascript:;" onclick="fensaisie('<?PHP echo $urlcreeme; ?>',1024,600,'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 $urlcreeme; ?>',1024,600,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');")> Ajouter un mode</a>
			<?PHP
			} 
			else  // Edition ou suppression = zone non modifiable (affichage seul)
			{
				if ($rete_codeme<>"-1")
				{
					$row = lit_enr_me($rete_codeme,TRUE);
					if (is_array($row))
						extract($row);
				}
				else
					$me_nom="Sans objet";
			?>
			<input name="codeme" type="hidden" id="codeme" value="<?PHP echo $rete_codeme ?>">	
			<input name="nomme" type="text" id="nomme" value="<?PHP echo $me_nom ?>" size="50" maxlength="50" readonly="1">
			<?PHP 
			} 
			?>
		</td>
	</tr>
	</table>
	
	<!-- Numéro de bordereau -->
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_bord" align="right">Bordereau</td>
		<td>
			<?PHP
			if (($td == "add") OR ($td == "edit"))
			{ 
			?>
				<input name="bord" type="text" id="bord" value="<?PHP echo htmlspecialchars($rete_bord) ?>" size="20">
			<?PHP } else { ?>
				<input name="bord" type="text" id="bord" value="<?PHP echo htmlspecialchars($rete_bord) ?>" size="20" readonly="1">
			<?PHP } ?>
		</td>
	</tr>
	</table>
	  
	<!-- Nombre de colis -->
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_nbcol" align="right">Nombre de colis</td>
		<td>
			<?PHP
			if (($td == "add") OR ($td == "edit"))
			{ 
			?>
				<input name="nbcol" type="text" id="nbcol" value="<?PHP echo htmlspecialchars($rete_nbcol) ?>" size="3" onChange="formatedeci(this.id,0);">
			<?PHP } else { ?>
				<input name="nbcol" type="text" id="nbcol" value="<?PHP echo htmlspecialchars($rete_nbcol) ?>" size="3" readonly="1">
			<?PHP } ?>
		</td>
	</tr>
	</table>

	<?PHP if ($td=="edit") { ?>
	<!-- Cloture de fiche -->
	<table width="100%"  border="0">
	<tr>
		<td width="160" class="rubfrm" id="f_clos" align="right">Clore la fiche</td>
		<td>
			<input type="checkbox" name="clos" id="clos" value="ok"<?PHP if (nb_art_in_envoi($rete_code,TRUE)==0) echo 'disabled="true"'; ?>>
			<br><span class="annot_petit_it">(Si coch&eacute;, cette fiche sera valid&eacute;e &agrave; la date d'envoi et ne sera plus modifiable)</span>
		</td>
	</tr>
	</table>
	<?PHP } else { ?>
	<input type="hidden" name="clos" id="clos" value="<?PHP if ($rete_clos==1) echo "ok"; ?>">
	<?PHP } ?>
	  
	<?PHP if ($td=="view") 
	{
		$row = lit_enr_me($rete_codeme,TRUE);
		if (is_array($row))
			extract($row);
		if (trim($me_lien)<>"")
		{ 
	?>
	<!-- Lien de contrôle du RMA -->
	<table width="100%"  border="0">
	<tr>
		<td colspan="2" width="100%" align="right">
		<a href="javascript:;" onclick="flienexterne('<?PHP echo $me_lien; ?>');">
		<img src="../img/web_go.png" border="0" align="absmiddle"> Se connecter au site du transporteur</a>
		</td>
	</tr>
	</table>
	<?PHP } }?>
	  
	<!-- Zone de saisie des articles et prestations -->
	<?PHP
	if (($td == "edit") OR ($td == "del") OR ($td == "view"))
	{
	?>
		<a name="envart"></a>
		<table width="100%"  border="0">
		<tr>
			<td class="rubfrm" align="center">
			Produits renvoy&eacute;s
			</td>
		</tr>
		</table>
		<div id="detpdte">
		</div>
	
		<!-- Lien d'ajout d'article ou de prestation-->
		<?PHP
		if ($td <> "del")
		{
			if ($td == "edit")
			{
			$urlchoixart = "retp_lst.php?tx=e&td=".$td."&cm=".$cm."&ce=".$ce."&ca=".$rete_codeage;
		
		?>
			<table width="100%"  border="0">
			<tr>
				<td width="50%">
					<a href="javascript:;" onclick="fensaisie('<?PHP echo $urlchoixart; ?>',1024,600,'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; ?>',1024,600,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');")> Ajouter un produit</a>
				</td>
				<td width="50%">&nbsp;
				
				</td>
			</tr>
			</table>			
		<?PHP
			}
		}
	}
	?>
	<p align="center">
	<?PHP
	if (($td == "edit") OR ($td == "add"))
	{
	?>
		<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
		<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_enr; ?>">
	<?PHP if ($td=="edit") { ?>
		<span id="butimp" <?PHP if (nb_art_in_envoi($ce,TRUE)>0) echo "style=\"visibility:visible\""; else echo "style=\"visibility:hidden\"";?>>
		<input name="enrimp" type="submit" class="bton_std" id="enrimp" value="Enregistrer & Imprimer">
		</span>
	<?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">
	<!--
	Calendar.setup({
		inputField     :    "dateenvf",     // id of the input field
		ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
		button         :    "f_img_dateenvf",  // trigger for the calendar (button ID)
		align          :    "Br",           // alignment (defaults to "Bl")
		electric	   :	false,
		singleClick    :    true
	});
	//-->
	</script>
	<?PHP
	if ($td == "add") 
	{
	?>
		<script type="text/javascript">
		<!--
		warnnbage(<?PHP echo nb_age_actives(); ?>,"env");
		warnnbmarque(<?PHP echo nb_marques(""); ?>,"env");
		//-->
		</script>
	<?PHP
	}
	?>  
	<!-- Affiché uniquement s'il y a au moins un destinataire, une agence active -->
	<?PHP
	}
	else
	{
		if (nb_marques("") == 0)
		{
	?>
		<script type="text/javascript">
		<!--
		setTimeout("self.location.href=('mque_lst.php');",2000)
		//-->
		</script>
		<p align="center" class="annot_std_it">Merci de cr&eacute;er au moins une marque...</p>
	<?PHP
		}
	
		if (nb_age_actives() == 0)
		{
	?>
		<script type="text/javascript">
		<!--
		setTimeout("self.location.href=('age_lst.php');",2000)
		//-->
		</script>
		<p align="center" class="annot_std_it">Il faut au moins une agence active ...</p>
	<?PHP
		}
	
	}
}
else
{
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('rete_lst.php?ord=DES&tri=Code');",2000)
	//-->
	</script>
	<p align="center" class="annot_std_it">Merci de choisir un de vos envois...</p>
<?PHP
}
include_once("pied.php");
?>
