Added Linework workflow
This commit is contained in:
282
Layout/default/Linework/Index.php
Normal file
282
Layout/default/Linework/Index.php
Normal file
@@ -0,0 +1,282 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
<?php $wftype = "termination"; ?>
|
||||
|
||||
|
||||
<!-- 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 active">Leitungsbau</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Leitungsbau</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
|
||||
<form method="get" action="<?=self::getUrl("Linework")?>">
|
||||
<div class="row">
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_network_id">Netzgebiet</label>
|
||||
<select name="filter[network_id]" id="filter_network_id" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach($mynetworks as $fnet): ?>
|
||||
<option value="<?=$fnet->id?>" <?=($filter['network_id'] == $fnet->id) ? "selected='selected'" : ""?>><?=$fnet->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_networksection_id">Bauabschnitt</label>
|
||||
<select name="filter[networksection_id]" id="filter_networksection_id" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach($mynetworks as $fnet): ?>
|
||||
<?php if(is_array($fnet->sections) && count($fnet->sections)): ?>
|
||||
<optgroup label="<?=$fnet->name?>">
|
||||
<?php foreach($fnet->sections as $section): ?>
|
||||
<option value="<?=$section->id?>" <?=($filter['networksection_id'] == $section->id) ? "selected='selected'" : ""?>><?=$section->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_status_id">Anschlussstatus</label>
|
||||
<select name="filter[status_id]" id="filter_status_id" class="form-control">
|
||||
<option></option>
|
||||
<?php foreach(TerminationstatusModel::getAll() as $status): ?>
|
||||
<option
|
||||
value="<?=$status->id?>"
|
||||
<?php if(is_array($filter)): ?>
|
||||
<?=($filter['status_id'] == $status->id) ? "selected='selected'" : ""?>
|
||||
<?php else: ?>
|
||||
<?=(($me->is("lineworker") && !$me->isAdmin()) && $status->id == 3) ? "selected='selected'" : ""?>
|
||||
<?php endif; ?>
|
||||
>
|
||||
<?=$status->code?> - <?=__($status->name."-t")?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_building_code">Gebäude Objekt ID</label>
|
||||
<input type="text" class="form-control" name="filter[building_code]" id="filter_building_code" value="<?=$filter['building_code']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="filter_code">Anschluss Objekt ID</label>
|
||||
<input type="text" class="form-control" name="filter[code]" id="filter_code" value="<?=$filter['code']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_building_street">Straße</label>
|
||||
<input type="text" class="form-control" name="filter[building_street]" id="filter_building_street" value="<?=$filter['building_street']?>" />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Linework")?>">Filter zurücksetzen</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Auftragsliste nach Netzgebiet</h4>
|
||||
|
||||
|
||||
<?php if(is_array($networks) && count($networks)): ?>
|
||||
<?php foreach($networks as $networkname => $terminations): ?>
|
||||
<?php if(!count($terminations)) continue; ?>
|
||||
<h4><?=$networkname?></h4>
|
||||
<table class="table workflow-table">
|
||||
<?php $bcount = 0; foreach($terminations as $term): ?>
|
||||
<?php
|
||||
$rowspan = 1;
|
||||
foreach($term->workflowitems as $item) {
|
||||
if($item->type == "delimiter") {
|
||||
$rowspan++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr id="termination-<?=$term->id?>" class="table-bg-<?=($bcount % 2 == 0) ? "even" : "odd"?>">
|
||||
<td>
|
||||
<div>
|
||||
<strong style="white-space: nowrap;"><?=$term->building->street?></strong><br />
|
||||
<span class="text-success"><?=$term->code?></span><br />
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<?=$term->contact?><br />
|
||||
<strong><?=$term->phone?></strong><br />
|
||||
<?=$term->email?>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<label <?=(!$term->lineworker_id) ? "class='text-danger' title='Keine Leitungsbaufirma ausgewählt'" : ""?>>
|
||||
<input type="checkbox" form="wf-termination-<?=$term->id?>" name="linework_enabled" value="1"
|
||||
<?=($term->linework_enabled == 1) ? "checked='checked'" : ""?> <?=(!$term->lineworker_id || !$me->is(["Admin", "pipeplanner", "lineplanner"])) ? "disabled='disabled'" : ""?>
|
||||
>
|
||||
Baufreigabe
|
||||
</label>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<button type="button" class="btn btn-primary" form="wf-termination-<?=$term->id?>" onclick="document.getElementById(this.getAttribute('form')).submit()">Speichern</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" name="wf-termination-<?=$term->id?>" id="wf-termination-<?=$term->id?>" action="<?=self::getUrl("Linework","save", ["filter" => $filter])?>" enctype="multipart/form-data" >
|
||||
<input type="hidden" name="id" value="<?=$term->id?>" />
|
||||
<table class="table workflow-table">
|
||||
<?php $i = 0; foreach($term->workflowitems as $item): ?>
|
||||
<?php if($i==0): ?>
|
||||
<?php if($item->type == "delimiter"): ?>
|
||||
<tr class="workflow-header"><th colspan='<?=$termination_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='<?=$termination_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-termination-<?=$term->id?>" name="workflow_comment" id="workflow_comment_<?=$term->id?>"><?=$term->workflow_comment?></textarea>
|
||||
</td>
|
||||
<td colspan="<?=$termination_wf_colspan - 3?>">
|
||||
<h5>Dokumente</h5>
|
||||
<table class="table-sm">
|
||||
<?php if(is_array($term->files) && count($term->files)): $i=0; foreach($term->files as $file): ?>
|
||||
<?php if($i % 2 == 0): ?>
|
||||
<tr>
|
||||
<td title="<?=$file->file->filename?>">
|
||||
<a href="<?=self::getUrl("TerminationFile", "delete", ['id' => $file->id, "from" => "linework"])?>" 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("TerminationFile", "delete", ['id' => $file->id, "from" => "linework"])?>" 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; endif; ?>
|
||||
<?=($i % 2 != 0) ? "<td></td></tr>" : ""?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong>Dokument hochladen</strong> <select class="form-control" name="file_type">
|
||||
<?php foreach(TT_WORKFLOW_TERMINATION_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="LineworkFileUpload" 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>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
var term;
|
||||
var hash = window.location.hash.substr(1);
|
||||
var match = hash.match(/object=(\d+)/);
|
||||
if(match && match[1]) {
|
||||
building = match[1]
|
||||
var pos = $('#object-' + term).offset().top;
|
||||
$(window).scrollTop(pos - 150 );
|
||||
}
|
||||
});
|
||||
|
||||
$('select[name=wfitem_linework_finished]').each(function() {
|
||||
var elem = this;
|
||||
//console.log(elem);
|
||||
$(elem).click(function() {
|
||||
var id_match = $(this).attr("id").match(/wfitem_linework_finished_(\d+)$/);
|
||||
var id = id_match[1];
|
||||
//console.log(id);
|
||||
|
||||
var ap_type=$('#wfitem_anschlusspunkt_typ_' + id).val();
|
||||
var ap_name=$('#wfitem_anschlusspunkt_name_' + id).val();
|
||||
var rohrname=$('#wfitem_rohrverband_name_' + id).val();
|
||||
var rohrtype=$('#wfitem_rohrtype_' + id).val();
|
||||
var rohrfarbe=$('#wfitem_rohrfarbe_' + id).val();
|
||||
|
||||
var ist_ap_type=$('#wfitem_ist_anschlusspunkt_typ_' + id).val();
|
||||
var ist_ap_name=$('#wfitem_ist_anschlusspunkt_name_' + id).val();
|
||||
var ist_rohrname=$('#wfitem_ist_rohrverband_name_' + id).val();
|
||||
var ist_rohrtype=$('#wfitem_ist_rohrtype_' + id).val();
|
||||
var ist_rohrfarbe=$('#wfitem_ist_rohrfarbe_' + id).val();
|
||||
|
||||
//console.log(ap_type, ap_name, rohrname, rohrtype, rohrfarbe);
|
||||
|
||||
if((!ap_type && !ist_ap_type) || (!ap_name && !ist_ap_type) || (!rohrname && !ist_rohrname) || (!rohrtype || !ist_rohrtype) || (!rohrfarbe && !ist_rohrfarbe)) {
|
||||
$(this).find("option").attr("disabled", true);
|
||||
}
|
||||
|
||||
if((ap_type || ist_ap_type) && (ap_name || ist_ap_name) && (rohrname || ist_rohrname) && (rohrtype || ist_rohrtype) && (rohrfarbe || ist_rohrfarbe)) {
|
||||
//console.log("enable");
|
||||
$(this).find("option").removeAttr("disabled");
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
|
||||
<?php $wftype = "building"; ?>
|
||||
|
||||
|
||||
<!-- start page title -->
|
||||
@@ -127,7 +127,7 @@
|
||||
<?=$building->email?>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<label <?=(!$building->pipeworker_id) ? "class='text-danger' title='Keine Tiefbaufirma ausgewählt'" : ""?>><input type="checkbox" form="wf-building-<?=$building->id?>" name="pipework_enabled" value="1" <?=($building->pipework_enabled==1) ? "checked='checked'" : ""?> <?=(!$building->pipeworker_id || !$me->is(["Admin", "Pipeplanner "])) ? "disabled='disabled'" : ""?>> Baufreigabe</label>
|
||||
<label <?=(!$building->pipeworker_id) ? "class='text-danger' title='Keine Tiefbaufirma ausgewählt'" : ""?>><input type="checkbox" form="wf-building-<?=$building->id?>" name="pipework_enabled" value="1" <?=($building->pipework_enabled==1) ? "checked='checked'" : ""?> <?=(!$building->pipeworker_id || !$me->is(["Admin", "pipeplanner"])) ? "disabled='disabled'" : ""?>> Baufreigabe</label>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<button type="button" class="btn btn-primary" form="wf-building-<?=$building->id?>" onclick="document.getElementById(this.getAttribute('form')).submit()">Speichern</button>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<td class="workflow-item">
|
||||
<?php if($item->type != "gps"): ?>
|
||||
<label class="form-label" for="wfitem_<?=$item->name?>_<?=$building->id?>">
|
||||
<label class="form-label" for="wfitem_<?=$item->name?>_<?=$$wftype->id?>">
|
||||
<?=($item->label) ? $item->label : " "?>
|
||||
<?=($item->required == 1) ? "*" : ""?>
|
||||
<?=($item->label && $item->required == 1) ? "*" : ""?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<input type="hidden" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=($item->value->value_int == 1) ? "1" : "0"?>" />
|
||||
<input type="hidden" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$$wftype->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?>"
|
||||
id="wfitemplaceholder_<?=$item->name?>_<?=$$wftype->id?>"
|
||||
value="1"
|
||||
<?=($item->value->value_int == 1) ? "checked='checked'" : ""?>
|
||||
onchange="$('#wfitem_<?=$item->name?>_<?=$building->id?>').val((this.checked) ? 1 : 0)"
|
||||
onchange="$('#wfitem_<?=$item->name?>_<?=$$wftype->id?>').val((this.checked) ? 1 : 0)"
|
||||
>
|
||||
|
||||
@@ -8,7 +8,7 @@ if(preg_match('/^(.+)-1R$/', $color_name, $cmatch)) {
|
||||
?>
|
||||
|
||||
|
||||
<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-<?=$color_name?>">
|
||||
<select class="form-control selectpicker show-tick" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$$wftype->id?>" title="Farbe wählen" data-style="btn-outline-<?=$color_name?>">
|
||||
<option></option>
|
||||
<?php foreach(TT_CABLE_COLORS as $name => $color): ?>
|
||||
<option
|
||||
@@ -23,24 +23,24 @@ if(preg_match('/^(.+)-1R$/', $color_name, $cmatch)) {
|
||||
</select>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#wfitem_<?=$item->name?>_<?=$building->id?>').change(function() {
|
||||
var color = $('#wfitem_<?=$item->name?>_<?=$building->id?> option:selected').data("bg-color");
|
||||
var name = $('#wfitem_<?=$item->name?>_<?=$building->id?> option:selected').val();
|
||||
$("wfitem_<?=$item->name?>_<?=$building->id?>").data("style", "btn-danger");
|
||||
console.log("button [data-id='wfitem_<?=$item->name?>_<?=$building->id?>']");
|
||||
console.log($("button [data-id='wfitem_<?=$item->name?>_<?=$building->id?>']"));
|
||||
$('#wfitem_<?=$item->name?>_<?=$$wftype->id?>').change(function() {
|
||||
var color = $('#wfitem_<?=$item->name?>_<?=$$wftype->id?> option:selected').data("bg-color");
|
||||
var name = $('#wfitem_<?=$item->name?>_<?=$$wftype->id?> option:selected').val();
|
||||
$("wfitem_<?=$item->name?>_<?=$$wftype->id?>").data("style", "btn-danger");
|
||||
console.log("button [data-id='wfitem_<?=$item->name?>_<?=$$wftype->id?>']");
|
||||
console.log($("button [data-id='wfitem_<?=$item->name?>_<?=$$wftype->id?>']"));
|
||||
|
||||
var matches;
|
||||
if(matches = name.match(/^(.+)-1R$/)) {
|
||||
name = matches[1];
|
||||
}
|
||||
|
||||
$("[data-id='wfitem_<?=$item->name?>_<?=$building->id?>']").removeClass(function (index, className) {
|
||||
$("[data-id='wfitem_<?=$item->name?>_<?=$$wftype->id?>']").removeClass(function (index, className) {
|
||||
console.log(className);
|
||||
return (className.match (/(^|\s)btn-outline-\S+/g) || []).join(' ');
|
||||
});
|
||||
|
||||
$("[data-id='wfitem_<?=$item->name?>_<?=$building->id?>']").addClass("btn-outline-" + name)
|
||||
$("[data-id='wfitem_<?=$item->name?>_<?=$$wftype->id?>']").addClass("btn-outline-" + name)
|
||||
|
||||
console.log(color);
|
||||
console.log(name);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" 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?>_<?=$$wftype->id?>" value="<?=$item->value->value_string?>" placeholder="<?=$item->placeholder?>" />
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#wfitem_<?=$item->name?>_<?=$building->id?>').datepicker({
|
||||
$('#wfitem_<?=$item->name?>_<?=$$wftype->id?>').datepicker({
|
||||
language: 'de',
|
||||
format: "dd.mm.yyyy",
|
||||
showWeekDays: true,
|
||||
|
||||
@@ -1,9 +1,47 @@
|
||||
<?php
|
||||
$options = [];
|
||||
$options = explode(";", $item->typedata);
|
||||
if(strpos($item->typedata, "=Model=") !== false) {
|
||||
// get options from Model
|
||||
$m = [];
|
||||
if(preg_match('/^=Model=(\w+)(?::([^:]+):)?$/', $item->typedata, $m)) {
|
||||
// dynamic enum
|
||||
$model = $m[1];
|
||||
$modelClass = $model."Model";
|
||||
|
||||
$filter = [];
|
||||
if($m[2]) {
|
||||
$filter_parts = explode("=", $m[2]);
|
||||
$filter_name = $filter_parts[0];
|
||||
$filter_value = $filter_parts[1];
|
||||
|
||||
if(substr($filter_value, 0, 1) == '`') {
|
||||
$filter_value = substr($filter_value, 1, strlen($filter_value) - 2);
|
||||
$objPath = explode("->", $filter_value);
|
||||
|
||||
if(count($objPath) > 1) {
|
||||
$obj = array_shift($objPath);
|
||||
$curr = $$obj;
|
||||
foreach($objPath as $part) {
|
||||
$curr = $curr->$part;
|
||||
}
|
||||
$filter_value = $curr;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($modelClass::search([$filter_name => $filter_value]) as $modelObject) {
|
||||
$options[] = $modelObject->id . "=" . $modelObject->name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$options = explode(";", $item->typedata);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<select class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>">
|
||||
<select class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$$wftype->id?>">
|
||||
<option></option>
|
||||
<?php foreach($options as $opt): ?>
|
||||
<?php
|
||||
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$$wftype->id?>" value="<?=$item->value->value_string?>">
|
||||
@@ -9,12 +9,12 @@
|
||||
?>
|
||||
<div class="row">
|
||||
<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]" id="wfitem_<?=$item->name?>_lat_<?=$building->id?>" value="<?=$lat?>" placeholder="<?=str_replace(",", ".", TT_PLACEHOLDER_GPS_LAT)?>">
|
||||
<label class="form-label" for="wfitem_<?=$item->name?>_lat_<?=$$wftype->id?>">GPS Breite <?=($item->required == 1) ? "*" : ""?></label>
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>[lat]" id="wfitem_<?=$item->name?>_lat_<?=$$wftype->id?>" value="<?=$lat?>" placeholder="<?=str_replace(",", ".", TT_PLACEHOLDER_GPS_LAT)?>">
|
||||
</div>
|
||||
<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]" id="wfitem_<?=$item->name?>_long_<?=$building->id?>" value="<?=$long?>" placeholder="<?=str_replace(",", ".", TT_PLACEHOLDER_GPS_LONG)?>">
|
||||
<label class="form-label" for="wfitem_<?=$item->name?>_long_<?=$$wftype->id?>">GPS Länge <?=($item->required == 1) ? "*" : ""?></label>
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>[long]" id="wfitem_<?=$item->name?>_long_<?=$$wftype->id?>" value="<?=$long?>" placeholder="<?=str_replace(",", ".", TT_PLACEHOLDER_GPS_LONG)?>">
|
||||
</div>
|
||||
<div class="col-md-2 padding-left-2">
|
||||
<label class="form-label"> </label>
|
||||
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$$wftype->id?>" value="<?=$item->value->value_string?>">
|
||||
@@ -1 +1 @@
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" 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?>_<?=$$wftype->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?>_<?=$building->id?>" value="<?=$item->value->value_string?>">
|
||||
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$$wftype->id?>" value="<?=$item->value->value_string?>">
|
||||
@@ -38,7 +38,7 @@
|
||||
<ul class="submenu">
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner","lineplanner"])): ?><li><a href="<?=self::getUrl("Building")?>">Objekte & Anschlüsse</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner","pipeworker"])): ?><li><a href="<?=self::getUrl("Pipework")?>">Tiefbau</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Lineworker")?>">Leitungsbau</a></li><?php endif; ?>
|
||||
<?php if($me->is(["Admin","netowner","pipeplanner","pipeworker","lineplanner","lineworker"])): ?><li><a href="<?=self::getUrl("Linework")?>">Leitungsbau</a></li><?php endif; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
307
application/Linework/LineworkController.php
Normal file
307
application/Linework/LineworkController.php
Normal file
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
class LineworkController extends mfBaseController {
|
||||
|
||||
protected function init() {
|
||||
$this->needlogin=true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me",$me);
|
||||
|
||||
if(!$me->is(["Admin", "netowner","pipeplanner","pipeworker", "lineplanner", "lineworker"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("Linework/Index");
|
||||
$filter = [];
|
||||
|
||||
$this->layout->set("filter", $this->request->filter);
|
||||
|
||||
if($this->request->filter) {
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
}
|
||||
|
||||
$my_networks = [];
|
||||
|
||||
// get allowed networks
|
||||
if($this->me->is("Admin")) {
|
||||
if($filter['network_id']) {
|
||||
$my_networks[] = new Network($filter['network_id']);
|
||||
} else {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
}
|
||||
$this->layout()->set("mynetworks", NetworkModel::getAll());
|
||||
} else {
|
||||
$use_filter_network = false;
|
||||
$my_networks = $this->me->my_networks;
|
||||
|
||||
foreach($my_networks as $mn) {
|
||||
if($mn->id == $filter['network_id']) {
|
||||
$use_filter_network = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if($use_filter_network) {
|
||||
$my_networks = [];
|
||||
$my_networks[] = new Network($filter['network_id']);
|
||||
}
|
||||
|
||||
$this->layout()->set("mynetworks", $this->me->my_networks);
|
||||
|
||||
}
|
||||
unset($filter['network_id']);
|
||||
|
||||
// get Buildings in networks
|
||||
$networks = [];
|
||||
foreach($my_networks as $network) {
|
||||
if(!array_key_exists($network->name, $networks)) {
|
||||
$networks[$network->name] = [];
|
||||
}
|
||||
|
||||
$termination_search = [
|
||||
"network_id" => $network->id,
|
||||
"workflow_finished" => 0
|
||||
];
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$termination_search[$name] = $value;
|
||||
}
|
||||
//$building_search = array_merge($building_search, $filter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($this->me->is("lineworker") && !$this->me->is(["Admin","pipeplanner", "lineplanner","netowner"])) {
|
||||
$this->log->debug("is lineworker");
|
||||
$termination_search["lineworker_id"] = ($this->me->address->parent_id) ? $this->me->address->parent_id : $this->me->address_id;
|
||||
|
||||
if(!count($filter)) {
|
||||
$termination_search["status_id"] = 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach(TerminationModel::search($termination_search) as $b) {
|
||||
if(!array_key_exists($b->id, $networks[$network->name])) {
|
||||
$networks[$network->name][$b->id] = $b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$term = reset(reset($networks));
|
||||
$item_colspan = 0;
|
||||
$i = 0;
|
||||
|
||||
//var_dump($term);exit;
|
||||
|
||||
// get fields between delimiters for colspan
|
||||
if(is_array($term->workflowitems) && count($term->workflowitems)) {
|
||||
foreach($term->workflowitems as $wfitem) {
|
||||
if($i == 0 && $wfitem->type == "delimiter") continue;
|
||||
|
||||
if($wfitem->type == "delimiter") {
|
||||
$item_colspan = $i;
|
||||
break;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
//var_dump($item_colspan);exit;
|
||||
$this->layout()->set("termination_wf_colspan", $item_colspan);
|
||||
$this->layout()->set("networks", $networks);
|
||||
//var_dump(reset(reset($networks))->workflowitems);exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
if(is_numeric($filter['networksection_id']) && $filter['networksection_id']) {
|
||||
$section = new Networksection($filter['networksection_id']);
|
||||
if($section->id) {
|
||||
$filter['network_id'] = $section->network_id;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($filter as $name => $value) {
|
||||
/*if($name == 'network_id') {
|
||||
$new_filter['id'] = $value;
|
||||
continue;
|
||||
}*/
|
||||
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
//var_dump($r->get());exit;
|
||||
$termination_id = $r->id;
|
||||
if(!is_numeric($termination_id) || $termination_id < 1) {
|
||||
$this->layout()->setFlash("Objekt nicht gefunden", "error");
|
||||
$this->redirect("Linework");
|
||||
}
|
||||
|
||||
$termination = new Termination($termination_id);
|
||||
if(!$termination->id) {
|
||||
$this->layout()->setFlash("Objekt nicht gefunden", "error");
|
||||
$this->redirect("Linework");
|
||||
}
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
|
||||
if($this->me->is(["Admin", "netowner","pipeplanner", "lineplanner"])) {
|
||||
if($r->linework_enabled == 1) {
|
||||
$termination->linework_enabled = 1;
|
||||
if($termination->status_id < 3) {
|
||||
$termination->status_id = 3;
|
||||
}
|
||||
} else {
|
||||
$termination->linework_enabled = 0;
|
||||
}
|
||||
$termination->save();
|
||||
}
|
||||
|
||||
if($termination->workflow_comment != $r->workflow_comment) {
|
||||
$termination->workflow_comment = $r->workflow_comment;
|
||||
$termination->workflow_comment_changed = date('U');
|
||||
$termination->workflow_comment_changed_by = $this->me->id;
|
||||
$termination->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" => "termination"]);
|
||||
if(!$item) {
|
||||
var_dump("no item: $name");exit;
|
||||
}
|
||||
$item->setObjectId($termination_id);
|
||||
$item->value->setValue($value);
|
||||
if($item->value->is_changed) {
|
||||
$item->value->save();
|
||||
}
|
||||
|
||||
$termination->resetProperties();
|
||||
|
||||
// set linework finished flag in building
|
||||
/*
|
||||
if($name == TT_WORKFLOW_ITEM_LINEWORK_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();
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Custom checks
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
if($building->workflowitems['pipework_finished']->value->value_string) {
|
||||
// unset Tiefbau abgeschlossen if missing values
|
||||
if( (!$building->workflowitems['anschlusspunkt_typ']->value->value_string && !$building->workflowitems['ist_anschlusspunkt_typ']->value->value_string)
|
||||
|| (!$building->workflowitems['anschlusspunkt_name']->value->value_string && !$building->workflowitems['ist_anschlusspunkt_name']->value->value_string)
|
||||
|| (!$building->workflowitems['rohrverband_name']->value->value_string && !$building->workflowitems['ist_rohrverband_name']->value->value_string)
|
||||
|| (!$building->workflowitems['rohrtype']->value->value_string && !$building->workflowitems['ist_rohrtype']->value->value_string)
|
||||
|| (!$building->workflowitems['rohrfarbe']->value->value_string && !$building->workflowitems['ist_rohrfarbe']->value->value_string)
|
||||
) {
|
||||
$building->workflowitems['pipework_finished']->value->value_string = "";
|
||||
$building->workflowitems['pipework_finished']->value->save();
|
||||
}
|
||||
}*/
|
||||
|
||||
// set building status if Status field was set
|
||||
/*
|
||||
if(defined("TT_WORKFLOW_ITEM_STATUS_FIELD") && defined("TT_WORKFLOW_ITEM_STATUS_VALUE_PASSED") && defined("TT_WORKFLOW_ITEM_STATUS_VALUE_CONNECTED")) {
|
||||
$status_value = $building->workflowitems[TT_WORKFLOW_ITEM_STATUS_FIELD]->value->value_string;
|
||||
//var_dump($status_value);exit;
|
||||
if($status_value == TT_WORKFLOW_ITEM_STATUS_VALUE_PASSED && $building->status_id != 4) {
|
||||
$building->status_id = 4;
|
||||
$building->save();
|
||||
}
|
||||
if($status_value == TT_WORKFLOW_ITEM_STATUS_VALUE_CONNECTED && $building->status_id != 5) {
|
||||
$building->status_id = 5;
|
||||
$building->save();
|
||||
}
|
||||
}*/
|
||||
|
||||
// file upload
|
||||
//var_dump($_FILES);exit;
|
||||
if(array_key_exists("LineworkFileUpload", $_FILES) && !$_FILES['LineworkFileUpload']['error']) {
|
||||
|
||||
try {
|
||||
$upload = new mfUpload("LineworkFileUpload");
|
||||
$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 {
|
||||
$tf = [];
|
||||
$tf['termination_id'] = $termination_id;
|
||||
$tf['file_id'] = $file_id;
|
||||
$tf['type'] = $r->file_type;
|
||||
$tf['name'] = $file->name;
|
||||
|
||||
$termfile = TerminationFileModel::create($tf);
|
||||
if(!$termfile->save()) {
|
||||
$file->delete();
|
||||
unlink($upload->getSavepath()."/".$upload->getFilename());
|
||||
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "warn");
|
||||
$this->redirect("Linework");
|
||||
}
|
||||
}
|
||||
} catch(Exception $ex) {
|
||||
$this->layout->setFlash("Fehler beim Dateiupload: ".$ex->getMessage(), "warn");
|
||||
$this->redirect("Linework");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->layout->setFlash("Workflow Eintrag erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Linework","Index", http_build_query(["filter" => $this->request->filter]), "object=".$termination_id);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,7 +84,6 @@ class NetworkAddressModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
mfLoghandler::singleton()->debug($where);
|
||||
$res = $db->select("NetworkAddress", "*", "$where ORDER BY `type`");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
|
||||
@@ -150,8 +150,7 @@ class OrderModel {
|
||||
LEFT JOIN Building ON (Building.id = Termination.building_id)
|
||||
WHERE $where
|
||||
GROUP BY `Order`.id";
|
||||
//var_dump($sql);exit;
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
|
||||
@@ -6,6 +6,8 @@ class Termination extends mfBaseModel {
|
||||
private $building;
|
||||
private $status;
|
||||
private $lineworker;
|
||||
private $workflowitems;
|
||||
private $files;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
@@ -70,7 +72,15 @@ class Termination extends mfBaseModel {
|
||||
return $code;
|
||||
}
|
||||
|
||||
|
||||
public function resetProperties() {
|
||||
$this->building = null;
|
||||
$this->status = null;
|
||||
$this->lineworder = null;
|
||||
$this->workflowitems = null;
|
||||
$this->files = null;
|
||||
$this->creator = null;
|
||||
$this->editor = null;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
@@ -80,6 +90,20 @@ class Termination extends mfBaseModel {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
if($name == "workflowitems") {
|
||||
foreach(WorkflowitemModel::search(["object_type" => "Termination", "active" => 1]) as $item) {
|
||||
$item->setObjectId($this->id);
|
||||
$this->workflowitems[$item->name] = $item;
|
||||
}
|
||||
//var_dump($this->workflowitems);exit;
|
||||
return $this->workflowitems;
|
||||
}
|
||||
|
||||
if($name == "files") {
|
||||
$this->files = TerminationFileModel::search(["termination_id" => $this->id]);
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
@@ -105,6 +105,14 @@ class TerminationModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("status_id", $filter)) {
|
||||
$status_id = $filter['status_id'];
|
||||
|
||||
if(is_numeric($status_id) && $status_id > 0) {
|
||||
$where .= " AND Termination.status_id = $status_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("network_id", $filter)) {
|
||||
$network_id = $filter['network_id'];
|
||||
if(is_numeric($network_id)) {
|
||||
@@ -114,6 +122,36 @@ class TerminationModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("networksection_id", $filter)) {
|
||||
$networksection_id = $filter['networksection_id'];
|
||||
if(is_numeric($networksection_id)) {
|
||||
$where .= " AND Building.networksection_id=$networksection_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("code", $filter)) {
|
||||
$code = FronkDB::singleton()->escape($filter['code']);
|
||||
if($code) {
|
||||
$where .= " AND Termination.code LIKE '%$code%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("building_code", $filter)) {
|
||||
$building_code = FronkDB::singleton()->escape($filter['building_code']);
|
||||
if($building_code) {
|
||||
$where .= " AND Building.code LIKE '%$building_code%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("building_street", $filter)) {
|
||||
$building_street = FronkDB::singleton()->escape($filter['building_street']);
|
||||
if($building_street) {
|
||||
$where .= " AND Building.street LIKE '%$building_street%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("status", $filter)) {
|
||||
if(in_array(substr($filter['status'], 1, 2), ["<=", ">="])) {
|
||||
$op = substr($filter['status'], 1, 2);
|
||||
|
||||
40
application/TerminationFile/TerminationFile.php
Normal file
40
application/TerminationFile/TerminationFile.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class TerminationFile extends mfBaseModel {
|
||||
private $file;
|
||||
private $termination;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
42
application/TerminationFile/TerminationFileController.php
Normal file
42
application/TerminationFile/TerminationFileController.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class TerminationFileController 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;
|
||||
|
||||
$termfile = new TerminationFile($id);
|
||||
if(!$termfile->id || $termfile->id != $id) {
|
||||
$this->layout()->setFlash("Datei nicht gefunden.", "error");
|
||||
$this->redirect("Termination");
|
||||
}
|
||||
|
||||
$term_id = $termfile->termination_id;
|
||||
$building_id = $termfile->termination->building_id;
|
||||
|
||||
$termfile->file->delete();
|
||||
$termfile->delete();
|
||||
|
||||
if($this->request->from == "linework") {
|
||||
$this->redirect("Linework", "Index", false, "object=".$termination_id);
|
||||
}
|
||||
|
||||
$this->redirect("building", "edit", ["id" => $building_id]);
|
||||
}
|
||||
}
|
||||
156
application/TerminationFile/TerminationFileModel.php
Normal file
156
application/TerminationFile/TerminationFileModel.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
class TerminationFileModel {
|
||||
public $termination_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 TerminationFile();
|
||||
|
||||
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("TerminationFile", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new TerminationFile($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("TerminationFile", "*", "1=1 ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new TerminationFile($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("TerminationFile", "*", "$where ORDER BY name, filename");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new TerminationFile($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 TerminationFile.* FROM TerminationFile
|
||||
LEFT JOIN File ON (TerminationFile.file_id = File.id)
|
||||
WHERE $where
|
||||
ORDER BY termination_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("termination_id", $filter)) {
|
||||
$termination_id = $filter['termination_id'];
|
||||
if(is_numeric($termination_id)) {
|
||||
$where .= " AND termination_id=$termination_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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,9 @@
|
||||
class Workflowvalue extends mfBaseModel {
|
||||
private $item;
|
||||
private $changer;
|
||||
public $is_changed = false;
|
||||
|
||||
public function setValue($value, $items) {
|
||||
public function setValue($value) {
|
||||
$this->item = $this->getProperty("item");
|
||||
|
||||
if($this->item->type == "delimiter" || $this->item->type == "empty") {
|
||||
@@ -58,6 +59,13 @@ class Workflowvalue extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if($value === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($value_type == "int" && !$value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($this->item->type == "bool" && $this->{"value_".$value_type} = null && $value == 0) {
|
||||
return true;
|
||||
@@ -67,11 +75,11 @@ class Workflowvalue extends mfBaseModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->is_changed = true;
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
|
||||
|
||||
if($this->{"value_".$value_type} != $value) {
|
||||
$this->{"value_".$value_type} = $value;
|
||||
$this->changed = date('U');
|
||||
|
||||
Reference in New Issue
Block a user