Feature/preorder add history
This commit is contained in:
committed by
Frank Schubert
parent
076b513039
commit
04153eb8d3
@@ -18,6 +18,7 @@ class Preorder extends mfBaseModel {
|
||||
private $editor;
|
||||
private $attribute = [];
|
||||
private $logistics;
|
||||
private $history;
|
||||
|
||||
public function afterLoad() {
|
||||
if($this->uid === "string") {
|
||||
@@ -49,7 +50,12 @@ class Preorder extends mfBaseModel {
|
||||
if($this->oaid != $old_oaid) {
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
||||
//TODO: history start
|
||||
if($this->status_id != $this->_old_data->status_id) {
|
||||
$this->createHistoryEntry();
|
||||
}
|
||||
|
||||
// run triggers based on new status
|
||||
$this->runStatusTrigger();
|
||||
// Cascade status changes down to adb_hausnummer and adb_wohneinheit
|
||||
@@ -59,6 +65,16 @@ class Preorder extends mfBaseModel {
|
||||
|
||||
$this->in_after_save--;
|
||||
}
|
||||
|
||||
public function createHistoryEntry() {
|
||||
$history = PreorderHistoryModel::create([
|
||||
"preorder_id" => $this->id,
|
||||
"key" => 'preorderstatus_id',
|
||||
"old_value" => $this->_old_data->status_id,
|
||||
"new_value" => $this->status_id
|
||||
]);
|
||||
$history->save();
|
||||
}
|
||||
|
||||
public function runStatusTrigger() {
|
||||
if(!$this->id) return true;
|
||||
@@ -699,7 +715,15 @@ class Preorder extends mfBaseModel {
|
||||
$this->logistics = $logistics;
|
||||
return $this->logistics;
|
||||
}
|
||||
|
||||
|
||||
if($name == "history") {
|
||||
$history = PreorderHistoryModel::search(["preorder_id" => $this->id]);
|
||||
$this->history = $history;
|
||||
|
||||
return $this->history;
|
||||
|
||||
}
|
||||
|
||||
if($name == "attribute") {
|
||||
if(!$this->attributes) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user