<?php
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
?>
<html>
<head>
<title>Seleccionar producto</title> 
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, initial-scale=1.0, user-scalable=no" />
<?php
AddJs();
?>
<link href="css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="ja/funciones.js"></script>
<style>
.tableFixHead          { overflow-y: auto; }
.tableFixHead thead th { position: sticky; top: 0; }

table  { border-collapse: collapse; width: 100%; }
th, td { padding: 3px 3px;  }
th     { background:#666; }
</style>

<script>
$(document).ready(function(){  
   Inicializar();
   jF("TxtNom");
});

function ParseFrm(){
	var width = document.body.clientWidth;
	var height = document.body.clientHeight;
	//document.getElementById("Cli").value=width;
	width=width -10;
	document.getElementById("DivT").style.width=width+"px";
}

function Zet(NOM,RUC,DIR,TEL,EMA,DNI){	
	window.opener.document.Frm.TxtCliente.value=NOM;
	window.opener.document.Frm.TxtRuc.value=RUC;	
	window.opener.document.Frm.TxtDIR.value=DIR;	
	window.opener.document.Frm.TxtTel.value=TEL;
	window.opener.document.Frm.TxtEma.value=EMA;
	window.opener.document.Frm.TxtDni.value=DNI;	
	//
	window.opener.document.Frm.CboVend.focus();
	window.close();
}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?php
include("cli_v_sel_bx.php");
$CX=0;
?>
<body style="background-color:#FFF;padding: 0 0 0 0; margin:0 0 0 0;overflow:hidden;"  onLoad="ParseFrm();" onResize="ParseFrm();">
<form id="Frm" style="padding: 0 0 0 0; margin:0 0 0 0"  method="post" action="cli_ven_sel.php" autocomplete="off">
<input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<input name="TxtAc" type="hidden" id="TxtAc" value="" />
<input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
<div class="container" style="max-width:95%; margin:0 0 0 0; padding:0 0 0 0">   
    <div  style="height:100vh;">  
       <table id="Tab"  border="0" cellspacing="0" cellpadding="0" style="background-color:#FFF; height:100%; width:98%">
       
       <tr style="height:5%;">
       <td valign="top">
       <div style="height:100%; width:100%; background-color:#09C; min-height:50px; vertical-align:middle" >
            <table width="90%" border="0" height="100%" style="margin:0 0 0 0; padding: 0 0 0 0">
            <tr>
            <td width="15px">&nbsp;</td>
            <td width="48px"><img src="b.png" width="48" height="48" longdesc="../sales.png"></td>
            <td style="color:#FFF"><b>SELECCIONAR CLIENTES</b></td>
            <td >&nbsp;</td>
            </tr>
            </table>
       </div>
       </td>
       </tr>
       
       <tr style="height:5%;">
       <td valign="top">
       
     <div class="form-row" style=" margin-left:0px; margin-right:0px">    
    	<div class="form-group col-sm-12" style="margin:0 0 0 0; padding: 0 0 0 0;">
            <table width="100%" border="0" height="100%" style="margin:0 0 0 0; padding: 0 0 0 0">
            <tr>
            <td width="50%">
            <label >NOMBRE / RAZON SOCIAL</label>
            <input name="TxtNom" type="text" id="TxtNom" 
            class="form-control lt" value="<?php echo $StrNom;?>"  
            tabindex="<?php echo ++$TI;?>" />

            </td>            
            <td width="30%">
            <label >CONTACTO</label>
            <input name="TxtCon" type="text" id="TxtCon" 
            class="form-control lt" value="<?php echo $StrCon;?>"  
            tabindex="<?php echo ++$TI;?>"/>
            </td>
            
            <td width="20%">
            <label >RUC</label>
            <input name="TxtRuc" type="text" id="TxtRuc" 
            class="form-control lt" value="<?php echo $StrRuc;?>"  
            tabindex="<?php echo ++$TI;?>"/>
            </td>

            </tr>
            </table>
        </div>            
	</div>
    
     <div class="form-row" style=" margin-left:0px; margin-right:0px">    
    	<div class="form-group col-sm-12" style="margin:0 0 0 0; padding: 0 0 0 0;">
            <table width="100%" border="0" height="100%" style="margin:0 0 0 0; padding: 0 0 0 0">
           
            <tr>
            <td colspan="2" valign="bottom" width="50%">
            <button type="button" id="CmdB" name="CmdB" class="btnp" style="background-color:#F90;width:100%;" 
            onClick="SM('F');" tabindex="<?php echo $CX++?>">Buscar</button>
            </td>
            
            <td valign="bottom" width="50%">
            <button type="button" id="CmdX" name="CmdX" class="btnp" style="background-color:#F90;width:100%;" 
            onClick="window.close()" tabindex="<?php echo $CX++?>">Cerrar</button>
            </td>
            </tr>
            </table>
        </div>            
	</div>
       
       
       </td>
       </tr>
       
       
       <tr style="height:90%">
       <td valign="top">
       <div class="tableFixHead" id="DivT" style="border:1px solid; border-color:#666; height:100%; background-color:#FFF;overflow:auto;">
            <table  style="font-size:0.9rem;" >
            
            <thead>
            
            <tr>
            <td colspan="6" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
            </tr>
            
            <tr>
            <th width="1%">#</th>
            <th width="70%">NOMBRE</th>            
            <th width="28%">RUC</th>
            <th width="1%">#</th>
            </tr>
            </thead>
            <?php
			$CX=0;
			$s="SELECT ID,NOMBRE,CONTACTO,RUC,TEL,CEL,DIRECCION,EMAIL,DNI
				FROM vclientes 
				WHERE ID>0 AND NOMBRE Like '$StrNomT' AND 
				CONTACTO Like '$StrConT' AND RUC Like '$StrRucT' ORDER BY NOMBRE ";
	
			$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
			$rs = grs($s);
			while ($r = $rs->fetch_assoc()){
				$CX++;
				$S_NOM=$r['NOMBRE'];
				$S_RUC=$r['RUC'];
				$S_DIR=$r['DIRECCION'];
				$S_TEL=$r['TEL'];
				$S_EMA=$r['EMAIL'];
				$S_DNI=$r['DNI'];
				//$PR=NF($r['PW'],2);
				$FN="Zet('".$S_NOM."','".$S_RUC."','".$S_DIR."','".$S_TEL."','".$S_EMA."','".$S_DNI."')";
				$CSS="";
				if($CX%2==0){
					$CSS=" style=\"background-color:#CCC\" ";
				}
			?>
                <tr <?php echo $CSS; ?> >
                <td><button type="button" class="btn btn-success" onClick="<?php echo $FN;?>">+</button></td>
                <td><?php echo $r[1];?></td>                
                <td><?php echo $r[3];?></td>                
                <td><button type="button" class="btn btn-success" onClick="<?php echo $FN;?>">+</button></td>
                </tr>
            <?php
			}
			?>
            </table>
       </div>
       </td>
       </tr>   
       </table>
    </div>
</div>
</form>
</body>
</html>
