Add new endpoint and vuejs components for room managment

This commit is contained in:
Ivymaster
2026-04-29 13:08:33 +02:00
parent 552faefa51
commit fe507e4185
15 changed files with 1865 additions and 5 deletions
+2
View File
@@ -122,6 +122,8 @@ $route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/person/(:num)'] = 'api/f
// load routes from extensions, also look for environment-specific configs
$subdirs = ['application/config/extensions', 'application/config/' . ENVIRONMENT . '/extensions'];
$route['lehre/RoomManager/.*'] = 'lehre/RoomManager/index';
foreach($subdirs as $subdir)
{
if(is_dir($subdir))
+60
View File
@@ -0,0 +1,60 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*/
class RoomManager extends Auth_Controller
{
private $_uid; // uid of the logged user
/**
* Constructor
*/
public function __construct()
{
parent::__construct(
array(
'index' => array('lehre/unterrichtszeiten_gk:r'),
)
);
$this->load->library('PermissionLib');
$this->load->library('AuthLib');
$this->loadPhrases(
array(
'ui',
'global',
'person',
'abschlusspruefung',
'password',
'lehre'
)
);
$this->_setAuthUID();
$this->setControllerId();
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
public function index()
{
return $this->load->view('room_manager/index');
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
/**
* Retrieve the UID of the logged user and checks if it is valid
*/
private function _setAuthUID()
{
$this->_uid = getAuthUID();
if (!$this->_uid) show_error('User authentification failed');
}
}
+205 -3
View File
@@ -33,19 +33,63 @@ class Ort extends FHCAPI_Controller
{
// NOTE(chris): additional permission checks will be done in SearchBarLib
parent::__construct([
'getAllRooms' => self::PERM_LOGGED,
'getRooms' => self::PERM_LOGGED,
'getTypes' => self::PERM_LOGGED,
'ContentID' => self::PERM_LOGGED,
'getOrtKurzbzContent' => self::PERM_LOGGED,
'getRooms' => self::PERM_LOGGED,
'getTypes' => self::PERM_LOGGED
'getRoom' => self::PERM_LOGGED,
'createRoom' => self::PERM_LOGGED,
'updateRoom' => self::PERM_LOGGED,
'deleteRoom' => self::PERM_LOGGED,
]);
$this->load->library('form_validation');
$this->load->model('ressource/Ort_model', 'OrtModel');
$this->config->load('raumsuche');
$this->loadPhrases([
'global',
'ui',
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
public function getAllRooms()
{
$filter = $this->input->get('filter', TRUE);
$filterData = [];
if (isset($filter['locationId']) && $filter['locationId'] !== '') {
$filterData['standort_id'] = $filter['locationId'];
}
if (isset($filter['organizationalUnitShortCode']) && $filter['organizationalUnitShortCode'] !== '') {
$filterData['oe_kurzbz'] = $filter['organizationalUnitShortCode'];
}
if (isset($filter['buildingComponent']) && $filter['buildingComponent'] !== '') {
$filterData['gebteil'] = $filter['buildingComponent'];
}
if (isset($filter['isForTrainingProgram']) && $filter['isForTrainingProgram'] === 'true') {
$filterData['lehre'] = $filter['isForTrainingProgram'] === 'true' ? true : false;
}
if (isset($filter['isReservationNeeded']) && $filter['isReservationNeeded'] === 'true') {
$filterData['reservieren'] = $filter['isReservationNeeded'] === 'true' ? true : false;
}
if (isset($filter['isActive']) && $filter['isActive'] === 'true') {
$filterData['aktiv'] = $filter['isActive'] === 'true' ? true : false;
}
$this->OrtModel->addOrder("ort_kurzbz", "ASC");
$result = $this->OrtModel->loadWhere($filterData);
$this->terminateWithSuccess($this->getDataOrTerminateWithError($result));
}
/**
* Retrieves all Ort entries filtered by the provided parameters
*/
@@ -54,7 +98,7 @@ class Ort extends FHCAPI_Controller
$this->load->library('form_validation');
$this->form_validation->set_data($_GET);
$this->form_validation->set_rules('datum','Datum','required');
$this->form_validation->set_rules('von','Uhrzeit Von','required|regex_match[/^[0-9]{2}:[0-9]{2}$/]');
$this->form_validation->set_rules('von','Uhrzeit Von','required|regexresponse_match[/^[0-9]{2}:[0-9]{2}$/]');
$this->form_validation->set_rules('bis','Uhrzeit Bis','required|regex_match[/^[0-9]{2}:[0-9]{2}$/]');
if($this->form_validation->run() == FALSE) {
$this->terminateWithValidationErrors($this->form_validation->error_array());
@@ -174,5 +218,163 @@ class Ort extends FHCAPI_Controller
$this->terminateWithSuccess($content);
}
public function getRoom($ort_kurzbz)
{
$result = $this->OrtModel->load($ort_kurzbz);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$result = hasData($result) ? current(getData($result)) : null;
return $this->terminateWithSuccess($result);
}
public function createRoom()
{
$this->form_validation->set_rules('ort_kurzbz', 'ort_kurzbz', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => $this->p->t('ui', 'shortCode')])
]);
if($this->form_validation->run() == FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
$this->db->trans_start();
$result = $this->OrtModel->db->query("INSERT INTO public.tbl_ort
(
oe_kurzbz,
content_id,
standort_id,
ort_kurzbz,
bezeichnung,
planbezeichnung,
aktiv,
lehre,
reservieren,
max_person,
stockwerk,
lageplan,
dislozierung,
kosten,
ausstattung,
telefonklappe,
m2,
gebteil,
arbeitsplaetze,
insertamum,
insertvon,
updateamum,
updatevon
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [
$this->input->post('oe_kurzbz'),
$this->input->post('contentId'),
$this->input->post('standort_id'),
$this->input->post('ort_kurzbz'),
$this->input->post('bezeichnung'),
$this->input->post('planbezeichnung'),
$this->input->post('aktiv') ? true : false,
$this->input->post('lehre') ? true : false,
$this->input->post('reservieren') ? true : false,
$this->input->post('max_person'),
$this->input->post('stockwerk'),
$this->input->post('lageplan'),
$this->input->post('dislozierung'),
$this->input->post('kosten'),
$this->input->post('ausstattung'),
$this->input->post('telefonklappe'),
$this->input->post('m2'),
$this->input->post('gebteil'),
$this->input->post('arbeitsplatze'),
date('c'),
getAuthUid(),
date('c'),
getAuthUid()
]);
$this->db->trans_complete();
return $this->terminateWithSuccess($result);
}
public function updateRoom($ort_kurzbz)
{
if (!$ort_kurzbz) {
$this->terminateWithError("missing ort_kurzbz parameter", self::ERROR_TYPE_GENERAL);
}
$this->db->trans_start();
$result = $this->OrtModel->db->query("UPDATE public.tbl_ort SET
oe_kurzbz = ?,
content_id = ?,
standort_id = ?,
bezeichnung = ?,
planbezeichnung = ?,
aktiv = ?,
lehre = ?,
reservieren = ?,
max_person = ?,
stockwerk = ?,
lageplan = ?,
dislozierung = ?,
kosten = ?,
ausstattung = ?,
telefonklappe = ?,
m2 = ?,
gebteil = ?,
arbeitsplaetze = ?,
updateamum = ?,
updatevon = ?
WHERE ort_kurzbz = ?", [
$this->input->post('oe_kurzbz'),
$this->input->post('contentId'),
$this->input->post('standort_id'),
$this->input->post('bezeichnung'),
$this->input->post('planbezeichnung'),
$this->input->post('aktiv') ? true : false,
$this->input->post('lehre') ? true : false,
$this->input->post('reservieren') ? true : false,
$this->input->post('max_person'),
$this->input->post('stockwerk'),
$this->input->post('lageplan'),
$this->input->post('dislozierung'),
$this->input->post('kosten'),
$this->input->post('ausstattung'),
$this->input->post('telefonklappe'),
$this->input->post('m2'),
$this->input->post('gebteil'),
$this->input->post('arbeitsplatze'),
date('c'),
getAuthUid(),
$ort_kurzbz
]);
$this->db->trans_complete();
return $this->terminateWithSuccess($result);
}
public function deleteRoom($ort_kurzbz)
{
$this->db->trans_start();
$result = $this->OrtModel->delete([
"ort_kurzbz" => $ort_kurzbz
]);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->db->trans_complete();
return $this->terminateWithSuccess(true);
}
}
@@ -0,0 +1,56 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
class LocationApi extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'getLocationsByCompanyType'=> self::PERM_LOGGED,
]);
$this->load->library('form_validation');
$this->load->model('organisation/standort_model', 'StandortModel');
$this->loadPhrases([
'global',
'ui',
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
public function getLocationsByCompanyType() {
$companyType = $this->input->get('companyType');
if (!isset($companyType)) {
$this->terminateWithError('companyType parameter is required', REST_Controller::HTTP_BAD_REQUEST);
return;
}
$result = $this->StandortModel->getByCompanyType($companyType);
return $this->terminateWithSuccess($this->getDataOrTerminateWithError($result));
}
}
@@ -0,0 +1,55 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
class OrganizationalUnitApi extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'getAllOrganizationalUnits'=> array('basis/organisationseinheit:r'),
]);
$this->load->library('form_validation');
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
$this->loadPhrases([
'global'
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
public function getAllOrganizationalUnits()
{
$entitledOrganizationalUnitsShortCodes = $this->permissionlib->getOE_isEntitledFor('basis/organisationseinheit');
$this->OrganisationseinheitModel->db->where_in('oe_kurzbz', $entitledOrganizationalUnitsShortCodes);
$result = $this->OrganisationseinheitModel->load();
$organization_units_result = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($organization_units_result);
}
}
@@ -35,5 +35,15 @@ class Standort_model extends DB_Model
return $this->loadWhere(array("firma_id" => $firma_id));
}
public function getByCompanyType($companyType)
{
$query = "SELECT s.* FROM public.tbl_standort s
JOIN public.tbl_firma f ON s.firma_id = f.firma_id
JOIN public.tbl_adresse a ON s.adresse_id = a.adresse_id
WHERE f.firmentyp_kurzbz = ?;";
return $this->execReadOnlyQuery($query, [$companyType]);
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
$includesArray = array(
'title' => 'Raumverwaltung',
'vue3' => true,
'axios027' => true,
'bootstrap5' => true,
'tabulator5' => true,
'fontawesome6' => true,
'primevue3' => true,
'navigationcomponent' => true,
'filtercomponent' => true,
'vuedatepicker11' => true,
'customJSs' => array(
'vendor/moment/luxonjs/luxon.min.js'
),
'customJSModules' => array(
'public/js/apps/RoomManagerApp.js'
),
'customCSSs' => array(
'public/css/components/primevue.css',
'public/css/components/verticalsplit.css',
'public/extensions/FHC-Core-Developer/css/FhcMain.css',
'public/css/components/calendar.css',
'public/css/components/vue-datepicker.css',
)
);
$this->load->view('templates/FHC-Header', $includesArray);
?>
<div id="main">
<router-view
cis-root="<?= CIS_ROOT; ?>"
>
</router-view>
</div>
<?php $this->load->view('templates/FHC-Footer', $includesArray); ?>