add endpoints getRoomsWithEmployeesAssigned and getEmployeesWithRoomAssigned

This commit is contained in:
Harald Bamberger
2026-05-12 11:22:57 +02:00
parent bbb4f8a01c
commit 862bdd94d7
2 changed files with 160 additions and 1 deletions
@@ -36,7 +36,9 @@ class Ort extends FHCAPI_Controller
'ContentID' => self::PERM_LOGGED,
'getOrtKurzbzContent' => self::PERM_LOGGED,
'getRooms' => self::PERM_LOGGED,
'getTypes' => self::PERM_LOGGED
'getTypes' => self::PERM_LOGGED,
'getRoomsWithEmployeesAssigned' => 'basis/ort:r',
'getEmployeesWithRoomAssigned' => 'basis/ort:r'
]);
$this->load->model('ressource/Ort_model', 'OrtModel');
@@ -174,5 +176,42 @@ class Ort extends FHCAPI_Controller
$this->terminateWithSuccess($content);
}
public function getRoomsWithEmployeesAssigned($ort_kurzbz=null)
{
$res = $this->OrtModel->getRoomsWithEmployeesAssigned($ort_kurzbz);
if (isError($res))
{
$this->terminateWithError(getError($res));
}
$data = hasData($res) ? getData($res) : [];
$this->json_decode_db_res($data);
$this->terminateWithSuccess($data);
}
public function getEmployeesWithRoomAssigned($mitarbeiter_uid=null)
{
$res = $this->OrtModel->getEmployeesWithRoomAssigned($mitarbeiter_uid);
if (isError($res))
{
$this->terminateWithError(getError($res));
}
$data = hasData($res) ? getData($res) : [];
$this->json_decode_db_res($data);
$this->terminateWithSuccess($data);
}
protected function json_decode_db_res(&$data)
{
array_walk($data, function($item, $key) {
isset($item->employees) && $item->employees = json_decode($item->employees);
isset($item->employee) && $item->employee = json_decode($item->employee);
isset($item->room) && $item->room = json_decode($item->room);
});
}
}