WIP Preorder Status Notifications
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class Preorder_Statustrigger_140 {
|
||||
private $log;
|
||||
|
||||
private $preorder;
|
||||
private $new_status;
|
||||
public $run_action = true;
|
||||
public function __construct(Preorder $preorder, Preorderstatus $new_status) {
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user