From 8c797fb212eca6e940a5c348cb8b259d71f38f94 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Thu, 7 Aug 2025 15:34:23 +0200 Subject: [PATCH] Personal LVPlan: generate download links also for employees not only for students --- .../controllers/api/frontend/v1/AuthInfo.php | 20 ++++++++++++++++++- public/js/api/authinfo.js | 7 ++++++- public/js/api/factory/authinfo.js | 6 ++++++ public/js/components/Cis/LvPlan/Personal.js | 20 +++++++++++++++---- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/application/controllers/api/frontend/v1/AuthInfo.php b/application/controllers/api/frontend/v1/AuthInfo.php index 1362aee18..72f396b4f 100644 --- a/application/controllers/api/frontend/v1/AuthInfo.php +++ b/application/controllers/api/frontend/v1/AuthInfo.php @@ -20,6 +20,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); class AuthInfo extends FHCAPI_Controller { + protected $uid; + protected $pid; + protected $isMitarbeiter; + protected $isStudent; /** * Object initialization @@ -28,10 +32,16 @@ class AuthInfo extends FHCAPI_Controller { parent::__construct([ 'getAuthUID' => self::PERM_LOGGED, + 'getAuthInfo' => self::PERM_LOGGED, ]); + $this->load->model('crm/Student_model', 'StudentModel'); + $this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel'); + $this->uid = getAuthUID(); $this->pid = getAuthPersonID(); + $this->isMitarbeiter = getData($this->MitarbeiterModel->isMitarbeiter($this->uid)) ?? false; + $this->isStudent = getData($this->StudentModel->isStudent($this->uid)) ?? false; } //------------------------------------------------------------------------------------------------------------------ @@ -47,6 +57,14 @@ class AuthInfo extends FHCAPI_Controller $this->terminateWithSuccess(['uid'=>$this->uid]); } - + public function getAuthInfo() + { + $data = (object) array( + 'uid' => $this->uid, + 'isMitarbeiter' => $this->isMitarbeiter, + 'isStudent' => $this->isStudent + ); + $this->terminateWithSuccess($data); + } } diff --git a/public/js/api/authinfo.js b/public/js/api/authinfo.js index 618cf2e26..cb79ac144 100644 --- a/public/js/api/authinfo.js +++ b/public/js/api/authinfo.js @@ -6,5 +6,10 @@ export default { { } ); }, - + getAuthInfo() { + return this.$fhcApi.get( + '/api/frontend/v1/AuthInfo/getAuthInfo', + {} + ); + }, }; \ No newline at end of file diff --git a/public/js/api/factory/authinfo.js b/public/js/api/factory/authinfo.js index 5cf88604f..80cec2649 100644 --- a/public/js/api/factory/authinfo.js +++ b/public/js/api/factory/authinfo.js @@ -21,5 +21,11 @@ export default { method: 'get', url: '/api/frontend/v1/AuthInfo/getAuthUID' }; + }, + getAuthInfo() { + return { + method: 'get', + url: '/api/frontend/v1/AuthInfo/getAuthInfo' + }; } }; \ No newline at end of file diff --git a/public/js/components/Cis/LvPlan/Personal.js b/public/js/components/Cis/LvPlan/Personal.js index 5c4be5c23..f6fd462da 100644 --- a/public/js/components/Cis/LvPlan/Personal.js +++ b/public/js/components/Cis/LvPlan/Personal.js @@ -19,7 +19,9 @@ export default { studiensemester_kurzbz: null, studiensemester_start: null, studiensemester_ende: null, - uid: null + uid: null, + isMitarbeiter: false, + isStudent: false }; }, computed:{ @@ -36,7 +38,15 @@ export default { downloadLinks() { if (!this.studiensemester_start || !this.studiensemester_ende || !this.uid) return false; - + + let type = false; + type = this.isStudent ? 'student' : type; + type = this.isMitarbeiter ? 'lektor' : type; + if (false === type) + { + return; + } + const opts = { zone: this.viewData.timezone }; const start = luxon.DateTime .fromISO(this.studiensemester_start, opts) @@ -47,7 +57,7 @@ export default { const download_link = FHC_JS_DATA_STORAGE_OBJECT.app_root + 'cis/private/lvplan/stpl_kalender.php' - + '?type=student' + + '?type=' + type + '&pers_uid=' + this.uid + '&begin=' + start + '&ende=' + ende; @@ -96,9 +106,11 @@ export default { }, created() { this.$api - .call(ApiAuthinfo.getAuthUID()) + .call(ApiAuthinfo.getAuthInfo()) .then(res => { this.uid = res.data.uid; + this.isMitarbeiter = res.data.isMitarbeiter; + this.isStudent = res.data.isStudent; }); }, template: /*html*/`