diff --git a/application/controllers/components/stv/Student.php b/application/controllers/components/stv/Student.php index 823b22b50..63663b230 100644 --- a/application/controllers/components/stv/Student.php +++ b/application/controllers/components/stv/Student.php @@ -305,5 +305,236 @@ class Student extends FHC_Controller return false; } return true; + + public function getAdressen($person_id) + { + $this->load->model('person/Adresse_model', 'AdresseModel'); + $this->load->model('person/Adressentyp_model', 'AdressentypModel'); + $this->load->model('ressource/firma_model', 'FirmaModel'); + + $this->AdresseModel->addSelect('*'); + $this->AdressentypModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)'); + $this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT'); + + $result = $this->AdresseModel->loadWhere( + array('person_id' => $person_id) + ); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } } + + public function addNewAddress($person_id) + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + //var_dump($_POST); + //echo ($_POST['ort']); + $this->load->model('person/Adresse_model', 'AdresseModel'); + // Load Libraries + $this->load->library('AuthLib'); + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + $result = $this->AdresseModel->insert( + [ + 'person_id' => $person_id, + 'strasse' => $_POST['strasse'], + 'insertvon' => 'FHC4', + 'insertamum' => date('c'), + 'plz' => $_POST['plz'], + 'ort' => $_POST['ort'], + 'gemeinde' => $_POST['gemeinde'], + 'nation' => $_POST['nation'], + 'heimatadresse' => $_POST['heimatadresse'], + 'zustelladresse' => $_POST['zustelladresse'], + 'co_name' => $_POST['co_name'], + 'typ' => $_POST['typ'] + ] + ); + + if (isError($result)) + { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return $this->outputJson($result); + } + return $this->outputJsonSuccess(true); + } + + public function getAdressentypen() + { + $this->load->model('person/Adressentyp_model', 'AdressentypModel'); + + $result = $this->AdressentypModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + + public function getGmeinden($plz) + { + //TODO(manu) finish + $result = ""; + return $result; + } + + public function getKontakte($person_id) + { + $this->load->model('person/Kontakt_model', 'KontaktModel'); + $this->load->model('organisation/standort_model', 'StandortModel'); + $this->load->model('ressource/firma_model', 'FirmaModel'); + + $this->KontaktModel->addSelect('*'); + $this->StandortModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT'); + $this->StandortModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT'); + + $result = $this->KontaktModel->loadWhere( + array('person_id' => $person_id) + ); + + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + + public function getBankverbindung($person_id) + { + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); + + $this->BankverbindungModel->addSelect('*'); + + $result = $this->BankverbindungModel->loadWhere( + array('person_id' => $person_id) + ); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + public function getAdressen($person_id) + { + $this->load->model('person/Adresse_model', 'AdresseModel'); + $this->load->model('person/Adressentyp_model', 'AdressentypModel'); + $this->load->model('ressource/firma_model', 'FirmaModel'); + + $this->AdresseModel->addSelect('*'); + $this->AdressentypModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)'); + $this->FirmaModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT'); + + $result = $this->AdresseModel->loadWhere( + array('person_id' => $person_id) + ); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + + public function addNewAddress($person_id) + { + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + //var_dump($_POST); + //echo ($_POST['ort']); + $this->load->model('person/Adresse_model', 'AdresseModel'); + // Load Libraries + $this->load->library('AuthLib'); + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + $result = $this->AdresseModel->insert( + [ + 'person_id' => $person_id, + 'strasse' => $_POST['strasse'], + 'insertvon' => 'FHC4', + 'insertamum' => date('c'), + 'plz' => $_POST['plz'], + 'ort' => $_POST['ort'], + 'gemeinde' => $_POST['gemeinde'], + 'nation' => $_POST['nation'], + 'heimatadresse' => $_POST['heimatadresse'], + 'zustelladresse' => $_POST['zustelladresse'], + 'co_name' => $_POST['co_name'], + 'typ' => $_POST['typ'] + ] + ); + + if (isError($result)) + { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return $this->outputJson($result); + } + return $this->outputJsonSuccess(true); + } + + public function getAdressentypen() + { + $this->load->model('person/Adressentyp_model', 'AdressentypModel'); + + $result = $this->AdressentypModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + + public function getGmeinden($plz) + { + //TODO(manu) finish + $result = ""; + return $result; + } + + public function getKontakte($person_id) + { + $this->load->model('person/Kontakt_model', 'KontaktModel'); + $this->load->model('organisation/standort_model', 'StandortModel'); + $this->load->model('ressource/firma_model', 'FirmaModel'); + + $this->KontaktModel->addSelect('*'); + $this->StandortModel->addJoin('public.tbl_standort st', 'ON (public.tbl_kontakt.standort_id = st.standort_id)', 'LEFT'); + $this->StandortModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = st.firma_id)', 'LEFT'); + + $result = $this->KontaktModel->loadWhere( + array('person_id' => $person_id) + ); + + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + + public function getBankverbindung($person_id) + { + $this->load->model('person/Bankverbindung_model', 'BankverbindungModel'); + + $this->BankverbindungModel->addSelect('*'); + + $result = $this->BankverbindungModel->loadWhere( + array('person_id' => $person_id) + ); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + } diff --git a/public/js/components/Stv/Studentenverwaltung/Details.js b/public/js/components/Stv/Studentenverwaltung/Details.js index 910a65866..2c4c4c837 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details.js +++ b/public/js/components/Stv/Studentenverwaltung/Details.js @@ -7,7 +7,8 @@ export default { current: this.$route.params.tab || 'details', tabTemplates: { details: 'Details', - notizen: 'Notizen' + notizen: 'Notizen', + kontakt: 'Kontakt' }, tabs: {} } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt.js new file mode 100644 index 000000000..6212f8e32 --- /dev/null +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt.js @@ -0,0 +1,67 @@ +import {CoreRESTClient} from '../../../../RESTClient.js'; +import AddressList from "./Kontakt/Address.js"; +import ContactList from "./Kontakt/Contact.js"; +import BankaccountList from "./Kontakt/Bankaccount.js"; +import PvToast from "../../../../../../index.ci.php/public/js/components/primevue/toast/toast.esm.min.js"; +export default { + components: { + AddressList, + ContactList, + BankaccountList, + PvToast + }, + props: { + student: Object + }, + data() { + return { + adressen: [], + kontakte: [], + bankverbindungen: [] + } + }, + created(){ + CoreRESTClient + .get('components/stv/Student/getAdressen/' + this.student.person_id) + .then(result => { + this.adressen = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + /* CoreRESTClient + .get('components/stv/Student/getKontakte/' + this.student.person_id) + .then(result => { + this.kontakte = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + CoreRESTClient + .get('components/stv/Student/getBankverbindung/' + this.student.person_id) + .then(result => { + this.bankverbindungen = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + });*/ + }, + template: ` +
+
+ Adressen + + +
+
+ Kontakt + + +
+
+ Bankverbindungen + + +
+
` +}; diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js new file mode 100644 index 000000000..3222326af --- /dev/null +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -0,0 +1,255 @@ +import {CoreFilterCmpt} from "../../../../filter/Filter.js"; +import {CoreRESTClient} from "../../../../../RESTClient"; + + +var editIcon = function(cell, formatterParams){ //plain text value + return ""; +}; +var deleteIcon = function(cell, formatterParams){ //plain text value + return ""; +}; + + +export default{ + components: { + CoreFilterCmpt + }, + props: { + uid: String + }, + emits: [ + 'update:selected' + ], + data() { + return{ + tabulatorOptions: { + ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Student/getAdressen/' + this.uid), + //autoColumns: true, + columns:[ + {title:"Typ", field:"bezeichnung"}, //TODO(manu) mix ok? + {title:"Strasse", field:"strasse"}, + {title:"Plz", field:"plz"}, + {title:"Ort", field:"ort"}, + {title:"Gemeinde", field:"gemeinde"}, + {title:"Nation", field:"nation"}, + {title:"Heimatadresse", field:"heimatadresse", + formatter: (cell, formatterParams, onRendered) => { + let output = cell.getValue() ? "ja" : "nein"; + return output;} + }, + {title:"Abweich.Empf", field:"co_name"}, + {title:"Firma", field:"name"}, //TODO(manu) check in DB + {title:"Firma_id", field:"firma_id", visible:false}, + {title:"Adresse_id", field:"adresse_id", visible:false}, + {title:"Person_id", field:"person_id", visible:false}, + {title:"Name", field:"name", visible:false}, + {title:"letzte Änderung", field:"updateamum", visible:false}, + {title:"Rechnungsadresse", field:"rechnungsadresse", visible:false, + formatter: (cell, formatterParams, onRendered) => { + let output = cell.getValue() ? "ja" : "nein"; + return output;} + }, + {title:"Anmerkung", field:"anmerkung", visible:false}, + {formatter:editIcon, width:40, align:"center", cellClick:function(e, cell){alert("Edit data for adresse_id: " + cell.getRow().getIndex())}}, + {formatter:deleteIcon, width:40, align:"center", cellClick:function(e, cell){alert("Delete data for adresse_id " + cell.getRow().getIndex())}}, + ], + layout: 'fitDataFill', + layoutColumnsOnNewData: false, + height: 'auto', + selectable: true, + index: 'adresse_id', + }, + tabulatorEvents: [ + + ], + lastSelected: null, + modalRefVis: false, + addressData: [], + formData: { + zustelladresse: false, + heimatadresse: false + }, + nations: [], + adressentypen: [] + } + }, + methods:{ + actionNewAdress(){ + + console.log("Neue Adresse anlegen"); + bootstrap.Modal.getOrCreateInstance(this.$refs.newAdressModal).show(); + }, + deleteAdressData(){ + return this.formData = null; + }, + hideModal(){ + bootstrap.Modal.getOrCreateInstance(this.$refs.newAdressModal).hide(); + }, + addNewAddress(formData) { + CoreRESTClient.post('components/stv/Student/addNewAddress/' + this.uid, + this.formData + ).then(response => { + console.log(response); + if (!response.data.error) { + this.statusCode = 0; + this.statusMsg = 'success'; + console.log('Speichern erfolgreich: ' + this.statusMsg); + this.$fhcAlert.alertSuccess('Speichern erfolgreich'); + } else { + this.statusCode = 0; + this.statusMsg = 'Error'; + console.log('Speichern nicht erfolgreich: ' + this.statusMsg); + this.$fhcAlert.alertError('Speichern nicht erfolgreich'); + } + }).catch(error => { + console.log(error); + this.statusCode = 0; + this.statusMsg = 'Error in Catch'; + console.log('Speichern nicht erfolgreich ' + this.statusMsg); + this.$fhcAlert.alertError('Fehler bei Speicherroutine aufgetreten'); + }).finally(() => { + window.scrollTo(0, 0); + hideModal(); + }); + }, + + + /* showModalRef(){ + + modalRef = true; + }*/ + /* updateUrl(url, first) { + this.lastSelected = first ? undefined : this.selected; + if (url) + url = CoreRESTClient._generateRouterURI(url); + if (!this.$refs.table.tableBuilt) + this.$refs.table.tabulator.on("tableBuilt", () => { + this.$refs.table.tabulator.setData(url); + }); + else + this.$refs.table.tabulator.setData(url); + }*/ + }, + created(){ + CoreRESTClient + .get('components/stv/Student/getNations') + .then(result => { + this.nations = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + CoreRESTClient + .get('components/stv/Student/getAdressentypen') + .then(result => { + this.adressentypen = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + }, + template: ` + +
+ + + + + + + + +
` +}; + diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js new file mode 100644 index 000000000..6a9ca06c6 --- /dev/null +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Bankaccount.js @@ -0,0 +1,99 @@ +import {CoreFilterCmpt} from "../../../../filter/Filter.js"; +import {CoreRESTClient} from "../../../../../RESTClient"; + +export default{ + components: { + CoreFilterCmpt + }, + props: { + uid: String + }, + emits: [ + 'update:selected' + ], + data() { + return{ + tabulatorOptions: { + ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Student/getBankverbindung/' + this.uid), + columns:[ + {title:"Name", field:"name"}, + {title:"Anschrift", field:"anschrift", visible:false}, + {title:"BIC", field:"bic"}, + {title:"BLZ", field:"blz", visible:false}, + {title:"IBAN", field:"iban"}, + {title:"Kontonummer", field:"kontonr", visible:false}, + {title:"Typ", field:"typ", visible:false, + formatter: (cell, formatterParams, onRendered) => { + let output; + switch(cell.getValue()){ + case "p": + output = "Privatkonto"; + break; + case "f": + output = "Firmenkonto"; + break; + default: + output = cell.getValue(); + } + return output;} + }, + {title:"Verrechnung", field:"verrechnung", visible:false, + formatter: (cell, formatterParams, onRendered) => { + let output = cell.getValue() ? "ja" : "nein"; + return output;} + }, + {title:"Person_id", field:"person_id", visible:false}, + {title:"Bankverbindung_id", field:"bankverbindung_id", visible:false}, + ], + layout: 'fitDataFill', + layoutColumnsOnNewData: false, + height: 'auto', + selectable: true, + index: 'bankverbindung_id', + }, + tabulatorEvents: [ + /* { + event: 'rowSelectionChanged', + handler: this.rowSelectionChanged + }, + { + event: 'dataProcessed', + handler: this.autoSelectRows + }*/ + ], + lastSelected: null + } + }, + methods:{ + actionNewAdress(){ + console.log("Neuen Kontakt anlegen"); + }, + updateUrl(url, first) { + this.lastSelected = first ? undefined : this.selected; + if (url) + url = CoreRESTClient._generateRouterURI(url); + if (!this.$refs.table.tableBuilt) + this.$refs.table.tabulator.on("tableBuilt", () => { + this.$refs.table.tabulator.setData(url); + }); + else + this.$refs.table.tabulator.setData(url); + } + }, + template: ` +
+ + +
` +}; + diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js new file mode 100644 index 000000000..203029fb2 --- /dev/null +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Contact.js @@ -0,0 +1,93 @@ +import {CoreFilterCmpt} from "../../../../filter/Filter.js"; +import {CoreRESTClient} from "../../../../../RESTClient"; + +var editIcon = function(cell, formatterParams){ //plain text value + return ""; +}; +var deleteIcon = function(cell, formatterParams){ //plain text value + return ""; +}; + +export default{ + components: { + CoreFilterCmpt + }, + props: { + uid: String + }, + emits: [ + 'update:selected' + ], + data() { + return{ + tabulatorOptions: { + ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Student/getKontakte/' + this.uid), + columns:[ + {title:"Typ", field:"kontakttyp"}, //TODO(manu) mix ok? + {title:"Kontakt", field:"kontakt"}, + {title:"Zustellung", field:"zustellung", + formatter: (cell, formatterParams, onRendered) => { + let output = cell.getValue() ? "ja" : "nein"; + return output;} + }, + {title:"Anmerkung", field:"anmerkung"}, + //{title:"Firma", field:"adress_id"}, + {title:"Firma_id", field:"firma_id", visible:false}, + {title:"Person_id", field:"person_id", visible:false}, + {title:"Kontakt_id", field:"kontakt_id", visible:false}, + {title:"letzte Änderung", field:"updateamum", visible:false}, + {formatter:editIcon, width:40, align:"center", cellClick:function(e, cell){alert("Edit data for kontakt_id: " + cell.getRow().getIndex())}}, + {formatter:deleteIcon, width:40, align:"center", cellClick:function(e, cell){alert("Delete data for kontakt_id " + cell.getRow().getIndex())}}, + ], + layout: 'fitDataFill', + layoutColumnsOnNewData: false, + height: 'auto', + selectable: true, + index: 'kontakt_id', + }, + tabulatorEvents: [ + /* { + event: 'rowSelectionChanged', + handler: this.rowSelectionChanged + }, + { + event: 'dataProcessed', + handler: this.autoSelectRows + }*/ + ], + lastSelected: null + } + }, + methods:{ + actionNewAdress(){ + console.log("Neuen Kontakt anlegen"); + }, + updateUrl(url, first) { + this.lastSelected = first ? undefined : this.selected; + if (url) + url = CoreRESTClient._generateRouterURI(url); + if (!this.$refs.table.tableBuilt) + this.$refs.table.tabulator.on("tableBuilt", () => { + this.$refs.table.tabulator.setData(url); + }); + else + this.$refs.table.tabulator.setData(url); + } + }, + template: ` +
+ + +
` +}; +