From 8f4e179315b81cfc4751b1349ffd06695c2822df Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 29 Jun 2021 20:57:24 +0200 Subject: [PATCH] Added adding POPs --- Layout/default/Address/Form.php | 1 + Layout/default/Network/Index.php | 34 ++++-- Layout/default/Pop/Form.php | 119 +++++++++++++++++++ application/Addresstype/AddresstypeModel.php | 28 ++++- application/Network/Network.php | 11 ++ application/Pop/PopController.php | 84 +++++++++++++ application/Pop/PopModel.php | 32 ++--- lang/de.php | 1 + 8 files changed, 283 insertions(+), 27 deletions(-) create mode 100644 Layout/default/Pop/Form.php diff --git a/Layout/default/Address/Form.php b/Layout/default/Address/Form.php index 4b5629659..42157b8da 100644 --- a/Layout/default/Address/Form.php +++ b/Layout/default/Address/Form.php @@ -129,6 +129,7 @@ + diff --git a/Layout/default/Network/Index.php b/Layout/default/Network/Index.php index 603d29530..c487930a2 100644 --- a/Layout/default/Network/Index.php +++ b/Layout/default/Network/Index.php @@ -65,21 +65,21 @@

Details zu name?>

- - +
+ - + - + @@ -89,15 +89,33 @@

POPs in name?>

pops) && count($network->pops)): ?> - +
Name name?>
Besitzer owner->getCompanyOrName()?>
Interne Notiz note)?>
+ + + + + + + pops as $pop): ?> + + + + + + + +
NameGPS (Breite, Länge)Standortinfo
name?>gps_lat?>, gps_long?>location?> + $pop->id])?>"> + $pop->id])?>" class="text-danger" title="Löschen"> +

Keine POPs vorhanden

- "> Neuen POP anlegen + $network->id])?>"> Neuen POP anlegen
-

3

+

Berechtigungen

diff --git a/Layout/default/Pop/Form.php b/Layout/default/Pop/Form.php new file mode 100644 index 000000000..1b3248494 --- /dev/null +++ b/Layout/default/Pop/Form.php @@ -0,0 +1,119 @@ + + +
+
+ + +
+
+
+
+ +
+

id) ? "POP bearbeiten" : "Neuer POP" ?>

+
+
+
+ + +
+
+ +
+
+

id) ? "POP bearbeiten" : "Neuer POP"?>

+ +
"> +
+
+ + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+ + + +
+
+
+ +
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/application/Addresstype/AddresstypeModel.php b/application/Addresstype/AddresstypeModel.php index 68c2ae972..1bbf71de5 100644 --- a/application/Addresstype/AddresstypeModel.php +++ b/application/Addresstype/AddresstypeModel.php @@ -92,8 +92,29 @@ class AddresstypeModel { if(is_array($filter['addresstype']) && count($filter['addresstype'])) { $at = $filter['addresstype']; $in = []; - if(in_array("owner", $at)) { - $in[] = "Addresstype.type = 'owner'"; + if(in_array("systemowner", $at)) { + $in[] = "Addresstype.type = 'systemowner'"; + } + if(in_array("netowner", $at)) { + $in[] = "Addresstype.type = 'netowner'"; + } + if(in_array("salespartner", $at)) { + $in[] = "Addresstype.type = 'Addresstype'"; + } + if(in_array("pipeworker", $at)) { + $in[] = "Addresstype.type = 'pipeworker'"; + } + if(in_array("lineworker", $at)) { + $in[] = "Addresstype.type = 'lineworker'"; + } + if(in_array("netoperator", $at)) { + $in[] = "Addresstype.type = 'netoperator'"; + } + if(in_array("support", $at)) { + $in[] = "Addresstype.type = 'support'"; + } + if(in_array("billing", $at)) { + $in[] = "Addresstype.type = 'billing'"; } if(in_array("employee", $at)) { $in[] = "Addresstype.type = 'employee'"; @@ -107,9 +128,6 @@ class AddresstypeModel { if(in_array("contact", $at)) { $in[] = "Addresstype.type = 'contact'"; } - if(in_array("billing", $at)) { - $in[] = "Addresstype.type = 'billing'"; - } $or = ""; if(count($in)) { diff --git a/application/Network/Network.php b/application/Network/Network.php index 29cd95c6c..f1143c4c1 100644 --- a/application/Network/Network.php +++ b/application/Network/Network.php @@ -2,6 +2,7 @@ class Network extends mfBaseModel { private $owner; + private $pops; public function getProperty($name) { if($this->$name == null) { @@ -15,6 +16,16 @@ class Network extends mfBaseModel { } } + if($name == "pops") { + if($this->id) { + $pops = PopModel::search(['network_id' => $this->id]); + $this->pops = $pops; + return $this->pops; + } else { + return null; + } + } + $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield); diff --git a/application/Pop/PopController.php b/application/Pop/PopController.php index c4124a649..16d087932 100644 --- a/application/Pop/PopController.php +++ b/application/Pop/PopController.php @@ -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]); + } } \ No newline at end of file diff --git a/application/Pop/PopModel.php b/application/Pop/PopModel.php index b7a09d106..231b0ee08 100644 --- a/application/Pop/PopModel.php +++ b/application/Pop/PopModel.php @@ -2,7 +2,11 @@ class PopModel { public $name = null; - public $owner_id = null; + public $network_id = null; + public $gps_lat = null; + public $gps_long = null; + public $location = null; + public $note = null; public $create_by = null; @@ -15,7 +19,7 @@ class PopModel { } public static function create(Array $data) { - $model = new Network(); + $model = new Pop(); foreach($data as $field => $value) { if(property_exists(get_called_class(), $field)) { @@ -33,10 +37,10 @@ class PopModel { $item = []; $db = FronkDB::singleton(); - $res = $db->select("Network", "*", "id=$id LIMIT 1"); + $res = $db->select("Pop", "*", "id=$id LIMIT 1"); if($db->num_rows($res)) { $data = $db->fetch_object($res); - $item = new Network($data); + $item = new Pop($data); } return $item; } @@ -46,10 +50,10 @@ class PopModel { $db = FronkDB::singleton(); - $res = $db->select("Network", "*"); + $res = $db->select("Pop", "*"); if($db->num_rows($res)) { while($data = $db->fetch_object($res)) { - $items[] = new Network($data); + $items[] = new Pop($data); } } return $items; @@ -60,10 +64,10 @@ class PopModel { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); - $res = $db->select("Network", "*". "$where ORDER BY name, owner_id"); + $res = $db->select("Pop", "*", "$where ORDER BY name, network_id"); if($db->num_rows($res)) { $data = $db->fetch_object($res); - $item = new Network($data); + $item = new Pop($data); if($item->id) { return $item; } else { @@ -78,10 +82,10 @@ class PopModel { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); - $res = $db->select("Network", "*". "$where ORDER BY name, owner_id"); + $res = $db->select("Pop", "*", "$where ORDER BY name, network_id"); if($db->num_rows($res)) { while($data = $db->fetch_object($res)) { - $items[] = new Network($data); + $items[] = new Pop($data); } } return $items; @@ -91,10 +95,10 @@ class PopModel { $where = "1=1 "; //var_dump($filter);exit; - if(array_key_exists("owner_id", $filter)) { - $ownerid= $filter['owner_id']; - if(is_numeric($ownerid)) { - $where .= " AND owner_id=$ownerid"; + if(array_key_exists("network_id", $filter)) { + $networkid = $filter['network_id']; + if(is_numeric($networkid)) { + $where .= " AND network_id=$networkid"; } } diff --git a/lang/de.php b/lang/de.php index e66b67a3b..bba6348ea 100644 --- a/lang/de.php +++ b/lang/de.php @@ -7,6 +7,7 @@ $l['salespartner'] = "Vertriebspartner"; $l['pipeworker'] = "Tiefbau"; $l['lineworker'] = "Leitungsbau"; $l['netoperator'] = "Netzbetreiber"; +$l['planner'] = "Planer"; $l['support'] = "Support"; $l['employee'] = "Mitarbeiter"; $l['customer'] = "Kunde";