changes for mark
This commit is contained in:
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user