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: =str_replace(["\n", "\r"], "", $contract->owner->getCompanyOrName())?>
+
+Telefon: =$contract->owner->phone?>
+
+e-Mail: =$contract->owner->email?>
+
+Kundennummer: =$contract->owner->customer_number?>
+
+Kunde: =str_replace(["\n", "\r"], "", $contract->owner->getCompanyOrName())?>
+
+
+### Altes Produkt:
+Vertragsinhaber: =$origin->owner->getCompanyOrName()?> [=$origin->owner->customer_number?>]
+Produkt: =$origin->product_name?>
+
+=$url_prefix?>=self::getUrl("Contract", "view", ["contract_id" => $origin->id])?>
+
+
+### Neues Produkt:
+Vertragsinhaber: =$contract->owner->getCompanyOrName()?> [=$contract->owner->customer_number?>]
+Produkt: =$contract->product_name?>
+
+=$url_prefix?>=self::getUrl("Contract", "view", ["contract_id" => $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");
|