From c5d36132d2a92a0863e06daf947ee1c58b5b6c28 Mon Sep 17 00:00:00 2001 From: Spitzer_Daniel Date: Wed, 2 Nov 2022 13:00:52 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Features=20Netzbau->=20Dateiablage=20und=20?= =?UTF-8?q?Stammdaten->Pops=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Layout/default/Filestore/Form.php | 247 +++++++++++++++ Layout/default/Filestore/Index.php | 85 +++++ Layout/default/Pop/Form.php | 296 +++++++++-------- Layout/default/Pop/Index.php | 249 +++++++++++++++ Layout/default/menu.php | 2 + application/Filestore/Filestore.php | 46 +++ application/Filestore/FilestoreController.php | 197 ++++++++++++ application/Filestore/FilestoreModel.php | 168 ++++++++++ .../FilestoreHistory/FilestoreHistory.php | 41 +++ .../FilestoreHistoryController.php | 151 +++++++++ .../FilestoreHistoryModel.php | 157 +++++++++ application/Pop/PopController.php | 299 ++++++++++-------- 12 files changed, 1669 insertions(+), 269 deletions(-) create mode 100644 Layout/default/Filestore/Form.php create mode 100644 Layout/default/Filestore/Index.php create mode 100644 Layout/default/Pop/Index.php create mode 100644 application/Filestore/Filestore.php create mode 100644 application/Filestore/FilestoreController.php create mode 100644 application/Filestore/FilestoreModel.php create mode 100644 application/FilestoreHistory/FilestoreHistory.php create mode 100644 application/FilestoreHistory/FilestoreHistoryController.php create mode 100644 application/FilestoreHistory/FilestoreHistoryModel.php diff --git a/Layout/default/Filestore/Form.php b/Layout/default/Filestore/Form.php new file mode 100644 index 000000000..3293e4f32 --- /dev/null +++ b/Layout/default/Filestore/Form.php @@ -0,0 +1,247 @@ + + +
+
+
+
+ +
+

Datei

+
+
+
+ + +
+
+ +
+
+

id) ? "Datei bearbeiten" : "Neue Datei" ?>

+ +
"> +
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + + +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/Layout/default/Filestore/Index.php b/Layout/default/Filestore/Index.php new file mode 100644 index 000000000..e2e52cbb7 --- /dev/null +++ b/Layout/default/Filestore/Index.php @@ -0,0 +1,85 @@ +getUrl($Mod, "Index"); +$pagination_baseurl_params = ["filter" => $filter]; +$pagination_entity_name = "Dateien"; +?> + + + + +
+
+
+
+ +
+

Dateiablage

+
+
+
+ + + +
+
+
+
+
+

Liste aller Dateien

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
NameBeschreibungErstellerBearbeiter
name ?>description ?>creator->name ?> (create) ?>)editor->name ?> (edit) ?>) + $file->file_id, 's' => $pagination['start']])?>"> + $file->id, 's' => $pagination['start']])?>"> + $file->id, 's' => $pagination['start']])?>" onclick="if(!confirm('Person/Firma wirklich löschen?')) return false;" class="text-danger" title="Löschen"> +
+ + + + + +
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/Layout/default/Pop/Form.php b/Layout/default/Pop/Form.php index 6194c56a0..751c6b2e2 100644 --- a/Layout/default/Pop/Form.php +++ b/Layout/default/Pop/Form.php @@ -1,150 +1,172 @@ - +
-
-
-
- -
-

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

+
+
+
+ +
+

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

+
-
- -
-
- -
-
-

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

- -
"> -
-
- - - -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- -
-
-

Access VLANs

-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- -
+
+
+ +
-
- -
- -
-
+

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

+ + $_GET["returnto"]]) ?>"> +
+
+ + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+

Access VLANs

+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+ + +
-
- -
- -
- -
-
- - - - -
+
+
- -
- + + + \ No newline at end of file diff --git a/Layout/default/Pop/Index.php b/Layout/default/Pop/Index.php new file mode 100644 index 000000000..22163042c --- /dev/null +++ b/Layout/default/Pop/Index.php @@ -0,0 +1,249 @@ +getUrl($Mod, "Index"); +$pagination_baseurl_params = ["filter" => $filter]; +$pagination_entity_name = "Pops"; +?> + + + + +
+
+
+
+ +
+

Pops

+
+
+
+ + + +
+
+
+
+
+

Liste aller Pops

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameNetgebietZutrittVlan Public/NatKoordinaten
name ?>network->name ?>location ?>vlan_public ?> / vlan_nat ?>gps_lat,'0') ?> , gps_long,0) ?> + $pop->id, 'returnto' => "pop"])?>"> + " class="text-danger" title="Löschen"> +
+ + + + + +
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/Layout/default/menu.php b/Layout/default/menu.php index 6ae37c0d9..cd8a3168d 100644 --- a/Layout/default/menu.php +++ b/Layout/default/menu.php @@ -35,6 +35,7 @@
  • "> Technologien
  • "> Benutzer
  • "> Netzgebiete
  • +
  • "> Pops
  • @@ -50,6 +51,7 @@ is(["Admin","netowner","pipeplanner","pipeworker","lineplanner","lineworker"])): ?>
  • "> Tiefbau
  • is(["Admin","netowner","lineplanner","lineworker"])): ?>
  • "> Leitungsbau
  • is(["Admin", "netowner", "netoperator", "lineworker"])): ?>
  • "> Patchungen
  • + is(["Admin", "netowner","pipeplanner","lineplanner","pipeworker", "netoperator", "lineworker"])): ?>
  • "> Dateiablage
  • diff --git a/application/Filestore/Filestore.php b/application/Filestore/Filestore.php new file mode 100644 index 000000000..2d794e1d6 --- /dev/null +++ b/application/Filestore/Filestore.php @@ -0,0 +1,46 @@ +$name == null) { + + if(!$this->id) { + return null; + } + + if($name == "creator") { + $this->creator = new User($this->create_by); + return $this->creator; + } + + if($name == "editor") { + $this->editor = new User($this->edit_by); + return $this->editor; + } + if($name == "histories") { + $this->histories=FilestoreHistoryModel::search(["filestore_id="=>$this->id]); + return $this->histories; + } + + $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; + } + + +} \ No newline at end of file diff --git a/application/Filestore/FilestoreController.php b/application/Filestore/FilestoreController.php new file mode 100644 index 000000000..ba33a710f --- /dev/null +++ b/application/Filestore/FilestoreController.php @@ -0,0 +1,197 @@ +needlogin = true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me", $me); + + if (!$me->is(["Admin", "netowner", "pipeplanner", "lineplanner", "pipeworker", "netoperator", "lineworker"])) { + $this->redirect("Dashboard"); + } + } + + protected function indexAction() + { + $this->layout()->setTemplate("Filestore/Index"); + $files = FilestoreModel::getAll(); + + + + // pagination defaults + $pagination = []; + $pagination['start'] = 0; + $pagination['count'] = 25; + $pagination['maxItems'] = 0; + if(is_numeric($this->request->s)) { + $pagination['start'] = intval($this->request->s); + } + $pagination['maxItems'] = FilestoreModel::count(); + $this->layout()->set("files", $files); + $this->layout()->set("pagination", $pagination); + + + } + + protected function addAction() + { + $this->layout()->setTemplate("Filestore/Form"); + } + + protected function saveAction() + { + $r = $this->request; + $id = $r->id; + //var_dump($r->get());exit; + if (is_numeric($id) && $id > 0) { + $mode = "edit"; + $filestore = new Filestore($id); + if (!$filestore->id) { + $this->layout()->setFlash("Datei nicht gefunden", "error"); + $this->redirect("Filestore"); + } + + $dataHistory = []; + $dataHistory['name'] = $filestore->name; + $dataHistory['description'] = $filestore->description; + $dataHistory['file_id'] = $filestore->file_id; + $dataHistory['filestore_id'] = $filestore->id; + $dataHistory['create'] = $filestore->create; + $dataHistory['create_by'] = $filestore->create_by; + $dataHistory['edit'] = date("U"); + } else { + $mode = "add"; + } + + $data = []; + $data['name'] = trim($r->name); + $data['description'] = trim($r->description); + + if (!$data['name']) { + $this->layout()->setFlash("Name darf nicht leer sein", "error"); + $this->redirect("Filestore"); + } + + if (array_key_exists("filestore", $_FILES) && !$_FILES['filestore']['error']) { + $upload_error = false; + + //var_dump($_FILES);exit; + $upload = new mfUpload("filestore"); + $upload->setSavepath(MFUPLOAD_FILE_SAVE_PATH . "/netzbetrieb"); + + if (!$upload->getSize()) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen: Dokument darf nicht leer sein!", "error"); + $this->redirect("Filestore"); + } + if (substr(strtolower($upload->getFilename()), -3, 3) == "pdf" && !$upload->validatePDF()) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen: PDF-Validierung fehlgeschlagen!", "error"); + $this->redirect("Filestore"); + } + try { + $upload->save(); + } catch (Exception $e) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen1", "error"); + $this->redirect("Filestore"); + } + $file_data = []; + $file_data['name'] = $upload->getOriginalFilename(); + $file_data['filename'] = ($r->file_filename) ? $r->file_filename : $upload->getOriginalFilename(); + $file_data['subfolder'] = "netzbetrieb"; + $file_data['store_filename'] = $upload->getFilename(); + $file_data['orig_filename'] = $upload->getOriginalFilename(); + + + $file = FileModel::create($file_data); + $file_id = $file->save(); + if (!$file_id) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen3", "error"); + $this->redirect("Filestore"); + } + $data['file_id'] = $file_id; + + if ($mode == "edit") { + + $fsh = FilestoreHistoryModel::create($dataHistory); + } + } else { + if ($mode == "add") { + $this->layout()->setFlash("Keine Datei angegeben", "error"); + $this->redirect("Filestore", "add"); + } + + } + +// var_dump($_FILES); +// var_dump($upload); +// exit; + + + if ($mode == "edit") { + $filestore->update($data); + + } else { + $filestore = FilestoreModel::create($data); + } +// var_dump($filestore); +// exit; + $id = $filestore->save(); + + if (!$id) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen33", "error"); + $this->redirect("Filestore"); + } + if ($fsh) { + $fsh->save(); + } + $this->layout()->setFlash("Dateiupload erfolgreich hochgeladen", "success"); + $this->redirect("Filestore"); + } + + protected function editAction() + { + $r = $this->request; + $id = $r->id; + //var_dump($r->get());exit; + if (!is_numeric($id) && $id < 1) { + + $this->layout()->setFlash("Datei nicht gefunden", "error"); + $this->redirect("Filestore"); + + } + $filestore = new Filestore($id); + + if (!$filestore->id) { + $this->layout()->setFlash("Datei nicht gefunden", "error"); + $this->redirect("Filestore"); + } + $this->layout()->set("file", $filestore); + + return $this->addAction(); + } + + protected function deleteAction() + { + $id = $this->request->id; + + + $filstore = new Filestore($id); + + if (!$filstore->id || $filstore->id != $id) { + $this->layout()->setFlash("Datei nicht gefunden.", "error"); + $this->redirect("Filestore"); + } + foreach ($filstore->histories as $h) { + $h->file->delete(); + $h->delete(); + + } + $filstore->file->delete(); + // check if Product is unused + $filstore->delete(); + $this->redirect("Filestore"); + } +} \ No newline at end of file diff --git a/application/Filestore/FilestoreModel.php b/application/Filestore/FilestoreModel.php new file mode 100644 index 000000000..f11111366 --- /dev/null +++ b/application/Filestore/FilestoreModel.php @@ -0,0 +1,168 @@ + $value) { + if (property_exists(get_called_class(), $field)) { + $model->$field = $value; + } + } + + $me = new User(); + $me->loadMe(); + + if ($model->create_by === null) { + $model->create_by = $me->id; + } + if ($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + public static function getOne($id) + { + if (!is_numeric($id) || !$id) { + throw new Exception("Invalid number", 400); + } + $item = []; + $db = FronkDB::singleton(); + + $res = $db->select("Filestore", "*", "id=$id LIMIT 1"); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Filestore($data); + } + return $item; + } + + public static function getAll() + { + $items = []; + + $db = FronkDB::singleton(); + $sql = "SELECT Filestore.* FROM Filestore + LEFT JOIN File ON (Filestore.file_id = File.id) + ORDER BY name"; + $res = $db->query($sql); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new Filestore($data); + } + } + return $items; + + } + + public static function getFirst() + { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("Filestore", "*", "$where ORDER BY name, filename"); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Filestore($data); + if ($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + public static function count() { + $db = FronkDB::singleton(); + + + $sql = " + SELECT count(Filestore.id) as cnt + FROM Filestore + "; + //mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + return $data->cnt; + } + return 0; + } + + public static function search($filter) + { + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + + $sql = "SELECT Filestore.* FROM Filestore + LEFT JOIN File ON (Filestore.file_id = File.id) + WHERE $where + ORDER BY name"; + + $res = $db->query($sql); + + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new Filestore($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) + { + $where = "1=1 "; + + + if (array_key_exists("file_id", $filter)) { + $file_id = $filter['file_id']; + if (is_numeric($file_id)) { + $where .= " AND file_id=$file_id"; + } + } + + //var_dump($filter);exit; + if (array_key_exists("name", $filter)) { + $name = FronkDB::singleton()->escape($filter['name']); + if ($name) { + $where .= " AND name='$name'"; + } + } + + if (array_key_exists("filename", $filter)) { + $filename = FronkDB::singleton()->escape($filter['filename']); + if ($filename) { + $where .= " AND File.filename='$filename'"; + } + } + + if (array_key_exists("subfolder", $filter)) { + $subfolder = FronkDB::singleton()->escape($filter['subfolder']); + if ($subfolder) { + $where .= " AND File.subfolder='$subfolder'"; + } + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/application/FilestoreHistory/FilestoreHistory.php b/application/FilestoreHistory/FilestoreHistory.php new file mode 100644 index 000000000..bd480e956 --- /dev/null +++ b/application/FilestoreHistory/FilestoreHistory.php @@ -0,0 +1,41 @@ +$name == null) { + + if(!$this->id) { + return null; + } + + if($name == "creator") { + $this->creator = new User($this->create_by); + return $this->creator; + } + + if($name == "editor") { + $this->editor = new User($this->edit_by); + return $this->editor; + } + + $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; + } + + +} \ No newline at end of file diff --git a/application/FilestoreHistory/FilestoreHistoryController.php b/application/FilestoreHistory/FilestoreHistoryController.php new file mode 100644 index 000000000..7b0301c4d --- /dev/null +++ b/application/FilestoreHistory/FilestoreHistoryController.php @@ -0,0 +1,151 @@ +needlogin = true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me", $me); + + if (!$me->is(["Admin", "netowner", "pipeplanner", "lineplanner", "pipeworker", "netoperator", "lineworker"])) { + $this->redirect("Dashboard"); + } + } + + protected function indexAction() + { + $this->layout()->setTemplate("Filestore/Index"); + $files = FilestoreModel::getAll(); + $this->layout()->set("files", $files); + } + + protected function addAction() + { + $this->layout()->setTemplate("Filestore/Form"); + } + + protected function saveAction() + { + $r = $this->request; + $id = $r->id; + //var_dump($r->get());exit; + if (is_numeric($id) && $id > 0) { + $mode = "edit"; + $filestore = new Filestore($id); + if (!$filestore->id) { + $this->layout()->setFlash("Datei nicht gefunden", "error"); + $this->redirect("Filestore"); + } + + $dataHistory = []; + $dataHistory['name'] = $filestore->name; + $dataHistory['description'] = $filestore->description; + $dataHistory['file_id'] = $filestore->file_id; + $dataHistory['create'] = $filestore->create; + $dataHistory['create_by'] = $filestore->create_by; + $dataHistory['edit'] = date("U"); + } else { + $mode = "add"; + } + + $data = []; + $data['name'] = trim($r->name); + $data['description'] = trim($r->description); + + if (!$data['name']) { + $this->layout()->setFlash("Name darf nicht leer sein", "error"); + $this->redirect("Filestore"); + } + + if (array_key_exists("filestore", $_FILES) && !$_FILES['filestore']['error']) { + $upload_error = false; + + //var_dump($_FILES);exit; + $upload = new mfUpload("filestore"); + $upload->setSavepath(MFUPLOAD_FILE_SAVE_PATH . "/netzbetrieb"); + + if (!$upload->getSize()) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen: Dokument darf nicht leer sein!", "error"); + $this->redirect("Filestore"); + } + if (substr(strtolower($upload->getFilename()), -3, 3) == "pdf" && !$upload->validatePDF()) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen: PDF-Validierung fehlgeschlagen!", "error"); + $this->redirect("Filestore"); + } + try { + $upload->save(); + } catch (Exception $e) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen", "error"); + $this->redirect("Filestore"); + } + $file_data = []; + $file_data['name'] = $upload->getOriginalFilename(); + $file_data['filename'] = ($r->file_filename) ? $r->file_filename : $upload->getOriginalFilename(); + $file_data['subfolder'] = "netzbetrieb"; + $file_data['store_filename'] = $upload->getFilename(); + $file_data['orig_filename'] = $upload->getOriginalFilename(); + + + $file = FileModel::create($file_data); + $file_id = $file->save(); + if (!$file_id) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen", "error"); + $this->redirect("Filestore"); + } + $data['file_id'] = $file_id; + $filestore = FilestoreHistoryModel::create($dataHistory); + } else { + if ($mode == "add") { + $this->layout()->setFlash("Keine Datei angegeben", "error"); + $this->redirect("Filestore", "add"); + } + + } + +// var_dump($_FILES); +// var_dump($upload); +// exit; + + + if ($mode == "edit") { + $filestore->update($data); + + } else { + $filestore = FilestoreModel::create($data); + } + $id = $filestore->save(); + + if (!$id) { + $this->layout()->setFlash("Dateiupload fehlgeschlagen", "error"); + $this->redirect("Filestore"); + } + $this->layout()->setFlash("Dateiupload erfolgreich hochgeladen", "success"); + $this->redirect("Filestore"); + } + + protected function editAction() + { + $r = $this->request; + $id = $r->id; + //var_dump($r->get());exit; + if (!is_numeric($id) && $id < 1) { + + $this->layout()->setFlash("Datei nicht gefunden", "error"); + $this->redirect("Filestore"); + + } + $filestore = new Filestore($id); + + if (!$filestore->id) { + $this->layout()->setFlash("Datei nicht gefunden", "error"); + $this->redirect("Filestore"); + } + $this->layout()->set("file", $filestore); + + return $this->addAction(); + } + +} \ No newline at end of file diff --git a/application/FilestoreHistory/FilestoreHistoryModel.php b/application/FilestoreHistory/FilestoreHistoryModel.php new file mode 100644 index 000000000..3faae0e21 --- /dev/null +++ b/application/FilestoreHistory/FilestoreHistoryModel.php @@ -0,0 +1,157 @@ + $value) { + if (property_exists(get_called_class(), $field)) { + $model->$field = $value; + } + } + + $me = new User(); + $me->loadMe(); + + if ($model->create_by === null) { + $model->create_by = $me->id; + } + if ($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + public static function getOne($id) + { + if (!is_numeric($id) || !$id) { + throw new Exception("Invalid number", 400); + } + $item = []; + $db = FronkDB::singleton(); + + $res = $db->select("FilestoreHistory", "*", "id=$id LIMIT 1"); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new FilestoreHistory($data); + } + return $item; + } + + public static function getAll() + { + $items = []; + + $db = FronkDB::singleton(); + $sql = "SELECT FilestoreHistory.* FROM FilestoreHistory + LEFT JOIN File ON (FilestoreHistory.file_id = File.id) + ORDER BY name"; + $res = $db->query($sql); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new FilestoreHistory($data); + } + } + return $items; + + } + + public static function getFirst() + { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("FilestoreHistory", "*", "$where ORDER BY name, filename"); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new FilestoreHistory($data); + if ($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function search($filter) + { + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + + $sql = "SELECT FilestoreHistory.* FROM FilestoreHistory + LEFT JOIN File ON (FilestoreHistory.file_id = File.id) + WHERE $where + ORDER BY name"; + + $res = $db->query($sql); + + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new FilestoreHistory($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) + { + $where = "1=1 "; + + + if (array_key_exists("file_id", $filter)) { + $file_id = $filter['file_id']; + if (is_numeric($file_id)) { + $where .= " AND file_id=$file_id"; + } + } + if (array_key_exists("filestore_id", $filter)) { + $filestore_id = $filter['filestore_id']; + if (is_numeric($filestore_id)) { + $where .= " AND filestore_id=$filestore_id"; + } + } + + //var_dump($filter);exit; + if (array_key_exists("name", $filter)) { + $name = FronkDB::singleton()->escape($filter['name']); + if ($name) { + $where .= " AND name='$name'"; + } + } + + if (array_key_exists("filename", $filter)) { + $filename = FronkDB::singleton()->escape($filter['filename']); + if ($filename) { + $where .= " AND File.filename='$filename'"; + } + } + + if (array_key_exists("subfolder", $filter)) { + $subfolder = FronkDB::singleton()->escape($filter['subfolder']); + if ($subfolder) { + $where .= " AND File.subfolder='$subfolder'"; + } + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/application/Pop/PopController.php b/application/Pop/PopController.php index fa014c605..b320e724d 100644 --- a/application/Pop/PopController.php +++ b/application/Pop/PopController.php @@ -1,144 +1,179 @@ needlogin=true; - $me = new User(); - $me->loadMe(); - $this->me = $me; - $this->layout()->set("me",$me); - - if(!$me->is(["Admin", "netowner", "pipeplanner"])) { - $this->redirect("Dashboard"); - } - } +class PopController extends mfBaseController +{ + private $returUrl = "Network"; - 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 init() + { + $this->needlogin = true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me", $me); + + if (!$me->is(["Admin", "netowner", "pipeplanner"])) { + $this->redirect("Dashboard"); + } } - } - - protected function editAction() { - $id = $this->request->id; - if(!is_numeric($id) || !$id) { - $this->layout()->setFlash("POP nicht gefunden", "error"); - $this->redirect("Network"); + + protected function indexAction() + { + + $this->layout()->setTemplate("Pop/Index"); + $pops = PopModel::getAll(); + $this->layout()->set("pops", $pops); + } - - $pop = new Pop($id); - if($pop->id != $id) { - $this->layout()->setFlash("POP nicht gefunden", "error"); - $this->redirect("Network"); + + 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); + } } - - $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"; + + 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(); } - - //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(); + + 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; + $this->log->debug(print_r($r, true)); + 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) ? $r->gps_lat : null; + $data['gps_long'] = ($r->gps_long) ? $r->gps_long : null; + $data['location'] = $r->location; + $data['vlan_public'] = ($r->vlan_public) ? $r->vlan_public : null; + $data['vlan_nat'] = ($r->vlan_nat) ? $r->vlan_nat : null; + $data['vlan_ipv6'] = ($r->vlan_ipv6) ? $r->vlan_ipv6 : null; + $data['note'] = $r->note; + + $data['edit_by'] = 1; + + if ($mode == "add") { + $data['create_by'] = 1; + $pop = PopModel::create($data); + } else { + $pop->update($data); + } + + + $new_id = $pop->save(); + if (!$new_id) { + $this->layout()->setFlash("Fehler beim Speichern", "error"); + $this->layout()->set("network", $network); + return $this->addAction(); + } + if ($this->request->returnto) { + $this->returUrl = ucfirst($this->request->returnto); + } + + $this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success"); + $this->redirect($this->returUrl, "Index", [], "view=pops&net=" . $pop->network_id); + + } - - $data = []; - $data['network_id'] = $r->network_id; - $data['name'] = $r->name; - $data['gps_lat'] = ($r->gps_lat) ? $r->gps_lat : null; - $data['gps_long'] = ($r->gps_long) ? $r->gps_long : null; - $data['location'] = $r->location; - $data['vlan_public'] = ($r->vlan_public) ? $r->vlan_public : null; - $data['vlan_nat'] = ($r->vlan_nat) ? $r->vlan_nat: null; - $data['vlan_ipv6'] = ($r->vlan_ipv6) ? $r->vlan_ipv6: null; - $data['note'] = $r->note; - - $data['edit_by'] = 1; - - if($mode == "add") { - $data['create_by'] = 1; - $pop = PopModel::create($data); - } else { - $pop->update($data); + + protected function apiAction() + { + $do = $this->request->do; + $data = []; + + switch ($do) { + case "getPops": + $return = $this->getPopsApi(); + break; + default: + $return = false; + } + + if (!is_array($return) || !count($return)) { + $data = ["status" => "error"]; + $this->returnJson($data); + } + $data['status'] = "OK"; + $data['result'] = $return; + $this->returnJson($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(); + + private function getPopsApi() + { + $network_id = $this->request->network_id; + if (!is_numeric($network_id) || $network_id < 1) { + return false; + } + + $network = new Network($network_id); + if (!$network->id) { + return false; + } + + $pops = []; + foreach ($network->pops as $pop) { + $pops[$pop->id] = $pop->name; + } + + return ["pops" => $pops]; } - - $this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success"); - $this->redirect("Network", "Index", [], "view=pops&net=".$pop->network_id); - } - - protected function apiAction() { - $do = $this->request->do; - $data = []; - - switch($do) { - case "getPops": - $return = $this->getPopsApi(); - break; - default: - $return = false; + + + protected function deleteAction() + { + $id = $this->request->id; + + + $pop = new Pop($id); + + if (!$pop->id || $pop->id != $id) { + $this->layout()->setFlash("Datei nicht gefunden.", "error"); + $this->redirect("Pop"); + } + + $pop->delete(); + $this->redirect("Pop"); } - - if(!is_array($return) || !count($return)) { - $data = ["status" => "error"]; - $this->returnJson($data); - } - $data['status'] = "OK"; - $data['result'] = $return; - $this->returnJson($data); - } - - private function getPopsApi() { - $network_id = $this->request->network_id; - if(!is_numeric($network_id) || $network_id < 1) { - return false; - } - - $network = new Network($network_id); - if(!$network->id) { - return false; - } - - $pops = []; - foreach($network->pops as $pop) { - $pops[$pop->id] = $pop->name; - } - - return ["pops" => $pops]; - } } \ No newline at end of file From cf92596ebffb26ec6f31c08ff8f4fe01b1e13396 Mon Sep 17 00:00:00 2001 From: Spitzer_Daniel Date: Thu, 16 Feb 2023 15:44:19 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Features=20Netzbau->=20Dateiablage=20und=20?= =?UTF-8?q?Stammdaten->Pops=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + Layout/default/Device/Detail.php | 182 +++++++++++++++ Layout/default/Device/Form.php | 133 +++++++++++ Layout/default/Device/Index.php | 220 ++++++++++++++++++ Layout/default/Devicemanufactor/Form.php | 84 +++++++ Layout/default/Devicemanufactor/Index.php | 186 +++++++++++++++ Layout/default/Devicetype/Form.php | 112 +++++++++ Layout/default/Devicetype/Index.php | 202 ++++++++++++++++ Layout/default/Pop/Detail.php | 182 +++++++++++++++ Layout/default/Pop/Index.php | 137 ++++++++++- Layout/default/header.php | 3 + Layout/default/menu.php | 21 +- application/Api/v1/AddressdbApicontroller.php | 2 +- application/Device/Device.php | 41 ++++ application/Device/DeviceController.php | 149 ++++++++++++ application/Device/DeviceModel.php | 128 ++++++++++ .../Devicemanufactor/Devicemanufactor.php | 39 ++++ .../DevicemanufactorController.php | 122 ++++++++++ .../DevicemanufactorModel.php | 122 ++++++++++ application/Devicetype/Devicetype.php | 41 ++++ .../Devicetype/DevicetypeController.php | 138 +++++++++++ application/Devicetype/DevicetypeModel.php | 125 ++++++++++ application/Pop/PopController.php | 21 ++ application/Pop/PopModel.php | 2 +- 24 files changed, 2371 insertions(+), 23 deletions(-) create mode 100644 Layout/default/Device/Detail.php create mode 100644 Layout/default/Device/Form.php create mode 100644 Layout/default/Device/Index.php create mode 100644 Layout/default/Devicemanufactor/Form.php create mode 100644 Layout/default/Devicemanufactor/Index.php create mode 100644 Layout/default/Devicetype/Form.php create mode 100644 Layout/default/Devicetype/Index.php create mode 100644 Layout/default/Pop/Detail.php create mode 100644 application/Device/Device.php create mode 100644 application/Device/DeviceController.php create mode 100644 application/Device/DeviceModel.php create mode 100644 application/Devicemanufactor/Devicemanufactor.php create mode 100644 application/Devicemanufactor/DevicemanufactorController.php create mode 100644 application/Devicemanufactor/DevicemanufactorModel.php create mode 100644 application/Devicetype/Devicetype.php create mode 100644 application/Devicetype/DevicetypeController.php create mode 100644 application/Devicetype/DevicetypeModel.php diff --git a/.gitignore b/.gitignore index 1d22cf262..857b1be46 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,5 @@ Thumbs.db *.bak *.swp +/Layout/default/DeviceDetail/ +/Layout/default/DeviceDetail/ diff --git a/Layout/default/Device/Detail.php b/Layout/default/Device/Detail.php new file mode 100644 index 000000000..3a075c56d --- /dev/null +++ b/Layout/default/Device/Detail.php @@ -0,0 +1,182 @@ + + + + + +
    +
    +
    +
    + +
    +

    Device data->name ?> + $devices->id]) ?>"> + + +

    +
    +
    +
    + +price)) { + $price = $devices->price; +} else { + $price = $devices->devicetype->price; +} +?> +
    +
    +
    +
    +
    +
    +
    +

    Allgemeine Informationen

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Device Namename ?>
    IP-Adresseip ?>
    Geräte Typdevicetype->name ?>
    Geräte Herstellerdevicetype->devicemanufactor->name ?>
    Mac Adressemac ?>
    Seriennummerserial ?>
    Preis
    Bemerkungcomment) ?>
    +
    + + +
    +
    +
    +

    Standort Informationen

    +
    + pop->name))) { + ?> +
    + + + + + + + + + + + + +
    Pop Namepop->name ?>
    Adresse + pop->gps_lat, '0') ?> + , pop->gps_long, 0) ?>
    +
    + +
    Keine Standort Informationen vorhanden
    + + + + +
    +
    +
    +

    Config Backups

    +
    + +
    + + + + + + + + + + + + + +
    Datum/Uhrzeit
    +
    + +
    Keine Configs vorhanden
    + + +
    +
    + +
    + +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/Layout/default/Device/Form.php b/Layout/default/Device/Form.php new file mode 100644 index 000000000..fb445a375 --- /dev/null +++ b/Layout/default/Device/Form.php @@ -0,0 +1,133 @@ + + + +
    +
    +
    +
    + +
    +

    Geräte

    +
    +
    +
    + + +
    +
    + +
    +
    +

    id) ? "Device bearbeiten" : "Neues Gerät" ?>

    + +
    "> +
    +
    + + + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    + + +
    + +
    + +
    +
    + + +
    +
    +
    + +
    +
    + + + + \ No newline at end of file diff --git a/Layout/default/Device/Index.php b/Layout/default/Device/Index.php new file mode 100644 index 000000000..93ef0c177 --- /dev/null +++ b/Layout/default/Device/Index.php @@ -0,0 +1,220 @@ +getUrl($Mod, "Index"); +$pagination_baseurl_params = ["filter" => $filter]; +$pagination_entity_name = "Device"; +?> + + + + +
    +
    +
    +
    + +
    +

    Devices

    +
    +
    +
    + + + +
    +
    +
    +
    +
    +

    Liste aller Devices

    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + price)) { + $price = $device->price; + } else { + $price = $device->devicetype->price; + } + ?> + + + + + + + + + + + + + + + + + + + + + +
    Geräte NameGeräte TypHerstellerPopIP-AdresseMac-AdresseSeriennummerPreismax. Leistung
    + $device->id]) ?>">name ?> + devicetype->name ?>devicetype->devicemanufactor->name ?>pop->name ?>ip ?>mac ?>serial ?>devicetype->power ?> Watt + $device->id]) ?>"> + $device->id]) ?>" + onclick="if(!confirm('Device wirklich löschen?')) return false;" class="text-danger" + title="Löschen"> + +
    + + + + + +
    +
    + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/Devicemanufactor/Form.php b/Layout/default/Devicemanufactor/Form.php new file mode 100644 index 000000000..a524cc9fc --- /dev/null +++ b/Layout/default/Devicemanufactor/Form.php @@ -0,0 +1,84 @@ + + + +
    +
    +
    +
    + +
    +

    id) ? "Gerätehersteller bearbeiten" : "Neuer Gerätehersteller" ?>

    +
    +
    +
    + + +
    +
    + +
    +
    +

    id) ? "Gerätehersteller bearbeiten" : "Neuer Gerätehersteller" ?>

    + +
    "> +
    +
    + + + + +
    + +
    + +
    +
    + + +
    +
    + + +
    + +
    + +
    +
    + + +
    +
    +
    + +
    +
    + + + + \ No newline at end of file diff --git a/Layout/default/Devicemanufactor/Index.php b/Layout/default/Devicemanufactor/Index.php new file mode 100644 index 000000000..2eb12c5f3 --- /dev/null +++ b/Layout/default/Devicemanufactor/Index.php @@ -0,0 +1,186 @@ +getUrl($Mod, "Index"); +$pagination_baseurl_params = ["filter" => $filter]; +$pagination_entity_name = "Devicemanufactor"; +?> + + + + + +
    +
    +
    +
    + +
    +

    Gerätehersteller

    +
    +
    +
    + + + +
    +
    +
    +
    +
    +

    Liste aller Gerätehersteller

    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameErstellt von
    name ?>creator->name ?> + (create) ?>) + + $devicemanufactor->id]) ?>"> + $devicemanufactor->id]) ?>" + onclick="if(!confirm('Gerätehersteller wirklich löschen?')) return false;" + class="text-danger" title="Löschen"> +
    +
    +
    + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/Devicetype/Form.php b/Layout/default/Devicetype/Form.php new file mode 100644 index 000000000..a0924f17f --- /dev/null +++ b/Layout/default/Devicetype/Form.php @@ -0,0 +1,112 @@ + + + +
    +
    +
    +
    + +
    +

    id) ? "Gerätetyp bearbeiten" : "Neuer Gerätetyp" ?>

    +
    +
    +
    + + +
    +
    + +
    +
    +

    id) ? "Gerätetyp bearbeiten" : "Neuer Gerätetyp" ?>

    + +
    "> +
    +
    + + + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    + + + +
    +
    + + +
    + +
    + +
    +
    + + +
    +
    +
    + +
    +
    + + + + \ No newline at end of file diff --git a/Layout/default/Devicetype/Index.php b/Layout/default/Devicetype/Index.php new file mode 100644 index 000000000..7830f643d --- /dev/null +++ b/Layout/default/Devicetype/Index.php @@ -0,0 +1,202 @@ +getUrl($Mod, "Index"); +$pagination_baseurl_params = ["filter" => $filter]; +$pagination_entity_name = "Devicetype"; +?> + + + + + +
    +
    +
    +
    + +
    +

    Gerätetyp

    +
    +
    +
    + + + +
    +
    +
    +
    +
    +

    Liste aller Gerätetypen

    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameHerstellerPreismax. Leistungerstellt von
    NameHerstellerPreis
    name ?>devicemanufactor->name ?>price ?> €power ?> Wattcreator->name ?> + (create) ?>) + + $devicetype->id]) ?>"> + $devicetype->id]) ?>" + onclick="if(!confirm('Gerätetyp wirklich löschen?')) return false;" class="text-danger" + title="Löschen"> +
    + + + + + +
    +
    + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/Pop/Detail.php b/Layout/default/Pop/Detail.php new file mode 100644 index 000000000..3a075c56d --- /dev/null +++ b/Layout/default/Pop/Detail.php @@ -0,0 +1,182 @@ + + + + + +
    +
    +
    +
    + +
    +

    Device data->name ?> + $devices->id]) ?>"> + + +

    +
    +
    +
    + +price)) { + $price = $devices->price; +} else { + $price = $devices->devicetype->price; +} +?> +
    +
    +
    +
    +
    +
    +
    +

    Allgemeine Informationen

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Device Namename ?>
    IP-Adresseip ?>
    Geräte Typdevicetype->name ?>
    Geräte Herstellerdevicetype->devicemanufactor->name ?>
    Mac Adressemac ?>
    Seriennummerserial ?>
    Preis
    Bemerkungcomment) ?>
    +
    + + +
    +
    +
    +

    Standort Informationen

    +
    + pop->name))) { + ?> +
    + + + + + + + + + + + + +
    Pop Namepop->name ?>
    Adresse + pop->gps_lat, '0') ?> + , pop->gps_long, 0) ?>
    +
    + +
    Keine Standort Informationen vorhanden
    + + + + +
    +
    +
    +

    Config Backups

    +
    + +
    + + + + + + + + + + + + + +
    Datum/Uhrzeit
    +
    + +
    Keine Configs vorhanden
    + + +
    +
    + +
    + +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/Layout/default/Pop/Index.php b/Layout/default/Pop/Index.php index 22163042c..01b475c6f 100644 --- a/Layout/default/Pop/Index.php +++ b/Layout/default/Pop/Index.php @@ -6,6 +6,37 @@ $pagination_entity_name = "Pops"; +
    @@ -32,16 +63,17 @@ $pagination_entity_name = "Pops";

    Liste aller Pops

    - - + + - +
    + @@ -49,8 +81,19 @@ $pagination_entity_name = "Pops"; - + + + + + + + + + + + + @@ -58,20 +101,28 @@ $pagination_entity_name = "Pops"; - + +
    Name NetgebietVlan Public/Nat Koordinaten
    network->name ?> location ?> vlan_public ?> / vlan_nat ?>gps_lat,'0') ?> , gps_long,0) ?>gps_lat, '0') ?> + , gps_long, 0) ?> - $pop->id, 'returnto' => "pop"])?>"> - " class="text-danger" title="Löschen"> + $pop->id, 'returnto' => "pop"]) ?>"> + " class="text-danger" title="Löschen">
    - - - + + + @@ -243,6 +294,68 @@ $pagination_entity_name = "Pops"; //refreshMap(); + let table; + $('#filterrow th').each(function (i) { + let title = $('#datatable thead th').eq($(this).index()).text(); + + if ($(this).index() == "5") { + + } else { + $(this).html(''); + } + }); + + table = $('#datatable').DataTable({ + buttons: [ + { + extend: 'excelHtml5', + text: 'XLSX Export', + className: 'btn-success margina' + + } + ], + orderCellsTop: true, + stateSave: true, + "initComplete": function () { + $('#datatable_filter').append(''); + $('#clear_cookie').click(function () { + $('input').val(''); + + table.search('').columns().search('').draw(); + }); + }, + "dom": 'flBrtip' + + }); + + $('#filterrow').on('keyup', 'input', function () { + + table + .column($(this).data('index')) + .search(this.value) + .draw(); + + + }); + var state = table.state.loaded(); + if (state) { + table.columns().eq(0).each(function (colIdx) { + var colSearch = state.columns[colIdx].search; + + if (colSearch.search) { + + + $('#filterrow').find("[data-index='" + colIdx + "']").val(colSearch.search); + + + } + }); + + table.draw(); + } + $(document).ready(function () { + + }); diff --git a/Layout/default/header.php b/Layout/default/header.php index 2a268eb8a..a5645311a 100644 --- a/Layout/default/header.php +++ b/Layout/default/header.php @@ -19,6 +19,7 @@ + @@ -30,6 +31,8 @@ + +