Showing unit OAID & preorder count in Preorder/Form
This commit is contained in:
@@ -7,6 +7,7 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
private $ftu_data;
|
||||
private $status;
|
||||
private $statusflags; // TODO
|
||||
private $preorders;
|
||||
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
@@ -283,6 +284,15 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
return $this->rimo_workorders;
|
||||
}
|
||||
|
||||
if($name == "preorders") {
|
||||
$preorders = PreorderModel::search(["adb_wohneinheit_id" => $this->id]);
|
||||
if(!count($preorders)) {
|
||||
return [];
|
||||
}
|
||||
$this->preorders = $preorders;
|
||||
return $this->preorders;
|
||||
}
|
||||
|
||||
if($name == "ftu_data") {
|
||||
$rimo_data = $this->getExternalRimoData();
|
||||
|
||||
|
||||
@@ -1065,6 +1065,8 @@ class AddressDBController extends mfBaseController {
|
||||
$u['extra'] = (string)$unit;
|
||||
$u['zusatz'] = $unit->zusatz;
|
||||
$u['usage'] = $unit->nutzung;
|
||||
$u['oaid'] = $unit->oaid;
|
||||
$u['preorder_count'] = count($unit->preorders);
|
||||
$results[] = $u;
|
||||
}
|
||||
|
||||
|
||||
@@ -496,6 +496,14 @@ class PreorderController extends mfBaseController {
|
||||
$data['create_by'] = $this->me->id;
|
||||
$preorder = PreorderModel::create($data);
|
||||
} else {
|
||||
// if new wohneinheit -> remove oaid from Preorder
|
||||
if($r->adb_wohneinheit_id && $preorder->adb_wohneinheit_id != $r->adb_wohneinheit_id) {
|
||||
$preorder->oaid = null;
|
||||
}
|
||||
if(!$r->adb_wohneinheit_id && $preorder->oaid) {
|
||||
$preorder->oaid = null;
|
||||
}
|
||||
|
||||
$preorder->update($data);
|
||||
}
|
||||
|
||||
@@ -655,6 +663,9 @@ class PreorderController extends mfBaseController {
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// if $preorder->adb_wohneinheit_id
|
||||
//if($preorder->_old)
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user