• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Form plugin mail or php

Oh and i also tried to say $html = $header . $rijen . $footer; because in the calc element its ending with return $header . $rijen . $footer;

but that causes a page not found.. when i also do echo $html it shows the desired table printed on the page not found page.
 
Ok, overthinking what i just wrote I think its logical that I cannot get the table in the pdf. Because I try to put
Code:
$rijen .= "
  <tr class=\"" . $rij_class . "\">
    <td class=\"naam\">" . $mw->naam . "</td>
    <td class=\"maand\">{g4e_orakel_uitbet_maak___maand} $jaar</td>
    <td class=\"uren\">" . number_format($tot_uren,2,',','.') . "</td>
    <td class=\"dagen\">$dagen</td>
    <td class=\"salaris\">&euro; " . number_format($mw->salaris,2,',','.') . "</td>
    <td class=\"fee\">&euro; " . number_format($fee,2,',','.') . "</td>
    <td class=\"totaal\">&euro; " . number_format($totaal,2,',','.') . "</td>
     <td class=\"bedrijf_id\">" . $mw->bedrijf_id . "</td>
  </tr>";

In the $html.

But $rijen is not anything at this moment. The real table with content is created with

Code:
return $header . $rijen . $footer;

So what i need is a way to:

Code:
$html = 'return $header . $rijen . $footer;' ;

I tried:

$html = array($header, $rijen, $footer); Also no luck.

But I know this is not possible...

Any idea's how to solve this??
 
Last edited:
Ok I tried two different things with no luck.


Code:
$html = "<!DOCTYPE html><html><body>";
$html .= '<div class = "some class" >' . $header . '</div>';
$html .= '<div class = "some class" >' . $rijen . '</div>';
$html .= '<div class = "some class" >' . $footer . '</div>';
$html .= '</body></html>';

returns a page not found with "Notice: Array to string conversion in /home/customer/www/orakel.egocentralis.nl/public_html/plugins/fabrik_form/logs/logs.php on line 270"

And i tried:


Code:
$sollution = array{
$header,
$rijen,
$footer);

$html = "<!DOCTYPE html><html><body>";
$html .= '<div class = "some class" >' . $sollution . '</div>';
$html .= '</body></html>';

What did send an email.. with the word array in the pdf and nothing more

:(
 
$html = $header . $rijen . $footer; is what you want, then pass that through dompdf and the get the dompdf output as a stringAttachment to mailer.

Also, if you want to style anything then you need to include the css with the html.
 
That was what I was thinking..

By pass that through domppdf you mean:


Code:
$html = "<!DOCTYPE html><html><body>";
$html = $header . $rijen . $footer;
$html .= '</body></html>';

//echo $html; exit;
require_once(JPATH_LIBRARIES . '/dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$pdfString = $dompdf->output();

Because when I do that i get an error:
Code:
Notice: Array to string conversion in /home/customer/www/orakel.egocentralis.nl/public_html/plugins/fabrik_form/logs/logs.php on line 270

I have tried to find a sollution for this, and did read a lot about arrays and strings. I think this is caused because the $rijen part is between the { } of a for each statement.
Code:
foreach ($medewerkers as $mw) {

And the output of $rijen is using the $mw variable.


Code:
  $rijen .= "
  <tr class=\"" . $rij_class . "\">
    <td class=\"naam\">" . $mw->naam . "</td>
    <td class=\"maand\">{g4e_orakel_uitbet_maak___maand} $jaar</td>
    <td class=\"uren\">" . number_format($tot_uren,2,',','.') . "</td>
    <td class=\"dagen\">$dagen</td>
    <td class=\"salaris\">&euro; " . number_format($mw->salaris,2,',','.') . "</td>
    <td class=\"fee\">&euro; " . number_format($fee,2,',','.') . "</td>
    <td class=\"totaal\">&euro; " . number_format($totaal,2,',','.') . "</td>
     <td class=\"bedrijf_id\">" . $mw->bedrijf_id . "</td>
  </tr>";

But i am not sure... And its not clear to me what to do if that is the problem.

I really hope you or someone will have an "Eureka" moment.. This is one of the last big projects of the website.

Any idea?
 
Last edited:
You can disable the notice by setting the debug level to None in the global configuration.

When you echo the $html and exit, do you see any array() in the output?
 
Hello,

When I echo the $html i get this as output:

Screenshot_71.png

but when i dont echo it, i return on a 404 page.

Is this because in another php plugin its putting this data in the database after submit, and i try to create a pdf of the same data in another php plugin? Or the table is allready calculated in the calc element of the form?
 
Because i tried a lot of things in this way I was thinking of another way. The table is stored in the database "g4e_orakel_uitbet_maak___tabel"
So I tried to call the table content.

Code:
$pdfoutputdemand = "{g4e_orakel_uitbet_maak___tabel}";

Then i called $pdfoutputdemand into $html


Code:
$html = "<!DOCTYPE html><html><body>";
$html .= $pdfoutputdemand;
$html .= '</body></html>';

//echo $html; exit;*/
require_once(JPATH_LIBRARIES . '/dompdf/dompdf_config.inc.php');
//$html = file_get_contents('https://orakel.egocentralis.nl/uitbet-nw/');
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$pdfoutput = $dompdf->output();

and the output in:

Code:
$mailer->addStringAttachment($pdfoutput, "Uitbetalingsvoorstel.pdf");

Maybe its a stupid way of thinking but after submitting the list/form it redirected to te right page, the details are stored in the database and the email is send with an pdf attachment.

The only thing is, that the pdf is not formatted and shows only the printing code of the table. Pls see image:
Screenshot_74.png

I also tried
Code:
$html = '<!DOCTYPE html><html><body>' . $pdfoutputdemand . '</body></html>';
But also with the table printed in code and not as a table.

So, is it possible to get the output of "{g4e_orakel_uitbet_maak___tabel}"; preloaded in a $variable what i can put in $html = $variable and it shows as the desired table?

I did try this because creating the table what is created in a calc element on the form didnt look logical and right. Now, i am almost there, but i need to find a way to render the table before it is putted in the pdf.

Is this a stupid way of thinking, or can someone point me in the right direction??
 
Last edited:
It is very strange, i know i am a noob.. but i was thinking that an $variable should output the content of that variable when i put it in the $html part. So, in the case of above post, i expected
Code:
$html = '<!DOCTYPE html><html><body>' . $pdfoutputdemand . '</body></html>';
to virtually print the table code <table><td> etc with the content between the body tags. But, what it does is just printing the content into the pdf as a text.

So i tried to extract the variable with different print commando's like print_f and print_r with no luck.
Code:
$html = print_r($pdfoutputdemand, TRUE);
This resulted in an empty pdf.

I tried to use $formModel->getElementData to get the data from the calc element what is making the table.

Code:
$jaja = $formModel->getElementData('g4e_orakel_uitbet_maak___tabel_raw');

$html = '<!DOCTYPE html><html><body>' . $jaja . '</body></html>';

With the _raw part it crashes the site on a 404 page, and without the raw part it is sending the table as a text to the pdf file, just like in the pdf in an earlier reply. The pdf is showing the table styling and content.

Then I did read a topic about the $formModel->getElementData to get the data from the calc element. There they said that sometimes it returned an array. So I tried to solve it with:
Code:
$jaja = $formModel->getElementData('g4e_orakel_uitbet_maak___tabel_raw', true);
$jaja = is_array($jaja) ? $jaja[0] : $jaja;




$html = '<!DOCTYPE html><html><body>' . $jaja . '</body></html>';

This resulted in sending an empty pdf.

Finally i came into $data so i tried that.

Code:
$jaja = $data['g4e_orakel_uitbet_maak___tabel'];
$html = '<!DOCTYPE html><html><body>' . $jaja . '</body></html>';

But this is returning a 404 page.

So, How can i get the outcome of {g4e_orakel_uitbet_maak___tabel_raw} printed as html code between <html><body>' . $jaja . '</body></html>. So it looks like:

Code:
$html = '<!DOCTYPE html>
<html>
<body>
<table class="uitbet-tabel"> 
<thead> 
<tr> <th class="naam">Naam</th> 
<th class="maand">Maand</th> 
<th class="uren">Uren</th>
 <th class="dagen">Dagen</th> 
<th class="salaris">Uursalaris</th> 
<th class="fee">Fee</th> 
<th class="totaal">Uitbetalen</th> 
<th class="bedrijf_id">Bedrijf_id</th> 
</tr>
</thead> 
<tbody> 
<tr class=""> 
<td class="naam">joep, Meloen van</td> 
<td class="maand">December2020</td>
 <td class="uren">37,00</td> 
<td class="dagen">4</td>
 <td class="salaris">&euro; 25,00</td>
 <td class="fee">&euro; 0,00</td> 
<td class="totaal">&euro; 925,00</td> 
<td class="bedrijf_id">22061978</td>
</tr> 
<tr class=""> 
<td class="naam">Nuijs, Jap van</td> 
<td class="maand">December 2020</td>
 <td class="uren">37,00</td>
 <td class="dagen">0</td> 
<td class="salaris">&euro; 40,00</td>
 <td class="fee">&euro; 0,00</td> 
<td class="totaal">&euro; 1.480,00</td>
 <td class="bedrijf_id">22061978</td>
</tr> 
<tr class="">
 <td class="naam">Nuijs, Japs van</td> 
<td class="maand">December 2020</td>
 <td class="uren">37,00</td> 
<td class="dagen">18</td> 
<td class="salaris">&euro; 36,00</td>
 <td class="fee">&euro; 0,00</td> 
<td class="totaal">&euro; 1.332,00</td> 
<td class="bedrijf_id">22061978</td>
</tr> 
</tbody>
 <tfoot>
 <tr class="pdf-niet"> 
<td>3 medewerkers</td> 
<td></td> 
<td></td>
 <td></td>
<td></td> 
<td></td> 
<td>&euro; 3.737,00</td>
 <td></td>
 </tr> <tr class="pdf-wel"> 
<td>3 medewerkers</td>
<td></td> 
<td></td> 
<td></td> 
<td></td> 
<td></td> 
<td>&euro; 3.737,00</td>
 <td></td> 
</tr> 
</tfoot>
</table>
</body>
</html>';

And then, renders this to a pdf when using:
Code:
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$pdfoutput = $dompdf->output();

Sorry for the long post.. but i want to show i do a lot of work to achieve what i want, but i cannot find the sollution. I hope someone can help me and guide me in the right direction.

thanks
 
Ok, because i couldnt get this solved, i did a different approach.

In the list/form where the table was created I decided to make some hidden calc fields and in that fields I requested the data what I dynamicly need.

So, the email address of the company of which the employee was creating the table. The full name of the accountant, his/her email, the employee name, etc.

Then, I had some placeholders what i could use in the MAIL plugin. Now, when company A makes the table , the emails will be send to the accountant of company A and the employee is in the reply to field. And with company B, the accountant of company B will get an email.. etc etc.

I have learned a lot in this topic, and have used dompdf on other places and there it is working great.

Now I solved it in this way and, it is working like a charm!!! I was not aware that I could use placeholders, and simply add the needed data to the table with hidden fields in the list/form.

Woohoo

Screenshot_83.png
 
I have a version of it that I updated for Joomla 4. I am attaching to this post. (revised zip file at 07:30 eastern, a small changed had not been included in it).
 

Attachments

  • mijosql.zip
    67.6 KB · Views: 106
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top