From f47f8d5da4cbcc33f91d7a6980f5808bdd462d89 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Thu, 25 Apr 2024 11:36:37 +0200 Subject: [PATCH] Konto: Phrases --- .../controllers/api/frontend/v1/stv/Konto.php | 25 +- .../controllers/components/stv/Config.php | 134 +++- application/models/crm/Konto_model.php | 4 +- .../Stv/Studentenverwaltung/Details/Konto.js | 169 ++--- .../Stv/Studentenverwaltung/List.js | 9 +- system/phrasesupdate.php | 639 +++++++++++++++++- 6 files changed, 817 insertions(+), 163 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Konto.php b/application/controllers/api/frontend/v1/stv/Konto.php index 002d84766..4606f5abc 100644 --- a/application/controllers/api/frontend/v1/stv/Konto.php +++ b/application/controllers/api/frontend/v1/stv/Konto.php @@ -49,7 +49,7 @@ class Konto extends FHCAPI_Controller // Load language phrases $this->loadPhrases([ - 'ui' + 'konto' ]); } @@ -175,22 +175,21 @@ class Konto extends FHCAPI_Controller return $row->nachname . ' ' . $row->vorname; }, $result); - // TODO(chris): Phrases - $result = $this->p->t('konto', 'buchung_vorhanden') . "\n"; + $result = $this->p->t('konto', 'confirm_overwrite') . "\n"; if (count($persons) > 10) { $result .= "-" . implode("\n-", array_slice($persons, 0, 10)) . "\n"; if (count($persons) == 11) { - $result .= "\n" . $this->p->t('konto', 'and_1_additional_person'); + $result .= "\n" . $this->p->t('konto', 'confirm_overwrite_1_add_pers'); } else { - $result .= "\n" . $this->p->t('konto', 'and_x_additional_person', [ + $result .= "\n" . $this->p->t('konto', 'confirm_overwrite_x_add_pers', [ 'x' => count($persons) - 10 ]); } } else { $result .= "-" . implode("\n-", $persons) . "\n"; } - $result .= $this->p->t('konto', 'proceed'); + $result .= $this->p->t('konto', 'confirm_overwrite_proceed'); $this->addError($result, 'confirm'); @@ -327,8 +326,8 @@ class Konto extends FHCAPI_Controller 'label' => 'Buchung # ' . $buchungsnr, 'rules' => 'regex_match[/^$/]', 'errors' => [ - 'regex_match' => 'Gegenbuchungen koennen nur auf die obersten Buchungen getaetigt werden' - ] // TODO(chris): phrase + 'regex_match' => $this->p->t('konto', 'error_counter_level') + ] ]; } } @@ -355,9 +354,9 @@ class Konto extends FHCAPI_Controller if ($betrag === null) { $this->addError($this->p->t( 'konto', - 'Buchung #{buchungsnr} does not exist', + 'error_missing', $buchung - ), self::ERROR_TYPE_GENERAL); // TODO(chris): phrase + ), self::ERROR_TYPE_GENERAL); continue; } @@ -482,7 +481,9 @@ class Konto extends FHCAPI_Controller $result = $result->retval; if (!$result) - $this->terminateWithError('buchung not found', self::ERROR_TYPE_GENERAL); // TODO(chris): phrase + $this->terminateWithError($this->p->t('konto', 'error_missing', [ + 'buchungsnr' => $buchungsnr + ]), self::ERROR_TYPE_GENERAL); $_POST['studiengang_kz'] = current($result)->studiengang_kz; @@ -500,7 +501,7 @@ class Konto extends FHCAPI_Controller if (isError($result)) { if (getCode($result) != 42) $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); // TODO(chris): phrase + $this->terminateWithError($this->p->t('konto', 'error_delete_level'), self::ERROR_TYPE_GENERAL); } $this->terminateWithSuccess(); diff --git a/application/controllers/components/stv/Config.php b/application/controllers/components/stv/Config.php index 78089d519..c06093c63 100644 --- a/application/controllers/components/stv/Config.php +++ b/application/controllers/components/stv/Config.php @@ -15,49 +15,57 @@ class Config extends FHC_Controller $this->load->library('AuthLib'); $this->load->library('PermissionLib'); + + $this->loadPhrases([ + 'global', + 'person', + 'lehre', + 'stv', + 'konto' + ]); } public function student() { - // TODO(chris): phrases $result = []; $result['details'] = [ - 'title' => 'Details', + 'title' => $this->p->t('stv', 'tab_details'), 'component' => './Stv/Studentenverwaltung/Details/Details.js' ]; - $result['notizen'] = [ - 'title' => 'Notizen', + $result['notes'] = [ + 'title' => $this->p->t('stv', 'notes'), 'component' => './Stv/Studentenverwaltung/Details/Notizen.js' ]; - $result['kontakt'] = [ - 'title' => 'Kontakt', + $result['contact'] = [ + 'title' => $this->p->t('stv', 'contact'), 'component' => './Stv/Studentenverwaltung/Details/Kontakt.js' ]; $result['prestudent'] = [ - 'title' => 'PreStudentIn', + 'title' => $this->p->t('stv', 'prestudent'), 'component' => './Stv/Studentenverwaltung/Details/Prestudent.js' ]; $result['status'] = [ - 'title' => 'Status', + 'title' => $this->p->t('stv', 'status'), 'component' => './Stv/Studentenverwaltung/Details/Status.js' ]; - $result['konto'] = [ - 'title' => 'Konto', + $result['banking'] = [ + 'title' => $this->p->t('stv', 'banking'), 'component' => './Stv/Studentenverwaltung/Details/Konto.js', 'config' => [ 'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN), 'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'), 'showMahnspanne' => (!defined('FAS_KONTO_SHOW_MAHNSPANNE') || FAS_KONTO_SHOW_MAHNSPANNE===true), 'showCreditpoints' => (defined('FAS_KONTO_SHOW_CREDIT_POINTS') && FAS_KONTO_SHOW_CREDIT_POINTS == 'true'), + 'columns' => $this->kontoColumns(), 'additionalCols' => [] ] ]; - $result['betriebsmittel'] = [ - 'title' => 'Betriebsmittel', + $result['resources'] = [ + 'title' => $this->p->t('stv', 'resources'), 'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js' ]; - $result['noten'] = [ - 'title' => 'Noten', + $result['grades'] = [ + 'title' => $this->p->t('stv', 'grades'), 'component' => './Stv/Studentenverwaltung/Details/Noten.js' ]; @@ -70,16 +78,16 @@ class Config extends FHC_Controller public function students() { - // TODO(chris): phrases $result = []; - $result['konto'] = [ - 'title' => 'Konto', + $result['banking'] = [ + 'title' => $this->p->t('stv', 'banking'), 'component' => './Stv/Studentenverwaltung/Details/Konto.js', 'config' => [ 'showZahlungsbestaetigung' => (defined('ZAHLUNGSBESTAETIGUNG_ANZEIGEN') && ZAHLUNGSBESTAETIGUNG_ANZEIGEN), 'showBuchungsnr' => $this->permissionlib->isBerechtigt('admin'), 'showMahnspanne' => (!defined('FAS_KONTO_SHOW_MAHNSPANNE') || FAS_KONTO_SHOW_MAHNSPANNE===true), 'showCreditpoints' => (defined('FAS_KONTO_SHOW_CREDIT_POINTS') && FAS_KONTO_SHOW_CREDIT_POINTS == 'true'), + 'columns' => $this->kontoColumnsMultiPerson(), 'additionalCols' => [] ] ]; @@ -90,4 +98,96 @@ class Config extends FHC_Controller $this->outputJsonSuccess($result); } + + protected function kontoColumns() + { + return [ + 'buchungsdatum' => [ + 'field' => "buchungsdatum", + 'title' => $this->p->t('konto', 'buchungsdatum') + ], + 'buchungstext' => [ + 'field' => "buchungstext", + 'title' => $this->p->t('konto', 'buchungstext') + ], + 'betrag' => [ + 'field' => "betrag", + 'title' => $this->p->t('konto', 'betrag') + ], + 'studiensemester_kurzbz' => [ + 'field' => "studiensemester_kurzbz", + 'title' => $this->p->t('lehre', 'studiensemester') + ], + 'buchungstyp_kurzbz' => [ + 'field' => "buchungstyp_kurzbz", + 'title' => $this->p->t('konto', 'buchungstyp'), + 'visible' => false + ], + 'buchungsnr' => [ + 'field' => "buchungsnr", + 'title' => $this->p->t('konto', 'buchungsnr'), + 'visible' => false + ], + 'insertvon' => [ + 'field' => "insertvon", + 'title' => $this->p->t('global', 'insertvon'), + 'visible' => false + ], + 'insertamum' => [ + 'field' => "insertamum", + 'title' => $this->p->t('global', 'insertamum'), + 'visible' => false + ], + 'kuerzel' => [ + 'field' => "kuerzel", + 'title' => $this->p->t('lehre', 'studiengang'), + 'visible' => false + ], + 'anmerkung' => [ + 'field' => "anmerkung", + 'title' => $this->p->t('global', 'anmerkung') + ], + 'actions' => [ + 'title' => $this->p->t('global', 'actions'), + 'frozen' => true + ] + ]; + } + protected function kontoColumnsMultiPerson() + { + return [ + 'person_id' => [ + 'field' => "person_id", + 'title' => $this->p->t('person', 'person_id') + ], + 'anrede' => [ + 'field' => "anrede", + 'title' => $this->p->t('person', 'anrede'), + 'visible' => false + ], + 'titelpost' => [ + 'field' => "titelpost", + 'title' => $this->p->t('person', 'titelpost'), + 'visible' => false + ], + 'titelpre' => [ + 'field' => "titelpre", + 'title' => $this->p->t('person', 'titelpre'), + 'visible' => false + ], + 'vorname' => [ + 'field' => "vorname", + 'title' => $this->p->t('person', 'vorname') + ], + 'vornamen' => [ + 'field' => "vornamen", + 'title' => $this->p->t('person', 'vornamen'), + 'visible' => false + ], + 'nachname' => [ + 'field' => "nachname", + 'title' => $this->p->t('person', 'nachname') + ] + ] + $this->kontoColumns(); + } } diff --git a/application/models/crm/Konto_model.php b/application/models/crm/Konto_model.php index 6122feef0..d130d5db8 100644 --- a/application/models/crm/Konto_model.php +++ b/application/models/crm/Konto_model.php @@ -84,8 +84,8 @@ class Konto_model extends DB_Model { $this->db->where('buchungsnr_verweis', $id); if ($this->db->count_all_results($this->dbTable)) - return error('Bitte zuerst die zugeordneten Buchungen loeschen'); - return parent::delete($id, 42); + return error('Bitte zuerst die zugeordneten Buchungen loeschen', 42); + return parent::delete($id); } /** diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Konto.js b/public/js/components/Stv/Studentenverwaltung/Details/Konto.js index 4b3152331..1acfcd9dd 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Konto.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Konto.js @@ -3,7 +3,6 @@ import FormInput from "../../../Form/Input.js"; import KontoNew from "./Konto/New.js"; import KontoEdit from "./Konto/Edit.js"; -// TODO(chris): Phrasen export default { components: { @@ -52,130 +51,46 @@ export default { } }, tabulatorColumns() { - let columns = []; - - if (Array.isArray(this.modelValue)) { - columns.push({ - field: "person_id", - title: "Person ID" - }); - columns.push({ - field: "anrede", - title: "Anrede", - visible: false - }); - columns.push({ - field: "titelpost", - title: "Titelpost", - visible: false - }); - columns.push({ - field: "titelpre", - title: "Titelpre", - visible: false - }); - columns.push({ - field: "vorname", - title: "Vorname" - }); - columns.push({ - field: "vornamen", - title: "Vornamen", - visible: false - }); - columns.push({ - field: "nachname", - title: "Nachname" - }); - } + const columns = { ...this.config.columns }; + if (!columns.actions) + columns.actions = { + title: '', + frozen: true + }; + columns.actions.formatter = cell => { + let container = document.createElement('div'); + container.className = "d-flex gap-2"; - columns = [...columns, ...[ - { - field: "buchungsdatum", - title: "Buchungsdatum" - }, - { - field: "buchungstext", - title: "Buchungstext" - }, - { - field: "betrag", - title: "Betrag" - }, - { - field: "studiensemester_kurzbz", - title: "StSem" - }, - { - field: "buchungstyp_kurzbz", - title: "Typ", - visible: false - }, - { - field: "buchungsnr", - title: "Buchungs Nr", - visible: false - }, - { - field: "insertvon", - title: "Angelegt von", - visible: false - }, - { - field: "insertamum", - title: "Anlagedatum", - visible: false - }, - { - field: "kuerzel", - title: "Studiengang", - visible: false - }, - { - field: "anmerkung", - title: "Anmerkung" - } - ]]; + let button = document.createElement('button'); + button.className = 'btn btn-outline-secondary'; + button.innerHTML = ''; + button.addEventListener('click', () => + this.$refs.edit.open(cell.getData()) + ); + container.append(button); - columns = [...columns, ...this.config.additionalCols]; + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary'; + button.innerHTML = ''; + button.addEventListener('click', evt => { + evt.stopPropagation(); + this.$fhcAlert + .confirmDelete() + .then(result => result ? cell.getData().buchungsnr : Promise.reject({handled:true})) + .then(this.$fhcApi.factory.stv.konto.delete) + .then(() => { + // TODO(chris): deleting a child also removes the siblings! + //cell.getRow().delete(); + this.reload(); + }) + .catch(this.$fhcAlert.handleSystemError); + }); + container.append(button); - columns.push({ - title: 'Actions', - formatter: cell => { - let container = document.createElement('div'); - container.className = "d-flex gap-2"; + return container; + }; - let button = document.createElement('button'); - button.className = 'btn btn-outline-secondary'; - button.innerHTML = ''; - button.addEventListener('click', () => - this.$refs.edit.open(cell.getData()) - ); - container.append(button); - - button = document.createElement('button'); - button.className = 'btn btn-outline-secondary'; - button.innerHTML = ''; - button.addEventListener('click', evt => { - evt.stopPropagation(); - this.$fhcAlert - .confirmDelete() - .then(result => result ? cell.getData().buchungsnr : Promise.reject({handled:true})) - .then(this.$fhcApi.factory.stv.konto.delete) - .then(() => { - // TODO(chris): deleting a child also removes the siblings! - //cell.getRow().delete(); - this.reload(); - }) - .catch(this.$fhcAlert.handleSystemError); - }); - container.append(button); - - return container; - }, - frozen: true - }); - return columns; + return Object.values(columns); }, tabulatorOptions() { return this.$fhcApi.factory.stv.konto.tabulatorConfig({ @@ -214,7 +129,7 @@ export default { }) .then(result => result.data) .then(this.updateData) - .then(() => 'Daten wurden gespeichert') + .then(() => this.$p.t('ui/gespeichert')) .then(this.$fhcAlert.alertSuccess) .catch(this.$fhcAlert.handleSystemError); }, @@ -263,7 +178,7 @@ export default { @@ -273,7 +188,7 @@ export default { @@ -308,7 +223,7 @@ export default { @click="actionCounter(selected)" :disabled="!selected.length" > - Gegenbuchen + {{ $p.t('stv/konto_counter') }} diff --git a/public/js/components/Stv/Studentenverwaltung/List.js b/public/js/components/Stv/Studentenverwaltung/List.js index 31f7d0963..3f59397c3 100644 --- a/public/js/components/Stv/Studentenverwaltung/List.js +++ b/public/js/components/Stv/Studentenverwaltung/List.js @@ -2,6 +2,7 @@ import {CoreFilterCmpt} from "../../filter/Filter.js"; import {CoreRESTClient} from '../../../RESTClient.js'; import ListNew from './List/New.js'; + export default { components: { CoreFilterCmpt, @@ -205,14 +206,14 @@ export default { :side-menu="false" reload new-btn-show - new-btn-label="InteressentIn" + :new-btn-label="$p.t('stv/action_new')" @click:new="actionNewPrestudent" >