diff --git a/application/controllers/api/frontend/v1/Stundenplan.php b/application/controllers/api/frontend/v1/Stundenplan.php index 091e6c19d..d360c1b90 100644 --- a/application/controllers/api/frontend/v1/Stundenplan.php +++ b/application/controllers/api/frontend/v1/Stundenplan.php @@ -34,7 +34,8 @@ class Stundenplan extends FHCAPI_Controller parent::__construct([ 'roomInformation' => self::PERM_LOGGED, - 'Stunden' => self::PERM_LOGGED + 'Stunden' => self::PERM_LOGGED, + 'Reservierungen' => self::PERM_LOGGED ]); $this->load->library('LogLib'); @@ -68,12 +69,16 @@ class Stundenplan extends FHCAPI_Controller public function roomInformation() { - + //TODO please split this algorithm into multiple smaller function it is not really mantainable like this // storing the get parameter in local variables $ort_kurzbz = $this->input->get('ort_kurzbz', TRUE); $start_date = $this->input->get('start_date', TRUE); $end_date = $this->input->get('end_date', TRUE); + if(!$ort_kurzbz || !$start_date || !$end_date){ + $this->terminateWithError("Missing parameters", self::ERROR_TYPE_GENERAL); + } + $this->addMeta("test_start_date",$start_date); $this->addMeta("ort",$ort_kurzbz); @@ -295,7 +300,6 @@ class Stundenplan extends FHCAPI_Controller } - $this->groupTheCalendar($result); //php start date $phpStartDate = new DateTime($start_date); @@ -309,9 +313,26 @@ class Stundenplan extends FHCAPI_Controller } - private function groupTheCalendar($data){ + public function Reservierungen() + { - } + $ort_kurzbz = $this->input->get('ort_kurzbz', TRUE); + $start_date = $this->input->get('start_date', TRUE); + $end_date = $this->input->get('end_date', TRUE); + + if(!$ort_kurzbz || !$start_date || !$end_date){ + $this->terminateWithError("Missing parameters", self::ERROR_TYPE_GENERAL); + } + + $this->load->model('ressource/Reservierung_model', 'ReservierungModel'); + + $result = $this->ReservierungModel->getRoomReservierungen($ort_kurzbz, $start_date, $end_date); + + if (isError($result)) + return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess(getData($result)); + } } diff --git a/application/models/ressource/Reservierung_model.php b/application/models/ressource/Reservierung_model.php index 7a3d1a4a4..260104305 100755 --- a/application/models/ressource/Reservierung_model.php +++ b/application/models/ressource/Reservierung_model.php @@ -12,6 +12,23 @@ class Reservierung_model extends DB_Model $this->pk = 'reservierung_id'; } + + /** + * @param $uid + * + * @return stdClass + */ + public function getRoomReservierungen($ort_kurzbz, $start_date, $end_date) + { + + $raum_reservierungen= $this->execReadOnlyQuery(" + SELECT * FROM lehre.vw_reservierung res + WHERE ort_kurzbz = ? AND datum >= ? AND datum <= ? + ", [$ort_kurzbz, $start_date, $end_date]); + + return $raum_reservierungen; + } + /** * @param $uid * diff --git a/application/models/ressource/Stundenplan_model.php b/application/models/ressource/Stundenplan_model.php index 17516afe0..299faa049 100755 --- a/application/models/ressource/Stundenplan_model.php +++ b/application/models/ressource/Stundenplan_model.php @@ -32,7 +32,7 @@ class Stundenplan_model extends DB_Model "*/ $raum_stundenplan= $this->execReadOnlyQuery(" - SELECT 'stundenplan_eintrag' as eintrags_type, ort_kurzbz, studiengang_kz, uid, stunde, datum, titel, semester, verband, gruppe, gruppe_kurzbz, stg_kurzbz, CONCAT(UPPER(sp.stg_typ),UPPER(sp.stg_kurzbz),'-',COALESCE(CAST(sp.semester AS varchar),'/'),COALESCE(CAST(sp.verband AS varchar),'/')) AS stg, CONCAT(lehrfach,'-',lehrform) AS lv_info, * FROM lehre.vw_stundenplan sp + SELECT CONCAT(UPPER(sp.stg_typ),UPPER(sp.stg_kurzbz),'-',COALESCE(CAST(sp.semester AS varchar),'/'),COALESCE(CAST(sp.verband AS varchar),'/')) AS stg, CONCAT(lehrfach,'-',lehrform) AS lv_info, * FROM lehre.vw_stundenplan sp WHERE ort_kurzbz = ? AND datum >= ? AND datum <= ? ", [$ort_kurzbz, $start_date, $end_date]); diff --git a/public/js/api/studenplan.js b/public/js/api/studenplan.js index 2da67a737..d691a72cf 100644 --- a/public/js/api/studenplan.js +++ b/public/js/api/studenplan.js @@ -12,4 +12,10 @@ export default { {} ); }, + getReservierungen(ort_kurzbz, start_date, end_date) { + return this.$fhcApi.get( + '/api/frontend/v1/Stundenplan/Reservierungen', + { ort_kurzbz, start_date, end_date} + ); + }, }; \ No newline at end of file diff --git a/public/js/apps/Cis/RoomInformation.js b/public/js/apps/Cis/RoomInformation.js index f4c9c21b7..a7aced683 100644 --- a/public/js/apps/Cis/RoomInformation.js +++ b/public/js/apps/Cis/RoomInformation.js @@ -10,13 +10,19 @@ const app = Vue.createApp({ return { stunden: [], events: null, - calendarWeek: new CalendarDate(new Date("2024-03-06")), + calendarWeek: new CalendarDate(new Date("2024-06-06")), } }, computed:{ currentDate: function(){ return new Date(this.calendarWeek.y, this.calendarWeek.m, this.calendarWeek.d); }, + weekFirstDay: function(){ + return this.calendarDateToString(this.calendarWeek.cdFirstDayOfWeek); + }, + weekLastDay: function(){ + return this.calendarDateToString(this.calendarWeek.cdLastDayOfWeek); + }, }, methods:{ // returns the string YYYY-MM-DD if param is instance of CalendarDate and null otherwise @@ -26,7 +32,8 @@ const app = Vue.createApp({ [calendarDate.y, calendarDate.m+1, calendarDate.d].join('-'): null; - } + }, + }, created() { @@ -36,10 +43,8 @@ const app = Vue.createApp({ }); - console.log(this.calendarDateToString(this.calendarWeek.cdFirstDayOfWeek),"this is the converted calendar date") - - - this.$fhcApi.factory.stundenplan.getRoomInfo('EDV_A6.09', this.calendarDateToString(this.calendarWeek.cdFirstDayOfWeek), this.calendarDateToString(this.calendarWeek.cdLastDayOfWeek)).then(res =>{ + // old testing room EDV_A6.09 + this.$fhcApi.factory.stundenplan.getRoomInfo('SEM_E0.04', this.weekFirstDay, this.weekLastDay).then(res =>{ let events; if (res.data && res.data.forEach) { res.data.forEach((el, i) => { @@ -55,7 +60,27 @@ const app = Vue.createApp({ this.events = res.data; } - }) + }); + + this.$fhcApi.factory.stundenplan.getReservierungen('SEM_E0.04', this.weekFirstDay, this.weekLastDay).then(res => { + if (res.data && res.data.forEach) { + res.data.forEach((el, i) => { + el.reservierung = true; + el.color = '#CCCCCC'; + el.start = new Date(el.datum + ' ' + this.stunden[el.stunde].beginn); + el.end = new Date(el.datum + ' ' + this.stunden[el.stunde].ende); + el.title = el.titel; + if (el.lehrform) + el.title += '-' + el.lehrform; + }); + + } + + let reservierungs_events = res.data; + console.log(reservierungs_events, " this are the reserverungs event") + this.events = [...this.events,...reservierungs_events]; + + }); }); }, @@ -63,9 +88,13 @@ const app = Vue.createApp({
- {{event.orig.lv_info}} - {{item}} - {{event.orig.lektor}} + + + {{event.orig.reservierung? event.orig.title :event.orig.lv_info}} + {{'this is a reservierung'}} + {{item}} + {{event.orig.reservierung? event.orig.uid : event.orig.lektor}} +