Merge branch 'feature-30660/FHC4_StudierendenGUI_Prototyp'

This commit is contained in:
Harald Bamberger
2024-08-13 17:27:28 +02:00
112 changed files with 21623 additions and 295 deletions
@@ -0,0 +1,40 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Studentenverwaltung extends Auth_Controller
{
public function __construct()
{
$permissions = [];
$router = load_class('Router');
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
parent::__construct($permissions);
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
}
/**
* @return void
*/
public function _remap()
{
$this->load->view('Studentenverwaltung', [
'permissions' => [
'student/bpk' => $this->permissionlib->isBerechtigt('student/bpk'),
'student/alias' => $this->permissionlib->isBerechtigt('student/alias'),
'basis/prestudent' => $this->permissionlib->isBerechtigt('basis/prestudent'),
'basis/prestudentstatus' => $this->permissionlib->isBerechtigt('basis/prestudentstatus'),
'assistenz_stgs' => $this->permissionlib->getSTG_isEntitledFor('assistenz'),
'admin' => $this->permissionlib->isBerechtigt('admin'),
'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'),
'student/keine_studstatuspruefung' => $this->permissionlib->isBerechtigt('student/keine_studstatuspruefung'),
'lehre/reihungstestAufsicht' => $this->permissionlib->isBerechtigt('lehre/reihungstestAufsicht')
],
'variables' => [
'semester_aktuell' => $this->variablelib->getVar('semester_aktuell')
]
]);
}
}
@@ -0,0 +1,133 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the UDFLib (back-end)
* Provides data to the ajax get calls about the Udf component
* Listens to ajax post calls to change the Udf data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Udf extends FHCAPI_Controller
{
/**
* Calls the parent's constructor and prepares the UDFLib
*/
public function __construct()
{
// NOTE: UdfLib has its own permissions checks
parent::__construct([
'load' => self::PERM_LOGGED,
'save' => self::PERM_LOGGED
]);
// Libraries
$this->load->library('form_validation');
$this->load->library('UDFLib');
// Models
$this->load->model($this->getTargetModelPath(), 'TargetModel');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Load all UDFs for a dataset
*
* @return void
*/
public function load()
{
$pks = $this->TargetModel->getPks();
foreach ($pks as $id)
$this->form_validation->set_rules($id, $id, 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$id = [];
foreach ($pks as $pk)
$id[$pk] = $this->input->post($pk);
if (!is_array($this->TargetModel->getPk()))
$id = current($id);
$result = $this->udflib->getFieldArray($this->TargetModel, $id);
$fields = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($fields);
}
/**
* Saves UDFs to a dataset
*
* @return void
*/
public function save()
{
$pks = $this->TargetModel->getPks();
foreach ($pks as $id)
$this->form_validation->set_rules($id, $id, 'required');
$result = $this->udflib->getCiValidations($this->TargetModel, $this->input->post());
$fieldValidations = $this->getDataOrTerminateWithError($result);
$this->form_validation->set_rules($fieldvalidations);
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$id = [];
$fields = $this->input->post();
foreach ($pks as $pk) {
$id[$pk] = $fields[$pk];
unset($fields[$pk]);
}
if (!is_array($this->TargetModel->getPk()))
$id = current($id);
$result = $this->TargetModel->update($id, $fields);
$this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess(array_fill_keys(array_keys($fields), ''));
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
/**
* Get the path to the target model from the url
*
* @return string
*/
private function getTargetModelPath()
{
$ci_model_path = array_slice($this->uri->rsegments, 2);
if ($ci_model_path)
$ci_model_path[] = ucfirst(array_pop($ci_model_path)) . '_model';
return implode(DIRECTORY_SEPARATOR, $ci_model_path);
}
}
@@ -0,0 +1,51 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
class NotizPerson extends Notiz_Controller
{
public function __construct()
{
parent::__construct([
'getUid' => ['admin:r', 'assistenz:r'],
'getNotizen' => ['admin:r', 'assistenz:r'],
'loadNotiz' => ['admin:r', 'assistenz:r'],
'addNewNotiz' => ['admin:rw', 'assistenz:rw'],
'updateNotiz' => ['admin:rw', 'assistenz:rw'],
'deleteNotiz' => ['admin:rw', 'assistenz:rw'],
'loadDokumente' => ['admin:r', 'assistenz:r'],
'getMitarbeiter' => ['admin:r', 'assistenz:r'],
'isBerechtigt' => ['admin:r', 'assistenz:r'],
]);
}
public function isBerechtigt($id, $typeId)
{
if($typeId != "person_id")
{
return $this->terminateWithError($this->p->t('ui', 'error_typeNotizIdIncorrect'), self::ERROR_TYPE_GENERAL);
}
//TODO define permission
if (!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid'))
{
$result = $this->p->t('lehre', 'error_keineSchreibrechte');
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function loadDokumente()
{
$notiz_id = $this->input->post('notiz_id');
// TODO(chris): make CI variant of endpoint
$this->NotizModel->addSelect($this->NotizModel->escape(base_url('content/notizdokdownload.php?id=')) . ' || campus.tbl_dms_version.dms_id AS preview');
return parent::loadDokumente();
}
}
@@ -53,7 +53,8 @@ class Leitung extends FHCAPI_Controller
// Load language phrases
$this->loadPhrases([
'studierendenantrag'
'studierendenantrag',
'lehre'
]);
}
@@ -0,0 +1,66 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
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 addresses
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Address extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'getNations' => self::PERM_LOGGED,
'getPlaces' => self::PERM_LOGGED
]);
}
public function getNations()
{
$this->load->model('codex/Nation_model', 'NationModel');
$this->NationModel->addOrder('kurztext');
$result = $this->NationModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getPlaces($plz)
{
$this->load->model('codex/Gemeinde_model', 'GemeindeModel');
$this->load->library('form_validation');
$this->form_validation->set_data(['address.plz' => $plz]);
$this->form_validation->set_rules('address.plz', 'PLZ', 'numeric|less_than[10000]');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$result = $this->GemeindeModel->getGemeindeByPlz($plz);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
}
@@ -0,0 +1,233 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
if (!defined('BASEPATH')) exit('No direct script access allowed');
use CI3_Events as Events;
/**
* This controller operates between (interface) the JS (GUI) and the back-end
* Provides data to the ajax get calls about the StV Config
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Config extends FHCAPI_Controller
{
public function __construct()
{
// TODO(chris): permissions
parent::__construct([
'student' => ['admin:r', 'assistenz:r'],
'students' => ['admin:r', 'assistenz:r']
]);
// Load Phrases
$this->loadPhrases([
'global',
'person',
'lehre',
'stv',
'konto'
]);
}
public function student()
{
$result = [];
$result['details'] = [
'title' => $this->p->t('stv', 'tab_details'),
'component' => './Stv/Studentenverwaltung/Details/Details.js'
];
$result['notes'] = [
'title' => $this->p->t('stv', 'tab_notes'),
'component' => './Stv/Studentenverwaltung/Details/Notizen.js'
];
$result['contact'] = [
'title' => $this->p->t('stv', 'tab_contact'),
'component' => './Stv/Studentenverwaltung/Details/Kontakt.js',
'config' => [
'showBankaccount' => $this->permissionlib->isBerechtigt('mitarbeiter/bankdaten')
|| $this->permissionlib->isBerechtigt('student/bankdaten')
]
];
$result['prestudent'] = [
'title' => $this->p->t('stv', 'tab_prestudent'),
'component' => './Stv/Studentenverwaltung/Details/Prestudent.js'
];
$result['status'] = [
'title' => 'Status',
'component' => './Stv/Studentenverwaltung/Details/MultiStatus.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['resources'] = [
'title' => $this->p->t('stv', 'tab_resources'),
'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js'
];
/* TODO(chris): Ausgeblendet für Testing
$result['grades'] = [
'title' => $this->p->t('stv', 'tab_grades'),
'component' => './Stv/Studentenverwaltung/Details/Noten.js'
];
*/
Events::trigger('stv_conf_student', function & () use (&$result) {
return $result;
});
$this->terminateWithSuccess($result);
}
public function students()
{
$result = [];
$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['status'] = [
'title' => 'Status',
'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js',
'config' => [
'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')
]
];
Events::trigger('stv_conf_students', function & () use (&$result) {
return $result;
});
$this->terminateWithSuccess($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();
}
}
@@ -0,0 +1,71 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
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 favorite verbände
* Listens to ajax post calls to change the favorite verbände data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Favorites extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'index' => self::PERM_LOGGED,
'set' => self::PERM_LOGGED
]);
// Load models
$this->load->model('system/Variable_model', 'VariableModel');
// TODO(chris): variable table might be to small to store favorites!
}
public function index()
{
$result = $this->VariableModel->getVariables(getAuthUID(), ['stv_favorites']);
$data = $this->getDataOrTerminateWithError($result);
if (!$data)
$this->outputJson(null);
else
$this->outputJson($data['stv_favorites']);
}
public function set()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('favorites', 'Favorites', 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$favorites = $this->input->post('favorites');
$result = $this->VariableModel->setVariable(getAuthUID(), 'stv_favorites', $favorites);
$this->getDataOrTerminateWithError($result);
$this->outputJsonSuccess(true);
}
}
@@ -0,0 +1,84 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
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()
{
parent::__construct([
'getStg' => self::PERM_LOGGED,
'setStg' => 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);
$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);
$this->terminateWithSuccess(true);
}
}
@@ -0,0 +1,754 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
class Kontakt extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'getAdressen' => ['admin:r', 'assistenz:r'],
'addNewAddress' => ['admin:rw', 'assistenz:rw'],
'addNewContact' => ['admin:rw', 'assistenz:rw'],
'addNewBankverbindung' => ['mitarbeiter/bankdaten:rw', 'student/bankdaten:rw'],
'updateAddress' => ['admin:rw', 'assistenz:rw'],
'updateContact' => ['admin:rw', 'assistenz:rw'],
'updateBankverbindung' => ['mitarbeiter/bankdaten:rw', 'student/bankdaten:rw'],
'loadAddress' => ['admin:r', 'assistenz:r'],
'loadContact' => ['admin:r', 'assistenz:r'],
'loadBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'],
'deleteAddress' => ['admin:rw', 'assistenz:rw'],
'deleteContact' => ['admin:rw','assistenz:rw'],
'deleteBankverbindung' => ['mitarbeiter/bankdaten:rw','astudent/bankdaten:rw'],
'getAdressentypen' => ['admin:r', 'assistenz:r'],
'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']
]);
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
$this->load->library('form_validation');
// Load language phrases
$this->loadPhrases([
'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');
// Extra Permissionchecks
$permsMa = [];
$permsStud = [];
switch ($this->router->method) {
case 'getBankverbindung':
case 'loadBankverbindung':
$permsMa = ['mitarbeiter/bankdaten:r'];
$permsStud = ['student/bankdaten:r'];
break;
case 'addNewBankverbindung':
case 'updateBankverbindung':
case 'deleteBankverbindung':
$permsMa = ['mitarbeiter/bankdaten:rw'];
$permsStud = ['student/bankdaten:rw'];
break;
case 'getAdressen':
case 'getKontakte':
case 'loadAddress':
case 'loadContact':
$permsMa = $permsStud = ['admin:r', 'assistenz:r'];
break;
case 'addNewAddress':
case 'addNewContact':
case 'updateAddress':
case 'updateContact':
case 'deleteAddress':
case 'deleteContact':
$permsMa = $permsStud = ['admin:rw', 'assistenz:rw'];
break;
}
if ($this->router->method == 'getAdressen'
|| $this->router->method == 'getKontakte'
|| $this->router->method == 'getBankverbindung'
|| $this->router->method == 'addNewAddress'
|| $this->router->method == 'addNewContact'
|| $this->router->method == 'addNewBankverbindung'
) {
$person_id = current(array_slice($this->uri->rsegments, 2));
$this->checkPermissionsForPerson($person_id, $permsMa, $permsStud);
} elseif ($this->router->method == 'loadAddress'
|| $this->router->method == 'loadContact'
|| $this->router->method == 'loadBankverbindung'
|| $this->router->method == 'updateAddress'
|| $this->router->method == 'updateContact'
|| $this->router->method == 'updateBankverbindung'
|| $this->router->method == 'deleteAddress'
|| $this->router->method == 'deleteContact'
|| $this->router->method == 'deleteBankverbindung'
) {
$id = current(array_slice($this->uri->rsegments, 2));
$model = 'person/Adresse_model';
if ($this->router->method == 'loadContact'
|| $this->router->method == 'updateContact'
|| $this->router->method == 'deleteContact'
) {
$model = 'person/Kontakt_model';
} elseif ($this->router->method == 'loadBankverbindung'
|| $this->router->method == 'updateBankverbindung'
|| $this->router->method == 'deleteBankverbindung'
) {
$model = 'person/Bankverbindung_model';
}
$this->load->model($model, 'TempModel');
$result = $this->TempModel->load($id);
$data = $this->getDataOrTerminateWithError($result);
if (!$result)
show_404();
$person_id = current($data)->person_id;
$this->checkPermissionsForPerson($person_id, $permsMa, $permsStud);
}
}
public function getAdressen($person_id)
{
$this->AdresseModel->addSelect('public.tbl_adresse.*');
$this->AdresseModel->addSelect('t.*');
$this->AdresseModel->addSelect('f.firma_id');
$this->AdresseModel->addSelect('f.name as firmenname');
$this->AdresseModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)');
$this->AdresseModel->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->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function addNewAddress($person_id)
{
$this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']),
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'PLZ'])
]);
if(isset($_POST['gemeinde']) && isset($_POST['ort']))
$this->form_validation->set_rules('plz', 'Postleitzahl', 'callback_validateLocationCombination', [
'validateLocationCombination' => $this->p->t('ui', 'error_location_combination')
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$uid = getAuthUID();
$co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null;
$strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null;
$ort = isset($_POST['ort']) ? $_POST['ort'] : null;
$gemeinde = isset($_POST['gemeinde']) ? $_POST['gemeinde'] : null;
$nation = isset($_POST['nation']) ? $_POST['nation'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$typ = isset($_POST['typ']) ? $_POST['typ'] : null;
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
if(isset($_POST['firma']))
{
$firma_id = $_POST['firma']['firma_id'];
}
else
$firma_id = null;
$result = $this->AdresseModel->insert(
[
'person_id' => $person_id,
'strasse' => $strasse,
'insertvon' => $uid,
'insertamum' => date('c'),
'plz' => $_POST['plz'],
'ort' => $ort,
'gemeinde' => $gemeinde,
'nation' => $nation,
'heimatadresse' => $_POST['heimatadresse'],
'zustelladresse' => $_POST['zustelladresse'],
'co_name' => $co_name,
'typ' => $typ,
'firma_id' => $firma_id,
'name' => $name,
'rechnungsadresse' => $_POST['rechnungsadresse'],
'anmerkung' => $anmerkung
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function updateAddress($address_id)
{
$uid = getAuthUID();
$this->form_validation->set_rules('plz', 'PLZ', 'required|numeric', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']),
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'PLZ'])
]);
if(isset($_POST['gemeinde']) && isset($_POST['ort']))
$this->form_validation->set_rules('plz', 'Postleitzahl', 'callback_validateLocationCombination', [
'validateLocationCombination' => $this->p->t('ui', 'error_location_combination')
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Adresse_model', 'AdresseModel');
if(!$address_id)
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
}
if(isset($_POST['firma']))
{
$firma_id = $_POST['firma']['firma_id'];
}
elseif(isset($_POST['firma_id']))
{
$firma_id = $_POST['firma_id'];
}
else
$firma_id = null;
$person_id = isset($_POST['person_id']) ? $_POST['person_id'] : null;
$co_name = isset($_POST['co_name']) ? $_POST['co_name'] : null;
$strasse = isset($_POST['strasse']) ? $_POST['strasse'] : null;
$ort = isset($_POST['ort']) ? $_POST['ort'] : null;
$gemeinde = isset($_POST['gemeinde']) ? $_POST['gemeinde'] : null;
$nation = isset($_POST['nation']) ? $_POST['nation'] : null;
$name = isset($_POST['name']) ? $_POST['name'] : null;
$typ = isset($_POST['typ']) ? $_POST['typ'] : null;
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
$result = $this->AdresseModel->update(
[
'adresse_id' => $address_id
],
[ 'person_id' => $person_id,
'strasse' => $strasse,
'updatevon' => $uid,
'updateamum' => date('c'),
'plz' => $_POST['plz'],
'ort' => $ort,
'gemeinde' => $gemeinde,
'nation' => $nation,
'heimatadresse' => $_POST['heimatadresse'],
'zustelladresse' => $_POST['zustelladresse'],
'co_name' => $co_name,
'typ' => $typ,
'firma_id' => $firma_id,
'name' => $name,
'rechnungsadresse' => $_POST['rechnungsadresse'],
'anmerkung' => $anmerkung
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function loadAddress($adresse_id)
{
$this->load->model('person/Adresse_model', 'AdresseModel');
$this->AdresseModel->addSelect('public.tbl_adresse.*');
$this->AdresseModel->addSelect('t.*');
$this->AdresseModel->addSelect('f.firma_id');
$this->AdresseModel->addSelect('f.name as firmenname');
$this->AdresseModel->addJoin('public.tbl_adressentyp t', 'ON (t.adressentyp_kurzbz = public.tbl_adresse.typ)');
$this->AdresseModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = public.tbl_adresse.firma_id)', 'LEFT');
$this->AdresseModel->addLimit(1);
$result = $this->AdresseModel->loadWhere(
array('adresse_id' => $adresse_id)
);
if (isError($result)) {
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess(current(getData($result)) ? : null);
}
public function deleteAddress($adresse_id)
{
$this->load->model('person/Adresse_model', 'AdresseModel');
$result = $this->AdresseModel->load([
'adresse_id'=> $adresse_id,
]);
if(isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$result = current(getData($result));
if($result->heimatadresse)
$this->terminateWithError($this->p->t('person', 'error_deleteHomeAdress'), self::ERROR_TYPE_GENERAL);
$result = $this->AdresseModel->delete(
array('adresse_id' => $adresse_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Adresse_id']), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(current(getData($result)) ? : null);
}
public function getAdressentypen()
{
$this->load->model('person/Adressentyp_model', 'AdressentypModel');
$result = $this->AdressentypModel->load();
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess(getData($result) ?: []);
}
public function getFirmen($searchString)
{
$this->load->model('ressource/firma_model', 'FirmaModel');
$result = $this->FirmaModel->searchFirmen($searchString);
if (isError($result)) {
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess($result ?: []);
}
public function getStandorte($searchString)
{
$this->load->model('organisation/standort_model', 'StandortModel');
$result = $this->StandortModel->searchStandorte($searchString);
if (isError($result)) {
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$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->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, 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)
);
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function getKontakttypen()
{
$this->load->model('person/Kontakttyp_model', 'KontakttypModel');
$result = $this->KontakttypModel->load();
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
else
{
$this->terminateWithSuccess(getData($result) ?: []);
}
}
public function loadContact($kontakt_id)
{
$this->load->model('person/Kontakt_model', 'KontaktModel');
$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);
$result = $this->KontaktModel->loadWhere(
array('kontakt_id' => $kontakt_id)
);
if (isError($result)) {
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
}
// $this->outputJsonSuccess(current(getData($result)));
$this->terminateWithSuccess(current(getData($result)));
}
public function addNewContact($person_id)
{
if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
{
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required|valid_email', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt']),
'valid_email' => $this->p->t('ui', 'error_fieldNoValidEmail', ['field' => 'Kontakt'])
]);
}
else
{
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt'])
]);
}
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Kontakt_model', 'KontaktModel');
$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(
[
'person_id' => $person_id,
'kontakttyp' => $kontakttyp,
'anmerkung' => $anmerkung,
'kontakt' => $kontakt,
'zustellung' => $_POST['zustellung'],
'insertvon' => $uid,
'insertamum' => date('c'),
'standort_id' => $standort_id,
'ext_id' => $ext_id
]
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function updateContact($kontakt_id)
{
$this->load->model('person/Kontakt_model', 'KontaktModel');
if(!$kontakt_id)
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
}
if(($_POST['kontakttyp'] == 'email' && isset($_POST['kontakt'])))
{
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required|valid_email', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt']),
'valid_email' => $this->p->t('ui', 'error_fieldNoValidEmail', ['field' => 'Kontakt'])
]);
}
else
{
$this->form_validation->set_rules('kontakt', 'Kontakt', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Kontakt'])
]);
}
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
/* 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');
$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(
[
'kontakt_id' => $kontakt_id
],
[
'person_id' => $person_id,
'kontakttyp' => $kontakttyp,
'anmerkung' => $anmerkung,
'kontakt' => $kontakt,
'zustellung' => $_POST['zustellung'],
'insertvon' => $uid,
'insertamum' => date('c'),
'standort_id' => $standort_id,
'ext_id' => $ext_id
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function deleteContact($kontakt_id)
{
$this->load->model('person/Kontakt_model', 'KontaktModel');
$result = $this->KontaktModel->delete(
array('kontakt_id' => $kontakt_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Kontakt_id']), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(current(getData($result)) ? : null);
}
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->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function addNewBankverbindung($person_id)
{
$this->form_validation->set_rules('iban', 'IBAN', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'IBAN'])
]);
$this->form_validation->set_rules('typ', 'TYP', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'TYP'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
$ext_id = $this->input->post('ext_id');
$oe_kurzbz = $this->input->post('oe_kurzbz');
$orgform_kurzbz = $this->input->post('orgform_kurzbz');
$name = $this->input->post('name');
$anschrift = $this->input->post('anschrift');
$bic = $this->input->post('bic');
$blz = $this->input->post('blz');
$kontonr = $this->input->post('kontonr');
$result = $this->BankverbindungModel->insert(
[
'person_id' => $person_id,
'name' => $name,
'anschrift' => $anschrift,
'bic' => $bic,
'iban' => $_POST['iban'],
'blz' => $blz,
'kontonr' => $kontonr,
'insertvon' => 'uid',
'insertamum' => date('c'),
'typ' => $_POST['typ'],
'verrechnung' => $_POST['verrechnung'],
'ext_id' => $ext_id,
'oe_kurzbz' => $oe_kurzbz,
'orgform_kurzbz' => $orgform_kurzbz
]
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function loadBankverbindung($bankverbindung_id)
{
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
$this->BankverbindungModel->addSelect('*');
$this->BankverbindungModel->addLimit(1);
$result = $this->BankverbindungModel->loadWhere(
array('bankverbindung_id' => $bankverbindung_id)
);
if (isError($result))
{
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Bankverbindung_id']), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess(current(getData($result)));
}
public function updateBankverbindung($bankverbindung_id)
{
$this->form_validation->set_rules('iban', 'IBAN', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'IBAN'])
]);
$this->form_validation->set_rules('typ', 'TYP', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'TYP'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
if(!$bankverbindung_id)
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Bankverbindung_id']), self::ERROR_TYPE_GENERAL);
}
$uid = getAuthUID();
$result = $this->BankverbindungModel->update(
[
'bankverbindung_id' => $bankverbindung_id
],
[
'person_id' => $_POST['person_id'],
'name' => $_POST['name'],
'anschrift' => $_POST['anschrift'],
'bic' => $_POST['bic'],
'iban' => $_POST['iban'],
'blz' => $_POST['blz'],
'kontonr' => $_POST['kontonr'],
'updatevon' => $uid,
'updateamum' => date('c'),
'typ' => $_POST['typ'],
'verrechnung' => $_POST['verrechnung'],
'ext_id' => $_POST['ext_id'],
'oe_kurzbz' => $_POST['oe_kurzbz'],
'orgform_kurzbz' => $_POST['orgform_kurzbz']
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->outputJsonSuccess(true);
}
public function deleteBankverbindung($bankverbindung_id)
{
$this->load->model('person/Bankverbindung_model', 'BankverbindungModel');
$result = $this->BankverbindungModel->delete(
array('bankverbindung_id' => $bankverbindung_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (!hasData($result))
{
$this->outputJson($result);
}
return $this->terminateWithSuccess(current(getData($result)) ? : null);
}
public function validateLocationCombination()
{
$this->load->model('codex/Gemeinde_model', 'GemeindeModel');
return $this->GemeindeModel->checkLocation($_POST['plz'], $_POST['gemeinde'], $_POST['ort']);
}
}
@@ -0,0 +1,495 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
if (!defined('BASEPATH')) exit('No direct script access allowed');
use CI3_Events as Events;
/**
* This controller operates between (interface) the JS (GUI) and the back-end
* Provides data to the ajax get calls about a Konto
* Listens to ajax post calls to change the Konto data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Konto extends FHCAPI_Controller
{
/**
* Calls the parent's constructor and prepares libraries and phrases
*/
public function __construct()
{
parent::__construct([
'get' => 'student/stammdaten:r',
'getBuchungstypen' => self::PERM_LOGGED,
'checkDoubles' => ['admin:r', 'assistenz:r'],
'insert' => ['admin:w', 'assistenz:w'],
'counter' => ['admin:w', 'assistenz:w'],
'update' => ['admin:w', 'assistenz:w'],
'delete' => ['admin:w', 'assistenz:w']
]);
// Load models
$this->load->model('crm/Konto_model', 'KontoModel');
// Load language phrases
$this->loadPhrases([
'konto'
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Get details for a prestudent
*
* @return void
*/
public function get()
{
$this->load->library('form_validation');
$person_id = $this->input->post('person_id');
if (!$person_id || !is_array($person_id)) {
$this->form_validation->set_rules('person_id', 'Person ID', 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$studiengang_kz = $this->input->post('studiengang_kz');
if ($this->input->post('only_open')) {
$result = $this->KontoModel->getOffeneBuchungen($person_id, $studiengang_kz);
} else {
$result = $this->KontoModel->getAlleBuchungen($person_id, $studiengang_kz);
}
$result = $this->getDataOrTerminateWithError($result);
// sort into tree
$childs = [];
$data = [];
foreach ($result as $entry) {
if ($entry->buchungsnr_verweis) {
if (isset($data[$entry->buchungsnr_verweis])) {
if (!isset($data[$entry->buchungsnr_verweis]->_children))
$data[$entry->buchungsnr_verweis]->_children = [];
$data[$entry->buchungsnr_verweis]->_children[] = $entry;
} else {
if (!isset($childs[$entry->buchungsnr_verweis]))
$childs[$entry->buchungsnr_verweis] = [];
$childs[$entry->buchungsnr_verweis][] = $entry;
}
} else {
$data[$entry->buchungsnr] = $entry;
if (isset($childs[$entry->buchungsnr]))
$entry->_children = $childs[$entry->buchungsnr];
}
}
$this->terminateWithSuccess(array_values($data));
}
/**
* Get list of Buchungstypen
*
* @return void
*/
public function getBuchungstypen()
{
$this->load->model('crm/Buchungstyp_model', 'BuchungstypModel');
$result = $this->BuchungstypModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
/**
* Check double Buchungen
*
* @return void
*/
public function checkDoubles()
{
if (!defined('FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK') || !FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK)
$this->terminateWithSuccess(false);
$this->load->library('form_validation');
$person_ids = $this->input->post('person_id');
if (!$person_ids || !is_array($person_ids)) {
$person_ids = [$person_ids];
$this->form_validation->set_rules('person_id', 'Person ID', 'required');
}
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required');
$this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$buchungstypen = unserialize(FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK);
$buchung = $this->input->post('buchungstyp_kurzbz');
if (!isset($buchungstypen[$buchung]))
$this->terminateWithSuccess(false);
$result = $this->KontoModel->checkDoubleBuchung($person_ids, $this->input->post('studiensemester_kurzbz'), $buchungstypen[$buchung]);
$result = $this->getDataOrTerminateWithError($result);
if (!$result)
$this->terminateWithSuccess(false);
$persons = array_map(function ($row) {
return $row->nachname . ' ' . $row->vorname;
}, $result);
$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', 'confirm_overwrite_1_add_pers');
} else {
$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', 'confirm_overwrite_proceed');
$this->addError($result, 'confirm');
$this->terminateWithSuccess(true);
}
/**
* Save Buchung
*
* @return void
*/
public function insert()
{
$this->load->library('form_validation');
$person_ids = $this->input->post('person_id');
if (!$person_ids || !is_array($person_ids)) {
$person_ids = [$person_ids];
$this->form_validation->set_rules('person_id', 'Person ID', 'required');
}
$this->form_validation->set_rules('betrag', 'Betrag', 'numeric');
$this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date');
$this->form_validation->set_rules('buchungstext', 'Buchungstext', 'max_length[256]');
$this->form_validation->set_rules('mahnspanne', 'Mahnspanne', 'integer');
$this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required|max_length[32]');
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required|max_length[16]');
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|has_permissions_for_stg[admin:rw,assistenz:rw]');
$this->form_validation->set_rules('credit_points', 'Credit Points', 'numeric');
Events::trigger('konto_insert_validation', $this->form_validation);
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$allowed = [
'betrag',
'buchungsdatum',
'buchungstext',
'mahnspanne',
'buchungstyp_kurzbz',
'studiensemester_kurzbz',
'studiengang_kz',
'credit_points',
'anmerkung'
];
$data = [
'insertamum' => date('c'),
'insertvon' => getAuthUID()
];
foreach ($allowed as $field)
if ($this->input->post($field) !== null)
$data[$field] = $this->input->post($field);
if (defined('FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE') && isset(unserialize(FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE)[$data['buchungstyp_kurzbz']])) {
$data['kostenstelle'] = unserialize(FAS_BUCHUNGSTYP_FIXE_KOSTENSTELLE)[$data['buchungstyp_kurzbz']];
}
$result = [];
foreach ($person_ids as $person_id) {
$id = $this->KontoModel->insert(array_merge($data, ['person_id' => $person_id]));
if (isError($id)) {
$this->addError(getError($id), self::ERROR_TYPE_DB);
} else {
$data = $this->KontoModel->withAdditionalInfo()->load(getData($id));
if (isError($data))
$this->addError(getError($data), self::ERROR_TYPE_DB);
else
$result[] = current(getData($data));
}
}
if ($result)
$this->terminateWithSuccess($result);
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
/**
* Save Counter Buchung
*
* @return void
*/
public function counter()
{
$this->load->library('form_validation');
$buchungsnrs = $this->input->post('buchungsnr');
if (!$buchungsnrs || !is_array($buchungsnrs)) {
$buchungsnrs = $buchungsnrs ? [$buchungsnrs] : [];
$this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required');
}
$this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$data = [];
$rules = [];
foreach ($buchungsnrs as $k => $buchungsnr) {
$result = $this->KontoModel->load($buchungsnr);
if (isError($result)) {
$rules[] = [
'field' => 'buchung[' . $k . ']',
'label' => 'Buchung #' . $buchungsnr,
'rules' => 'required',
'errors' => [
'required' => getError($result)
]
];
} elseif (!hasData($result)) {
$rules[] = [
'field' => 'buchung[' . $k . ']',
'label' => 'Buchung #' . $buchungsnr,
'rules' => 'required'
];
} else {
$data[$k] = get_object_vars(current(getData($result)));
$rules[] = [
'field' => 'buchung[' . $k . '][buchungsnr]',
'label' => 'Buchung # ' . $buchungsnr,
'rules' => 'required|numeric'
];
$rules[] = [
'field' => 'buchung[' . $k . '][studiengang_kz]',
'label' => 'Buchung # ' . $buchungsnr,
'rules' => 'required|has_permissions_for_stg[admin:rw,assistenz:rw]'
];
$rules[] = [
'field' => 'buchung[' . $k . '][buchungsnr_verweis]',
'label' => 'Buchung # ' . $buchungsnr,
'rules' => 'regex_match[/^$/]',
'errors' => [
'regex_match' => $this->p->t('konto', 'error_counter_level')
]
];
}
}
$this->form_validation->reset_validation();
$this->form_validation->set_data(['buchung' => $data]);
$this->form_validation->set_rules($rules);
Events::trigger('konto_counter_validation', $this->form_validation);
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$buchungsdatum = $this->input->post('buchungsdatum');
$newItems = [];
foreach ($data as $buchung) {
$result = $this->KontoModel->getDifferenz($buchung['buchungsnr']);
if (isError($result)) {
$this->addError(getError($result), self::ERROR_TYPE_GENERAL);
continue;
}
$betrag = $result->retval;
if ($betrag === null) {
$this->addError($this->p->t(
'konto',
'error_missing',
$buchung
), self::ERROR_TYPE_GENERAL);
continue;
}
$result = $this->KontoModel->insert([
'person_id' => $buchung['person_id'],
'studiengang_kz' => $buchung['studiengang_kz'],
'studiensemester_kurzbz' => $buchung['studiensemester_kurzbz'],
'buchungstext' => $buchung['buchungstext'],
'buchungstyp_kurzbz' => $buchung['buchungstyp_kurzbz'],
'credit_points' => $buchung['credit_points'],
'zahlungsreferenz' => $buchung['zahlungsreferenz'],
'betrag' => $betrag,
'buchungsdatum' => $buchungsdatum,
'mahnspanne' => '0',
'buchungsnr_verweis' => $buchung['buchungsnr'],
'insertamum' => date('c'),
'insertvon' => getAuthUID(),
'anmerkung' => ''
]);
if (isError($result)) {
$this->addError(getError($result), self::ERROR_TYPE_GENERAL);
continue;
}
$newItems = null;
// TODO(chris): get as tree?
/*$result = $this->KontoModel->withAdditionalInfo()->load($result->retval);
if (!hasData($result))
$newItems = null;
elseif ($newItems !== null)
$newItems[] = current(getData($result));*/
}
$this->terminateWithSuccess($newItems);
}
/**
* Save Buchung
*
* @return void
*/
public function update()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required');
$this->form_validation->set_rules('betrag', 'Betrag', 'numeric');
$this->form_validation->set_rules('buchungsdatum', 'Buchungsdatum', 'is_valid_date');
$this->form_validation->set_rules('buchungstext', 'Buchungstext', 'max_length[256]');
$this->form_validation->set_rules('mahnspanne', 'Mahnspanne', 'integer');
$this->form_validation->set_rules('buchungstyp_kurzbz', 'Buchungstyp', 'required|max_length[32]');
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required|max_length[16]');
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required|has_permissions_for_stg[admin:rw,assistenz:rw]');
$this->form_validation->set_rules('credit_points', 'Credit Points', 'numeric');
Events::trigger('konto_update_validation', $this->form_validation);
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$id = $this->input->post('buchungsnr');
$allowed = [
'betrag',
'buchungsdatum',
'buchungstext',
'mahnspanne',
'buchungstyp_kurzbz',
'studiensemester_kurzbz',
'studiengang_kz',
'credit_points',
'anmerkung'
];
$data = [
'updateamum' => date('c'),
'updatevon' => getAuthUID()
];
foreach ($allowed as $field)
if ($this->input->post($field) !== null)
$data[$field] = $this->input->post($field);
$result = $this->KontoModel->update($id, $data);
$this->getDataOrTerminateWithError($result);
$result = null;
// TODO(chris): get as tree?
/*$result = $this->KontoModel->withAdditionalInfo()->load($id);
#$result = $this->getDataOrTerminateWithError($result);
if (isError($result))
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$result = $result->retval;*/
$this->terminateWithSuccess($result);
}
/**
* Delete Buchung
*
* @return void
*/
public function delete()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('buchungsnr', 'Buchungsnr', 'required');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$buchungsnr = $this->input->post('buchungsnr');
$result = $this->KontoModel->load($buchungsnr);
$result = $this->getDataOrTerminateWithError($result);
if (!$result)
$this->terminateWithError($this->p->t('konto', 'error_missing', [
'buchungsnr' => $buchungsnr
]));
$_POST['studiengang_kz'] = current($result)->studiengang_kz;
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'has_permissions_for_stg[admin:rw,assistenz:rw]');
Events::trigger('konto_delete_validation', $this->form_validation);
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
Events::trigger('konto_delete', $buchungsnr);
$result = $this->KontoModel->delete($buchungsnr);
if (isError($result)) {
if (getCode($result) != 42)
$this->terminateWithError(getError($result));
$this->terminateWithError($this->p->t('konto', 'error_delete_level'));
}
$this->terminateWithSuccess();
}
}
@@ -0,0 +1,147 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
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 generally used lists
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Lists extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'getStudiensemester' => self::PERM_LOGGED,
'getStgs' => self::PERM_LOGGED,
'getSprachen' => self::PERM_LOGGED,
'getGeschlechter' => self::PERM_LOGGED,
'getAusbildungen' => self::PERM_LOGGED,
'getOrgforms' => self::PERM_LOGGED,
'getStati' => self::PERM_LOGGED
]);
}
public function getStudiensemester()
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->StudiensemesterModel->addOrder('ende');
$result = $this->StudiensemesterModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getStgs()
{
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->StudiengangModel->addSelect('*');
$this->StudiengangModel->addSelect('UPPER(typ || kurzbz) AS kuerzel');
$this->StudiengangModel->addOrder('typ');
$this->StudiengangModel->addOrder('kurzbz');
$result = $this->StudiengangModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getSprachen()
{
$this->load->model('system/Sprache_model', 'SpracheModel');
$this->SpracheModel->addOrder('sprache');
$result = $this->SpracheModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getGeschlechter()
{
$this->load->model('person/Geschlecht_model', 'GeschlechtModel');
$this->GeschlechtModel->addOrder('sort');
$this->GeschlechtModel->addOrder('geschlecht');
$this->GeschlechtModel->addSelect('*');
#$this->GeschlechtModel->addTranslatedSelect("bezeichnung_mehrsprachig", "bezeichnung");
$this->GeschlechtModel->addSelect("bezeichnung_mehrsprachig[(SELECT index FROM public.tbl_sprache WHERE sprache=" . $this->GeschlechtModel->escape(DEFAULT_LANGUAGE) . " LIMIT 1)] AS bezeichnung");
$result = $this->GeschlechtModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getAusbildungen()
{
$this->load->model('codex/Ausbildung_model', 'AusbildungModel');
$this->AusbildungModel->addOrder('ausbildungcode');
$result = $this->AusbildungModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getOrgforms()
{
$this->load->model('codex/Orgform_model', 'OrgformModel');
$this->OrgformModel->addOrder('bezeichnung');
$result = $this->OrgformModel->loadWhere(['rolle' => true]);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getStati()
{
$lang = getUserLanguage();
$this->load->model('crm/Status_model', 'StatusModel');
$this->StatusModel->addSelect('*');
#$this->StatusModel->addTranslatedSelect('bezeichnung_mehrsprachig', 'bezeichnung');
$this->StatusModel->addSelect(
'bezeichnung_mehrsprachig[(
SELECT index
FROM public.tbl_sprache
WHERE sprache=' . $this->StatusModel->escape($lang) . '
LIMIT 1
)] AS bezeichnung',
false
);
#$this->StatusModel->addOrder('ext_id');
$result = $this->StatusModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
}
@@ -0,0 +1,384 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
class Notiz extends Notiz_Controller
{
public function __construct()
{
parent::__construct([
'getUid' => ['admin:r', 'assistenz:r'],
'getNotizen' => ['admin:r', 'assistenz:r'],
'loadNotiz' => ['admin:r', 'assistenz:r'], // TODO(manu): self::PERM_LOGGED
'addNewNotiz' => ['admin:rw', 'assistenz:rw'], // TODO(manu): self::PERM_LOGGED
'updateNotiz' => ['admin:rw', 'assistenz:rw'], // TODO(manu): self::PERM_LOGGED
'deleteNotiz' => ['admin:r', 'assistenz:r'],
'loadDokumente' => ['admin:r', 'assistenz:r'],
'getMitarbeiter' => ['admin:r', 'assistenz:r']
]);
//Load Models
$this->load->model('person/Notiz_model', 'NotizModel');
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
// Load language phrases
$this->loadPhrases([
'ui'
]);
}
/* public function getUid()
{
$this->terminateWithSuccess(getAuthUID());
}*/
public function getNotizen($id, $type)
{
//check if valid type
$result = $this->NotizzuordnungModel->isValidType($type);
if(isError($result))
$this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL);
//$this->terminateWithError(" after check type not valid", self::ERROR_TYPE_GENERAL);
$result = $this->NotizModel->getNotizWithDocEntries($id, $type);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
// return $this->terminateWithError("type not valid", self::ERROR_TYPE_GENERAL);
}
/* public function loadNotiz()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
//$this->load->model('person/Notiz_model', 'NotizModel');
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT');
$this->NotizModel->addSelect('*');
$this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum
THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate");
$this->NotizModel->addLimit(1);
$result = $this->NotizModel->loadWhere(
array('notiz_id' => $notiz_id)
);
if (isError($result))
{
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
else
{
$this->terminateWithSuccess(current(getData($result)));
}
}
public function updateNotiz()
{
$this->load->library('form_validation');
$this->load->library('DmsLib');
if (isset($_POST['data']))
{
$data = json_decode($_POST['data']);
unset($_POST['data']);
foreach ($data as $k => $v) {
$_POST[$k] = $v;
}
}
$notiz_id = $this->input->post('notiz_id');
if(!$notiz_id)
{
$this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
//Form Validation
$this->form_validation->set_rules('titel', 'Titel', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
]);
$this->form_validation->set_rules('text', 'Text', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
//update Notiz
$uid = getAuthUID();
$titel = $this->input->post('titel');
$text = $this->input->post('text');
$verfasser_uid = $this->input->post('verfasser');
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
$erledigt = $this->input->post('erledigt');
$start = $this->input->post('start');
$ende = $this->input->post('ende');
$result = $this->NotizModel->update(
[
'notiz_id' => $notiz_id
],
[
'titel' => $titel,
'updatevon' => $uid,
'updateamum' => date('c'),
'text' => $text,
'verfasser_uid' => $verfasser_uid,
'bearbeiter_uid' => $bearbeiter_uid,
'start' => $start,
'ende' => $ende,
'erledigt' => $erledigt
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
//update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
$this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id');
$dms_uploaded = null;
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
$dms_id_arr = null;
}
else
{
$result = getData($result);
foreach($result as $doc) {
$dms_id_arr[] = array(
'name' => $doc->name,
'dms_id' => $doc->dms_id
);
}
}
foreach ($_FILES as $k => $file)
{
//update(2) alle neuen files (alle außer type application/x.fhc-dms+json) anhängen
if($file["type"] == 'application/x.fhc-dms+json')
{
$dms_uploaded[] = array(
'name' => $file["name"]
);
}
else
{
$dms = array(
'kategorie_kurzbz' => 'notiz',
'version' => 0,
'name' => $file["name"],
'mimetype' => $file["type"],
'insertamum' => date('c'),
'insertvon' => $uid
);
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
$result = $this->dmslib->upload($dms, $k, array('*'));
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$dms_id = $result->retval['dms_id'];
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
}
}
//update(3) check if Dateien gelöscht wurden
if(count($dms_uploaded) != count($dms_id_arr))
{
if (count($dms_uploaded) == 0)
{
$filesDeleted = $dms_id_arr;
}
else
{
$upload_new_names = array_column($dms_uploaded, "name");
$filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) {
return !in_array($file["name"], $upload_new_names);
});
}
foreach ($filesDeleted as $file)
{
$result = $this->dmslib->removeAll($file['dms_id']);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
else
$this->outputJson($result);
}
}
return $this->terminateWithSuccess($result);
}*/
/* public function deleteNotiz()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
$type = $this->input->post('type_id');
$id = $this->input->post('id');
//dms_id auslesen aus notizdokument wenn vorhanden
$dms_id_arr = [];
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
if(hasData($result))
{
$result = getData($result);
foreach ($result as $doc) {
$dms_id_arr[] = $doc->dms_id;
}
}
if($dms_id_arr)
{
$this->load->library('DmsLib');
foreach($dms_id_arr as $dms_id)
{
$result = $this->dmslib->removeAll($dms_id);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->outputJson($result);
}
}
//delete Notizzuordnung
if($type == "software_id")
{
// Loads extension Model
$this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel');
$result = $this->ExtensionnotizzuordnungModel->delete([
'notiz_id' => $notiz_id,
'id' => strval($id)
],
[
'type_id' => $type
]);
}
else
{
//notizzuordnungsid!
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
}
$this->load->model('person/Notiz_model', 'NotizModel');
//$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
//TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann
//Löschen von Notiz
$result = $this->NotizModel->delete(
array('notiz_id' => $notiz_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if(!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(current(getData($result)));
}*/
/* public function loadDokumente()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
$this->NotizModel->addSelect('campus.tbl_dms_version.*');
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)');
$this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)');
$result = $this->NotizModel->loadWhere(
array('public.tbl_notiz.notiz_id' => $notiz_id)
);
if (isError($result)) {
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if(!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result));
}*/
/* public function getMitarbeiter($searchString)
{
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString);
if (isError($result)) {
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess($result);
}*/
public function isBerechtigt($id, $typeId)
{
if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid'))
{
$result = $this->p->t('lehre','error_keineSchreibrechte');
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return success("berechtigt in überschreibender Funktion");
/* return $this->terminateWithError('keine Berechtigung bro', self::ERROR_TYPE_GENERAL);*/
}
}
@@ -0,0 +1,299 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
class Prestudent extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'get' => ['admin:r', 'assistenz:r'],
'updatePrestudent' => ['admin:rw', 'assistenz:rw'],
'getHistoryPrestudents' => ['admin:r', 'assistenz:r'],
'getBezeichnungZGV' => ['admin:r', 'assistenz:r'],
'getBezeichnungDZgv' => ['admin:r', 'assistenz:r'],
'getBezeichnungMZgv' => ['admin:r', 'assistenz:r'],
'getAusbildung' => ['admin:r', 'assistenz:r'],
'getAufmerksamdurch' => ['admin:r', 'assistenz:r'],
'getBerufstaetigkeit' => ['admin:r', 'assistenz:r'],
'getTypenStg' => ['admin:r', 'assistenz:r'],
'getStudienplaene' => ['admin:r', 'assistenz:r'],
'getStudiengang' => ['admin:r', 'assistenz:r']
]);
if ($this->router->method == 'updatePrestudent') {
$prestudent_id = current(array_slice($this->uri->rsegments, 2));
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:rw', 'assistenz:rw']);
} elseif ($this->router->method == 'get'
|| $this->router->method == 'getStudienplaene'
|| $this->router->method == 'getStudiengang'
) {
$prestudent_id = current(array_slice($this->uri->rsegments, 2));
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:r', 'assistenz:r']);
} elseif ($this->router->method == 'getHistoryPrestudents') {
$person_id = current(array_slice($this->uri->rsegments, 2));
$this->checkPermissionsForPerson($person_id, ['admin:r', 'assistenz:r'], ['admin:r', 'assistenz:r']);
}
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
// Load language phrases
$this->loadPhrases([
'ui', 'studierendenantrag', 'lehre'
]);
}
public function get($prestudent_id)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->PrestudentModel->addSelect('*');
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
if(!hasData($result))
{
return show_404();
}
$this->terminateWithSuccess(current(getData($result)));
}
public function updatePrestudent($prestudent_id)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
// UDF
$this->load->library('UDFLib');
$result = $this->udflib->getCiValidations($this->PrestudentModel, $this->input->post());
$udf_field_validations = $this->getDataOrTerminateWithError($result);
//Form validation
$this->load->library('form_validation');
$this->form_validation->set_rules($udf_field_validations);
$this->form_validation->set_rules('priorisierung', 'Priorisierung', 'numeric', [
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Priorisierung'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$uid = getAuthUID();
$array_allowed_props_prestudent = [
'aufmerksamdurch_kurzbz',
'studiengang_kz',
'gsstudientyp_kurzbz',
'person_id',
'berufstaetigkeit_code',
'ausbildungcode',
'zgv_code',
'zgvort',
'zgvdatum',
'zgvnation',
'zgvmas_code',
'zgvmaort',
'zgvmadatum',
'zgvmanation',
'facheinschlberuf',
'bismelden',
'anmerkung',
'dual',
'zgvdoktor_code',
'zgvdoktorort',
'zgvdoktordatum',
'zgvdoktornation',
'aufnahmegruppe_kurzbz',
'priorisierung',
'foerderrelevant',
'zgv_erfuellt',
'zgvmas_erfuellt',
'zgvdoktor_erfuellt',
'mentor',
'aufnahmeschluessel',
'standort_code'
];
// add UDFs
$result = $this->udflib->getDefinitionForModel($this->PrestudentModel);
$definitions = $this->getDataOrTerminateWithError($result);
foreach ($definitions as $def)
$array_allowed_props_prestudent[] = $def['name'];
$update_prestudent = array();
foreach ($array_allowed_props_prestudent as $prop)
{
$val = $this->input->post($prop);
if ($val !== null || $prop == 'foerderrelevant') {
$update_prestudent[$prop] = $val;
}
}
$update_prestudent['updateamum'] = date('c');
$update_prestudent['updatevon'] = $uid;
if (count($update_prestudent))
{
$result = $this->PrestudentModel->update(
$prestudent_id,
$update_prestudent
);
$this->getDataOrTerminateWithError($result);
return $this->terminateWithSuccess(true);
}
return $this->terminateWithSuccess(false);
}
public function getHistoryPrestudents($person_id)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$result = $this->PrestudentModel->getHistoryPrestudents($person_id);
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess(getData($result) ?: []);
}
public function getBezeichnungZGV()
{
$this->load->model('codex/Zgv_model', 'ZgvModel');
$this->ZgvModel->addOrder('zgv_code');
$result = $this->ZgvModel->load();
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
public function getBezeichnungDZgv()
{
$this->load->model('codex/Zgvdoktor_model', 'ZgvdoktorModel');
$this->ZgvdoktorModel->addOrder('zgvdoktor_code');
$result = $this->ZgvdoktorModel->load();
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
public function getBezeichnungMZgv()
{
$this->load->model('codex/Zgvmaster_model', 'ZgvmasterModel');
$this->ZgvmasterModel->addOrder('zgvmas_code');
$result = $this->ZgvmasterModel->load();
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
public function getAusbildung()
{
$this->load->model('codex/Ausbildung_model', 'AusbildungModel');
$this->AusbildungModel->addOrder('ausbildungcode');
$result = $this->AusbildungModel->load();
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
public function getAufmerksamdurch()
{
$this->load->model('codex/Aufmerksamdurch_model', 'AufmerksamdurchModel');
$this->AufmerksamdurchModel->addOrder('aufmerksamdurch_kurzbz');
$result = $this->AufmerksamdurchModel->load();
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
public function getBerufstaetigkeit()
{
$this->load->model('codex/Berufstaetigkeit_model', 'BerufstaetigkeitModel');
$this->BerufstaetigkeitModel->addOrder('berufstaetigkeit_code');
$result = $this->BerufstaetigkeitModel->load();
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
public function getTypenStg()
{
$this->load->model('education/Gsstudientyp_model', 'GsstudientypModel');
$this->GsstudientypModel->addOrder('gsstudientyp_kurzbz');
$result = $this->GsstudientypModel->load();
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
public function getStudienplaene($prestudent_id)
{
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
$result = $this->StudienplanModel->getStudienplaeneByPrestudents($prestudent_id);
$data = $this->getDataOrTerminateWithError($result);
return $this->terminateWithSuccess($data);
}
/**
* Gets details for the Studiengang of the Prestudent
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function getStudiengang($prestudent_id)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->PrestudentModel->addSelect('stg.*');
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz');
$result = $this->PrestudentModel->load($prestudent_id);
$stg = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess(current($stg));
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,562 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
/**
* This controller operates between (interface) the JS (GUI) and the back-end
* Provides data to the ajax get calls about a Student
* Listens to ajax post calls to change the Student data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Student extends FHCAPI_Controller
{
/**
* Calls the parent's constructor and prepares libraries and phrases
*/
public function __construct()
{
parent::__construct([
'get' => ['admin:r', 'assistenz:r'],
'save' => ['admin:rw', 'assistenz:rw'],
'check' => ['admin:rw', 'assistenz:rw'],
'add' => ['admin:rw', 'assistenz:rw'] // TODO(chris): extra permissions
]);
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
if ($this->router->method == 'get'
|| $this->router->method == 'save'
) {
$prestudent_id = current(array_slice($this->uri->rsegments, 2));
if ($this->router->method == 'get')
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:r', 'assistenz:r']);
else
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:rw', 'assistenz:rw']);
}
// Load language phrases
$this->loadPhrases([
'ui'
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Get details for a prestudent
*
* @param string $prestudent_id
* @return void
*/
public function get($prestudent_id)
{
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->PrestudentModel->addSelect('p.*');
$this->PrestudentModel->addSelect('s.student_uid');
$this->PrestudentModel->addSelect('matrikelnr');
$this->PrestudentModel->addSelect('b.aktiv');
$this->PrestudentModel->addSelect('v.semester');
$this->PrestudentModel->addSelect('v.verband');
$this->PrestudentModel->addSelect('v.gruppe');
$this->PrestudentModel->addSelect('b.alias');
if (defined('ACTIVE_ADDONS') && strpos(ACTIVE_ADDONS, 'bewerbung') !== false) {
$this->PrestudentModel->addSelect(
"(
SELECT kontakt
FROM public.tbl_kontakt
WHERE kontakttyp='email'
AND person_id=p.person_id
AND zustellung
ORDER BY kontakt_id
LIMIT 1
) AS email_privat",
false
);
}
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 'student_uid = uid', 'LEFT');
$this->PrestudentModel->addJoin(
'public.tbl_studentlehrverband v',
'b.uid = v.student_uid AND v.studiensemester_kurzbz = ' . $this->PrestudentModel->escape($studiensemester_kurzbz),
'LEFT'
);
$this->PrestudentModel->addJoin('public.tbl_person p', 'p.person_id = tbl_prestudent.person_id');
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
$student = $this->getDataOrTerminateWithError($result);
if (!$student)
return show_404();
$this->terminateWithSuccess(current($student));
}
/**
* Saves data to a prestudent
*
* @param string $prestudent_id
* @return void
*/
public function save($prestudent_id)
{
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
$this->load->model('person/Person_model', 'PersonModel');
$this->load->model('crm/Student_model', 'StudentModel');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
$this->load->library('form_validation');
$this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date');
$this->form_validation->set_rules('semester', 'Semester', 'integer');
$this->load->library('UDFLib');
$result = $this->udflib->getCiValidations($this->PersonModel, $this->input->post());
//TODO(Manu) check with Chris: input number not allowed
$udf_field_validations = $this->getDataOrTerminateWithError($result);
$this->form_validation->set_rules($udf_field_validations);
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$result = $this->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
$student = $this->getDataOrTerminateWithError($result);
$uid = $student ? current($student)->student_uid : null;
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
$person = $this->getDataOrTerminateWithError($result);
$person_id = $person ? current($person)->person_id : null;
$array_allowed_props_lehrverband = ['verband', 'semester', 'gruppe'];
$update_lehrverband = array();
foreach ($array_allowed_props_lehrverband as $prop) {
$val = $this->input->post($prop);
if ($val !== null) {
$update_lehrverband[$prop] = $val;
}
}
$array_allowed_props_person = [
'anrede',
'bpk',
'titelpre',
'titelpost',
'nachname',
'vorname',
'vornamen',
'wahlname',
'gebdatum',
'gebort',
'geburtsnation',
'svnr',
'ersatzkennzeichen',
'staatsbuergerschaft',
'matr_nr',
'sprache',
'geschlecht',
'familienstand',
'foto',
'anmerkung',
'homepage'
];
// add UDFs
$result = $this->udflib->getDefinitionForModel($this->PersonModel);
$definitions = $this->getDataOrTerminateWithError($result);
foreach ($definitions as $def)
$array_allowed_props_person[] = $def['name'];
$update_person = array();
foreach ($array_allowed_props_person as $prop) {
$val = $this->input->post($prop);
if ($val !== null) {
$update_person[$prop] = $val;
}
}
$array_allowed_props_student = ['matrikelnr'];
$update_student = array();
foreach ($array_allowed_props_student as $prop) {
$val = $this->input->post($prop);
if ($val !== null) {
$update_student[$prop] = $val;
}
}
// Check PKs
if (count($update_lehrverband) + count($update_student) && $uid === null) {
// TODO(chris): phrase
$this->terminateWithValidationErrors(['' => "Kein/e StudentIn vorhanden!"]);
}
if (count($update_person) && $person_id === null) {
// TODO(chris): phrase
$this->terminateWithValidationErrors(['' => "Keine Person vorhanden!"]);
}
// Do Updates
if (count($update_lehrverband)) {
$result = $this->StudentlehrverbandModel->update([
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'student_uid' => $uid
], $update_lehrverband);
$this->getDataOrTerminateWithError($result);
}
if (count($update_person)) {
$result = $this->PersonModel->update(
$person_id,
$update_person
);
$this->getDataOrTerminateWithError($result);
}
if (count($update_student)) {
$result = $this->StudentModel->update(
[$uid],
$update_student
);
$this->getDataOrTerminateWithError($result);
}
$this->terminateWithSuccess(array_fill_keys(array_merge(
array_keys($update_lehrverband),
array_keys($update_person),
array_keys($update_student)
), ''));
}
public function check()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$vorname = $this->input->post('vorname');
$nachname = $this->input->post('nachname');
$gebdatum = $this->input->post('gebdatum');
if (!$vorname && !$nachname && !$gebdatum)
$this->terminateWithValidationErrors(['At least one of vorname, nachname or gebdatum must be set']);
$this->load->model('person/Person_model', 'PersonModel');
if ($gebdatum)
$this->PersonModel->db->where('gebdatum', (new DateTime($gebdatum))->format('Y-m-d'));
if ($vorname && $nachname) {
$this->PersonModel->db->or_group_start();
$this->PersonModel->db->where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->db->escape($nachname) . ')', false);
$this->PersonModel->db->where('LOWER(vorname)', 'LOWER(' . $this->PersonModel->db->escape($vorname) . ')', false);
$this->PersonModel->db->group_end();
} elseif ($nachname) {
$this->PersonModel->db->or_where('LOWER(nachname)', 'LOWER(' . $this->PersonModel->escape($nachname) . ')', false);
}
$result = $this->PersonModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function add()
{
if (!$this->input->post('person_id')) {
if (!isset($_POST['address']) || !is_array($_POST['address']))
$_POST['address'] = [];
$_POST['address']['func'] = 1;
}
if ($this->input->post('incoming')) {
$_POST['ausbildungssemester'] = 0;
}
$this->load->library('form_validation');
$this->form_validation->set_rules('nachname', 'Nachname', 'callback_requiredIfNotPersonId', [
'requiredIfNotPersonId' => $this->p->t('ui', 'error_required')
]);
$this->form_validation->set_rules('geschlecht', 'Geschlecht', 'callback_requiredIfNotPersonId', [
'requiredIfNotPersonId' => $this->p->t('ui', 'error_required')
]);
$this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'callback_isValidDate', [
'isValidDate' => $this->p->t('ui', 'error_invalid_date')
]);
$this->form_validation->set_rules('address[func]', 'Address', 'required|integer|less_than[2]|greater_than[-2]');
$this->form_validation->set_rules('address[plz]', 'PLZ', 'callback_requiredIfAddressFunc', [
'requiredIfAddressFunc' => $this->p->t('ui', 'error_required')
]);
$this->form_validation->set_rules('address[gemeinde]', 'Gemeinde', 'callback_requiredIfAddressFunc', [
'requiredIfAddressFunc' => $this->p->t('ui', 'error_required')
]);
$this->form_validation->set_rules('address[ort]', 'Ort', 'callback_requiredIfAddressFunc', [
'requiredIfAddressFunc' => $this->p->t('ui', 'error_required')
]);
$this->form_validation->set_rules('address[address]', 'Adresse', 'callback_requiredIfAddressFunc', [
'requiredIfAddressFunc' => $this->p->t('ui', 'error_required')
]);
$this->form_validation->set_rules('email', 'E-Mail', 'valid_email');
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'required');
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required');
$this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'required|integer|less_than[9]|greater_than[-1]');
// TODO(chris): validate studienplan with studiengang, semester and orgform?
// TODO(chris): validate person_id, studiengang_kz, studiensemester_kurzbz, orgform_kurzbz, nation, gemeinde, ort, geschlecht?
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
// TODO(chris): This should be in a library
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
$this->db->trans_start();
$result = $this->addInteressent();
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE)
$this->terminateWithError('TODO(chris): TEXT', self::ERROR_TYPE_GENERAL);
$this->terminateWithSuccess($result);
}
protected function addInteressent()
{
// Person anlegen wenn nötig
$person_id = $this->input->post('person_id');
if (!$person_id) {
$this->load->model('person/Person_model', 'PersonModel');
$data = [
'nachname' => $this->input->post('nachname'),
'insertamum' => date('c'),
'insertvon' => getAuthUID(),
'zugangscode' => uniqid(),
'aktiv' => true
];
if ($this->input->post('anrede'))
$data['anrede'] = $this->input->post('anrede');
if ($this->input->post('titelpre'))
$data['titelpre'] = $this->input->post('titelpre');
if ($this->input->post('titelpost'))
$data['titelpost'] = $this->input->post('titelpost');
if ($this->input->post('vorname'))
$data['vorname'] = $this->input->post('vorname');
if ($this->input->post('vornamen'))
$data['vornamen'] = $this->input->post('vornamen');
if ($this->input->post('wahlname'))
$data['wahlname'] = $this->input->post('wahlname');
if ($this->input->post('geschlecht'))
$data['geschlecht'] = $this->input->post('geschlecht');
if ($this->input->post('gebdatum'))
$data['gebdatum'] = (new DateTime($this->input->post('datum_obj')))->format('Y-m-d');
if ($this->input->post('geburtsnation'))
$data['geburtsnation'] = $this->input->post('geburtsnation');
if ($this->input->post('staatsbuergerschaft'))
$data['staatsbuergerschaft'] = $this->input->post('staatsbuergerschaft');
$result = $this->PersonModel->insert($data);
$person_id = $this->getDataOrTerminateWithError($result);
}
// Addresse anlegen
$anlegen = $this->input->post('address[func]');
if ($anlegen) {
$this->load->model('person/Adresse_model', 'AdresseModel');
$data = [
'nation' => $this->input->post('address[nation]'),
'strasse' => $this->input->post('address[address]'),
'plz' => $this->input->post('address[plz]'),
'ort' => $this->input->post('address[ort]'),
'gemeinde' => $this->input->post('address[gemeinde]'),
'typ' => 'h',
'zustelladresse' => true,
];
if ($anlegen < 0) { // Überschreiben
$this->AdresseModel->addOrder('zustelladresse', 'DESC');
$this->AdresseModel->addOrder('sort');
$result = $this->AdresseModel->loadWhere([
'person_id' => $person_id
]);
$address = $this->getDataOrTerminateWithError($result);
if ($address) {
$address = current($address);
$data['updateamum'] = date('c');
$data['updatevon'] = getAuthUID();
$result = $this->AdresseModel->update($address->adresse_id, $data);
$this->getDataOrTerminateWithError($result);
} else {
//Wenn keine Adrese vorhanden ist dann eine neue Anlegen
$anlegen = 1;
$data['heimatadresse'] = true;
}
}
if ($anlegen > 0) {
$data['person_id'] = $person_id;
$data['insertamum'] = date('c');
$data['insertvon'] = getAuthUID();
if (!isset($data['heimatadresse']))
$data['heimatadresse'] = !$this->input->post('person_id');
$result = $this->AdresseModel->insert($data);
$this->getDataOrTerminateWithError($result);
}
}
// Kontaktdaten
$kontaktdaten = [];
foreach (['email', 'telefon', 'mobil'] as $k) {
$v = $this->input->post($k);
if ($v)
$kontaktdaten[$k] = $v;
}
if (count($kontaktdaten)) {
$this->load->model('person/Kontakt_model', 'KontaktModel');
foreach ($kontaktdaten as $typ => $kontakt) {
$data = [
'person_id' => $person_id,
'kontakttyp' => $typ,
'kontakt' => $kontakt,
'zustellung' => true,
'insertamum' => date('c'),
'insertvon' => getAuthUID()
];
$result = $this->KontaktModel->insert($data);
$this->getDataOrTerminateWithError($result);
}
}
// Prestudent anlegen
$data = [
'aufmerksamdurch_kurzbz' => 'k.A.',
'person_id' => $person_id,
'studiengang_kz' => $this->input->post('studiengang_kz'),
'ausbildungcode' => $this->input->post('letzteausbildung'),
'anmerkung' => $this->input->post('anmerkungen'),
'reihungstestangetreten' => false,
'bismelden' => true
];
$ausbildungsart = $this->input->post('ausbildungsart');
if ($ausbildungsart)
$data['anmerkung'] .= ' Ausbildungsart:' . $ausbildungsart;
// Incomings und ausserordentliche sind bei Meldung nicht förderrelevant
$incoming = $this->input->post('incoming');
if ($incoming || substr($data['studiengang_kz'], 0, 1) == '9')
$data['foerderrelevant'] = false;
// Wenn die Person schon im System erfasst ist, dann die ZGV des Datensatzes uebernehmen
$this->PrestudentModel->addOrder('zgvmas_code');
$this->PrestudentModel->addOrder('zgv_code', 'DESC');
$this->PrestudentModel->addLimit(1);
$result = $this->PrestudentModel->loadWhere([
'person_id' => $person_id
]);
$prestudent = $this->getDataOrTerminateWithError($result);
if ($prestudent) {
$prestudent = current($prestudent);
if ($prestudent->zgv_code) {
$data['zgv_code'] = $prestudent->zgv_code;
$data['zgvort'] = $prestudent->zgvort;
$data['zgvdatum'] = $prestudent->zgvdatum;
$data['zgvmas_code'] = $prestudent->zgvmas_code;
$data['zgvmaort'] = $prestudent->zgvmaort;
$data['zgvmadatum'] = $prestudent->zgvmadatum;
}
}
// Prestudent speichern
$result = $this->PrestudentModel->insert($data);
$prestudent_id = $this->getDataOrTerminateWithError($result);
// Prestudent Rolle Anlegen
$data = [
'prestudent_id' => $prestudent_id,
'status_kurzbz' => $incoming ? 'Incoming' : 'Interessent',
'studiensemester_kurzbz' => $this->input->post('studiensemester_kurzbz'),
'ausbildungssemester' => $this->input->post('ausbildungssemester') ?: 0,
'orgform_kurzbz' => $this->input->post('orgform_kurzbz') ?: null,
'studienplan_id' => $this->input->post('studienplan_id') ?: null,
'datum' => date('Y-m-d'),
'insertamum' => date('c'),
'insertvon' => getAuthUID()
];
$result = $this->PrestudentstatusModel->insert($data);
$this->getDataOrTerminateWithError($result);
if ($incoming) {
// TODO(chris): IMPLEMENT!
//Matrikelnummer und UID generieren
//Benutzerdatensatz anlegen
//Studentendatensatz anlegen
//StudentLehrverband anlegen
}
// TODO(chris): DEBUG
/*$result = $this->PrestudentModel->loadWhere([
'pestudent_id' => 1
]);
if (isError($result)) {
return $result;
}*/
$this->terminateWithSuccess(true);
}
public function requiredIfNotPersonId($value)
{
if (isset($_POST['person_id']))
return true;
return !!$value;
}
public function requiredIfAddressFunc($value)
{
if (!$_POST['address']['func'])
return true;
return !!$value;
}
}
@@ -0,0 +1,743 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
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 listing students
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Students extends FHCAPI_Controller
{
private $allowedStgs = [];
public function __construct()
{
$permissions = [];
$router = load_class('Router');
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
parent::__construct($permissions);
$this->allowedStgs = $this->permissionlib->getSTG_isEntitledFor('admin') ?: [];
$this->allowedStgs = array_merge($this->allowedStgs, $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []);
if (!$this->allowedStgs) {
$this->_outputAuthError([$router->method => ['admin:r', 'assistenz:r']]);
exit;
}
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
}
/**
* Remap calls:
* / => return []
* /inout => return []
* /inout/incoming => getIncoming
* /inout/outgoing => getOutgoing
* /inout/gemeinsamestudien => getGemeinsamestudien
* /(studiengang_kz) => getStudents
* /(studiengang_kz)/prestudent => getPrestudents
* /(studiengang_kz)/prestudent/* => getPrestudents
* /(studiengang_kz)/(semester) => getStudents
* /(studiengang_kz)/(semester)/grp/(gruppe_kurzbz) => getStudents
* /(studiengang_kz)/(semester)/(verband) => getStudents
* /(studiengang_kz)/(semester)/(verband)/(gruppe) => getStudents
* /(studiengang_kz)/(org_form) => getStudents
* /(studiengang_kz)/(org_form)/prestudent => getPrestudents
* /(studiengang_kz)/(org_form)/prestudent/* => getPrestudents
* /(studiengang_kz)/(org_form)/(semester) => getStudents
* /(studiengang_kz)/(org_form)/(semester)/grp/(gruppe_kurzbz)
* => getStudents
* /(studiengang_kz)/(org_form)/(semester)/(verband) => getStudents
* /(studiengang_kz)/(org_form)/(semester)/(verband)/(gruppe)
* => getStudents
* /uid/(student_uid) => getStudent
* /prestudent/(prestudent_id) => getPrestudent
* /person/(person_id) => getPerson
*
* @param string $method
* @param array $params (optional)
*
* @return void
*/
public function _remap($method, $params = [])
{
if ($method == '' || $method == 'index')
return $this->terminateWithSuccess([]);
if ($method == 'inout') {
if (!count($params))
return $this->terminateWithSuccess([]);
switch ($params[0]) {
case 'incoming':
return $this->getIncoming();
case 'outgoing':
return $this->getOutgoing();
case 'gemeinsamestudien':
return $this->getGemeinsamestudien();
default:
return show_404();
}
}
$count = count($params);
if (!$count)
return $this->getStudents($method);
if ($method == 'uid' && $count == 1)
return $this->getStudent($params[0]);
if ($method == 'prestudent' && $count == 1)
return $this->getPrestudent($params[0]);
if ($method == 'person' && $count == 1)
return $this->getPerson($params[0]);
if (is_numeric($params[0])) {
$sem = $params[0];
if ($count == 3 && $params[1] == 'grp') {
$g = $params[2];
$ver = null;
$grp = null;
} else {
$g = null;
$ver = $count > 1 ? $params[1] : null;
$grp = $count > 2 ? $params[2] : null;
}
return $this->getStudents($method, $sem, $ver, $grp, $g);
} elseif ($params[0] == 'prestudent') {
if ($count == 1)
return $this->getPrestudents($method);
if ($count == 2)
return $this->getPrestudents($method, $params[1]);
return $this->getPrestudents($method, $params[1], $params[$count-1]);
} else {
$org = $params[0];
if ($count > 1 && $params[1] == 'prestudent') {
if ($count == 2)
return $this->getPrestudents($method, null, null, $org);
if ($count == 3)
return $this->getPrestudents($method, $params[2], null, $org);
return $this->getPrestudents($method, $params[2], $params[$count-1], $org);
}
$sem = $count > 1 ? $params[1] : null;
if ($count == 4 && $params[2] == 'grp') {
$g = $params[3];
$ver = null;
$grp = null;
} else {
$g = null;
$ver = $count > 2 ? $params[2] : null;
$grp = $count > 3 ? $params[3] : null;
}
return $this->getStudents($method, $sem, $ver, $grp, $g, $org);
}
show_404();
}
/**
* @return void
*/
protected function getIncoming()
{
// TODO(chris): IMPLEMENT!
$this->terminateWithSuccess([]);
}
/**
* @return void
*/
protected function getOutgoing()
{
// TODO(chris): IMPLEMENT!
$this->terminateWithSuccess([]);
}
/**
* @return void
*/
protected function getGemeinsamestudien()
{
// TODO(chris): IMPLEMENT!
$this->terminateWithSuccess([]);
}
/**
* @param integer $studiengang_kz
* @param string $studiensemester_kurzbz (optional)
* @param string $filter (optional)
* @param string $orgform_kurzbz (optional)
*
* @return void
*/
protected function getPrestudents($studiengang_kz, $studiensemester_kurzbz = null, $filter = null, $orgform_kurzbz = null)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$stdsemEsc = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL';
$selectRT = "
SELECT 1
FROM public.tbl_rt_person
JOIN public.tbl_reihungstest r ON (rt_id = reihungstest_id)
WHERE person_id=p.person_id
AND studienplan_id IN (
SELECT studienplan_id
FROM lehre.tbl_studienplan
JOIN lehre.tbl_studienordnung o USING(studienordnung_id)
WHERE o.studiengang_kz=tbl_prestudent.studiengang_kz
)
AND r.studiensemester_kurzbz=" . $stdsemEsc;
$where = ['tbl_prestudent.studiengang_kz' => $studiengang_kz];
if ($orgform_kurzbz) {
$where['ps.orgform_kurzbz'] = $orgform_kurzbz;
}
switch ($filter) {
case "interessenten":
$where['ps.status_kurzbz'] = 'Interessent';
break;
case "bewerbungnichtabgeschickt":
$where['ps.status_kurzbz'] = 'Interessent';
$where['bewerbung_abgeschicktamum'] = null;
break;
case "bewerbungabgeschickt":
$where['ps.status_kurzbz'] = 'Interessent';
$where['bewerbung_abgeschicktamum IS NOT NULL'] = null;
$where['bestaetigtam'] = null;
break;
case "statusbestaetigt":
$where['ps.status_kurzbz'] = 'Interessent';
$where['bestaetigtam IS NOT NULL'] = null;
break;
case "statusbestaetigtrtnichtangemeldet":
$where['ps.status_kurzbz'] = 'Interessent';
$where['bestaetigtam IS NOT NULL'] = null;
$this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false);
break;
case "statusbestaetigtrtangemeldet":
$where['ps.status_kurzbz'] = 'Interessent';
$where['bestaetigtam IS NOT NULL'] = null;
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
break;
case "zgv":
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$result = $this->StudiengangModel->load($studiengang_kz);
$stg = $this->getDataOrTerminateWithError($result);
if (!$stg)
$this->terminateWithValidationErrors(['' => 'Studiengang does not exist']); // TODO(chris): phrase
$stg = current($stg);
$where['ps.status_kurzbz'] = 'Interessent';
if ($stg->typ == 'm') {
$where['zgvmas_code IS NOT NULL'] = null;
if (defined('ZGV_ERFUELLT_ANZEIGEN') && ZGV_ERFUELLT_ANZEIGEN)
$where['zgvmas_erfuellt'] = true;
} elseif ($stg->typ == 'p') {
$where['zgvdoktor_code IS NOT NULL'] = null;
if (defined('ZGV_DOKTOR_ANZEIGEN') && ZGV_DOKTOR_ANZEIGEN)
$where['zgvdoktor_erfuellt'] = true;
} else {
$where['zgv_code IS NOT NULL'] = null;
if (defined('ZGV_ERFUELLT_ANZEIGEN') && ZGV_ERFUELLT_ANZEIGEN)
$where['zgv_erfuellt'] = true;
}
break;
case "reihungstestangemeldet":
$where['ps.status_kurzbz'] = 'Interessent';
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
break;
case "reihungstestnichtangemeldet":
$where['ps.status_kurzbz'] = 'Interessent';
$this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false);
break;
case "bewerber":
$where['ps.status_kurzbz'] = 'Bewerber';
break;
case "bewerberrtnichtangemeldet":
$where['ps.status_kurzbz'] = 'Bewerber';
$this->PrestudentModel->db->where('NOT EXISTS(' . $selectRT . ')', null, false);
break;
case "bewerberrtangemeldet":
$where['ps.status_kurzbz'] = 'Bewerber';
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
break;
case "bewerberrtangemeldetteilgenommen":
$where['ps.status_kurzbz'] = 'Bewerber';
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
$where['reihungstestangetreten'] = true;
break;
case "bewerberrtangemeldetnichtteilgenommen":
$where['ps.status_kurzbz'] = 'Bewerber';
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
$where['reihungstestangetreten'] = false;
break;
case "aufgenommen":
$where['ps.status_kurzbz'] = 'Aufgenommener';
break;
case "warteliste":
$where['ps.status_kurzbz'] = 'Wartender';
break;
case "absage":
$where['ps.status_kurzbz'] = 'Abgewiesener';
break;
case "incoming":
// NOTE(chris): in FAS it was not filtered for studiengang_kz
$where['ps.status_kurzbz'] = 'Incoming';
break;
case "absolvent":
$where['ps.status_kurzbz'] = 'Absolvent';
break;
case "diplomand":
$where['ps.status_kurzbz'] = 'Diplomand';
break;
default:
if (!$studiensemester_kurzbz) {
// TODO(chris): this does not work with $orgform_kurzbz != null
$where['ps.status_kurzbz'] = null;
} else {
$this->PrestudentModel->db->where_in('ps.status_kurzbz', [
'Interessent',
'Bewerber',
'Aufgenommener',
'Wartender',
'Abgewiesener'
]);
}
break;
}
/*
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.prestudent_id=tbl_prestudent.prestudent_id
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', '
ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
AND ps.prestudent_id=tbl_prestudent.prestudent_id
AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT');*/
$this->prepareQuery($studiensemester_kurzbz);
$this->PrestudentModel->addSelect("
CASE WHEN ps.status_kurzbz IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent')
THEN ps.ausbildungssemester::text
ELSE ''::text END AS semester", false);
$this->PrestudentModel->addSelect("'' AS verband");
$this->PrestudentModel->addSelect("'' AS gruppe");
$this->addSelectPrioRel();
$this->addFilter($studiensemester_kurzbz);
$result = $this->PrestudentModel->loadWhere($where);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
/**
* @param integer $studiengang_kz
* @param integer $semester (optional)
* @param string $verband (optional)
* @param integer $gruppe (optional)
* @param string $gruppe_kurzbz (optional)
* @param string $orgform_kurzbz (optional)
*
* @return void
*/
protected function getStudents($studiengang_kz, $semester = null, $verband = null, $gruppe = null, $gruppe_kurzbz = null, $orgform_kurzbz = null)
{
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
/*
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id');
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.prestudent_id=tbl_prestudent.prestudent_id
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid');
$this->PrestudentModel->addJoin(
'public.tbl_studentlehrverband v',
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz)
);*/
$this->prepareQuery($studiensemester_kurzbz, '');
$this->PrestudentModel->addSelect('v.semester');
$this->PrestudentModel->addSelect('v.verband');
$this->PrestudentModel->addSelect('v.gruppe');
$this->PrestudentModel->addSelect("'' AS priorisierung_relativ");
$where = [];
if ($gruppe_kurzbz !== null) {
$this->PrestudentModel->addJoin('public.tbl_benutzergruppe g', 'uid');
$where['g.gruppe_kurzbz'] = $gruppe_kurzbz;
$where['g.studiensemester_kurzbz'] = $studiensemester_kurzbz;
} else {
$where['v.studiengang_kz'] = $studiengang_kz;
if ($semester !== null)
$where['v.semester'] = $semester;
if ($verband !== null)
$where['v.verband'] = $verband;
if ($gruppe !== null)
$where['v.gruppe'] = $gruppe;
if (!$verband && !$gruppe && $orgform_kurzbz !== null) {
$this->PrestudentModel->db->where(
"(
SELECT orgform_kurzbz
FROM public.tbl_prestudentstatus
WHERE prestudent_id=tbl_prestudent.prestudent_id
AND studiensemester_kurzbz=" . $this->PrestudentModel->escape($studiensemester_kurzbz) . "
ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1
) =",
$this->PrestudentModel->escape($orgform_kurzbz),
false
);
}
}
$this->addFilter($studiensemester_kurzbz);
$result = $this->PrestudentModel->loadWhere($where);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
/**
* @param string $prestudent_id
*
* @return void
*/
protected function getPrestudent($prestudent_id)
{
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
/*
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.prestudent_id=tbl_prestudent.prestudent_id
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid', 'LEFT');
$this->PrestudentModel->addJoin(
'public.tbl_studentlehrverband v',
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz),
'LEFT'
);*/
$this->prepareQuery($studiensemester_kurzbz);
$this->PrestudentModel->addSelect("COALESCE(v.semester::text, CASE WHEN public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') THEN public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)::text ELSE ''::text END) AS semester", false);
$this->PrestudentModel->addSelect('v.verband');
$this->PrestudentModel->addSelect('v.gruppe');
$this->addSelectPrioRel();
$this->addFilter($studiensemester_kurzbz);
$result = $this->PrestudentModel->loadWhere([
'tbl_prestudent.prestudent_id' => $prestudent_id
]);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
/**
* @param string $student_uid
*
* @return void
*/
protected function getStudent($student_uid)
{
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
/*
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id');
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.prestudent_id=tbl_prestudent.prestudent_id
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid');
$this->PrestudentModel->addJoin(
'public.tbl_studentlehrverband v',
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz),
'LEFT'
);*/
$this->prepareQuery($studiensemester_kurzbz);
$this->PrestudentModel->addSelect('v.semester');
$this->PrestudentModel->addSelect('v.verband');
$this->PrestudentModel->addSelect('v.gruppe');
$this->addSelectPrioRel();
$this->addFilter($studiensemester_kurzbz);
$result = $this->PrestudentModel->loadWhere([
's.student_uid' => $student_uid
]);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
/**
* @param integer $person_id
*
* @return void
*/
protected function getPerson($person_id)
{
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
/*
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id');
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid');
$this->PrestudentModel->addJoin(
'public.tbl_studentlehrverband v',
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz=' . $this->PrestudentModel->escape($studiensemester_kurzbz),
'LEFT'
);*/
$this->prepareQuery($studiensemester_kurzbz);
$this->PrestudentModel->addSelect('v.semester');
$this->PrestudentModel->addSelect('v.verband');
$this->PrestudentModel->addSelect('v.gruppe');
$this->addSelectPrioRel();
$this->addFilter($studiensemester_kurzbz);
$result = $this->PrestudentModel->loadWhere([
'p.person_id' => $person_id
]);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
/**
* @param string|null $studiensemester_kurzbz
* @param string $type
*
* @return void
*/
protected function prepareQuery($studiensemester_kurzbz, $type = 'LEFT')
{
$stdsemEsc = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL';
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', $type);
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus pls', '
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.prestudent_id=tbl_prestudent.prestudent_id
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
$this->PrestudentModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid', 'LEFT');
$this->PrestudentModel->addJoin(
'public.tbl_studentlehrverband v',
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz' . ($studiensemester_kurzbz ? '=' . $stdsemEsc : ' IS NULL'),
$type
);
$this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', '
ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
AND ps.prestudent_id=tbl_prestudent.prestudent_id
AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT');
$this->PrestudentModel->addSelect("b.uid");
$this->PrestudentModel->addSelect('titelpre');
$this->PrestudentModel->addSelect('nachname');
$this->PrestudentModel->addSelect('vorname');
$this->PrestudentModel->addSelect('wahlname');
$this->PrestudentModel->addSelect('vornamen');
$this->PrestudentModel->addSelect('titelpost');
$this->PrestudentModel->addSelect('svnr');
$this->PrestudentModel->addSelect('ersatzkennzeichen');
$this->PrestudentModel->addSelect('gebdatum');
$this->PrestudentModel->addSelect('geschlecht');
// semester
// verband
// gruppe
$this->PrestudentModel->addSelect('UPPER(stg.typ || stg.kurzbz) AS studiengang');
$this->PrestudentModel->addSelect('tbl_prestudent.studiengang_kz');
$this->PrestudentModel->addSelect("s.matrikelnr");
$this->PrestudentModel->addSelect('p.person_id');
$this->PrestudentModel->addSelect('pls.status_kurzbz AS status');
$this->PrestudentModel->addSelect('pls.datum AS status_datum');
$this->PrestudentModel->addSelect('pls.bestaetigtam AS status_bestaetigung');
$this->PrestudentModel->addSelect(
"(SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id=p.person_id AND zustellung LIMIT 1) AS mail_privat",
false
);
$this->PrestudentModel->addSelect("
CASE WHEN b.uid IS NOT NULL AND b.uid<>''
THEN b.uid || " . $this->PrestudentModel->escape(DOMAIN) . "
ELSE '' END AS mail_intern", false);
$this->PrestudentModel->addSelect('p.anmerkung AS anmerkungen');
$this->PrestudentModel->addSelect('tbl_prestudent.anmerkung');
$this->PrestudentModel->addSelect('pls.orgform_kurzbz');
$this->PrestudentModel->addSelect('aufmerksamdurch_kurzbz');
$this->PrestudentModel->addSelect(
"(SELECT rt_gesamtpunkte AS punkte FROM public.tbl_prestudent WHERE prestudent_id=ps.prestudent_id) AS punkte",
false
);
$this->PrestudentModel->addSelect('tbl_prestudent.aufnahmegruppe_kurzbz');
$this->PrestudentModel->addSelect('tbl_prestudent.dual');
$this->PrestudentModel->addSelect('p.matr_nr');
$this->PrestudentModel->addSelect('sp.bezeichnung AS studienplan_bezeichnung');
$this->PrestudentModel->addSelect('tbl_prestudent.prestudent_id');
// priorisierung_relativ
$this->PrestudentModel->addSelect('mentor');
$this->PrestudentModel->addSelect('b.aktiv AS bnaktiv');
/*$this->PrestudentModel->addSelect('tbl_prestudent.reihungstest_id');
$this->PrestudentModel->addSelect('tbl_prestudent.anmeldungreihungstest');
$this->PrestudentModel->addSelect('tbl_prestudent.gsstudientyp_kurzbz');
$this->PrestudentModel->addSelect('tbl_prestudent.priorisierung');
$this->PrestudentModel->addSelect('p.zugangscode');
$this->PrestudentModel->addSelect('p.bpk');*/
$this->PrestudentModel->db->where_in('tbl_prestudent.studiengang_kz', $this->allowedStgs);
$this->PrestudentModel->addOrder('nachname');
$this->PrestudentModel->addOrder('vorname');
}
/**
* @return void
*/
protected function addSelectPrioRel()
{
$this->PrestudentModel->addSelect("(
SELECT count(*)
FROM (
SELECT *, public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) AS laststatus
FROM PUBLIC.tbl_prestudent pss
JOIN PUBLIC.tbl_prestudentstatus USING (prestudent_id)
WHERE person_id = p.person_id
AND studiensemester_kurzbz = (
SELECT studiensemester_kurzbz
FROM PUBLIC.tbl_prestudentstatus
WHERE prestudent_id = tbl_prestudent.prestudent_id
AND status_kurzbz = 'Interessent'
LIMIT 1
)
AND status_kurzbz = 'Interessent'
) prest
WHERE laststatus NOT IN ('Abbrecher', 'Abgewiesener', 'Absolvent')
AND priorisierung <= tbl_prestudent.priorisierung
) || ' (' || tbl_prestudent.priorisierung || ')' AS priorisierung_relativ", false);
}
/**
* 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);
}
}
}
@@ -0,0 +1,489 @@
<?php
/**
* 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 <https://www.gnu.org/licenses/>.
*/
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 verbände
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class Verband extends FHCAPI_Controller
{
public function __construct()
{
$permissions = [];
$router = load_class('Router');
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
parent::__construct($permissions);
// Load Models
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
}
/**
* Remap calls:
* /
* /(studiengang_kz) => getStudiengang
* /(studiengang_kz)/(semester) => getSemester
* /(studiengang_kz)/(semester)/(verband) => getVerband
* /(studiengang_kz)/(org_form) => getStudiengang
* /(studiengang_kz)/(org_form)/(semester) => getSemester
* /(studiengang_kz)/(org_form)/(semester)/(verband) => getVerband
*
* @param string $method
* @param array $params (optional)
*
* @return void
*/
public function _remap($method, $params = [])
{
if ($method == '' || $method == 'index')
return $this->getBase();
// NOTE(chris): Test if access is allowed ($method is the Studiengang)
if (!$this->permissionlib->isBerechtigt('assistenz', 's', $method)
&& !$this->permissionlib->isBerechtigt('admin', 's', $method)
) {
return $this->_outputAuthError([$method => ['admin:r', 'assistenz:r']]);
}
$count = count($params);
if (!$count)
return $this->getStudiengang($method);
if ($count == 1) {
if (is_numeric($params[0]))
return $this->getSemester($method, $params[0]);
else
return $this->getStudiengang($method, $params[0]);
}
if ($count == 2) {
if (is_numeric($params[0]))
return $this->getVerband($method, $params[0], $params[1]);
else
return $this->getSemester($method, $params[1], $params[0]);
}
if ($count == 3 && !is_numeric($params[0]) && is_numeric($params[1]) && !is_numeric($params[2]))
return $this->getVerband($method, $params[1], $params[2], $params[0]);
show_404();
}
/**
* @return void
*/
protected function getBase()
{
$this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
$this->StudiengangModel->addDistinct();
$this->StudiengangModel->addSelect("v.studiengang_kz AS link");
$this->StudiengangModel->addSelect(
"CONCAT(kurzbzlang, ' (', UPPER(CONCAT(typ, kurzbz)), ') - ', tbl_studiengang.bezeichnung) AS name",
false
);
$this->StudiengangModel->addSelect('erhalter_kz');
$this->StudiengangModel->addSelect('typ');
$this->StudiengangModel->addSelect('kurzbz');
$this->StudiengangModel->addSelect('studiengang_kz');
$this->StudiengangModel->addSelect('studiengang_kz AS stg_kz');
$this->StudiengangModel->addOrder('erhalter_kz');
$this->StudiengangModel->addOrder('typ');
$this->StudiengangModel->addOrder('kurzbz');
$stgs = $this->permissionlib->getSTG_isEntitledFor('admin') ?: [];
$stgs = array_merge($stgs, $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: []);
if (!$stgs)
$this->terminateWithSuccess([]);
$this->StudiengangModel->db->where_in('studiengang_kz', $stgs);
$result = $this->StudiengangModel->loadWhere(['v.aktiv' => true]);
$list = $this->getDataOrTerminateWithError($result);
if ($this->permissionlib->isBerechtigt('inout/uebersicht'))
$list[] = [
'name' => 'International',
'link' => 'inout',
'children' => [
[
'name' => 'Incoming',
'link' => 'inout/incoming',
'leaf' => true
],
[
'name' => 'Outgoing',
'link' => 'inout/outgoing',
'leaf' => true
],
[
'name' => 'Gemeinsame Studien',
'link' => 'inout/gemeinsamestudien',
'leaf' => true
]
]
];
$this->terminateWithSuccess($list);
}
/**
* @param integer $studiengang_kz
* @param string $orgform (optional)
*
* @return void
*/
protected function getStudiengang($studiengang_kz, $org_form = null)
{
$link = $studiengang_kz . '/';
if ($org_form !== null)
$link .= $org_form . '/';
$this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
$this->StudiengangModel->addDistinct();
$this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", semester) AS link", false);
$this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester ORDER BY verband, gruppe LIMIT 1)) AS name", false);
$this->StudiengangModel->addSelect('semester');
$this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
$this->StudiengangModel->addOrder('semester');
if ($org_form !== null) {
$this->StudiengangModel->db->group_start();
$this->StudiengangModel->db->where('v.semester', 0);
$this->StudiengangModel->db->or_where('v.orgform_kurzbz', $org_form);
$this->StudiengangModel->db->group_end();
}
$result = $this->StudiengangModel->loadWhere([
'v.studiengang_kz' => $studiengang_kz,
'v.aktiv' => true
]);
$list = $this->getDataOrTerminateWithError($result);
array_unshift($list, [
'name' => 'PreStudent',
'link' => $link . 'prestudent',
'children' => $this->getStdSem($link . 'prestudent/', $studiengang_kz)
]);
if ($org_form === null) {
// NOTE(chris): if mischform show orgforms
$result = $this->StudiengangModel->load($studiengang_kz);
$result = $this->getDataOrTerminateWithError($result);
if ($result) {
if (current($result)->mischform) {
$this->load->model('organisation/Studienordnung_model', 'StudienordnungModel');
$this->StudienordnungModel->addDistinct();
$this->StudienordnungModel->addSelect("CONCAT(studiengang_kz, '/', p.orgform_kurzbz) AS link");
$this->StudienordnungModel->addSelect("p.orgform_kurzbz AS name");
$this->StudienordnungModel->addJoin('lehre.tbl_studienplan p', 'studienordnung_id');
$result = $this->StudienordnungModel->loadWhere([
'aktiv' => true,
'studiengang_kz' => $studiengang_kz,
'p.orgform_kurzbz !=' => 'DDP'
]);
$result = $this->getDataOrTerminateWithError($result);
$list = array_merge($list, $result);
}
}
}
$this->terminateWithSuccess($list);
}
/**
* @param integer $studiengang_kz
* @param integer $semester
* @param string $orgform
*
* @return void
*/
protected function getSemester($studiengang_kz, $semester, $org_form = null)
{
$link = $studiengang_kz . '/';
if ($org_form !== null)
$link .= $org_form . '/';
$link .= $semester . '/';
$this->load->model('organisation/Gruppe_model', 'GruppeModel');
$this->GruppeModel->addDistinct();
$this->GruppeModel->addSelect("CONCAT(" . $this->GruppeModel->escape($link . 'grp/') . ", gruppe_kurzbz) AS link", false);
$this->GruppeModel->addSelect("CONCAT(gruppe_kurzbz, ' (', bezeichnung, ')') AS name", false);
$this->GruppeModel->addSelect("TRUE AS leaf", false);
$this->GruppeModel->addSelect('sort');
$this->GruppeModel->addSelect('gruppe_kurzbz');
$this->GruppeModel->addSelect($this->GruppeModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
$this->GruppeModel->addOrder('sort');
$this->GruppeModel->addOrder('gruppe_kurzbz');
$where = [
'studiengang_kz' => $studiengang_kz,
'semester' => $semester,
'lehre' => true,
'sichtbar' => true,
'aktiv' => true,
'direktinskription' => false
];
if ($org_form !== null)
$where['orgform_kurzbz'] = $org_form;
$result = $this->GruppeModel->loadWhere($where);
$list = $this->getDataOrTerminateWithError($result);
$this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
$this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", verband) AS link", false);
$this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband ORDER BY gruppe LIMIT 1)) AS name", false);
$this->StudiengangModel->addSelect("CASE WHEN MAX(gruppe)='' OR MAX(gruppe)=' ' THEN TRUE ELSE FALSE END AS leaf");
$this->StudiengangModel->addSelect('verband');
$this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
$this->StudiengangModel->addOrder('verband');
$this->StudiengangModel->addGroupBy('link, name, verband');
$where = [
'v.studiengang_kz' => $studiengang_kz,
'v.semester' => $semester,
'v.verband !=' => '',
'v.aktiv' => true
];
if ($org_form !== null && $semester) // NOTE(chris): on semester 0 show all?
$where['v.orgform_kurzbz'] = $org_form;
$result = $this->StudiengangModel->loadWhere($where);
$result = $this->getDataOrTerminateWithError($result);
$list = array_merge($list, $result);
$this->terminateWithSuccess($list);
}
/**
* @param integer $studiengang_kz
* @param integer $semester
* @param integer $verband
* @param string $orgform
*
* @return void
*/
protected function getVerband($studiengang_kz, $semester, $verband, $org_form = null)
{
$link = $studiengang_kz . '/';
if ($org_form !== null)
$link .= $org_form . '/';
$link .= $semester . '/'. $verband . '/';
$this->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
$this->StudiengangModel->addDistinct();
$this->StudiengangModel->addSelect("CONCAT(" . $this->StudiengangModel->escape($link) . ", gruppe) AS link", false);
$this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, gruppe, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband AND gruppe=v.gruppe ORDER BY gruppe LIMIT 1)) AS name", false);
$this->StudiengangModel->addSelect("TRUE AS leaf", false);
$this->StudiengangModel->addSelect('gruppe');
$this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
$this->StudiengangModel->addOrder('gruppe');
$where = [
'v.studiengang_kz' => $studiengang_kz,
'v.semester' => $semester,
'v.verband' => $verband,
'v.gruppe !=' => '',
'v.aktiv' => true
];
if ($org_form !== null && $semester) // NOTE(chris): on semester 0 show all?
$where['v.orgform_kurzbz'] = $org_form;
$result = $this->StudiengangModel->loadWhere($where);
$list = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($list);
}
/**
* @param string $link
* @param integer $studiengang_kz
*
* @return array
*/
protected function getStdSem($link, $studiengang_kz)
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->load->model('system/Variable_model', 'VariableModel');
$result = $this->VariableModel->getVariables(getAuthUID(), ['number_displayed_past_studiensemester']);
$data = $this->getDataOrTerminateWithError($result);
$number_displayed_past_studiensemester = $data['number_displayed_past_studiensemester'] ?? null;
$this->StudiensemesterModel->addPlusMinus(null, $number_displayed_past_studiensemester);
$this->StudiensemesterModel->addOrder('ende');
$result = $this->StudiensemesterModel->load();
$studiensemester = $this->getDataOrTerminateWithError($result);
$result = [];
$studiengang_kz = (int)$studiengang_kz;
foreach ($studiensemester as $sem) {
$semlink = $link . $sem->studiensemester_kurzbz;
$intlink = $semlink . '/interessenten';
$result[] = [
'name' => $sem->studiensemester_kurzbz,
'link' => $semlink,
'stg_kz' => $studiengang_kz,
'children' => [
[
'name' => 'Interessenten',
'link' => $intlink,
'stg_kz' => $studiengang_kz,
'children' => [
[
'name' => 'Bewerbung nicht abgeschickt',
'link' => $intlink . '/bewerbungnichtabgeschickt',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'Bewerbung abgeschickt, Status unbestätigt',
'link' => $intlink . '/bewerbungabgeschickt',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'ZGV erfüllt',
'link' => $intlink . '/zgv',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'Status bestätigt',
'link' => $intlink . '/statusbestaetigt',
'stg_kz' => $studiengang_kz,
'children' => [
[
'name' => 'Nicht zum Reihungstest angemeldet',
'link' => $intlink . '/statusbestaetigtrtnichtangemeldet',
'leaf' => true
],
[
'name' => 'Reihungstest angemeldet',
'link' => $intlink . '/statusbestaetigtrtangemeldet',
'leaf' => true
]
]
],
[
'name' => 'Nicht zum Reihungstest angemeldet',
'link' => $intlink . '/reihungstestnichtangemeldet',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'Reihungstest angemeldet',
'link' => $intlink . '/reihungstestangemeldet',
'stg_kz' => $studiengang_kz,
'leaf' => true
]
]
],
[
'name' => 'Bewerber',
'link' => $semlink . '/bewerber',
'stg_kz' => $studiengang_kz,
'children' => [
[
'name' => 'Nicht zum Reihungstest angemeldet',
'link' => $intlink . '/bewerberrtnichtangemeldet',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'Reihungstest angemeldet',
'link' => $intlink . '/bewerberrtangemeldet',
'stg_kz' => $studiengang_kz,
'children' => [
[
'name' => 'Teilgenommen',
'link' => $intlink . '/bewerberrtangemeldetteilgenommen',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'Nicht teilgenommen',
'link' => $intlink . '/bewerberrtangemeldetnichtteilgenommen',
'stg_kz' => $studiengang_kz,
'leaf' => true
]
]
]
]
],
[
'name' => 'Aufgenommen',
'link' => $semlink . '/aufgenommen',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'Warteliste',
'link' => $semlink . '/warteliste',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'Absage',
'link' => $semlink . '/absage',
'stg_kz' => $studiengang_kz,
'leaf' => true
],
[
'name' => 'Incoming',
'link' => $semlink . '/incoming',
'stg_kz' => $studiengang_kz,
'leaf' => true
]
]
];
}
return $result;
}
}
@@ -0,0 +1,168 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Noten extends Auth_Controller
{
public function __construct()
{
parent::__construct([
'get' => 'student/noten:r',
'getZeugnis' => 'student/noten:r',
'update' => ['admin:w', 'assistenz:w']
]);
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
}
public function get()
{
$this->load->model('codex/Note_model', 'NoteModel');
$result = $this->NoteModel->addOrder('note');
$result = $this->NoteModel->load();
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
return $this->outputJson($result);
}
public function getZeugnis($prestudent_id, $all = null)
{
$this->load->model('crm/Student_model', 'StudentModel');
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
$result = $this->StudentModel->loadWhere([
'prestudent_id' => $prestudent_id
]);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson($result);
}
if (!hasData($result))
return $this->outputJsonSuccess(null);
$student_uid = current(getData($result))->student_uid;
$studiensemester_kurzbz = ($all === null) ? $this->variablelib->getVar('semester_aktuell') : null;
$result = $this->ZeugnisnoteModel->getZeugnisnoten($student_uid, $studiensemester_kurzbz);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
return $this->outputJson($result);
}
public function update()
{
$this->load->model('crm/Student_model', 'StudentModel');
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
$this->load->library('form_validation');
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
if (empty($_POST) || !is_array(current($_POST))) {
$result = $this->hasPermissionUpdate($this->input->post('lehrveranstaltung_id'), $this->input->post('student_uid'));
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN);
return $this->outputJson($result);
}
$this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrverantaltung ID', 'required|numeric');
$this->form_validation->set_rules('student_uid', 'Student UID', 'required');
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester Kurzbezeichnung', 'required');
$this->form_validation->set_rules('note', 'Note', 'required|numeric');
$post = [$_POST];
} else {
foreach ($_POST as $i => $data) {
$lvid = isset($data['lehrveranstaltung_id']) ? $data['lehrveranstaltung_id'] : null;
$uid = isset($data['student_uid']) ? $data['student_uid'] : null;
$result = $this->hasPermissionUpdate($lvid, $uid);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_FORBIDDEN);
return $this->outputJson($result);
}
$this->form_validation->set_rules($i . '[lehrveranstaltung_id]', '#' . $i . ' Lehrverantaltung ID', 'required|numeric');
$this->form_validation->set_rules($i . '[student_uid]', '#' . $i . ' Student UID', 'required');
$this->form_validation->set_rules($i . '[studiensemester_kurzbz]', '#' . $i . ' Studiensemester Kurzbezeichnung', 'required');
$this->form_validation->set_rules($i . '[note]', '#' . $i . ' Note', 'required|numeric');
}
$post = $_POST;
}
if ($this->form_validation->run() == false) {
$this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST);
return $this->outputJsonError($this->form_validation->error_array());
}
$final_result = success();
$this->ZeugnisnoteModel->db->trans_start();
foreach ($post as $i => $data) {
$note = $data['note'];
unset($data['note']);
$result = $this->ZeugnisnoteModel->update($data, [
'note' => $note,
'benotungsdatum' => date('c'),
'updateamum' => date('c'),
'updatevon' => getAuthUID()
]);
if (isError($result)) {
$final_result = $result;
break;
}
}
$this->ZeugnisnoteModel->db->trans_complete();
if (isError($final_result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($final_result);
}
protected function hasPermissionUpdate($lehrveranstaltung_id, $student_uid)
{
// TODO(chris): error phrases!
if ($lehrveranstaltung_id === null || $student_uid === null)
return success();
$result = $this->StudentModel->load([$student_uid]);
if (isError($result))
return $result;
if (!hasData($result))
return error('Fehler beim Ermitteln des Studenten');
$student = current(getData($result));
if ($this->permissionlib->isBerechtigt('admin', 'suid', $student->studiengang_kz))
return success();
if ($this->permissionlib->isBerechtigt('assistenz', 'suid', $student->studiengang_kz))
return success();
$result = $this->StudienplanModel->getAllOesForLv($lehrveranstaltung_id);
if (isError($result))
return $result;
$oes = getData($result) ?: [];
$result = $this->LehrveranstaltungModel->getStg($lehrveranstaltung_id);
if (isError($result))
return $result;
if (hasData($result))
$oes[] = current(getData($result));
foreach ($oes as $oe) {
if ($this->permissionlib->isBerechtigt('admin', 'suid', $oe->oe_kurzbz))
return success();
if ($this->permissionlib->isBerechtigt('assistenz', 'suid', $oe->oe_kurzbz))
return success();
}
return error('Forbidden');
}
}
@@ -0,0 +1,43 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Studienplan extends Auth_Controller
{
public function __construct()
{
// TODO(chris): access!
parent::__construct([
'get' => self::PERM_LOGGED
]);
}
public function get()
{
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
$_POST = json_decode($this->input->raw_input_stream, true);
$this->load->library('form_validation');
$this->form_validation->set_rules('studiengang_kz', 'StudiengangKz', 'required|numeric');
$this->form_validation->set_rules('studiensemester_kurzbz', 'StudiensemesterKurbz', 'required');
$this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'numeric');
if ($this->form_validation->run() == false) {
$this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST);
return $this->outputJsonError($this->form_validation->error_array());
}
$studiengang_kz = $this->input->post('studiengang_kz');
$studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
$ausbildungssemester = $this->input->post('ausbildungssemester') ?: null;
$orgform_kurzbz = $this->input->post('orgform_kurzbz') ?: null;
$result = $this->StudienplanModel->getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $ausbildungssemester, $orgform_kurzbz);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
}
@@ -0,0 +1,78 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Studiensemester extends Auth_Controller
{
public function __construct()
{
// TODO(chris): access!
parent::__construct([
'index' => self::PERM_LOGGED,
'now' => self::PERM_LOGGED,
'set' => self::PERM_LOGGED
]);
}
public function index()
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->StudiensemesterModel->addOrder('start');
$result = $this->StudiensemesterModel->load();
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
public function now()
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$result = $this->StudiensemesterModel->getNearest();
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJson(getError($result));
}
$result = getData($result) ?: [];
if (count($result) != 1) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
$this->outputJsonError(count($result) ? 'Mehrere Studiensemester aktiv' : 'Kein Studiensemester aktiv');
} else {
$this->outputJsonSuccess(current($result)->studiensemester_kurzbz);
}
}
public function set()
{
$this->load->library('AuthLib');
$this->load->library('form_validation');
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required');
if ($this->form_validation->run() == false) {
$this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST);
return $this->outputJsonError($this->form_validation->error_array());
}
$stdsem = $this->input->post('studiensemester');
$this->load->model('system/Variable_model', 'VariableModel');
$result = $this->VariableModel->setVariable(getAuthUID(), 'semester_aktuell', $stdsem);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson($result);
}
$this->outputJsonSuccess(true);
}
}
+17 -1
View File
@@ -29,6 +29,10 @@ class AntragJob extends JOB_Controller
$this->load->model('crm/Student_model', 'StudentModel');
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->loadPhrases([
'lehre'
]);
}
/**
@@ -451,11 +455,23 @@ class AntragJob extends JOB_Controller
if (isError($result))
$this->logError(getError($result));
$this->load->model('crm/Statusgrund_model', 'StatusgrundModel');
$result = $this->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStgl']);
if (isError($result)) {
$this->logError(getError($result));
continue;
} elseif (!hasData($result)) {
$this->logError($this->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStgl']));
continue;
}
$statusgrund = current(getData($result));
$result = $this->prestudentlib->setAbbrecher(
$antrag->prestudent_id,
$antrag->studiensemester_kurzbz,
'AntragJob',
'abbrecherStgl',
$statusgrund->statusgrund_id,
$antrag->insertamum,
null,
$antrag->insertvon ?: $insertvon
+42 -2
View File
@@ -88,6 +88,22 @@ abstract class Auth_Controller extends FHC_Controller
}
}
/**
* Checks for Permissions depending on the Studiengang of a Prestudent
* and exits/outputs an error if they are not met.
*
* @param integer $prestudent_id
* @param array $permStud Perms if the person is a Student
*
* @return void
*/
protected function checkPermissionsForPrestudent($prestudent_id, $permStud)
{
if (!$this->hasPermissionsForPrestudent($prestudent_id, $permStud)) {
$this->_outputAuthError([$this->router->method => $permStud]);
}
}
/**
* Checks for Permissions depending if the given person is a
* Mitarbeiter and/or Student
@@ -97,11 +113,11 @@ abstract class Auth_Controller extends FHC_Controller
* @param array $permMa Perms if the person is a Mitarbeiter
* @param array $permStud Perms if the person is a Student
*
* @return boolean
* @return integer 0 if permission is granted
*/
protected function hasPermissionsForPerson($person_id, $permMa, $permStud)
{
$res = 0;
$res = 3;
$this->load->model('person/Person_model', 'PersonModel');
$this->PersonModel->addJoin('public.tbl_benutzer', 'person_id');
$this->PersonModel->addJoin('public.tbl_mitarbeiter', 'uid = mitarbeiter_uid');
@@ -129,6 +145,30 @@ abstract class Auth_Controller extends FHC_Controller
return $res;
}
/**
* Checks for Permissions depending on the Studiengang of a Prestudent
* and returns the result.
*
* @param integer $prestudent_id
* @param array $permStud Perms if the person is a Student
*
* @return boolean
*/
protected function hasPermissionsForPrestudent($prestudent_id, $permStud)
{
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$result = $this->PrestudentModel->load($prestudent_id);
if (!hasData($result))
show_404();
$stg = current(getData($result))->studiengang_kz;
foreach ($permStud as $k => $v) {
$perm = $this->permissionlib->convertAccessType($v);
if ($this->permissionlib->isBerechtigt($perm[0], $perm[1], $stg))
return true;
}
return false;
}
/**
* Outputs an error message and sets the HTTP Header.
* This function is protected so that it can be overwritten.
+17
View File
@@ -827,6 +827,23 @@ class DB_Model extends CI_Model
return $result;
}
public function getDbTable()
{
return $this->dbTable;
}
public function getPk()
{
return $this->pk;
}
public function getPks()
{
if (is_array($this->pk))
return $this->pk;
return [$this->pk];
}
// ------------------------------------------------------------------------------------------
// Protected methods
+6 -1
View File
@@ -94,7 +94,7 @@ class FHCAPI_Controller extends Auth_Controller
// ---------------------------------------------------------------
/**
* @param array $data
* @param string|array|object $data
* @param string $type (optional)
* @return void
*/
@@ -110,6 +110,8 @@ class FHCAPI_Controller extends Auth_Controller
$error['messages'] = $data;
else
$error = $data;
} elseif (is_object($data)) {
$error = (array)$data;
} else {
$error['message'] = $data;
}
@@ -117,6 +119,9 @@ class FHCAPI_Controller extends Auth_Controller
if ($type)
$error['type'] = $type;
if (!isset($error['type']))
$error['type'] = self::ERROR_TYPE_GENERAL;
$this->returnObj['errors'][] = $error;
}
+461
View File
@@ -0,0 +1,461 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
abstract class Notiz_Controller extends FHCAPI_Controller
{
const DEFAULT_PERMISSION_R = 'admin:r';
const DEFAULT_PERMISSION_RW = 'admin:rw';
//public function __construct($zuordnung = 'person/Notizzuordnung_model')
public function __construct($permissions)
{
$default_permissions = [
'getUid' => self::DEFAULT_PERMISSION_R,
'getNotizen' => self::DEFAULT_PERMISSION_R,
'loadNotiz' => self::DEFAULT_PERMISSION_R,
'addNewNotiz' => self::DEFAULT_PERMISSION_RW,
'updateNotiz' => self::DEFAULT_PERMISSION_RW,
'deleteNotiz' => self::DEFAULT_PERMISSION_RW,
'loadDokumente' => self::DEFAULT_PERMISSION_R,
'getMitarbeiter' => self::DEFAULT_PERMISSION_R,
'isBerechtigt' => self::DEFAULT_PERMISSION_R,
];
if(!is_array($permissions))
{
$this->terminateWithError("Notiz_controller construct: permissions must be an array");
}
$merged_permissions = array_merge($default_permissions, $permissions);
parent::__construct($merged_permissions);
//Load Models
$this->load->model('person/Notiz_model', 'NotizModel');
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
// Load language phrases
$this->loadPhrases([
'ui'
]);
}
public function getUid()
{
$this->terminateWithSuccess(getAuthUID());
}
//Override function for extensions
protected function assignNotiz($notiz_id, $id, $type)
{
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
$result = $this->NotizzuordnungModel->isValidType($type);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$result = $this->NotizzuordnungModel->insert(array('notiz_id' => $notiz_id, $type => $id));
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return success(getData($result));
}
//Override function for extensions
protected function deleteNotizzuordnung($notiz_id, $id, $type)
{
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
$result = $this->NotizzuordnungModel->isValidType($type);
if (isError($result)) {
$this->terminateWithError('type not in table notizzuordnung enthalten..', self::ERROR_TYPE_GENERAL);
}
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return success(getData($result));
}
//Override function for extensions
public function getNotizen($id, $type)
{
$result = $this->NotizzuordnungModel->isValidType($type);
if(isError($result))
$this->terminateWithError($result->retval, self::ERROR_TYPE_GENERAL);
$result = $this->NotizModel->getNotizWithDocEntries($id, $type);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result) ?: []);
}
//Override function
protected function isBerechtigt($id, $typeId){
return $this->terminateWithError("in abstract function: define right in extension", self::ERROR_TYPE_GENERAL);
}
public function loadNotiz()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
//$this->load->model('person/Notiz_model', 'NotizModel');
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT');
$this->NotizModel->addSelect('*');
$this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum
THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate");
$this->NotizModel->addLimit(1);
$result = $this->NotizModel->loadWhere(
array('notiz_id' => $notiz_id)
);
if (isError($result))
{
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
else
{
$this->terminateWithSuccess(current(getData($result)));
}
}
public function addNewNotiz($id, $paramTyp = null)
{
$this->load->library('DmsLib');
$this->load->library('form_validation');
$uid = getAuthUID();
if (isset($_POST['data']))
{
$data = json_decode($_POST['data']);
unset($_POST['data']);
foreach ($data as $k => $v) {
$_POST[$k] = $v;
}
}
//Form Validation
$this->form_validation->set_rules('titel', 'Titel', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
]);
$this->form_validation->set_rules('text', 'Text', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$titel = $this->input->post('titel');
$text = $this->input->post('text');
$erledigt = $this->input->post('erledigt');
$verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid;
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : null;
$type = $this->input->post('typeId');
$start = $this->input->post('start');
$ende = $this->input->post('ende');
// Start DB transaction
$this->db->trans_start();
//Save note
$result = $this->NotizModel->insert(array('titel' => $titel, 'text' => $text, 'erledigt' => $erledigt, 'verfasser_uid' => $verfasser_uid,
"insertvon" => $verfasser_uid, 'start' => $start, 'ende' => $ende, 'bearbeiter_uid' => $bearbeiter_uid));
if (isError($result))
{
$this->db->trans_rollback();
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$notiz_id = $result->retval;
//save Notizzuordnung
$result = $this->assignNotiz($notiz_id, $id, $type);
if (isError($result))
{
$this->db->trans_rollback();
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
//save Documents
$dms_id_arr = [];
foreach ($_FILES as $k => $file)
{
$dms = array(
'kategorie_kurzbz' => 'notiz',
'version' => 0,
'name' => $file["name"],
'mimetype' => $file["type"],
'insertamum' => date('c'),
'insertvon' => $uid
);
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
//Todo define in dms component: readFile, downloadFile
$result = $this->dmslib->upload($dms, $k, ['*']);
/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/
if (isError($result))
{
$this->db->trans_rollback();
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$dms_id_arr[] = $result->retval['dms_id'];
}
//save entry in Notizdokument
if($dms_id_arr)
{
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
foreach($dms_id_arr as $dms_id)
{
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
if (isError($result))
{
$this->db->trans_rollback();
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
}
}
$this->db->trans_commit();
return $this->terminateWithSuccess($result);
}
public function updateNotiz()
{
$this->load->library('form_validation');
$this->load->library('DmsLib');
if (isset($_POST['data']))
{
$data = json_decode($_POST['data']);
unset($_POST['data']);
foreach ($data as $k => $v) {
$_POST[$k] = $v;
}
}
$notiz_id = $this->input->post('notiz_id');
if(!$notiz_id)
{
$this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
//Form Validation
$this->form_validation->set_rules('titel', 'Titel', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
]);
$this->form_validation->set_rules('text', 'Text', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
//update Notiz
$uid = getAuthUID();
$titel = $this->input->post('titel');
$text = $this->input->post('text');
$verfasser_uid = isset($_POST['verfasser']) ? $_POST['verfasser'] : $uid;
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
$erledigt = $this->input->post('erledigt');
$start = $this->input->post('start');
$ende = $this->input->post('ende');
$result = $this->NotizModel->update(
[
'notiz_id' => $notiz_id
],
[
'titel' => $titel,
'updatevon' => $uid,
'updateamum' => date('c'),
'text' => $text,
'verfasser_uid' => $verfasser_uid,
'bearbeiter_uid' => $bearbeiter_uid,
'start' => $start,
'ende' => $ende,
'erledigt' => $erledigt
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
//update(1) loading all dms-entries with this notiz_id
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
$this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id');
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
$result = $this->getDataOrTerminateWithError($result);
foreach ($result as $doc) {
$dms_id_arr[$doc->dms_id] = array(
'name' => $doc->name,
'dms_id' => $doc->dms_id
);
}
foreach ($_FILES as $k => $file)
{
//update(2) attach all new files (except type application/x.fhc-dms+json)
if($file["type"] == 'application/x.fhc-dms+json')
{
$jsonFile = json_decode(file_get_contents($file['tmp_name']));
unset($dms_id_arr[$jsonFile->dms_id]);
#$dms_uploaded[] = $jsonFile->dms_id;
}
else
{
$dms = array(
'kategorie_kurzbz' => 'notiz',
'version' => 0,
'name' => $file["name"],
'mimetype' => $file["type"],
'insertamum' => date('c'),
'insertvon' => $uid
);
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
//Todo define in dms component: readFile, downloadFile
$result = $this->dmslib->upload($dms, $k, array('*'));
$result = $this->getDataOrTerminateWithError($result);
$dms_id = $result['dms_id'];
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
$this->getDataOrTerminateWithError($result);
}
}
//update(3) check if all files have been deleted
foreach ($dms_id_arr as $file)
{
$result = $this->dmslib->removeAll($file['dms_id']);
$this->getDataOrTerminateWithError($result);
}
return $this->terminateWithSuccess($result);
}
public function deleteNotiz()
{
$this->load->library('DmsLib');
$notiz_id = $this->input->post('notiz_id');
$typeId = $this->input->post('type_id');
$id = $this->input->post('id');
//TODO(manu): define Permissions for deletion document if filecomponent finished
//get dms_id from notizdokument
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
$result = $this->getDataOrTerminateWithError($result);
// Start DB transaction
$this->db->trans_start();
if ($result)
$this->load->library('DmsLib');
foreach ($result as $doc) {
$res = $this->dmslib->removeAll($doc->dms_id);
if (isError($result))
{
$this->db->trans_rollback();
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
}
//delete Notizzuordnung
$result = $this-> deleteNotizzuordnung($notiz_id, $id, $typeId);
if (isError($result))
{
$this->db->trans_rollback();
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->load->model('person/Notiz_model', 'NotizModel');
//Delete Note
$result = $this->NotizModel->delete($notiz_id);
if (isError($result))
{
$this->db->trans_rollback();
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if(!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
$this->db->trans_complete();
return $this->terminateWithSuccess(getData($result));
}
public function loadDokumente()
{
$notiz_id = $this->input->post('notiz_id');
$this->NotizModel->addSelect('campus.tbl_dms_version.*');
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)');
$this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)');
$result = $this->NotizModel->loadWhere(
array('public.tbl_notiz.notiz_id' => $notiz_id)
);
if (isError($result)) {
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if(!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result));
}
public function getMitarbeiter($searchString)
{
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString);
if (isError($result)) {
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess($result);
}
}
+25 -6
View File
@@ -121,7 +121,7 @@ class AntragLib
public function unpauseAntrag($antrag_id, $insertvon)
{
if ($insertvon == Studierendenantragstatus_model::INSERTVON_DEREGISTERED)
return error($this->p->t('studierendenantrag', 'error_no_right'));
return error($this->_ci->p->t('studierendenantrag', 'error_no_right'));
if ($insertvon == Studierendenantragstatus_model::INSERTVON_ABMELDUNGSTGL) {
return $this->_ci->StudierendenantragstatusModel->resumeAntraegeForAbmeldungStgl($antrag_id);
}
@@ -257,18 +257,28 @@ class AntragLib
if (isError($result))
$errors[] = getError($result);
$this->_ci->load->model('crm/Statusgrund_model', 'StatusgrundModel');
$result = $this->_ci->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStud']);
if (isError($result)) {
$errors[] = getError($result);
continue;
} elseif (!hasData($result)) {
$errors[] = $this->_ci->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStud']);
continue;
}
$statusgrund = current(getData($result));
$result = $this->_ci->prestudentlib->setAbbrecher(
$antrag->prestudent_id,
$antrag->studiensemester_kurzbz,
$insertvon,
'abbrecherStud',
$statusgrund->statusgrund_id,
$antrag->datum,
$insertam
);
if (isError($result))
{
if (isError($result)) {
$errors[] = getError($result);
return $errors;
continue;
}
$result = $this->_ci->PersonModel->loadPrestudent($antrag->prestudent_id);
@@ -421,11 +431,20 @@ class AntragLib
// NOTE(chris): here we should have error handling but at the
// moment there is no way to notify the user for "soft" errors
$this->_ci->load->model('crm/Statusgrund_model', 'StatusgrundModel');
$result = $this->_ci->StatusgrundModel->loadWhere(['statusgrund_kurzbz' => 'abbrecherStgl']);
if (isError($result))
return $result;
if (!hasData($result))
return error($this->_ci->p->t('lehre', 'error_noStatusgrund', ['statusgrund_kurzbz' => 'abbrecherStgl']));
$statusgrund = current(getData($result));
$result = $this->_ci->prestudentlib->setAbbrecher(
$antrag->prestudent_id,
$antrag->studiensemester_kurzbz,
$insertvon,
'abbrecherStgl',
$statusgrund->statusgrund_id,
$status->insertamum
);
+521 -28
View File
@@ -35,8 +35,15 @@ class PrestudentLib
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
}
public function setAbbrecher($prestudent_id, $studiensemester_kurzbz, $insertvon = null, $statusgrund_kurzbz = null, $datum = null, $bestaetigtam = null, $bestaetigtvon = null)
{
public function setAbbrecher(
$prestudent_id,
$studiensemester_kurzbz,
$insertvon = null,
$statusgrund_id = null,
$datum = null,
$bestaetigtam = null,
$bestaetigtvon = null
) {
if (!$insertvon)
$insertvon = getAuthUID();
if (!$bestaetigtvon)
@@ -70,8 +77,8 @@ class PrestudentLib
if(!$bestaetigtam)
$bestaetigtam = date('c');
//Status und Statusgrund updaten
$result = $this->_ci->PrestudentstatusModel->withGrund($statusgrund_kurzbz)->insert([
// Status und Statusgrund updaten
$result = $this->_ci->PrestudentstatusModel->insert([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => Prestudentstatus_model::STATUS_ABBRECHER,
'studiensemester_kurzbz' => $prestudent_status->studiensemester_kurzbz,
@@ -82,13 +89,13 @@ class PrestudentLib
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
'studienplan_id'=> $prestudent_status->studienplan_id,
'bestaetigtvon' => $bestaetigtvon,
'bestaetigtam' => $bestaetigtam
'bestaetigtam' => $bestaetigtam,
'statusgrund_id' => $statusgrund_id
]);
if (isError($result))
return $result;
//Verband anlegen
$result = $this->_ci->LehrverbandModel->load([
'studiengang_kz' => $student->studiengang_kz,
@@ -134,7 +141,7 @@ class PrestudentLib
]);
}
//noch nicht eingetragene Zeugnisnoten auf 9 setzen
// noch nicht eingetragene Zeugnisnoten auf 9 setzen
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $prestudent_status->studiensemester_kurzbz);
if (isError($result))
return $result;
@@ -166,9 +173,9 @@ class PrestudentLib
}
//Update Aktionen
// Update Aktionen
//StudentModel updaten
// StudentModel updaten
$this->_ci->StudentModel->update([
'student_uid' => $student->student_uid
], [
@@ -192,7 +199,7 @@ class PrestudentLib
'updatevon' => $insertvon
]);
//Benutzer inaktiv setzen
// Benutzer inaktiv setzen
$this->_ci->BenutzerModel->update([
'uid' => $student->student_uid
], [
@@ -206,17 +213,28 @@ class PrestudentLib
return success();
}
public function setUnterbrecher($prestudent_id, $studiensemester_kurzbz, $studierendenantrag_id, $insertvon = null)
{
public function setUnterbrecher(
$prestudent_id,
$studiensemester_kurzbz,
$studierendenantrag_id = null,
$insertvon = null,
$ausbildungssemester = null,
$statusgrund_id = null
) {
$ausbildungssemester_plus = 0;
if (!$insertvon)
$insertvon = getAuthUID();
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz);
if (isError($result))
return $result;
$result = getData($result);
if (!$result) {
if (!$result) { // NOTE(chris): no status in target stdsem
//NOTE(manu): only valid if nextSemester focus max
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
@@ -224,7 +242,7 @@ class PrestudentLib
return $result;
$result = getData($result);
//check if ausbildungssemester is last
// check if ausbildungssemester is last
$this->_ci->StudiengangModel->addJoin('public.tbl_prestudent p', 'studiengang_kz');
$res = $this->_ci->StudiengangModel->loadWhere(['p.prestudent_id' => $prestudent_id]);
if(isError($res))
@@ -249,31 +267,47 @@ class PrestudentLib
}
$prestudent_status = current($result);
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
if (isError($result))
return $result;
$result = getData($result);
if (!$result)
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
$student = current($result);
$resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id);
if (isError($resultAntrag))
return $resultAntrag;
$resultAntrag = getData($resultAntrag);
if (!$resultAntrag)
return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id]));
$antrag = current($resultAntrag);
if ($studierendenantrag_id)
{
$resultAntrag = $this->_ci->StudierendenantragModel->load($studierendenantrag_id);
if (isError($resultAntrag))
return $resultAntrag;
$resultAntrag = getData($resultAntrag);
if (!$resultAntrag)
return error($this->_ci->p->t('studierendenantrag', 'error_no_antrag_found', ['id' => $studierendenantrag_id]));
//Status updaten
$antrag = current($resultAntrag);
$anmerkung = 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg;
}
else
$anmerkung = '';
if ($ausbildungssemester)
$semester = $ausbildungssemester;
else
$semester = $prestudent_status->ausbildungssemester + $ausbildungssemester_plus;
// Status updaten
$result = $this->_ci->PrestudentstatusModel->insert([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => Prestudentstatus_model::STATUS_UNTERBRECHER,
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'ausbildungssemester' => $prestudent_status->ausbildungssemester + $ausbildungssemester_plus,
'ausbildungssemester' => $semester,
'datum' => date('c'),
'insertvon' => $insertvon,
'insertamum' => date('c'),
@@ -281,7 +315,8 @@ class PrestudentLib
'studienplan_id'=> $prestudent_status->studienplan_id,
'bestaetigtvon' => $insertvon,
'bestaetigtam' => date('c'),
'anmerkung'=> 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg
'anmerkung'=> $anmerkung,
'statusgrund_id' => $statusgrund_id
]);
if (isError($result))
@@ -332,7 +367,7 @@ class PrestudentLib
]);
}
//noch nicht eingetragene Zeugnisnoten auf 9 setzen
// noch nicht eingetragene Zeugnisnoten auf 9 setzen
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $studiensemester_kurzbz);
if (isError($result))
return $result;
@@ -363,10 +398,9 @@ class PrestudentLib
}
}
// Update Aktionen
//Update Aktionen
//StudentModel updaten
// StudentModel updaten
$this->_ci->StudentModel->update([
'student_uid' => $student->student_uid
], [
@@ -409,4 +443,463 @@ class PrestudentLib
return success();
}
public function setStudent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
{
$authUID = getAuthUID();
$now = date('c');
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
if (isError($result))
return $result;
if (!hasData($result))
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudentstatus', [
'prestudent_id' => $prestudent_id
]));
$prestudent_status = current(getData($result));
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
if (isError($result))
return $result;
if (!hasData($result))
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
$student = current(getData($result));
$this->_ci->load->library('VariableLib', ['uid' => $authUID]);
$semester_aktuell = $this->_ci->variablelib->getVar('semester_aktuell');
// Update Aktionen
// Status updaten
$result = $this->_ci->PrestudentstatusModel->insert([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT,
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'statusgrund_id' => $statusgrund_id,
'ausbildungssemester' => $ausbildungssemester,
'datum' => $now,
'insertvon' => $authUID,
'insertamum' => $now,
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
'studienplan_id'=> $prestudent_status->studienplan_id,
'bestaetigtvon' => $authUID,
'bestaetigtam' => $now
]);
if (isError($result))
return $result;
// Student updaten
$result = $this->_ci->StudentModel->update([
'student_uid' => $student->student_uid
], [
'semester' => $ausbildungssemester,
'verband' => '',
'gruppe' => '',
'updatevon' => $authUID,
'updateamum' => $now
]);
if (isError($result))
return $result;
// Studentlehrverband updaten
$result = $this->_ci->StudentlehrverbandModel->update([
'student_uid' => $student->student_uid,
'studiensemester_kurzbz' => $semester_aktuell
], [
'semester' => $ausbildungssemester,
'verband' => '',
'gruppe' => '',
'updatevon' => $authUID,
'updateamum' => $now
]);
if (isError($result))
return $result;
// Benutzer updaten
$result = $this->_ci->BenutzerModel->load([$student->student_uid]);
if (isError($result))
return $result;
if (!hasData($result))
return error($this->_ci->p->t('person', 'error_noBenutzer'));
$benutzer = current(getData($result));
$updateData = [
'aktiv' => true,
'updateamum' => $now,
'updatevon' => $authUID
];
if (!$benutzer->aktiv) {
$updateData['updateaktivam'] = $now;
$updateData['updateaktivvon'] = $authUID;
}
$this->_ci->BenutzerModel->update([$student->student_uid], $updateData);
return success();
}
public function setFirstStudent(
$prestudent_id,
$studiensemester_kurzbz,
$ausbildungssemester,
$orgform_kurzbz,
$studienplan_id,
$statusgrund_id
) {
$this->_ci->PrestudentModel->addJoin('public.tbl_person p', 'person_id');
$this->_ci->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz');
$result = $this->_ci->PrestudentModel->load($prestudent_id);
if (isError($result))
return $result;
if (!hasData($result))
return error('No prestudent');
$student_data = current(getData($result));
$authUID = getAuthUID();
$now = date('c');
$today = date('Y-m-d');
$jahr = mb_substr($studiensemester_kurzbz, 4, 2);
// Genererate Personenkennzeichen
$personenkennzeichen = $this->_ci->StudentModel->generateMatrikelnummer2(
$student_data->studiengang_kz,
$studiensemester_kurzbz,
$student_data->typ
);
if (isError($personenkennzeichen))
return $personenkennzeichen;
$personenkennzeichen = getData($personenkennzeichen);
// Generate UID
$uid = $this->_ci->StudentModel->generateUID(
$student_data->kurzbz,
$jahr,
$student_data->typ,
$personenkennzeichen,
$student_data->vorname,
$student_data->nachname
);
if (isError($uid))
return $uid;
$uid = getData($uid);
// Generate Matrikelnummer
$matrikelnummer = $this->_ci->BenutzerModel->generateMatrikelnummer(
$student_data->oe_kurzbz
);
if (isError($matrikelnummer))
return $matrikelnummer;
$matrikelnummer = getData($matrikelnummer);
// Generate Alias
$alias = '';
if (!defined('GENERATE_ALIAS_STUDENT')
|| GENERATE_ALIAS_STUDENT === true
) {
$result = $this->_ci->BenutzerModel->generateAliasFromName($student_data->vorname, $student_data->nachname);
if (isError($result))
return $result;
$alias = getData($result);
}
// Generate Activation Key
$activationkey = $this->_ci->BenutzerModel->generateActivationkey();
// Overwrite stuff
if (defined('SET_UID_AS_MATRIKELNUMMER')
&& SET_UID_AS_MATRIKELNUMMER)
$matrikelnummer = $uid;
if (defined('SET_UID_AS_PERSONENKENNZEICHEN')
&& SET_UID_AS_PERSONENKENNZEICHEN)
$personenkennzeichen = $uid;
// Update Person
$this->_ci->load->model('person/Person_model', 'PersonModel');
$result = $this->_ci->PersonModel->update([
'person_id' => $student_data->person_id,
'matr_nr' => null
], [
'matr_nr' => $matrikelnummer
]);
if (isError($result))
return $result;
// Add Benutzer
$result = $this->_ci->BenutzerModel->insert([
'uid' => $uid,
'person_id' => $student_data->person_id,
'aktiv' => true,
'aktivierungscode' => $activationkey,
'alias' => $alias,
'insertvon' => $authUID,
'insertamum' => $now,
]);
if (isError($result))
return $result;
// Add Student
$result = $this->_ci->StudentModel->insert([
'student_uid' => $uid,
'matrikelnr' => $personenkennzeichen,
'prestudent_id' => $prestudent_id,
'studiengang_kz' => $student_data->studiengang_kz,
'semester' => $ausbildungssemester,
'verband' => ' ',
'gruppe' => ' ',
'insertvon' => $authUID,
'insertamum' => $now
]);
if (isError($result))
return $result;
// Add Lehrverband if it does not exist
$result = $this->_ci->LehrverbandModel->load([' ', ' ', $ausbildungssemester, $student_data->studiengang_kz]);
if (isError($result))
return $result;
if (!hasData($result)) {
$result = $this->_ci->LehrverbandModel->insert([
'studiengang_kz' => $student_data->studiengang_kz,
'semester' => $ausbildungssemester,
'verband' => ' ',
'gruppe' => ' ',
'aktiv' => true
]);
if (isError($result))
return $result;
}
// Add Rolle
$result = $this->_ci->PrestudentstatusModel->insert([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => Prestudentstatus_model::STATUS_STUDENT,
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'ausbildungssemester' => $ausbildungssemester,
'orgform_kurzbz'=> $orgform_kurzbz,
'studienplan_id'=> $studienplan_id,
'datum' => $today,
'insertamum' => $now,
'insertvon' => $authUID,
'bestaetigtam' => $today,
'bestaetigtvon' => $authUID,
'statusgrund_id' => $statusgrund_id
]);
if (isError($result))
return $result;
// Add Studentlehrverband
$result = $this->_ci->StudentlehrverbandModel->insert([
'student_uid' => $uid,
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'studiengang_kz' => $student_data->studiengang_kz,
'semester' => $ausbildungssemester,
'verband' => ' ',
'gruppe' => ' ',
'insertamum' => $now,
'insertvon' => $authUID
]);
if (isError($result))
return $result;
return success();
}
public function setDiplomand($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
{
return $this->setBasic(
getAuthUID(),
date('c'),
Prestudentstatus_model::STATUS_DIPLOMAND,
$prestudent_id,
$studiensemester_kurzbz,
$ausbildungssemester,
$statusgrund_id
);
}
public function setAbsolvent($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
{
$authUID = getAuthUID();
$now = date('c');
$result = $this->setBasic(
$authUID,
$now,
Prestudentstatus_model::STATUS_ABSOLVENT,
$prestudent_id,
$studiensemester_kurzbz,
$ausbildungssemester,
$statusgrund_id
);
if (isError($result))
return $result;
// Load Student
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
if (isError($result))
return $result;
if (!hasData($result))
return error($this->_ci->p->t('studierendenantrag', 'error_no_student_for_prestudent', ['prestudent_id' => $prestudent_id]));
$student = current(getData($result));
// Benutzer inaktiv setzen
$this->_ci->BenutzerModel->update([
'uid' => $student->student_uid
], [
'aktiv' => false,
'updateaktivvon' => $authUID,
'updateaktivam' => $now,
'updatevon' => $authUID,
'updateamum' => $now
]);
if (isError($result))
return $result;
return success();
}
public function setBewerber($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
{
$result = $this->setBasic(
getAuthUID(),
date('c'),
Prestudentstatus_model::STATUS_BEWERBER,
$prestudent_id,
$studiensemester_kurzbz,
$ausbildungssemester,
$statusgrund_id
);
if (isError($result))
return $result;
if (SEND_BEWERBER_INFOMAIL) {
// TODO(chris): IMPLEMENT!
}
return success();
}
public function setAufgenommener($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
{
return $this->setBasic(
getAuthUID(),
date('c'),
Prestudentstatus_model::STATUS_AUFGENOMMENER,
$prestudent_id,
$studiensemester_kurzbz,
$ausbildungssemester,
$statusgrund_id
);
}
public function setAbgewiesener($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
{
return $this->setBasic(
getAuthUID(),
date('c'),
Prestudentstatus_model::STATUS_ABGEWIESENER,
$prestudent_id,
$studiensemester_kurzbz,
$ausbildungssemester,
$statusgrund_id
);
}
public function setWartender($prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id)
{
return $this->setBasic(
getAuthUID(),
date('c'),
Prestudentstatus_model::STATUS_WARTENDER,
$prestudent_id,
$studiensemester_kurzbz,
$ausbildungssemester,
$statusgrund_id
);
}
protected function setBasic($authUID, $now, $status_kurzbz, $prestudent_id, $studiensemester_kurzbz, $ausbildungssemester, $statusgrund_id = null)
{
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
if (isError($result))
return $result;
if (!hasData($result))
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudentstatus', [
'prestudent_id' => $prestudent_id
]));
$prestudent_status = current(getData($result));
// Update Aktionen
// Status updaten
$result = $this->_ci->PrestudentstatusModel->insert([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => $status_kurzbz,
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'ausbildungssemester' => $ausbildungssemester,
'datum' => $now,
'insertvon' => $authUID,
'insertamum' => $now,
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
'studienplan_id'=> $prestudent_status->studienplan_id,
'bestaetigtvon' => $authUID,
'bestaetigtam' => $now,
'statusgrund_id' => $statusgrund_id
]);
if (isError($result))
return $result;
return success();
}
}
@@ -0,0 +1,922 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class PrestudentstatusCheckLib
{
const INTERESSENT_STATUS = 'Interessent';
const BEWERBER_STATUS = 'Bewerber';
const AUFGENOMMENER_STATUS = 'Aufgenommener';
const UNTERBRECHER_STATUS = 'Unterbrecher';
const STUDENT_STATUS = 'Student';
const DIPLOMAND_STATUS = 'Diplomand';
const ABSOLVENT_STATUS = 'Absolvent';
const ABBRECHER_STATUS = 'Abbrecher';
private $_ci;
private $_statusAbfolgeVorStudent = [self::INTERESSENT_STATUS, self::BEWERBER_STATUS, self::AUFGENOMMENER_STATUS];
private $_endStatusArr = [self::ABSOLVENT_STATUS, self::ABBRECHER_STATUS];
private $_cache_history = [];
/**
* Object initialization
*/
public function __construct()
{
$this->_ci =& get_instance();
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->_ci->load->model('person/Person_model', 'PersonModel');
$this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->_ci->load->model('crm/Student_model', 'StudentModel');
$this->_ci->load->model('organisation/Studienplan_model', 'StudienplanModel');
$this->_ci->load->model('codex/Bismeldestichtag_model', 'BismeldestichtagModel');
}
/**
* Checks if a status add is valid.
* @return object error if invalid
*/
public function checkStatusAdd(
$prestudent_id,
$status_kurzbz,
$new_status_studiensemester_kurzbz,
$new_status_datum,
$new_status_ausbildungssemester,
$new_studienplan_id
) {
$studentName = '';
$nameRes = $this->_ci->PersonModel->loadPrestudent($prestudent_id);
if (hasData($nameRes))
{
$nameData = getData($nameRes)[0];
$studentName = $nameData->vorname.' '.$nameData->nachname;
}
// Datum des neuen Status darf nicht in Vergangenheit liegen, sonst Probleme wenn neues Datum < Bismeldedatum
if (new DateTime($new_status_datum) < new DateTime('today'))
return error($studentName . $this->_ci->p->t('lehre', 'error_entryInPast'));
return $this->_checkIfValidStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_status_studiensemester_kurzbz,
$new_status_datum,
$new_status_ausbildungssemester,
$new_studienplan_id
);
}
/**
* Checks if a status update is valid.
* @return error if invalid
*/
public function checkStatusUpdate(
$prestudent_id,
$status_kurzbz,
$new_status_studiensemester_kurzbz,
$new_status_datum,
$new_status_ausbildungssemester,
$new_studienplan_id,
$old_status_studiensemester,
$old_status_ausbildungssemester
) {
return $this->_checkIfValidStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_status_studiensemester_kurzbz,
$new_status_datum,
$new_status_ausbildungssemester,
$new_studienplan_id,
$old_status_studiensemester,
$old_status_ausbildungssemester
);
}
/**
* Checks if a student already exists.
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function checkIfExistingStudent($prestudent_id)
{
$result = $this->_ci->StudentModel->loadWhere([
'prestudent_id' => $prestudent_id
]);
if (isError($result))
return $result;
return success(hasData($result));
}
/**
* Check if Reihungstest was admitted
*
* @param stdClass $prestudent
*
* @return stdClass
*/
public function checkIfAngetreten($prestudent)
{
return success($prestudent->reihungstestangetreten);
}
/**
* Check if ZGV-Code is registered
*
* @param stdClass $prestudent
*
* @return stdClass
*/
public function checkIfZGVEingetragen($prestudent_person)
{
return success((boolean)$prestudent_person->zgv_code);
}
/**
* Check if Master ZGV-Code is registered
*
* @param stdClass $prestudent
*
* @return booleans $zgv_code, error if not registered
*/
public function checkIfZGVEingetragenMaster($prestudent)
{
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
$result = $this->_ci->StudiengangModel->load($prestudent->studiengang_kz);
if (isError($result))
return $result;
if (!hasData($result))
return error($this->_ci->p->t('studierendenantrag', 'error_no_stg', ['studiengang_kz' => $prestudent->studiengang_kz]));
if (current($result->retval)->typ != 'm')
return success(true); // NOTE(chris): we only test master stgs, all other stgs should default to true
return success((boolean)$prestudent->zgvmas_code);
}
/**
* Checks if a bewerber status already exists.
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function checkIfExistingBewerberstatus($prestudent_id)
{
$result = $this->_ci->PrestudentstatusModel->loadWhere([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER
]);
if (isError($result))
return $result;
return success(hasData($result));
}
/**
* Checks if status aufgenommen already exists.
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function checkIfExistingAufgenommenerstatus($prestudent_id)
{
$result = $this->_ci->PrestudentstatusModel->loadWhere([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER
]);
if (isError($result))
return $result;
return success(hasData($result));
}
/**
* Checks if the last Bewerber status and the last Aufgenommener status
* have the same studiensemester and ausbildungssemester.
*
* Attention:
* If one of those two status is missing the function returns true!
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function checkIfLastBewerberAndAufgenommenerShareSemesters($prestudent_id)
{
$this->_ci->PrestudentstatusModel->addOrder('datum', 'DESC');
$this->_ci->PrestudentstatusModel->addOrder('insertamum', 'DESC');
$this->_ci->PrestudentstatusModel->addLimit(1);
$result = $this->_ci->PrestudentstatusModel->loadWhere([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => Prestudentstatus_model::STATUS_BEWERBER
]);
if (isError($result))
return $result;
if (!hasData($result))
return success(true);
$bewerber = current(getData($result));
$this->_ci->PrestudentstatusModel->addOrder('datum', 'DESC');
$this->_ci->PrestudentstatusModel->addOrder('insertamum', 'DESC');
$this->_ci->PrestudentstatusModel->addLimit(1);
$result = $this->_ci->PrestudentstatusModel->loadWhere([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => Prestudentstatus_model::STATUS_AUFGENOMMENER
]);
if (isError($result))
return $result;
if (!hasData($result))
return success(true);
$aufgenommener = current(getData($result));
return success(
$bewerber->studiensemester_kurzbz == $aufgenommener->studiensemester_kurzbz
&& $bewerber->ausbildungssemester == $aufgenommener->ausbildungssemester
);
}
/**
* Check if Bismeldestichtag erreicht
*
* @param DateTime $statusDatum
* @param string $studiensemester_kurzbz
*
* @return stdClass
*/
public function checkIfMeldestichtagErreicht($statusDatum, $studiensemester_kurzbz = null)
{
$result = $this->_ci->BismeldestichtagModel->checkIfMeldestichtagErreicht($statusDatum, $studiensemester_kurzbz);
if (isError($result))
return $result;
return success(getData($result) == "1");
}
/**
* Runs all checks on Status History and saves it in cache.
*
* @param integer $prestudent_id
* @param string $status_kurzbz
* @param DateTime $new_date
* @param string $new_studiensemester_kurzbz
* @param integer $new_ausbildungssemester
* @param string $old_studiensemester_kurzbz
* @param integer $old_ausbildungssemester
*
* @return stdClass
*/
protected function prepareStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
) {
// Generate key for caching
$primary = implode('|', [
$prestudent_id,
$status_kurzbz,
$new_date->format('Y-m-d'),
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
]);
if (isset($this->_cache_history[$primary]))
return $this->_cache_history[$primary];
$this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
// Get the history
$result = $this->_ci->PrestudentstatusModel->getHistoryWithNewOrEditedState(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
);
if (isError($result))
return $result;
if (!hasData($result))
return error('This is impossible');
$history = getData($result);
$historyCount = count($history);
// Run checks
$checks = [
'timesequence' => true,
'laststatus' => true,
'unterbrechersemester' => true,
'abbrechersemester' => true,
'diplomant' => true,
'student' => true
];
for ($n = 0, $c = 1; $c < $historyCount; $n++, $c++) {
if (!$checks['timesequence']
&& !$checks['laststatus']
&& !$checks['unterbrechersemester']
&& !$checks['abbrechersemester']
&& !$checks['diplomant']
&& !$checks['student']
)
break; // early out
$next = $history[$n];
$current = $history[$c];
// Zeitabfolge ungültig?
if ($checks['timesequence']
&& $next->start < $current->start
)
$checks['timesequence'] = false;
// Abbrecher- oder Absolventenstatus muss Endstatus sein
if ($checks['laststatus']
&& in_array($current->status_kurzbz, [self::ABSOLVENT_STATUS, self::ABBRECHER_STATUS])
)
$checks['laststatus'] = false;
// wenn Unterbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
if ($checks['unterbrechersemester']
&& $current->status_kurzbz == self::UNTERBRECHER_STATUS
&& $next->status_kurzbz == self::UNTERBRECHER_STATUS
&& $current->ausbildungssemester != $next->ausbildungssemester
)
$checks['unterbrechersemester'] = false;
// wenn Abbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
if ($checks['abbrechersemester']
&& $current->status_kurzbz == self::UNTERBRECHER_STATUS
&& $next->status_kurzbz == self::ABBRECHER_STATUS
&& $current->ausbildungssemester != $next->ausbildungssemester
)
$checks['abbrechersemester'] = false;
if (($checks['diplomant']
|| $checks['student'])
&& $next->status_kurzbz == self::STUDENT_STATUS
) {
$restl_stati = array_unique(array_column(array_slice($history, $c), 'status_kurzbz'));
// keine Studenten nach Diplomand Status
if ($checks['diplomant']
&& in_array(self::DIPLOMAND_STATUS, $restl_stati)
)
$checks['diplomant'] = false;
// vor Studentenstatus müssen bestimmte Status vorhanden sein
if ($checks['student']
&& array_values(array_intersect($restl_stati, $this->_statusAbfolgeVorStudent)) != array_values($this->_statusAbfolgeVorStudent)
)
$checks['student'] = false;
}
}
$this->_cache_history[$primary] = success($checks);
return success($checks);
}
/**
* Checks if the time sequence of the status history is valid.
*
* @param integer $prestudent_id
* @param string $status_kurzbz
* @param DateTime $new_date
* @param string $new_studiensemester_kurzbz
* @param integer $new_ausbildungssemester
* @param string $old_studiensemester_kurzbz
* @param integer $old_ausbildungssemester
*
* @return stdClass
*/
public function checkStatusHistoryTimesequence(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
) {
$result = $this->prepareStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
);
if (isError($result))
return $result;
return success(getData($result)['timesequence']);
}
/**
* Checks if the last status of the status history is not Abbrecher or
* Absolvent.
*
* @param integer $prestudent_id
* @param string $status_kurzbz
* @param DateTime $new_date
* @param string $new_studiensemester_kurzbz
* @param integer $new_ausbildungssemester
* @param string $old_studiensemester_kurzbz
* @param integer $old_ausbildungssemester
*
* @return stdClass
*/
public function checkStatusHistoryLaststatus(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
) {
$result = $this->prepareStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
);
if (isError($result))
return $result;
return success(getData($result)['laststatus']);
}
/**
* Checks if two consecutively Unterbrecher have the same
* ausbildungssemester in the status history.
*
* @param integer $prestudent_id
* @param string $status_kurzbz
* @param DateTime $new_date
* @param string $new_studiensemester_kurzbz
* @param integer $new_ausbildungssemester
* @param string $old_studiensemester_kurzbz
* @param integer $old_ausbildungssemester
*
* @return stdClass
*/
public function checkStatusHistoryUnterbrechersemester(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
) {
$result = $this->prepareStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
);
if (isError($result))
return $result;
return success(getData($result)['unterbrechersemester']);
}
/**
* Checks if an Unterbrecher followed by an Abbrecher have the same
* ausbildungssemester in the status history.
*
* @param integer $prestudent_id
* @param string $status_kurzbz
* @param DateTime $new_date
* @param string $new_studiensemester_kurzbz
* @param integer $new_ausbildungssemester
* @param string $old_studiensemester_kurzbz
* @param integer $old_ausbildungssemester
*
* @return stdClass
*/
public function checkStatusHistoryAbbrechersemester(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
) {
$result = $this->prepareStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
);
if (isError($result))
return $result;
return success(getData($result)['abbrechersemester']);
}
/**
* Checks if no Diplomant is followed by a Student in the status history.
*
* @param integer $prestudent_id
* @param string $status_kurzbz
* @param DateTime $new_date
* @param string $new_studiensemester_kurzbz
* @param integer $new_ausbildungssemester
* @param string $old_studiensemester_kurzbz
* @param integer $old_ausbildungssemester
*
* @return stdClass
*/
public function checkStatusHistoryDiplomant(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
) {
$result = $this->prepareStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
);
if (isError($result))
return $result;
return success(getData($result)['diplomant']);
}
/**
* Checks if a Student precedes given stati in the status history.
*
* @param integer $prestudent_id
* @param string $status_kurzbz
* @param DateTime $new_date
* @param string $new_studiensemester_kurzbz
* @param integer $new_ausbildungssemester
* @param string $old_studiensemester_kurzbz
* @param integer $old_ausbildungssemester
*
* @return stdClass
*/
public function checkStatusHistoryStudent(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
) {
// TODO(chris): TEST
$result = $this->prepareStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
);
if (isError($result))
return $result;
return success(getData($result)['student']);
}
/**
* Checks if Personenkennzeichen is set correctly.
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function checkPersonenkennzeichen($prestudent_id)
{
// TODO(chris): TEST
$this->_ci->PrestudentstatusModel->addSelect('tbl_prestudentstatus.prestudent_id');
$this->_ci->PrestudentstatusModel->addSelect('tbl_student.matrikelnr');
$this->_ci->PrestudentstatusModel->addJoin('public.tbl_student', 'prestudent_id');
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.datum', 'DESC');
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.insertamum', 'DESC');
$this->_ci->PrestudentstatusModel->addOrder('tbl_prestudentstatus.ext_id', 'DESC');
$this->_ci->PrestudentstatusModel->addLimit(1);
$result = $this->_ci->PrestudentstatusModel->loadWhere([
'tbl_prestudentstatus.prestudent_id' => $prestudent_id,
'tbl_prestudentstatus.status_kurzbz' => self::STATUS_STUDENT
]);
if (isError($result))
return $result;
if (!hasData($result))
return success(true); // Not a student yet so no wrong personenkennzeichen
$data = current(getData($result));
$jahr = $this->_ci->StudiensemesterModel->getStudienjahrNumberFromStudiensemester($data->studiensemester_kurzbz);
return success($jahr == mb_substr($data->matrikelnr, 0, 2));
}
/**
* Checks if Orgform of Student status and Bewerber status match.
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function checkStudentOrgform($prestudent_id)
{
// TODO(chris): TEST
$result = $this->_ci->PrestudentstatusModel->getBewerberWhereOrgformNotStudent($prestudent_id);
if (isError($result))
return $result;
return success(!hasData($result));
}
/**
* Check if History of StatusData is valid
* @param integer $prestudent_id
* @return error if not valid, array StatusArr if valid
*/
private function _checkIfValidStatusHistory(
$prestudent_id,
$status_kurzbz,
$new_status_studiensemester_kurzbz,
$new_status_datum,
$new_status_ausbildungssemester,
$new_studienplan_id,
$old_status_studiensemester = null,
$old_status_ausbildungssemester = null
) {
//get start studiensemester
$semResult = $this->_ci->StudiensemesterModel->load([
'studiensemester_kurzbz' => $new_status_studiensemester_kurzbz
]);
if (isError($semResult))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($semResult));
}
if (!hasData($semResult)) {
return error($this->_ci->p->t('lehre', 'error_noStudiensemester') . $new_status_studiensemester_kurzbz);
}
$studiensemester = getData($semResult)[0];
$new_status_semesterstart = $studiensemester->start;
// get studienplan orgform
$new_studienplan_orgform_kurzbz = '';
$this->_ci->StudienplanModel->addSelect('orgform_kurzbz');
$stplResult = $this->_ci->StudienplanModel->load([
'studienplan_id' => $new_studienplan_id
]);
if (isError($stplResult))
{
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
return $this->outputJson(getError($stplResult));
}
if (hasData($stplResult)) $new_studienplan_orgform_kurzbz = getData($stplResult)[0]->orgform_kurzbz;
//get all prestudentstati
$resultPs = $this->_ci->PrestudentstatusModel->getAllPrestudentstatiWithStudiensemester($prestudent_id);
if (isError($resultPs)) return $resultPs;
$resultArr = hasData($resultPs) ? getData($resultPs) : [];
$statusArr = [];
$newStatusInserted = false;
$new_status_datum_form = new DateTime($new_status_datum);
$new_status_semesterstart_form = new DateTime($new_status_semesterstart);
if (!isEmptyArray($resultArr))
{
// neuen Status zum Hinzufügen
$first_status = $resultArr[0];
$neuer_status = new stdClass();
$neuer_status->status_kurzbz = $status_kurzbz;
$neuer_status->studiensemester_kurzbz = $new_status_studiensemester_kurzbz;
$neuer_status->datum = $new_status_datum;
$neuer_status->ausbildungssemester = $new_status_ausbildungssemester;
$neuer_status->studienplan_orgform_kurzbz = $new_studienplan_orgform_kurzbz;
$neuer_status->matrikelnr = $first_status->matrikelnr;
$neuer_status->vorname = $first_status->vorname;
$neuer_status->nachname = $first_status->nachname;
// Status, welcher gerade geändert wird, holen
$status_to_change = array_filter(
$resultArr,
function ($status) use ($status_kurzbz, $old_status_studiensemester, $old_status_ausbildungssemester) {
return
$status->status_kurzbz == $status_kurzbz
&& $status->studiensemester_kurzbz == $old_status_studiensemester
&& $status->ausbildungssemester == $old_status_ausbildungssemester;
}
);
if (!isEmptyArray($status_to_change))
{
$status_to_change_index = key($status_to_change);
// wenn sich Studiensemester und Ausbildungssemester nicht geändert haben...
if ($new_status_studiensemester_kurzbz == $old_status_studiensemester
&& $new_status_ausbildungssemester == $old_status_ausbildungssemester)
{
// ...neuen status an selber stelle einfügen wie zu ändernder Status
$resultArr[$status_to_change_index] = (object)array_merge((array)$resultArr[$status_to_change_index], (array)$neuer_status);
$newStatusInserted = true;
}
else
{
// bei Status mit neuem Semester: alten Status entfernen
unset($resultArr[$status_to_change_index]);
}
}
}
foreach ($resultArr as $row)
{
$studiensemester_start = new DateTime($row->studiensemester_start);
$status_datum = new DateTime($row->datum);
if ($new_status_datum_form >= $status_datum && $new_status_semesterstart_form >= $studiensemester_start)
{
if (!$newStatusInserted)
{
// neuer Status erstmals größer als Datum eines bestehenden Status -> neuen Status EINMALIG einfügen für spätere Statusprüfung
$statusArr[] = $neuer_status;
$newStatusInserted = true;
}
$statusArr[] = $row;
}
elseif ($new_status_datum_form <= $status_datum && $new_status_semesterstart_form <= $studiensemester_start)
{
$statusArr[] = $row;
}
else
{
// Zeitabfolge ungültig, Fehler
return error($this->_ci->p->t('lehre', 'error_statuseintrag_zeitabfolge'));
}
}
// erster Studentstatus
$ersterStudent = null;
// Über alle gespeicherten Status gehen und Statusabfolge prüfen
for ($i = 0; $i < count($statusArr); $i++)
{
$curr_status = $statusArr[$i];
$curr_status_kurzbz = $curr_status->status_kurzbz;
$curr_status_ausbildungssemester = $curr_status->ausbildungssemester;
$next_idx = $i - 1; //absteigend sortiert, nächster Status ist vorheriger Eintrag
$next_status = isset($statusArr[$next_idx]) ? $statusArr[$next_idx] : null;
$studentName = $curr_status->vorname . ' ' . $curr_status->nachname;
if ($curr_status_kurzbz == self::STUDENT_STATUS) $ersterStudent = $curr_status;
// Abbrecher- oder Absolventenstatus muss Endstatus sein
if (isset($next_status) && in_array($curr_status_kurzbz, $this->_endStatusArr))
{
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_endstatus'));
}
// wenn Unterbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
if
($curr_status_kurzbz == self::UNTERBRECHER_STATUS && isset($next_status) && $next_status->status_kurzbz == self::UNTERBRECHER_STATUS
&& $curr_status_ausbildungssemester != $next_status->ausbildungssemester)
{
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveUnterbrecher'));
}
// wenn Abbrecher auf Unterbrecher folgt, muss Ausbildungssemester gleich sein
if (isset($next_status)
&& $curr_status_kurzbz == self::UNTERBRECHER_STATUS
&& $next_status->status_kurzbz == self::ABBRECHER_STATUS && $curr_status_ausbildungssemester != $next_status->ausbildungssemester)
{
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveUnterbrecherAbbrecher'));
}
if (isset($next_status) && $next_status->status_kurzbz == self::STUDENT_STATUS)
{
$restliche_status_obj = array_slice($statusArr, $i);
$restliche_status = array_unique(array_column($restliche_status_obj, 'status_kurzbz'));
$status_intersected = array_intersect($restliche_status, $this->_statusAbfolgeVorStudent);
// Vor Studentstatus darf kein Diplomand Status vorhanden sein
if (in_array(self::DIPLOMAND_STATUS, $restliche_status))
{
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_consecutiveDiplomandStudent'));
}
// Vor Studentstatus müssen bestimmte Status vorhanden sein
if (array_values($status_intersected) != array_values(array_reverse($this->_statusAbfolgeVorStudent)))
{
return error(
$studentName . ' '
. $this->_ci->p->t('lehre', 'error_wrongStatusOrderBeforeStudent', array(implode(', ', $this->_statusAbfolgeVorStudent)))
);
}
}
}
if (isset($ersterStudent))
{
$studentName = $ersterStudent->vorname . ' ' . $ersterStudent->nachname;
// wenn erster Studentstatus, checken ob Personenkennzeichen passt
$studienjahrNumber = $this->_ci->StudiensemesterModel->getStudienjahrNumberFromStudiensemester($ersterStudent->studiensemester_kurzbz);
if ($studienjahrNumber != mb_substr($ersterStudent->matrikelnr, 0, 2))
{
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_personenkennzeichenPasstNichtZuStudiensemester'));
}
// wenn erster Studentstatus, checken ob Orgform des Bewerbers mit Studenten übereinstimmt
if (!isEmptyArray(
array_filter(
$restliche_status_obj,
function ($s) use ($ersterStudent) {
return
$s->status_kurzbz == self::BEWERBER_STATUS
&& (
$s->studienplan_orgform_kurzbz != $ersterStudent->studienplan_orgform_kurzbz
);
}
)
)
)
{
return error($studentName . ' ' . $this->_ci->p->t('lehre', 'error_bewerberOrgformUngleichStudentOrgform'));
}
}
return $resultPs;
}
}
+64
View File
@@ -358,6 +358,35 @@ EOSC;
*/
private function _student($searchstr, $type)
{
$dbModel = new DB_Model();
$students = $dbModel->execReadOnlyQuery('
SELECT
\''.$type.'\' AS type,
s.student_uid AS uid,
s.matrikelnr,
p.person_id AS person_id,
p.vorname || \' \' || p.nachname AS name,
k.kontakt as email ,
p.foto
FROM public.tbl_student s
JOIN public.tbl_benutzer b ON(b.uid = s.student_uid)
JOIN public.tbl_person p USING(person_id)
LEFT JOIN (
SELECT kontakt, person_id
FROM public.tbl_kontakt
WHERE kontakttyp = \'email\'
) as k USING(person_id)
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
GROUP BY type, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto
');
// If something has been found then return it
if (hasData($students)) return getData($students);
// Otherwise return an empty array
return array();
}
@@ -366,6 +395,41 @@ EOSC;
*/
private function _prestudent($searchstr, $type)
{
$dbModel = new DB_Model();
$prestudent = $dbModel->execReadOnlyQuery('
SELECT
\''.$type.'\' AS type,
ps.prestudent_id,
ps.studiengang_kz,
p.person_id AS person_id,
b.uid,
p.vorname || \' \' || p.nachname AS name,
(
SELECT kontakt
FROM public.tbl_kontakt
WHERE kontakttyp = \'email\'
AND person_id = p.person_id
LIMIT 1
) as email,
p.foto,
sg.bezeichnung
FROM public.tbl_prestudent ps
LEFT JOIN public.tbl_student s USING (prestudent_id)
LEFT JOIN public.tbl_benutzer b ON (b.uid = s.student_uid)
JOIN public.tbl_person p ON (p.person_id = ps.person_id)
LEFT JOIN public.tbl_studiengang sg ON (sg.studiengang_kz = ps.studiengang_kz)
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
or cast(ps.prestudent_id as text) ILIKE \'%'.$dbModel->escapeLIKE($searchstr).'%\'
GROUP BY type, b.uid, ps.prestudent_id, ps.studiengang_kz, sg.bezeichnung, s.student_uid, s.matrikelnr, p.person_id, name, email, p.foto
');
// If something has been found then return it
if (hasData($prestudent)) return getData($prestudent);
// Otherwise return an empty array
return array();
}
+163 -5
View File
@@ -65,6 +65,8 @@ class UDFLib
private $_udfUniqueId; // Property that contains the UDF widget unique id
private $_definition_cache = [];
/**
* Gets CI instance
*/
@@ -157,7 +159,7 @@ class UDFLib
$found = false; // used to check if the field is found or not in the json schema
$this->_sortJsonSchemas($jsonSchemasArray); // Sort the list of UDF by sort property
// Loops through json schemas
foreach ($jsonSchemasArray as $jsonSchema)
{
@@ -292,7 +294,7 @@ class UDFLib
// Checks if the requiredPermissions is available and it is a valid array or a valid string
if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
&& (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
{
// Then check if the user has the permissions to read such UDF
if (!$this->_readAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))
@@ -353,7 +355,7 @@ class UDFLib
// Checks if the requiredPermissions is available and it is a valid array or a valid string
if (isset($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
&& (!isEmptyArray($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
|| !isEmptyString($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER})))
{
// Then check if the user has the permissions to write such UDF
if (!$this->_writeAllowed($decodedUDFDefinition->{self::REQUIRED_PERMISSIONS_PARAMETER}))
@@ -613,6 +615,162 @@ class UDFLib
);
}
/**
* Gets the UDF definitions for a model
*
* @param DB_Model $targetModel
*
* @return stdClass
*/
public function getDefinitionForModel($targetModel)
{
$dbTable = $targetModel->getDbTable();
if (!isset($this->_definition_cache[$dbTable])) {
$this->_ci->load->model('system/UDF_model', 'UDFModel');
list($schema, $table) = explode('.', $dbTable);
$result = $this->_ci->UDFModel->loadWhere([
'schema' => $schema,
'table' => $table
]);
if (isError($result))
return $result;
if (!hasData($result))
$this->_definition_cache[$dbTable] = [];
else
$this->_definition_cache[$dbTable] = json_decode(current($result->retval)->jsons, true);
}
return success($this->_definition_cache[$dbTable]);
}
/**
* Gets the UDFs for db entry with translated params and resolved listValues for dropdowns
*
* @param DB_Model $targetModel
* @param mixed $id
*
* @return stdClass
*/
public function getFieldArray($targetModel, $id)
{
// Load Libraries
$this->_ci->load->library('PhrasesLib');
$this->_ci->load->library('PermissionLib');
$result = $this->getDefinitionForModel($targetModel);
if (isError($result))
return $result;
$definitions = $result->retval;
usort($definitions, function ($a, $b) {
return $a[self::SORT] - $b[self::SORT];
});
$values = $targetModel->getUDFs($id);
$fields = [];
foreach ($definitions as $field) {
// check read permissions
if (!$this->_ci->permissionlib->hasAtLeastOne(
$field[self::REQUIRED_PERMISSIONS_PARAMETER],
self::PERMISSION_TABLE_METHOD,
self::PERMISSION_TYPE_READ
))
continue;
// set value
if (isset($values[$field[self::NAME]])) {
$field['value'] = $values[$field[self::NAME]];
} elseif (isset($field['defaultValue'])) {
$field['value'] = $field['defaultValue'];
} elseif (isset($field[self::TYPE]) && $field[self::TYPE] == 'checkbox') {
$field['value'] = false;
} else {
$field['value'] = '';
}
// translate params
foreach ([self::LABEL, self::TITLE, self::PLACEHOLDER] as $key) {
if (isset($field[$key])) {
$res = $this->_ci->phraseslib->getPhrases(self::PHRASES_APP_NAME, getUserLanguage(), $field[$key], null, null, 'no');
if (hasData($res))
$field[$key] = current(getData($res))->text;
}
}
// check write permissions
$field['disabled'] = !$this->_ci->permissionlib->hasAtLeastOne(
$field[self::REQUIRED_PERMISSIONS_PARAMETER],
self::PERMISSION_TABLE_METHOD,
self::PERMISSION_TYPE_WRITE
);
// set listValues for dropdowns
if (isset($field[self::LIST_VALUES])) {
if (isset($field[self::LIST_VALUES]['enum'])) {
$field['options'] = $field[self::LIST_VALUES]['enum'];
} elseif (isset($field[self::LIST_VALUES]['sql'])) {
$res = $this->_ci->UDFModel->execReadOnlyQuery($field[self::LIST_VALUES]['sql']);
$field['options'] = hasData($res) ? getData($res) : [];
}
}
// add to array
$fields[] = $field;
}
return success($fields);
}
/**
* Gets a validation config array for CI form_validation
*
* @param DB_Model $targetModel
* @param array (optional) $filter
*
* @return stdClass
*/
public function getCiValidations($targetModel, $filter = null)
{
$result = $this->getDefinitionForModel($targetModel);
if (isError($result))
return $result;
$definitions = getData($result);
$result = [];
foreach ($definitions as $def) {
if ($filter && !isset($filter[$def['name']]))
continue;
$validations = [];
if (isset($def['requiredPermissions']))
$validations[] = 'has_write_permissions[' . implode(',', $def['requiredPermissions']) . ']';
if (isset($def['required']))
$validations[] = 'required';
if (isset($def['validation'])) {
if (isset($def['validation']['max-value']))
$validations[] = 'less_than_equal_to[' . $def['validation']['max-value'] . ']';
if (isset($def['validation']['min-value']))
$validations[] = 'greater_than_equal_to[' . $def['validation']['min-value'] . ']';
if (isset($def['validation']['max-length']))
$validations[] = 'max_length[' . $def['validation']['max-length'] . ']';
if (isset($def['validation']['min-length']))
$validations[] = 'min_length[' . $def['validation']['min-length'] . ']';
if (isset($def['validation']['regex']) && is_array($def['validation']['regex'])) {
foreach ($def['validation']['regex'] as $regex) {
if ($regex['language'] == 'php') {
$validations[] = 'regex_match[' . $regex['expression'] . ']';
}
}
}
}
if ($validations)
$result[] = [
'field' => $def['name'],
'label' => $def['title'],
'rules' => $validations
];
}
return success($result);
}
// -------------------------------------------------------------------------------------------------
// Private methods
//
@@ -841,7 +999,7 @@ class UDFLib
$htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{self::NAME};
$htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{self::NAME};
}
/**
* Sort the list of UDF by sort property
*/
@@ -864,7 +1022,7 @@ class UDFLib
return ($a->{self::SORT} < $b->{self::SORT}) ? -1 : 1;
});
}
/**
* Loads the UDF description by the given schema and table
*/
@@ -1,7 +1,6 @@
<?php
class Bismeldestichtag_model extends DB_Model
{
/**
* Constructor
*/
@@ -12,6 +11,88 @@ class Bismeldestichtag_model extends DB_Model
$this->pk = 'meldestichtag_id';
}
public function getLastReachedMeldestichtag($studiensemester_kurzbz = null)
{
$this->addSelect('meldestichtag_id');
$this->addSelect('meldestichtag');
$this->addSelect('studiensemester_kurzbz');
$this->addSelect('insertamum');
$this->addSelect('insertvon');
$this->addSelect('updateamum');
$this->addSelect('updatevon');
if ($studiensemester_kurzbz) {
$this->db->where('studiensemester_kurzbz', $studiensemester_kurzbz);
}
$this->addOrder('meldestichtag', 'DESC');
$this->addLimit(1);
return $this->loadWhere([
'meldestichtag < NOW()' => null
]);
}
/**
* Prüft, ob Meldestichtag für ein bestimmtes Statusdatum und Studiensemester erreicht ist.
*
* @param $status_datum
* @return boolean true wenn erreicht, oder false
*/
public function checkIfMeldestichtagErreicht($status_datum, $studiensemester_kurzbz = null)
{
$erreicht = false;
if (isset($studiensemester_kurzbz))
{
// Studiensemesterende holen
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$result = $this->StudiensemesterModel->loadWhere(
array(
'studiensemester_kurzbz' => $studiensemester_kurzbz
)
);
if(isError($result))
{
return $result;
}
$result = current(getData($result));
$studiensemester_ende = new DateTime($result->ende);
}
// letztes erreichtes Bismeldedatum holen
$result = $this->getLastReachedMeldestichtag();
if (isError($result))
{
return $result;
}
if (!hasData($result)) {
return success("0",'No Statusdata vorhanden');
}
$stichtag = current(getData($result));
$stichtag = new DateTime($stichtag->meldestichtag);
$statusDatum = new DateTime($status_datum);
// Prüfen, ob Studentstatusdatum oder Studiensemester vor dem Stichtagsdatum liegen
if (isset($statusDatum))
{
if (isset($stichtag))
$erreicht = $statusDatum < $stichtag;
}
if (isset($studiensemester_ende))
{
$erreicht = $erreicht || $studiensemester_ende < $stichtag;
}
if ($erreicht)
return success("1", "Studentstatus mit Datum oder Semesterende vor erreichtem Meldestichtag können nicht hinzugefügt werden");
return success("0", "Meldestatus nicht erreicht");
}
/**
* Gets last Bismeldestichtag for a Studiensemester.
* @param $studiensemester_kurzbz
@@ -19,4 +19,13 @@ class Gemeinde_model extends DB_Model
return $this->loadWhere(array("plz" => $plz));
}
public function checkLocation($plz, $gemeinde, $ort)
{
$this->db->where('ortschaftsname', $ort);
$this->db->where('name', $gemeinde);
$this->db->where('plz', $plz);
return (boolean)$this->db->count_all_results($this->dbTable);
}
}
+215
View File
@@ -1,4 +1,7 @@
<?php
use CI3_Events as Events;
class Konto_model extends DB_Model
{
@@ -12,6 +15,218 @@ class Konto_model extends DB_Model
$this->pk = 'buchungsnr';
}
/**
* Insert Data into DB-Table
*
* @param array $data DataArray for Insert
* @return stdClass
*/
public function insert($data, $encryptedColumns = null)
{
if (isset($data['buchungsnr_verweis']) && $data['buchungsnr_verweis'])
return parent::insert($data, $encryptedColumns);
$this->db->trans_begin();
$result = parent::insert($data, $encryptedColumns);
if (isError($result)) {
$this->db->trans_rollback();
return $result;
}
$buchungsnr = $result->retval;
// If studiengang_kz is not present in $data it will fail above since it is a not null field
$studiengang_kz = $data['studiengang_kz'];
$zahlungsreferenz = false;
Events::trigger('generate_zahlungsreferenz', $buchungsnr, $data, function ($value) use ($zahlungsreferenz) {
$zahlungsreferenz = $value;
});
if ($zahlungsreferenz === false) {
$result = $this->execQuery('SELECT UPPER(oe_kurzbz) || ? as zahlungsreferenz
FROM public.tbl_studiengang
WHERE studiengang_kz=?', [$buchungsnr, $studiengang_kz]);
if (isError($result)) {
$this->db->trans_rollback();
return $result;
}
$zahlungsreferenz = current(getData($result))->zahlungsreferenz;
} elseif (isError($zahlungsreferenz)) {
$this->db->trans_rollback();
return $zahlungsreferenz;
}
$result = $this->update($buchungsnr, [
'zahlungsreferenz' => $zahlungsreferenz
]);
if (isError($result)) {
$this->db->trans_rollback();
return $result;
}
$this->db->trans_commit();
return success($buchungsnr);
}
/**
* Delete data from DB-Table
*
* @param string $id Primary Key for DELETE
*
* @return stdClass
*/
public function delete($id)
{
$this->db->where('buchungsnr_verweis', $id);
if ($this->db->count_all_results($this->dbTable))
return error('Bitte zuerst die zugeordneten Buchungen loeschen', 42);
return parent::delete($id);
}
/**
* Adds additional fields to the Query
*
* @return Konto_model
*/
public function withAdditionalInfo()
{
$this->addSelect($this->dbTable . '.*');
$this->addSelect('UPPER(typ::varchar(1) || kurzbz) AS kuerzel');
$this->addSelect('person.anrede');
$this->addSelect('person.titelpost');
$this->addSelect('person.titelpre');
$this->addSelect('person.vorname');
$this->addSelect('person.vornamen');
$this->addSelect('person.nachname');
$this->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->addJoin('public.tbl_person person', 'person_id', 'LEFT');
Events::trigger('konto_query');
return $this;
}
/**
* Get all accounting entries for a person optionally filtered by Studiengang
*
* @param integer|array $person_id
* @param string (optional) $studiengang_kz
*
* @return stdClass
*/
public function getAlleBuchungen($person_id, $studiengang_kz = '')
{
$this->withAdditionalInfo();
$this->addOrder('buchungsdatum');
if (is_array($person_id))
$this->db->where_in('person_id', $person_id);
else
$this->db->where('person_id', $person_id);
if ($studiengang_kz)
return $this->loadWhere([
'studiengang_kz' => $studiengang_kz
]);
return $this->load();
}
/**
* Get all open accounting entries for a person optionally filtered by Studiengang
*
* @param integer|array $person_id
* @param string (optional) $studiengang_kz
*
* @return stdClass
*/
public function getOffeneBuchungen($person_id, $studiengang_kz = '')
{
$this->addSelect('buchungsnr');
$this->db->where('(betrag + (
SELECT CASE WHEN sum(betrag) is null THEN 0 ELSE sum(betrag) END
FROM ' . $this->dbTable . '
WHERE buchungsnr_verweis=konto_a.buchungsnr
)) !=', 0, false);
if (is_array($person_id))
$this->db->where_in('person_id', $person_id);
else
$this->db->where('person_id', $person_id);
$sql = $this->db->get_compiled_select($this->dbTable . ' konto_a');
$this->db->group_start();
$this->db->where_in('buchungsnr', $sql, false);
$this->db->or_where_in('buchungsnr_verweis', $sql, false);
$this->db->group_end();
return $this->getAlleBuchungen($person_id, $studiengang_kz);
}
/**
* Check double Buchungen
*
* @param array $person_ids
* @param string $studiensemester_kurzbz
* @param array $buchungstyp_kurzbzs
*
* @return stdClass
*/
public function checkDoubleBuchung($person_ids, $studiensemester_kurzbz, $buchungstyp_kurzbzs)
{
$this->addSelect('vorname');
$this->addSelect('nachname');
$this->addJoin('public.tbl_person', 'person_id');
$this->db->where_in('person_id', $person_ids);
$this->db->where_in('buchungstyp_kurzbz', $buchungstyp_kurzbzs);
$this->addGroupBy('vorname, nachname');
$this->addOrder('nachname');
$this->addOrder('vorname');
return $this->loadWhere([
'studiensemester_kurzbz' => $studiensemester_kurzbz
]);
}
/**
* Berechnet den offenen Betrag einer Buchung
*
* @param integer $buchungsnr
*
* @return stdClass
*/
public function getDifferenz($buchungsnr)
{
$this->addSelect('buchungsnr_verweis');
$this->db->where('buchungsnr', $buchungsnr);
$sql = $this->db->get_compiled_select($this->dbTable);
$this->addSelect('buchungsnr_verweis');
$this->db->where('buchungsnr', $buchungsnr);
$this->db->or_where('buchungsnr_verweis', '(' . $sql . ')', false);
$sql = $this->db->get_compiled_select($this->dbTable);
$this->addSelect('sum(betrag) differenz');
$this->db->where('buchungsnr', $buchungsnr);
$this->db->or_where('buchungsnr_verweis', $buchungsnr);
$this->db->or_where('buchungsnr', '(' . $sql . ')', false);
$result = $this->load();
if (isError($result))
return $result;
if (!hasData($result))
return success(null);
return success(current(getData($result))->differenz * -1);
}
/**
* Sets a Payment as paid
*/
@@ -14,6 +14,39 @@ class Prestudent_model extends DB_Model
$this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel');
}
/**
* Update Data in DB-Table
*
* @param string $id PK for DB-Table
* @param array $data DataArray for Insert
* @return array
*/
public function update($id, $data, $encryptedColumns = null)
{
if (isset($data['zgvmas_code'])
|| isset($data['zgvmanation'])
|| isset($data['zgv_code'])
|| isset($data['zgvnation'])
) {
/**
* Falls ZGV vorhanden, setze Ausstellungsstaat (für BIS-Meldung)
* auf Nation der höchsten angegebenen ZGV
*/
$case = '(CASE
WHEN zgvmas_code IS NOT NULL AND zgvmanation IS NOT NULL THEN zgvmanation
WHEN zgv_code IS NOT NULL AND zgvnation IS NOT NULL THEN zgvnation
ELSE NULL END)';
foreach (['zgvmas_code', 'zgvmanation', 'zgv_code', 'zgvnation'] as $key)
if (isset($data[$key]))
$case = str_replace($key, $this->escape($data[$key]), $case);
$this->db->set('ausstellungsstaat', $case, false);
}
return parent::update($id, $data, $encryptedColumns);
}
/**
* getLastStatuses
*/
@@ -700,4 +733,33 @@ class Prestudent_model extends DB_Model
return $this->execQuery($query, array($prestudent_id));
}
/**
* Gets history of all prestudents, person_id given
* @param int $person_id
* @return object
*/
public function getHistoryPrestudents($person_id)
{
$query = "
SELECT ps.studiensemester_kurzbz, p.priorisierung, p.studiengang_kz, sg.kurzbzlang, ps.orgform_kurzbz,
ps.status_kurzbz, s.student_uid, sp.bezeichnung, ps.ausbildungssemester,
CONCAT(ps.status_kurzbz, ' (', ps.ausbildungssemester, '. Semester)') as status, p.prestudent_id
FROM public.tbl_prestudent p
JOIN (
SELECT DISTINCT ON(prestudent_id) *
FROM public.tbl_prestudentstatus
WHERE prestudent_id IN (SELECT prestudent_id FROM public.tbl_prestudent WHERE person_id = ?)
ORDER BY prestudent_id, datum desc, insertamum desc
) ps USING(prestudent_id)
JOIN public.tbl_status USING(status_kurzbz)
LEFT JOIN public.tbl_status_grund g USING (statusgrund_id)
JOIN public.tbl_studiengang sg USING(studiengang_kz)
LEFT JOIN lehre.tbl_studienplan sp USING (studienplan_id)
LEFT JOIN public.tbl_student s USING (prestudent_id)
ORDER BY p.priorisierung
";
return $this->execQuery($query, array($person_id));
}
}
@@ -5,6 +5,15 @@ class Prestudentstatus_model extends DB_Model
const STATUS_ABBRECHER = 'Abbrecher';
const STATUS_UNTERBRECHER = 'Unterbrecher';
const STATUS_STUDENT = 'Student';
const STATUS_DIPLOMAND = 'Diplomand';
const STATUS_ABSOLVENT = 'Absolvent';
const STATUS_BEWERBER = 'Bewerber';
const STATUS_AUFGENOMMENER = 'Aufgenommener';
const STATUS_WARTENDER = 'Wartender';
const STATUS_ABGEWIESENER = 'Abgewiesener';
const STATUS_INTERESSENT = 'Interessent';
const STATUS_INCOMING = 'Incoming';
/**
* Constructor
@@ -330,13 +339,252 @@ class Prestudentstatus_model extends DB_Model
*/
public function withGrund($statusgrund_kurzbz)
{
if($statusgrund_kurzbz)
if ($statusgrund_kurzbz)
$this->db->set(
'statusgrund_id',
'(SELECT statusgrund_id FROM public.tbl_status_grund WHERE statusgrund_kurzbz =' . $this->db->escape($statusgrund_kurzbz) .')',
'(SELECT statusgrund_id FROM public.tbl_status_grund WHERE statusgrund_kurzbz=' . $this->db->escape($statusgrund_kurzbz) . ')',
false
);
return $this;
}
/**
* Check if there is only one prestudentstatus left
*
* @param integer $prestudent_id
* @param string $studiensemester_kurzbz
*
* @return stdClass
*/
public function checkIfLastStatusEntry($prestudent_id, $studiensemester_kurzbz = null)
{
$this->addSelect('COUNT(*) AS anzahl', false);
if ($studiensemester_kurzbz)
$this->db->where('studiensemester_kurzbz', $studiensemester_kurzbz);
$result = $this->loadWhere([
'prestudent_id' => $prestudent_id
]);
if (isError($result))
return $result;
$resultObject = current($result->retval);
$anzahl = (int)$resultObject->anzahl;
if ($anzahl <= 1)
return success(true, $this->p->t('lehre', 'error_lastRole'));
return success(false, $this->p->t('lehre', 'anzahl_existingRoles', ['anzahl' => $anzahl]));
}
public function getAllPrestudentstatiWithStudiensemester($prestudent_id)
{
$qry = "
SELECT
tbl_prestudentstatus.status_kurzbz,
tbl_prestudentstatus.studiensemester_kurzbz,
tbl_prestudentstatus.ausbildungssemester,
tbl_prestudentstatus.datum,
s.start AS studiensemester_start,
pl.orgform_kurzbz AS studienplan_orgform_kurzbz,
stud.matrikelnr,
pers.vorname,
pers.nachname
FROM
public.tbl_prestudentstatus
JOIN public.tbl_studiensemester s USING (studiensemester_kurzbz)
JOIN public.tbl_prestudent USING (prestudent_id)
JOIN public.tbl_person pers USING (person_id)
LEFT JOIN public.tbl_student stud USING (prestudent_id)
LEFT JOIN lehre.tbl_studienplan pl USING (studienplan_id)
WHERE
prestudent_id = ?
ORDER BY
public.tbl_prestudentstatus.datum DESC,
public.tbl_prestudentstatus.insertamum DESC,
public.tbl_prestudentstatus.ext_id DESC
";
return $this->execQuery($qry, array($prestudent_id));
}
/**
* Gets status history of a prestudent
* This function uses the language of the logged in user to
* translate the given statusgrund
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function getHistoryPrestudent($prestudent_id)
{
$lang= getUserLanguage();
$this->addSelect('tbl_prestudentstatus.prestudent_id');
$this->addSelect('tbl_prestudentstatus.status_kurzbz');
$this->addSelect('tbl_prestudentstatus.studiensemester_kurzbz');
$this->addSelect('tbl_prestudentstatus.ausbildungssemester');
$this->addSelect('tbl_prestudentstatus.datum');
$this->addSelect("TO_CHAR(tbl_prestudentstatus.datum::timestamp, 'DD.MM.YYYY') AS format_datum");
$this->addSelect('tbl_prestudentstatus.insertamum');
$this->addSelect('tbl_prestudentstatus.insertvon');
$this->addSelect('tbl_prestudentstatus.updateamum');
$this->addSelect('tbl_prestudentstatus.updatevon');
$this->addSelect('tbl_prestudentstatus.orgform_kurzbz');
$this->addSelect('tbl_prestudentstatus.bestaetigtam');
$this->addSelect("TO_CHAR(tbl_prestudentstatus.bestaetigtam::timestamp, 'DD.MM.YYYY') AS format_bestaetigtam");
$this->addSelect('tbl_prestudentstatus.bestaetigtvon');
$this->addSelect('tbl_prestudentstatus.bewerbung_abgeschicktamum');
$this->addSelect("TO_CHAR(tbl_prestudentstatus.bewerbung_abgeschicktamum::timestamp, 'DD.MM.YYYY') AS format_bewerbung_abgeschicktamum");
$this->addSelect('tbl_prestudentstatus.anmerkung');
$this->addSelect('plan.studienplan_id');
$this->addSelect('plan.bezeichnung');
$this->addSelect('grund.beschreibung[(
SELECT index
FROM public.tbl_sprache
WHERE sprache=' . $this->escape($lang) . '
)] AS statusgrund_bezeichnung', false);
$this->addSelect("CASE
WHEN s.student_uid IS NOT NULL
AND tbl_prestudentstatus.status_kurzbz IN (" . implode(",", $this->escape([
'Student',
'Diplomand',
'Abbrecher',
'Absolvent',
'Ausserodentlicher',
'Incoming',
'Outgoing',
'Unterbrecher'
])) . ")
THEN lv.semester || lv.verband || lv.gruppe
ELSE '-'
END AS lehrverband", false);
$this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT');
$this->addJoin('public.tbl_status_grund grund', 'statusgrund_id', 'LEFT');
$this->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT');
$this->addJoin(
'public.tbl_studentlehrverband lv',
's.student_uid IS NOT NULL AND s.student_uid=lv.student_uid AND tbl_prestudentstatus.studiensemester_kurzbz=lv.studiensemester_kurzbz',
'LEFT'
);
$this->addOrder('tbl_prestudentstatus.datum', 'DESC');
$this->addOrder('tbl_prestudentstatus.insertamum', 'DESC');
$this->addOrder('tbl_prestudentstatus.ext_id', 'DESC');
return $this->loadWhere([
'tbl_prestudentstatus.prestudent_id' => $prestudent_id
]);
}
/**
* Gets status history of a prestudent for checking purposes.
* This function adds the new state or replaces the edited.
*
* @param integer $prestudent_id
* @param string $status_kurzbz
* @param DateTime $new_date
* @param string $new_studiensemester_kurzbz
* @param integer $new_ausbildungssemester
* @param string $old_studiensemester_kurzbz
* @param integer $old_ausbildungssemester
*
* @return stdClass
*/
public function getHistoryWithNewOrEditedState(
$prestudent_id,
$status_kurzbz,
$new_date,
$new_studiensemester_kurzbz,
$new_ausbildungssemester,
$old_studiensemester_kurzbz,
$old_ausbildungssemester
) {
$new_date = $new_date->format('Y-m-d');
$this->addSelect('status_kurzbz');
$this->addSelect('studiensemester_kurzbz');
$this->addSelect('ausbildungssemester');
$this->addSelect('datum');
$this->addSelect('insertamum');
$this->addSelect('ext_id');
if ($old_studiensemester_kurzbz || $old_ausbildungssemester) {
$this->db->not_group_start();
$this->db->where('status_kurzbz', $status_kurzbz);
$this->db->where('studiensemester_kurzbz', $old_studiensemester_kurzbz);
$this->db->where('ausbildungssemester', $old_ausbildungssemester);
$this->db->group_end();
}
$this->db->where('prestudent_id', $prestudent_id);
$tmpTable = $this->db->get_compiled_select($this->dbTable);
$tmpTable .= "UNION
SELECT " .
$this->escape($status_kurzbz) . " AS status_kurzbz, " .
$this->escape($new_studiensemester_kurzbz) . " AS studiensemester_kurzbz, " .
$this->escape($new_ausbildungssemester) . " AS ausbildungssemester, " .
$this->escape($new_date) . "::date AS datum," .
$this->escape(date('c')) . "::date AS insertamum," .
"NULL AS ext_id";
$this->addJoin('public.tbl_studiensemester sem', 'studiensemester_kurzbz');
$this->addOrder('s.datum', 'DESC');
$this->addOrder('s.insertamum', 'DESC');
$this->addOrder('s.ext_id', 'DESC');
$dbTable = $this->dbTable;
$this->dbTable = "(" . $tmpTable . ") s";
$result = $this->load();
$this->dbTable = $dbTable;
return $result;
}
/**
* For checks if Orgform of Student status and Bewerber status match.
* Returns any Bewerber status that does not match the first Student
* status' Orgform.
*
* @param integer $prestudent_id
*
* @return stdClass
*/
public function getBewerberWhereOrgformNotStudent($prestudent_id)
{
$this->addSelect('plan.orgform_kurzbz');
$this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT');
$this->addOrder('tbl_prestudentstatus.datum', 'DESC');
$this->addOrder('tbl_prestudentstatus.insertamum', 'DESC');
$this->addOrder('tbl_prestudentstatus.ext_id', 'DESC');
$this->addLimit(1);
$this->db->where('prestudent_id', $prestudent_id);
$this->db->where('status_kurzbz', self::STATUS_STUDENT);
$sql = $this->db->get_compiled_select($this->dbTable);
$this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT');
$this->db->where('plan.orgform_kurzbz !=', '(' . $sql . ')', false);
return $this->loadWhere([
'prestudent_id' => $prestudent_id,
'status_kurzbz' => self::STATUS_BEWERBER
]);
}
}
+17
View File
@@ -11,4 +11,21 @@ class Status_model extends DB_Model
$this->dbTable = 'public.tbl_status';
$this->pk = 'status_kurzbz';
}
public function getAllStatiWithStatusgruende()
{
$lang = '[(SELECT index FROM public.tbl_sprache WHERE sprache=' . $this->escape(getUserLanguage()) . ' LIMIT 1)]';
$this->addSelect('sg.status_kurzbz');
$this->addSelect('statusgrund_id');
$this->addSelect('sg.bezeichnung_mehrsprachig' . $lang . ' AS bezeichnung');
$this->addSelect('sg.beschreibung' . $lang . ' AS beschreibung');
$this->addJoin('public.tbl_status_grund sg', 'ON (sg.status_kurzbz = public.tbl_status.status_kurzbz)', 'LEFT');
return $this->loadWhere([
'aktiv'=> true,
]);
}
}
@@ -27,4 +27,19 @@ class Statusgrund_model extends DB_Model
return success($status->retval);
}
public function getAktiveGruende()
{
$lang = '[(SELECT index FROM public.tbl_sprache WHERE sprache=' . $this->escape(getUserLanguage()) . ' LIMIT 1)]';
$this->addSelect('tbl_status_grund.*');
$this->addSelect('bezeichnung_mehrsprachig' . $lang . ' AS bezeichnung');
$this->addSelect('beschreibung' . $lang . ' AS beschreibung');
$this->addOrder('bezeichnung_mehrsprachig' . $lang);
return $this->loadWhere([
'aktiv' => true
]);
}
}
+166 -1
View File
@@ -1,4 +1,8 @@
<?php
use \InvalidArgumentException as InvalidArgumentException;
use \CI3_Events as Events;
class Student_model extends DB_Model
{
@@ -43,9 +47,169 @@ class Student_model extends DB_Model
$max = 0;
$max += 1;
return $matrikelnummer.sprintf("%03d", $max);
}
/**
* Generiert die Matrikelnummer
* FORMAT: 0710254001
* 07 = Jahr
* 1/2/0 = WS/SS/incoming
* 0254 = Studiengangskennzahl vierstellig
* 001 = Laufende Nummer
* copy of generateMatrikelnummer plus
* logic FH Burgenland
*
* TODO(chris): replace function above with this?
* TODO(chris): rename to generatePersonenkennzeichen?
*
* @param integer $studiengang_kz
* @param string $studiensemester_kurzbz
* @param string $typ
*
* @return stdClass
*/
public function generateMatrikelnummer2($studiengang_kz, $studiensemester_kurzbz, $typ = null)
{
$personenkennzeichen = false;
Events::trigger(
'generate_personenkennzeichen',
function ($value) use ($personenkennzeichen) {
$personenkennzeichen = $value;
},
$studiengang_kz,
$studiensemester_kurzbz,
$typ
);
if ($personenkennzeichen !== false)
return success($personenkennzeichen);
// Validierung der Eingabewerte
if (strlen($studiensemester_kurzbz) < 6) {
throw new InvalidArgumentException("Ungültiges studiensemester_kurzbz Format.");
}
$jahr = mb_substr($studiensemester_kurzbz, 4);
$art = substr($studiensemester_kurzbz, 0, 2);
if (($studiengang_kz < 0) || (isset($typ) && ($typ == 'l')))
{
$studiengang_kz=abs($studiengang_kz);
//Lehrgang
switch($art)
{
case 'WS':
$art = '3';
break;
case 'SS':
$art = '4';
break;
default:
$art = '0';
break;
}
}
else
{
//Studiengang
switch($art)
{
case 'WS':
$art = '1';
break;
case 'SS':
$art = '2';
break;
default:
$art = '0';
break;
}
}
if($art=='2' || $art=='4')
$jahr = $jahr-1;
//FH-Burgenland - weil leider die AO Studiengänge aufgeteilt sind
//(AO sind normal 9+erhalter Nummer, matrikelnr/personenkz wird auch im DVUH Extension berücksichtigt)
if ($studiengang_kz >= 90010 && $studiengang_kz <= 90019)
{
$matrikelnummer = sprintf("%02d", $jahr).$art.substr($studiengang_kz, 0, 4);
}
else
{
$matrikelnummer = sprintf("%02d", $jahr).$art.sprintf("%04d", $studiengang_kz);
}
$qry = "SELECT matrikelnr FROM public.tbl_student WHERE matrikelnr LIKE ? ORDER BY matrikelnr DESC LIMIT 1";
$matrikelnrres = $this->execQuery($qry, array($matrikelnummer.'%'));
$max = 0;
if ($matrikelnrres && hasData($matrikelnrres)) {
$max = mb_substr($matrikelnrres->retval[0]->matrikelnr, 7);
if (!is_numeric($max)) {
$max = (int)$max;
}
}
$max += 1;
return success($matrikelnummer.sprintf("%03d", $max));
}
/**
* Generiert die UID
* FORMAT: el07b001
* $stgkzl: el = studiengangskuerzel
* $jahr: 07 = Jahr
* $stgtyp: b/m/d/x = Bachelor/Master/Diplom/Incoming
* $matrikelnummer
* 001 = Laufende Nummer Wenn StSem==SS dann wird zur Nummer 500 dazugezaehlt
* Bei Incoming im Masterstudiengang wird auch 500 dazugezaehlt
*
* @param string $stgkzl
* @param string $jahr
* @param string $stgtyp
* @param string $matrikelnummer
* @param string $vorname
* @param string $nachname
*
* @return stdClass
*/
public function generateUID($stgkzl, $jahr, $stgtyp, $matrikelnummer, $vorname, $nachname)
{
$uid = false;
Events::trigger(
'generate_student_uid',
function ($value) use ($uid) {
$uid = $value;
},
$stgkzl,
$jahr,
$stgtyp,
$matrikelnummer,
$vorname,
$nachname
);
if ($uid !== false)
return success($uid);
$art = mb_substr($matrikelnummer, 2, 1);
$nr = mb_substr($matrikelnummer, mb_strlen(trim($matrikelnummer))-3);
if($art=='2') //Sommersemester
$nr = $nr+500;
elseif($art=='0' && $stgtyp=='m') //Incoming im Masterstudiengang
$nr = $nr+500;
elseif($art=='4' && $stgtyp=='l') // Lehrgangsteilnehmer im Sommersemester
$nr = $nr+500;
return success(mb_strtolower($stgkzl.$jahr.($art!='0'?$stgtyp:'x').$nr));
}
/**
* Get students UID by PrestudentID.
* @param $prestudent_id
@@ -78,7 +242,8 @@ class Student_model extends DB_Model
OR lower(person.nachname) like ".$this->db->escape('%'.$filter.'%')."
OR lower(person.vorname) like ".$this->db->escape('%'.$filter.'%')."
OR lower(person.nachname || ' ' || person.vorname) like ".$this->db->escape('%'.$filter.'%')."
OR lower(person.vorname || ' ' || person.nachname) like ".$this->db->escape('%'.$filter.'%'));
OR lower(person.vorname || ' ' || person.nachname) like ".$this->db->escape('%'.$filter.'%')
);
return $result;
}
@@ -0,0 +1,14 @@
<?php
class Gsstudientyp_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'bis.tbl_gsstudientyp';
$this->pk = 'gsstudientyp_kurzbz';
}
}
@@ -493,4 +493,11 @@ class Lehrveranstaltung_model extends DB_Model
return $this->execQuery($qry, array($student_uid));
}
public function getStg($lehrveranstaltung_id)
{
$this->addSelect('stg.*');
$this->addJoin('public.tbl_studiengang stg', 'studiengang_kz');
return $this->load($lehrveranstaltung_id);
}
}
@@ -11,5 +11,7 @@ class Studentlehrverband_model extends DB_Model
$this->dbTable = 'public.tbl_studentlehrverband';
$this->pk = array('studiensemester_kurzbz', 'student_uid');
$this->hasSequence = false;
$this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel');
}
}
@@ -11,4 +11,34 @@ class Lehrverband_model extends DB_Model
$this->dbTable = 'public.tbl_lehrverband';
$this->pk = array('gruppe', 'verband', 'semester', 'studiengang_kz');
}
/**
* Gets the maximum possible semester for one or more Studiengaenge.
* If there are more than one Studiengang each maximum is calculated and
* the smallest result is returned.
*
* @param array $studiengang_kzs
*
* @return stdClass
*/
public function getMaxSemester($studiengang_kzs)
{
$sqls = [];
foreach ($studiengang_kzs as $studiengang_kz) {
$this->addSelect('MAX(semester) AS maxsem');
$this->db->where('studiengang_kz', $studiengang_kz);
$sqls[] = $this->db->get_compiled_select($this->dbTable);
}
$this->addSelect('MIN(a.maxsem) AS maxsem');
$dbTable = $this->dbTable;
$this->dbTable = '(' . implode(' UNION ', $sqls) . ') AS a';
$result = $this->load();
$this->dbTable = $dbTable;
return $result;
}
}
@@ -11,4 +11,29 @@ class Standort_model extends DB_Model
$this->dbTable = 'public.tbl_standort';
$this->pk = 'standort_id';
}
public function searchStandorte($filter)
{
$filter = strtoLower($filter);
$qry = "
SELECT
s.kurzbz, s.standort_id
FROM
public.tbl_standort s
WHERE
lower (s.kurzbz) LIKE '%". $this->db->escape_like_str($filter)."%'
OR
lower (s.bezeichnung) LIKE '%". $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));
}
}
@@ -106,4 +106,32 @@ class Studienplan_model extends DB_Model
'tbl_studienplan_lehrveranstaltung.semester' => $semester
));
}
public function getAllOesForLv($lehrveranstaltung_id)
{
$this->addDistinct('oe_kurzbz');
$this->addJoin('lehre.tbl_studienplan_lehrveranstaltung lv', 'studienplan_id');
$this->addJoin('lehre.tbl_studienordnung', 'studienordnung_id');
$this->addJoin('public.tbl_studiengang', 'studiengang_kz');
return $this->loadWhere([
'lv.lehrveranstaltung_id' => $lehrveranstaltung_id
]);
}
public function getStudienplaeneByPrestudents($prestudent_id)
{
$this->addDistinct();
$this->addSelect($this->dbTable . '.*');
$this->addSelect('sem.start AS start_stsem');
$this->addJoin('lehre.tbl_studienordnung o', 'studienordnung_id');
$this->addJoin('public.tbl_prestudent p', 'studiengang_kz');
$this->addJoin('public.tbl_studiensemester sem', 'sem.studiensemester_kurzbz = o.gueltigvon', 'LEFT');
$this->addOrder('sem.start');
return $this->loadWhere([
'prestudent_id' => $prestudent_id
]);
}
}
@@ -13,35 +13,35 @@ class Studiensemester_model extends DB_Model
$this->hasSequence = false;
}
/**
* Get actual Studiensemester.
*
* @return array
*/
public function getAkt()
{
return $this->loadWhere(array(
'start <= ' => 'NOW()',
'ende >= ' => 'NOW()'
)
);
}
/**
* Get actual Studiensemester.
*
* @return array
*/
public function getAkt()
{
return $this->loadWhere(array(
'start <= ' => 'NOW()',
'ende >= ' => 'NOW()'
)
);
}
// Get next study semester
public function getNext()
{
$query = '
SELECT *
FROM
public.tbl_studiensemester
WHERE
start > now()
ORDER BY start
LIMIT 1;
';
{
$query = '
SELECT *
FROM
public.tbl_studiensemester
WHERE
start > now()
ORDER BY start
LIMIT 1;
';
return $this->execQuery($query);
}
return $this->execQuery($query);
}
/**
* getLastOrAktSemester
@@ -182,10 +182,10 @@ class Studiensemester_model extends DB_Model
return success(array());
$query = "
SELECT *
FROM public.tbl_studiensemester
WHERE ( ?::date < ende AND ?::date > start )
ORDER BY start DESC";
SELECT *
FROM public.tbl_studiensemester
WHERE ( ?::date < ende AND ?::date > start )
ORDER BY start DESC";
return $this->execQuery($query, array($from, $to));
}
@@ -200,7 +200,7 @@ class Studiensemester_model extends DB_Model
{
$query = "SELECT studiensemester_kurzbz, start, ende FROM public.vw_studiensemester
WHERE studiensemester_kurzbz <> ?
ORDER BY delta, start LIMIT 1";
ORDER BY delta, start LIMIT 1";
return $this->execQuery($query, array($studiensemester_kurzbz));
}
@@ -211,7 +211,46 @@ class Studiensemester_model extends DB_Model
FROM public.tbl_studiensemester
WHERE start >= NOW() OR (start <= NOW() AND ende >= NOW())
ORDER BY start';
return $this->execQuery($query);
}
/**
* Liefert ausgehend von heutigen Datum $plus studiensemester in die Zukunft und $minus Studiensemester in die Vergangenheit
*
* @param integer $plus Optional. Wieviele Studiensemester in die Zukunft sollen ausgegeben werden. Wenn NULL werden alle zukuenftigen geliefert.
* @param integer $minus Optional. Wieviele Studiensemester in die Vergangenheit sollen ausgegeben werden. Wenn NULL werden alle vergangenen geliefert.
*
* @return stdClass
*/
public function addPlusMinus($plus = null, $minus = null)
{
$this->addSelect($this->pk);
$this->addOrder('ende');
if ($plus)
$this->addLimit($plus);
$this->db->where('start >= NOW()', null, false);
$plus = $this->db->get_compiled_select($this->dbTable);
$this->addSelect($this->pk);
$this->addOrder('start', 'DESC');
if ($minus)
$this->addLimit($minus);
$this->db->where('start <= NOW()', null, false);
$minus = $this->db->get_compiled_select($this->dbTable);
$this->db->where_in($this->pk, '(' . $plus . ') UNION (' . $minus . ')', false);
}
/**
* Holt letzen zwei Ziffern des Studienjahres von Studiensemester, z.B. 24 für WS2024 und SS2025
* @param studiensemester_kurzbz
* @return string Studienjahr Nummer
*/
public function getStudienjahrNumberFromStudiensemester($studiensemester_kurzbz)
{
$studienjahrNumber = mb_substr($studiensemester_kurzbz, 4, 2);
if (is_numeric($studienjahrNumber) && mb_substr($studiensemester_kurzbz, 0, 2) == 'SS') (int)$studienjahrNumber -= 1;
return $studienjahrNumber;
}
}
+1 -1
View File
@@ -24,4 +24,4 @@ class Adresse_model extends DB_Model
$this->addSelect($select);
return $this->loadWhere(array('person_id' => $person_id, 'zustelladresse'=> true));
}
}
}
+81 -11
View File
@@ -1,4 +1,7 @@
<?php
use \CI3_Events as Events;
class Benutzer_model extends DB_Model
{
@@ -74,22 +77,88 @@ class Benutzer_model extends DB_Model
*/
public function generateAlias($uid)
{
$aliasres = '';
$this->addLimit(1);
$this->addSelect('vorname, nachname');
$this->addJoin('public.tbl_person', 'person_id');
$nameresult = $this->loadWhere(array('uid' => $uid));
if (hasData($nameresult))
{
$aliasdata = getData($nameresult);
$alias = $this->_sanitizeAliasName($aliasdata[0]->vorname).'.'.$this->_sanitizeAliasName($aliasdata[0]->nachname);
$aliasexists = $this->aliasExists($alias);
if (isError($nameresult))
return $nameresult;
if (hasData($aliasexists) && !getData($aliasexists)[0])
$aliasres = $alias;
}
return success($aliasres);
if (!hasData($nameresult))
return success('');
$aliasdata = current(getData($nameresult));
return $this->generateAliasFromName($aliasdata->vorname, $aliasdata->nachname);
}
/**
* Generates alias for a vor- and nachname.
*
* @param string $vorname
* @param string $nachname
*
* @return stdClass
*/
public function generateAliasFromName($vorname, $nachname)
{
$alias = $this->_sanitizeAliasName($vorname . '.' . $nachname);
$result = $this->aliasExists($alias);
if (isError($result))
return $result;
if (current(getData($result)))
return success('');
return success($alias);
}
/**
* Generates a matrikelnummer
*
* @param string $oe_kurzbz
*
* @return stdClass
*/
public function generateMatrikelnummer($oe_kurzbz)
{
$matrikelnummer = false;
Events::trigger(
'generate_matrikelnummer',
function ($value) use ($matrikelnummer) {
$matrikelnummer = $value;
},
$oe_kurzbz
);
if ($matrikelnummer !== false)
return success($matrikelnummer);
return success(null);
}
/**
* Generates an activation key
*
* @return string
*/
public function generateActivationkey()
{
$this->load->library('CryptLib');
$key = '';
for ($i=0; $i<32; $i++)
$key .= ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'][mt_rand(0, 15)];
$value = uniqid(mt_rand(), true);
$length = strlen($value);
$value = str_pad($value, $length + 32 - ($length % 32), chr(0));
return md5($this->cryptlib->RIJNDAEL_256_ECB($value, $key, true));
}
// --------------------------------------------------------------------------------------------
@@ -100,9 +169,10 @@ class Benutzer_model extends DB_Model
* @param string $str
* @return string
*/
private function _sanitizeAliasName($str)
{
$str = sanitizeProblemChars($str);
return mb_strtolower(str_replace(' ','_', $str));
return mb_strtolower(str_replace(' ', '_', $str));
}
}
+40 -3
View File
@@ -139,12 +139,51 @@ class Notiz_model extends DB_Model
*/
public function getNotiz($person_id)
{
// Join with the table public.tbl_notizzuordnung using notiz_id
$this->addSelect('public.tbl_notiz.*');
$this->addJoin('public.tbl_notizzuordnung', 'notiz_id');
return $this->loadWhere(array('person_id' => $person_id));
}
/**
* gets all Notizen with Documententries for a certain type and type_id
* @param String type of id eg. person_id, prestudent_id, mitarbeiter_uid, projekt_kurzbz, projektphase_id, projekttask_id,
* bestellung_id, lehreinheit_id, anrechnung_id, uid)
* @param $id the corresponding id, part of public.tbl_notizzuordnung
*/
public function getNotizWithDocEntries($id, $type)
{
$qry = "
SELECT
n.*, count(dms_id) as countDoc, z.notizzuordnung_id,
TO_CHAR (CASE
WHEN n.updateamum >= n.insertamum THEN n.updateamum
ELSE n.insertamum
END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate,
regexp_replace(n.text, '<[^>]*>', '', 'g') as text_stripped,
TO_CHAR(n.start::timestamp, 'DD.MM.YYYY') AS start_format,
TO_CHAR(n.ende::timestamp, 'DD.MM.YYYY') AS ende_format,
z.notiz_id, z.person_id as id, ? as type_id
FROM
public.tbl_notiz n
JOIN
public.tbl_notizzuordnung z USING (notiz_id)
LEFT JOIN
public.tbl_notiz_dokument dok USING (notiz_id)
LEFT JOIN
campus.tbl_dms_version USING (dms_id)
WHERE
z.$type = ?
GROUP BY
notiz_id, z.notizzuordnung_id
";
return $this->execQuery($qry, array($type, $id));
}
/**
* gets all Notizen for a person with a specific title
* @param $person_id
@@ -231,6 +270,4 @@ class Notiz_model extends DB_Model
return $this->loadWhere(array('anrechnung_id' => $anrechnung_id));
}
// ------------------------------------------------------------------------------------------------------
}
@@ -0,0 +1,14 @@
<?php
class Notizdokument_model extends DB_Model
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->dbTable = 'public.tbl_notiz_dokument';
$this->pk= array('notiz_id' , 'dms_id');
}
}
@@ -11,4 +11,38 @@ class Notizzuordnung_model extends DB_Model
$this->dbTable = 'public.tbl_notizzuordnung';
$this->pk = 'notizzuordnung_id';
}
public function isValidType($type)
{
$validTypes = [];
$qry = "
SELECT column_name
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'tbl_notizzuordnung'
AND column_name not in ('notizzuordnung_id', 'notiz_id')
";
$type_arr = $this->execQuery($qry);
$type_arr = $type_arr->retval;
foreach ($type_arr as $t)
{
$validTypes[] = $t->column_name;
}
//TODO(manu) param id
if (in_array($type, $validTypes) )
//if (in_array($type, $validTypes) ||($type == 'software_id')) //Just for testing
{
return success("Type " . $type . " is valid");
// $result = success('Type of Id is valid');
}
else
{
return error("Type " . $type . " is NOT valid");
}
//return $result;
}
}
@@ -11,4 +11,18 @@ class Firma_model extends DB_Model
$this->dbTable = 'public.tbl_firma';
$this->pk = 'firma_id';
}
public function searchFirmen($filter)
{
$filter = strtoLower($filter);
$qry = "
SELECT
f.name, f.firma_id
FROM
public.tbl_firma f
WHERE
lower (f.name) LIKE '%". $this->db->escape_like_str($filter)."%'";
return $this->execQuery($qry);
}
}
@@ -216,4 +216,26 @@ class Mitarbeiter_model extends DB_Model
return success($kurzbz);
}
public function searchMitarbeiter($filter)
{
$filter = strtoLower($filter);
$qry = "
SELECT
ma.mitarbeiter_uid, CONCAT(p.nachname, ' ', p.vorname, ' (', ma.mitarbeiter_uid , ')') as mitarbeiter
FROM
public.tbl_mitarbeiter ma
JOIN
public.tbl_benutzer b on (ma.mitarbeiter_uid = b.uid)
JOIN
public.tbl_person p on (p.person_id = b.person_id)
WHERE
lower (p.nachname) LIKE '%". $this->db->escape_like_str($filter)."%'
OR
lower (p.vorname) LIKE '%". $this->db->escape_like_str($filter)."%'
OR
(ma.mitarbeiter_uid) LIKE '%". $this->db->escape_like_str($filter)."%'";
return $this->execQuery($qry);
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
$includesArray = array(
'title' => 'Studentenverwaltung',
'axios027' => true,
'bootstrap5' => true,
'fontawesome6' => true,
'vue3' => true,
'primevue3' => true,
#'filtercomponent' => true,
'tabulator5' => true,
'tinymce5' => true,
'phrases' => array(
'global',
'ui',
'notiz',
),
'customCSSs' => [
'public/css/components/vue-datepicker.css',
'public/css/components/primevue.css',
'public/css/Studentenverwaltung.css'
],
'customJSs' => [
#'vendor/npm-asset/primevue/tree/tree.min.js',
#'vendor/npm-asset/primevue/toast/toast.min.js'
],
'customJSModules' => [
'public/js/apps/Studentenverwaltung.js'
]
);
$this->load->view('templates/FHC-Header', $includesArray);
?>
<?php
$configArray = [
'generateAlias' => !defined('GENERATE_ALIAS_STUDENT') ? true : GENERATE_ALIAS_STUDENT,
'showZgvDoktor' => !defined('ZGV_DOKTOR_ANZEIGEN') ? false : ZGV_DOKTOR_ANZEIGEN,
'showZgvErfuellt' => !defined('ZGV_ERFUELLT_ANZEIGEN') ? false : ZGV_ERFUELLT_ANZEIGEN
];
?>
<div id="main">
<router-view
default-semester="<?= $variables['semester_aktuell']; ?>"
active-addons="<?= defined('ACTIVE_ADDONS') ? ACTIVE_ADDONS : ''; ?>"
stv-root="<?= site_url('Studentenverwaltung'); ?>"
cis-root="<?= CIS_ROOT; ?>"
:permissions="<?= htmlspecialchars(json_encode($permissions)); ?>"
:config="<?= htmlspecialchars(json_encode($configArray)); ?>"
>
</router-view>
</div>
<?php $this->load->view('templates/FHC-Footer', $includesArray); ?>
@@ -41,6 +41,7 @@
{
generateCSSsInclude('vendor/fortawesome/font-awesome6/css/fontawesome.min.css');
generateCSSsInclude('vendor/fortawesome/font-awesome6/css/solid.min.css');
generateCSSsInclude('vendor/fortawesome/font-awesome6/css/regular.min.css'); // NOTE(chris): for favorites in stv
generateCSSsInclude('vendor/fortawesome/font-awesome6/css/brands.min.css');
}
+115
View File
@@ -0,0 +1,115 @@
@import './Fhc.css';
@import './components/searchbar.css';
@import './components/verticalsplit.css';
@import './components/FilterComponent.css';
@import './components/Tabs.css';
@import './components/Notiz.css';
html {
font-size: .875em;
}
.navbar-dark .navbar-brand:focus {
box-shadow: 0 0 0 .25rem rgba(13,110,253,.25);
z-index: 3;
}
.searchbar {
margin-right: 0!important;
}
.searchbar > .input-group {
margin-right: 0!important;
}
.searchbar > .input-group > * {
border-radius: 0!important;
}
.stv {
display: flex;
flex-direction: column;
height: 100vh;
}
.stv > header {
flex: 0 0 auto;
}
.stv > div {
flex: 1 1 auto;
}
#sidebarMenu {
width: 0%;
}
.tabulator-row.disabled.tabulator-row-odd .tabulator-cell {
color: var(--gray-400);
}
.tabulator-row.disabled.tabulator-row-even .tabulator-cell {
color: var(--gray-500);
}
/* Dropdown Toolbar Interessent, submenu */
.dropend .dropdown-toggle.d-flex::after {
height: 0;
}
@media (min-width: 768px) {
#sidebarMenu {
visibility: visible!important;
transform: none;
position: inherit;
z-index: 1;
}
}
@media (max-width: 769px) {
.stv-verband {
max-height: calc(100% - 3rem);
overflow: auto;
}
}
.stv-verband .p-treetable-tbody > tr > td {
display: flex;
padding-top: .25rem!important;
padding-bottom: .25rem!important;
}
.stv-verband .p-treetable-tbody > tr > td > button {
flex: 0 0 auto;
}
.stv-verband .p-treetable-tbody > tr > td > span {
flex: 1 1 auto;
}
.stv-verband.p-tree {
/*overflow: auto;*/
}
.stv-verband.p-tree .p-treenode-icon {
display: none;
}
.stv-list {
display: flex;
flex-direction: column;
}
.stv-list > #filterTableDataset {
flex: 1 1 auto;
}
.toast.toast-success {
color: #0f5132;
background-color: #d1e7dd!important;
border-color: #badbcc!important;
}
.toast.toast-danger {
color: #842029;
background-color: #f8d7da!important;
border-color: #f5c2c7!important;
}
.has-filter .fa-filter {
color: var(--bs-success);
}
+10
View File
@@ -39,8 +39,18 @@
z-index: 999999;
}
.tabulator {
font-size: 1rem;
}
.tabulator-cell .btn {
padding: 0 .7rem;
min-height: 25px;
min-width: 25px;
}
.tabulator-row.tabulator-selectable:focus {
box-shadow: 0 0 0 .24rem rgba(13,110,253,.25);
z-index: 1;
outline: 0;
}
+6
View File
@@ -0,0 +1,6 @@
.notizTitle {
color: darkred;
}
.notizText {
color: darkblue;
}
+3 -3
View File
@@ -121,8 +121,8 @@ export const CoreRESTClient = {
*/
getError: function(response) {
if (typeof response[CORE_REST_CLIENT_RETVAL] === "object"
&& Object.keys(response[CORE_REST_CLIENT_RETVAL]).length > 0
if (typeof response === "object"
&& Object.keys(response).length > 0
&& response.hasOwnProperty(CORE_REST_CLIENT_RETVAL))
{
return response[CORE_REST_CLIENT_RETVAL];
@@ -136,7 +136,7 @@ export const CoreRESTClient = {
*/
getErrorCode: function(response) {
if (typeof response[CORE_REST_CLIENT_RETVAL] === "object" && response.hasOwnProperty(CORE_REST_CLIENT_ERROR))
if (typeof response === "object" && response.hasOwnProperty(CORE_REST_CLIENT_ERROR))
{
return response[CORE_REST_CLIENT_ERROR];
}
+4
View File
@@ -20,6 +20,8 @@ import phrasen from "./phrasen.js";
import navigation from "./navigation.js";
import filter from "./filter.js";
import studstatus from "./studstatus.js";
import stv from "./stv.js";
import notiz from "./notiz.js";
import betriebsmittel from "./betriebsmittel.js";
export default {
@@ -28,5 +30,7 @@ export default {
navigation,
filter,
studstatus,
stv,
notiz,
betriebsmittel
};
+5
View File
@@ -0,0 +1,5 @@
import person from "./notiz/person.js";
export default {
person
}
+41
View File
@@ -0,0 +1,41 @@
export default {
getNotizen (url, config, params){
return this.$fhcApi.get('api/frontend/v1/notiz/notizPerson/getNotizen/' + params.id + '/' + params.type);
},
getUid(){
return this.$fhcApi.get('api/frontend/v1/notiz/notizPerson/getUid/');
},
addNewNotiz(id, formData) {
return this.$fhcApi.post('api/frontend/v1/notiz/notizPerson/addNewNotiz/' + id,
formData
);
},
loadNotiz(notiz_id){
return this.$fhcApi.post('api/frontend/v1/notiz/notizPerson/loadNotiz/', {
notiz_id
});
},
loadDokumente(notiz_id){
return this.$fhcApi.post('api/frontend/v1/notiz/notizPerson/loadDokumente/', {
notiz_id
});
},
deleteNotiz(notiz_id, type_id, id){
return this.$fhcApi.post('api/frontend/v1/notiz/notizPerson/deleteNotiz/', {
notiz_id,
type_id,
id
});
},
updateNotiz(notiz_id, formData){
return this.$fhcApi.post('api/frontend/v1/notiz/notizPerson/updateNotiz/' + notiz_id,
formData
);
},
getMitarbeiter(event){
return this.$fhcApi.get('api/frontend/v1/notiz/notizPerson/getMitarbeiter/' + event);
},
isBerechtigt(id, type_id){
return this.$fhcApi.get('api/frontend/v1/notiz/notizPerson/isBerechtigt/');
}
}
+17
View File
@@ -0,0 +1,17 @@
import verband from './stv/verband.js';
import students from './stv/students.js';
import filter from './stv/filter.js';
import konto from './stv/konto.js';
export default {
verband,
students,
filter,
konto,
configStudent() {
return this.$fhcApi.get('api/frontend/v1/stv/config/student');
},
configStudents() {
return this.$fhcApi.get('api/frontend/v1/stv/config/students');
}
};
+10
View File
@@ -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
});
}
};
+37
View File
@@ -0,0 +1,37 @@
export default {
tabulatorConfig(config, self) {
config.ajaxURL = 'api/frontend/v1/stv/konto/get';
config.ajaxParams = () => {
const params = {
person_id: self.modelValue.person_id || self.modelValue.map(e => e.person_id),
only_open: self.filter,
studiengang_kz: self.studiengang_kz_intern ? self.stg_kz : ''
};
return params;
};
config.ajaxRequestFunc = (url, config, params) => this.$fhcApi.post(url, params, config);
config.ajaxResponse = (url, params, response) => response.data;
return config;
},
checkDoubles(data) {
return this.$fhcApi.post('api/frontend/v1/stv/konto/checkDoubles', data, {
confirmErrorHandler: error => true
});
},
insert(data) {
return this.$fhcApi.post('api/frontend/v1/stv/konto/insert', data);
},
counter(data) {
return this.$fhcApi.post('api/frontend/v1/stv/konto/counter', data);
},
edit(data) {
return this.$fhcApi.post('api/frontend/v1/stv/konto/update', data);
},
delete(buchungsnr) {
return this.$fhcApi.post('api/frontend/v1/stv/konto/delete', {buchungsnr});
},
getBuchungstypen() {
return this.$fhcApi.get('api/frontend/v1/stv/konto/getBuchungstypen');
}
};
+14
View File
@@ -0,0 +1,14 @@
export default {
uid(uid) {
return this.$fhcApi.getUri('api/frontend/v1/stv/students/uid/' + uid);
},
prestudent(prestudent_id) {
return this.$fhcApi.getUri('api/frontend/v1/stv/students/prestudent/' + prestudent_id);
},
person(person_id) {
return this.$fhcApi.getUri('api/frontend/v1/stv/students/person/' + person_id);
},
verband(relative_path) {
return this.$fhcApi.getUri('api/frontend/v1/stv/students/' + relative_path);
}
}
+15
View File
@@ -0,0 +1,15 @@
export default {
get() {
return this.$fhcApi.get('api/frontend/v1/stv/verband');
},
favorites: {
get() {
return this.$fhcApi.get('api/frontend/v1/stv/favorites');
},
set(favorites) {
return this.$fhcApi.post('api/frontend/v1/stv/favorites/set', {
favorites
});
}
}
}
+47
View File
@@ -0,0 +1,47 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*/
import FhcStudentenverwaltung from "../components/Stv/Studentenverwaltung.js";
import fhcapifactory from "./api/fhcapifactory.js";
import Phrasen from "../plugin/Phrasen.js";
const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
const router = VueRouter.createRouter({
history: VueRouter.createWebHistory(),
routes: [
{ path: `/${ciPath}/studentenverwaltung`, component: FhcStudentenverwaltung },
{ path: `/${ciPath}/studentenverwaltung/prestudent/:prestudent_id`, component: FhcStudentenverwaltung },
{ path: `/${ciPath}/studentenverwaltung/prestudent/:prestudent_id/:tab`, component: FhcStudentenverwaltung },
{ path: `/${ciPath}/studentenverwaltung/student/:id`, component: FhcStudentenverwaltung },
{ path: `/${ciPath}/studentenverwaltung/person/:person_id`, component: FhcStudentenverwaltung }
]
});
const app = Vue.createApp();
app
.use(router)
.use(primevue.config.default, {
zIndex: {
overlay: 1100
}
})
.use(Phrasen)
.mount('#main');
@@ -37,11 +37,11 @@ export default {
ajaxURL: 'dummy',
ajaxRequestFunc: this.endpoint.getAllBetriebsmittel,
ajaxParams: () => {
return {
type: this.typeId,
id: this.id
}
},
return {
type: this.typeId,
id: this.id
};
},
ajaxResponse: (url, params, response) => response.data,
columns: [
{title: "Nummer", field: "nummer", width: 150},
@@ -151,7 +151,7 @@ export default {
},
watch: {
id() {
this.$refs.table.tabulator.setData('dummy');
this.$refs.table.reloadTable();
}
},
methods: {
+1 -1
View File
@@ -1,4 +1,4 @@
import BsAlert from './Alert';
import BsAlert from './Alert.js';
export default {
mixins: [
+1 -1
View File
@@ -93,7 +93,7 @@ export default {
document.body.appendChild(wrapper);
});
},
template: `<div ref="modal" class="bootstrap-modal modal" tabindex="-1" @[\`hide.bs.modal\`]="$emit('hideBsModal')" @[\`hidden.bs.modal\`]="$emit('hiddenBsModal')" @[\`hidePrevented.bs.modal\`]="$emit('hidePreventedBsModal')" @[\`show.bs.modal\`]="$emit('showBsModal')" @[\`shown.bs.modal\`]="$emit('shownBsModal')">
template: `<div ref="modal" class="bootstrap-modal modal" tabindex="-1" @[\`hide.bs.modal\`]="$emit('hideBsModal', $event)" @[\`hidden.bs.modal\`]="$emit('hiddenBsModal', $event)" @[\`hidePrevented.bs.modal\`]="$emit('hidePreventedBsModal', $event)" @[\`show.bs.modal\`]="$emit('showBsModal', $event)" @[\`shown.bs.modal\`]="$emit('shownBsModal', $event)">
<div class="modal-dialog" :class="dialogClass">
<div class="modal-content">
<div v-if="$slots.title" class="modal-header">
+1 -1
View File
@@ -1,5 +1,5 @@
import BsAlert from './Alert';
import BsAlert from './Alert.js';
export default {
mixins: [
+1 -1
View File
@@ -121,4 +121,4 @@ export default {
<component :is="tag || 'FhcFragment'" v-bind="$attrs">
<slot></slot>
</component>`
}
}
+9 -6
View File
@@ -24,7 +24,11 @@ export default {
inputGroup: Boolean,
type: String,
name: String,
containerClass: [String, Array, Object]
containerClass: [String, Array, Object],
label: String,
// NOTE(chris): remove these from $attrs array to prevent doubled event listeners
onInput: [Array, Function],
'onUpdate:modelValue': [Array, Function]
},
data() {
return {
@@ -174,7 +178,7 @@ export default {
let uuid = this.$attrs.id;
if (this.lcType == 'datepicker')
uuid = this.$attrs.uid;
if (!uuid && this.$attrs.label)
if (!uuid && this.label)
uuid = 'fhc-form-input';
if (!uuid)
return undefined;
@@ -236,13 +240,12 @@ export default {
},
template: `
<component :is="!hasContainer ? 'FhcFragment' : 'div'" class="position-relative" :class="autoContainerClass">
<label v-if="$attrs.label && lcType != 'radio' && lcType != 'checkbox'" :class="!noAutoClass && 'form-label'" :for="idCmp">{{$attrs.label}}</label>
<label v-if="label && lcType != 'radio' && lcType != 'checkbox'" :class="!noAutoClass && 'form-label'" :for="idCmp">{{label}}</label>
<input v-if="tag == 'input'" :type="lcType" ref="input" v-model="modelValueCmp" v-bind="$attrs" :id="idCmp" :name="name" :class="validationClass" :modelValue="undefined" @input="clearValidationForThisName(); $emit('input', $event)">
<textarea v-else-if="tag == 'textarea'" ref="input" v-model="modelValueCmp" v-bind="$attrs" :id="idCmp" :name="name" :class="validationClass" :modelValue="undefined" @input="clearValidationForThisName(); $emit('input', $event)"></textarea>
<select v-else-if="tag == 'select'" ref="input" v-model="modelValueCmp" v-bind="$attrs" :id="idCmp" :name="name" :class="validationClass" :modelValue="undefined" @input="clearValidationForThisName(); $emit('input', $event)">
<slot></slot>
</select>
<component
v-else-if="tag == 'VueDatePicker'"
ref="input"
@@ -315,7 +318,7 @@ export default {
>
<slot></slot>
</component>
<label v-if="$attrs.label && (lcType == 'radio' || lcType == 'checkbox')" :for="idCmp" :class="!noAutoClass && 'form-check-label'">{{$attrs.label}}</label>
<label v-if="label && (lcType == 'radio' || lcType == 'checkbox')" :for="idCmp" :class="!noAutoClass && 'form-check-label'">{{label}}</label>
<div v-if="valid !== undefined && feedback.length && !noFeedback" :class="feedbackClass">
<template v-for="(msg, i) in feedback" :key="i">
<hr v-if="i" class="m-0">
@@ -324,4 +327,4 @@ export default {
</div>
</component>
`
}
}
+21 -9
View File
@@ -1,4 +1,9 @@
import DmsItem from './Dms/Item.js';
export default {
components: {
DmsItem
},
emits: [
'update:modelValue'
],
@@ -53,8 +58,14 @@ export default {
},
watch: {
modelValue(n) {
if (n instanceof FileList)
if (!n)
return;
if (n instanceof FileList) {
if (!this.$refs.upload) {
return;
}
return this.$refs.upload.files = n;
}
const dt = new DataTransfer();
const dms = [];
@@ -75,13 +86,14 @@ export default {
<div class="form-upload-dms">
<input ref="upload" class="form-control" :class="inputClass" :id="id" :name="name" :multiple="multiple" type="file" @change="addFiles">
<ul v-if="modelValue.length && multiple && !noList" class="list-unstyled m-0">
<li v-for="(file, index) in modelValue" :key="index" class="d-flex mx-1 mt-1 align-items-start">
<span class="col-auto"><i class="fa fa-file me-1"></i></span>
<span class="col">{{ file.name }}</span>
<button class="col-auto btn btn-outline-secondary btn-p-0" @click="removeFile(index)">
<i class="fa fa-close"></i>
</button>
</li>
<dms-item
v-for="(file, index) in modelValue"
:key="index"
v-model="file"
class="d-flex mx-1 mt-1 align-items-start"
@delete="removeFile(index)"
>
</dms-item>
</ul>
</div>`
}
}
@@ -0,0 +1,37 @@
export default {
emits: [
'delete'
],
props: {
modelValue: {
type: [File, Object],
required: true
}
},
data() {
return {
preview: ''
};
},
watch: {
modelValue(n) {
if (n.type == 'application/x.fhc-dms+json') {
n.text().then(result => {
const obj = JSON.parse(result);
this.preview = obj.preview || '';
});
}
}
},
template: `
<li class="form-upload-dms-item">
<span class="col-auto"><i class="fa fa-file me-1"></i></span>
<span class="col">{{ modelValue.name }}</span>
<a v-if="preview" :href="preview" target="_blank" class="col-auto btn btn-outline-secondary btn-p-0 me-1">
<i class="fa fa-download"></i>
</a>
<button class="col-auto btn btn-outline-secondary btn-p-0" @click="$emit('delete')">
<i class="fa fa-close"></i>
</button>
</li>`
}
+48
View File
@@ -0,0 +1,48 @@
export default {
props: [
'dateien',
'multiupload'
],
computed: {
intDateien:{
get() {
return this.dateien;
},
set(value) {
this.$emit('update:dateien', value);
}
},
},
methods: {
handleFileChange(event) {
this.intDateien = event.target.files;
},
deleteFile(id) {
const dt = new DataTransfer();
const files = this.$refs.upload.files;
for (let i = 0; i < files.length; i++) {
const file = files[i];
if (id !== i)
dt.items.add(file);
}
this.$refs.upload.files = dt.files;
this.$emit('update:dateien', dt.files);
}
},
template: `
<span>
<input type="file" :multiple="multiupload" ref="upload" @change="handleFileChange" v-model="dateien"/>
</span>
<span>
<ul>
<li v-for="(datei,index) in dateien">
<button>{{datei.name}}</button><button class="text-danger" @click="deleteFile(index)"><i class="fa fa-remove"></i></button>
</li>
</ul>
</span>
</div>
</template>`
}
+1 -1
View File
@@ -38,4 +38,4 @@ export default {
</div>
</template>
`
};
};
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,211 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*/
import CoreSearchbar from "../searchbar/searchbar.js";
import VerticalSplit from "../verticalsplit/verticalsplit.js";
import StvVerband from "./Studentenverwaltung/Verband.js";
import StvList from "./Studentenverwaltung/List.js";
import StvDetails from "./Studentenverwaltung/Details.js";
import StvStudiensemester from "./Studentenverwaltung/Studiensemester.js";
export default {
components: {
CoreSearchbar,
VerticalSplit,
StvVerband,
StvList,
StvDetails,
StvStudiensemester
},
props: {
defaultSemester: String,
config: Object,
permissions: Object,
stvRoot: String,
cisRoot: String,
activeAddons: String // semicolon separated list of active addons
},
provide() {
return {
cisRoot: this.cisRoot,
activeAddonBewerbung: this.activeAddons.split(';').includes('bewerbung'),
configGenerateAlias: this.config.generateAlias,
configShowZgvDoktor: this.config.showZgvDoktor,
configShowZgvErfuellt: this.config.showZgvErfuellt,
hasBpkPermission: this.permissions['student/bpk'],
hasAliasPermission: this.permissions['student/alias'],
hasPrestudentPermission: this.permissions['basis/prestudent'],
hasPrestudentstatusPermission: this.permissions['basis/prestudentstatus'],
hasAssistenzPermissionForStgs: this.permissions['assistenz_stgs'],
hasSchreibrechtAss: this.permissions['assistenz_schreibrechte'],
hasAdminPermission: this.permissions['admin'],
hasPermissionToSkipStatusCheck: this.permissions['student/keine_studstatuspruefung'],
hasPermissionRtAufsicht: this.permissions['lehre/reihungstestAufsicht'],
lists: this.lists,
defaultSemester: this.defaultSemester,
$reloadList: () => {
this.$refs.stvList.reload();
}
}
},
data() {
return {
selected: [],
searchbaroptions: {
types: [
"student",
"prestudent"
],
actions: {
student: {
defaultaction: {
type: "link",
action: function(data) {
return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/studentenverwaltung/student/' + data.uid;
}
},
childactions: [
]
},
prestudent: {
defaultaction: {
type: "link",
action: function(data) {
return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/studentenverwaltung/prestudent/' + data.prestudent_id;
}
},
childactions: [
]
}
}
},
studiengangKz: undefined,
studiensemesterKurzbz: this.defaultSemester,
lists: {
nations: [],
sprachen: [],
geschlechter: []
}
}
},
methods: {
onSelectVerband({link, studiengang_kz}) {
this.studiengangKz = studiengang_kz;
this.$refs.stvList.updateUrl(this.$fhcApi.factory.stv.students.verband(link));
},
studiensemesterChanged(v) {
this.studiensemesterKurzbz = v;
this.$refs.stvList.updateUrl();
this.$refs.details.reload();
},
reloadList() {
this.$refs.stvList.reload();
}
},
created() {
this.$fhcApi
.get('api/frontend/v1/stv/address/getNations')
.then(result => {
this.lists.nations = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/lists/getSprachen')
.then(result => {
this.lists.sprachen = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/lists/getGeschlechter')
.then(result => {
this.lists.geschlechter = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/lists/getAusbildungen')
.then(result => {
this.lists.ausbildungen = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/lists/getStgs')
.then(result => {
this.lists.stgs = result.data;
this.lists.active_stgs = this.lists.stgs.filter(stg => stg.aktiv);
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/lists/getOrgforms')
.then(result => {
this.lists.orgforms = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.factory.stv.konto.getBuchungstypen()
.then(result => {
this.lists.buchungstypen = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/lists/getStudiensemester')
.then(result => {
this.lists.studiensemester = result.data;
this.lists.studiensemester_desc = result.data.toReversed();
})
.catch(this.$fhcAlert.handleSystemError);
},
mounted() {
if (this.$route.params.id) {
this.$refs.stvList.updateUrl(this.$fhcApi.factory.stv.students.uid(this.$route.params.id), true);
} else if (this.$route.params.prestudent_id) {
this.$refs.stvList.updateUrl(this.$fhcApi.factory.stv.students.prestudent(this.$route.params.prestudent_id), true);
} else if (this.$route.params.person_id) {
this.$refs.stvList.updateUrl(this.$fhcApi.factory.stv.students.person(this.$route.params.person_id), true);
}
},
template: `
<div class="stv">
<header class="navbar navbar-expand-lg navbar-dark bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-4 col-lg-3 col-xl-2 me-0 px-3" :href="stvRoot">FHC 4.0</a>
<button class="navbar-toggler d-md-none m-1 collapsed" type="button" data-bs-toggle="offcanvas" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" :aria-label="$p.t('ui/toggle_nav')"><span class="navbar-toggler-icon"></span></button>
<core-searchbar :searchoptions="searchbaroptions" :searchfunction="$fhcApi.factory.search.search" class="searchbar w-100"></core-searchbar>
</header>
<div class="container-fluid overflow-hidden">
<div class="row h-100">
<nav id="sidebarMenu" class="bg-light offcanvas offcanvas-start col-md p-md-0 h-100">
<div class="offcanvas-header justify-content-end px-1 d-md-none">
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" :aria-label="$p.t('ui/schliessen')"></button>
</div>
<stv-verband @select-verband="onSelectVerband" class="col" style="height:0%"></stv-verband>
<stv-studiensemester :default="defaultSemester" @changed="studiensemesterChanged"></stv-studiensemester>
</nav>
<main class="col-md-8 ms-sm-auto col-lg-9 col-xl-10">
<vertical-split>
<template #top>
<stv-list ref="stvList" v-model:selected="selected" :studiengang-kz="studiengangKz" :studiensemester-kurzbz="studiensemesterKurzbz"></stv-list>
</template>
<template #bottom>
<stv-details ref="details" :students="selected"></stv-details>
</template>
</vertical-split>
</main>
</div>
</div>
</div>`
};
@@ -0,0 +1,60 @@
import FhcTabs from "../../Tabs.js";
// TODO(chris): alt & title
// TODO(chris): phrasen
export default {
components: {
FhcTabs
},
data() {
return {
configStudent: null,
configStudents: null
};
},
props: {
students: Array
},
computed: {
appRoot() {
return FHC_JS_DATA_STORAGE_OBJECT.app_root;
}
},
methods: {
reload() {
if (this.$refs.tabs?.$refs?.current?.reload)
this.$refs.tabs.$refs.current.reload();
}
},
created() {
this.$fhcApi
.factory.stv.configStudent()
.then(result => {
this.configStudent = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.factory.stv.configStudents()
.then(result => {
this.configStudents = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="stv-details h-100 pb-3 d-flex flex-column">
<div v-if="!students?.length" class="justify-content-center d-flex h-100 align-items-center">
Bitte StudentIn auswählen!
</div>
<div v-else-if="configStudent && configStudents" class="d-flex flex-column h-100 pb-3">
<div class="d-flex justify-content-start align-items-center w-100 pb-3 gap-3" style="max-height:8rem">
<img v-for="student in students" :key="student.person_id" class="d-block h-100 rounded" alt="profilbild" :src="appRoot + 'cis/public/bild.php?src=person&person_id=' + student.person_id">
<div v-if="students.length == 1">
<h2 class="h4">{{students[0].titlepre}} {{students[0].vorname}} {{students[0].nachname}} {{students[0].titlepost}}</h2>
</div>
</div>
<fhc-tabs v-if="students.length == 1" ref="tabs" :modelValue="students[0]" :config="configStudent" :default="$route.params.tab" style="flex: 1 1 0%; height: 0%" @changed="reload"></fhc-tabs>
<fhc-tabs v-else ref="tabs" :modelValue="students" :config="configStudents" :default="$route.params.tab" style="flex: 1 1 0%; height: 0%" @changed="reload"></fhc-tabs>
</div>
</div>`
};
@@ -0,0 +1,23 @@
import CoreBetriebsmittel from "../../../Betriebsmittel/Betriebsmittel.js";
export default {
components: {
CoreBetriebsmittel
},
props: {
modelValue: Object
},
template: `
<div class="stv-details-betriebsmittel h-100 pb-3">
<core-betriebsmittel
:endpoint="$fhcApi.factory.betriebsmittel.person"
ref="formc"
type-id="person_id"
:id="modelValue.person_id"
:uid="modelValue.uid"
>
</core-betriebsmittel>
</div>
`
};
@@ -0,0 +1,462 @@
import CoreForm from '../../../Form/Form.js';
import FormInput from '../../../Form/Input.js';
import FormUploadImage from '../../../Form/Upload/Image.js';
import CoreUdf from '../../../Udf/Udf.js';
export default {
components: {
CoreForm,
FormInput,
FormUploadImage,
CoreUdf
},
inject: {
showBpk: {
from: 'hasBpkPermission',
default: false
},
showZugangscode: {
from: 'activeAddonBewerbung',
default: false
},
cisRoot: {
from: 'cisRoot'
},
generateAlias: {
from: 'configGenerateAlias',
default: false
},
hasAliasPermission: {
from: 'hasAliasPermission',
default: false
},
lists: {
from: 'lists'
}
},
props: {
modelValue: Object
},
data() {
return {
test: {udf_viaf: 'TEST'},
familienstaende: {
"": "--keine Auswahl--",
"g": "geschieden",
"l": "ledig",
"v": "verheiratet",
"w": "verwitwet"
},
original: null,
data: null,
changed: {},
udfChanges: false,
studentIn: null,
gebDatumIsValid: false,
gebDatumIsInvalid: false
}
},
computed: {
aliasNotAllowed() {
return this.generateAlias === false && !this.hasAliasPermission;
},
changedLength() {
return Object.keys(this.changed).length;
},
noImageSrc() {
return FHC_JS_DATA_STORAGE_OBJECT.app_root + 'skin/images/profilbild_dummy.jpg';
}
},
watch: {
modelValue(n) {
this.updateStudent(n);
},
data: {
// TODO(chris): use @input instead?
handler(n) {
let res = {};
for (var k in this.original) {
if (k == 'gebdatum') {
if (new Date(this.original[k]).toString() != new Date(n[k]).toString())
res[k] = n[k];
} else {
// TODO(chris): null && ""? should there be an exception for this?
if (this.original[k] !== n[k] && !(this.original[k] === null && n[k] === ""))
res[k] = n[k];
}
}
this.changed = res;
},
deep: true
}
},
methods: {
updateStudent(n) {
// TODO(chris): move to fhcapi.factory
this.$fhcApi
.get('api/frontend/v1/stv/student/get/' + n.prestudent_id)
.then(result => {
this.data = result.data;
if (!this.data.familienstand)
this.data.familienstand = '';
this.original = {...(this.original || {}), ...this.data};
})
.catch(this.$fhcAlert.handleSystemError);
},
save() {
if (!this.changedLength)
return;
this.$refs.form.clearValidation();
this.$refs.form
.post('api/frontend/v1/stv/student/save/' + this.modelValue.prestudent_id, this.changed)
.then(result => {
this.original = {...this.data};
this.changed = {};
this.$refs.form.setFeedback(true, result.data);
})
.catch(this.$fhcAlert.handleSystemError)
},
udfsLoaded(udfs) {
this.original = {...(this.original || {}), ...udfs};
},
reload(){
this.updateStudent(this.modelValue);
}
},
created() {
this.updateStudent(this.modelValue);
},
//TODO(chris): Phrasen
//TODO(chris): Geburtszeit? Anzahl der Kinder?
template: `
<core-form ref="form" class="stv-details-details" @submit.prevent="save">
<div class="position-sticky top-0 z-1">
<button type="submit" class="btn btn-primary position-absolute top-0 end-0" :disabled="!changedLength">Speichern</button>
</div>
<fieldset class="overflow-hidden">
<legend>Person</legend>
<template v-if="data">
<div class="row mb-3">
<form-input
container-class="col-4"
label="Person ID"
type="text"
v-model="data.person_id"
name="person_id"
readonly
>
</form-input>
<div v-if="showZugangscode" class="col-4">
<label>Zugangscode</label>
<div class="align-self-center">
<span class="form-text">
<a :href="cisRoot + 'addons/bewerbung/cis/registration.php?code=' + data.zugangscode + '&emailAdresse=' + data.email_privat" target="_blank">{{data.zugangscode}}</a>
</span>
</div>
</div>
<form-input
v-if="showBpk"
container-class="col-4"
label="BPK"
type="text"
v-model="data.bpk"
name="bpk"
maxlength="28"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Anrede"
type="text"
v-model="data.anrede"
name="anrede"
maxlength="16"
>
</form-input>
<form-input
container-class="col-4"
label="Titel Pre"
type="text"
v-model="data.titelpre"
name="titelpre"
maxlength="64"
>
</form-input>
<form-input
container-class="col-4"
label="Titel Post"
type="text"
v-model="data.titelpost"
name="titelpost"
maxlength="32"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Nachname"
type="text"
v-model="data.nachname"
name="nachname"
maxlength="64"
>
</form-input>
<form-input
container-class="col-4"
label="Vorname"
type="text"
v-model="data.vorname"
name="vorname"
maxlength="32"
>
</form-input>
<form-input
container-class="col-4"
label="Vornamen"
type="text"
v-model="data.vornamen"
name="vornamen"
maxlength="128"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Wahlname"
type="text"
v-model="data.wahlname"
name="wahlname"
maxlength="128"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Geburtsdatum"
type="DatePicker"
v-model="data.gebdatum"
name="gebdatum"
:clearable="false"
no-today
auto-apply
:enable-time-picker="false"
format="dd.MM.yyyy"
preview-format="dd.MM.yyyy"
teleport
>
</form-input>
<form-input
container-class="col-4"
label="Geburtsort"
type="text"
v-model="data.gebort"
name="gebort"
maxlength="128"
>
</form-input>
<form-input
container-class="col-4"
label="Geburtsnation"
type="select"
v-model="data.geburtsnation"
name="geburtsnation"
>
<option value="">-- keine Auswahl --</option>
<!-- TODO(chris): gesperrte nationen können nicht ausgewählt werden! Um das zu realisieren müsste man ein pseudo select machen -->
<option v-for="nation in lists.nations" :key="nation.nation_code" :value="nation.nation_code" :disabled="nation.sperre">{{nation.kurztext}}</option>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="SVNR"
type="text"
v-model="data.svnr"
name="svnr"
maxlength="16"
>
</form-input>
<form-input
container-class="col-4"
label="Ersatzkennzeichen"
type="text"
v-model="data.ersatzkennzeichen"
name="ersatzkennzeichen"
maxlength="10"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Staatsbürgerschaft"
type="select"
v-model="data.staatsbuergerschaft"
name="staatsbuergerschaft"
>
<option value="">-- keine Auswahl --</option>
<!-- TODO(chris): gesperrte nationen können nicht ausgewählt werden! Um das zu realisieren müsste man ein pseudo select machen -->
<option v-for="nation in lists.nations" :key="nation.nation_code" :value="nation.nation_code" :disabled="nation.sperre">{{nation.kurztext}}</option>
</form-input>
<form-input
container-class="col-4"
label="Matrikelnummer"
type="text"
v-model="data.matr_nr"
name="matr_nr"
maxlength="32"
>
</form-input>
<form-input
container-class="col-4"
label="Sprache"
type="select"
v-model="data.sprache"
name="sprache"
>
<option v-for="sprache in lists.sprachen" :key="sprache.sprache" :value="sprache.sprache">{{sprache.sprache}}</option>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Geschlecht"
type="select"
v-model="data.geschlecht"
name="geschlecht"
>
<option v-for="geschlecht in lists.geschlechter" :key="geschlecht.geschlecht" :value="geschlecht.geschlecht">{{geschlecht.bezeichnung}}</option>
</form-input>
<form-input
container-class="col-4"
label="Familienstand"
type="select"
v-model="data.familienstand"
name="familienstand"
>
<option v-for="(bezeichnung, key) in familienstaende" :key="key" :value="key">{{bezeichnung}}</option>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Foto"
type="UploadImage"
v-model="data.foto"
name="foto"
>
<img alt="No Image" :src="noImageSrc" class="w-100">
</form-input>
<form-input
container-class="col-4"
label="Anmerkung"
type="textarea"
v-model="data.anmerkung"
name="anmerkung"
rows="8"
>
</form-input>
<form-input
container-class="col-4"
label="Homepage"
type="text"
v-model="data.homepage"
name="homepage"
maxlength="256"
>
</form-input>
</div>
</template>
<div v-else>
Loading...
</div>
<core-udf @load="udfsLoaded" v-model="data" class="row-cols-3 g-3 mb-3" ci-model="person/person" :pk="{person_id:modelValue.person_id}"></core-udf>
</fieldset>
<fieldset v-if="data?.student_uid" class="overflow-hidden">
<legend>StudentIn</legend>
<template v-if="data">
<div class="row mb-3">
<form-input
container-class="col-4"
label="UID"
type="text"
v-model="data.student_uid"
name="student_uid"
readonly
>
</form-input>
<form-input
container-class="col-4"
label="Personenkennzeichen"
type="text"
v-model="data.matrikelnr"
name="matrikelnr"
readonly
>
</form-input>
<div class="col-4 pt-4 d-flex align-items-center">
<form-input
container-class="form-check"
label="Aktiv"
type="checkbox"
v-model="data.aktiv"
name="aktiv"
>
</form-input>
</div>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Semester"
type="text"
v-model="data.semester"
name="semester"
maxlength="2"
>
</form-input>
<form-input
container-class="col-4"
label="Verband"
type="text"
v-model="data.verband"
name="verband"
maxlength="1"
>
</form-input>
<form-input
container-class="col-4"
label="Gruppe"
type="text"
v-model="data.gruppe"
name="gruppe"
maxlength="1"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
label="Alias"
type="text"
v-model="data.alias"
name="alias"
:disabled="aliasNotAllowed"
>
</form-input>
</div>
</template>
<div v-else>
Loading...
</div>
</fieldset>
</core-form>`
};
@@ -0,0 +1,39 @@
import AddressList from "./Kontakt/Address.js";
import ContactList from "./Kontakt/Contact.js";
import BankaccountList from "./Kontakt/Bankaccount.js";
export default {
components: {
AddressList,
ContactList,
BankaccountList,
},
props: {
modelValue: Object,
config: Object
},
data() {
return {
adressen: [],
kontakte: [],
bankverbindungen: []
}
},
template: `
<div class="stv-details-kontakt h-100 pb-3">
<fieldset class="overflow-hidden">
<legend>{{this.$p.t('person', 'adressen')}}</legend>
<address-list ref="adressList" :uid="modelValue.person_id"></address-list>
</fieldset>
<br>
<fieldset class="overflow-hidden">
<legend>{{this.$p.t('global', 'kontakt')}}</legend>
<contact-list ref="contactList" :uid="modelValue.person_id"></contact-list>
</fieldset>
<br>
<fieldset v-if="config.showBankaccount" class="overflow-hidden">
<legend>{{this.$p.t('person', 'bankverbindungen')}}</legend>
<bankaccount-list ref="bankaccountList" :uid="modelValue.person_id"></bankaccount-list>
</fieldset>
</div>`
};
@@ -0,0 +1,583 @@
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
import PvAutoComplete from "../../../../../../../index.ci.php/public/js/components/primevue/autocomplete/autocomplete.esm.min.js";
import FhcFormValidation from '../../../../Form/Validation.js';
import BsModal from "../../../../Bootstrap/Modal.js";
import FormForm from '../../../../Form/Form.js';
import FormInput from '../../../../Form/Input.js';
export default{
components: {
CoreFilterCmpt,
PvAutoComplete,
FhcFormValidation,
BsModal,
FormForm,
FormInput
},
props: {
uid: Number
},
data() {
return{
tabulatorOptions: {
ajaxURL: 'api/frontend/v1/stv/kontakt/getAdressen/' + this.uid,
ajaxRequestFunc: this.$fhcApi.get,
ajaxResponse: (url, params, response) => response.data,
//autoColumns: true,
columns:[
{title:"Typ", field:"bezeichnung"},
{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:"tickCross",
hozAlign:"center",
formatterParams: {
tickElement: '<i class="fa fa-check text-success"></i>',
crossElement: '<i class="fa fa-xmark text-danger"></i>'
}
},
{
title:"Zustelladresse",
field:"zustelladresse",
formatter:"tickCross",
hozAlign:"center",
formatterParams: {
tickElement: '<i class="fa fa-check text-success"></i>',
crossElement: '<i class="fa fa-xmark text-danger"></i>'
}
},
{title:"Abweich.Empf", field:"co_name"},
{title:"Firma", field:"firmenname"},
{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},
{title: 'Aktionen', field: 'actions',
minWidth: 150, // Ensures Action-buttons will be always fully displayed
formatter: (cell, formatterParams, onRendered) => {
let container = document.createElement('div');
container.className = "d-flex gap-2";
let button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-edit"></i>';
button.addEventListener('click', (event) =>
this.actionEditAdress(cell.getData().adresse_id)
);
container.append(button);
button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-xmark"></i>';
button.addEventListener('click', () =>
this.actionDeleteAdress(cell.getData().adresse_id)
);
container.append(button);
return container;
},
frozen: true
},
],
layout: 'fitDataFill',
layoutColumnsOnNewData: false,
height: 'auto',
selectable: true,
index: 'adresse_id',
persistenceID: 'stv-details-kontakt-address'
},
tabulatorEvents: [
{
event: 'tableBuilt',
handler: async () => {
await this.$p.loadCategory(['notiz','global','person', 'ui']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('bezeichnung').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('strasse').component.updateDefinition({
title: this.$p.t('person', 'strasse')
});
cm.getColumnByField('plz').component.updateDefinition({
title: this.$p.t('person', 'plz')
});
cm.getColumnByField('ort').component.updateDefinition({
title: this.$p.t('person', 'ort')
});
cm.getColumnByField('gemeinde').component.updateDefinition({
title: this.$p.t('person', 'gemeinde')
});
cm.getColumnByField('nation').component.updateDefinition({
title: this.$p.t('person', 'nation')
});
cm.getColumnByField('heimatadresse').component.updateDefinition({
title: this.$p.t('person', 'heimatadresse')
});
cm.getColumnByField('co_name').component.updateDefinition({
title: this.$p.t('person', 'co_name')
});
cm.getColumnByField('name').component.updateDefinition({
title: this.$p.t('person', 'firma_zusatz')
});
cm.getColumnByField('firmenname').component.updateDefinition({
title: this.$p.t('person', 'firma')
});
cm.getColumnByField('updateamum').component.updateDefinition({
title: this.$p.t('notiz', 'letzte_aenderung')
});
cm.getColumnByField('rechnungsadresse').component.updateDefinition({
title: this.$p.t('person', 'rechnungsadresse')
});
cm.getColumnByField('anmerkung').component.updateDefinition({
title: this.$p.t('global', 'anmerkung')
});
}
}
],
addressData: {
zustelladresse: true,
heimatadresse: true,
rechnungsadresse: false,
typ: 'h',
nation: 'A'
},
statusNew: true,
places: [],
suggestions: {},
nations: [],
adressentypen: [],
firmen: [],
filteredFirmen: [],
abortController: {
suggestions: null,
places: null
}
}
},
computed:{
orte() {
return this.places.filter(ort => ort.name == this.addressData.gemeinde);
},
gemeinden() {
return Object.values(this.places.reduce((res,place) => {
res[place.name] = place;
return res;
}, {}));
}
},
watch: {
uid() {
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getAdressen/' + this.uid);
},
},
methods:{
actionNewAdress() {
this.resetModal();
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.adressModal.show();
}
});
},
actionDeleteAdress(adress_id) {
this.loadAdress(adress_id).then(() => {
if(this.addressData.adresse_id)
if(this.addressData.heimatadresse)
this.$fhcAlert.alertError(this.$p.t('person', 'error_deleteHomeAdress'));
else {
this.$fhcAlert
.confirmDelete()
.then(result => result
? adress_id
: Promise.reject({handled: true}))
.then(this.deleteAddress)
.catch(this.$fhcAlert.handleSystemError);
}
});
},
addNewAddress(addressData) {
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewAddress/' + this.uid,
this.addressData
).then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('adressModal');
this.resetModal();
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
reload() {
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;
return result;
})
.catch(this.$fhcAlert.handleSystemError);
},
updateAddress(adress_id) {
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateAddress/' + adress_id,
this.addressData
).then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('adressModal');
this.resetModal();
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
deleteAddress(adress_id) {
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteAddress/' + adress_id)
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
}).catch(this.$fhcAlert.handleSystemError)
.finally(()=> {
window.scrollTo(0, 0);
this.reload();
});
},
loadPlaces() {
if (this.abortController.places)
this.abortController.places.abort();
if (this.addressData.nation != 'A' || !this.addressData.plz)
return;
this.abortController.places = new AbortController();
this.$fhcApi
.get('api/frontend/v1/stv/address/getPlaces/' + this.addressData.plz, undefined, {
signal: this.abortController.places.signal
})
.then(result => {
this.places = result.data;
});
/* .catch(error => {
if (error.code != "ERR_CANCELED")
window.setTimeout(this.loadPlaces, 100);
else
this.$fhcAlert.handleSystemError(error);
});*/
},
search(event) {
return this.$fhcApi
.get('api/frontend/v1/stv/kontakt/getFirmen/' + event.query)
.then(result => {
this.filteredFirmen = result.data.retval;
});
},
hideModal(modalRef) {
this.$refs[modalRef].hide();
},
resetModal() {
this.addressData = {};
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() {
this.$fhcApi
.get('api/frontend/v1/stv/address/getNations')
.then(result => {
this.nations = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/kontakt/getAdressentypen')
.then(result => {
this.adressentypen = result.data;
})
.catch(this.$fhcAlert.handleSystemError)
},
template: `
<div class="stv-details-kontakt-address h-100 pt-3">
<!--Modal: AddressModal-->
<bs-modal ref="adressModal">
<template #title>
<p v-if="statusNew" class="fw-bold mt-3">{{$p.t('person', 'adresse_new')}}</p>
<p v-else class="fw-bold mt-3">{{$p.t('person', 'adresse_edit')}}</p>
</template>
<form-form class="row g-3 mt-2" ref="addressData">
<div class="row mb-3">
<form-input
type="select"
name="adressentyp"
:label="$p.t('global/typ')"
v-model="addressData.typ"
>
<option
v-for="typ in adressentypen"
:key="typ.adressentyp_kurzbz"
:value="typ.adressentyp_kurzbz"
>
{{typ.bezeichnung}}
</option>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="strasse"
:label="$p.t('person/strasse')"
v-model="addressData.strasse"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="select"
name="nation"
:label="$p.t('person/nation')"
v-model="addressData.nation"
>
<option
v-for="nation in nations"
:key="nation.nation_code"
:value="nation.nation_code"
:disabled="nation.sperre"
>
{{nation.kurztext}}
</option>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="plz"
:label="$p.t('person/plz') + ' *'"
v-model="addressData.plz"
required
@input="loadPlaces"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
v-if="addressData.nation == 'A'"
type="select"
name="gemeinde"
:label="$p.t('person/gemeinde')"
v-model="addressData.gemeinde"
>
<option v-if="!gemeinden.length" disabled>{{$p.t('ui', 'bittePlzWaehlen')}}</option>
<option
v-for="gemeinde in gemeinden"
:key="gemeinde.name"
:value="gemeinde.name"
>
{{gemeinde.name}}
</option>
</form-input>
<form-input
v-else
type="text"
name="addressData.gemeinde"
v-model="addressData.gemeinde"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
v-if="addressData.nation == 'A'"
type="select"
name="ort"
:label="$p.t('person/ort')"
v-model="addressData.ort"
>
<option v-if="!orte.length" disabled>{{$p.t('ui', 'bitteGemeindeWaehlen')}}</option>
<option
v-for="ort in orte"
:key="ort.ortschaftsname"
:value="ort.ortschaftsname"
>
{{ort.ortschaftsname}}
</option>
</form-input>
<form-input
v-else
type="text"
name="ort"
v-model="addressData.ort"
>
</form-input>
</div>
<div class="row mb-3">
<div class="col-sm-4">
<form-input
container-class="form-check"
type="checkbox"
name="heimatadresse"
:label="$p.t('person/heimatadresse')"
v-model="addressData.heimatadresse"
>
</form-input>
</div>
</div>
<div class="row mb-3">
<div class="col-sm-4">
<form-input
container-class="form-check"
type="checkbox"
name="zustelladresse"
:label="$p.t('person/zustelladresse')"
v-model="addressData.zustelladresse"
>
</form-input>
</div>
</div>
<div class="row mb-3">
<form-input
type="text"
name="co_name"
:label="$p.t('person/co_name')"
v-model="addressData.co_name"
>
</form-input>
</div>
<div class="row mb-3">
<div class="col-sm-4">
<form-input
container-class="form-check"
type="checkbox"
name="rechnungsadresse"
:label="$p.t('person/rechnungsadresse')"
v-model="addressData.rechnungsadresse"
>
</form-input>
</div>
</div>
<div v-if="statusNew" class="row mb-3">
<form-input
type="autocomplete"
:label="$p.t('person/firma')"
name="firma_name"
v-model="addressData.firma"
optionLabel="name"
:suggestions="filteredFirmen"
@complete="search"
:min-length="3"
>
</form-input>
</div>
<div v-else class="row mb-3">
<form-input
v-if="addressData.firmenname"
type="text"
name="name"
:label="$p.t('person/firma')"
v-model="addressData.firmenname"
>
</form-input>
<form-input
v-else
type="autocomplete"
:label="$p.t('person/firma')"
name="firma_name"
v-model="addressData.firma"
optionLabel="name"
:suggestions="filteredFirmen"
@complete="search"
:min-length="3"
>
</form-input>
</div>
<div class="row mb-3">
<input type="hidden" class="form-control" id="firma_id" v-model="addressData.firma_id">
</div>
<div class="row mb-3">
<form-input
type="text"
name="firma_zusatz"
:label="$p.t('person/firma_zusatz')"
v-model="addressData.name"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="anmerkung"
:label="$p.t('global/anmerkung')"
v-model="addressData.anmerkung"
>
</form-input>
</div>
</form-form>
<template #footer>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{$p.t('ui', 'abbrechen')}}</button>
<button v-if="statusNew" type="button" class="btn btn-primary" @click="addNewAddress()">OK</button>
<button v-else type="button" class="btn btn-primary" @click="updateAddress(addressData.adresse_id)">OK</button>
</template>
</bs-modal>
<core-filter-cmpt
ref="table"
:tabulator-options="tabulatorOptions"
:tabulator-events="tabulatorEvents"
table-only
:side-menu="false"
reload
new-btn-show
new-btn-label="Adresse"
@click:new="actionNewAdress"
>
</core-filter-cmpt>
</div>`
};
@@ -0,0 +1,336 @@
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
import BsModal from "../../../../Bootstrap/Modal.js";
import FormForm from '../../../../Form/Form.js';
import FormInput from '../../../../Form/Input.js';
export default{
components: {
CoreFilterCmpt,
BsModal,
FormForm,
FormInput
},
props: {
uid: Number
},
data() {
return{
tabulatorOptions: {
ajaxURL: 'api/frontend/v1/stv/Kontakt/getBankverbindung/' + this.uid,
ajaxRequestFunc: this.$fhcApi.get,
ajaxResponse: (url, params, response) => response.data,
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:"tickCross",
hozAlign:"center",
formatterParams: {
tickElement: '<i class="fa fa-check text-success"></i>',
crossElement: '<i class="fa fa-xmark text-danger"></i>'
}
},
{title:"Person_id", field:"person_id", visible:false},
{title:"Bankverbindung_id", field:"bankverbindung_id", visible:false},
{title: 'Aktionen', field: 'actions',
minWidth: 150, // Ensures Action-buttons will be always fully displayed
formatter: (cell, formatterParams, onRendered) => {
let container = document.createElement('div');
container.className = "d-flex gap-2";
let button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-edit"></i>';
button.addEventListener('click', (event) =>
this.actionEditBankverbindung(cell.getData().bankverbindung_id)
);
container.append(button);
button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-xmark"></i>';
button.addEventListener('click', () =>
this.actionDeleteBankverbindung(cell.getData().bankverbindung_id)
);
container.append(button);
return container;
},
frozen: true
},
],
layout: 'fitDataFill',
layoutColumnsOnNewData: false,
height: 'auto',
selectable: true,
index: 'bankverbindung_id',
persistenceID: 'stv-details-kontakt-bankaccount'
},
tabulatorEvents: [
{
event: 'tableBuilt',
handler: async() => {
await this.$p.loadCategory(['global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('anschrift').component.updateDefinition({
title: this.$p.t('person', 'anschrift')
});
cm.getColumnByField('kontonr').component.updateDefinition({
title: this.$p.t('person', 'kontonr')
});
cm.getColumnByField('blz').component.updateDefinition({
title: this.$p.t('person', 'blz')
});
cm.getColumnByField('typ').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('verrechnung').component.updateDefinition({
title: this.$p.t('person', 'verrechnung')
});
}
}
],
lastSelected: null,
bankverbindungData: {
verrechnung: true,
typ: 'p'
},
statusNew: true
}
},
watch: {
uid(){
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Kontakt/getBankverbindung/' + this.uid);
}
},
methods:{
actionNewBankverbindung(){
this.resetModal();
this.$refs.bankverbindungModal.show();
},
actionEditBankverbindung(bankverbindung_id){
this.statusNew = false;
this.loadBankverbindung(bankverbindung_id).then(() => {
if(this.bankverbindungData.bankverbindung_id)
this.$refs.bankverbindungModal.show();
});
},
actionDeleteBankverbindung(bankverbindung_id){
this.loadBankverbindung(bankverbindung_id).then(() => {
this.$fhcAlert
.confirmDelete()
.then(result => result
? bankverbindung_id
: Promise.reject({handled: true}))
.then(this.deleteBankverbindung)
.catch(this.$fhcAlert.handleSystemError);
});
},
addNewBankverbindung(bankverbindungData) {
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewBankverbindung/' + this.uid,
this.bankverbindungData
).then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('bankverbindungModal');
this.resetModal();
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
loadBankverbindung(bankverbindung_id){
this.statusNew = false;
return this.$fhcApi.get('api/frontend/v1/stv/kontakt/loadBankverbindung/' + bankverbindung_id)
.then(
result => {
this.bankverbindungData = result.data;
return result;
})
.catch(this.$fhcAlert.handleSystemError);
},
updateBankverbindung(bankverbindung_id){
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateBankverbindung/' + bankverbindung_id,
this.bankverbindungData)
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('bankverbindungModal');
this.resetModal();
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
deleteBankverbindung(bankverbindung_id){
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteBankverbindung/' + bankverbindung_id)
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
}).catch(this.$fhcAlert.handleSystemError)
.finally(()=> {
window.scrollTo(0, 0);
this.resetModal();
this.reload();
});
},
hideModal(modalRef){
this.$refs[modalRef].hide();
},
reload(){
this.$refs.table.reloadTable();
},
resetModal(){
this.bankverbindungData = {};
this.bankverbindungData.name = "";
this.bankverbindungData.anschrift = "";
this.bankverbindungData.iban = "";
this.bankverbindungData.bic = "";
this.bankverbindungData.kontonr = "";
this.bankverbindungData.blz = "";
this.bankverbindungData.bic = "";
this.bankverbindungData.verrechnung = true;
this.bankverbindungData.typ = 'p';
this.statusNew = true;
},
},
template: `
<div class="stv-details-kontakt-bankaccount h-100 pt-3">
<!--Modal: Bankverbindung-->
<BsModal title="Bankverbindung anlegen" ref="bankverbindungModal">
<template #title>
<p v-if="statusNew" class="fw-bold mt-3">{{$p.t('person', 'bankvb_new')}}</p>
<p v-else class="fw-bold mt-3">{{$p.t('person', 'bankvb_edit')}}</p>
</template>
<form-form class="row g-3" ref="bankverbindungData">
<div class="row my-3">
<form-input
type="text"
name="name"
label="Name"
v-model="bankverbindungData.name"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="anschrift"
:label="$p.t('person/anschrift')"
v-model="bankverbindungData.anschrift"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="iban"
label="IBAN *"
v-model="bankverbindungData.iban"
required
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="bic"
label="BIC"
v-model="bankverbindungData.bic"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="kontonr"
:label="$p.t('person/kontonr')"
v-model="bankverbindungData.kontonr"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="blz"
:label="$p.t('person/blz')"
v-model="bankverbindungData.blz"
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="select"
name="typ"
:label="$p.t('global/typ')"
v-model="bankverbindungData.typ"
required
>
<option value="p">{{$p.t('person', 'privatkonto')}}</option>
<option value="f">{{$p.t('person', 'firmenkonto')}}</option>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="form-check"
type="checkbox"
name="verrechnung"
:label="$p.t('person/verrechnung')"
v-model="bankverbindungData.verrechnung"
>
</form-input>
</div>
</form-form>
<template #footer>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{$p.t('ui', 'abbrechen')}}</button>
<button v-if="statusNew" type="button" class="btn btn-primary" @click="addNewBankverbindung()">OK</button>
<button v-else type="button" class="btn btn-primary" @click="updateBankverbindung(bankverbindungData.bankverbindung_id)">OK</button>
</template>
</BsModal>
<core-filter-cmpt
ref="table"
:tabulator-options="tabulatorOptions"
:tabulator-events="tabulatorEvents"
table-only
:side-menu="false"
reload
new-btn-show
new-btn-label="Bankverbindung"
@click:new="actionNewBankverbindung"
>
</core-filter-cmpt>
</div>`
};
@@ -0,0 +1,401 @@
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
import BsModal from "../../../../Bootstrap/Modal.js";
import PvAutoComplete from "../../../../../../../index.ci.php/public/js/components/primevue/autocomplete/autocomplete.esm.min.js";
import FormForm from '../../../../Form/Form.js';
import FormInput from '../../../../Form/Input.js';
export default{
components: {
CoreFilterCmpt,
PvAutoComplete,
BsModal,
FormForm,
FormInput
},
props: {
uid: Number
},
data() {
return{
tabulatorOptions: {
ajaxURL: 'api/frontend/v1/stv/Kontakt/getKontakte/' + this.uid,
ajaxRequestFunc: this.$fhcApi.get,
ajaxResponse: (url, params, response) => response.data,
columns:[
{title:"Typ", field:"kontakttyp"},
{title:"Kontakt", field:"kontakt"},
{
title:"Zustellung",
field:"zustellung",
formatter:"tickCross",
hozAlign:"center",
formatterParams: {
tickElement: '<i class="fa fa-check text-success"></i>',
crossElement: '<i class="fa fa-xmark text-danger"></i>'
}
},
{title:"Anmerkung", field:"anmerkung"},
{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},
{title:"Standort_id", field:"standort_id", visible:false},
{title:"letzte Änderung", field:"lastupdate", visible:false},
{title: 'Aktionen', field: 'actions',
minWidth: 150, // Ensures Action-buttons will be always fully displayed
formatter: (cell, formatterParams, onRendered) => {
let container = document.createElement('div');
container.className = "d-flex gap-2";
let button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-edit"></i>';
button.addEventListener('click', (event) =>
this.actionEditContact(cell.getData().kontakt_id)
);
container.append(button);
button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-xmark"></i>';
button.addEventListener('click', () =>
this.actionDeleteContact(cell.getData().kontakt_id)
);
container.append(button);
return container;
},
frozen: true
},
],
layout: 'fitDataFill',
layoutColumnsOnNewData: false,
height: 'auto',
selectable: true,
index: 'kontakt_id',
persistenceID: 'stv-details-kontakt-contact'
},
tabulatorEvents: [
{
event: 'tableBuilt',
handler: async() => {
await this.$p.loadCategory(['notiz','global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('kontakttyp').component.updateDefinition({
title: this.$p.t('global', 'typ')
});
cm.getColumnByField('kontakt').component.updateDefinition({
title: this.$p.t('global', 'kontakt')
});
cm.getColumnByField('zustellung').component.updateDefinition({
title: this.$p.t('person', 'zustellung')
});
cm.getColumnByField('anmerkung').component.updateDefinition({
title: this.$p.t('global', 'anmerkung')
});
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',
firma_id: null
},
statusNew: true,
kontakttypen: [],
firmen: [],
filteredFirmen: [],
filteredOrte: null,
}
},
watch: {
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.contactModal.show();
},
actionEditContact(contact_id){
this.statusNew = false;
this.loadContact(contact_id);
this.$refs.contactModal.show();
},
actionDeleteContact(contact_id){
this.loadContact(contact_id);
this.$fhcAlert
.confirmDelete()
.then(result => result
? contact_id
: Promise.reject({handled: true}))
.then(this.deleteContact)
.catch(this.$fhcAlert.handleSystemError);
},
addNewContact(formData) {
this.$fhcApi.post('api/frontend/v1/stv/kontakt/addNewContact/' + this.uid,
this.contactData)
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal("contactModal");
this.resetModal();
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
this.reload();
});
},
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 => {
this.contactData = result.data;
return result;
})
.catch(this.$fhcAlert.handleSystemError);
},
deleteContact(kontakt_id){
this.$fhcApi.post('api/frontend/v1/stv/kontakt/deleteContact/' + kontakt_id)
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
})
.catch(this.$fhcAlert.handleSystemError)
.finally(()=> {
window.scrollTo(0, 0);
this.resetModal();
this.reload();
});
},
updateContact(kontakt_id){
this.$fhcApi.post('api/frontend/v1/stv/kontakt/updateContact/' + kontakt_id,
this.contactData).
then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.hideModal('contactModal');
this.resetModal();
this.reload();
}).catch(this.$fhcAlert.handleSystemError)
.finally(()=> {
window.scrollTo(0, 0);
this.reload();
});
},
hideModal(modalRef){
this.$refs[modalRef].hide();
},
reload(){
this.$refs.table.reloadTable();
},
searchFirma(event) {
return this.$fhcApi
.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.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(){
this.$fhcApi
.get('api/frontend/v1/stv/kontakt/getKontakttypen')
.then(result => {
this.kontakttypen = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="stv-details-kontakt-contact h-100 pt-3">
<!--Modal: contactModal-->
<BsModal ref="contactModal">
<template #title>
<p v-if="statusNew" class="fw-bold mt-3">{{$p.t('person', 'kontakt_new')}}</p>
<p v-else class="fw-bold mt-3">{{$p.t('person', 'kontakt_edit')}}</p>
</template>
<form-form class="row g-3" ref="contactData">
<div class="row my-3">
<form-input
type="select"
name="typ"
:label="$p.t('global/typ')"
v-model="contactData.kontakttyp">
>
<option value="">keine Auswahl</option>
<option v-for="typ in kontakttypen" :key="typ.kontakttyp_kurzbz" :value="typ.kontakttyp" >{{typ.kontakttyp}}</option>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="kontakt"
:label="$p.t('global/kontakt')+ ' *'"
v-model="contactData.kontakt">
required
>
</form-input>
</div>
<div class="row mb-3">
<form-input
type="text"
name="anmerkung"
:label="$p.t('global/anmerkung')"
v-model="contactData.anmerkung">
>
</form-input>
</div>
<div class="row mb-3">
<div class="col-sm-4">
<form-input
container-class="form-check"
type="checkbox"
name="zustellung"
:label="$p.t('person/zustellung')"
v-model="contactData.zustellung"
>
</form-input>
</div>
</div>
<div v-if="statusNew" class="row mb-3">
<form-input
type="autocomplete"
:label="$p.t('person/firma')"
name="firma_name"
v-model="contactData.firma"
optionLabel="name"
:suggestions="filteredFirmen"
@complete="searchFirma"
:min-length="3"
>
</form-input>
</div>
<div v-else class="row mb-3">
<form-input
v-if="contactData.name"
type="text"
name="name"
:label="$p.t('person/firma')"
v-model="contactData.name"
>
</form-input>
<form-input
v-else
type="autocomplete"
:label="$p.t('person/firma')"
name="firma_name"
v-model="contactData.firma"
optionLabel="name"
:suggestions="filteredFirmen"
@complete="searchFirma"
:min-length="3"
>
</form-input>
</div>
<input type="hidden" class="form-control" id="firma_id" v-model="contactData.firma_id">
<input type="hidden" class="form-control" id="standort_id" v-model="contactData.standort_id">
<div class="row mb-3" v-if="contactData.standort_id || filteredOrte">
<form-input
v-if="contactData.name"
type="text"
name="name"
:label="$p.t('person/firma') + ' / ' + $p.t('person/standort')"
v-model="contactData.bezeichnung"
>
</form-input>
<form-input
v-else
type="select"
name="ort"
:label="$p.t('person/standort')"
v-model="contactData.standort_id"
>
<option v-if="filteredOrte" disabled>{{$p.t('ui', 'bitteStandortWaehlen')}}</option>
<option
v-for="ort in filteredOrte"
:key="ort.standort_id"
:value="ort.standort_id"
>
{{ort.bezeichnung}}
</option>
</form-input>
</div>
</form-form>
<template #footer>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{$p.t('ui', 'abbrechen')}}</button>
<button v-if="statusNew" type="button" class="btn btn-primary" @click="addNewContact()">OK</button>
<button v-else type="button" class="btn btn-primary" @click="updateContact(contactData.kontakt_id)">OK</button>
</template>
</BsModal>
<core-filter-cmpt
ref="table"
:tabulator-options="tabulatorOptions"
:tabulator-events="tabulatorEvents"
table-only
:side-menu="false"
reload
new-btn-show
new-btn-label="Kontakt"
@click:new="actionNewContact"
>
</core-filter-cmpt>
</div>`
};
@@ -0,0 +1,257 @@
import {CoreFilterCmpt} from "../../../filter/Filter.js";
import FormInput from "../../../Form/Input.js";
import KontoNew from "./Konto/New.js";
import KontoEdit from "./Konto/Edit.js";
const LOCAL_STORAGE_ID_FILTER = 'stv_details_konto_2024-01-11_filter';
export default {
components: {
CoreFilterCmpt,
FormInput,
KontoNew,
KontoEdit
},
props: {
modelValue: Object,
config: {
type: Object,
default: {}
}
},
data() {
return {
filter: false,
studiengang_kz: false,
counterdate: new Date()
};
},
computed: {
personIds() {
if (this.modelValue.person_id)
return [this.modelValue.person_id];
return this.modelValue.map(e => e.person_id);
},
stg_kz() {
if (this.modelValue.studiengang_kz)
return this.modelValue.studiengang_kz;
let values = this.modelValue.map(e => e.studiengang_kz).filter((v,i,a) => a.indexOf(v) === i);
if (values.length != 1)
return '';
return values[0];
},
studiengang_kz_intern: {
get() {
if (this.stg_kz)
return this.studiengang_kz;
else
return false;
},
set(value) {
this.studiengang_kz = value;
}
},
tabulatorColumns() {
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";
let button = document.createElement('button');
button.className = 'btn btn-outline-secondary';
button.innerHTML = '<i class="fa fa-edit"></i>';
button.addEventListener('click', () =>
this.$refs.edit.open(cell.getData())
);
container.append(button);
button = document.createElement('button');
button.className = 'btn btn-outline-secondary';
button.innerHTML = '<i class="fa fa-trash"></i>';
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;
};
return Object.values(columns);
},
tabulatorOptions() {
return this.$fhcApi.factory.stv.konto.tabulatorConfig({
dataTree: true,
columns: this.tabulatorColumns,
selectable: true,
selectableRangeMode: 'click',
index: 'buchungsnr',
persistenceID: 'stv-details-konto'
}, this);
}
},
watch: {
modelValue() {
this.$refs.table.reloadTable();
}
},
methods: {
reload() {
this.$refs.table.reloadTable();
},
updateData(data) {
if (!data)
return this.reload();
// TODO(chris): check children (!delete?, multiple children)
//this.$refs.table.tabulator.updateOrAddData(data.map(row => row.buchungsnr_verweis ? {buchungsnr:row.buchungsnr_verweis, _children:row} : row));
this.$refs.table.tabulator.updateOrAddData(data);
},
actionNew() {
this.$refs.new.open();
},
actionCounter(selected) {
this.$fhcApi
.factory.stv.konto.counter({
buchungsnr: selected.map(e => e.buchungsnr),
buchungsdatum: this.counterdate
})
.then(result => result.data)
.then(this.updateData)
.then(() => this.$p.t('ui/gespeichert'))
.then(this.$fhcAlert.alertSuccess)
.catch(this.$fhcAlert.handleSystemError);
},
downloadPdf(selected) {
if (Array.isArray(this.modelValue)) {
let id_uid = this.modelValue.reduce((a,c) => {
if (c.uid)
a[c.person_id] = c.uid;
return a
}, {});
let persons = selected.reduce((a,c) => {
if (!a[c.person_id]) {
let uid = id_uid[c.person_id] || '';
a[c.person_id] = uid + '&buchungsnummern=' + c.buchungsnr;
} else {
a[c.person_id] += ';' + c.buchungsnr;
}
return a;
}, {});
Object.values(persons).forEach(part => window.open(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
'content/pdfExport.php?xml=konto.rdf.php&xsl=Zahlung&uid=' +
part,
'_blank'
));
} else {
window.open(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
'content/pdfExport.php?xml=konto.rdf.php&xsl=Zahlung&uid=' +
(this.modelValue.uid || '') +
'&buchungsnummern=' +
selected.map(row => row.buchungsnr).join(';'),
'_blank'
);
}
},
setFilter(type) {
if (type == 'open')
window.localStorage.setItem(LOCAL_STORAGE_ID_FILTER, this.filter ? 1 : 0);
else if (type == 'current_stg')
this.$fhcApi.factory
.stv.filter.setStg(this.studiengang_kz)
.catch(this.$fhcAlert.handleSystemError);
this.$nextTick(this.$refs.table.reloadTable);
}
},
created() {
this.filter = window.localStorage.getItem(LOCAL_STORAGE_ID_FILTER) == 1;
this.$fhcApi.factory
.stv.filter.getStg()
.then(result => this.studiengang_kz = result.data)
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="stv-details-konto h-100 d-flex flex-column">
<div class="row justify-content-end">
<div class="col-lg-3">
<form-input
container-class="form-switch"
type="checkbox"
:label="$p.t('stv/konto_filter_open')"
v-model="filter"
@update:model-value="setFilter('open')"
>
</form-input>
</div>
<div class="col-lg-3">
<form-input
container-class="form-switch"
type="checkbox"
:label="$p.t('stv/konto_filter_current_stg')"
v-model="studiengang_kz_intern"
:disabled="!stg_kz"
@update:model-value="setFilter('current_stg')"
>
</form-input>
</div>
</div>
<core-filter-cmpt
ref="table"
table-only
:side-menu="false"
:tabulator-options="tabulatorOptions"
reload
new-btn-show
:new-btn-label="$p.t('konto/buchung')"
:new-btn-disabled="stg_kz === ''"
@click:new="actionNew"
>
<template #actions="{selected}">
<div class="input-group w-auto">
<form-input
type="DatePicker"
v-model="counterdate"
input-group
:enable-time-picker="false"
auto-apply
@cleared="counterdate = new Date()"
>
</form-input>
<button
class="btn btn-outline-secondary"
@click="actionCounter(selected)"
:disabled="!selected.length"
>
{{ $p.t('stv/konto_counter') }}
</button>
</div>
<button
v-if="config.showZahlungsbestaetigung"
class="btn btn-outline-secondary"
@click="downloadPdf(selected)"
:disabled="!selected.length"
>
<i class="fa fa-download"></i> {{ $p.t('stv/konto_payment_confirmation') }}
</button>
</template>
</core-filter-cmpt>
<konto-new ref="new" :config="config" @saved="updateData" :person-ids="personIds" :stg-kz="stg_kz"></konto-new>
<konto-edit ref="edit" :config="config" @saved="updateData"></konto-edit>
</div>`
};
@@ -0,0 +1,164 @@
import BsModal from "../../../../Bootstrap/Modal.js";
import CoreForm from "../../../../Form/Form.js";
import FormValidation from "../../../../Form/Validation.js";
import FormInput from "../../../../Form/Input.js";
export default {
components: {
BsModal,
CoreForm,
FormValidation,
FormInput
},
inject: {
lists: {
from: 'lists'
}
},
props: {
config: {
type: Object,
default: {}
}
},
data() {
return {
loading: false,
data: {}
};
},
methods: {
save() {
this.$refs.form.clearValidation();
this.loading = true;
this.$refs.form
.factory.stv.konto.edit(this.data)
.then(result => {
this.$emit('saved', result.data);
this.loading = false;
this.$refs.modal.hide();
this.$fhcAlert.alertSuccess(this.$p.t('ui/gespeichert'));
})
.catch(error => {
this.$fhcAlert.handleSystemError(error);
this.loading = false;
});
},
open(data) {
this.data = {...data};
this.$refs.modal.show();
},
preventCloseOnLoading(ev) {
if (this.loading)
ev.returnValue = false;
}
},
template: `
<core-form ref="form" class="stv-details-konto-edit" @submit.prevent="save">
<bs-modal ref="modal" @hide-bs-modal="preventCloseOnLoading">
<form-validation></form-validation>
<fieldset :disabled="loading">
<form-input
v-if="config.showBuchungsnr"
v-model="data.buchungsnr"
name="buchungsnr"
:label="$p.t('konto/buchungsnr')"
disabled
>
</form-input>
<form-input
v-model="data.betrag"
name="betrag"
:label="$p.t('konto/betrag')"
>
</form-input>
<form-input
type="DatePicker"
v-model="data.buchungsdatum"
name="buchungsdatum"
:label="$p.t('konto/buchungsdatum')"
:enable-time-picker="false"
auto-apply
>
</form-input>
<form-input
v-model="data.buchungstext"
name="buchungstext"
:label="$p.t('konto/buchungstext')"
>
</form-input>
<form-input
v-if="config.showMahnspanne"
v-model="data.mahnspanne"
name="mahnspanne"
:label="$p.t('konto/mahnspanne')"
>
</form-input>
<form-input
type="select"
v-model="data.buchungstyp_kurzbz"
name="buchungstyp_kurzbz"
:label="$p.t('konto/buchungstyp')"
>
<option v-for="typ in lists.buchungstypen" :key="typ.buchungstyp_kurzbz" :value="typ.buchungstyp_kurzbz" :class="typ.aktiv ? '' : 'text-decoration-line-through text-muted'">
{{ typ.beschreibung }}
</option>
</form-input>
<form-input
type="select"
v-model="data.studiensemester_kurzbz"
name="studiensemester_kurzbz"
:label="$p.t('lehre/studiensemester')"
>
<option v-for="sem in lists.studiensemester" :key="sem.studiensemester_kurzbz" :value="sem.studiensemester_kurzbz">
{{ sem.studiensemester_kurzbz }}
</option>
</form-input>
<form-input
type="select"
v-model="data.studiengang_kz"
name="studiengang_kz"
:label="$p.t('lehre/studiengang')"
>
<option v-for="stg in lists.stgs" :key="stg.studiengang_kz" :value="stg.studiengang_kz">
{{ stg.kuerzel }}
</option>
</form-input>
<form-input
v-if="config.showCreditpoints"
v-model="data.credit_points"
name="credit_points"
:label="$p.t('konto/credit_points')"
>
</form-input>
<form-input
v-model="data.zahlungsreferenz"
name="zahlungsreferenz"
:label="$p.t('konto/reference')"
disabled
>
</form-input>
<form-input
type="textarea"
v-model="data.anmerkung"
name="anmerkung"
:label="$p.t('global/anmerkung')"
>
</form-input>
</fieldset>
<template #title>
{{ $p.t('stv/konto_title_edit', data) }}
</template>
<template #footer>
<button type="submit" class="btn btn-primary" :disabled="loading">
<i v-if="loading" class="fa fa-spinner fa-spin"></i>
{{ $p.t('ui/speichern') }}
</button>
</template>
</bs-modal>
</core-form>`
};
@@ -0,0 +1,203 @@
import BsModal from "../../../../Bootstrap/Modal.js";
import BsConfirm from "../../../../Bootstrap/Confirm.js";
import CoreForm from "../../../../Form/Form.js";
import FormValidation from "../../../../Form/Validation.js";
import FormInput from "../../../../Form/Input.js";
export default {
components: {
BsModal,
CoreForm,
FormValidation,
FormInput
},
inject: {
lists: {
from: 'lists'
},
defaultSemester: {
from: 'defaultSemester'
}
},
props: {
personIds: {
type: Array,
required: true
},
stgKz: {
type: Number,
required: true
},
config: {
type: Object,
default: {}
}
},
data() {
return {
loading: false,
data: {}
};
},
computed: {
reversedSems() {
return this.lists.studiensemester.toReversed();
},
activeBuchungstypen() {
return this.lists.buchungstypen.filter(e => e.aktiv);
}
},
methods: {
save() {
this.$refs.form.clearValidation();
this.loading = true;
const data = {...{
person_id: this.personIds,
studiengang_kz: this.stgKz
}, ...this.data};
this.$refs.form
.factory.stv.konto.checkDoubles(data)
.then(result => result.data
? Promise.all(
result.errors
.filter(e => e.type == 'confirm')
.map(e => BsConfirm.popup(Vue.h('div', {class:'text-preline'}, e.message)))
)
: Promise.resolve())
.then(() => data)
.then(this.$refs.form.factory.stv.konto.insert)
.then(result => {
this.$emit('saved', result.data);
this.loading = false;
this.$refs.modal.hide();
this.$fhcAlert.alertSuccess(this.$p.t('ui/gespeichert'));
})
.catch(error => {
if (error)
this.$fhcAlert.handleSystemError(error);
this.loading = false;
});
},
open() {
this.data = {
buchungstyp_kurzbz: '',
betrag: '-0.00',
buchungsdatum: new Date(),
buchungstext: '',
mahnspanne: 30,
studiensemester_kurzbz: this.defaultSemester,
credit_points: null,
anmerkung: ''
};
this.$refs.modal.show();
},
preventCloseOnLoading(ev) {
if (this.loading)
ev.returnValue = false;
},
checkDefaultBetrag(ev) {
const typ = this.lists.buchungstypen.filter(e => e.buchungstyp_kurzbz == ev).pop();
const amount = typ.standardbetrag || '-0.00';
const text = typ.standardtext || '';
const creditpoints = typ.credit_points || '';
if (!this.data.betrag || this.data.betrag == '-0.00')
this.data.betrag = amount;
if (!this.data.buchungstext)
this.data.buchungstext = text;
if (this.config.showCreditpoints && (this.data.credit_points == '0.00' || this.data.credit_points === null))
this.data.credit_points = creditpoints;
}
},
template: `
<core-form ref="form" class="stv-details-konto-edit" @submit.prevent="save">
<bs-modal ref="modal" @hide-bs-modal="preventCloseOnLoading">
<form-validation></form-validation>
<fieldset :disabled="loading">
<form-input
type="select"
v-model="data.buchungstyp_kurzbz"
name="buchungstyp_kurzbz"
:label="$p.t('konto/buchungstyp')"
@update:model-value="checkDefaultBetrag"
>
<option v-for="typ in activeBuchungstypen" :key="typ.buchungstyp_kurzbz" :value="typ.buchungstyp_kurzbz" :class="typ.aktiv ? '' : 'text-decoration-line-through text-muted'">
{{ typ.beschreibung }}
</option>
</form-input>
<form-input
v-model="data.betrag"
name="betrag"
:label="$p.t('konto/betrag')"
>
</form-input>
<form-input
type="DatePicker"
v-model="data.buchungsdatum"
name="buchungsdatum"
:label="$p.t('konto/buchungsdatum')"
:enable-time-picker="false"
auto-apply
>
</form-input>
<form-input
v-model="data.buchungstext"
name="buchungstext"
:label="$p.t('konto/buchungstext')"
>
</form-input>
<form-input
v-if="config.showMahnspanne"
v-model="data.mahnspanne"
name="mahnspanne"
:label="$p.t('konto/mahnspanne')"
>
</form-input>
<form-input
type="select"
v-model="data.studiensemester_kurzbz"
name="studiensemester_kurzbz"
:label="$p.t('lehre/studiensemester')"
>
<option v-for="sem in reversedSems" :key="sem.studiensemester_kurzbz" :value="sem.studiensemester_kurzbz">
{{ sem.studiensemester_kurzbz }}
</option>
</form-input>
<form-input
v-if="config.showCreditpoints"
v-model="data.credit_points"
name="credit_points"
:label="$p.t('konto/credit_points')"
>
</form-input>
<form-input
type="textarea"
v-model="data.anmerkung"
name="anmerkung"
:label="$p.t('global/anmerkung')"
>
</form-input>
</fieldset>
<template #title>
{{ $p.t(
'stv',
personIds.length > 1 ? 'konto_title_new_multi' : 'konto_title_new',
{ x: personIds.length }
) }}
</template>
<template #footer>
<button type="submit" class="btn btn-primary" :disabled="loading">
<i v-if="loading" class="fa fa-spinner fa-spin"></i>
{{ $p.t('ui/speichern') }}
</button>
</template>
</bs-modal>
</core-form>`
};
@@ -0,0 +1,15 @@
import TblMultiStatus from "./Prestudent/MultiStatus.js";
export default {
components: {
TblMultiStatus
},
props: {
modelValue: Object,
},
template: `
<div class="stv-details-multistatus h-100">
<tbl-multi-status :model-value="modelValue"></tbl-multi-status>
</div>
`
}
@@ -0,0 +1,19 @@
import NotenZeugnis from './Noten/Zeugnis.js';
export default {
components: {
NotenZeugnis
},
props: {
modelValue: Object
},
methods: {
reload() {
this.$refs.zeugnis.$refs.table.reloadTable();
}
},
template: `
<div class="stv-details-noten h-100 d-flex flex-column">
<noten-zeugnis ref="zeugnis" :student="modelValue"></noten-zeugnis>
</div>`
};
@@ -0,0 +1,111 @@
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
import {CoreRESTClient} from '../../../../../RESTClient.js';
import ZeugnisActions from './Zeugnis/Actions.js';
const LOCAL_STORAGE_ID = 'stv_details_noten_zeugnis_2024-01-11_stdsem_all';
export default {
components: {
CoreFilterCmpt,
ZeugnisActions
},
props: {
student: Object
},
data() {
return {
validStudent: true,
tabulatorEvents: [],
stdsem: ''
};
},
computed: {
ajaxURL() {
return CoreRESTClient._generateRouterURI('components/stv/Noten/getZeugnis/' + this.student.prestudent_id + this.stdsem);
},
tabulatorOptions() {
return {
ajaxURL: this.ajaxURL,
ajaxResponse: (url, params, response) => {
if (!response.retval)
this.validStudent = false;
else
this.validStudent = true;
return response.retval || [];
},
columns: [
{ field: 'zeugnis', title: 'Zeugnis', formatter: 'tickCross' },
{ field: 'lehrveranstaltung_bezeichnung', title: 'Lehrveranstaltung' },
{ field: 'note_bezeichnung', title: 'Note' },
{ field: 'uebernahmedatum', title: 'Übernahmedatum', visible: false },
{ field: 'benotungsdatum', title: 'Benotungsdatum', visible: false },
{ field: 'benotungsdatum-iso', title: 'Benotungsdatum ISO', visible: false },
{ field: 'studiensemester_kurzbz', title: 'Studiensemester', visible: false },
{ field: 'note', title: 'Note Numerisch', visible: false },
{ field: 'lehrveranstaltung_id', title: 'Lehrveranstaltung ID', visible: false },
{ field: 'studiengang', title: 'Studiengang', visible: false },
{ field: 'studiengang_kz', title: 'Studiengang Kennzahl', visible: false },
{ field: 'studiengang_lv', title: 'StudiengangLV', visible: false },
{ field: 'studiengang_kz_lv', title: 'Studiengang_kzLV', visible: false },
{ field: 'semester_lv', title: 'SemesterLV', visible: false },
{ field: 'ects_lv', title: 'ECTS', visible: false },
{ field: 'lehrform', title: 'Lehrform', visible: false },
{ field: 'kurzbz', title: 'Kurzbz', visible: false },
{ field: 'punkte', title: 'Punkte', visible: false },
{ field: 'lehrveranstaltung_bezeichnung_english', title: 'Englisch', visible: false }
],
layout: 'fitDataStretch',
height: '100%',
selectable: true,
selectableRangeMode: 'click',
persistenceID: 'stv-details-noten-zeugnis'
};
}
},
watch: {
ajaxURL(n) {
if (this.$refs.table)
this.$refs.table.tabulator.setData(n);
}
},
methods: {
setGrades(selected) {
CoreRESTClient
.post('components/stv/Noten/update', selected)
.then(this.$refs.table.reloadTable)
.catch(this.$fhcAlert.handleFormValidation);
},
saveStdsem(event) {
window.localStorage.setItem(LOCAL_STORAGE_ID, event.target.value ? 'true' : '');
}
},
created() {
const savedPath = window.localStorage.getItem(LOCAL_STORAGE_ID);
this.stdsem = savedPath ? '/all' : '';
},
// TODO(chris): phrasen
template: `
<div class="stv-details-noten-zeugnis h-100 d-flex flex-column">
<div v-if="!validStudent">Kein Student</div>
<template v-else>
<div class="mb-3">
<select class="form-select" v-model="stdsem" @input="saveStdsem">
<option value="">Aktuelles Semester</option>
<option value="/all">Alle Semester</option>
</select>
</div>
<core-filter-cmpt
ref="table"
:tabulator-options="tabulatorOptions"
:tabulator-events="tabulatorEvents"
table-only
:side-menu="false"
reload
>
<template #actions="{selected}">
<zeugnis-actions :selected="selected" @set-grades="setGrades"></zeugnis-actions>
</template>
</core-filter-cmpt>
</template>
</div>`
};
@@ -0,0 +1,54 @@
import {CoreRESTClient} from '../../../../../../RESTClient.js';
export default {
emits: [
'setGrades'
],
props: {
selected: Array
},
data() {
return {
grades: []
};
},
computed: {
current: {
get() {
if (!this.selected.length)
return '';
if (this.selected.length == 1)
return this.selected[0].note;
const grades = Object.keys(this.selected.reduce((a,c) => {
a[c.note] = true;
return a;
}, {}));
if (grades.length == 1)
return grades[0];
return '';
},
set(note) {
this.$emit('setGrades', this.selected.map(zeugnis => {
const { lehrveranstaltung_id, uid: student_uid, studiensemester_kurzbz } = zeugnis;
return { lehrveranstaltung_id, student_uid, studiensemester_kurzbz, note };
}));
}
}
},
created() {
CoreRESTClient
.get('components/stv/Noten/get')
.then(result => result.data)
.then(result => {
this.grades = result.retval;
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="stv-details-noten-zeugnis-actions">
<select class="form-select" v-model="current" :disabled="!selected.length">
<option value="" disabled>Note setzen</option>
<option v-for="grade in grades" :key="grade.note" :value="grade.note">{{ grade.bezeichnung }}</option>
</select>
</div>`
};
@@ -0,0 +1,109 @@
import CoreNotiz from "../../../Notiz/Notiz.js";
export default {
components: {
CoreNotiz
},
props: {
modelValue: Object
},
template: `
<div class="stv-details-notizen h-100 pb-3 overflow-hidden">
<!-- mit factory als endpoint -->
<core-notiz
:endpoint="$fhcApi.factory.notiz.person"
ref="formc"
notiz-layout="twoColumnsFormLeft"
type-id="person_id"
:id="modelValue.person_id"
show-document
show-tiny-mce
:visible-columns="['titel','text','verfasser','bearbeiter','dokumente']"
>
</core-notiz>
<!--
---------------------------------------------------------------------------------------------
-------------------- DESCRIPTION FOR PARAMETER PROPS ----------------------------------------
---------------------------------------------------------------------------------------------
endpoint: for corecontroller: eg: :endpoint="$fhcApi.factory.notiz.person"
(...prestudent, ...mitarbeiter, ...bestellung, ...lehreinheit, ...projekt, ...projektphase, ...projekttask, ...anrechnung)
for extensions: write own controller extending core NotizController
ref="formc"
type-id: id to which table the notizdata should be connected... eg. person_id, prestudent_id, uid (for mitarbeiter_uid), projekt_kurzbz, projektphase_id, projekttask_id,
bestellung_id, lehreinheit_id, anrechnung_id
notizLayout: "classicFas", "twoColumnsFormLeft", twoColumnsFormRight, popupModal"
showErweitert: if true: section with following fields will be displayed:
'verfasser', 'bearbeiter', 'von', 'bis'
showDocument: if true: section with documentHandling will be displayed
showTinyMCE: if true: section with WYSIWYG Editor for Text will be displayed
visibleColumns: list, which fields shoult be showed as default in filter component
fullVersion: :visibleColumns="['titel','text','bearbeiter','verfasser','von','bis','dokumente','erledigt','notiz_id','notizzuordnung_id','id','lastupdate']"
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
-->
<!--
---------------------------------------------------------------------------------------------
------------------------ SOME TESTDATA -----------------------------------------------------
---------------------------------------------------------------------------------------------
<core-notiz
:endpoint="$fhcApi.factory.notiz.mitarbeiter"
ref="formc"
type-id="uid"
:id= "'ma0068'"
notiz-layout="twoColumnsFormLeft"
show-document
show-tiny-mce
show-erweitert
:visible-columns="['titel','text','verfasser','bearbeiter','dokumente']"
>
</core-notiz>
<core-notiz
:endpoint="$fhcApi.factory.notiz.prestudent"
ref="formc"
type-id="prestudent_id"
:id="modelValue.prestudent_id"
notiz-layout="twoColumnsFormLeft"
:show-erweitert="true"
:show-document="true"
:showTinyMCE="true"
:visible-columns="['titel','text','verfasser','bearbeiter','dokumente']"
>
</core-notiz>
<core-notiz
:endpoint="$fhcApi.factory.notiz.projekt"
ref="formc"
type-id="projekt_kurzbz"
:id="'EA74'"
notiz-layout="twoColumnsFormLeft"
:show-erweitert="true"
:show-document="true"
:showTinyMCE="true"
:visible-columns="['titel','text','verfasser','bearbeiter','dokumente']"
>
</core-notiz>-->
</div>
`
};
@@ -0,0 +1,523 @@
import FormForm from '../../../Form/Form.js';
import FormInput from '../../../Form/Input.js';
import TblHistory from "./Prestudent/History.js";
import CoreUdf from '../../../Udf/Udf.js';
export default {
components: {
FormForm,
FormInput,
TblHistory,
CoreUdf
},
inject: {
lists: {
from: 'lists'
},
showZgvErfuellt: {
from: 'configShowZgvErfuellt',
default: false
},
showZgvDoktor: {
from: 'configShowZgvDoktor',
default: false
},
hasPrestudentPermission: {
from: 'hasPrestudentPermission',
default: false
},
hasAssistenzPermission: {
from: 'hasAssistenzPermission',
default: false
},
hasAdminPermission: {
from: 'hasAdminPermission',
default: false
},
defaultSemester: {
from: 'defaultSemester',
}
},
props: {
modelValue: Object,
},
data() {
return {
data: [],
listZgvs: [],
listZgvsmaster: [],
listZgvsdoktor: [],
listStgs: [],
listAusbildung: [],
listAufmerksamdurch: [],
listBerufe: [],
listFoerderrelevant: [
{ text: 'wie Studiengang', value: null },
{ text: 'Ja', value: true },
{ text: 'Nein', value: false }
],
listStgTyp: [],
initialFormData: {},
deltaArray: {},
actionUpdate: false
};
},
computed: {
deltaLength() {
return Object.keys(this.deltaArray).length;
}
},
watch: {
data: {
// TODO(chris): use @input instead?
handler(n) {
const delta = {};
for (const key in this.data) {
if (this.data[key] !== this.initialFormData[key]) {
delta[key] = this.data[key];
this.actionUpdate = true;
}
}
this.deltaArray = delta;
},
deep: true
},
modelValue(n){
this.loadPrestudent(n);
}
},
methods: {
loadPrestudent() {
this.$fhcApi
.get('api/frontend/v1/stv/prestudent/get/' + this.modelValue.prestudent_id)
.then(result => result.data)
.then(result => {
this.data = result;
//neue DataVariable um ein Delta der vorgenommenen Änderungen berechnen zu können
this.initialFormData = {...this.data};
})
.catch(this.$fhcAlert.handleSystemError);
},
udfsLoaded(udfs) {
this.initialFormData = {...(this.initialFormData || {}), ...udfs};
},
updatePrestudent(){
this.$refs.form
.post('api/frontend/v1/stv/prestudent/updatePrestudent/' + this.modelValue.prestudent_id, this.deltaArray)
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.deltaArray = [];
this.actionUpdate = false;
})
.catch(this.$fhcAlert.handleSystemError)
.finally(() => {
window.scrollTo(0, 0);
});
},
},
created() {
this.loadPrestudent();
this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getBezeichnungZGV')
.then(result => result.data)
.then(result => {
this.listZgvs = result;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getBezeichnungMZgv')
.then(result => result.data)
.then(result => {
this.listZgvsmaster = result;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getBezeichnungDZgv')
.then(result => result.data)
.then(result => {
this.listZgvsdoktor = result;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/lists/getStgs')
.then(result => result.data)
.then(result => {
this.listStgs = result;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getAusbildung')
.then(result => result.data)
.then(result => {
this.listAusbildung = result;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getAufmerksamdurch')
.then(result => result.data)
.then(result => {
this.listAufmerksamdurch = result;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getBerufstaetigkeit')
.then(result => result.data)
.then(result => {
this.listBerufe = result;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getTypenStg')
.then(result => result.data)
.then(result => {
this.listStgTyp = result;
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="stv-details-prestudent h-100 pb-3">
<form-form ref="form" class="stv-details-prestudent" @submit.prevent="updatePrestudent">
<div class="position-sticky top-0 z-1">
<button type="submit" class="btn btn-primary position-absolute top-0 end-0" :disabled="!deltaLength">Speichern</button>
</div>
<fieldset class="overflow-hidden">
<legend>{{$p.t('lehre', 'title_zgv')}} {{modelValue.nachname}} {{modelValue.vorname}}</legend>
<div class="row mb-3">
<form-input
container-class="col-3"
label="Prestudent_id"
type="text"
v-model="data.prestudent_id"
name="prestudent_id"
readonly
>
</form-input>
<form-input
container-class="col-3"
label="Person_id"
type="text"
v-model="data.person_id"
name="person_id"
readonly
>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-3"
label="ZGV"
type="select"
v-model="data.zgv_code"
name="zgvcode"
>
<option v-for="zgv in listZgvs" :key="zgv.zgv_code" :value="zgv.zgv_code">{{zgv.zgv_bez}}</option>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('infocenter', 'zgvOrt')"
type="text"
v-model="data.zgvort"
name="zgvort"
>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('infocenter', 'zgvDatum')"
type="DatePicker"
v-model="data.zgvdatum"
name="zgvdatum"
no-today
auto-apply
:enable-time-picker="false"
format="dd.MM.yyyy"
preview-format="dd.MM.yyyy"
:teleport="true"
>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('infocenter', 'zgvNation')"
type="select"
v-model="data.zgvnation"
name="zgvnation"
>
<!-- TODO(chris): gesperrte nationen können nicht ausgewählt werden! Um das zu realisieren müsste man ein pseudo select machen -->
<option v-for="nation in lists.nations" :key="nation.nation_code" :value="nation.nation_code" :disabled="nation.sperre">{{nation.kurztext}}</option>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-3"
:label="$p.t('lehre', 'zgvMaster')"
type="select"
v-model="data.zgvmas_code"
name="zgvmascode"
>
<option v-for="mzgv in listZgvsmaster" :key="mzgv.zgvmas_code" :value="mzgv.zgvmas_code">{{mzgv.zgvmas_bez}}</option>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('lehre', 'zgvMasterOrt')"
type="text"
v-model="data.zgvmaort"
name="zgvmaort"
>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('lehre', 'zgvMasterDatum')"
type="DatePicker"
v-model="data.zgvmadatum"
name="zgvmadatum"
no-today
auto-apply
:enable-time-picker="false"
format="dd.MM.yyyy"
preview-format="dd.MM.yyyy"
:teleport="true"
>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('lehre', 'zgvMasterNation')"
type="select"
v-model="data.zgvmanation"
name="zgvmanation"
>
<!-- TODO(chris): gesperrte nationen können nicht ausgewählt werden! Um das zu realisieren müsste man ein pseudo select machen -->
<option v-for="nation in lists.nations" :key="nation.nation_code" :value="nation.nation_code" :disabled="nation.sperre">{{nation.kurztext}}</option>
</form-input>
</div>
<!--ZGV Doktor-->
<div v-if="showZgvDoktor" class="row mb-3">
<form-input
container-class="col-3"
:label="$p.t('lehre', 'zgvDoktor')"
type="select"
v-model="data.zgvdoktor_code"
name="zgvdoktor_code"
>
<option v-for="zgv in listZgvsdoktor" :key="zgv.zgvdoktor_code" :value="zgv.zgvdoktor_code">{{zgv.zgvdoktor_bez}}</option>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('lehre', 'zgvDoktorOrt')"
type="text"
v-model="data.zgvdoktorort"
name="zgvdoktorort"
>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('lehre', 'zgvDoktorDatum')"
type="DatePicker"
v-model="data.zgvdoktordatum"
name="zgvdoktordatum"
no-today
auto-apply
:enable-time-picker="false"
format="dd.MM.yyyy"
preview-format="dd.MM.yyyy"
:teleport="true"
>
</form-input>
<form-input
container-class="col-3"
:label="$p.t('lehre', 'zgvDoktorNation')"
type="select"
v-model="data.zgvdoktornation"
name="zgvdoktornation"
>
<!-- TODO(chris): gesperrte nationen können nicht ausgewählt werden! Um das zu realisieren müsste man ein pseudo select machen -->
<option v-for="nation in lists.nations" :key="nation.nation_code" :value="nation.nation_code" :disabled="nation.sperre">{{nation.kurztext}}</option>
</form-input>
</div>
<div v-if="showZgvErfuellt" class="row mb-3">
<div class="col-3 pt-4 d-flex align-items-center">
<form-input
container-class="form-check"
:label="$p.t('infocenter', 'zgvErfuellt')"
type="checkbox"
v-model="data.zgv_erfuellt"
name="zgv_erfuellt"
>
</form-input>
</div>
<div class="col-3 pt-4 d-flex align-items-center">
<form-input
container-class="form-check"
:label="$p.t('infocenter', 'zgvMasterErfuellt')"
type="checkbox"
v-model="data.zgvmas_erfuellt"
name="zgvmas_erfuellt"
>
</form-input>
</div>
<div v-if="showZgvDoktor" class="col-3 pt-4 d-flex align-items-center">
<form-input
container-class="form-check"
:label="$p.t('infocenter', 'zgvDoktorErfuellt')"
type="checkbox"
v-model="data.zgvdoktor_erfuellt"
name="zgvdoktor_erfuellt"
>
</form-input>
</div>
</div>
</fieldset>
<fieldset class="overflow-hidden">
<legend>PrestudentIn</legend>
<div class="row mb-3">
<form-input
container-class="col-4"
:label="$p.t('person', 'aufmerksamDurch')"
type="select"
v-model="data.aufmerksamdurch_kurzbz"
name="aufmerksamDurch"
>
<option v-for="adurch in listAufmerksamdurch" :key="adurch.aufmerksamdurch_kurzbz" :value="adurch.aufmerksamdurch_kurzbz">{{adurch.beschreibung}}</option>
</form-input>
<form-input
container-class="col-4"
:label="$p.t('person', 'berufstaetigkeit')"
type="select"
v-model="data.berufstaetigkeit_code"
name="berufstaetigkeit_code"
>
<option v-for="beruf in listBerufe" :key="beruf.berufstaetigkeit_code" :value="beruf.berufstaetigkeit_code">{{beruf.berufstaetigkeit_bez}} </option>
</form-input>
<form-input
container-class="col-4"
:label="$p.t('person', 'ausbildung')"
type="select"
v-model="data.ausbildungcode"
name="ausbildungcode"
>
<option v-for="ausbld in listAusbildung" :key="ausbld.ausbildungcode" :value="ausbld.ausbildungcode">{{ausbld.ausbildungbez}} </option>
</form-input>
</div>
` + /* TODO(chris): Ausgeblendet für Testing
<div class="row mb-3">
<form-input
container-class="col-4"
label="Aufnahmeschlüssel"
type="text"
v-model="data.aufnahmeschluessel"
name="aufnahmeschluessel"
disabled
>
</form-input>
<div class="col-4 pt-4 d-flex align-items-center">
<form-input
container-class="form-check"
:label="$p.t('person', 'facheinschlaegigBerufstaetig')"
type="checkbox"
v-model="data.facheinschlberuf"
name="facheinschlberuf"
>
</form-input>
</div>
<!--Todo(manu) validierung Integer, liste hier null-->
<form-input
container-class="col-4"
:label="$p.t('person', 'bisstandort')"
type="text"
v-model="data.standort_code"
name="standort_code"
disabled
>
</form-input>
</div>
*/`
<div class="row mb-3">
<form-input
container-class="col-4"
:label="$p.t('lehre', 'studiengang')"
type="select"
v-model="data.studiengang_kz"
name="studiengang_kz"
disabled
>
<option v-for="stg in listStgs" :key="stg.studiengang_kz" :value="stg.studiengang_kz">{{stg.kuerzel}} - {{stg.bezeichnung}} </option>
</form-input>
<form-input
container-class="col-4"
:label="$p.t('lehre', 'studientyp')"
type="select"
v-model="data.gsstudientyp_kurzbz"
name="gsstudientyp_kurzbz"
>
<option v-for="typ in listStgTyp" :key="typ.typ" :value="typ.typ">{{typ.bezeichnung}} </option>
</form-input>
</div>
<div class="row mb-3">
<form-input
container-class="col-4"
:label="$p.t('global', 'anmerkung')"
type="text"
v-model="data.anmerkung"
name="anmerkung"
>
</form-input>
<div class="col-2 pt-4 d-flex align-items-center">
<form-input
container-class="form-check"
:label="$p.t('person', 'bismelden')"
type="checkbox"
v-model="data.bismelden"
name="bismelden"
>
</form-input>
</div>
<div class="col-2 pt-4 d-flex align-items-center">
<form-input
container-class="form-check"
:label="$p.t('lehre', 'dual')"
type="checkbox"
v-model="data.dual"
name="dual"
>
</form-input>
</div>
` + /* TODO(chris): Ausgeblendet für Testing
<form-input
container-class="col-3"
:label="$p.t('lehre', 'foerderrelevant')"
type="select"
v-model="data.foerderrelevant"
name="foerderrelevant"
>
<option v-for="entry in listFoerderrelevant" :value="entry.value">{{entry.text}}</option>
</form-input>
*/`
<form-input
container-class="col-1"
:label="$p.t('lehre', 'prioritaet')"
type="text"
v-model="data.priorisierung"
name="priorisierung"
:disabled="!hasPrestudentPermission"
>
</form-input>
</div>
<core-udf @load="udfsLoaded" v-model="data" class="row-cols-3 g-3 mb-3" ci-model="crm/prestudent" :pk="{prestudent_id:modelValue.prestudent_id}"></core-udf>
</fieldset>
</form-form>
<div>
<legend>Gesamthistorie</legend>
<tbl-history :person-id="modelValue.person_id" :prestudent-id="modelValue.prestudent_id"></tbl-history>
</div>
</div>
`
};
@@ -0,0 +1,80 @@
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
export default{
components: {
CoreFilterCmpt
},
props: {
personId: Number,
prestudentId: Number
},
data() {
return {
tabulatorOptions: {
ajaxURL: 'api/frontend/v1/stv/Prestudent/getHistoryPrestudents/' + this.personId,
ajaxRequestFunc: this.$fhcApi.get,
ajaxResponse: (url, params, response) => response.data,
//autoColumns: true,
columns:[
{title:"StSem", field:"studiensemester_kurzbz"},
{title:"Prio", field:"priorisierung"},
{title:"Stg", field:"kurzbzlang"},
{title:"Orgform", field:"orgform_kurzbz"},
{title:"Studienplan", field:"bezeichnung"},
{title:"UID", field:"student_uid"},
{title:"Status", field:"status"},
{title:"PrestudentId", field:"prestudent_id", visible:false}
],
rowFormatter: row => {
const rowData = row.getData();
const element = row.getElement();
if (["Abgewiesener","Abbrecher","Absolvent"].includes(rowData.status_kurzbz)) {
element.classList.add('disabled');
}
if (rowData.prestudent_id == this.prestudentId) {
element.classList.add('fw-bold');
}
},
layout: 'fitDataFill',
layoutColumnsOnNewData: false,
height: 'auto',
selectable: false,
persistenceID: 'stv-details-prestudent-history'
},
tabulatorEvents: [
{
event: 'tableBuilt',
handler: async () => {
await this.$p.loadCategory(['lehre']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('orgform_kurzbz').component.updateDefinition({
title: this.$p.t('lehre', 'organisationsform')
});
cm.getColumnByField('bezeichnung').component.updateDefinition({
title: this.$p.t('lehre', 'studienplan')
});
}
}
]
}
},
watch: {
personId() {
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Prestudent/getHistoryPrestudents/' + this.personId);
}
},
template: `
<div class="stv-details-prestudent-history h-100 pt-3">
<core-filter-cmpt
ref="table"
:tabulator-options="tabulatorOptions"
:tabulator-events="tabulatorEvents"
table-only
:side-menu="false"
>
</core-filter-cmpt>
</div>`
}
@@ -0,0 +1,362 @@
import {CoreFilterCmpt} from "../../../../filter/Filter.js";
import BsModal from "../../../../Bootstrap/Modal.js";
import BsConfirm from "../../../../Bootstrap/Confirm.js";
import FormInput from '../../../../Form/Input.js';
import StatusModal from '../Status/Modal.js';
import StatusDropdown from '../Status/Dropdown.js';
export default{
components: {
CoreFilterCmpt,
BsModal,
FormInput,
StatusModal,
StatusDropdown
},
inject: {
defaultSemester: {
from: 'defaultSemester',
},
hasPermissionToSkipStatusCheck: {
from: 'hasPermissionToSkipStatusCheck',
default: false
},
$reloadList: {
from: '$reloadList',
required: true
}
},
computed: {
prestudentIds() {
if (this.modelValue.prestudent_id)
{
return [this.modelValue.prestudent_id];
}
return this.modelValue.map(e => e.prestudent_id);
},
showToolbarStudent() {
if (Array.isArray(this.modelValue)) {
if (!this.modelValue.length)
return false;
return this.modelValue.every(item => item.uid);
}
return !!this.modelValue.uid;
},
showToolbarInteressent() {
if (Array.isArray(this.modelValue)) {
if (!this.modelValue.length)
return false;
return !this.modelValue.some(item => item.uid);
}
return !this.modelValue.uid;
}
},
props: {
modelValue: Object
},
data() {
return {
tabulatorOptions: {
ajaxURL: 'api/frontend/v1/stv/Status/getHistoryPrestudent/' + this.modelValue.prestudent_id,
ajaxRequestFunc: this.$fhcApi.get,
ajaxResponse: (url, params, response) => response.data,
columns: [
{title: "Kurzbz", field: "status_kurzbz", tooltip: true},
{title: "StSem", field: "studiensemester_kurzbz"},
{title: "Sem", field: "ausbildungssemester"},
{title: "Lehrverband", field: "lehrverband", width: 72},
{title: "Datum", field: "format_datum"},
{title: "Studienplan", field: "bezeichnung"},
{title: "BestätigtAm", field: "format_bestaetigtam"},
{title: "AbgeschicktAm", field: "format_bewerbung_abgeschicktamum", visible:false},
{title: "Statusgrund", field: "statusgrund_bezeichnung"},
{title: "Organisationsform", field: "orgform_kurzbz", visible: false},
{title: "PrestudentInId", field: "prestudent_id", visible: false},
{title: "StudienplanId", field: "studienplan_id", visible: false},
{title: "Anmerkung", field: "anmerkung", visible: false},
{title: "BestätigtVon", field: "bestaetigtvon", visible: false},
{title: "InsertAmUm", field: "format_insertamum", visible: false},
{title: "InsertVon", field: "insertvon", visible: false},
{title: "UpdateAmUm", field: "format_updateamum", visible: false},
{title: "UpdateVon", field: "updatevon", visible: false},
{
title: 'Aktionen', field: 'actions',
minWidth: 150, // Ensures Action-buttons will be always fully displayed
formatter: (cell, formatterParams, onRendered) => {
const container = document.createElement('div');
container.className = "d-flex gap-2";
const data = cell.getData();
let button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-forward"></i>';
button.title = 'Status vorrücken';
button.addEventListener('click', () =>
this.actionAdvanceStatus(data.status_kurzbz, data.studiensemester_kurzbz, data.ausbildungssemester)
);
if (!['Student', 'Diplomand', 'Unterbrecher'].includes(data.status_kurzbz))
button.disabled = true;
container.append(button);
button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-check"></i>';
button.title = 'Status bestätigen';
button.addEventListener('click', () =>
this.actionConfirmStatus(data.status_kurzbz, data.studiensemester_kurzbz, data.ausbildungssemester)
);
if (data.bestaetigtam || !data.bewerbung_abgeschicktamum)
button.disabled = true;
container.append(button);
button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-edit"></i>';
button.title = 'Status bearbeiten';
button.addEventListener('click', () =>
this.actionEditStatus(data.status_kurzbz, data.studiensemester_kurzbz, data.ausbildungssemester)
);
if (this.dataMeldestichtag && this.dataMeldestichtag > data.datum && !this.hasPermissionToSkipStatusCheck)
button.disabled = true;
container.append(button);
button = document.createElement('button');
button.className = 'btn btn-outline-secondary btn-action';
button.innerHTML = '<i class="fa fa-xmark"></i>';
button.title = 'Status löschen';
button.addEventListener('click', () =>
this.actionDeleteStatus(data.status_kurzbz, data.studiensemester_kurzbz, data.ausbildungssemester)
);
if (this.dataMeldestichtag && this.dataMeldestichtag > data.datum && !this.hasPermissionToSkipStatusCheck)
button.disabled = true;
container.append(button);
return container;
},
frozen: true
},
],
rowFormatter: (row) => {
const rowData = row.getData();
if (this.dataMeldestichtag && this.dataMeldestichtag > rowData.datum)
{
row.getElement().classList.add('disabled');
}
},
layout: 'fitDataFill',
layoutColumnsOnNewData: false,
height: 'auto',
selectable: false,
},
tabulatorEvents: [
{
event: 'tableBuilt',
handler: async () => {
await this.$p.loadCategory(['lehre','global','person']);
let cm = this.$refs.table.tabulator.columnManager;
cm.getColumnByField('lehrverband').component.updateDefinition({
title: this.$p.t('lehre', 'lehrverband')
});
cm.getColumnByField('format_bestaetigtam').component.updateDefinition({
title: this.$p.t('lehre', 'bestaetigt_am')
});
cm.getColumnByField('format_bewerbung_abgeschicktamum').component.updateDefinition({
title: this.$p.t('lehre', 'bewerbung_abgeschickt_am')
});
cm.getColumnByField('bezeichnung').component.updateDefinition({
title: this.$p.t('lehre', 'studienplan')
});
cm.getColumnByField('actions').component.updateDefinition({
title: this.$p.t('global', 'aktionen')
});
cm.getColumnByField('format_datum').component.updateDefinition({
title: this.$p.t('global', 'datum')
});
cm.getColumnByField('anmerkung').component.updateDefinition({
title: this.$p.t('global', 'anmerkung')
});
cm.getColumnByField('bestaetigtvon').component.updateDefinition({
title: this.$p.t('lehre', 'bestaetigt_von')
});
cm.getColumnByField('format_insertamum').component.updateDefinition({
title: this.$p.t('lehre', 'insert_am')
});
cm.getColumnByField('insertvon').component.updateDefinition({
title: this.$p.t('lehre', 'insert_von')
});
}
}
],
statusData: {},
statusId: {},
dataMeldestichtag: null,
statusNew: true,
maxSem: 0
};
},
watch: {
modelValue() {
if (this.$refs.table) {
if (this.$refs.table.tableBuilt)
this.$refs.table.tabulator.setData('api/frontend/v1/stv/Status/getHistoryPrestudent/' + this.modelValue.prestudent_id);
else
this.data.tabulatorOptions.ajaxURL = 'api/frontend/v1/stv/Status/getHistoryPrestudent/' + this.modelValue.prestudent_id;
}
this.getMaxSem();
}
},
methods: {
getMaxSem() {
const studiengang_kzs = this.modelValue.studiengang_kz
? [this.modelValue.studiengang_kz]
: this.modelValue.map(prestudent => prestudent.studiengang_kz);
this.maxSem = 0;
this.$fhcApi
.post('api/frontend/v1/stv/status/getMaxSemester/', {studiengang_kzs})
.then(result => this.maxSem = result.data)
.catch(this.$fhcAlert.handleSystemError);
},
actionNewStatus() {
this.$refs.test.open(this.modelValue);
},
actionEditStatus(status, stdsem, ausbildungssemester) {
this.$refs.test.open(this.modelValue, status, stdsem, ausbildungssemester);
},
actionDeleteStatus(status, stdsem, ausbildungssemester) {
const statusId = {
prestudent_id: this.modelValue.prestudent_id,
status_kurzbz: status,
studiensemester_kurzbz: stdsem,
ausbildungssemester: ausbildungssemester
};
this.$fhcAlert
.confirmDelete()
.then(result => result
? 'api/frontend/v1/stv/status/isLastStatus/' + statusId.prestudent_id
: Promise.reject({handled: true})
)
.then(this.$fhcApi.get)
.then(result => result.data
? new Promise((resolve, reject) => { BsConfirm.popup(this.$p.t('lehre', 'last_status_confirm_delete')).then(resolve).catch(() => reject({handled:true})) })
: true
)
.then(result => result
? 'api/frontend/v1/stv/status/deleteStatus/' + Object.values(statusId).join('/')
: Promise.reject({handled: true})
)
.then(this.$fhcApi.post)
.then(() => this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')))
.then(this.reload)
.then(this.$reloadList)
.catch(this.$fhcAlert.handleSystemError);
},
actionAdvanceStatus(status, stdsem, ausbildungssemester) {
const statusId = {
prestudent_id: this.modelValue.prestudent_id,
status_kurzbz: status,
studiensemester_kurzbz: stdsem,
ausbildungssemester: ausbildungssemester
};
this.$fhcApi
.post('api/frontend/v1/stv/status/advanceStatus/' + Object.values(statusId).join('/'))
.then(() => this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successAdvance')))
.then(this.reload)
.catch(this.$fhcAlert.handleSystemError);
},
actionConfirmStatus(status, stdsem, ausbildungssemester) {
BsConfirm
.popup(this.$p.t('stv', 'status_confirm_popup'))
.then(() => this.$fhcApi.post(
'api/frontend/v1/stv/status/confirmStatus/' +
this.modelValue.prestudent_id + '/' +
status + '/' +
stdsem + '/' +
ausbildungssemester
))
.then(() => this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successConfirm')))
.then(this.reload)
.catch(this.$fhcAlert.handleSystemError);
},
reload() {
if (this.$refs.table)
this.$refs.table.reloadTable();
}
},
created() {
this.getMaxSem();
this.$fhcApi
.get('api/frontend/v1/stv/status/getLastBismeldestichtag/')
.then(result => {
this.dataMeldestichtag = result.data[0].meldestichtag;
if (this.$refs.table && this.$refs.table.tableBuilt)
this.$refs.table.tabulator.redraw(true);
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="stv-multistatus h-100 pt-3">
<status-modal
ref="test"
:meldestichtag="new Date(dataMeldestichtag)"
:max-sem="maxSem"
@saved="reload"
>
</status-modal>
<core-filter-cmpt
v-if="!this.modelValue.length"
ref="table"
:tabulator-options="tabulatorOptions"
:tabulator-events="tabulatorEvents"
table-only
:side-menu="false"
reload
new-btn-show
new-btn-label="Status"
@click:new="actionNewStatus"
>
<template #actions="{updateData2}">
<!-- SingleSelectButton-->
<status-dropdown
ref="statusDropdown"
:show-toolbar-student="showToolbarStudent"
:show-toolbar-interessent="showToolbarInteressent"
:prestudent-ids="prestudentIds"
@reload-table="reload"
>
</status-dropdown>
</template>
</core-filter-cmpt>
<div v-else>
<!--MultiSelectButton-->
<status-dropdown
ref="statusDropdown"
:show-toolbar-student="showToolbarStudent"
:show-toolbar-interessent="showToolbarInteressent"
:prestudent-ids="prestudentIds"
@reload-table="reload"
>
</status-dropdown>
</div>
</div>`
};
@@ -0,0 +1,336 @@
import BsModal from "../../../../Bootstrap/Modal.js";
import BsConfirm from "../../../../Bootstrap/Confirm.js";
import BsPrompt from "../../../../Bootstrap/Prompt.js";
import FormInput from '../../../../Form/Input.js';
export default {
components: {
BsModal,
FormInput
},
inject: {
$reloadList: {
from: '$reloadList',
required: true
}
},
emits: [
'reloadTable'
],
props: {
showToolbarStudent: {
type: Boolean,
required: true
},
showToolbarInteressent: {
type: Boolean,
required: true
},
prestudentIds: {
type: Array,
required: true,
default: () => []
}
},
data() {
return {
listDataToolbar: [],
//TODO(Manu) get from config
statiInteressent: ["Bewerber", "Aufgenommener", "Student" , "Wartender", "Abgewiesener"],
statiStudent: ["Abbrecher", "Unterbrecher", "Student" , "Diplomand", "Absolvent"]
};
},
computed: {
showToolbar() {
return this.showToolbarStudent || this.showToolbarInteressent;
},
sortedGruende() {
return this.listDataToolbar.reduce((result,current) => {
if (!result[current.status_kurzbz])
result[current.status_kurzbz] = [];
result[current.status_kurzbz].push(current);
return result;
}, {});
},
resultInteressentArray() {
const result = [];
this.statiInteressent.forEach(status => {
const defaultObject = {
status_kurzbz: status,
statusgrund_id: null,
link: () => this['changeStatusTo' + status](),
children: []
};
if (status === "Student") {
defaultObject.link = () => this.changeInteressentToStudent();
}
result.push(defaultObject);
if(this.sortedGruende[status]) {
this.sortedGruende[status].forEach(item => {
const itemObject = {
status_kurzbz: item.status_kurzbz,
statusgrund_id: item.statusgrund_id,
beschreibung: item.beschreibung,
link: () => this['changeStatusTo' + item.status_kurzbz](item.statusgrund_id),
};
if (item.status_kurzbz === "Student") {
itemObject.link = () => this['changeInteressentTo' + item.status_kurzbz](item.statusgrund_id);
}
defaultObject.children.push(itemObject);
});
//push one item object if student is in the array
const hasStudentChild = defaultObject.children.some(child => child.status_kurzbz === "Student");
if (hasStudentChild) {
defaultObject.children.push({
status_kurzbz: 'Student',
statusgrund_id: null,
beschreibung: 'Student',
link: () => this.changeInteressentToStudent()
});
}
}
});
return result;
},
resultStudentArray() {
const result = [];
this.statiStudent.forEach(status => {
const defaultObject = {
status_kurzbz: status,
statusgrund_id: null,
link: () => this['changeStatusTo' + status](),
children: []
};
result.push(defaultObject);
if(this.sortedGruende[status]) {
this.sortedGruende[status].forEach(item => {
const itemObject = {
status_kurzbz: item.status_kurzbz,
statusgrund_id: item.statusgrund_id,
beschreibung: item.beschreibung,
link: () => this['changeStatusTo' + item.status_kurzbz](item.statusgrund_id)
};
defaultObject.children.push(itemObject);
});
}
//push one item object if student is in the array
const hasStudentChild = defaultObject.children.some(child => child.status_kurzbz === "Student");
if (hasStudentChild) {
defaultObject.children.push({
status_kurzbz: 'Student',
statusgrund_id: null,
beschreibung: 'Student',
link: () => this.changeStatusToStudent()
});
}
});
return result;
}
},
methods: {
changeInteressentToStudent(statusgrund_id) {
this.addStudent({status_kurzbz: 'student', statusgrund_id});
},
addStudent(data) {
Promise
.allSettled(
this.prestudentIds.map(prestudent_id => this.$fhcApi.post(
'api/frontend/v1/stv/status/addStudent/' + prestudent_id,
data,
{ errorHeader: prestudent_id }
))
)
.then(res => this.showFeedback(res, data.status_kurzbz));
},
changeStatusToAbbrecher(statusgrund_id) {
this
.confirmStatusChange('Abbrecher', statusgrund_id)
.then(this.changeStatus)
.catch(this.$fhcAlert.handleSystemError);
},
changeStatusToUnterbrecher(statusgrund_id) {
this
.confirmStatusChange('Unterbrecher', statusgrund_id)
.then(this.changeStatus)
.catch(this.$fhcAlert.handleSystemError);
},
changeStatusToStudent(statusgrund_id) {
this
.promtAusbildungssemester('Student', statusgrund_id)
.then(this.changeStatus)
.catch(this.$fhcAlert.handleSystemError);
},
changeStatusToDiplomand(statusgrund_id) {
this.changeStatus({status_kurzbz: 'Diplomand', statusgrund_id});
},
changeStatusToAbsolvent(statusgrund_id) {
this.changeStatus({status_kurzbz: 'Absolvent', statusgrund_id});
},
changeStatusToBewerber(statusgrund_id) {
this.changeStatus({status_kurzbz: 'Bewerber', statusgrund_id});
},
changeStatusToAufgenommener(statusgrund_id) {
this
.confirmStatusChange('Aufgenommener', statusgrund_id)
.then(this.changeStatus)
.catch(this.$fhcAlert.handleSystemError);
},
changeStatusToAbgewiesener(statusgrund_id) {
this
.confirmStatusChange('Abgewiesener', statusgrund_id)
.then(this.changeStatus)
.catch(this.$fhcAlert.handleSystemError);
},
changeStatusToWartender(statusgrund_id) {
this
.confirmStatusChange('Wartender', statusgrund_id)
.then(this.changeStatus)
.catch(this.$fhcAlert.handleSystemError);
},
confirmStatusChange(status, statusgrund_id) {
const count = this.prestudentIds.length;
return BsConfirm
.popup(this.$p.t(
'lehre',
count > 1 ? 'modal_StatusactionPlural' : 'modal_StatusactionSingle',
{ count, status }
))
.then(() => ({
status_kurzbz: status,
statusgrund_id
}));
},
promtAusbildungssemester(status, statusgrund_id) {
const count = this.prestudentIds.length;
return BsPrompt
.popup(this.$p.t(
'lehre',
count > 1 ? 'modal_askAusbildungssemPlural' : 'modal_askAusbildungssem',
{ count, status }
))
.then(ausbildungssemester => ({
status_kurzbz: status,
ausbildungssemester,
statusgrund_id
}));
},
changeStatus(data) {
Promise
.allSettled(
this.prestudentIds.map(prestudent_id => this.$fhcApi.post(
'api/frontend/v1/stv/status/changeStatus/' + prestudent_id,
data,
{ errorHeader: prestudent_id }
))
)
.then(res => this.showFeedback(res, data.status_kurzbz));
},
showFeedback(results, status_kurzbz) {
const countSuccess = results.filter(result => result.status == "fulfilled").length;
const countError = results.length - countSuccess;
//Feedback Success als infoalert
this.$fhcAlert.alertInfo(this.$p.t('ui', 'successNewStatus', {
countSuccess,
status: status_kurzbz,
countError
}));
if(results.length == 1 && countSuccess > 0){
this.$emit('reloadTable');
}
this.$reloadList();
}
},
created() {
this.$fhcApi
.get('api/frontend/v1/stv/status/getStatusarray/')
.then(result => result.data)
.then(result => {
this.listDataToolbar = result;
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="stv-status-dropdown">
<div v-if="showToolbar" class="btn-group">
<button ref="toolbarButton" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
{{$p.t('lehre', 'btn_statusAendern')}}
</button>
<ul class="dropdown-menu">
<!--toolbar Interessent-->
<template v-if="showToolbarInteressent">
<li v-for="item in resultInteressentArray" :key="item.status_kurzbz" class="w-100">
<div v-if="item.children.length > 0" class="btn-group dropend w-100">
<a
class="dropdown-item dropdown-toggle d-flex justify-content-between align-items-center"
data-bs-toggle="dropdown"
aria-expanded="false"
href="#"
>
{{ item.status_kurzbz }}
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li v-for="child in item.children" :key="child.statusgrund_id">
<a class="dropdown-item" @click.prevent="child.link" href="#">{{ child.beschreibung }}</a>
</li>
</ul>
</div>
<div v-else>
<a
class="dropdown-item"
@click.prevent="item.link"
href="#"
>
{{ item.status_kurzbz }}
</a>
</div>
</li>
</template>
<!--toolbar Student-->
<template v-if="showToolbarStudent">
<li v-for="item in resultStudentArray" :key="item.status_kurzbz" class="w-100">
<div v-if="item.children.length > 0" class="btn-group dropend w-100">
<a
class="dropdown-item dropdown-toggle d-flex justify-content-between align-items-center"
data-bs-toggle="dropdown"
aria-expanded="false"
href="#"
>
{{ item.status_kurzbz }}
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li v-for="child in item.children" :key="child.statusgrund_id">
<a class="dropdown-item" @click.prevent="child.link" href="#">{{ child.beschreibung }}</a>
</li>
</ul>
</div>
<div v-else>
<a
class="dropdown-item"
@click.prevent="item.link"
href="#"
>
{{ item.status_kurzbz }}
</a>
</div>
</li>
</template>
</ul>
</div>
</div>`
};
@@ -0,0 +1,398 @@
import BsModal from "../../../../Bootstrap/Modal.js";
import CoreForm from '../../../../Form/Form.js';
import FormValidation from '../../../../Form/Validation.js';
import FormInput from '../../../../Form/Input.js';
export default{
components: {
BsModal,
CoreForm,
FormValidation,
FormInput
},
inject: {
defaultSemester: {
from: 'defaultSemester',
},
hasPermissionToSkipStatusCheck: {
from: 'hasPermissionToSkipStatusCheck',
default: false
},
hasPrestudentstatusPermission: {
from: 'hasPrestudentstatusPermission',
default: false
},
lists: {
from: 'lists'
},
$reloadList: {
from: '$reloadList',
required: true
}
},
emit: [
'saved'
],
props: {
meldestichtag: {
type: Date,
required: true
},
maxSem: {
type: Number,
required: true
}
},
data() {
return {
prestudent: {},
originalDatum: null,
statusNew: true,
mischform: false,
statusId: {},
formData: {},
studienplaene: [],
statusgruende: [],
stati: [],
allowedNewStatus: [
'Interessent',
'Bewerber',
'Aufgenommener',
'Student',
'Unterbrecher',
'Diplomand',
'Incoming'
]
};
},
computed: {
semester() {
return Array.from({length: this.maxSem}, (_, index) => index);
},
bisLocked() {
if (this.statusNew || this.hasPermissionToSkipStatusCheck)
return false;
if (!this.originalDatum || !this.meldestichtag)
return true;
return this.originalDatum < this.meldestichtag;
},
isStatusBeforeStudent() {
let isStatusStudent = ['Student', 'Absolvent', 'Diplomand'];
return !isStatusStudent.includes(this.formData.status_kurzbz);
},
allowedStati() {
if (!this.stati)
return [];
if (this.statusNew)
return this.stati.filter(status => this.allowedNewStatus.includes(status.status_kurzbz));
return this.stati.filter(status => this.statusId.status_kurzbz == status.status_kurzbz);
},
gruende() {
return this.statusgruende.filter(grund => grund.status_kurzbz == this.formData.status_kurzbz);
}
},
methods: {
open(prestudent, status_kurzbz, studiensemester_kurzbz, ausbildungssemester) {
this.$refs.modal.hide();
if (!status_kurzbz && !studiensemester_kurzbz && !ausbildungssemester) {
this.statusNew = true;
this.statusId = prestudent.prestudent_id;
this.formData = {
status_kurzbz: 'Interessent',
studiensemester_kurzbz: this.defaultSemester,
ausbildungssemester: 1,
datum: new Date(),
bestaetigtam: new Date(),
bewerbung_abgeschicktamum: null,
studienplan_id: null,
anmerkung: null,
rt_stufe: null,
statusgrund_id: null
};
this.originalDatum = null;
this.loadStudienplaeneAndSetPrestudent(prestudent)
.then(this.$refs.form.clearValidation)
.then(this.$refs.modal.show)
.catch(this.$fhcAlert.handleSystemError);
} else {
this.statusId = {
prestudent_id: prestudent.prestudent_id,
status_kurzbz,
studiensemester_kurzbz,
ausbildungssemester
};
this.$fhcApi
.post('api/frontend/v1/stv/status/loadStatus/', this.statusId)
.then(result => {
this.statusNew = false;
this.formData = result.data;
this.originalDatum = new Date(result.data.datum);
return prestudent;
})
.then(this.loadStudienplaeneAndSetPrestudent)
.then(this.$refs.form.clearValidation)
.then(this.$refs.modal.show)
.catch(this.$fhcAlert.handleSystemError);
}
},
insertStatus() {
this.$refs.form
.post(
'api/frontend/v1/stv/status/insertStatus/' + this.statusId,
this.formData
)
.then(result => {
this.$reloadList();
this.$emit('saved');
this.$refs.modal.hide();
})
.catch(this.$fhcAlert.handleSystemError);
},
editStatus() {
this.$refs.form
.post(
'api/frontend/v1/stv/status/updateStatus/' + Object.values(this.statusId).join('/'),
this.formData
)
.then(result => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
this.$reloadList();
this.$emit('saved');
this.$refs.modal.hide();
})
.catch(this.$fhcAlert.handleSystemError);
},
loadStudienplaeneAndSetPrestudent(prestudent) {
const old_id = this.prestudent.prestudent_id;
this.prestudent = prestudent;
if (old_id == prestudent.prestudent_id)
return Promise.resolve();
return this.$fhcApi
.get('api/frontend/v1/stv/prestudent/getStudienplaene/' + prestudent.prestudent_id)
.then(result => this.studienplaene = result.data)
.then(() => this.$fhcApi.get('api/frontend/v1/stv/prestudent/getStudiengang/' + prestudent.prestudent_id))
.then(result => this.mischform = result.data.mischform);
}
},
created() {
this.$fhcApi
.get('api/frontend/v1/stv/status/getStatusgruende')
.then(result => this.statusgruende = result.data)
.catch(this.$fhcAlert.handleSystemError);
/*this.$fhcApi
.get('api/frontend/v1/stv/lists/getStati')
.then(result => this.stati = result.data)
.catch(this.$fhcAlert.handleSystemError);*/
this.stati = [
{ status_kurzbz: 'Interessent', bezeichnung: 'Interessent'},
{ status_kurzbz: 'Bewerber', bezeichnung: 'Bewerber'},
{ status_kurzbz: 'Aufgenommener', bezeichnung: 'Aufgenommener'},
{ status_kurzbz: 'Student', bezeichnung: 'Student'},
{ status_kurzbz: 'Unterbrecher', bezeichnung: 'Unterbrecher'},
{ status_kurzbz: 'Diplomand', bezeichnung: 'Diplomand'},
{ status_kurzbz: 'Incoming', bezeichnung: 'Incoming'},
{ status_kurzbz: 'Absolvent', bezeichnung: 'Absolvent'},
{ status_kurzbz: 'Abbrecher', bezeichnung: 'Abbrecher'},
{ status_kurzbz: 'Abgewiesener', bezeichnung: 'Abgewiesener'},
{ status_kurzbz: 'Wartender', bezeichnung: 'Wartender'}
];
},
template: `
<bs-modal class="stv-status-modal" ref="modal">
<template #title>
{{ $p.t('lehre', statusNew ? 'status_new' : 'status_edit', prestudent) }}
</template>
<core-form ref="form">
<form-validation></form-validation>
<p v-if="bisLocked && !isStatusBeforeStudent">
<b>{{$p.t('bismeldestichtag', 'info_MeldestichtagStatusgrund')}}</b>
</p>
<p v-if="bisLocked && isStatusBeforeStudent">
<b>{{$p.t('bismeldestichtag', 'info_MeldestichtagStatusgrundSemester')}}</b>
</p>
<form-input
container-class="mb-3"
type="select"
v-model="formData.status_kurzbz"
name="status_kurzbz"
:label="$p.t('lehre/status_rolle')"
required
:disabled="!statusNew"
>
<option
v-for="status in allowedStati"
:value="status.status_kurzbz"
>
{{ status.bezeichnung }}
</option>
</form-input>
<form-input
container-class="mb-3"
type="select"
v-model="formData.studiensemester_kurzbz"
name="studiensemester_kurzbz"
:label="$p.t('lehre/studiensemester')"
:disabled="bisLocked"
>
<option
v-for="sem in lists.studiensemester_desc"
:key="sem.studiensemester_kurzbz"
:value="sem.studiensemester_kurzbz"
>
{{ sem.studiensemester_kurzbz }}
</option>
</form-input>
<form-input
container-class="mb-3"
type="select"
v-model="formData.ausbildungssemester"
name="ausbildungssemester"
:label="$p.t('lehre/ausbildungssemester')"
:disabled="bisLocked && !isStatusBeforeStudent"
>
<option
v-for="number in semester"
:key="number"
:value="number"
>
{{ number }}
</option>
</form-input>
<form-input
v-if="mischform"
container-class="mb-3"
type="select"
v-model="formData.orgform_kurzbz"
name="orgform_kurzbz"
:label="$p.t('lehre/organisationsform')"
:disabled="bisLocked && !isStatusBeforeStudent"
>
<option
v-for="orgform in lists.orgforms"
:key="orgform.orgform_kurzbz"
:value="orgform.orgform_kurzbz"
>
{{ orgform.bezeichnung }}
</option>
</form-input>
<form-input
container-class="mb-3"
type="DatePicker"
v-model="formData.datum"
name="datum"
:label="$p.t('global/datum')"
auto-apply
:enable-time-picker="false"
format="dd.MM.yyyy"
preview-format="dd.MM.yyyy"
:teleport="true"
:disabled="bisLocked"
>
</form-input>
<form-input
container-class="mb-3"
type="DatePicker"
v-model="formData.bestaetigtam"
name="bestaetigtam"
:label="$p.t('lehre/bestaetigt_am')"
auto-apply
:enable-time-picker="false"
format="dd.MM.yyyy"
preview-format="dd.MM.yyyy"
:teleport="true"
:disabled="bisLocked"
>
</form-input>
<form-input
container-class="mb-3"
type="DatePicker"
v-model="formData.bewerbung_abgeschicktamum"
name="bewerbung_abgeschicktamum"
:label="$p.t('lehre/bewerbung_abgeschickt_am')"
auto-apply
:enable-time-picker="false"
format="dd.MM.yyyy"
preview-format="dd.MM.yyyy"
:teleport="true"
:disabled="bisLocked || !hasPrestudentstatusPermission"
>
</form-input>
<form-input
container-class="mb-3"
type="select"
v-model="formData.studienplan_id"
name="studienplan_id"
:label="$p.t('lehre/studienplan')"
:disabled="bisLocked"
>
<option
v-for="plan in studienplaene"
:key="plan.studienplan_id"
:value="plan.studienplan_id"
>
{{ plan.bezeichnung }}
</option>
</form-input>
<form-input
container-class="mb-3"
type="text"
v-model="formData.anmerkung"
name="anmerkung"
:label="$p.t('global/anmerkung')"
:disabled="bisLocked"
>
</form-input>
<form-input
container-class="mb-3"
type="select"
v-model="formData.rt_stufe"
name="rt_stufe"
:label="$p.t('lehre/aufnahmestufe')"
:disabled="bisLocked"
>
<option :value="null">-- {{$p.t('fehlermonitoring', 'keineAuswahl')}} --</option>
<option v-for="entry in [1,2,3]" :key="entry" :value="entry">{{entry}}</option>
</form-input>
<form-input
v-if="gruende.length"
container-class="mb-3"
type="select"
v-model="formData.statusgrund_id"
name="statusgrund_id"
:label="$p.t('international/grund')"
>
<option :value="null">-- {{$p.t('fehlermonitoring', 'keineAuswahl')}} --</option>
<option
v-for="grund in gruende"
:key="grund.statusgrund_id"
:value="grund.statusgrund_id"
>
{{ grund.bezeichnung }}
</option>
</form-input>
</core-form>
<template #footer>
<button
type="button"
class="btn btn-primary"
@click="statusNew ? insertStatus() : editStatus()"
>
{{ $p.t('ui', 'ok') }}
</button>
</template>
</bs-modal>`
};
@@ -0,0 +1,278 @@
import {CoreFilterCmpt} from "../../filter/Filter.js";
import ListNew from './List/New.js';
export default {
components: {
CoreFilterCmpt,
ListNew
},
inject: [
'lists'
],
props: {
selected: Array,
studiengangKz: Number,
studiensemesterKurzbz: String
},
emits: [
'update:selected'
],
data() {
function dateFormatter(cell)
{
let val = cell.getValue();
if (!val)
return '&nbsp;';
let date = new Date(val);
return date.toLocaleDateString();
}
return {
tabulatorOptions: {
columns:[
{title:"UID", field:"uid"},
{title:"TitelPre", field:"titelpre"},
{title:"Nachname", field:"nachname"},
{title:"Vorname", field:"vorname"},
{title:"Wahlname", field:"wahlname", visible:false},
{title:"Vornamen", field:"vornamen", visible:false},
{title:"TitelPost", field:"titelpost"},
{title:"SVNR", field:"svnr"},
{title:"Ersatzkennzeichen", field:"ersatzkennzeichen"},
{title:"Geburtsdatum", field:"gebdatum", formatter:dateFormatter},
{title:"Geschlecht", field:"geschlecht"},
{title:"Sem.", field:"semester"},
{title:"Verb.", field:"verband"},
{title:"Grp.", field:"gruppe"},
{title:"Studiengang", field:"studiengang"},
{title:"Studiengang_kz", field:"studiengang_kz", visible:false},
{title:"Personenkennzeichen", field:"matrikelnr"},
{title:"PersonID", field:"person_id"},
{title:"Status", field:"status"},
{title:"Status Datum", field:"status_datum", visible:false, formatter:dateFormatter},
{title:"Status Bestaetigung", field:"status_bestaetigung", visible:false, formatter:dateFormatter},
{title:"EMail (Privat)", field:"mail_privat", visible:false},
{title:"EMail (Intern)", field:"mail_intern", visible:false},
{title:"Anmerkungen", field:"anmerkungen", visible:false},
{title:"AnmerkungPre", field:"anmerkung", visible:false},
{title:"OrgForm", field:"orgform_kurzbz"},
{title:"Aufmerksamdurch", field:"aufmerksamdurch_kurzbz", visible:false},
{title:"Gesamtpunkte", field:"punkte", visible:false},
{title:"Aufnahmegruppe", field:"aufnahmegruppe_kurzbz", visible:false},
{title:"Dual", field:"dual", visible:false, formatter:'tickCross', formatterParams: {
tickElement: '<i class="fas fa-check text-success"></i>',
crossElement: '<i class="fas fa-times text-danger"></i>'
}},
{title:"Matrikelnummer", field:"matr_nr", visible:false},
{title:"Studienplan", field:"studienplan_bezeichnung"},
{title:"PreStudentInnenID", field:"prestudent_id"},
{title:"Priorität", field:"priorisierung_relativ"},
{title:"Mentor", field:"mentor", visible:false},
{title:"Aktiv", field:"bnaktiv", visible:false, formatter:'tickCross', formatterParams: {
allowEmpty:true,
tickElement: '<i class="fas fa-check text-success"></i>',
crossElement: '<i class="fas fa-times text-danger"></i>'
}},
],
rowFormatter(row) {
if (row.getData().bnaktiv === false) {
row.getElement().classList.add('text-muted');
}
},
ajaxResponse: (url, params, response) => response.data,
layout: 'fitDataStretch',
layoutColumnsOnNewData: false,
height: '100%',
selectable: true,
selectableRangeMode: 'click',
index: 'prestudent_id',
persistenceID: 'stv-list'
},
tabulatorEvents: [
{
event: 'rowSelectionChanged',
handler: this.rowSelectionChanged
},
{
event: 'dataProcessed',
handler: this.autoSelectRows
},
{
event: 'rowClick',
handler: this.handleRowClick // TODO(chris): this should be in the filter component
}
],
focusObj: null, // TODO(chris): this should be in the filter component
lastSelected: null,
filterKontoCount0: undefined,
filterKontoMissingCounter: undefined
}
},
methods: {
reload() {
this.$refs.table.reloadTable();
},
actionNewPrestudent() {
this.$refs.new.open();
},
rowSelectionChanged(data) {
this.lastSelected = this.selected;
this.$emit('update:selected', data);
},
autoSelectRows(data) {
if (this.lastSelected) {
// NOTE(chris): reselect rows on refresh
let selected = this.lastSelected.map(el => this.$refs.table.tabulator.getRow(el.prestudent_id))
// TODO(chris): unselect current item if it's no longer in the table?
// or maybe reselect only the last one?
selected = selected.filter(el => el);
if (selected.length)
this.$refs.table.tabulator.selectRow(selected);
} else if(this.lastSelected === undefined) {
// NOTE(chris): select row if it's the only one (preferably only on startup)
if (data.length == 1) {
this.$refs.table.tabulator.selectRow(this.$refs.table.tabulator.getRows());
}
}
},
updateUrl(url, first) {
this.lastSelected = first ? undefined : this.selected;
const params = {}, filter = {};
if (this.filterKontoCount0)
filter.konto_count_0 = this.filterKontoCount0;
if (this.filterKontoMissingCounter)
filter.konto_missing_counter = this.filterKontoMissingCounter;
if (filter.konto_count_0 || filter.konto_missing_counter)
params.filter = filter;
if (!this.$refs.table.tableBuilt) {
if (!this.$refs.table.tabulator) {
this.tabulatorOptions.ajaxURL = url;
this.tabulatorOptions.ajaxParams = params;
} else
this.$refs.table.tabulator.on("tableBuilt", () => {
this.$refs.table.tabulator.setData(url, params);
});
} else
this.$refs.table.tabulator.setData(url, params);
},
onKeydown(e) { // TODO(chris): this should be in the filter component
if (!this.focusObj)
return;
switch (e.code) {
case 'Enter':
case 'Space':
e.preventDefault();
const e2 = new Event('click', e);
e2.altKey = e.altKey;
e2.ctrlKey = e.ctrlKey;
e2.shiftKey = e.shiftKey;
this.focusObj.dispatchEvent(e2);
//row.component.toggleSelect();
break;
case 'ArrowUp':
e.preventDefault();
var next = this.focusObj.previousElementSibling;
if (next)
this.changeFocus(this.focusObj, next);
break;
case 'ArrowDown':
e.preventDefault();
var next = this.focusObj.nextElementSibling;
if (next)
this.changeFocus(this.focusObj, next);
break;
}
},
changeFocus(a, b) { // TODO(chris): this should be in the filter component
if (b) {
b.tabIndex = 0;
this.focusObj = b;
b.focus();
} else {
this.focusObj = null;
}
a.tabIndex = -1;
return this.focusObj;
},
onFocus(e) { // TODO(chris): this should be in the filter component
if (!this.focusObj) {
var container, target;
if (e.target.classList.contains('tabulator-container')) {
container = e.target;
target = container.querySelector('.tabulator-row');
} else if (e.target.classList.contains('tabulator-row')) {
container = e.target.closest('.tabulator-container');
target = e.target;
}
if (container && target) {
this.changeFocus(container, target);
}
}
},
handleRowClick(e, row) { // TODO(chris): this should be in the filter component
if (this.focusObj) {
let el = row.getElement();
if (el != this.focusObj)
this.changeFocus(this.focusObj, el);
}
}
},
// TODO(chris): focusin, focusout, keydown and tabindex should be in the filter component
// TODO(chris): filter component column chooser has no accessibilty features
template: `
<div class="stv-list h-100 pt-3">
<div class="tabulator-container d-flex flex-column h-100" :class="{'has-filter': filterKontoCount0 || filterKontoMissingCounter}" tabindex="0" @focusin="onFocus" @keydown="onKeydown">
<core-filter-cmpt
ref="table"
:tabulator-options="tabulatorOptions"
:tabulator-events="tabulatorEvents"
table-only
:side-menu="false"
reload
` + /* TODO(chris): Ausgeblendet für Testing
new-btn-show
*/`
:new-btn-label="$p.t('stv/action_new')"
@click:new="actionNewPrestudent"
>
<template #filter>
<div class="card">
<div class="card-body">
<div class="input-group mb-3">
<label class="input-group-text col-4" for="stv-list-filter-konto-count-0">{{ $p.t('stv/konto_filter_count_0') }}</label>
<select class="form-select" id="stv-list-filter-konto-count-0" v-model="filterKontoCount0" @input="$nextTick(updateUrl)">
<option v-for="typ in lists.buchungstypen" :key="typ.buchungstyp_kurzbz" :value="typ.buchungstyp_kurzbz">
{{ typ.beschreibung }}
</option>
</select>
<button v-if="filterKontoCount0" class="btn btn-outline-secondary" @click="filterKontoCount0 = undefined; updateUrl()">
<i class="fa fa-times"></i>
</button>
</div>
<div class="input-group">
<label class="input-group-text col-4" for="stv-list-filter-konto-missing-counter">{{ $p.t('stv/konto_filter_missing_counter') }}</label>
<select class="form-select" id="stv-list-filter-konto-missing-counter" v-model="filterKontoMissingCounter" @input="$nextTick(updateUrl)">
<option value="alle">{{ $p.t('stv/konto_all_types') }}</option>
<option v-for="typ in lists.buchungstypen" :key="typ.buchungstyp_kurzbz" :value="typ.buchungstyp_kurzbz">
{{ typ.beschreibung }}
</option>
</select>
<button v-if="filterKontoMissingCounter" class="btn btn-outline-secondary" @click="filterKontoMissingCounter = undefined; updateUrl()">
<i class="fa fa-times"></i>
</button>
</div>
</div>
</div>
</template>
</core-filter-cmpt>
</div>
<list-new ref="new" :studiengang-kz="studiengangKz" :studiensemester-kurzbz="studiensemesterKurzbz"></list-new>
</div>`
};

Some files were not shown because too many files have changed in this diff Show More