This topic is locked

on('afterSave' event

6/19/2022 3:15:49 PM
PHPRunner General questions
G
Grdimitris author

I found in ths forum that exist on afterSave event https://www.google.com/search?client=firefox-b-d&q=js+add+on+afterSave+ivent but how to make it work.
i added it in javascript on load event but it cant triggered.
I have an invoice table and I want after I add a record and after the AfterADD event witch update counters and other tables to ask if you want to cut a receipt which is optional and not required

admin 6/21/2022

In PHPRunner you can use AfterAdd or AfterEdit event to execute your code after the record was added or edited.

G
Grdimitris author 6/22/2022

Yes i know that.
But i want after save and execute the After save event to open a dialog i user wants to proceed to an optional page to fill in another page in another table.

K
kohle 6/22/2022

Hi,

Afteradd is server side, so its php programming and Dialogs are local javascript.

What I would do, but maybe others have a better idea :

In the after add event you redirect to a new page with some get parameters :
header("Location: anypage.php?id1=par1....");

On the anypage.php start something like this:
(After the include, you can use all session variables of the phprunner project on this page)

<?php
include("../include/dbcommon.php");
if($_SESSION['user_group']!="admin" && $_SESSION['user_group']!="admin2")die(-1); //or use the phprunner security api
?>

Do your Javascript , htmls forms and php (database updates)
and after submit reload the phprunner page.
Use for this the get parameters or a session variable to save the link of the phprunner page

rgs
J.

admin 6/22/2022

As @kohle suggests, use redirect in AfterAdd event to the additional page.

G
Grdimitris author 6/23/2022

Thank you kohle and admin
Excellent idea.

  1. I put a dummy field in add page of first table.
  2. In before save event in javascript on oad i ask if user wants to proceed to an optional page.
    as https://xlinesoft.com/phprunner/docs/how_to_ask_for_confirmation_before_saving_record.htm
    3)In before add assign to a $_SESSION variable the dummy field and then unset.
  3. At the end of after add event depending from $_SESSION variable i have
    Header ("location: my_redirect_page.php?afm='".$values['afm']."'&xreosid=".$values['xreos_id']);
    But no redirection.
    The my_redirect_page.php is in the root folder as the current add page.