WIP Preorder Status Notifications

This commit is contained in:
Frank Schubert
2024-11-26 15:10:27 +01:00
parent 30530a0177
commit 9a3eca761e
6 changed files with 128 additions and 0 deletions
+28
View File
@@ -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;
}
/*