Building/Form: pipe- and lineworker is updated when network is changed
This commit is contained in:
@@ -207,7 +207,7 @@
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="pipeworker_id">Tiefbau</label>
|
||||
<label class="col-lg-2 col-form-label" for="pipeworker_id">Tiefbau *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="select2 form-control " name="pipeworker_id" id="pipeworker_id" >
|
||||
<option></option>
|
||||
@@ -219,9 +219,9 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="lineworker_id">Kabelbau</label>
|
||||
<label class="col-lg-2 col-form-label" for="lineworker_id">Kabelbau *</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="select2 form-control " name="lineworker_id" id="type_id" <?=(!$me->is("Admin")) ? "disabled='disabled'" : ""?>>
|
||||
<select class="select2 form-control " name="lineworker_id" id="lineworker_id" <?=(!$me->is("Admin")) ? "disabled='disabled'" : ""?>>
|
||||
<option></option>
|
||||
<?php foreach($lineworkers as $lw): ?>
|
||||
<option value="<?=$lw->id?>" <?=($building->lineworker_id == $lw->id) ? "selected='selected'" : ""?>><?=$lw->getCompanyOrName()?></option>
|
||||
@@ -293,15 +293,12 @@
|
||||
},
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
console.log(success);
|
||||
pops = success.result.pops;
|
||||
if(typeof pops !== 'object' || pops === null) {
|
||||
return true;
|
||||
}
|
||||
$("#pop_id option:gt(0)").remove();
|
||||
console.log(pops);
|
||||
for(var pop_id in pops) {
|
||||
console.log(pop_id + ": " + pops[pop_id]);
|
||||
$("#pop_id").append($("<option></option>").attr("value", pop_id).text(pops[pop_id]));
|
||||
}
|
||||
}
|
||||
@@ -310,15 +307,43 @@
|
||||
);
|
||||
}
|
||||
|
||||
$("#network_id").change(function() {
|
||||
updatePops();
|
||||
});
|
||||
|
||||
function updatePermissions() {
|
||||
var network_id = $("#network_id").val();
|
||||
if(!network_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var types = ["lineworker", "pipeworker"];
|
||||
|
||||
// get new pops
|
||||
$.get("<?=self::getUrl("Network","Api")?>",
|
||||
{
|
||||
"do": "getPermissions",
|
||||
network_id: network_id,
|
||||
types: types.join('|')
|
||||
},
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
var perms = success.result.permissions;
|
||||
types.forEach(function(type) {
|
||||
$("#" + type + "_id").empty();
|
||||
$("#" + type + "_id").append($("<option></option>"));
|
||||
for(var perm_id in perms[type]) {
|
||||
$("#" + type + "_id").append($("<option></option>").attr("value", perm_id).text(perms[type][perm_id]));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'json'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
<?php if($building->gps_lat && $building->gps_long): ?>
|
||||
|
||||
////////////
|
||||
// Map
|
||||
////////////
|
||||
var gpslat = <?=($building->gps_lat) ? $building->gps_lat : 0?>;
|
||||
var gpslong = <?=($building->gps_long) ? $building->gps_long : 0?>;
|
||||
console.log(gpslat + "," + gpslong);
|
||||
@@ -342,9 +367,14 @@
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
$("#network_id").change(function() {
|
||||
updatePops();
|
||||
updatePermissions();
|
||||
});
|
||||
|
||||
$( document ).ready(function() {
|
||||
updatePops();
|
||||
updatePermissions();
|
||||
});
|
||||
|
||||
|
||||
|
||||
10
Layout/default/mfExceptionhandler/error_404.php
Normal file
10
Layout/default/mfExceptionhandler/error_404.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>mvcfronk Error 404 - Module not found</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Error 404</h1>
|
||||
<h3>The Module was not found</h3>
|
||||
<!-- <?=$Exception?> -->
|
||||
</body>
|
||||
</html>
|
||||
10
Layout/default/mfExceptionhandler/error_500.php
Normal file
10
Layout/default/mfExceptionhandler/error_500.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>500 - Internal application error</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Error 500</h1>
|
||||
<h3>An internal Error occured.</h3>
|
||||
<!-- <?=$Exception?> -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$code=$Exception->Code;
|
||||
if($code) {
|
||||
echo "Error $code: ";
|
||||
}
|
||||
echo $Exception->Message;
|
||||
echo "\n";
|
||||
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Error</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3><?=$Exception?></h3>
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,7 +13,9 @@ class DashboardController extends mfBaseController {
|
||||
protected function indexAction() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
protected function testAction() {
|
||||
$search = [
|
||||
'street' => "Kastellfeldgasse 20",
|
||||
@@ -25,5 +27,5 @@ class DashboardController extends mfBaseController {
|
||||
$coords = Gmaps_Geocoding::getCoords($search);
|
||||
var_dump($coords);
|
||||
exit;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -98,4 +98,55 @@ class NetworkController extends mfBaseController {
|
||||
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Network", "Edit", ['id' => $new_id]);
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
$do = $this->request->do;
|
||||
$data = [];
|
||||
|
||||
switch($do) {
|
||||
case "getPermissions":
|
||||
$return = $this->getPermissionsApi();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
|
||||
if(!is_array($return) || !count($return)) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
$data['status'] = "OK";
|
||||
$data['result'] = $return;
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
private function getPermissionsApi() {
|
||||
if(!$this->request->types) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$network_id = $this->request->network_id;
|
||||
if(!is_numeric($network_id) || $network_id < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$network = new Network($network_id);
|
||||
if(!$network->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$types = explode("|", $this->request->types);
|
||||
|
||||
$permissions = [];
|
||||
$nas = NetworkAddressModel::search(['network_id' => $network_id, "addresstype" => $types]);
|
||||
foreach($nas as $na) {
|
||||
if(!array_key_exists($na->type, $permissions)) {
|
||||
$permissions[$na->type] = [];
|
||||
}
|
||||
$address = new Address($na->address_id);
|
||||
$permissions[$na->type][$na->address_id] = str_replace(["\r","\n"]," ",$address->getCompanyOrName());
|
||||
}
|
||||
|
||||
return ["permissions" => $permissions];
|
||||
}
|
||||
}
|
||||
@@ -117,6 +117,7 @@ class NetworkAddressModel {
|
||||
$in = [];
|
||||
foreach(TT_ROLES as $role) {
|
||||
if(in_array($role, $at)) {
|
||||
$role = $db->escape($role);
|
||||
$in[] = "NetworkAddress.type = '$role'";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user