Page 2 of 2

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

Posted: Sat Apr 24, 2021 11:25 am
by Olikun
no, always the latest.
A new data set is added every day (except weekends)

Image

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

Posted: Sat Apr 24, 2021 11:31 am
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.)

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

Posted: Sat Apr 24, 2021 11:54 am
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.

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

Posted: Sat Apr 24, 2021 12:10 pm
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.

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

Posted: Mon Apr 26, 2021 8:10 pm
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?

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

Posted: Mon Apr 26, 2021 8:31 pm
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.

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

Posted: Mon Apr 26, 2021 8:47 pm
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

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

Posted: Tue Apr 27, 2021 8:36 am
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(...);
	

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

Posted: Tue Apr 27, 2021 2:47 pm
by Olikun
ok thanks, but how do i edit it now?

I am not allowed to use the hash cookies?

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

Posted: Tue Apr 27, 2021 2:54 pm
by kev1n
Can we discuss this in a private message? I don't quite undestand what you mean.