diff --git a/Layout/default/Preorder/include/preorder-detail.php b/Layout/default/Preorder/include/preorder-detail.php
index dffcfebae..259fd5fea 100644
--- a/Layout/default/Preorder/include/preorder-detail.php
+++ b/Layout/default/Preorder/include/preorder-detail.php
@@ -501,7 +501,7 @@
=(array_key_exists($flag->id, $preorder->statusflags) && $preorder->statusflags[$flag->id]->value && $preorder->statusflags[$flag->id]->value->value) ? "checked='checked'" : ""?>
/>
-
=$preorder->statusflags[$flag->id]->code?> - =$preorder->statusflags[$flag->id]->name?> |
+ =$preorder->statusflags[$flag->id]->name?> |
@@ -554,7 +554,7 @@
| =date("d.m.Y H:i:s", $history->create)?> |
=$history->creator->name?> |
- =$history->key?> |
+ =$history->getKey()?> |
=$history->getText("old")?> |
=$history->getText("new")?> |
diff --git a/application/PreorderHistory/PreorderHistory.php b/application/PreorderHistory/PreorderHistory.php
index d52d38c26..e6f001288 100644
--- a/application/PreorderHistory/PreorderHistory.php
+++ b/application/PreorderHistory/PreorderHistory.php
@@ -37,9 +37,23 @@ class PreorderHistory extends mfBaseModel {
}
}
+
return $value;
}
+ public function getKey() {
+ $key = $this->key;
+
+ if(preg_match('/^preorderstatusflag-(\d+)-/', $key, $m)) {
+ if(array_key_exists(1, $m)) {
+ $id = $m[1];
+ $psf = new Preorderstatusflag($id);
+ return "Status Flag ".$psf->name;
+ }
+ }
+ return $key;
+ }
+
public function getText($type = "new") {
$value = $this->getValue($type);
if($value === null) return "";
diff --git a/application/PreorderStatusflag/PreorderStatusflag.php b/application/PreorderStatusflag/PreorderStatusflag.php
index b847aedd6..0245c52c0 100644
--- a/application/PreorderStatusflag/PreorderStatusflag.php
+++ b/application/PreorderStatusflag/PreorderStatusflag.php
@@ -10,6 +10,12 @@ class PreorderStatusflag extends mfBaseModel {
if($name == "value") {
if(!$this->preorder_id) return null;
$value = PreorderStatusflagValueModel::getFirst(["preorder_id" => $this->preorder_id, "flag_id" => $this->id]);
+ if(!$value) {
+ $value = PreorderStatusflagValueModel::create([
+ "preorder_id" => $this->preorder_id,
+ "flag_id" => $this->id
+ ]);
+ }
$this->value = $value;
return $this->value;
}
diff --git a/application/PreorderStatusflagValue/PreorderStatusflagValue.php b/application/PreorderStatusflagValue/PreorderStatusflagValue.php
index 67f739735..4b2604abe 100644
--- a/application/PreorderStatusflagValue/PreorderStatusflagValue.php
+++ b/application/PreorderStatusflagValue/PreorderStatusflagValue.php
@@ -2,4 +2,15 @@
class PreorderStatusflagValue extends mfBaseModel {
+ protected function afterSave() {
+ if($this->_old_data->value != $this->value) {
+ $history = PreorderHistoryModel::create([
+ "preorder_id" => $this->preorder_id,
+ "key" => "preorderstatusflag-".$this->flag_id."-value",
+ "old_value" => $this->_old_data->value,
+ "new_value" => $this->data->value
+ ]);
+ $history->save();
+ }
+ }
}
\ No newline at end of file