Finished Building -> termination
This commit is contained in:
@@ -14,6 +14,88 @@ class TerminationController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
|
||||
$id = $r->id;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$term = new Termination($id);
|
||||
if(!$term->id) {
|
||||
$this->layout()->setFlash("Anschluss nicht gefunden", "error");
|
||||
$this->redirect("Building");
|
||||
}
|
||||
} else {
|
||||
$id = false;
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$building = new Building($r->building_id);
|
||||
if(!$building->id) {
|
||||
$this->layout()->setFlash("Anschluss nicht gefunden", "error");
|
||||
$this->redirect("Building");
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['building_id'] = $r->building_id;
|
||||
$data['name'] = $r->name;
|
||||
$data['contact'] = $r->contact;
|
||||
$data['phone'] = $r->phone;
|
||||
$data['email'] = $r->email;
|
||||
$data['lineworker_id'] = $building->lineworker_id;
|
||||
|
||||
$data['edit_by'] = $this->me->id;
|
||||
|
||||
if($mode == "add") {
|
||||
$data['create_by'] = $this->me->id;
|
||||
$term = TerminationModel::create($data);
|
||||
} else {
|
||||
$term->update($data);
|
||||
}
|
||||
|
||||
$new_id = $term->save();
|
||||
if(!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Building", "Index", [], "building=".$term->building_id);
|
||||
}
|
||||
|
||||
if(!$term->code) {
|
||||
$term->code = $term->getNewObjectCode();
|
||||
$term->save();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Anschluss gespeichert.", "success");
|
||||
$this->redirect("Building", "Index", [], "building=".$term->building_id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function delete() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
$this->layout()->setFlash("Keine Berechtigung", "error");
|
||||
$this->redirect("Building");
|
||||
}
|
||||
|
||||
$id = $this->request->id;
|
||||
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Objekt nicht gefunden", "error");
|
||||
$this->redirect("Building");
|
||||
}
|
||||
|
||||
$term = new Termination($id);
|
||||
if(!$term->id) {
|
||||
$this->layout()->setFlash("Anschluss nicht gefunden", "error");
|
||||
$this->redirect("Building");
|
||||
}
|
||||
|
||||
$building_id = $term->building_id;
|
||||
|
||||
$term->delete();
|
||||
|
||||
$this->layout()->setFlash("Anschluss gelöscht", "success");
|
||||
$this->redirect("Building", "Index", [], "building=".$building_id);
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
$do = $this->request->do;
|
||||
|
||||
Reference in New Issue
Block a user