Form plugin mail or php

I have to rewrite some functionallity on the website but to achieve this i want to understand some things better. I have 2 places on the website where mails are being sended in different ways.

1)

One is in a list what creates a groupmail functionallity and this is using a plugin in the form called php. In this php code there is the code to send an email.. add recipients, send to address, subject, body, etc. The emails are sended at"End of form submission (onAfterProcess).

2)
The other one, is on a list where some financial details are combined in a table, and where the user can choose to send this details to the accountant. For this, there is a button to select yes or no and if selected yes, the email will be send to the accountant after saving the form. The plugin what is used in the form is the email plugin. It's triggered via a condition in the condition field like:
Code:
return ("{g4e_orakel_uitbet_maak___mail_raw}" == "1");
This plugin will send the email to the same accountant everytime because its an email address in the to field. I want to have this different.
__________________________

What I need is in situation 2 to write a query where there will be an email address selected belonging to the company of the employee who is making the financial table. So this email address will be dynamic since we have different companies and because of that different accountants.

Now i have different questions about this email plugin:

  1. in the to field there are two fields. Email to and email to (eval). Can i leave the email to field empty if I use the Email to (eval) field? So i can write the query for the dynamic choosen email adresses.
  2. In the options tab, I can give a from email address, and a reply to address and a subject. For this I need also a query since this information depends on what user/employee is sending the email to the accountant. I need to have the email address of the company of the employee who is submitting the form. For me, it looks like that fields are only for standard email addresses and not for queries like what is possible in the email to (eval) field. Is this correct? Or can i make a query somewhere what will take care of this information?
And also some questions about the php plugin:

  1. In the php plugin what is sending the groupmails I have more or less the query i need to send the email to the different company accountants. I only have to change the content. But, can i replace the email plugin with the php plugin? For that I need the "start script" setting will use the condition
    Code:
    return ("{g4e_orakel_uitbet_maak___mail_raw}" == "1");
    and not "End of form submission (onAfterProcess) i think. Can this be done?
  2. In the php plugin, i have a query/code to add recipient, from name, etc. I have asked things about this in another topic. Is it possible to use this query / code in the email plugin?
So in short, how can I get the functionallity i use in the php plugin.. into the email plugin.. or , let the email plugin behave in the way i want.

Can someone point me in the good direction??
 
It would probably be easier to change the email plugin to a php plugin and create your email content there. If the text content changes based on some condition you have 2 choices. First, simply test the condition and str_replace in the email body, or, create one or more articles as email templates. You can do string substitutions by inserting placeholders in the articles (or text string of the email). Create the placeholders using some unique identifiers, such as wrapping them with [[placeholder]] to search on. I do this all the time and it works well.
 
It would probably be easier to change the email plugin to a php plugin and create your email content there.

Oke, i am thinking of doing that but what i dont understand is the trigger condition. In the email plugin, there is a condition field, where
Code:
return ("{g4e_orakel_uitbet_maak___mail_raw}" == "1");
is used. This is a radiobutton and if selected yes, the email will be send.

But the php form uses a different way to work.. with the execute script settings in a dropdown.

How can i get the php plugin get executed only if the radio button has a value of 1 like
Code:
return ("{g4e_orakel_uitbet_maak___mail_raw}" == "1");
Because when i know that, the php body is allready populated with the right queries and codes.
 
You just need to wrap your code into a condition:
Code:
if ('{g4e_orakel_uitbet_maak___mail_raw}' == '1') {

    // do whatever the plugin is supposed to do
   
}
 
That simple???
And i dont need to tell an else command?
Well, basic PHP...
If you want a script to run only if ... is true, then wrap it into the condition.
If nothing else, no "else".
If something else, than "else { ... }" or "elseif (...) { ... }".

If it's the same trigger as your existing PHP form plugin, just append the new code.
If it's a different trigger, just use a new, additional PHP form plugin.
How to get form field values depending on trigger: http://fabrikar.com/forums/index.php?wiki/php-form-plugin/

that will overwrite the php plugin setting?
Not sure what you mean...
 
Not sure what you mean...
never mind, that question got an answer automaticly.

So, now i have a small thing and I do not know how to solve it. I have the php plugin sending the email to the desired address so thats very good. But, in the email plugin there is in the attachment settings a setting "attach as pdf = yes. attachment.png

In the form settings / layout i see settings about the pdf attachment pdf.png

So when the mail is sended via the mail plugin there is an attachment added as pdf. The pdf contains the data from the generated table.

In the mail plugin settings there is a line of text used :
Code:
Uitbetalingsvoorstel {g4e_orakel_uitbet_maak___maand} {g4e_orakel_uitbet_maak___jaar}
and that turns out to be the name of the pdf.

Now, i have one problem because the pdf is not stored in the database, just added as attachment.

How can i reach this in the php plugin that the attachment is also added like in the mail plugin??

So that I can put the right value into
Code:
    $mailer->addAttachment($??????);

I hope you can point me out in the good direction...

Oh, and you call it basic php... i feel like i am in elementary school :) its all new to me.. but learning fast and a lot.
 
In phpmyadmin i see in the parameters section of the form this:

Code:
"email_conditon":{"4":"return (\"{g4e_orakel_uitbet_maak___mail_raw}\" == \"1\");"},"email_update_field":{"4":""},"email_headers_eval":{"4":""},"email_attach_type":{"4":""},"email_attach_eval":{"4":""},"attach_pdf":{"4":"1"},"plugins":["logs","php","php","redirect","email"

Thats the only thing i can find in the database of the pdf. So i am realy stuck about this.
 
2 things, first, rather than wrap your code in the if statement check the reveres and then simply return. Something like this:
Code:
if ('{g4e_orakel_uitbet_maak___mail_raw}' != '1') return;

Makes the code cleaner that way.

I suspect (I don't know for sure) that the mail plugin must render the message or data as a pdf for attachment. You will need to do this in your php script yourself. You could try and pull the code from the email plugin, or call dompdf yourself. There are lots of tutorials on how to use dompdf.

Another option would be to install the free Koolreport library which can render your data into a pdf which you can then attach to the email with the addAttachment mailer call. But this may be a steeper learning curve (but worth it if you ever need reporting for other tasks).
 
or call dompdf
uhm.. is the email plugin also using dompdf?? or is this a totally different something...

Since in form/layout there are settings how to render the pdf.. and in the mailplugin to attach it...
I hope its the same technique otherwise it feels like i have to build something new around something what is working allready in an other plugin.
 
ok dompdf is allready in my library.. so now i have to find a way to get it as an attachment into the phpplugin so the mail function will work as it was with the mail plugin but then with other email addressess..
 
I cannot find an example how to get the dompdf to create a pdf and insert it in the email as an attachment. Its stupid i think, but i cannot find a single thing what will help me with this matter.

Can someone point me in the right direction or tell me how i can get the generated content after a form submission into a pdf what i can attach to an email?
 
What i understand it has to do with this settings of the printscreen. But i cannot find how to call for the pdf what is created after submitting/save the form/list. layout.png
 
Here is an example of how I did it once. Modify for your own needs. This example outputs to the browser but you can output to a text string and then attach using the mailer->addStringAttachment($dompdf->output()); You may need some additional parameters here. Make sure you delete the exit at the end and just return.
 

Attachments

  • dompdf.example.txt
    8.8 KB · Views: 88
Ok, I am puzzling for hours now but i cant get it to work. The problem is I think the way the table is builded. with the email plugin, it just grabs the table as a pdf and that is very okay. But in the php plugin I cannot get this to work. I tried to do everything with the example you sended me but with no luck.

The table is rendered this way: (at the end i will post the full code)

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>";
 
}

  $header = "
  <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>";
 
  $footer = "
  </tbody>
  <tfoot>
    <tr class=\"pdf-wel\">
      <td>" . $pdf_aantal . " medewerkers</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td>&euro; " . number_format($pdf_bedrag, 2, ',', '.') . "</td>
       <td></td>
     
    </tr>
  </tfoot>
</table>";



return $header . $rijen . $footer;

So i tried to use the dompdf with :

Code:
$htmlopen = "<!DOCTYPE html><html><body>";
$html = "";

$html .='Header table code without $header'
$html .= 'rijen table code with extra ''around the data what is pulled'
$html . ='Footer table code without $footer'

I also tried $html = $htmlopen . $header . $rijen . $footer . $htmlclose;

I tried $html = "'return $header . $rijen . $footer'";

I tried a lot.. but its not working.

The email part, is working....... with the script i wrote for it. ..

Code:
$db = FabrikWorker::getDbo();
$q = $db->getQuery(true);
$q
  ->select("CONCAT(voornaam_contactpersoon, ', ', tussenvoegsel_contactpersoon, ' ', achternaam_contactpersoon) AS naam, email_adres_bedrijf, straat, huisnummer, postcode, vestiging_plaats, bedrijfsnaam")
  ->from("egocentralis_bedrijven")
  ->where("bedrijf_id IN (SELECT bedrijf_id FROM g4e_orakel_personeel WHERE userid = {$my->id}) OR bedrijf_id IN (SELECT bedrijf_id FROM egocentralis_bedrijven WHERE userid = {$my->id})");
$db->setQuery($q);
$mails = $db->loadObjectList();

$bn = $db->getQuery(true);
$bn
->select('bedrijfsnaam')
  ->from('egocentralis_bedrijven')
  ->where('bedrijf_id IN (SELECT bedrijf_id FROM g4e_orakel_personeel WHERE userid = {$my->id}) OR bedrijf_id IN (SELECT bedrijf_id FROM egocentralis_bedrijven WHERE userid = {$my->id})');
$db->setQuery($bn);
$bedrijfsnaam = $db->loadResult();


// Splits de adressen in groepen van 20, zodat de mail niet ineens naar honderden mensen gaat



// Maak een mail dat het profiel bijna verloopt
$mail_ber = "
  <html>
  <body>
  <br /><br /> Hierbij het Uitbetalingsvoorstel {g4e_orakel_uitbet_maak___maand} {g4e_orakel_uitbet_maak___jaar}  van de maand
 
    <i><span style=\"font-family: 'Verdana',sans-serif; color: #0070c0;font-size:14.0px;\">Vriendelijke groeten,</span></i><br /><br />
 
    <span style=\"font-size: 12.0pt; color: #0070c0;\"><br />
    </span>
    <table style=\"border:0;font-size:12.0pt;color:#0070C0;padding:0;margin:0;\">
    <tr><td style=\"padding-left:0px;\"><b><span style=\"font-family: 'Blackadder ITC';font-size: 14.0pt;\"></span></b></td><td></td></tr>
    <tr><td style=\"padding-left:0px;\"><b><span style=\"font-family: 'Blackadder ITC';font-size: 14.0pt;\"></span></b></td><td></td></tr>
    <tr><td style=\"padding-left:0px;\"><b><span style=\"font-family: 'Blackadder ITC';font-size: 14.0pt;\"></span></b></td><td>&nbsp;&nbsp;06 43545075</td></tr>
    </table>
    <span style=\"font-size: 13.5pt; font-family: 'Blackadder ITC'; color: red;\"></span>
    <br />
    <br />
  
  </body>
  </html>";

$mail_ond = "Uitbetalingsvoorstel {g4e_orakel_uitbet_maak___maand} {g4e_orakel_uitbet_maak___jaar}";

  // Maak een mailobject
  $mailer = JFactory::getMailer();
 
  foreach($mails as $mail) {
  $mail_van = array(
  $mail->email_adres_bedrijf,
  $mail->bedrijfsnaam
);


  // Voeg afzender, ontvanger, reply-to toe in het object
    $mailer->addRecipient($mail->email_adres_bedrijf);
    $mailer->setSender($mail_van);
    $mailer->addReplyTo($mail->email_adres_bedrijf, $bedrijfsnaam);
   // $mailer->addRecipient("jaspervannuijs@gmail.com");
   // $mailer->setSender($mail_van);
   // $mailer->addReplyTo('jaspervannuijs@gmail.com', "Jasper");

    // Als er een bestand is toegevoegd, voeg dit toe als bijlage
    $mailer->addStringAttachment($pdfString, 'Uitbetalingsvoorstel {g4e_orakel_uitbet_maak___maand} {g4e_orakel_uitbet_maak___jaar}.pdf');

    // Mail is html, base64 voor goede weergave ondertekening
    $mailer->isHTML(true);
    $mailer->Encoding = 'base64';
       
    // Onderwerp en bericht   
    $mailer->setSubject($mail_ond);
    $mailer->setBody($mail_ber);
   
    // Voeg de groep toe als bcc
//    $mailer->addBcc($groep);

    // Verstuur de mail
    $resultaat = $mailer->Send();

  }
}
}

Can someone please give me an advice how to get the table into a pdf via dompdf?? It would really help me further.. I know I ask a lot but I try to make the website working for a non profit company for people with mental problems. Can someone please tell me.. how to get the outcome of :
Code:
return $header . $rijen . $footer;
into the dompdf.

I will put the full code in my next comment.


it is really appreciated! sorry for any bad english
 
Code:
// Laad ingevulde info uit formulier
$maand = "{g4e_orakel_uitbet_maak___maand_raw}";
$jaar = "{g4e_orakel_uitbet_maak___jaar_raw}";
$t_eerste = strtotime("1-" . $maand . "-" . $jaar);
$t_laatste = strtotime("-1 day", strtotime("+1 month", $t_eerste));
$laatste = date("Y-m-d", $t_laatste);
$eerste = date("Y-m-d", $t_eerste);
$totaal_bedrag = 0;
$totaal_aantal = 0;

$pdf_bedrag = 0;
$pdf_aantal = 0;

// Maak verbinding met de database
$db = FabrikWorker::getDbo();

// Vraag alle medewerkers op (met salaris) die actief zijn/waran in maand
$q_mw = $db->getQuery(true);
$q_mw
  ->select("p.persid, CONCAT(p.achternaam, ', ', p.roepnaam, ' ', p.tussenvoegsel) AS naam, p.bedrijf_id, s.salaris, u.uren")
  ->from("g4e_orakel_personeel p LEFT JOIN g4e_orakel_personeel_salaris s ON (p.persid = s.persid AND DATE(s.van) <= " . $db->quote($laatste) . " AND (DATE(s.tot) > " . $db->quote($eerste) . " OR DATE(s.tot) = " . $db->quote("0000-00-00") . ")) LEFT JOIN g4e_orakel_personeel_uren u ON (p.persid = u.persid AND DATE(u.van) <= " . $db->quote($laatste) . " AND (DATE(u.tot) > " . $db->quote($eerste) . " OR DATE(u.tot) = " . $db->quote("0000-00-00") . "))")
  ->where("p.bedrijf_id IN (SELECT bedrijf_id FROM egocentralis_bedrijven WHERE userid = '{$my->id}') AND DATE(p.in_dienst_sinds) <= " . $db->quote($laatste) . " AND (DATE(p.in_dienst_tot) >= " . $db->quote($eerste) . " OR DATE(p.in_dienst_tot) = " . $db->quote('0000-00-00') . ") AND s.salaris > " . $db->quote(0) . " OR p.bedrijf_id IN (SELECT bedrijf_id FROM g4e_orakel_personeel WHERE userid = '{$my->id}') AND  DATE(p.in_dienst_sinds) <= " . $db->quote($laatste) . " AND (DATE(p.in_dienst_tot) >= " . $db->quote($eerste) . " OR DATE(p.in_dienst_tot) = " . $db->quote('0000-00-00') . ") AND s.salaris > " . $db->quote(0))
  ->order("p.achternaam");
$db->setQuery($q_mw);
$medewerkers = $db->loadObjectList();

$rijen = "";

// Voor elke medewerker
foreach ($medewerkers as $mw) {
  // Als medewerker 0-uren contract heeft
  if ($mw->uren == '0') {
    // Selecteer alle uren van de medewerker in de maand die zijn goedgekeurd
    $q_uren = $db->getQuery(true);
    $q_uren
      ->select("SUM(uren) AS somuren")
      ->from("g4e_orakel_urenreg")
      ->where("persid = " . $db->quote($mw->persid) . " AND MONTH(datum) = " .  $db->quote($maand) . " AND YEAR(datum) = " .  $db->quote($jaar) . " AND gekeurd = " .  $db->quote('1') . " AND code <> " . $db->quote('138'));
    $db->setQuery($q_uren);
    $uren = $db->loadResult();
   
    // Selecteer alle overhead van de medewerker in de maand bij uren die zijn goedgekeurd en waar geen maatregel is
    $q_oh = $db->getQuery(true);
    $q_oh
      ->select("SUM(overhead) AS somoh")
      ->from("g4e_orakel_urenreg")
      ->where("persid = " . $db->quote($mw->persid) . " AND MONTH(datum) = " .  $db->quote($maand) . " AND YEAR(datum) = " .  $db->quote($jaar) . " AND gekeurd = " .  $db->quote('1') . " AND geen_oh = " . $db->quote('0') . " AND code <> " . $db->quote('138'));
    $db->setQuery($q_oh);
    $oh = $db->loadResult();
   
    // Selecteer alle uren met code 138 (ziek 70%, die uren tellen maar 70% mee)
    $q_ziek = $db->getQuery(true);
    $q_ziek
      ->select("SUM(uren) AS somuren")
      ->from("g4e_orakel_urenreg")
      ->where("persid = " . $db->quote($mw->persid) . " AND MONTH(datum) = " .  $db->quote($maand) . " AND YEAR(datum) = " .  $db->quote($jaar) . " AND gekeurd = " .  $db->quote('1') . " AND code = " . $db->quote('138'));
    $db->setQuery($q_ziek);
    $ziek = $db->loadResult();
   
    // Tel uren en oh op
    $tot_uren = $uren + $oh + ($ziek * 0.7);
  } else {
    // Anders, uren = contracturen
    $tot_uren = $mw->uren;
  }

  // Tel het aantal dagen waarop een medewerker heeft gewerkt (uren geschreven) in de maand
  $q_dagen = $db->getQuery(true);
  $q_dagen
    ->select("COUNT(DISTINCT(DATE(datum)))")
    ->from("g4e_orakel_urenreg")
    ->where("persid = " . $db->quote($mw->persid) . " AND MONTH(datum) = " .  $db->quote($maand) . " AND YEAR(datum) = " .  $db->quote($jaar) . " AND gekeurd = " .  $db->quote('1'));
  $db->setQuery($q_dagen);
  $dagen = $db->loadResult();

  // Voor de leden van het management, bereken de fee
  if ($mw->persid == 'costh00' || $mw->persid == 'bogem00') {
    // Selecteer totaal uren in maand maal fee van medewerker op dag uren, met code met fee en goedgekeurd
    $q_fee = $db->getQuery(true);
    $q_fee
      ->select("SUM((u.uren * p.fee))")
      ->from("g4e_orakel_urenreg u LEFT JOIN g4e_orakel_personeel_fee p ON (u.persid = p.persid AND p.van <= u.datum AND (p.tot >= u.datum OR DATE(p.tot) = '0000-00-00'))")
      ->where("MONTH(u.datum) = " . $db->quote($maand) . " AND YEAR(u.datum) = " . $db->quote($jaar) . " AND u.code IN (SELECT c.id FROM g4e_orakel_urencode c WHERE c.fee = " . $db->quote('1') . ") AND u.gekeurd = " . $db->quote('1'));
    $db->setQuery($q_fee);
    $fee = $db->loadResult();
   
    $fee = $fee * 0.3;
    $rij_class = "pdf-niet";
  } else {
    $fee = 0;
    $rij_class = "";
  }

  $tot_uren = round($tot_uren, 2);
  // Uitendelijk totaal te betalen. Uren maal salaris, plus eventuele fee
  $totaal = ($tot_uren * $mw->salaris) + $fee;



  $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>";

}

  $header = "
  <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>";

  $footer = "
  </tbody>
  <tfoot>
    <tr class=\"pdf-wel\">
      <td>" . $pdf_aantal . " medewerkers</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td>&euro; " . number_format($pdf_bedrag, 2, ',', '.') . "</td>
       <td></td>
     
    </tr>
  </tfoot>
</table>";



return $header . $rijen . $footer;
 
Hi,

I think the problem is, the table is created in a calc element and is showing on the frontend of the website. There I can click the button if the data has to be mailed or not and save the result. The sending of the mail with the attached pdf is handled by the 'mailplugin' and the saving of the data into the database is handled with a 'php plugin'

Now, that i cannot mail via the mailplugin, i need to use a php plugin. There I use the same code to create the table what is used in the calc element of the form.

Is it correct that i ask the same data twice and that this is not a good approach?
Can I retrieve / call the data from the calc element into the php plugin?

I am sorry I did not explain in the right way what i tried. When I copy the calc element content into the php plugin i tried to create the dompdf object for example in this way:


Code:
$html = '<!DOCTYPE html><html><body>';
$html .='
  <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>';

$html .= '  </tbody>
  <tfoot>
      <tr class=\"pdf-wel\">
      <td>' . $pdf_aantal . ' medewerkers</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td>&euro; ' . number_format($pdf_bedrag, 2, ',', '.') . '</td>
       <td></td>
     
    </tr>
  </tfoot>
</table>';
$html .= '</body></html>';

And then:

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

This is without the '$rijen' part because i thought that part was causing the problem. Because its between a { } section what also contains a very long query. Sorry but to show i have to put in a long code: The table content part is at the end of the code.

Code:
$rijen = "";

// Voor elke medewerker
foreach ($medewerkers as $mw) {
  // Als medewerker 0-uren contract heeft
  if ($mw->uren == '0') {
    // Selecteer alle uren van de medewerker in de maand die zijn goedgekeurd
    $q_uren = $db->getQuery(true);
    $q_uren
      ->select("SUM(uren) AS somuren")
      ->from("g4e_orakel_urenreg")
      ->where("persid = " . $db->quote($mw->persid) . " AND MONTH(datum) = " .  $db->quote($maand) . " AND YEAR(datum) = " .  $db->quote($jaar) . " AND gekeurd = " .  $db->quote('1') . " AND code <> " . $db->quote('138'));
    $db->setQuery($q_uren);
    $uren = $db->loadResult();
  
    // Selecteer alle overhead van de medewerker in de maand bij uren die zijn goedgekeurd en waar geen maatregel is
    $q_oh = $db->getQuery(true);
    $q_oh
      ->select("SUM(overhead) AS somoh")
      ->from("g4e_orakel_urenreg")
      ->where("persid = " . $db->quote($mw->persid) . " AND MONTH(datum) = " .  $db->quote($maand) . " AND YEAR(datum) = " .  $db->quote($jaar) . " AND gekeurd = " .  $db->quote('1') . " AND geen_oh = " . $db->quote('0') . " AND code <> " . $db->quote('138'));
    $db->setQuery($q_oh);
    $oh = $db->loadResult();
  
    // Selecteer alle uren met code 138 (ziek 70%, die uren tellen maar 70% mee)
    $q_ziek = $db->getQuery(true);
    $q_ziek
      ->select("SUM(uren) AS somuren")
      ->from("g4e_orakel_urenreg")
      ->where("persid = " . $db->quote($mw->persid) . " AND MONTH(datum) = " .  $db->quote($maand) . " AND YEAR(datum) = " .  $db->quote($jaar) . " AND gekeurd = " .  $db->quote('1') . " AND code = " . $db->quote('138'));
    $db->setQuery($q_ziek);
    $ziek = $db->loadResult();
  
    // Tel uren en oh op
    $tot_uren = $uren + $oh + ($ziek * 0.7);
  } else {
    // Anders, uren = contracturen
    $tot_uren = $mw->uren;
  }

  // Tel het aantal dagen waarop een medewerker heeft gewerkt (uren geschreven) in de maand
  $q_dagen = $db->getQuery(true);
  $q_dagen
    ->select("COUNT(DISTINCT(DATE(datum)))")
    ->from("g4e_orakel_urenreg")
    ->where("persid = " . $db->quote($mw->persid) . " AND MONTH(datum) = " .  $db->quote($maand) . " AND YEAR(datum) = " .  $db->quote($jaar) . " AND gekeurd = " .  $db->quote('1'));
  $db->setQuery($q_dagen);
  $dagen = $db->loadResult();

  // Voor de leden van het management, bereken de fee
  if ($mw->persid == 'costh00' || $mw->persid == 'bogem00') {
    // Selecteer totaal uren in maand maal fee van medewerker op dag uren, met code met fee en goedgekeurd
    $q_fee = $db->getQuery(true);
    $q_fee
      ->select("SUM((u.uren * p.fee))")
      ->from("g4e_orakel_urenreg u LEFT JOIN g4e_orakel_personeel_fee p ON (u.persid = p.persid AND p.van <= u.datum AND (p.tot >= u.datum OR DATE(p.tot) = '0000-00-00'))")
      ->where("MONTH(u.datum) = " . $db->quote($maand) . " AND YEAR(u.datum) = " . $db->quote($jaar) . " AND u.code IN (SELECT c.id FROM g4e_orakel_urencode c WHERE c.fee = " . $db->quote('1') . ") AND u.gekeurd = " . $db->quote('1'));
    $db->setQuery($q_fee);
    $fee = $db->loadResult();
  
    $fee = $fee * 0.3;
    $rij_class = "pdf-niet";
  } else {
    $fee = 0;
    $rij_class = "";
  }

  $tot_uren = round($tot_uren, 2);
  // Uitendelijk totaal te betalen. Uren maal salaris, plus eventuele fee
  $totaal = ($tot_uren * $mw->salaris) + $fee;



  $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>";

}

I also tried other things but it kept on going to a 404 page not found. Then I tried to also echo $html to look if it would render the table. After submitting the form, I get the (ofcourse empty table because i did not include $rijen) table on the next page copied on a 404 page..

Then I tried simply to insert
Code:
$html ='hello';
this worked and I received the pdf with only hello in it.

Then i tried to only copy the table without the query :

Code:
  $html = '<!DOCTYPE html><html><body>';
 
  $html .='<table class=\"uitbet-tabel\">
    <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>
    <tr>
       <td class="naam">testname</td>
    <td class="maand">Januari</td>
    <td class="uren">20</td>
    <td class="dagen">10</td>
    <td class="salaris">10</td>
    <td class="fee">100</td>
    <td class="totaal">120</td>
     <td class="bedrijf_id">Jap bv</td>
  </tr>
      <tr class="pdf-wel">
      <td>10  medewerkers</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td>&euro; 1000 </td>
       <td></td>
    
    </tr>
</table>';
 
$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();

This returned a email with a table printed in it.. no styling.. but the table is working. See attachment

pdf sended.png

So now i need to know, how I can get the output of the calc element, the table.. into the php plugin so i can send it as a pdf to the recipient. Or how i can load it in $html when using the content of the calc element in the php plugin.

I think, just copy the content from the calc element in the php plugin will work, but i am not sure how to put the data into the $html.

frontend.png
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top