Sending email to ticketsystem after Contract Cancel

This commit is contained in:
Frank Schubert
2024-07-11 20:44:19 +02:00
parent 8c2c3cbcbe
commit ffbd465c3e
3 changed files with 67 additions and 8 deletions

View File

@@ -238,8 +238,8 @@ class Contract extends mfBaseModel {
"owner" => $this->getProperty("owner")
];
$pdf = new PdfForm("Emailtemplates/attachments/cancel_notification.pdf", $pdf_vars);
$pdf->download();
exit;
//$pdf->download();
//exit;
$pdfpath = $pdf->render();
$tvalue = $pdf->getReturnedValues();
$pdfname = $tvalue["filename"];
@@ -272,11 +272,31 @@ class Contract extends mfBaseModel {
$email->addAttachment($pdfpath, null, $pdfname, "application/pdf");
$email->send();
$email->setSubject("Kündigungbestätigung ".$this->owner->customer_number." ".str_replace(["\n", "\r"], "", $this->owner->getCompanyOrName()));
$email->setTo("office@xinon.at");
$email->send();
$this->log->info(__METHOD__.": Sending Cancel Notication for ".$this->owner_id." to $to");
}
$tk_tpl = new Layout();
$tk_tpl->setTemplate("Emailtemplates/customer/cancel_ticket");
foreach($pdf_vars as $name => $val) {
$tk_tpl->set($name, $val);
}
$tk_body = $tk_tpl->render();
$tk_values = $tk_tpl->getReturnedValue();
$tk_email = new Emailnotification();
$tk_email->setSubject($tk_values["subject"]);
$tk_email->setBody($tk_body);
$tk_email->setFrom($tk_values["from_email"], $tk_values["from_email_name"]);
$tk_email->setTo($to);
$tk_email->setHeader("X-".MFAPPNAME."-Cid", $this->id);
$tk_email->send();
}
public function getProperty($name) {