Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Send the form (data record) by email - possible?

Questions related to using nuBuilder Forte.
Olikun
Posts: 68
Joined: Tue Mar 09, 2021 6:45 pm

Re: Send the form (data record) by email - possible?

Unread post by Olikun »

no, always the latest.
A new data set is added every day (except weekends)

Image
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: Send the form (data record) by email - possible?

Unread post by kev1n »

Set up a cron job / scheduled job and run nucall_ext.php which then executes a php procedure.

More information can be found in the code library

(nucall_ext.php is already included in v4.5.)
Olikun
Posts: 68
Joined: Tue Mar 09, 2021 6:45 pm

Re: Send the form (data record) by email - possible?

Unread post by Olikun »

I'll try it later with the CronJob

Another question.

I want to add a table to the email and add the fields there.

Image



I created a table and copied the Quallcode into your code, but I always get an error message when I send it

Code: Select all

$body =

<title></title>
<br />
<title></title>
<br />
<title></title>
<table border="0" cellpadding="2" cellspacing="2" style="width: 702px; text-align: left; margin-left: auto; margin-right: auto;">
  <tbody>
    <tr>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">1F3
      </td>
      <td style="text-align: center;">
      </td>
    </tr>
    <tr>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">
      </td>
    </tr>
    <tr>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">
      </td>
    </tr>
    <tr>
      <td style="text-align: center;">Sorte
      </td>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">Sorte
      </td>
    </tr>
    <tr>
      <td style="text-align: center;">1W11
      </td>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">1W21
      </td>
    </tr>
    <tr>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">
      </td>
    </tr>
    <tr>
      <td style="text-align: center;">Gewicht nach Trocknung
      </td>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">Gewicht nach Trocknung
      </td>
    </tr>
    <tr>
      <td style="text-align: center;">1W13
      </td>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">1W23
      </td>
    </tr>
    <tr>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">
      </td>
      <td style="text-align: center;">
      </td>
  </tbody>
</table>


$subject = "Email XYZ #lieferdatum#";

$from_name = "nuBuider";
$from_address = "info@xxx.de";
$to = "info@3xxx.de";
$cc = "";
$bcc = "";

 
nuSendEmail($to, $from_address, $from_name, $body, $subject, [], true, $cc, $bcc);
I have the table from my Shopware shop in the HTML eMails and it works there.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: Send the form (data record) by email - possible?

Unread post by kev1n »

Add single quotes after $body = and after </table>

Code: Select all

$body = '

your code here ....

</table>
';
Use https://phpcodechecker.com/ to perform a syntax check.
Olikun
Posts: 68
Joined: Tue Mar 09, 2021 6:45 pm

Re: Send the form (data record) by email - possible?

Unread post by Olikun »

ok, new information here

I designed my HTML email, it looks very good.

For testing purposes, I wrote your code on the form. It works, an email is always sent with the data record when it is saved.


I don't want the email to be sent when it is saved, but automatically every day at 6 p.m.

I removed the code from the form and created a procedure with it.

kev1n wrote:Set up a cron job / scheduled job and run nucall_ext.php which then executes a php procedure.

More information can be found in the code library

(nucall_ext.php is already included in v4.5.)

The link for the CronJob (... / core / nucall_ext.php? P = ... & acc = ...)
I created it and it works, an email is sent when I call up the link.

But only with the hash cookies # ..: #

The email looks like it should be, only without data. only with hash cookies


How does the procedure know which data set to take?
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: Send the form (data record) by email - possible?

Unread post by kev1n »

Hi,

Use nuRunQuery() and db_fetch_object() to retrieve the data with the latest date.
Then, instead of using Hash Cookies in your HTML code, which only work when a record is open, use variables/placeholders in your HTML code which are replaced with the values from the result set.

I can well imagine that this is not entirely clear. I will try to provide a bit more info tomorrow.
Olikun
Posts: 68
Joined: Tue Mar 09, 2021 6:45 pm

Re: Send the form (data record) by email - possible?

Unread post by Olikun »

kev1n wrote:Hi,

Use nuRunQuery() and db_fetch_object() to retrieve the data with the latest date.
Then, instead of using Hash Cookies in your HTML code, which only work when a record is open, use variables/placeholders in your HTML code which are replaced with the values from the result set.

I can well imagine that this is not entirely clear. I will try to provide a bit more info tomorrow.

thank you, but that sounds difficult XD


maybe, if you have the time, you can do an example in your https://test.nubuilder.cloud/

I think that would help
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: Send the form (data record) by email - possible?

Unread post by kev1n »

It's not that difficult, try something like this:

Code: Select all

// Select the row with the latest date

$s	= "
		SELECT column1, column1
		FROM your_table		
		ORDER by column_date desc LIMIT 1		
	   ";
	   
$t	= nuRunQuery($s);

$r = db_fetch_object($t)

$column1	= $r->column1;
$column2	= $r->column2;

$body = 'Hello, <br><br> $column1, $column2';

// Replace the variables since $body string is wrapped in single quotes:

$body = str_replace("$column1", $column1, $body);
$body = str_replace("$column2", $column2, $body);
	
nuSendEmail(...);
	
Olikun
Posts: 68
Joined: Tue Mar 09, 2021 6:45 pm

Re: Send the form (data record) by email - possible?

Unread post by Olikun »

ok thanks, but how do i edit it now?

I am not allowed to use the hash cookies?
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: Send the form (data record) by email - possible?

Unread post by kev1n »

Can we discuss this in a private message? I don't quite undestand what you mean.
Post Reply