legacy raumsuche.php -> cis4 vue component

This commit is contained in:
Johann Hoffmann
2025-02-28 16:41:18 +01:00
parent 4a01198e10
commit bc7dba1c14
10 changed files with 447 additions and 4 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class Raumsuche extends Auth_Controller
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct([
'index' => ['basis/cis:r']
]);
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* @return void
*/
public function index()
{
$viewData = array(
'uid'=>getAuthUID(),
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'Raumsuche']);
}
}
@@ -35,6 +35,8 @@ class Ort extends FHCAPI_Controller
parent::__construct([
'ContentID' => self::PERM_LOGGED,
'getOrtKurzbzContent' => self::PERM_LOGGED,
'getRooms' => self::PERM_LOGGED,
'getTypes' => self::PERM_LOGGED
]);
$this->load->model('ressource/Ort_model', 'OrtModel');
@@ -44,6 +46,57 @@ class Ort extends FHCAPI_Controller
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Retrieves all Ort entries filtered by the provided parameters
*/
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/Stunde_model', 'StundeModel');
$vonStunde = getData($this->StundeModel->getStundeForTime($von))[0]->stunde;
$bisStunde = getData($this->StundeModel->getStundeForTime($bis))[0]->stunde;
$params = array();
$qry = "SELECT DISTINCT tbl_ort.*
FROM public.tbl_ort JOIN public.tbl_ortraumtyp USING(ort_kurzbz)
WHERE aktiv AND lehre AND ort_kurzbz NOT LIKE '\\\\_%'";
if($typ) {
$params[] = $typ;
$qry.= "AND raumtyp_kurzbz= ?";
}
$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<=?
)
";
$params = array_merge($params, [$datum, $vonStunde, $bisStunde, $datum, $vonStunde, $bisStunde]);
$result = $this->OrtModel->execReadOnlyQuery($qry, $params);
$this->terminateWithSuccess($result);
}
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;
");
$this->terminateWithSuccess(getData($result));
}
/**
* Gets a JSON body via HTTP POST and provides the parameters
*/
@@ -11,4 +11,19 @@ class Stunde_model extends DB_Model
$this->dbTable = 'lehre.tbl_stunde';
$this->pk = 'stunde';
}
/**
* $time needs to be of PGSQL TIME format
*/
public function getStundeForTime($time) {
$query = "
SELECT min(stunde) as stunde FROM (
SELECT stunde, extract(epoch from (beginn-?)) AS delta FROM lehre.tbl_stunde
UNION
SELECT stunde, extract(epoch from (ende-?)) AS delta FROM lehre.tbl_stunde
) foo WHERE delta>=0
";
return $this->execReadOnlyQuery($query, [$time, $time]);
}
}
@@ -5,7 +5,7 @@ $includesArray = array(
'axios027' => true,
'bootstrap5' => true,
'fontawesome6' => true,
'tabulator5' => true,
'tabulator5' => true, // TODO: upgrade to 6 when available
'vue3' => true,
'primevue3' => true,
'vuedatepicker11' => true,
@@ -24,7 +24,8 @@ $includesArray = array(
),
'customJSs' => array(
'vendor/npm-asset/primevue/accordion/accordion.js',
'vendor/npm-asset/primevue/accordiontab/accordiontab.js'
'vendor/npm-asset/primevue/accordiontab/accordiontab.js',
'vendor/npm-asset/primevue/inputnumber/inputnumber.js'
),
'customJSModules' => array(
'public/js/apps/Dashboard/Fhc.js'