diff --git a/application/controllers/api/frontend/v1/Studgang.php b/application/controllers/api/frontend/v1/Studgang.php new file mode 100644 index 000000000..0e4eb3205 --- /dev/null +++ b/application/controllers/api/frontend/v1/Studgang.php @@ -0,0 +1,58 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); +class Studgang extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + parent::__construct([ + 'getStudiengangInfo'=> self::PERM_LOGGED, + + ]); + + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + + // Loads phrases system + $this->loadPhrases([ + 'global' + ]); + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + public function getStudiengangInfo(){ + // fetches the Studiengang Information which is used next the the news + $studiengangInfo = $this->StudiengangModel->getStudiengangInfoForNews(); + $studiengangInfo= $this->getDataOrTerminateWithError($studiengangInfo); + $this->terminateWithSuccess($studiengangInfo); + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + + +} + diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index e306ce950..a69175cd8 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -647,4 +647,121 @@ class Studiengang_model extends DB_Model return $this->load(); } + + /** + * @return stdClass + */ + public function getStudiengangInfoForNews() + { + + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $this->load->model('person/Person_model', 'PersonModel'); + + $addEmailProperty= function(&$benutzerfunktionen){ + if(count($benutzerfunktionen) && defined('DOMAIN')) + { + $benutzerfunktionen = array_map(function($benutzer) + { + $benutzer->email = $benutzer->alias."@".DOMAIN; + return $benutzer; + },$benutzerfunktionen) ; + } + + }; + $addFotoProperty= function(&$collection){ + $collection = array_map(function($item){ + $person_id = $this->PersonModel->getByUid($item->uid); + if(isError($person_id)) + return error($person_id); + $person_id = current(getData($person_id))->person_id; + $this->PersonModel->addSelect('foto'); + $foto = $this->PersonModel->loadWhere(array('person_id'=>$person_id)); + if(isError($foto)) + return error($foto); + $foto = current(getData($foto))->foto; + $item->foto = $foto; + return $item; + },$collection); + }; + + + $this->load->model('crm/Student_model', 'StudentModel'); + + //TODO: this does not work for Mitarbeiter + $student = $this->StudentModel->loadWhere(['student_uid' => getAuthUID()]); + if (isError($student)) + return error($student); + if (getData($student)) { + $student = current(getData($student)); + $studiengang_kz = $student->studiengang_kz; + $semester = $student->semester; + } + + $stg_obj = $this->load($studiengang_kz); + if(isError($stg_obj)) + return error($stg_obj); + if(getData($stg_obj)) + { + $stg_obj = current(getData($stg_obj)); + } + + $stg_ltg = $this->getLeitungDetailed($stg_obj->studiengang_kz); + if (isError($stg_ltg)) + return $stg_ltg; + $stg_ltg = getData($stg_ltg) ?: []; + $addFotoProperty($stg_ltg); + + $gf_ltg = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('gLtg', $stg_obj->oe_kurzbz); + if (isError($gf_ltg)) + return $gf_ltg; + $gf_ltg = getData($gf_ltg) ?: []; + $addEmailProperty($gf_ltg); + + $stv_ltg = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('stvLtg', $stg_obj->oe_kurzbz); + if (isError($stv_ltg)) + return $stv_ltg; + $stv_ltg = getData($stv_ltg) ?: []; + $addEmailProperty($stv_ltg); + + $ass = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('ass', $stg_obj->oe_kurzbz); + if (isError($ass)) + return $ass; + $ass = getData($ass) ?: []; + $addEmailProperty($ass); + $addFotoProperty($ass); + + $hochschulvertr = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('hsv'); + if (isError($hochschulvertr)) + return $hochschulvertr; + $hochschulvertr = getData($hochschulvertr) ?: []; + $addEmailProperty($hochschulvertr); + + + $stdv = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('stdv', $stg_obj->oe_kurzbz); + if (isError($stdv)) + return $stdv; + $stdv = getData($stdv) ?: []; + $addEmailProperty($stdv); + + + $jahrgangsvertr = $this->BenutzerfunktionModel->getBenutzerFunktionenDetailed('jgv', $stg_obj->oe_kurzbz, $semester); + if (isError($jahrgangsvertr)) + return $jahrgangsvertr; + $jahrgangsvertr = getData($jahrgangsvertr) ?: []; + $addEmailProperty($jahrgangsvertr); + + + $result_object = new stdClass(); + $result_object->studiengang = $stg_obj; + $result_object->semester = $semester; + $result_object->stg_ltg = $stg_ltg; + $result_object->gf_ltg = $gf_ltg; + $result_object->stv_ltg = $stv_ltg; + $result_object->ass = $ass; + $result_object->hochschulvertr = $hochschulvertr; + $result_object->stdv = $stdv; + $result_object->jahrgangsvertr = $jahrgangsvertr; + + return success($result_object); + } } diff --git a/public/js/api/cms.js b/public/js/api/cms.js index 28cb56961..b80bb5cde 100644 --- a/public/js/api/cms.js +++ b/public/js/api/cms.js @@ -11,15 +11,6 @@ export default { ); }, - news(limit) { - return this.$fhcApi.get( - "/api/frontend/v1/Cms/news", - { - limit: limit - } - ); - }, - getNews(page = 1, page_size = 10) { return this.$fhcApi.get( "/api/frontend/v1/Cms/getNews", @@ -36,5 +27,12 @@ export default { {} ); }, + + getNewsExtra: function(){ + return this.$fhcApi.get( + "/api/frontend/v1/Cms/getStudiengangInfoForNews", + {} + ); + } } \ No newline at end of file diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index c4106c3f6..affbac0cc 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -33,6 +33,7 @@ import ort from "./ort.js"; import cms from "./cms.js"; import lehre from "./lehre.js"; import addons from "./addons.js"; +import studiengang from "./studiengang.js"; export default { search, @@ -52,5 +53,6 @@ export default { ort, cms, lehre, - addons + addons, + studiengang, }; diff --git a/public/js/api/studiengang.js b/public/js/api/studiengang.js new file mode 100644 index 000000000..103725479 --- /dev/null +++ b/public/js/api/studiengang.js @@ -0,0 +1,9 @@ +export default { + studiengangInformation: function () { + return this.$fhcApi.get( + "/api/frontend/v1/Studgang/getStudiengangInfo", + {} + ); + } + +} \ No newline at end of file diff --git a/public/js/components/Cis/Cms/StudiengangInformation/StudiengangInformation.js b/public/js/components/Cis/Cms/StudiengangInformation/StudiengangInformation.js new file mode 100644 index 000000000..6fae52f1d --- /dev/null +++ b/public/js/components/Cis/Cms/StudiengangInformation/StudiengangInformation.js @@ -0,0 +1,117 @@ +import StudiengangPerson from "./StudiengangPerson"; + +export default { +data(){ + return{ + studiengang:null, + semester: null, + stg_ltg: null, + gf_ltg: null, + stv_ltg: null, + ass: null, + hochschulvertr: null, + stdv: null, + jahrgangsvertr: null, + } +}, +components:{ + StudiengangPerson +}, +template:/*html*/` + +`, +computed:{ + collection_array: function(){ + return [{ title: "Studiengangsleitung", collection: this.stg_ltg }, { title: "geschäftsführende Leitung", collection: this.gf_ltg },{ title: "stellvertretende Leitung", collection: this.stv_ltg },{ title: "Sekretariat", collection: this.ass} ]; + }, + + studiengangs_assistenz_array: function () { + // early return if the reactive data is not yet loaded or not present + if (!this.ass) + return null; + + return this.ass.map((assistenz) => { + return { + fullname: this.studiengangs_person_fullname(assistenz.titelpre, assistenz.vorname, assistenz.nachname), + telefone: this.studiengangs_person_phone(assistenz.kontakt, assistenz.telefonklappe), + ort: assistenz.planbezeichnung ?? null, + email: this.studiengangs_person_email(assistenz.email), + } + }) + }, +}, +methods:{ + studiengangs_person_data: function (collection) { + // early return if the reactive data is not yet loaded or not present + if (!collection || !Array.isArray(collection) || collection.length === 0) + return null; + + return collection.map((item) => { + return { + fullname: this.studiengangs_person_fullname(item.titelpre, item.vorname, item.nachname), + telefone: this.studiengangs_person_phone(item.kontakt, item.telefonklappe), + ort: item.planbezeichnung ?? null, + email: this.studiengangs_person_email(item.email), + foto: item.foto ? 'data:image/png;base64,'.concat(item.foto) : null, + } + }) + }, + studiengangs_person_fullname: function(titelpre, vorname, nachname){ + if (titelpre && vorname && nachname) + { + return `${titelpre} ${vorname} ${nachname}`; + } + else if (vorname && nachname) + { + return `${vorname} ${nachname}`; + } + else if (nachname) + { + return vorname; + } + else + { + return null; + } + }, + studiengangs_person_phone: function (telefone,telefoneklappe) { + if(telefone && telefoneklappe) + { + return "tel:".concat(telefone).concat(" "+telefoneklappe); + } + else if(telefone) + { + return "tel:".concat(telefone); + } + else + { + return null; + } + }, + studiengangs_person_email: function (email) { + if (email) + { + return "mailto:".concat(email); + } + else { + return null; + } + }, +}, +mounted(){ + this.$fhcApi.factory.studiengang.studiengangInformation() + .then(res => res.data) + .then(studiengangInformationen => { + Object.assign(this, studiengangInformationen); + }); + +}, + +}; \ No newline at end of file diff --git a/public/js/components/Cis/Cms/StudiengangInformation/StudiengangPerson.js b/public/js/components/Cis/Cms/StudiengangInformation/StudiengangPerson.js new file mode 100644 index 000000000..848b31256 --- /dev/null +++ b/public/js/components/Cis/Cms/StudiengangInformation/StudiengangPerson.js @@ -0,0 +1,85 @@ +export default { + data(){ + + }, + props:{ + person_data: + { + type: Object, + required: true + } + }, + computed:{ + formattedEmail: function(){ + if(!this.person_data ) return null; + let emailString= this.person_data.email.replace("mailto:", ""); + // when splitting a string, the letter that is used to split the string will be removed from the result + let emailArray = emailString.split('@'); + // returns both parts of the splitted string in combination with the removed letter and a word break + return emailArray[0] + '@' + emailArray[1]; + }, + }, + template:/*html*/` +
+
+ person_dataFoto +
+
+
{{person_data.fullname}}
+
+
+
+ +
+ +
+ + + {{person_data.ort}} + +
+
+ + + + +
+ +
+
+
+ `, +} \ No newline at end of file