Page 1 of 1

Send a SMS with text

Posted: 2023-01-06 15:34
by pasbonte
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...

Re: Send a SMS with text

Posted: 2023-01-06 22:10
by pbottcher
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);
}

Re: Send a SMS with text

Posted: 2023-01-07 09:39
by pasbonte
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);
}


Re: Send a SMS with text

Posted: 2023-01-07 10:28
by pbottcher
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.