diff --git a/application/controllers/api/frontend/v1/ProfilUpdate.php b/application/controllers/api/frontend/v1/ProfilUpdate.php new file mode 100644 index 000000000..2890b1f59 --- /dev/null +++ b/application/controllers/api/frontend/v1/ProfilUpdate.php @@ -0,0 +1,99 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the SearchBarLib (back-end) + * Provides data to the ajax get calls about the searchbar component + * This controller works with JSON calls on the HTTP GET and the output is always JSON + */ +class ProfilUpdate extends FHCAPI_Controller +{ + + public static $STATUS_PENDING = NULL; + public static $STATUS_ACCEPTED = NULL; + public static $STATUS_REJECTED = NULL; + + public static $TOPICS = []; + + /** + * Object initialization + */ + public function __construct() + { + parent::__construct([ + 'getStatus' => self::PERM_LOGGED, + 'fotoSperre' => self::PERM_LOGGED, + + ]); + + + $this->load->model('person/Profil_update_model', 'ProfilUpdateModel'); + $this->load->model('person/Kontakt_model', 'KontaktModel'); + $this->load->model('person/Adresse_model', 'AdresseModel'); + $this->load->model('person/Adressentyp_model', 'AdressenTypModel'); + $this->load->model('person/Person_model', 'PersonModel'); + $this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel'); + $this->load->model('crm/Student_model', 'StudentModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + $this->load->model('system/Sprache_model', 'SpracheModel'); + $this->load->model('person/Profil_update_status_model', 'ProfilUpdateStatusModel'); + $this->load->model('person/Profil_update_topic_model', 'ProfilUpdateTopicModel'); + + $this->load->library('DmsLib'); + $this->load->library('PermissionLib'); + + //? put the uid and pid inside the controller for reusability + $this->uid = getAuthUID(); + $this->pid = getAuthPersonID(); + + // setup the ProfilUpdate states + $this->ProfilUpdateStatusModel->addSelect(['status_kurzbz']); + $status_kurzbz = $this->ProfilUpdateStatusModel->load(); + if (hasData($status_kurzbz)) { + list($status_pending, $status_accepted, $status_rejected) = getData($status_kurzbz); + + self::$STATUS_PENDING = $status_pending->status_kurzbz; + self::$STATUS_ACCEPTED = $status_accepted->status_kurzbz; + self::$STATUS_REJECTED = $status_rejected->status_kurzbz; + } + // setup the ProfilUpdate topics + $this->ProfilUpdateTopicModel->addSelect(['topic_kurzbz']); + $topic_kurzbz = $this->ProfilUpdateTopicModel->load(); + + if (hasData($topic_kurzbz)) { + foreach (getData($topic_kurzbz) as $topic) { + self::$TOPICS[$topic->topic_kurzbz] = $topic->topic_kurzbz; + } + } + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + public function getStatus() + { + $this->terminateWithSuccess([self::$STATUS_PENDING => self::$STATUS_PENDING, self::$STATUS_ACCEPTED => self::$STATUS_ACCEPTED, self::$STATUS_REJECTED => self::$STATUS_REJECTED]); + } + + +} + + \ No newline at end of file diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index c993a86d6..73ce0dd7f 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -21,6 +21,7 @@ import navigation from "./navigation.js"; import filter from "./filter.js"; import studstatus from "./studstatus.js"; import profil from "./profil.js"; +import profilUpdate from "./profilUpdate.js"; export default { search, @@ -29,4 +30,5 @@ export default { filter, studstatus, profil, + profilUpdate, }; diff --git a/public/js/api/profilUpdate.js b/public/js/api/profilUpdate.js new file mode 100644 index 000000000..08b9ad4b7 --- /dev/null +++ b/public/js/api/profilUpdate.js @@ -0,0 +1,129 @@ +export default { + //! API calls for profil update requests + + getStatus: function () { + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/api/frontend/v1/ProfilUpdate/getStatus`,{}); + }, + + getTopic: function () { + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/getTopic`,{}); + }, + + getProfilUpdateRequest: function () { + + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/getAllRequests`,{}); + + }, + + + //TODO post request + acceptProfilRequest: function (payload) { + + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/Cis/ProfilUpdate/acceptProfilRequest"; + return axios.post(url, payload); + }, + + //TODO post request + denyProfilRequest: function (payload) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/Cis/ProfilUpdate/denyProfilRequest"; + return axios.post(url, payload); + }, + + //TODO post request + replaceProfilUpdateAttachment: function (dms) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/replaceProfilUpdateAttachment`; + + return axios.post(url, dms, { + headers: { "Content-Type": "multipart/form-data" }, + }); + }, + + //TODO post request + //? new reuquests + insertFile: function (dms, replace = null) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/insertFile/${replace}`; + + return axios.post(url, dms, { + headers: { "Content-Type": "multipart/form-data" }, + }); + }, + + //TODO post request + getProfilRequestFiles: function (requestID) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/getProfilRequestFiles`; + + return axios.post(url, requestID); + }, + + selectProfilRequest: function (uid = null, id = null) { + + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/selectProfilRequest`,{ uid: uid, id: id }); + }, + + //TODO post request + insertProfilRequest: function (topic, payload, fileID = null) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/insertProfilRequest`; + + return axios.post(url, { + topic, + payload, + ...(fileID ? { fileID: fileID } : {}), + }); + }, + + //TODO post request + updateProfilRequest: function (topic, payload, ID, fileID = null) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/updateProfilRequest`; + + return axios.post(url, { + topic, + payload, + ID, + ...(fileID ? { fileID: fileID } : {}), + }); + }, + + //TODO post request + deleteProfilRequest: function (requestID) { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + `/Cis/ProfilUpdate/deleteProfilRequest`; + + return axios.post(url, requestID); + }, + }; + \ No newline at end of file diff --git a/public/js/apps/Cis/Profil.js b/public/js/apps/Cis/Profil.js index f2726a3db..728bcd09f 100755 --- a/public/js/apps/Cis/Profil.js +++ b/public/js/apps/Cis/Profil.js @@ -353,10 +353,12 @@ const profilApp = Vue.createApp({ }, }, - created() { + async created() { // fetch profilUpdateStates to provide them to children components - Vue.$fhcapi.ProfilUpdate.getStatus() + + await this.$fhcApi.factory.profilUpdate.getStatus() .then((response) => { + console.log(response.data,"this is the response when we set the status") this.profilUpdateStates = response.data; }) .catch((error) => { diff --git a/public/js/apps/Cis/ProfilUpdateRequests.js b/public/js/apps/Cis/ProfilUpdateRequests.js index f62d096af..c72a7592f 100755 --- a/public/js/apps/Cis/ProfilUpdateRequests.js +++ b/public/js/apps/Cis/ProfilUpdateRequests.js @@ -22,6 +22,7 @@ const app = Vue.createApp({ }, methods: {}, created() { + console.log("this is the place i am searching for") Vue.$fhcapi.ProfilUpdate.getStatus() .then((response) => { this.profilUpdateStates = response.data;