raumsuche student config for allowed roomtypes

This commit is contained in:
Johann Hoffmann
2025-03-03 13:51:43 +01:00
parent a408c85fd4
commit 225d6b0a83
3 changed files with 66 additions and 18 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
// liste von raumtyp_kurzbz welche in raumsuche studenten angezeigt werden
$config['roomtypes_student'] = array(
'LAB BM/Chem',
'xEDV 1-36',
'xEDV 37-60',
'EDV 60',
'EDV-HÖPL',
'EDV ES',
'LAB Elek',
'LAB ES/TK',
'Ener-EDV',
'Ener-Lab',
'Ener-SEM',
'Ener-HS',
'HS 59-109',
'HS 25-38',
'HS 39-58',
'LAB Inf',
'LAB Robo',
'LAB SET'
);
+32 -11
View File
@@ -40,7 +40,7 @@ class Ort extends FHCAPI_Controller
]);
$this->load->model('ressource/Ort_model', 'OrtModel');
$this->config->load('raumsuche');
}
//------------------------------------------------------------------------------------------------------------------
@@ -51,13 +51,16 @@ class Ort extends FHCAPI_Controller
*/
public function getRooms()
{
// TODO: form validation
$datum = $this->input->get('datum', TRUE);
$von = $this->input->get('von', TRUE);
$bis = $this->input->get('bis', TRUE);
$typ = $this->input->get('typ', TRUE);
$personenanzahl = $this->input->get('personenanzahl', TRUE);
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$isMitarbeiter = $this->MitarbeiterModel->isMitarbeiter(getAuthUID())->retval;
$this->load->model('ressource/Stunde_model', 'StundeModel');
$vonStunde = getData($this->StundeModel->getStundeForTime($von))[0]->stunde;
$bisStunde = getData($this->StundeModel->getStundeForTime($bis))[0]->stunde;
@@ -68,20 +71,28 @@ class Ort extends FHCAPI_Controller
WHERE aktiv AND lehre AND ort_kurzbz NOT LIKE '\\\\_%'";
if($typ) {
$params[] = $typ;
$qry.= "AND raumtyp_kurzbz= ?";
$qry.= "AND raumtyp_kurzbz = ?";
}
if(!$isMitarbeiter) { // students are only allowed to get a subset defined by config
$qry.= ' AND raumtyp_kurzbz IN ?';
$params[] = $this->config->item('roomtypes_student');
$this->addMeta('config', $this->config->item('roomtypes_student'));
}
$qry.= "AND (max_person>= ? OR max_person is null)";
$params[] = $personenanzahl;
$qry.=" AND ort_kurzbz NOT IN
(
SELECT ort_kurzbz FROM lehre.tbl_stundenplandev WHERE datum=? AND stunde>=? AND stunde<=?
UNION
SELECT ort_kurzbz FROM campus.tbl_reservierung WHERE datum=? AND stunde>=? AND stunde<=?
SELECT ort_kurzbz FROM lehre.tbl_stundenplandev WHERE datum = ? AND stunde >= ? AND stunde <= ?
UNION
SELECT ort_kurzbz FROM campus.tbl_reservierung WHERE datum= ? AND stunde >= ? AND stunde <= ?
)
";
$params = array_merge($params, [$datum, $vonStunde, $bisStunde, $datum, $vonStunde, $bisStunde]);
$this->addMeta('qry', $qry);
$this->addMeta('params', $params);
$result = $this->OrtModel->execReadOnlyQuery($qry, $params);
$this->terminateWithSuccess($result);
@@ -90,9 +101,19 @@ class Ort extends FHCAPI_Controller
public function getTypes()
{
$this->load->model('ressource/Raumtyp_model', 'RaumtypModel');
$result = $this->OrtModel->execReadOnlyQuery("
SELECT * FROM public.tbl_raumtyp WHERE aktiv = true ORDER BY raumtyp_kurzbz;
");
$qry = "SELECT * FROM public.tbl_raumtyp WHERE aktiv = true";
$params = array();
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$isMitarbeiter = $this->MitarbeiterModel->isMitarbeiter(getAuthUID())->retval;
if(!$isMitarbeiter) { // students are only allowed to get a subset defined by config
$qry.= ' AND raumtyp_kurzbz IN ?';
$params[] = $this->config->item('roomtypes_student');
}
$qry .= " ORDER BY raumtyp_kurzbz;";
$result = $this->OrtModel->execReadOnlyQuery($qry, $params);
$this->terminateWithSuccess(getData($result));
}
@@ -97,7 +97,7 @@ export default {
const d = data.map(room => {
return {
ort_kurzbz: room.ort_kurzbz,
bezeichnung: room.bezeichnung,
bezeichnung: room.bezeichnung.replace('&amp;', '&'),
nummer: room.planbezeichnung,
personen: room.max_person,
linkInfo: room.content_id ? this.roomInfoLink(room) : null,
@@ -111,12 +111,15 @@ export default {
},
loadRoomTypes() {
this.$fhcApi.factory.ort.getRoomTypes().then(res => {
res?.data?.forEach(type => {
type.beschreibung = type.beschreibung.replace('&amp;', '&')
})
this.selectedType = this.defaultType
this.roomtypes = res?.data ?? []
})
},
loadRooms() {
this.$fhcApi.factory.ort.getRooms(this.date, this.getTimeString(this.von), this.getTimeString(this.bis), this.selectedType?.raumtyp_kurzbz ?? '', this.anzahl)
this.$fhcApi.factory.ort.getRooms(this.datum, this.getTimeString(this.von), this.getTimeString(this.bis), this.selectedType?.raumtyp_kurzbz ?? '', this.anzahl)
.then(res => {
if(res?.data?.retval) this.setupData(res.data.retval)
})
@@ -181,9 +184,9 @@ export default {
v-model="datum"
:clearable="false"
date-picker
:enable-time="false"
:enable-time-picker="false"
:format="dateFormat"
text-input="true"
:text-input="true"
auto-apply>
</VueDatePicker>
</div>
@@ -193,7 +196,7 @@ export default {
:clearable="false"
time-picker
:format="timeFormat"
text-input="true"
:text-input="true"
auto-apply
>
</VueDatePicker>
@@ -204,7 +207,7 @@ export default {
:clearable="false"
time-picker
:format="timeFormat"
text-input="true"
:text-input="true"
auto-apply>
</VueDatePicker>
</div>
@@ -224,7 +227,6 @@ export default {
</div>
<core-filter-cmpt
@tableBuilt="raumsucheTableBuilt"
@uuidDefined="handleUuidDefined"
:title="''"
ref="raumsucheTable"