From f3380a771cffc56bfa5be9566456945869a32da5 Mon Sep 17 00:00:00 2001 From: Spitzer_Daniel Date: Wed, 22 Mar 2023 16:24:42 +0100 Subject: [PATCH 1/3] Remerge --- Layout/default/Device/Detail.php | 2 +- Layout/default/Device/Form.php | 2 +- Layout/default/Device/Index.php | 4 ++-- Layout/default/Devicemanufactor/Index.php | 4 ++-- Layout/default/Devicetype/Form.php | 2 +- Layout/default/Devicetype/Index.php | 4 ++-- application/Device/Device.php | 1 - application/Device/DeviceController.php | 1 - application/Device/DeviceModel.php | 1 - 9 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Layout/default/Device/Detail.php b/Layout/default/Device/Detail.php index 98eb19cfa..3ee27f889 100644 --- a/Layout/default/Device/Detail.php +++ b/Layout/default/Device/Detail.php @@ -2,7 +2,7 @@ ?> - + @@ -135,7 +135,7 @@ $pagination_entity_name = "Device"; }); - + \ No newline at end of file diff --git a/Layout/default/Devicemanufactor/Index.php b/Layout/default/Devicemanufactor/Index.php index ce8eb742c..9b4a11186 100644 --- a/Layout/default/Devicemanufactor/Index.php +++ b/Layout/default/Devicemanufactor/Index.php @@ -4,7 +4,7 @@ $pagination_baseurl_params = ["filter" => $filter]; $pagination_entity_name = "Devicemanufactor"; ?> - +
@@ -88,7 +88,7 @@ $pagination_entity_name = "Devicemanufactor"; }); - + \ No newline at end of file diff --git a/Layout/default/Devicetype/Form.php b/Layout/default/Devicetype/Form.php index ac4f20d18..db799cdcf 100644 --- a/Layout/default/Devicetype/Form.php +++ b/Layout/default/Devicetype/Form.php @@ -1,5 +1,5 @@ - +
diff --git a/Layout/default/Devicetype/Index.php b/Layout/default/Devicetype/Index.php index f09a21d50..d36b5e3ea 100644 --- a/Layout/default/Devicetype/Index.php +++ b/Layout/default/Devicetype/Index.php @@ -4,7 +4,7 @@ $pagination_baseurl_params = ["filter" => $filter]; $pagination_entity_name = "Devicetype"; ?> - +
@@ -106,7 +106,7 @@ $pagination_entity_name = "Devicetype"; }); - + \ No newline at end of file diff --git a/application/Device/Device.php b/application/Device/Device.php index 178f165fc..4abccfb32 100644 --- a/application/Device/Device.php +++ b/application/Device/Device.php @@ -1,5 +1,4 @@ Date: Wed, 22 Mar 2023 16:27:00 +0100 Subject: [PATCH 2/3] Remerge --- Layout/default/Device/Detail.php | 1 - Layout/default/Device/Form.php | 1 - Layout/default/Device/Index.php | 3 --- Layout/default/Devicemanufactor/Form.php | 1 - Layout/default/Devicemanufactor/Index.php | 1 - application/Device/Device.php | 1 - application/Device/DeviceController.php | 1 - application/Device/DeviceModel.php | 1 - application/Devicemanufactor/Devicemanufactor.php | 1 - application/Devicemanufactor/DevicemanufactorController.php | 1 - application/Devicemanufactor/DevicemanufactorModel.php | 1 - 11 files changed, 13 deletions(-) diff --git a/Layout/default/Device/Detail.php b/Layout/default/Device/Detail.php index 3ee27f889..504c576f7 100644 --- a/Layout/default/Device/Detail.php +++ b/Layout/default/Device/Detail.php @@ -270,5 +270,4 @@ if ($devices->power != "0.0") { - \ No newline at end of file diff --git a/Layout/default/Device/Form.php b/Layout/default/Device/Form.php index f3821541a..1105f2099 100644 --- a/Layout/default/Device/Form.php +++ b/Layout/default/Device/Form.php @@ -5,7 +5,6 @@ foreach ($devicetypes as $devicetype) { } asort($deviceTypes); - ?> diff --git a/Layout/default/Device/Index.php b/Layout/default/Device/Index.php index a873d5f48..f30cfdbf2 100644 --- a/Layout/default/Device/Index.php +++ b/Layout/default/Device/Index.php @@ -5,9 +5,6 @@ $pagination_entity_name = "Device"; ?> -
diff --git a/Layout/default/Devicemanufactor/Form.php b/Layout/default/Devicemanufactor/Form.php index 0d2b6100e..796309910 100644 --- a/Layout/default/Devicemanufactor/Form.php +++ b/Layout/default/Devicemanufactor/Form.php @@ -1,5 +1,4 @@ -
diff --git a/Layout/default/Devicemanufactor/Index.php b/Layout/default/Devicemanufactor/Index.php index 9b4a11186..2eb243c17 100644 --- a/Layout/default/Devicemanufactor/Index.php +++ b/Layout/default/Devicemanufactor/Index.php @@ -22,7 +22,6 @@ $pagination_entity_name = "Devicemanufactor";
-
diff --git a/application/Device/Device.php b/application/Device/Device.php index 4abccfb32..43aa1e620 100644 --- a/application/Device/Device.php +++ b/application/Device/Device.php @@ -34,7 +34,6 @@ class Device extends mfBaseModel return null; } } - return $this->$name; } } \ No newline at end of file diff --git a/application/Device/DeviceController.php b/application/Device/DeviceController.php index 695aae919..7e64ee1f9 100644 --- a/application/Device/DeviceController.php +++ b/application/Device/DeviceController.php @@ -1,7 +1,6 @@ needlogin = true; diff --git a/application/Device/DeviceModel.php b/application/Device/DeviceModel.php index f64b286b5..622d8e69b 100644 --- a/application/Device/DeviceModel.php +++ b/application/Device/DeviceModel.php @@ -17,7 +17,6 @@ class DeviceModel public static function find($data) { - } public static function create(array $data) diff --git a/application/Devicemanufactor/Devicemanufactor.php b/application/Devicemanufactor/Devicemanufactor.php index 8edb05baf..b07d7722a 100644 --- a/application/Devicemanufactor/Devicemanufactor.php +++ b/application/Devicemanufactor/Devicemanufactor.php @@ -1,5 +1,4 @@ Date: Wed, 22 Mar 2023 16:56:02 +0100 Subject: [PATCH 3/3] Remerge --- Layout/default/Device/Detail.php | 3 +- Layout/default/Device/Form.php | 17 ++++- application/Device/Device.php | 2 + application/Device/DeviceController.php | 88 +++++++++++++++++-------- application/Device/DeviceModel.php | 10 +-- public/assets/css/datatables-std.css | 4 ++ 6 files changed, 91 insertions(+), 33 deletions(-) diff --git a/Layout/default/Device/Detail.php b/Layout/default/Device/Detail.php index 504c576f7..225265a3a 100644 --- a/Layout/default/Device/Detail.php +++ b/Layout/default/Device/Detail.php @@ -25,7 +25,8 @@
-

Device: data->name ?> +

Device: data->name ?> + $devices->id, 'returnto' => "device-detail"]) ?>"> diff --git a/Layout/default/Device/Form.php b/Layout/default/Device/Form.php index 1105f2099..91b3ddbba 100644 --- a/Layout/default/Device/Form.php +++ b/Layout/default/Device/Form.php @@ -1,10 +1,25 @@ id]=$devicetype->devicemanufactor->name . " " . $devicetype->name; + $deviceTypes[$devicetype->id] = $devicetype->devicemanufactor->name . " " . $devicetype->name; } asort($deviceTypes); +if ($device->price == "0.00") { + $price = ""; +} else { + $price = $device->price; +} +if ($device->power == "0.0") { + $power = ""; +} else { + $power = $device->power; +} +if (isset($_GET['returnto']) && $_GET['returnto'] == "device-detail") { + $cancelUrl = self::getUrl("Device", "Detail", ["id" => $device->id]); +} else { + $cancelUrl = self::getUrl("Device"); +} ?> diff --git a/application/Device/Device.php b/application/Device/Device.php index 43aa1e620..178f165fc 100644 --- a/application/Device/Device.php +++ b/application/Device/Device.php @@ -1,4 +1,5 @@ $name; } } \ No newline at end of file diff --git a/application/Device/DeviceController.php b/application/Device/DeviceController.php index 7e64ee1f9..37c9b49c6 100644 --- a/application/Device/DeviceController.php +++ b/application/Device/DeviceController.php @@ -1,6 +1,8 @@ needlogin = true; @@ -93,7 +95,7 @@ class DeviceController extends mfBaseController $data = []; $data['name'] = trim($r->name); $data['devicetype_id'] = $r->devicetype_id; - if (trim($r->pop_id)=="0") { + if (trim($r->pop_id) == "0") { $data['pop_id'] = NULL; } else { $data['pop_id'] = $r->pop_id; @@ -179,32 +181,6 @@ class DeviceController extends mfBaseController } $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker); } - $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"); @@ -214,4 +190,62 @@ class DeviceController extends mfBaseController $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker); } + protected function apiAction() + { + if (!$this->me->is(["Admin"])) { + $this->redirect("Dashboard"); + } + $do = $this->request->do; + $format = $this->request->format; + $filename = $this->request->filename; + $id = $this->request->id; + $ip = $this->request->ip; + + $data = []; + + switch ($do) { + case "getconfig": + $return = $this->getConfig($id, $format, $filename); + break; + case "createconfig": + $return = $this->createConfig($ip); + break; + default: + $return = false; + } + + } + + private function getConfig($id, $format, $filename) + { + $configDownload = DeviceModel::getconifgdownload($id, $format); +// + +// header('Content-Type: application/octet-stream'); + header('Content-Type: text/plain'); + header('Content-disposition: attachment; filename="' . $filename . '"'); + echo $configDownload; + + exit; + } + + private function createConfig($ip) + { + $r = $this->request; + $id = $r->id; + $createConfig = DeviceModel::configcreate($ip); + if ($createConfig->success==="true") + { + $this->layout()->setFlash("Backup wurde erfolgreich erstellt", "success"); + } + else + { + $this->layout()->setFlash("Backup konnte nicht erstellt werden. Fehler: ".$createConfig->error, "error"); + } + $returnUrl = "Device"; + $returnAction = "Detail"; + $returnVariables['id'] = $id; + return $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker); + } + } \ No newline at end of file diff --git a/application/Device/DeviceModel.php b/application/Device/DeviceModel.php index 622d8e69b..b5df9bdcc 100644 --- a/application/Device/DeviceModel.php +++ b/application/Device/DeviceModel.php @@ -1,4 +1,5 @@ select("Device", "*", "$where ORDER BY name"); - if($db->num_rows($res)) { - while($data = $db->fetch_object($res)) { + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { $items[] = new Device($data); } } @@ -119,9 +121,9 @@ class DeviceModel $where = "1=1 "; //var_dump($filter);exit; - if(array_key_exists("pop_id", $filter)) { + if (array_key_exists("pop_id", $filter)) { $popid = $filter['pop_id']; - if(is_numeric($popid)) { + if (is_numeric($popid)) { $where .= " AND pop_id=$popid"; } } diff --git a/public/assets/css/datatables-std.css b/public/assets/css/datatables-std.css index 9aaeaf448..bf18a25ab 100644 --- a/public/assets/css/datatables-std.css +++ b/public/assets/css/datatables-std.css @@ -32,6 +32,10 @@ width: 50px; } +.edit-width-large { + width: 100px; +} + .order-date-pill { margin: 2px; white-space: nowrap;