Updated vice versa updating of status flags / attributes

This commit is contained in:
Luca Haid
2025-01-21 16:33:27 +01:00
parent 4f6f968d7a
commit e52daf887b
2 changed files with 25 additions and 0 deletions
@@ -1063,6 +1063,27 @@ class PreorderController extends mfBaseController {
return false;
}
if ($flag_id == 1) {
$preorder = new Preorder($preorder_id);
if(!$preorder->id) {
return false;
}
$attribute = "inhouse_cabling_supplied";
$attribs = $preorder->attribute;
if(!$attribs) {
$attribs = [];
}
$attribs[$attribute] = $value ? 1 : 0;
$preorder->attributes = json_encode($attribs);
if($preorder->save()) {
return ["id" => $preorder_id, "attribute" => $attribute, "update" => date("d.m.Y H:i", $preorder->edit)];
} else {
$this->returnJson(["status" => "error", "result" => ["id" => $preorder_id, "attribute" => $attribute]]);
}
}
$flagvalue = PreorderStatusflagValueModel::getFirst(["preorder_id" => $preorder_id, "flag_id" => $flag_id]);
if(!$flagvalue) {
$flagvalue = PreorderStatusflagValueModel::create([