<?php

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

$xacceso=0;
$sql_acce='select * from usrdoc1 where docu like "ROL%" and info="1" and user="'.$_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 Roles de Pago ' );}	

	
mysql_query("SET NAMES 'utf8'");
$fecha1 = date('Y-m-j');
$nuevafecha = strtotime ( '-1 month' , strtotime ( $fecha1 ) ) ;
$xfecha1 = date ( 'Y-m-j' , $nuevafecha );
$xfecha1= date('Y-m-'.'01');
$xfecha2= date('Y-m-d');

$xfgrou='E';	
$xforde='D';
$xfcodi='1';

	
$sql_upd='update nvdd0 set nvdd_abrev=nvdd_descri where nvdd_abrev="" or nvdd_abrev is null';
$res_upd=mysql_query($sql_upd,$link_vcrx);
	
	
?>



<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==9 || e.keyCode==13)
	if(e.keyCode==13)
	{
		var fn=document.getElementById(idfec).value;
		fn=fecha_format(fn);
		document.getElementById(idfec).value=fn;
	}
}


function rolpt1d(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('rolptot2').innerHTML='Cargando...';
$.ajax({
		cache:false,
		url:'../lib/vrrolpt1d.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('rolptot2').innerHTML=dato;
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              document.getElementById('rolptot2').innerHTML='Not connect: Verify Network.';
           } else if (jqXHR.status == 404) {
               document.getElementById('rolptot2').innerHTML='Requested page not found [404]';
           } else if (jqXHR.status == 500) {
               document.getElementById('rolptot2').innerHTML='Internal Server Error [500].';
           } else if (exception === 'parsererror') {
               document.getElementById('rolptot2').innerHTML='Requested JSON parse failed.';
           } else if (exception === 'timeout') {
               //console.log('Time out error.');
			   document.getElementById('rolptot2').innerHTML='Servidor no Responde';
           } else if (exception === 'abort') {
               document.getElementById('rolptot2').innerHTML='Ajax request aborted.';
           } else {
               document.getElementById('rolptot2').innerHTML='Uncaught Error: ' + jqXHR.responseText;
           }

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

}



function redireccionar() 
{
var docu=document.getElementById('docu').value;
var enti=document.getElementById('enti').value;
var item=document.getElementById('item').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 fgroud=document.getElementById('fgroud').checked;
var fgroue=document.getElementById('fgroue').checked;
var fgroui=document.getElementById('fgroui').checked;
var fgroum=document.getElementById('fgroum').checked;
var fgrous=document.getElementById('fgrous').checked;
// var fgrouf=document.getElementById('fgrouf').checked;
var fgrour=document.getElementById('fgrour').checked;
// var fgroup=document.getElementById('fgroup').checked;
var fgrouc=document.getElementById('fgrouc').checked;
var fgroug=document.getElementById('fgroug').checked;

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


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

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

if (fcodis){fcodi='1';}
if (fcodia){fcodi='2';}
if (fcodie){fcodi='3';}
	
	
if (fgroud){fgrou='D';}
if (fgroue){fgrou='E';}
if (fgroui){fgrou='I';}
if (fgroum){fgrou='M';}
if (fgrous){fgrou='S';}
// if (fgrouf){fgrou='F';}
if (fgrour){fgrou='R';}
// if (fgroup){fgrou='P';}
if (fgrouc){fgrou='C';}
if (fgroug){fgrou='G';}

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



pagina="?opt=<?php echo $_GET['opt']?>" 
+"&fecha_ini="+fecha_ini 
+"&fecha_fin="+fecha_fin 
+"&fgrou="+fgrou
+"&fcodi="+fcodi
+"&forde="+forde
+"&docu="+docu
+"&enti="+enti
+"&item="+item;

		$.ajax({
		cache:false,
		url:'vrrolpt2.php',
		datatype: "text",
	    async:true,
		type:'POST',
		data:{opt:"<?php echo $_GET['opt']?>",
		fecha_ini:fecha_ini,
		fecha_fin:fecha_fin,
		fgrou:fgrou,
		fcodi:fcodi,
		forde:forde,
		docu:docu,
		enti:enti,
		item:item,
		}, 
    	beforeSend: function(jqXHR, textStatus)
		{
	                  
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
	
			
			document.getElementById('rolptot1').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 docu=document.getElementById('docu').value;
var enti=document.getElementById('enti').value;
var item=document.getElementById('item').value;
var ptov=document.getElementById('ptov').value;

var flsub=document.getElementById('flsub').value;
var fzsub=document.getElementById('fzsub').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 fgroud=document.getElementById('fgroud').checked;
var fgroue=document.getElementById('fgroue').checked;
var fgroui=document.getElementById('fgroui').checked;
var fgroum=document.getElementById('fgroum').checked;
var fgrous=document.getElementById('fgrous').checked;
// var fgrouf=document.getElementById('fgrouf').checked;
var fgrour=document.getElementById('fgrour').checked;
// var fgroup=document.getElementById('fgroup').checked;
var fgrouc=document.getElementById('fgrouc').checked;
var fgroug=document.getElementById('fgroug').checked;

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

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

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

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


if (fgroud){fgrou='D';}
if (fgroue){fgrou='E';}
if (fgroui){fgrou='I';}
if (fgroum){fgrou='M';}
if (fgrous){fgrou='S';}
// if (fgrouf){fgrou='F';}
// if (fgroup){fgrou='P';}
if (fgrouc){fgrou='C';}
if (fgroug){fgrou='G';}

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



pagina="../lib/impr_rolpt0.php?"
+"&fecha_ini="+fecha_ini 
+"&fecha_fin="+fecha_fin 
+"&fgrou="+fgrou
+"&fcodi="+fcodi
+"&forde="+forde
+"&fdocu="+docu
+"&fenti="+enti
+"&fitem="+item
;

if (fgrou=="R")
{
pagina="../lib/impr_rolxe0.php?"
+"&fecha_ini="+fecha_ini 
+"&fecha_fin="+fecha_fin 
+"&fgrou="+fgrou
+"&fcodi="+fcodi
+"&forde="+forde
+"&fenti="+enti;
	
// +"&fcsub="+fcsub;
	
}
window.open(pagina);


} 


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

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

</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 style ="border-left:solid 1px;">
<div align="center">
<span>REPORTE X</span>
</div>
<div>
		<?php $pname="fgroup"; $pidtxt='fgroue'; $pcaption='Empleado'; if($xfgrou=='E'){$pdefa='checked';}; include('vrradio.php'); ?>	
		<?php $pname="fgroup"; $pidtxt='fgroui'; $pcaption='Novedad'; if($xfgrou=='I'){$pdefa='checked';}; include('vrradio.php'); ?>	
		<?php $pname="fgroup"; $pidtxt='fgrouc'; $pcaption='Centro'; if($xfgrou=='C'){$pdefa='checked';}; include('vrradio.php'); ?>	
</div>
</th>
	
<th style ="border-left:solid 0px;">
<div align="center">
<span>.</span>
</div>
<div>
		<?php $pname="fgroup"; $pidtxt='fgroud'; $pcaption='Documento'; if($xfgrou=='D'){$pdefa='checked';}; include('vrradio.php'); ?>	
		<?php $pname="fgroup"; $pidtxt='fgrour'; $pcaption='Rol X Empleado'; if($xfgrou=='R'){$pdefa='checked';}; include('vrradio.php'); ?>	
		<?php $pname="fgroup"; $pidtxt='fgroug'; $pcaption='Rol General'; if($xfgrou=='G'){$pdefa='checked';}; include('vrradio.php'); ?>	
</div>
</th>
	
	
<!-- 
<th>
<div>
<input type="hidden" id="fgroup" name="fgroup" <?php if($xfgrou=='P'){echo 'checked';}?>/><span></span> <br/>
<input type="hidden" id="fgrouv" name="fgroup" <?php if($xfgrou=='V'){echo 'checked';}?>/><span></span> <br/>
<input type="hidden" id="fgrouz" name="fgroup" <?php if($xfgrou=='Z'){echo 'checked';}?>/><span></span> <br/>
</div>
</th>
 -->
<th>
<div>
<div><br/>	</div>

<input type="hidden" id="fgroum" name="fgroup" <?php if($xfgrou=='M'){echo 'checked';}?>/><span></span> <br/>
<input type="hidden" id="fgrous" name="fgroup" <?php if($xfgrou=='S'){echo 'checked';}?>/><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/>
<input type="radio" id="fordet" name="forder" <?php if($xforde=='T'){echo 'checked';}?>/><span>Totales</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 align="center" style ="border-left:solid 1px;">
<?php $pcaption='Consultar';  $ponclick="redireccionar();" ;include('vrbutton.php'); ?>
<br>
<?php $pcaption='Imprimir';  $ponclick="imprimirlista();" ;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;">
<table>
	<tr>
		<?php $pcaption='Empleado';  $ptabla='enti'; $pidtxt='enti'; $pdefa=$xfenti; $pnotob=1; include('vrgetcod.php'); ?>
	</tr>
</table>	
	</th>
<th style ="border-left:solid 1px;">
<table>	
	<tr>
		<?php $pcaption='Item';  $ptabla='item'; $pidtxt='item'; $pdefa=$xfitem; $pnotob=1; include('vrgetcod.php'); ?>
	</tr>
</table>	
	</th>	
<th style ="border-left:solid 1px;">
<table>	
	<tr>
		<?php $pcaption='Docu';  $ptabla='docu'; $pidtxt='docu'; $pdefa=$xfdocu; $pnotob=1; include('vrgetcod.php'); ?>
	</tr>
</table>	
</th>
</div>
</th>
</tr>
</table>	
	
</div>

<hr/>


<div id="rolptot1" style="overflow-y:scroll; height:300px;"></div>

<br>
<div id="rolptot2"></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 }?>