Added edit indication to workflow

This commit is contained in:
Frank Schubert
2021-08-30 20:55:21 +02:00
parent fc9e943466
commit aa05334ce2
8 changed files with 185 additions and 97 deletions

View File

@@ -26,99 +26,116 @@
<h4 class="header-title mb-3">Auftragsliste nach Netzgebiet</h4>
<?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>
<div>
<strong style="white-space: nowrap;"><?=$building->street?></strong><br />
<span class="text-success"><?=$building->code?></span><br />
</div>
<div class="mt-1">
<?=$building->contact?><br />
<strong><?=$building->phone?></strong><br />
<?=$building->email?>
</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"): ?>
<tr class="workflow-header"><th colspan='<?=$building_wf_colspan?>'><?=$item->label?></th></tr><tr>
<?php else: ?>
<tr>
<?php endif; ?>
<?php else: ?>
<?php if($item->type == "delimiter"): ?>
</tr><tr class="workflow-header"><th colspan='<?=$building_wf_colspan?>'><?=$item->label?></th></tr><tr>
<?php else: ?>
<?php include(realpath(dirname(__FILE__)."/../")."/Workflow/form.php"); ?>
<?php endif; ?>
<?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 if(is_array($networks) && count($networks)): ?>
<?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>
<div>
<strong style="white-space: nowrap;"><?=$building->street?></strong><br />
<span class="text-success"><?=$building->code?></span><br />
</div>
<div class="mt-1">
<?=$building->contact?><br />
<strong><?=$building->phone?></strong><br />
<?=$building->email?>
</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"): ?>
<tr class="workflow-header"><th colspan='<?=$building_wf_colspan?>'><?=$item->label?></th></tr><tr>
<?php else: ?>
<tr>
<?php endif; ?>
<?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 if($item->type == "delimiter"): ?>
</tr><tr class="workflow-header"><th colspan='<?=$building_wf_colspan?>'><?=$item->label?></th></tr><tr>
<?php else: ?>
<?php include(realpath(dirname(__FILE__)."/../")."/Workflow/form.php"); ?>
<?php endif; ?>
<?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>
</form>
</td>
</tr>
<?php $bcount++; endforeach; ?>
</table>
<?php 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 title="<?=$file->file->filename?>">
<a href="<?=self::getUrl("BuildingFile", "delete", ['id' => $file->id, "from" => "pipework"])?>" onclick="if(!confirm('Dokument wirklich löschen?')) return false;" class="text-danger mr-1" title="Dokument löschen">
<i class="fas fa-trash"></i>
</a>
<a href="<?=self::getUrl("File", "Download", ['id' => $file->file->id])?>">
<i class="fas fa-download"></i> <?=$file->type?>
</a>
</td>
<?php else: ?>
<td title="<?=$file->file->filename?>">
<a href="<?=self::getUrl("BuildingFile", "delete", ['id' => $file->id, "from" => "pipework"])?>" onclick="if(!confirm('Dokument wirklich löschen?')) return false;" class="text-danger mr-1" title="Dokument löschen">
<i class="fas fa-trash"></i>
</a>
<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>
</form>
</td>
</tr>
<?php $bcount++; endforeach; ?>
</table>
<?php endforeach; ?>
<?php else: ?>
<i>Keine Bauaufträge gefunden</i>
<?php endif; ?>
</div>
</div>
@@ -129,7 +146,16 @@
<script type="text/javascript">
$(document).ready(function() {
var building;
var hash = window.location.hash.substr(1);
var match = hash.match(/object=(\d+)/);
if(match && match[1]) {
building = match[1]
var pos = $('#building-' + building).offset().top;
$(window).scrollTop(pos - 150 );
}
});
</script>

View File

@@ -46,5 +46,14 @@
include(realpath(dirname(__FILE__)."/items/")."/string.php");
}
?>
<small
class="text-info text-mono"
<?php if($item->value->changed): ?>
title="Geändert: <?=date("d.m.Y H.i",$item->value->changed)?> von <?=$item->value->changer->name?> (<?=$item->value->changer->address->getCompanyOrName(true)?>)"
<?php endif; ?>
>
<?php if($item->value->changed): ?>
<?=date("d.m.Y",$item->value->changed)?><br />(<?=$item->value->changer->name?>)
<?php endif; ?>
</small>
</td>

View File

@@ -24,12 +24,17 @@ class Address extends mfBaseModel {
}
public function getCompanyOrName() {
public function getCompanyOrName($returnParent = false) {
if($returnParent && $this->parent_id) {
return $this->getProperty("parent")->getCompanyOrName(true);
}
if($this->company) {
return $this->company;
}
return $this->getFullName();
}
public function loadAddresstypes() {

View File

@@ -153,7 +153,7 @@ class BuildingModel {
if(array_key_exists("code", $filter)) {
$code = FronkDB::singleton()->escape($filter['code']);
if($code) {
$where .= "AND Building.`code`='$code'";
$where .= " AND Building.`code`='$code'";
}
}

View File

@@ -27,10 +27,15 @@ class BuildingFileController extends mfBaseController {
$this->redirect("Building");
}
$building_id = $buildingfile->order_id;
$building_id = $buildingfile->building_id;
$buildingfile->file->delete();
$buildingfile->delete();
if($this->request->from == "pipework") {
$this->redirect("Pipework", "Index", false, "object=".$building_id);
}
$this->redirect("Building", "edit", ["id" => $building_id]);
}
}

View File

@@ -17,6 +17,10 @@ class PipeworkController extends mfBaseController {
protected function indexAction() {
$this->layout()->setTemplate("Pipework/Index");
if($this->request->filter) {
$filter = $this->getPreparedFilter($this->request->filter);
}
// get allowed networks
if($this->me->is("Admin")) {
$my_networks = NetworkModel::getAll();
@@ -35,6 +39,12 @@ class PipeworkController extends mfBaseController {
"network_id" => $network->id,
"workflow_finished" => 0
];
if(is_array($filter) && count($filter)) {
$building_search = array_merge($building_search, $filter);
}
$this->log->debug(print_r($building_search, true));
foreach(BuildingModel::search($building_search) as $b) {
if(!array_key_exists($b->id, $networks[$network->name])) {
@@ -66,6 +76,10 @@ class PipeworkController extends mfBaseController {
}
private function getPreparedFilter($filter) {
return $filter;
}
protected function saveAction() {
$r = $this->request;
@@ -182,7 +196,7 @@ class PipeworkController extends mfBaseController {
}
$this->layout->setFlash("Workflow Eintrag erfolgreich gespeichert.", "success");
$this->redirect("Pipework","Index", false, "wf-building-".$building_id);
$this->redirect("Pipework","Index", false, "object=".$building_id);

View File

@@ -2,6 +2,7 @@
class Workflowvalue extends mfBaseModel {
private $item;
private $changer;
public function setValue($value, $items) {
$this->item = $this->getProperty("item");
@@ -43,18 +44,33 @@ class Workflowvalue extends mfBaseModel {
}
if($this->item->type == "gps") {
if(is_array($value) && count($value) == 2) {
$lat = $value['lat'];
$long = $value['long'];
$value = "$lat;$long";
if($lat == null && $long == null) {
$value = null;
}
} else {
$value = "";
$value = null;
}
}
if($this->item->type == "bool" && $this->{"value_".$value_type} = null && $value == 0) {
return true;
}
if($value == null && $this->{"value_".$value_type} == null) {
return true;
}
$me = new User();
$me->loadMe();
if($this->{"value_".$value_type} != $value) {
$this->{"value_".$value_type} = $value;
@@ -77,6 +93,15 @@ class Workflowvalue extends mfBaseModel {
return $this->item;
}
if($name == "changer") {
if($this->changed && $this->changed_by) {
$this->changer = new User($this->changed_by);
return $this->changer;
} else {
return new Address();
}
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);

View File

@@ -130,3 +130,7 @@ td.controls {
color: red;
}
.flash-bg {
background-color: yellow !important;
color: yellow;
}