<?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='NUEVO B/L';
$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 $empr_nombre .' - ' . $_SESSION['user_vcrx_descri'];?></title>
<link rel="stylesheet" href="http://vcrxol.com/css/ambiente.css"  type="text/css" />
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
<script type="text/javascript">
function _consigna(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('enti',document.getElementById('consigna').value,'consigna','consigna_descri','');
	}
}

function _agente(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('agnt',document.getElementById('agente').value,'agente','agente_descri','');
	}
}

function _nave(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('nave',document.getElementById('nave1').value,'nav1e','nave1_descri','');
	}
}

function _nave2(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('nave',document.getElementById('nave2').value,'nave2','nave2_descri','');
	}
}


function _ptoorig(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('port',document.getElementById('ptoorig').value,'ptoorig','ptoorig_descri','');
	}
}

function _ptodest(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('port',document.getElementById('ptodest').value,'ptodest','ptodest_descri','');
	}
}

function _vendedor(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('vndd',document.getElementById('vendedor').value,'vendedor','vendedor_descri','');
	}
}

function _contenedor(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('cntn',document.getElementById('contenedor').value,'contenedor','contenedor_descri','');
	}
}


function guarda_bldn()
{
	//var codigo=document.getElementById('codigo').value;
	var descri=document.getElementById('descri').value;
	var master=document.getElementById('master').value;
	var house=document.getElementById('house').value;
	var job=document.getElementById('job').value;
	var vendedor=document.getElementById('vendedor').value;
	var agente=document.getElementById('agente').value;
	var consigna=document.getElementById('consigna').value;
	var nave1=document.getElementById('nave1').value;
	var viaje=document.getElementById('viaje').value;
	var nave2=document.getElementById('nave2').value;
	var booking=document.getElementById('booking').value;
	var manifiesto=document.getElementById('manifiesto').value;
	var ptoorig=document.getElementById('ptoorig').value;
	var ptodest=document.getElementById('ptodest').value;
	var fecha1=document.getElementById('fecha1').value;
	var fecha2=document.getElementById('fecha2').value;
	var contenedor=document.getElementById('contenedor').value;
	var carga=document.getElementById('carga').value;
	var peso=document.getElementById('peso').value;
	
	var codigo=document.getElementById('codigo').value=master+'-'+house;
	document.getElementById('codigo').value=codigo;
descri=master+'/'+house;
	
$.ajax({
		cache:false,
		url:'nbldn2.php',
		datatype: "text",
	    async:true,
		type:'POST',
		data:{
			codigo:codigo,
			descri:descri,
			master:master,house:house,job:job,
			vendedor:vendedor,
			agente:agente,
			consigna:consigna,
			nave1:nave1,
			nave2:nave2,
			booking:booking,
			manifiesto:manifiesto,
			ptoorig:ptoorig,
			ptodest:ptodest,
			fecha1:fecha1,
			fecha2:fecha2,
			contenedor:contenedor,
			carga:carga,
			peso:peso
		},
   		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') 
							{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 _carga_bldn(e)
{
	if(e=='onblur' || e.keyCode==13){return false;}
	var master=document.getElementById('master').value;	
	var house=document.getElementById('house').value;	
	var codigo=document.getElementById('codigo').value=master+'-'+house;
	document.getElementById('codigo').value=codigo;
	
	$.ajax({
		cache:false,
		url:'nbldn3.php',
		datatype: "text",
	    async:true,
		type:'POST',
		data:{codigo:codigo},
   		beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{
			console.log(dato);
			if($(dato).find("error").text()!=0){return false;}
			document.getElementById('descri').value=$(dato).find("hdd_descri").text();
			document.getElementById('job').value=$(dato).find("hdd_job").text();
			document.getElementById('vendedor').value=$(dato).find("hdd_vendedor").text();
			document.getElementById('agente').value=$(dato).find("hdd_agente").text();
			document.getElementById('consigna').value=$(dato).find("hdd_consigna").text();
			document.getElementById('nave1').value=$(dato).find("hdd_nave1").text();
			document.getElementById('viaje').value=$(dato).find("hdd_viaje").text();
			document.getElementById('nave2').value=$(dato).find("hdd_nave2").text();
			document.getElementById('booking').value=$(dato).find("hdd_booking").text();
			document.getElementById('manifiesto').value=$(dato).find("hdd_manifiesto").text();
			document.getElementById('ptoorig').value=$(dato).find("hdd_ptoorig").text();
			document.getElementById('ptodest').value=$(dato).find("hdd_ptodest").text();
			document.getElementById('fecha1').value=$(dato).find("hdd_fecha1").text();
			document.getElementById('fecha2').value=$(dato).find("hdd_fecha2").text();
			document.getElementById('contenedor').value=$(dato).find("hdd_contenedor").text();
			document.getElementById('carga').value=$(dato).find("hdd_carga").text();
			document.getElementById('peso').value=$(dato).find("hdd_peso").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:30000
	});
}


<?php include('../../_js/busca_maes3.js');?>
<?php include('../../_js/lista_maes3.js');?>
<?php include('../../_js/fecha_format.js');?>

</script>
<style type="text/css">
body{background:#ffffff;}
.dper_txt{border:solid 1px #000000; border-radius:2px; padding:2px; margin:2px;}
</style>
</head>

<body>
<div align="center">
	<div>
	<div align="center"><?php include('../../_lib/cabecera2.php');?></div>
	<div>
    <table>
    
    <tr>
    	<td><input type="button" value="CODIGO:" /></td>
        <td><input type="text" id="codigo" /></td>
        <td></td>
    </tr>

    <tr>
    	<td><input type="button" value="DESCRI:" /></td>
        <td><input type="text" id="descri" /></td>
        <td></td>
    </tr>

    <tr>
   		<?php $pcaption='B/L MASTER';  $pidtxt='master'; $plong=20;  $ponblur="_carga_bldn(event);"; include('vrgettxt.php'); ?>
    </tr>

    <tr>
   		<?php $pcaption='HOUSE';  $pidtxt='house'; $plong=20;  $ponblur="_carga_bldn(event);"; include('vrgettxt.php'); ?>
    </tr>
    <tr>
   		<?php $pcaption='JOB';  $pidtxt='job'; $plong=20;  include('vrgettxt.php'); ?>
    </tr>

    <tr>
					<?php $pcaption='VENDEDOR'; $ptabla='vndd'; $pidtxt='vendedor';   include('vrgetcod.php'); ?>
    </tr>

    <tr>
					<?php $pcaption='AGENTE'; $ptabla='agnt'; $pidtxt='agente';   include('vrgetcod.php'); ?>
    </tr>

    <tr>
			<?php $pcaption='CONSIGNATARIO'; $ptabla='enti'; $pidtxt='consigna';   include('vrgetcod.php'); ?>
    </tr>

    <tr>
					<?php $pcaption='NAVE'; $ptabla='nave'; $pidtxt='nave1';   include('vrgetcod.php'); ?>
    </tr>

    <tr>
   		<?php $pcaption='VIAJE';  $pidtxt='viaje'; $plong=10;  include('vrgettxt.php'); ?>
    </tr>

    <tr>
					<?php $pcaption='TRASBORDO'; $ptabla='nave'; $pidtxt='nave2';   include('vrgetcod.php'); ?>
    </tr>

    <tr>
   		<?php $pcaption='BOOKING';  $pidtxt='booking'; $plong=20;  include('vrgettxt.php'); ?>
    </tr>

    <tr>
   		<?php $pcaption='MANIFIESTO';  $pidtxt='manifiesto'; $plong=20;  include('vrgettxt.php'); ?>
    </tr>

    <tr>
		<?php $pcaption='PTO.ORIG.'; $ptabla='port'; $pidtxt='ptoorig';   include('vrgetcod.php'); ?>
    </tr>

    <tr>
		<?php $pcaption='PTO.DEST.'; $ptabla='port'; $pidtxt='ptodest';   include('vrgetcod.php'); ?>
    </tr>

    <tr>
		<?php $pcaption='FEC.SALIDA';  $pidtxt='fecha1';   include('vrgetfec.php'); ?>
    </tr>
    <tr>
		<?php $pcaption='FEC.LLEGADA';  $pidtxt='fecha2';   include('vrgetfec.php'); ?>
    </tr>


    <tr>
		<?php $pcaption='CONTENEDOR'; $ptabla='cntn'; $pidtxt='contenedor';   include('vrgetcod.php'); ?>
    </tr>

    <tr>
		<?php $pcaption='CARGA';  $pidtxt='carga';   $plong=20; include('vrgettxt.php'); ?>
    </tr>

    <tr>
		<?php $pcaption='PESO';  $pidtxt='peso';   include('vrgetval.php'); ?>
    </tr>

    <tr>
		<td colspan="2">
		<?php $pcaption='GRABAR';  $ponclick="guarda_bldn();";   include('vrbutton.php'); ?>
		</td>		
    </tr>


		</table>
    
<!--     <input type="button" value="Guardar" onclick="guarda_bldn();" /> -->
    </div>
    </div>
</div>

<?php		
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>    
 -->
</body>
</html>