Added Network
This commit is contained in:
97
Layout/default/Network/Form.php
Normal file
97
Layout/default/Network/Form.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
|
||||
<div class="wrapper">
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Network")?>">Netzgebiete</a></li>
|
||||
<li class="breadcrumb-item active"><?=($network->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Netzgebiete</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?=($network->id) ? "Netzbereich bearbeiten" : "Neuer Netzbereich"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Network", "save")?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<input type="hidden" name="id" value="<?=$network->id?>" />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="name">Name</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="name" id="name" value="<?=$network->name?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="owner_id">Besitzer</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="select2 form-control " name="owner_id" id="owner_id">
|
||||
<option></option>
|
||||
<?php foreach($owners as $owner): ?>
|
||||
<option value="<?=$owner->id?>" <?=($network->owner_id == $owner->id) ? "selected='selected'" : ""?>><?=($owner->getCompanyOrName())?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
||||
<div class="col-lg-10">
|
||||
<textarea id="note" class="form-control" name="note" rows="5"><?=$network->note?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!-- end container-fluid -->
|
||||
</div>
|
||||
<!-- end wrapper -->
|
||||
|
||||
<script type="text/javascript">
|
||||
$("#parent_id").select2({
|
||||
allowClear: true,
|
||||
placeholder: ""
|
||||
});
|
||||
$("#addresstypes").select2();
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
78
Layout/default/Network/Index.php
Normal file
78
Layout/default/Network/Index.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
|
||||
<div class="wrapper">
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>">the-tool</a></li>
|
||||
<?php if(is_array($filter['addresstype']) && count($filter['addresstype'])): ?>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Address")?>">Netzgebiete</a></li>
|
||||
<li class="breadcrumb-item active">
|
||||
<?php foreach($filter['addresstype'] as $type) { $types[] = __($type); } ?>
|
||||
<?=implode(", ", $types)?>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li class="breadcrumb-item active">Netzgebiete</li>
|
||||
<?php endif; ?>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Netzgebiete</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title mb-4">Liste aller Netzgebiete</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary" href="<?=self::getUrl("Network", "add")?>"><i class="fas fa-plus"></i> Neues Netzgebiet anlegen</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(is_array($networks) && count($networks)): ?>
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Besitzer</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($networks as $network): ?>
|
||||
<tr>
|
||||
<td><?=$network->name?></td>
|
||||
<td><?=nl2br($network->owner->getFullName())?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Pop", "Index", ["filter" => ["network_id" => $network->id]])?>" title="POPs anzeigen"><i class="fas fa-project-diagram"></i></a>
|
||||
<a href="<?=self::getUrl("Network", "edit", ["id" => $network->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Network", "delete", ["id" => $network->id])?>" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<div class="row"><p class="col-md-12"><i>Keine Netzgebiete gefunden</i></p></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!-- end container-fluid -->
|
||||
</div>
|
||||
<!-- end wrapper -->
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
@@ -21,9 +21,9 @@
|
||||
<li><a href="<?=self::getUrl("Address", "Index" , ["filter" => ["addresstype" => ["supplier"]]])?>">Lieferanten</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?=self::getUrl("User")?>">Benutzer</a>
|
||||
</li>
|
||||
<li><a href="<?=self::getUrl("User")?>">Benutzer</a></li>
|
||||
<li><a href="<?=self::getUrl("Network")?>">Neztgebiete</a></li>
|
||||
<li><a href="<?=self::getUrl("Pop")?>">POPs</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
class AddressController extends mfBaseController {
|
||||
private $filter;
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
/*
|
||||
if(!$me->isAdmin()) {
|
||||
$this->redirect("Dashboard");
|
||||
}*/
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
//var_dump($this->request->filter);
|
||||
$default_filter = ['parents_only' => 1];
|
||||
|
||||
@@ -94,8 +94,29 @@ class AddressModel {
|
||||
if(is_array($filter['addresstype']) && count($filter['addresstype'])) {
|
||||
$at = $filter['addresstype'];
|
||||
$in = [];
|
||||
if(in_array("owner", $at)) {
|
||||
$in[] = "Addresstype.type = 'owner'";
|
||||
if(in_array("systemowner", $at)) {
|
||||
$in[] = "Addresstype.type = 'systemowner'";
|
||||
}
|
||||
if(in_array("netowner", $at)) {
|
||||
$in[] = "Addresstype.type = 'netowner'";
|
||||
}
|
||||
if(in_array("salespartner", $at)) {
|
||||
$in[] = "Addresstype.type = 'Addresstype'";
|
||||
}
|
||||
if(in_array("pipeworker", $at)) {
|
||||
$in[] = "Addresstype.type = 'pipeworker'";
|
||||
}
|
||||
if(in_array("lineworker", $at)) {
|
||||
$in[] = "Addresstype.type = 'lineworker'";
|
||||
}
|
||||
if(in_array("netoperator", $at)) {
|
||||
$in[] = "Addresstype.type = 'netoperator'";
|
||||
}
|
||||
if(in_array("support", $at)) {
|
||||
$in[] = "Addresstype.type = 'support'";
|
||||
}
|
||||
if(in_array("billing", $at)) {
|
||||
$in[] = "Addresstype.type = 'billing'";
|
||||
}
|
||||
if(in_array("employee", $at)) {
|
||||
$in[] = "Addresstype.type = 'employee'";
|
||||
@@ -109,9 +130,6 @@ class AddressModel {
|
||||
if(in_array("contact", $at)) {
|
||||
$in[] = "Addresstype.type = 'contact'";
|
||||
}
|
||||
if(in_array("billing", $at)) {
|
||||
$in[] = "Addresstype.type = 'billing'";
|
||||
}
|
||||
|
||||
$or = "";
|
||||
if(count($in)) {
|
||||
|
||||
@@ -36,15 +36,19 @@ class AddressattributeModel {
|
||||
if(!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Addressattribute", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Addressattribute($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getAll($filter = false) {
|
||||
@@ -76,10 +80,8 @@ class AddressattributeModel {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return $items;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
|
||||
@@ -24,14 +24,14 @@ class AddresstypeModel {
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
31
application/Network/Network.php
Normal file
31
application/Network/Network.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class Network extends mfBaseModel {
|
||||
private $owner;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "owner") {
|
||||
if($this->id) {
|
||||
$this->owner = new Address($this->owner_id);
|
||||
return $this->owner;
|
||||
} else {
|
||||
return 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;
|
||||
}
|
||||
}
|
||||
95
application/Network/NetworkController.php
Normal file
95
application/Network/NetworkController.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
class NetworkController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
/*
|
||||
if(!$me->isAdmin()) {
|
||||
$this->redirect("Dashboard");
|
||||
}*/
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$this->layout()->set("owners", AddressModel::search(['addresstype' => ["netowner"]]));
|
||||
$this->layout()->set("networks", NetworkModel::getAll());
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Network/Form");
|
||||
$this->layout()->set("owners", AddressModel::search(['addresstype' => ["netowner"]]));
|
||||
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Netzgebiet nicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
|
||||
$network = new Network($id);
|
||||
if($network->id != $id) {
|
||||
$this->layout()->setFlash("Netzgebiet nicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
|
||||
$this->layout()->set("network", $network);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r);
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$network = new Network($id);
|
||||
if(!$network->id) {
|
||||
$this->layout()->setFlash("Netzgebie tnicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
//var_dump($r->addresstypes);exit;
|
||||
|
||||
if(!$r->owner_id || !$r->name) {
|
||||
$this->layout()->setFlash("Bitte Name und Besitzer eintragen", "error");
|
||||
$this->layout()->set("network", $network);
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['owner_id'] = $r->owner_id;
|
||||
$data['name'] = $r->name;
|
||||
$data['note'] = $r->note;
|
||||
|
||||
$data['edit_by'] = 1;
|
||||
|
||||
if($mode == "add") {
|
||||
$data['create_by'] = 1;
|
||||
$network = NetworkModel::create($data);
|
||||
} else {
|
||||
$network->update($data);
|
||||
}
|
||||
|
||||
//var_dump($address);exit;
|
||||
|
||||
$new_id = $network->save();
|
||||
if(!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->layout()->set("network", $network);
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
|
||||
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Network", "Edit", ['id' => $new_id]);
|
||||
}
|
||||
}
|
||||
105
application/Network/NetworkModel.php
Normal file
105
application/Network/NetworkModel.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
class NetworkModel {
|
||||
public $name = null;
|
||||
public $owner_id = 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 Network();
|
||||
|
||||
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("Network", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Network($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Network", "*");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Network($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Network", "*". "$where ORDER BY name, owner_id");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Network($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("Network", "*". "$where ORDER BY name, owner_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Network($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("owner_id", $filter)) {
|
||||
$ownerid= $filter['owner_id'];
|
||||
if(is_numeric($ownerid)) {
|
||||
$where .= " AND owner_id=$ownerid";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
5
application/Pop/Pop.php
Normal file
5
application/Pop/Pop.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
class Pop extends mfBaseModel {
|
||||
|
||||
}
|
||||
17
application/Pop/PopController.php
Normal file
17
application/Pop/PopController.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class PopController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
/*
|
||||
if(!$me->isAdmin()) {
|
||||
$this->redirect("Dashboard");
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user