Added adding POPs
This commit is contained in:
@@ -13,5 +13,89 @@ class PopController extends mfBaseController {
|
||||
$this->redirect("Dashboard");
|
||||
}*/
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Pop/Form");
|
||||
$this->layout()->set("networks", NetworkModel::getAll());
|
||||
if($this->request->network_id) {
|
||||
$pop = new Pop();
|
||||
$pop->network_id = $this->request->network_id;
|
||||
$this->layout()->set("pop", $pop);
|
||||
}
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("POP nicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
|
||||
$pop = new Pop($id);
|
||||
if($pop->id != $id) {
|
||||
$this->layout()->setFlash("POP nicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
|
||||
$this->layout()->set("pop", $pop);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r);exit;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$pop = new Pop($id);
|
||||
if(!$pop->id) {
|
||||
$this->layout()->setFlash("POP nicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
//var_dump($r->addresstypes);exit;
|
||||
|
||||
if(!$r->network_id || !$r->name) {
|
||||
$this->layout()->setFlash("Bitte Name und Netzgebiet eintragen", "error");
|
||||
$this->layout()->set("pop", $pop);
|
||||
unset($r->network_id);
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['network_id'] = $r->network_id;
|
||||
$data['name'] = $r->name;
|
||||
$data['gps_lat'] = $r->gps_lat;
|
||||
$data['gps_long'] = $r->gps_long;
|
||||
$data['location'] = $r->location;
|
||||
$data['note'] = $r->note;
|
||||
|
||||
$data['edit_by'] = 1;
|
||||
|
||||
if($mode == "add") {
|
||||
$data['create_by'] = 1;
|
||||
$pop = PopModel::create($data);
|
||||
} else {
|
||||
$pop->update($data);
|
||||
}
|
||||
|
||||
//var_dump($address);exit;
|
||||
|
||||
$new_id = $pop->save();
|
||||
if(!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->layout()->set("network", $network);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Pop", "Edit", ['id' => $new_id]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user