Remerge
This commit is contained in:
@@ -25,7 +25,8 @@
|
|||||||
<li class="breadcrumb-item active">Device Detail</li>
|
<li class="breadcrumb-item active">Device Detail</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<h4 class="page-title">Device: <span class="font-weight-normal ml-1"><?= $devices->data->name ?></span> <span class="ml-2">
|
<h4 class="page-title">Device: <span class="font-weight-normal ml-1"><?= $devices->data->name ?></span>
|
||||||
|
<span class="ml-2">
|
||||||
<a href="<?= self::getUrl("Device", "edit", ["id" => $devices->id, 'returnto' => "device-detail"]) ?>">
|
<a href="<?= self::getUrl("Device", "edit", ["id" => $devices->id, 'returnto' => "device-detail"]) ?>">
|
||||||
<button class="btn btn-primary">Bearbeiten</button>
|
<button class="btn btn-primary">Bearbeiten</button>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||||
<?php
|
<?php
|
||||||
foreach ($devicetypes as $devicetype) {
|
foreach ($devicetypes as $devicetype) {
|
||||||
$deviceTypes[$devicetype->id]=$devicetype->devicemanufactor->name . " " . $devicetype->name;
|
$deviceTypes[$devicetype->id] = $devicetype->devicemanufactor->name . " " . $devicetype->name;
|
||||||
}
|
}
|
||||||
asort($deviceTypes);
|
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");
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?=date('U')?>" rel="stylesheet" type="text/css"/>
|
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?=date('U')?>" rel="stylesheet" type="text/css"/>
|
||||||
<!-- start page title -->
|
<!-- start page title -->
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Device extends mfBaseModel
|
class Device extends mfBaseModel
|
||||||
{
|
{
|
||||||
private $editor;
|
private $editor;
|
||||||
@@ -34,6 +35,7 @@ class Device extends mfBaseModel
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->$name;
|
return $this->$name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class DeviceController extends mfBaseController
|
class DeviceController extends mfBaseController
|
||||||
{
|
{
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->needlogin = true;
|
$this->needlogin = true;
|
||||||
@@ -93,7 +95,7 @@ class DeviceController extends mfBaseController
|
|||||||
$data = [];
|
$data = [];
|
||||||
$data['name'] = trim($r->name);
|
$data['name'] = trim($r->name);
|
||||||
$data['devicetype_id'] = $r->devicetype_id;
|
$data['devicetype_id'] = $r->devicetype_id;
|
||||||
if (trim($r->pop_id)=="0") {
|
if (trim($r->pop_id) == "0") {
|
||||||
$data['pop_id'] = NULL;
|
$data['pop_id'] = NULL;
|
||||||
} else {
|
} else {
|
||||||
$data['pop_id'] = $r->pop_id;
|
$data['pop_id'] = $r->pop_id;
|
||||||
@@ -179,32 +181,6 @@ class DeviceController extends mfBaseController
|
|||||||
}
|
}
|
||||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
$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") {
|
if ($mode == "edit") {
|
||||||
$this->layout()->setFlash("Device erfolgreich geändert", "success");
|
$this->layout()->setFlash("Device erfolgreich geändert", "success");
|
||||||
@@ -214,4 +190,62 @@ class DeviceController extends mfBaseController
|
|||||||
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
$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. <b>Fehler</b>: ".$createConfig->error, "error");
|
||||||
|
}
|
||||||
|
$returnUrl = "Device";
|
||||||
|
$returnAction = "Detail";
|
||||||
|
$returnVariables['id'] = $id;
|
||||||
|
return $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class DeviceModel
|
class DeviceModel
|
||||||
{
|
{
|
||||||
public $name = null;
|
public $name = null;
|
||||||
@@ -17,6 +18,7 @@ class DeviceModel
|
|||||||
|
|
||||||
public static function find($data)
|
public static function find($data)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create(array $data)
|
public static function create(array $data)
|
||||||
@@ -106,8 +108,8 @@ class DeviceModel
|
|||||||
$db = FronkDB::singleton();
|
$db = FronkDB::singleton();
|
||||||
$where = self::getSqlFilter($filter);
|
$where = self::getSqlFilter($filter);
|
||||||
$res = $db->select("Device", "*", "$where ORDER BY name");
|
$res = $db->select("Device", "*", "$where ORDER BY name");
|
||||||
if($db->num_rows($res)) {
|
if ($db->num_rows($res)) {
|
||||||
while($data = $db->fetch_object($res)) {
|
while ($data = $db->fetch_object($res)) {
|
||||||
$items[] = new Device($data);
|
$items[] = new Device($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,9 +121,9 @@ class DeviceModel
|
|||||||
$where = "1=1 ";
|
$where = "1=1 ";
|
||||||
|
|
||||||
//var_dump($filter);exit;
|
//var_dump($filter);exit;
|
||||||
if(array_key_exists("pop_id", $filter)) {
|
if (array_key_exists("pop_id", $filter)) {
|
||||||
$popid = $filter['pop_id'];
|
$popid = $filter['pop_id'];
|
||||||
if(is_numeric($popid)) {
|
if (is_numeric($popid)) {
|
||||||
$where .= " AND pop_id=$popid";
|
$where .= " AND pop_id=$popid";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@
|
|||||||
width: 50px;
|
width: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit-width-large {
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
.order-date-pill {
|
.order-date-pill {
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
Reference in New Issue
Block a user