<? include("../../comun/conexion3.php");
include("../../comun/funciones.php");
$idcliente=$_GET['idcliente'];
$idalias=$_GET['idalias'];
$cond.= ($idalias !='') ? _and($cond)." idalias like '".$idalias."%' " : '';
//$cond.= ($idcliente!='undefined') ? _and($cond)." idcliente like '".$idcliente."%' " : '';


if($cond=='') $cond = ' 1 = 1';

$query=mysqli_query("select * from contactos where  ".$cond." order by contacto limit 100");

//echo "select * from alias where  ".$cond." order by nickname limit 100";
if(mysqli_num_rows($query)<1) {
	echo '<span style="color:red"> No hay contactos registrados para esta sucursal</span>';
	return;
}
?>
<? if(mysqli_num_rows($query)>0){?>
 <table border="0" width="600"  style="border:1px solid #666; margin-left:3%; border-collapse:collapse; "  >

<tr>
<td  style="background-color:#999; color:#FFF;border:1px solid #666;">
ID
</td>
<td  style="background-color:#999; color:#FFF;border:1px solid #666;">
CONTACTO
</td>
<td  style="background-color:#999; color:#FFF;border:1px solid #666;">
TELEFONO
</td>
<td  style="background-color:#999; color:#FFF;border:1px solid #666;">
EMAIL
</td>
<td  style="background-color:#999; color:#FFF;border:1px solid #666;">
AREA
</td>
</tr>        
<?
		while($rs = mysqli_fetch_array($query)) {
		?>
		<tr style="border:1px solid #666;" onclick="
document.getElementById('idcontacto').value='<?=$rs['id']?>';
document.getElementById('contacto').value='<?=$rs['contacto']?>';
document.getElementById('mailing_tarifarios').checked='<?=$rs['mailing_tarifarios']=='1' ? true : false?>';
document.getElementById('mailing_itinerarios').checked='<?=$rs['mailing_itinerarios']=='1' ? true : false?>';
document.getElementById('telefono_contacto').value='<?=$rs['telefono_contacto']?>';
document.getElementById('email_contacto').value='<?=$rs['email_contacto']?>';" 
ondblclick="parent.document.getElementById('ContactosBox').close()">

<td style="border:1px solid #666; cursor:pointer"><?=$rs['id']?></td>
<td style="border:1px solid #666;; cursor:pointer"><?=strtoupper($rs['contacto'])?></td>
<td style="border:1px solid #666;; cursor:pointer"><?=strtoupper($rs['telefono_contacto'])?></td>
       <!-- <td style="border:1px solid #666;; cursor:pointer"><input type="checkbox"  disabled="disabled" <? //=$rs['cuentawwa']=='1' ? 'checked="checked"' :''?> /></td>-->
        <td style="border:1px solid #666;; cursor:pointer"><?=strtoupper($rs['email_contacto'])?></td>
        <td style="border:1px solid #666;; cursor:pointer"><?=strtoupper(busquedaB("select area from areas where abreviatura = '".$rs['area']."'","area"))?></td>
 		</tr>
		<?	
		}
		?>

    </table>
       
<? }else{ ?>
<br />
B&uacute;squeda sin resultados

<? }  
?>
