How to call a javascript function on on_after_insert event, something like this:
$e[“on_after_insert”] = array(“after_insert”, null, false);
$g->set_events($e);
function after_insert($data){
global $g;
$consulta = ” SELECT *
FROM inventario_produccion.prueba_articulos_areas
WHERE codigo_articulo = {$data[“params”][“codigo_articulo”]}
and id_area ={$data[“params”][“id_area”]}”;
$ejecutar = mysql_query($consulta);
$row = mysql_fetch_array($ejecutar);
$existencia = $row[“existencia”];
$cantidad = $data[“params”][“cantidad”];
$resta = $existencia – $cantidad;
$g->execute_query(“UPDATE inventario_produccion.prueba_articulos_areas SET existencia = “.$resta. “
//WHERE codigo_articulo = {$data[“params”][“codigo_articulo”]} and id_area = {$data[“params”][“id_area”]}”);
$codigo_articuloD = $data[“params”][“codigo_articulo”];
$areaD = $data[“params”][“id_area”];
echo(‘<script type=”text/javascript”>correo_salidas(‘.$areaD.’, ‘.$codigo_articuloD.’, ‘.$resta.’);</script>’);
}
You can replace last echo line with:
phpgrid_msg(“Record Saved<script>alert(123);</script>”,1);
sorry, but where I supposed to see the message? because I cant see it
Emailed you working demo.
I sent you my work, thanks
Demo code here: https://gist.github.com/gridphp/6542345291dfb4db4fef8f8d483dd37d
P.S the javascript function make a ajax call