From 18f5f78a8f60ff1a94b12ed830e3fbe5809f4426 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 25 Jul 2024 21:35:53 +0200 Subject: [PATCH] Added productchange notification ticket email --- .../Contract/include/productchange-action.php | 4 +- .../order/productchange-ticket.php | 47 +++++++++++++++++++ application/Contract/Contract.php | 31 ++++++++++++ application/Contract/ContractController.php | 2 + 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 Layout/default/Emailtemplates/order/productchange-ticket.php diff --git a/Layout/default/Contract/include/productchange-action.php b/Layout/default/Contract/include/productchange-action.php index 45fa8728a..a93ce9cda 100644 --- a/Layout/default/Contract/include/productchange-action.php +++ b/Layout/default/Contract/include/productchange-action.php @@ -197,7 +197,7 @@ ?> "> - cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?> @@ -207,7 +207,7 @@ - diff --git a/Layout/default/Emailtemplates/order/productchange-ticket.php b/Layout/default/Emailtemplates/order/productchange-ticket.php new file mode 100644 index 000000000..86e1af9a5 --- /dev/null +++ b/Layout/default/Emailtemplates/order/productchange-ticket.php @@ -0,0 +1,47 @@ +setReturnValue([ + 'subject' => "Produktwechsel ".$contract->owner->getCompanyOrName(), + 'from_email' => "workspace.admin@xinon.at", + 'from_email_name' => "thetool" +]); + +$url_prefix = "http".($_SERVER["HTTPS"] ? "s" : "")."://".$_SERVER["HTTP_HOST"]; +?> +project: storungen-and-support +type: Produktwechsel +status: Neu +priority: Residential +Kundenname: owner->getCompanyOrName())?> + +Telefon: owner->phone?> + +e-Mail: owner->email?> + +Kundennummer: owner->customer_number?> + +Kunde: owner->getCompanyOrName())?> + + +### Altes Produkt: +Vertragsinhaber: owner->getCompanyOrName()?> [owner->customer_number?>] +Produkt: product_name?> + + $origin->id])?> + + +### Neues Produkt: +Vertragsinhaber: owner->getCompanyOrName()?> [owner->customer_number?>] +Produkt: product_name?> + + $contract->id])?> + + +finish_date): ?> +Neues Produkt hat fertigstellungdatum, somit ist nach der technischen Umstellung nichts mehr zu machen. + +⚠️ Neues Produkt muss nach der technischen Umstellung in thetool FERTIGGESTELLT werden. + diff --git a/application/Contract/Contract.php b/application/Contract/Contract.php index 7a8fc4864..359bbe5a5 100644 --- a/application/Contract/Contract.php +++ b/application/Contract/Contract.php @@ -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; diff --git a/application/Contract/ContractController.php b/application/Contract/ContractController.php index aaa7e2853..07c3373d4 100644 --- a/application/Contract/ContractController.php +++ b/application/Contract/ContractController.php @@ -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");