datatables-std.css für Standard DT erstellt

datatables-std.js für Standard DT erstellt
zugewiesen an:
Device,Devicetype,Devicemanufactor,Pop,Filestore

Pop Detail Ansicht erstellt
Filestore auf DT umgebaut

Bugfixing:
* Bearbeiten aus verschiedenen Ansichten werden nun richtig zurückgeleitet (Devices/Pops)
* Sortierung Devicetype in Devices wurde nun per Arraysort durchgeführt
This commit is contained in:
Spitzer_Daniel
2023-02-20 22:15:36 +01:00
parent 2af021040f
commit 71d9675350
18 changed files with 427 additions and 538 deletions
+29 -4
View File
@@ -93,13 +93,11 @@ class DeviceController extends mfBaseController
$data = [];
$data['name'] = trim($r->name);
$data['devicetype_id'] = $r->devicetype_id;
if (empty(trim($r->pop_id))) {
if (trim($r->pop_id)=="0") {
$data['pop_id'] = NULL;
} else {
$data['pop_id'] = $r->pop_id;
}
$data['ip'] = $r->ip;
$data['mac'] = $r->mac;
$data['serial'] = $r->serial;
@@ -139,11 +137,38 @@ class DeviceController extends mfBaseController
$this->layout()->setFlash("Device konnte nicht angelegt werden", "error");
$this->redirect("Device");
}
$returnUrl="Device";
$returnAction = "Index";
$returnVariables = array();
$returnAnker = "";
if ($this->request->returnto) {
if (strpos($this->request->returnto, "-") !== false) {
$urls = explode('-', $this->request->returnto);
$urlCounter = 0;
$returnUrlGen = "";
foreach ($urls as $url) {
if ($urlCounter > 0) {
$returnUrlGen .= "/";
}
$returnUrlGen .= ucfirst($url);
$urlCounter++;
}
$returnAction = "";
$returnVariables['id'] = $id;
$returnUrl = $returnUrlGen;
} else {
$returnUrl = ucfirst($this->request->returnto);
}
}
if ($mode == "edit") {
$this->layout()->setFlash("Device erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Device erfolgreich angelegt", "success");
}
$this->redirect("Device");
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
}
+5 -6
View File
@@ -100,9 +100,8 @@ class DeviceModel
public static function search($filter) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Device", "*", "$where ORDER BY name, network_id");
$res = $db->select("Device", "*", "$where ORDER BY name");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Device($data);
@@ -115,10 +114,10 @@ class DeviceModel
$where = "1=1 ";
//var_dump($filter);exit;
if(array_key_exists("network_id", $filter)) {
$networkid = $filter['network_id'];
if(is_numeric($networkid)) {
$where .= " AND network_id=$networkid";
if(array_key_exists("pop_id", $filter)) {
$popid = $filter['pop_id'];
if(is_numeric($popid)) {
$where .= " AND pop_id=$popid";
}
}
@@ -60,7 +60,7 @@ class DevicetypeController extends mfBaseController
$mode = "edit";
$devicetype = new Devicetype($id);
if (!$devicetype->id) {
$this->layout()->setFlash("Gerätehersteller nicht gefunden", "error");
$this->layout()->setFlash("Gerätetyp nicht gefunden", "error");
$this->redirect("Devicetype");
}
} else {
@@ -109,14 +109,14 @@ class DevicetypeController extends mfBaseController
$id = $devicetype->save();
if (!$id) {
$this->layout()->setFlash("Gerätehersteller konnte nicht angelegt werden", "error");
$this->layout()->setFlash("Gerätetyp konnte nicht angelegt werden", "error");
$this->redirect("Devicetype");
}
if ($mode == "edit") {
$this->layout()->setFlash("Gerätehersteller erfolgreich geändert", "success");
$this->layout()->setFlash("Gerätetyp erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Gerätehersteller erfolgreich angelegt", "success");
$this->layout()->setFlash("Gerätetyp erfolgreich angelegt", "success");
}
$this->redirect("Devicetype");
}
@@ -127,7 +127,7 @@ class DevicetypeController extends mfBaseController
$id = $this->request->id;
$devicetype = new Devicetype($id);
if (!$devicetype->id || $devicetype->id != $id) {
$this->layout()->setFlash("Gerätehersteller nicht gefunden.", "error");
$this->layout()->setFlash("Gerätetyp nicht gefunden.", "error");
$this->redirect("Devicetype");
}
+33 -25
View File
@@ -1,6 +1,7 @@
<?php
class DevicetypeModel {
class DevicetypeModel
{
public $name = null;
public $power = null;
public $price = null;
@@ -12,16 +13,18 @@ class DevicetypeModel {
public $create = null;
public $edit = null;
public static function find($data) {
public static function find($data)
{
}
public static function create(Array $data) {
public static function create(array $data)
{
$model = new Devicetype();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
if(substr($field, 0, 5) == "vlan_" && !$value) {
foreach ($data as $field => $value) {
if (property_exists(get_called_class(), $field)) {
if (substr($field, 0, 5) == "vlan_" && !$value) {
$model->$field = null;
continue;
}
@@ -30,45 +33,47 @@ class DevicetypeModel {
}
$me = mfValuecache::singleton()->get("me");
if(!$me) {
if (!$me) {
$me = new User();
$me->loadMe();
mfValuecache::singleton()->set("me", $me);
}
if($model->create_by === null) {
if ($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
if ($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id) {
if(!is_numeric($id) || !$id) {
public static function getOne($id)
{
if (!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("Devicetype", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) {
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Devicetype($data);
}
return $item;
}
public static function getAll() {
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Devicetype", "*");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$res = $db->select("Devicetype", "*", "1=1 ORDER BY name");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Devicetype($data);
}
}
@@ -76,15 +81,16 @@ class DevicetypeModel {
}
public static function getFirst() {
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Devicetype", "*", "$where ORDER BY name, network_id");
if($db->num_rows($res)) {
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Devicetype($data);
if($item->id) {
if ($item->id) {
return $item;
} else {
return null;
@@ -93,27 +99,29 @@ class DevicetypeModel {
return null;
}
public static function search($filter) {
public static function search($filter)
{
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Devicetype", "*", "$where ORDER BY name, network_id");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Devicetype($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if(array_key_exists("network_id", $filter)) {
if (array_key_exists("network_id", $filter)) {
$networkid = $filter['network_id'];
if(is_numeric($networkid)) {
if (is_numeric($networkid)) {
$where .= " AND network_id=$networkid";
}
}
+31 -4
View File
@@ -35,13 +35,15 @@ class PopController extends mfBaseController
$this->redirect("Pop");
}
$device = new Device($id);
if ($device->id != $id) {
$pop = new Pop($id);
if ($pop->id != $id) {
$this->layout()->setFlash("Pop nicht gefunden", "error");
$this->redirect("Pop");
}
$this->layout()->setTemplate("Pop/Detail");
$filter['pop_id'] = $id;
$this->layout()->set("devices", DeviceModel::search($filter));
$pops = PopModel::getOne($id);
$this->layout()->set("pops", $pops);
@@ -130,11 +132,36 @@ class PopController extends mfBaseController
return $this->addAction();
}
if ($this->request->returnto) {
$this->returUrl = ucfirst($this->request->returnto);
$returnAction = "Index";
$returnVariables = array();
$returnAnker = "";
if (strpos($this->request->returnto, "-") !== false) {
$urls = explode('-', $this->request->returnto);
$urlCounter = 0;
$returnUrl = "";
foreach ($urls as $url) {
if ($urlCounter > 0) {
$returnUrl .= "/";
}
$returnUrl .= ucfirst($url);
$urlCounter++;
}
$returnAction = "";
$returnVariables['id'] = $id;
$this->returUrl = $returnUrl;
var_dump($returnUrl);
} else {
$this->returUrl = ucfirst($this->request->returnto);
}
} else {
$returnAnker = "view=pops&net=" . $pop->network_id;
}
$this->layout()->setFlash("Pop erfolgreich gespeichert.", "success");
$this->redirect($this->returUrl, "Index", [], "view=pops&net=" . $pop->network_id);
$this->redirect($this->returUrl, $returnAction, $returnVariables, $returnAnker);
}