/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Autores: Pedro Obregón Mejías
Rubén D. Mancera Morán
Versión: 1.0
Fecha Liberación del código: 13/07/2004
Galopín para gnuLinEx 2004 -- Extremadura
*/
?>
Galopin v1.0
include ("conectar.php");
if ($ini5=="0") {
$consulta3 = "Select max(codpresupuesto) as maximo from presupuestostmp";
$resultado3 = mysql_query($consulta3, $conexion);
$lafila3=mysql_fetch_array($resultado3);
if (empty($lafila3["maximo"])) { $codpresupuesto=0; }
else { $codpresupuesto=$lafila3["maximo"]; }
$codpresupuesto++;
$fe="0000-00-00";
$ob="nada";
$consulta3="INSERT INTO `presupuestostmp` (`codpresupuesto` , `fecha` , `iva` , `codcliente` , `anyo` , `observaciones` )
VALUES ('$codpresupuesto', '$fe' , '0' , '0' , '0' , '$ob')";
$consulta3=mysql_query($consulta3, $conexion);
$consulta= "delete from presupuestolineatmp where codpresupuesto='$codpresupuesto'";
$consulta=mysql_query($consulta, $conexion);
}
$consulta = "Select * from clientes where codcliente='$codcli'";
$resultado = mysql_query($consulta, $conexion);
$lafila=mysql_fetch_array($resultado);
?>
Código de cliente:
echo $lafila["codcliente"]; ?>
Nombre:
echo $lafila["nombre"]; ?>
CIF/NIF:
echo $lafila["nif"]; ?>
F. Pago:
$fp=$lafila["codfp"];
$consulta0 = "Select * from formapago where codfp='$fp'";
$resultado0 = mysql_query($consulta0, $conexion);
$lafila0=mysql_fetch_array($resultado0); ?>
echo $lafila0["denfp"]; ?>
Dirección:
echo $lafila["direccion"]; ?>
$prov=$lafila["codprovincia"];
$consulta0 = "Select * from provincias where codprovincia='$prov'";
$resultado0 = mysql_query($consulta0, $conexion);
$lafila0=mysql_fetch_array($resultado0); ?>
if ($borrar==1) {
$consulta8="delete from presupuestolineatmp where codpresupuesto='$codpresupuesto' and numlinea='$numlinea'";
$resultado8 = mysql_query($consulta8, $conexion);
} ?>
Fecha presupuesto:
echo $fecha; ?>
Tipo de IVA
echo $iva0; ?>%
if ($ini=="1") {
if (!empty($codigo)) {
$familia = substr($codigo,0,2);
$subfamilia = substr($codigo,2,2);
$codigoarticulo = substr($codigo,4,2);
$consulta2 = "select * from articulos where codfamilia='$familia' and codsubfamilia='$subfamilia' and codigo='$codigoarticulo'";
$resultado2 = mysql_query($consulta2, $conexion);
$filas=mysql_num_rows($resultado2);
$mal=0;
if ($filas==0) { ?>
print "Error, código de artículo incorrecto"; ?>
}
if ($filas>0) {
$lafila2=mysql_fetch_array($resultado2);
$precio=$pvp;
if ((!preg_match("/^[0-9]*(.[0-9]{0,4})?$/", $precio)) or ($precio==0)) { ?>
$mensajeerror="Error, precio incorrecto. "; $mal=1;?>
}
if ((!preg_match("/^[0-9]*(.[0-9]{0,4})?$/", $cantidad)) or ($cantidad==0)) {
$mensajeerror=$mensajeerror. "Error, cantidad incorrecta. "; $mal=1;
}
if ((!preg_match("/^[0-9]*(.[0-9]{0,4})?$/", $dcto))) {
$mensajeerror=$mensajeerror. "Error, descuento incorrecto. "; $mal=1;
} ?>
$consulta6 = "select * from articulos where codfamilia='$familia' and codsubfamilia='$subfamilia' and codigo='$codigoarticulo'";
$resultado6 = mysql_query($consulta6, $conexion);
$lafila6=mysql_fetch_array($resultado6); ?>
$consulta7 = "select codpresupuesto, sum(importe) as total from presupuestolineatmp where codpresupuesto='$codpresupuesto' group by codpresupuesto";
$resultado7 = mysql_query($consulta7, $conexion);
$lafila7=mysql_fetch_array($resultado7);
$bi=sprintf("%01.2f",$lafila7["total"]);
$ac=$iva0/100;
$iva=$bi*$ac;
$iva=sprintf("%01.2f",$iva);
$tot=$lafila7["total"]+$iva;
$tot=sprintf("%01.2f",$tot);
?>