From 729509a45d7ef09ccf71e548a880f0c50e256641 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Thu, 23 May 2024 15:40:23 +0200 Subject: [PATCH] WIP --- .../components/Cis/Stundenplan.php | 3 ++ .../models/ressource/Stundenplan_model.php | 14 +++++++- public/js/apps/Cis/RoomInformation.js | 36 ++++++++++++++----- public/js/components/Calendar/Week/Page.js | 16 +++++++-- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/application/controllers/components/Cis/Stundenplan.php b/application/controllers/components/Cis/Stundenplan.php index 2ec001843..3ca8bbc2e 100755 --- a/application/controllers/components/Cis/Stundenplan.php +++ b/application/controllers/components/Cis/Stundenplan.php @@ -70,6 +70,9 @@ class Stundenplan extends Auth_Controller { $this->load->model('ressource/Stundenplan_model', 'StundenplanModel'); + + + $result = $this->StundenplanModel->getRoomDataOnDay('EDV_A2.06','2024-05-21'); //echo($this->db->last_query()); echo json_encode($result); diff --git a/application/models/ressource/Stundenplan_model.php b/application/models/ressource/Stundenplan_model.php index 4d0a7893b..b566b0325 100755 --- a/application/models/ressource/Stundenplan_model.php +++ b/application/models/ressource/Stundenplan_model.php @@ -19,9 +19,21 @@ class Stundenplan_model extends DB_Model * @return stdClass */ public function getRoomDataOnDay($ort_kurzbz,$date){ + + + $this->addSelect(['*',"CONCAT(UPPER(sp.stg_typ),UPPER(sp.stg_kurzbz),'-',COALESCE(CAST(sp.semester AS varchar),'/'),COALESCE(CAST(sp.verband AS varchar),'/')) as eintrag","lektor","CONCAT(lehrfach,'-',lehrform)"]); + /* $this->addSelect(["lehre.tbl_stundenplan.*","CONCAT(UPPER(sg.typ),UPPER(sg.kurzbz),'-',lehre.tbl_stundenplan.semester,lehre.tbl_stundenplan.verband) as simml"]); + $this->addJoin("public.tbl_lehrverband as lv","lv.studiengang_kz=lehre.tbl_stundenplan.studiengang_kz AND lv.gruppe=lehre.tbl_stundenplan.gruppe AND lv.verband=lehre.tbl_stundenplan.verband AND lv.semester=lehre.tbl_stundenplan.semester","LEFT"); + $this->addJoin("public.tbl_studiengang as sg","sg.studiengang_kz=lehre.tbl_stundenplan.studiengang_kz","LEFT"); $res = $this->loadWhere(['ort_kurzbz'=>$ort_kurzbz,'datum'=>$date]); $res = hasData($res) ? getData($res): null; - return $res; + return $res; */ + $this->db->where('ort_kurzbz','EDV_A2.06',true); + $this->db->where('datum','2024-05-21',true); + + $query = $this->db->get_compiled_select('lehre.vw_stundenplan sp'); + + return $this->execQuery($query, [$ort_kurzbz, $date]); } /** diff --git a/public/js/apps/Cis/RoomInformation.js b/public/js/apps/Cis/RoomInformation.js index 63587d2d1..adb571047 100644 --- a/public/js/apps/Cis/RoomInformation.js +++ b/public/js/apps/Cis/RoomInformation.js @@ -7,7 +7,8 @@ const app = Vue.createApp({ data() { return { stunden: [], - events: null + events: null, + testDate: new Date('2024-05-21'), } }, created() { @@ -18,11 +19,33 @@ const app = Vue.createApp({ this.stunden[std.stunde] = std; // TODO(chris): geht besser }); console.log("this are the loaded stunden", this.stunden) + + axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Stundenplan/RoomInformation').then(res => { + let events; + console.log(" this is the res of the api call room information",res); + if (res.data && res.data.forEach) { + res.data.forEach((el, i) => { + + console.log(el,"this is the element that gets changed") + el.id = i; + el.color = '#' + (el.farbe || '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.lehrfach; + if (el.lehrform) + el.title += '-' + el.lehrform; + }); + events = res.data; + //console.log("this are the room events",events) + //this.events = events; + } + }).catch((e)=>{console.log(e,"this is the exception")}) }); axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Stundenplan').then(res => { let events; + console.log(" this is the res of the api call stundenplan",res); if (res.data.retval && res.data.retval.forEach) { res.data.retval.forEach((el, i) => { el.id = i; @@ -34,18 +57,15 @@ const app = Vue.createApp({ el.title += '-' + el.lehrform; }); events = res.data.retval; + console.log("this are the events of the stundenplan",events) } - console.log("this are the loaded events",events) // TODO(chris): do we need that - }).catch((e)=>{console.log(e,"this is the exception")}) + }).catch((e)=>{console.log(e,"this is the exception")}) - axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Stundenplan/RoomInformation').then(res => { - console.log(res) - console.log("this string got printed after the get was successfully finished") - }).catch((e)=>{console.log(e,"this is the exception")}) + @@ -53,7 +73,7 @@ const app = Vue.createApp({ template: /*html*/`
- +
`, }); diff --git a/public/js/components/Calendar/Week/Page.js b/public/js/components/Calendar/Week/Page.js index 47d48b7f7..ce86f36bd 100755 --- a/public/js/components/Calendar/Week/Page.js +++ b/public/js/components/Calendar/Week/Page.js @@ -28,7 +28,8 @@ export default { }, computed: { days() { - let tmpDate = new CalendarDate(this.year, 1, 1); // NOTE(chris): somewhere in the middle of the year + + let tmpDate = new CalendarDate(this.year,1,1); // NOTE(chris): somewhere in the middle of the year tmpDate.w = this.week; let startDay = tmpDate.firstDayOfWeek; let result = []; @@ -36,9 +37,11 @@ export default { result.push(new Date(startDay.getFullYear(), startDay.getMonth(), startDay.getDate() + i)); } return result; + }, eventsPerDayAndHour() { const res = {}; + console.log("this are the days",this.days) this.days.forEach(day => { let key = day.toDateString(); @@ -46,6 +49,7 @@ export default { nextDay.setDate(nextDay.getDate()+1); nextDay.setMilliseconds(nextDay.getMilliseconds()-1); let d = {events:[],lanes:1}; + console.log("this are the events",this.events, "and this is the key",key) if (this.events[key]) { this.events[key].forEach(evt => { let event = {orig:evt,lane:1,maxLane:1,start: evt.start < day ? day : evt.start, end: evt.end > nextDay ? nextDay : evt.end,shared:[],setSharedMaxRecursive(doneItems) { @@ -75,6 +79,9 @@ export default { } }, methods: { + printTest:function(param){ + console.log("HERE",param) + }, changeToMonth(day) { if (!this.noMonthView) { this.date.set(day); @@ -91,6 +98,7 @@ export default { }, template: `
+
@@ -104,8 +112,10 @@ export default {
{{hour}}:00