diff --git a/Layout/default/Preordercampaign/Form.php b/Layout/default/Preordercampaign/Form.php
index 47fc8777a..9ce1b0c7b 100644
--- a/Layout/default/Preordercampaign/Form.php
+++ b/Layout/default/Preordercampaign/Form.php
@@ -376,6 +376,24 @@
+
Emailbenachrichtigungen
+
+
API-User
diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php
index 671c37470..55f13386e 100644
--- a/application/Preorder/Preorder.php
+++ b/application/Preorder/Preorder.php
@@ -153,6 +153,8 @@ class Preorder extends mfBaseModel {
$this->log->error("config TT_PREORDER_STATUS_MATRIX not defined!");
}
+ $actions = [];
+
// run every trigger bnetween old and new status code
foreach(TT_PREORDER_STATUS_MATRIX as $intermediate_code => $status) {
if($intermediate_code <= $old_status->code) continue;
@@ -180,12 +182,38 @@ class Preorder extends mfBaseModel {
$trigger = new $classname($this, $new_status);
$trigger->run();
+ if(array_key_exists("action", $status) && is_array($status) && property_exists($trigger, "run_action") && $trigger->run_action) {
+ foreach($status["action"] as $type => $action) {
+ if(!array_key_exists($type, $actions)) {
+ $actions[$type] = [];
+ }
+ $actions[$type][] = $trigger;
+ }
+ }
+
+ // run last email action
+ if(array_key_exists("email", $actions) && is_array($actions["email"]) && count($actions["email"])) {
+ $email_action = array_pop($actions["email"]);
+ $this->runTriggerEmailAction($email_action);
+ }
+
}
return true;
+ }
+
+ private function runTriggerEmailAction($action) {
+ if(!array_key_exists("template", $action)) return false;
+ if(!array_key_exists("from", $action)) return false;
+ //if(!array_key_exists("to", $action)) return false;
+ //if(!array_key_exists("data", $action)) return false;
+
+
+
+
}
/*
diff --git a/application/Preorder/statustrigger/245.php b/application/Preorder/statustrigger/245.php
new file mode 100644
index 000000000..7eaef027f
--- /dev/null
+++ b/application/Preorder/statustrigger/245.php
@@ -0,0 +1,46 @@
+log = mfLoghandler::singleton();
+
+ $this->preorder = $preorder;
+ $this->new_status = $new_status;
+ }
+
+ public function run() {
+ $this->log->debug(__METHOD__.": running trigger");
+
+ $changes = false;
+
+ if(!$this->preorder->ciftoken) {
+ $this->preorder->ciftoken = $this->preorder->createCiftoken();
+ $changes = true;
+ }
+
+ /*if(!$this->preorder->ciftoken) {
+ $this->log->warning("Error creating ciftoken for preorder ".$this->preorder->id);
+ return true;
+ }*/
+ if(!$this->preorder->cifurl) {
+ $this->preorder->cifurl = $this->preorder->generateCifUrl();
+ $changes = true;
+ }
+
+ if(!$this->preorder->cifcableurl) {
+ $this->preorder->cifcableurl = $this->preorder->generateCifCableUrl();
+ $changes = true;
+ }
+
+ if($changes) {
+ $this->preorder->save();
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/application/Preordercampaign/PreordercampaignController.php b/application/Preordercampaign/PreordercampaignController.php
index 2f65109e6..5c8424874 100644
--- a/application/Preordercampaign/PreordercampaignController.php
+++ b/application/Preordercampaign/PreordercampaignController.php
@@ -236,6 +236,8 @@ class PreordercampaignController extends mfBaseController {
$data['homes_total'] = (int)$r->homes_total;
$data["cifurl"] = trim($r->cifurl);
$data["cifcableurl"] = trim($r->cifcableurl);
+ $data["from_email_name"] = trim($r->from_email_name);
+ $data["from_email"] = trim($r->from_email);
if($r->from) {
$data['from'] = self::dateToTimestamp($r->from);
diff --git a/application/Preordercampaign/PreordercampaignModel.php b/application/Preordercampaign/PreordercampaignModel.php
index c1a89ba2a..b8842d8b6 100644
--- a/application/Preordercampaign/PreordercampaignModel.php
+++ b/application/Preordercampaign/PreordercampaignModel.php
@@ -19,6 +19,8 @@ class PreordercampaignModel {
public $allow_unit_update;
public $cifurl;
public $cifcableurl;
+ public $from_email_name;
+ public $from_email;
public $banned_rimo_fcp;
public $note;
diff --git a/db/migrations/20241125152024_preordercampaign_add_email_from.php b/db/migrations/20241125152024_preordercampaign_add_email_from.php
new file mode 100644
index 000000000..79161471b
--- /dev/null
+++ b/db/migrations/20241125152024_preordercampaign_add_email_from.php
@@ -0,0 +1,32 @@
+getEnvironment() == "thetool") {
+ $table = $this->table('Preordercampaign');
+ $table->addColumn('from_email_name', 'string', ["null" => true, "default" => null, 'limit' => 64, "after" => "cifcableurl"]);
+ $table->addColumn('from_email', 'string', ["null" => true, "default" => null, 'limit' => 64, "after" => "from_email_name"]);
+ $table->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}