


function creer_table_navires_attendus(navires_attendus, fichier, navires_attendus_tri)
{

//syntaxe : navires_attendus.ajouter_champ(nom, libelle, type_donnee, valeur_initiale, longueur, position) ;
navires_attendus.ajouter_champ("numero_annonce", "Numéro d'annonce", "", "", 8, 1) ;
navires_attendus.ajouter_champ("type_article", "Type Article '1'", "", "", 1, 9) ;
navires_attendus.ajouter_champ("poste_quai", "Poste à quai", "", "", 3, 10) ;
navires_attendus.ajouter_champ("date_bxa", "Date prévue BXA", "", "", 10, 13) ;
navires_attendus.ajouter_champ("marchandises_chargees", "Marchandises chargées", "", "", 20, 23) ;
navires_attendus.ajouter_champ("marchandises_dechargees", "Marchandises déchargées", "", "", 20, 43) ;
navires_attendus.ajouter_champ("courtier_montee", "Courtier montée", "", "", 10, 63) ;
navires_attendus.ajouter_champ("agent", "Agent", "", "", 10, 73) ;
navires_attendus.ajouter_champ("tirant_av", "Tirant d'eau AV annoncé montée", "", "", 3, 83) ;
navires_attendus.ajouter_champ("tirant_ar", "Tirant d'eau AR annoncé montée", "", "", 3, 86) ;
navires_attendus.ajouter_champ("date_mouillage", "Date prévue mouillage", "", "", 10, 89) ;
navires_attendus.ajouter_champ("date_amarrage", "Date prévue amarrage", "", "", 10, 99) ;
navires_attendus.ajouter_champ("provenance", "Provenance", "", "", 33, 109) ;
navires_attendus.ajouter_champ("nom", "Nom", "", "", 20, 142) ;
navires_attendus.ajouter_champ("pavillon", "Pavillon", "", "", 33, 162) ;
navires_attendus.ajouter_champ("type", "Type", "", "", 33, 195) ;
navires_attendus.ajouter_champ("longueur", "Longueur", "", "", 4, 228) ;
navires_attendus.ajouter_champ("largeur", "Largeur", "", "", 3, 232) ;
navires_attendus.ajouter_champ("jauge_nette", "Jauge nette", "", "", 6, 235) ;
navires_attendus.ajouter_champ("jauge_brute", "Jauge brute", "", "", 6, 241) ;
navires_attendus.ajouter_champ("port_lourd", "Port en lourd", "", "", 6, 247) ;
navires_attendus.ajouter_champ("port_attache", "Port d'attache", "", "", 33, 253) ;
navires_attendus.ajouter_champ("armateur", "Armateur", "", "", 20, 286) ;
// retenir le contenu du fichier dans la table virtuelle , le chiffre est le numéro d'article :
navires_attendus.charger_fichier_navire(fichier, "1") ;

//ajouter des champs date/heure retravaillés et prets à l'affichage
navires_attendus.ajouter_champ("date_affichee", "Date réelle d'amarrage", "", "", 8) ;
navires_attendus.ajouter_champ("heure_affichee", "Heure réelle d'amarrage", "", "", 5) ;
navires_attendus.ajouter_champ("date_tri", "Date servant juste au tri par date", "", "", 10) ;
// libéllé du n° de quai :
navires_attendus.ajouter_champ("nom_terminal", "Nom du terminal", "", "", 20) ;	
// longueur des navires en m :
navires_attendus.ajouter_champ("longueur_affichee", "Longueur", "", "", 7) ;
navires_attendus.ajouter_champ("largeur_affichee", "Largeur", "", "", 6) ;

var i , date_bxa , jours, mois, annees, heures, minutes, date_affichee, heure_affichee , date_tri,longueur_affichee;
for ( i = 0 ; i < navires_attendus.nb_enregistrements ; i ++ )
	{
	date_bxa = navires_attendus.enregistrements[i].date_bxa ;
	jours = date_bxa.substring(0 , 2) ;
	mois = date_bxa.substring(2 , 4) ;
	annees = date_bxa.substring(4 , 6) ;
	heures = date_bxa.substring(6 , 8) ;
	minutes = date_bxa.substring(8 , 10) ;
	date_affichee = jours + "/" + mois + "/" + annees ;
	heure_affichee = heures + "h" + minutes ;
	if (heures == "  ")
		heure_affichee = "" ;
	//date_tri = annees + mois + jours + heures + minutes ;
	date_tri = new Date(annees,mois,jours,heures,minutes) ;
	longueur_affichee = trim(navires_attendus.enregistrements[i].longueur) ;
	longueur_affichee = enlever_zeros_devant_entier(longueur_affichee) ;
	if (longueur_affichee != "" )
		{
		longueur_affichee = parseInt(longueur_affichee) ;
		longueur_affichee = longueur_affichee/10 ;
		longueur_affichee = longueur_affichee + " m" ;
		}
	largeur_affichee = trim(navires_attendus.enregistrements[i].largeur) ;
	largeur_affichee = enlever_zeros_devant_entier(largeur_affichee) ;
	if (largeur_affichee != "" )
		{
		largeur_affichee = parseInt(largeur_affichee) ;
		largeur_affichee = largeur_affichee/10 ;
		largeur_affichee = largeur_affichee + " m" ;
		}
	navires_attendus.enregistrements[i].date_affichee = date_affichee ;
	navires_attendus.enregistrements[i].heure_affichee = heure_affichee ;
	navires_attendus.enregistrements[i].date_tri = date_tri ;
	navires_attendus.enregistrements[i].longueur_affichee = longueur_affichee ;
	navires_attendus.enregistrements[i].largeur_affichee = largeur_affichee ;
	// appel de la fonction dans navires_postes.js :
	navires_attendus.enregistrements[i].nom_terminal = trouver_nom_terminal(navires_attendus.enregistrements[i].poste_quai)
	}

navires_attendus.trier(navires_attendus_tri) ;

}

function afficher_table_navires_attendus(navires_attendus)
{
var nb_enregistrements = navires_attendus.nb_enregistrements ;
var i ;
var nav_attendus ;

for ( i = 0 ; i < nb_enregistrements ; i ++ )
	{
	nav_attendus = navires_attendus.enregistrements[i] ;
	afficher_navire_attendu(nav_attendus,i) ;
	}
return(true) ;
} 

function afficher_navire_attendu(nav_attendus,i)
{
var date_sortie,heure_sortie ;

date_bxa = nav_attendus.date_affichee ;
heure_bxa = nav_attendus.heure_affichee ;
if (heure_bxa.length != "" )
	heure_bxa = " à " + heure_bxa ;

var js =''; 

js +='<table width="576" border="0" cellspacing="0" cellpadding="0"> ';
js +='	<tr>  ';
js +='		<td height="26" colspan="1" bgcolor="#1B40A1" valign="center" class="txtblanc" >&nbsp;&nbsp;'  + nav_attendus.nom  +  '</td> ';
js +='		<td colspan="1" width="20%" bgcolor="#1B40A1" valign="center" class="txtblanc" ><span class="tnaviresblanc">Poste :&nbsp;</span>'  + nav_attendus.poste_quai  +  ' - ' +  nav_attendus.nom_terminal   +  '&nbsp;&nbsp;</td> ';
js +='		<td colspan="1" width="20%" bgcolor="#1B40A1" valign="center" class="txtblanc" ><a href="javascript:ouvrir_fiche_navire_attendu(' + i + ');"><span  class="tnaviresblanc"><img src="../images/img_commun/puce_double.gif" width="11" height="11">&nbsp;&nbsp;Plus de détails&nbsp;</span></a>&nbsp;</td> ';
js +='	</tr> ';
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="3"></td> ';
js +='	</tr> ';
js +='	<tr bgcolor=#f9fcf5> ';
js +='		<td bgcolor=#f9fcf5 class="txtbold"><span class="tnaviresvert">Date prévue arrivée :&nbsp;</span>'  + date_bxa  +  heure_bxa + '</td> ';
js +='		<td bgcolor=#f9fcf5 class="txtbold"><span class="tnaviresvert">&nbsp;</span>'  +  '</td> ';
js +='		<td  bgcolor=#f9fcf5 class="txtbold" width="20%">&nbsp;</td> ';
js +='	</tr>	 ';					
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="3"></td> ';
js +='	</tr>	 ';				
/*
js +='	<tr bgcolor="#E4E9F5"  height="20"> ';
js +='		<td class="tnavires" width="40%">Agent : <span class="txtbold">'  + nav_attendus.agent  +  '</span></td> ';
js +='		<td class="tnavires" width="40%">&nbsp;</td> ';
js +='		<td class="tnavires" width="20%">&nbsp;<span class="txtbold">'  +  '</span></td> ';
js +='	</tr> ';
js +='	 <tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr>	 ';	
*/	
js +='	<tr bgcolor="#D7F8F1"  height="20"> ';
js +='		<td class="tnavires" width="40%">Provenance : <span class="txtbold">'  + nav_attendus.provenance  +  '</span></td> ';
js +='		<td class="tnavires" width="40%">Agent : <span class="txtbold">'  + nav_attendus.agent  + '</span></td> ';
js +='		<td class="tnavires" width="20%">Longueur : <span class="txtbold">'  + nav_attendus.longueur_affichee  +  '</span></td>  ';			
js +='	</tr>	 ';			
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr>	 ';	
js +='	<tr bgcolor="#E4E9F5"  height="20"> ';
js +='		<td class="tnavires" width="40%">Déchargement  : <span class="txtbold"> '  + nav_attendus.marchandises_dechargees  +  ' </span></td> ';
js +='		<td class="tnavires" width="40%">Chargement : <span class="txtbold">'  + nav_attendus.marchandises_chargees  +  '</span></td> ';
js +='		<td class="tnavires" width="20%">Port en lourd : <span class="txtbold">'  + nav_attendus.port_lourd  +  '</span></td> ';
js +='	</tr> ';
js +='	 <tr >  ';
js +='		<td colspan="3" bgcolor="#056E65" ><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr>	 ';	
js +='	<tr  bgcolor="#D7F8F1"  height="20"> ';
js +='		<td class="tnavires" width="40%" >Armateur : <span class="txtbold">'  + nav_attendus.armateur  +  '</span></td> ';
js +='		<td class="tnavires" width="60%" colspan="2">Pavillon : <span class="txtbold">'  + nav_attendus.pavillon  +  '</span></td> ';
js +='	</tr>	 ';
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr> 	 ';
js +='</table> ';
js +='<br> ';
document.write( js) ;
return(js) ;
} 


function afficher_fiche_navire_attendu(nav_attendus,i)
{
var date_sortie,heure_sortie ;

date_bxa = nav_attendus.date_affichee ;
heure_bxa = nav_attendus.heure_affichee ;
if (heure_bxa.length != "" )
	heure_bxa = " à " + heure_bxa ;

var js =''; 

js +='<table width="450" border="0" cellspacing="0" cellpadding="0"> ';
js +='	<tr>  ';
js +='		<td height="26" colspan="1" bgcolor="#1B40A1" valign="center" class="txtblanc" >&nbsp;&nbsp;'  + nav_attendus.nom  +  '</td> ';
js +='		<td colspan="1" bgcolor="#1B40A1" valign="center" class="txtblanc" ><span class="tnaviresblanc">Poste :&nbsp;</span>'  + nav_attendus.poste_quai  +  ' - ' +  nav_attendus.nom_terminal   +   '&nbsp;&nbsp;</td> ';
js +='		<td colspan="1" width="5%" bgcolor="#1B40A1" valign="center" class="txtblanc" ><a href="javascript:self.close();"><img src="../images/img_commun/picto_quitter_bleu.gif" width="20" height="20" align="right" border="0" alt="Fermez la fiche"></a></td> ';
js +='	</tr> ';
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="3"></td> ';
js +='	</tr> ';
js +='	<tr bgcolor=#f9fcf5> ';
js +='		<td bgcolor=#f9fcf5 class="txtbold"><span class="tnaviresvert">Date prévue arrivée :&nbsp;</span>'  + date_bxa  +  heure_bxa + '</td> ';
js +='		<td bgcolor=#f9fcf5 class="txtbold" colspan="2"><span class="tnaviresvert">&nbsp;</span>'  +  '</td> ';
js +='	</tr>	 ';					
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="3"></td> ';
js +='	</tr>	 ';				

js +='	<tr bgcolor="#D7F8F1"  height="20"> ';
js +='		<td class="tnavires" width="40%">Provenance : <span class="txtbold">'  + nav_attendus.provenance  +  '</span></td> ';
js +='		<td class="tnavires" width="40%" colspan="2">Type  : <span class="txtbold"> '  + nav_attendus.type  +  ' </span></td> ';
js +='	</tr>	 ';			
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr>	 ';	
js +='	<tr bgcolor="#E4E9F5"  height="20"> ';
js +='		<td class="tnavires" width="40%">Déchargement  : <span class="txtbold"> '  + nav_attendus.marchandises_dechargees  +  ' </span></td> ';
js +='		<td class="tnavires" width="40%" colspan="2">Chargement : <span class="txtbold">'  + nav_attendus.marchandises_chargees  +  '</span></td> ';
js +='	</tr> ';
js +='	 <tr >  ';
js +='		<td colspan="3" bgcolor="#056E65" ><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr>	 ';	
js +='	<tr  bgcolor="#D7F8F1"  height="20"> ';
js +='		<td class="tnavires" width="40%" >Armateur : <span class="txtbold">'  + nav_attendus.armateur  +  '</span></td> ';
js +='		<td class="tnavires" width="40%" colspan="2">Pavillon : <span class="txtbold">'  + nav_attendus.pavillon  +  '</span></td> ';
js +='	</tr>	 ';
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr> 	 ';

js +='	<tr bgcolor="#E4E9F5"  height="20"> ';
js +='		<td class="tnavires" width="40%">Tirant d\'eau avant  : <span class="txtbold"> '  + nav_attendus.tirant_av  +  ' </span></td> ';
js +='		<td class="tnavires" width="40%" colspan="2">Tirant d\'eau arrière : <span class="txtbold">'  + nav_attendus.tirant_ar  +  '</span></td> ';
js +='	</tr> ';
js +='	 <tr >  ';
js +='		<td colspan="3" bgcolor="#056E65" ><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr>	 ';	

js +='	<tr  bgcolor="#D7F8F1"  height="20"> ';
js +='		<td class="tnavires" width="40%">Jauge nette  : <span class="txtbold"> '  + nav_attendus.jauge_nette  +  ' </span></td> ';
js +='		<td class="tnavires" width="40%" colspan="2">Jauge brute : <span class="txtbold">'  + nav_attendus.jauge_brute  +  '</span></td> ';
js +='	</tr>	 ';
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr> 	 ';

js +='	<tr bgcolor="#E4E9F5"  height="20"> ';
js +='		<td class="tnavires" width="40%">Longueur  : <span class="txtbold"> '  + nav_attendus.longueur_affichee  +  ' </span></td> ';
js +='		<td class="tnavires" width="40%" colspan="2">Largeur : <span class="txtbold">'  + nav_attendus.largeur_affichee  +  '</span></td> ';
js +='	</tr> ';
js +='	 <tr >  ';
js +='		<td colspan="3" bgcolor="#056E65" ><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr>	 ';	

js +='	<tr  bgcolor="#D7F8F1"  height="20"> ';
js +='		<td class="tnavires" width="40%" colspan="1">Agent : <span class="txtbold">'  + nav_attendus.agent  + '</span></td> ';
js +='		<td class="tnavires" width="40%" colspan="2">Port d\'attache : <span class="txtbold">'  + nav_attendus.port_attache  +  '</span></td> ';
js +='	</tr>	 ';
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr> 	 ';

js +='	<tr  bgcolor="#E4E9F5"  height="20"> ';
js +='		<td class="tnavires" width="40%">Courtier montée  : <span class="txtbold"> '  + nav_attendus.courtier_montee  +  ' </span></td> ';
js +='		<td class="tnavires" width="40%" colspan="2">Tonnage : <span class="txtbold">'  + nav_attendus.port_lourd  +  '</span></td> ';
js +='	</tr>	 ';
js +='	<tr>  ';
js +='		<td colspan="3" bgcolor="#056E65"><img src="../../images/img_commun/espaceur.gif" width="1" height="1"></td> ';
js +='	</tr> 	 ';



js +='	<tr>  ';
js +='		<td height="26" colspan="1" bgcolor="#1B40A1" valign="center" class="txtblanc" >&nbsp;&nbsp;</td> ';
js +='		<td colspan="1" bgcolor="#1B40A1" valign="center" class="txtblanc" >&nbsp;</td> ';
js +='		<td colspan="1" width="5%" bgcolor="#1B40A1" valign="center" class="txtblanc" ><a href="javascript:self.close();"><img src="../images/img_commun/picto_quitter_bleu.gif" width="20" height="20" align="right" border="0" alt="Fermez la fiche"></a></td> ';
js +='	</tr> ';
js +='</table> ';

document.write( js) ;
return(js) ;
} 

function enlever_zeros_devant_entier(nombre_chaine)
{
var i , longueur_chaine, zero, longueur ;
longueur_chaine = nombre_chaine.length ;

for ( i = 0 ; i < longueur_chaine ; i ++ )
	{
	zero = nombre_chaine.substring(0 , 1) ;
	if (zero != "0" && zero != " " )
		{break ;}
	nombre_chaine = nombre_chaine.substring(1 , nombre_chaine.length);	
	}
	
	return(nombre_chaine) ;	
}
