changes for mark
This commit is contained in:
@@ -104,6 +104,15 @@
|
||||
<input type="text" class="form-control" name="filter[building_street]" id="filter_building_street" value="<?=$filter['building_street']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_linework_enabled">Baufreigabe</label>
|
||||
<select name="filter[linework_enabled]" id="filter_linework_enabled" class="form-control">
|
||||
<option value="">Alle</option>
|
||||
<option value="1" <?=(array_key_exists("linework_enabled", $filter) && $filter["linework_enabled"] == "1") ? "selected='selected'" : ""?>>Ja</option>
|
||||
<option value="0" <?=(array_key_exists("linework_enabled", $filter) && $filter["linework_enabled"] == "0") ? "selected='selected'" : ""?>>Nein</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<?php if(array_key_exists("status_id", $filter)): ?>
|
||||
<?=($filter['status_id'] == $status->id) ? "selected='selected'" : ""?>
|
||||
<?php else: ?>
|
||||
<?=($status->id == 3) ? "selected='selected'" : ""?>
|
||||
<?=(!in_array($me->id, ["145","62","56"]) && $status->id == 3) ? "selected='selected'" : ""?>
|
||||
<?php endif; ?>
|
||||
>
|
||||
<?=$status->code?> - <?=__($status->name."-b")?></option>
|
||||
@@ -91,6 +91,15 @@
|
||||
<label class="form-label" for="filter_street">Straße</label>
|
||||
<input type="text" class="form-control" name="filter[street]" id="filter_street" value="<?=$filter['street']?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_pipework_enabled">Baufreigabe</label>
|
||||
<select name="filter[pipework_enabled]" id="filter_pipework_enabled" class="form-control">
|
||||
<option value="">Alle</option>
|
||||
<option value="1" <?=(array_key_exists("pipework_enabled", $filter) && $filter["pipework_enabled"] == "1") ? "selected='selected'" : ""?>>Ja</option>
|
||||
<option value="0" <?=(array_key_exists("pipework_enabled", $filter) && $filter["pipework_enabled"] == "0") ? "selected='selected'" : ""?>>Nein</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -99,7 +108,10 @@
|
||||
<div class="row mt-2">
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Pipework")?>">Filter zurücksetzen</a>
|
||||
<a class="btn btn-secondary" href="<?=self::getUrl("Pipework")?>">Filter zurücksetzen</a>
|
||||
<?php if ($me->is(["Admin"])) :?>
|
||||
<a class="btn btn-outline-secondary" href="<?=self::getUrl("Pipework", "History")?>">Zur Historie</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div style="width: 512px;">
|
||||
<div class="row">
|
||||
|
||||
@@ -167,6 +167,13 @@ class BuildingModel {
|
||||
$where .= " AND Building.pipeworker_id=$pipeworker_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("pipework_enabled", $filter)) {
|
||||
$pipework_enabled = $filter['pipework_enabled'];
|
||||
if(!empty($pipework_enabled) || $pipework_enabled === "0") {
|
||||
$where .= " AND Building.pipework_enabled=$pipework_enabled";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("type", $filter) && is_array($filter['type']) && count($filter['type'])) {
|
||||
$ot = $filter['type'];
|
||||
@@ -267,5 +274,54 @@ class BuildingModel {
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
public static function getHistory($from, $to, $network_id, $street_filter): array {
|
||||
$sql = "SELECT b.id AS building_id,
|
||||
b.street AS building_street,
|
||||
b.zip AS building_zip,
|
||||
b.city AS building_city,
|
||||
wi.id AS item_id,
|
||||
wi.name AS item_name,
|
||||
wi.label AS item_label,
|
||||
wi.type AS item_type,
|
||||
wv.id AS value_id,
|
||||
wv.value_string,
|
||||
wv.value_int,
|
||||
wv.value_text,
|
||||
(wv.create) AS created_at,
|
||||
wv.create_by AS created_by_user_id,
|
||||
(wv.edit) AS last_edited_at,
|
||||
wv.edit_by AS last_edited_by_user_id
|
||||
FROM Workflowvalue wv
|
||||
JOIN Workflowitem wi ON wv.item_id = wi.id
|
||||
JOIN Building b ON wv.object_id = b.id";
|
||||
$where = ["wi.object_type = 'Building'", "wi.num < 150"];
|
||||
|
||||
if ($from !== null && $to !== null) {
|
||||
$where[] = "((wv.create >= " . intval($from) . " AND wv.create <= " . intval($to) . ") OR (wv.edit >= " . intval($from) . " AND wv.edit <= " . intval($to) . "))";
|
||||
}
|
||||
if ($network_id !== null) {
|
||||
$where[] = "b.network_id = " . intval($network_id);
|
||||
}
|
||||
if (!empty($street_filter)) {
|
||||
$escaped_street = addslashes($street_filter);
|
||||
$where[] = "b.street LIKE '%" . $escaped_street . "%'";
|
||||
}
|
||||
|
||||
$sql .= " WHERE " . implode(" AND ", $where);
|
||||
$sql .= " ORDER BY wv.edit DESC, wv.create DESC;";
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$res = $db->query($sql);
|
||||
|
||||
if ($db->num_rows($res)) {
|
||||
$items = [];
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = $data;
|
||||
}
|
||||
return $items;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class PipeworkController extends mfBaseController {
|
||||
}
|
||||
|
||||
|
||||
if(!array_key_exists("status_id", $filter)) {
|
||||
if(!in_array($this->me->id, ["145","62","56"]) && !array_key_exists("status_id", $filter)) {
|
||||
$building_search["status_id"] = 3;
|
||||
}
|
||||
|
||||
@@ -461,5 +461,51 @@ class PipeworkController extends mfBaseController {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function historyAction() {
|
||||
if (!$this->me->isAdmin()) {
|
||||
throw new Exception("Forbidden", 403);
|
||||
}
|
||||
|
||||
Helper::renderVue($this, "PipeworkHistory", "PipeworkHistory", [
|
||||
"IS_ADMIN" => $this->me->isAdmin(),
|
||||
"NETWORKS" => array_map(function ($network) {
|
||||
return [
|
||||
"value" => $network->id,
|
||||
"text" => $network->name,
|
||||
];
|
||||
}, NetworkModel::getAll()),
|
||||
"USERS" => array_map(function ($user) {
|
||||
return [
|
||||
"value" => $user->id,
|
||||
"text" => $user->name,
|
||||
];
|
||||
}, UserModel::search(['employee' => true])),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function historyAPIAction() {
|
||||
if (!$this->me->isAdmin()) self::sendError("Keine Berechtigung");
|
||||
|
||||
$from = $this->request->from;
|
||||
$to = $this->request->to;
|
||||
$network_id = $this->request->network_id;
|
||||
$street_filter = $this->request->street_filter;
|
||||
|
||||
// from and to is unix timestamp
|
||||
if ($from && $to) {
|
||||
$from = (int)$from;
|
||||
$to = (int)$to;
|
||||
if ($from > $to) self::sendError('Von kann nicht nach dem Bis-Datum liegen');
|
||||
$fourWeeksInSeconds = 2419200;
|
||||
// if (($to - $from) > $fourWeeksInSeconds) self::sendError('Der Zeitraum darf maximal 4 Wochen betragen');
|
||||
}
|
||||
|
||||
if ($from && $to && $network_id) {
|
||||
self::returnJson(["status" => "OK","data" => BuildingModel::getHistory($from,$to,$network_id,$street_filter)]);
|
||||
} else {
|
||||
self::sendError('Fehlerhafte Parameter');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +146,13 @@ class TerminationModel {
|
||||
$where .= " AND Termination.status_id = $status_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("linework_enabled", $filter)) {
|
||||
$linework_enabled = $filter['linework_enabled'];
|
||||
if(!empty($linework_enabled) || $linework_enabled === '0') {
|
||||
$where .= " AND Termination.linework_enabled=$linework_enabled";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("lineworker_id", $filter)) {
|
||||
$lineworker_id = $filter['lineworker_id'];
|
||||
|
||||
119
public/js/pages/PipeworkHistory/PipeworkHistory.js
Normal file
119
public/js/pages/PipeworkHistory/PipeworkHistory.js
Normal file
@@ -0,0 +1,119 @@
|
||||
Vue.component('pipework-history', {
|
||||
//language=Vue
|
||||
template: `<tt-card>
|
||||
|
||||
|
||||
<div class="filter-row">
|
||||
<tt-input label="Addresse" v-model="address" placeholder="Adresse" row sm/>
|
||||
<tt-autocomplete :items="window.TT_CONFIG.NETWORKS" v-model="selectedNetwork" label="Netzgebiet" row/>
|
||||
<tt-date-picker date-range v-model="dateRange" label="Datum" row sm/>
|
||||
|
||||
<tt-button :disabled="checkParameters !== true" @click="getPipeworkHistory" text="Anzeigen" sm icon="fa-solid fa-magnifying-glass" additional-class="btn-primary"/>
|
||||
<span v-if="checkParameters !== true" class="text-danger">{{ checkParameters }}</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<tt-table v-if="pipeworkHistory.length > 0" :config="pipeworkHistoryTableConfig" :data="pipeworkHistory" :key="pipeworkHistoryTableIndex">
|
||||
<template #item_type="{ row }">
|
||||
<span v-if="row.value_int !== null">{{ row.value_int }}</span>
|
||||
<span v-else-if="row.value_string !== null">{{ row.value_string }}</span>
|
||||
<span v-else-if="row.value_text !== null">{{ row.value_text }}</span>
|
||||
<span v-else>Unbekannt</span>
|
||||
</template>
|
||||
|
||||
<template #last_edited_at="{ row }">
|
||||
<span v-if="row.last_edited_at">{{ window.moment.unix(row.last_edited_at).format('DD.MM.YYYY HH:mm') }}</span>
|
||||
<span v-else>Unbekannt</span>
|
||||
</template>
|
||||
|
||||
<template #last_edited_by_user_id="{ row }">
|
||||
<span v-if="row.last_edited_by_user_id">{{ window.TT_CONFIG.USERS.find(user => user.value === row.last_edited_by_user_id)?.text }}</span>
|
||||
<span v-else>Unbekannt</span>
|
||||
</template>
|
||||
|
||||
<template #item_id="{ row }">
|
||||
<tt-button @click="openPipework(row)" text="Zum Tiefbau" icon="fa-solid fa-pen-to-square" additional-class="btn-primary" sm/>
|
||||
</template>
|
||||
|
||||
</tt-table>
|
||||
</div>
|
||||
|
||||
|
||||
</tt-card>`,
|
||||
data() {
|
||||
return {
|
||||
window: window,
|
||||
address: '',
|
||||
dateRange: {
|
||||
from: window.moment().subtract(4, 'weeks').unix(),
|
||||
to: window.moment().unix()
|
||||
},
|
||||
selectedNetwork: null,
|
||||
pipeworkHistory: [],
|
||||
pipeworkHistoryLoading: true,
|
||||
pipeworkHistoryError: false,
|
||||
pipeworkHistoryTableIndex: 0,
|
||||
pipeworkHistoryTableConfig: {
|
||||
key: 'PipeworkHistoryTable',
|
||||
tableHeader: 'Tiefbau Historie',
|
||||
defaultPageSize: 50,
|
||||
headers: [
|
||||
{text: 'Straße', key: 'building_street'},
|
||||
{text: 'Ort', key: 'building_city'},
|
||||
{text: 'Feld', key: 'item_label'},
|
||||
{text: 'Wert', key: 'item_type'},
|
||||
{text: 'Editiert', key: 'last_edited_at'},
|
||||
{text: 'Von', key: 'last_edited_by_user_id'},
|
||||
{text: 'Actions', key: 'item_id'},
|
||||
],
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
checkParameters() {
|
||||
if (!this.selectedNetwork) {
|
||||
return 'Bitte Netzgebiet auswählen';
|
||||
} else if (this.dateRange.from && this.dateRange.to) {
|
||||
const from = window.moment.unix(this.dateRange.from);
|
||||
const to = window.moment.unix(this.dateRange.to);
|
||||
const diff = to.diff(from, 'days');
|
||||
if (diff > 28) {
|
||||
return 'Bitte Zeitraum von maximal 4 Wochen auswählen';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getPipeworkHistory() {
|
||||
this.pipeworkHistoryLoading = true;
|
||||
this.pipeworkHistoryError = false;
|
||||
|
||||
try {
|
||||
const response = await axios.get(`${window.TT_CONFIG.BASE_PATH}/Pipework/HistoryAPI`, {
|
||||
params: {
|
||||
network_id: this.selectedNetwork,
|
||||
street_filter: this.address,
|
||||
from: this.dateRange.from,
|
||||
to: this.dateRange.to
|
||||
}
|
||||
})
|
||||
this.pipeworkHistory = response.data.data;
|
||||
this.pipeworkHistoryLoading = false;
|
||||
this.pipeworkHistoryTableIndex++;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.pipeworkHistoryLoading = false;
|
||||
this.pipeworkHistoryError = true;
|
||||
this.window.notify('error', 'Fehler beim Abrufen der Daten');
|
||||
}
|
||||
},
|
||||
openPipework(row) {
|
||||
|
||||
const networkId = this.selectedNetwork;
|
||||
const street = row.building_street;
|
||||
|
||||
this.window.open(`${window.TT_CONFIG.BASE_PATH}/Pipework?filter[network_id]=${networkId}&filter[street]=${street}&filter[status_id]=`, '_blank');
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user