<?php


/*
	identification de  la phase de recherches en cours
		phase = 0  : phase initiale avec premier choix des critères 
		phase = 1  : pahases suivantes
*/
	$phase = isset($this->request->params[0]) ? 1 : 0;
	$page = isset($this->request->params[0])?$this->request->params[0] : 1; 
	if ($page== 'S') {$page=1;}
	
	echo "<center><h1>".decode_lng_text("SEARCH_TITLE")."</h1></center></br>";

	$country = $this->request->params[0];
	$zone = $this->request->params[1];
	$city = $this->request->params[2];

	/*
	* affichage du panneau de selection des critères
	*/
	echo "<center><table id='recherche_selection' ><tr style=' background-color:#FAD278; text-align:center; font-weight:bold;'>";
	echo "<td colspan=3>Choisissez un type de recherches</center></td></tr>";
	echo "<tr style='border:none; text-align:center; font-weight:bold;'>";

	echo "<td><a href='".Router::url('recherches/individus')."'>".decode_lng_text('SEARCH_TITLE_INDIVIDUS')."</a></td>";
	echo "<td>".decode_lng_text('SEARCH_TITLE_EVENTS')."</td>";
	echo "<td ><a href='".Router::url('recherches/couples')."'>".decode_lng_text('SEARCH_TITLE_COUPLES')."</a></td>";

	echo "</tr></table></center></br>";

	/*
	* affichage du tableau de selection des critères "événements"
	*/

	echo "<div id='panneau-events' style='visibility:display'>";

	echo "<center>";

	echo "<form id='recherche_events' action='ObtenirLibellesPagination(\"".BASE_URL."\"); ObtenirRecherchesEvent(\"".BASE_URL."\")' method='post'>";
	// Countries
	echo display_lng_text("GEDTAG_CTRY");
	echo "  <select id='list_country' name='list_country' onchange='ObtenirRecherchesZones(\"".BASE_URL."\");' >";
	echo "<option value='All'>".display_lng_text('EVNT_ALL')."</option>";
	foreach ($_SESSION['t_countries'] as $k=>$row_country) {
		if ($row_country['id_country']==$country) {$selected = "selected=selected";}  else { $selected ='';}
		echo "<option value='".$row_country['id_country']."'" . $selected .">".$row_country['libelle']."(".$row_country['decompte'].")</option>";
	}
	echo "</select> ";
//echo "<div id=liste_zones></div>";
	// Zones
	echo display_lng_text("EVNT_ZONE");	
	echo "  <select id=list_zones name=list_zones onchange='ObtenirRecherchesCities(\"".BASE_URL."\")'>";

	echo "<option value='All' >".decode_lng_text('EVNT_ALL_F')."</option>";
	if ($_SESSION['s_phase'] == 'recherches_lieux') {
		foreach ($_SESSION['t_zones'] as $k=>$row_zone) {
			if ($row_zone['id_zone']==$zone) {$selected = "selected=selected";}  else { $selected ='';}
			echo "<option value='".$row_zone['id_zone']."' " . $selected .">".$row_zone['libelle']."(".$row_zone['decompte'].")</option>";
		}
	}
	
	// if($_SESSION['s_phase'] == 'recherches_lieux') { foreach ...} // pour remplir 
	echo "</select> ";

	// City
	echo display_lng_text("GEDTAG_CITY");	
	echo "  <select id=list_cities name=list_cities>";
	
	
	echo "<option value='All' >".decode_lng_text('EVNT_ALL_F')."</option>";
	if ($_SESSION['s_phase'] == 'recherches_lieux') {
		foreach ($_SESSION['t_cities'] as $k=>$row_city) {
			if ($row_city['id_city']==$city) {$selected = "selected=selected";} else { $selected ='';}
			echo "<option value='".$row_city['id_city']."' " . $selected .">".$row_city['libelle']."(".$row_city['decompte'].")</option>";
		}
		
	}
	echo "</select></br></br>";
	
	// Events
	echo display_lng_text("EVNT_EVNT");
	echo " <select id=list_events name=list_events >";
	echo "<option value='All'>".decode_lng_text('EVNT_ALL')."</option>";
	echo "<optgroup label='".decode_lng_text('EVNT_EC')."'>";
	foreach ($_SESSION['t_type_evenements'] as $k=>$row) {
		if ($row['type']>115) { break;}
		$type_libelle = 'GEDTAG_'.$row['code'];
		echo "<option value='".$row['type']."'>".decode_lng_text($type_libelle)."</option>";
	}
	echo "</optgroup>";
	echo "<optgroup label='".decode_lng_text('EVNT_OTHER')."'>";
	foreach ($_SESSION['t_type_evenements'] as $k=>$row) {
		if ($row['type']<116) { continue;}
		$type_libelle = 'GEDTAG_'.$row['code'];
		echo "<option value='".$row['type']."'>".decode_lng_text($type_libelle)."</option>";
	}
	echo "<option value='0'>".decode_lng_text('EVNT_OTHER')."</option>";	
	echo "</select></br></br>";

	// Date
	echo display_lng_text("EVNT_DATE")."  ". display_lng_text("DETAIL_DATE_BEGIN");
	echo "  <input id=date_begin name=date_begin> ".	display_lng_text("DETAIL_DATE_END");
	echo "  <input id=date_end name=date_end></br></br></br>";

	echo "<input type=button value='".decode_lng_text("EVNT_SEA")."' onClick='ObtenirLibellesPagination(\"".BASE_URL."\"); ObtenirRecherchesEvent(\"".BASE_URL."\")'>";

	echo "</form>";

	echo "</div>";

/*
*Affichage du résultat
*/
// vue d'attente pendant la recherche
	echo "<div id='attente_retour'class='attente box2 w500p' >
			<table style='text-align: center; height=300px; width:100%;'>
			  <tbody>

				<tr>
				  <td style='text-align: center;'>
					<img width='400px' height='25px' src='".IMAGES."attente.gif' alt='Attente  recherches' /> 
				  </td>
				</tr>
				<tr>
				  <td style='text-align: center;font-size:16px;'>
						<p><br/><i>".display_lng_text('SEARCH_ATTENTE')."</i> <br/>  </p>
				  </td>
				</tr>
				
			  </tbody>
			</table>
				
		</div>";
	
/*
*     Affichage du résultat
*/
	if ($phase==0) { return; }
	echo "<div id='recherches_resultats'></div>";

	echo "</div>";

?>
