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 "; //var_dump($filter);exit; if (array_key_exists("network_id", $filter)) { $networkid = $filter['network_id']; if (is_numeric($networkid)) { $where .= " AND network_id=$networkid"; } } //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 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 = '
'; $return .= '
'; unset($option); foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) { if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"'; else $selected = ""; $option .= ''; } $return .= '
von
bis
'; } else if ($oldrack != $module['rack_id']) { unset($option); foreach ($racks as $rackid => $rack) { if ($rackid == $module['rack_id']) $selected = 'selected="selected"'; else $selected = ""; $option .= ''; } $return .= '
'; $return .= '
'; $return .= '
'; unset($option); foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) { if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"'; else $selected = ""; $option .= ''; } $return .= '
von
bis
'; } else { unset($option); foreach ($racksmodules[$module['rack_id']] as $racksmoduleid => $racksmodule) { if ($racksmoduleid == $module['module_id']) $selected = 'selected="selected"'; else $selected = ""; $option .= ''; } $return .= '
von
bis
'; } $oldrack = $module['rack_id']; $counter++; } $return .= "
"; return $return; } }