mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Merge branch 'feature-63445/Studierendenverwaltung_Filter' into studvw_2025-11_rc
This commit is contained in:
@@ -33,6 +33,7 @@ class Config extends FHCAPI_Controller
|
||||
{
|
||||
// TODO(chris): permissions
|
||||
parent::__construct([
|
||||
'filter' => ['admin:r', 'assistenz:r'],
|
||||
'student' => ['admin:r', 'assistenz:r'],
|
||||
'students' => ['admin:r', 'assistenz:r']
|
||||
]);
|
||||
@@ -53,6 +54,158 @@ class Config extends FHCAPI_Controller
|
||||
$this->load->config('stv');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the config for the student filters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function filter()
|
||||
{
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
$this->load->model('crm/Buchungstyp_model', 'BuchungstypModel');
|
||||
|
||||
$this->BuchungstypModel->addOrder('beschreibung');
|
||||
|
||||
$result = $this->BuchungstypModel->load();
|
||||
|
||||
$buchungstyp_kurzbz = $this->getDataOrTerminateWithError($result);
|
||||
$buchungstyp_kurzbz_plus_all = array_merge([[
|
||||
'buchungstyp_kurzbz' => 'all',
|
||||
'beschreibung' => $this->p->t('stv', 'konto_all_types')
|
||||
]], $buchungstyp_kurzbz);
|
||||
|
||||
$this->load->model('crm/Statusgrund_model', 'StatusgrundModel');
|
||||
|
||||
$result = $this->StatusgrundModel->getAktiveGruende();
|
||||
|
||||
$statusgruende = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = [];
|
||||
|
||||
$result[] = [
|
||||
'id' => 'filter_konto_count_0',
|
||||
'label' => $this->p->t('stv', 'filter_konto_count_0'),
|
||||
'type' => 'konto',
|
||||
'fixed' => [
|
||||
'missing' => true,
|
||||
'usestdsem' => true
|
||||
],
|
||||
'dynamic' => [
|
||||
'buchungstyp_kurzbz' => [
|
||||
'type' => 'select',
|
||||
'values' => $buchungstyp_kurzbz,
|
||||
'value_key' => 'buchungstyp_kurzbz',
|
||||
'label_key' => 'beschreibung'
|
||||
]
|
||||
]
|
||||
];
|
||||
$result[] = [
|
||||
'id' => 'filter_konto_missing_counter',
|
||||
'label' => $this->p->t('stv', 'filter_konto_missing_counter'),
|
||||
'type' => 'konto_counter',
|
||||
'dynamic' => [
|
||||
'buchungstyp_kurzbz' => [
|
||||
'type' => 'select',
|
||||
'values' => $buchungstyp_kurzbz_plus_all,
|
||||
'value_key' => 'buchungstyp_kurzbz',
|
||||
'label_key' => 'beschreibung'
|
||||
],
|
||||
'samestg' => [
|
||||
'type' => 'bool',
|
||||
'label' => $this->p->t('stv', 'filter_konto_samestg'),
|
||||
'default' => $this->variablelib->getVar('kontofilterstg') == 'true'
|
||||
]
|
||||
]
|
||||
];
|
||||
$result[] = [
|
||||
'id' => 'filter_documents',
|
||||
'label' => $this->p->t('stv', 'filter_documents'),
|
||||
'type' => 'documents'
|
||||
];
|
||||
$result[] = [
|
||||
'id' => 'filter_konto_missing_counter_past',
|
||||
'label' => $this->p->t('stv', 'filter_konto_missing_counter_past'),
|
||||
'type' => 'konto_counter',
|
||||
'fixed' => [
|
||||
'past' => true
|
||||
],
|
||||
'dynamic' => [
|
||||
'buchungstyp_kurzbz' => [
|
||||
'type' => 'select',
|
||||
'values' => $buchungstyp_kurzbz_plus_all,
|
||||
'value_key' => 'buchungstyp_kurzbz',
|
||||
'label_key' => 'beschreibung'
|
||||
],
|
||||
'samestg' => [
|
||||
'type' => 'bool',
|
||||
'label' => $this->p->t('stv', 'filter_konto_samestg'),
|
||||
'default' => $this->variablelib->getVar('kontofilterstg') == 'true'
|
||||
]
|
||||
]
|
||||
];
|
||||
$result[] = [
|
||||
'id' => 'filter_konto_missing_studiengebuehr',
|
||||
'label' => $this->p->t('stv', 'filter_konto_missing_studiengebuehr'),
|
||||
'type' => 'konto',
|
||||
'fixed' => [
|
||||
'missing' => true,
|
||||
'usestdsem' => true
|
||||
],
|
||||
'dynamic' => [
|
||||
'buchungstyp_kurzbz' => [
|
||||
'type' => 'select',
|
||||
'values' => $buchungstyp_kurzbz,
|
||||
'value_key' => 'buchungstyp_kurzbz',
|
||||
'label_key' => 'beschreibung'
|
||||
]
|
||||
]
|
||||
];
|
||||
$result[] = [
|
||||
'id' => 'filter_konto_studiengebuehrerhoeht',
|
||||
'label' => $this->p->t('stv', 'filter_konto_studiengebuehrerhoeht'),
|
||||
'type' => 'konto',
|
||||
'fixed' => [
|
||||
'usestdsem' => true
|
||||
],
|
||||
'dynamic' => [
|
||||
'buchungstyp_kurzbz' => [
|
||||
'type' => 'select',
|
||||
'values' => $buchungstyp_kurzbz,
|
||||
'value_key' => 'buchungstyp_kurzbz',
|
||||
'label_key' => 'beschreibung'
|
||||
]
|
||||
]
|
||||
];
|
||||
$result[] = [
|
||||
'id' => 'filter_zgv_without_date',
|
||||
'label' => $this->p->t('stv', 'filter_zgv_without_date'),
|
||||
'type' => 'zgv'
|
||||
];
|
||||
$result[] = [
|
||||
'id' => 'filter_statusgrund',
|
||||
'label' => $this->p->t('stv', 'filter_statusgrund'),
|
||||
'type' => 'statusgrund',
|
||||
'fixed' => [
|
||||
'usestdsem' => true
|
||||
],
|
||||
'dynamic' => [
|
||||
'statusgrund_id' => [
|
||||
'type' => 'select',
|
||||
'values' => $statusgruende,
|
||||
'value_key' => 'statusgrund_id',
|
||||
'label_key' => 'bezeichnung'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
Events::trigger('stv_conf_filter', function & () use (&$result) {
|
||||
return $result;
|
||||
});
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function student()
|
||||
{
|
||||
$result = [];
|
||||
|
||||
@@ -44,7 +44,6 @@ class Students extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('PhrasesLib');
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
@@ -904,40 +903,20 @@ class Students extends FHCAPI_Controller
|
||||
*/
|
||||
protected function addFilter($studiensemester_kurzbz)
|
||||
{
|
||||
$filter = json_decode($this->input->get('filter'), true);
|
||||
$filter = $this->input->post('filter');
|
||||
|
||||
if (!is_array($filter))
|
||||
{
|
||||
$this->addMeta('addfilter', 'invalid filter: ' . $this->input->get('filter'));
|
||||
$this->addMeta('addfilter', 'invalid filter: ' . json_encode($this->input->post('filter')));
|
||||
return;
|
||||
}
|
||||
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);
|
||||
foreach ($filter as $item) {
|
||||
if (isset($item['usestdsem']) && $item['usestdsem'])
|
||||
$item['studiensemester_kurzbz'] = $studiensemester_kurzbz;
|
||||
if (!$this->PrestudentModel->addFilter($item)) {
|
||||
$this->addMeta('addfilter', 'invalid filter: ' . json_encode($item));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use CI3_Events as Events;
|
||||
|
||||
class Prestudent_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
@@ -782,4 +784,118 @@ class Prestudent_model extends DB_Model
|
||||
|
||||
return $this->execQuery($query, array($person_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a filter to the query builder
|
||||
*
|
||||
* @param array $filter
|
||||
* @return boolean
|
||||
*/
|
||||
public function addFilter($filter)
|
||||
{
|
||||
if (!isset($filter['type']))
|
||||
return false;
|
||||
|
||||
switch ($filter['type']) {
|
||||
case 'konto':
|
||||
$bt = '';
|
||||
$stdsem = '';
|
||||
$comp = '!=';
|
||||
|
||||
if (isset($filter['buchungstyp_kurzbz']) && $filter['buchungstyp_kurzbz'] != 'all')
|
||||
$bt = ' AND buchungstyp_kurzbz=' . $this->escape($filter['buchungstyp_kurzbz']);
|
||||
|
||||
if (isset($filter['studiensemester_kurzbz']))
|
||||
$stdsem = ' AND studiensemester_kurzbz=' . $this->escape($filter['studiensemester_kurzbz']);
|
||||
|
||||
if (isset($filter['missing']) && $filter['missing']) {
|
||||
$comp = '=';
|
||||
$this->db->where('get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) !=', 'Incoming');
|
||||
}
|
||||
|
||||
$this->db->where('(
|
||||
SELECT count(*)
|
||||
FROM public.tbl_konto
|
||||
WHERE person_id=tbl_prestudent.person_id
|
||||
' . $bt . '
|
||||
' . $stdsem . '
|
||||
) ' . $comp, 0);
|
||||
break;
|
||||
|
||||
case 'konto_counter':
|
||||
$bt = '';
|
||||
$samestg = '';
|
||||
$past = '';
|
||||
|
||||
if (isset($filter['buchungstyp_kurzbz']) && $filter['buchungstyp_kurzbz'] != 'all')
|
||||
$bt = ' AND buchungstyp_kurzbz = ' . $this->escape($filter['buchungstyp_kurzbz']);
|
||||
|
||||
if (isset($filter['samestg']) && $filter['samestg'])
|
||||
$samestg = ' AND studiengang_kz = tbl_prestudent.studiengang_kz';
|
||||
|
||||
if (isset($filter['past']) && $filter['past'])
|
||||
$past = ' AND buchungsdatum < NOW()';
|
||||
|
||||
$this->db->where('(
|
||||
SELECT sum(betrag)
|
||||
FROM public.tbl_konto
|
||||
WHERE person_id = tbl_prestudent.person_id
|
||||
' . $bt . '
|
||||
' . $samestg . '
|
||||
' . $past . '
|
||||
) !=', 0);
|
||||
break;
|
||||
|
||||
case 'zgv':
|
||||
$this->db
|
||||
->group_start()
|
||||
->group_start()
|
||||
->where('zgv_code IS NOT NULL')
|
||||
->where('zgvdatum IS NULL')
|
||||
->group_end()
|
||||
->or_group_start()
|
||||
->where('zgvmas_code IS NOT NULL')
|
||||
->where('zgvmadatum IS NULL')
|
||||
->group_end()
|
||||
->or_group_start()
|
||||
->where('zgvdoktor_code IS NOT NULL')
|
||||
->where('zgvdoktordatum IS NULL')
|
||||
->group_end()
|
||||
->group_end();
|
||||
break;
|
||||
|
||||
case 'documents':
|
||||
$this->db->where('(
|
||||
SELECT count(*)
|
||||
FROM public.tbl_dokumentstudiengang
|
||||
WHERE dokument_kurzbz NOT IN (
|
||||
SELECT dokument_kurzbz
|
||||
FROM tbl_dokumentprestudent
|
||||
WHERE prestudent_id=tbl_prestudent.prestudent_id
|
||||
)
|
||||
AND studiengang_kz=tbl_prestudent.studiengang_kz
|
||||
) !=', 0);
|
||||
break;
|
||||
|
||||
case 'statusgrund':
|
||||
if (!isset($filter['statusgrund_id']))
|
||||
return false;
|
||||
|
||||
if (isset($filter['studiensemester_kurzbz']))
|
||||
$stdsem = ' AND studiensemester_kurzbz=' . $this->escape($filter['studiensemester_kurzbz']);
|
||||
|
||||
$this->db->where('(
|
||||
SELECT count(*)
|
||||
FROM public.tbl_prestudentstatus
|
||||
WHERE prestudent_id = tbl_prestudent.prestudent_id
|
||||
AND statusgrund_id = ' . $this->escape($filter['statusgrund_id']) . '
|
||||
' . $stdsem . '
|
||||
) !=', 0);
|
||||
break;
|
||||
}
|
||||
|
||||
Events::trigger('prestudent_add_filter', $filter);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user