<?php

function enti_tot()
{
require('../cfg/res.php');

mysql_query('update enti0 set enti_descri=enti_razsoc where enti_descri="" or enti_descri is null',$link_vcrx);

$xacceso=0;
// $sql_acce='select * from usrdoc1 where docu like "ENTI%" and cons="1" and user="'.$_SESSION['user_vcrx_id'].'" ';
$sql_acce='select * from usrdoc1 where docu like "ITEM%" and cons="1" and (user="'.$_SESSION['user_vcrx_id'].'" or cedula="'.$_SESSION['user_vcrx_id'].'" or codigo="'.$_SESSION['user_vcrx_id'].'")';
	
$res_acce=mysql_query($sql_acce,$link_vcrx);
if (mysql_num_rows($res_acce)!=0){$xacceso=1;}
if (mb_stristr('sist.supe',$_SESSION['user_vcrx_tipo'])){$xacceso=1;}
if ($xacceso==0){echo '<font size="8" color="red"><b>';die('No tiene acceso a Lista de Entidades ' );}	

$xaccecont=0;
$sql_acce='select * from usrdoc1 where docu like "DD%" and info="1" and user="'.$_SESSION['user_vcrx_id'].'" ';
$res_acce=mysql_query($sql_acce,$link_vcrx);
if (mysql_num_rows($res_acce)!=0){$xaccecont=1;}
if (mb_stristr('sist.supe',$_SESSION['user_vcrx_tipo'])){$xaccecont=1;}
	
	
// $res_m=mysql_query('alter table adrs0 modify column adrs_codigo int not null auto_increment first',$link_vcrx);
// echo $res_m;
	
$xfgrou='Z';
$xforde='D';
$xfcodi='1';
$xfentt='4';

// COMPLETA DESCRIP

// 		+'case ';
// 			+'when left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and length(enti_codigo)=10 then "C" ';
// 			+'when left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and length(enti_codigo)=13 then "R" ';
// 			+'when left(enti_codigo,2)="99" and length(enti_pasaporte)>0 then "P" ';
// 			+'when left(enti_codigo,2)="99" and length(enti_pasaporte)=0 then "F" ';
// 			+'else "-" end as enti_tipoid,';
// 		+'case ';
// 			+'when left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and substr(enti_codigo,3,1)<="5" then "N" ';
// 			+'when left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and substr(enti_codigo,3,1)="6" then "P" ';
// 			+'when left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and substr(enti_codigo,3,1)="9" then "J" ';
// 			+'else "-" end as enti_tiporuc,';

$sql_adrs0='update adrs0 set adrs_status="-" where adrs_status is null';
$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);

$sql_enti0='update enti0 set enti_status="-" where enti_status is null';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);

$sql_enti0='update enti0 set enti_sexo=0 where substr(enti_codigo,3,1)>5 ';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
	
$sql_enti0='update enti0, entisexo set enti0.enti_sexo=entisexo.enti_sexo ';
$sql_enti0.='where enti0.enti_nom1=entisexo.enti_nom1 and enti_nom1>"" and enti0.enti_sexo!=1 and enti0.enti_sexo!=2';
// $sql_enti0.='    and enti_nom1>"" ';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
	
$sql_enti0='update enti0 set enti_codigo=trim(enti_codigo),enti_descri=trim(enti_descri),enti_razsoc=trim(enti_razsoc),enti_nomcom=trim(enti_nomcom),enti_ape1=trim(enti_ape1),enti_ape2=trim(enti_ape2),enti_nom1=trim(enti_nom1),enti_nom2=trim(enti_nom2)';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
$sql_enti0='update enti0 set enti_calle1=trim(enti_calle1),enti_calle2=trim(enti_calle2),enti_calle3=trim(enti_calle3),enti_callen=trim(enti_callen)';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);

$sql_enti0='update enti0 set enti_descri="" where enti_descri is null';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
	
$sql_enti0='update enti0 set enti_codigo=concat(enti_codigo,"001") where length(enti_codigo)=10 and left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and (substr(enti_codigo,3,1)="6" or substr(enti_codigo,3,1)="9")';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);

	
$sql_enti0='update enti0 set enti_descri=concat(enti_ape1," ",enti_ape2," ",enti_nom1," ",enti_nom2) where enti_descri="" and length(enti_codigo)=10 and left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and substr(enti_codigo,3,1)<="5"';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
$sql_enti0='update enti0 set enti_descri=enti_razsoc where enti_descri="" and length(enti_codigo)=13 and left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and (substr(enti_codigo,3,1)="6" or substr(enti_codigo,3,1)="9")';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
$sql_enti0='update enti0 set enti_nomcom=enti_razsoc where enti_nomcom="" and length(enti_codigo)=13 and left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and (substr(enti_codigo,3,1)="6" or substr(enti_codigo,3,1)="9")';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);

$sql_enti0='update enti0 set enti_razsoc=enti_descri where enti_razsoc="" and length(enti_codigo)=13 and left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and (substr(enti_codigo,3,1)="6" or substr(enti_codigo,3,1)="9")';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
$sql_enti0='update enti0 set enti_nomcom=enti_descri where enti_nomcom="" and length(enti_codigo)=13 and left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24" and (substr(enti_codigo,3,1)="6" or substr(enti_codigo,3,1)="9")';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);

	
$sql_enti0='update enti0 set enti_descri=upper(enti_descri), enti_nom1=upper(enti_nom1), enti_nom2=upper(enti_nom2),enti_ape1=upper(enti_ape1), enti_ape2=upper(enti_ape2)';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
$sql_enti0='update enti0 set enti_direccion=upper(enti_direccion), enti_calle1=upper(enti_calle1), enti_calle2=upper(enti_calle2),enti_callen=upper(enti_callen), enti_calle3=upper(enti_calle3)';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
	
$sql_enti0='update enti0 set enti_direccion="" where enti_direccion is null';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);
$sql_enti0='update enti0 set enti_direccion=concat(enti_calle1," /",enti_callen,"/",enti_calle2," //",enti_calle3) where enti_direccion=""';
$res_enti0=mysql_query($sql_enti0,$link_vcrx);

$sql_adrs0='update adrs0 set adrs_calle1=upper(adrs_calle1),adrs_calle2=upper(adrs_calle2),adrs_calle3=upper(adrs_calle3),adrs_callen=upper(adrs_callen),adrs_email=lower(adrs_email)';
$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);

$sql_adrs0='update adrs0 set adrs_calle1=trim(adrs_calle1),adrs_calle2=trim(adrs_calle2),adrs_calle3=trim(adrs_calle3),adrs_callen=trim(adrs_callen)';
$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);
$sql_adrs0='update adrs0 set adrs_descri="" where adrs_descri is null';
$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);
$sql_adrs0='update adrs0 set adrs_direccion="" where adrs_direccion is null';
$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);
$sql_adrs0='update adrs0 set adrs_direccion=concat(adrs_calle1," (",adrs_callen,") ",adrs_calle2," /",adrs_calle3) where adrs_direccion=""';
$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);

	
	
// $sql_enti0='update enti0 set descri= case ';
// $sql_enti0.='when (enti_descri="" or enti_descri is null) and (left(enti_codigo,2)>="01" and left(enti_codigo,2)<="24") and (length(enti_codigo)=10 ';
// $res_enti0=mysql_query($sql_enti0,$link_vcrx);
	
	
	
	
if (1==0)
{
// CARGA DATOS DE DIRECCIONES	
	
$sql_enti0='select distinct enti_codigo from enti00 ';
	$sql_enti0.='where length(enti_codigo)>=10 and (enti_adrs=0 or enti_adrs is null)  ';
	$sql_enti0.='and (enti_tipoid = "C" or enti_tipoid="R") ';
	$sql_enti0.='and ((enti_calle1>"" and enti_calle1 is not null)or(enti_direccion>"" and enti_direccion is not null)) ';
	$sql_enti0.='order by enti_codigo';
// echo $sql_enti0;	
$res_enti0=mysql_query($sql_enti0,$link_vcrx);

while($r_enti0=mysql_fetch_assoc($res_enti0))
{
	$xenti=trim($r_enti0['enti_codigo']);

	$sql_adrs0='select * from adrs0 where trim(adrs_enti)="'.$xenti.'" order by adrs_codigo';
	$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);
	if (mysql_num_rows($res_adrs0)==0)
	{
		$sql_adrs0='insert into adrs0(adrs_enti) value("'.$xenti.'")';
		$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);
// 		echo $sql_adrs0."\n";
	}

// 	$sql_adrs0='select * from adrs0 where trim(adrs_enti)="'.$xenti.'" order by adrs_defa desc,adrs_codigo';
// 	$res_adrs0=mysql_query($sql_adrs0,$link_vcrx);

// 	$xadrs=mysql_result($res_adrs0,0,'adrs_codigo');
// 	$sql_entiu='update enti0 set enti_adrs='.$xadrs.' where enti_codigo="'.$xenti.'" and (enti_adrs="" or enti_adrs is null)';
// 	$res_entiu=mysql_query($sql_entiu,$link_vcrx);

// 	if (mysql_num_rows($res_adrs0)==1)
// 	{	
// 	$xadrs=mysql_result($res_adrs0,0,'adrs_codigo');
// 	$sql_entiu='update enti0 set enti_adrs='.$xadrs.' where enti_codigo="'.$xenti.'"';
// 	$res_entiu=mysql_query($sql_entiu,$link_vcrx);
// 	}

// 	if (mysql_num_rows($res_adrs0)>1)
// 	{	
// 	$xadrs=mysql_result($res_adrs0,0,'adrs_codigo');
// 	$sql_entiu='update enti0 set enti_adrs='.$xadrs.' where enti_codigo="'.$xenti.'" and (enti_adrs="" or enti_adrs is null)';
// 	$res_entiu=mysql_query($sql_entiu,$link_vcrx);
// 	}	
}
}	
$sql_adrsu='update adrs0,enti0 set ';
$sql_adrsu.='	adrs_defa=1,';
$sql_adrsu.='	adrs_direccion=enti_direccion,';
$sql_adrsu.='	adrs_tlfn=enti_telefono,';
$sql_adrsu.='	adrs_calle1=enti_calle1,';
$sql_adrsu.='	adrs_calle2=enti_calle2,';
$sql_adrsu.='	adrs_calle3=enti_calle3,';
$sql_adrsu.='	adrs_callen=enti_callen,';
$sql_adrsu.='	adrs_cdad=enti_cdad, ';
$sql_adrsu.='	adrs_status="-" ';
$sql_adrsu.='	where adrs_codigo=enti_adrs and adrs_enti=enti_codigo';
$res_adrsu=mysql_query($sql_adrsu,$link_vcrx);

$sql_adrsu='	update adrs0 set adrs_status="-" where adrs_status is null';
// $res_adrsu=mysql_query($sql_adrsu,$link_vcrx);

// 	echo $sql_adrsu;
	
	
// mysql_query('insert into adrs0(adrs_enti) select distinct enti from vtas1 where status!="X" and status!="O" and enti not in(select adrs_enti from adrs0) ',$link_vcrx);
// mysql_query('insert into adrs0(adrs_enti) select distinct enti from comp1 where status!="X" and status!="O" and enti not in(select adrs_enti from adrs0) ',$link_vcrx);
// mysql_query('insert into adrs0(adrs_enti) select distinct enti from nomi1 where status!="X" and status!="O" and enti not in(select adrs_enti from adrs0) order by enti',$link_vcrx);

// mysql_query('update adrs0,enti0 set adrs_calle1=enti_calle1       where adrs_enti=enti_codigo and adrs_calle1 is null or adrs_calle1=""',$link_vcrx);
// mysql_query('update adrs0,enti0 set adrs_calle2=enti_calle2       where adrs_enti=enti_codigo and adrs_calle2 is null or adrs_calle2=""',$link_vcrx);
// mysql_query('update adrs0,enti0 set adrs_calle3=enti_calle3       where adrs_enti=enti_codigo and adrs_calle3 is null or adrs_calle3=""',$link_vcrx);
// mysql_query('update adrs0,enti0 set adrs_callen=enti_callen       where adrs_enti=enti_codigo and adrs_callen is null or adrs_callen=""',$link_vcrx);
// mysql_query('update adrs0,enti0 set adrs_tlfn=enti_telefono       where adrs_enti=enti_codigo and adrs_tlfn is null or adrs_tlfn=""',$link_vcrx);
// mysql_query('update adrs0,enti0 set adrs_cdad=enti_cdad       where adrs_enti=enti_codigo and adrs_cdad is null or adrs_cdad=""',$link_vcrx);
// mysql_query('update adrs0,enti0 set adrs_direccion=enti_direccion where adrs_enti=enti_codigo and adrs_direccion is null or adrs_direccion=""',$link_vcrx);
	
	
mysql_query("SET NAMES 'utf8'");
$fecha1 = date('Y-m-j');
$nuevafecha = strtotime ( '-12 month' , strtotime ( $fecha1 ) ) ;
// $xfecha1 = date ( 'Y-m-j' , $nuevafecha );
$xfecha1 = date ( 'Y-m-01' , $nuevafecha );
// $xfecha1= date('Y-m'.'-01');
// $xfecha1= date('2000-01-01');
$xfecha2= date('Y-m-d');

?>



<script type="text/javascript">
<?php include('../../_js/busca_maes3.js');?>
<?php include('../../_js/lista_maes3.js');?>
<?php include('../../_js/fecha_format.js');?>


function _fecha(e,idfec)
{
// 	if(e.keyCode==13)
if(e.keyCode==9 || e.keyCode==13)
	{
		var fn=document.getElementById(idfec).value;
		fn=fecha_format(fn);
		document.getElementById(idfec).value=fn;
	}
}



function entil1d(grupox,idnumx,obj)
{
	
	
	var obj2=obj.parentNode;
	var obj3=obj2.parentNode;	
	for(i=0;i<=document.getElementsByClassName('filax').length-1;i++)
	{
		document.getElementsByClassName('filax').item(i).style.background='#fff';
	}
       obj3.style.background='#09c';

document.getElementById('entilot2').innerHTML='Cargando...';
$.ajax({
		cache:false,
		url:'../lib/vrentil1d.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{grupo:grupox,idnum:idnumx,fini:document.getElementById('fecha_ini').value,ffin:document.getElementById('fecha_fin').value},
    	beforeSend: function(jqXHR, textStatus)
		{
	
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			 console.log(dato);
			 document.getElementById('entilot2').innerHTML=dato;
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              document.getElementById('entilot2').innerHTML='Not connect: Verify Network.';
           } else if (jqXHR.status == 404) {
               document.getElementById('entilot2').innerHTML='Requested page not found [404]';
           } else if (jqXHR.status == 500) {
               document.getElementById('entilot2').innerHTML='Internal Server Error [500].';
           } else if (exception === 'parsererror') {
               document.getElementById('entilot2').innerHTML='Requested JSON parse failed.';
           } else if (exception === 'timeout') {
               //console.log('Time out error.');
			   document.getElementById('entilot2').innerHTML='Servidor no Responde';
           } else if (exception === 'abort') {
               document.getElementById('entilot2').innerHTML='Ajax request aborted.';
           } else {
               document.getElementById('entilot2').innerHTML='Uncaught Error: ' + jqXHR.responseText;
           }

		}, 
	    complete:function(jqXHR, textStatus)
    	{
			
			if(textStatus==='success')
	        {
 
			}           
		},
		timeout:60000
	});

}


function redireccionar(xtipo) 
{
var enti=document.getElementById('enti').value;
var item=document.getElementById('item').value;
var fzsub=document.getElementById('fzsub').value;
var flsub=document.getElementById('flsub').value;
var ftpro=document.getElementById('ftpro').value;
var fcdad=document.getElementById('fcdad').value;
var frcdd=document.getElementById('frcdd').value;
var fvndd=document.getElementById('fvndd').value;
// var fctlg=document.getElementById('fctlg').value;

	
var fecha_ini=document.getElementById('fecha_ini').value;
var fecha_fin=document.getElementById('fecha_fin').value;
fecha_ini=fecha_format(fecha_ini);
if(fecha_ini=='error'){alert('formato de fecha incorrecta'); document.getElementById('fecha_ini').focus();return false;}
fecha_fin=fecha_format(fecha_fin);
if(fecha_fin=='error'){alert('formato de fecha incorrecta'); document.getElementById('fecha_fin').focus();return false;}

var fgrout=document.getElementById('fgrout').checked;
var fgrour=document.getElementById('fgrour').checked;
var fgrouv=document.getElementById('fgrouv').checked;
var fgrouz=document.getElementById('fgrouz').checked;
var fgroul=document.getElementById('fgroul').checked;

var fcodis=document.getElementById('fcodis').checked;
var fcodia=document.getElementById('fcodia').checked;
var fcodie=document.getElementById('fcodie').checked;

var fenttt=document.getElementById('fenttt').checked;
var fenttc=document.getElementById('fenttc').checked;
var fenttp=document.getElementById('fenttp').checked;
var fentte=document.getElementById('fentte').checked;

var fordec=document.getElementById('fordec').checked;
var forded=document.getElementById('forded').checked;

var fgrou='D';
var forde='D';
var fcodi='1';
var fentt='4';

if (fcodis){fcodi='1';}
if (fcodia){fcodi='2';}
if (fcodie){fcodi='3';}

if (fenttc){fentt='1';}
if (fenttp){fentt='2';}
if (fentte){fentt='3';}
if (fenttt){fentt='4';}

	
if (fgrout){fgrou='T';}
if (fgrour){fgrou='R';}
if (fgrouv){fgrou='V';}
if (fgrouz){fgrou='Z';}
if (fgroul){fgrou='L';}

if (fordec){forde='C';}
if (forded){forde='D';}
// console.log(fentt);
	
document.getElementById('entilot1').innerHTML='Cargando datos...';
		$.ajax({
		cache:false,
		url:'vrentil2.php',
		datatype: "text",
	    async:true,
		type:'POST',
		data:{opt:"<?php echo $_GET['opt']?>",
		xtipo:xtipo,
		fecha_ini:fecha_ini,
		fecha_fin:fecha_fin,
		fgrou:fgrou,
		fcodi:fcodi,
		fentt:fentt,
		forde:forde,
		enti:enti,
		item:item,
		fcdad:fcdad,
		fzsub:fzsub,
		ftpro:ftpro,
		flsub:flsub,
		fvndd:fvndd,
		frcdd:frcdd},
    	beforeSend: function(jqXHR, textStatus)
		{
	                  
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
	
			
			document.getElementById('entilot1').innerHTML=dato;
			
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
				if (jqXHR.status === 0) {
	              console.log('Not connect: Verify Network.');
		           } else if (jqXHR.status == 404) {
	               console.log('Requested page not found [404]');
		           } else if (jqXHR.status == 500) {
	               console.log('Internal Server Error [500].');
		           } else if (exception === 'parsererror') {
	               console.log('Requested JSON parse failed.');
		           } else if (exception === 'timeout') {
	               alert('Servidor no Responde');
		           } else if (exception === 'abort') {
	               console.log('Ajax request aborted.');
		           } else {
	               console.log('Uncaught Error: ' + jqXHR.responseText);
           			}
			
			
		   

		}, 
		complete:function(jqXHR, textStatus)
    	{
			if(textStatus==='success')
	        {
				    				    	
			}
		},
		timeout:300000
	});



//location.href=pagina;
} 



//function imprimirlista(entix,entid) 

function imprimirlista() 
{

var enti=document.getElementById('enti').value;
var item=document.getElementById('item').value;

var flsub=document.getElementById('flsub').value;
var fzsub=document.getElementById('fzsub').value;
var ftpro=document.getElementById('ftpro').value;
var fcdad=document.getElementById('fcdad').value;
var frcdd=document.getElementById('frcdd').value;
var fvndd=document.getElementById('fvndd').value;
// var fctlg=document.getElementById('fctlg').value;

var fecha_ini=document.getElementById('fecha_ini').value;
var fecha_fin=document.getElementById('fecha_fin').value;

fecha_ini=fecha_format(fecha_ini);
if(fecha_ini=='error'){alert('formato de fecha incorrecta'); document.getElementById('fecha_ini').focus();return false;}
fecha_fin=fecha_format(fecha_fin);
if(fecha_fin=='error'){alert('formato de fecha incorrecta'); document.getElementById('fecha_fin').focus();return false;}


var fgrout=document.getElementById('fgrout').checked;
var fgrour=document.getElementById('fgrour').checked;
var fgrouv=document.getElementById('fgrouv').checked;
var fgrouz=document.getElementById('fgrouz').checked;
var fgroul=document.getElementById('fgroul').checked;

var fordec=document.getElementById('fordec').checked;
var forded=document.getElementById('forded').checked;

var fcodis=document.getElementById('fcodis').checked;
var fcodia=document.getElementById('fcodia').checked;
var fcodie=document.getElementById('fcodie').checked;

var fenttt=document.getElementById('fenttt').checked;
var fenttc=document.getElementById('fenttc').checked;
var fenttp=document.getElementById('fenttp').checked;
var fentte=document.getElementById('fentte').checked;


	
var fgrou='D';
var forde='D';
var fcodi='1';
var fentt='4';

if (fcodis){fcodi='1';}
if (fcodia){fcodi='2';}
if (fcodie){fcodi='3';}

if (fenttc){fentt='1';}
if (fenttp){fentt='2';}
if (fentte){fentt='3';}
if (fenttt){fentt='4';}
	

	
if (fgrout){fgrou='T';}
if (fgrour){fgrou='R';}
if (fgrouv){fgrou='V';}
if (fgrouz){fgrou='Z';}
if (fgroul){fgrou='L';}

if (fordec){forde='C';}
if (forded){forde='D';}

// console.log(fentt);
// echo fentt;

pagina="../lib/impr_entil0.php?"
+"&fecha_ini="+fecha_ini 
+"&fecha_fin="+fecha_fin 
+"&fgrou="+fgrou
+"&fcodi="+fcodi
+"&fentt="+fentt
+"&forde="+forde
+"&fenti="+enti
+"&fitem="+item
+"&fcdad="+fcdad 
+"&fzsub="+fzsub 
+"&ftpro="+ftpro 
+"&flsub="+flsub 
+"&fvndd="+fvndd
+"&frcdd="+frcdd;
// +"&fctlg="+fctlg;

console.log(pagina);

window.open(pagina);
} 


function _enti(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('enti',document.getElementById('enti').value,'enti','enti_descri','');
	}
}

function _item(e)
{

	if(e.keyCode==9 || e.keyCode==13)
	{
			busca_maes2('item',document.getElementById('item').value,'item','descri','');
	}
}

function _modi(codigo)
{
	console.log(codigo);
	var ctaxcob=document.getElementById('cxc_'+codigo).value;
	var ctaxpag=document.getElementById('cxp_'+codigo).value;
	
	$.ajax({
		cache:false,
		url:'vrmenti0.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{
				codigo:codigo,
				ctaxcob:ctaxcob,
				ctaxpag:ctaxpag
			}, 
    	beforeSend: function(jqXHR, textStatus)
		{
	
		}, 
		success:function(dato, textStatus, jqXHR)
		{
			document.getElementById('error_'+codigo).innerHTML=dato;
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {console.log('Not connect: Verify Network.');}
						else if (jqXHR.status == 404) {console.log('Requested page not found [404]');}
						else if (jqXHR.status == 500) {console.log('Internal Server Error [500].');}
						else if (exception === 'parsererror') {console.log('Requested JSON parse failed.');}
						else if (exception === 'timeout') {alert('Servidor no Responde');}
						else if (exception === 'abort') {console.log('Ajax request aborted.');}
						else {console.log('Uncaught Error: ' + jqXHR.responseText);}

		}, 
	    complete:function(jqXHR, textStatus)
    	{
			if(textStatus==='success'){}           
		},
		timeout:30000
	});

	
}
	
	
	
	
</script>

<div style=" max-height:200px; overflow-y:scroll; margin-top:5px;">

<table id="tabla_filtros" width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse;font-size:12px; border:#000000 solid 1px;">
<tr align="left" valign="top">

<th>
<table>	
	<caption>FECHAS</caption>	
	<tr>
		<?php $pcaption='inicial';  $pidtxt='fecha_ini'; $pdefa=$xfecha1; $pobj=3; include('vrgetfec.php'); ?>
</tr>
	<tr>
		<?php $pcaption='final';  $pidtxt='fecha_fin'; $pdefa=$xfecha2; $pobj=3; include('vrgetfec.php'); ?>
</tr>
</table>
</th>



<th style ="border-left:solid 1px;" >
<div align="center" >
<span>AGRUPADO X</span>
</div>
<div>
<input type="radio" id="fgrouz" name="fgroup" <?php if($xfgrou=='Z'){echo 'checked';}?>/><span>Zonas</span> <br/>
<input type="radio" id="fgrout" name="fgroup" <?php if($xfgrou=='T'){echo 'checked';}?>/><span>Proveedor</span> <br/>
<input type="radio" id="fgrouv" name="fgroup" <?php if($xfgrou=='V'){echo 'checked';}?>/><span>Vendedor</span> <br/>
<input type="radio" id="fgrour" name="fgroup" <?php if($xfgrou=='R'){echo 'checked';}?>/><span>Recaudador</span> <br/>
<input type="radio" id="fgroul" name="fgroup" <?php if($xfgrou=='L'){echo 'checked';}?> style="display:none;"/><span></span> <br/>
</div>
</th>



<th style ="border-left:solid 1px;">
<div align="center">
<span>ORDENADO X</span>
</div>
<div>
<input type="radio" id="forded" name="forder" <?php if($xforde=='D'){echo 'checked';}?>/><span>Nombre</span> <br/>
<input type="radio" id="fordec" name="forder" <?php if($xforde=='C'){echo 'checked';}?>/><span>Codigo</span> <br/>
</div>
</th>

<th style ="border-left:solid 1px;display:none;">
<div align="center">
<span>CODIGOS</span>
</div>
<div>
<input type="radio" id="fcodis" name="tcodi" <?php if($xfcodi=='1'){echo 'checked';}?>/><span>Sistema</span> <br/>
<input type="radio" id="fcodia" name="tcodi" <?php if($xfcodi=='2'){echo 'checked';}?>/><span>Auxiliar</span> <br/>
<input type="radio" id="fcodie" name="tcodi" <?php if($xfcodi=='3'){echo 'checked';}?>/><span>EAN (Barras)</span> <br/>
</div>
</th>

<th style ="border-left:solid 1px;">
<div align="center">
<span>ENTIDADES</span>
</div>
<div>
<input type="radio" id="fenttc" name="fentt" <?php if($xfentt=='1'){echo 'checked';}?>/><span>Clientes</span> <br/>
<input type="radio" id="fenttp" name="fentt" <?php if($xfentt=='2'){echo 'checked';}?>/><span>Proveedores</span> <br/>
<input type="radio" id="fentte" name="fentt" <?php if($xfentt=='3'){echo 'checked';}?>/><span>Empleados</span> <br/>
<input type="radio" id="fenttt" name="fentt" <?php if($xfentt=='4'){echo 'checked';}?>/><span>Todos</span> <br/>

</div>
</th>



<th style ="border-left:solid 1px;">
<div align="center">
<span>FILTROS</span>
</div>
<table>
<tr>
		<?php $pcaption='ENTIDAD';  $ptabla='enti'; $pdefa=$xfenti; $pnotob=1; include('vrgetcod.php'); ?>
</tr>
<tr>
		<?php $pcaption='ZONA';  $ptabla='zsub'; $pidtxt='fzsub'; $pdefa=$xfzsub; include('vrgetcod.php'); ?>
</tr>
<tr>
		<?php $pcaption='T.PROV';  $ptabla='tpro'; $pidtxt='ftpro';  $pdefa=$xftpro; include('vrgetcod.php'); ?>
</tr>
<tr style="display:none;">
		<?php $pcaption='ITEM';  $ptabla='item'; ; include('vrgetcod.php'); ?>
</tr>
</table>	
<!--     	<div align="right">
	    <span><input type="button" id="entilbl" value="ENTIDAD" accesskey="" onClick="list_carga('enti','enti','enti_descri');" /></span> 
	    <input type="text" id="enti" onKeyDown="_enti(event);" placeholder="enti" size="10" style="text-transform:uppercase;" value="<?php echo $xfenti;?>" /> 
        <span id="enti_descri" style="font-weight:bold; height:25px; display:none;"></span>
	</div> -->
<!--     	<div align="right">
	    <span><input type="button" id="itemlbl" value="ITEM" onclick="list_carga('item','item','item_descri','');" style="font-weight:bold" /></span> 
	    <input type="text" id="item" placeholder="item" size="10" onKeyDown="_item(event);" style="text-transform:uppercase;" value="<?php echo $xfitem;?>" /> 
        <span id="item_descri" style="font-weight:bold; height:25px; display:none;"></span>
	</div> -->
</th>

<th>
<table>
<tr >
		<?php $pcaption='Ciudad';  $ptabla='cdad'; $pidtxt='fcdad'; $pdefa=$xfcdad; include('vrgetcod.php'); ?>
</tr>
<tr >
		<?php $pcaption='Vendedor';  $ptabla='vndd'; $pidtxt='fvndd'; $pdefa=$xfvndd; include('vrgetcod.php'); ?>
</tr>
<tr >
		<?php $pcaption='Recaudador';  $ptabla='rcdd'; $pidtxt='frcdd'; $pdefa=$xfrcdd; include('vrgetcod.php'); ?>
</tr>
<tr style="display:none;">
		<?php $pcaption='LINEA';  $ptabla='lsub'; $pidtxt='flsub';  include('vrgetcod.php'); ?>
</tr>
</table>	
	
<!-- <div>
    	<div align="right">
	    <span>Zona</span> 
	    <input type="text" id="fzsub" placeholder="zona" size="10" value="<?php echo $xfzsub;?>" /> 
	</div>
    	<div align="right">
	    <span>Tip.Prov.</span> 
	    <input type="text" id="ftpro" placeholder="zona" size="10" value="<?php echo $xftpro;?>" /> 
	</div>
    	<div align="right">
	    <span>Linea</span> 
	    <input type="text" id="flsub" placeholder="linea" size="10" value="<?php echo $xflsub;?>" /> 
	</div>
</div> -->
</th>

<th style ="border-left:solid 1px;">
</th>


<th align="center" style ="border-left:solid 1px;">
<?php $pcaption='Consultar';  $ponclick="redireccionar(1);" ;include('vrbutton.php'); ?>
<br>
<?php $pcaption='Imprimir';  $ponclick="imprimirlista();" ;include('vrbutton.php'); ?>
<br>
<?php //$pcaption='Nuevo';  $ponclick="window.open('nenti1.php','_blank');" ;include('vrbutton.php'); ?>
<?php $pcaption='Nuevo';  $ponclick="php_func('new_enti()');redireccionar();" ;include('vrbutton.php'); ?>
	
</th>
</tr>
</table>

<table id="tabla_filtros2" width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse;font-size:12px; border:#000000 solid 1px;">
<tr>
<!-- <th>FILTROS</th> -->
<th style ="border-left:solid 1px;" valign="top" >
<table>
</table>	
</th>

<th style ="border-left:solid 1px;">
<table>
</table>	
</th>

<th style ="border-left:solid 1px;">
<table>
</table>
</th>

<th style ="border-left:solid 1px;">
<table>
</table>
</th>
	
	
<th style ="border-left:solid 1px; <?php if ($xaccecont==0){echo 'display:none;';}?>">
<table align="center">

<th align="center" style ="border-left:none 1px;">
<?php $pcaption='Cuentas';  $ponclick="redireccionar('4');" ;include('vrbutton.php'); ?>
<!-- 	<br> -->
<?php //$pcaption='Modif.Det.';  $ponclick="redireccionar('2');" ;include('vrbutton.php'); ?>
</th>
	
</table>
</th>
	
	
</tr>
</table>
</div>
<hr/>

<div id="entilot1" style="overflow-y:scroll;overflow-x:scroll; height:250px;"></div>
<br>
<div id="entilot2" style="overflow-x:scroll;"></div>

<?php		
// $xwidth=40;	
require('lista_car.php');
?>	
<!-- 
<div id="lista_temporal_contenedor" style=" display:none; padding:0px; margin:0px; background: #666; opacity:0.5; width:100%; min-height: 100%; height:auto !important;position: fixed;top:0;left:0; z-index:1;" ></div>
<div id="lista_cargador" style=" display:none; background:#FFF;position: fixed; top:50px;z-index:10;" ><img src="../img/ajax-loader.gif" /></div>    
<div id="lista_temporal" style=" display:none; background:#FFF;position: fixed; top:50px;z-index:10; overflow-y:scroll; min-height:50px; max-height:400px; width:100%;" ><img src="../img/ajax-loader.gif" /></div>    
 -->



<?php }?>