diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index 0a3189fdd..d125fcc0e 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -19,6 +19,7 @@ class Profil extends Auth_Controller 'View' => ['student/anrechnung_beantragen:r','user:r'], 'foto_sperre_function' => ['student/anrechnung_beantragen:r','user:r'], 'getView' => ['student/anrechnung_beantragen:r','user:r'], + 'editProfil' => ['student/anrechnung_beantragen:r','user:r'], ]); $this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel'); @@ -30,7 +31,7 @@ class Profil extends Auth_Controller $this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel'); $this->load->model('ressource/Betriebsmittelperson_model', 'BetriebsmittelpersonModel'); $this->load->model('person/Kontakt_model', 'KontaktModel'); - + $this->load->model('crm/Profil_change_model', 'ChangeModel'); //? put the uid and pid inside the controller for further usage in views $this->uid = getAuthUID(); @@ -62,6 +63,23 @@ class Profil extends Auth_Controller + + + public function editProfil(){ + + $json = $this->input->raw_input_stream; + $data = ["uid"=>"karpenko", "profil_changes"=>$json, "change_timestamp"=>"NOW()"]; + //? gets the data inside the public.tbl_cis_profil_update + //$res = json_encode($this->ChangeModel->load([$this->uid])); + + //? inserts new row inside the public.tbl_cis_profil_update table + $insert_res = json_encode($this->ChangeModel->insert($data)); + + echo $insert_res; + + } + + private function viewMitarbeiterProfil($uid){ diff --git a/application/models/crm/Profil_change_model.php b/application/models/crm/Profil_change_model.php new file mode 100644 index 000000000..eea42a5d0 --- /dev/null +++ b/application/models/crm/Profil_change_model.php @@ -0,0 +1,38 @@ +dbTable = 'public.tbl_cis_profil_update'; + $this->pk = ['uid']; + $this->hasSequence = false; + + //? loading other models to query them + $this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel'); + } + + /** + * getLastStatuses + */ + public function getData($uid){ + + $res = $this->load($uid); + $res = hasData($res) ? getData($res)[0] : null; + + return $res; + } + + public function insertData($data){ + + $res = $this->insert($data); + //$res = hasData($res) ? getData($res)[0] : null; + + return $res; + } + +} diff --git a/public/css/components/Profil.css b/public/css/components/Profil.css index 5334dfa48..e6d820ed6 100644 --- a/public/css/components/Profil.css +++ b/public/css/components/Profil.css @@ -14,6 +14,18 @@ } } +.image-lock{ + height:22px; + width:21px; + background-color:white; + position:absolute; + top:0; + right:12px; + display:flex; + align-items:center; + justify-content:center; +} + .tabulator-collapsed-row{ padding:15px; background-color: rgba(0,0,0,0.1); @@ -41,10 +53,10 @@ background-color:white; } -.fhc-form .form-control:focus{ +/* .fhc-form .form-control:focus{ border-color:white; box-shadow:none; -} +} */ .fhc-form .form-floating > .form-control:focus ~ .floating-title, .form-floating > .form-control:not(:placeholder-shown) ~ .floating-title, .form-floating > .form-select ~ .floating-title{ opacity: .65; diff --git a/public/js/apps/api/userdata.js b/public/js/apps/api/userdata.js index 8a13d16ae..d671cbd66 100644 --- a/public/js/apps/api/userdata.js +++ b/public/js/apps/api/userdata.js @@ -1,6 +1,10 @@ export default { - + editProfil: function(payload) { + const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ + `/Cis/Profil/editProfil`; + return axios.post(url,payload); + }, isMitarbeiterOrStudent: function(uid) { const url = FHC_JS_DATA_STORAGE_OBJECT.app_root diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index c466c28f0..c6306b982 100644 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -1,14 +1,18 @@ import fhcapifactory from "../../../apps/api/fhcapifactory.js"; import { CoreFilterCmpt } from "../../../components/filter/Filter.js"; +import BsModal from "../../Bootstrap/Modal.js"; export default { components: { CoreFilterCmpt, + BsModal, }, data() { return { collapseIconFunktionen: true, collapseIconBetriebsmittel: true, + //? this reactive object contains all the field the user is able to edit and keep track of which fields he has edited + editData:null, funktionen_table_options: { height: 300, layout: "fitColumns", @@ -114,8 +118,64 @@ export default { }, //? this is the prop passed to the dynamic component with the custom data of the view - props: ["data"], + + props: { + data: Object, + + /* + * NOTE(chris): + * Hack to expose in "emits" declared events to $props which we use + * in the v-bind directive to forward all events. + * @see: https://github.com/vuejs/core/issues/3432 + + onHideBsModal: Function, + onHiddenBsModal: Function, + onHidePreventedBsModal: Function, + onShowBsModal: Function, + onShownBsModal: Function + */ + }, + /* mixins: [ + BsModal, + + ], */ + popup(options) { + return BsModal.popup.bind(this)(null, options); + }, methods: { + showModal() { + this.$refs.bsmodal.show() + }, + + hideModal() { + // You can call the hide method of the modal component if needed + this.$refs.bsmodal.hide(); + }, + + + insertEditData(){ + + + let editDataKeys = Object.keys(this.editData); + let this_data = Object.entries(this.data).filter(([key,value])=>{ + return editDataKeys.includes(key); + }) + + if(JSON.stringify(this_data) == JSON.stringify(Object.entries(this.editData))){ + + console.log("the editData contains the same information",JSON.stringify(this_data),"editData values:", JSON.stringify(Object.entries(this.editData))); + }else{ + console.log("the editData HAS DIFFERENT INFORMATION"); + } + + /* if(somethingChanged){ + console.log("the editData contains changed information"); + }else{ + console.log("the editData does not contain changed information"); + } */ + //? insert editData into a new row inside the public.tbl_cis_profil_update table + //Vue.$fhcapi.UserData.editProfil(this.editData); + }, sperre_foto_function() { if (!this.data) { return; @@ -191,7 +251,7 @@ export default { return { Username: this.data.username, Anrede: this.data.anrede, - Titel: this.data.titelpre, + Titel: this.data.titel, Postnomen: this.data.postnomen, }; }, @@ -253,8 +313,26 @@ export default { }; }, }, + created() { + + this.editData = JSON.parse( + JSON.stringify( + { + emails:this.data.emails, + kontakte: this.data.kontakte, + + personData : {...this.personData, vorname: this.data.vorname, nachname: this.data.nachname} + })); + + console.log(this.data.titelpre); + + + }, mounted() { + + + this.$refs.betriebsmittelTable.tabulator.on("tableBuilt", () => { this.$refs.betriebsmittelTable.tabulator.setData(this.data.mittel); }); @@ -262,12 +340,18 @@ export default { this.$refs.funktionenTable.tabulator.on("tableBuilt", () => { this.$refs.funktionenTable.tabulator.setData(this.data.funktionen); }); + + + + }, template: ` +
{{JSON.stringify(editData,null,2)}}{{JSON.stringify(data.emails,null,2)}}