4, 2 => 12, 3 => 24, 4 => 24, 5 => 48, 6 => 96, 7 => 144, 8 => 144, 9 => 192, 10 => 288); public static function find($data) { } public static function create(array $data) { $model = new FiberPlanCable(); foreach ($data as $field => $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 getOne($id) { if (!is_numeric($id) || !$id) { throw new Exception("Invalid number", 400); } $item = []; $db = FronkDB::singleton(); $res = $db->select("FiberPlanCable", "*", "id=$id LIMIT 1"); if ($db->num_rows($res)) { $data = $db->fetch_object($res); $item = new FiberPlanCable($data); } return $item; } public static function getAll() { $items = []; $db = FronkDB::singleton(); $res = $db->select("FiberPlanCable", "*", "1=1"); if ($db->num_rows($res)) { while ($data = $db->fetch_object($res)) { $items[] = new FiberPlanCable($data); } } return $items; } public static function getFirst() { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); $res = $db->select("FiberPlanCable", "*", "$where "); if ($db->num_rows($res)) { $data = $db->fetch_object($res); $item = new FiberPlanCable($data); if ($item->id) { return $item; } else { return null; } } return null; } public static function search($filter) { $items = []; $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); $res = $db->select("FiberPlanCable", "*", "$where"); if ($db->num_rows($res)) { while ($data = $db->fetch_object($res)) { $items[] = new FiberPlanCable($data); } } return $items; } private static function getSqlFilter($filter) { $where = "1=1 "; if (array_key_exists("description", $filter) && $filter['description']) { $description = $filter['description']; $where .= " AND description='$description'"; } if (array_key_exists("network_id", $filter)) { if (is_array($filter['network_id'])) { $ids = array_map('intval', $filter['network_id']); $ids = array_filter($ids, function($id) { return $id > 0; }); if (!empty($ids)) { $idList = implode(',', $ids); $where .= " AND network_id IN ($idList)"; } } else { $network_id = intval($filter['network_id']); if ($network_id > 0) { $where .= " AND network_id=$network_id"; } elseif ($network_id === 0) { $where .= " AND (network_id IS NULL OR network_id=0)"; } } } //var_dump($filter, $where);exit; return $where; } public static function getFiberPlanPipe($network_id) { { $items = []; $db = FronkDB::singleton(); $sql = "SELECT * FROM `FiberPlanPipeEndpoint`"; $res = $db->query($sql); if ($db->num_rows($res)) { while ($data = $db->fetch_object($res)) { $ok = 0; $FiberplanPipeEndpoint = new FiberPlanPipeEndpoint($data); if ($data->fiberPlanDispatcher_id) { if ($FiberplanPipeEndpoint->fiberPlanDispatcher->network_id == $network_id) { $ok = 1; } } if ($data->building_id) { if ($FiberplanPipeEndpoint->building->network_id == $network_id) { $ok = 1; } } if ($data->pop_id) { $sql = "SELECT id FROM PopNetwork WHERE pop_id='" . $data->pop_id . "' AND network_id='" . $network_id . "'"; $result = $db->query($sql); if ($db->num_rows($result)) { $ok = 1; } } if ($ok == 1) { $items[$FiberplanPipeEndpoint->fiberPlanPipe_id]['description'] = $FiberplanPipeEndpoint->fiberPlanPipe->description; $items[$FiberplanPipeEndpoint->fiberPlanPipe_id]['id'] = $FiberplanPipeEndpoint->fiberPlanPipe_id; } } $response['success'] = true; $response['data'] = $items; } else { $response['success'] = false; } echo json_encode($response); exit; } } public static function getFiberPlanPipeSub($fiberplanpipe_id, $internal = 0) { $items = []; $db = FronkDB::singleton(); $sql = "SELECT `FiberPlanPipe`.`id`,`type`, `type_description`, `fiberPlanPipeTemplate_id`,`pipe7x4`, `pipe14x10`,colors FROM `FiberPlanPipe` LEFT JOIN `FiberPlanPipeTemplate` ON `FiberPlanPipeTemplate`.`id`=`FiberPlanPipe`.`fiberPlanPipeTemplate_id` LEFT JOIN `FiberPlanPipeManufacturer` ON `FiberPlanPipeTemplate`.`fiberPlanPipeManufacturer_id`=`FiberPlanPipeManufacturer`.`id` WHERE `FiberPlanPipe`.`id`='" . $fiberplanpipe_id . "' "; $res = $db->query($sql); $buildings = FiberPlanPipeModel::getBuildingInfoAll(); if ($db->num_rows($res)) { while ($data = $db->fetch_array($res)) { $items[] = $data; } $response['success'] = true; $response['data'] = $items; $response['variables']['type_description'] = FiberPlanPipeModel::$type_descrition_definition; } else { $response['success'] = false; } if ($internal == 0) { echo json_encode($response); exit; } else { return $response; } } public static function getLineworkerAddresses() { $items = []; $db = FronkDB::singleton(); $sql = "SELECT `Addresstype`.`id`,`Address`.`company` FROM `Addresstype` INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`) WHERE `type` = 'lineworker' ORDER by `Address`.`company` "; $res = $db->query($sql); if ($db->num_rows($res)) { while ($data = $db->fetch_object($res)) { $items[] = new FiberPlanCable($data); } } return $items; } public static function getCableRoute($cable_id) { $route = []; $db = FronkDB::singleton(); // SQL-Abfrage mit object_type für Dispatcher $sql = "SELECT fcs.station_order, fcs.station_type, fcs.station_id, CASE WHEN fcs.station_type = 'pop' THEN p.name WHEN fcs.station_type = 'dispatcher' THEN d.description END as station_name, CASE WHEN fcs.station_type = 'pop' THEN p.gps_lat WHEN fcs.station_type = 'dispatcher' THEN d.gps_lat END as gps_lat, CASE WHEN fcs.station_type = 'pop' THEN p.gps_long WHEN fcs.station_type = 'dispatcher' THEN d.gps_long END as gps_long, d.object_type FROM FiberPlanCableStation fcs LEFT JOIN Pop p ON fcs.station_type = 'pop' AND fcs.station_id = p.id LEFT JOIN FiberPlanDispatcher d ON fcs.station_type = 'dispatcher' AND fcs.station_id = d.id WHERE fcs.cable_id = " . intval($cable_id) . " ORDER BY fcs.station_order ASC"; $res = $db->query($sql); if ($db->num_rows($res)) { while ($data = $db->fetch_array($res)) { $route[] = [ 'order' => $data['station_order'], 'type' => $data['station_type'], 'id' => $data['station_id'], 'name' => $data['station_name'], 'gps_lat' => $data['gps_lat'], 'gps_long' => $data['gps_long'], 'object_type' => $data['object_type'] // Neu: object_type hinzugefügt ]; } } return $route; } public static function generateEndpoint($endpoint, $destination, $html = 1) { $endpoint = json_decode($endpoint, true); $popid = $endpoint['pop_id']; $racks = []; $db = FronkDB::singleton(); $sql = "SELECT `id`, `pop_id`, `name`, `he` FROM `Poprack` WHERE `pop_id`='" . $popid . "' "; $res = $db->query($sql); if ($db->num_rows($res)) { while ($data = $db->fetch_array($res)) { $racks[$data['id']] = $data['name']; } } $sql = "SELECT `Poprackmodule`.`id`, `Poprackmodule`.`poprack_id`, `Poprackmodule`.`type`, `Poprackmodule`.`device_id`, `Poprackmodule`.`name`, `Poprackmodule`.`start_he`, `Poprackmodule`.`end_he`, `Poprackmodule`.`ports`, `Poprackmodule`.`plug`, `Poprackmodule`.`width`, `Poprackmodule`.`position`,pop_id FROM `Poprackmodule` INNER JOIN `Poprack` ON (`Poprack`.`id`=`Poprackmodule`.`poprack_id`) WHERE `Poprack`.`pop_id`= '" . $popid . "'"; $res = $db->query($sql); if ($db->num_rows($res)) { while ($data = $db->fetch_array($res)) { if ($data['plug'] == 1) $plug = 'LC/APC'; elseif ($data['plug'] == 2) $plug = 'SC/APC'; elseif ($data['plug'] == 3) $plug = 'E2000/APC'; $racksmodules[$data['poprack_id']][$data['id']]['name'] = $data['name']; $racksmodules[$data['poprack_id']][$data['id']]['plug'] = $plug; $racksmodules[$data['poprack_id']][$data['id']]['ports'] = $data['ports']; $racksmodules[$data['poprack_id']][$data['id']]['start_he'] = $data['start_he']; } } $counter = 1; $oldrack = ""; if ($html == "0") { $return['racks'] = $racks; $return['racksmodules'] = $racksmodules; return $return; } foreach ($endpoint['data'] as $module) { unset($option); if ($counter === 1) { foreach ($racks as $rackid => $rack) { if ($rackid == $module['rack_id']) $selected = 'selected="selected"'; else $selected = ""; $option .= ''; } $return = '