From bef53dadb1c24a1b933a1e15640829236ecd21f7 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Tue, 11 Jun 2024 09:27:40 +0200 Subject: [PATCH] refactor Tab Contact --- .../api/frontend/v1/stv/Kontakt.php | 60 +- .../models/organisation/Standort_model.php | 24 + .../Details/Kontakt/Address.js | 514 ++++++------------ .../Details/Kontakt/Bankaccount.js | 122 ++++- .../Details/Kontakt/Contact.js | 316 +++++------ system/phrasesupdate.php | 20 + 6 files changed, 527 insertions(+), 529 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Kontakt.php b/application/controllers/api/frontend/v1/stv/Kontakt.php index ac66c69c0..154729aa3 100644 --- a/application/controllers/api/frontend/v1/stv/Kontakt.php +++ b/application/controllers/api/frontend/v1/stv/Kontakt.php @@ -26,9 +26,9 @@ class Kontakt extends FHCAPI_Controller 'getKontakttypen' => ['admin:r', 'assistenz:r'], 'getFirmen' => ['admin:r', 'assistenz:r'], 'getStandorte' => ['admin:r', 'assistenz:r'], + 'getStandorteByFirma' => ['admin:r', 'assistenz:r'], 'getKontakte' => ['admin:r', 'assistenz:r'], - 'getBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'], - + 'getBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'] ]); // Load Libraries @@ -40,12 +40,17 @@ class Kontakt extends FHCAPI_Controller 'ui', 'person' ]); + + // Load models + $this->load->model('person/Adresse_model', 'AdresseModel'); + $this->load->model('organisation/standort_model', 'StandortModel'); + $this->load->model('ressource/firma_model', 'FirmaModel'); + $this->load->model('person/Kontakt_model', 'KontaktModel'); + } public function getAdressen($person_id) { - $this->load->model('person/Adresse_model', 'AdresseModel'); - $this->AdresseModel->addSelect('public.tbl_adresse.*'); $this->AdresseModel->addSelect('t.*'); $this->AdresseModel->addSelect('f.firma_id'); @@ -79,8 +84,6 @@ class Kontakt extends FHCAPI_Controller $this->terminateWithValidationErrors($this->form_validation->error_array()); } - $this->load->model('person/Adresse_model', 'AdresseModel'); - $uid = getAuthUID(); $co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null; $strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null; @@ -155,6 +158,10 @@ class Kontakt extends FHCAPI_Controller { $firma_id = $_POST['firma']['firma_id']; } + elseif(isset($_POST['firma_id'])) + { + $firma_id = $_POST['firma_id']; + } else $firma_id = null; @@ -291,18 +298,27 @@ class Kontakt extends FHCAPI_Controller $this->terminateWithSuccess($result ?: []); } + public function getStandorteByFirma($firma_id) + { + $this->load->model('organisation/standort_model', 'StandortModel'); + + $result = $this->StandortModel->getStandorteByFirma($firma_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + public function getKontakte($person_id) { - $this->load->model('person/Kontakt_model', 'KontaktModel'); - $this->load->model('organisation/standort_model', 'StandortModel'); - $this->KontaktModel->addSelect("*, + $this->KontaktModel->addSelect("public.tbl_kontakt.*, TO_CHAR (CASE WHEN public.tbl_kontakt.updateamum >= public.tbl_kontakt.insertamum THEN public.tbl_kontakt.updateamum ELSE public.tbl_kontakt.insertamum - END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate"); + END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate, st.bezeichnung, f.name"); $this->StandortModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT'); - + $this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT'); $result = $this->KontaktModel->loadWhere( array('person_id' => $person_id) ); @@ -321,7 +337,9 @@ class Kontakt extends FHCAPI_Controller $result = $this->KontakttypModel->load(); if (isError($result)) { $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } else { + } + else + { $this->terminateWithSuccess(getData($result) ?: []); } } @@ -330,9 +348,10 @@ class Kontakt extends FHCAPI_Controller { $this->load->model('person/Kontakt_model', 'KontaktModel'); - $this->KontaktModel->addSelect('public.tbl_kontakt.*'); + $this->KontaktModel->addSelect('*, public.tbl_kontakt.*'); $this->KontaktModel->addSelect('st.kurzbz'); $this->KontaktModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT'); + $this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT'); $this->KontaktModel->addLimit(1); @@ -368,19 +387,13 @@ class Kontakt extends FHCAPI_Controller $this->load->model('person/Kontakt_model', 'KontaktModel'); - if(isset($_POST['standort'])) - { - $standort_id = $_POST['standort']['standort_id']; - } - else - $standort_id = null; - $uid = getAuthUID(); $kontakttyp = $this->input->post('kontakttyp'); $anmerkung = $this->input->post('anmerkung'); $kontakt = $this->input->post('kontakt'); $ext_id = $this->input->post('ext_id'); + $standort_id = $this->input->post('standort_id'); $result = $this->KontaktModel->insert( [ @@ -426,12 +439,12 @@ class Kontakt extends FHCAPI_Controller $this->terminateWithValidationErrors($this->form_validation->error_array()); } - if(isset($_POST['standort'])) +/* if(isset($_POST['standort'])) { $standort_id = $_POST['standort']['standort_id']; } else - $standort_id = null; + $standort_id = null;*/ $uid = getAuthUID(); $kontakttyp = $this->input->post('kontakttyp'); @@ -439,6 +452,9 @@ class Kontakt extends FHCAPI_Controller $kontakt = $this->input->post('kontakt'); $ext_id = $this->input->post('ext_id'); $person_id = $this->input->post('person_id'); + $standort_id = $this->input->post('standort_id'); + + //return $this->terminateWithError("in update " . $standort_id, self::ERROR_TYPE_GENERAL); $result = $this->KontaktModel->update( [ diff --git a/application/models/organisation/Standort_model.php b/application/models/organisation/Standort_model.php index 03a06ffae..d46dad1c6 100644 --- a/application/models/organisation/Standort_model.php +++ b/application/models/organisation/Standort_model.php @@ -28,5 +28,29 @@ class Standort_model extends DB_Model return $this->execQuery($qry); } + +/* public function searchStandorteByFirma($filter) + { + $filter = strtoLower($filter); + $qry = " + SELECT + s.kurzbz, s.standort_id + FROM + public.tbl_firma f + LEFT JOIN + public.tbl_standort s ON(f.firma_id = s.firma_id) + WHERE + f.firma_id = '". $this->db->escape_like_str($filter)."'"; + + + return $this->execQuery($qry); + }*/ + + public function getStandorteByFirma($firma_id) + { + $this->addSelect("DISTINCT ON (standort_id) bezeichnung, standort_id"); + + return $this->loadWhere(array("firma_id" => $firma_id)); + } } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js index 10ec77e8c..20513add8 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -154,13 +154,7 @@ export default{ typ: 'h', nation: 'A' }, - initData: { - zustelladresse: true, - heimatadresse: true, - rechnungsadresse: false, - typ: 'h', - nation: 'A' - }, + statusNew: true, places: [], suggestions: {}, nations: [], @@ -192,14 +186,15 @@ export default{ methods:{ actionNewAdress() { this.resetModal(); - this.$refs.newAdressModal.show(); + this.$refs.adressModal.show(); }, actionEditAdress(adress_id) { + this.statusNew = false; this.loadAdress(adress_id).then(() => { if(this.addressData.adresse_id) { this.loadPlaces(this.addressData.plz); - this.$refs.editAdressModal.show(); + this.$refs.adressModal.show(); } }); @@ -218,7 +213,7 @@ export default{ this.addressData ).then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); - this.hideModal('newAdressModal'); + this.hideModal('adressModal'); this.resetModal(); }).catch(this.$fhcAlert.handleSystemError) .finally(() => { @@ -230,6 +225,7 @@ export default{ this.$refs.table.reloadTable(); }, loadAdress(adress_id) { + this.statusNew = false; return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadAddress/' + adress_id) .then(result => { this.addressData = result.data; @@ -242,7 +238,7 @@ export default{ this.addressData ).then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); - this.hideModal('editAdressModal'); + this.hideModal('adressModal'); this.resetModal(); }).catch(this.$fhcAlert.handleSystemError) .finally(() => { @@ -294,7 +290,20 @@ export default{ }, resetModal() { this.addressData = {}; - this.addressData = this.initData; + + this.addressData.strasse = null; + this.addressData.zustelladresse = true; + this.addressData.heimatadresse = true; + this.addressData.rechnungsadresse = false; + this.addressData.co_name = null; + this.addressData.firma_id = null; + this.addressData.name = null; + this.addressData.anmerkung = null; + this.addressData.typ = 'h'; + this.addressData.nation = 'A'; + this.addressData.plz = null; + + this.statusNew = true; }, }, created() { @@ -314,139 +323,130 @@ export default{ template: `
- - - - + + + +
- -
- + - -
+ {{typ.bezeichnung}} + +
- -
-
- -
- + - -
-
+ {{nation.kurztext}} + + +
- -
- - -
+ +
- -
- + + - - - - -
+ {{gemeinde.name}} + + + +
- -
- + + + + - - - - - -
+ > +
-
@@ -454,12 +454,12 @@ export default{
-
@@ -467,239 +467,63 @@ export default{
- -
- - -
+ +
-
- -
- -
- -
-
- -
- -
- - -
-
- -
- -
- - -
-
- - - - - - - - - - -
- -
- - - -
-
-
- -
- - -
-
- -
- -
- - - -
-
- -
- -
- - -
-
- -
- -
- - - - -
-
- -
- -
- - - - -
-
- -
- -
- - -
-
- -
- -
- - -
-
- -
- -
- - -
-
- -
- -
- - -
-
- -
- -
- -
-
- -
+
+ + +
+ +
+ + + +
@@ -707,33 +531,31 @@ export default{
- -
- - -
+ +
- -
- -
+
+ @@ -745,7 +567,7 @@ export default{ diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js index 78dfada64..2a26f9fc1 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js @@ -85,7 +85,7 @@ export default{ layoutColumnsOnNewData: false, height: 'auto', selectable: true, - index: 'bankverbindung_id', + index: 'bankverbindung_id' }, tabulatorEvents: [ { @@ -118,6 +118,7 @@ export default{ verrechnung: true, typ: 'p' }, + statusNew: true } }, watch: { @@ -128,12 +129,13 @@ export default{ methods:{ actionNewBankverbindung(){ this.resetModal(); - this.$refs.newBankverbindungModal.show(); + this.$refs.bankverbindungModal.show(); }, actionEditBankverbindung(bankverbindung_id){ + this.statusNew = false; this.loadBankverbindung(bankverbindung_id).then(() => { if(this.bankverbindungData.bankverbindung_id) - this.$refs.editBankverbindungModal.show(); + this.$refs.bankverbindungModal.show(); }); }, actionDeleteBankverbindung(bankverbindung_id){ @@ -147,7 +149,7 @@ export default{ this.bankverbindungData ).then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); - this.hideModal('newBankverbindungModal'); + this.hideModal('bankverbindungModal'); this.resetModal(); }).catch(this.$fhcAlert.handleSystemError) .finally(() => { @@ -156,6 +158,7 @@ export default{ }); }, loadBankverbindung(bankverbindung_id){ + this.statusNew = false; return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadBankverbindung/' + bankverbindung_id) .then( result => { @@ -169,7 +172,7 @@ export default{ this.bankverbindungData) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); - this.hideModal('editBankverbindungModal'); + this.hideModal('bankverbindungModal'); this.resetModal(); }).catch(this.$fhcAlert.handleSystemError) .finally(() => { @@ -206,13 +209,114 @@ export default{ this.bankverbindungData.bic = ""; this.bankverbindungData.verrechnung = true; this.bankverbindungData.typ = 'p'; + + this.statusNew = true; }, }, template: `
+ + + + + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + + + +
+
+ + +
+
+ + + +
+ - + - + diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js index 17f559a94..3bb8e0a55 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js @@ -35,7 +35,8 @@ export default{ } }, {title:"Anmerkung", field:"anmerkung"}, - {title:"Firma", field:"kurzbz", visible:false}, + {title:"Firma", field:"name", visible:false}, + {title:"Standort", field:"bezeichnung", visible:false}, {title:"Firma_id", field:"firma_id", visible:false}, {title:"Person_id", field:"person_id", visible:false}, {title:"Kontakt_id", field:"kontakt_id", visible:false}, @@ -94,43 +95,53 @@ export default{ cm.getColumnByField('anmerkung').component.updateDefinition({ title: this.$p.t('global', 'anmerkung') }); - cm.getColumnByField('kurzbz').component.updateDefinition({ - title: this.$p.t('person', 'firma') - }); + cm.getColumnByField('lastupdate').component.updateDefinition({ title: this.$p.t('notiz', 'letzte_aenderung') }); - } - } + cm.getColumnByField('name').component.updateDefinition({ + title: this.$p.t('person', 'firma') + }); + cm.getColumnByField('bezeichnung').component.updateDefinition({ + title: this.$p.t('person', 'standort') + }); + }} ], lastSelected: null, contactData: { zustellung: true, - kontakttyp: 'email' - }, - initData: { - zustellung: true, - kontakttyp: 'email' + kontakttyp: 'email', + firma_id: null }, + statusNew: true, kontakttypen: [], - standorte: [], - selectedStandort: null, - filteredStandorte: null + firmen: [], + filteredFirmen: [], + filteredOrte: null, } }, watch: { - uid(){ + uid() { this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getKontakte/' + this.uid); + }, + contactData: { + handler(newVal) { + if (newVal.firma && newVal.firma.firma_id !== null && typeof newVal.firma.firma_id !== 'undefined') { + this.loadStandorte(this.contactData.firma.firma_id); + } + }, + deep: true } }, methods:{ actionNewContact(){ this.resetModal(); - this.$refs.newContactModal.show(); + this.$refs.contactModal.show(); }, actionEditContact(contact_id){ + this.statusNew = false; this.loadContact(contact_id); - this.$refs.editContactModal.show(); + this.$refs.contactModal.show(); }, actionDeleteContact(contact_id){ this.loadContact(contact_id); @@ -141,7 +152,7 @@ export default{ this.contactData) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); - this.hideModal("newContactModal"); + this.hideModal("contactModal"); this.resetModal(); }).catch(this.$fhcAlert.handleSystemError) .finally(() => { @@ -150,6 +161,9 @@ export default{ }); }, loadContact(contact_id){ + this.statusNew = false; + if(this.contactData.firma_id) + this.loadStandorte(this.contactData.firma_id); return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadContact/' + contact_id) .then( result => { @@ -176,7 +190,7 @@ export default{ this.contactData). then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); - this.hideModal('editContactModal'); + this.hideModal('contactModal'); this.resetModal(); this.reload(); }).catch(this.$fhcAlert.handleSystemError) @@ -185,22 +199,39 @@ export default{ this.reload(); }); }, + hideModal(modalRef){ this.$refs[modalRef].hide(); }, reload(){ this.$refs.table.reloadTable(); }, - search(event) { + searchFirma(event) { return this.$fhcApi - .get('api/frontend/v1/stv/kontakt/getStandorte/' + event.query) - .then(result => { - this.filteredStandorte = result.data.retval; + .get('api/frontend/v1/stv/kontakt/getFirmen/' + event.query) + .then(result => { + this.filteredFirmen = result.data.retval; + }); + }, + loadStandorte(firmen_id) { + return this.$fhcApi + .get('api/frontend/v1/stv/kontakt/getStandorteByFirma/' + firmen_id) + .then(result => { + this.filteredOrte = result.data; }); }, resetModal(){ this.contactData = {}; - this.contactData = this.initData; + this.contactData.zustellung = true; + this.contactData.kontakttyp = 'email'; + this.contactData.kontakt = ''; + this.contactData.anmerkung = null; + this.contactData.firma_id = null; + this.contactData.name = null; + this.contactData.standort_id = null; + this.contactData.bezeichnung = null; + + this.statusNew = true; }, }, created(){ @@ -213,159 +244,140 @@ export default{ }, template: `
- - - - + + + + - - -
- -
- - > - - - -
-
- -
- -
- - required - > - -
-
- -
- -
- - > - -
-
- -
- -
- - -
-
- -
- -
- -
-
-
- - -
- - - - - - -
- -
- -
+ +
+ + + > + + + +
+ +
+ + required + > +
- -
- - required - > - -
-
- -
- -
- - > - -
+ + > +
-
-
- +
+ + +
+ +
+ + + +
-
- -
- - -
-
- -
-
- + + + +
+ + + + + + +
+ + + - + diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 715daa1f9..07a7ee5a2 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -28162,6 +28162,26 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'bitteStandortWaehlen', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Bitte Standort wählen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Please select location', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), );