Added Role view to Network
This commit is contained in:
@@ -131,7 +131,6 @@
|
||||
<option value="pipeplanner" <?=(array_key_exists("pipeplanner", $address->types)) ? "selected='selected'" : "pipeplanner"?>><?=__("pipeplanner")?></option>
|
||||
<option value="lineplanner" <?=(array_key_exists("lineplanner", $address->types)) ? "selected='selected'" : "lineplanner"?>><?=__("lineplanner")?></option>
|
||||
<option value="netoperator" <?=(array_key_exists("netoperator", $address->types)) ? "selected='selected'" : "netoperator"?>><?=__("netoperator")?></option>
|
||||
<option value="planner" <?=(array_key_exists("planner", $address->types)) ? "selected='selected'" : "planner"?>><?=__("planner")?></option>
|
||||
<option value="support" <?=(array_key_exists("support", $address->types)) ? "selected='selected'" : "support"?>><?=__("support")?></option>
|
||||
<option value="billing" <?=(array_key_exists("billing", $address->types)) ? "selected='selected'" : ""?>><?=__("billing")?></option>
|
||||
<option value="employee" <?=(array_key_exists("employee", $address->types)) ? "selected='selected'" : ""?>><?=__("employee")?></option>
|
||||
|
||||
@@ -125,19 +125,34 @@
|
||||
<h4>Berechtigungen</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php if(is_array($network->pops) && count($network->pops)): ?>
|
||||
<?php if(is_array($network->addresstypes) && count($network->addresstypes)): ?>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>GPS (Breite, Länge)</th>
|
||||
<th>Standortinfo</th>
|
||||
<?php foreach(['netowner','salespartner','pipeworker','lineworker','pipeplanner','lineplanner','netoperator',] as $role): ?>
|
||||
<th><?=__($role)?></th>
|
||||
<?php endforeach ?>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($network->pops as $pop): ?>
|
||||
<?php foreach($network->addresstypes as $address_id => $addresstypes): ?>
|
||||
<tr>
|
||||
<td><?=$pop->name?></td>
|
||||
<td><?=$pop->gps_lat?>, <?=$pop->gps_long?></td>
|
||||
<td><?=nl2br($pop->location)?></td>
|
||||
<td><?=AddressModel::getOne($address_id)->getCompanyOrName()?></td>
|
||||
<?php foreach(TT_NETWORK_ROLES as $role): ?>
|
||||
<td>
|
||||
<?php if(AddresstypeModel::getFirst(['address_id' => $address_id, 'addresstype' => [$role]]) !== null): ?>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="role_<?=$role?>[<?=$address_id?>]"
|
||||
value="1"
|
||||
<?php foreach($addresstypes as $type): ?>
|
||||
<?php if($type->type == $role): ?>
|
||||
checked='checked'
|
||||
<?php continue; endif; ?>
|
||||
<?php endforeach; ?>
|
||||
/>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
<td class="controls" style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Pop", "edit", ["id" => $pop->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Pop", "delete", ["id" => $pop->id])?>" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
|
||||
@@ -33,7 +33,7 @@ class Address extends mfBaseModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->types = AddresstypeModel::search(['address_id' => $this->id]);
|
||||
$this->types = AddresstypeModel::search(['address_id' => $this->id], true);
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
|
||||
@@ -19,11 +19,7 @@ class AddressModel {
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
public static function find($data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new Address();
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
<?php
|
||||
|
||||
class Addresstype extends mfBaseModel {
|
||||
private $address;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$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;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,29 @@ class AddresstypeModel {
|
||||
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
$log->debug(print_r($filter,true));
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Addresstype.* FROM Addresstype
|
||||
WHERE $where
|
||||
ORDER BY address_id ASC, `primary` DESC, type ASC";
|
||||
$log->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new NetworkAddress($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter, $indexByType = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
@@ -73,11 +95,15 @@ class AddresstypeModel {
|
||||
$sql = "SELECT Addresstype.* FROM Addresstype
|
||||
WHERE $where
|
||||
ORDER BY address_id ASC, `primary` DESC, type ASC";
|
||||
//var_dump($sql);
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->type] = new Addresstype($data);
|
||||
while($data = $db->fetch_object($res)) {
|
||||
if($indexByType) {
|
||||
$items[$data->type] = new Addresstype($data);
|
||||
} else {
|
||||
$items[] = new Addresstype($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -99,7 +125,7 @@ class AddresstypeModel {
|
||||
$in[] = "Addresstype.type = 'netowner'";
|
||||
}
|
||||
if(in_array("salespartner", $at)) {
|
||||
$in[] = "Addresstype.type = 'Addresstype'";
|
||||
$in[] = "Addresstype.type = 'salespartner'";
|
||||
}
|
||||
if(in_array("pipeworker", $at)) {
|
||||
$in[] = "Addresstype.type = 'pipeworker'";
|
||||
@@ -107,6 +133,12 @@ class AddresstypeModel {
|
||||
if(in_array("lineworker", $at)) {
|
||||
$in[] = "Addresstype.type = 'lineworker'";
|
||||
}
|
||||
if(in_array("pipeplanner", $at)) {
|
||||
$in[] = "Addresstype.type = 'pipeplanner'";
|
||||
}
|
||||
if(in_array("lineplanner", $at)) {
|
||||
$in[] = "Addresstype.type = 'lineplanner'";
|
||||
}
|
||||
if(in_array("netoperator", $at)) {
|
||||
$in[] = "Addresstype.type = 'netoperator'";
|
||||
}
|
||||
|
||||
@@ -3,6 +3,36 @@
|
||||
class Network extends mfBaseModel {
|
||||
private $owner;
|
||||
private $pops;
|
||||
private $addresstypes;
|
||||
private $roles;
|
||||
|
||||
public function loadAddresstypes() {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//$this->loadRoles();
|
||||
|
||||
$types = NetworkAddressModel::search(['network_id' => $this->id]);
|
||||
|
||||
foreach($types as $type) {
|
||||
$this->addresstypes[$type->address_id][] = $type;
|
||||
}
|
||||
|
||||
//var_dump($this->addresstypes);exit;
|
||||
}
|
||||
|
||||
public function loadRoles() {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$types = AddresstypeModel::search(['addresstype' => TT_NETWORK_ROLES]);
|
||||
var_dump($types);exit;
|
||||
foreach($types as $type) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
@@ -26,6 +56,15 @@ class Network extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if($name == "addresstypes") {
|
||||
if($this->id) {
|
||||
$this->loadAddresstypes();
|
||||
return $this->addresstypes;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
@@ -17,6 +17,10 @@ class NetworkController extends mfBaseController {
|
||||
protected function indexAction() {
|
||||
$this->layout()->set("owners", AddressModel::search(['addresstype' => ["netowner"]]));
|
||||
$this->layout()->set("networks", NetworkModel::getAll());
|
||||
|
||||
/*$net = new Network(1);
|
||||
$at = $net->addresstypes; //[1]->addresstype->address;
|
||||
var_dump($at);exit;*/
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
|
||||
@@ -10,10 +10,7 @@ class NetworkModel {
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
public static function find($data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new Network();
|
||||
|
||||
@@ -60,7 +57,7 @@ class NetworkModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Network", "*". "$where ORDER BY name, owner_id");
|
||||
$res = $db->select("Network", "*", "$where ORDER BY name, owner_id");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Network($data);
|
||||
@@ -78,7 +75,7 @@ class NetworkModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Network", "*". "$where ORDER BY name, owner_id");
|
||||
$res = $db->select("Network", "*", "$where ORDER BY name, owner_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Network($data);
|
||||
|
||||
23
application/NetworkAddress/NetworkAddress.php
Normal file
23
application/NetworkAddress/NetworkAddress.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
class NetworkAddress extends mfBaseModel {
|
||||
private $network;
|
||||
private $address;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$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;
|
||||
}
|
||||
}
|
||||
108
application/NetworkAddress/NetworkAddressModel.php
Normal file
108
application/NetworkAddress/NetworkAddressModel.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
class NetworkAddressModel {
|
||||
public $network_id = null;
|
||||
public $address_id = null;
|
||||
public $type = null;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new NetworkAddress();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model ->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
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("NetworkAddress", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new NetworkAddress($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("NetworkAddress", "*");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new NetworkAddress($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("NetworkAddress", "*", "$where ORDER BY `type`");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new NetworkAddress($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("NetworkAddress", "*", "$where ORDER BY `type`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new NetworkAddress($data->id);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("network_id", $filter)) {
|
||||
$network_id = $filter['network_id'];
|
||||
if(is_numeric($network_id)) {
|
||||
$where .= " AND network_id=$network_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("address_id", $filter)) {
|
||||
$address_id = $filter['address_id'];
|
||||
if(is_numeric($address_id)) {
|
||||
$where .= " AND address_id=$address_id";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,9 @@ define("LOGFILENAME",BASEDIR."/var/log/".MFAPPNAME.".log");
|
||||
* Application-specific settings
|
||||
*/
|
||||
|
||||
define("TT_ROLES", ['systemowner','netowner','salespartner','pipeworker','lineworker','pipeplanner','lineplanner','netoperator','support','billing','employee','customer','supplier','contact']);
|
||||
define("TT_NETWORK_ROLES", ['netowner','salespartner','pipeworker','lineworker','pipeplanner','lineplanner','netoperator']);
|
||||
|
||||
|
||||
// Upload settings
|
||||
define('MFUPLOAD_FILE_SAVE_PATH',BASEDIR.'/files'); // folder where files will be stored
|
||||
@@ -35,7 +38,6 @@ define('MFLOCALE_TIME', "de_AT.UTF-8");
|
||||
define('MFLOCALE_MONETARY', "de_AT.UTF-8");
|
||||
define('MFLOCALE_NUMERIC', "de_AT.UTF-8");
|
||||
|
||||
|
||||
/*
|
||||
* Maintainer / developer settings
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user