Location: PHPKode > projects > Alliances Manager > vistas/buscador.php
<?php
/*
 *  Alliances Manager (Gestionador de Alianzas) - Travian
 *  Copyright (C) 2008-12  Viva Mayer, Francisco Mesías <hide@address.com>
 *
 *  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 3 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.  If not, see <http://www.gnu.org/licenses/>.
*/

if (isset($_POST['x'], $_POST['y'])) {
  $x   = (int) $_POST['x'];
  $y   = (int) $_POST['y'];
} else {
  $x = 0;
  $y = 0;
}

$select_off = ""; $select_def = ""; $select_spy = "";

$inf = ""; $cab = ""; $cat = ""; $ari = ""; $spy = "";

$d_inf = "disabled=\"disabled\" style=\"background-color: #996600;\"";
$d_cab = "disabled=\"disabled\" style=\"background-color: #996600;\"";
$d_cat = "disabled=\"disabled\" style=\"background-color: #996600;\"";
$d_ari = "disabled=\"disabled\" style=\"background-color: #996600;\"";
$d_spy = "disabled=\"disabled\" style=\"background-color: #996600;\"";

if (isset($_POST['tipo'])) {
   if ($_POST['tipo']=="off") {
	 $select_off = " selected=\"selected\"";
	 
	 $inf = $_POST['inf']; $cab = $_POST['cab']; $cat = $_POST['cat']; $ari = $_POST['ari'];
	 
	 $d_inf = "style=\"background-color: #FFFFCC;\"";
	 $d_cab = "style=\"background-color: #FFFFCC;\"";
	 $d_cat = "style=\"background-color: #FFFFCC;\"";
	 $d_ari = "style=\"background-color: #FFFFCC;\"";
   }
   elseif ($_POST['tipo']=="def") { 
	 $select_def = " selected=\"selected\"";
	 
	 $inf = $_POST['inf'];
	 $cab = $_POST['cab'];
	 
	 $d_inf = "style=\"background-color: #FFFFCC;\"";
	 $d_cab = "style=\"background-color: #FFFFCC;\"";
   }
   elseif ($_POST['tipo']=="spy") {
	 
	 $select_spy = " selected=\"selected\"";
	 
	 $spy = $_POST['spy'];
	 
	 $d_spy = "style=\"background-color: #FFFFCC;\"";
   }
}
cabecera("",self::$texto->get('HEAD08'));
?>
<script type="text/javascript">
<!--
 function Bloquear() {
  document.obj1.inf.disabled = true;
  document.obj1.cab.disabled = true;
  document.obj1.cat.disabled = true;
  document.obj1.ari.disabled = true;
  document.obj1.spy.disabled = true;
  
  document.obj1.inf.style.backgroundColor = "#996600";
  document.obj1.cab.style.backgroundColor = "#996600";
  document.obj1.cat.style.backgroundColor = "#996600";
  document.obj1.ari.style.backgroundColor = "#996600";
  document.obj1.spy.style.backgroundColor = "#996600";
}
  
function ActivarMinimos (selector) { 
  switch (selector.selectedIndex) {
     case 0:
	 	Bloquear();
	 	break;	
	 case 1: 
	      document.obj1.inf.disabled = false;
		  document.obj1.cab.disabled = false;
		  document.obj1.cat.disabled = false;
		  document.obj1.ari.disabled = false;
		  document.obj1.spy.disabled = true;
		  
		  document.obj1.inf.value = "";
		  document.obj1.cab.value = "";
		  document.obj1.cat.value = "";
		  document.obj1.ari.value = "";
		  document.obj1.spy.value = "";
		  
		  document.obj1.inf.style.backgroundColor = "#FFFFCC";
		  document.obj1.cab.style.backgroundColor = "#FFFFCC";
		  document.obj1.cat.style.backgroundColor = "#FFFFCC";
		  document.obj1.ari.style.backgroundColor = "#FFFFCC";
		  document.obj1.spy.style.backgroundColor = "#996600";
	 	break;
	 case 2:
	      document.obj1.inf.disabled = false;
		  document.obj1.cab.disabled = false;
		  document.obj1.cat.disabled = true;
		  document.obj1.ari.disabled = true;
		  document.obj1.spy.disabled = true;
		  
		  document.obj1.inf.value = "";
		  document.obj1.cab.value = "";
		  document.obj1.cat.value = "";
		  document.obj1.ari.value = "";
		  document.obj1.spy.value = "";
		  
		  document.obj1.inf.style.backgroundColor = "#FFFFCC";
		  document.obj1.cab.style.backgroundColor = "#FFFFCC";
		  document.obj1.cat.style.backgroundColor = "#996600";
		  document.obj1.ari.style.backgroundColor = "#996600";
		  document.obj1.spy.style.backgroundColor = "#996600";
	 	break;
	 case 3: 
		  document.obj1.inf.disabled = true;
		  document.obj1.cab.disabled = true;
		  document.obj1.cat.disabled = true;
		  document.obj1.ari.disabled = true;
		  document.obj1.spy.disabled = false;
		  
		  document.obj1.inf.value = "";
		  document.obj1.cab.value = "";
		  document.obj1.cat.value = "";
		  document.obj1.ari.value = "";
		  document.obj1.spy.value = "";
		  
		  document.obj1.inf.style.backgroundColor = "#996600";
		  document.obj1.cab.style.backgroundColor = "#996600";
		  document.obj1.cat.style.backgroundColor = "#996600";
		  document.obj1.ari.style.backgroundColor = "#996600";
		  document.obj1.spy.style.backgroundColor = "#FFFFCC";
		  
	 	break;
  }
}
//-->
</script>
</head>

<body>
<div id="top"><?php include("libs/top.php")?></div>
<div id="contenido">
<form name="obj1" action="?ctrl=Tropas&mod=Buscador" method="post">
<table width="723" border="0" align="center" cellpadding="2" cellspacing="1" class="tabla_search">
    <tr class="E1">
      <td><?=self::$texto->get('coordenadas')?> ( x | y ) </td>
      <td><?=self::$texto->get('tipo.busqueda')?></td>
      <td><?=self::$texto->get('infanteria')?></td>
      <td><?=self::$texto->get('caballeria')?></td>
      <td><?=self::$texto->get('catas')?></td>
      <td><?=self::$texto->get('arietes')?></td>
      <td><?=self::$texto->get('espias')?></td>
    </tr>
    <tr>
      <td>( 
        <input name="x" type="text" tabindex="1" size="2" maxlength="4" value="<?=$x?>" /> 
        | 
        <input name="y" type="text" tabindex="2" size="2" maxlength="4" value="<?=$y?>" /> 
        ) </td>
      <td><select name="tipo" id="tipo" tabindex="3" onChange="ActivarMinimos(this)">
        <option>Elegir...</option>
		<option value="off"<?=$select_off?>><?=self::$texto->get('ofensiva')?></option>
        <option value="def"<?=$select_def?>><?=self::$texto->get('defensiva')?></option>
        <option value="spy"<?=$select_spy?>><?=self::$texto->get('espionaje')?></option>
      </select>      </td>
      <td><input name="inf" type="text" tabindex="4" size="10" <?=$d_inf?> value="<?=$inf?>"/></td>
      <td><input name="cab" type="text" tabindex="5" size="10" <?=$d_cab?> value="<?=$cab?>"/></td>
      <td><input name="cat" type="text" tabindex="6" size="10" <?=$d_cat?> value="<?=$cat?>"/></td>
      <td><input name="ari" type="text" tabindex="7" size="10" <?=$d_ari?> value="<?=$ari?>"/></td>
      <td><input name="spy" type="text" tabindex="8" size="10" <?=$d_spy?> value="<?=$spy?>"/></td>
    </tr>
    <tr>
      <td colspan="7"><input type="submit" class="boton" value="<?=self::$texto->get('buscar')?>" /></td>
      </tr>
  </table>
  <center>
    <div style="font-size: 13px;"><?=self::$texto->get('aterisco.buscador')?></div>
  </center>
</form>
<?php
if (isset($resultado))
{
?>
<br>
<table width="68%" border="0" align="center" cellpadding="2" cellspacing="1" class="tabla_buscador">
  <tr class="E1">
    <td width="150"><?=self::$texto->get('jugador')?></td>
    <td width="100"><?=self::$texto->get('origen')?></td>
    <td><?=self::$texto->get('tropas')?></td>
    <td width="150"><?=self::$texto->get('tiempo.viaje')?></td>
  </tr>
<?php
$num = count($resultado);
$cont = 0; $cell = "class=\"R1\"";
while ($cont < $num)
{
	// Determinamos la raza del jugador
	$idraza = (int) ($resultado[$cont]['tropas'][0]['id'] / 10);
	switch($idraza)
	{
		case 1: $Raza = 'romano'; break;
		case 2: $Raza = 'germano'; break;
		case 3: $Raza = 'galo'; break;
	}
	
	if ($cont == ($num-1)) $cell = "";
	
	echo "<tr >\n";
    echo "<td ".$cell.">".$resultado[$cont]['player']."</td>\n";
    echo "<td ".$cell.">(".$resultado[$cont]['ox']." | ".$resultado[$cont]['oy'].")</td>\n";
    
	echo "<td ".$cell."> ";
	$ArregloTropas = self::$texto->get($Raza); // tiene el array con los nombres
	$num2 = count($resultado[$cont]['tropas']); $con2 = 0;
	while ($con2 < $num2)
	{
		$id = $resultado[$cont]['tropas'][$con2]['id'];
		
		$cantidad = $resultado[$cont]['tropas'][$con2]['cant'];
		
		echo "<img src=\"imagenes/tropas/".$Raza."/".$id.".gif\" alt=\"".$ArregloTropas[$id]."\" width=\"16\" height=\"16\" title=\"".$ArregloTropas[$id]."\"/> ".$cantidad." ";		
		++$con2;
	}
	echo "</td>\n";
    echo "<td ".$cell.">".$resultado[$cont]['tiempo']."</td>\n";
  	echo "</tr>\n\n";
	
	++$cont;
}
?>
</table>
<?php
}
?>
</div>
</body>
</html>
Return current item: Alliances Manager