<?php 
session_start();
require('../cfg/cfg.php');
require('../cfg/res.php');
?>
<!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_id'];?> - Generar Inventario</title>
<link rel="stylesheet" href="http://vcrxol.com/_css/comun.css" type="text/css" />
<link rel="stylesheet" href="../css/comun2.css" type="text/css" />
<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/busca_ficha.js');?>
<?php include('../../_js/fecha_format.js');?>

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

function docu_key(e)
{
		var docux=document.getElementById('docu').value;
		
		if(docux=='' || docux==' ')
		{
			return false;
		}
	
		if(e.keyCode==13)
		{
			docu_();	
		}
		
}
function docu_()
{
	busca_maes2('docu',document.getElementById('docu').value,'docu','docu_descri','');
}

function reca_invep()
{
// 	docu_();
// 	if(document.getElementById('docu_descri').innerHTML=='N/A' || document.getElementById('docu_descri').innerHTML=='')
// 	{
// 		return false;
// 	}
	var error='ext_error';
	var lsub=document.getElementById('lsub').value;
	var item=document.getElementById('item').value;
	var fini=document.getElementById('fini').value;
	var ffin=document.getElementById('ffin').value;
		$.ajax({
						cache:false,
						url:'vrrecainvep2.php',
						datatype: "text",
	    			async:false,
						type:'POST',
						data:{fini:fini,ffin:ffin,lsub:lsub,item:item}, 
    				beforeSend: function(jqXHR, textStatus){}, 
						success:function(dato, textStatus, jqXHR){console.log(dato);},
						error:function(jqXHR,textStatus,errorThrown )
						{
           		if(document.getElementById(error))
							{
							document.getElementById(error).innerHTML='';
							if (jqXHR.status === 0) {document.getElementById(error).innerHTML='Not connect: Verify Network.';}
								else if (jqXHR.status == 404) {document.getElementById(error).innerHTML='Requested page not found [404]';} 
								else if (jqXHR.status == 500) {document.getElementById(error).innerHTML='Internal Server Error [500].';} 
								else if (exception === 'parsererror') {document.getElementById(error).innerHTML='Requested JSON parse failed.';} 
								else if (exception === 'timeout') {document.getElementById(error).innerHTML='Servidor no Responde';} 
								else if (exception === 'abort') {document.getElementById(error).innerHTML='Ajax request aborted.';} 
								else {document.getElementById(error).innerHTML='Uncaught Error: ' + jqXHR.responseText;}
						 }
					   else
					   {
							if (jqXHR.status === 0) {console.log('Not connect: Verify Network.');}
							 	else if (jqXHR.status == 404) {console.log('Requested page not found [404]');}
							 	else if (jqXHR.status == 500) {console.log('Internal Server Error [500].');}
							 	else if (exception === 'parsererror') {console.log('Requested JSON parse failed.');}
							 	else if (exception === 'timeout') {alert('Servidor no Responde');}
							 	else if (exception === 'abort') {console.log('Ajax request aborted.');} 
							 	else {console.log('Uncaught Error: ' + jqXHR.responseText);}
							}
						}, 
						complete:function(jqXHR, textStatus){if(textStatus==='success'){}},
						timeout:300000
					});

}



</script>

</head>

<body>
<?php
	$fecha1 = date('Y-m-j');
$nuevafecha = strtotime ( '-1 month' , strtotime ( $fecha1 ) ) ;
$xfecha1 = date ( 'Y-m-j' , $nuevafecha );
$xfecha1= date('Y-m-'.'01');
$xfecha2= date('Y-m-d');

	?>
<div align="center" >
	<div align="center">
<table width="100%">
	<tr>
    	<td>
			<a href="http://<?php echo $empr_codigo;?>.vcrxol.com/main/" title="INICIO" ><img src="http://vcrxol.com/_logo/logo<?php echo $empr_codigo;?>1.png" width="190"/></a>		</td>
        <td>
	        <div style="font-size:18px; font-weight:bolder;  margin:0px 0px 0px 5px; padding:0px 0px 0px 5px; width:300px;border-bottom:#09c solid 2px;" align="left">RECALCULAR INVENTARIOS (COSTO PROMEDIO)</div>
        </td>
        <td  align="right"><span style="font-weight:bolder;"><?php echo $_SESSION['user_vcrx_descri'];?></span>&nbsp;</td>
    	<td width="70"  align="right"><input type="image" src="http://vcrxol.com/_img/salir.png"  title="Salir" onclick="if(confirm('Esta Seguro que Desea Salir?')){window.location.href ='../salir.php';}" style="border:none;"/>&nbsp;</td>
    </tr>
</table>

<table>
<!-- 	<tr>
    	<td><input type="button" value="DOCU:" onclick="docu_();"  class="lst"  /></td>
        <td><input type="text" id="docu" onkeypress="docu_key(event);" /></td>
        <td><div id="docu_descri"></div></td>
    </tr> -->
	<tr>
<td>
<table>	
	<caption>FECHAS</caption>	
	<tr>
		<?php $pcaption='inicial';  $pidtxt='fini'; $pdefa=$xfecha1; $pobj=3; include('vrgetfec.php'); ?>
</tr>
	<tr>
		<?php $pcaption='final';  $pidtxt='ffin'; $pdefa=$xfecha2; $pobj=3; include('vrgetfec.php'); ?>
</tr>
</table>
</td>			
	</tr>
	<tr>
		<?php $pcaption='LINEA';  $ptabla='lsub'; include('vrgetcod.php'); ?>
</tr>
	<tr>
		<?php $pcaption='ITEM';  $ptabla='item'; include('vrgetcod.php'); ?>
</tr>
<!-- 	<tr>
    	<td>NUMERO</td>
        <td><input type="text" id="nini" /></td>
        <td><input type="text" id="nfin" /></td>
    </tr> -->
<tr>
	<td colspan="3"><input type="button" onclick="reca_invep();" value="Generar" class="btn" /></td>
</tr>
</table>


<div id="ext_error"></div>
<div id="ext_list"></div>
</div>
</div>
</body>
</html>