Merge branch 'spidev' into 'master'

Faserplanung

See merge request fronk/thetool!334
This commit is contained in:
Frank Schubert
2024-04-16 14:58:44 +00:00
26 changed files with 3893 additions and 3 deletions
@@ -0,0 +1,59 @@
<?php
class FiberPlanDispatcher extends mfBaseModel
{
private $editor;
private $network;
private $creator;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($this->creator === null) {
$this->creator = new User($this->create_by);
if($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
}
}
return $this->creator;
}
if($name == "editor") {
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
if($this->editor === null) {
$this->editor = new User($this->edit_by);
if($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
if(!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}
@@ -0,0 +1,182 @@
<?php
class FiberPlanDispatcherController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("FiberPlanDispatcher/Index");
$fiberplandispatchers = FiberPlanDispatcherModel::getAll();
$this->layout()->set("fiberplandispatchers", $fiberplandispatchers);
}
protected function addAction()
{
$this->layout()->setTemplate("FiberPlanDispatcher/Form");
$networks = NetworkModel::getAll();
$this->layout()->set("networks", $networks);
$networkaddresses = NetworkAddressModel::getAll();
$this->layout()->set("networkaddresses", $networkaddresses);
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Verteiler/Schacht nicht gefunden", "error");
$this->redirect("FiberPlanDispatcher");
}
$fiberplandispatchers = new FiberPlanDispatcher($id);
if ($fiberplandispatchers->id != $id) {
$this->layout()->setFlash("Verteiler/Schacht nicht gefunden", "error");
$this->redirect("FiberPlanDispatcher");
}
$this->layout()->set("fiberplandispatchers", $fiberplandispatchers);
if ($fiberplandispatchers->object_type == "2") {
$sleeves = FiberPlanDispatchersleeveModel::getAllbyDispatcher($id);
$this->layout()->set("sleeves", $sleeves);
}
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$fiberplandispatcher = new FiberPlanDispatcher($id);
if (!$fiberplandispatcher->id) {
$this->layout()->setFlash("Verteiler/Schacht nicht gefunden", "error");
$this->redirect("FiberPlanDispatcher");
}
} else {
$mode = "add";
}
$data = [];
$data['network_id'] = trim($r->network_id);
$data['object_type'] = trim($r->object_type);
$data['description'] = trim($r->description);
if ($r->type) {
$data['type'] = trim($r->type);
}
if ($r->gps_lat) {
$data['gps_lat'] = trim($r->gps_lat);
}
if ($r->gps_long) {
$data['gps_long'] = trim($r->gps_long);
}
if ($r->comment) {
$data['comment'] = trim($r->comment);
}
if (!$data['network_id']) {
$this->layout()->setFlash("Netzgebiet darf nicht leer sein", "error");
$this->redirect("FiberPlanDispatcher");
}
if (!$data['object_type']) {
$this->layout()->setFlash("Objekt Typ darf nicht leer sein", "error");
$this->redirect("FiberPlanDispatcher");
}
if (!$data['description']) {
$this->layout()->setFlash("Beschreibung darf nicht leer sein", "error");
$this->redirect("FiberPlanDispatcher");
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$fiberplandispatcher->update($data);
} else {
$fiberplandispatcher = FiberPlanDispatcherModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $fiberplandispatcher->save();
if ($mode == "edit") {
if ($data['object_type'] == "2") {
FiberPlanDispatchersleeveModel::deletebyDispatcher($id);
$sleeves = $r->sleeves;
$sleevedata = [];
if (is_array($sleeves)) {
foreach ($sleeves as $sleeve) {
$sleevedata['name'] = trim($sleeve);
$sleevedata['fiberPlanDispatcher_id'] = $id;
$fiberplandispatchersleeve = FiberPlanDispatchersleeveModel::create($sleevedata);
$fiberplandispatchersleeve->save();
}
}
}
} else {
if ($data['object_type'] == "2") {
$sleeves = $r->sleeves;
$sleevedata = [];
if (is_array($sleeves)) {
foreach ($sleeves as $sleeve) {
$sleevedata['name'] = trim($sleeve);
$sleevedata['fiberPlanDispatcher_id'] = $id;
$fiberplandispatchersleeve = FiberPlanDispatchersleeveModel::create($sleevedata);
$fiberplandispatchersleeve->save();
}
}
}
}
if (!$id) {
$this->layout()->setFlash("Verteiler/Schacht konnte nicht angelegt werden", "error");
$this->redirect("FiberPlanDispatcher");
}
if ($mode == "edit") {
$this->layout()->setFlash("Verteiler/Schacht erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Verteiler/Schacht erfolgreich angelegt", "success");
}
$this->redirect("FiberPlanDispatcher");
}
protected function deleteAction()
{
$id = $this->request->id;
$fiberplandispatcher = new FiberPlanDispatcher($id);
if (!$fiberplandispatcher->id || $fiberplandispatcher->id != $id) {
$this->layout()->setFlash("Verteiler/Schacht nicht gefunden.", "error");
$this->redirect("FiberPlanDispatcher");
}
$fiberplandispatcher->delete();
$this->redirect("FiberPlanDispatcher");
}
}
@@ -0,0 +1,137 @@
<?php
class FiberPlanDispatcherModel
{
public $network_id = null;
public $object_type = null;
public $price = null;
public $gps_lat = null;
public $gps_long = null;
public $type = null;
public $comment = null;
public $description = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
public $edit = null;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new FiberPlanDispatcher();
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("Devicetype", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Devicetype($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("FiberPlanDispatcher", "*", "1=1 ORDER BY network_id");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanDispatcher($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Devicetype", "*", "$where ORDER BY name, network_id");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Devicetype($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("Devicetype", "*", "$where ORDER BY name, network_id");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Devicetype($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;
}
}
@@ -0,0 +1,60 @@
<?php
class FiberPlanDispatchersleeve extends mfBaseModel
{
private $editor;
private $creator;
private $fiberPlanDispatcher;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($this->creator === null) {
$this->creator = new User($this->create_by);
if($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
}
}
return $this->creator;
}
if($name == "editor") {
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
if($this->editor === null) {
$this->editor = new User($this->edit_by);
if($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
if(!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}
@@ -0,0 +1,127 @@
<?php
class FiberPlanDispatchersleeveController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("FiberPlanDispatchersleeve/Index");
$fiberplandispatchersleeves = FiberPlanDispatchersleeveModel::getAll();
$this->layout()->set("fiberplandispatchersleeves", $fiberplandispatchersleeves);
}
protected function addAction()
{
$fiberPlanDispatchers=FiberPlanDispatcherModel::getAll();
$this->layout()->set("fiberPlanDispatchers", $fiberPlanDispatchers);
$this->layout()->setTemplate("FiberPlanDispatchersleeve/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Muffen nicht gefunden", "error");
$this->redirect("FiberPlanDispatchersleeve");
}
$fiberplandispatchersleeves = new FiberPlanDispatchersleeve($id);
if ($fiberplandispatchersleeves->id != $id) {
$this->layout()->setFlash("Muffen nicht gefunden", "error");
$this->redirect("FiberPlanDispatchersleeve");
}
$this->layout()->set("fiberplandispatchersleeves", $fiberplandispatchersleeves);
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$fiberplandispatchersleeves = new FiberPlanDispatchersleeve($id);
if (!$fiberplandispatchersleeves->id) {
$this->layout()->setFlash("Muffe nicht gefunden", "error");
$this->redirect("FiberPlanDispatchersleeve");
}
} else {
$mode = "add";
}
$data = [];
$data['fiberPlanDispatcher_id'] = trim($r->fiberPlanDispatcher_id);
$data['name'] = trim($r->name);
if (!$data['fiberPlanDispatcher_id']) {
$data['fiberPlanDispatcher_id']=NULL;
}
if (!$data['name']) {
$data['name']=NULL;
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$fiberplandispatchersleeves->update($data);
} else {
$fiberplandispatchersleeves = FiberPlanDispatchersleeveModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $fiberplandispatchersleeves->save();
if (!$id) {
$this->layout()->setFlash("Muffen konnte nicht angelegt werden", "error");
$this->redirect("FiberPlanDispatchersleeve");
}
if ($mode == "edit") {
$this->layout()->setFlash("Muffen erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Muffen erfolgreich angelegt", "success");
}
$this->redirect("FiberPlanDispatchersleeve");
}
protected function deleteAction()
{
$id = $this->request->id;
$fiberplandispatchersleeves = new FiberPlanDispatchersleeve($id);
if (!$fiberplandispatchersleeves->id || $fiberplandispatchersleeves->id != $id) {
$this->layout()->setFlash("Muffen nicht gefunden.", "error");
$this->redirect("FiberPlanDispatchersleeve");
}
$fiberplandispatchersleeves->delete();
$this->redirect("FiberPlanDispatchersleeve");
}
}
@@ -0,0 +1,153 @@
<?php
class FiberPlanDispatchersleeveModel
{
private $fiberPlanDispatcher_id;
private $name;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new FiberPlanDispatchersleeve();
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("FiberPlanDispatchersleeve", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanDispatchersleeve($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("FiberPlanDispatchersleeve", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanDispatchersleeve($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("FiberPlanDispatchersleeve", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanDispatchersleeve($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("FiberPlanDispatchersleeve", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanDispatchersleeve($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 getAllbyDispatcher($dispatcher_id)
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT `id`, `fiberPlanDispatcher_id`, `name` FROM `FiberPlanDispatchersleeve`
WHERE `fiberPlanDispatcher_id`='" . $dispatcher_id . "'";
$res = $db->query($sql);
if ($db->num_rows($res)) {
$oldrackid = "";
$counter = -1;
while ($data = $db->fetch_array($res)) {
$items[] = $data;
}
return $items;
}
}
public static function deletebyDispatcher($dispatcher_id)
{
$db = FronkDB::singleton();
$sql = "DELETE FROM `FiberPlanDispatchersleeve` WHERE `fiberPlanDispatcher_id`='" . $dispatcher_id . "'";
$db->query($sql);
}
}
@@ -0,0 +1,62 @@
<?php
class FiberPlanPipe extends mfBaseModel
{
private $editor;
private $creator;
private $network;
private $fiberPlanPipeManufacturer;
private $fiberPlanPipeTemplate;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($this->creator === null) {
$this->creator = new User($this->create_by);
if($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
}
}
return $this->creator;
}
if($name == "editor") {
$this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
if($this->editor === null) {
$this->editor = new User($this->edit_by);
if($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
if(!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name);
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}
@@ -0,0 +1,281 @@
<?php
class FiberPlanPipeController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$networks = NetworkModel::getAll();
$this->layout()->setTemplate("FiberPlanPipe/Index");
$fiberplanpipes = FiberPlanPipeModel::getAll();
$pipworkeraddresses = FiberPlanPipeModel::getPipeworkerAddresses();
$buildings = FiberPlanPipeModel::getBuildingInfoAll();
$this->layout()->set("networks", $networks);
$this->layout()->set("buildings", $buildings);
$this->layout()->set("pipworkeraddresses", $pipworkeraddresses);
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
}
protected function addAction()
{
$networks = NetworkModel::getAll();
$fiberplanpipetemplates = FiberPlanPipeModel::getTemplates();
$pipworkeraddresses = FiberPlanPipeModel::getPipeworkerAddresses();
$this->layout()->set("networks", $networks);
$this->layout()->set("pipworkeraddresses", $pipworkeraddresses);
$this->layout()->set("fiberplanpipetemplates", $fiberplanpipetemplates);
$this->layout()->setTemplate("FiberPlanPipe/Form");
}
protected function apiAction()
{
$do = $this->request->do;
$network = $this->request->network_id;
$bdtype = $this->request->bdtype;
switch ($do) {
case "getBuildingInfo":
$return = $this->getBuildingInfo($network, $bdtype);
break;
case "getPops":
$return = $this->getPops($network);
break;
default:
$return = false;
}
}
protected function detailAction()
{
$id = $this->request->id;
$networks = NetworkModel::getAll();
$this->layout()->setTemplate("FiberPlanPipe/Detail");
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
$this->redirect("FiberPlanPipe");
}
$fiberplanpipes = new FiberPlanPipe($id);
if ($fiberplanpipes->id != $id) {
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
$this->redirect("FiberPlanPipe");
}
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
$pipworkeraddresses = FiberPlanPipeModel::getPipeworkerAddresses();
$buildings = FiberPlanPipeModel::getBuildingInfoAll();
$fiberplanpipeendpoints = FiberPlanPipeEndpointModel::search(['fiberPlanPipe_id' => $id]);
$this->layout()->set("networks", $networks);
$this->layout()->set("buildings", $buildings);
$this->layout()->set("pipworkeraddresses", $pipworkeraddresses);
$this->layout()->set("fiberplanpipeendpoints", $fiberplanpipeendpoints);
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
$this->redirect("FiberPlanPipe");
}
$fiberplanpipes = new FiberPlanPipe($id);
if ($fiberplanpipes->id != $id) {
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden", "error");
$this->redirect("FiberPlanPipe");
}
$fiberplanpipeendpoints = FiberPlanPipeEndpointModel::search(['fiberPlanPipe_id' => $id]);
$this->layout()->set("fiberplanpipeendpoints", $fiberplanpipeendpoints);
$this->layout()->set("fiberplanpipes", $fiberplanpipes);
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
var_dump($r->get());
die();
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$fiberplanpipes = new FiberPlanPipe($id);
if (!$fiberplanpipes->id) {
$this->layout()->setFlash("Rohrverzeichnisse nicht gefunden", "error");
$this->redirect("FiberPlanPipe");
}
} else {
$mode = "add";
}
$data = [];
$data['description'] = trim($r->description);
$data['gisid'] = trim($r->gisid);
$data['type'] = trim($r->type);
$data['type_description'] = trim($r->type_description);
$data['fiberplanpipetemplate_id'] = trim($r->fiberplanpipetemplate_id);
$data['length'] = trim($r->length);
$data['status'] = trim($r->status);
$data['responsible'] = trim($r->responsible);
$data['responsible_text'] = trim($r->responsible_text);
$data['address_id'] = trim($r->address_id);
$data['comment'] = trim($r->comment);
$returnUrl = "FiberPlanPipe";
$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);
} else {
$returnUrlGen .= 'FiberPlanPipe';
}
$urlCounter++;
}
$returnAction = "";
$returnVariables['id'] = $id;
$returnUrl = $returnUrlGen;
} else {
$returnUrl = ucfirst($this->request->returnto);
}
}
if (!$data['description']) {
$this->layout()->setFlash("Bezeichnung darf nicht leer sein", "error");
$this->redirect("FiberPlanPipe");
}
if (!$data['type']) {
$data['type'] = NULL;
}
if (!$data['gisid']) {
$data['gisid'] = NULL;
}
if (!$data['responsible_text']) {
$data['responsible_text'] = NULL;
}
if (!$data['address_id']) {
$data['address_id'] = NULL;
}
if (!$data['type_description']) {
$data['type_description'] = NULL;
}
if (!$data['fiberplanpipetemplate_id']) {
$data['fiberplanpipetemplate_id'] = NULL;
}
if (!$data['length']) {
$data['length'] = NULL;
}
if (!$data['startpoint']) {
$data['startpoint'] = NULL;
}
if (!$data['endpoint']) {
$data['endpoint'] = NULL;
}
if (!$data['status']) {
$data['status'] = NULL;
}
if (!$data['responsible']) {
$data['responsible'] = NULL;
}
if (!$data['comment']) {
$data['comment'] = NULL;
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$fiberplanpipes->update($data);
} else {
$fiberplanpipes = FiberPlanPipeModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $fiberplanpipes->save();
$endpoint_id = $r->endpointid;
$endpoint_type = $r->endpoint_type;
$endpoint = $r->endpoint;
if (!empty($endpoint)) {
$counter = 1;
foreach ($endpoint as $key => $Endpoint) {
if ($endpoint_type[$key] == 4) {
$endpointarray['fiberPlanDispatcher_id'] = $Endpoint;
} else if ($endpoint_type[$key] == 2) {
$endpointarray['pop_id'] = $Endpoint;
}
$endpointarray['fiberPlanPipe_id'] = $id;
$endpointarray['sort'] = $counter;
if ($endpoint_id[$key]) {
$fiberplanpipeendpoint = new FiberPlanPipeEndpoint($id);
$fiberplanpipeendpoint->update($endpointarray);
} else {
$fiberplanpipeendpoint = FiberPlanPipeEndpointModel::create($endpointarray);
}
$fiberplanpipeendpoint->save();
$counter++;
}
}
if (!$id) {
$this->layout()->setFlash("Rohrverzeichnis konnte nicht angelegt werden", "error");
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
if ($mode == "edit") {
$this->layout()->setFlash("Rohrverzeichnis erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Rohrverzeichnis erfolgreich angelegt", "success");
}
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
protected function deleteAction()
{
$id = $this->request->id;
$fiberplanpipes = new FiberPlanPipe($id);
if (!$fiberplanpipes->id || $fiberplanpipes->id != $id) {
$this->layout()->setFlash("Rohrverzeichnis nicht gefunden.", "error");
$this->redirect("FiberPlanPipe");
}
$fiberplanpipes->delete();
$this->redirect("FiberPlanPipe");
}
protected function getBuildingInfo($network, $bdtype)
{
FiberPlanPipeModel::getBuildingInfo($network, $bdtype);
}
}
@@ -0,0 +1,376 @@
<?php
class FiberPlanPipeModel
{
private $network_id;
private $description;
private $gisid;
private $type;
private $type_description;
private $fiberplanpipetemplate_id;
private $length;
private $startpoint_type;
private $startpoint_network_id;
private $startpoint;
private $midpoint;
private $endpoint_network_id;
private $entpoint_type;
private $endpoint;
private $status;
private $responsible;
private $responsible_text;
private $address_id;
private $comment;
public static $type_descrition_definition = array(1 => "MR7", 2 => "MR14", 3 => "MR16", 4 => "MR20", 5 => "PE32", 6 => "PE40", 7 => "PE50", 8 => "KSR50", 9 => "KSR80", 10 => "KSR100");
public static $type_definition = array(1 => "Enzel", 2 => "Schutzrohr", 3 => "Verband");
public static function find($data)
{
}
public static function create(array $data)
{
$model = new FiberPlanPipe();
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("FiberPlanPipe", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanPipe($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("FiberPlanPipe", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipe($data);
}
}
return $items;
}
public static function getAllPipeManufacturer()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("FiberPlanPipeManufacturer", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipe($data);
}
}
return $items;
}
public static function getAllPipe()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT `FiberPlanPipe`.`id`,`FiberPlanPipe`.`description`,`FiberPlanPipe`.`type`,`FiberPlanPipe`.`type_description`,`FiberPlanPipe`.`startpoint_network_id`, `FiberPlanPipe`.`endpoint_network_id`,`FiberPlanPipeTemplate`. `fiberPlanPipeManufacturer_id`,`FiberPlanPipeTemplate`.`pipe7x4`,`FiberPlanPipeTemplate`.`pipe14x10` FROM `FiberPlanPipe`
LEFT JOIN `FiberPlanPipeTemplate` ON `FiberPlanPipe`.`fiberPlanPipeTemplate_id`=`FiberPlanPipeTemplate`.id";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipe($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("FiberPlanPipe", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanPipe($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("FiberPlanPipe", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipe($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 getTemplates()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT `FiberPlanPipeTemplate`.id,FiberPlanPipeTemplate.pipe7x4,FiberPlanPipeTemplate.pipe14x10,FiberPlanPipeManufacturer.name FROM `FiberPlanPipeTemplate` INNER JOIN FiberPlanPipeManufacturer ON FiberPlanPipeManufacturer.id=FiberPlanPipeTemplate.fiberPlanPipeManufacturer_id ";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipe($data);
}
}
return $items;
}
public static function getPipeworkerAddresses()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT `Addresstype`.`id`,`Address`.`company` FROM `Addresstype`
INNER JOIN `Address` ON (`Address`.`id`=`Addresstype`.`address_id`)
WHERE `type` = 'pipeworker' ORDER by `Address`.`company` ";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipe($data);
}
}
return $items;
}
public static function getBuildingInfo($network, $bdtype, $api = 1)
{
$items = [];
$db = FronkDB::singleton();
if ($bdtype == "1") {
$sql = "SELECT `id`,`description` `name` FROM `FiberPlanDispatcher` WHERE network_id='" . $network . "' AND `object_type`='3' ";
} else if ($bdtype == "2") {
$sql = "SELECT `Pop`.`id`,`Pop`.`name` FROM `PopNetwork`
INNER JOIN `Pop` ON (`Pop`.`id`=`PopNetwork`.`pop_id`)
WHERE `PopNetwork`.`network_id`='" . $network . "'";
} else if ($bdtype == "3") {
$sql = "SELECT `id`,`code` ,`street`, `zip`, `city` name FROM Building WHERE network_id='" . $network . "' ORDER by street";
} else if ($bdtype == "4") {
$sql = "SELECT `id`,`description` `name` FROM `FiberPlanDispatcher` WHERE network_id='" . $network . "' AND (`object_type`='1' OR `object_type`='2') ";
}
$res = $db->query($sql);
if ($db->num_rows($res)) {
$counter = 0;
while ($data = $db->fetch_array($res)) {
$items[$counter]['id'] = $data['id'];
if ($bdtype == "3") {
$items[$counter]['name'] = $data['street'] . " " . $data['zip'] . " " . $data['city'];
} else {
$items[$counter]['name'] = $data['name'];
}
$counter++;
}
}
if ($api === 1) {
echo json_encode($items);
exit;
} else {
return $items;
}
}
public static function getBuildingInfoAll()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT `id`, `fiberPlanDispatcher_id`, `name` FROM `FiberPlanDispatchersleeve` ORDER by id";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_array($res)) {
$sleeves[$data['fiberPlanDispatcher_id']][$data['id']] = $data['name'];
}
}
$sql = "SELECT '1' as `type`,'Greenfield' as `typename`,`id`,`description` as `name`,`gps_lat`,`gps_long` FROM `FiberPlanDispatcher` WHERE `object_type`='3'
UNION
SELECT '2' as `type`,'Pop' as `typename`,`id`,`name`,`gps_lat`,`gps_long` FROM `Pop`
UNION
SELECT '3' as `type`,'Building' as `typename`,`id`,CONCAT_WS(' ',`street`, `zip`, `city`) as name,`gps_lat`,`gps_long` FROM Building
UNION
SELECT '4' as `type`,'Schacht-Verteiler' as `typename`,`id`,`description` as `name`,`gps_lat`,`gps_long` FROM `FiberPlanDispatcher` WHERE (`object_type`='1' OR `object_type`='2')";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_array($res)) {
$items[$data['type']][$data['id']] = $data;
if ($data['type'] == 4) {
$items[$data['type']][$data['id']]['sleeves'] = $sleeves[$data['id']];
}
}
}
return $items;
}
public static function generateEndpoints($endpoints, $networks)
{
foreach ($networks as $network) {
$Network[$network->id] = $network->name;
}
$counter = 1;
$endpointuparrow = "";
$typeArray[1] = 'Greenfield';
$typeArray[2] = 'POP';
$typeArray[3] = 'Building';
$typeArray[4] = 'Schacht-Verteiler';
// print_r($buildings);
$counter = 1;
foreach ($endpoints as $Endpoint) {
if ($Endpoint->pop_id) {
$networkid = $Endpoint->pop->network_id;
$endpointid = $Endpoint->pop->id;
$endpointtype = 2;
} else if ($Endpoint->fiberPlanDispatcher_id) {
$networkid = $Endpoint->fiberPlanDispatcher->network_id;
$endpointid = $Endpoint->fiberPlanDispatcher->id;
if ($Endpoint->fiberPlanDispatcher->object_type == 3) {
$endpointtype = 1;
} else {
$endpointtype = 4;
}
} else if ($Endpoint->building_id) {
$networkid = $Endpoint->building->network_id;
$endpointid = $Endpoint->building->id;
$endpointtype = 3;
}
$randid = rand(1000, 10000);
if ($counter > 1) {
$Endpointuparrow = '<i title="nach oben verschieben" class="fa-sharp fa-solid fa-up move-endpoint-up"></i>';
}
if ($counter == 1) {
$endpointType = "Startpunkt";
$endpointsymbol = '<span class="endpointsymbol"><i id="add-endpoint" class="fa-regular fa-circle-plus"></i></span>';
}
else if (count($endpoints)==2)
{
$endpointcount = $counter - 1;
$endpointType = "Standort " . $endpointcount;
$endpointsymbol='<span class="endpointsymbol">';
}
else {
$endpointcount = $counter - 1;
$endpointType = "Standort " . $endpointcount;
$endpointsymbol = '<span class="endpointsymbol"><i class="fa-regular fa-circle-minus remove-endpoint"></i></span>';
}
$html = '<div class="form-group row endpoint-maindiv">
<label class="col-lg-2 col-form-label endpoint-label" for="' . $randid . '_endpoint_network_id"><span class="label-text">' . $endpointType . ' * </span>' . $Endpointuparrow . $endpointsymbol . '</label>
<div class="col-lg-2"><select id="' . $randid . '_endpoint_network_id" required="required" name="endpoint_network_id[]" class="select2 form-control endpoint_network_id">';
foreach ($networks as $network) {
if ($network->id == $networkid) {
$html .= '<option selected="selected" value="' . $network->id . '">' . $network->name . '</option>';
} else {
$html .= '<option value="' . $network->id . '">' . $network->name . '</option>';
}
}
$html .= '</select></div>
<div class="col-lg-2 ">
<select id="' . $randid . '_endpoint_type" name="endpoint_type[]" required="required" class="select2 form-control endpoint_type" >';
foreach ($typeArray as $key => $type) {
if ($key == $endpointtype) {
$html .= '<option selected="selected" value="' . $key . '">' . $type . '</option>';
} else {
$html .= '<option value="' . $key . '">' . $type . '</option>';
}
}
$html .= '</select></div>
<div class="col-lg-2" id="' . $randid . '_end-point-building">
<select id=' . $randid . '_endpoint" required="required" name="endpoint[]" class="select2 form-control">';
$buildings = FiberPlanPipeModel::getBuildingInfo($networkid, $endpointtype, 0);
foreach ($buildings as $key => $building) {
if ($building['id'] == $endpointid) {
$html .= '<option selected="selected" value="' . $building['id'] . '">' . $building['name'] . '</option>';
} else {
$html .= '<option value="' . $building['id'] . '">' . $building['name'] . '</option>';
}
}
$html .= '</select><input type="hidden" name="endpointid[]" value="' . $Endpoint->id . '" ></div></div>';
echo $html;
$counter++;
}
}
}
@@ -0,0 +1,64 @@
<?php
class FiberPlanPipeEndpoint extends mfBaseModel
{
private $editor;
private $creator;
private $fiberPlanPipe;
private $pop;
private $fiberPlanDispatcher;
private $building;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if ($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
if ($this->creator === null) {
$this->creator = new User($this->create_by);
if ($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
}
}
return $this->creator;
}
if ($name == "editor") {
$this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
if ($this->editor === null) {
$this->editor = new User($this->edit_by);
if ($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name . "_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield);
if (!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if ($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name);
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}
@@ -0,0 +1,145 @@
<?php
class FiberPlanPipeEndpointController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("FiberPlanPipeEndpoint/Index");
$fiberplanpipeendpoints = FiberPlanPipeEndpointModel::getAll();
$this->layout()->set("fiberplanpipeendpoints", $fiberplanpipeendpoints);
}
protected function addAction()
{
$fiberPlanPipes=FiberPlanPipeModel::getAll();
$this->layout()->set("fiberPlanPipes", $fiberPlanPipes);
$pops=PopModel::getAll();
$this->layout()->set("pops", $pops);
$fiberPlanDispatchers=FiberPlanDispatcherModel::getAll();
$this->layout()->set("fiberPlanDispatchers", $fiberPlanDispatchers);
$buildings=BuildingModel::getAll();
$this->layout()->set("buildings", $buildings);
$this->layout()->setTemplate("FiberPlanPipeEndpoint/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("dfsdf nicht gefunden", "error");
$this->redirect("FiberPlanPipeEndpoint");
}
$fiberplanpipeendpoints = new FiberPlanPipeEndpoint($id);
if ($fiberplanpipeendpoints->id != $id) {
$this->layout()->setFlash("dfsdf nicht gefunden", "error");
$this->redirect("FiberPlanPipeEndpoint");
}
$this->layout()->set("fiberplanpipeendpoints", $fiberplanpipeendpoints);
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$fiberplanpipeendpoints = new FiberPlanPipeEndpoint($id);
if (!$fiberplanpipeendpoints->id) {
$this->layout()->setFlash("sdfsdf nicht gefunden", "error");
$this->redirect("FiberPlanPipeEndpoint");
}
} else {
$mode = "add";
}
$data = [];
$data['fiberPlanPipe_id'] = trim($r->fiberPlanPipe_id);
$data['pop_id'] = trim($r->pop_id);
$data['fiberPlanDispatcher_id'] = trim($r->fiberPlanDispatcher_id);
$data['building_id'] = trim($r->building_id);
$data['sort'] = trim($r->sort);
if (!$data['fiberPlanPipe_id']) {
$data['fiberPlanPipe_id']=NULL;
}
if (!$data['pop_id']) {
$data['pop_id']=NULL;
}
if (!$data['fiberPlanDispatcher_id']) {
$data['fiberPlanDispatcher_id']=NULL;
}
if (!$data['building_id']) {
$data['building_id']=NULL;
}
if (!$data['sort']) {
$data['sort']=NULL;
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$fiberplanpipeendpoints->update($data);
} else {
$fiberplanpipeendpoints = FiberPlanPipeEndpointModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $fiberplanpipeendpoints->save();
if (!$id) {
$this->layout()->setFlash("dfsdf konnte nicht angelegt werden", "error");
$this->redirect("FiberPlanPipeEndpoint");
}
if ($mode == "edit") {
$this->layout()->setFlash("dfsdf erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("dfsdf erfolgreich angelegt", "success");
}
$this->redirect("FiberPlanPipeEndpoint");
}
protected function deleteAction()
{
$id = $this->request->id;
$fiberplanpipeendpoints = new FiberPlanPipeEndpoint($id);
if (!$fiberplanpipeendpoints->id || $fiberplanpipeendpoints->id != $id) {
$this->layout()->setFlash("dfsdf nicht gefunden.", "error");
$this->redirect("FiberPlanPipeEndpoint");
}
$fiberplanpipeendpoints->delete();
$this->redirect("FiberPlanPipeEndpoint");
}
}
@@ -0,0 +1,129 @@
<?php
class FiberPlanPipeEndpointModel
{
private $fiberPlanPipe_id;
private $pop_id;
private $fiberPlanDispatcher_id;
private $building_id;
private $sort;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new FiberPlanPipeEndpoint();
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("FiberPlanPipeEndpoint", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanPipeEndpoint($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("FiberPlanPipeEndpoint", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipeEndpoint($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("FiberPlanPipeEndpoint", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanPipeEndpoint($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("FiberPlanPipeEndpoint", "*", "$where ORDER by sort");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipeEndpoint($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("fiberPlanPipe_id", $filter)) {
$fiberPlanPipe_id = $filter['fiberPlanPipe_id'];
if (is_numeric($fiberPlanPipe_id)) {
$where .= " AND fiberPlanPipe_id=$fiberPlanPipe_id";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}
@@ -0,0 +1,42 @@
<?php
class FiberPlanPipeManufacturer extends mfBaseModel
{
private $editor;
private $creator;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if ($name == "creator") {
$this->creator = new User($this->create_by);
return $this->creator;
}
if ($name == "editor") {
$this->editor = new User($this->edit_by);
return $this->editor;
}
$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;
}
}
@@ -0,0 +1,126 @@
<?php
class FiberPlanPipeManufacturerModel
{
private $name;
private $colors;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new FiberPlanPipeManufacturer();
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("FiberPlanPipeManufacturer", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanPipeManufacturer($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("FiberPlanPipeManufacturer", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipeManufacturer($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("FiberPlanPipeManufacturer", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanPipeManufacturer($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("FiberPlanPipeManufacturer", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipeManufacturer($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;
}
}
@@ -0,0 +1,43 @@
<?php
class FiberPlanPipeTemplate extends mfBaseModel
{
private $editor;
private $creator;
private $fiberPlanPipeManufacturer;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if ($name == "creator") {
$this->creator = new User($this->create_by);
return $this->creator;
}
if ($name == "editor") {
$this->editor = new User($this->edit_by);
return $this->editor;
}
$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;
}
}
@@ -0,0 +1,127 @@
<?php
class FiberPlanPipeTemplateModel
{
private $fiberplanpipemanufacturer_id;
private $pipe7x4;
private $pipe14x10;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new FiberPlanPipeTemplate();
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("FiberPlanPipeTemplate", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanPipeTemplate($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("FiberPlanPipeTemplate", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipeTemplate($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("FiberPlanPipeTemplate", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new FiberPlanPipeTemplate($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("FiberPlanPipeTemplate", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new FiberPlanPipeTemplate($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;
}
}