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


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

$query=mysqli_query("select * from alias where  ".$cond." order by socialreason 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 sucursales registradas para este cliente o la b&uacute;squeda es vacia</span>';
	return;
}
?>
<? if(mysqli_num_rows($query)>0){?>
 <table border="0"  style="border:1px solid #666; margin-left:3%; border-collapse:collapse; font-family:Verdana, Geneva, sans-serif; font-size:11px"  width="900"  >

<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;">
NICKNAME
</td>

<td  style="background-color:#999; color:#FFF;border:1px solid #666;">
RAZON SOCIAL
</td>

<td style="background-color:#999; color:#FFF;border:1px solid #666;">CUENTA WWA</td>

</tr>        
<?
/* parent.document.getElementById('razonsocialc').value='<?=strtoupper($rs['socialreason'])?>';
        parent.document.getElementById('alias').value='<?=strtoupper($rs['socialreason'])?>';*/
		while($rs = mysqli_fetch_array($query)) {
		?>
		<tr style="border:1px solid #666;" 
        onclick="
        parent.document.getElementById('idalias').value='<?=strtoupper($rs['id'])?>';
        parent.document.getElementById('llenado').click();"
        ondblclick="
        parent.document.getElementById('idalias').value='<?=strtoupper($rs['id'])?>';
        parent.document.getElementById('llenado').click();
       
parent.document.getElementById('AliasBox').close()">

<td style="border:1px solid #666; cursor:pointer"><?=$rs['id']?></td>
<td style="border:1px solid #666;; cursor:pointer; color:#F00"><?=strtoupper($rs['nickname'])?></td>
<td style="border:1px solid #666;; cursor:pointer; color:#F00"><?=strtoupper($rs['socialreason'])?></td>
        
        <td style="border:1px solid #666;; cursor:pointer"><input type="checkbox"  disabled="disabled" <?=$rs['cuentawwa']=='1' ? 'checked="checked"' :''?> /></td>
		</tr>
        
       
        	
            <!--busqueda de contactos-->
            <?
            $qC= mysqli_query("select * from contactos where idalias = '".$rs[id]."'");
			if(mysqli_num_rows($qC)>0){
			?>
            <tr>
	       
            <td>&nbsp;&nbsp;</td>
            <td colspan="3">
            <table cellspacing="5" cellpadding="5"  width="900" >
            
            <tr style="font-size:10px">
            <td width="161" style="background-color:#0FF; cursor:pointer">CONTACTO</td>
            <td width="86" style="background-color:#0FF; cursor:pointer">TELEFONO</td>
            <td width="79" style="background-color:#0FF; cursor:pointer">EMAIL</td>
            <td width="138" style="background-color:#0FF; cursor:pointer">PUESTO</td>
            <td width="71"  align="center" style="background-color:#0FF;; cursor:pointer;"> TARIFAS</td>
            <td width="74"  align="center" style="background-color:#0FF;; cursor:pointer;"> ITINERARIOS</td>
            <td width="45" style="background-color:#0FF;; cursor:pointer" align="center"> CREO</td>
            <td width="119"  align="center" style="background-color:#0FF;; cursor:pointer">
            VISIBLE EN
            </td> 
            </tr>
            
            <? while($rqc=mysqli_fetch_array($qC)){ ?>
            <tr            
            onclick="parent.document.getElementById('idcontacto').value='<?=$rqc['id']?>';
            parent.document.getElementById('idcontactoA').value='<?=$rqc['id']?>';
            parent.document.getElementById('idalias').value='<?=$rqc['idalias']?>';
            parent.document.getElementById('llenado').click();
            parent.document.getElementById('llenado_contacto').click();
            "
            ondblclick="
            parent.document.getElementById('idcontacto').value='<?=$rqc['id']?>';
            parent.document.getElementById('idcontactoA').value='<?=$rqc['id']?>';
            parent.document.getElementById('idalias').value='<?=$rqc['idalias']?>';
             parent.document.getElementById('llenado').click();
            parent.document.getElementById('llenado_contacto').click();
   			parent.document.getElementById('AliasBox').close()">

            <td style="background-color:#9FF; cursor:pointer"><?=$rqc['contacto']?></td>
            <td style="background-color:#9FF; cursor:pointer"><?=$rqc['telefono_contacto']?></td>
            <td style="background-color:#9FF; cursor:pointer"><?=strtolower($rqc['email_contacto'])?></td>
            <td style="background-color:#9FF; cursor:pointer"><?=$rqc['puesto']?></td>
            
            <td style="background-color:#9FF;; cursor:pointer" align="center">
            <input type="checkbox"  disabled="disabled" <?=$rqc['mailing_tarifarios']==1 ? 'checked="checked"' :''?> /></td>
            <td style="background-color:#9FF;; cursor:pointer"  align="center">
            <input type="checkbox"  disabled="disabled" <?=$rqc['mailing_itinerarios']=='1' ? 'checked="checked"' :''?> /></td>
            
            <td style="background-color:#9FF;; cursor:pointer" align="center">
			<?=strtoupper($rqc['area'])?>
			</td>
            <td style="background-color:#9FF;; cursor:pointer"  align="center">
            C <input type="checkbox"  disabled="disabled" <?=$rqc['visible_en_comercial']=='1' ? 'checked="checked"' :''?> />
            E <input type="checkbox"  disabled="disabled" <?=$rqc['visible_en_expo']=='1' ? 'checked="checked"' :''?> />
            I <input type="checkbox"  disabled="disabled" <?=$rqc['visible_en_impo']=='1' ? 'checked="checked"' :''?> />
            </td> 
            </tr>
            <? } ?>
            </table>
            </td>
            </tr>
            
            <? } ?>
		
		<?	
		}
		?>

    </table>
       
<? }else{ ?>

B&uacute;squeda sin resultados

<? }  
?>

