diff --git a/Layout/default/Device/Index.php b/Layout/default/Device/Index.php index 046c53aa4..bdcfda732 100644 --- a/Layout/default/Device/Index.php +++ b/Layout/default/Device/Index.php @@ -6,6 +6,11 @@ $pagination_entity_name = "Device"; +
@@ -37,22 +42,18 @@ $pagination_entity_name = "Device";
- - - - - + - + @@ -97,7 +98,17 @@ $pagination_entity_name = "Device"; $backup = 'N/A'; } - + if ($device->pop->id) { + $destination = ' $device->pop->id]) . '">' . $device->pop->name . ''; + } else if ($device->addr_street) { + $address = $device->addr_street . " " . $device->addr_number . ", " . $device->addr_zip . " " . $device->addr_city; + $destination = '' . $address . ''; + } else if ($device->gps_lat) { + $address = $device->gps_lat . " , " . $device->gps_long; + $destination = '' . $address . ''; + } else { + $destination = ''; + } ?> @@ -106,14 +117,14 @@ $pagination_entity_name = "Device"; - + - - + + @@ -129,11 +140,6 @@ $pagination_entity_name = "Device";
Device Name Geräte Typ HerstellerPopPop/Adresse IP-Adresse Mac-Adresse Seriennummer Preismax. Leistungmax. Leistung Backup
devicetype->name ?> devicetype->devicemanufactor->name ?>pop->name ?> ip ?> mac ?> serial ?> Watt Watt
- - - - - @@ -142,11 +148,11 @@ $pagination_entity_name = "Device"; + frei'; + $position++; + $calcwidth = $calcwidth + $slots['width']; + + } + if ($slots['width'] < 12 && $position != $slots['position']) { + echo 'frei'; + $position++; + $calcwidth = $calcwidth + $slots['width']; + } + if ($slots['width'] < 12 && $position != $slots['position']) { + echo 'frei'; + $position++; + $calcwidth = $calcwidth + $slots['width']; + } + echo ' ' . $slots['modulname'] . $extTextspan . ''; + $position++; + $calcwidth = $calcwidth + $slots['width']; + } + if ($calcwidth != 12) { + echo 'frei'; + $calcwidth = $calcwidth + $slots['width']; + } + if ($calcwidth != 12) { + echo 'frei'; + $calcwidth = $calcwidth + $slots['width']; + } + if ($calcwidth != 12) { + echo 'frei'; + $calcwidth = $calcwidth + $slots['width']; + } + + $blocktd = $modulelenght + $i; + + } + } + if ($i >= $blocktd) { + echo ' frei'; + } + + ?> + + + + + + + + + + + + + + + + - + - + $('#module-type').val(parent.find('td').eq(1).data('type')).change(); + if ($('#module-type').val() == "1") { + $('#module-device-id').hide(); + $('#module-device-text').text(parent.find('td').eq(1).data('name')); + $('#module-device-text').show(); + } + if (parent.find('td').eq(1).data('ports') != "") { + $('#module-ports').val(parent.find('td').eq(1).data('ports')).change(); + $('#module-plug').val(parent.find('td').eq(1).data('plug')); + } + $('#module-type').attr('disabled', 'disabled'); + $('#module-name').val(parent.find('td').eq(1).data('name')); + // $('#module-name').attr('disabled', 'disabled'); - \ No newline at end of file + + $('#module-remove').data('moduleid', parent.find('td').eq(1).data('id')); + $('#module-update').data('moduleid', parent.find('td').eq(1).data('id')); + } else { + $('#module-remove').hide(); + $('#module-update').hide(); + $('#module-add').show(); + $('#module-name-div').show(); + $('#module-name').removeAttr('disabled'); + $('#module-device-div').hide(); + $('#module-device-id').show(); + $('#module-device-id').attr('disabled', 'disabled'); + $('#module-type').val('0').change(); + $('#module-type').removeAttr('disabled'); + $('#module-plug').removeAttr('disabled'); + $('#module-ports').removeAttr('disabled'); + $('#module-name').val(''); + $('#module-ports').val('48'); + $('#module-ports').trigger("change"); + $('#module-position-div').hide(); + $('#module-update').hide(); + $('#module-device-text').hide(); + } + } else { + $('#module-remove').hide(); + $('#module-update').hide(); + $('#module-add').show(); + for (let i = 1; i <= rackhe; i++) { + if (i == trigger.data('he')) { + selected = 'selected="selected"'; + } else { + selected = ''; + } + if (trigger.closest('tbody').find('tr').eq(i - 1).find('td').eq(1).hasClass('he-free')) { + options = options + ''; + } + if (hemaxcountactive == 1 && i > trigger.data('he') && !trigger.closest('tbody').find('tr').eq(i - 1).find('td').eq(1).hasClass('he-free')) { + hemaxcountactive = 0; + } + if (hemaxcountactive == 1 && i > trigger.data('he') && trigger.closest('tbody').find('tr').eq(i - 1).find('td').eq(1).hasClass('he-free')) { + hemaxcount++; + } + } + $('#he-start-div').html(``); + options = ""; + selected = ""; + for (let i = 1; i <= hemaxcount; i++) { + options = options + ''; + } + $('#he-count-div').html(``); + if (edit == 0) { + $('#module-name-div').show(); + $('#module-name').removeAttr('disabled'); + $('#module-device-div').hide(); + $('#module-device-id').attr('disabled', 'disabled'); + $('#module-type').val('0').change(); + $('#module-type').removeAttr('disabled'); + $('#module-width').removeAttr('disabled'); + $('#module-plug').removeAttr('disabled'); + $('#module-ports').removeAttr('disabled'); + $('#module-name').val(''); + $('#module-width').val('12'); + $('#module-ports').val('48'); + $('#module-ports').trigger("change"); + $('#module-position').empty(); + $('#module-position-div').hide(); + $('#module-device-text').hide(); + $('#module-device-id').show(); + + } + } + }); + + $("body").on("change", "#module-type", function () { + if (parseInt($(this).val()) === 1) { + $('#module-name-div').hide(); + $('#module-name').attr('disabled', 'disabled'); + $('#module-device-div').show(); + + $('#module-device-id').removeAttr('disabled'); + $('#module-ports-div').hide(); + $('#module-plug-div').hide(); + } else if (parseInt($(this).val()) === 0) { + $('#module-name-div').show(); + $('#module-name').removeAttr('disabled'); + $('#module-device-div').hide(); + $('#module-device-id').attr('disabled', 'disabled'); + $('#module-ports-div').show(); + $('#module-plug-div').show(); + } else { + $('#module-name-div').show(); + $('#module-name').removeAttr('disabled'); + $('#module-device-div').hide(); + $('#module-device-id').attr('disabled', 'disabled'); + $('#module-ports-div').hide(); + $('#module-plug-div').hide(); + } + }); + + $("body").on("change", "#module-he-start", function () { + var rackhe = trigger.closest('table').find('th').data('rackhe'); + var hemaxcount = 1; + var hemaxcountactive = 1 + var options; + var selected; + for (let i = 1; i <= rackhe; i++) { + if (hemaxcountactive == 1 && i > $(this).val() && !trigger.closest('tbody').find('tr').eq(i - 1).find('td').eq(1).hasClass('he-free')) { + hemaxcountactive = 0; + } + + if (hemaxcountactive == 1 && i > $(this).val() && trigger.closest('tbody').find('tr').eq(i - 1).find('td').eq(1).hasClass('he-free')) { + hemaxcount++; + } + } + for (let i = 1; i <= hemaxcount; i++) { + options = options + ''; + } + $('#he-count-div').html(``); + }); + + $("body").on("click", "#module-add", function () { + var error; + var rackid = trigger.closest('table').find('th').data('rackid'); + var endhe = parseInt($.trim($('#module-he-start').val())) + parseInt($.trim($('#module-he-count').val())) - 1; + + + if (!$.trim($('#module-name').val()) && $.trim($('#module-type').val()) != "1") { + error = "Modul Name darf nicht leer sein"; + } + if ($.trim($('#module-type').val()) == "1" && !$.trim($('#module-device-id').val())) { + error = "Kein Device ausgewählt"; + } + + + if (!error) { + $.post(" 'addModule']) ?>&poprack_id=" + rackid, { + type: $.trim($('#module-type').val()), + device_id: $.trim($('#module-device-id').val()), + name: $.trim($('#module-name').val()), + start_he: $.trim($('#module-he-start').val()), + end_he: endhe, + ports: $.trim($('#module-ports').val()), + plug: $.trim($('#module-plug').val()), + width: $.trim($('#module-width').val()), + position: $.trim($('#module-position').val()) + + }, function (data) { + if (data.success === true) { + $('#rackModuleModal').modal('toggle'); + $.get(" 'generateRack']) ?>&id=" + rackid, function (data, status) { + trigger.closest('tbody').html(data); + }); + } + }, "json"); + } else { + $(this).closest('.modal').find('.alert').text(error); + $(this).closest('.modal').find('.alert').show(); + } + }); + $("body").on("click", "#module-remove", function () { + var moduleid = $(this).data('moduleid'); + var rackid = trigger.closest('table').find('th').data('rackid'); + if (confirm("Modul entfernen?")) { + $.post(" 'removeModule']) ?>", { + id: moduleid + }, function (data) { + if (data.success === true) { + $('#rackModuleModal').modal('toggle'); + $.get(" 'generateRack']) ?>&id=" + rackid, function (data, status) { + trigger.closest('tbody').html(data); + }); + } + }, "json"); + } + }); + $("body").on("click", "#module-update", function () { + var moduleid = $(this).data('moduleid'); + var rackid = trigger.closest('table').find('th').data('rackid'); + var error; + if (!$.trim($('#module-name').val())) { + error = "Modul Name darf nicht leer sein"; + } + if (!error) { + $.post(" 'updateModule']) ?>", { + id: moduleid, + name: $.trim($('#module-name').val()), + ports: $.trim($('#module-ports').val()), + plug: $.trim($('#module-plug').val()) + }, function (data) { + if (data.success === true) { + $('#rackModuleModal').modal('toggle'); + $.get(" 'generateRack']) ?>&id=" + rackid, function (data, status) { + trigger.closest('tbody').html(data); + }); + } + }, "json"); + } else { + $(this).closest('.modal').find('.alert').text(error); + $(this).closest('.modal').find('.alert').show(); + } + }); + + $("body").on("click", "#rack-update", function () { + var rackid = $(this).data('rackid'); + var rackmin = $(this).data('rackminhe'); + var error; + + if ($('#rack-he').val() < rackmin) { + error = "Minimale Höheneinheiten: " + rackmin; + } + if ($('#rack-he').val() > 60) { + error = "Maximale Höheneinheiten: 60"; + } + + if (!$.isNumeric($('#rack-he').val())) { + error = "Bitte Zahl bei Höheneinheiten eingeben"; + } + + if (!$.trim($('#rack-he').val())) { + error = "Höheneinheiten darf nicht leer sein"; + } + if (!$.trim($('#rack-name').val())) { + error = "Schrank Name darf nicht leer sein"; + } + if (!error) { + $.post(" 'editRack']) ?>&poprack_id=" + rackid, { + name: $.trim($('#rack-name').val()), + he: $.trim($('#rack-he').val()) + + }, function (data) { + if (data.success === true) { + $('#rackModal').modal('toggle'); + location.reload(); + } + }, "json"); + } else { + $(this).closest('.modal').find('.alert').text(error); + $(this).closest('.modal').find('.alert').show(); + } + }); + $("body").on("click", "#rack-add", function () { + var popid = $(this).data('popid'); + var error; + + if ($('#rack-he').val() < 1) { + error = "Minimale Höheneinheiten: " + 1; + } + if ($('#rack-he').val() > 60) { + error = error = "Maximale Höheneinheiten: 60"; + } + + if (!$.isNumeric($('#rack-he').val())) { + error = "Bitte Zahl bei Höheneinheiten eingeben"; + } + + if (!$.trim($('#rack-he').val())) { + error = "Höheneinheiten darf nicht leer sein"; + } + if (!$.trim($('#rack-name').val())) { + error = "Schrank Name darf nicht leer sein"; + } + if (!error) { + $.post(" 'addRack']) ?>&pop_id=" + popid, { + name: $.trim($('#rack-name').val()), + he: $.trim($('#rack-he').val()) + + }, function (data) { + if (data.success === true) { + $('#rackModal').modal('toggle'); + location.reload(); + } + }, "json"); + } else { + $(this).closest('.modal').find('.alert').text(error); + $(this).closest('.modal').find('.alert').show(); + } + }); + + $("body").on("click", "#rack-remove", function () { + var rackid = $(this).data('rackid'); + + $.post(" 'removeRack']) ?>", { + id: rackid + }, function (data) { + if (data.success === true) { + $('#rackModal').modal('toggle'); + location.reload(); + } + }, "json"); + + }); + $("body").on("change", "#module-width", function () { + if ($(this).val() == "12") { + $('#module-position-div').hide(); + } else if ($(this).val() == "6") { + $('#module-position').html(` + +`); + $('#module-position-div').show(); + } else if ($(this).val() == "4") { + $('#module-position').html(` + + + `); + $('#module-position-div').show(); + } else if ($(this).val() == "3") { + $('#module-position').html(` + + + +`); + $('#module-position-div').show(); + } + }); + + + $("body").on("change", "#module-ports", function () { + var plugs = []; + if ($(this).find(':selected').data('plugs') !== undefined) { + plugs = $(this).find(':selected').data('plugs').split(';'); + $("#module-plug option").each(function () { + if (plugs.includes($(this).val())) { + $(this).show(); + } else { + if ($(this).val() == $('#module-plug').val()) { + $('#module-plug').val(plugs[0]); + } + $(this).hide(); + } + }); + } + }); + + $("body").on("change", "#module-slot", function () { + $('#module-position').val($(this).val()); + var parent = trigger.closest('tr'); + if (trigger.closest('tr').find('td').eq(1).html() === undefined) { + parent = trigger.closest('tr').prev(); + for (let i = 1; i <= rackhe; i++) { + if (parent.find('td').eq(1).html() !== undefined) { + break; + } else { + parent = parent.prev(); + } + } + } + var newmodule = false; + var tdnumber = parseInt($(this).val()) + if (parent.find('td').eq(tdnumber).data('id') === undefined) { + newmodule = true; + } + if (!newmodule) { + $('#module-remove').show(); + $('#module-update').show(); + $('#module-add').hide(); + + + $('#module-type').val(parent.find('td').eq(tdnumber).data('type')).change(); + if ($('#module-type').val() == "1") { + $('#module-device-id').hide(); + $('#module-device-text').text(parent.find('td').eq(tdnumber).data('name')); + $('#module-device-text').show(); + } + if (parent.find('td').eq(tdnumber).data('ports') != "") { + $('#module-ports').val(parent.find('td').eq(tdnumber).data('ports')).change(); + $('#module-plug').val(parent.find('td').eq(tdnumber).data('plug')); + } + $('#module-type').attr('disabled', 'disabled'); + $('#module-name').val(parent.find('td').eq(tdnumber).data('name')); + // $('#module-name').attr('disabled', 'disabled'); + + + $('#module-remove').data('moduleid', parent.find('td').eq(tdnumber).data('id')); + $('#module-update').data('moduleid', parent.find('td').eq(tdnumber).data('id')); + } else { + $('#module-remove').hide(); + $('#module-update').hide(); + $('#module-add').show(); + $('#module-name-div').show(); + $('#module-name').removeAttr('disabled'); + $('#module-device-div').hide(); + $('#module-device-id').show(); + $('#module-device-id').attr('disabled', 'disabled'); + $('#module-type').val('0').change(); + $('#module-type').removeAttr('disabled'); + $('#module-plug').removeAttr('disabled'); + $('#module-ports').removeAttr('disabled'); + $('#module-name').val(''); + $('#module-ports').val('48'); + $('#module-ports').trigger("change"); + $('#module-position-div').hide(); + $('#module-update').hide(); + $('#module-device-text').hide(); + } + }); + + + }); + + + + + diff --git a/Layout/default/Pop/Form.php b/Layout/default/Pop/Form.php index 751c6b2e2..9e4cf3d73 100644 --- a/Layout/default/Pop/Form.php +++ b/Layout/default/Pop/Form.php @@ -1,4 +1,17 @@ - + $pop->id]); + $cancelText="Pop Detail"; +} else if (isset($_GET['returnto'])) { + $cancelUrl = self::getUrl("Pop"); + $cancelText="Pops"; +} else +{ + $cancelUrl = self::getUrl("Network"); +} + +?>
@@ -11,14 +24,14 @@ - + + href=""> + @@ -140,6 +153,9 @@
+ + +
diff --git a/Layout/default/Pop/Index.php b/Layout/default/Pop/Index.php index 3f6efc0d8..78fb927c4 100644 --- a/Layout/default/Pop/Index.php +++ b/Layout/default/Pop/Index.php @@ -37,10 +37,11 @@ $pagination_entity_name = "Pops"; + - +
diff --git a/application/Pop/PopController.php b/application/Pop/PopController.php index b4a9c6f74..a1ff0ca09 100644 --- a/application/Pop/PopController.php +++ b/application/Pop/PopController.php @@ -43,6 +43,7 @@ class PopController extends mfBaseController $this->layout()->setTemplate("Pop/Detail"); $filter['pop_id'] = $id; + $this->layout()->set("popracks", PoprackModel::getAllbyPop($id)); $this->layout()->set("devices", DeviceModel::search($filter)); $pops = PopModel::getOne($id); $this->layout()->set("pops", $pops); @@ -151,7 +152,6 @@ class PopController extends mfBaseController $returnAction = ""; $returnVariables['id'] = $id; $this->returUrl = $returnUrl; - var_dump($returnUrl); } else { $this->returUrl = ucfirst($this->request->returnto); diff --git a/application/Poprack/Poprack.php b/application/Poprack/Poprack.php new file mode 100644 index 000000000..7e079fbee --- /dev/null +++ b/application/Poprack/Poprack.php @@ -0,0 +1,25 @@ +$name == null) { + + $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/Poprack/PoprackController.php b/application/Poprack/PoprackController.php new file mode 100644 index 000000000..e3ef118d6 --- /dev/null +++ b/application/Poprack/PoprackController.php @@ -0,0 +1,229 @@ +request->do; + + $data = []; + + switch ($do) { + case "addRack": + $return = $this->addRack(); + break; + case "editRack": + $return = $this->editRack(); + break; + case "removeRack": + $return = $this->removeRack(); + break; + case "sortRack": + $return = $this->sortRack(); + break; + case "generateRack"; + $return = $this->generateRack(); + 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); + } + + private function addRack() + { + $r = $this->request; + $pop_id = $r->pop_id; + $data = []; + $data['name'] = trim($r->name); + $data['he'] = trim($r->he); + $data['pop_id'] = trim($pop_id); + $poprack = PoprackModel::create($data); + + $new_id = $poprack->save(); +// var_dump($r);die(); + if (!$new_id) { + $response['success'] = false; + } else { + $response['success'] = true; + } + echo json_encode($response); + exit; + } + + private function editRack() + { + $r = $this->request; + $id = $r->poprack_id; + $poprack = new Poprack($id); + $response['success'] = false; + if ($poprack->id) { + $data = []; + $data['name'] = $r->name; + $data['he'] = $r->he; + $poprack->update($data); + if ($poprack->save()) { + $response['success'] = true; + } + } + echo json_encode($response); + exit; + } + + private function sortRack() + { + $r = $this->request; + $racksortids = $r->racksortids; +// var_dump($racksortids); +// die(); + + foreach ($racksortids as $sort => $id) { + $poprack = new Poprack($id); + $response['success'] = false; + if ($poprack->id) { + $data = []; + $data['sort'] = $sort; + $poprack->update($data); + if ($poprack->save()) { + $response['success'] = true; + } + } + } + echo json_encode($response); + exit; + } + + + private function removeRack() + { + $id = $this->request->id; + $poprack = new Poprack($id); + if (!$poprack->id || $poprack->id != $id) { + $response['success'] = false; + } else { + $poprack->delete(); + $response['success'] = true; + } + echo json_encode($response); + exit; + + } + + private function generateRack() + { + $id = $this->request->id; + $cellwidth = 227; + $blocktd = 0; + $poprack = PoprackModel::getAllbyRack($id); + $plugs[1] = "LC"; + $plugs[2] = "SC"; + $plugs[3] = "E2000"; + for ($i = 1; $i <= $poprack[0]['rack']['he']; $i++) : + echo ' + '; + foreach ($poprack[0]['modules'] as $module) { + + if ($module['start_he'] == $i) { + $modulestart = 1; + + $modulelenght = $module['end_he'] - $module['start_he'] + 1; + $position = 1; + $slotcounter = 0; + $calcwidth = 0; + $extText = ""; + $extTextspan=""; + foreach ($module['slots'] as $slots) { + $extText = ""; + if ($slots['type'] == '0') { + $color = '#9fff6e'; + $colorclass = "rack-color-lwl"; + if ($slots['plug']) { + + $extText = " (" . $plugs[$slots['plug']] . "/" . $slots['ports'] . "P)"; + $extTextspan = "".$extText.""; + } + } else if ($slots['type'] == '1') { + + $color = '#b6c6ff'; + $colorclass = "rack-color-device"; + } else if ($slots['type'] == '2') { + + $color = '#ff8100'; + $colorclass = "rack-color-rpanel"; + } else if ($slots['type'] == '3') { + $color = '#ffad59'; + $colorclass = "rack-color-infra"; + } else if ($slots['type'] == '4') { + $color = '#96f3de'; + $colorclass = "rack-color-panel"; + } else if ($slots['type'] == '5') { + $color = '#96f3de'; + $colorclass = "rack-color-blocked"; + } + if ($slots['width'] == "12") { + $width = "85%"; + $maxwidth = $cellwidth; + } else if ($slots['width'] == "6") { + $width = "42%"; + $maxwidth = intval($cellwidth / 2); + } else if ($slots['width'] == "4") { + $width = "28%"; + $maxwidth = intval($cellwidth / 3); + } else if ($slots['width'] == "3") { + $width = "21%"; + $maxwidth = intval($cellwidth / 4); + } + if ($slots['width'] < 12 && $position != $slots['position']) { + echo ''; + $position++; + $calcwidth = $calcwidth + $slots['width']; + + } + if ($slots['width'] < 12 && $position != $slots['position']) { + echo ''; + $position++; + $calcwidth = $calcwidth + $slots['width']; + } + if ($slots['width'] < 12 && $position != $slots['position']) { + echo ''; + $position++; + $calcwidth = $calcwidth + $slots['width']; + } + echo ''; + $position++; + $calcwidth = $calcwidth + $slots['width']; + } + if ($calcwidth != 12) { + echo ''; + $calcwidth = $calcwidth + $slots['width']; + } + if ($calcwidth != 12) { + echo ''; + $calcwidth = $calcwidth + $slots['width']; + } + if ($calcwidth != 12) { + echo ''; + $calcwidth = $calcwidth + $slots['width']; + } + + $blocktd = $modulelenght + $i; + + } + } + if ($i >= $blocktd) { + echo ''; + } + echo ''; + endfor; + die(); + } +} \ No newline at end of file diff --git a/application/Poprack/PoprackModel.php b/application/Poprack/PoprackModel.php new file mode 100644 index 000000000..29e479b3d --- /dev/null +++ b/application/Poprack/PoprackModel.php @@ -0,0 +1,183 @@ + $value) { + if (property_exists(get_called_class(), $field)) { + if (substr($field, 0, 5) == "vlan_" && !$value) { + $model->$field = null; + continue; + } + $model->$field = $value; + } + } + + $me = mfValuecache::singleton()->get("me"); + if (!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::singleton()->set("me", $me); + } + + 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 getAllbyPop($pop_id) + { + $items = []; + + $db = FronkDB::singleton(); + $sql = "(SELECT `Poprackmodule`.`type`,`Poprack`.`id`,`Poprack`.`sort`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Poprackmodule`.`name` as `modulname`,device_id ,`Poprackmodule`.`id` as moduleid,`Poprackmodule`.`width` as modulewidth,`Poprackmodule`.`position` as moduleposition,`Poprackmodule`.`ports` as moduleports,`Poprackmodule`.`plug` as moduleplug FROM `Poprack` + LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id` AND `Poprackmodule`.`type`!=1) + WHERE `Poprack`.`pop_id`='" . $pop_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.start_he,`Poprackmodule`.position) + UNION + (SELECT `Poprackmodule`.`type`,`Poprack`.`id`,`Poprack`.`sort`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Device`.`name` as `modulname`,device_id,`Poprackmodule`.`id` as moduleid,`Poprackmodule`.`width` as modulewidth,`Poprackmodule`.`position` as moduleposition,`Poprackmodule`.`ports` as moduleports,`Poprackmodule`.`plug` as moduleplug FROM `Poprack` + LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id` AND `Poprackmodule`.`type`=1) + LEFT JOIN `Device` ON (`Device`.`id`=`Poprackmodule`.`device_id`) + WHERE `Poprack`.`pop_id`='" . $pop_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.start_he,`Poprackmodule`.position) + ORDER BY sort,name,start_he,moduleposition + "; + +// +// $sql = "SELECT `Poprack`.`id`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Poprackmodule`.`name` as `modulname` FROM `Poprack` +// LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id`) +// WHERE `Poprack`.`pop_id`='" . $pop_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.`start_he`"; + $res = $db->query($sql); + if ($db->num_rows($res)) { + $oldrackid = ""; + $counter = -1; + while ($data = $db->fetch_array($res)) { + + if ($oldrackid != $data['id']) { + $counter++; + $items[$counter]['rack']['id'] = $data['id']; + $items[$counter]['rack']['name'] = $data['name']; + $items[$counter]['rack']['he'] = $data['he']; + $modulecounter = 0; + } + if ($data['modulname']) { + if ($data['device_id']) { + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['device_id'] = $data['device_id']; + } + $items[$counter]['modules'][$data['start_he']]['start_he'] = $data['start_he']; + $items[$counter]['modules'][$data['start_he']]['end_he'] = $data['end_he']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['modulname'] = $data['modulname']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['moduleid'] = $data['moduleid']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['type'] = $data['type']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['width'] = $data['modulewidth']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['position'] = $data['moduleposition']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['ports'] = $data['moduleports']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['plug'] = $data['moduleplug']; + $modulecounter++; + } + $oldrackid = $data['id']; + } + + } + + return $items; + + } + + public static function getAllbyRack($rack_id) + { + $items = []; + + $db = FronkDB::singleton(); + $sql = "(SELECT `Poprackmodule`.`type`,`Poprack`.`id`,`Poprack`.`sort`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Poprackmodule`.`name` as `modulname`,device_id ,`Poprackmodule`.`id` as moduleid,`Poprackmodule`.`width` as modulewidth,`Poprackmodule`.`position` as moduleposition,`Poprackmodule`.`ports` as moduleports,`Poprackmodule`.`plug` as moduleplug FROM `Poprack` + LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id` AND `Poprackmodule`.`type`!=1) + WHERE `Poprack`.`id`='" . $rack_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.start_he,`Poprackmodule`.position) + UNION + (SELECT `Poprackmodule`.`type`,`Poprack`.`id`,`Poprack`.`sort`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Device`.`name` as `modulname`,device_id,`Poprackmodule`.`id` as moduleid,`Poprackmodule`.`width` as modulewidth,`Poprackmodule`.`position` as moduleposition,`Poprackmodule`.`ports` as moduleports,`Poprackmodule`.`plug` as moduleplug FROM `Poprack` + LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id` AND `Poprackmodule`.`type`=1) + LEFT JOIN `Device` ON (`Device`.`id`=`Poprackmodule`.`device_id`) + WHERE `Poprack`.`id`='" . $rack_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.start_he,`Poprackmodule`.position) + ORDER BY sort,name,start_he,moduleposition + "; + +// +// $sql = "SELECT `Poprack`.`id`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Poprackmodule`.`name` as `modulname` FROM `Poprack` +// LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id`) +// WHERE `Poprack`.`pop_id`='" . $pop_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.`start_he`"; + $res = $db->query($sql); + if ($db->num_rows($res)) { + $oldrackid = ""; + $counter = -1; + while ($data = $db->fetch_array($res)) { + + if ($oldrackid != $data['id']) { + $counter++; + $items[$counter]['rack']['id'] = $data['id']; + $items[$counter]['rack']['name'] = $data['name']; + $items[$counter]['rack']['he'] = $data['he']; + $modulecounter = 0; + } + if ($data['modulname']) { + if ($data['device_id']) { + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['device_id'] = $data['device_id']; + } + $items[$counter]['modules'][$data['start_he']]['start_he'] = $data['start_he']; + $items[$counter]['modules'][$data['start_he']]['end_he'] = $data['end_he']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['modulname'] = $data['modulname']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['moduleid'] = $data['moduleid']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['type'] = $data['type']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['width'] = $data['modulewidth']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['position'] = $data['moduleposition']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['ports'] = $data['moduleports']; + $items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['plug'] = $data['moduleplug']; + $modulecounter++; + } + $oldrackid = $data['id']; + } + + } + + return $items; + + } + + public static function getpoprack($pop_id) + { + $items = []; + $db = FronkDB::singleton(); + $sql = "SELECT `id`, `name`, `he` FROM `Poprack` WHERE pop_id='" . $pop_id . "' "; + + $res = $db->query($sql); + if ($db->num_rows($res)) { + while ($data = $db->fetch_array($res)) { + $items[] = $data; + } + + $response['data'] = $items; + $response['success'] = true; + + + } else { + $response['success'] = false; + } + echo json_encode($response); + exit; + } + +} \ No newline at end of file diff --git a/application/Poprackmodule/Poprackmodule.php b/application/Poprackmodule/Poprackmodule.php new file mode 100644 index 000000000..5299399d0 --- /dev/null +++ b/application/Poprackmodule/Poprackmodule.php @@ -0,0 +1,25 @@ +$name == null) { + + $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/Poprackmodule/PoprackmoduleController.php b/application/Poprackmodule/PoprackmoduleController.php new file mode 100644 index 000000000..78d686742 --- /dev/null +++ b/application/Poprackmodule/PoprackmoduleController.php @@ -0,0 +1,116 @@ +request->do; + + $data = []; + + switch ($do) { + case "addModule": + $return = $this->addModule(); + break; + case "removeModule": + $return = $this->removeModule(); + break; + case "updateModule": + $return = $this->updateModule(); + 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); + } + + private function addModule() + { + $r = $this->request; + $id = $r->id; + $data = []; + $data['poprack_id'] = $r->poprack_id; + $data['type'] = $r->type; + if ($data['type'] == 0) { + $data['ports'] = ($r->ports) ? $r->ports : null; + $data['plug'] = ($r->plug) ? $r->plug : null; + } + if ($data['type'] == 1) { + $data['device_id'] = ($r->device_id) ? $r->device_id : null; + } + $data['name'] = ($r->name) ? $r->name : null; + $data['start_he'] = $r->start_he; + $data['end_he'] = $r->end_he; + $data['width'] = $r->width; + $data['position'] = ($r->position) ? $r->position : null; + + $poprackmodule = PoprackmoduleModel::create($data); + + $new_id = $poprackmodule->save(); +// var_dump($r);die(); + if (!$new_id) { + $response['success'] = false; + } else { + $response['success'] = true; + } + echo json_encode($response); + exit; + } + + private function updateModule() + { + $r = $this->request; + $id = $r->id; + if (is_numeric($id) && $id > 0) { + $poprackmodule = new Poprackmodule($id); + if (!$poprackmodule->id) { + $response['success'] = false; + echo json_encode($response); + exit; + die(); + } + } + $data = []; + + if ($r->type == 0) { + $data['ports'] = ($r->ports) ? $r->ports : null; + $data['plug'] = ($r->plug) ? $r->plug : null; + } + $data['name'] = ($r->name); + $poprackmodule->update($data); + + $new_id = $poprackmodule->save(); +// var_dump($r);die(); + if (!$new_id) { + $response['success'] = false; + } else { + $response['success'] = true; + } + echo json_encode($response); + exit; + } + + private function removeModule() + { + $id = $this->request->id; + $poprackmodule = new Poprackmodule($id); + if (!$poprackmodule->id || $poprackmodule->id != $id) { + $response['success'] = false; + } else { + $poprackmodule->delete(); + $response['success'] = true; + } + echo json_encode($response); + exit; + + } + + +} \ No newline at end of file diff --git a/application/Poprackmodule/PoprackmoduleModel.php b/application/Poprackmodule/PoprackmoduleModel.php new file mode 100644 index 000000000..d96129c9d --- /dev/null +++ b/application/Poprackmodule/PoprackmoduleModel.php @@ -0,0 +1,77 @@ + $value) { + if (property_exists(get_called_class(), $field)) { + if (substr($field, 0, 5) == "vlan_" && !$value) { + $model->$field = null; + continue; + } + $model->$field = $value; + } + } + + $me = mfValuecache::singleton()->get("me"); + if (!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::singleton()->set("me", $me); + } + + 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 getpoprackmodule($poprack_id) + { + $items = []; + $db = FronkDB::singleton(); + $sql = "SELECT `id`, `name`, `start_he`,`end_he` FROM `Poprackmodule` WHERE `poprack_id`='" . $poprack_id . "' AND type ='0' ORDER by name"; + + $res = $db->query($sql); + if ($db->num_rows($res)) { + while ($data = $db->fetch_array($res)) { + $items[] = $data; + } + + $response['data'] = $items; + $response['success'] = true; + + + } else { + $response['success'] = false; + } + echo json_encode($response); + exit; + } + + +} \ No newline at end of file diff --git a/public/assets/js/datatables-std.js b/public/assets/js/datatables-std.js index c883afb79..3131e2411 100644 --- a/public/assets/js/datatables-std.js +++ b/public/assets/js/datatables-std.js @@ -2,7 +2,6 @@ let table; if (typeof hidesearch === "undefined") { var hidesearch; hidesearch = [100]; - console.log(hidesearch); } if (typeof cstmdom === "undefined") {
Name
He' . $i . 'freifreifrei ' . $slots['modulname'] . $extTextspan . 'freifreifrei frei