Pop-up windows after record upgraded

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Pop-up windows after record upgraded

Post by dgasparin » 2020-04-27 07:48

Hello,
I need your help about this "problem".
I need to make a pop-up window after a record is upgraded.
I need also, when the operator click on it, it has to be moved to that table.
Could you help me please?
Thank you very much indeed
Have a nice day
Davide

dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: Pop-up windows after record upgraded

Post by dgasparin » 2020-04-27 15:20

To better explain, I need, when the table ID changes ,to open a popup windows

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Pop-up windows after record upgraded

Post by pbottcher » 2020-04-27 20:57

Hi,

maybe you can explain a little bit more what you try. What tables do you have? What means upgrade of a record, or table ID changes?
What did you try so far?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: Pop-up windows after record upgraded

Post by dgasparin » 2020-04-28 13:56

Hi Pascal,
you are right I'm sorry. This is the schema. I'm receiving, from my external devices an alarm when the health parameters are outside the preconfigured thresholds. The alarm is a string that will are recorded inside our database.At this moment I configured the appgini application, when a new alarm is received, the system sends an email to preconfigured email addresses. When the alarm is managed another email are sent. I would like to add the possibility to open a popup windows to alert the opertor that an alarm is incoming. Pushing the button the operator is moved to the right table and record.
Do you think is possible? To do this I used the php table.php file inside the hook directory
Thank you so much
Davide

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Pop-up windows after record upgraded

Post by pbottcher » 2020-04-28 18:41

Hi Davide,

thanks, that makes it almost clear. If I assume correctly, you will create a record in the database upon receiving an external alert.
Once this record is created you send an email, once updated, another email is send.
As the system is not "interactive" (meaning that there is no real communcation happenind toward the client) I see a possible solution that you could look into like this.

Once you create your record in the database add an additional field (e.g. status which can have a value of new/done) and set the field to new.

In the hooks/header-extra.php add some code for the operator (assuming that he has a dedicated group or memberID),

- check that the current user is the operator
- if yes, query the database-table with the alert info for a record with the status = new
- if found add the javascript to create the popup with the link to the correct record.

like this, every time the operator navigates within the app, he will check for a new alert and get a popup.

In addition, if you want to do this periodically, add a timer to handle a recurring call to an AJAX post to check for new alerts.

Hope that gives you a start.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

dgasparin
Veteran Member
Posts: 31
Joined: 2020-03-26 13:03

Re: Pop-up windows after record upgraded

Post by dgasparin » 2020-04-29 15:50

Hi Pascal,
thank you for your kind answer.
At this moment, when an alaram is wrote inside the DB, the Appgini, using the hook file table.php sends an email, so the receiver knows that an alarm is arrived and the same when the record is changed. Inside the th eemail there is the link to arrive, directly, to the alarm received.
I would like to add another function to add a pop-up windows to all operators with te same link under the button and when one of them, the first, push the button inside the windows, take in charge the alarm.
This is the hook file now:
<?php
function ticket_init(&$options, $memberInfo, &$args) {
return TRUE;
}
function ticket_header($contentType, $memberInfo, &$args) {
$header='';
switch($contentType) {
case 'tableview':
$header='';
break;
case 'detailview':
$header='';
break;
case 'tableview+detailview':
$header='';
break;
case 'print-tableview':
$header='';
break;
case 'print-detailview':
$header='';
break;
case 'filters':
$header='';
break;
}
return $header;
}
function ticket_footer($contentType, $memberInfo, &$args) {
$footer='';
switch($contentType) {
case 'tableview':
$footer='';
break;
case 'detailview':
$footer='';
break;
case 'tableview+detailview':
$footer='';
break;
case 'print-tableview':
$footer='';
break;
case 'print-detailview':
$footer='';
break;
case 'filters':
$footer='';
break;
}

return $footer;
}

function ticket_before_insert(&$data, $memberInfo, &$args) {
return TRUE;
}
function ticket_after_insert($data, $memberInfo, &$args) {
// our modified code for sending the email notification
$userEmail=sqlValue("select email from membership_users where memberID='".getLoggedMemberID()."'");
// our modified code for sending the email notification
@mail("[email protected], ",
/* comma-separated list of recipients */


/* message subject */
"New ticket arrived",

/* message contents */
"A new record has been added by ".getLoggedMemberID().
".\n\n".
"To view it, please go to:\n".
"http://www.company.com/ticket_view.php? ... dID=$recID",

/* we must add sender email similar to this */
"[email protected]
);
return TRUE;
}

function ticket_before_update(&$data, $memberInfo, &$args) {

return TRUE;
}

function ticket_after_update($data, $memberInfo, &$args) {
// our modified code for sending the email notification
$userEmail=sqlValue("select email from membership_users where memberID='".getLoggedMemberID()."'");
// our modified code for sending the email notification
@mail("[email protected]",
/* comma-separated list of recipients */

/* message subject */
"Ticket modified",

/* message contents */
"A record has been changed by ".getLoggedMemberID().
".\n\n".
"To view it, please go to:\n".
"http://www.company.com/ticket_view.php? ... dID=$recID",

/* we must add sender email similar to this */
"[email protected]"
);
return TRUE;
}
function ticket_before_delete($selectedID, &$skipChecks, $memberInfo, &$args) {
return TRUE;
}
function ticket_after_delete($selectedID, $memberInfo, &$args) {
}
function ticket_dv($selectedID, $memberInfo, &$html, &$args) {
}
function ticket_csv($query, $memberInfo, &$args) {
return $query;
}
function ticket_batch_actions(&$args) {
return array();
}


What do you think, is it possible to do this?
Thank you so much
Davide

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Pop-up windows after record upgraded

Post by pbottcher » 2020-04-29 18:26

Hi Davide,

yes I think it is, you can try with what I wrote in my last post here.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply