From bfb3f09f79a4963e47c3784290b9cba61450937e Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 11 Dec 2024 17:15:18 +0100 Subject: [PATCH] CIS4 and old CIS support --- application/controllers/Cis/BankData.php | 43 ++++++++ .../controllers/api/frontend/v1/Bank.php | 12 +-- application/views/Cis/BankData.php | 31 ++++++ public/js/api/bankData.js | 14 +++ public/js/api/fhcapifactory.js | 5 +- public/js/apps/Cis/BankData.js | 31 ++++++ public/js/components/Cis/BankData.js | 100 ++++++++++++++++++ 7 files changed, 229 insertions(+), 7 deletions(-) create mode 100644 application/controllers/Cis/BankData.php create mode 100644 application/views/Cis/BankData.php create mode 100644 public/js/api/bankData.js create mode 100644 public/js/apps/Cis/BankData.js create mode 100644 public/js/components/Cis/BankData.js diff --git a/application/controllers/Cis/BankData.php b/application/controllers/Cis/BankData.php new file mode 100644 index 000000000..fbacde85a --- /dev/null +++ b/application/controllers/Cis/BankData.php @@ -0,0 +1,43 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +class BankData extends Auth_Controller +{ + /** + * + */ + public function __construct() + { + parent::__construct( + array( + 'view' => 'basis/cis:r' + ) + ); + } + + /** + * + */ + public function view() + { + $this->load->view('Cis/BankData'); + } +} + diff --git a/application/controllers/api/frontend/v1/Bank.php b/application/controllers/api/frontend/v1/Bank.php index 7fd69ed85..f177e318a 100644 --- a/application/controllers/api/frontend/v1/Bank.php +++ b/application/controllers/api/frontend/v1/Bank.php @@ -72,11 +72,11 @@ class Bank extends FHCAPI_Controller array($loggedPersonId) ); - // If a db error occurred then terminate - if (isError($bankDataResult)) $this->terminateWithError('Database error while retrieving bank data', self::ERROR_TYPE_DB); + // Get the retrieved data or terminate + $data = $this->getDataOrTerminateWithError($bankDataResult); - // If everythin was fine then return the database results - $this->terminateWithSuccess(getData($bankDataResult)); + // Anyway terminate it! + $this->terminateWithSuccess($data); } /** @@ -120,7 +120,7 @@ class Bank extends FHCAPI_Controller $writeDataResult = null; // it is considered as an error - // If at least a record exists + // If at least a record exists then update if (hasData($bankDataResult)) { // Then update @@ -136,7 +136,7 @@ class Bank extends FHCAPI_Controller ) ); } - else + else // otherwise insert { // Otherwise insert $writeDataResult = $this->BankverbindungModel->insert( diff --git a/application/views/Cis/BankData.php b/application/views/Cis/BankData.php new file mode 100644 index 000000000..5240decb3 --- /dev/null +++ b/application/views/Cis/BankData.php @@ -0,0 +1,31 @@ + 'Bank data', + 'primevue3' => true, + 'customJSModules' => ['public/js/apps/Cis/BankData.js'], + 'customCSSs' => ['public/css/components/FormUnderline.css'] + ); + + if (defined('CIS4')) + { + $this->load->view('templates/CISVUE-Header', $includesArray); + } + else + { + $this->load->view('templates/FHC-Header', $includesArray); + } +?> + +
+ +load->view('templates/CISVUE-Footer', $includesArray); + } + else + { + $this->load->view('templates/FHC-Footer', $includesArray); + } +?> + diff --git a/public/js/api/bankData.js b/public/js/api/bankData.js new file mode 100644 index 000000000..4fbb3d7ec --- /dev/null +++ b/public/js/api/bankData.js @@ -0,0 +1,14 @@ +export default { + getBankData() { + return this.$fhcApi.get('api/frontend/v1/Bank/getBankData'); + }, + postBankData(name, bic, iban) { + return this.$fhcApi.post( + 'api/frontend/v1/Bank/postBankData', { + name: name, + bic: bic, + iban: iban + }); + } +}; + diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index c4106c3f6..86c3c7f48 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -33,6 +33,7 @@ import ort from "./ort.js"; import cms from "./cms.js"; import lehre from "./lehre.js"; import addons from "./addons.js"; +import bankData from "./bankData.js"; export default { search, @@ -52,5 +53,7 @@ export default { ort, cms, lehre, - addons + addons, + bankData }; + diff --git a/public/js/apps/Cis/BankData.js b/public/js/apps/Cis/BankData.js new file mode 100644 index 000000000..8fe6db177 --- /dev/null +++ b/public/js/apps/Cis/BankData.js @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2024 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import BankData from "../../components/Cis/BankData.js"; +import fhcapifactory from "../../api/fhcapifactory.js"; +import Phrasen from "../../plugin/Phrasen.js"; + +const bankDataApp = Vue.createApp({ + name: 'BankDataApp', + components: { + BankData + }, + template: `` +}); + +bankDataApp.use(Phrasen).mount('#content'); + diff --git a/public/js/components/Cis/BankData.js b/public/js/components/Cis/BankData.js new file mode 100644 index 000000000..4d8c90198 --- /dev/null +++ b/public/js/components/Cis/BankData.js @@ -0,0 +1,100 @@ +/** + * Copyright (C) 2022 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import CoreForm from '../Form/Form.js'; +import FormInput from '../Form/Input.js'; +import FormValidation from "../Form/Validation.js"; + +export default { + components: { + CoreForm, + FormValidation, + FormInput + }, + data() { + return { + bankName: '', + bic: '', + iban: '' + } + }, + methods: { + save() { + this.$refs.form.factory.bankData.postBankData(this.bankName, this.bic, this.iban) + .then(result => { + this.$emit('saved', result.data); + this.$fhcAlert.alertSuccess(this.$p.t('ui/gespeichert')); + }) + .catch(error => { + this.$fhcAlert.handleSystemError(error); + }); + } + }, + created() { + this.$fhcApi.factory.bankData.getBankData() + .then(result => { + if (result.data.length > 0) + { + this.bankName = result.data[0].name; + this.bic = result.data[0].bic; + this.iban = result.data[0].iban; + } + }) + .catch(this.$fhcAlert.handleSystemError); + }, + template: ` +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+
` +}; +