/*
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
*/
?>
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) { ?>
if ($ini2==1) { ?>
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;
} ?>
print $mensajeerror; ?>
if ($mal==0) {
$cantidad = str_replace(",",".",$cantidad);
$precio = str_replace(",",".",$precio);
$dcto = str_replace(",",".",$dcto);
$dcto=sprintf("%01.2f",$dcto);
$dcto0=$dcto/100;
$importe=$precio*$cantidad;
$dcto0=$importe*$dcto0;
$importe=$importe-$dcto0;
$importe=sprintf("%01.2f",$importe);
$descrip=$lafila2["descripcion"];
$consulta1 = "INSERT INTO `partelineatmp` ( `codparte` , `codfamilia` , `codsubfamilia` , `codigo` , `cantidad` , `precio` , `importe` , `dcto` )
VALUES ('$maxcodparte', '$familia' , '$subfamilia' , '$codigoarticulo' , '$cantidad' , '$precio' , '$importe' , '$dcto' )";
$resultado1 = mysql_query($consulta1, $conexion);
} } }
$consulta5 = "select * from partelineatmp where codparte='$maxcodparte' order by numlinea";
$resultado5 = mysql_query($consulta5, $conexion);
?>
| Código |
Descripción |
Cantidad |
Precio |
Dcto |
Importe |
Eliminar |
while ($lafila5=mysql_fetch_array($resultado5)) { ?>
| echo $lafila5["codfamilia"];
echo $lafila5["codsubfamilia"];
echo $lafila5["codigo"];
$familia=$lafila5["codfamilia"];
$subfamilia=$lafila5["codsubfamilia"];
$codigoarticulo=$lafila5["codigo"]; ?> |
$consulta6 = "select * from articulos where codfamilia='$familia' and codsubfamilia='$subfamilia' and codigo='$codigoarticulo'";
$resultado6 = mysql_query($consulta6, $conexion);
$lafila6=mysql_fetch_array($resultado6); ?>
echo substr($lafila6["descripcion"],0,45); ?> |
$ca= number_format($lafila5["cantidad"],2,",","."); echo $ca; ?> |
$pr1= number_format($lafila5["precio"],2,",","."); echo $pr1; ?>
|
if ($lafila5["dcto"]=="0") { ?>
|
} else { ?>
$lafila5["dcto"]=sprintf("%01.2f", $lafila5["dcto"]);echo $lafila5["dcto"]; ?>% |
} ?>
$pr2= number_format($lafila5["importe"],2,",","."); echo $pr2; ?> |
} ?>
$consulta7 = "select codparte, sum(importe) as total from partelineatmp where codparte='$maxcodparte' group by codparte";
$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);
?>
|
Base imponible |
$bi= number_format($bi,2,",","."); echo $bi."€"; ?> |
|
IVA |
$iva= number_format($iva,2,",","."); echo $iva."€"; ?> |
|
Precio Total |
$total2= number_format($tot,2,",","."); ?>
echo $total2."€"; ?> |