Localisateur des points de service

{source}
<?php
$lien=JURI::root();
$lang =& JFactory::getLanguage();
$langueencour = $lang->getTag();
if($langueencour =='pt-BR'){
    define ('RECHERCHE_POINT_SERVICE', 'Pesquisar nossos Postos de Atendimento');
    define ('VOUS_CHERCHEZ', 'você Pesquisar');
    define ('AGENCE_LOCAL', 'agência local');
    define ('VILLE', 'Cidade');
    define ('DISTRIBUTEUR_BILLETS', 'Teller Machine (ATM)');
    define ('TERMINAUS_PAYMENT', 'Terminal de Pagamento (TPE)');
    define ('POINT_TRANSFER', "Ponto de transferência de dinheiro");
    define ('TROUVER', "ENCONTRAR");
    define ('RESULTAT_RECHERCHE', "Resultados da busca em ");
    define ('CHOIX_PAYS', "Selecione o país");
    define ('AUCUN_RESUL', 'No ponto de serviço encontrado!');
}else if($langueencour =='fr-FR'){
  
    define ('RECHERCHE_POINT_SERVICE', 'Rechercher nos Points de service');
    define ('VOUS_CHERCHEZ', 'Vous cherchez…');
    define ('AGENCE_LOCAL', 'Agence locale');
    define ('DISTRIBUTEUR_BILLETS', 'Distributeur de Billets (DAB)');
    define ('TERMINAUS_PAYMENT', 'Terminal de Paiement (TPE)');
    define ('POINT_TRANSFER', "Point de transfert d'argent");
    define ('TROUVER', "TROUVER");
    define ('RESULTAT_RECHERCHE', "Résultats de votre recherche au ");
    define ('CHOIX_PAYS', "Choix du pays");
    define ('VILLE', 'Ville');
    define ('AUCUN_RESUL', 'Aucun point de service trouvé!');
}else if($langueencour =='es-ES'){
  
    define ('RECHERCHE_POINT_SERVICE', 'Pesquisar nossos Postos de Atendimento');
    define ('VOUS_CHERCHEZ', 'ti Busca');
    define ('AGENCE_LOCAL', 'Agencia Local');
       define ('VILLE', 'Ciudad');
    define ('DISTRIBUTEUR_BILLETS', 'Cajero (ATM)');
    define ('TERMINAUS_PAYMENT', 'Terminal de Pago (TPE)');
    define ('POINT_TRANSFER', "Transferencia de dinero Point");
    define ('TROUVER', "ENCONTRAR");
    define ('RESULTAT_RECHERCHE', "Resultados de la búsqueda en ");
    define ('CHOIX_PAYS', "Seleccione el país");
    define ('AUCUN_RESUL', 'No service point found!');
  
}else {
  
    define ('RECHERCHE_POINT_SERVICE', 'Search our Service Points');
    define ('VOUS_CHERCHEZ', 'Search…');
    define ('AGENCE_LOCAL', 'Local Agency');
    define ('VILLE', 'City');
    define ('DISTRIBUTEUR_BILLETS', 'Teller Machine (ATM)');
    define ('TERMINAUS_PAYMENT', 'Payment Terminal (TPE)');
    define ('POINT_TRANSFER', "Money Transfer Point");
    define ('TROUVER', "FIND");
    define ('RESULTAT_RECHERCHE', "Search results in ");
    define ('CHOIX_PAYS', "Select a country");
       define ('AUCUN_RESUL', 'No service point found!');
}

?>
<script language="javascript">
function afficheville(pays)
{
    if(pays=="")
    {
    }else{
    var xhr=null;
 
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() {
    document.getElementById("villeX").style.display="block";
    document.getElementById("villeX").innerHTML=xhr.responseText;
    };
 
    //on appelle le fichier reponse.txt
    xhr.open("GET", "<?php echo $lien; ?>docville/listeville.php?idpays="+pays+"&lang=<?php echo $langueencour; ?>", true);
    xhr.send(null);
    }
}

function verif(){
    if(document.recherche1.agence.checked==false && document.recherche1.gab.checked==false && document.recherche1.tpe.checked==false && document.recherche1.monetfirst.checked==false && document.recherche1.moneygram.checked==false && document.recherche1.westernunion.checked==false && document.recherche1.smallworld.checked==false){
        alert("MERCI DE CHOISIR un service");
        return false;
    }
    else{ return true;}
    }

</script>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#villeX{display:none; margin-bottom:8px; margin-top:-6px;}
#villeX select{ width:180px;  padding-top:6px; padding-bottom:2px;}
</style>

<div style="width:100%; background:url(images/imgb.png); position:fixed; height:1200px; display:none; top:0px; left:0px;" id="mape12" >

<div style="width:800px; background:#FFF; margin:auto;">
<div id="titremap"></div>
<div id="map-canvas"></div>
</div>
</div>

<div class="custom">
<h2 class="title"><a href="#"><?php echo RECHERCHE_POINT_SERVICE; ?> </a></h2>
<form class="details-form" action="" method="post"  onsubmit="return verif()" name="recherche1" ><fieldset>
<h2><a href="#"><?php echo VOUS_CHERCHEZ; ?>…</a><span class="col">
  <select name="pays" required onChange="afficheville(this.value)" >
    <option value=''><?php echo CHOIX_PAYS ?></option>
    <?php
$lang =& JFactory::getLanguage();
$langueencour = $lang->getTag();

$info =& JFactory::getDBO();

$query_pays = "SELECT * FROM #__categories WHERE parent_id='57' AND language='$langueencour' AND published=1 ORDER BY note";
$info->setQuery($query_pays);
$info_pays = $info ->loadObjectList();
if(isset($_POST['pays'])) $idpays=$_POST['pays'];
else $idpays=0;
foreach($info_pays as $pays)
{  if($idpays==$pays->id)$selected="selected='selected'";
        else $selected='';
    echo " <option value='$pays->id' $selected> $pays->title </option>";
$tabpaysq[$pays->id]=$pays->title;
}

?>
  </select>
</span></h2>
<div class="col-holder">
<div class="col">

<?php //if(isset($_POST['ville'])){ echo "<div id='villeX' style='display:block' > <select name='ville' ><option> $_POST[ville]</option></select>"; }
//else echo" <div id='villeX'>";
?> <div id='villeX'></div>

<ul class="rad-list">
<li><input id="lab01" name="agence" type="checkbox" value="1" /> <label for="lab01"><?php echo AGENCE_LOCAL; ?></label></li>
<li><input id="lab02" name="gab" type="checkbox" value="1"/> <label for="lab02" ><?php  echo DISTRIBUTEUR_BILLETS; ?></label></li>
<li><input id="lab03" name="tpe" type="checkbox" value="1" /> <label for="lab03"><?php echo TERMINAUS_PAYMENT; ?></label></li>
</ul></div>

<div class="col">
<ul class="rad-list">
<li><input id="verichec" name="verifchek" type="checkbox" value="point-transfert" /> <label for="lab05"><?php echo POINT_TRANSFER; ?> </label></li>
</ul>
<ul class="ch-list" >

<!–<li><input id="trans3" name="westernunion" value="1" type="checkbox"  onChange="chekglogal('verichec')" /> <label for="lab07">Flash Transfer</label></li>–>

<li><input id="trans3" name="westernunion" value="1" type="checkbox"  onChange="chekglogal('verichec')" /> <label for="lab07">Western Union</label></li>
<li><input id="trans4" name="smallworld" value="1" type="checkbox"  onChange="chekglogal('verichec')" /> <label for="lab08">Small World</label></li>
</ul>
<input type="submit" name="trouve" value="<?php echo TROUVER; ?>"/></div>
</div>
</fieldset></form>

<?php

$texte_agence='';
$texte_GAB='';
$texte_TPE='';
$texte_Ville=$_POST['ville'];
$moneygrame="";
$moneyfist="";
$wester="";
$smallword="";
if(isset($_POST['trouve']) )
{
$id_cat=intval($_POST['pays']);

$elmt=addslashes($_POST['rad1']);
$ville=stripslashes($_POST['ville']);
$smalsql1="";
$smalsql="";
if(isset($_POST['agence']) and $_POST['agence']==1){
$smalsql.=" OR (fieldsid='14' AND value=1) ";
$texte_agence=AGENCE_LOCAL.", ";
}

if(isset($_POST['gab']) and $_POST['gab']==1){
$smalsql.=" OR (fieldsid='15' AND value=1) ";
$texte_agence=DISTRIBUTEUR_BILLETS.", ";
}
if(isset($_POST['tpe']) and $_POST['tpe']==1){
$smalsql.=" OR (fieldsid='16' AND value=1) ";
$texte_TPE=TERMINAUS_PAYMENT.", ";
}

if(isset($_POST['monetfirst']) and $_POST['monetfirst']==1){
$smalsql.=" OR (fieldsid='17' AND value=1) ";
$moneyfist="MoneyFirst, ";

}

if(isset($_POST['moneygram']) and $_POST['moneygram']==1){
$smalsql.=" OR (fieldsid='18' AND value=1) ";
$moneygrame="MoneyGram, ";
}

if(isset($_POST['westernunion']) and $_POST['westernunion']==1){
$smalsql.=" OR (fieldsid='19' AND value=1) ";
$wester="Western Union, ";
}

if(isset($_POST['smallworld']) and $_POST['smallworld']==1){
$smalsql.=" OR (fieldsid='20' AND value=1) ";
$smallword="Small World.";
}
echo "<h2 class='title'><a href='#'> ".RESULTAT_RECHERCHE." $tabpaysq[$id_cat] -> $texte_Ville -> $texte_agence $texte_GAB $texte_TPE  $moneyfist $moneygrame $wester $smallword</a></h2>";
$info =& JFactory::getDBO();
//$query_elm = "SELECT * FROM #__content INNER JOIN #__fieldsattach_values ON #__content.id=#__fieldsattach_values.articleid WHERE catid='$id_cat' AND #__fieldsattach_values.value='$elmt' $smalsql";

$query_elm = "SELECT #__content.id,`asset_id`,`title`,`alias`,`introtext`,`fulltext`, `state`, `catid`,`created`,`images`,`urls`,`language`,`articleid`, `fieldsid`, `value` FROM #__content INNER JOIN #__fieldsattach_values ON #__content.id=#__fieldsattach_values.articleid
WHERE catid='$id_cat' AND title like'%$ville%' AND (fieldsid=1 AND value='' $smalsql) GROUP BY #__content.id";

$info->setQuery($query_elm);
$info_elm = $info->loadObjectList();
$info->query();
$numrow=$info->getNumRows();
if($numrow<=0){
echo" <h3>&nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp;".AUCUN_RESUL."</h3>";   
   
}else{
echo "<ul class='results-list'>";
foreach($info_elm as $elment)
{
$tabimg=explode(',',stripslashes($elment->images));
$tabimg2=explode(':',$tabimg[0]);
$srcimg=JURI::root().str_replace('"','',$tabimg2[1]);
//if($srcimg==JURI::root())$srcimg=JURI::root()."images/defaul.jpg";

echo"<li>
<div class='holder-panel'>";
if($srcimg==JURI::root()){}else{
echo "<div class='img-holder item-image'>
<!–<a class='lightbox' href='#' style='position:absolute; padding:3px 8px 3px 8px; background:#CCC; color:#000; margin-left:123px; margin-top:145px;'>Localiser</a>–>

<img src='$srcimg' width='191' height='170' >
</div>";
}
$info2 =& JFactory::getDBO();
$query_elm = "SELECT * FROM alf_fieldsattach_values WHERE articleid='$elment->id' ";
$info2->setQuery($query_elm);
$info_reseau = $info2->loadObjectList();
echo "<div class='btn-bar'> ";

foreach($info_reseau as $elmimgs)
{
if($elmimgs->fieldsid==14 and $elmimgs->value==1)
echo "<a class='btn01' href='#' title='Agence locale' >btn01</a>";
if($elmimgs->fieldsid==15 and $elmimgs->value==1)
echo "<a class='btn02' href='#' title='Distributeur de Billets (GAB)' >btn02</a>";
if($elmimgs->fieldsid==16 and $elmimgs->value==1)
echo "<a class='btn03' href='#' title='Terminal de Paiement (TPE)' >btn03</a>";
if($elmimgs->fieldsid==17 and $elmimgs->value==1)
echo "<a class='btn04' href='#' title='MoneyFirst' >btn04</a>";
if($elmimgs->fieldsid==18 and $elmimgs->value==1)
echo "<a class='btn05' href='#' title='MoneyGram' >btn05</a>";
if($elmimgs->fieldsid==19 and $elmimgs->value==1)
echo "<a class='btn06' href='#' title='Western Union' >btn06</a>";
if($elmimgs->fieldsid==20 and $elmimgs->value==1)
echo "<a class='btn07' href='#' title='Small World' >btn07</a>";
}

echo"</div></div>
<div class='holder-text'> <h3><font color='red'>$elment->title</font></h3>";
echo $elment->introtext."</div></li>";

//echo"<br><input type='button' onClick='affichemap(50,100,\"$elment->title\")' value='affiche map'><br>";
}
echo "</ul>";
}
}
?>
</div>

{/source}