<?php 
session_start();
include('../cfg/cfg.php');
include('../cfg/res.php');
if(empty($_SESSION['user_vcrx_tipo']) || !isset($_SESSION['user_vcrx_tipo']))
{
	die('<a href="../salir.php">SU SESSION EXPIRO.</a>');
}


$pagina_descri='ASIGNA CUENTAS ';
$pagina_nivel;
$pagina_tipo;
$month = date('m');
$year = date('Y');
$day = date("d", mktime(0,0,0, $month+1, 0, $year));

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $empr_nombre .' - ' . $_SESSION['user_vcrx_descri'];?></title>
<style type="text/css">
body{ 
margin:0px; 
padding:0px; 
font-family:"Courier New", Courier, monospace;

}
.fecha{ width:100px;}
</style>
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>

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

	
	var fini=document.getElementById('fini').value;
	var ffin=document.getElementById('ffin').value;
	var proveedor=document.getElementById('proveedor').value;
	var item=document.getElementById('item').value;
	var numero=document.getElementById('numero').value;
	
	var prov_order='0';
	if(document.getElementById('prov_order').checked)
	{				
		prov_order='1';
	}

	var docu_order='0';
	if(document.getElementById('docu_order').checked)
	{				
		docu_order='1';
	}
	
	var fecha_order='0';
	if(document.getElementById('fecha_order').checked)
	{				
		fecha_order='1';
	}

	
	
	$.ajax({
		cache:false,
		url:'vrasigc2.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{
				fini:fini,
				ffin:ffin,
				proveedor:proveedor,
				item:item,
				numero:numero,
				prov_order:prov_order,
				fecha_order:fecha_order,
				docu_order:docu_order
				
				}, 
    	beforeSend: function(jqXHR, textStatus)
		{
	
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			console.log(textStatus);
			console.log(jqXHR);
			//console.log(dato);
			document.getElementById('consulta_detalle').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') {
               //console.log('Time out error.');
			   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
	});



}

function _asignar(idnum,iddet)
{
	var itemx=document.getElementById('item_'+idnum+'_'+iddet).value;
	var ctasx=document.getElementById('ctas_'+idnum+'_'+iddet).value;
	console.log(itemx);
	console.log(ctasx);
		$.ajax({
		cache:false,
		url:'vrasigc3.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{
				idnum2:idnum,
				iddet:iddet,
				item:itemx,
				ctas:ctasx
			}, 
    	beforeSend: function(jqXHR, textStatus)
		{
	
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			console.log(textStatus);
			console.log(jqXHR);
			console.log(dato);
			document.getElementById('error_'+idnum+'_'+iddet).innerHTML=dato;
			//document.getElementById('consulta_detalle').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') {
               //console.log('Time out error.');
			   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>
</head>

<body>
<div align="center">
	<div>
	<div align="center"><?php include('../../_lib/cabecera2.php');?></div>
<div>
<table width="100%" cellpadding="4">
<tr valign="top" align="center">
	<td width="19%">
    	<div style="font-weight:bolder;">Fechas</div>
        <div style="text-align:right;">FIni<input type="text" class="fecha" id="fini" placeholder="aaaa-mm-dd" value="<?php echo date('Y-m-01');?>" /></div>
        <div style="text-align:right;">FFin<input type="text"  class="fecha" id="ffin" placeholder="aaaa-mm-dd" value="<?php echo date('Y-m').'-'.$day;?>" /></div>
    </td>
    <td width="21%">
    	<div style="font-weight:bolder;">Ordenar por</div>
        <div style="text-align:left;"><input type="checkbox" id="prov_order"  />Proveedor</div>
        <div style="text-align:left;"><input type="checkbox" id="docu_order"  />Documento</div>
        <div style="text-align:left;"><input type="checkbox" id="fecha_order" />Fecha</div>
    </td>
    <td width="27%">
	    <div  style="font-weight:bolder;">Filtros</div>
        <div style="text-align:right;">Proveedor<input type="text" id="proveedor" /></div>
        <div style="text-align:right;">Item<input type="text" id="item" /></div>
        <div style="text-align:right;">Numero<input type="text" id="numero" /></div>
    </td>
    <td width="33%">
    	<div><input type="button" value="Consultar" onclick=" _consultar();" /></div>
    </td>
</tr>
</table>

<div id="consulta_detalle"></div>
</div>

</div>
</div>

</body>
</html>