Add a second sql order each time you insert

QuestionsAdd a second sql order each time you insert
Sergio Pulido asked 10 years ago

add a second sql order each time you insert and edit records, I've tried the sample code, but only the order, adding runs.

$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);

function add_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["IdDiario"] = $id;

$FechaDelMovimiento = date(Y-m-d);

$sql = "INSERT INTO `trazabilidad`
(`IdTraza`, `IdEntrada`, `Idproducto`, `FCaducidad`, `Referencia`, `Cantidad`, `UnidadCaja`, `Total`, `Lote`, `Tipo`, `UBI`, `igic`, `FMOVI`, `Almacen`)
VALUES
(NULL, '{$data["params"]["IdDetalleEntrada"]}', '{$data["params"]["IdProducto"]}', '{$data["params"]["FechaCaducidad"]}', '{$data["params"]["RefProv"]}', '{$data["params"]["Cantidad"]}', '{$data["params"]["UnidadCaja"]}',
'{$data["params"]["Total"]}', '{$data["params"]["Lote"]}', 'E', '{$data["params"]["UBICACION"]}', '{$data["params"]["IGIC"]}', '".$FechaDelMovimiento."', '1')";
mysql_query($sql);

1 Answers
Abu Ghufran answered 10 years ago

// params are array(<function-name>,<class-object> or <null-if-global-func>,<continue-default-operation>)
// if you pass last argument as true, functions will act as a data filter, and insert/update will be performed by grid

$e["on_insert"] = array("add_client", null, true);

It looks like it is running default insert as well as yours, so making 3rd arg to false should run only your insert.

Your Answer

0 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?