Mobile Integration,Pop Multiple Networks,DataTables responsible update,Migrations
Mobile Integration: * in footer.php js eingefügt damit das mobile Menu funktioniert * in menu.php bzw. app.css neue Klasse eingefügt mobile-hide um in der mobilen Version Menupünkte zu verstecken Pop Multiple Networks * Pops können nun mehrere Netzgebiete haben * Netzgebiete und Pop ansicht angepasst * (Script muss ausgeführt werden um die PopNetwork Table vom Bestand zu befüllen) DataTables responsible update * Datatables update und responsible addon * Diverse Anpassungen für Responsible in: - Pops, Geräte Hersteller, Geräte Typen, Devices, Benutzer Migrations * PopNetwork * Poprackmodulepatch
This commit is contained in:
@@ -114,7 +114,7 @@ class Network extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "pops") {
|
||||
$pops = PopModel::search(['network_id' => $this->id]);
|
||||
$pops = PopNetworkModel::search(['network_id' => $this->id]);
|
||||
$this->pops = $pops;
|
||||
return $this->pops;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ class PopController extends mfBaseController
|
||||
{
|
||||
|
||||
$this->layout()->setTemplate("Pop/Index");
|
||||
$pops = PopModel::getAll();
|
||||
$pops = PopModel::getAlladv();
|
||||
|
||||
$this->layout()->set("pops", $pops);
|
||||
|
||||
}
|
||||
@@ -40,7 +41,8 @@ class PopController extends mfBaseController
|
||||
$this->layout()->setFlash("Pop nicht gefunden", "error");
|
||||
$this->redirect("Pop");
|
||||
}
|
||||
|
||||
$popnetwork = PopNetworkModel::getbyPopid($id);
|
||||
$this->layout()->set("popnetwork", implode(', ' , $popnetwork['name']));
|
||||
$this->layout()->setTemplate("Pop/Detail");
|
||||
$filter['pop_id'] = $id;
|
||||
$this->layout()->set("popracks", PoprackModel::getAllbyPop($id));
|
||||
@@ -76,6 +78,8 @@ class PopController extends mfBaseController
|
||||
$this->redirect("Network");
|
||||
}
|
||||
|
||||
$popnetwork = PopNetworkModel::getbyPopid($id);
|
||||
$this->layout()->set("popnetwork", $popnetwork['network_id']);
|
||||
$this->layout()->set("pop", $pop);
|
||||
return $this->addAction();
|
||||
}
|
||||
@@ -106,7 +110,8 @@ class PopController extends mfBaseController
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['network_id'] = $r->network_id;
|
||||
|
||||
|
||||
$data['name'] = $r->name;
|
||||
$data['gps_lat'] = ($r->gps_lat) ? $r->gps_lat : null;
|
||||
$data['gps_long'] = ($r->gps_long) ? $r->gps_long : null;
|
||||
@@ -127,11 +132,34 @@ class PopController extends mfBaseController
|
||||
|
||||
|
||||
$new_id = $pop->save();
|
||||
|
||||
|
||||
if (!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->layout()->set("network", $network);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
if ($r->network_id) {
|
||||
$oldPopnetworks = json_encode(PopNetworkModel::getbyPopid($new_id));
|
||||
|
||||
|
||||
$result = array_diff($r->network_id, $oldPopnetworks);
|
||||
|
||||
if ($oldPopnetworks != json_encode($r->network_id)) {
|
||||
PopNetworkModel::deletebyPopid($new_id);
|
||||
unset($data);
|
||||
$data = [];
|
||||
foreach ($r->network_id as $networkid) {
|
||||
$data['network_id'] = $networkid;
|
||||
$data['pop_id'] = $new_id;
|
||||
$popNetwork = PopNetworkModel::create($data);
|
||||
$popNetwork->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->request->returnto) {
|
||||
$returnAction = "Index";
|
||||
$returnVariables = array();
|
||||
|
||||
@@ -1,130 +1,163 @@
|
||||
<?php
|
||||
|
||||
class PopModel {
|
||||
public $name = null;
|
||||
public $network_id = null;
|
||||
public $gps_lat = null;
|
||||
public $gps_long = null;
|
||||
public $location = null;
|
||||
public $vlan_public = null;
|
||||
public $vlan_nat = null;
|
||||
public $vlan_ipv6 = null;
|
||||
|
||||
public $note = 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 Pop();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
if(substr($field, 0, 5) == "vlan_" && !$value) {
|
||||
$model->$field = null;
|
||||
continue;
|
||||
class PopModel
|
||||
{
|
||||
public $name = null;
|
||||
public $network_id = null;
|
||||
public $gps_lat = null;
|
||||
public $gps_long = null;
|
||||
public $location = null;
|
||||
public $vlan_public = null;
|
||||
public $vlan_nat = null;
|
||||
public $vlan_ipv6 = null;
|
||||
|
||||
public $note = 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 Pop();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = mfValuecache::singleton()->get("me");
|
||||
if(!$me) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
mfValuecache::singleton()->set("me", $me);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
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("Pop", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Pop($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Pop", "*","1=1 ORDER by name");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Pop($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Pop", "*", "$where ORDER BY name, network_id");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Pop($data);
|
||||
if($item->id) {
|
||||
public static function getOne($id)
|
||||
{
|
||||
if (!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Pop", "*", "id=$id LIMIT 1");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Pop($data);
|
||||
}
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Pop", "*", "$where ORDER BY name, network_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Pop($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";
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Pop", "*", "1=1 ORDER by name");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new Pop($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
public static function getAlladv()
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT `Pop`.`id`, `Pop`.`network_id`, `Pop`.`name`, `Pop`.`gps_lat`, `Pop`.`gps_long`, `Pop`.`location`, `Pop`.`vlan_public`, `Pop`.`vlan_nat`, `Pop`.`vlan_ipv6`, `Pop`.`note`,`Network`.`name` as Networkname FROM `Pop`
|
||||
INNER JOIN `PopNetwork` ON (`Pop`.`id`=`PopNetwork`.`pop_id`)
|
||||
INNER JOIN `Network` ON (`Network`.`id`=`PopNetwork`.`network_id`)";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$Pops[$data['id']]['data'] = $data;
|
||||
$Pops[$data['id']]['networks'][] = $data['Networkname'];
|
||||
}
|
||||
}
|
||||
foreach ($Pops as $key => $Pop) {
|
||||
$Pop['data']['networks'] = implode(', ', $Pop['networks']);
|
||||
$items[] = new Pop((object)$Pop['data']);
|
||||
}
|
||||
|
||||
|
||||
return $items;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst()
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Pop", "*", "$where ORDER BY name, network_id");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Pop($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("Pop", "*", "$where ORDER BY name, network_id");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new Pop($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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
44
application/PopNetwork/PopNetwork.php
Normal file
44
application/PopNetwork/PopNetwork.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
class PopNetwork extends mfBaseModel
|
||||
{
|
||||
private $editor;
|
||||
private $creator;
|
||||
private $pop;
|
||||
private $network;
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
154
application/PopNetwork/PopNetworkModel.php
Normal file
154
application/PopNetwork/PopNetworkModel.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
class PopNetworkModel
|
||||
{
|
||||
private $pop_id;
|
||||
private $network_id;
|
||||
|
||||
|
||||
public static function find($data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function create(array $data)
|
||||
{
|
||||
$model = new PopNetwork();
|
||||
|
||||
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("PopNetwork", "*", "id=$id LIMIT 1");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new PopNetwork($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("PopNetwork", "*", "1=1");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new PopNetwork($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getbyPopid($pop_id)
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$sql = "SELECT `PopNetwork`.`id`,`PopNetwork`.`network_id`,`Network`.`name` FROM `PopNetwork`
|
||||
INNER JOIN `Network` ON (`Network`.`id`=`PopNetwork`.`network_id`)
|
||||
WHERE `PopNetwork`.`pop_id`='" . $pop_id . "'";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$items['network_id'][] = $data['network_id'];
|
||||
$items['name'][] = $data['name'];
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function deletebyPopid($pop_id)
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "DELETE FROM `PopNetwork` WHERE `pop_id`='" . $pop_id . "'";
|
||||
$db->query($sql);
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst()
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("PopNetwork", "*", "$where ");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new PopNetwork($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("PopNetwork", "*", "$where");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new PopNetwork($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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -173,6 +173,28 @@ class PoprackModel
|
||||
$response['success'] = true;
|
||||
|
||||
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
public static function getdispatchersleeve($dispatcher_id)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT `id`, `name` FROM `FiberPlanDispatchersleeve` WHERE fiberPlanDispatcher_id='" . $dispatcher_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;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class PoprackmoduleController extends mfBaseController
|
||||
|
||||
private function addModule()
|
||||
{
|
||||
$ports = 0;
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
$data = [];
|
||||
@@ -40,7 +41,9 @@ class PoprackmoduleController extends mfBaseController
|
||||
$data['type'] = $r->type;
|
||||
if ($data['type'] == 0) {
|
||||
$data['ports'] = ($r->ports) ? $r->ports : null;
|
||||
$ports = $data['ports'];
|
||||
$data['plug'] = ($r->plug) ? $r->plug : null;
|
||||
|
||||
}
|
||||
if ($data['type'] == 1) {
|
||||
$data['device_id'] = ($r->device_id) ? $r->device_id : null;
|
||||
@@ -59,6 +62,16 @@ class PoprackmoduleController extends mfBaseController
|
||||
$response['success'] = false;
|
||||
} else {
|
||||
$response['success'] = true;
|
||||
if ($data['type'] == 0) {
|
||||
unset($data);
|
||||
$data = [];
|
||||
$data['poprackmodule_id'] = $new_id;
|
||||
for ($i = 1; $i <= $ports; $i++) {
|
||||
$data['port'] = $i;
|
||||
$poprackmodulepatch = PoprackmodulepatchModel::create($data);
|
||||
$poprackmodulepatch->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
@@ -82,12 +95,26 @@ class PoprackmoduleController extends mfBaseController
|
||||
if ($r->type == 0) {
|
||||
$data['ports'] = ($r->ports) ? $r->ports : null;
|
||||
$data['plug'] = ($r->plug) ? $r->plug : null;
|
||||
$poprackmodulepatchcounter = PoprackmodulepatchModel::countAllModule($id);
|
||||
if ($poprackmodulepatchcounter > $data['ports']) {
|
||||
for ($i = $poprackmodulepatchcounter; $i > $data['ports']; $i--) {
|
||||
PoprackmodulepatchModel::deletebyPort($id, $i);
|
||||
}
|
||||
|
||||
} else if ($poprackmodulepatchcounter < $data['ports']) {
|
||||
$datapatchModel=[];
|
||||
for ($i = $poprackmodulepatchcounter + 1; $i <= $data['ports']; $i++) {
|
||||
$datapatchModel['poprackmodule_id'] = $id;
|
||||
$datapatchModel['port'] = $i;
|
||||
$poprackmodulepatch = PoprackmodulepatchModel::create($datapatchModel);
|
||||
$poprackmodulepatch->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$data['name'] = ($r->name);
|
||||
$poprackmodule->update($data);
|
||||
|
||||
$new_id = $poprackmodule->save();
|
||||
// var_dump($r);die();
|
||||
if (!$new_id) {
|
||||
$response['success'] = false;
|
||||
} else {
|
||||
|
||||
44
application/Poprackmodulepatch/Poprackmodulepatch.php
Normal file
44
application/Poprackmodulepatch/Poprackmodulepatch.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
class Poprackmodulepatch extends mfBaseModel
|
||||
{
|
||||
private $editor;
|
||||
private $creator;
|
||||
private $poprackmodule;
|
||||
private $fiberPlanCable;
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
108
application/Poprackmodulepatch/PoprackmodulepatchModel.php
Normal file
108
application/Poprackmodulepatch/PoprackmodulepatchModel.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
class PoprackmodulepatchModel
|
||||
{
|
||||
private $poprackmodule_id;
|
||||
private $port;
|
||||
private $fiberPlanCable_id;
|
||||
private $destination;
|
||||
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 Poprackmodulepatch();
|
||||
|
||||
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("Poprackmodulepatch", "*", "id=$id LIMIT 1");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Poprackmodulepatch($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function countAllModule($moduleId)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT `id` FROM `Poprackmodulepatch` WHERE `poprackmodule_id`='" . $moduleId . "'";
|
||||
|
||||
$res = $db->query($sql);
|
||||
$countrows = $db->num_rows($res);
|
||||
return $countrows;
|
||||
}
|
||||
|
||||
public static function deletebyPort($moduleId, $port)
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "DELETE FROM `Poprackmodulepatch` WHERE `port`='" . $port . "' AND `poprackmodule_id`='" . $moduleId . "'";
|
||||
$res = $db->query($sql);
|
||||
}
|
||||
|
||||
public static function updatebyPort($moduleId, $port, $fiberPlanCable_id)
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "UPDATE `Poprackmodulepatch` SET fiberPlanCable_id='" . $fiberPlanCable_id . "' WHERE `port`='" . $port . "' AND `poprackmodule_id`='" . $moduleId . "'";
|
||||
echo $sql . "\n";
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
public static function updatebyPortRange($moduleId, $startport, $endport, $fiberPlanCable_id)
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "UPDATE `Poprackmodulepatch` SET fiberPlanCable_id='" . $fiberPlanCable_id . "' WHERE `port`>='" . $startport . "' AND `port`<='" . $endport . "' AND `poprackmodule_id`='" . $moduleId . "'";
|
||||
echo $sql . "\n";
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
public static function clearPort($fiberPlanCable_id)
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "UPDATE `Poprackmodulepatch` SET fiberPlanCable_id=NULL WHERE `fiberPlanCable_id`='" . $fiberPlanCable_id . "'";
|
||||
$db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user