changes for mark

This commit is contained in:
Luca Haid
2025-04-10 12:45:12 +02:00
parent 9df3e9f926
commit 4d8806c64a
6 changed files with 254 additions and 5 deletions

View File

@@ -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');
}
}
}