<?php
include'../include/funciones.php';
include'../session/validar.php';
//validar('../../index.php');
include'../include/sql.php';
include'../include/page_bottom.php';
$lineas = 23;
//Fecha actual
//Fecha vencimiento
//Consulto datos del proveedor para mostrar en el combo
$cliente = $sql->consulta("SELECT * FROM tb_clientes");
///Consulto el ultimo codigo de la factura
$consulta_cod_factura = $sql->consulta("SELECT MAX(codifact) AS codifact FROM tb_facturas");
//Le sumo + 1 por ejemplo la factura 083 + 1 da 084 y esa seria la factura actual
$resultado_cod_factura = $sql->fetch_array($consulta_cod_factura);
$codfactura = $resultado_cod_factura['codifact'] + 1;
?>
<!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"><!-- InstanceBegin template="/Templates/index.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Johana 0.1 - Factura de Venta</title>
<!-- InstanceEndEditable -->
<link href="../../css/sytle.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="../../img/icono.ico" />
<script type="text/javascript" src="../../scripts/history.js"></script>
<!-- InstanceBeginEditable name="head" -->
<link href="../../css/grilla.css" rel="stylesheet" type="text/css" />
<link href="../../css/validate.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../../css/tiger/theme.css"/>
<link rel="stylesheet" type="text/css" href="../../css/jquery-ui-1.8.9.custom.css"/>
<script type="text/javascript" src="../../scripts/jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../../scripts/jquery/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="../../scripts/calendario/calendar.js"></script>
<script type="text/javascript" src="../../scripts/calendario/calendar-es.js"></script>
<script type="text/javascript" src="../../scripts/calendario/calendar-setup.js"></script>
<script type="text/javascript">
$(function(){
$('#referencia').autocomplete({
source : '../modelos/sugerencias_productos.php',
select: function(event, ui) {
$("#descripcion").val(ui.item.descripcion);
$("#valor").val(ui.item.valor);
},
});
});
window.onload = function() {
Calendar.setup({inputField: "fecha", ifFormat: "%Y-%m-%d",button: "selector"});
Calendar.setup({inputField: "vencimiento", ifFormat: "%Y-%m-%d",button: "selector2"});
}
function change_fecha(){
if(document.form.cmbfpago.selectedIndex == 1){
document.form.vencimiento.value = '<?php echo $hoy ?>';
}
else{
document.form.vencimiento.value = '<?php echo $vencimiento ?>';
}
}
function agregar()
{
if(document.form.referencia.value != "" && document.form.cantidad.value != "" && document.form.descripcion.value != "" && document.form.valor.value != "" &&document.form.descuento.value != ""){
<?php $indice = 0 ?>
document.form.cant<?php echo $indice ?>.style.visibility = 'visible';
document.form.refeprod<?php echo $indice ?>.style.visibility = 'visible';
document.form.desc<?php echo $indice ?>.style.visibility = 'visible';
document.form.valor<?php echo $indice ?>.style.visibility = 'visible';
document.form.valortotal<?php echo $indice ?>.style.visibility = 'visible';
document.form.cant<?php echo $indice ?>.value = document.form.cantidad.value;
document.form.refeprod<?php echo $indice ?>.value = document.form.referencia.value;
document.form.desc<?php echo $indice ?>.value = document.form.descripcion.value;
document.form.valor<?php echo $indice ?>.value = document.form.valor.value;
cantidad = document.form.cantidad.value;
descuento = (document.form.descuento.value/100);
valor = document.form.valor.value;
porcentaje = valor * descuento;
valor_parcial = valor - porcentaje;
valor_final = cantidad * valor_parcial;
document.form.valortotal<?php echo $indice ?>.value = valor_final;
<?php echo $indice++ ?>
document.form.cantidad.value = "";
document.form.referencia.value = "";
document.form.descripcion.value = "";
document.form.valor.value = "";
document.form.descuento.value = "";
}else{
alert('Complete todos los campos antes de agregar el producto a la factura');
}
}
</script>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="header">Empresa</div>
<div id="boton_atras"><a href="panel.php"><img src="http://www.forosdelweb.com/img/home.png" width="16" height="16" alt="Inicio" /></a> <img src="http://www.forosdelweb.com/img/back.png" width="16" height="16" alt="Atras" onclick="nav(-1)" style="cursor:pointer" /></div>
<div id="datos_login">
Bienvenido <strong><?php echo $_SESSION['descusua'] ?></strong> | <strong><?php echo $_SESSION['rollusua'] ?></strong> <a href="#" title="Opciones de Cuenta"><img src="http://www.forosdelweb.com/img/opciones.png" width="16" height="16" alt="Opciones de Cuenta" /></a> <a href="http://www.forosdelweb.com/f18/session/logout.php" title="Cerrar Sesión"><img src="http://www.forosdelweb.com/img/salir.png" width="16" height="16" alt="Cerrar Sesión" /></a>
</div>
<div class="cleaner"></div>
<!-- InstanceBeginEditable name="Contenido" -->
<fieldset>
<legend>Factura de venta<!--../modelos/generar_comprobante.php--> </legend>
<form action="../modelos/generar_comprobante.php" method="post" enctype="multipart/form-data" name="form" id="form">
<br />
<br />
<table width="90%" border="0" align="center" class="table">
<tr align="center" class="td_bg">
<td height="30"><strong>Codigo/Referencia</strong></td>
<td><strong>Cantidad</strong></td>
<td><strong>Descripción/Aplicación</strong></td>
<td><strong>Valor UNIT.</strong></td>
<td><strong>Descuento</strong></td>
<td> </td>
</tr>
<tr align="center">
<td><input name="referencia" type="text" class="valid_field" id="referencia" autocomplete="off" /></td>
<td><input name="cantidad" type="text" class="valid_field" id="cantidad" size="2" autocomplete="off" /></td>
<td><input name="descripcion" type="text" class="valid_field" id="descripcion" size="70" autocomplete="off" /></td>
<td><input name="valor" type="text" class="valid_field" id="valor" size="20" autocomplete="off" /></td>
<td><input name="descuento" type="text" class="valid_field" id="descuento" size="3" autocomplete="off" />%</td>
<td><img src="http://www.forosdelweb.com/img/grilla/add.png" width="16" height="16" alt="Añadir producto" onclick="agregar()" /></td>
</tr>
</table>
<br />
<br />
<table width="90%" border="0" align="center" class="table">
<tr align="center" valign="middle" class="td_bg">
<td height="30"><strong>Cant</strong></td>
<td><strong>Codigo/Referencia</strong></td>
<td><strong>Descripción/Aplicación</strong></td>
<td><strong>Valor UNIT.</strong></td>
<td><strong>Valor TOTAL</strong></td>
</tr>
<?php for ($i = 0; $i < $lineas; $i++): ?>
<tr align="center">
<td><input name="cant<?php echo $i ?>" type="text" class="field_factura" id="cant<?php echo $i ?>" style="visibility:hidden" size="2" readonly="readonly" /></td>
<td><input name="refeprod<?php echo $i ?>" type="text" class="field_factura" id="refeprod<?php echo $i ?>" style="visibility:hidden" readonly="readonly" /></td>
<td><input name="desc<?php echo $i ?>" type="text" class="field_factura" id="desc<?php echo $i ?>" style="visibility:hidden" size="70" readonly="readonly" /></td>
<td><input name="valor<?php echo $i ?>" type="text" class="field_factura" id="valor<?php echo $i ?>" style="visibility:hidden" size="20" readonly="readonly" /></td>
<td><input name="valortotal<?php echo $i ?>" type="text" class="field_factura" id="valortotal<?php echo $i ?>" style="visibility:hidden" size="20" readonly="readonly" /></td>
</tr>
<?php endfor; ?>
</table>
</form>
</fieldset>
<!-- InstanceEndEditable -->
<div class="cleaner"></div>
<div id="content_bottom">
<?php bottom_page(); ?>
</div>
<!-- InstanceBeginEditable name="Paginacion" -->
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd -->
</html>