From 39c9c6637cdab997a841afb701347781b04268d4 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Fri, 27 Aug 2021 10:23:11 +0200 Subject: [PATCH] Added pdf debug function --- Layout/default/Address/Index.php | 2 +- .../attachments/new_order.pdf.php | 2 +- application/Dashboard/DashboardController.php | 50 +++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Layout/default/Address/Index.php b/Layout/default/Address/Index.php index ed4fff781..3697760e6 100644 --- a/Layout/default/Address/Index.php +++ b/Layout/default/Address/Index.php @@ -70,7 +70,7 @@ endforeach; ?> "> - + 1) ? ", ..." : ""?> diff --git a/Layout/default/Emailtemplates/attachments/new_order.pdf.php b/Layout/default/Emailtemplates/attachments/new_order.pdf.php index 86cd6e801..fe5ba3c7c 100644 --- a/Layout/default/Emailtemplates/attachments/new_order.pdf.php +++ b/Layout/default/Emailtemplates/attachments/new_order.pdf.php @@ -56,7 +56,7 @@ getFullName()): ?> getFullName()?>
- street?> + street?>
zip?> city?> diff --git a/application/Dashboard/DashboardController.php b/application/Dashboard/DashboardController.php index 1f8f11c3d..fad37dc34 100644 --- a/application/Dashboard/DashboardController.php +++ b/application/Dashboard/DashboardController.php @@ -27,4 +27,54 @@ class DashboardController extends mfBaseController { $a = new Address(1); var_dump($a->generateServicePin());exit; } + + protected function pdfAction() { + $order = new Order(7); + $owner = new Address(1); + + $pdf = new Layout(); + $pdf->setTemplate("Emailtemplates/attachments/new_order.pdf"); + $pdf->set("ressourcePathPrefix", BASEDIR."/public/"); + $pdf->set("owner", $owner); + $pdf->set("order", $order); + + $pdfpath = $pdf->renderPDF(); + $tvalue = $pdf->getReturnedValue(); + $pdfname = $tvalue['filename']; + + echo $pdfname; + + exit; + return true; + //var_dump($pdfpath);exit; + + // send email to customer + + // TODO template rendern auslagern nach Emailtempate klasse + $tpl = new Layout(); + $tpl->setTemplate("Emailtemplates/customer/new_order"); + $tpl->set("owner", $owner); + $body = $tpl->render(); + + $values = $tpl->getReturnedValue(); + + $subject = $values['subject']; + $from = $values['from_email']; + $from_name = $values['from_email_name']; + $to = $owner->email; + + if(!$subject || !$from || !$from_name || !$to) { + $this->log->warn("Service PIN Email not sent. (subject: '$subject', from: '$from', from_email: '$from_email', to: '$to')"); + } else { + $email = new Emailnotification(); + $email->setSubject($subject); + $email->setBody($body); + $email->setFrom($from, $from_name); + $email->setTo($to); + $email->setHeader("X-xinon-oid", $order->id); + $email->setHeader("X-xinon-pid", $product->id); + $email->addAttachment($pdfpath, null, $pdfname, "application/pdf"); + $email->send(); + } + } } \ No newline at end of file