Added Terminations to buildings
This commit is contained in:
@@ -8,38 +8,7 @@ class Building extends mfBaseModel {
|
||||
private $type;
|
||||
private $status;
|
||||
private $pipeworker;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "type") {
|
||||
$this->type = new Buildingtype($this->type_id);
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
if($name == "status") {
|
||||
$this->status = new Buildingstatus($this->status_id);
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
if($name == "pipeworker") {
|
||||
$this->pipeworker = new Address($this->pipeworker_id);
|
||||
return $this->pipeworker;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
private $terminations;
|
||||
|
||||
public function getNewObjectCode() {
|
||||
if(!$this->zip) {
|
||||
@@ -116,4 +85,41 @@ class Building extends mfBaseModel {
|
||||
return $Gridcell;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "type") {
|
||||
$this->type = new Buildingtype($this->type_id);
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
if($name == "status") {
|
||||
$this->status = new Buildingstatus($this->status_id);
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
if($name == "pipeworker") {
|
||||
$this->pipeworker = new Address($this->pipeworker_id);
|
||||
return $this->pipeworker;
|
||||
}
|
||||
|
||||
if($name == "terminations") {
|
||||
$this->terminations = TerminationModel::search(['building_id' => $this->id]);
|
||||
return $this->terminations;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,6 +140,31 @@ class BuildingController extends mfBaseController {
|
||||
$building->save();
|
||||
}
|
||||
|
||||
// Anschlüsse anlegen
|
||||
if($building->units > 0) {
|
||||
for($i = 1; $i <= $building->units; $i++) {
|
||||
$data = [];
|
||||
$data['building_id'] = $building->id;
|
||||
$data['code'] = $building->code . "." . sprintf("%03d", $i);
|
||||
|
||||
if($building->units == 1) {
|
||||
$data['contact'] = $building->contact;
|
||||
$data['phone'] = $building->phone;
|
||||
$data['email'] = $building->email;
|
||||
}
|
||||
|
||||
if($building->lineworker_id) {
|
||||
$data['lineworker_id'] = $building->lineworker_id;
|
||||
}
|
||||
if($building->oan_id) {
|
||||
$data['oan_id'] = $building->oan_id. "." . sprintf("%03d", $i);
|
||||
}
|
||||
|
||||
$term = TerminationModel::create($data);
|
||||
$term->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->layout()->setFlash("Objekt erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Building", "Edit", ['id' => $new_id]);
|
||||
|
||||
Reference in New Issue
Block a user