Added adding POPs

This commit is contained in:
Frank Schubert
2021-06-29 20:57:24 +02:00
parent 032390a097
commit 8f4e179315
8 changed files with 283 additions and 27 deletions

View File

@@ -129,6 +129,7 @@
<option value="pipeworker" <?=(array_key_exists("pipeworker", $address->types)) ? "selected='selected'" : "pipeworker"?>><?=__("pipeworker")?></option> <option value="pipeworker" <?=(array_key_exists("pipeworker", $address->types)) ? "selected='selected'" : "pipeworker"?>><?=__("pipeworker")?></option>
<option value="lineworker" <?=(array_key_exists("lineworker", $address->types)) ? "selected='selected'" : "lineworker"?>><?=__("lineworker")?></option> <option value="lineworker" <?=(array_key_exists("lineworker", $address->types)) ? "selected='selected'" : "lineworker"?>><?=__("lineworker")?></option>
<option value="netoperator" <?=(array_key_exists("netoperator", $address->types)) ? "selected='selected'" : "netoperator"?>><?=__("netoperator")?></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="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="billing" <?=(array_key_exists("billing", $address->types)) ? "selected='selected'" : ""?>><?=__("billing")?></option>
<option value="employee" <?=(array_key_exists("employee", $address->types)) ? "selected='selected'" : ""?>><?=__("employee")?></option> <option value="employee" <?=(array_key_exists("employee", $address->types)) ? "selected='selected'" : ""?>><?=__("employee")?></option>

View File

@@ -65,21 +65,21 @@
<ul class="nav nav-pills navtab-bg nav-justified"> <ul class="nav nav-pills navtab-bg nav-justified">
<li class="nav-item"><a class="nav-link active" href="#net-detail-<?=$network->id?>-detail" data-toggle="tab" aria-expanded="false">Details</a></li> <li class="nav-item"><a class="nav-link active" href="#net-detail-<?=$network->id?>-detail" data-toggle="tab" aria-expanded="false">Details</a></li>
<li class="nav-item"><a class="nav-link" href="#net-detail-<?=$network->id?>-pops" data-toggle="tab" aria-expanded="false">POPs</a></li> <li class="nav-item"><a class="nav-link" href="#net-detail-<?=$network->id?>-pops" data-toggle="tab" aria-expanded="false">POPs</a></li>
<li class="nav-item"><a class="nav-link" href="#net-detail-<?=$network->id?>-third" data-toggle="tab" aria-expanded="false">Noawos</a></li> <li class="nav-item"><a class="nav-link" href="#net-detail-<?=$network->id?>-third" data-toggle="tab" aria-expanded="false">Berechtigungen</a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div id="net-detail-<?=$network->id?>-detail" class="tab-pane show active"> <div id="net-detail-<?=$network->id?>-detail" class="tab-pane show active">
<h4>Details zu <strong><?=$network->name?></strong></h4> <h4>Details zu <strong><?=$network->name?></strong></h4>
<table class="table table-bordered table-striped"> <table class="table table-bordered">
<tr> <tr class="bg-white">
<th>Name</th> <th>Name</th>
<td><?=$network->name?></td> <td><?=$network->name?></td>
</tr> </tr>
<tr> <tr class="bg-white">
<th>Besitzer</th> <th>Besitzer</th>
<td><?=$network->owner->getCompanyOrName()?></td> <td><?=$network->owner->getCompanyOrName()?></td>
</tr> </tr>
<tr> <tr class="bg-white">
<th>Interne Notiz</th> <th>Interne Notiz</th>
<td><?=nl2br($network->note)?></td> <td><?=nl2br($network->note)?></td>
</tr> </tr>
@@ -89,15 +89,33 @@
<h4>POPs in <strong><?=$network->name?></strong></h4> <h4>POPs in <strong><?=$network->name?></strong></h4>
<?php if(is_array($network->pops) && count($network->pops)): ?> <?php if(is_array($network->pops) && count($network->pops)): ?>
<table class="table" >
<tr>
<th>Name</th>
<th>GPS (Breite, Länge)</th>
<th>Standortinfo</th>
<th></th>
</tr>
<?php foreach($network->pops as $pop): ?>
<tr>
<td><?=$pop->name?></td>
<td><?=$pop->gps_lat?>, <?=$pop->gps_long?></td>
<td><?=$pop->location?></td>
<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>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?> <?php else: ?>
<p><i>Keine POPs vorhanden</i></p> <p><i>Keine POPs vorhanden</i></p>
<?php endif; ?> <?php endif; ?>
<a class="btn btn-primary" href="<?=self::getUrl("Pop", "add")?>"><i class="fas fa-plus"></i> Neuen POP anlegen</a> <a class="btn btn-primary" href="<?=self::getUrl("Pop", "add", ['network_id' => $network->id])?>"><i class="fas fa-plus"></i> Neuen POP anlegen</a>
</div> </div>
<div id="net-detail-<?=$network->id?>-third" class="tab-pane"> <div id="net-detail-<?=$network->id?>-third" class="tab-pane">
<h4>3</h4> <h4>Berechtigungen</h4>
</div> </div>
</div> </div>

119
Layout/default/Pop/Form.php Normal file
View File

@@ -0,0 +1,119 @@
<?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">POP</li>
<li class="breadcrumb-item active"><?=($pop->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title"><?=($pop->id) ? "POP bearbeiten" : "Neuer POP" ?></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"><?=($pop->id) ? "POP bearbeiten" : "Neuer POP"?></h4>
<form class="form-horizontal" method="post" action="<?=self::getUrl("Pop", "save")?>">
<div class="card">
<div class="card-body">
<input type="hidden" name="id" value="<?=$pop->id?>" />
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="network_id">Netzgebiet</label>
<div class="col-lg-10">
<select class="select2 form-control " name="network_id" id="owner_id">
<option></option>
<?php foreach($networks as $network): ?>
<option value="<?=$network->id?>" <?=($pop->network_id == $network->id) ? "selected='selected'" : ""?>><?=($network->name)?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<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="<?=$pop->name?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gps_lat">GPS Breite</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="gps_lat" id="name" value="<?=$pop->gps_lat?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="gps_long">GPS Länge</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="gps_long" id="name" value="<?=$pop->gps_long?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="location">Standortinfo</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="location" id="name" value="<?=$pop->location?>">
</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"><?=$pop->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"); ?>

View File

@@ -92,8 +92,29 @@ class AddresstypeModel {
if(is_array($filter['addresstype']) && count($filter['addresstype'])) { if(is_array($filter['addresstype']) && count($filter['addresstype'])) {
$at = $filter['addresstype']; $at = $filter['addresstype'];
$in = []; $in = [];
if(in_array("owner", $at)) { if(in_array("systemowner", $at)) {
$in[] = "Addresstype.type = 'owner'"; $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)) { if(in_array("employee", $at)) {
$in[] = "Addresstype.type = 'employee'"; $in[] = "Addresstype.type = 'employee'";
@@ -107,9 +128,6 @@ class AddresstypeModel {
if(in_array("contact", $at)) { if(in_array("contact", $at)) {
$in[] = "Addresstype.type = 'contact'"; $in[] = "Addresstype.type = 'contact'";
} }
if(in_array("billing", $at)) {
$in[] = "Addresstype.type = 'billing'";
}
$or = ""; $or = "";
if(count($in)) { if(count($in)) {

View File

@@ -2,6 +2,7 @@
class Network extends mfBaseModel { class Network extends mfBaseModel {
private $owner; private $owner;
private $pops;
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
@@ -15,6 +16,16 @@ class Network extends mfBaseModel {
} }
} }
if($name == "pops") {
if($this->id) {
$pops = PopModel::search(['network_id' => $this->id]);
$this->pops = $pops;
return $this->pops;
} else {
return null;
}
}
$classname = ucfirst($name); $classname = ucfirst($name);
$idfield = $name."_id"; $idfield = $name."_id";
$this->$name = new $classname($this->$idfield); $this->$name = new $classname($this->$idfield);

View File

@@ -13,5 +13,89 @@ class PopController extends mfBaseController {
$this->redirect("Dashboard"); $this->redirect("Dashboard");
}*/ }*/
} }
protected function indexAction() {
}
protected function addAction() {
$this->layout()->setTemplate("Pop/Form");
$this->layout()->set("networks", NetworkModel::getAll());
if($this->request->network_id) {
$pop = new Pop();
$pop->network_id = $this->request->network_id;
$this->layout()->set("pop", $pop);
}
}
protected function editAction() {
$id = $this->request->id;
if(!is_numeric($id) || !$id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
}
$pop = new Pop($id);
if($pop->id != $id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
}
$this->layout()->set("pop", $pop);
return $this->addAction();
}
protected function saveAction() {
$r = $this->request;
$id = $r->id;
//var_dump($r);exit;
if(is_numeric($id) && $id > 0) {
$mode = "edit";
$pop = new Pop($id);
if(!$pop->id) {
$this->layout()->setFlash("POP nicht gefunden", "error");
$this->redirect("Network");
}
} else {
$mode = "add";
}
//var_dump($r->addresstypes);exit;
if(!$r->network_id || !$r->name) {
$this->layout()->setFlash("Bitte Name und Netzgebiet eintragen", "error");
$this->layout()->set("pop", $pop);
unset($r->network_id);
return $this->add();
}
$data = [];
$data['network_id'] = $r->network_id;
$data['name'] = $r->name;
$data['gps_lat'] = $r->gps_lat;
$data['gps_long'] = $r->gps_long;
$data['location'] = $r->location;
$data['note'] = $r->note;
$data['edit_by'] = 1;
if($mode == "add") {
$data['create_by'] = 1;
$pop = PopModel::create($data);
} else {
$pop->update($data);
}
//var_dump($address);exit;
$new_id = $pop->save();
if(!$new_id) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
$this->layout()->set("network", $network);
return $this->addAction();
}
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
$this->redirect("Pop", "Edit", ['id' => $new_id]);
}
} }

View File

@@ -2,7 +2,11 @@
class PopModel { class PopModel {
public $name = null; public $name = null;
public $owner_id = null; public $network_id = null;
public $gps_lat = null;
public $gps_long = null;
public $location = null;
public $note = null; public $note = null;
public $create_by = null; public $create_by = null;
@@ -15,7 +19,7 @@ class PopModel {
} }
public static function create(Array $data) { public static function create(Array $data) {
$model = new Network(); $model = new Pop();
foreach($data as $field => $value) { foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) { if(property_exists(get_called_class(), $field)) {
@@ -33,10 +37,10 @@ class PopModel {
$item = []; $item = [];
$db = FronkDB::singleton(); $db = FronkDB::singleton();
$res = $db->select("Network", "*", "id=$id LIMIT 1"); $res = $db->select("Pop", "*", "id=$id LIMIT 1");
if($db->num_rows($res)) { if($db->num_rows($res)) {
$data = $db->fetch_object($res); $data = $db->fetch_object($res);
$item = new Network($data); $item = new Pop($data);
} }
return $item; return $item;
} }
@@ -46,10 +50,10 @@ class PopModel {
$db = FronkDB::singleton(); $db = FronkDB::singleton();
$res = $db->select("Network", "*"); $res = $db->select("Pop", "*");
if($db->num_rows($res)) { if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) { while($data = $db->fetch_object($res)) {
$items[] = new Network($data); $items[] = new Pop($data);
} }
} }
return $items; return $items;
@@ -60,10 +64,10 @@ class PopModel {
$db = FronkDB::singleton(); $db = FronkDB::singleton();
$where = self::getSqlFilter($filter); $where = self::getSqlFilter($filter);
$res = $db->select("Network", "*". "$where ORDER BY name, owner_id"); $res = $db->select("Pop", "*", "$where ORDER BY name, network_id");
if($db->num_rows($res)) { if($db->num_rows($res)) {
$data = $db->fetch_object($res); $data = $db->fetch_object($res);
$item = new Network($data); $item = new Pop($data);
if($item->id) { if($item->id) {
return $item; return $item;
} else { } else {
@@ -78,10 +82,10 @@ class PopModel {
$db = FronkDB::singleton(); $db = FronkDB::singleton();
$where = self::getSqlFilter($filter); $where = self::getSqlFilter($filter);
$res = $db->select("Network", "*". "$where ORDER BY name, owner_id"); $res = $db->select("Pop", "*", "$where ORDER BY name, network_id");
if($db->num_rows($res)) { if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) { while($data = $db->fetch_object($res)) {
$items[] = new Network($data); $items[] = new Pop($data);
} }
} }
return $items; return $items;
@@ -91,10 +95,10 @@ class PopModel {
$where = "1=1 "; $where = "1=1 ";
//var_dump($filter);exit; //var_dump($filter);exit;
if(array_key_exists("owner_id", $filter)) { if(array_key_exists("network_id", $filter)) {
$ownerid= $filter['owner_id']; $networkid = $filter['network_id'];
if(is_numeric($ownerid)) { if(is_numeric($networkid)) {
$where .= " AND owner_id=$ownerid"; $where .= " AND network_id=$networkid";
} }
} }

View File

@@ -7,6 +7,7 @@ $l['salespartner'] = "Vertriebspartner";
$l['pipeworker'] = "Tiefbau"; $l['pipeworker'] = "Tiefbau";
$l['lineworker'] = "Leitungsbau"; $l['lineworker'] = "Leitungsbau";
$l['netoperator'] = "Netzbetreiber"; $l['netoperator'] = "Netzbetreiber";
$l['planner'] = "Planer";
$l['support'] = "Support"; $l['support'] = "Support";
$l['employee'] = "Mitarbeiter"; $l['employee'] = "Mitarbeiter";
$l['customer'] = "Kunde"; $l['customer'] = "Kunde";