From 318087c572149cfcd7599c19a6bf6409e0c65b29 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Fri, 16 Feb 2024 15:37:20 +0100 Subject: [PATCH] sends email to the user if a profil update was accepted or rejected --- application/controllers/Cis/ProfilUpdate.php | 22 ++++++++++--------- public/js/components/Cis/Profil/EditProfil.js | 9 +------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/application/controllers/Cis/ProfilUpdate.php b/application/controllers/Cis/ProfilUpdate.php index 7fa00e4ae..550bd3595 100755 --- a/application/controllers/Cis/ProfilUpdate.php +++ b/application/controllers/Cis/ProfilUpdate.php @@ -52,8 +52,13 @@ class ProfilUpdate extends Auth_Controller } - private function sendEmail_onProfilUpdate_acceptionRejection($uid){ - + private function sendEmail_onProfilUpdate_response($uid,$topic,$status){ + $this->load->helper('hlp_sancho_helper'); + $email = $uid . "@" . DOMAIN; + $mail_res = sendSanchoMail("profil_update_response",['topic'=>$topic,'status'=>$status,'href'=>'https://c3p0.ma0594.technikum-wien.at/fh-core/cis.php/Cis/Profil'],$email,("Profil Änderung ".$status)); + if(!$mail_res){ + show_error("failed to send email to " . $email); + } } @@ -208,7 +213,6 @@ class ProfilUpdate extends Auth_Controller ]; $tmp_res=$this->dmslib->upload($dms , 'files', array("jpg", "png", "pdf")); - var_dump($tmp_res); $tmp_res = hasData($tmp_res)? getData($tmp_res) : null; array_push($res,$tmp_res); } @@ -345,7 +349,7 @@ class ProfilUpdate extends Auth_Controller //? sends emails to the correspondents of the $uid $this->sendEmail_onProfilUpdate_insertion($this->uid,$json->topic); - echo json_encode($insertID); + echo json_encode(success($insertID)); } } @@ -364,10 +368,7 @@ class ProfilUpdate extends Auth_Controller //catch error }else{ $updateID = hasData($updateID)? getData($updateID)[0]: null; - $editTimestamp = $this->ProfilUpdateModel->getTimestamp($updateID,true); - - $date = success(date_create($editTimestamp)->format('d.m.Y')); - echo json_encode($date); + echo json_encode(success($updateID)); } } @@ -479,7 +480,7 @@ class ProfilUpdate extends Auth_Controller return; } } - + $this->sendEmail_onProfilUpdate_response($uid,$topic,"accepted"); echo json_encode($this->setStatusOnUpdateRequest($id, "accepted", $status_message, $requested_change)); }else{ show_error("You have not the necessary permissions to accept this profil_update"); @@ -493,6 +494,7 @@ class ProfilUpdate extends Auth_Controller $_POST = json_decode($this->input->raw_input_stream,true); $id = $this->input->post('profil_update_id',true); $uid = $this->input->post('uid',true); + $topic = $this->input->post('topic',true); $status_message = $this->input->post('status_message',true); $is_mitarbeiter_profil_update = getData($this->MitarbeiterModel->isMitarbeiter($uid)); @@ -504,6 +506,7 @@ class ProfilUpdate extends Auth_Controller $this->permissionlib->isBerechtigt('mitarbeiter/stammdaten',"suid") && $is_mitarbeiter_profil_update ) { + $this->sendEmail_onProfilUpdate_response($uid,$topic,"rejected"); echo json_encode($this->setStatusOnUpdateRequest($id, "rejected", $status_message)); }else{ show_error("You have not the necessary permissions to accept this profil_update"); @@ -554,7 +557,6 @@ class ProfilUpdate extends Auth_Controller else{ $requested_change['updateamum']="NOW()"; $requested_change['updatevon']=getAuthUID(); - var_dump($requested_change); $update_kontakt_id = $this->KontaktModel->update($kontakt_id,$requested_change); diff --git a/public/js/components/Cis/Profil/EditProfil.js b/public/js/components/Cis/Profil/EditProfil.js index 51322aa70..d72925639 100755 --- a/public/js/components/Cis/Profil/EditProfil.js +++ b/public/js/components/Cis/Profil/EditProfil.js @@ -103,14 +103,7 @@ export default { } }, - uploadFiles: async function (files) { - let updatedFiles = []; - - if (this.editData.updateID) { - - } - - + uploadFiles: async function (files) { if (files[0].type !== "application/x.fhc-dms+json"){ let formData = new FormData();