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;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
46
application/Preorder/statustrigger/245.php
Normal file
46
application/Preorder/statustrigger/245.php
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user