<?php 
session_start();
require('../cfg/cfg.php');
include('php_gene1.php');
//$pagina_descri='REGISTRO DE DOCUMENTOS -'.time().' ';
$pagina_descri='REGISTRO DE DOCUMENTOS ';
$pagina_nivel;
$pagina_tipo;

?>
<!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 $pagina_descri; ?></title>

<style type="text/css">
body{font-family: courier new;}
body input {font-family: courier new; font-size:14px}
body button {font-family: courier new; font-size:14px;}
body textarea {font-family: courier new; font-size:14px}
.sub_deta{ padding-left:2px;}

#docu{border: solid 1px #000; width:40px; padding-left:2px; text-transform:uppercase;}
#bode{border: solid 1px #000; width:50px; padding-left:2px;}
#numero{border: solid 1px #000; width:80px; padding-left:2px; text-align:right;}
#numer{border: solid 1px #000; width:80px; padding-left:2px; text-align:right;}
#enti{border: solid 1px #000; width:110px; padding-left:2px;}
#concepto{border: solid 1px #000; resize:none;text-transform:uppercase;}
#fecha{border: solid 1px #000; width:150px; font-size:14px; padding-left:2px;}
#bod2{border: solid 1px #000; width:50px; padding-left:2px;}
@media print {

#reg_deta{ font-size:12px;}
/*.tablitita{ font-size:12px; border:none; }*/
#deta_cont{ display:none; visibility:hidden;}
#deta_txt{ display:none; visibility:hidden;}

#doculbl    { border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#docu       { border:none; background:none; color:#000; font-size:10px;}
#docu_descri{ border:none; background:none; color:#000; font-size:10px;}

#bodelbl    { border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#bode       { border:none; background:none; color:#000; font-size:10px;}
#bode_descri{ border:none; background:none; color:#000; font-size:10px;}
#numero{border:none; background:none; color:#000; font-size:10px;}
#numero_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#enti_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#enti {border:none; background:none; color:#000; font-size:10px;}
#concepto_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#concepto{border:none; background:none; color:#000; font-size:10px;}
#fecha_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#fecha{border:none; background:none; color:#000; font-size:10px;}
#table_cont_btn{ display:none;}
.e_detab{ display:none;}
#bode2_btn{border:none; background:none; color:#000; font-size:10px; font-weight:bolder;}
#bod2{border:none; background:none; color:#000; font-size:10px;}
} 
</style>
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
<script type="text/javascript">
var edicion=1;
window.onload = function (){

document.getElementById('docu').addEventListener('onchange',       editar);
document.getElementById('ptov').addEventListener('onchange',       editar);
document.getElementById('ptoe').addEventListener('onchange',       editar);
document.getElementById('bode').addEventListener('onchange',       editar);
document.getElementById('caja').addEventListener('onchange',       editar);
document.getElementById('ctab').addEventListener('onchange',       editar);
document.getElementById('numero').addEventListener('onchange',     editar);
document.getElementById('enti').addEventListener('onchange',       editar);
document.getElementById('concepto').addEventListener('onchange',   editar);
document.getElementById('fecha').addEventListener('onchange',      editar);
document.getElementById('benefic').addEventListener('onchange',    editar);
document.getElementById('valor').addEventListener('onchange',      editar);
document.getElementById('plazo').addEventListener('onchange',      editar);
document.getElementById('vndd').addEventListener('onchange',       editar);
document.getElementById('zsub').addEventListener('onchange',       editar);
document.getElementById('nvdd1').addEventListener('onchange',      editar);
document.getElementById('dcto1').addEventListener('onchange',      editar);
document.getElementById('iva1').addEventListener('onchange',       editar);
document.getElementById('fpag').addEventListener('onchange',       editar);
document.getElementById('suco').addEventListener('onchange',       editar);
document.getElementById('bcos').addEventListener('onchange',       editar);
document.getElementById('numcta').addEventListener('onchange',     editar);
document.getElementById('nomcta').addEventListener('onchange',     editar);
document.getElementById('bod2').addEventListener('onchange',       editar);
document.getElementById('drtr').addEventListener('onchange',       editar);
document.getElementById('bldn').addEventListener('onchange',       editar);
document.getElementById('sntr').addEventListener('onchange',       editar);
document.getElementById('vhcl').addEventListener('onchange',       editar);
document.getElementById('aplidocu').addEventListener('onchange',   editar);
document.getElementById('apliptoe').addEventListener('onchange',   editar);
document.getElementById('aplinumero').addEventListener('onchange', editar);
document.getElementById('atrzdate').addEventListener('onchange', editar);
document.getElementById('atrztime').addEventListener('onchange', editar);
document.getElementById('atrzruc').addEventListener('onchange', editar);
document.getElementById('atrznume').addEventListener('onchange', editar);

/*
document.getElementById('dcto').addEventListener('onfocus', function(){
	if(document.getElementById('dcto1').value!=''){
		document.getElementById('dcto').value=document.getElementById('dcto1').value;}
	});
*/
}

function prueba()
	{
// 		alert(document.getElementById('enti').value);
	}


function editar(){edicion=1;}
function showobj(e)
{
	limpia();
//  	document.getElementById('entidad').setAttribute('defa',document.getElementById('docu').value);
 	document.getElementById('enti').setAttribute('docu',document.getElementById('docu').value);
 	document.getElementById('item').setAttribute('docu',document.getElementById('docu').value);


	document.getElementById('atrzruc').disabled='true';
	
	document.getElementById('error1').style.display='none';
	document.getElementById('btn_final').style.display='none';

	document.getElementById('tr_numero').style.display='none';
	document.getElementById('tr_fecha').style.display='none';
	document.getElementById('tr_fechasale').style.display='none';
	document.getElementById('tr_enti').style.display='none';
	document.getElementById('tr_benefic').style.display='none';
	document.getElementById('tr_concepto').style.display='none';

	document.getElementById('enti_btn').value='ENTIDAD';
	document.getElementById('valorlbl').value='VALOR';
	document.getElementById('puni_btn').value='P.UNIT.';
	document.getElementById('fecha_btn').value='FECHA ';

	document.getElementById('tr_ptov').style.display='none';
	document.getElementById('tr_ptoe').style.display='none';

	document.getElementById('tr_caja').style.display='none';
	document.getElementById('tr_ctab').style.display='none';

	document.getElementById('tr_bcos').style.display='none';
	document.getElementById('tr_numcta').style.display='none';
	document.getElementById('tr_nomcta').style.display='none';

	
	document.getElementById('tr_atrz').style.display='none';
	document.getElementById('tr_suco').style.display='none';
	document.getElementById('tr_fpag').style.display='none';

	document.getElementById('tr_bode').style.display='none';
	document.getElementById('tr_bod2').style.display='none';

	
	document.getElementById('tr_valor').style.display='none';

	document.getElementById('tr_plazo').style.display='none';
	document.getElementById('tr_dcto').style.display='none';
	document.getElementById('tr_iva').style.display='none';
	document.getElementById('tr_vndd').style.display='none';
	document.getElementById('tr_zsub').style.display='none';
	document.getElementById('tr_apli').style.display='none';
	document.getElementById('tr_aplicxcp').style.display='none';

	document.getElementById('tr_drtr').style.display='none';
	document.getElementById('tr_bldn').style.display='none';
	document.getElementById('tr_sntr').style.display='none';
	document.getElementById('tr_vhcl').style.display='none';

	
// detail OFF

	document.getElementById('deta_txt').style.display='none';
	document.getElementById('deta_cxcp').style.display='none';

	document.getElementById('th_item').style.display='none';
	document.getElementById('th_nvdd').style.display='none';
	document.getElementById('th_docum').style.display='none';
// 	document.getElementById('th_descri').style.display='none';
	document.getElementById('th_item_descri').style.display='none';
	document.getElementById('th_docum_descri').style.display='none';
	document.getElementById('th_nvdd_descri').style.display='none';
	document.getElementById('th_fecha2').style.display='none';
	document.getElementById('th_enti2').style.display='none';
	document.getElementById('th_enti2_descri').style.display='none';
	document.getElementById('th_ptoem').style.display='none';
	document.getElementById('th_numer').style.display='none';
	document.getElementById('th_cant').style.display='none';
//RCSA
	document.getElementById('th_puni_o').style.display='none';
	document.getElementById('th_puni_a').style.display='none';
	document.getElementById('th_impo').style.display='none';

//PACO
	document.getElementById('th_cntn').style.display='none';
	document.getElementById('th_cntnf1').style.display='none';
	document.getElementById('th_cntnf2').style.display='none';
	document.getElementById('th_chasis').style.display='none';

	document.getElementById('th_puni').style.display='none';
	document.getElementById('th_pvp1').style.display='none';

	document.getElementById('th_ice').style.display='none';
	document.getElementById('th_dcto').style.display='none';
	document.getElementById('th_iva').style.display='none';
	document.getElementById('th_irbp').style.display='none';
	document.getElementById('th_dispo').style.display='none';
	document.getElementById('th_cobpag').style.display='none';

	document.getElementById('th_ctas').style.display='none';
	document.getElementById('th_ctas_descri').style.display='none';
	document.getElementById('th_debito').style.display='none';
	document.getElementById('th_credito').style.display='none';
	document.getElementById('th_cair').style.display='none';
	document.getElementById('th_base').style.display='none';
	document.getElementById('th_porc').style.display='none';

	document.getElementById('th_csub').style.display='none';

	document.getElementById('th_numserie').style.display='none';
	document.getElementById('th_lote').style.display='none';
	document.getElementById('th_cambio').style.display='none';
	document.getElementById('th_cambio_descri').style.display='none';

	document.getElementById('th_sueldo').style.display='none';
	document.getElementById('th_valanti').style.display='none';
	document.getElementById('th_poranti').style.display='none';
	document.getElementById('th_iess').style.display='none';
	document.getElementById('th_reloj').style.display='none';
	document.getElementById('th_atraso').style.display='none';
	document.getElementById('th_falta').style.display='none';
	document.getElementById('th_h25').style.display='none';
	document.getElementById('th_h50').style.display='none';
	document.getElementById('th_h100').style.display='none';

	document.getElementById('th_de13').style.display='none';
	document.getElementById('th_de14').style.display='none';
	document.getElementById('th_fres').style.display='none';
	
	
	document.getElementById('th_detalle').style.display='none';
	document.getElementById('th_graba').style.display='none';

	document.getElementById('th_lamina').style.display='none';
	document.getElementById('th_largo').style.display='none';
	document.getElementById('th_ancho').style.display='none';





/*
*/

// if(e.keyCode==9 || e.keyCode==13)
var docu=document.getElementById('docu').value;
if(docu!=='')
{
	var tdeta='';
	var ldoc=docu.toLowerCase().substring(0,2);
	
	docu=docu.toLowerCase();
	var empr=document.getElementById('empr_codigo').value
	
	var reg='';
	var reg2='';

	if (docu!='')
	{
	document.getElementById('tr_fecha').style.display='table-row';
	document.getElementById('tr_numero').style.display='table-row';
	document.getElementById('tr_enti').style.display='table-row';
	document.getElementById('tr_concepto').style.display='table-row';
	document.getElementById('btn_final').style.display='table-cell';
	document.getElementById('deta_txt').style.display='block';
	}

	reg='/(fp)/';
// 	if(reg.test(docu))
	if(reg.indexOf(ldoc)>=0)
	{
		document.getElementById('tr_plazo').style.display='table-row';
		document.getElementById('tr_dcto').style.display='table-row';
		document.getElementById('tr_suco').style.display='table-row';
		document.getElementById('tr_fpag').style.display='table-row';
	}
	
// 	reg=/(fp)|(np)/;
// 	if(reg.test(docu))
	reg='/(fp.np)/';
	if('fp.np'.indexOf(ldoc)>=0)
	{
		document.getElementById('tr_atrz').style.display='table-row';
	}
	
// 	reg=/(fp)|(np)|(ap)/;
// 	if(reg.test(docu))
	reg='/(fp.np.ap)/';
	if(reg.indexOf(ldoc)>=0)
	{
		document.getElementById('tr_ptoe').style.display='table-row';
		document.getElementById('enti_btn').value='PROVEEDOR';
		tdeta='itemp';
	}

// 	reg=/(fc)|(fr)|(nv)|(op)/;
// 	if(reg.test(docu))
	reg='/(fc.fr.nv.op.pf)/';
	if(reg.indexOf(ldoc)>=0)
	{
		document.getElementById('tr_ptov').style.display='table-row';
		document.getElementById('tr_plazo').style.display='table-row';
		document.getElementById('tr_vndd').style.display='table-row';
		document.getElementById('tr_zsub').style.display='table-row';
		document.getElementById('tr_dcto').style.display='table-row';

		
		document.getElementById('enti_btn').value='CLIENTE';
		tdeta='itemv';

// 		reg=/(gnya)|(leie)/;
// 		if(reg.test(empr))
		reg='(gnya.leie)';
		if(reg.indexOf(empr)>0)
		{document.getElementById('tr_drtr').style.display='table-row'; }	
	}


// 	reg=/(nc)/;
// 	if(reg.test(docu))
	reg='/(nc)/';
	if(reg.indexOf(ldoc)>=0)
	{
	document.getElementById('tr_ptoe').style.display='table-row';
	document.getElementById('tr_apli').style.display='table-row';
	document.getElementById('tr_aplicxcp').style.display='table-row';
	document.getElementById('enti_btn').value='CLIENTE';
	tdeta='itemv';
	}

// 	reg=/(np)/;
// 	if(reg.test(docu))
	reg='/(np)/';
	if(reg.indexOf(ldoc)>=0)
	{
	document.getElementById('tr_ptoe').style.display='table-row';
	document.getElementById('tr_apli').style.display='table-row';
	document.getElementById('tr_aplicxcp').style.display='table-row';
	document.getElementById('enti_btn').value='PROVEEDOR';
	tdeta='itemp';
	}


// 	reg=/(ie)|(ic)|(iv)|(na)/;
// 	if(reg.test(docu))
	reg='/(ie.ic.iv.na.cc)/';
	if(reg.indexOf(ldoc)>=0)
	{
		document.getElementById('tr_valor').style.display='table-row';
		document.getElementById('tr_caja').style.display='table-row';
		document.getElementById('enti_btn').value='CLIENTE';
		if (/(ie)/.test(docu)){document.getElementById('valorlbl').value='EFECTIVO';}
		if (/(ic)|(iv)|(cc)/.test(docu))
		{
			document.getElementById('tr_bcos').style.display='table-row';
			document.getElementById('tr_numcta').style.display='table-row';
			document.getElementById('tr_nomcta').style.display='table-row';
		}
		tdeta='docu';
	}

	reg='/(ee.)/';
	if(reg.indexOf(ldoc)>=0)
	{
		document.getElementById('tr_valor').style.display='table-row';
		document.getElementById('tr_caja').style.display='table-row';
		document.getElementById('enti_btn').value='PROVEEDOR';
		if (/(ee)/.test(docu)){document.getElementById('valorlbl').value='EFECTIVO';}
		if (/(ic)|(iv)/.test(docu))
		{
// 			document.getElementById('tr_bcos').style.display='table-row';
// 			document.getElementById('tr_numcta').style.display='table-row';
// 			document.getElementById('tr_nomcta').style.display='table-row';
		}
		tdeta='docu';
	}

	
	
	reg='(db)|(dc)|(ch)|(ev)|(dp)|(ca)|(tb)|(nd)';
// 	if(reg.test(docu))
	if(reg.indexOf(ldoc)>=0)
		
	{document.getElementById('tr_ctab').style.display='table-row';}
		reg='(ch)';
// 		if(reg.test(docu))
	if(reg.indexOf(ldoc)>=0)
			
		{
			document.getElementById('tr_benefic').style.display='table-row';
			tdeta='docu';
		}
		reg='(ch)|(ev)|(dp)|(ca)|(tb)|(nd)|(ee)';
// 	if(reg.test(docu))
	if(reg.indexOf(ldoc)>=0)
		{
			document.getElementById('enti_btn').value='PROVEEDOR';
			tdeta='docu';
		}
// 		reg=/(dc)/;
// 		if(reg.test(docu))
		reg='/(dc.db)/';
		if(reg.indexOf(ldoc)>=0)
		{
			document.getElementById('enti_btn').value='CLIENTE';
			tdeta='docu';
		}

// 	reg=/(ib)|(eb)/;
// 	if(reg.test(docu))
	reg='/(ib.eb)/';
	if(reg.indexOf(ldoc)>=0)
	{	
		document.getElementById('tr_bode').style.display='table-row';
		if(docu.substring(0,1)=='i'){tdeta='itemi';}
			else{tdeta='iteme';}

		if(docu.substring(3,4)=='3')
		{document.getElementById('tr_bod2').style.display='table-row';}

		if(docu.substring(3,4)=='1')
		{tdeta=tdeta+'c';}
	}

// 	reg=/(nm)|(nmn)|(n1)/;
// 	if(reg.test(docu))
	reg='/(nm)/';
	if(reg.indexOf(ldoc)>=0)
	{	
	document.getElementById('tr_numero').style.display='none';
// 	document.getElementById('tr_numero').style.display='table-row';
	document.getElementById('tr_enti').style.display='table-row';
	document.getElementById('tr_fechasale').style.display='table-row';
	document.getElementById('tr_concepto').style.display='none';
	document.getElementById('btn_final').style.display='none';
	document.getElementById('fecha_btn').value='FECHA INGRESO';
	tdeta='nomi';
	}

// 	reg=/(ro)/;
// 	if(reg.test(docu))
	reg='/(ro)/';
	if(reg.indexOf(ldoc)>=0)
	{	
		tdeta='nvdd';
	}


// 	reg=/(qp)/;
// 	if(reg.test(docu))
	reg='/(qp)/';
	if(reg.indexOf(ldoc)>=0)
	{	
		document.getElementById('tr_ptoe').style.display='table-row';
		document.getElementById('tr_bode').style.display='table-row';
		if(docu.substring(0,1)=='i')
		{tdeta='itemq';}
		else
		{tdeta='itemq';}
	}

// 	reg=/(rc)/;
// 	if(reg.test(docu))
	reg='/(rc)/';
	if(reg.indexOf(ldoc)>=0)
	{
		document.getElementById('tr_ptoe').style.display='table-row';
// 		document.getElementById('tr_apli').style.display='table-row';
		document.getElementById('enti_btn').value='CLIENTE';	
		tdeta='rete';
	}

// 	reg=/(rp)/;
// 	if(reg.test(docu))
	reg='/(rp)/';
	if(reg.indexOf(ldoc)>=0)
	{
		document.getElementById('tr_ptoe').style.display='table-row';
		document.getElementById('enti_btn').value='PROVEEDOR';	
		tdeta='rete';
	}

// 	reg=/(dd)/;
// 	if(reg.test(docu))
	reg='/(dd)/';
	if(reg.indexOf(ldoc)>=0)
	{tdeta='ctas';}

	reg2=/(item)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('deta_txt').style.display='table-cell';
		document.getElementById('th_item').style.display='table-cell';
		document.getElementById('th_item_descri').style.display='table-cell';
		document.getElementById('th_cant').style.display='table-cell';

		document.getElementById('th_detalle').style.display='table-cell';
		document.getElementById('th_graba').style.display='table-cell';
	}
	
	reg2=/(itemp)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('th_puni').style.display='table-cell';
		document.getElementById('th_ice').style.display='table-cell';
		document.getElementById('th_dcto').style.display='table-cell';
		document.getElementById('th_iva').style.display='table-cell';
		document.getElementById('th_ctas').style.display='table-cell';
		document.getElementById('th_ctas_descri').style.display='table-cell';
		document.getElementById('th_cair').style.display='table-cell';

		reg=/(yyyy)|(xxxx)/;
		if(reg.test(empr))
		{document.getElementById('th_irbp').style.display='table-cell';}

		
		
		document.getElementById('th_cobpag').style.display='table-cell';
	}

	reg2=/(itemv)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('th_puni').style.display='table-cell';
		document.getElementById('th_dcto').style.display='table-cell';
		document.getElementById('th_iva').style.display='table-cell';
		document.getElementById('th_dispo').style.display='table-cell';
		document.getElementById('th_cobpag').style.display='table-cell';

		reg=/(tcor)|(xxxx)/;
		if(reg.test(empr))
		{document.getElementById('th_ice').style.display='table-cell';}

		reg=/(yyyy)|(xxxx)/;
		if(reg.test(empr))
		{document.getElementById('th_irbp').style.display='table-cell';}

	}
	
	reg2=/(itemq)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('th_puni').style.display='table-cell';
		document.getElementById('th_lote').style.display='table-cell';
	}

// 	reg=/(ib10)/;
// 	if(reg.test(docu))
	reg='/(ib10)/';
	if(reg.indexOf(docu)>0)
	{document.getElementById('th_puni').style.display='table-cell';}
	
	reg2=/(itemi)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('th_numserie').style.display='table-cell';
		document.getElementById('th_lote').style.display='table-cell';
	}

	reg2=/(iteme)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('th_csub').style.display='table-cell';
		document.getElementById('th_numserie').style.display='table-cell';
		document.getElementById('th_lote').style.display='table-cell';
		document.getElementById('th_dispo').style.display='table-cell';
	}

	reg2=/(itemic)|(itemec)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('th_cambio').style.display='table-cell';
		document.getElementById('th_cambio_descri').style.display='table-cell';
	}

	reg2=/(nomi)/;
	if(reg2.test(tdeta))
	{
// 		document.getElementById('puni_btn').value='UNIT.';
// 		document.getElementById('th_enti2').style.display='table-cell';
// 		document.getElementById('th_enti2_descri').style.display='table-cell';

		document.getElementById('th_fecha2').style.display='table-cell';

		document.getElementById('th_sueldo').style.display='table-cell';
		document.getElementById('th_valanti').style.display='table-cell';
		document.getElementById('th_poranti').style.display='table-cell';
		document.getElementById('th_iess').style.display='table-cell';
		document.getElementById('th_reloj').style.display='table-cell';
		document.getElementById('th_atraso').style.display='table-cell';
		document.getElementById('th_falta').style.display='table-cell';
		document.getElementById('th_h25').style.display='table-cell';
		document.getElementById('th_h50').style.display='table-cell';
		document.getElementById('th_h100').style.display='table-cell';

		document.getElementById('th_de13').style.display='table-cell';
		document.getElementById('th_de14').style.display='table-cell';
		document.getElementById('th_fres').style.display='table-cell';

		
// 		document.getElementById('th_detalle').style.display='table-cell';
		document.getElementById('th_graba').style.display='table-cell';
	}

	reg2=/(nvdd)|(rolp)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('puni_btn').value='UNIT.';
		document.getElementById('th_enti2').style.display='table-cell';
		document.getElementById('th_enti2_descri').style.display='table-cell';
		document.getElementById('th_nvdd').style.display='table-cell';
		document.getElementById('th_nvdd_descri').style.display='table-cell';
		document.getElementById('th_cant').style.display='table-cell';
		document.getElementById('th_puni').style.display='table-cell';
		document.getElementById('th_csub').style.display='table-cell';
		document.getElementById('th_detalle').style.display='table-cell';
		document.getElementById('th_graba').style.display='table-cell';
	}

	reg2=/(docu)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('deta_txt').style.display='table-cell';
		document.getElementById('th_docum').style.display='table-cell';
		document.getElementById('th_docum_descri').style.display='table-cell';
		document.getElementById('th_ptoem').style.display='table-cell';
		document.getElementById('th_numer').style.display='table-cell';
		document.getElementById('th_cant').style.display='table-cell';
		document.getElementById('th_ctas').style.display='table-cell';
		document.getElementById('th_ctas_descri').style.display='table-cell';
		document.getElementById('th_detalle').style.display='table-cell';
		document.getElementById('th_graba').style.display='table-cell';
	}

	reg2=/(rete)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('deta_txt').style.display='table-cell';
		document.getElementById('th_docum').style.display='table-cell';
		document.getElementById('th_docum_descri').style.display='table-cell';
		document.getElementById('th_ptoem').style.display='table-cell';
		document.getElementById('th_numer').style.display='table-cell';
		document.getElementById('th_cair').style.display='table-cell';
		document.getElementById('th_base').style.display='table-cell';
		document.getElementById('th_porc').style.display='table-cell';
		document.getElementById('th_numer').style.display='table-cell';
		document.getElementById('th_detalle').style.display='table-cell';
		document.getElementById('th_graba').style.display='table-cell';
	}

	reg2=/(ctas)/;
	if(reg2.test(tdeta))
	{
		document.getElementById('deta_txt').style.display='table-cell';
		document.getElementById('th_ctas').style.display='table-cell';
		document.getElementById('th_ctas_descri').style.display='table-cell';
		document.getElementById('th_debito').style.display='table-cell';
		document.getElementById('th_credito').style.display='table-cell';
		document.getElementById('th_csub').style.display='table-cell';
		document.getElementById('th_detalle').style.display='table-cell';
		document.getElementById('th_graba').style.display='table-cell';
	}

// 		reg=/(fp)|(fc)|(fr)|(nc)|(np)|(op)|(ap)/;
// 		if(reg.test(docu))
		reg='/(fp.fc.fr.nc.np.op.pf.ap)/';
		if(reg.indexOf(ldoc)>=0)
		{	
		reg=/(apri)|(emar)|(emun)/;
		if(reg.test(empr))
		{	document.getElementById('tr_bldn').style.display='table-row';}	

			if((document.getElementById('empr_codigo').value)=='rcsa')
			{
				document.getElementById('tr_sntr').style.display='table-row';
				document.getElementById('tr_vhcl').style.display='table-row';
			}
			if((document.getElementById('empr_codigo').value)=='rcsa')
			{
				document.getElementById('tr_sntr').style.display='table-row';
				document.getElementById('tr_vhcl').style.display='table-row';
			}
			if(document.getElementById('empr_codigo').value=='ecgl' || document.getElementById('empr_codigo').value=='demo')
			{
				document.getElementById('th_lamina').style.display='table-cell';
				document.getElementById('th_largo').style.display='table-cell';
				document.getElementById('th_ancho').style.display='table-cell';
			}


		
		}	

	
// 		reg=/(fc)|(fr)/;
// 		if(reg.test(docu))
		reg='/(fc.fr)/';
		if(reg.indexOf(ldoc)>=0)
		{	
		reg=/(pcs1)|(prs1)/;
		if(reg.test(empr))
		{
		document.getElementById('th_cntn').style.display='table-cell';
		document.getElementById('th_cntnf1').style.display='table-cell';
		document.getElementById('th_cntnf2').style.display='table-cell';
		}
		}
	
}
}

function carga_tabla1()
{
	var docu=document.getElementById('docu').value;
	var ptoe=document.getElementById('ptoe').value;
	var ptov=document.getElementById('ptov').value;
	var caja=document.getElementById('caja').value;
	var ctab=document.getElementById('ctab').value;
	var bode=document.getElementById('bode').value;
	var numero=document.getElementById('numero').value;
	var enti=document.getElementById('enti').value;
	
  document.body.style.cursor='wait';
	
$.ajax({
		cache:false,
		url:'../lib/vrnewreg4.php',
		datatype: "text",
	 	async:false,
		type:'POST',
		data:{docu:docu,ptoe:ptoe,ptov:ptov,caja:caja,ctab:ctab,bode:bode,numero:numero,enti:enti}, 
    beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
      console.log(dato);
			console.log(textStatus);
			if(textStatus=='success')
			{
			document.body.style.cursor='default';
			document.getElementById('docu_carga2').innerHTML=dato;
			if($(dato).find("hdd_enti_cod").text()!=""){document.getElementById('enti').value=$(dato).find("hdd_enti_cod").text();}
			if($(dato).find("hdd_enti_descri").text()!=""){document.getElementById('enti_descri').innerHTML=$(dato).find("hdd_enti_descri").text();}
			if($(dato).find("hdd_enti_concepto").text()!=""){document.getElementById('concepto').value=$(dato).find("hdd_enti_concepto").text();}
			if($(dato).find("hdd_fecha").text()!=""){document.getElementById('fecha').value=$(dato).find("hdd_fecha").text();}
			if($(dato).find("hdd_atrz_nume").text()!=""){document.getElementById('atrznume').value=$(dato).find("hdd_atrz_nume").text();}
			if($(dato).find("hdd_fecha_auto").text()!=""){document.getElementById('atrzdate').value=$(dato).find("hdd_fecha_auto").text();}
			if($(dato).find("hdd_tiempo_auto").text()!=""){document.getElementById('atrztime').value=$(dato).find("hdd_tiempo_auto").text();}
			if($(dato).find("hdd_atrz_ruc").text()!=""){document.getElementById('atrzruc').value=$(dato).find("hdd_atrz_ruc").text();}
			if($(dato).find("hdd_suco").text()!=""){document.getElementById('suco').value=$(dato).find("hdd_suco").text();}
			if($(dato).find("hdd_suco_descri").text()!=""){document.getElementById('suco_descri').innerHTML=$(dato).find("hdd_suco_descri").text();}
			if($(dato).find("hdd_fpag").text()!=""){document.getElementById('fpag').value=$(dato).find("hdd_fpag").text();}
			if($(dato).find("hdd_fpag_descri").text()!=""){document.getElementById('fpag_descri').innerHTML=$(dato).find("hdd_fpag_descri").text();}
			if($(dato).find("hdd_tobode").text()!=""){document.getElementById('bod2').value=$(dato).find("hdd_tobode").text();}
			if($(dato).find("hdd_tobode_descri").text()!=""){document.getElementById('bod2_descri').innerHTML=$(dato).find("hdd_tobode_descri").text();}
			
			if($(dato).find("hdd_enti_drtr_cod").text()!=""){document.getElementById('drtr').value=$(dato).find("hdd_enti_drtr_cod").text();}
			if($(dato).find("hdd_enti_drtr_descri").text()!=""){document.getElementById('drtr_descri').innerHTML=$(dato).find("hdd_enti_drtr_descri").text();}
			if($(dato).find("hdd_vndd").text()!=""){document.getElementById('vndd').value=$(dato).find("hdd_vndd").text();}
			if($(dato).find("hdd_vndd_descri").text()!=""){document.getElementById('vndd_descri').innerHTML=$(dato).find("hdd_vndd_descri").text();}
			if($(dato).find("hdd_sntr").text()!=""){document.getElementById('sntr').value=$(dato).find("hdd_sntr").text();}
      if($(dato).find("hdd_sntr_descri").text()!=""){document.getElementById('sntr_descri').innerHTML=$(dato).find("hdd_sntr_descri").text();}
      if($(dato).find("hdd_vhcl").text()!=""){document.getElementById('vhcl').value=$(dato).find("hdd_vhcl").text();}
			if($(dato).find("hdd_vhcl_descri").text()!=""){document.getElementById('vhcl_descri').innerHTML=$(dato).find("hdd_vhcl_descri").text();}
			
			document.getElementById('hdd_idxreg').value=$(dato).find("hdd_idxreg2").text();
      if($(dato).find("hdd_stfin").text()=='1'){document.getElementById('agregar').disabled=true;}
			else{document.getElementById('agregar').disabled=false;}
			
			carga_tabla2();
			edicion=0;
			}
		},
		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
	});
	
}

	
function _docu(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('docu',document.getElementById('docu').value,'docu','docu_descri','');	
		document.getElementById('ptoe').value='';
	}
}

function _docuapli(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{busca_maes2('docu',document.getElementById('aplidocu').value,'aplidocu','aplidocu_descri','');	}
}
		
function _aplicxcp(e)
{
	document.getElementById('deta_cxcp').style.display='block';
	var docu=document.getElementById('docu').value;
	var ldoc=docu.toLowerCase().substring(0,2);
	

	var enti=document.getElementById('enti').value;
	
  document.body.style.cursor='wait';
	
$.ajax({
		cache:false,
		url:'../lib/vrnewreg4.php',
		datatype: "text",
	  async:false,
		type:'POST',
		data:{docu:docu,ptoe:ptoe,ptov:ptov,caja:caja,ctab:ctab,bode:bode,numero:numero,enti:enti}, 
   	beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
//       console.log(dato);
// 			console.log(textStatus);
			if(textStatus=='success')
			{
			document.body.style.cursor='default';
			document.getElementById('docu_carga2').innerHTML=dato;
			if($(dato).find("hdd_enti_cod").text()!=""){document.getElementById('enti').value=$(dato).find("hdd_enti_cod").text();}
			if($(dato).find("hdd_enti_descri").text()!=""){document.getElementById('enti_descri').innerHTML=$(dato).find("hdd_enti_descri").text();}
			
			document.getElementById('hdd_idxreg').value=$(dato).find("hdd_idxreg2").text();
      if($(dato).find("hdd_stfin").text()=='1'){document.getElementById('agregar').disabled=true;}
			else{document.getElementById('agregar').disabled=false;}
			}
		},
		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
	});
	
}

function ptoe(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		var pad0="001001";
		var num1=parseInt(document.getElementById("ptoe").value)+"";
		num1=num1.trim();
		if(num1=="NaN"){num1="1";}
		//if(e.keyCode==9 || e.keyCode==13)
		document.getElementById("ptoe").value=pad0.substring(0, pad0.length-num1.length)+num1;

		if(e.keyCode==13)
		{
			busca_ndocu(document.getElementById('docu').value,document.getElementById('ptoe').value,'numero');
		}
	}
}

function _ptoem(e)
{

	if(e.keyCode==9 || e.keyCode==13)
	{
		var pad0="001001";
		var num1=parseInt(document.getElementById("ptoem").value)+"";
		num1=num1.trim();
		if(num1=="NaN")
		{num1="1";}
		if(e.keyCode==9 || e.keyCode==13)
		{
			document.getElementById("ptoem").value=pad0.substring(0, pad0.length-num1.length)+num1;
// 		busca_ndocu(document.getElementById('docu').value,document.getElementById('ptoe').value,'numero');
		}
		if(e.keyCode==13)
		{	
// 			document.getElementById('numero').focus();
		}
	
	}
}

function _ptov(e)
{
	busca_ndocu(document.getElementById('docu').value,document.getElementById('ptov').value,'numero');
}

function _bode()
{
	busca_ndocu(document.getElementById('docu').value,document.getElementById('bode').value,'numero');
}

function _ctab(e)
{
	busca_ndocu(document.getElementById('docu').value,document.getElementById('ctab').value,'numero');
// 	busca_maes2('ctab',document.getElementById('ctab').value,'ctab','ctab_descri','');
}

function _caja(e)
{
	busca_ndocu(document.getElementById('docu').value,document.getElementById('caja').value,'numero');
// 	busca_maes2('caja',document.getElementById('caja').value,'caja','caja_descri','');
}

function fecha()
{
var xdate = new Date();
var xdatea=xdate.getFullYear()+'-'+(xdate.getMonth()+1)+'-'+xdate.getDate();
var xfecha=document.getElementById('fecha').value;

xfecha=fecha_format(xfecha);
document.getElementById('fecha').value=xfecha;
xfecha=new Date(xfecha);
xfecha.setDate(xfecha.getDate()+1);

var xdif=parseInt(xfecha-xdate)/(1000*60*60*24);
if (xdif>365){document.getElementById('fecha').value=xdatea;}
// if (xdif<-90){document.getElementById('fecha').value=xdatea;}
// if (xdif<-365){document.getElementById('fecha').value=xdatea;}
if (xdif<-1000){document.getElementById('fecha').value=xdatea;}


var xfechasale=document.getElementById('fechasale').value;
xfechasale=fecha_format(xfechasale);
document.getElementById('fechasale').value=xfechasale;
xfechasale=new Date(xfechasale);
var xdifsale=parseInt(xfechasale-xfecha)/(1000*60*60*24);
if (xdifsale<90)
{
	xfechasale=xfecha;
	xfechasale.setDate(xfecha.getDate()+90);	
	xfechasale=	xfechasale.getFullYear()+'-'+(xfechasale.getMonth()+1)+'-'+xfechasale.getDate();
	document.getElementById('fechasale').value=xfechasale;
}
_atrzdate();
}

function _atrzdate()
{
var xfecha=document.getElementById('fecha').value;
xfecha=fecha_format(xfecha);
xfecha=new Date(xfecha);
xfecha.setDate(xfecha.getDate()+1)

var xfatrz=document.getElementById('atrzdate').value;
xfatrz=fecha_format(xfatrz,2);
document.getElementById('atrzdate').value=xfatrz;
xfatrz=fecha_format(xfatrz);
xfatrz= new Date(xfatrz);
xfatrz.setDate(xfatrz.getDate()+1)
var xdif=parseInt(xfatrz-xfecha)/(1000*60*60*24*7);
var xdatea=(xfecha.getDate()+0)+'-'+(xfecha.getMonth()+1)+'-'+xfecha.getFullYear();
if (xdif>1){document.getElementById('atrzdate').value=xdatea;}
if (xdif<0){document.getElementById('atrzdate').value=xdatea;}
	
}	

function _atrztime(e,e2)
{
// 	if(e.keyCode==13)
	var xnumbloq=document.getElementById(e2).value.toUpperCase();
		xvnum='0123456789.:';
		xnum='';
		for (i=0; i<xnumbloq.length;i++)
			{
				xcar=xnumbloq.substring(i,i+1);	
				if (xvnum.indexOf(xcar)>=0){xnum+=xcar;}
			}
			xnum=xnum.replace('..','.')
			xnum=xnum.replace('::',':')
		 	document.getElementById(e2).value=xnum;
	

if(e.keyCode==9 || e.keyCode==13)
	{
		var fn=document.getElementById(e2).value;
// 		console.log(fn);
		if (fn==""){fn="00:00:00";}
		else{fn=hora_format(fn);}
		document.getElementById(e2).value=fn;
	}
}
	
	
	
	
function _numero(e)
{
	var num1=parseInt(document.getElementById("numero").value)+"";
	num1=num1.trim();

	if(num1=="NaN")	{num1="0";}
	if(1==1)
	{
	if(num1=="0" || num1=="NaN")
	{
		// buscar ptoe dependiendo del docu
		busca_ndocu(document.getElementById('docu').value,document.getElementById('ptoe').value,'numero');
		num1=parseInt(document.getElementById("numero").value)+"";
		num1=num1.trim();	
	}
	}

// 	if(e.keyCode==13)
	if(1==1)
	{
		document.getElementById("enti").focus();
    carga_tabla1();
//     carga_tabla2();
	}
}

function _numer(e)
{
	var pad0="000000000";
	var num1=parseInt(document.getElementById("numer").value)+"";
	num1=num1.trim();
	if(num1=="NaN")
	{num1="0";}
	if(e.keyCode==9 || e.keyCode==13)
	{document.getElementById("numer").value=pad0.substring(0, pad0.length-num1.length)+num1;}
	if(e.keyCode==13)
	{
		document.getElementById("cant").focus();
	}
}


function aplipto(e)
{
	var pad0="001001";
	var num1=parseInt(document.getElementById("apliptoe").value)+"";
	num1=num1.trim();
	if(num1=="NaN")
	{	num1="";}
	if (num1>0)
	{document.getElementById("apliptoe").value=pad0.substring(0, pad0.length-num1.length)+num1;}
	if(e.keyCode==9 || e.keyCode==13)
	{	document.getElementById("aplinumero").focus();}

}

function aplinum(e)
{
	var pad0="000000000";
	var num1=parseInt(document.getElementById("aplinumero").value)+"";
	num1=num1.trim();
	if(num1=="NaN")
	{
		num1="";
	}
	if (num1>0)
	{
		document.getElementById("aplinumero").value=pad0.substring(0, pad0.length-num1.length)+num1;
	}

}


function enti(e,rucempr)
{
	var reg='';
		var etmp=document.getElementById('enti').value.trim();
		var edoc=document.getElementById('docu').value;
		if(etmp.length==10){document.getElementById('atrzruc').value=document.getElementById('enti').value+'001';}
		if(etmp.length==13){document.getElementById('atrzruc').value=document.getElementById('enti').value;}
		if(edoc=='FP11'){document.getElementById('atrzruc').value=rucempr;}

// 	if(e.keyCode==13)
	if(1==1)
	{
// 		reg=/(fp)|(rc)|()/;
// 		if(reg.test(edoc))
// 			{
				carga_tabla1();
// 				carga_tabla2();
// 			}
	}
	
	
	
}


function _concepto(e)
{
}





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

function bode2(e)
{if(e.keyCode==9 || e.keyCode==13){busca_maes2('bode',document.getElementById('bod2').value,'bod2','bode2_descri','');}}

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

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

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

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

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

function _ctas(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('ctas',document.getElementById('ctas').value,'ctas','ctas_descri','');
		document.getElementById("ctas").focus();
	}
}

function item_cuenta(e)
{if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('ctas',document.getElementById('item_cuenta').value,'item_cuenta','item_cuenta_descri','');
		alert('Cuenta : ' + document.getElementById('item_cuenta_descri').value);
	}
}



function item(e)
{
	var reg='';
// 	if(e.keyCode==9 || e.keyCode==13)
	if(1==1)
	{
// 		var docu=document.getElementById('docu').value.strtoupper;
		var docu=document.getElementById('docu').value;
		var ldoc=docu.toLowerCase().substring(0,2);
		
		var enti=document.getElementById('enti').value;
// 		reg=/(FC)|(FR)|(NV)|(OP)|(FP)|(PP)|(IB)/;
// 		if(reg.test(docu))
		reg='/(fc.fr.nv.op.pf.fp.pp.ib)/';
		if(reg.indexOf(ldoc)>=0)
		{
			busca_item(document.getElementById('item').value,document.getElementById('docu').value,document.getElementById('enti').value,'item','item_descri','puni','ice','dcto','iva','irbp','cair','ctas','');
		}
		else
		{
			busca_maes2('item',document.getElementById('item').value,'item','item_descri','');
		}
                if(document.getElementById('dcto1').value!=''){document.getElementById('dcto').value=document.getElementById('dcto1').value;}
	
	}
}


function docum(e)
{
// 	document.getElementById('docum').value=strtoupper(document.getElementById('docum').value);
	if(e.keycode==9 || e.keyCode==13){busca_maes2('docu',document.getElementById('docum').value,'docum','docum_descri','');}
}


// function X_graba_docu_deta()
// {
// }

function graba_full()
{
	var docu=document.getElementById('docu').value;
	var ldoc=docu.toLowerCase().substring(0,2);
	
	var fecha=document.getElementById('fecha').value;
	var ptoe=document.getElementById('ptoe').value;
	var numero=document.getElementById('numero').value;
	var enti=document.getElementById('enti').value;
	var benefic=document.getElementById('benefic').value;

	var caja=document.getElementById('caja').value;
	var ctab=document.getElementById('ctab').value;
	var bcos=document.getElementById('bcos').value;
	var bode=document.getElementById('bode').value;
	var ptov=document.getElementById('ptov').value;

	var drtr=document.getElementById('drtr').value;
	var bldn=document.getElementById('bldn').value;
	var sntr=document.getElementById('sntr').value;
	var vhcl=document.getElementById('vhcl').value;
		
	var valor=document.getElementById('valor').value;
	var concepto=document.getElementById('concepto').value;

	var vndd=document.getElementById('vndd').value;
	var bod2=document.getElementById('bod2').value;
	var plazo=document.getElementById('plazo').value;
	var valor=document.getElementById('valor').value;

	var zsub=document.getElementById('zsub').value;
	var aplidocu=document.getElementById('aplidocu').value;
	var apliptoe=document.getElementById('apliptoe').value;
	var aplinumero=document.getElementById('aplinumero').value;
	
	var suco=document.getElementById('suco').value;
	var fpag=document.getElementById('fpag').value;
	
	var atrzdate=document.getElementById('atrzdate').value;
	var atrztime=document.getElementById('atrztime').value;
	var atrzruc=document.getElementById('atrzruc').value;
	var atrznume=document.getElementById('atrznume').value;
	var fecha2=document.getElementById('fecha2').value.toUpperCase();
	var enti2=document.getElementById('enti2').value.toUpperCase();
	var nvdd=document.getElementById('nvdd').value.toUpperCase();
	
	var item=document.getElementById('item').value.toUpperCase();
	var docum=document.getElementById('docum').value.toUpperCase();
	var ptoem=document.getElementById('ptoem').value;
	var numer=document.getElementById('numer').value;
	var ctas=document.getElementById('ctas').value;
	var cant=document.getElementById('cant').value;
	var puni=document.getElementById('puni').value;
	var dcto1=document.getElementById('dcto1').value;
	var iva1=document.getElementById('iva1').value;
	var dcto=document.getElementById('dcto').value;
	var ice=document.getElementById('ice').value;
	var iva=document.getElementById('iva').value;
	var irbp=document.getElementById('irbp').value;
	var pvp1=document.getElementById('pvp1').value;
	var base=document.getElementById('base').value;
	var porc=document.getElementById('porc').value;

	var puni_o=document.getElementById('puni_o').value;
	var puni_a=document.getElementById('puni_a').value;
	var impo=document.getElementById('impo').value;
	var cntn=document.getElementById('cntn').value;
	var cntnf1=document.getElementById('cntnf1').value;
	var cntnf2=document.getElementById('cntnf2').value;
	var chasis=document.getElementById('chasis').value;

	var csub=document.getElementById('csub').value;
	var debito=document.getElementById('debito').value;
	var credito=document.getElementById('credito').value;
	var cambio=document.getElementById('cambio').value;
	var numserie=document.getElementById('numserie').value;
	var detalle=document.getElementById('detalle').value;
  var cair=document.getElementById('cair').value;
	
	var sueldo=document.getElementById('sueldo').value;
	var poranti=document.getElementById('poranti').value;
	var valanti=document.getElementById('valanti').value;
	var iess=document.getElementById('iess').checked;
	var reloj=document.getElementById('reloj').checked;
	var atraso=document.getElementById('atraso').checked;
	var falta=document.getElementById('falta').checked;
	var h25=document.getElementById('h25').checked;
	var h50=document.getElementById('h50').checked;
	var h100=document.getElementById('h100').checked;
	var de13=document.getElementById('de13').checked;
	var de14=document.getElementById('de14').checked;
	var fres=document.getElementById('fres').checked;
	
	var lamina=document.getElementById('lamina').value;
	var largo=document.getElementById('largo').value;
	var ancho=document.getElementById('ancho').value;

	var hora;
	fecha=fecha_format(fecha);
	hora=hora_format(atrztime);
	
	if(fecha=='error')
	{
		alert('Formato de Fecha Incorrecta');
		document.getElementById('fecha').focus();
		return false;
	}
	
	if(docu=='EB13' && bod2=='')
	{
		alert('Error en Bodega Destino');
		document.getElementById('bod2').focus();
		return false
	}

	if(docu!='ROL1' && docu!='NMN1' && enti=='')
	{
		alert('Error en Entidad');
		document.getElementById('enti').focus();
		return false
	}
	
$.ajax({
		cache:false,
		url:'../lib/vrnewreg1g.php',
		datatype: "text",
    async:true,
		type:'POST',
		data:{
			docu:docu,
			ptoe:ptoe,
			numero:numero,
			fecha:fecha,
			enti:enti,
			enti2:enti2,
			fecha2:fecha2,
			nvdd:nvdd,
			sueldo:sueldo,
			poranti:poranti,
			valanti:valanti,
			iess:iess,
			reloj:reloj,
			atraso:atraso,
			falta:falta,
			h25:h25,
			h50:h50,
			h100:h100,
			de13:de13,
			de14:de14,
			fres:fres,
			benefic:benefic,
			concepto:concepto,
			caja:caja,
			ctab:ctab,
			bode:bode,
			bod2:bod2,
			plazo:plazo,
			bcos:bcos,
			zsub:zsub,
			vndd:vndd,
			ptov:ptov,
			valor:valor,
			aplidocu:aplidocu,
			apliptoe:apliptoe,
			aplinumero:aplinumero,
			atrzdate:atrzdate,
			atrztime:atrztime,
			atrzruc:atrzruc,
			atrznume:atrznume,
			suco:suco,fpag:fpag,
			item:item,ptoem:ptoem,docum:docum,numer:numer,
			cant:cant,puni:puni,dcto:dcto,dcto1:dcto1,ice:ice,iva1:iva1,iva:iva,irbp:irbp,pvp1:pvp1,
			base:base,porc:porc,cair:cair,
			ctas:ctas,debito:debito,credito:credito,csub:csub,
			numserie:numserie,cambio:cambio,
			iess:iess,
			cntn:cntn,chasis:chasis,
			cntnf1:cntnf1,cntnf2:cntnf2,
			puni_o:puni_o,puni_a:puni_a,impo:impo,
			drtr:drtr,bldn:bldn,
			sntr:sntr,vhcl:vhcl,
			lamina:lamina,largo:largo,ancho:ancho,
			detalle:detalle
		}, 
 		beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
			document.getElementById('hdd_idxreg').value=$(dato).find("hdd_idxidnum").text();
			if(document.getElementById('numero')){	}
			console.log(dato);
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
// 		alert('ERROR AL GRABAR');
		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
	});

// 	limpia();
//if(edicion==1){carga_tabla1();}
carga_tabla1();
// carga_tabla2();
limpia();
var xidnum=	document.getElementById('hdd_idxreg').value;
if (xidnum!='')	
{	
_contab(docu,xidnum);	
_invent(docu,xidnum);	
}
}

function carga_tabla2()
{
	var docu=document.getElementById('docu').value;
	var ptoe=document.getElementById('ptoe').value;
	var ptov=document.getElementById('ptov').value;
	var caja=document.getElementById('caja').value;
	var ctab=document.getElementById('ctab').value;
	var bode=document.getElementById('bode').value;
	var numero=document.getElementById('numero').value;
	var enti=document.getElementById('enti').value;
	
  document.body.style.cursor = 'wait';
$.ajax({
		cache:false,
		url:'../lib/vrnewreg100.php',
		datatype: "text",
    async:true,
		type:'POST',
		data:{docu:docu,ptoe:ptoe,ptov:ptov,caja:caja,ctab:ctab,bode:bode,numero:numero,enti:enti}, 
    beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
     	document.body.style.cursor = 'default';       
			document.getElementById('reg_deta').innerHTML=dato;
			console.log($(dato).find("error").text());
		},
		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:60000
	});

//+++++
$.ajax({
		cache:false,
		url:'../lib/vrnewreg12.php',
		datatype: "text",
	    async:true,
		type:'POST',
		data:{docu:document.getElementById('docu').value,idnumx:document.getElementById('hdd_idxreg').value}, 
    	beforeSend: function(jqXHR, textStatus){}, 
		
		success:function(dato, textStatus, jqXHR)
		{document.getElementById('total_box').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
	});
//+++++


}


function valsueldo()	
{
	var sueldo=document.getElementById('sueldo').value;
	var poranti=document.getElementById('poranti').value;
	var valanti=document.getElementById('valanti').value;
	
	sueldo=Math.abs(sueldo);
	valanti=Math.abs(valanti);
	poranti=Math.abs(poranti);
	
	console.log(sueldo);
	
	if (sueldo<366){sueldo=366;}
	if (poranti>0 && valanti==0){valanti=sueldo*poranti/100;}
	if (poranti==0 && valanti>0){poranti=valanti/sueldo*100;}
	if (poranti>0 && valanti>0)
	{
		if(Math.abs(valanti-sueldo*poranti/100)>.01)
		{
			alert('Anticipo NO CUADRA');
// 			document.getElementById('poranti').focus();
			poranti=0;
			valanti=0;
		}
	}

	document.getElementById('sueldo').value=sueldo.toFixed(2);
	if (poranti>0){document.getElementById('poranti').value=poranti.toFixed(2);}else{document.getElementById('poranti').value=0;}
	if (valanti>0){document.getElementById('valanti').value=valanti.toFixed(2);}else{document.getElementById('valanti').value=0;}
	
	
}

function status_ox(docux,idnumx,extra,opcionx)
{

$.ajax({
		cache:false,
		url:'../lib/vrnewreg5.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{docux:docux,idnumx:idnumx,opcionx:opcionx},
    	beforeSend: function(jqXHR, textStatus)
		{
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			//console.log(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 limpia()
{
	var cajan=document.getElementsByClassName('sub_deta').length-1;
	for(i=0;i<=cajan;i++)
	{
		document.getElementsByClassName('sub_deta').item(i).value='';
		document.getElementsByClassName('sub_deta').item(i).innerHTML='';
	}
	document.getElementById('reg_deta').innerHTML='';

	var reg = '';
	var docu=document.getElementById('docu').value
	var ldoc=docu.toLowerCase().substring(0,2);

	
// 	reg=/(fc)|(fr)|(nc)|(op)|(fp)|(np)|(ap)/;
// 	if(reg.test(docu))
	reg='/(fc.fr.nc.op..pf.fp.np.ap)/';
	if(reg.indexOf(ldoc)>=0)
	{
// 	document.getElementById('dcto').value=document.getElementById('dcto1').value;
// 	document.getElementById('cant').value=1;
// 	document.getElementById('iva').value=14;
	document.getElementById('iva').value=12;
	
	}
	if(document.getElementById('dcto1').value!=''){document.getElementById('dcto').value=document.getElementById('dcto1').value;}
	

}

function finalizar()
{
// graba_full();
	var docu=document.getElementById('docu').value;
	var ptoe=document.getElementById('ptoe').value;
	var numero=document.getElementById('numero').value;
	var caja=document.getElementById('caja').value;
	var ctab=document.getElementById('ctab').value;
	var bcos=document.getElementById('bcos').value;
	var bode=document.getElementById('bode').value;
	var ptov=document.getElementById('ptov').value;
	var zsub=document.getElementById('zsub').value;
	var ptoem=document.getElementById('ptoem').value;
	var enti=document.getElementById('enti').value;

$.ajax({
		cache:false,
		url:'../lib/vrnewreg1f.php',
		datatype: "text",
	  async:false,
		type:'POST',
		data:{
		docu:docu,
		ptoe:ptoe,
		numero:numero,
		caja:caja,
		ctab:ctab,
		bcos:bcos,
		bode:bode,
		ptov:ptov,
		zsub:zsub,
		ptoem:ptoem,
		enti:enti},
  	beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
			console.log(dato);
	    var fin=$(dato).find("error").text();
			if(fin=='0')
			{
				document.getElementById('agregar').disabled=true;
				carga_tabla2();
			}
		},
		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:60000
	});


}

function _imprimir_docu()
{
	var idx_d
// 	var docu_d;
	var docu=document.getElementById('docu').value;
	var ldoc=docu.toLowerCase().substring(0,2);

	if(document.getElementById("hdd_idxreg2"))
	{
		console.log("existe hdd_idxreg2");
		
		idx_d=document.getElementById("hdd_idxreg2").value;
		if( isNaN(idx_d) || idx_d=='')
		{
			return false;
		}
// 		docu_d=document.getElementById("docu").value;
		window.open ('celectop1.php?docu='+docu+'&idnum='+idx_d+'&formato=1','_blank')
		return false;
	}
	else
	{
		//return false;
	}

	if(document.getElementById("hdd_idxreg"))
	{
		
		
		idx_d=document.getElementById("hdd_idxreg").value;
		console.log("existe hdd_idxreg"+idx_d+':)');
		if( isNaN(idx_d) || idx_d=='')
		{
			return false;
		}
		docu_d=document.getElementById("docu").value;
		window.open ('celectop1.php?docu='+docu_d+'&idnum='+idx_d+'&formato=1','_blank')
	}
	else
	{
		return false;
	}
}

	
function _cobpag_docu()
{
	var idx_d
// 	var docu_d;
	var docu=document.getElementById('docu').value;
	var ldoc=docu.toLowerCase().substring(0,2);

	if(document.getElementById("hdd_idxreg2"))
	{
		console.log("existe hdd_idxreg2");
		
		idx_d=document.getElementById("hdd_idxreg2").value;
		if( isNaN(idx_d) || idx_d=='')
		{
			return false;
		}
// 		docu_d=document.getElementById("docu").value;
		var reg;
		
// 		if(reg.test(docu_d))
// 		reg=/(fc)|(fr)|(NV)/;
		reg='/(fc.fr.nv)/';
		if(reg.indexOf(ldoc)>=0)
		{window.open ('vrcobro0.php?docu='+docu+'&idnum='+idx_d,'_blank')}
		
// 		reg=/(FP)|(AP)/;
// 		if(reg.test(docu_d))
		reg='/(fp.ap)/';
		if(reg.indexOf(ldoc)>=0)
		{window.open ('vrpago0.php?docu='+docu+'&idnum='+idx_d+'&formato=1','_blank')}
		
		return false;
	}
	else
	{
		//return false;
	}

	if(document.getElementById("hdd_idxreg"))
	{
		
		
		idx_d=document.getElementById("hdd_idxreg").value;
		console.log("existe hdd_idxreg"+idx_d+':)');
		if( isNaN(idx_d) || idx_d=='')
		{
			return false;
		}
		docu_d=document.getElementById("docu").value;
		window.open ('celectop1.php?docu='+docu_d+'&idnum='+idx_d+'&formato=1','_blank')
	}
	else
	{
		return false;
	}
}
	
	
	
<?php include('../../_js/busca_maes3.js');?>
<?php include('../../_js/lista_maes3.js');?>
<?php include('../../_js/fecha_format.js');?>
<?php include('../../_js/hora_format.js');?>
<?php include('../../_js/deledeta.js');?>
	
	
</script>


</head>

<body>


<?php include('../../_lib/cabecera2.php');?>

<br>

<table border="2px" cellspacing="0" cellpadding="2" width="100%" style="font-size:14px; border-collapse:collapse;">
<tr valign="top">
<td width="33%">
	<table cellspacing="0" cellpadding="2" width="100%" style="font-size:14px; border-collapse:collapse;">
	    	<tr id="tr_docu" style="display:table-row;" valign="top">
					<?php $pcaption='DOCUMENTO'; $ptabla='docu'; $ponblur='showobj(event);';  include('vrgetcod.php'); ?>
<!-- 		</td> -->
        </tr>
        <tr id="tr_ptoe" style="display:none;" valign="center">
					<?php $pcaption='PTO.EMI.'; $pidtxt='ptoe'; $plong=6; $ponblur='ptoe(event);'; $pdefa='001001'; include('vrgetnum.php'); ?>
        </tr>
        <tr id="tr_ptov" style="display:none;" valign="top">
					<?php $pcaption='PTO.VTA.'; $ptabla='ptov';  $pdefa='V001'; $ponblur='_ptov();'; include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_bode" style="display:none;" valign="top">
					<?php $pcaption='BODEGA'; $ptabla='bode'; $pdefa='B010'; $ponblur='_bode();'; include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_caja" style="display:none;" valign="top">
					<?php $pcaption='CAJA'; $ptabla='caja'; $pdefa='C001'; $ponblur='_caja();'; include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_ctab" style="display:none;" valign="top">
					<?php $pcaption='CTA.BANC.'; $ptabla='ctab'; $pdefa='B010'; $ponblur='_ctab();'; include('vrgetcod.php'); ?>
        </tr>
    	<tr id="tr_numero" style="display:none;" valign="center">
					<?php $pcaption='NUMERO'; $pidtxt='numero';  $plong=9; $ponblur='_numero(event);';  include('vrgetnum.php'); ?>
        </tr>
    	<tr id="tr_enti" style="display:none;" valign="top">
					<?php $pcaption='ENTIDAD'; $ptabla='enti';  $ponblur='enti(event,'.$empr_ruc.');'; $ponchange='';  include('vrgetcod.php'); ?>
        </tr>
    	<tr id="tr_concepto" style="display:none;" valign="top">
					<?php $pcaption='CONCEPTO'; $pidtxt='concepto'; $plong=40; $prows=5;  include('vrgettxt.php'); ?>
       </tr>
    	<tr style="display:none;" valign="top">
       		<td>
       		<input type="button"  tabIndex="-1"  value="DETALLE" onClick="if(confirm('Registrar Detalle?')){graba_docu();}" />
       		</td>
       		<td></td>
       </tr>
    </table>
</td>

<td width="33%">
	<table id="cab2_reg" border="0" cellspacing="0" cellpadding="2" width="100%" style="font-size:14px; border-collapse:collapse;">
    	<tr id="tr_fecha" style="display:none;" valign="center">
				<?php $pcaption='FECHA'; $pidtxt='fecha'; $ponblur='fecha();'; include('vrgetfec.php'); ?> 
      </tr>
    	<tr id="tr_fechasale" style="display:none;" valign="center">
				<?php $pcaption='FECHA SALIDA'; $pidtxt='fechasale'; $ponblur='fecha();'; include('vrgetfec.php'); ?> 
      </tr>
    	<tr id="tr_benefic" style="display:none;" valign="top">
					<?php $pcaption='BENEFICIARIO'; $pidtxt='benefic'; $plong=15; include('vrgettxt.php'); ?>
      </tr>
        <tr id="tr_valor" style="display:none;" valign="top">
					<?php $pcaption='VALOR'; $pidtxt='valor';   include('vrgetval.php'); ?>
        </tr>
        <tr id="tr_plazo" style="display:none;" valign="top">
					<?php $pcaption='PLAZO'; $pidtxt='plazo'; $plong=3; include('vrgetnum.php'); ?>
        </tr>
        <tr id="" style="display:none;" valign="top">
        	<td width="10%">
        	<div><input id="valorlbl" type="button"  tabIndex="-1"  value="VALOR" accesskey="P"  /></div>
        	</td>
        	<td>
        	<span><input type="text" accesskey="V" id="valor" style="border: solid 1px #000; width:80px; padding-left:2px; text-align:right;" /></span>
					<span id="valor_descri" style="font-weight:bold; height:25px;"></span>           	
         	</td>
        </tr>
        <tr id="tr_vndd" style="display:none;" valign="top">
				<?php $pcaption='VENDEDOR'; $ptabla='vndd';  include('vrgetcod.php'); ?>
				</tr>
        <tr id="tr_zsub" style="display:none;" valign="top">
				<?php $pcaption='ZONA'; $ptabla='zsub'; include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_nvdd" style="display:none;" valign="top">
					<?php $pcaption='NOVEDAD'; $ptabla='nvdd'; $pidtxt='nvdd1';  include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_dcto" style="display:none;" valign="top">
				<?php $pcaption='%DCTO'; $pidtxt='dcto1'; $plong=5; include('vrgetval.php'); ?>
        </tr>
        <tr id="tr_iva" style="display:none;" valign="top">
				<?php $pcaption='%IVA'; $pidtxt='iva1'; $plong=5; include('vrgetval.php'); ?>
        </tr>
        <tr id="tr_fpag" style="display:none;" valign="top">
					<?php $pcaption='F.PAGO'; $ptabla='fpag'; $pdefa='20'; include('vrgetcod.php'); ?>
        </tr>
	      <tr id="tr_suco" style="display:none;" valign="top">
 					<?php $pcaption='SUST.COMP.'; $ptabla='suco'; $pdefa='01'; include('vrgetcod.php'); ?>
				</tr>
        <tr id="tr_bcos" style="display:none;" valign="top">
					<?php $pcaption='BANCO'; $ptabla='bcos'; include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_numcta" style="display:none;" valign="top">
					<?php $pcaption='#CTA.(T/C)'; $pidtxt='numcta'; $plong=16; include('vrgetnum.php'); ?>
        </tr>
        <tr id="tr_nomcta" style="display:none;" valign="top">
					<?php $pcaption='NOM.CTA.'; $pidtxt='nomcta'; $plong=15; include('vrgettxt.php'); ?>
        </tr>
        <tr id="tr_bod2" style="display:none;" valign="top">
					<?php $pcaption='BODEGA 2'; $ptabla='bode'; $pidtxt='bod2'; include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_drtr" style="display:none;" valign="top">
					<?php $pcaption='DIRECTOR'; $ptabla='drtr'; include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_bldn" style="display:none;" valign="top">
					<?php $pcaption='B/L'; $ptabla='bldn';  include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_sntr" style="display:none;" valign="top">
					<?php $pcaption='SINIESTRO'; $ptabla='sntr'; include('vrgetcod.php'); ?>
        </tr>
        <tr id="tr_vhcl" style="display:none;" valign="top">
					<?php $pcaption='VEHICULO'; $ptabla='vhcl';  include('vrgetcod.php'); ?>
        </tr>
    </table>

<!-- <br> -->
	<table id="cab2b_reg" border="0" cellspacing="0" cellpadding="2" width="100%" style="font-size:14px; border-collapse:collapse;">
        <tr id="tr_apli" style="display:none;" valign="top">
	        	<td width="10%" >
           	<table border="0" width="10%">
						<tr>
						<td align="center" colspan="2" style="">
<!-- 							<input type="button"  tabIndex="-1"  value="- APLICAR A:  -"> -->
						<?php $pcaption='APLICAR'; $pidtxt='aplicar';  $ponclick=''; include('vrbutton.php'); ?>
					</td>	
						</tr>	
		    		<tr style="display:table-row;" valign="top">
						<?php $pcaption='DOCUMENTO'; $ptabla='docu'; $pidtxt='aplidocu';   include('vrgetcod.php'); ?>
		        </tr>
		       	<tr>
						<?php $pcaption='PTO.EMI.'; $pidtxt='apliptoe';  $plong=6; $pdefa='001001'; include('vrgetnum.php'); ?>
						<?php $pcaption='NUMERO'; $pidtxt='aplinumero';  $plong=9; $pdefa='1'; include('vrgetnum.php'); ?>
        		</tr>
	     			</table>
           	</td> 
        </tr>
        <tr id="tr_aplicxcp" style="display:none;" valign="top">
					<td>
						<?php $pcaption='APLICAR'; $pidtxt='aplicxcp';  $ponclick='_aplicxcp(event);'; include('vrbutton.php'); ?>
					</td>	
					<td></td>
        </tr>
    </table>
	
<!-- <br> -->
	<table id="cab2b_reg" border="0" cellspacing="0" cellpadding="2" width="100%" style="font-size:14px; border-collapse:collapse;">
		<tr id="tr_atrz" style="display:none;" valign="top">
        	<td width="10%" >
            	<table border="0" width="10%">
							<tr>
							<td align="center" colspan="4" style=""><input type="button"  tabIndex="-1"  value="A U T O R I Z A C I O N" style="width:100%;font-weight:bold;"></td>
							</tr>	
            	<tr>
							<?php $pcaption='Fecha(cad)'; $pidtxt='atrzdate'; $plong=10; $pobj=2; $ponblur='_atrzdate();'; include('vrgettxt.php'); ?> 
							<?php $pcaption='Hora(c.e.)'; $pidtxt='atrztime'; $plong=8; $pobj=2; $pdefa='00:00:00'; $ponblur='_atrztime();'; include('vrgettxt.php'); ?> 
							<?php $pcaption='RUC'; $pidtxt='atrzruc'; $plong=13; $pobj=2;  include('vrgetnum.php'); ?>
							<?php $pcaption='NUMERO'; $pidtxt='atrznume'; $plong=10; $pobj=2; include('vrgetnum.php'); ?>
		        	</tr>
            	</table>
           	</td> 
        </tr>
	</table>
</td>

<td width="33%">
<table id="table_cont_btn" width="100%" border="0" cellpadding="0" cellspacing="0"  style="border-collapse:collapse; ">
<tr>
	<td>
	<input id="xbtn_imprime" type="image" width="20" src="http://vcrxol.com/_img/print2.png" onClick="_imprimir_docu();" />
	</td>
	<td align="center" id="th_cobpag" style="display:none;">
	<input id="xbtn_cobpag" type="image" width="30"  src="http://vcrxol.com/_img/ico_cash.png" onClick="_cobpag_docu();" />
	</td>
	<td width="100%" align="right"  id="btn_final" style="margin:0px; padding:0px;display:none;">
	<input id="xbtn_final" type="button"  tabIndex="-1"  width="20"  value="Finalizar" src="http://vcrxol.com/_img/ico_plus2.png" onClick="if(confirm('Desea Finalizar?')){finalizar();}" />
	</td>
</tr>
</table>
<?php include('vrmsjerr.php') ?>
<div id="total_box"></div>
</td>
</table>

<hr/>
<div id="docu_carga"></div>
<div id="docu_carga2" style="display:none;"></div>
<div id="deta_cont" align="left" style="display:block;">

<div id="deta_cab" style=" margin:0px; padding:0px;display:none;"></div>

<div id="deta_cxcp" style=" margin:0px; padding:0px;display:none;">
</div>

<div id="deta_txt" style=" margin:0px; padding:0px;display:none;">
<table width="100%" border="0" cellpadding="0" cellspacing="0"  style="border-collapse:collapse; background:#eee;">
<tr align="center" valign="center" style="border-top: solid 1px;border-bottom: solid 1px">
  		<?php $pcaption='_FECHA_'; $pidtxt="fecha2"; $pobj=2; include('vrgetfec.php'); ?> 
  		<?php $pcaption='CEDULA'; $ptabla='enti'; $pidtxt="enti2"; $pobj=4; include('vrgetcod.php'); ?> 
  		<?php $pcaption='ITEM'; $ptabla='item'; $pobj=4; $ponblur='item(event);'; include('vrgetcod.php'); ?> 
  		<?php $pcaption='NOVEDAD'; $ptabla='nvdd';  $pobj=4; include('vrgetcod.php'); ?> 
  		<?php $pcaption='DOCU'; $ptabla='docu'; $pidtxt="docum"; $pobj=4; include('vrgetcod.php'); ?>  
  		<?php $pcaption='P.EMIS.';  $pidtxt="ptoem"; $plong=6; $pobj=2; $pdefa='001001'; include('vrgetnum.php'); ?>  
  		<?php $pcaption='NUMERO'; $pidtxt='numer'; $plong=9; $pobj=2; $ponclick="list_cxcp('docu','enti','numer')"; include('vrgetnum.php'); ?> 
  		<?php $pcaption='CANT.'; $pidtxt='cant'; $plong=8; $pobj=2; include('vrgetval.php'); ?>

	<!--  ECGL  -->
  		<?php $pcaption='LAMINA'; $pidtxt='lamina'; $plong=8; $pobj=2; include('vrgettxt.php'); ?>
  		<?php $pcaption='LARGO';  $pidtxt='largo';  $plong=8; $pobj=2; include('vrgettxt.php'); ?>
  		<?php $pcaption='ANCHO';  $pidtxt='ancho';  $plong=8; $pobj=2; include('vrgettxt.php'); ?>
	<!--  RCSA  -->

	<!--  RCSA  -->
  		<?php $pcaption='P.UNIT.'; $pidtxt='puni_o'; $plong=8; $pobj=2; include('vrgetval.php'); ?>
  		<?php $pcaption='P.ALT..'; $pidtxt='puni_a'; $plong=7; $pobj=2; include('vrgetval.php'); ?>
  		<?php $pcaption='IMPO'; $pidtxt='impo'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
	<!--  RCSA  -->

<!--  PACO.PCS1.PSR1.IDMT  -->
  		<?php $pcaption='CONTENEDOR'; $ptabla='cntn'; $pobj=2; include('vrgetcod.php'); ?>
  		<?php $pcaption='DESDE'; $pidtxt='cntnf1'; $pobj=2; include('vrgetfec.php'); ?>
  		<?php $pcaption='HASTA'; $pidtxt='cntnf2'; $pobj=2; include('vrgetfec.php'); ?>
  		<?php $pcaption='CHASIS'; $pidtxt='chasis'; $plong=10; $pobj=2; include('vrgettxt.php'); ?>
<!--  PACO  -->

  		<?php $pcaption='P.UNIT.'; $pidtxt='puni'; $plong=8; $pobj=2; include('vrgetval.php'); ?>
			<?php $pcaption='P.V.P.'; $pidtxt='pvp1'; $plong=8; $pobj=2; include('vrgetval.php'); ?> 
  		<?php $pcaption='%ICE'; $pidtxt='ice'; $pobj=2; include('vrgetval.php'); ?>
  		<?php $pcaption='%DCTO'; $pidtxt='dcto'; $pobj=2; include('vrgetval.php'); ?> 
  		<?php //$pcaption='%IVA'; $pidtxt='iva'; $pobj=2; $pdefa=14; include('vrgetval.php'); ?> 
  		<?php $pcaption='%IVA'; $pidtxt='iva'; $pobj=2; $pdefa=12; include('vrgetval.php'); ?> 
  		<?php $pcaption='IRBP'; $pidtxt='irbp'; $pobj=2; $plong=4; include('vrgetval.php'); ?> 
  		<?php $pcaption='CAIR'; $ptabla='cair';  $pobj=2; include('vrgetcod.php'); ?> 
  		<?php $pcaption='CUENTA'; $ptabla='ctas'; $pobj=4; include('vrgetcod.php'); ?>
  		<?php $pcaption='BASE'; $pidtxt='base'; $plong=7; $pobj=2; include('vrgetval.php'); ?> 
  		<?php $pcaption='%RET'; $pidtxt='porc'; $pobj=2; include('vrgetval.php'); ?> 
  		<?php $pcaption='DEBITO'; $pidtxt='debito'; $plong=9; $pobj=2; include('vrgetval.php'); ?> 
  		<?php $pcaption='CREDITO'; $pidtxt='credito'; $plong=9; $pobj=2; include('vrgetval.php'); ?> 
  		<?php $pcaption='C.SUB'; $ptabla='csub'; $pobj=2; include('vrgetcod.php'); ?> 
  		<?php $pcaption='# SERIE'; $pidtxt='numserie'; $plong=15; $pobj=2; include('vrgettxt.php'); ?>  
  		<?php $pcaption='LOTE'; $pidtxt='lote'; $plong=5; $pobj=2; include('vrgettxt.php'); ?> 
  		<?php $pcaption='Cambio'; $ptabla='item'; $pidtxt='cambio';  $pobj=4; include('vrgetcod.php'); ?> 

  		<?php $pcaption='SUELDO'; $pidtxt='sueldo'; $plong=9; $pobj=2;  $ponblur='valsueldo();'; include('vrgetval.php'); ?>
  		<?php $pcaption='% ANTI'; $pidtxt='poranti'; $pobj=2; $ponblur='valsueldo();'; include('vrgetval.php'); ?>
  		<?php $pcaption='ANTICIPO'; $pidtxt='valanti'; $plong=9; $pobj=2; $ponblur='valsueldo();'; include('vrgetval.php'); ?>
  		<?php $pcaption='IESS'; $pidtxt='iess'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
  		<?php $pcaption='RELOJ'; $pidtxt='reloj'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
  		<?php $pcaption='ATRASO'; $pidtxt='atraso'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
  		<?php $pcaption='FALTA'; $pidtxt='falta'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
  		<?php $pcaption='H_25%'; $pidtxt='h25'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
  		<?php $pcaption='H_50%'; $pidtxt='h50'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
  		<?php $pcaption='H100%'; $pidtxt='h100'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>

			<?php $pcaption='D_13'; $pidtxt='de13'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
			<?php $pcaption='D_14'; $pidtxt='de14'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
			<?php $pcaption='F.RES'; $pidtxt='fres'; $plong=1; $pobj=2; include('vrchkbox.php'); ?>
			
			<?php $pcaption='DETALLE'; $pidtxt='detalle'; $plong=50; $pobj=2; include('vrgettxt.php'); ?>

		<th id="th_graba" style="display:none;" valign="center">     
  		<?php $pcaption='AGREGAR LINEA'; $pidtxt='agregar'; $ponclick="graba_full();"; include('vrbutton.php'); ?>
<!--     <input type="button"  accesskey="G" id="agregar"  align="center" onClick="graba_full();" value="AGREGAR&#13;&#10;LINEA"  style="font-weight:bold;max-width:80px;max-height:80px;whitespace:normal;"/> -->
    </th>

    <th id="th_dispo" style="display:none;">     
    <div>D</div>     
    <div><input type="text" id="dispo"  class="sub_deta" style="width:80px;text-align:right;" disabled ="true" /></div>
    </th>

	</tr>
</table>
</div>
	
</table>
</div>

<hr/>
<div id="reg_deta"></div>
<table id="errores"  border="0" cellspacing="0" cellpadding="0" width="100%" style="font-size:14px; border-collapse:collapse;">
        <tr style="display:none;" valign="center">
       	<td><input type="text" id="error1" style="border:none; display:none; width:500px; padding-left:2px;background-color:white;"  value="" /></td>
        </tr>
</table>
</div>

<div id="proce_carg_cab"></div>
<input type="hidden" id="empr_codigo" value="<?php echo $empr_codigo ?>" />
<input type="hidden" id="item_cuenta_descri" />
<input type="hidden" id="cair_descri" />
<input type="hidden" id="hdd_idxreg"  />
<input type="hidden" id="hdd_docuxreg"  />

<?php	require('lista_car.php'); ?>	

</html>