diff --git a/application/controllers/api/frontend/v1/stv/Filter.php b/application/controllers/api/frontend/v1/stv/Filter.php new file mode 100644 index 000000000..d5ee44d13 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Filter.php @@ -0,0 +1,90 @@ +. + */ + +if (!defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about the Studiengang filter + * Listens to ajax post calls to change the Studiengang filter data + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Filter extends FHCAPI_Controller +{ + /** + * Calls the parent's constructor and prepares libraries and phrases + */ + public function __construct() + { + // TODO(chris): permissions + parent::__construct([ + 'getStg' => 'student/stammdaten:r',#self::PERM_LOGGED, + 'setStg' => 'student/stammdaten:r'#self::PERM_LOGGED + ]); + + // Load models + $this->load->model('system/Variable_model', 'VariableModel'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Get current setting + * + * @return void + */ + public function getStg() + { + $result = $this->VariableModel->getVariables(getAuthUID(), ['kontofilterstg']); + + #$data = $this->getDataOrTerminateWithError($result); + if (isError($result)) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + $data = $result->retval; + + $this->terminateWithSuccess($data['kontofilterstg'] == 'true'); + } + + /** + * Set current setting + * + * @return void + */ + public function setStg() + { + $this->load->library('form_validation'); + + $studiengang_kz = $this->input->post('studiengang_kz'); + + if ($studiengang_kz === null) { + $this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $result = $this->VariableModel->setVariable(getAuthUID(), 'kontofilterstg', $studiengang_kz ? 'true' : 'false'); + + #$this->getDataOrTerminateWithError($result); + if (isError($result)) + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess(true); + } +} 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 46a7ec30a..1f3d9bb72 100644 --- a/application/controllers/components/stv/Config.php +++ b/application/controllers/components/stv/Config.php @@ -15,53 +15,61 @@ 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', 'tab_notes'), 'component' => './Stv/Studentenverwaltung/Details/Notizen.js' ]; - $result['kontakt'] = [ - 'title' => 'Kontakt', + $result['contact'] = [ + 'title' => $this->p->t('stv', 'tab_contact'), 'component' => './Stv/Studentenverwaltung/Details/Kontakt.js' ]; $result['prestudent'] = [ - 'title' => 'PreStudentIn', + 'title' => $this->p->t('stv', 'tab_prestudent'), 'component' => './Stv/Studentenverwaltung/Details/Prestudent.js' ]; - $result['status'] = [ - 'title' => 'Status', - 'component' => './Stv/Studentenverwaltung/Details/Status.js' - ]; $result['multistatus'] = [ - 'title' => 'MultiStatus', + 'title' => 'Status', 'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js' ]; $result['konto'] = [ 'title' => 'Konto', + 'component' => './Stv/Studentenverwaltung/Details/Konto.js' + ]; + $result['banking'] = [ + 'title' => $this->p->t('stv', 'tab_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', 'tab_resources'), 'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js' ]; - $result['noten'] = [ - 'title' => 'Noten', + $result['grades'] = [ + 'title' => $this->p->t('stv', 'tab_grades'), 'component' => './Stv/Studentenverwaltung/Details/Noten.js' ]; @@ -74,35 +82,30 @@ class Config extends FHC_Controller public function students() { - // TODO(chris): phrases $result = []; - $result['konto'] = [ - 'title' => 'Konto', + $result['banking'] = [ + 'title' => $this->p->t('stv', 'tab_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' => [] ] ]; $result['multistatus'] = [ - 'title' => 'MultiStatus', + 'title' => 'Status', 'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js', 'config' => [ - 'abbrecherStgl' => $this->permissionlib->isBerechtigt('admin'), - 'abbrecherStud' => $this->permissionlib->isBerechtigt('admin') + 'changeStatusToAbbrecherStgl' => $this->permissionlib->isBerechtigt('admin'), + 'changeStatusToAbbrecherStud' => $this->permissionlib->isBerechtigt('admin'), + 'changeStatusToUnterbrecher' => $this->permissionlib->isBerechtigt('admin'), + 'changeStatusToDiplomand' => $this->permissionlib->isBerechtigt('admin'), + 'changeStatusToAbsolvent' => $this->permissionlib->isBerechtigt('admin') ] ]; -/* $result['status'] = [ - 'title' => 'Status', - 'component' => './Stv/Studentenverwaltung/Details/Status.js', - 'config' => [ - 'abbrecherStgl' => $this->permissionlib->isBerechtigt('admin'), - 'abbrecherStud' => $this->permissionlib->isBerechtigt('admin') - ] - ];*/ Events::trigger('stv_conf_students', function & () use (&$result) { return $result; @@ -110,4 +113,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/controllers/components/stv/Students.php b/application/controllers/components/stv/Students.php index 9bd2df73f..475497141 100644 --- a/application/controllers/components/stv/Students.php +++ b/application/controllers/components/stv/Students.php @@ -2,6 +2,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); +// TODO(chris): Prestudent status missing + class Students extends FHC_Controller { public function __construct() @@ -320,6 +322,8 @@ class Students extends FHC_Controller break; } + $this->addFilter($studiensemester_kurzbz); + $this->outputJson([]); } @@ -426,6 +430,8 @@ class Students extends FHC_Controller } + $this->addFilter($studiensemester_kurzbz); + $result = $this->PrestudentModel->loadWhere($where); if (isError($result)) { @@ -497,6 +503,8 @@ class Students extends FHC_Controller $this->PrestudentModel->addSelect('p.zugangscode'); $this->PrestudentModel->addSelect('p.bpk'); + $this->addFilter($studiensemester_kurzbz); + $result = $this->PrestudentModel->loadWhere([ 'tbl_prestudent.prestudent_id' => $prestudent_id ]); @@ -570,6 +578,8 @@ class Students extends FHC_Controller $this->PrestudentModel->addSelect('p.zugangscode'); $this->PrestudentModel->addSelect('p.bpk'); + $this->addFilter($studiensemester_kurzbz); + $result = $this->PrestudentModel->loadWhere([ 's.student_uid' => $student_uid ]); @@ -643,6 +653,8 @@ class Students extends FHC_Controller $this->PrestudentModel->addSelect('p.zugangscode'); $this->PrestudentModel->addSelect('p.bpk'); + $this->addFilter($studiensemester_kurzbz); + $result = $this->PrestudentModel->loadWhere([ 'p.person_id' => $person_id ]); @@ -654,4 +666,45 @@ class Students extends FHC_Controller $this->outputJson(getData($result) ?: []); } } + + /** + * Adds additional filters to the query + * + * @param string $studiensemester_kurzbz + * + * @return void + */ + protected function addFilter($studiensemester_kurzbz) + { + $filter = $this->input->get('filter'); + if (isset($filter['konto_count_0'])) { + $bt = $this->PrestudentModel->escape($filter['konto_count_0']); + $stdsem = $this->PrestudentModel->escape($studiensemester_kurzbz); + + $this->PrestudentModel->db->where('( + SELECT count(*) + FROM public.tbl_konto + WHERE person_id=tbl_prestudent.person_id + AND buchungstyp_kurzbz=' . $bt . ' + AND studiensemester_kurzbz=' . $stdsem . ' + ) =', 0); + $this->PrestudentModel->db->where('get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) !=', 'Incoming'); + } + if (isset($filter['konto_missing_counter'])) { + $bt = $this->PrestudentModel->escape($filter['konto_missing_counter']); + $stg = ''; + if ($this->variablelib->getVar('kontofilterstg') == 'true') + $stg = ' AND studiengang_kz=tbl_prestudent.studiengang_kz'; + + $bt = $bt == 'alle' ? '' : ' AND buchungstyp_kurzbz=' . $bt; + + $this->PrestudentModel->db->where('( + SELECT sum(betrag) + FROM public.tbl_konto + WHERE person_id=tbl_prestudent.person_id' . + $bt . + $stg . ' + ) !=', 0); + } + } } 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/css/Studentenverwaltung.css b/public/css/Studentenverwaltung.css index d29455097..1fa35623e 100644 --- a/public/css/Studentenverwaltung.css +++ b/public/css/Studentenverwaltung.css @@ -104,3 +104,7 @@ html { background-color: #f8d7da!important; border-color: #f5c2c7!important; } + +.has-filter .fa-filter { + color: var(--bs-success); +} diff --git a/public/js/api/stv.js b/public/js/api/stv.js index 2a84ab0b7..ab3e918a1 100644 --- a/public/js/api/stv.js +++ b/public/js/api/stv.js @@ -1,5 +1,7 @@ +import filter from './stv/filter.js'; import konto from './stv/konto.js'; export default { + filter, konto }; \ No newline at end of file diff --git a/public/js/api/stv/filter.js b/public/js/api/stv/filter.js new file mode 100644 index 000000000..13c7f55fd --- /dev/null +++ b/public/js/api/stv/filter.js @@ -0,0 +1,10 @@ +export default { + getStg() { + return this.$fhcApi.get('api/frontend/v1/stv/filter/getStg'); + }, + setStg(studiengang_kz) { + return this.$fhcApi.post('api/frontend/v1/stv/filter/setStg', { + studiengang_kz + }); + } +}; \ No newline at end of file diff --git a/public/js/apps/api/fhcapifactory.js b/public/js/apps/api/fhcapifactory.js index c1f1e0d5c..9303a941c 100644 --- a/public/js/apps/api/fhcapifactory.js +++ b/public/js/apps/api/fhcapifactory.js @@ -1,5 +1,7 @@ import Search from "./search.js"; +import stv from "../../api/stv.js"; export default { - "Search": Search + "Search": Search, + stv }; diff --git a/public/js/components/Stv/Studentenverwaltung.js b/public/js/components/Stv/Studentenverwaltung.js index affbe2984..69fa03dee 100644 --- a/public/js/components/Stv/Studentenverwaltung.js +++ b/public/js/components/Stv/Studentenverwaltung.js @@ -190,14 +190,14 @@ export default {
@@ -288,7 +217,7 @@ export default { :tabulator-options="tabulatorOptions" reload new-btn-show - new-btn-label="Buchung" + :new-btn-label="$p.t('konto/buchung')" :new-btn-disabled="stg_kz === ''" @click:new="actionNew" > @@ -308,7 +237,7 @@ export default { @click="actionCounter(selected)" :disabled="!selected.length" > - Gegenbuchen + {{ $p.t('stv/konto_counter') }}
diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Konto/Edit.js b/public/js/components/Stv/Studentenverwaltung/Details/Konto/Edit.js index d7b2976e3..26b8f0891 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Konto/Edit.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Konto/Edit.js @@ -3,7 +3,6 @@ import CoreForm from "../../../../Form/Form.js"; import FormValidation from "../../../../Form/Validation.js"; import FormInput from "../../../../Form/Input.js"; -// TODO(chris): Phrasen export default { components: { @@ -40,7 +39,7 @@ export default { this.$emit('saved', result.data); this.loading = false; this.$refs.modal.hide(); - this.$fhcAlert.alertSuccess('Daten wurden gespeichert'); + this.$fhcAlert.alertSuccess(this.$p.t('ui/gespeichert')); }) .catch(error => { this.$fhcAlert.handleSystemError(error); @@ -66,21 +65,21 @@ export default { v-if="config.showBuchungsnr" v-model="data.buchungsnr" name="buchungsnr" - label="Buchungsnr" + :label="$p.t('konto/buchungsnr')" disabled > @@ -88,21 +87,21 @@ export default { @@ -146,18 +145,18 @@ export default { type="textarea" v-model="data.anmerkung" name="anmerkung" - label="Anmerkung" + :label="$p.t('global/anmerkung')" > diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Konto/New.js b/public/js/components/Stv/Studentenverwaltung/Details/Konto/New.js index 90cdfdd2d..52e15a4d5 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Konto/New.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Konto/New.js @@ -4,7 +4,6 @@ import CoreForm from "../../../../Form/Form.js"; import FormValidation from "../../../../Form/Validation.js"; import FormInput from "../../../../Form/Input.js"; -// TODO(chris): Phrasen export default { components: { @@ -74,7 +73,7 @@ export default { this.$emit('saved', result.data); this.loading = false; this.$refs.modal.hide(); - this.$fhcAlert.alertSuccess('Daten wurden gespeichert'); + this.$fhcAlert.alertSuccess(this.$p.t('ui/gespeichert')); }) .catch(error => { if (error) @@ -125,7 +124,7 @@ export default { type="select" v-model="data.buchungstyp_kurzbz" name="buchungstyp_kurzbz" - label="Typ" + :label="$p.t('konto/buchungstyp')" @update:model-value="checkDefaultBetrag" >