Added productchange notification ticket email

This commit is contained in:
Frank Schubert
2024-07-25 21:35:53 +02:00
parent 3a6c03414b
commit 18f5f78a8f
4 changed files with 82 additions and 2 deletions

View File

@@ -399,6 +399,32 @@ class Contract extends mfBaseModel {
}
public function sendProductchangeNotification(Contract $origin) {
$tk_tpl = new Layout();
$tk_tpl->setTemplate("Emailtemplates/order/productchange-ticket");
$tpl_vars = [
"contract" => $this,
"origin" => $origin
];
foreach($tpl_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("workspace@xinon.at");
$tk_email->setHeader("X-" . MFAPPNAME . "-Cid", $this->id);
$tk_email->send();
}
public function getProperty($name) {
if($this->$name == null) {
@@ -628,6 +654,11 @@ class Contract extends mfBaseModel {
$old_id = $this->id;
$this->id = null;
$data = $this->data;
$this->data = new stdClass();
foreach($data as $key => $value) {
$this->data->$key = $value;
}
// cleanup Contract daten
$this->orderproduct_id = null;

View File

@@ -593,6 +593,8 @@ class ContractController extends mfBaseController
$this->layout()->setFlash("Konnte Verknüpfung nicht speichern", "warn");
}
$new_contract->sendProductchangeNotification($contract);
$this->layout()->setFlash("Produktwechsel erfolgreich erstellt", "success");
if($f == "o") {
$this->redirect("Order");