Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2008, 10:12
antmegev
 
Fecha de Ingreso: septiembre-2008
Mensajes: 58
Antigüedad: 15 años, 8 meses
Puntos: 0
actualizar y que los datos queden igual en unas cajas de texto

hola como estan?

bueno mi duda es como le hago en este codigo, lo que pasa es ke kiero mandar guardar los datos del form2, pero al darle al importe, saca el subtotal,iva,total y pues kiero ke keden igual cuando los mande para que asi cuando inserten otro, lo sume kon lo anterior.
este es el codigo, gracias.
<?php require_once('Connections/facturas.php'); ?>
<?php if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$a= aki es lo ke me falta(fac_subtotal);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO variables (fac_cantidad, fac_unidad, fac_desc, fac_p_unitario, fac_importe) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['fac_cantidad'], "text"),
GetSQLValueString($_POST['fac_unidad'], "text"),
GetSQLValueString($_POST['fac_desc'], "text"),
GetSQLValueString($_POST['fac_p_unitario'], "text"),
GetSQLValueString($_POST['fac_importe'], "text"));
mysql_select_db($database_facturas, $facturas);
$Result1 = mysql_query($insertSQL, $facturas) or die(mysql_error());
$insertGoTo = "pruebafactura.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_fact = "-1";
if (isset($_GET['id'])) {
$colname_fact = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_facturas, $facturas);
$query_fact = sprintf("SELECT * FROM cliente_fac WHERE id = %s", GetSQLValueString($colname_fact, "int"));
$fact = mysql_query($query_fact, $facturas) or die(mysql_error());
$row_fact = mysql_fetch_assoc($fact);
$totalRows_fact = mysql_num_rows($fact);
$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
$colname_Recordset1 = $_GET['id'];
}
mysql_select_db($database_facturas, $facturas);
$query_Recordset1 = sprintf("SELECT * FROM variables WHERE id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $facturas) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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>Creacion de factura</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:575px;
top:486px;
width:122px;
height:29px;
z-index:1;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body>
<script language = "JavaScript" type="text/javascript">
function ivatotal() {
var subtotal = event.srcElement.value
var iva = Math.round(subtotal*.15*100)/100
var total = Math.round(subtotal*1.15*100)/100
document.getElementById('fac_subtotal').value = subtotal
document.form3.fac_iva.value=iva
document.form3.fac_total.value=total
}
</script>
<table width="90%" height="128" border="0" bordercolor="#FFFFFF">
<tr>
<td colspan="3" scope="col"><form id="form1" name="form1" method="get" action="">
<label></label>
<table width="100%" border="0">
<tr>
<td width="9%" scope="col"><div align="left">No. cliente</div></td>
<td width="33%" scope="col"><?php echo $row_fact['no_clien']; ?></td>
<td width="17%" scope="col"><div align="left">Nombre:</div></td>
<td width="41%" scope="col"><?php echo $row_fact['nom_clien']; ?></td>
</tr>
<tr>
<td>Domicilio:</td>
<td><?php echo $row_fact['dom_clien']; ?></td>
<td>Ciudad:</td>
<td><?php echo $row_fact['ciud_clien']; ?></td>
</tr>
<tr>
<td>Telefono:</td>
<td><label><?php echo $row_fact['tel_clien']; ?></label></td>
<td><label>R.F.C:</label></td>
<td><?php echo $row_fact['rfc_clien']; ?></td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td colspan="3">
<form action="<?php echo $editFormAction; ?>thisformrefresh" method="post" name="form2" id="form2">

<table width="738" border="1" bordercolor="#7F9DB9">
<tr>
<th width="60" height="10" scope="col">cantidad</th>
<th width="51" scope="col">unidad</th>
<th width="300" scope="col">descripcion</th>
<th width="144" scope="col">p unitario</th>
<th width="149" scope="col">importe</th>
</tr>
<tr>
<th height="11" scope="col"><label>
<input name="fac_cantidad" type="text" id="fac_cantidad" size="5" />
</label></th>
<th scope="col"><label>
<input name="fac_unidad" type="text" id="fac_unidad" size="5" />
</label></th>
<th width="300" scope="col"><label>
<input name="fac_desc" type="text" id="fac_desc" size="50" />
</label></th>
<th width="144" scope="col"><label>
<input type="text" name="fac_p_unitario" id="fac_p_unitario" />
</label></th>
<th width="149" scope="col"><label>
<input type="text" name="fac_importe" id="fac_importe" onkeyup="javascript:ivatotal()" />
</label></th>
</tr>
</table>
<input type="submit" name="button" id="button" value="Enviar" />
<label></label>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<form action="" method="post" name="form3" id="form3">
<table width="100%" border="0"><tr><th colspan="3" scope="col"><table width="849" border="0"><tr><th width="843" height="154" scope="col"><div align="right">
<table width="100%" border="0">
<tr>
<th colspan="4" scope="col"><label></label>
<label></label>
<label></label>
<table width="793" border="0">
<tr>
<th width="26" rowspan="3" scope="col">&nbsp;</th>
<th width="429" scope="col">importe con letra:
<label></label><div align="left"></div></th>
<th width="324" scope="col"><div align="right">
<label></label>
subtotal:
<input type="text" name="fac_subtotal" id="fac_subtotal" value="<?php echo $a; ?>"/>
</div></th>
</tr>
<tr>
<th width="429" scope="col"><input name="fac_impcletra" type="text" id="fac_impcletra" size="60" /></th>
<th scope="col"><label> </label>
<div align="right">iva:
<input type="text" name="fac_iva" id="fac_iva" readonly="true" />
</div>
<div align="right"></div></th>
</tr>
<tr>
<th width="429" rowspan="2" scope="col">&nbsp;</th>
<th rowspan="2" scope="col"><label> </label>
<div align="right">total:
<input type="text" name="fac_total" id="fac_total" readonly="true" />
</div>
<div align="right"></div></th>
</tr>
<tr>
<th width="26" scope="col">&nbsp;</th>
</tr>
</table>
<label></label></th>
</tr>
<tr>
<td width="546" height="32"><label> </label></td>
<td width="69"><div align="right">Dia:
<input name="fac_dia" type="text" id="fac_dia" size="5" />
</div></td>
<td width="104"><label></label>
<div align="right">Mes:
<input name="fac_mes" type="text" id="fac_mes" size="10" />
</div></td>
<td width="106" colspan="2"><div align="right">Año:
<input name="fac_fecha" type="text" id="fac_fecha" size="10" />
</div></td>
</tr>
</table>
<input name="enviar" type="submit" value="Enviar" />
</div>
</th>
</tr>
</table>
</th>
</tr>
</table>
<label> </label>
<p align="right">
<label></label>
<label></label>
</p>
</form></td>
</tr>
<tr>
<td width="36%"><a href="busqueda_cliente.php"><img src="objetos/flecha_re.gif" width="22" height="22" border="0" /></a></td>
<td width="21%" bordercolor="#000000"><a href="index.php">MENU PRINCIPAL</a></td>
<td width="43%">&nbsp;</td>
</tr>
</table>
<p>&nbsp; </p>
<p>&nbsp;</p>

<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($fact);

mysql_free_result($Recordset1);
?>