<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = '../index.php';
		</script>
		<? 
		exit();
		}
$id_empresa = $_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];
$id_autoriza=25;

/*Sesiones*/
include("../conex.php");
include("../autoriza.php");

$txtfecha = date('d')."/".date('m')."/".date('Y');
?>
<!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=iso-8859-1" />
<title>Libro de Compra</title>
<script language="JavaScript" src="../css/cal.js" type="text/JavaScript"></script>
<style type="text/css">
<!--
body {
	background-color: #CCCCCC;
	margin-left: 0px;
	margin-top: 3px;
	margin-right: 0px;
	margin-bottom: 0px;
}
select {
	clear: right;
	float: left;
	height: auto;
	width: 267px;
}
-->
#div1{
	margin-left:30px;
	float:left;
	width:50%;
}
#div2{
	margin-left:60px;
	float: left;
	width:40%;
}
</style>
</head>
<body>
<div align="center">

<form id="form1" name="form1" method="post" action="muestra.php" target="mainFrame">

<td width="100%" align="center"><font size="+2">Libro Compra</font></td>

<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
	
	<tr>
		<td>Seleccione mes: 
	    <input name="txtfecha" id="txtfecha" type="text" style="border-width:0; background-color:#CCCCCC; text-align:center" align="center" value="<?=$txtfecha?>" size="7" readonly>
			<a  href="javascript:show_calendar('form1.txtfecha');"><img name="foto2" id="foto2" align="top" border="0" src="../Images/CALENDAR.gif" style="cursor:pointer" title="Presione aqui y seleccione la fecha" />
		</a>
        </td>
        <td>
       <?
			$sql_umed ="SELECT bodega.id, descripcion  FROM bodega ORDER BY descripcion ASC";
			$res_umed = mysql_query($sql_umed,$enlace);
			$contb=0;
			?>
<select name="lstbodega" id="lstbodega" style="width:200px"  > 
			  <option value="0" selected="selected">Bodega (Todos)</option>
			  <?
			  while (mysql_fetch_object ($res_umed))
				{
				$sql_umed_cod = mysql_result($res_umed, $contb, "bodega.id");
				$sql_umed_nom = mysql_result($res_umed, $contb, "descripcion");
				
			?>
                <option value="<?=$sql_umed_cod?>"><? echo $sql_umed_nom;?></option>
			<?
				$contb = $contb+1;
			}
			?>
      </select>	 
        
        </td>



	  <td>
		  <select name="tdcto" id="tdcto"  onChange="javascript:form1.submit();">
			<option value="0" selected>SELECCIONE TIPO DOCUMENTO
			<option value="0">TODOS
			<option value="1">BOLETAS
			<option value="2">GUIAS
            <option value="3">FACTURAS, NC, ND y Electronicas
             <option value="4">Orden de Compra
			</select>
		</td>
	<td><input type="submit" name="Submit" value="Ver Libro"/> <input type="submit" name="Submit" value="Salir" onClick="fun_salir();"/>
    </td>
</table>

</form>
<div id="div1">
<form action="muestra_dte.php" method="post" name="form2" enctype="multipart/form-data"  target="mainFrame">

<table border="0" align="center">
		   <td>Subir XML Manualmente</td>
           <td><input type="submit" name="Submit2" value="Subir DTE" /></td>
             <td><span class="combos"> 
           <input name="reserva" type="file" id="reserva" size="40" onBlur="LimitAttach(this,7);">   </span></td>
</table>
</form>
</div>
<div id="div2">
<form method="post" id="formulario">
<table border="0" align="center">
           <td>Obtener XML Automaticamente</td> 
           <td><button type="button" id="tuboton">Obtener XML</button></td>
           <td><label id="cargando" style="visibility:hidden"><img src="../Images/loading.gif"/></label></td>
</table>
</form>
</div>
</div>
</body>
</html>

<script language="javascript">
function fun_salir()
	{
	window.top.open('','_parent','');window.top.close();
	}
	

	
function LimitAttach(tField,iType) 
{
file=tField.value;
if (iType==1) { 
extArray = new Array(".gif",".jpg",".png",".bmp");
}
if (iType==2) {
extArray = new Array(".swf");
}
if (iType==3) {
extArray = new Array(".exe",".sit",".zip",".tar",".swf",".mov",".hqx",".ra",".wmf",".mp3",".qt",".med",".et");
}
if (iType==4) {
extArray = new Array(".mov",".ra",".wmf",".mp3",".qt",".med",".et",".wav");
}
if (iType==5) {
extArray = new Array(".html",".htm",".shtml");
}
if (iType==6) {
extArray = new Array(".doc",".xls",".ppt");
}
if (iType==7) {
extArray = new Array(".xml");
}

allowSubmit = false;
if (!file) return;

while (file.indexOf("\\") != -1) file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) {
allowSubmit = true;
break;
}
} 

if (!allowSubmit) 
{
alert("Usted sólo puede subir archivos con extensiones " + (extArray.join(" ")) + "\nPor favor seleccione un nuevo archivo");
}
} 
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$("#tuboton").click(function(){ 
var fecha_busqueda=$('#txtfecha').val();
 document.getElementById("cargando").style.visibility = 'visible';
  $.post("obtener-xml_mcc.php?fb="+fecha_busqueda, function(){  
  	document.getElementById("cargando").style.visibility = 'hidden';
   }); 
});
</script>
