Send a SMS with text

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
pasbonte
Veteran Member
Posts: 162
Joined: 2013-02-06 09:49

Send a SMS with text

Post by pasbonte » 2023-01-06 15:34

Hello
I know how to make a global selection, and send sms to checked records, but I would like to put a free field in the body of the SMS, a text that can change, so a text that is not necessarily saved.
Ideally:
I tick my records
I click on SEND SMS
A POP UP window opens with the text to enter and presto we send..
I dream...

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

Re: Send a SMS with text

Post by pbottcher » 2023-01-06 22:10

Hi,

if you have your function ready to send the sms on a selected record, you can just add a popup with requesting the data you need to be entered. Once the users entered that data, pass it to the "SEND SMS" PHP in the url. Now you can use the data to fill the SMS.

something like:

Code: Select all

function send_sms (table_name, id){
 
    var url = 'send_sms.php?table=' + table_name;
    var input = windowPrompt(message);
    url = encodeURI(id) + '=' + encodeURIComponent(input);
   
    window.open(url);
}
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.

pasbonte
Veteran Member
Posts: 162
Joined: 2013-02-06 09:49

Re: Send a SMS with text

Post by pasbonte » 2023-01-07 09:39

hello

no work...

Code: Select all

function envoyer_sms(GES_SMS, ids){
	
    /* in GES_SMS-tv.js
      we'll open the mail labels page in a new window
      that page is a server-side PHP script named mail-labels.php
      but first, let's prepare the parameters to send to that script
    */
    var url = 'envoyer_sms.php?table=' + GES_SMS;
	var input = windowPrompt(message);
    url = encodeURI(id) + '=' + encodeURIComponent(input);
   
    window.open(url);
	
    for(var i = 0; i < ids.length; i++){
        url = url + '&'
            + encodeURI('ids[]') + '='
            + encodeURIComponent(ids[i]);
    }
     
    window.open(url);
}


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

Re: Send a SMS with text

Post by pbottcher » 2023-01-07 10:28

Hi,

there is an error in the script:

Code: Select all

function envoyer_sms(GES_SMS, ids){
   const message="Please enter data";
   var text=window.prompt(message);
   var url = envoyer_sms.php?table=' + GES_SMS + "&id="+encodeURI(ids)+"&text="+encodeURI(text);
    window.open(url);
}
This is just a sample. It will send one message for all selected id's. If you want to send per selected id a message, you need to amend the code an loop through the selected id's and create your url accordingly.
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