From 733275a16270f4b74aaf600b671f90913a6b5e6c Mon Sep 17 00:00:00 2001 From: Simon Gschnell Date: Fri, 22 Dec 2023 14:18:49 +0100 Subject: [PATCH] first profil info edit template --- application/controllers/Cis/Profil.php | 20 +- .../models/crm/Profil_change_model.php | 38 ++++ public/css/components/Profil.css | 16 +- public/js/apps/api/userdata.js | 6 +- .../Cis/Profil/MitarbeiterProfil.js | 176 +++++++++++++++++- .../components/Cis/Profil/ProfilEditModal.js | 61 ++++++ .../js/components/Cis/Profil/StudentProfil.js | 6 +- system/dbupdate_3.4.php | 3 +- system/dbupdate_3.4/25999_C4_ma0594.php | 31 +++ 9 files changed, 343 insertions(+), 14 deletions(-) create mode 100644 application/models/crm/Profil_change_model.php create mode 100644 public/js/components/Cis/Profil/ProfilEditModal.js create mode 100644 system/dbupdate_3.4/25999_C4_ma0594.php 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)}}
+
@@ -362,11 +446,11 @@ export default { -
+
- -
+ +
@@ -461,7 +545,87 @@ export default {
- + + + +
+ + + + + + + + + + + + +
+ diff --git a/public/js/components/Cis/Profil/ProfilEditModal.js b/public/js/components/Cis/Profil/ProfilEditModal.js new file mode 100644 index 000000000..4813e2d3b --- /dev/null +++ b/public/js/components/Cis/Profil/ProfilEditModal.js @@ -0,0 +1,61 @@ + +export default { + + data() { + return { + + + }; + }, + + + props: ["editData"], + methods: { + + }, + + computed: { + + + + + }, + + mounted() { + console.log(this.editData); + + + }, + + template: ` + + + + + + + + `, + }; + + + + + + diff --git a/public/js/components/Cis/Profil/StudentProfil.js b/public/js/components/Cis/Profil/StudentProfil.js index 62a4a0799..84997b0ac 100644 --- a/public/js/components/Cis/Profil/StudentProfil.js +++ b/public/js/components/Cis/Profil/StudentProfil.js @@ -293,11 +293,11 @@ export default { -
+
- -
+ +
diff --git a/system/dbupdate_3.4.php b/system/dbupdate_3.4.php index 0d1e554dc..4a20a6289 100644 --- a/system/dbupdate_3.4.php +++ b/system/dbupdate_3.4.php @@ -47,7 +47,7 @@ require_once('dbupdate_3.4/30181_tabelle_anrechnung_neue_attribute_fuer_begruend require_once('dbupdate_3.4/29529_infocenter_anpassungen.php'); require_once('dbupdate_3.4/29835_uhstat1_erfassung_der_uhstat1_daten_ueber_das_bewerbungstool.php'); require_once('dbupdate_3.4/33714_erhoehter_studienbeitrag_fuer_drittsaatenangehoerig.php'); - +require_once('dbupdate_3.4/25999_C4_ma0594.php'); // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; @@ -221,6 +221,7 @@ $tabellen=array( "public.tbl_benutzerfunktion" => array("benutzerfunktion_id","fachbereich_kurzbz","uid","oe_kurzbz","funktion_kurzbz","semester", "datum_von","datum_bis", "updateamum","updatevon","insertamum","insertvon","ext_id","bezeichnung","wochenstunden"), "public.tbl_benutzergruppe" => array("uid","gruppe_kurzbz","studiensemester_kurzbz","updateamum","updatevon","insertamum","insertvon","ext_id"), "public.tbl_bewerbungstermine" => array("bewerbungstermin_id","studiengang_kz","studiensemester_kurzbz","beginn","ende","nachfrist","nachfrist_ende","anmerkung", "insertamum", "insertvon", "updateamum", "updatevon","studienplan_id","nationengruppe_kurzbz"), + "public.tbl_cis_profil_update" => array("uid","profil_changes","change_timestamp"), "public.tbl_buchungstyp" => array("buchungstyp_kurzbz","beschreibung","standardbetrag","standardtext","aktiv","credit_points"), "public.tbl_dokument" => array("dokument_kurzbz","bezeichnung","ext_id","bezeichnung_mehrsprachig","dokumentbeschreibung_mehrsprachig","ausstellungsdetails"), "public.tbl_dokumentprestudent" => array("dokument_kurzbz","prestudent_id","mitarbeiter_uid","datum","updateamum","updatevon","insertamum","insertvon","ext_id"), diff --git a/system/dbupdate_3.4/25999_C4_ma0594.php b/system/dbupdate_3.4/25999_C4_ma0594.php new file mode 100644 index 000000000..f5bb66213 --- /dev/null +++ b/system/dbupdate_3.4/25999_C4_ma0594.php @@ -0,0 +1,31 @@ +db_query("SELECT 1 FROM public.tbl_cis_profil_update LIMIT 1")) + { + $qry = "CREATE TABLE public.tbl_cis_profil_update ( + uid VARCHAR(32) NOT NULL, + profil_changes jsonb NOT NULL, + change_timestamp TIMESTAMP NOT NULL, + CONSTRAINT tbl_cis_profil_update_pk PRIMARY KEY(uid), + CONSTRAINT tbl_cis_profil_update_fk FOREIGN KEY(uid) REFERENCES public.tbl_benutzer(uid) + ); + + GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_cis_profil_update TO vilesci; + GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_cis_profil_update TO web;"; + + if(!$db->db_query($qry)) + echo 'public.tbl_cis_profil_update: '.$db->db_last_error().'
'; + else + echo '
public.tbl_cis_profil_update: table created'; + } + + + if($db->db_num_rows($result)==0) + { + $qry = "INSERT INTO public.tbl_cis_profil_update(uid, profil_changes, change_timestamp) VALUES('ma0594', '{\"test\":\"data\"}', NOW());"; + + if(!$db->db_query($qry)) + echo 'Prüfungstyp: '.$db->db_last_error().'
'; + else + echo '
test eintrag in public.tbl_cis_profil_update hinzugefügt'; + } \ No newline at end of file