WIP Pipework Workflow
This commit is contained in:
@@ -25,34 +25,43 @@
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Auftragsliste nach Netzgebiet</h4>
|
||||
|
||||
<form method="post" action="<?=self::getUrl("Pipework","save")?>" >
|
||||
|
||||
|
||||
<?php foreach($networks as $networkname => $buildings): ?>
|
||||
<?php if(!count($buildings)) continue; ?>
|
||||
<h4><?=$networkname?></h4>
|
||||
<table class="table workflow-table">
|
||||
<?php $bcount = 0; foreach($buildings as $building): ?>
|
||||
<?php
|
||||
$rowspan = 1;
|
||||
foreach($building->workflowitems as $item) {
|
||||
if($item->type == "delimiter") {
|
||||
$rowspan++;
|
||||
}
|
||||
<?php foreach($networks as $networkname => $buildings): ?>
|
||||
<?php if(!count($buildings)) continue; ?>
|
||||
<h4><?=$networkname?></h4>
|
||||
<table class="table workflow-table">
|
||||
<?php $bcount = 0; foreach($buildings as $building): ?>
|
||||
<?php
|
||||
$rowspan = 1;
|
||||
foreach($building->workflowitems as $item) {
|
||||
if($item->type == "delimiter") {
|
||||
$rowspan++;
|
||||
}
|
||||
?>
|
||||
<tr id="building-<?=$building->id?>" class="table-bg-<?=($bcount % 2 == 0) ? "even" : "odd"?>">
|
||||
<td>
|
||||
}
|
||||
?>
|
||||
<tr id="building-<?=$building->id?>" class="table-bg-<?=($bcount % 2 == 0) ? "even" : "odd"?>">
|
||||
<td>
|
||||
<div>
|
||||
<strong style="white-space: nowrap;"><?=$building->street?></strong><br />
|
||||
<span class="text-success"><?=$building->code?></span><br />
|
||||
<br />
|
||||
Kontakt:<br />
|
||||
</div>
|
||||
<div class="mt-1">
|
||||
<?=$building->contact?><br />
|
||||
<strong><?=$building->phone?></strong><br />
|
||||
<?=$building->email?>
|
||||
</td>
|
||||
<td>
|
||||
</div>
|
||||
<div class="mt-1">
|
||||
<label><input type="checkbox" form="wf-building-<?=$building->id?>" name="pipework_enabled" value="1" <?=($building->pipework_enabled==1) ? "checked='checked'" : ""?>> Baufreigabe</label>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary" form="wf-building-<?=$building->id?>" onclick="document.getElementById(this.getAttribute('form')).submit()">Speichern</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" name="wf-building-<?=$building->id?>" id="wf-building-<?=$building->id?>" action="<?=self::getUrl("Pipework","save")?>" enctype="multipart/form-data" >
|
||||
<input type="hidden" name="id" value="<?=$building->id?>" />
|
||||
<table class="table workflow-table">
|
||||
|
||||
<?php $i = 0; foreach($building->workflowitems as $item): ?>
|
||||
<?php if($i==0): ?>
|
||||
<?php if($item->type == "delimiter"): ?>
|
||||
@@ -69,14 +78,47 @@
|
||||
<?php endif; ?>
|
||||
<?php $i++; endforeach; ?>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<label class="form-label">Kommentar</label> <textarea class="form-control" style="height:100%" form="wf-building-<?=$building->id?>" name="workflow_comment" id="workflow_comment_<?=$building->id?>"><?=$building->workflow_comment?></textarea>
|
||||
</td>
|
||||
<td colspan="<?=$building_wf_colspan - 3?>">
|
||||
<h5>Dokumente</h5>
|
||||
<table class="table-sm">
|
||||
<?php $i=0; foreach($building->files as $file): ?>
|
||||
<?php if($i % 2 == 0): ?>
|
||||
<tr>
|
||||
<td><a href="<?=self::getUrl("File", "Download", ['id' => $file->file->id])?>"><i class="fas fa-download"></i> <?=$file->type?></a></td>
|
||||
<?php else: ?>
|
||||
<td><a href="<?=self::getUrl("File", "Download", ['id' => $file->file->id])?>"><i class="fas fa-download"></i> <?=$file->type?></a></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php $i++; endforeach; ?>
|
||||
<?=($i % 2 != 0) ? "<td></td></tr>" : ""?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Dokument hochladen</strong> <select class="form-control" name="file_type">
|
||||
<?php foreach(TT_WORKFLOW_BUILDING_FILE_TYPES as $type): ?>
|
||||
<option value="<?=$type?>"><?=$type?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<small>Erlaubte Dateiendungen: <?=MFUPLOAD_ALLOWED_EXTENSIONS_STR?></small>
|
||||
<input type="file" name="PipeworkFileUpload" class="form-control-file" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $bcount++; endforeach; ?>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</form>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $bcount++; endforeach; ?>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -86,62 +128,7 @@
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function toggleBuilding(id) {
|
||||
$('#building-detail-' + id).toggle();
|
||||
if($('#building-detail-' + id).is(":hidden")) {
|
||||
$('#building-' + id).removeClass("table-info");
|
||||
$('#building-' + id).removeClass("text-info");
|
||||
} else {
|
||||
$('#building-' + id).addClass("text-info");
|
||||
$('#building-' + id).addClass("table-info");
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTerminationControl(id, type) {
|
||||
$("#term-" + type + "-" + id + "-text").toggle();
|
||||
$("#term-" + type + "-" + id + "-input").toggle();
|
||||
$("#term-" + type + "-" + id + "-edit").toggle();
|
||||
}
|
||||
|
||||
function saveTerminationControl(id, type) {
|
||||
if(!Number.isInteger(id) || id < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var value = $("#term-" + type + "-" + id + "-input input[type=text]").val();
|
||||
|
||||
$.post("<?=self::getUrl("Termination","Api")?>",
|
||||
{
|
||||
'do': "setValue",
|
||||
id: id,
|
||||
type: type,
|
||||
value: value
|
||||
},
|
||||
function(success) {
|
||||
if(success.status == "OK") {
|
||||
$("#term-" + type + "-" + id + "-text").text(value);
|
||||
} else {
|
||||
console.log("error saving (" + type + ", '" + value + "')");
|
||||
}
|
||||
|
||||
toggleTerminationControl(id, type);
|
||||
},
|
||||
'json');
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
var building;
|
||||
var hash = window.location.hash.substr(1);
|
||||
var match = hash.match(/building=(\d+)/);
|
||||
if(match && match[1]) {
|
||||
building = match[1]
|
||||
toggleBuilding(building);
|
||||
|
||||
//$('body').scrollTop($('#building-' + building).offset() - 50);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1 +1,10 @@
|
||||
<input type="checkbox" class="form-control" name="wfitem_<?=$item->name?>_<?=$building->id?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>">
|
||||
<input type="hidden" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=($item->value->value_int == 1) ? "1" : "0"?>" />
|
||||
<input
|
||||
type="checkbox"
|
||||
class="form-control"
|
||||
name="wfitemplaceholder_<?=$item->name?>"
|
||||
id="wfitemplaceholder_<?=$item->name?>_<?=$building->id?>"
|
||||
value="1"
|
||||
<?=($item->value->value_int == 1) ? "checked='checked'" : ""?>
|
||||
onchange="$('#wfitem_<?=$item->name?>_<?=$building->id?>').val((this.checked) ? 1 : 0)"
|
||||
>
|
||||
|
||||
@@ -1 +1,20 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>_<?=$building->id?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>">
|
||||
<select class="form-control selectpicker show-tick" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" title="Farbe wählen" data-style="btn-outline-secondary">
|
||||
<option></option>
|
||||
<?php foreach(TT_CABLE_COLORS as $name => $color): ?>
|
||||
<option
|
||||
style="background-color: rgba(<?=$color["r"]?>,<?=$color["g"]?>,<?=$color["b"]?>, .5); color: #<?=$color["hexfg"]?>"
|
||||
value="<?=$name?>"
|
||||
data-bg-color="#<?=$color["hex"]?>" <?=($color['mark']) ? "data-icon='fa-ellipsis-h'" : ""?>
|
||||
<?=($name == $item->value->value_string) ? "selected='selected'" : ""?>
|
||||
>
|
||||
<?=ucfirst($name)?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#wfitem_<?=$item->name?>_<?=$building->id?>').change(function() {
|
||||
var color = $('#wfitem_<?=$item->name?>_<?=$building->id?> option:selected').data("bg-color");
|
||||
//console.log(color);
|
||||
});
|
||||
</script>
|
||||
@@ -1,4 +1,4 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>_<?=$building->id?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>" placeholder="<?=$item->placeholder?>" />
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>" placeholder="<?=$item->placeholder?>" />
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#wfitem_<?=$item->name?>_<?=$building->id?>').datepicker({
|
||||
|
||||
@@ -3,7 +3,7 @@ $options = [];
|
||||
$options = explode(";", $item->typedata);
|
||||
?>
|
||||
|
||||
<select class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>">
|
||||
<select class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>">
|
||||
<option></option>
|
||||
<?php foreach($options as $opt): ?>
|
||||
<?php
|
||||
@@ -16,6 +16,6 @@ $options = explode(";", $item->typedata);
|
||||
}
|
||||
?>
|
||||
|
||||
<option value="<?=$key?>"><?=$label?></option>
|
||||
<option value="<?=$key?>" <?=($key == $item->value->value_string) ? "selected='selected'" : ""?>><?=$label?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>" value="<?=$item->value->value_string?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>">
|
||||
@@ -1,25 +1,23 @@
|
||||
<?php
|
||||
$lat = "";
|
||||
$long = "";
|
||||
if($item->value_string) {
|
||||
$gps_parts = explode(";", $item->value_string);
|
||||
if($item->value->value_string) {
|
||||
$gps_parts = explode(";", $item->value->value_string);
|
||||
$lat = $gps_parts[0];
|
||||
$long = $gps_parts[1];
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-md-6 padding-right-2">
|
||||
<div class="col-md-5 padding-right-2">
|
||||
<label class="form-label" for="wfitem_<?=$item->name?>_lat_<?=$building->id?>">GPS Breite <?=($item->required == 1) ? "*" : ""?></label>
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>_lat_<?=$building->id?>" id="wfitem_<?=$item->name?>_lat_<?=$building->id?>" value="<?=$lat?>" placeholder="<?=str_replace(",", ".", TT_PLACEHOLDER_GPS_LAT)?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>[lat]" id="wfitem_<?=$item->name?>_lat_<?=$building->id?>" value="<?=$lat?>" placeholder="<?=str_replace(",", ".", TT_PLACEHOLDER_GPS_LAT)?>">
|
||||
</div>
|
||||
<div class="col-md-6 padding-left-2">
|
||||
<div class="col-md-5 padding-left-2">
|
||||
<label class="form-label" for="wfitem_<?=$item->name?>_long_<?=$building->id?>">GPS Länge <?=($item->required == 1) ? "*" : ""?></label>
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>_long_<?=$building->id?>" id="wfitem_<?=$item->name?>_long_<?=$building->id?>" value="<?=$long?>" placeholder="<?=str_replace(",", ".", TT_PLACEHOLDER_GPS_LONG)?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>[long]" id="wfitem_<?=$item->name?>_long_<?=$building->id?>" value="<?=$long?>" placeholder="<?=str_replace(",", ".", TT_PLACEHOLDER_GPS_LONG)?>">
|
||||
</div>
|
||||
<div class="col-md-2 padding-left-2">
|
||||
<label class="form-label"> </label>
|
||||
<div><?php if($lat && $long): ?><a href="https://www.google.com/maps/search/?api=1&query=<?=$lat?>,<?=$long?>" target="_blank">Maps</a><?php endif; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if($lat && $long): ?>
|
||||
<a href="https://www.google.com/maps/search/?api=1&query=<?=$lat?>,<?=$long?>" target="_blank"><i class="fas fa-external-link-alt"></i> Auf Google Maps öffnen</a>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>" value="<?=$item->value->value_string?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>">
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>_<?=$building->id?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>" placeholder="<?=$item->placeholder?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>" placeholder="<?=$item->placeholder?>">
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>" value="<?=$item->value->value_string?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>">
|
||||
@@ -22,6 +22,11 @@
|
||||
<!-- end Footer -->
|
||||
|
||||
<!--<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/vendor.min.js"></script>-->
|
||||
|
||||
<script type="text/javascript">
|
||||
$(".selectpicker").selectpicker({
|
||||
iconBase: "fas",
|
||||
tickIcon: "check"
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -16,6 +16,7 @@
|
||||
<link href="<?=self::getResourcePath()?>assets/css/leaflet.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?=self::getResourcePath()?>assets/css/thetool.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
|
||||
<link href="<?=self::getResourcePath()?>assets/libs/select2/select2.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?=self::getResourcePath()?>assets/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?=self::getResourcePath()?>css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>js/jquery.min.js"></script>
|
||||
@@ -23,7 +24,9 @@
|
||||
<script src="<?=self::getResourcePath()?>js/bootstrap-datepicker.min.js"></script>
|
||||
<script src="<?=self::getResourcePath()?>js/bootstrap-datepicker.de.min.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>js/popper.min.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/bootstrap-select.min.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class Building extends mfBaseModel {
|
||||
private $pipeworker;
|
||||
private $terminations;
|
||||
private $workflowitems;
|
||||
private $files;
|
||||
|
||||
public function getAddress($singelLine = false) {
|
||||
if(!$this->id) {
|
||||
@@ -126,11 +127,17 @@ class Building extends mfBaseModel {
|
||||
if($name == "workflowitems") {
|
||||
foreach(WorkflowitemModel::search(["object_type" => "building", "active" => 1]) as $item) {
|
||||
$item->setObjectId($this->id);
|
||||
$this->workflowitems[] = $item;
|
||||
$this->workflowitems[$item->name] = $item;
|
||||
}
|
||||
//var_dump($this->workflowitems);exit;
|
||||
return $this->workflowitems;
|
||||
}
|
||||
|
||||
if($name == "files") {
|
||||
$this->files = BuildingFileModel::search(["building_id" => $this->id]);
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
39
application/BuildingFile/BuildingFile.php
Normal file
39
application/BuildingFile/BuildingFile.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
class BuildingFile extends mfBaseModel {
|
||||
private $file;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
36
application/BuildingFile/BuildingFileController.php
Normal file
36
application/BuildingFile/BuildingFileController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class BuildingFileController 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 editAction() {
|
||||
// internal redirect to File::editAction
|
||||
}
|
||||
|
||||
protected function deleteAction() {
|
||||
$id = $this->request->id;
|
||||
|
||||
$buildingfile = new BuildingFile($id);
|
||||
if(!$buildingfile->id || $buildingfile->id != $id) {
|
||||
$this->layout()->setFlash("Datei nicht gefunden.", "error");
|
||||
$this->redirect("Building");
|
||||
}
|
||||
|
||||
$building_id = $buildingfile->order_id;
|
||||
|
||||
$buildingfile->file->delete();
|
||||
$buildingfile->delete();
|
||||
$this->redirect("Building", "edit", ["id" => $building_id]);
|
||||
}
|
||||
}
|
||||
156
application/BuildingFile/BuildingFileModel.php
Normal file
156
application/BuildingFile/BuildingFileModel.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
class BuildingFileModel {
|
||||
public $building_id;
|
||||
public $file_id;
|
||||
public $type;
|
||||
public $name;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new BuildingFile();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model ->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
public static function getOne($id) {
|
||||
if(!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("BuildingFile", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new BuildingFile($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("BuildingFile", "*", "1=1 ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new BuildingFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("BuildingFile", "*", "$where ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new BuildingFile($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT BuildingFile.* FROM BuildingFile
|
||||
LEFT JOIN File ON (BuildingFile.file_id = File.id)
|
||||
WHERE $where
|
||||
ORDER BY building_id, name";
|
||||
|
||||
$res = $db->query($sql);
|
||||
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new BuildingFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
|
||||
if(array_key_exists("file_id", $filter)) {
|
||||
$file_id = $filter['file_id'];
|
||||
if(is_numeric($file_id)) {
|
||||
$where .= " AND file_id=$file_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("building_id", $filter)) {
|
||||
$building_id = $filter['building_id'];
|
||||
if(is_numeric($building_id)) {
|
||||
$where .= " AND building_id=$building_id";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND name='$name'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("type", $filter)) {
|
||||
$type = FronkDB::singleton()->escape($filter['type']);
|
||||
if($type) {
|
||||
$where .= " AND type='$type'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("filename", $filter)) {
|
||||
$filename = FronkDB::singleton()->escape($filter['filename']);
|
||||
if($filename) {
|
||||
$where .= " AND File.filename='$filename'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("subfolder", $filter)) {
|
||||
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
|
||||
if($subfolder) {
|
||||
$where .= " AND File.subfolder='$subfolder'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,18 +17,26 @@ class PipeworkController extends mfBaseController {
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("Pipework/Index");
|
||||
|
||||
// get allowed networks
|
||||
if($this->me->is("Admin")) {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
} else {
|
||||
$my_networks = $this->me->my_networks;
|
||||
}
|
||||
|
||||
|
||||
// get Buildings in networks
|
||||
$networks = [];
|
||||
foreach($my_networks as $network) {
|
||||
if(!array_key_exists($network->name, $networks)) {
|
||||
$networks[$network->name] = [];
|
||||
}
|
||||
foreach(BuildingModel::search(["network_id" => $network->id, "workflow_finished" => 0]) as $b) {
|
||||
|
||||
$building_search = [
|
||||
"network_id" => $network->id,
|
||||
"workflow_finished" => 0
|
||||
];
|
||||
|
||||
foreach(BuildingModel::search($building_search) as $b) {
|
||||
if(!array_key_exists($b->id, $networks[$network->name])) {
|
||||
$networks[$network->name][$b->id] = $b;
|
||||
}
|
||||
@@ -39,7 +47,7 @@ class PipeworkController extends mfBaseController {
|
||||
$item_colspan = 0;
|
||||
$i = 0;
|
||||
|
||||
//var_dump($building->workflowitems);exit;
|
||||
// get fields between delimiters for colspan
|
||||
foreach($building->workflowitems as $wfitem) {
|
||||
if($i == 0 && $wfitem->type == "delimiter") continue;
|
||||
|
||||
@@ -54,9 +62,130 @@ class PipeworkController extends mfBaseController {
|
||||
$this->layout()->set("building_wf_colspan", $item_colspan);
|
||||
$this->layout()->set("networks", $networks);
|
||||
//var_dump(reset(reset($networks))->workflowitems);exit;
|
||||
// get delimiter count, to adjust rowspan
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
//var_dump($r->get());exit;
|
||||
$building_id = $r->id;
|
||||
if(!is_numeric($building_id) || $building_id < 1) {
|
||||
$this->layout()->setFlash("Objekt nicht gefunden", "error");
|
||||
$this->redirect("Pipework");
|
||||
}
|
||||
|
||||
$building = new Building($building_id);
|
||||
if(!$building->id) {
|
||||
$this->layout()->setFlash("Objekt nicht gefunden", "error");
|
||||
$this->redirect("Pipework");
|
||||
}
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
|
||||
if($this->me->is(["Admin", "netowner", "pipeplanner"])) {
|
||||
if($r->pipework_enabled == 1) {
|
||||
$building->pipework_enabled = 1;
|
||||
} else {
|
||||
$building->pipework_enabled = 0;
|
||||
}
|
||||
$building->save();
|
||||
}
|
||||
|
||||
if($building->workflow_comment != $r->workflow_comment) {
|
||||
$building->workflow_comment = $r->workflow_comment;
|
||||
$building->workflow_comment_changed = date('U');
|
||||
$building->workflow_comment_changed_by = $this->me->id;
|
||||
$building->save();
|
||||
}
|
||||
|
||||
$items = [];
|
||||
|
||||
// get workflow values from request
|
||||
foreach($r->get() as $field_name => $value) {
|
||||
$m = [];
|
||||
if(preg_match('/^wfitem_(.+)$/', $field_name, $m)) {
|
||||
if(!$m[1]) {
|
||||
continue;
|
||||
}
|
||||
$items[$m[1]] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($items);exit;
|
||||
|
||||
foreach($items as $name => $value) {
|
||||
$item = WorkflowitemModel::getFirst(["name" => $name, "object_type" => "building"]);
|
||||
if(!$item) {
|
||||
var_dump("no item: $name");exit;
|
||||
}
|
||||
$item->setObjectId($building_id);
|
||||
$item->value->setValue($value, $items);
|
||||
//var_dump($item);exit;
|
||||
$item->value->save();
|
||||
|
||||
// set pipework finished flag in building
|
||||
if($name == TT_WORKFLOW_ITEM_PIPEWORK_DONE) {
|
||||
if($value && $building->workflow_finished == 0) {
|
||||
$building->workflow_finished = 1;
|
||||
$building->save();
|
||||
} elseif(!$value && $building->workflow_finished == 1) {
|
||||
$building->workflow_finished = 0;
|
||||
$building->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// file upload
|
||||
|
||||
if(array_key_exists("PipeworkFileUpload", $_FILES) && !$_FILES['PipeworkFileUpload']['error']) {
|
||||
//var_dump($_FILES);exit;
|
||||
try {
|
||||
$upload = new mfUpload("PipeworkFileUpload");
|
||||
$upload->setSavepath(MFUPLOAD_FILE_SAVE_PATH."/documents");
|
||||
$upload->save();
|
||||
|
||||
$file_data = [];
|
||||
$file_data['name'] = ($r->file_name) ? $r->file_name : $upload->getOriginalFilename();
|
||||
$file_data['filename'] = ($r->file_filename) ? $r->file_filename : $upload->getOriginalFilename();
|
||||
$file_data['store_filename'] = $upload->getFilename();
|
||||
$file_data['orig_filename'] = $upload->getOriginalFilename();
|
||||
|
||||
$file = FileModel::create($file_data);
|
||||
$file_id = $file->save();
|
||||
if(!$file_id) {
|
||||
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "warn");
|
||||
unlink($upload->getSavepath()."/".$upload->getFilename());
|
||||
} else {
|
||||
$bf = [];
|
||||
$bf['building_id'] = $building_id;
|
||||
$bf['file_id'] = $file_id;
|
||||
$bf['type'] = $r->file_type;
|
||||
$bf['name'] = $file->name;
|
||||
|
||||
$buildingfile = BuildingFileModel::create($bf);
|
||||
if(!$buildingfile->save()) {
|
||||
$file->delete();
|
||||
unlink($upload->getSavepath()."/".$upload->getFilename());
|
||||
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "warn");
|
||||
}
|
||||
}
|
||||
} catch(Exception $ex) {
|
||||
$this->layout->setFlash("Fehler beim Dateiupload: ".$ex->getMessage(), "warn");
|
||||
$this->redirect("Pipework");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->layout->setFlash("Workflow Eintrag erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Pipework");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,72 @@
|
||||
class Workflowvalue extends mfBaseModel {
|
||||
private $item;
|
||||
|
||||
public function setValue($value, $items) {
|
||||
$this->item = $this->getProperty("item");
|
||||
|
||||
if($this->item->type == "delimiter" || $this->item->type == "empty") {
|
||||
return true;
|
||||
}
|
||||
|
||||
$value_type = "string";
|
||||
|
||||
switch($this->item->type) {
|
||||
case "string":
|
||||
$value_type = "string";
|
||||
break;
|
||||
case "enum":
|
||||
$value_type = "string";
|
||||
break;
|
||||
case "gps":
|
||||
$value_type = "string";
|
||||
break;
|
||||
case "color":
|
||||
$value_type = "string";
|
||||
break;
|
||||
case "date":
|
||||
$value_type = "string";
|
||||
break;
|
||||
case "int":
|
||||
$value_type = "int";
|
||||
break;
|
||||
case "bool":
|
||||
$value_type = "int";
|
||||
break;
|
||||
case "file":
|
||||
$value_type = "int";
|
||||
break;
|
||||
case "text":
|
||||
$value_type = "text";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($this->item->type == "gps") {
|
||||
if(is_array($value) && count($value) == 2) {
|
||||
$lat = $value['lat'];
|
||||
$long = $value['long'];
|
||||
$value = "$lat;$long";
|
||||
} else {
|
||||
$value = "";
|
||||
}
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($this->{"value_".$value_type} != $value) {
|
||||
$this->{"value_".$value_type} = $value;
|
||||
$this->changed = date('U');
|
||||
$this->changed_by = $me->id;
|
||||
}
|
||||
|
||||
if($this->new() == "new") {
|
||||
$this->changed = date('U');
|
||||
$this->changed_by = $me->id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
6
public/assets/css/bootstrap-select.min.css
vendored
Normal file
6
public/assets/css/bootstrap-select.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -67,9 +67,8 @@
|
||||
|
||||
}
|
||||
|
||||
.workflow-table .workflow-item input[type=text],
|
||||
.workflow-table .workflow-item select {
|
||||
/*max-width: 180px;*/
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.padding-left-2 {
|
||||
|
||||
9
public/assets/js/bootstrap-select.min.js
vendored
Normal file
9
public/assets/js/bootstrap-select.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
public/assets/js/popper.min.js
vendored
Normal file
5
public/assets/js/popper.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user