<?php if (!isset($_REQUEST['proveedor']) || $_REQUEST['proveedor'] < 1 || !isset($_REQUEST['codigo']) || $_REQUEST['codigo'] < 1 || !isset($_REQUEST['monto']) || $_REQUEST['monto'] <= 0 || !isset($_REQUEST['fondo']) || $_REQUEST['fondo'] < 1) { $action_message = "Debe ingresar todos los datos de la operación!"; return; } include_once 'include/sesion.php'; $sesion = new Sesion(); $query = "UPDATE compras SET saldo = (saldo - " . $_REQUEST['monto'] . ") WHERE codigo = " . $_REQUEST['codigo']; if (!mysql_query($query)) { $action_message = mysql_error(); return; } $query = "UPDATE fondos SET saldo = (saldo - " . $_REQUEST['monto'] . ") WHERE codigo = " . $_REQUEST['fondo']; if (!mysql_query($query)) { $action_message = mysql_error(); return; } $query = "\n UPDATE\n proveedores\n SET\n saldo = (saldo - " . $_REQUEST['monto'] . ")\n WHERE\n codigo = " . $_REQUEST['proveedor']; if (!mysql_query($query)) { $action_message = mysql_error(); return; } $query = "INSERT INTO pagos (\n fecha, \n proveedor, \n usuario, \n operacion, \n fondo, \n monto\n ) VALUES (\n NOW(),\n " . $_REQUEST['proveedor'] . ",\n " . $sesion->get_user_id() . ",\n " . $_REQUEST['codigo'] . ",\n " . $_REQUEST['fondo'] . ",\n " . $_REQUEST['monto'] . "\n )"; if (!mysql_query($query)) { $action_message = mysql_error(); return; } $action_message = "Se ha registrado el pago!";
<?php if (!isset($_REQUEST['cliente']) || $_REQUEST['cliente'] < 1 || !isset($_REQUEST['codigo']) || $_REQUEST['codigo'] < 1 || !isset($_REQUEST['monto']) || $_REQUEST['monto'] <= 0 || !isset($_REQUEST['fondo']) || $_REQUEST['fondo'] < 1) { $action_message = "Debe ingresar todos los datos de la operación!"; return; } include_once 'include/sesion.php'; $sesion = new Sesion(); $query = "UPDATE ventas SET saldo = (saldo - " . $_REQUEST['monto'] . ") WHERE codigo = " . $_REQUEST['codigo']; if (!mysql_query($query)) { $action_message = mysql_error(); return; } $query = "UPDATE fondos SET saldo = (saldo + " . $_REQUEST['monto'] . ") WHERE codigo = " . $_REQUEST['fondo']; if (!mysql_query($query)) { $action_message = mysql_error(); return; } $query = "\n UPDATE\n clientes\n SET\n saldo = (saldo - " . $_REQUEST['monto'] . ")\n WHERE\n codigo = " . $_REQUEST['cliente']; if (!mysql_query($query)) { $action_message = mysql_error(); return; } $query = "INSERT INTO cobros (\n fecha, \n cliente, \n usuario, \n operacion, \n fondo, \n monto\n ) VALUES (\n NOW(),\n " . $_REQUEST['cliente'] . ",\n " . $sesion->get_user_id() . ",\n " . $_REQUEST['codigo'] . ",\n " . $_REQUEST['fondo'] . ",\n " . $_REQUEST['monto'] . "\n )"; if (!mysql_query($query)) { $action_message = mysql_error(); return; } $action_message = "Se ha registrado el pago!";