Showing unit OAID & preorder count in Preorder/Form

This commit is contained in:
Frank Schubert
2024-12-11 13:04:26 +01:00
parent 72367e2a63
commit 2154b326c2
4 changed files with 29 additions and 2 deletions

View File

@@ -153,7 +153,7 @@
<div class="col-lg-10">
<select class="form-control" name="adb_wohneinheit_id" id="adb_wohneinheit_id" <?=($preorder && $preorder->adb_wohneinheit_id && is_array($preorder->adb_wohneinheit->rimo_workorders) && count($preorder->adb_wohneinheit->rimo_workorders)) ? "disabled='disabled'" : ""?>>
<?php if($preorder->adb_wohneinheit_id): ?>
<option value="<?=$preorder->adb_wohneinheit_id?>" selected="selected"><?=$preorder->adb_hausnummer->strasse->name?> <?=$preorder->adb_hausnummer->hausnummer?> <?=$preorder->adb_wohneinheit?><?=($preorder->adb_wohneinheit->extref) ? " (".$preorder->adb_wohneinheit->extref.")" : ""?></option>
<option value="<?=$preorder->adb_wohneinheit_id?>" selected="selected"><?=$preorder->adb_hausnummer->strasse->name?> <?=$preorder->adb_hausnummer->hausnummer?> <?=$preorder->adb_wohneinheit?><?=($preorder->adb_wohneinheit->extref) ? " (".$preorder->adb_wohneinheit->extref.")" : ""?><?=($preorder->adb_wohneinheit->oaid) ?: ""?><?=(count($preorder->adb_wohneinheit->preorders)) ? " [".count($preorder->adb_wohneinheit->preorders)." Bestellungen]" : ""?></option>
<?php endif; ?>
</select>
<?php if($preorder && $preorder->adb_wohneinheit_id && is_array($preorder->adb_wohneinheit->rimo_workorders) && count($preorder->adb_wohneinheit->rimo_workorders)): ?>
@@ -597,6 +597,8 @@
opt += " " + unit.extra;
}
if(unit.extref) opt += " (" + unit.extref + ")";
if(unit.oaid) opt += " - " + unit.oaid;
if(unit.preorder_count) opt += " - " + unit.preorder_count + " Bestellung";
/*let extras = new Array();
if(unit.block) extras.push("Block " + unit.block);
@@ -626,7 +628,9 @@
.data("stiege", unit.stiege)
.data("stock", unit.stock)
.data("tuer", unit.tuer)
.data("zusatz", unit.zusatz);
.data("zusatz", unit.zusatz)
.data("oaid", unit.oaid)
.data["preorder_count"];
afterHausnummerChange();

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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)
}
/*