mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Merge branch 'master' into feature-55978/infocenter_electronic_onboarding_filter
This commit is contained in:
@@ -3,12 +3,35 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use CI3_Events as Events;
|
||||
|
||||
/**
|
||||
* NOTE(chris): example:
|
||||
Events::on('stv_conf_student', function (&$res) {
|
||||
$res['test'] = [
|
||||
'title' => 'TEST',
|
||||
'component' => './Stv/Studentenverwaltung/Details/Notizen.js'
|
||||
];
|
||||
});
|
||||
*/
|
||||
Events::on('loadRenderers', function ($renderers) {
|
||||
$fhc_core_renderers =& $renderers();
|
||||
$fhc_core_renderers["lehreinheit"] = array(
|
||||
'calendarEvent' => APP_ROOT.'public/js/components/Cis/Renderer/Lehreinheit/calendarEvent.js',
|
||||
'modalTitle' => APP_ROOT.'public/js/components/Cis/Renderer/Lehreinheit/modalTitle.js',
|
||||
'modalContent' => APP_ROOT.'public/js/components/Cis/Renderer/Lehreinheit/modalContent.js',
|
||||
'calendarEventStyles' => APP_ROOT.'public/css/Cis4/CoreCalendarEvents.css'
|
||||
);
|
||||
});
|
||||
|
||||
Events::on('loadRenderers', function ($renderers) {
|
||||
$fhc_core_renderers =& $renderers();
|
||||
$fhc_core_renderers["reservierung"] = array(
|
||||
'calendarEvent' => APP_ROOT.'public/js/components/Cis/Renderer/Reservierungen/calendarEvent.js',
|
||||
'modalTitle' => APP_ROOT.'public/js/components/Cis/Renderer/Reservierungen/modalTitle.js',
|
||||
'modalContent' => APP_ROOT.'public/js/components/Cis/Renderer/Reservierungen/modalContent.js',
|
||||
'calendarEventStyles' => APP_ROOT.'public/css/Cis4/CoreCalendarEvents.css'
|
||||
);
|
||||
});
|
||||
|
||||
Events::on('loadRenderers', function ($renderers) {
|
||||
$fhc_core_renderers =& $renderers();
|
||||
$fhc_core_renderers["ferien"] = array(
|
||||
'calendarEvent' => APP_ROOT.'public/js/components/Cis/Renderer/Feiertage/calendarEvent.js',
|
||||
'modalTitle' => APP_ROOT.'public/js/components/Cis/Renderer/Feiertage/modalTitle.js',
|
||||
'modalContent' => APP_ROOT.'public/js/components/Cis/Renderer/Feiertage/modalContent.js',
|
||||
'calendarEventStyles' => APP_ROOT.'public/css/Cis4/CoreCalendarEvents.css'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
// Define configuration parameters
|
||||
$config['timezone'] = 'Europe/Vienna';
|
||||
@@ -7,3 +7,9 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
$config['cis_menu_root_content_id'] = 11087;
|
||||
// send Mails for ProfilUpdate
|
||||
$config['cis_send_profil_update_mails'] = true;
|
||||
// Vilesci CI BaseUrl
|
||||
$config['cis_vilesci_base_url'] = defined('VILESCI_ROOT') ? VILESCI_ROOT : APP_ROOT;
|
||||
$config['cis_vilesci_index_page'] = 'index.ci.php';
|
||||
// Cis CI BaseUrl
|
||||
$config['cis_base_url'] = defined('CIS_ROOT') ? CIS_ROOT : APP_ROOT;
|
||||
$config['cis_index_page'] = 'cis.php';
|
||||
|
||||
@@ -6,4 +6,4 @@ $config['use_vuejs_dev_version'] = false;
|
||||
// use bundled javascript
|
||||
$config['use_bundled_javascript'] = false;
|
||||
// systemerror_mailto use in FHC-Alert Plugin - if empty Link will not be rendered
|
||||
$config['systemerror_mailto'] = '';
|
||||
$config['systemerror_mailto'] = '';
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/*It defines which tags are available in LVVerwaltung and whether they are editable
|
||||
|
||||
$config['lvverwaltung_tags'] = [
|
||||
'tag_1' => ['readonly' => false],
|
||||
'tag_1' => ['readonly' => true]
|
||||
];
|
||||
*/
|
||||
|
||||
$config['lvverwaltung_tags'] = [];
|
||||
@@ -64,7 +64,7 @@ $config['navigation_header'] = array(
|
||||
'lehrveranstaltungen' => array(
|
||||
'link' => site_url('lehre/lvplanung/LvTemplateUebersicht'),
|
||||
'icon' => '',
|
||||
'description' => 'Lehrveranstaltungen',
|
||||
'description' => 'Lehrveranstaltungen Templates',
|
||||
'sort' => 15
|
||||
),
|
||||
'reihungstest' => array(
|
||||
@@ -81,6 +81,16 @@ $config['navigation_header'] = array(
|
||||
'sort' => 30,
|
||||
'requiredPermissions' => 'infocenter:r'
|
||||
),
|
||||
'lvverwaltung' => array(
|
||||
'link' => site_url('LVVerwaltung'),
|
||||
'icon' => '',
|
||||
'description' => 'LV Verwaltung',
|
||||
'requiredPermissions' => array(
|
||||
'admin:r',
|
||||
'assistenz:r'
|
||||
),
|
||||
'sort' => 35
|
||||
),
|
||||
'lehrauftrag' => array(
|
||||
'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'),
|
||||
'description' => 'Lehrauftrag',
|
||||
@@ -93,7 +103,7 @@ $config['navigation_header'] = array(
|
||||
),
|
||||
'zverfueg' => array(
|
||||
'link' => site_url('lehre/lvplanung/AdminZeitverfuegbarkeit'),
|
||||
'description' => 'Zeitverfügbarkeit',
|
||||
'description' => 'Zeitverfügbarkeit',
|
||||
'expand' => true,
|
||||
'sort' => 45,
|
||||
'requiredPermissions' => array(
|
||||
@@ -325,4 +335,4 @@ $config['navigation_menu']['system/issues/Issues/*'] = array(
|
||||
'target' => '_blank',
|
||||
'requiredPermissions' => array('admin:rw')
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
// liste von raumtyp_kurzbz welche in raumsuche studenten angezeigt werden
|
||||
$config['roomtypes_student'] = array(
|
||||
'LAB BM/Chem',
|
||||
'xEDV 1-36',
|
||||
'xEDV 37-60',
|
||||
'EDV 60',
|
||||
'EDV-HÖPL',
|
||||
'EDV ES',
|
||||
'LAB Elek',
|
||||
'LAB ES/TK',
|
||||
'Ener-EDV',
|
||||
'Ener-Lab',
|
||||
'Ener-SEM',
|
||||
'Ener-HS',
|
||||
'HS 59-109',
|
||||
'HS 25-38',
|
||||
'HS 39-58',
|
||||
'LAB Inf',
|
||||
'LAB Robo',
|
||||
'LAB SET'
|
||||
);
|
||||
@@ -61,26 +61,81 @@ $route['api/v1/organisation/[O|o]rganisationseinheit/(:any)'] = 'api/v1/organisa
|
||||
$route['api/v1/ressource/[B|b]etriebsmittelperson/(:any)'] = 'api/v1/ressource/betriebsmittelperson2/$1';
|
||||
$route['api/v1/system/[S|s]prache/(:any)'] = 'api/v1/system/sprache2/$1';
|
||||
|
||||
$route['Cis/Stundenplan/.*'] = 'Cis/Stundenplan/index/$1';
|
||||
$route['Cis/LvPlan/.*'] = 'Cis/LvPlan/index/$1';
|
||||
$route['Cis/MyLvPlan/.*'] = 'Cis/MyLvPlan/index/$1';
|
||||
$route['Cis/MyLv/.*'] = 'Cis/MyLv/index/$1';
|
||||
|
||||
// load routes from extensions
|
||||
$subdir = 'application/config/extensions';
|
||||
$dirlist = scandir($subdir);
|
||||
// Studierendenverwaltung List Routes
|
||||
$route['api/frontend/v1/stv/[sS]tudents/inout'] = 'api/frontend/v1/stv/Students/index';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})'] = 'api/frontend/v1/stv/Students/index';
|
||||
|
||||
if ($dirlist)
|
||||
// (studiensemester_kurzbz)/inout[/(incoming|outgoing|gemeinsamestudien)]
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout'] = 'api/frontend/v1/stv/Students/index';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/incoming'] = 'api/frontend/v1/stv/Students/getIncoming';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/outgoing'] = 'api/frontend/v1/stv/Students/getOutgoing';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/inout/gemeinsamestudien'] = 'api/frontend/v1/stv/Students/getGemeinsamestudien';
|
||||
|
||||
// (studiengang_kz)/prestudent[/(studiensemester_kurzbz)[/(filter)[/(otherfilter)]]]
|
||||
$route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/prestudent'] = 'api/frontend/v1/stv/Students/getPrestudents/$1';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/prestudent/([WS]S[0-9]{4})'] = 'api/frontend/v1/stv/Students/getPrestudents/$1/$2';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/prestudent/([WS]S[0-9]{4})/(:any)'] = 'api/frontend/v1/stv/Students/getPrestudents/$1/$2/$3';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/prestudent/([WS]S[0-9]{4})/(:any)/(:any)'] = 'api/frontend/v1/stv/Students/getPrestudents/$1/$2/$4';
|
||||
|
||||
// (studiengang_kz)/(orgform)/prestudent[/(studiensemester_kurzbz)[/(filter)[/(otherfilter)]]]
|
||||
$route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/([A-Z]{2,3})/prestudent'] = 'api/frontend/v1/stv/Students/getPrestudentsOrgform/$1/$2';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/([A-Z]{2,3})/prestudent/([WS]S[0-9]{4})'] = 'api/frontend/v1/stv/Students/getPrestudentsOrgform/$1/$2/$3';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/([A-Z]{2,3})/prestudent/([WS]S[0-9]{4})/(:any)'] = 'api/frontend/v1/stv/Students/getPrestudentsOrgform/$1/$2/$3/$4';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/(-?[0-9]+)/([A-Z]{2,3})/prestudent/([WS]S[0-9]{4})/(:any)/(:any)'] = 'api/frontend/v1/stv/Students/getPrestudentsOrgform/$1/$2/$3/$5';
|
||||
|
||||
// (studiensemester_kurzbz)/(studiengang_kz)/(semester)/grp/(gruppe)
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/(:num)/grp/(:any)'] = 'api/frontend/v1/stv/Students/getStudentsSpezialgruppe/$1/$2/$3/$4';
|
||||
|
||||
// (studiensemester_kurzbz)/(studiengang_kz)[/(semester)[/(verband)[/(gruppe)]]]
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)'] = 'api/frontend/v1/stv/Students/getStudents/$1/$2';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/(:num)'] = 'api/frontend/v1/stv/Students/getStudents/$1/$2/$3';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/(:num)/(:any)'] = 'api/frontend/v1/stv/Students/getStudents/$1/$2/$3/$4';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/(:num)/(:any)/(:any)'] = 'api/frontend/v1/stv/Students/getStudents/$1/$2/$3/$4/$5';
|
||||
|
||||
// (studiensemester_kurzbz)/(studiengang_kz)/(orgform)/(semester)/grp/(gruppe)
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/([A-Z]{2,3})/(:num)/grp/(:any)'] = 'api/frontend/v1/stv/Students/getStudentsOrgformSpezialgruppe/$1/$2/$3/$4/$5';
|
||||
|
||||
// (studiensemester_kurzbz)/(studiengang_kz)/(orgform)[/(semester)[/(verband)[/(gruppe)]]]
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/([A-Z]{2,3})'] = 'api/frontend/v1/stv/Students/getStudentsOrgform/$1/$2/$3';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/([A-Z]{2,3})/(:num)'] = 'api/frontend/v1/stv/Students/getStudentsOrgform/$1/$2/$3/$4';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/([A-Z]{2,3})/(:num)/(:any)'] = 'api/frontend/v1/stv/Students/getStudentsOrgform/$1/$2/$3/$4/$5';
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/(-?[0-9]+)/([A-Z]{2,3})/(:num)/(:any)/(:any)'] = 'api/frontend/v1/stv/Students/getStudentsOrgform/$1/$2/$3/$4/$5/$6';
|
||||
|
||||
// // (studiensemester_kurzbz)/uid/(uid)
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/uid/(:any)'] = 'api/frontend/v1/stv/Students/getStudent/$1/$2';
|
||||
// // (studiensemester_kurzbz)/prestudent/(prestudent_id)
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/prestudent/(:num)'] = 'api/frontend/v1/stv/Students/getPrestudent/$1/$2';
|
||||
// // (studiensemester_kurzbz)/person/(person_id)
|
||||
$route['api/frontend/v1/stv/[sS]tudents/([WS]S[0-9]{4})/person/(:num)'] = 'api/frontend/v1/stv/Students/getPerson/$1/$2';
|
||||
|
||||
// load routes from extensions, also look for environment-specific configs
|
||||
$subdirs = ['application/config/extensions', 'application/config/' . ENVIRONMENT . '/extensions'];
|
||||
|
||||
foreach($subdirs as $subdir)
|
||||
{
|
||||
$files = array_diff($dirlist, array('.','..'));
|
||||
|
||||
foreach ($files as &$item)
|
||||
if(is_dir($subdir))
|
||||
{
|
||||
if (is_dir($subdir . DIRECTORY_SEPARATOR . $item))
|
||||
$dirlist = scandir($subdir);
|
||||
if ($dirlist)
|
||||
{
|
||||
$routes_file = $subdir . DIRECTORY_SEPARATOR . $item . DIRECTORY_SEPARATOR . 'routes.php';
|
||||
$files = array_diff($dirlist, array('.','..'));
|
||||
|
||||
if (file_exists($routes_file))
|
||||
foreach ($files as &$item)
|
||||
{
|
||||
require($routes_file);
|
||||
if (is_dir($subdir . DIRECTORY_SEPARATOR . $item))
|
||||
{
|
||||
$routes_file = $subdir . DIRECTORY_SEPARATOR . $item . DIRECTORY_SEPARATOR . 'routes.php';
|
||||
|
||||
if (file_exists($routes_file))
|
||||
{
|
||||
require($routes_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,874 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
$config['person'] = [
|
||||
'primarykey' => 'person_id',
|
||||
'table' => 'public.tbl_person',
|
||||
'searchfields' => [
|
||||
'uid' => [
|
||||
'comparison' => 'equals',
|
||||
'field' => 'uid',
|
||||
'join' => [
|
||||
'table' => "public.tbl_benutzer",
|
||||
'using' => "person_id"
|
||||
],
|
||||
'1-n' => true
|
||||
],
|
||||
'vorname' => [
|
||||
'alias' => ['firstname'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'vorname'
|
||||
],
|
||||
'nachname' => [
|
||||
'alias' => ['lastname', 'surename'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'nachname'
|
||||
],
|
||||
'name' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => "(vorname || ' ' || nachname)"
|
||||
],
|
||||
'email' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => 'kontakt',
|
||||
'join' => [
|
||||
'table' => "public.tbl_kontakt",
|
||||
'on' => "kontakttyp = 'email' AND tbl_kontakt.person_id = tbl_person.person_id"
|
||||
],
|
||||
"1-n" => true
|
||||
],
|
||||
'tel' => [
|
||||
'alias' => ['phone', 'telefon'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'kontakt',
|
||||
'join' => [
|
||||
'table' => "public.tbl_kontakt",
|
||||
'on' => "kontakttyp IN ('telefon', 'so.tel', 'mobil') AND tbl_kontakt.person_id = tbl_person.person_id"
|
||||
],
|
||||
"1-n" => true
|
||||
],
|
||||
'preid' => [
|
||||
'alias' => ['prestudent_id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'prestudent_id',
|
||||
'join' => [
|
||||
'table' => "public.tbl_prestudent",
|
||||
'using' => "person_id"
|
||||
],
|
||||
'1-n' => true
|
||||
],
|
||||
'pid' => [
|
||||
'alias' => ['person_id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'person_id'
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"ARRAY( SELECT uid FROM public.tbl_benutzer WHERE person_id = p.person_id ) AS uids",
|
||||
"p.person_id",
|
||||
"(p.vorname || ' ' || p.nachname) AS name",
|
||||
"ARRAY( SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp = 'email' AND person_id=p.person_id ) AS email",
|
||||
"CASE
|
||||
WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto
|
||||
ELSE NULL END
|
||||
AS photo_url"
|
||||
],
|
||||
'resultjoin' => "
|
||||
JOIN public.tbl_person p USING (person_id)"
|
||||
];
|
||||
|
||||
$config['student'] = [
|
||||
'primarykey' => 'student_uid',
|
||||
'table' => 'public.tbl_student',
|
||||
'searchfields' => [
|
||||
'uid' => [
|
||||
'comparison' => 'equals',
|
||||
'field' => 'student_uid'
|
||||
],
|
||||
'vorname' => [
|
||||
'alias' => ['firstname'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'vorname',
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_prestudent",
|
||||
'using' => "prestudent_id"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'nachname' => [
|
||||
'alias' => ['lastname', 'surename'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'nachname',
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_prestudent",
|
||||
'using' => "prestudent_id"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'name' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => "(vorname || ' ' || nachname)",
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_prestudent",
|
||||
'using' => "prestudent_id"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'email' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => 'kontakt',
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_prestudent",
|
||||
'using' => "prestudent_id"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_kontakt",
|
||||
'on' => "kontakttyp = 'email' AND tbl_kontakt.person_id = tbl_prestudent.person_id"
|
||||
]
|
||||
],
|
||||
"1-n" => true
|
||||
],
|
||||
'tel' => [
|
||||
'alias' => ['phone', 'telefon'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'kontakt',
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_prestudent",
|
||||
'using' => "prestudent_id"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_kontakt",
|
||||
'on' => "kontakttyp IN ('telefon', 'so.tel', 'mobil') AND tbl_kontakt.person_id = tbl_prestudent.person_id"
|
||||
]
|
||||
],
|
||||
"1-n" => true
|
||||
],
|
||||
'stg' => [
|
||||
'alias' => ['studiengang'],
|
||||
'comparison' => 'equals',
|
||||
'field' => "typ || kurzbz",
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_prestudent",
|
||||
'using' => "prestudent_id"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_studiengang",
|
||||
'on' => "tbl_studiengang.studiengang_kz = tbl_prestudent.studiengang_kz"
|
||||
]
|
||||
]
|
||||
],
|
||||
'preid' => [
|
||||
'alias' => ['prestudent_id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'prestudent_id'
|
||||
],
|
||||
'pid' => [
|
||||
'alias' => ['person_id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'person_id',
|
||||
'join' => [
|
||||
'table' => "public.tbl_prestudent",
|
||||
'using' => "prestudent_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"s.student_uid AS uid",
|
||||
"s.matrikelnr",
|
||||
"p.person_id",
|
||||
"(p.vorname || ' ' || p.nachname) AS name",
|
||||
"(s.student_uid || '@" . DOMAIN . "') || ARRAY( SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp = 'email' AND person_id=p.person_id ) AS email",
|
||||
"CASE
|
||||
WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto
|
||||
ELSE NULL END
|
||||
AS photo_url",
|
||||
"b.aktiv"
|
||||
],
|
||||
'resultjoin' => "
|
||||
JOIN public.tbl_student s USING (student_uid)
|
||||
JOIN public.tbl_benutzer b ON(b.uid = s.student_uid)
|
||||
JOIN public.tbl_person p USING(person_id)"
|
||||
];
|
||||
|
||||
$prestudent_sort = [
|
||||
"Student",
|
||||
"Incoming",
|
||||
"Outgoing",
|
||||
"Diplomand",
|
||||
"Unterbrecher",
|
||||
"Aufgenommener",
|
||||
"Wartender",
|
||||
"Bewerber",
|
||||
"Interessent",
|
||||
"Abgewiesener",
|
||||
"Absolvent",
|
||||
"Abbrecher",
|
||||
"Ausserordentlicher",
|
||||
"Praktikant"
|
||||
];
|
||||
$prestudent_sort_array = "array['" . implode("','", $prestudent_sort) . "']";
|
||||
$config['prestudent'] = [
|
||||
'primarykey' => 'prestudent_id',
|
||||
'table' => 'public.tbl_prestudent',
|
||||
'searchfields' => [
|
||||
'uid' => [
|
||||
'comparison' => 'equals',
|
||||
'field' => 'student_uid',
|
||||
'join' => [
|
||||
'table' => "public.tbl_student",
|
||||
'using' => "prestudent_id"
|
||||
]
|
||||
],
|
||||
'vorname' => [
|
||||
'alias' => ['firstname'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'vorname',
|
||||
'join' => [
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
],
|
||||
'nachname' => [
|
||||
'alias' => ['lastname', 'surename'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'nachname',
|
||||
'join' => [
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
],
|
||||
'name' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => "(vorname || ' ' || nachname)",
|
||||
'join' => [
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
],
|
||||
'email' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => 'kontakt',
|
||||
'join' => [
|
||||
'table' => "public.tbl_kontakt",
|
||||
'on' => "kontakttyp = 'email' AND tbl_kontakt.person_id = tbl_prestudent.person_id"
|
||||
],
|
||||
"1-n" => true
|
||||
],
|
||||
'tel' => [
|
||||
'alias' => ['phone', 'telefon'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'kontakt',
|
||||
'join' => [
|
||||
'table' => "public.tbl_kontakt",
|
||||
'on' => "kontakttyp IN ('telefon', 'so.tel', 'mobil') AND tbl_kontakt.person_id = tbl_prestudent.person_id"
|
||||
],
|
||||
"1-n" => true
|
||||
],
|
||||
'stg' => [
|
||||
'alias' => ['studiengang'],
|
||||
'comparison' => 'equals',
|
||||
'field' => "typ || kurzbz",
|
||||
'join' => [
|
||||
'table' => "public.tbl_studiengang",
|
||||
'using' => "studiengang_kz"
|
||||
]
|
||||
],
|
||||
'preid' => [
|
||||
'alias' => ['prestudent_id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'prestudent_id'
|
||||
],
|
||||
'pid' => [
|
||||
'alias' => ['person_id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => 'person_id',
|
||||
'join' => [
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"ps.prestudent_id",
|
||||
"ps.studiengang_kz",
|
||||
"s.matrikelnr",
|
||||
"p.person_id",
|
||||
"b.uid",
|
||||
"(p.vorname || ' ' || p.nachname) AS name",
|
||||
"(b.uid || '@" . DOMAIN . "') || ARRAY( SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp = 'email' AND person_id=p.person_id ) AS email",
|
||||
"CASE
|
||||
WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto
|
||||
ELSE NULL END
|
||||
AS photo_url",
|
||||
"UPPER(sg.typ || sg.kurzbz) AS stg_kuerzel",
|
||||
"sg.bezeichnung",
|
||||
"(
|
||||
SELECT bezeichnung_mehrsprachig[(TABLE lang)]
|
||||
FROM public.tbl_status
|
||||
WHERE status_kurzbz = public.get_rolle_prestudent(ps.prestudent_id, NULL)
|
||||
LIMIT 1
|
||||
) AS status",
|
||||
"COALESCE(
|
||||
(
|
||||
SELECT COALESCE(plan.orgform_kurzbz, pss.orgform_kurzbz)
|
||||
FROM public.tbl_prestudentstatus pss
|
||||
LEFT JOIN lehre.tbl_studienplan plan USING (studienplan_id)
|
||||
WHERE pss.prestudent_id=ps.prestudent_id
|
||||
ORDER BY pss.datum DESC, pss.insertamum DESC, pss.ext_id DESC
|
||||
LIMIT 1
|
||||
),
|
||||
sg.orgform_kurzbz
|
||||
) AS orgform",
|
||||
"b.aktiv",
|
||||
"array_position(" . $prestudent_sort_array . ", public.get_rolle_prestudent(ps.prestudent_id, NULL)) AS sort"
|
||||
],
|
||||
'resultjoin' => "
|
||||
LEFT JOIN public.tbl_prestudent ps USING (prestudent_id)
|
||||
LEFT JOIN public.tbl_student s ON (ps.prestudent_id = s.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)"
|
||||
];
|
||||
|
||||
$config['employee'] = [
|
||||
'alias' => ['ma', 'mitarbeiter'],
|
||||
'primarykey' => 'mitarbeiter_uid',
|
||||
'table' => 'public.tbl_mitarbeiter',
|
||||
'searchfields' => [
|
||||
'uid' => [
|
||||
'alias' => ['mitarbeiter_uid'],
|
||||
'comparison' => 'equals',
|
||||
'field' => "mitarbeiter_uid"
|
||||
],
|
||||
'vorname' => [
|
||||
'alias' => ['firstname'],
|
||||
'comparison' => 'similar',
|
||||
'field' => "vorname",
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_benutzer",
|
||||
'on' => "uid = mitarbeiter_uid"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'nachname' => [
|
||||
'alias' => ['lastname', 'surename'],
|
||||
'comparison' => 'similar',
|
||||
'field' => "nachname",
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_benutzer",
|
||||
'on' => "uid = mitarbeiter_uid"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'name' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => "(vorname || ' ' || nachname)",
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_benutzer",
|
||||
'on' => "uid = mitarbeiter_uid"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_person",
|
||||
'using' => "person_id"
|
||||
]
|
||||
]
|
||||
],
|
||||
'email' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => "COALESCE(alias, uid) || '" . '@' . DOMAIN . "'",
|
||||
'join' => [
|
||||
'table' => "public.tbl_benutzer",
|
||||
'on' => "uid = mitarbeiter_uid"
|
||||
]
|
||||
],
|
||||
'tel' => [
|
||||
'alias' => ['phone', 'telefon'],
|
||||
'comparison' => 'similar',
|
||||
'field' => "TRIM(COALESCE(kontakt, '') || ' ' || COALESCE(telefonklappe, ''))",
|
||||
'join' => [
|
||||
'table' => "public.tbl_kontakt",
|
||||
'on' => "kontakttyp = 'telefon' AND tbl_kontakt.standort_id = tbl_mitarbeiter.standort_id"
|
||||
],
|
||||
"1-n" => true
|
||||
],
|
||||
'pid' => [
|
||||
'alias' => ['person_id'],
|
||||
'comparison' => 'equal-int',
|
||||
'field' => "person_id",
|
||||
'join' => [
|
||||
'table' => "public.tbl_benutzer",
|
||||
'on' => "uid = mitarbeiter_uid"
|
||||
]
|
||||
],
|
||||
'oe' => [
|
||||
'alias' => ['ou', 'organisationseinheit', 'organisationunit'],
|
||||
'comparison' => 'vector',
|
||||
'field' => "fts_bezeichnung",
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_benutzerfunktion",
|
||||
'on' => "mitarbeiter_uid = uid
|
||||
AND funktion_kurzbz = 'oezuordnung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_organisationseinheit",
|
||||
'using' => "oe_kurzbz"
|
||||
]
|
||||
],
|
||||
'1-n' => true
|
||||
],
|
||||
'kst' => [
|
||||
'comparison' => 'vector',
|
||||
'field' => "fts_bezeichnung",
|
||||
'join' => [
|
||||
[
|
||||
'table' => "public.tbl_benutzerfunktion",
|
||||
'on' => "mitarbeiter_uid = uid
|
||||
AND funktion_kurzbz = 'kstzuordnung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())"
|
||||
],
|
||||
[
|
||||
'table' => "public.tbl_organisationseinheit",
|
||||
'using' => "oe_kurzbz"
|
||||
]
|
||||
],
|
||||
'1-n' => true
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"b.uid",
|
||||
"p.person_id",
|
||||
"(p.vorname || ' ' || p.nachname) AS name",
|
||||
"ARRAY(
|
||||
SELECT
|
||||
'[' || ot.bezeichnung || '] ' || o.bezeichnung AS bezeichnung
|
||||
FROM public.tbl_benutzerfunktion bf
|
||||
JOIN public.tbl_organisationseinheit o USING(oe_kurzbz)
|
||||
JOIN public.tbl_organisationseinheittyp ot USING(organisationseinheittyp_kurzbz)
|
||||
WHERE bf.funktion_kurzbz = 'oezuordnung'
|
||||
AND (bf.datum_von IS NULL OR bf.datum_von <= NOW())
|
||||
AND (bf.datum_bis IS NULL OR bf.datum_bis >= NOW())
|
||||
AND bf.uid = b.uid
|
||||
GROUP BY o.bezeichnung, ot.bezeichnung
|
||||
) AS organisationunit_name",
|
||||
"COALESCE(b.alias, b.uid) || '" . '@' . DOMAIN . "' AS email",
|
||||
"TRIM(COALESCE(k.kontakt, '') || ' ' || COALESCE(m.telefonklappe, '')) AS phone",
|
||||
"'" . base_url("/cis/public/bild.php?src=person&person_id=") . "' || p.person_id AS photo_url",
|
||||
"ARRAY(
|
||||
SELECT
|
||||
'[' || ot.bezeichnung || '] ' || o.bezeichnung AS bezeichnung
|
||||
FROM public.tbl_benutzerfunktion bf
|
||||
JOIN public.tbl_organisationseinheit o USING(oe_kurzbz)
|
||||
JOIN public.tbl_organisationseinheittyp ot USING(organisationseinheittyp_kurzbz)
|
||||
WHERE bf.funktion_kurzbz = 'kstzuordnung'
|
||||
AND (bf.datum_von IS NULL OR bf.datum_von <= NOW())
|
||||
AND (bf.datum_bis IS NULL OR bf.datum_bis >= NOW())
|
||||
AND bf.uid = b.uid
|
||||
GROUP BY o.bezeichnung, ot.bezeichnung
|
||||
) AS standardkostenstelle"
|
||||
],
|
||||
'resultjoin' => "
|
||||
JOIN public.tbl_mitarbeiter m USING (mitarbeiter_uid)
|
||||
JOIN public.tbl_benutzer b ON (b.uid = m.mitarbeiter_uid)
|
||||
JOIN public.tbl_person p USING(person_id)
|
||||
LEFT JOIN (
|
||||
SELECT kontakt, standort_id
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = 'telefon'
|
||||
) k ON (k.standort_id = m.standort_id)"
|
||||
];
|
||||
|
||||
// TODO(chris): move to searchpv21.php
|
||||
$config['unassigned_employee'] = $config['employee'];
|
||||
$config['unassigned_employee']['alias'] = ['mitarbeiter_ohne_zuordnung'];
|
||||
$config['unassigned_employee']['prepare'] = "unassigned_employee AS (
|
||||
SELECT tbl_mitarbeiter.*
|
||||
FROM public.tbl_mitarbeiter
|
||||
LEFT JOIN public.tbl_benutzerfunktion ON (
|
||||
uid = mitarbeiter_uid
|
||||
AND funktion_kurzbz = 'kstzuordnung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
)
|
||||
WHERE tbl_benutzerfunktion.bezeichnung IS NULL
|
||||
UNION
|
||||
SELECT tbl_mitarbeiter.*
|
||||
FROM public.tbl_mitarbeiter
|
||||
LEFT JOIN public.tbl_benutzerfunktion ON (
|
||||
uid = mitarbeiter_uid
|
||||
AND funktion_kurzbz = 'oezuordnung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
)
|
||||
WHERE tbl_benutzerfunktion.bezeichnung IS NULL
|
||||
)";
|
||||
$config['unassigned_employee']['table'] = "unassigned_employee";
|
||||
$config['unassigned_employee']['searchfields']['tel']['join']['on'] = "
|
||||
kontakttyp = 'telefon'
|
||||
AND tbl_kontakt.standort_id = unassigned_employee.standort_id
|
||||
";
|
||||
$config['unassigned_employee']['renderer'] = 'employee';
|
||||
|
||||
$config['organisationunit'] = [
|
||||
'alias' => ['ou', 'organisationseinheit', 'oe'],
|
||||
'primarykey' => 'oe_kurzbz',
|
||||
'table' => 'public.tbl_organisationseinheit',
|
||||
'searchfields' => [
|
||||
'uid' => [
|
||||
'comparison' => 'equals',
|
||||
'field' => 'uid',
|
||||
'prepare' => "organisationunit_leader(oe_kurzbz, uid, vorname, nachname) AS (
|
||||
SELECT oe_kurzbz, vorname, nachname, uid
|
||||
FROM public.tbl_benutzerfunktion
|
||||
JOIN public.tbl_benutzer USING (uid)
|
||||
JOIN public.tbl_person USING (person_id)
|
||||
WHERE funktion_kurzbz = 'Leitung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND tbl_benutzer.aktiv = TRUE
|
||||
)",
|
||||
'join' => [
|
||||
'table' => "organisationunit_leader",
|
||||
'using' => "oe_kurzbz"
|
||||
],
|
||||
'1-n' => true
|
||||
],
|
||||
'vorname' => [
|
||||
'alias' => ['firstname'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'vorname',
|
||||
'prepare' => "organisationunit_leader(oe_kurzbz, uid, vorname, nachname) AS (
|
||||
SELECT oe_kurzbz, vorname, nachname, uid
|
||||
FROM public.tbl_benutzerfunktion
|
||||
JOIN public.tbl_benutzer USING (uid)
|
||||
JOIN public.tbl_person USING (person_id)
|
||||
WHERE funktion_kurzbz = 'Leitung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND tbl_benutzer.aktiv = TRUE
|
||||
)",
|
||||
'join' => [
|
||||
'table' => "organisationunit_leader",
|
||||
'using' => "oe_kurzbz"
|
||||
],
|
||||
'1-n' => true
|
||||
],
|
||||
'nachname' => [
|
||||
'alias' => ['lastname', 'surename'],
|
||||
'comparison' => 'similar',
|
||||
'field' => 'nachname',
|
||||
'prepare' => "organisationunit_leader(oe_kurzbz, uid, vorname, nachname) AS (
|
||||
SELECT oe_kurzbz, vorname, nachname, uid
|
||||
FROM public.tbl_benutzerfunktion
|
||||
JOIN public.tbl_benutzer USING (uid)
|
||||
JOIN public.tbl_person USING (person_id)
|
||||
WHERE funktion_kurzbz = 'Leitung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND tbl_benutzer.aktiv = TRUE
|
||||
)",
|
||||
'join' => [
|
||||
'table' => "organisationunit_leader",
|
||||
'using' => "oe_kurzbz"
|
||||
],
|
||||
'1-n' => true
|
||||
],
|
||||
'name' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => "(vorname || ' ' || nachname)",
|
||||
'prepare' => "organisationunit_leader(oe_kurzbz, uid, vorname, nachname) AS (
|
||||
SELECT oe_kurzbz, vorname, nachname, uid
|
||||
FROM public.tbl_benutzerfunktion
|
||||
JOIN public.tbl_benutzer USING (uid)
|
||||
JOIN public.tbl_person USING (person_id)
|
||||
WHERE funktion_kurzbz = 'Leitung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND tbl_benutzer.aktiv = TRUE
|
||||
)",
|
||||
'join' => [
|
||||
'table' => "organisationunit_leader",
|
||||
'using' => "oe_kurzbz"
|
||||
],
|
||||
'1-n' => true
|
||||
],
|
||||
'oe' => [
|
||||
'alias' => ['ou', 'organisationseinheit', 'organisationunit'],
|
||||
'comparison' => 'vector',
|
||||
'field' => "fts_bezeichnung"
|
||||
],
|
||||
'kurzbz' => [
|
||||
'alias' => ['oe_kurzbz'],
|
||||
'comparison' => 'equals',
|
||||
'field' => "oe_kurzbz"
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"oe.oe_kurzbz",
|
||||
"('[' || type.bezeichnung || '] ' || oe.bezeichnung) AS name",
|
||||
"oe_parent.oe_kurzbz AS parentoe_kurzbz",
|
||||
"(CASE WHEN oe_parent.bezeichnung IS NOT NULL THEN '[' || type_parent.bezeichnung || '] ' || oe_parent.bezeichnung END) AS parentoe_name",
|
||||
"ARRAY(
|
||||
SELECT JSON_BUILD_OBJECT('uid', b.uid, 'vorname', p.vorname, 'nachname', p.nachname, 'name', (p.vorname || ' ' || p.nachname))
|
||||
FROM public.tbl_benutzerfunktion bf
|
||||
JOIN public.tbl_benutzer b USING (uid)
|
||||
JOIN public.tbl_person p USING (person_id)
|
||||
WHERE funktion_kurzbz = 'Leitung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND b.aktiv = TRUE
|
||||
AND oe_kurzbz = oe.oe_kurzbz
|
||||
) AS leaders",
|
||||
"(
|
||||
SELECT COUNT(*)
|
||||
FROM public.tbl_benutzerfunktion
|
||||
WHERE funktion_kurzbz = 'oezuordnung'
|
||||
AND (datum_von IS NULL OR datum_von <= NOW())
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND oe_kurzbz = oe.oe_kurzbz
|
||||
) AS number_of_people",
|
||||
"(CASE WHEN oe.mailverteiler THEN oe.oe_kurzbz || '" . '@' . DOMAIN . "' END) AS mailgroup"
|
||||
],
|
||||
'resultjoin' => "
|
||||
JOIN public.tbl_organisationseinheit oe
|
||||
USING (oe_kurzbz)
|
||||
JOIN public.tbl_organisationseinheittyp type
|
||||
USING (organisationseinheittyp_kurzbz)
|
||||
LEFT JOIN public.tbl_organisationseinheit oe_parent
|
||||
ON (oe_parent.oe_kurzbz = oe.oe_parent_kurzbz)
|
||||
LEFT JOIN public.tbl_organisationseinheittyp type_parent
|
||||
ON (oe_parent.organisationseinheittyp_kurzbz = type_parent.organisationseinheittyp_kurzbz)"
|
||||
];
|
||||
|
||||
$config['room'] = [
|
||||
'alias' => ['raum'],
|
||||
'primarykey' => 'ort_kurzbz',
|
||||
'table' => 'public.tbl_ort',
|
||||
'searchfields' => [
|
||||
'name' => [
|
||||
'comparison' => 'similar',
|
||||
'field' => 'ort_kurzbz'
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"ort.ort_kurzbz",
|
||||
"ort.gebteil AS building",
|
||||
"ort.ausstattung AS equipment",
|
||||
"ort.stockwerk AS floor",
|
||||
"ort.dislozierung AS room_number",
|
||||
"ort.content_id",
|
||||
"address.ort AS city",
|
||||
"address.plz AS zip",
|
||||
"address.strasse AS street",
|
||||
"ort.max_person",
|
||||
"ort.arbeitsplaetze AS workplaces"
|
||||
],
|
||||
'resultjoin' => "
|
||||
JOIN public.tbl_ort ort
|
||||
USING (ort_kurzbz)
|
||||
LEFT JOIN public.tbl_standort
|
||||
USING (standort_id)
|
||||
LEFT JOIN public.tbl_adresse address
|
||||
USING (adresse_id)"
|
||||
];
|
||||
$sprache = getUserLanguage();
|
||||
$config['cms'] = [
|
||||
'primarykey' => 'contentsprache_id',
|
||||
'table' => 'campus.tbl_contentsprache',
|
||||
'prepare' => "
|
||||
cms_auth (content_id) AS (
|
||||
SELECT content_id
|
||||
FROM campus.tbl_content c
|
||||
WHERE NOT EXISTS (SELECT 1 FROM campus.tbl_contentgruppe g WHERE g.content_id=c.content_id)
|
||||
UNION
|
||||
SELECT content_id
|
||||
FROM public.vw_gruppen g
|
||||
JOIN campus.tbl_contentgruppe c USING (gruppe_kurzbz)
|
||||
WHERE uid = (TABLE auth)
|
||||
),
|
||||
cms_active (content_id, template_kurzbz) AS (
|
||||
SELECT content_id, template_kurzbz
|
||||
FROM cms_auth
|
||||
JOIN campus.tbl_content USING (content_id)
|
||||
WHERE aktiv = TRUE
|
||||
),
|
||||
cms_active_redirect (content_id) AS (
|
||||
SELECT content_id
|
||||
FROM cms_active
|
||||
WHERE template_kurzbz = 'redirect'
|
||||
),
|
||||
cms_active_redirect_linked (content_id) AS (
|
||||
SELECT content_id
|
||||
FROM cms_active_redirect
|
||||
JOIN campus.tbl_contentsprache USING (content_id)
|
||||
WHERE LEFT((xpath('string(/content/url)', content))[1]::text, 1) <> '#'
|
||||
),
|
||||
cms_active_others (content_id) AS (
|
||||
SELECT content_id
|
||||
FROM cms_active
|
||||
WHERE template_kurzbz IN ('contentmittitel', 'contentohnetitel', 'contentmittitel_filterwidget')
|
||||
)
|
||||
",
|
||||
'searchfields' => [
|
||||
'content' => [
|
||||
'alias' => ['inhalt'],
|
||||
'comparison' => "vector",
|
||||
'field' => "(
|
||||
setweight(to_tsvector('simple', COALESCE(titel, '')), 'A')
|
||||
||
|
||||
setweight(to_tsvector('simple', COALESCE(content, '')::text), 'B')
|
||||
)"
|
||||
],
|
||||
'content_id' => [
|
||||
'alias' => ['id'],
|
||||
'comparison' => "equal-int",
|
||||
'field' => "content_id"
|
||||
],
|
||||
'lang' => [
|
||||
'alias' => ['language', 'sprache'],
|
||||
'comparison' => "equals",
|
||||
'field' => "sprache"
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"contentsprache.content_id",
|
||||
"content.template_kurzbz",
|
||||
"contentsprache.version",
|
||||
"contentsprache.sprache AS language",
|
||||
"contentsprache.titel AS title",
|
||||
"contentsprache.content",
|
||||
"(xpath('string(/content/url)', contentsprache.content))[1] AS content_url"
|
||||
],
|
||||
'resultjoin' => "
|
||||
JOIN campus.tbl_contentsprache contentsprache
|
||||
USING (contentsprache_id)
|
||||
JOIN campus.tbl_content content
|
||||
USING (content_id)
|
||||
WHERE content_id IN (
|
||||
SELECT content_id
|
||||
FROM cms_active_redirect_linked
|
||||
UNION
|
||||
SELECT content_id
|
||||
FROM cms_active_others
|
||||
)
|
||||
AND version = campus.get_highest_content_version(content_id)
|
||||
AND contentsprache.sprache = '{$sprache}'"
|
||||
];
|
||||
|
||||
$config['dms'] = [
|
||||
'primarykey' => 'dms_id, version',
|
||||
'table' => 'campus.tbl_dms_version',
|
||||
'searchfields' => [
|
||||
'keywords' => [
|
||||
'alias' => ['keyword', 'keywords', 'schlagwort', 'schlagworte'],
|
||||
'comparison' => "vector",
|
||||
'field' => "(to_tsvector('simple', COALESCE(schlagworte, '')))"
|
||||
]
|
||||
],
|
||||
'resultfields' => [
|
||||
"v.dms_id",
|
||||
"v.version",
|
||||
"v.filename",
|
||||
"v.mimetype",
|
||||
"v.name",
|
||||
"v.beschreibung AS description",
|
||||
"v.schlagworte AS keywords"
|
||||
],
|
||||
'resultjoin' => "
|
||||
JOIN campus.tbl_dms_version v
|
||||
USING (dms_id, version)
|
||||
WHERE cis_suche = TRUE
|
||||
AND version=(SELECT MAX(version) FROM campus.tbl_dms_version WHERE dms_id=v.dms_id)
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
fue.tbl_projekt_dokument p
|
||||
WHERE p.dms_id = v.dms_id
|
||||
) AND (
|
||||
NOT EXISTS (
|
||||
WITH RECURSIVE categories (kategorie_kurzbz) AS (
|
||||
SELECT
|
||||
kategorie_kurzbz
|
||||
FROM
|
||||
campus.tbl_dms c
|
||||
WHERE c.dms_id = v.dms_id
|
||||
UNION ALL
|
||||
SELECT
|
||||
cat.parent_kategorie_kurzbz AS kategorie_kurzbz
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie cat USING (kategorie_kurzbz)
|
||||
)
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie_gruppe USING (kategorie_kurzbz)
|
||||
UNION
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie USING (kategorie_kurzbz)
|
||||
WHERE
|
||||
berechtigung_kurzbz IS NOT NULL
|
||||
) OR EXISTS (
|
||||
WITH RECURSIVE categories (kategorie_kurzbz) AS (
|
||||
SELECT
|
||||
kategorie_kurzbz
|
||||
FROM
|
||||
campus.tbl_dms c
|
||||
WHERE c.dms_id = v.dms_id
|
||||
UNION ALL
|
||||
SELECT
|
||||
cat.parent_kategorie_kurzbz AS kategorie_kurzbz
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie cat USING (kategorie_kurzbz)
|
||||
)
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
categories
|
||||
JOIN campus.tbl_dms_kategorie_gruppe USING (kategorie_kurzbz)
|
||||
JOIN public.tbl_benutzergruppe USING(gruppe_kurzbz)
|
||||
WHERE
|
||||
uid = (TABLE auth)
|
||||
)
|
||||
)"
|
||||
];
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
$CI =& get_instance();
|
||||
|
||||
|
||||
$config['employee'] = $CI->config->item('employee', 'search');
|
||||
$config['employee']['resultjoin'] = "
|
||||
JOIN public.tbl_mitarbeiter m USING (mitarbeiter_uid)
|
||||
JOIN public.tbl_benutzer b ON (b.uid = m.mitarbeiter_uid AND b.aktiv = true)
|
||||
JOIN public.tbl_person p USING(person_id)
|
||||
LEFT JOIN (
|
||||
SELECT kontakt, standort_id
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = 'telefon'
|
||||
) k ON (k.standort_id = m.standort_id)";
|
||||
|
||||
$config['student'] = $CI->config->item('student', 'search');
|
||||
unset($config['student']['searchfields']['email']);
|
||||
unset($config['student']['searchfields']['tel']);
|
||||
$config['student']['resultfields'] = [
|
||||
"s.student_uid AS uid",
|
||||
"s.matrikelnr",
|
||||
"p.person_id",
|
||||
"(p.vorname || ' ' || p.nachname) AS name",
|
||||
"ARRAY[s.student_uid || '@' || '" . DOMAIN . "'] AS email",
|
||||
"CASE
|
||||
WHEN (p.foto_sperre = false AND p.foto IS NOT NULL) THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto
|
||||
ELSE NULL END
|
||||
AS photo_url",
|
||||
"b.aktiv"
|
||||
];
|
||||
$config['student']['resultjoin'] = "
|
||||
JOIN public.tbl_student s USING (student_uid)
|
||||
JOIN public.tbl_benutzer b ON(b.uid = s.student_uid AND b.aktiv = true)
|
||||
JOIN public.tbl_person p USING(person_id)";
|
||||
|
||||
$config['organisationunit'] = $CI->config->item('organisationunit', 'search');
|
||||
$config['organisationunit']['prepare'] = 'active_organisationseinheit AS (SELECT * FROM public.tbl_organisationseinheit WHERE aktiv = true AND organisationseinheittyp_kurzbz <> \'Container\')';
|
||||
$config['organisationunit']['table'] = 'active_organisationseinheit';
|
||||
|
||||
$config['room'] = $CI->config->item('room', 'search');
|
||||
|
||||
$config['cms'] = $CI->config->item('cms', 'search');
|
||||
|
||||
$config['dms'] = $CI->config->item('dms', 'search');
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/*
|
||||
* TODO: 2025-07-21 ma0080 bare integer comparision results in db error
|
||||
* if searchstring is numeric but out of range of int, think about
|
||||
* more sophisticated solution using column data type - quick fix
|
||||
* convert field and search string to text
|
||||
*/
|
||||
$config['equal-int'] = [
|
||||
'priority' => 4,
|
||||
'rank' => "0",
|
||||
'compare' => "{field}::text = {word}::text",
|
||||
'force_integer' => true
|
||||
];
|
||||
|
||||
$config['equals'] = [
|
||||
'priority' => 3,
|
||||
'rank' => "0",
|
||||
'compare' => "LOWER({field}) = {word}"
|
||||
];
|
||||
|
||||
$config['similar'] = [
|
||||
'priority' => 2,
|
||||
'rank' => "(COALESCE({field}, '') <->> {word})",
|
||||
'compare' => "COALESCE({field}, '') %> {word}",
|
||||
'compare_boolean' => "COALESCE({field}, '') ILIKE {like:word}"
|
||||
];
|
||||
|
||||
$config['vector'] = [
|
||||
'priority' => 1,
|
||||
'rank' => "ts_rank({field}, to_tsquery('simple', {word}))",
|
||||
'compare' => "to_tsquery('simple', {word}) @@ {field}"
|
||||
];
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
$CI =& get_instance();
|
||||
|
||||
|
||||
$config['student'] = $CI->config->item('student', 'search');
|
||||
|
||||
$config['prestudent'] = $CI->config->item('prestudent', 'search');
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
$config['number_displayed_past_studiensemester_default'] = 5;
|
||||
$config['tabs'] =
|
||||
[
|
||||
'details' => [
|
||||
@@ -52,6 +53,14 @@ $config['tabs'] =
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'exemptions' => [
|
||||
//if true, Anrechnungen can be added and edited in tab Anrechnungen
|
||||
'editableAnrechnungen' => false,
|
||||
],
|
||||
'notes' => [
|
||||
//if true, the count of Messages will be shown in the header of the Tab Messages
|
||||
'showCountNotes' => true
|
||||
]
|
||||
];
|
||||
|
||||
@@ -74,3 +83,33 @@ if (!defined('ZGV_DOKTOR_ANZEIGEN') || !ZGV_DOKTOR_ANZEIGEN) {
|
||||
$fieldsZgvDoktor
|
||||
);
|
||||
}
|
||||
|
||||
$config['student_tab_order'] = [
|
||||
'details',
|
||||
'notes',
|
||||
'messages',
|
||||
'contact',
|
||||
'prestudent',
|
||||
'status',
|
||||
'documents',
|
||||
'archive',
|
||||
'banking',
|
||||
'grades',
|
||||
'exam',
|
||||
'exemptions',
|
||||
'finalexam',
|
||||
'mobility',
|
||||
'jointstudies',
|
||||
'admissionDates',
|
||||
'groups',
|
||||
'functions',
|
||||
'coursedates',
|
||||
'resources',
|
||||
];
|
||||
$config['students_tab_order'] = [
|
||||
'banking',
|
||||
'status',
|
||||
'groups',
|
||||
'finalexam',
|
||||
'archive',
|
||||
];
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
|
||||
// changing the color theme
|
||||
|
||||
$config['theme_name']='default';
|
||||
$config['theme_css']= "public/css/theme/default.css";
|
||||
$config['theme_logo']= "public/images/logo_fh-complete_300x46.png";
|
||||
$config['theme_modes']=['light','dark'];
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Abgabetool extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => self::PERM_LOGGED,
|
||||
'getStudentProjektarbeitAbgabeFile' => self::PERM_LOGGED,
|
||||
'Mitarbeiter' => self::PERM_LOGGED,
|
||||
'Student' => self::PERM_LOGGED,
|
||||
'Deadlines' => self::PERM_LOGGED
|
||||
]);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = array(
|
||||
'uid'=>getAuthUID(),
|
||||
);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'Abgabetool']);
|
||||
}
|
||||
|
||||
public function Student()
|
||||
{
|
||||
|
||||
$viewData = array(
|
||||
'uid'=>getAuthUID(),
|
||||
);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'AbgabetoolStudent']);
|
||||
}
|
||||
|
||||
public function Mitarbeiter()
|
||||
{
|
||||
|
||||
$viewData = array(
|
||||
'uid'=>getAuthUID(),
|
||||
);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'AbgabetoolMitarbeiter']);
|
||||
}
|
||||
|
||||
public function Deadlines()
|
||||
{
|
||||
|
||||
$viewData = array(
|
||||
'uid'=>getAuthUID(),
|
||||
);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'DeadlinesOverview']);
|
||||
}
|
||||
|
||||
|
||||
public function getStudentProjektarbeitAbgabeFile()
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
$this->_ci->load->helper('download');
|
||||
|
||||
$paabgabe_id = $this->_ci->input->get('paabgabe_id');
|
||||
$student_uid = $this->_ci->input->get('student_uid');
|
||||
|
||||
if (!isset($paabgabe_id) || isEmptyString($paabgabe_id) || !isset($student_uid) || isEmptyString($student_uid))
|
||||
$this->terminateWithJsonError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
$this->_ci->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
|
||||
|
||||
$isZugeteilterBetreuer = count($this->_ci->ProjektarbeitModel->checkZuordnung($student_uid, getAuthUID())->retval) > 0;
|
||||
|
||||
if(getAuthUID() == $student_uid || $isZugeteilterBetreuer) {
|
||||
$file_path = PAABGABE_PATH.$paabgabe_id.'_'.$student_uid.'.pdf';
|
||||
if(file_exists($file_path)) {
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Disposition: attachment; filename="'.basename($file_path).'"');
|
||||
header('Content-Length: ' . filesize($file_path));
|
||||
|
||||
flush(); // send headers first just in case
|
||||
readfile($file_path); // read file content to output buffer
|
||||
|
||||
} else {
|
||||
$this->terminateWithJsonError('File not found');
|
||||
}
|
||||
} else {
|
||||
$this->terminateWithJsonError('Keine Zuordnung!');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@ class Auth extends FHC_Controller
|
||||
{
|
||||
$this->load->library('AuthLib');
|
||||
$this->authlib->logout();
|
||||
redirect('/Cis/Auth/login', 'refresh');
|
||||
setcookie('fhclogout', 'fhclogout', 0, '/');
|
||||
redirect(base_url('/cis/private/logout.php'), 'refresh');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class Documents extends Auth_Controller
|
||||
|
||||
$stgs = [];
|
||||
$stsemArray = [];
|
||||
$buchungstypen = implode('\',\'', defined("CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN") ? unserialize(CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN) : []);
|
||||
$buchungstypen = defined("CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN") ? unserialize(CIS_DOKUMENTE_STUDIENBEITRAG_TYPEN) : [];
|
||||
$person_ids = [];
|
||||
foreach ($stati as $status) {
|
||||
$person_ids[] = $status->person_id;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class LvPlan extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => ['basis/cis:r']
|
||||
]);
|
||||
|
||||
// Load Config
|
||||
$this->load->config('calendar');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = array(
|
||||
'uid'=>getAuthUID(),
|
||||
'timezone' => $this->config->item('timezone')
|
||||
);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'LvPlan']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class MyLvPlan extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => ['basis/cis:r']
|
||||
]);
|
||||
|
||||
// Load Config
|
||||
$this->load->config('calendar');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$viewData = array(
|
||||
'uid'=>getAuthUID(),
|
||||
'timezone' => $this->config->item('timezone')
|
||||
);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'MyLvPlan']);
|
||||
}
|
||||
}
|
||||
@@ -55,8 +55,13 @@ class Profil extends Auth_Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->load->library('ProfilLib');
|
||||
$profil_data = $this->profillib->getView(getAuthUID());
|
||||
$profil_data = hasData($profil_data) ? getData($profil_data) : null;
|
||||
$viewData = array(
|
||||
|
||||
'editable'=>true,
|
||||
'profil_data' => $profil_data,
|
||||
);
|
||||
$this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'profilIndex']);
|
||||
}
|
||||
@@ -68,8 +73,16 @@ class Profil extends Auth_Controller
|
||||
*/
|
||||
public function View($uid)
|
||||
{
|
||||
$viewData = array ('uid' => $uid);
|
||||
|
||||
$this->load->library('ProfilLib');
|
||||
$profil_data = $this->profillib->getView($uid);
|
||||
$profil_data = hasData($profil_data) ? getData($profil_data) : null;
|
||||
$viewData = array (
|
||||
'uid' => $uid,
|
||||
'profil_data'=>$profil_data,
|
||||
);
|
||||
if($uid == getAuthUID()){
|
||||
$viewData['editable'] = true;
|
||||
}
|
||||
$this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'profilViewUid']);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,54 +9,21 @@ if (!defined('BASEPATH'))
|
||||
class ProfilUpdate extends Auth_Controller
|
||||
{
|
||||
|
||||
public static $STATUS_PENDING = NULL;
|
||||
public static $STATUS_ACCEPTED = NULL;
|
||||
public static $STATUS_REJECTED = NULL;
|
||||
|
||||
public static $TOPICS = [];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'],
|
||||
'id' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'],
|
||||
'getProfilUpdateWithPermission' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r'],
|
||||
'acceptProfilRequest' => ['student/stammdaten:rw', 'mitarbeiter/stammdaten:rw'],
|
||||
'denyProfilRequest' => ['student/stammdaten:rw', 'mitarbeiter/stammdaten:rw'],
|
||||
'show' => ['basis/cis:r'],
|
||||
|
||||
'insertProfilRequest' => ['basis/cis:rw'],
|
||||
'updateProfilRequest' => ['basis/cis:rw'],
|
||||
'deleteProfilRequest' => ['basis/cis:rw'],
|
||||
'selectProfilRequest' => ['basis/cis:r'],
|
||||
'insertFile' => ['basis/cis:rw'],
|
||||
'getProfilRequestFiles' => ['basis/cis:r'],
|
||||
'getStatus' => ['basis/cis:r'],
|
||||
'getTopic' => ['basis/cis:r'],
|
||||
'show' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r', 'basis/cis:r'],
|
||||
'id' => ['student/stammdaten:r', 'mitarbeiter/stammdaten:r']
|
||||
]);
|
||||
|
||||
$this->load->config('cis');
|
||||
|
||||
$this->load->model('person/Profil_update_model', 'ProfilUpdateModel');
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
$this->load->model('person/Adressentyp_model', 'AdressenTypModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->load->model('system/Sprache_model', 'SpracheModel');
|
||||
$this->load->model('person/Profil_update_status_model', 'ProfilUpdateStatusModel');
|
||||
$this->load->model('person/Profil_update_topic_model', 'ProfilUpdateTopicModel');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'ui',
|
||||
'global',
|
||||
'person',
|
||||
'profil',
|
||||
'profilUpdate'
|
||||
)
|
||||
);
|
||||
@@ -64,32 +31,10 @@ class ProfilUpdate extends Auth_Controller
|
||||
$this->load->library('DmsLib');
|
||||
$this->load->library('PermissionLib');
|
||||
|
||||
//? put the uid and pid inside the controller for reusability
|
||||
$this->uid = getAuthUID();
|
||||
$this->pid = getAuthPersonID();
|
||||
|
||||
// setup the ProfilUpdate states
|
||||
$this->ProfilUpdateStatusModel->addSelect(['status_kurzbz']);
|
||||
$status_kurzbz = $this->ProfilUpdateStatusModel->load();
|
||||
if (hasData($status_kurzbz)) {
|
||||
list($status_pending, $status_accepted, $status_rejected) = getData($status_kurzbz);
|
||||
|
||||
self::$STATUS_PENDING = $status_pending->status_kurzbz;
|
||||
self::$STATUS_ACCEPTED = $status_accepted->status_kurzbz;
|
||||
self::$STATUS_REJECTED = $status_rejected->status_kurzbz;
|
||||
}
|
||||
// setup the ProfilUpdate topics
|
||||
$this->ProfilUpdateTopicModel->addSelect(['topic_kurzbz']);
|
||||
$topic_kurzbz = $this->ProfilUpdateTopicModel->load();
|
||||
|
||||
if (hasData($topic_kurzbz)) {
|
||||
foreach (getData($topic_kurzbz) as $topic) {
|
||||
self::$TOPICS[$topic->topic_kurzbz] = $topic->topic_kurzbz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('Cis/ProfilUpdate');
|
||||
@@ -100,129 +45,14 @@ class ProfilUpdate extends Auth_Controller
|
||||
$this->load->view('Cis/ProfilUpdate', ['profil_update_id' => $profil_update_id]);
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
echo json_encode([self::$STATUS_PENDING => self::$STATUS_PENDING, self::$STATUS_ACCEPTED => self::$STATUS_ACCEPTED, self::$STATUS_REJECTED => self::$STATUS_REJECTED]);
|
||||
}
|
||||
|
||||
public function getTopic()
|
||||
{
|
||||
echo json_encode(self::$TOPICS);
|
||||
}
|
||||
|
||||
private function sendEmail_onProfilUpdate_response($uid, $topic, $status)
|
||||
{
|
||||
if($this->config->item('cis_send_profil_update_mails') === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
$email = $uid . "@" . DOMAIN;
|
||||
|
||||
|
||||
function languageQuery($language)
|
||||
{
|
||||
return "select index from public.tbl_sprache where sprache = '" + $language + "'";
|
||||
}
|
||||
$this->ProfilUpdateStatusModel->addSelect(["bezeichnung_mehrsprachig[(" . languageQuery('German') . ")] as status_de", "bezeichnung_mehrsprachig[(" . languageQuery('English') . ")] as status_en"]);
|
||||
$status_translation = $this->ProfilUpdateStatusModel->loadWhere(["status_kurzbz" => $status]);
|
||||
if (isError($status_translation)) {
|
||||
show_error($this->p->t('profilUpdate', 'ProfilUpdateStatusTranslationError'));
|
||||
}
|
||||
$status_translation = hasData($status_translation) ? getData($status_translation)[0] : null;
|
||||
if (isset($status_translation)) {
|
||||
$mail_res = sendSanchoMail("profil_update_response", ['topic' => $topic, 'status_de' => $status_translation->status_de, 'status_en' => $status_translation->status_en, 'href' => APP_ROOT . 'Cis/Profil'], $email, ("Profil Änderung " . $this->p->t('profilUpdate', 'pending')));
|
||||
if (!$mail_res) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_email_error'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function sendEmail_onProfilUpdate_insertion($uid, $profil_update_id, $topic)
|
||||
{
|
||||
if($this->config->item('cis_send_profil_update_mails') === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
$emails = [];
|
||||
|
||||
$isMitarbeiter_res = $this->MitarbeiterModel->isMitarbeiter($uid);
|
||||
if (isError($isMitarbeiter_res)) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_mitarbeiterCheck_error'));
|
||||
}
|
||||
$isMitarbeiter_res = getData($isMitarbeiter_res);
|
||||
|
||||
//! if the $uid is a mitarbeiter and student, only the hr is notified by email
|
||||
if ($isMitarbeiter_res) {
|
||||
//? user is not a student therefore he is a mitarbeiter, send email to Personalverwaltung
|
||||
//? use constant variable MAIL_GST to mail to the personalverwaltung
|
||||
$this->MitarbeiterModel->addSelect([TRUE]);
|
||||
$this->MitarbeiterModel->addJoin("public.tbl_benutzer", "public.tbl_benutzer.uid = public.tbl_mitarbeiter.mitarbeiter_uid");
|
||||
//? check if the the userID is a mitarbeiter and if the benutzer is active
|
||||
$res = $this->MitarbeiterModel->loadWhere(["public.tbl_mitarbeiter.mitarbeiter_uid" => $uid, "public.tbl_benutzer.aktiv" => TRUE]);
|
||||
if (isError($res)) {
|
||||
show_error("was not able to query the mitarbeiter and benutzer by the uid: " . $uid);
|
||||
}
|
||||
if (hasData($res)) {
|
||||
array_push($emails, MAIL_GST);
|
||||
} else {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_mitarbeiterCheck_error'));
|
||||
}
|
||||
} else {
|
||||
//? if it is not a mitarbeiter, check whether it is a student and send email to studiengang
|
||||
$isStudent_res = $this->StudentModel->isStudent($uid);
|
||||
if (isError($isStudent_res)) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_studentCheck_error'));
|
||||
}
|
||||
$isStudent_res = getData($isStudent_res);
|
||||
if ($isStudent_res) {
|
||||
//? Send email to the Studiengangsassistentinnen
|
||||
$this->StudentModel->addSelect(["public.tbl_studiengang.email"]);
|
||||
$this->StudentModel->addJoin("public.tbl_benutzer", "public.tbl_benutzer.uid = public.tbl_student.student_uid");
|
||||
$this->StudentModel->addJoin("public.tbl_prestudent", "public.tbl_benutzer.person_id = public.tbl_prestudent.person_id");
|
||||
$this->StudentModel->addJoin("public.tbl_prestudentstatus", "public.tbl_prestudentstatus.prestudent_id = public.tbl_prestudent.prestudent_id");
|
||||
$this->StudentModel->addJoin("public.tbl_studiengang", "public.tbl_studiengang.studiengang_kz = public.tbl_prestudent.studiengang_kz");
|
||||
//* check if the benutzer itself is active
|
||||
//* check if the student status is Student or Diplomand (active students)
|
||||
$this->StudentModel->db->where_in("public.tbl_prestudentstatus.status_kurzbz", ['Student', 'Diplomand']);
|
||||
$res = $this->StudentModel->loadWhere(["public.tbl_benutzer.aktiv" => TRUE, "public.tbl_student.student_uid" => $uid]);
|
||||
if (isError($res)) {
|
||||
show_error(getData($res));
|
||||
} else {
|
||||
$res = hasData($res) ? getData($res) : [];
|
||||
foreach ($res as $emailObj) {
|
||||
array_push($emails, $emailObj->email);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$mail_res = [];
|
||||
//? sending email
|
||||
foreach ($emails as $email) {
|
||||
array_push($mail_res, sendSanchoMail("profil_update", ['uid' => $uid, 'topic' => $topic, 'href' => APP_ROOT . 'Cis/ProfilUpdate/id/' . $profil_update_id], $email, ("Profil Änderung von " . $uid)));
|
||||
}
|
||||
foreach ($mail_res as $m_res) {
|
||||
if (!$m_res) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_email_error'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function show($dms_id)
|
||||
{
|
||||
|
||||
$profil_update = $this->ProfilUpdateModel->loadWhere(['attachment_id' => $dms_id]);
|
||||
$profil_update = hasData($profil_update) ? getData($profil_update)[0] : null;
|
||||
|
||||
//? checks if an profil update exists with the dms_id requested from the user
|
||||
if ($profil_update) {
|
||||
if ($profil_update)
|
||||
{
|
||||
$is_mitarbeiter_profil_update = getData($this->MitarbeiterModel->isMitarbeiter($profil_update->uid));
|
||||
$is_student_profil_update = getData($this->StudentModel->isStudent($profil_update->uid));
|
||||
|
||||
@@ -230,7 +60,8 @@ class ProfilUpdate extends Auth_Controller
|
||||
$this->permissionlib->isBerechtigt('student/stammdaten:r') && $is_student_profil_update ||
|
||||
$this->permissionlib->isBerechtigt('mitarbeiter/stammdaten:r') && $is_mitarbeiter_profil_update ||
|
||||
$this->uid == $profil_update->uid
|
||||
) {
|
||||
)
|
||||
{
|
||||
// Get file to be downloaded from DMS
|
||||
$newFilename = $this->uid . "/document_" . $dms_id;
|
||||
$download = $this->dmslib->download($dms_id);
|
||||
@@ -239,576 +70,17 @@ class ProfilUpdate extends Auth_Controller
|
||||
|
||||
// Download file
|
||||
$this->outputFile(getData($download));
|
||||
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_permission_error'));
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_dms_error'));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function insertFile($replace)
|
||||
{
|
||||
$replace = json_decode($replace);
|
||||
|
||||
if (!count($_FILES)) {
|
||||
echo json_encode([]);
|
||||
return;
|
||||
}
|
||||
|
||||
//? if replace is set it contains the profil_update_id in which the attachment_id has to be replaced
|
||||
if (isset($replace)) {
|
||||
$this->ProfilUpdateModel->addSelect(["attachment_id"]);
|
||||
$profilUpdate = $this->ProfilUpdateModel->load([$replace]);
|
||||
if (isError($profilUpdate)) {
|
||||
return json_encode(error($this->p->t('profilUpdate', 'profilUpdate_loading_error')));
|
||||
}
|
||||
//? get the attachmentID
|
||||
$dms_id = hasData($profilUpdate) ? getData($profilUpdate)[0]->attachment_id : null;
|
||||
|
||||
//? delete old dms_file of Profil Update
|
||||
$this->deleteOldVersionFile($dms_id);
|
||||
}
|
||||
|
||||
|
||||
$files = $_FILES['files'];
|
||||
$file_count = count($files['name']);
|
||||
|
||||
$res = [];
|
||||
|
||||
for ($i = 0; $i < $file_count; $i++) {
|
||||
$_FILES['files']['name'] = $files['name'][$i];
|
||||
$_FILES['files']['type'] = $files['type'][$i];
|
||||
$_FILES['files']['tmp_name'] = $files['tmp_name'][$i];
|
||||
$_FILES['files']['error'] = $files['error'][$i];
|
||||
$_FILES['files']['size'] = $files['size'][$i];
|
||||
|
||||
$dms = [
|
||||
"kategorie_kurzbz" => "profil_aenderung",
|
||||
"version" => 0,
|
||||
"name" => $_FILES['files']['name'],
|
||||
"mimetype" => $_FILES['files']['type'],
|
||||
"beschreibung" => $this->uid . " Profil Änderung",
|
||||
"insertvon" => $this->uid,
|
||||
"insertamum" => "NOW()",
|
||||
];
|
||||
|
||||
$tmp_res = $this->dmslib->upload($dms, 'files', array("jpg", "png", "pdf"));
|
||||
|
||||
$tmp_res = hasData($tmp_res) ? getData($tmp_res) : null;
|
||||
array_push($res, $tmp_res);
|
||||
}
|
||||
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
|
||||
public function selectProfilRequest()
|
||||
{
|
||||
$_GET = json_decode($this->input->raw_input_stream, true);
|
||||
$uid = $this->input->get('uid');
|
||||
$id = $this->input->get('id');
|
||||
$whereClause = ['uid' => $this->uid];
|
||||
|
||||
if (isset($uid))
|
||||
$whereClause['uid'] = $uid;
|
||||
if (isset($id))
|
||||
$whereClause['id'] = $id;
|
||||
|
||||
$res = $this->ProfilUpdateModel->getProfilUpdatesWhere($whereClause);
|
||||
$res = hasData($res) ? getData($res) : null;
|
||||
echo json_encode($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getProfilRequestFiles()
|
||||
{
|
||||
$id = json_decode($this->input->raw_input_stream);
|
||||
|
||||
$this->ProfilUpdateModel->addSelect(["attachment_id"]);
|
||||
$attachmentID = $this->ProfilUpdateModel->load([$id]);
|
||||
if (isError($attachmentID)) {
|
||||
return json_encode(error($this->p->t('profilUpdate', 'profilUpdate_loading_error')));
|
||||
}
|
||||
//? get the attachmentID
|
||||
$dms_id = hasData($attachmentID) ? getData($attachmentID)[0]->attachment_id : null;
|
||||
|
||||
//? get the name to the file
|
||||
$this->DmsVersionModel->addSelect(["name", "dms_id"]);
|
||||
$attachment = $this->DmsVersionModel->load([$dms_id, 0]);
|
||||
if (isError($attachment)) {
|
||||
return json_encode(error($this->p->t('profilUpdate', 'profilUpdate_dmsVersion_error')));
|
||||
}
|
||||
$attachment = hasData($attachment) ? getData($attachment) : null;
|
||||
//? returns {name:..., dms_id:...}
|
||||
echo json_encode($attachment);
|
||||
}
|
||||
|
||||
public function insertProfilRequest()
|
||||
{
|
||||
|
||||
$json = json_decode($this->input->raw_input_stream);
|
||||
|
||||
$payload = $json->payload;
|
||||
$identifier = property_exists($json->payload, "kontakt_id") ? "kontakt_id" : (property_exists($json->payload, "adresse_id") ? "adresse_id" : null);
|
||||
|
||||
$data = ["topic" => $json->topic, "uid" => $this->uid, "requested_change" => json_encode($payload), "insertamum" => "NOW()", "insertvon" => $this->uid, "status" => self::$STATUS_PENDING ?: 'Pending'];
|
||||
|
||||
//? insert fileID in the dataset if sent with post request
|
||||
if (isset($json->fileID)) {
|
||||
$data['attachment_id'] = $json->fileID;
|
||||
|
||||
}
|
||||
|
||||
//? loops over all updateRequests from a user to validate if the new request is valid
|
||||
$res = $this->ProfilUpdateModel->getProfilUpdatesWhere(["uid" => $this->uid]);
|
||||
if (isError($res)) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_loading_error'));
|
||||
}
|
||||
$res = hasData($res) ? getData($res) : null;
|
||||
|
||||
//? the user cannot delete a zustelladresse/kontakt
|
||||
if (isset($payload->delete) && $payload->{$identifier == "kontakt_id" ? "zustellung" : "zustelladresse"}) {
|
||||
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_deleteZustellung_error')));
|
||||
return;
|
||||
}
|
||||
|
||||
//? if the user tries to delete a adresse, checks whether the adresse is a heimatadresse, if so an error is raised
|
||||
if (isset($payload->delete) && $identifier == "adresse_id") {
|
||||
$adr = $this->AdresseModel->load($payload->$identifier);
|
||||
$adr = getData($adr)[0];
|
||||
if ($adr->heimatadresse) {
|
||||
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_deleteZustellung_error')));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
$pending_changes = array_filter($res, function ($element) {
|
||||
return $element->status == (self::$STATUS_PENDING ?: "Pending");
|
||||
});
|
||||
|
||||
foreach ($pending_changes as $update_request) {
|
||||
$existing_change = $update_request->requested_change;
|
||||
|
||||
//? the user can add as many new kontakte/adressen as he likes
|
||||
if (!isset($payload->add) && property_exists($existing_change, $identifier) && property_exists($payload, $identifier) && $existing_change->$identifier == $payload->$identifier) {
|
||||
//? the kontakt_id / adresse_id of a change has to be unique
|
||||
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_changeTwice_error')));
|
||||
return;
|
||||
}
|
||||
|
||||
//? if it is not updating any kontakt/adresse, the topic has to be unique
|
||||
elseif (!$identifier && $update_request->topic == $json->topic) {
|
||||
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_changeTopicTwice_error', ['0' => $update_request->topic])));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$insertID = $this->ProfilUpdateModel->insert($data);
|
||||
|
||||
if (isError($insertID)) {
|
||||
show_error(getData($insertID));
|
||||
} else {
|
||||
$insertID = hasData($insertID) ? getData($insertID) : null;
|
||||
|
||||
//? sends emails to the correspondents of the $uid
|
||||
$this->sendEmail_onProfilUpdate_insertion($this->uid, $insertID, $json->topic);
|
||||
echo json_encode(success($insertID));
|
||||
}
|
||||
}
|
||||
|
||||
public function updateProfilRequest()
|
||||
{
|
||||
$json = json_decode($this->input->raw_input_stream);
|
||||
|
||||
$updateData = ["requested_change" => json_encode($json->payload), "updateamum" => "NOW()", "updatevon" => $this->uid];
|
||||
if (isset($json->fileID)) {
|
||||
$updateData['attachment_id'] = json_decode($json->fileID);
|
||||
}
|
||||
$updateID = $this->ProfilUpdateModel->update([$json->ID], $updateData);
|
||||
//? insert fileID in the dataset if sent with post request
|
||||
|
||||
if (isError($updateID)) {
|
||||
//catch error
|
||||
} else {
|
||||
$updateID = hasData($updateID) ? getData($updateID)[0] : null;
|
||||
//TODO: should an email be sent to the responsable people when the user changes his profil update
|
||||
echo json_encode(success($updateID));
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProfilRequest()
|
||||
{
|
||||
|
||||
$json = json_decode($this->input->raw_input_stream);
|
||||
$delete_res = $this->ProfilUpdateModel->delete([$json]);
|
||||
echo json_encode($delete_res);
|
||||
}
|
||||
|
||||
|
||||
public function getProfilUpdateWithPermission($status = null)
|
||||
{
|
||||
// early return if no status has been passed as argument
|
||||
if (!isset($status)) {
|
||||
echo json_encode($this->ProfilUpdateModel->getProfilUpdateWithPermission());
|
||||
return;
|
||||
}
|
||||
|
||||
// get the sprache of the user
|
||||
$sprachenIndex = $this->SpracheModel->loadWhere(["sprache" => getUserLanguage()]);
|
||||
$sprachenIndex = hasData($sprachenIndex) ? getData($sprachenIndex)[0]->index : null;
|
||||
|
||||
if (isset($sprachenIndex) && isset($status)) {
|
||||
// get the corresponding status kurz_bz primary key out of the translation
|
||||
$status = $this->ProfilUpdateStatusModel->execReadOnlyQuery("select * from public.tbl_profil_update_status where ? = ANY(bezeichnung_mehrsprachig)", [$status]);
|
||||
$status = hasData($status) ? getData($status)[0]->status_kurzbz : null;
|
||||
$res = $this->ProfilUpdateModel->getProfilUpdateWithPermission(isset($status) ? ['status' => $status] : null);
|
||||
|
||||
echo json_encode($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function getOE_from_student($student_uid)
|
||||
{
|
||||
|
||||
//? returns the oe_einheit eines Studenten
|
||||
$query = "SELECT public.tbl_studiengang.oe_kurzbz
|
||||
FROM public.tbl_student
|
||||
JOIN public.tbl_studiengang ON tbl_student.studiengang_kz = public.tbl_studiengang.studiengang_kz
|
||||
WHERE public.tbl_student.student_uid = ?;";
|
||||
|
||||
$res = $this->StudentModel->execReadOnlyQuery($query, [$student_uid]);
|
||||
if (!isSuccess($res)) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_loadingOE_error'));
|
||||
}
|
||||
$res = hasData($res) ? getData($res) : [];
|
||||
$res = array_map(
|
||||
function ($item) {
|
||||
return $item->oe_kurzbz;
|
||||
},
|
||||
$res
|
||||
);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
public function acceptProfilRequest()
|
||||
{
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
$id = $this->input->post('profil_update_id', true);
|
||||
$uid = $this->input->post('uid', true);
|
||||
|
||||
//? fetching person_id using UID
|
||||
$personID = $this->PersonModel->getByUid($uid);
|
||||
$personID = hasData($personID) ? getData($personID)[0]->person_id : null;
|
||||
$status_message = $this->input->post('status_message', true);
|
||||
$topic = $this->input->post('topic', true);
|
||||
|
||||
//! somehow the xss check converted boolean false to empty string
|
||||
$requested_change = $this->input->post('requested_change');
|
||||
|
||||
//! check for required information
|
||||
if (!isset($id) || !isset($uid) || !isset($personID) || !isset($requested_change) || !isset($topic)) {
|
||||
return json_encode(error($this->p->t('profilUpdate', 'profilUpdate_requiredInformation_error')));
|
||||
}
|
||||
|
||||
$is_mitarbeiter_profil_update = getData($this->MitarbeiterModel->isMitarbeiter($uid));
|
||||
$is_student_profil_update = getData($this->StudentModel->isStudent($uid));
|
||||
|
||||
|
||||
//? check if the permissions are set correctly
|
||||
if (
|
||||
$this->permissionlib->isBerechtigt('student/stammdaten', "suid", $this->getOE_from_student($uid)) && $is_student_profil_update ||
|
||||
$this->permissionlib->isBerechtigt('mitarbeiter/stammdaten', "suid") && $is_mitarbeiter_profil_update
|
||||
) {
|
||||
|
||||
if (is_array($requested_change) && array_key_exists("adresse_id", $requested_change)) {
|
||||
$insertID = $this->handleAdresse($requested_change, $personID);
|
||||
$insertID = hasData($insertID) ? getData($insertID) : null;
|
||||
if (isset($insertID)) {
|
||||
$requested_change['adresse_id'] = $insertID;
|
||||
$update_res = $this->updateRequestedChange($id, $requested_change);
|
||||
if (isError($update_res)) {
|
||||
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_address_error', [$insertID])));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (is_array($requested_change) && array_key_exists("kontakt_id", $requested_change)) {
|
||||
$insertID = $this->handleKontakt($requested_change, $personID);
|
||||
$insertID = hasData($insertID) ? getData($insertID) : null;
|
||||
if (isset($insertID)) {
|
||||
$requested_change['kontakt_id'] = $insertID;
|
||||
$update_res = $this->updateRequestedChange($id, $requested_change);
|
||||
if (isError($update_res)) {
|
||||
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_kontakt_error', [$insertID])));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
switch ($topic) {
|
||||
// mapping phrasen to database columns to make the update with the correct column names
|
||||
case self::$TOPICS['Titel']:
|
||||
$topic = "titelpre";
|
||||
break;
|
||||
case self::$TOPICS['Postnomen']:
|
||||
$topic = "titelpost";
|
||||
break;
|
||||
case self::$TOPICS['Vorname']:
|
||||
$topic = "vorname";
|
||||
break;
|
||||
case self::$TOPICS['Nachname']:
|
||||
$topic = "nachname";
|
||||
break;
|
||||
default:
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_topic_error', [$topic]));
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $this->PersonModel->update($personID, [$topic => $requested_change["value"]]);
|
||||
if (isError($result)) {
|
||||
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_insert_error')));
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->sendEmail_onProfilUpdate_response($uid, $topic, self::$STATUS_ACCEPTED);
|
||||
|
||||
echo json_encode($this->setStatusOnUpdateRequest($id, self::$STATUS_ACCEPTED, $status_message, $requested_change));
|
||||
} else {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_permission_error'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function denyProfilRequest()
|
||||
{
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
$id = $this->input->post('profil_update_id', true);
|
||||
$uid = $this->input->post('uid', true);
|
||||
$topic = $this->input->post('topic', true);
|
||||
$status_message = $this->input->post('status_message', true);
|
||||
|
||||
$is_mitarbeiter_profil_update = getData($this->MitarbeiterModel->isMitarbeiter($uid));
|
||||
$is_student_profil_update = getData($this->StudentModel->isStudent($uid));
|
||||
|
||||
|
||||
if (
|
||||
$this->permissionlib->isBerechtigt('student/stammdaten', "suid", $this->getOE_from_student($uid)) && $is_student_profil_update ||
|
||||
$this->permissionlib->isBerechtigt('mitarbeiter/stammdaten', "suid") && $is_mitarbeiter_profil_update
|
||||
) {
|
||||
$this->sendEmail_onProfilUpdate_response($uid, $topic, self::$STATUS_REJECTED);
|
||||
echo json_encode($this->setStatusOnUpdateRequest($id, self::$STATUS_REJECTED, $status_message));
|
||||
} else {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_permission_error'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function updateRequestedChange($id, $requested_change)
|
||||
{
|
||||
return $this->ProfilUpdateModel->update([$id], ['requested_change' => json_encode($requested_change)]);
|
||||
}
|
||||
|
||||
private function setStatusOnUpdateRequest($id, $status, $status_message)
|
||||
{
|
||||
return $this->ProfilUpdateModel->update([$id], ["status" => $status, "status_timestamp" => "NOW()", "status_message" => $status_message]);
|
||||
}
|
||||
|
||||
private function deleteOldVersionFile($dms_id)
|
||||
{
|
||||
if (!isset($dms_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//? collect all the results of the deleted versions in an array
|
||||
$res = array();
|
||||
|
||||
//? delete all the different versions of the dms_file
|
||||
$dmsVersions = $this->DmsVersionModel->loadWhere(["dms_id" => $dms_id]);
|
||||
$dmsVersions = hasData($dmsVersions) ? getData($dmsVersions) : null;
|
||||
if (isset($dmsVersions)) {
|
||||
$zwischen_res = array_map(function ($item) {
|
||||
return $item->version;
|
||||
}, $dmsVersions);
|
||||
foreach ($zwischen_res as $version) {
|
||||
array_push($res, $this->DmsVersionModel->delete([$dms_id, $version]));
|
||||
}
|
||||
} else {
|
||||
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_dmsVersion_error')));
|
||||
}
|
||||
|
||||
//? returns a result for each deleted dms_file
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
private function handleKontakt($requested_change, $personID)
|
||||
{
|
||||
$kontakt_id = $requested_change["kontakt_id"];
|
||||
//? removes the kontakt_id because we don't want to update the kontakt_id in the database
|
||||
unset($requested_change["kontakt_id"]);
|
||||
|
||||
|
||||
//! ADD
|
||||
if (array_key_exists('add', $requested_change) && $requested_change['add']) {
|
||||
//? removes add flag
|
||||
unset($requested_change['add']);
|
||||
$requested_change['person_id'] = $personID;
|
||||
$requested_change['insertamum'] = "NOW()";
|
||||
$requested_change['insertvon'] = getAuthUID();
|
||||
$insertID = $this->KontaktModel->insert($requested_change);
|
||||
$insert_kontakt_id = $insertID;
|
||||
if (isError($insert_kontakt_id)) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_insertKontakt_error'));
|
||||
}
|
||||
$insert_kontakt_id = hasData($insert_kontakt_id) ? getData($insert_kontakt_id) : null;
|
||||
if ($insert_kontakt_id) {
|
||||
$this->handleDupplicateZustellKontakte($requested_change['zustellung'], $insert_kontakt_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//! DELETE
|
||||
elseif (array_key_exists('delete', $requested_change) && $requested_change['delete']) {
|
||||
$this->KontaktModel->delete($kontakt_id);
|
||||
}
|
||||
//! UPDATE
|
||||
else {
|
||||
$requested_change['updateamum'] = "NOW()";
|
||||
$requested_change['updatevon'] = getAuthUID();
|
||||
|
||||
$update_kontakt_id = $this->KontaktModel->update($kontakt_id, $requested_change);
|
||||
|
||||
if (isError($update_kontakt_id)) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_updateKontakt_error'));
|
||||
}
|
||||
$update_kontakt_id = hasData($update_kontakt_id) ? getData($update_kontakt_id) : null;
|
||||
if ($update_kontakt_id) {
|
||||
$this->handleDupplicateZustellKontakte($requested_change['zustellung'], $update_kontakt_id);
|
||||
}
|
||||
}
|
||||
return isset($insertID) ? $insertID : null;
|
||||
}
|
||||
|
||||
private function handleAdresse($requested_change, $personID)
|
||||
{
|
||||
|
||||
$this->AdressenTypModel->addSelect(["adressentyp_kurzbz"]);
|
||||
$adr_kurzbz = $this->AdressenTypModel->loadWhere(["bezeichnung" => $requested_change['typ']]);
|
||||
$adr_kurzbz = hasData($adr_kurzbz) ? getData($adr_kurzbz)[0]->adressentyp_kurzbz : null;
|
||||
//? replace the address_typ with its correct kurzbz foreign key
|
||||
$requested_change['typ'] = $adr_kurzbz;
|
||||
|
||||
$adresse_id = $requested_change["adresse_id"];
|
||||
//? removes the adresse_id because we don't want to update the kontakt_id in the database
|
||||
unset($requested_change["adresse_id"]);
|
||||
|
||||
|
||||
//! ADD
|
||||
if (array_key_exists('add', $requested_change) && $requested_change['add']) {
|
||||
|
||||
//? removes add flag
|
||||
unset($requested_change['add']);
|
||||
$requested_change['insertamum'] = "NOW()";
|
||||
$requested_change['insertvon'] = getAuthUID();
|
||||
$requested_change['person_id'] = $personID;
|
||||
//TODO: zustelladresse, heimatadresse, rechnungsadresse und nation werden nicht beachtet
|
||||
$insertID = $this->AdresseModel->insert($requested_change);
|
||||
$insert_adresse_id = $insertID;
|
||||
if (isError($insert_adresse_id)) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_insertAdresse_error'));
|
||||
}
|
||||
$insert_adresse_id = hasData($insert_adresse_id) ? getData($insert_adresse_id) : null;
|
||||
if ($insert_adresse_id) {
|
||||
$this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $insert_adresse_id);
|
||||
}
|
||||
|
||||
}
|
||||
//! DELETE
|
||||
elseif (array_key_exists('delete', $requested_change) && $requested_change['delete']) {
|
||||
$this->AdresseModel->delete($adresse_id);
|
||||
}
|
||||
//! UPDATE
|
||||
else {
|
||||
$requested_change['updateamum'] = "NOW()";
|
||||
$requested_change['updatevon'] = getAuthUID();
|
||||
$update_adresse_id = $this->AdresseModel->update($adresse_id, $requested_change);
|
||||
if (isError($update_adresse_id)) {
|
||||
show_error($this->p->t('profilUpdate', 'profilUpdate_updateAdresse_error'));
|
||||
}
|
||||
$update_adresse_id = hasData($update_adresse_id) ? getData($update_adresse_id) : null;
|
||||
if ($update_adresse_id) {
|
||||
$this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $update_adresse_id);
|
||||
}
|
||||
}
|
||||
return isset($insertID) ? $insertID : null;
|
||||
}
|
||||
|
||||
|
||||
private function handleDupplicateZustellKontakte($zustellung, $kontakt_id)
|
||||
{
|
||||
if ($zustellung) {
|
||||
$this->PersonModel->addSelect("public.tbl_kontakt.kontakt_id");
|
||||
$this->PersonModel->addJoin("public.tbl_kontakt", "public.tbl_kontakt.person_id = public.tbl_person.person_id");
|
||||
$zustellKontakteArray = $this->PersonModel->loadWhere(["public.tbl_person.person_id" => $this->pid, "zustellung" => TRUE]);
|
||||
if (!isSuccess($zustellKontakteArray)) {
|
||||
return error($this->p->t('profilUpdate', 'profilUpdate_loadingZustellkontakte_error'));
|
||||
}
|
||||
$zustellKontakteArray = hasData($zustellKontakteArray) ? getData($zustellKontakteArray) : null;
|
||||
|
||||
if ($zustellung && count($zustellKontakteArray) > 0) {
|
||||
$zustellKontakteArray = array_filter($zustellKontakteArray, function ($kontakt) use ($kontakt_id) {
|
||||
return $kontakt->kontakt_id != $kontakt_id;
|
||||
});
|
||||
foreach ($zustellKontakteArray as $kontakt) {
|
||||
$this->KontaktModel->update($kontakt->kontakt_id, ["zustellung" => FALSE]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function handleDupplicateZustellAdressen($zustellung, $adresse_id)
|
||||
{
|
||||
if ($zustellung) {
|
||||
$this->PersonModel->addSelect("public.tbl_adresse.adresse_id");
|
||||
$this->PersonModel->addJoin("public.tbl_adresse", "public.tbl_adresse.person_id = public.tbl_person.person_id");
|
||||
$zustellAdressenArray = $this->PersonModel->loadWhere(["public.tbl_person.person_id" => $this->pid, "zustelladresse" => TRUE]);
|
||||
if (!isSuccess($zustellAdressenArray)) {
|
||||
return error($this->p->t('profilUpdate', 'profilUpdate_loadingZustellAdressen_error'));
|
||||
}
|
||||
$zustellAdressenArray = hasData($zustellAdressenArray) ? getData($zustellAdressenArray) : null;
|
||||
|
||||
if ($zustellung && count($zustellAdressenArray) > 0) {
|
||||
|
||||
$zustellAdressenArray = array_filter($zustellAdressenArray, function ($adresse) use ($adresse_id) {
|
||||
|
||||
return $adresse->adresse_id != $adresse_id;
|
||||
});
|
||||
foreach ($zustellAdressenArray as $adresse) {
|
||||
$this->AdresseModel->update($adresse->adresse_id, ["zustelladresse" => FALSE]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Stundenplan extends Auth_Controller
|
||||
class Raumsuche extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
@@ -25,11 +25,11 @@ class Stundenplan extends Auth_Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
|
||||
$viewData = array(
|
||||
'uid'=>getAuthUID(),
|
||||
);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'Stundenplan']);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'Raumsuche']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class Studium extends Auth_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => ['basis/cis:r'],
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
|
||||
/**
|
||||
* index loads the Studium view
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$viewData = array(
|
||||
|
||||
);
|
||||
$this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'studium']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -17,6 +17,9 @@ class Cis4 extends Auth_Controller
|
||||
'index' => 'basis/cis:r'
|
||||
)
|
||||
);
|
||||
|
||||
// Load Config
|
||||
$this->load->config('calendar');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
@@ -27,15 +30,16 @@ class Cis4 extends Auth_Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('person/Person_model','PersonModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$personData = getData($this->PersonModel->getByUid(getAuthUID()))[0];
|
||||
|
||||
$viewData = array(
|
||||
'uid' => getAuthUID(),
|
||||
'name' => $personData->vorname,
|
||||
'person_id' => $personData->person_id
|
||||
'person_id' => $personData->person_id,
|
||||
'timezone' => $this->config->item('timezone')
|
||||
);
|
||||
|
||||
$this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'FhcDashboard']);
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'FhcDashboard']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +87,14 @@ class Cms extends Auth_Controller
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData'=>$viewData, 'route' => 'News']);
|
||||
}
|
||||
|
||||
public function getRoomInformation($ort_kurzbz){
|
||||
public function getRoomInformation($ort_kurzbz)
|
||||
{
|
||||
// Load Config
|
||||
$this->load->config('calendar');
|
||||
|
||||
$viewData = array(
|
||||
'ort_kurzbz' => $ort_kurzbz
|
||||
'ort_kurzbz' => $ort_kurzbz,
|
||||
'timezone' => $this->config->item('timezone')
|
||||
);
|
||||
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'CmsRoom']);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class LVVerwaltung extends Auth_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$permissions = [];
|
||||
|
||||
$router = load_class('Router');
|
||||
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
|
||||
parent::__construct($permissions);
|
||||
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function _remap()
|
||||
{
|
||||
$this->load->view('LVVerwaltung', [
|
||||
'permissions' => [
|
||||
'lehre/lehrveranstaltung' => $this->permissionlib->isBerechtigt('lehre/lehrveranstaltung'),
|
||||
'lv-plan/gruppenentfernen' => $this->permissionlib->isBerechtigt('lv-plan/gruppenentfernen'),
|
||||
'lv-plan/lektorentfernen' => $this->permissionlib->isBerechtigt('lv-plan/lektorentfernen'),
|
||||
],
|
||||
'variables' => [
|
||||
'semester_aktuell' => $this->variablelib->getVar('semester_aktuell')
|
||||
],
|
||||
'configs' => [
|
||||
'showVertragsdetails' => defined('FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN') && FAS_LV_LEKTORINNENZUTEILUNG_VERTRAGSDETAILS_ANZEIGEN,
|
||||
'showGewichtung' => defined('CIS_GESAMTNOTE_GEWICHTUNG') && CIS_GESAMTNOTE_GEWICHTUNG,
|
||||
'lehreinheitAnmerkungDefault' => defined('LEHREINHEIT_ANMERKUNG_DEFAULT') ? LEHREINHEIT_ANMERKUNG_DEFAULT : '',
|
||||
'lehreinheitRaumtypDefault' => defined('DEFAULT_LEHREINHEIT_RAUMTYP') ? DEFAULT_LEHREINHEIT_RAUMTYP : '',
|
||||
'lehreinheitRaumtypAlternativeDefault' => defined('DEFAULT_LEHREINHEIT_RAUMTYP_ALTERNATIV') ? DEFAULT_LEHREINHEIT_RAUMTYP_ALTERNATIV : ''
|
||||
]
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class NeueNachricht extends Auth_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$permissions = [];
|
||||
$router = load_class('Router');
|
||||
$permissions[$router->method] = ['vertrag/mitarbeiter:r'];
|
||||
parent::__construct($permissions);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function _remap()
|
||||
{
|
||||
//now working
|
||||
$this->load->view('Nachrichten', [
|
||||
'permissions' => [
|
||||
'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'),
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class AuthInfo extends FHCAPI_Controller
|
||||
{
|
||||
protected $uid;
|
||||
protected $pid;
|
||||
protected $isMitarbeiter;
|
||||
protected $isStudent;
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
@@ -28,10 +32,16 @@ class AuthInfo extends FHCAPI_Controller
|
||||
{
|
||||
parent::__construct([
|
||||
'getAuthUID' => self::PERM_LOGGED,
|
||||
'getAuthInfo' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
|
||||
$this->uid = getAuthUID();
|
||||
$this->pid = getAuthPersonID();
|
||||
$this->isMitarbeiter = getData($this->MitarbeiterModel->isMitarbeiter($this->uid)) ?? false;
|
||||
$this->isStudent = getData($this->StudentModel->isStudent($this->uid)) ?? false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
@@ -47,6 +57,14 @@ class AuthInfo extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess(['uid'=>$this->uid]);
|
||||
}
|
||||
|
||||
|
||||
public function getAuthInfo()
|
||||
{
|
||||
$data = (object) array(
|
||||
'uid' => $this->uid,
|
||||
'isMitarbeiter' => $this->isMitarbeiter,
|
||||
'isStudent' => $this->isStudent
|
||||
);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ class Documents extends FHCAPI_Controller
|
||||
parent::__construct([
|
||||
'permissionAlternativeFormat' => self::PERM_LOGGED,
|
||||
'archive' => ['admin:rw', 'assistenz:rw'],
|
||||
'archiveSigned' => ['admin:rw', 'assistenz:rw']
|
||||
'archiveSigned' => ['admin:rw', 'assistenz:rw'],
|
||||
'download' => ['admin:rw', 'assistenz:rw']
|
||||
]);
|
||||
|
||||
// Load Phrases
|
||||
@@ -66,7 +67,7 @@ class Documents extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a not signed document.
|
||||
* Archive a not signed document.
|
||||
*
|
||||
* @param string $xml (optional)
|
||||
* @param string $xsl (optional)
|
||||
@@ -79,7 +80,7 @@ class Documents extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a signed document.
|
||||
* Archive a signed document.
|
||||
*
|
||||
* @param string $xml (optional)
|
||||
* @param string $xsl (optional)
|
||||
@@ -91,6 +92,42 @@ class Documents extends FHCAPI_Controller
|
||||
return $this->_archive($xml, $xsl, getAuthUID());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function download($xml, $xsl, $sign_user = null)
|
||||
{
|
||||
$akteExportData = $this->_getAkteExportData($xml, $xsl, $sign_user);
|
||||
|
||||
$akteData = $akteData['akteData'];
|
||||
$exportData = $akteData['exportData'];
|
||||
|
||||
/**
|
||||
* [
|
||||
'vorlage' => $vorlage,
|
||||
'xml_data' => $data,
|
||||
'oe_kurzbz' => $xsl_oe_kurzbz,
|
||||
'version' => $version,
|
||||
'outputformat' => $outputformat,
|
||||
'sign_user' => $sign_user
|
||||
]
|
||||
*/
|
||||
|
||||
// Output
|
||||
$result = $this->documentexportlib->showContent(
|
||||
$akteData['akteData']['inhalt'],
|
||||
$exportData['vorlage'],
|
||||
$exportData['xml_data'],
|
||||
$exportData['oe_kurzbz'],
|
||||
$exportData['version'],
|
||||
$exportData['outputformat'],
|
||||
$exportData['sign_user']
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for archive() and archiveSigned()
|
||||
*
|
||||
@@ -100,16 +137,36 @@ class Documents extends FHCAPI_Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function _archive($xml, $xsl, $sign_user = null)
|
||||
private function _archive($xml, $xsl, $sign_user = null)
|
||||
{
|
||||
$akteData = $this->_getAkteExportData($xml, $xsl, $sign_user);
|
||||
|
||||
$this->load->model('crm/Akte_model', 'AkteModel');
|
||||
$result = $this->AkteModel->insert($akteData['akteData']);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $xml
|
||||
* @param string $xsl
|
||||
* @param string $sign_user (optional)
|
||||
*
|
||||
* @return array with Akte data and export data
|
||||
*/
|
||||
private function _getAkteExportData($xml, $xsl, $sign_user = null)
|
||||
{
|
||||
if (!$xml || !$xsl) {
|
||||
$this->load->library('form_validation');
|
||||
if (!$xml) {
|
||||
$xml = $this->input->post_get('xml');
|
||||
$this->addMeta('xml', $xml);
|
||||
$this->form_validation->set_rules('xml', 'xml', 'required');
|
||||
}
|
||||
if (!$xsl) {
|
||||
$xsl = $this->input->post_get('xsl');
|
||||
$this->addMeta('xsl', $xsl);
|
||||
$this->form_validation->set_rules('xsl', 'xsl', 'required');
|
||||
}
|
||||
|
||||
@@ -151,6 +208,7 @@ class Documents extends FHCAPI_Controller
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
|
||||
$result = $this->VorlageModel->load($xsl);
|
||||
$this->addMeta("ress", $result);
|
||||
$vorlage = current($this->getDataOrTerminateWithError($result));
|
||||
if (!$vorlage)
|
||||
show_404();
|
||||
@@ -171,12 +229,13 @@ class Documents extends FHCAPI_Controller
|
||||
$studiengang_kz = null;
|
||||
if ($akteData['uid']) {
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->StudentModel->addSelect('tbl_student.*, UPPER(typ || kurzbz) AS kuerzel');
|
||||
$this->StudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz', 'LEFT');
|
||||
$result = $this->StudentModel->load([$akteData['uid']]);
|
||||
$student = current($this->getDataOrTerminateWithError($result));
|
||||
|
||||
$ss = $this->input->post_get('ss');
|
||||
|
||||
|
||||
if ($ss !== null) {
|
||||
$this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$result = $this->PrestudentstatusModel->getLastStatus($student->prestudent_id, $ss);
|
||||
@@ -275,7 +334,7 @@ class Documents extends FHCAPI_Controller
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz', 'LEFT');
|
||||
$result = $this->PrestudentModel->load($prestudent_id);
|
||||
$prestudent = current($this->getDataOrTerminateWithError($result));
|
||||
|
||||
|
||||
$studiengang_kz = $prestudent->studiengang_kz;
|
||||
$akteData['person_id'] = $prestudent->person_id;
|
||||
$akteData['titel'] = mb_substr($xsl . "_" . $prestudent->kuerzel, 0, 64);
|
||||
@@ -318,9 +377,10 @@ class Documents extends FHCAPI_Controller
|
||||
|
||||
$result = $this->VorlagestudiengangModel->getCurrent($xsl, $xsl_oe_kurzbz, $version);
|
||||
$access_rights = current($this->getDataOrTerminateWithError($result));
|
||||
// TODO: was bedeutet wenn keine berechtigung?
|
||||
if (!$access_rights || !$access_rights->berechtigung)
|
||||
return show_404();
|
||||
|
||||
|
||||
$allowed = false;
|
||||
foreach ($access_rights->berechtigung as $access_right) {
|
||||
if ($this->permissionlib->isBerechtigt($access_right)) {
|
||||
@@ -394,11 +454,11 @@ class Documents extends FHCAPI_Controller
|
||||
|
||||
if (!$vorlage->archivierbar)
|
||||
$this->terminateWithError($this->p->t("stv", "grades_error_archive"));
|
||||
|
||||
|
||||
if ($sign_user && !$vorlage->signierbar)
|
||||
$this->terminateWithError($this->p->t("stv", "grades_error_sign"));
|
||||
|
||||
|
||||
|
||||
$this->load->library('DocumentExportLib');
|
||||
|
||||
// XML Data
|
||||
@@ -413,10 +473,17 @@ class Documents extends FHCAPI_Controller
|
||||
$akteData['titel'] .= '.pdf';
|
||||
$akteData['inhalt'] = base64_encode($content);
|
||||
|
||||
$this->load->model('crm/Akte_model', 'AkteModel');
|
||||
$result = $this->AkteModel->insert($akteData);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
return [
|
||||
'akteData' => $akteData,
|
||||
'exportData' =>
|
||||
[
|
||||
'vorlage' => $vorlage,
|
||||
'xml_data' => $data,
|
||||
'oe_kurzbz' => $xsl_oe_kurzbz,
|
||||
'version' => $version,
|
||||
'outputformat' => $outputformat,
|
||||
'sign_user' => $sign_user
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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 languages
|
||||
* This controller works with JSON calls on the HTTP GET and the output is always JSON
|
||||
*/
|
||||
class Language extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'get' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('system/Sprache_model', 'SpracheModel');
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
$this->SpracheModel->addOrder('sprache');
|
||||
|
||||
$result = $this->SpracheModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,14 @@
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
//require_once('../../../include/studiengang.class.php');
|
||||
//require_once('../../../include/student.class.php');
|
||||
//require_once('../../../include/datum.class.php');
|
||||
//require_once('../../../include/mail.class.php');
|
||||
//require_once('../../../include/benutzerberechtigung.class.php');
|
||||
//require_once('../../../include/phrasen.class.php');
|
||||
//require_once('../../../include/projektarbeit.class.php');
|
||||
//require_once('../../../include/projektbetreuer.class.php');
|
||||
|
||||
class Lehre extends FHCAPI_Controller
|
||||
{
|
||||
@@ -31,10 +39,33 @@ class Lehre extends FHCAPI_Controller
|
||||
'lvStudentenMail' => self::PERM_LOGGED,
|
||||
'LV' => self::PERM_LOGGED,
|
||||
'Pruefungen' => self::PERM_LOGGED,
|
||||
'getStudentProjektarbeiten' => self::PERM_LOGGED, // TODO: abgabetool berechtigung?
|
||||
'getStudentProjektabgaben' => self::PERM_LOGGED,
|
||||
'postStudentProjektarbeitZwischenabgabe' => self::PERM_LOGGED,
|
||||
'postStudentProjektarbeitEndupload' => self::PERM_LOGGED,
|
||||
'getMitarbeiterProjektarbeiten' => self::PERM_LOGGED,
|
||||
'postProjektarbeitAbgabe' => self::PERM_LOGGED,
|
||||
'deleteProjektarbeitAbgabe' => self::PERM_LOGGED,
|
||||
'postSerientermin' => self::PERM_LOGGED,
|
||||
'fetchDeadlines' => self::PERM_LOGGED // TODO: mitarbeiter recht prüfen
|
||||
]);
|
||||
|
||||
|
||||
$this->load->library('PhrasesLib');
|
||||
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui',
|
||||
'abgabetool'
|
||||
)
|
||||
);
|
||||
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
|
||||
require_once(FHCPATH . 'include/studiengang.class.php');
|
||||
require_once(FHCPATH . 'include/student.class.php');
|
||||
require_once(FHCPATH . 'include/projektarbeit.class.php');
|
||||
require_once(FHCPATH . 'include/projektbetreuer.class.php');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
@@ -94,10 +125,557 @@ class Lehre extends FHCAPI_Controller
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches all projektabgabetermine for a given projektarbeit_id used in cis4 student abgabetool
|
||||
*/
|
||||
public function getStudentProjektabgaben() {
|
||||
$projektarbeit_id = $this->input->get("projektarbeit_id",TRUE);
|
||||
|
||||
// TODO: error messages
|
||||
|
||||
if (!isset($projektarbeit_id) || isEmptyString($projektarbeit_id))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
$projektarbeit_obj = new projektarbeit();
|
||||
if($projektarbeit_id==-1)
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
if(!$projektarbeit_obj->load($projektarbeit_id))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
$paIsCurrent = $projektarbeit_obj->projektarbeitIsCurrent($projektarbeit_id);
|
||||
|
||||
$this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
|
||||
$ret = $this->ProjektarbeitModel->getProjektarbeitAbgabetermine($projektarbeit_id);
|
||||
|
||||
// TODO: fetch zweitbetreuer
|
||||
|
||||
$this->terminateWithSuccess(array($ret, $paIsCurrent));
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches all projektarbeiten and betreuer for a given student_uid used in cis4 student abgabetool
|
||||
*/
|
||||
public function getStudentProjektarbeiten($uid)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
|
||||
|
||||
if (!isset($uid) || isEmptyString($uid))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
$isZugeteilterBetreuer = count($this->ProjektarbeitModel->checkZuordnung($uid, getAuthUID())->retval) > 0;
|
||||
$this->addMeta('isZugeteilterBetreuer', $isZugeteilterBetreuer);
|
||||
$isMitarbeiter = $this->MitarbeiterModel->isMitarbeiter(getAuthUID());
|
||||
|
||||
if ($isMitarbeiter && $isZugeteilterBetreuer){
|
||||
$projektarbeiten = $this->ProjektarbeitModel->getStudentProjektarbeitenWithBetreuer($uid);
|
||||
} else {
|
||||
$projektarbeiten = $this->ProjektarbeitModel->getStudentProjektarbeitenWithBetreuer(getAuthUID());
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess(array($projektarbeiten, DOMAIN, $uid));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* projektarbeit - upload for zwischenabgaben in cis4 student abgabetool
|
||||
*/
|
||||
public function postStudentProjektarbeitZwischenabgabe()
|
||||
{
|
||||
|
||||
$projektarbeit_id = $_POST['projektarbeit_id'];
|
||||
$paabgabe_id = $_POST['paabgabe_id'];
|
||||
$student_uid = $_POST['student_uid'];
|
||||
$bperson_id = $_POST['bperson_id'];
|
||||
$paabgabetyp_kurzbz = $_POST['paabgabetyp_kurzbz'];
|
||||
|
||||
if (!isset($projektarbeit_id) || isEmptyString($projektarbeit_id)
|
||||
|| !isset($paabgabe_id) || isEmptyString($paabgabe_id)
|
||||
|| !isset($student_uid) || isEmptyString($student_uid)
|
||||
|| !isset($paabgabetyp_kurzbz) || isEmptyString($paabgabetyp_kurzbz))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
if ((isset($_FILES) and isset($_FILES['file']) and ! $_FILES['file']['error'])) {
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], PAABGABE_PATH.$paabgabe_id.'_'.$student_uid.'.pdf');
|
||||
|
||||
if(file_exists(PAABGABE_PATH.$paabgabe_id.'_'.$student_uid.'.pdf')) {
|
||||
|
||||
exec('chmod 640 "'.PAABGABE_PATH.$paabgabe_id.'_'.$student_uid.'.pdf'.'"');
|
||||
|
||||
$this->load->model('education/Paabgabe_model', 'PaabgabeModel');
|
||||
$res = $this->PaabgabeModel->update($paabgabe_id, array(
|
||||
'abgabedatum' => date('Y-m-d'),
|
||||
'updatevon' => getAuthUID(),
|
||||
'updateamum' => date('Y-m-d H:i:s')
|
||||
));
|
||||
|
||||
$this->sendUploadEmail($bperson_id, $projektarbeit_id, $paabgabetyp_kurzbz, $student_uid);
|
||||
$this->terminateWithSuccess($res);
|
||||
} else {
|
||||
$this->terminateWithError('Error moving File');
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->terminateWithError('File missing');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* upload für finale abgaben aka Endupload in cis4 student abgabetool
|
||||
*/
|
||||
public function postStudentProjektarbeitEndupload()
|
||||
{
|
||||
|
||||
$projektarbeit_id = $_POST['projektarbeit_id'];
|
||||
$paabgabe_id = $_POST['paabgabe_id'];
|
||||
$student_uid = $_POST['student_uid'];
|
||||
$sprache = $_POST['sprache'];
|
||||
$abstract = $_POST['abstract'];
|
||||
$abstract_en = $_POST['abstract_en'];
|
||||
$schlagwoerter = $_POST['schlagwoerter'];
|
||||
$schlagwoerter_en = $_POST['schlagwoerter_en'];
|
||||
$seitenanzahl = $_POST['seitenanzahl'];
|
||||
$bperson_id = $_POST['bperson_id'];
|
||||
$paabgabetyp_kurzbz = $_POST['paabgabetyp_kurzbz'];
|
||||
|
||||
if (!isset($projektarbeit_id) || isEmptyString($projektarbeit_id)
|
||||
|| !isset($paabgabe_id) || isEmptyString($paabgabe_id)
|
||||
|| !isset($student_uid) || isEmptyString($student_uid)
|
||||
|| !isset($paabgabetyp_kurzbz) || isEmptyString($paabgabetyp_kurzbz))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
// TODO: maybe check for other params aswell?
|
||||
|
||||
if ((isset($_FILES) and isset($_FILES['file']) and ! $_FILES['file']['error'])) {
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], PAABGABE_PATH.$paabgabe_id.'_'.$student_uid.'.pdf');
|
||||
|
||||
if(file_exists(PAABGABE_PATH.$paabgabe_id.'_'.$student_uid.'.pdf')) {
|
||||
|
||||
// Loads Libraries
|
||||
$this->load->library('SignatureLib');
|
||||
|
||||
// Check if the document is signed
|
||||
$signaturVorhanden = true;
|
||||
$signList = SignatureLib::list(PAABGABE_PATH.$paabgabe_id.'_'.$student_uid.'.pdf');
|
||||
if (is_array($signList) && count($signList) > 0)
|
||||
{
|
||||
// The document is signed
|
||||
$uploadedDocumentSigned = 'The document is signed';
|
||||
}
|
||||
elseif ($signList === null)
|
||||
{
|
||||
$uploadedDocumentSigned = 'WARNING: signature server error';
|
||||
}
|
||||
else
|
||||
{
|
||||
$signaturVorhanden = false;
|
||||
$uploadedDocumentSigned = 'No document signature found';
|
||||
}
|
||||
$this->addMeta('signaturInfo', $uploadedDocumentSigned);
|
||||
|
||||
if ($signaturVorhanden === false)
|
||||
{
|
||||
$this->signaturFehltEmail($student_uid);
|
||||
}
|
||||
|
||||
// TODO error handle get data has data the updates
|
||||
// update projektarbeit cols
|
||||
$this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
|
||||
$this->ProjektarbeitModel->updateProjektarbeit($projektarbeit_id,$sprache,$abstract,$abstract_en
|
||||
,$schlagwoerter, $schlagwoerter_en, $seitenanzahl);
|
||||
|
||||
|
||||
// update paabgabe datum
|
||||
$this->load->model('education/Paabgabe_model', 'PaabgabeModel');
|
||||
$res = $this->PaabgabeModel->update($paabgabe_id, array(
|
||||
'abgabedatum' => date('Y-m-d'),
|
||||
'updatevon' => getAuthUID(),
|
||||
'updateamum' => date('Y-m-d H:i:s')
|
||||
));
|
||||
|
||||
$this->sendUploadEmail($bperson_id, $projektarbeit_id, $paabgabetyp_kurzbz, $student_uid);
|
||||
|
||||
$this->terminateWithSuccess($res);
|
||||
} else {
|
||||
$this->terminateWithError('Error moving File');
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->terminateWithError('File missing');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function signaturFehltEmail($student_uid) {
|
||||
|
||||
|
||||
// Mail an Studiengang wenn keine Signatur gefunden wurde
|
||||
$student = new student();
|
||||
if(!$student->load($student_uid))
|
||||
$this->terminateWithError($this->p->t('global','userNichtGefunden'), 'general');
|
||||
|
||||
$stg_obj = new studiengang();
|
||||
if(!$stg_obj->load($student->studiengang_kz))
|
||||
$this->terminateWithError($this->p->t('global','fehlerBeimLesenAusDatenbank'), 'general');
|
||||
|
||||
$subject = 'Abgabe ohne Signatur';
|
||||
$tomail = $stg_obj->email;
|
||||
$data = array(
|
||||
'vorname' => $student->vorname,
|
||||
'nachname' => $student->nachname,
|
||||
'studiengang' => $stg_obj->bezeichnung
|
||||
);
|
||||
|
||||
$mailres = sendSanchoMail(
|
||||
'ParbeitsbeurteilungSiganturFehlt',
|
||||
$data,
|
||||
$tomail,
|
||||
$subject,
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg'
|
||||
);
|
||||
}
|
||||
|
||||
private function sendUploadEmail($bperson_id, $projektarbeit_id, $paabgabetyp_kurzbz, $student_uid) {
|
||||
|
||||
$this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
|
||||
|
||||
$resBetr = $this->ProjektarbeitModel->getProjektbetreuerAnrede($bperson_id);
|
||||
|
||||
$projektarbeit_obj = new projektarbeit();
|
||||
|
||||
if(!$projektarbeit_obj->load($projektarbeit_id))
|
||||
$this->terminateWithError('Ungueltiger Eintrag');
|
||||
|
||||
$num_rows_sem = $projektarbeit_obj->projektarbeitIsCurrent($projektarbeit_id);
|
||||
|
||||
if( null === $num_rows_sem || false === $num_rows_sem )
|
||||
{
|
||||
$this->terminateWithError($this->p->t('abgabetool','fehlerAktualitaetProjektarbeit'), 'general');
|
||||
}
|
||||
|
||||
foreach($resBetr->retval as $betreuerRow) {
|
||||
|
||||
// query student benutzer view for every betreuer row
|
||||
$studentUser = $this->ProjektarbeitModel->getProjektarbeitBenutzer($student_uid)->retval[0];
|
||||
|
||||
// TODO: hasdata, getData etc
|
||||
|
||||
// 1. Begutachter mail ohne Token
|
||||
$mail_baselink = APP_ROOT."index.ci.php/extensions/FHC-Core-Projektarbeitsbeurteilung/ProjektarbeitsbeurteilungErstbegutachter";
|
||||
$mail_fulllink = "$mail_baselink?projektarbeit_id=".$projektarbeit_id."&uid=".$studentUser->uid;
|
||||
$projekttyp_kurzbz = $projektarbeit_obj->projekttyp_kurzbz;
|
||||
$subject = $projektarbeit_obj->projekttyp_kurzbz == 'Diplom' ? 'Masterarbeitsbetreuung' : 'Bachelorarbeitsbetreuung';
|
||||
$abgabetyp = $paabgabetyp_kurzbz == 'end' ? 'Endabgabe' : 'Zwischenabgabe';
|
||||
|
||||
$maildata = array();
|
||||
$maildata['geehrt'] = "geehrte".($betreuerRow->anrede=="Herr"?"r":"");
|
||||
$maildata['anrede'] = $betreuerRow->anrede;
|
||||
$maildata['betreuer_voller_name'] = $betreuerRow->first;
|
||||
$maildata['student_anrede'] = $studentUser->anrede;
|
||||
$maildata['student_voller_name'] = trim($studentUser->titelpre." ".$studentUser->vorname." ".$studentUser->nachname." ".$studentUser->titelpost);
|
||||
$maildata['abgabetyp'] = $abgabetyp;
|
||||
$maildata['parbeituebersichtlink'] = "<p><a href='".APP_ROOT."cis/private/lehre/abgabe_lektor_frameset.html'>Zur Projektarbeitsübersicht</a></p>";
|
||||
$maildata['bewertunglink'] = $num_rows_sem >= 1 && $paabgabetyp_kurzbz == 'end' ? "<p><a href='$mail_fulllink'>Zur Beurteilung der Arbeit</a></p>" : "";
|
||||
$maildata['token'] = "";
|
||||
|
||||
$mailres = sendSanchoMail(
|
||||
'ParbeitsbeurteilungEndupload',
|
||||
$maildata,
|
||||
$betreuerRow->mitarbeiter_uid."@".DOMAIN,
|
||||
$subject,
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg',
|
||||
get_uid()."@".DOMAIN);
|
||||
|
||||
if(!$mailres)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('abgabetool', 'fehlerMailBegutachter'), 'general');
|
||||
}
|
||||
|
||||
// 2. Begutachter mail, wenn Endabgabe, mit Token wenn extern
|
||||
if ($paabgabetyp_kurzbz == 'end')
|
||||
{
|
||||
// Zweitbegutachter holen
|
||||
$zweitbegutachter = new projektbetreuer();
|
||||
$zweitbegutachterRes = $zweitbegutachter->getZweitbegutachterWithToken($bperson_id, $projektarbeit_id, $studentUser->uid);
|
||||
|
||||
if ($zweitbegutachterRes)
|
||||
{
|
||||
$zweitbegutachterResults = $zweitbegutachter->result;
|
||||
|
||||
foreach ($zweitbegutachterResults as $begutachter)
|
||||
{
|
||||
// token generieren, wenn noch nicht vorhanden und notwendig (wird in methode überprüft)
|
||||
$tokenGenRes = $zweitbegutachter->generateZweitbegutachterToken($begutachter->person_id, $projektarbeit_id);
|
||||
|
||||
if (!$tokenGenRes)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('abgabetool', 'fehlerMailZweitBegutachter'), 'general');
|
||||
}
|
||||
|
||||
// Zweitbegutachter (evtl. mit Token) holen
|
||||
$zweitbegutachterMitToken = new projektbetreuer();
|
||||
$begutachterMitTokenRes = $zweitbegutachterMitToken->getZweitbegutachterWithToken($bperson_id, $projektarbeit_id, $studentUser->uid, $begutachter->person_id);
|
||||
|
||||
if (!$begutachterMitTokenRes)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('abgabetool', 'fehlerMailZweitBegutachter'), 'general');
|
||||
}
|
||||
|
||||
// Email an Zweitbegutachter senden
|
||||
if (isset($zweitbegutachterMitToken->result[0]))
|
||||
{
|
||||
$begutachterMitToken = $zweitbegutachterMitToken->result[0];
|
||||
|
||||
$path = $begutachterMitToken->betreuerart_kurzbz == 'Zweitbegutachter' ? 'ProjektarbeitsbeurteilungZweitbegutachter' : 'ProjektarbeitsbeurteilungErstbegutachter';
|
||||
$mail_baselink = APP_ROOT."index.ci.php/extensions/FHC-Core-Projektarbeitsbeurteilung/$path";
|
||||
$mail_fulllink = "$mail_baselink?projektarbeit_id=".$projektarbeit_id."&uid=".$studentUser->uid;
|
||||
$intern = isset($begutachterMitToken->uid);
|
||||
$mail_link = $intern ? $mail_fulllink : $mail_baselink;
|
||||
|
||||
$zweitbetmaildata = array();
|
||||
$zweitbetmaildata['geehrt'] = "geehrte" . ($begutachterMitToken->anrede == "Herr" ? "r" : "");
|
||||
$zweitbetmaildata['anrede'] = $begutachterMitToken->anrede;
|
||||
$zweitbetmaildata['betreuer_voller_name'] = $begutachterMitToken->voller_name;
|
||||
$zweitbetmaildata['student_anrede'] = $maildata['student_anrede'];
|
||||
$zweitbetmaildata['student_voller_name'] = $maildata['student_voller_name'];
|
||||
$zweitbetmaildata['abgabetyp'] = $abgabetyp;
|
||||
$zweitbetmaildata['parbeituebersichtlink'] = $intern ? $maildata['parbeituebersichtlink'] : "";
|
||||
$zweitbetmaildata['bewertunglink'] = $num_rows_sem >= 1 ? "<p><a href='$mail_link'>Zur Beurteilung der Arbeit</a></p>" : "";
|
||||
$zweitbetmaildata['token'] = $num_rows_sem >= 1 && isset($begutachterMitToken->zugangstoken) && !$intern ? "<p>Zugangstoken: " . $begutachterMitToken->zugangstoken . "</p>" : "";
|
||||
|
||||
$mailres = sendSanchoMail(
|
||||
'ParbeitsbeurteilungEndupload',
|
||||
$zweitbetmaildata,
|
||||
$begutachterMitToken->email,
|
||||
$subject,
|
||||
'sancho_header_min_bw.jpg',
|
||||
'sancho_footer_min_bw.jpg',
|
||||
get_uid()."@".DOMAIN
|
||||
);
|
||||
|
||||
if (!$mailres)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('abgabetool', 'fehlerMailBegutachter'), 'general');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getMitarbeiterProjektarbeiten() {
|
||||
$this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
|
||||
|
||||
$boolParamStr = $this->input->get('showall');
|
||||
$trueStrings = ['true', '1'];
|
||||
$falseStrings = ['false', '0'];
|
||||
|
||||
// Handle missing or invalid parameter
|
||||
if ($boolParamStr === null) {
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
}
|
||||
$boolParamStrLower = strtolower($boolParamStr);
|
||||
|
||||
if (in_array($boolParamStrLower, $trueStrings, true)) {
|
||||
$showAllBool = true;
|
||||
} elseif (in_array($boolParamStrLower, $falseStrings, true)) {
|
||||
$showAllBool = false;
|
||||
} else {
|
||||
// $this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
}
|
||||
|
||||
$projektarbeiten = $this->ProjektarbeitModel->getMitarbeiterProjektarbeiten(getAuthUID(), $showAllBool);
|
||||
|
||||
$this->terminateWithSuccess(array($projektarbeiten, DOMAIN));
|
||||
}
|
||||
|
||||
public function postProjektarbeitAbgabe() {
|
||||
$projektarbeit_id = $_POST['projektarbeit_id'];
|
||||
$paabgabe_id = $_POST['paabgabe_id'];
|
||||
$paabgabetyp_kurzbz = $_POST['paabgabetyp_kurzbz'];
|
||||
$datum = $_POST['datum'];
|
||||
$fixtermin = $_POST['fixtermin'];
|
||||
$kurzbz = $_POST['kurzbz'];
|
||||
|
||||
if (!isset($projektarbeit_id) || isEmptyString($projektarbeit_id)
|
||||
|| !isset($paabgabe_id) || isEmptyString($paabgabe_id)
|
||||
|| !isset($datum) || isEmptyString($datum)
|
||||
|| !isset($datum) || isEmptyString($datum)
|
||||
|| !isset($paabgabetyp_kurzbz) || isEmptyString($paabgabetyp_kurzbz))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
$this->load->model('education/Paabgabe_model', 'PaabgabeModel');
|
||||
|
||||
if($paabgabe_id == -1) {
|
||||
$result = $this->PaabgabeModel->insert(
|
||||
array(
|
||||
'projektarbeit_id' => $projektarbeit_id,
|
||||
'paabgabetyp_kurzbz' => $paabgabetyp_kurzbz,
|
||||
'fixtermin' => $fixtermin,
|
||||
'datum' => $datum,
|
||||
'kurzbz' => $kurzbz,
|
||||
'insertvon' => getAuthUID(),
|
||||
'insertamum' => date('Y-m-d H:i:s')
|
||||
)
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
} else {
|
||||
$result = $this->PaabgabeModel->update(
|
||||
$paabgabe_id,
|
||||
array(
|
||||
'paabgabetyp_kurzbz' => $paabgabetyp_kurzbz,
|
||||
'datum' => $datum,
|
||||
'kurzbz' => $kurzbz,
|
||||
'updatevon' => getAuthUID(),
|
||||
'updateamum' => date('Y-m-d H:i:s')
|
||||
)
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProjektarbeitAbgabe() {
|
||||
$paabgabe_id = $_POST['paabgabe_id'];
|
||||
|
||||
if (!isset($paabgabe_id) || isEmptyString($paabgabe_id))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
$this->load->model('education/Paabgabe_model', 'PaabgabeModel');
|
||||
|
||||
$result = $this->PaabgabeModel->load($paabgabe_id);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if(count($result) == 0)
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
// TODO: berechtigung?
|
||||
if($result[0]->insertvon === getAuthUID()) {
|
||||
$result = $this->PaabgabeModel->delete($paabgabe_id);
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
}
|
||||
|
||||
/**
|
||||
* endpoint for adding the same paabgabe for multiple projektarbeiten
|
||||
* can be slow for large n since it queries twice per projektarbeit_id
|
||||
*/
|
||||
public function postSerientermin() {
|
||||
$projektarbeit_ids = $_POST['projektarbeit_ids'];
|
||||
$datum = $_POST['datum'];
|
||||
$paabgabetyp_kurzbz = $_POST['paabgabetyp_kurzbz'];
|
||||
$bezeichnung = $_POST['bezeichnung'];
|
||||
$kurzbz = $_POST['kurzbz'];
|
||||
|
||||
if (!isset($projektarbeit_ids) || !is_array($projektarbeit_ids) || empty($projektarbeit_ids)
|
||||
|| !isset($datum) || isEmptyString($datum)
|
||||
|| !isset($kurzbz) || isEmptyString($kurzbz)
|
||||
|| !isset($bezeichnung) || isEmptyString($bezeichnung)
|
||||
|| !isset($paabgabetyp_kurzbz) || isEmptyString($paabgabetyp_kurzbz))
|
||||
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
|
||||
|
||||
// old script checks if there already are tbl_paabgabe entries with exact date, type & kurzbz
|
||||
// for each termin - good to check that in principle but should not matter in this place. if necessary
|
||||
// duplicate abgabetermine can be easily deleted manually, also via cronjob@night.
|
||||
|
||||
// since this entry includes the kurzbz string match, it should have only ever mattered when there were
|
||||
// multiple users entering the exact same set of (date, type, kurzbz) - which is a much more narrow case than the
|
||||
// general "saveMultiple" function should handle
|
||||
|
||||
// old script afterwards again queries if user is not the zweitbetreuer of any id - this is blocked in the ui
|
||||
// and should never unintentionally happen
|
||||
|
||||
// TODO: check berechtigung &/|| zuordnung?
|
||||
|
||||
$this->load->model('education/Paabgabe_model', 'PaabgabeModel');
|
||||
$this->load->model('education/Projektarbeit_model', 'ProjektarbeitModel');
|
||||
|
||||
$res = [];
|
||||
foreach ($projektarbeit_ids as $projektarbeit_id) {
|
||||
|
||||
$result = $this->PaabgabeModel->insert(
|
||||
array(
|
||||
'projektarbeit_id' => $projektarbeit_id,
|
||||
'paabgabetyp_kurzbz' => $paabgabetyp_kurzbz,
|
||||
'fixtermin' => false,
|
||||
'datum' => $datum,
|
||||
'kurzbz' => $kurzbz,
|
||||
'insertvon' => getAuthUID(),
|
||||
'insertamum' => date('Y-m-d H:i:s')
|
||||
)
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// $res[] = $data;
|
||||
|
||||
// send mail to student
|
||||
$result = $this->ProjektarbeitModel->getStudentInfoForProjektarbeitId($projektarbeit_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// $this->addMeta('emaildata'.$projektarbeit_id, $data);
|
||||
|
||||
$datetime = new DateTime($datum);
|
||||
$dateEmailFormatted = $datetime->format('d.m.Y');
|
||||
|
||||
$anredeFillString = $data[0]->anrede=="Herr"?"r":"";
|
||||
|
||||
$fullFormattedNameString = trim($data[0]->titelpre." ".$data[0]->vorname." ".$data[0]->nachname." ".$data[0]->titelpost);
|
||||
$res[] = $fullFormattedNameString;
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'anrede' => $data[0]->anrede,
|
||||
'anredeFillString' => $anredeFillString,
|
||||
'datum' => $dateEmailFormatted,
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'fullFormattedNameString' => $fullFormattedNameString,
|
||||
'kurzbz' => $kurzbz
|
||||
);
|
||||
|
||||
$email = $data[0]->uid."@".DOMAIN;
|
||||
|
||||
sendSanchoMail(
|
||||
'neuerAbgabetermin',
|
||||
$body_fields,
|
||||
$email,
|
||||
$this->p->t('abgabetool', 'neuerTerminBachelorMasterbetreuung')
|
||||
);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($res);
|
||||
|
||||
}
|
||||
|
||||
public function fetchDeadlines() {
|
||||
$person_id = $_POST['person_id'];
|
||||
|
||||
if (!isset($person_id) || isEmptyString($person_id))
|
||||
$person_id = getAuthPersonId();
|
||||
|
||||
|
||||
if($person_id !== getAuthPersonId()) {
|
||||
$this->load->library('PermissionLib');
|
||||
$isAdmin = $this->permissionlib->isBerechtigt('admin');
|
||||
if(!$isAdmin) $this->terminateWithError($this->p->t('ui', 'keineBerechtigung'), 'general');
|
||||
}
|
||||
|
||||
$this->load->model('education/Paabgabe_model', 'PaabgabeModel');
|
||||
$result = $this->PaabgabeModel->getDeadlines($person_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2025 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');
|
||||
|
||||
class Lehrveranstaltung extends FHCAPI_Controller
|
||||
{
|
||||
private $_ci;
|
||||
private $_uid;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getByEmp' => ['admin:r', 'assistenz:r'],
|
||||
'getByStg' => ['admin:r', 'assistenz:r'],
|
||||
'loadByLV' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
$this->_setAuthUID();
|
||||
|
||||
$this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $this->_uid]);
|
||||
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'ui'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getByEmp($studiensemester_kurzbz = null, $mitarbeiter_uid = null, $stg_kz = null)
|
||||
{
|
||||
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$studiensemester_kurzbz = $this->getStudiensemesterKurzbz($studiensemester_kurzbz);
|
||||
|
||||
$lehrveranstaltungen = $this->_ci->LehreinheitModel->getLvsByEmployee($mitarbeiter_uid, $studiensemester_kurzbz, $stg_kz);
|
||||
$lehrveranstaltungen_data = $this->getDataOrTerminateWithError($lehrveranstaltungen);
|
||||
|
||||
$tree = [];
|
||||
|
||||
foreach ($lehrveranstaltungen_data as $lehrveranstaltung)
|
||||
{
|
||||
$lehreinheiten = $this->_ci->LehreinheitModel->getByLvidStudiensemester($lehrveranstaltung->lehrveranstaltung_id, $studiensemester_kurzbz, $mitarbeiter_uid);
|
||||
$lehreinheiten_data = $this->getDataOrTerminateWithError($lehreinheiten);
|
||||
|
||||
if (!isset($lehrveranstaltung->_children))
|
||||
{
|
||||
$lehrveranstaltung->_children = $lehreinheiten_data;
|
||||
}
|
||||
$tree[] = $lehrveranstaltung;
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($tree);
|
||||
}
|
||||
public function getByStg($studiensemester_kurzbz = null, $studiengang_kz = null, $semester = null)
|
||||
{
|
||||
if (is_null($studiengang_kz) || !preg_match("/^-?[1-9][0-9]*$/", (string)$studiengang_kz))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$verband = null;
|
||||
if (!is_null($semester) && !is_numeric($semester))
|
||||
{
|
||||
$verband = $semester;
|
||||
$semester = null;
|
||||
}
|
||||
|
||||
$this->_ci->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
|
||||
$studiensemester_kurzbz = $this->getStudiensemesterKurzbz($studiensemester_kurzbz);
|
||||
$studienplan_data = $this->_ci->StudienplanModel->getStudienplaeneBySemester($studiengang_kz, $studiensemester_kurzbz, $semester, $verband);
|
||||
|
||||
$studienplan_ids = array();
|
||||
$only_ids = array();
|
||||
$placeholders = array();
|
||||
|
||||
if (hasData($studienplan_data))
|
||||
{
|
||||
foreach (getData($studienplan_data) as $studienplan) {
|
||||
$placeholders[] = "(?, ?)";
|
||||
$studienplan_ids[] = $studienplan->studienplan_id;
|
||||
$studienplan_ids[] = $studienplan->semester;
|
||||
$only_ids[] = $studienplan->studienplan_id;
|
||||
}
|
||||
}
|
||||
|
||||
$lehrveranstaltungen_data = $this->_ci->LehrveranstaltungModel->getLvsByStudiengang($studienplan_ids, $placeholders, $only_ids, $studiengang_kz, $studiensemester_kurzbz, $semester, $verband);
|
||||
$lehrveranstaltungen_data = hasData($lehrveranstaltungen_data) ? getData($lehrveranstaltungen_data) : array();
|
||||
|
||||
$tree = [];
|
||||
foreach ($lehrveranstaltungen_data as $row)
|
||||
{
|
||||
$rowData = $row;
|
||||
|
||||
$lehreinheiten_data = $this->_ci->LehreinheitModel->getByLvidStudiensemester($row->lehrveranstaltung_id, $studiensemester_kurzbz);
|
||||
|
||||
if (hasData($lehreinheiten_data))
|
||||
{
|
||||
$lehreinheiten = getData($lehreinheiten_data);
|
||||
$rowData->_children = $lehreinheiten;
|
||||
}
|
||||
|
||||
if (!isEmptyString($row->studienplan_lehrveranstaltung_id_parent))
|
||||
{
|
||||
$child = $this->_ci->StudienplanModel->loadStudienplanLehrveranstaltung($row->studienplan_lehrveranstaltung_id_parent);
|
||||
|
||||
if (hasData($child))
|
||||
{
|
||||
$child = getData($child)[0];
|
||||
$searchId = $child->lehrveranstaltung_id;
|
||||
|
||||
foreach ($lehrveranstaltungen_data as &$searchParent)
|
||||
{
|
||||
if ($searchParent->lehrveranstaltung_id === $searchId)
|
||||
{
|
||||
if (!isset($searchParent->_children))
|
||||
{
|
||||
$searchParent->_children = [];
|
||||
}
|
||||
|
||||
if (is_array($searchParent->_children))
|
||||
{
|
||||
$searchParent->_children[] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
$searchParent->_children = [$searchParent->_children, $row];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$tree[] = $rowData;
|
||||
}
|
||||
}
|
||||
|
||||
$counter = 0;
|
||||
$this->assignUniqueIndex($tree, $counter);
|
||||
$this->terminateWithSuccess($tree);
|
||||
}
|
||||
|
||||
|
||||
public function loadByLV($lehrveranstaltung_id = null)
|
||||
{
|
||||
if (is_null($lehrveranstaltung_id) || !ctype_digit((string)$lehrveranstaltung_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->_ci->LehrveranstaltungModel->addSelect('lehrveranstaltung_id, lehrform_kurzbz, lehre, bezeichnung as lvbezeichnung, sprache');
|
||||
$lehrveranstaltung_result = $this->_ci->LehrveranstaltungModel->loadWhere(array('lehrveranstaltung_id' => $lehrveranstaltung_id));
|
||||
$lehrveranstaltung_result = $this->getDataOrTerminateWithError($lehrveranstaltung_result);
|
||||
$lehrveranstaltung = $lehrveranstaltung_result[0];
|
||||
|
||||
$this->_ci->LehreinheitModel->addSelect('lehrveranstaltung_id_kompatibel');
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung_kompatibel', 'lehrveranstaltung_id');
|
||||
$lehrfaecher = $this->_ci->LehreinheitModel->loadWhere(array('lehrveranstaltung_id' => $lehrveranstaltung->lehrveranstaltung_id));
|
||||
|
||||
$lehrfaecher_array = [];
|
||||
if (hasData($lehrfaecher))
|
||||
$lehrfaecher_array = array_merge($lehrfaecher_array, array_column(getData($lehrfaecher), 'lehrveranstaltung_id_kompatibel'));
|
||||
|
||||
$lehrfaecher_array[] = $lehrveranstaltung->lehrveranstaltung_id;
|
||||
|
||||
$this->_ci->LehrveranstaltungModel->addDistinct('lehrfach_id');
|
||||
$this->_ci->LehrveranstaltungModel->addSelect("tbl_lehrveranstaltung.lehrveranstaltung_id, CONCAT(tbl_lehrveranstaltung.bezeichnung || '(' || tbl_lehrveranstaltung.oe_kurzbz || ')') as lehrfach");
|
||||
$this->_ci->LehrveranstaltungModel->db->where_in('tbl_lehrveranstaltung.lehrveranstaltung_id', $lehrfaecher_array);
|
||||
$lehrfaecher_result = $this->_ci->LehrveranstaltungModel->load();
|
||||
|
||||
$lehrfaecher_array = hasData($lehrfaecher_result) ? getData($lehrfaecher_result) : array();
|
||||
|
||||
$lehrveranstaltung->lehrfaecher = $lehrfaecher_array;
|
||||
$this->terminateWithSuccess($lehrveranstaltung);
|
||||
}
|
||||
|
||||
/*
|
||||
* (david) ggf. im naechsten release
|
||||
* public function loadByOrganization($oe_kurzbz)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$lehrveranstaltungen = $this->LehrveranstaltungModel->getLvsByOrganization($oe_kurzbz);
|
||||
$lehrveranstaltungen_data = $this->getDataOrTerminateWithError($lehrveranstaltungen);
|
||||
$tree = [];
|
||||
|
||||
foreach ($lehrveranstaltungen_data as $lehrveranstaltung)
|
||||
{
|
||||
$lehreinheiten = $this->LehreinheitModel->getByLvidStudiensemester($lehrveranstaltung->lehrveranstaltung_id, $studiensemester_kurzbz);
|
||||
$lehreinheiten_data = $this->getDataOrTerminateWithError($lehreinheiten);
|
||||
|
||||
if (!isset($lehrveranstaltung->_children))
|
||||
{
|
||||
|
||||
$lehrveranstaltung->_children = $lehreinheiten_data;
|
||||
}
|
||||
$tree[] = $lehrveranstaltung;
|
||||
}
|
||||
$this->terminateWithSuccess($tree);
|
||||
}*/
|
||||
|
||||
/*public function loadByFachbereich($fachbereich, $mitarbeiter_uid = null)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$this->LehreinheitModel->getLvsByFachbereich($fachbereich, $studiensemester_kurzbz, $mitarbeiter_uid);
|
||||
}*/
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid)
|
||||
show_error('User authentification failed');
|
||||
}
|
||||
|
||||
private function assignUniqueIndex(&$nodes, &$counter)
|
||||
{
|
||||
foreach ($nodes as &$node)
|
||||
{
|
||||
$node->uniqueindex = $counter++;
|
||||
if (!empty($node->_children) && is_array($node->_children))
|
||||
{
|
||||
$this->assignUniqueIndex($node->_children, $counter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getStudiensemesterKurzbz($studiensemester_kurzbz = null)
|
||||
{
|
||||
if (!is_null($studiensemester_kurzbz))
|
||||
{
|
||||
$studiensemester_result = $this->_ci->StudiensemesterModel->load($studiensemester_kurzbz);
|
||||
|
||||
if (isError($studiensemester_result) || !hasData($studiensemester_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
return getData($studiensemester_result)[0]->studiensemester_kurzbz;
|
||||
}
|
||||
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
|
||||
$this->load->library("PermissionLib", null, 'PermissionLib');
|
||||
|
||||
$this->load->library("PhrasesLib");
|
||||
$this->load->library("PhrasesLib", null, 'PhrasesLib');
|
||||
$this->loadPhrases(array('global', 'lehre'));
|
||||
}
|
||||
|
||||
@@ -269,6 +269,8 @@ class LvMenu extends FHCAPI_Controller
|
||||
'lehrfach_id'=>$lehrfach_id,
|
||||
'lektor_der_lv'=>$lektor_der_lv,
|
||||
'lehrfach_oe_kurzbz_arr'=>$lehrfach_oe_kurzbz_arr,
|
||||
'permissionLib' => &$this->PermissionLib,
|
||||
'phrasesLib' => &$this->PhrasesLib
|
||||
];
|
||||
|
||||
Events::trigger('lvMenuBuild',
|
||||
@@ -331,6 +333,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
'id'=>'core_menu_lvinfo',
|
||||
'position'=>'10',
|
||||
'name'=>$this->p->t('lehre', 'lehrveranstaltungsinformation'),
|
||||
'phrase' => 'lehre/lehrveranstaltungsinformation',
|
||||
'icon'=>'../../../skin/images/button_lvinfo.png',
|
||||
'link'=>'',
|
||||
'c4_icon'=> base_url('skin/images/button_lvinfo.png'),
|
||||
@@ -349,6 +352,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
'id'=>'core_menu_feedback',
|
||||
'position'=>'60',
|
||||
'name'=>$this->p->t('lehre', 'feedback'),
|
||||
'phrase' => 'lehre/feedback',
|
||||
'c4_icon'=> base_url('skin/images/button_feedback.png'),
|
||||
'c4_link'=> base_url('feedback.php?lvid='.$lvid),
|
||||
);
|
||||
@@ -366,6 +370,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
'id'=>'core_menu_gesamtnote',
|
||||
'position'=>'80',
|
||||
'name'=>$this->p->t('lehre', 'gesamtnote'),
|
||||
'phrase' => 'lehre/gesamtnote',
|
||||
'c4_icon'=> base_url('skin/images/button_endnote.png'),
|
||||
'c4_link'=> base_url('cis/private/lehre/benotungstool/lvgesamtnoteverwalten.php?lvid='.urlencode($lvid).'&stsem='.urlencode($angezeigtes_stsem))
|
||||
//'c4_link'=> base_url('benotungstool/lvgesamtnoteverwalten.php?lvid='.urlencode($lvid).'&stsem='.urlencode($angezeigtes_stsem))
|
||||
@@ -378,6 +383,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
'id'=>'core_menu_gesamtnote',
|
||||
'position'=>'80',
|
||||
'name'=>$this->p->t('lehre', 'gesamtnote'),
|
||||
'phrase'=>'lehre/gesamtnote',
|
||||
'c4_icon'=>base_url('skin/images/button_endnote.png'),
|
||||
'c4_link'=>'#',
|
||||
'c4_linkList'=>[[$this->p->t('lehre', 'noteneingabedeaktiviert'),'#']],
|
||||
@@ -450,6 +456,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
'id'=>'core_menu_mailanstudierende',
|
||||
'position'=>'100',
|
||||
'name'=>$this->p->t('lehre', 'mail'),
|
||||
'phrase' => 'lehre/mail',
|
||||
'c4_icon'=>base_url('skin/images/button_feedback.png'),
|
||||
'c4_icon2' => 'fa-regular fa-envelope',
|
||||
'c4_link'=>$mailto,
|
||||
@@ -474,6 +481,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
'id'=>'core_menu_abmeldung',
|
||||
'position'=>'120',
|
||||
'name'=>$this->p->t('lehre', 'abmelden'),
|
||||
'phrase'=>'lehre/abmelden',
|
||||
'c4_icon'=>base_url('skin/images/button_studiupload.png'),
|
||||
'c4_link'=>base_url('abmeldung.php?lvid='.urlencode($lvid).'&stsem='.urlencode($angezeigtes_stsem)),
|
||||
);
|
||||
@@ -508,6 +516,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
'id' => 'core_menu_anerkennungNachgewiesenerKenntnisse',
|
||||
'position' => '128',
|
||||
'name' => $this->p->t('lehre', 'anrechnung'),
|
||||
'phrase' => 'lehre/anrechnung',
|
||||
'c4_icon' => base_url('skin/images/button_listen.png'),
|
||||
'c4_icon2' => 'fa-regular fa-folder-open',
|
||||
'c4_link' => base_url('cis.php/lehre/anrechnung/RequestAnrechnung?studiensemester='.urlencode($angezeigtes_stsem).'&lv_id='.urlencode($lvid))
|
||||
@@ -525,6 +534,7 @@ class LvMenu extends FHCAPI_Controller
|
||||
'id' => 'core_menu_anerkennungNachgewiesenerKenntnisse_empfehlen',
|
||||
'position' => '128',
|
||||
'name' => $this->p->t('lehre', 'anrechnungen'),
|
||||
'phrase' => 'lehre/anrechnung',
|
||||
'c4_icon'=> base_url('skin/images/button_listen.png'),
|
||||
'c4_icon2' => 'fa-regular fa-folder-open',
|
||||
'c4_link' => base_url('cis.php/lehre/anrechnung/ReviewAnrechnungUebersicht?studiensemester='.urlencode($angezeigtes_stsem))
|
||||
|
||||
@@ -0,0 +1,363 @@
|
||||
<?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;
|
||||
use \DateTime as DateTime;
|
||||
use \DateTimeZone as DateTimeZone;
|
||||
|
||||
class LvPlan extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct([
|
||||
'getRoomplan' => self::PERM_LOGGED,
|
||||
'Stunden' => self::PERM_LOGGED,
|
||||
'getReservierungen' => self::PERM_LOGGED,
|
||||
'LvPlanEvents' => self::PERM_LOGGED,
|
||||
'eventsPersonal' => self::PERM_LOGGED,
|
||||
'eventsLv' => self::PERM_LOGGED,
|
||||
'getLehreinheitStudiensemester' => self::PERM_LOGGED,
|
||||
'studiensemesterDateInterval' => self::PERM_LOGGED,
|
||||
'getLvPlanForStudiensemester' => self::PERM_LOGGED,
|
||||
'getLv' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
$this->load->library('LogLib');
|
||||
$this->loglib->setConfigs(array(
|
||||
'classIndex' => 5,
|
||||
'functionIndex' => 5,
|
||||
'lineIndex' => 4,
|
||||
'dbLogType' => 'API', // required
|
||||
'dbExecuteUser' => 'RESTful API'
|
||||
));
|
||||
|
||||
$this->load->library('form_validation');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* fetches LvPlan and Moodle events together
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function LvPlanEvents()
|
||||
{
|
||||
$hasLv = $this->input->post('lv_id');
|
||||
|
||||
return $hasLv ? $this->eventsLv() : $this->eventsPersonal();
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches LvPlan, Moodle and Ferien events together for the logged in user
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function eventsPersonal()
|
||||
{
|
||||
$this->load->library('StundenplanLib');
|
||||
|
||||
// form validation
|
||||
$this->form_validation->set_rules('start_date', "start_date", "required");
|
||||
$this->form_validation->set_rules('end_date', "end_date", "required");
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the post parameter in local variables
|
||||
$start_date = $this->input->post('start_date', true);
|
||||
$end_date = $this->input->post('end_date', true);
|
||||
|
||||
// fetching lvplan events
|
||||
$result = $this->stundenplanlib->getEventsUser($start_date, $end_date);
|
||||
$lvplanEvents = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// fetching moodle events
|
||||
$moodleEvents = $this->fetchMoodleEvents($start_date, $end_date);
|
||||
|
||||
// fetching ferien events
|
||||
$ferienEvents = $this->fetchFerienEvents($start_date, $end_date);
|
||||
|
||||
|
||||
$this->terminateWithSuccess(array_merge(
|
||||
$lvplanEvents,
|
||||
$moodleEvents,
|
||||
$ferienEvents
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches LvPlan and Ferien events together for the lv
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function eventsLv()
|
||||
{
|
||||
$this->load->library('StundenplanLib');
|
||||
|
||||
// form validation
|
||||
$this->form_validation->set_rules('start_date', "start_date", "required");
|
||||
$this->form_validation->set_rules('end_date', "end_date", "required");
|
||||
$this->form_validation->set_rules('lv_id', "lv_id", "required|integer");
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the post parameter in local variables
|
||||
$start_date = $this->input->post('start_date', true);
|
||||
$end_date = $this->input->post('end_date', true);
|
||||
$lv_id = $this->input->post('lv_id', true);
|
||||
|
||||
// fetching lvplan events
|
||||
$result = $this->stundenplanlib->getEventsLv($lv_id, $start_date, $end_date);
|
||||
$lvplanEvents = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// fetching ferien events
|
||||
$ferienEvents = $this->fetchFerienEvents($start_date, $end_date);
|
||||
|
||||
|
||||
$this->terminateWithSuccess(array_merge(
|
||||
$lvplanEvents,
|
||||
$ferienEvents
|
||||
));
|
||||
}
|
||||
|
||||
//TODO: delete this function if we don't use the old calendar export endpoints anymore
|
||||
public function studiensemesterDateInterval($date){
|
||||
$this->load->model('organisation/Studiensemester_model','StudiensemesterModel');
|
||||
$studiensemester =$this->StudiensemesterModel->getByDate(date_format(date_create($date),'Y-m-d'));
|
||||
$studiensemester =current($this->getDataOrTerminateWithError($studiensemester));
|
||||
$this->terminateWithSuccess($studiensemester);
|
||||
}
|
||||
|
||||
public function getLvPlanForStudiensemester($studiensemester,$lvid){
|
||||
$this->load->library('StundenplanLib');
|
||||
$this->load->model('organisation/Studiensemester_model','StudiensemesterModel');
|
||||
|
||||
$studiensemester_result = $this->StudiensemesterModel->loadWhere(["studiensemester_kurzbz"=>$studiensemester]);
|
||||
$studiensemester_result = current($this->getDataOrTerminateWithError($studiensemester_result));
|
||||
$timespan_start = new DateTime($studiensemester_result->start);
|
||||
$timespan_ende = new DateTime($studiensemester_result->ende);
|
||||
$lvplan = $this->stundenplanlib->getStundenplan(date_format($timespan_start, 'Y-m-d'),date_format($timespan_ende, 'Y-m-d'), $lvid);
|
||||
$this->terminateWithSuccess($lvplan);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* fetches Stunden layout from database
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function Stunden()
|
||||
{
|
||||
$this->load->model('ressource/Stunde_model', 'StundeModel');
|
||||
|
||||
$this->StundeModel->addOrder('stunde', 'ASC');
|
||||
$stunden = $this->StundeModel->load();
|
||||
|
||||
$stunden = $this->getDataOrTerminateWithError($stunden);
|
||||
|
||||
$this->terminateWithSuccess($stunden);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches room events from a certain date
|
||||
* @access public
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getRoomplan()
|
||||
{
|
||||
$this->form_validation->set_rules('ort_kurzbz', "Ort", "required");
|
||||
$this->form_validation->set_rules('start_date', "start_date", "required");
|
||||
$this->form_validation->set_rules('end_date', "end_date", "required");
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the post parameter in local variables
|
||||
$ort_kurzbz = $this->input->post('ort_kurzbz', true);
|
||||
$start_date = $this->input->post('start_date', true);
|
||||
$end_date = $this->input->post('end_date', true);
|
||||
|
||||
// get data
|
||||
$this->load->library('StundenplanLib');
|
||||
|
||||
$roomplan_data = $this->stundenplanlib->getRoomplan($ort_kurzbz, $start_date, $end_date);
|
||||
|
||||
$roomplan_data = $this->getDataOrTerminateWithError($roomplan_data);
|
||||
|
||||
$this->terminateWithSuccess($roomplan_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the reservierungen of a room if the ort_kurzbz parameter is
|
||||
* supplied otherwise gets the reservierungen of the lvplan of a student
|
||||
* @access public
|
||||
*
|
||||
* @param string $ort_kurzbz
|
||||
* @return void
|
||||
*/
|
||||
public function getReservierungen($ort_kurzbz = null)
|
||||
{
|
||||
$this->form_validation->set_rules('start_date', "StartDate", "required");
|
||||
$this->form_validation->set_rules('end_date', "EndDate", "required");
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the post parameter in local variables
|
||||
$start_date = $this->input->post('start_date', true);
|
||||
$end_date = $this->input->post('end_date', true);
|
||||
|
||||
// get data
|
||||
$this->load->library('StundenplanLib');
|
||||
|
||||
$result = $this->stundenplanlib->getReservierungen($start_date, $end_date, $ort_kurzbz);
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getLehreinheitStudiensemester($lehreinheit_id){
|
||||
$this->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->LehreinheitModel->addSelect(["studiensemester_kurzbz"]);
|
||||
$result = $this->LehreinheitModel->load($lehreinheit_id);
|
||||
$result = current($this->getDataOrTerminateWithError($result))->studiensemester_kurzbz;
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* get details for a lv
|
||||
* @access public
|
||||
*
|
||||
* @param integer $lehrveranstaltung_id
|
||||
* @return void
|
||||
*/
|
||||
public function getLv($lehrveranstaltung_id)
|
||||
{
|
||||
if (!$lehrveranstaltung_id && $lehrveranstaltung_id !== 0 && $lehrveranstaltung_id !== '0')
|
||||
return show_404();
|
||||
|
||||
// Load Phrases
|
||||
$this->loadPhrases(['lehre']);
|
||||
|
||||
// Validation
|
||||
$this->form_validation->set_data([
|
||||
'lehrveranstaltung_id' => $lehrveranstaltung_id
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('lehrveranstaltung_id', $this->p->t('lehre', 'lehrveranstaltung_id'), 'integer');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// Get Data
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
|
||||
$result = $this->LehrveranstaltungModel->load($lehrveranstaltung_id);
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess(current($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch moodle events
|
||||
*
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
* @return array
|
||||
*/
|
||||
private function fetchMoodleEvents($start_date, $end_date)
|
||||
{
|
||||
$this->load->config('calendar');
|
||||
|
||||
$tz = new DateTimeZone($this->config->item('timezone'));
|
||||
|
||||
$start = new DateTime($start_date);
|
||||
$start->setTimezone($tz);
|
||||
|
||||
$end = new DateTime($end_date);
|
||||
$end->setTimezone($tz);
|
||||
$end->modify('+1 day -1 second');
|
||||
|
||||
$moodle_events = [];
|
||||
|
||||
Events::trigger(
|
||||
'moodleCalendarEvents',
|
||||
function & () use (&$moodle_events) {
|
||||
return $moodle_events;
|
||||
},
|
||||
[
|
||||
'start_date' => $start->format('c'),
|
||||
'end_date' => $end->format('c'),
|
||||
'username' => getAuthUID()
|
||||
]
|
||||
);
|
||||
|
||||
return $moodle_events;
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch ferien events
|
||||
*
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
* @return array
|
||||
*/
|
||||
private function fetchFerienEvents($start_date, $end_date)
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->load->model('education/Studentlehrverband_model', 'StudentLehrverbandModel');
|
||||
|
||||
$currentStudiensemester = $this->StudiensemesterModel->getByDate($start_date);
|
||||
$currentStudiensemester = $this->getDataOrTerminateWithError($currentStudiensemester);
|
||||
|
||||
if ($currentStudiensemester) {
|
||||
$studentsemester_kurzbz = current($currentStudiensemester)->studiensemester_kurzbz;
|
||||
|
||||
$studiengang = $this->StudentLehrverbandModel->loadWhere([
|
||||
"student_uid" => getAuthUID(),
|
||||
"studiensemester_kurzbz" => $studentsemester_kurzbz
|
||||
]);
|
||||
$studiengang = $this->getDataOrTerminateWithError($studiengang);
|
||||
|
||||
if ($studiengang)
|
||||
$studiengang_kz = current($studiengang)->studiengang_kz;
|
||||
else
|
||||
$studiengang_kz = 0;
|
||||
} else {
|
||||
$studiengang_kz = 0;
|
||||
}
|
||||
|
||||
$ferienEvents = $this->stundenplanlib->fetchFerienTageEvents($start_date, $end_date, $studiengang_kz);
|
||||
|
||||
return $this->getDataOrTerminateWithError($ferienEvents);
|
||||
}
|
||||
}
|
||||
@@ -35,15 +35,98 @@ class Ort extends FHCAPI_Controller
|
||||
parent::__construct([
|
||||
'ContentID' => self::PERM_LOGGED,
|
||||
'getOrtKurzbzContent' => self::PERM_LOGGED,
|
||||
'getRooms' => self::PERM_LOGGED,
|
||||
'getTypes' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
$this->load->model('ressource/Ort_model', 'OrtModel');
|
||||
|
||||
$this->config->load('raumsuche');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Retrieves all Ort entries filtered by the provided parameters
|
||||
*/
|
||||
public function getRooms()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($_GET);
|
||||
$this->form_validation->set_rules('datum','Datum','required');
|
||||
$this->form_validation->set_rules('von','Uhrzeit Von','required|regex_match[/^[0-9]{2}:[0-9]{2}$/]');
|
||||
$this->form_validation->set_rules('bis','Uhrzeit Bis','required|regex_match[/^[0-9]{2}:[0-9]{2}$/]');
|
||||
if($this->form_validation->run() == FALSE) {
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$datum = $this->input->get('datum', TRUE);
|
||||
$von = $this->input->get('von', TRUE);
|
||||
$bis = $this->input->get('bis', TRUE);
|
||||
$typ = $this->input->get('typ', TRUE);
|
||||
$personenanzahl = $this->input->get('personenanzahl', TRUE);
|
||||
|
||||
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$isMitarbeiter = $this->MitarbeiterModel->isMitarbeiter(getAuthUID())->retval;
|
||||
|
||||
$this->load->model('ressource/Stunde_model', 'StundeModel');
|
||||
$vonStunde = getData($this->StundeModel->getStundeForTime($von))[0]->stunde;
|
||||
$bisStunde = getData($this->StundeModel->getStundeForTime($bis))[0]->stunde;
|
||||
|
||||
$params = array();
|
||||
$qry = "SELECT DISTINCT tbl_ort.*
|
||||
FROM public.tbl_ort JOIN public.tbl_ortraumtyp USING(ort_kurzbz)
|
||||
WHERE aktiv AND lehre AND ort_kurzbz NOT LIKE '\\\\_%'";
|
||||
if($typ) {
|
||||
$params[] = $typ;
|
||||
$qry.= "AND raumtyp_kurzbz = ?";
|
||||
}
|
||||
|
||||
if(!$isMitarbeiter) { // students are only allowed to get a subset defined by config
|
||||
$qry.= ' AND raumtyp_kurzbz IN ?';
|
||||
$params[] = $this->config->item('roomtypes_student');
|
||||
$this->addMeta('config', $this->config->item('roomtypes_student'));
|
||||
}
|
||||
|
||||
$qry.= "AND (max_person>= ? OR max_person is null)";
|
||||
$params[] = $personenanzahl;
|
||||
|
||||
$qry.=" AND ort_kurzbz NOT IN
|
||||
(
|
||||
SELECT ort_kurzbz FROM lehre.tbl_stundenplandev WHERE datum = ? AND stunde >= ? AND stunde <= ?
|
||||
UNION
|
||||
SELECT ort_kurzbz FROM campus.tbl_reservierung WHERE datum= ? AND stunde >= ? AND stunde <= ?
|
||||
)
|
||||
";
|
||||
$params = array_merge($params, [$datum, $vonStunde, $bisStunde, $datum, $vonStunde, $bisStunde]);
|
||||
// $this->addMeta('qry', $qry);
|
||||
// $this->addMeta('params', $params);
|
||||
$result = $this->OrtModel->execReadOnlyQuery($qry, $params);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getTypes()
|
||||
{
|
||||
$this->load->model('ressource/Raumtyp_model', 'RaumtypModel');
|
||||
$qry = "SELECT * FROM public.tbl_raumtyp WHERE aktiv = true";
|
||||
$params = array();
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
|
||||
$isMitarbeiter = $this->MitarbeiterModel->isMitarbeiter(getAuthUID())->retval;
|
||||
if(!$isMitarbeiter) { // students are only allowed to get a subset defined by config
|
||||
$qry.= ' AND raumtyp_kurzbz IN ?';
|
||||
$params[] = $this->config->item('roomtypes_student');
|
||||
}
|
||||
|
||||
$qry .= " ORDER BY raumtyp_kurzbz;";
|
||||
|
||||
$result = $this->OrtModel->execReadOnlyQuery($qry, $params);
|
||||
|
||||
$this->terminateWithSuccess(getData($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
|
||||
@@ -27,27 +27,17 @@ class Profil extends FHCAPI_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getView' => self::PERM_LOGGED,
|
||||
'fotoSperre' => self::PERM_LOGGED,
|
||||
'getGemeinden' => self::PERM_LOGGED,
|
||||
'getAllNationen' => self::PERM_LOGGED,
|
||||
'isMitarbeiter' => self::PERM_LOGGED,
|
||||
|
||||
'profilViewData' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->load->library('PermissionLib');
|
||||
|
||||
$this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel');
|
||||
$this->load->model('ressource/Betriebsmittelperson_model', 'BetriebsmittelpersonModel');
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
$this->load->model('person/Profil_update_model', 'ProfilUpdateModel');
|
||||
$this->load->model('content/DmsVersion_model', 'DmsVersionModel');
|
||||
|
||||
|
||||
//? put the uid and pid inside the controller for reusability
|
||||
@@ -58,66 +48,25 @@ class Profil extends FHCAPI_Controller
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
|
||||
/**
|
||||
* function that returns the data used for the corresponding view
|
||||
* the client side parses the @param $uid and calls this function to get the data to the correct view
|
||||
* @access public
|
||||
* @param boolean $uid the userID used to identify which information should be retrieved for which view
|
||||
* @return stdClass all the data corresponding to a view of a user
|
||||
*/
|
||||
public function getView($uid)
|
||||
{
|
||||
$res = new stdClass();
|
||||
$editAllowed = getAuthUID() == $uid || $this->permissionlib->isBerechtigt('admin');
|
||||
|
||||
// if parsing the URL did not found a UID then the UID of the logged in user is used
|
||||
if ($uid == "Profil" || $uid == $this->uid) {
|
||||
$isMitarbeiter = $this->MitarbeiterModel->isMitarbeiter($this->uid);
|
||||
if (isError($isMitarbeiter)) {
|
||||
show_error("error while checking if UID: " . $this->uid . " is a mitarbeiter");
|
||||
public function profilViewData($uid=null){
|
||||
$this->load->library('ProfilLib');
|
||||
$editable = false;
|
||||
if(isset($uid) && $uid != null){
|
||||
$profil_data = $this->profillib->getView($uid);
|
||||
if($uid == getAuthUID()){
|
||||
$editable = true;
|
||||
}
|
||||
$isMitarbeiter = getData($isMitarbeiter);
|
||||
if ($isMitarbeiter) {
|
||||
$res->view = "MitarbeiterProfil";
|
||||
$res->data = $this->mitarbeiterProfil();
|
||||
$res->data->pid = $this->pid;
|
||||
} else {
|
||||
$res->view = "StudentProfil";
|
||||
$res->data = $this->studentProfil();
|
||||
$res->data->pid = $this->pid;
|
||||
}
|
||||
// editing your own profil - true
|
||||
$editAllowed = true;
|
||||
}else{
|
||||
$editable = true;
|
||||
$profil_data = $this->profillib->getView(getAuthUID());
|
||||
}
|
||||
// UID is availabe when accessing Profil/View/:uid
|
||||
else {
|
||||
$this->PersonModel->addSelect(["person_id"]);
|
||||
$pid = $this->PersonModel->getByUid($uid);
|
||||
if (isError($pid)) {
|
||||
show_error("error while trying to update table public.tbl_person while searching for a person with UID: " . $uid);
|
||||
}
|
||||
$pid = hasData($pid) ? getData($pid)[0] : null;
|
||||
if (!$pid) {
|
||||
show_error("Person with UID: " . $uid . " does not exist");
|
||||
}
|
||||
$isMitarbeiter = $this->MitarbeiterModel->isMitarbeiter($uid);
|
||||
if (isError($isMitarbeiter)) {
|
||||
show_error("error while checking if UID: " . $uid . " is a mitarbeiter");
|
||||
}
|
||||
$isMitarbeiter = getData($isMitarbeiter);
|
||||
if ($isMitarbeiter) {
|
||||
$res->view = "ViewMitarbeiterProfil";
|
||||
$res->data = $this->viewMitarbeiterProfil($uid);
|
||||
|
||||
} else {
|
||||
$res->view = "ViewStudentProfil";
|
||||
$res->data = $this->viewStudentProfil($uid);
|
||||
}
|
||||
}
|
||||
$res->data->editAllowed = $editAllowed;
|
||||
$this->terminateWithSuccess($res);
|
||||
|
||||
$profil_data = hasData($profil_data) ? getData($profil_data) : null;
|
||||
$viewData = array(
|
||||
'editable'=>$editable,
|
||||
'profil_data' => $profil_data,
|
||||
);
|
||||
$this->terminateWithSuccess($viewData);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,14 +83,11 @@ class Profil extends FHCAPI_Controller
|
||||
|
||||
$res = $this->PersonModel->update($this->pid, ["foto_sperre" => $value]);
|
||||
if (isError($res)) {
|
||||
show_error("error while trying to update table public.tbl_person");
|
||||
$this->terminateWithError("error while trying to update table public.tbl_person");
|
||||
}
|
||||
$this->PersonModel->addSelect("foto_sperre");
|
||||
$res = $this->PersonModel->load($this->pid);
|
||||
if (isError($res)) {
|
||||
show_error("error while trying to query table public.tbl_person");
|
||||
}
|
||||
|
||||
|
||||
$res = $this->getDataOrTerminateWithError($res);
|
||||
|
||||
$this->terminateWithSuccess(current($res));
|
||||
@@ -194,91 +140,7 @@ class Profil extends FHCAPI_Controller
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* function that returns the data used for viewing another mitarbeiter profile
|
||||
* @access private
|
||||
* @param integer $uid the userID to retrieve the mitarbeiter data
|
||||
* @return stdClass restricted mitarbeiter data
|
||||
*/
|
||||
private function viewMitarbeiterProfil($uid)
|
||||
{
|
||||
$mailverteiler_res = $this->getMailverteiler($uid);
|
||||
$benutzer_funktion_res = $this->getBenutzerFunktion($uid);
|
||||
$benutzer_res = $this->getBenutzerAlias($uid);
|
||||
$person_res = $this->getPersonInfo($uid);
|
||||
$mitarbeiter_res = $this->getMitarbeiterInfo($uid);
|
||||
$telefon_res = $this->getTelefonInfo($uid);
|
||||
|
||||
$res = new stdClass();
|
||||
$res->username = $uid;
|
||||
|
||||
//? Person Info
|
||||
foreach ($person_res as $key => $val) {
|
||||
$res->$key = $val;
|
||||
}
|
||||
|
||||
//? Mitarbeiter Info
|
||||
foreach ($mitarbeiter_res as $key => $val) {
|
||||
$res->$key = $val;
|
||||
|
||||
}
|
||||
|
||||
$intern_email = array();
|
||||
$intern_email["type"] = "intern";
|
||||
$intern_email["email"] = $uid . "@" . DOMAIN;
|
||||
$extern_email = array();
|
||||
$extern_email["type"] = "alias";
|
||||
$extern_email["email"] = $benutzer_res->alias . "@" . DOMAIN;
|
||||
$res->emails = array($intern_email, $extern_email);
|
||||
|
||||
$res->funktionen = $benutzer_funktion_res;
|
||||
$res->mailverteiler = $mailverteiler_res;
|
||||
$res->standort_telefon = isset($telefon_res) ? $telefon_res->kontakt : null;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* function that returns the data used for viewing another student profile
|
||||
* @access private
|
||||
* @param integer $uid the userID to retrieve the student data
|
||||
* @return stdClass restricted student data
|
||||
*/
|
||||
private function viewStudentProfil($uid)
|
||||
{
|
||||
$mailverteiler_res = $this->getMailverteiler($uid);
|
||||
$person_res = $this->getPersonInfo($uid);
|
||||
$student_res = $this->getStudentInfo($uid);
|
||||
$matr_res = $this->getMatrikelNummer($uid);
|
||||
|
||||
$res = new stdClass();
|
||||
$res->username = $uid;
|
||||
|
||||
//? Person Information
|
||||
foreach ($person_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
//? Student Information
|
||||
foreach ($student_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
$intern_email = array();
|
||||
$intern_email["type"] = "intern";
|
||||
$intern_email["email"] = $uid . "@" . DOMAIN;
|
||||
|
||||
$res->emails = [$intern_email];
|
||||
$res->matrikelnummer = $matr_res->matr_nr;
|
||||
$res->mailverteiler = $mailverteiler_res;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* checks whether a specific userID is a mitarbeiter or not (foreword declaration of the function isMitarbeiter in Mitarbeiter_model.php)
|
||||
* @access public
|
||||
@@ -302,394 +164,9 @@ class Profil extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* function that returns the data used for the mitarbeiter profile
|
||||
* @access private
|
||||
* @return stdClass mitarbeiter data
|
||||
*/
|
||||
private function mitarbeiterProfil()
|
||||
{
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
$zutrittskarte_ausgegebenam = $this->getZutrittskarteDatum($this->uid);
|
||||
$adresse_res = $this->getAdressenInfo($this->pid);
|
||||
$kontakte_res = $this->getKontaktInfo($this->pid);
|
||||
$mailverteiler_res = $this->getMailverteiler($this->uid);
|
||||
$person_res = $this->getPersonInfo($this->uid, true);
|
||||
$benutzer_funktion_res = $this->getBenutzerFunktion($this->uid);
|
||||
$betriebsmittelperson_res = $this->getBetriebsmittelInfo($this->pid);
|
||||
$profilUpdates = $this->getProfilUpdates($this->uid);
|
||||
$telefon_res = $this->getTelefonInfo($this->uid);
|
||||
$mitarbeiter_res = $this->getMitarbeiterInfo($this->uid);
|
||||
|
||||
$res = new stdClass();
|
||||
$res->username = $this->uid;
|
||||
|
||||
//? Person Information
|
||||
foreach ($person_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
//? Mitarbeiter Information
|
||||
foreach ($mitarbeiter_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
$res->adressen = $adresse_res;
|
||||
$res->zutrittsdatum = $zutrittskarte_ausgegebenam;
|
||||
$res->kontakte = $kontakte_res;
|
||||
$res->mittel = $betriebsmittelperson_res;
|
||||
$res->mailverteiler = $mailverteiler_res;
|
||||
|
||||
$intern_email = array();
|
||||
$intern_email["type"] = "intern";
|
||||
$intern_email["email"] = $this->uid . "@" . DOMAIN;
|
||||
$extern_email = array();
|
||||
$extern_email["type"] = "alias";
|
||||
$extern_email["email"] = $mitarbeiter_res->alias . "@" . DOMAIN;
|
||||
$res->emails = [$intern_email, $extern_email];
|
||||
|
||||
$res->funktionen = $benutzer_funktion_res;
|
||||
$res->standort_telefon = $telefon_res;
|
||||
$res->profilUpdates = $profilUpdates;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* function that returns the data used for the student profile
|
||||
* @access private
|
||||
* @return stdClass student data
|
||||
*/
|
||||
private function studentProfil()
|
||||
{
|
||||
$betriebsmittelperson_res = $this->getBetriebsmittelInfo($this->pid);
|
||||
$kontakte_res = $this->getKontaktInfo($this->pid);
|
||||
$zutrittskarte_ausgegebenam = $this->getZutrittskarteDatum($this->uid);
|
||||
$adresse_res = $this->getAdressenInfo($this->pid);
|
||||
$mailverteiler_res = $this->getMailverteiler($this->uid);
|
||||
$person_res = $this->getPersonInfo($this->uid, true);
|
||||
$zutrittsgruppe_res = $this->getZutrittsgruppen($this->uid);
|
||||
$student_res = $this->getStudentInfo($this->uid);
|
||||
$matr_res = $this->getMatrikelNummer($this->uid);
|
||||
$profilUpdates = $this->getProfilUpdates($this->uid);
|
||||
|
||||
$res = new stdClass();
|
||||
$res->username = $this->uid;
|
||||
|
||||
//? Person Information
|
||||
foreach ($person_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
//? Student Information
|
||||
foreach ($student_res as $key => $value) {
|
||||
$res->$key = trim($value);
|
||||
}
|
||||
|
||||
$intern_email = array();
|
||||
$intern_email["type"] = "intern";
|
||||
$intern_email["email"] = $this->uid . "@" . DOMAIN;
|
||||
|
||||
$res->emails = [$intern_email];
|
||||
$res->adressen = $adresse_res;
|
||||
$res->zutrittsdatum = $zutrittskarte_ausgegebenam;
|
||||
$res->kontakte = $kontakte_res;
|
||||
$res->mittel = $betriebsmittelperson_res;
|
||||
$res->matrikelnummer = $matr_res->matr_nr;
|
||||
$res->zuttritsgruppen = $zutrittsgruppe_res;
|
||||
$res->mailverteiler = $mailverteiler_res;
|
||||
$res->profilUpdates = $profilUpdates;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gets all the mailverteiler using the tables: tbl_benutzer, tbl_benutzergruppe, tbl_gruppe
|
||||
* @access private
|
||||
* @param integer $uid the userID used to retrieve the mailverteiler
|
||||
* @return array returns the mailvertailer corresponding to a userID
|
||||
*/
|
||||
private function getMailverteiler($uid)
|
||||
{
|
||||
$this->PersonModel->addSelect('gruppe_kurzbz, beschreibung');
|
||||
$this->PersonModel->addJoin('tbl_benutzer', 'person_id');
|
||||
$this->PersonModel->addJoin('tbl_benutzergruppe', 'uid');
|
||||
$this->PersonModel->addJoin('tbl_gruppe', 'gruppe_kurzbz');
|
||||
|
||||
$mailverteiler_res = $this->PersonModel->loadWhere(array('mailgrp' => true, 'uid' => $uid));
|
||||
if (isError($mailverteiler_res)) {
|
||||
show_error("was not able to query the table public.tbl_benutzer:" . getData($mailverteiler_res));
|
||||
}
|
||||
$mailverteiler_res = hasData($mailverteiler_res) ? getData($mailverteiler_res) : null;
|
||||
$mailverteiler_res = array_map(function ($element) {
|
||||
$element->mailto = "mailto:" . $element->gruppe_kurzbz . "@" . DOMAIN;
|
||||
return $element;
|
||||
}, $mailverteiler_res);
|
||||
return $mailverteiler_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all the Benutzerfunktionen of a corresponding user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to retrieve the Benutzerfunktionen
|
||||
* @return array returns the Benutzerfunktionen corresponding to a userID
|
||||
*/
|
||||
private function getBenutzerFunktion($uid)
|
||||
{
|
||||
$this->BenutzerfunktionModel->addSelect(["tbl_benutzerfunktion.bezeichnung as Bezeichnung", "tbl_organisationseinheit.bezeichnung as Organisationseinheit", "datum_von as Gültig_von", "datum_bis as Gültig_bis", "wochenstunden as Wochenstunden"]);
|
||||
$this->BenutzerfunktionModel->addJoin("tbl_organisationseinheit", "oe_kurzbz");
|
||||
|
||||
$benutzer_funktion_res = $this->BenutzerfunktionModel->loadWhere(array('uid' => $uid));
|
||||
if (isError($benutzer_funktion_res)) {
|
||||
show_error("was not able to query the table public.tbl_benutzerfunktion:" . getData($benutzer_funktion_res));
|
||||
}
|
||||
$benutzer_funktion_res = hasData($benutzer_funktion_res) ? getData($benutzer_funktion_res) : null;
|
||||
return $benutzer_funktion_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all the Betriebsmittel of a corresponding user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to retrieve the Betriebsmittel
|
||||
* @return array returns the Betriebsmittel corresponding to a userID
|
||||
*/
|
||||
private function getBetriebsmittelInfo($pid)
|
||||
{
|
||||
$this->BetriebsmittelpersonModel->addSelect(["CONCAT(betriebsmitteltyp, ' ' ,beschreibung) as Betriebsmittel", "nummer as Nummer", "ausgegebenam as Ausgegeben_am"]);
|
||||
|
||||
//? betriebsmittel are not needed in a view
|
||||
$betriebsmittelperson_res = $this->BetriebsmittelpersonModel->getBetriebsmittel($pid);
|
||||
if (isError($betriebsmittelperson_res)) {
|
||||
show_error("was not able to query the table public.tbl_betriebsmittelperson:" . getData($betriebsmittelperson_res));
|
||||
}
|
||||
$betriebsmittelperson_res = hasData($betriebsmittelperson_res) ? getData($betriebsmittelperson_res) : null;
|
||||
return $betriebsmittelperson_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the alias of a corresponding user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the alias
|
||||
* @return string the alias of the userID
|
||||
*/
|
||||
private function getBenutzerAlias($uid)
|
||||
{
|
||||
$this->BenutzerModel->addSelect(["alias"]);
|
||||
$benutzer_res = $this->BenutzerModel->load([$uid]);
|
||||
if (isError($benutzer_res)) {
|
||||
show_error("was not able to query the table public.tbl_benutzer:" . getData($benutzer_res));
|
||||
} else {
|
||||
$benutzer_res = hasData($benutzer_res) ? getData($benutzer_res)[0] : null;
|
||||
}
|
||||
|
||||
return $benutzer_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the person information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the person information
|
||||
* @param integer $geburtsInfo flag wether to add the columns gebort, gebdatum, foto_sperre or not
|
||||
* @return array all the person informaion corresponding to a userID
|
||||
*/
|
||||
private function getPersonInfo($uid, $geburtsInfo = null)
|
||||
{
|
||||
$selectClause = ["foto", "foto_sperre", "anrede", "titelpost as postnomen", "titelpre as titel", "vorname", "nachname"];
|
||||
/** @param integer $geburtsInfo */
|
||||
if ($geburtsInfo) {
|
||||
array_push($selectClause, "gebort");
|
||||
array_push($selectClause, "TO_CHAR(gebdatum, 'DD.MM.YYYY') as gebdatum");
|
||||
}
|
||||
$this->BenutzerModel->addSelect($selectClause);
|
||||
$this->BenutzerModel->addJoin("tbl_person", "person_id");
|
||||
|
||||
$person_res = $this->BenutzerModel->load([$uid]);
|
||||
if (isError($person_res)) {
|
||||
show_error("was not able to query the table public.tbl_benutzer:" . getData($person_res));
|
||||
} else {
|
||||
$person_res = hasData($person_res) ? getData($person_res)[0] : null;
|
||||
}
|
||||
|
||||
if( ($person_res->foto === null) || (($this->uid !== $uid) && ($person_res->foto_sperre !== false)) )
|
||||
{
|
||||
$dummy_foto = base64_encode(file_get_contents(DOC_ROOT.'skin/images/profilbild_dummy.jpg'));
|
||||
$person_res->foto = $dummy_foto;
|
||||
}
|
||||
|
||||
return $person_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the mitarbeiter information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the mitarbeiter information
|
||||
* @return array all the mitarbeiter informaion corresponding to a userID
|
||||
*/
|
||||
private function getMitarbeiterInfo($uid)
|
||||
{
|
||||
$this->MitarbeiterModel->addSelect(["kurzbz", "telefonklappe", "alias", "ort_kurzbz"]);
|
||||
$this->MitarbeiterModel->addJoin("tbl_benutzer", "tbl_benutzer.uid = tbl_mitarbeiter.mitarbeiter_uid");
|
||||
$mitarbeiter_res = $this->MitarbeiterModel->load($uid);
|
||||
if (isError($mitarbeiter_res)) {
|
||||
show_error("was not able to query the table public.tbl_mitarbeiter:" . getData($mitarbeiter_res));
|
||||
} else {
|
||||
$mitarbeiter_res = hasData($mitarbeiter_res) ? getData($mitarbeiter_res)[0] : null;
|
||||
}
|
||||
|
||||
return $mitarbeiter_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the telefon information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the telefon information
|
||||
* @return array all the telefon informaion corresponding to a userID
|
||||
*/
|
||||
private function getTelefonInfo($uid)
|
||||
{
|
||||
$this->MitarbeiterModel->addSelect(["kontakt"]);
|
||||
$this->MitarbeiterModel->addJoin("tbl_kontakt", "tbl_mitarbeiter.standort_id = tbl_kontakt.standort_id");
|
||||
$this->MitarbeiterModel->addLimit(1);
|
||||
$telefon_res = $this->MitarbeiterModel->loadWhere(["mitarbeiter_uid" => $uid, "kontakttyp" => "telefon"]);
|
||||
if (isError($telefon_res)) {
|
||||
show_error("was not able to query the table public.tbl_mitarbeiter:" . getData($telefon_res));
|
||||
}
|
||||
$telefon_res = hasData($telefon_res) ? getData($telefon_res)[0] : null;
|
||||
return $telefon_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the student information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the student information
|
||||
* @return array all the student informaion corresponding to a userID
|
||||
*/
|
||||
private function getStudentInfo($uid)
|
||||
{
|
||||
$this->StudentModel->addSelect(['tbl_studiengang.bezeichnung as studiengang', 'tbl_studiengang.studiengang_kz as studiengang_kz', 'tbl_student.semester', 'tbl_student.verband', 'tbl_student.gruppe', 'tbl_student.matrikelnr as personenkennzeichen']);
|
||||
$this->StudentModel->addJoin('tbl_studiengang', "tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz");
|
||||
|
||||
$student_res = $this->StudentModel->load([$uid]);
|
||||
if (isError($student_res)) {
|
||||
show_error("was not able to query the table public.tbl_student:" . getData($student_res));
|
||||
}
|
||||
$student_res = hasData($student_res) ? getData($student_res)[0] : null;
|
||||
return $student_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the profil updates corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the profil updates
|
||||
* @return array all the profil updates corresponding to a userID
|
||||
*/
|
||||
private function getProfilUpdates($uid)
|
||||
{
|
||||
$profilUpdates = $this->ProfilUpdateModel->getProfilUpdatesWhere(['uid' => $uid]);
|
||||
if (isError($profilUpdates)) {
|
||||
show_error("was not able to query the table public.tbl_profil_update:" . getData($profilUpdates));
|
||||
}
|
||||
$profilUpdates = hasData($profilUpdates) ? getData($profilUpdates) : null;
|
||||
return $profilUpdates;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the Matrikelnummer corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the Matrikelnummer
|
||||
* @return integer the Matrikelnummer corresponding to a userID
|
||||
*/
|
||||
private function getMatrikelNummer($uid)
|
||||
{
|
||||
$this->BenutzerModel->addSelect(["matr_nr"]);
|
||||
$this->BenutzerModel->addJoin("tbl_person", "person_id");
|
||||
|
||||
$matr_res = $this->BenutzerModel->load([$uid]);
|
||||
if (isError($matr_res)) {
|
||||
show_error("was not able to query the table public.tbl_benutzer:" . getData($matr_res));
|
||||
}
|
||||
$matr_res = hasData($matr_res) ? getData($matr_res)[0] : [];
|
||||
return $matr_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the Zutrittsgruppen corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the Zutrittsgruppen
|
||||
* @return array all the Zutrittsgruppen corresponding to a userID
|
||||
*/
|
||||
private function getZutrittsgruppen($uid)
|
||||
{
|
||||
$this->BenutzergruppeModel->addSelect(['bezeichnung']);
|
||||
$this->BenutzergruppeModel->addJoin('tbl_gruppe', 'gruppe_kurzbz');
|
||||
|
||||
$zutrittsgruppe_res = $this->BenutzergruppeModel->loadWhere(array("uid" => $uid, "zutrittssystem" => true));
|
||||
if (isError($zutrittsgruppe_res)) {
|
||||
show_error("was not able to query the table public.tbl_benutzergruppe:" . getData($zutrittsgruppe_res));
|
||||
}
|
||||
$zutrittsgruppe_res = hasData($zutrittsgruppe_res) ? getData($zutrittsgruppe_res) : null;
|
||||
return $zutrittsgruppe_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the address information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the address information
|
||||
* @return array all the address information corresponding to a userID
|
||||
*/
|
||||
private function getAdressenInfo($pid)
|
||||
{
|
||||
$adresse_res = $this->AdresseModel->addSelect(["adresse_id", "strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort", "zustelladresse", "gemeinde", "nation"]);
|
||||
$adresse_res = $this->AdresseModel->addOrder("zustelladresse", "DESC");
|
||||
$adresse_res = $this->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz");
|
||||
|
||||
$adresse_res = $this->AdresseModel->loadWhere(["person_id" => $pid]);
|
||||
if (isError($adresse_res)) {
|
||||
show_error("was not able to query the table public.tbl_adresse:" . getData($adresse_res));
|
||||
}
|
||||
$adresse_res = hasData($adresse_res) ? getData($adresse_res) : null;
|
||||
return $adresse_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the kontakt information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the kontakt information
|
||||
* @return array all the kontakt information corresponding to a userID
|
||||
*/
|
||||
private function getKontaktInfo($pid)
|
||||
{
|
||||
$this->KontaktModel->addSelect(['kontakttyp', 'kontakt_id', 'kontakt', 'tbl_kontakt.anmerkung', 'tbl_kontakt.zustellung']);
|
||||
$this->KontaktModel->addJoin('public.tbl_standort', 'standort_id', 'LEFT');
|
||||
$this->KontaktModel->addJoin('public.tbl_firma', 'firma_id', 'LEFT');
|
||||
$this->KontaktModel->addOrder('kontakttyp, kontakt, tbl_kontakt.updateamum, tbl_kontakt.insertamum');
|
||||
|
||||
$kontakte_res = $this->KontaktModel->loadWhere(['person_id' => $pid]);
|
||||
if (isError($kontakte_res)) {
|
||||
show_error("was not able to query the table public.tbl_kontakt:" . getData($kontakte_res));
|
||||
}
|
||||
$kontakte_res = hasData($kontakte_res) ? getData($kontakte_res) : null;
|
||||
return $kontakte_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the date of issue of the FH access card corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the date of issue of the FH access card
|
||||
* @return string the date of issue of the FH access card corresponding to a userID
|
||||
*/
|
||||
private function getZutrittskarteDatum($uid)
|
||||
{
|
||||
$zutrittskarte_ausgegebenam = $this->BetriebsmittelpersonModel->getBetriebsmittelByUid($uid, "Zutrittskarte");
|
||||
if (isError($zutrittskarte_ausgegebenam)) {
|
||||
show_error("was not able to query the table wavi.tbl_bentriebsmittelperson:" . getData($zutrittskarte_ausgegebenam));
|
||||
}
|
||||
$zutrittskarte_ausgegebenam = hasData($zutrittskarte_ausgegebenam) ? getData($zutrittskarte_ausgegebenam)[0]->ausgegebenam : null;
|
||||
|
||||
//? formats date from 01-01-2000 to 01.01.2000
|
||||
$zutrittskarte_ausgegebenam = str_replace("-", ".", $zutrittskarte_ausgegebenam);
|
||||
return $zutrittskarte_ausgegebenam;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
'updateProfilRequest' => self::PERM_LOGGED,
|
||||
'deleteProfilRequest' => self::PERM_LOGGED,
|
||||
'insertFile' => self::PERM_LOGGED,
|
||||
'updateProfilbild' => self::PERM_LOGGED,
|
||||
'show' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
@@ -478,12 +479,101 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($res);
|
||||
}
|
||||
|
||||
public function updateProfilbild()
|
||||
{
|
||||
|
||||
$resize = function($filename, $width, $height){
|
||||
// Hoehe und Breite neu berechnen
|
||||
list($width_orig, $height_orig) = getimagesize($filename);
|
||||
|
||||
if ($width && ($width_orig < $height_orig))
|
||||
{
|
||||
$width = ($height / $height_orig) * $width_orig;
|
||||
}
|
||||
else
|
||||
{
|
||||
$height = ($width / $width_orig) * $height_orig;
|
||||
}
|
||||
|
||||
$image_p = imagecreatetruecolor($width, $height);
|
||||
|
||||
$image = imagecreatefromjpeg($filename);
|
||||
|
||||
//Bild nur verkleinern aber nicht vergroessern
|
||||
if($width_orig>$width || $height_orig>$height)
|
||||
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
|
||||
else
|
||||
$image_p = $image;
|
||||
|
||||
imagejpeg($image_p, $filename, 80);
|
||||
|
||||
@imagedestroy($image_p);
|
||||
@imagedestroy($image);
|
||||
};
|
||||
|
||||
if (!count($_FILES)) {
|
||||
$this->terminateWithError("No file available for upload");
|
||||
}
|
||||
|
||||
$files = $_FILES['files'];
|
||||
|
||||
$_FILES['files']['name'] = current($files['name']);
|
||||
$_FILES['files']['type'] = current($files['type']);
|
||||
$_FILES['files']['tmp_name'] = current($files['tmp_name']);
|
||||
$_FILES['files']['error'] = current($files['error']);
|
||||
$_FILES['files']['size'] = current($files['size']);
|
||||
$_FILES['files']['tmp_name'] = current($files['tmp_name']);
|
||||
|
||||
$filename = $_FILES['files']['tmp_name'];
|
||||
|
||||
$ext = substr(current($files['name']), strrpos(current($files['name']), '.') + 1);
|
||||
if($ext!='jpg' && $ext!='jpeg'){
|
||||
$this->terminateWithError("Only jpg and jpeg files are allowed for profilbild upload");
|
||||
}
|
||||
|
||||
// resize
|
||||
$resize($filename, 827, 1063);
|
||||
|
||||
//akte
|
||||
$fp = fopen($filename,'r');
|
||||
//auslesen
|
||||
$content = fread($fp, filesize($filename));
|
||||
$base64_content = base64_encode($content);
|
||||
$this->load->library('AkteLib');
|
||||
$aktenInsertResult = $this->aktelib->add($this->pid,'Lichtbil',"Lichtbild_".$this->pid.".jpg","image/jpg",$fp,"Lichtbild gross");
|
||||
fclose($fp);
|
||||
if (isError($aktenInsertResult)) {
|
||||
$this->terminateWithError(getError($aktenInsertResult));
|
||||
}
|
||||
|
||||
// in person abspeichern
|
||||
$resize($filename, 101, 130);
|
||||
$fp = fopen($filename,'r');
|
||||
$content = fread($fp, filesize($filename));
|
||||
fclose($fp);
|
||||
$base64_content = base64_encode($content);
|
||||
$this->load->model('person/Person_model','PersonModel');
|
||||
$personUpdate = $this->PersonModel->update($this->pid, ["foto"=>$base64_content]);
|
||||
if(isError($personUpdate)){
|
||||
$this->terminateWithError(getError($personUpdate));
|
||||
}
|
||||
|
||||
|
||||
// update foto status
|
||||
$this->load->model('person/Fotostatusperson_model','FotostatusModel');
|
||||
$fotoInsert = $this->FotostatusModel->insert(["person_id"=>$this->pid,"fotostatus_kurzbz"=>"hochgeladen","datum"=>date('Y-m-d'),"insertamum"=>date('Y-m-d H:i:s'),"insertvon"=>$this->uid,"updateamum"=>date('Y-m-d H:i:s'),"updatevon"=>$this->uid]);
|
||||
if(isError($fotoInsert)){
|
||||
$this->terminateWithError(getError($fotoInsert));
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess();
|
||||
}
|
||||
|
||||
public function getProfilUpdateWithPermission($status = null)
|
||||
{
|
||||
// early return if no status has been passed as argument
|
||||
if (!isset($status)) {
|
||||
echo json_encode($this->ProfilUpdateModel->getProfilUpdateWithPermission());
|
||||
return;
|
||||
$this->terminateWithSuccess($this->ProfilUpdateModel->getProfilUpdateWithPermission());
|
||||
}
|
||||
|
||||
// get the sprache of the user
|
||||
@@ -496,7 +586,7 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$status = hasData($status) ? getData($status)[0]->status_kurzbz : null;
|
||||
$res = $this->ProfilUpdateModel->getProfilUpdateWithPermission(isset($status) ? ['status' => $status] : null);
|
||||
|
||||
echo json_encode($res);
|
||||
$this->terminateWithSuccess($res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,9 +637,10 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
//? Send email to the Studiengangsassistentinnen
|
||||
$this->StudentModel->addSelect(["public.tbl_studiengang.email"]);
|
||||
$this->StudentModel->addJoin("public.tbl_benutzer", "public.tbl_benutzer.uid = public.tbl_student.student_uid");
|
||||
$this->StudentModel->addJoin("public.tbl_prestudent", "public.tbl_benutzer.person_id = public.tbl_prestudent.person_id");
|
||||
$this->StudentModel->addJoin("public.tbl_prestudent", "public.tbl_benutzer.person_id = public.tbl_prestudent.person_id and public.tbl_student.studiengang_kz = public.tbl_prestudent.studiengang_kz");
|
||||
$this->StudentModel->addJoin("public.tbl_prestudentstatus", "public.tbl_prestudentstatus.prestudent_id = public.tbl_prestudent.prestudent_id");
|
||||
$this->StudentModel->addJoin("public.tbl_studiengang", "public.tbl_studiengang.studiengang_kz = public.tbl_prestudent.studiengang_kz");
|
||||
$this->StudentModel->addGroupBy(["public.tbl_studiengang.email"]);
|
||||
//* check if the benutzer itself is active
|
||||
//* check if the student status is Student or Diplomand (active students)
|
||||
$this->StudentModel->db->where_in("public.tbl_prestudentstatus.status_kurzbz", ['Student', 'Diplomand']);
|
||||
@@ -566,8 +657,10 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
}
|
||||
$mail_res = [];
|
||||
//? sending email
|
||||
foreach ($emails as $email) {
|
||||
array_push($mail_res, sendSanchoMail("profil_update", ['uid' => $uid, 'topic' => $topic, 'href' => APP_ROOT . 'Cis/ProfilUpdate/id/' . $profil_update_id], $email, ("Profil Änderung von " . $uid)));
|
||||
foreach ($emails as $email)
|
||||
{
|
||||
$href = $this->config->item('cis_vilesci_base_url') . $this->config->item('cis_vilesci_index_page') . '/Cis/ProfilUpdate/id/' . $profil_update_id;
|
||||
array_push($mail_res, sendSanchoMail("profil_update", ['uid' => $uid, 'topic' => $topic, 'href' => $href], $email, ("Profil Änderung von " . $uid)));
|
||||
}
|
||||
foreach ($mail_res as $m_res) {
|
||||
if (!$m_res) {
|
||||
@@ -590,21 +683,21 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
|
||||
function languageQuery($language)
|
||||
{
|
||||
return "select index from public.tbl_sprache where sprache = '" + $language + "'";
|
||||
return "select index from public.tbl_sprache where sprache = '" . $language . "'";
|
||||
}
|
||||
|
||||
$this->ProfilUpdateStatusModel->addSelect(["bezeichnung_mehrsprachig[(" . languageQuery('German') . ")] as status_de", "bezeichnung_mehrsprachig[(" . languageQuery('English') . ")] as status_en"]);
|
||||
|
||||
$status_translation = $this->ProfilUpdateStatusModel->loadWhere(["status_kurzbz" => $status]);
|
||||
|
||||
if (isError($status_translation)) {
|
||||
$this->terminateWithError($this->p->t('profilUpdate', 'ProfilUpdateStatusTranslationError'));
|
||||
}
|
||||
|
||||
$status_translation = hasData($status_translation) ? getData($status_translation)[0] : null;
|
||||
|
||||
if (isset($status_translation)) {
|
||||
$mail_res = sendSanchoMail("profil_update_response", ['topic' => $topic, 'status_de' => $status_translation->status_de, 'status_en' => $status_translation->status_en, 'href' => APP_ROOT . 'Cis/Profil'], $email, ("Profil Änderung " . $this->p->t('profilUpdate', 'pending')));
|
||||
if (isset($status_translation))
|
||||
{
|
||||
$href = $this->config->item('cis_base_url') . $this->config->item('cis_index_page') . '/Cis/Profil';
|
||||
$mail_res = sendSanchoMail("profil_update_response", ['topic' => $topic, 'status_de' => $status_translation->status_de, 'status_en' => $status_translation->status_en, 'href' => $href], $email, ("Profil Änderung " . $status_translation->status_de . ' / Profile Update ' . $status_translation->status_en));
|
||||
if (!$mail_res) {
|
||||
$this->addError($this->p->t('profilUpdate', 'profilUpdate_email_error'));
|
||||
}
|
||||
@@ -613,7 +706,13 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
|
||||
private function setStatusOnUpdateRequest($id, $status, $status_message)
|
||||
{
|
||||
return $this->ProfilUpdateModel->update([$id], ["status" => $status, "status_timestamp" => "NOW()", "status_message" => $status_message]);
|
||||
return $this->ProfilUpdateModel->update([$id], [
|
||||
"status" => $status,
|
||||
"status_timestamp" => "NOW()",
|
||||
"status_message" => $status_message,
|
||||
"updateamum" => "NOW()",
|
||||
"updatevon" => getAuthUID()
|
||||
]);
|
||||
}
|
||||
|
||||
private function updateRequestedChange($id, $requested_change)
|
||||
@@ -623,13 +722,12 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
|
||||
private function deleteOldVersionFile($dms_id)
|
||||
{
|
||||
if (!isset($dms_id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// starting the transaction
|
||||
$this->db->trans_start();
|
||||
|
||||
|
||||
if (!isset($dms_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//? delete the file from the profilUpdate first
|
||||
$profilUpdateFileDelete = $this->ProfilUpdateModel->removeFileFromProfilUpdate($dms_id);
|
||||
@@ -684,13 +782,8 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
|
||||
$res = $this->StudentModel->execReadOnlyQuery($query, [$student_uid]);
|
||||
$res = $this->getDataOrTerminateWithError($res, $this->p->t('profilUpdate', 'profilUpdate_loadingOE_error'));
|
||||
$res = array_map(
|
||||
function ($item) {
|
||||
return $item->oe_kurzbz;
|
||||
},
|
||||
$res
|
||||
);
|
||||
return $res;
|
||||
$oe = ($res[0])->oe_kurzbz;
|
||||
return $oe;
|
||||
}
|
||||
|
||||
private function handleAdresse($requested_change, $personID)
|
||||
@@ -720,7 +813,7 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$insert_adresse_id = $insertID;
|
||||
$insert_adresse_id = $this->getDataOrTerminateWithError($insert_adresse_id, $this->p->t('profilUpdate', 'profilUpdate_insertAdresse_error'));
|
||||
if ($insert_adresse_id) {
|
||||
$this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $insert_adresse_id);
|
||||
$this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $insert_adresse_id, $personID);
|
||||
}
|
||||
}
|
||||
//! DELETE
|
||||
@@ -732,12 +825,33 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
}
|
||||
//! UPDATE
|
||||
else {
|
||||
$requested_change['updateamum'] = "NOW()";
|
||||
$requested_change['updatevon'] = getAuthUID();
|
||||
$update_adresse_id = $this->AdresseModel->update($adresse_id, $requested_change);
|
||||
$update_adresse_id = $this->getDataOrTerminateWithError($update_adresse_id, $this->p->t('profilUpdate', 'profilUpdate_updateAdresse_error'));
|
||||
$this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $update_adresse_id);
|
||||
$curadresse_res = $this->AdresseModel->load($adresse_id);
|
||||
$curadresse = ($this->getDataOrTerminateWithError($curadresse_res))[0];
|
||||
|
||||
if($curadresse->heimatadresse)
|
||||
{
|
||||
$tmpadresse = array_merge((array) $curadresse, $requested_change);
|
||||
unset($tmpadresse["adresse_id"]);
|
||||
$tmpadresse['insertamum'] = "NOW()";
|
||||
$tmpadresse['insertvon'] = getAuthUID();
|
||||
$tmpadresse['person_id'] = $personID;
|
||||
unset($tmpadresse["heimatadresse"]);
|
||||
unset($tmpadresse["updateamum"]);
|
||||
unset($tmpadresse["updatevon"]);
|
||||
|
||||
$tmpadresse_res = $this->AdresseModel->insert($tmpadresse);
|
||||
$tmpadresse_id = $this->getDataOrTerminateWithError($tmpadresse_res, $this->p->t('profilUpdate', 'profilUpdate_insertAdresse_error'));
|
||||
$this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $tmpadresse_id, $personID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$requested_change['updateamum'] = "NOW()";
|
||||
$requested_change['updatevon'] = getAuthUID();
|
||||
|
||||
$update_adresse_id = $this->AdresseModel->update($adresse_id, $requested_change);
|
||||
$update_adresse_id = $this->getDataOrTerminateWithError($update_adresse_id, $this->p->t('profilUpdate', 'profilUpdate_updateAdresse_error'));
|
||||
$this->handleDupplicateZustellAdressen($requested_change['zustelladresse'], $update_adresse_id, $personID);
|
||||
}
|
||||
}
|
||||
return $insertID ?? null;
|
||||
}
|
||||
@@ -759,7 +873,7 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$insert_kontakt_id = $insertID;
|
||||
$insert_kontakt_id = $this->getDataOrTerminateWithError($insert_kontakt_id, $this->p->t('profilUpdate', 'profilUpdate_insertKontakt_error'));
|
||||
if ($insert_kontakt_id) {
|
||||
$this->handleDupplicateZustellKontakte($requested_change['zustellung'], $insert_kontakt_id);
|
||||
$this->handleDupplicateZustellKontakte($requested_change['zustellung'], $insert_kontakt_id, $requested_change['kontakttyp'], $personID);
|
||||
}
|
||||
}
|
||||
//! DELETE
|
||||
@@ -776,18 +890,18 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$update_kontakt_id = $this->KontaktModel->update($kontakt_id, $requested_change);
|
||||
$update_kontakt_id = $this->getDataOrTerminateWithError($update_kontakt_id, $this->p->t('profilUpdate', 'profilUpdate_updateKontakt_error'));
|
||||
if ($update_kontakt_id) {
|
||||
$this->handleDupplicateZustellKontakte($requested_change['zustellung'], $update_kontakt_id);
|
||||
$this->handleDupplicateZustellKontakte($requested_change['zustellung'], $update_kontakt_id, $requested_change['kontakttyp'], $personID);
|
||||
}
|
||||
}
|
||||
return isset($insertID) ? $insertID : null;
|
||||
}
|
||||
|
||||
private function handleDupplicateZustellAdressen($zustellung, $adresse_id)
|
||||
private function handleDupplicateZustellAdressen($zustellung, $adresse_id, $person_id)
|
||||
{
|
||||
if ($zustellung) {
|
||||
$this->PersonModel->addSelect("public.tbl_adresse.adresse_id");
|
||||
$this->PersonModel->addJoin("public.tbl_adresse", "public.tbl_adresse.person_id = public.tbl_person.person_id");
|
||||
$zustellAdressenArray = $this->PersonModel->loadWhere(["public.tbl_person.person_id" => $this->pid, "zustelladresse" => TRUE]);
|
||||
$zustellAdressenArray = $this->PersonModel->loadWhere(["public.tbl_person.person_id" => $person_id, "zustelladresse" => TRUE]);
|
||||
if (isError($zustellAdressenArray)) {
|
||||
$this->terminateWithError($this->p->t('profilUpdate', 'profilUpdate_loadingZustellAdressen_error'));
|
||||
}
|
||||
@@ -800,6 +914,8 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
return $adresse->adresse_id != $adresse_id;
|
||||
});
|
||||
|
||||
$this->addMeta('bhzustelladressen', $zustellAdressenArray);
|
||||
|
||||
// remove the zustelladresse from all other zustelladressen
|
||||
foreach ($zustellAdressenArray as $adresse) {
|
||||
$this->AdresseModel->update($adresse->adresse_id, ["zustelladresse" => FALSE]);
|
||||
@@ -809,12 +925,16 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
private function handleDupplicateZustellKontakte($zustellung, $kontakt_id)
|
||||
private function handleDupplicateZustellKontakte($zustellung, $kontakt_id, $kontakttyp, $person_id)
|
||||
{
|
||||
if ($zustellung) {
|
||||
$this->PersonModel->addSelect("public.tbl_kontakt.kontakt_id");
|
||||
$this->PersonModel->addJoin("public.tbl_kontakt", "public.tbl_kontakt.person_id = public.tbl_person.person_id");
|
||||
$zustellKontakteArray = $this->PersonModel->loadWhere(["public.tbl_person.person_id" => $this->pid, "zustellung" => TRUE]);
|
||||
$zustellKontakteArray = $this->PersonModel->loadWhere([
|
||||
"public.tbl_person.person_id" => $person_id,
|
||||
"zustellung" => TRUE,
|
||||
"kontakttyp" => $kontakttyp
|
||||
]);
|
||||
if (!isSuccess($zustellKontakteArray)) {
|
||||
return error($this->p->t('profilUpdate', 'profilUpdate_loadingZustellkontakte_error'));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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;
|
||||
|
||||
class RendererLoader extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct([
|
||||
'GetRenderers' => self::PERM_LOGGED,
|
||||
|
||||
]);
|
||||
|
||||
$this->load->library('LogLib');
|
||||
$this->loglib->setConfigs(array(
|
||||
'classIndex' => 5,
|
||||
'functionIndex' => 5,
|
||||
'lineIndex' => 4,
|
||||
'dbLogType' => 'API', // required
|
||||
'dbExecuteUser' => 'RESTful API'
|
||||
));
|
||||
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* fetches Stundenplan and Moodle events together
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function GetRenderers(){
|
||||
$renderer_paths = [];
|
||||
Events::trigger(
|
||||
'loadRenderers',
|
||||
function & () use (&$renderer_paths)
|
||||
{
|
||||
return $renderer_paths;
|
||||
}
|
||||
);
|
||||
$this->terminateWithSuccess($renderer_paths);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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');
|
||||
|
||||
class RouteInfo extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'info' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->load->model('system/Webservicelog_model', 'WebservicelogModel');
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
$payload = json_decode($this->input->raw_input_stream);
|
||||
|
||||
if (isset($payload->app) && isset($payload->path) && $this->isValidApp($payload->app) && $this->isValidPath($payload->path))
|
||||
{
|
||||
$this->WebservicelogModel->insert(array(
|
||||
'webservicetyp_kurzbz' => 'content',
|
||||
'beschreibung' => $payload->app,
|
||||
'request_data' => $payload->path,
|
||||
'execute_user' => getAuthUID(),
|
||||
'execute_time' => 'NOW()'
|
||||
));
|
||||
}
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
protected function isValidApp($app)
|
||||
{
|
||||
return preg_match("/^[A-Za-z0-9\-_]+$/", $app);
|
||||
}
|
||||
|
||||
protected function isValidPath($path)
|
||||
{
|
||||
return preg_match("/^[\/A-Za-z0-9_.\-~?%=&;]+$/", $path);
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,12 @@ class Searchbar extends FHCAPI_Controller
|
||||
{
|
||||
// NOTE(chris): additional permission checks will be done in SearchBarLib
|
||||
parent::__construct([
|
||||
'search' => self::PERM_LOGGED
|
||||
'search' => self::PERM_LOGGED,
|
||||
'searchCis' => self::PERM_LOGGED,
|
||||
'searchStv' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Load the library SearchBarLib
|
||||
$this->load->library('SearchBarLib');
|
||||
$this->load->model('system/Webservicelog_model', 'WebservicelogModel');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
@@ -50,6 +51,7 @@ class Searchbar extends FHCAPI_Controller
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$this->load->library('SearchBarLib');
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Checks if the searchstr and the types parameters are in the POSTed JSON
|
||||
@@ -63,7 +65,64 @@ class Searchbar extends FHCAPI_Controller
|
||||
$result = $this->searchbarlib->search($this->input->post(self::SEARCHSTR_PARAM), $this->input->post(self::TYPES_PARAM));
|
||||
if (property_exists($result, 'error'))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithSuccess($result);
|
||||
|
||||
$this->addMeta('mode', 'simple');
|
||||
|
||||
$this->terminateWithSuccess($result->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
public function searchCis()
|
||||
{
|
||||
return $this->searchAdvanced([ 'config' => 'searchcis' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
public function searchStv()
|
||||
{
|
||||
return $this->searchAdvanced([ 'config' => 'searchstv' ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
private function searchAdvanced($config)
|
||||
{
|
||||
$this->load->library('SearchLib', $config);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Checks if the searchstr and the types parameters are in the POSTed JSON
|
||||
$this->form_validation->set_rules(self::SEARCHSTR_PARAM, null, 'required');
|
||||
$this->form_validation->set_rules(self::TYPES_PARAM . '[]', null, 'required');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// Convert to json the result from searchlib->search
|
||||
$result = $this->searchlib->search($this->input->post(self::SEARCHSTR_PARAM), $this->input->post(self::TYPES_PARAM));
|
||||
|
||||
$this->WebservicelogModel->insert(array(
|
||||
'webservicetyp_kurzbz' => 'content',
|
||||
'beschreibung' => $config['config'],
|
||||
'request_data' => json_encode(array(
|
||||
self::SEARCHSTR_PARAM => $this->input->post(self::SEARCHSTR_PARAM),
|
||||
self::TYPES_PARAM => $this->input->post(self::TYPES_PARAM)
|
||||
)),
|
||||
'execute_user' => getAuthUID(),
|
||||
'execute_time' => 'NOW()'
|
||||
));
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->addMeta('time', $result->meta['time']);
|
||||
$this->addMeta('searchstring', $result->meta['searchstring']);
|
||||
$this->addMeta('mode', 'advanced');
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,329 @@
|
||||
<?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;
|
||||
|
||||
class Studium extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getStudienAllSemester'=> self::PERM_LOGGED,
|
||||
'getStudiengaengeForStudienSemester'=> self::PERM_LOGGED,
|
||||
'getStudienplaeneBySemester'=> self::PERM_LOGGED,
|
||||
'getLvEvaluierungInfo'=> self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
$this->load->model('organisation/Studienordnung_model','StudienordnungModel');
|
||||
$this->load->model('organisation/Studiensemester_model',"StudiensemesterModel");
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
$this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$this->load->model('codex/Orgform_model','OrgformModel');
|
||||
$this->load->model('person/Person_model','PersonModel');
|
||||
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
public function getStudienAllSemester(){
|
||||
|
||||
$parameter_studiensemester = $this->input->get('studiensemester',true);
|
||||
$parameter_studiengang = $this->input->get('studiengang',true);
|
||||
$parameter_semester = $this->input->get('semester',true);
|
||||
$parameter_studienplan = $this->input->get('studienplan',true);
|
||||
|
||||
$aktuelles_studiensemester = current($this->getDataOrTerminateWithError($this->StudiensemesterModel->getAktOrNextSemester()));
|
||||
|
||||
if($this->getDataOrTerminateWithError($this->StudentModel->isStudent(getAuthUID()))){
|
||||
$studentLehrverband =$this->StudentlehrverbandModel->loadWhere(["student_uid" => getAuthUID(), "studiensemester_kurzbz" => $aktuelles_studiensemester->studiensemester_kurzbz]);
|
||||
$studentLehrverband = current($this->getDataOrTerminateWithError($studentLehrverband));
|
||||
|
||||
$student_studiensemester = $studentLehrverband->studiensemester_kurzbz;
|
||||
$student_studiengang = $studentLehrverband->studiengang_kz;
|
||||
$student_semester = $studentLehrverband->semester;
|
||||
$student_studienplan = $this->getStudienPlanFromPrestudentStatus(getAuthPersonId())->studienplan_id;
|
||||
|
||||
if(!isset($parameter_studiensemester))
|
||||
$parameter_studiensemester = $student_studiensemester;
|
||||
if(!isset($parameter_studiengang))
|
||||
$parameter_studiengang = $student_studiengang;
|
||||
if(!isset($parameter_semester))
|
||||
$parameter_semester = $student_semester;
|
||||
if(!isset($parameter_studienplan))
|
||||
$parameter_studienplan = $student_studienplan;
|
||||
}
|
||||
|
||||
if(isset($parameter_studiensemester)){
|
||||
$parameter_studiensemester = current($this->getDataOrTerminateWithError($this->StudiensemesterModel->loadWhere(["studiensemester_kurzbz" => $parameter_studiensemester])));
|
||||
}
|
||||
|
||||
if(isset($parameter_studiengang)){
|
||||
$parameter_studiengang = current($this->getDataOrTerminateWithError($this->StudiengangModel->loadWhere(["studiengang_kz" => $parameter_studiengang])));
|
||||
}
|
||||
|
||||
if(isset($parameter_studienplan)){
|
||||
$this->StudienplanModel->addJoin("lehre.tbl_studienordnung", "studienordnung_id");
|
||||
$this->StudienplanModel->addJoin("lehre.tbl_studienplan_semester", "studienplan_id");
|
||||
$parameter_studienplan = $this->StudienplanModel->loadWhere(["studienplan_id" => $parameter_studienplan, "aktiv" => TRUE]);
|
||||
$parameter_studienplan = current($this->getDataOrTerminateWithError($parameter_studienplan));
|
||||
}
|
||||
|
||||
// fetch studiensemester
|
||||
$allStudienSemester = $this->getDataOrTerminateWithError($this->StudiensemesterModel->load());
|
||||
|
||||
|
||||
if(isset($parameter_studiensemester) && !empty(array_filter($allStudienSemester, function($studiensemester) use($parameter_studiensemester){
|
||||
return $studiensemester->studiensemester_kurzbz == $parameter_studiensemester->studiensemester_kurzbz;
|
||||
}))){
|
||||
$aktuelles_studiensemester = $parameter_studiensemester;
|
||||
}
|
||||
|
||||
// fetch studiengaenge
|
||||
$studiengaenge = $this->computeStudiengaenge($aktuelles_studiensemester->studiensemester_kurzbz);
|
||||
$aktuelles_studiengang = current($studiengaenge);
|
||||
if(!$aktuelles_studiengang){
|
||||
$aktuelles_studiengang = null;
|
||||
}
|
||||
if(isset($parameter_studiengang) && !empty(array_filter( $studiengaenge,function($studiengang)use($parameter_studiengang){
|
||||
return $studiengang->studiengang_kz == $parameter_studiengang->studiengang_kz;
|
||||
}))){
|
||||
$aktuelles_studiengang = $parameter_studiengang;
|
||||
}
|
||||
|
||||
// compute semester and studienplaene
|
||||
if($aktuelles_studiengang){
|
||||
$studienplaene = $this->computeStudienplaene($aktuelles_studiengang->studiengang_kz, $aktuelles_studiensemester->studiensemester_kurzbz);
|
||||
}else{
|
||||
$studienplaene =[];
|
||||
}
|
||||
|
||||
$semester = array_values(array_unique(array_map(function($item){
|
||||
return $item->semester;
|
||||
}, $studienplaene)));
|
||||
$aktuelles_semester = current($semester);
|
||||
if(!$aktuelles_semester){
|
||||
$aktuelles_semester = null;
|
||||
}
|
||||
if(isset($parameter_semester) && in_array($parameter_semester, $semester)){
|
||||
$aktuelles_semester = $parameter_semester;
|
||||
}
|
||||
|
||||
$semester_studienplan = array_filter($studienplaene, function($item) use($aktuelles_semester){
|
||||
return $item->semester == $aktuelles_semester;
|
||||
});
|
||||
|
||||
// fetch current studienplan based on semester
|
||||
$aktuelles_studienplan = current($semester_studienplan);
|
||||
if(!$aktuelles_studienplan){
|
||||
$aktuelles_studienplan = null;
|
||||
}
|
||||
if(isset($parameter_studienplan) && !empty(array_filter( $semester_studienplan, function($studienplan) use($parameter_studienplan){
|
||||
return $studienplan->studienplan_id == $parameter_studienplan->studienplan_id;
|
||||
}))){
|
||||
$aktuelles_studienplan = $parameter_studienplan ;
|
||||
}
|
||||
|
||||
// fetch studienplan lehrveranstaltungen
|
||||
if($aktuelles_studienplan){
|
||||
$lehrveranstaltungen = $this->computeStudienplanLehrveranstaltungen($aktuelles_studienplan->studienplan_id, $aktuelles_semester);
|
||||
foreach($lehrveranstaltungen as $lehrv){
|
||||
foreach($lehrv->lehrveranstaltungen as $lv){
|
||||
$lvLektoren =$this->computeLektorenFromLehrveranstaltung($lv->lehrveranstaltung_id,$aktuelles_semester, $aktuelles_studiengang->studiengang_kz, $aktuelles_studiensemester->studiensemester_kurzbz);
|
||||
$lv->lektoren = $lvLektoren;
|
||||
}
|
||||
|
||||
}
|
||||
$aktuelles_lehrveranstaltungen = $lehrveranstaltungen;
|
||||
}else{
|
||||
$aktuelles_lehrveranstaltungen = [];
|
||||
}
|
||||
|
||||
// result object
|
||||
$result = new stdClass();
|
||||
$result->studienSemester = [];
|
||||
$result->studienSemester["all"]= $allStudienSemester;
|
||||
$result->studienSemester["preselected"]=$aktuelles_studiensemester;
|
||||
$result->studiengang["all"]=$studiengaenge;
|
||||
$result->studiengang["preselected"]=$aktuelles_studiengang;
|
||||
$result->semester["all"] =$semester;
|
||||
$result->semester["preselected"] =$aktuelles_semester;
|
||||
$result->studienplan["all"]=$semester_studienplan;
|
||||
$result->studienplan["preselected"]=$aktuelles_studienplan;
|
||||
$result->lehrveranstaltungen=$aktuelles_lehrveranstaltungen;
|
||||
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getLvEvaluierungInfo($studiensemester_kurzbz, $lehrveranstaltung_id){
|
||||
$result = [];
|
||||
Events::trigger('lvEvaluierungsInfo', function & () use (&$result) {
|
||||
return $result;
|
||||
},$lehrveranstaltung_id, $studiensemester_kurzbz);
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getStudiengaengeForStudienSemester($studiensemester){
|
||||
$studiengaenge = $this->computeStudiengaenge($studiensemester);
|
||||
$this->terminateWithSuccess($studiengaenge);
|
||||
}
|
||||
|
||||
public function getStudienplaeneBySemester(){
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($this->input->get());
|
||||
$this->form_validation->set_rules('studiengang', 'studiengang', 'required');
|
||||
$this->form_validation->set_rules('studiensemester', 'studiensemester', 'required');
|
||||
if($this->form_validation->run() == FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$studiengang = $this->input->get('studiengang',true);
|
||||
$studiensemester = $this->input->get('studiensemester',true);
|
||||
$studienplaene = $this->computeStudienplaene($studiengang, $studiensemester);
|
||||
$this->terminateWithSuccess($studienplaene);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
private function computeStudienplaene($studiengang, $studiensemester){
|
||||
$studienplaene = $this->StudienplanModel->getStudienplaeneBySemester($studiengang, $studiensemester);
|
||||
$studienplaene = $this->getDataOrTerminateWithError($studienplaene);
|
||||
$studienplaene = array_map(function($studienplan){
|
||||
$orgform = current($this->getDataOrTerminateWithError($this->OrgformModel->loadWhere(["orgform_kurzbz" => $studienplan->orgform_kurzbz])));
|
||||
$studienplan->orgform_bezeichnung = $orgform->bezeichnung;
|
||||
return $studienplan;
|
||||
},$studienplaene);
|
||||
return $studienplaene;
|
||||
}
|
||||
|
||||
private function computeStudienplanLehrveranstaltungen($studienplan_id, $semester){
|
||||
|
||||
/*
|
||||
SELECT tbl_lehrveranstaltung.*,
|
||||
tbl_studienplan_lehrveranstaltung.studienplan_lehrveranstaltung_id,
|
||||
tbl_studienplan_lehrveranstaltung.semester as stpllv_semester,
|
||||
tbl_studienplan_lehrveranstaltung.pflicht as stpllv_pflicht,
|
||||
tbl_studienplan_lehrveranstaltung.koordinator as stpllv_koordinator,
|
||||
tbl_studienplan_lehrveranstaltung.studienplan_lehrveranstaltung_id_parent,
|
||||
tbl_studienplan_lehrveranstaltung.sort stpllv_sort,
|
||||
tbl_studienplan_lehrveranstaltung.curriculum,
|
||||
tbl_studienplan_lehrveranstaltung.export,
|
||||
tbl_studienplan_lehrveranstaltung.genehmigung
|
||||
FROM lehre.tbl_lehrveranstaltung
|
||||
JOIN lehre.tbl_studienplan_lehrveranstaltung
|
||||
USING(lehrveranstaltung_id)
|
||||
WHERE tbl_studienplan_lehrveranstaltung.studienplan_id=" . $this->db_add_param($studienplan_id, FHC_INTEGER);
|
||||
if (defined("CIS_PROFIL_STUDIENPLAN_MODULE_AUSBLENDEN") && CIS_PROFIL_STUDIENPLAN_MODULE_AUSBLENDEN)
|
||||
$qry .= " AND tbl_lehrveranstaltung.lehrtyp_kurzbz != 'modul'";
|
||||
if (!is_null($semester))
|
||||
{
|
||||
$qry.=" AND tbl_studienplan_lehrveranstaltung.semester=" . $this->db_add_param($semester, FHC_INTEGER);
|
||||
} */
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
|
||||
$query = "
|
||||
SELECT tbl_lehrveranstaltung.*,
|
||||
tbl_studienplan_lehrveranstaltung.studienplan_lehrveranstaltung_id,
|
||||
tbl_studienplan_lehrveranstaltung.semester as stpllv_semester,
|
||||
tbl_studienplan_lehrveranstaltung.pflicht as stpllv_pflicht,
|
||||
tbl_studienplan_lehrveranstaltung.koordinator as stpllv_koordinator,
|
||||
tbl_studienplan_lehrveranstaltung.studienplan_lehrveranstaltung_id_parent,
|
||||
tbl_studienplan_lehrveranstaltung.sort stpllv_sort,
|
||||
tbl_studienplan_lehrveranstaltung.curriculum,
|
||||
tbl_studienplan_lehrveranstaltung.export,
|
||||
tbl_studienplan_lehrveranstaltung.genehmigung
|
||||
FROM lehre.tbl_lehrveranstaltung
|
||||
JOIN lehre.tbl_studienplan_lehrveranstaltung
|
||||
USING(lehrveranstaltung_id)
|
||||
WHERE
|
||||
tbl_lehrveranstaltung.lehre = true AND
|
||||
tbl_studienplan_lehrveranstaltung.studienplan_id=? AND tbl_studienplan_lehrveranstaltung.semester=?";
|
||||
|
||||
if (defined("CIS_PROFIL_STUDIENPLAN_MODULE_AUSBLENDEN") && CIS_PROFIL_STUDIENPLAN_MODULE_AUSBLENDEN)
|
||||
$query .= " AND tbl_lehrveranstaltung.lehrtyp_kurzbz != 'modul'";
|
||||
|
||||
$lehrveranstaltungen = $this->LehrveranstaltungModel->execReadOnlyQuery($query,[$studienplan_id, $semester]);
|
||||
|
||||
$lehrveranstaltungen = $this->getDataOrTerminateWithError($lehrveranstaltungen);
|
||||
usort($lehrveranstaltungen, function($a, $b){
|
||||
if($a->lehrtyp_kurzbz == "modul"){
|
||||
return -1;
|
||||
}
|
||||
else if($b->lehrtyp_kurzbz == "modul"){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
$lehrveranstaltungen= array_reduce($lehrveranstaltungen,function($carry, $lehrv){
|
||||
if($lehrv->lehrtyp_kurzbz == "modul"){
|
||||
$lehrv->lehrveranstaltungen = [];
|
||||
array_push($carry, $lehrv);
|
||||
}
|
||||
else{
|
||||
$parent =array_filter($carry, function($item)use($lehrv){
|
||||
return $item->studienplan_lehrveranstaltung_id == $lehrv->studienplan_lehrveranstaltung_id_parent;
|
||||
});
|
||||
$parent = current($parent);
|
||||
if($parent){
|
||||
$parent->lehrveranstaltungen[] = $lehrv;
|
||||
}
|
||||
}
|
||||
return $carry;
|
||||
}, []);
|
||||
return $lehrveranstaltungen;
|
||||
}
|
||||
|
||||
private function computeStudiengaenge($studiensemester){
|
||||
$studiengang_studiensemester_result = $this->StudiengangModel->getStudiengaengeByStudiensemester($studiensemester);
|
||||
$studiengang_studiensemester_result = $this->getDataOrTerminateWithError($studiengang_studiensemester_result);
|
||||
return $studiengang_studiensemester_result;
|
||||
}
|
||||
|
||||
private function getStudienPlanFromPrestudentStatus($person_id){
|
||||
$studienplan_id = current($this->getDataOrTerminateWithError($this->PrestudentstatusModel->getLastStatusPerson($person_id)))->studienplan_id;
|
||||
$studienplan =current($this->getDataOrTerminateWithError($this->StudienplanModel->loadWhere(["studienplan_id"=>$studienplan_id])));
|
||||
return $studienplan;
|
||||
}
|
||||
|
||||
private function computeLektorenFromLehrveranstaltung($lehreinheit_id, $semester, $studiengang, $studiensemester){
|
||||
$this->load->library('StundenplanLib');
|
||||
$lektoren = $this->stundenplanlib->getLektorenFromLehrveranstaltung($lehreinheit_id,$semester, $studiengang,$studiensemester);
|
||||
$lektoren = $this->getDataOrTerminateWithError($lektoren) ?? [];
|
||||
|
||||
$lektoren = array_map(function($lektor){
|
||||
return ["name"=>$this->getDataOrTerminateWithError($this->PersonModel->getFullName($lektor)), "email"=>$lektor."@".DOMAIN];
|
||||
},$lektoren);
|
||||
|
||||
return $lektoren;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,618 +0,0 @@
|
||||
<?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');
|
||||
|
||||
class Stundenplan extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct([
|
||||
'getRoomplan' => self::PERM_LOGGED,
|
||||
'Stunden' => self::PERM_LOGGED,
|
||||
'Reservierungen' => self::PERM_LOGGED,
|
||||
'getStundenplan' => self::PERM_LOGGED,
|
||||
'getLehreinheitStudiensemester' => self::PERM_LOGGED,
|
||||
'studiensemesterDateInterval' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->load->library('LogLib');
|
||||
$this->loglib->setConfigs(array(
|
||||
'classIndex' => 5,
|
||||
'functionIndex' => 5,
|
||||
'lineIndex' => 4,
|
||||
'dbLogType' => 'API', // required
|
||||
'dbExecuteUser' => 'RESTful API'
|
||||
));
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
//load models
|
||||
$this->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
$this->load->model('ressource/Reservierung_model', 'ReservierungModel');
|
||||
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
//TODO: delete this function if we don't use the old calendar export endpoints anymore
|
||||
public function studiensemesterDateInterval($date){
|
||||
$this->load->model('organisation/Studiensemester_model','StudiensemesterModel');
|
||||
$studiensemester =$this->StudiensemesterModel->getByDate(date_format(date_create($date),'Y-m-d'));
|
||||
$studiensemester =current($this->getDataOrTerminateWithError($studiensemester));
|
||||
$this->terminateWithSuccess($studiensemester);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* fetches Stunden layout from database
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function Stunden()
|
||||
{
|
||||
$this->load->model('ressource/Stunde_model', 'StundeModel');
|
||||
|
||||
$stunden = $this->StundeModel->load();
|
||||
|
||||
$stunden = $this->getDataOrTerminateWithError($stunden);
|
||||
|
||||
$this->terminateWithSuccess($stunden);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches room events from a certain date
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
public function getRoomplan()
|
||||
{
|
||||
// form validation
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($_GET);
|
||||
$this->form_validation->set_rules('ort_kurzbz',"Ort","required");
|
||||
$this->form_validation->set_rules('start_date',"start_date","required");
|
||||
$this->form_validation->set_rules('end_date',"end_date","required");
|
||||
if($this->form_validation->run() === FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the get parameter in local variables
|
||||
$ort_kurzbz = $this->input->get('ort_kurzbz', TRUE);
|
||||
$start_date = $this->input->get('start_date', TRUE);
|
||||
$end_date = $this->input->get('end_date', TRUE);
|
||||
|
||||
$roomplan_data = $this->StundenplanModel->stundenplanGruppierung($this->StundenplanModel->getRoomQuery($ort_kurzbz, $start_date, $end_date));
|
||||
|
||||
$roomplan_data = $this->getDataOrTerminateWithError($roomplan_data);
|
||||
|
||||
$this->expand_object_information($roomplan_data);
|
||||
|
||||
$this->terminateWithSuccess($roomplan_data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches stundenplan events from a UID and start/end date
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
|
||||
public function getStundenplan(){
|
||||
|
||||
$this->load->model('ressource/Mitarbeiter_model','MitarbeiterModel');
|
||||
$this->load->model('organisation/Studiensemester_model','StudiensemesterModel');
|
||||
$this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$this->load->model('person/Benutzergruppe_model','BenutzergruppeModel');
|
||||
|
||||
// form validation
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($_GET);
|
||||
$this->form_validation->set_rules('start_date', "start_date", "required");
|
||||
$this->form_validation->set_rules('end_date', "end_date", "required");
|
||||
if ($this->form_validation->run() === FALSE)
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
// storing the get parameter in local variables
|
||||
$start_date = $this->input->get('start_date', TRUE);
|
||||
$end_date = $this->input->get('end_date', TRUE);
|
||||
$lv_id = $this->input->get('lv_id', TRUE);
|
||||
|
||||
$student_uid = getAuthUID();
|
||||
if(is_null($student_uid))
|
||||
{
|
||||
$this->terminateWithError("No UID");
|
||||
}
|
||||
|
||||
$semester_range = $this->studienSemesterErmitteln($start_date,$end_date);
|
||||
$this->sortStudienSemester($semester_range);
|
||||
$this->applyLoadUeberSemesterHaelfte($semester_range);
|
||||
|
||||
if($lv_id) { // fetch Stundenplan for lva, irrelevant of who is requesting it (for now)
|
||||
|
||||
$stundenplan_data = $this->StundenplanModel->getStundenplanLVA($start_date, $end_date, $lv_id);
|
||||
$stundenplan_data = $this->getDataOrTerminateWithError($stundenplan_data) ?? [];
|
||||
$this->expand_object_information($stundenplan_data);
|
||||
|
||||
// query lv itself in case its Stundenplan is being queried and it has no entries
|
||||
$this->load->model('education/Lehrveranstaltung_model','LehrveranstaltungModel');
|
||||
$lv = getData($this->LehrveranstaltungModel->load($lv_id))[0];
|
||||
$this->addMeta('lv', $lv);
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
|
||||
}
|
||||
|
||||
$is_mitarbeiter = getData($this->MitarbeiterModel->isMitarbeiter($student_uid));
|
||||
if($is_mitarbeiter)
|
||||
{
|
||||
|
||||
$stundenplan_data = $this->StundenplanModel->getStundenplanMitarbeiter($start_date, $end_date, $student_uid);
|
||||
$stundenplan_data = $this->getDataOrTerminateWithError($stundenplan_data) ?? [];
|
||||
$this->expand_object_information($stundenplan_data);
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
} else {
|
||||
// getting the gruppen_kurzbz of the student in the different studiensemester
|
||||
$benutzer_gruppen = $this->fetchBenutzerGruppenFromStudiensemester($semester_range);
|
||||
|
||||
// getting the student_lehrverbaende of the student in the different studiensemester
|
||||
$student_lehrverband = $this->fetchStudentlehrverbandFromStudiensemester($semester_range);
|
||||
|
||||
$stundenplan_query = $this->StundenplanModel->getStundenplanQuery($start_date, $end_date, $semester_range, $benutzer_gruppen, $student_lehrverband);
|
||||
if(!$stundenplan_query)
|
||||
{
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
$stundenplan_data = $this->StundenplanModel->stundenplanGruppierung($stundenplan_query);
|
||||
$stundenplan_data = $this->getDataOrTerminateWithError($stundenplan_data) ?? [];
|
||||
|
||||
$this->expand_object_information($stundenplan_data);
|
||||
|
||||
$this->returnObj['$stundenplan_query'] = $stundenplan_query;
|
||||
$this->returnObj['$student_lehrverband'] = $student_lehrverband;
|
||||
$this->returnObj['$benutzer_gruppen'] = $benutzer_gruppen;
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// gets the reservierungen of a room if the ort_kurzbz parameter is supplied otherwise gets the reservierungen of the stundenplan of a student
|
||||
public function Reservierungen($ort_kurzbz = null)
|
||||
{
|
||||
//form validation
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_data($_GET);
|
||||
$this->form_validation->set_rules('start_date', "StartDate", "required");
|
||||
$this->form_validation->set_rules('end_date', "EndDate", "required");
|
||||
if($this->form_validation->run() == FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$this->load->model('ressource/Mitarbeiter_model','MitarbeiterModel');
|
||||
|
||||
// storing the get parameter in local variables
|
||||
$start_date = $this->input->get('start_date', TRUE);
|
||||
$end_date = $this->input->get('end_date', TRUE);
|
||||
|
||||
$is_mitarbeiter = getData($this->MitarbeiterModel->isMitarbeiter(getAuthUID()));
|
||||
if($is_mitarbeiter)
|
||||
{
|
||||
$reservierungen = $this->ReservierungModel->getReservierungenMitarbeiter($start_date, $end_date, $ort_kurzbz);
|
||||
} else {
|
||||
// querying the reservierungen
|
||||
$reservierungen = $this->ReservierungModel->getReservierungen($start_date, $end_date, $ort_kurzbz);
|
||||
}
|
||||
|
||||
$reservierungen = $this->getDataOrTerminateWithError($reservierungen) ?? [];
|
||||
$this->expand_object_information($reservierungen);
|
||||
$this->terminateWithSuccess($reservierungen);
|
||||
|
||||
}
|
||||
|
||||
public function getLehreinheitStudiensemester($lehreinheit_id){
|
||||
$this->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->LehreinheitModel->addSelect(["studiensemester_kurzbz"]);
|
||||
$result = $this->LehreinheitModel->load($lehreinheit_id);
|
||||
$result = current($this->getDataOrTerminateWithError($result))->studiensemester_kurzbz;
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
// ################# Private Functions
|
||||
|
||||
private function expand_object_information($data){
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
|
||||
$lektor_obj_array = array();
|
||||
$gruppe_obj_array = array();
|
||||
|
||||
// load lektor object
|
||||
foreach ($item->lektor as $lv_lektor)
|
||||
{
|
||||
$this->StundenplanModel->addLimit(1);
|
||||
$lektor_object = $this->StundenplanModel->execReadOnlyQuery("
|
||||
SELECT mitarbeiter_uid, vorname, nachname, kurzbz
|
||||
FROM public.tbl_mitarbeiter
|
||||
JOIN public.tbl_benutzer benutzer ON benutzer.uid = mitarbeiter_uid
|
||||
JOIN public.tbl_person person ON person.person_id = benutzer.person_id
|
||||
WHERE kurzbz = ?", [$lv_lektor]);
|
||||
if (isError($lektor_object)) {
|
||||
$this->show_error(getError($lektor_object));
|
||||
}
|
||||
$lektor_object = $this->getDataOrTerminateWithError($lektor_object);
|
||||
if(count($lektor_object) == 0)
|
||||
{
|
||||
$this->terminateWithError("No lektor object");
|
||||
}
|
||||
$lektor_object = current($lektor_object);
|
||||
// only provide needed information of the mitarbeiter object
|
||||
$lektor_obj_array[] = $lektor_object;
|
||||
}
|
||||
|
||||
// load gruppe object
|
||||
foreach ($item->gruppe as $lv_gruppe)
|
||||
{
|
||||
$lv_gruppe = strtr($lv_gruppe, ['(' => '', ')' => '', '"' => '']);
|
||||
$lv_gruppe_array = explode(",", $lv_gruppe);
|
||||
list($gruppe, $verband, $semester, $studiengang_kz, $gruppen_kuerzel) = $lv_gruppe_array;
|
||||
|
||||
$lv_gruppe_object = new stdClass();
|
||||
$lv_gruppe_object->gruppe = $gruppe;
|
||||
$lv_gruppe_object->verband = $verband;
|
||||
$lv_gruppe_object->semester = $semester;
|
||||
$lv_gruppe_object->studiengang_kz = $studiengang_kz;
|
||||
$lv_gruppe_object->kuerzel = $gruppen_kuerzel;
|
||||
|
||||
$gruppe_obj_array[] = $lv_gruppe_object;
|
||||
}
|
||||
|
||||
if($item->ort_kurzbz) {
|
||||
|
||||
$ort_content_object = $this->StundenplanModel->execReadOnlyQuery("
|
||||
SELECT content_id
|
||||
FROM public.tbl_ort
|
||||
WHERE ort_kurzbz = ?", [$item->ort_kurzbz]);
|
||||
if (isError($ort_content_object)) {
|
||||
$this->show_error(getError($ort_content_object));
|
||||
}
|
||||
$ort_content_object = getData($ort_content_object)[0];
|
||||
if($ort_content_object) {
|
||||
$item->ort_content_id = $ort_content_object->content_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$item->gruppe = $gruppe_obj_array;
|
||||
$item->lektor = $lektor_obj_array;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// function used to sort an array of studiensemester strings
|
||||
private function sortStudienSemester(&$semester_range){
|
||||
usort(
|
||||
$semester_range,
|
||||
function($first,$second)
|
||||
{
|
||||
$sem_first = null;
|
||||
$year_first = null;
|
||||
$match_first = null;
|
||||
|
||||
$sem_second = null;
|
||||
$year_second = null;
|
||||
$match_second = null;
|
||||
|
||||
preg_match('/([WS]+)([0-9]+)/',$first,$match_first);
|
||||
preg_match('/([WS]+)([0-9]+)/',$second,$match_second);
|
||||
|
||||
$sem_first = $match_first[1];
|
||||
$year_first = intval($match_first[2]);
|
||||
|
||||
$sem_second = $match_second[1];
|
||||
$year_second = intval($match_second[2]);
|
||||
|
||||
if($year_first < $year_second)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if($year_first > $year_second)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if($year_first == $year_second && $sem_first > $sem_second)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if($year_first == $year_second && $sem_first < $sem_second)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function fetchBenutzerGruppenFromStudiensemester($semester_range){
|
||||
$student_uid = getAuthUID();
|
||||
$benutzer_gruppen = [];
|
||||
// for each studiensemester fetch the benutzer gruppen and add them to an associate $bentuzer_gruppen array
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [['gruppe1_SS2023','gruppe2_SS2023'],['gruppe1_WS2023','gruppe2_WS2023']],
|
||||
['SS2024'] => [['gruppe1_WS2023','gruppe2_WS2023'],['gruppe1_SS2024','gruppe2_SS2024']],
|
||||
['WS2024'] => [['gruppe1_SS2024','gruppe2_SS2024'],['gruppe1_WS2024','gruppe2_WS2024']],
|
||||
]
|
||||
*/
|
||||
foreach($semester_range as $semester_key => $semester_array)
|
||||
{
|
||||
$benutzer_gruppen[$semester_key] = [];
|
||||
// each semester could have ajoint semesters that need to be checked
|
||||
foreach($semester_array as $semester=>$semester_date_range)
|
||||
{
|
||||
// for each active semester query the benutzer_gruppen associated to the semester
|
||||
$benutzer_query = $this->BenutzergruppeModel->execReadOnlyQuery("
|
||||
SELECT * FROM tbl_benutzergruppe where uid = ? AND studiensemester_kurzbz = ?",[$student_uid, $semester]);
|
||||
$benutzer_query_result = $this->getDataOrTerminateWithError($benutzer_query);
|
||||
array_push(
|
||||
$benutzer_gruppen[$semester_key],
|
||||
array_map(
|
||||
function($item)
|
||||
{
|
||||
return "'".$item->gruppe_kurzbz. "'";
|
||||
},
|
||||
$benutzer_query_result
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// merge the gruppen of each studiensemester together for the original studiensemester
|
||||
/*
|
||||
[
|
||||
['WS2023'] => ['gruppe1_SS2023','gruppe2_SS2023','gruppe1_WS2023','gruppe2_WS2023'],
|
||||
['SS2024'] => ['gruppe1_WS2023','gruppe2_WS2023','gruppe1_SS2024','gruppe2_SS2024'],
|
||||
['WS2024'] => ['gruppe1_SS2024','gruppe2_SS2024','gruppe1_WS2024','gruppe2_WS2024'],
|
||||
]
|
||||
*/
|
||||
$benutzer_gruppen = array_map(
|
||||
function($gruppe)
|
||||
{
|
||||
$merged_gruppe = [];
|
||||
foreach($gruppe as $gruppen_array)
|
||||
{
|
||||
$merged_gruppe = array_merge($merged_gruppe, $gruppen_array);
|
||||
}
|
||||
return $merged_gruppe;
|
||||
},
|
||||
$benutzer_gruppen
|
||||
);
|
||||
|
||||
return $benutzer_gruppen;
|
||||
}
|
||||
|
||||
private function fetchStudentlehrverbandFromStudiensemester($semester_range){
|
||||
$student_uid = getAuthUID();
|
||||
$student_lehrverband = [];
|
||||
// for each studiensemester fetch the studentlehrverbaende and add them to an associate $student_lehrverband array
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [ [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
['SS2024'] => [ [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ], [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
['WS2024'] => [ [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ], [ ['stg_kz'=>298,'semester'=>3,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
]
|
||||
*/
|
||||
foreach($semester_range as $semester_key => $semester_array)
|
||||
{
|
||||
$student_lehrverband[$semester_key] = [];
|
||||
foreach($semester_array as $semester=>$semester_date_range)
|
||||
{
|
||||
// for each active semester query the student_lehrverband associated to the semester
|
||||
$lehrverband_query = $this->BenutzergruppeModel->execReadOnlyQuery("
|
||||
SELECT * FROM tbl_studentlehrverband where student_uid = ? AND studiensemester_kurzbz = ?", [$student_uid, $semester]);
|
||||
$lehrverband_query_result = $this->getDataOrTerminateWithError($lehrverband_query);
|
||||
array_push($student_lehrverband[$semester_key], array_map(
|
||||
function ($item)
|
||||
{
|
||||
$result = new stdClass();
|
||||
$result->studiengang_kz = $item->studiengang_kz;
|
||||
$result->semester = $item->semester;
|
||||
$result->verband = $item->verband;
|
||||
$result->gruppe = $item->gruppe;
|
||||
return $result;
|
||||
},
|
||||
$lehrverband_query_result));
|
||||
}
|
||||
}
|
||||
|
||||
// merge the studentlehrverband of each studiensemester together for the original studiensemester
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ],
|
||||
['SS2024'] => [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""], ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ],
|
||||
['WS2024'] => [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""], ['stg_kz'=>298,'semester'=>3,'verband'=>"A",'gruppe'=>""] ],
|
||||
]
|
||||
*/
|
||||
$student_lehrverband = array_map(
|
||||
function($studentlehrverband)
|
||||
{
|
||||
$merged_studentlehrverband = [];
|
||||
foreach($studentlehrverband as $studentlehrverband_array)
|
||||
{
|
||||
$merged_studentlehrverband = array_merge($merged_studentlehrverband, $studentlehrverband_array);
|
||||
}
|
||||
return $merged_studentlehrverband;
|
||||
},
|
||||
$student_lehrverband
|
||||
);
|
||||
|
||||
return $student_lehrverband;
|
||||
}
|
||||
|
||||
private function applyLoadUeberSemesterHaelfte(&$semester_range){
|
||||
/*
|
||||
@var($semester_collection)
|
||||
convert the array of studiensemester into an associative array with the studiensemester as the key
|
||||
and the values of each key are the studiensemester needed for the query associated to that studiensemester
|
||||
example:
|
||||
|
||||
#INPUT:
|
||||
['WS2023','SS2024','WS2024']
|
||||
#OUTPUT:
|
||||
[
|
||||
'WS2023' => ['SS2023','WS2023']
|
||||
'SS2024' => ['WS2023','SS2024']
|
||||
'WS2024' => ['SS2024','WS2024']
|
||||
]
|
||||
*/
|
||||
$semester_collection = [];
|
||||
foreach($semester_range as $studiensemester)
|
||||
{
|
||||
$previous_studiensemester = $this->StudiensemesterModel->getPreviousFrom($studiensemester);
|
||||
$previous_studiensemester = $this->getDataOrTerminateWithError($previous_studiensemester);
|
||||
if (count($previous_studiensemester) == 0) {
|
||||
$this->terminateWithError("No previous semester");
|
||||
}
|
||||
$previous_studiensemester = current($previous_studiensemester)->studiensemester_kurzbz;
|
||||
$semester_collection[$studiensemester] = [$previous_studiensemester, $studiensemester];
|
||||
}
|
||||
|
||||
/*
|
||||
@var($studienSemesterDateRanges)
|
||||
fetches for each studiensemester the start and end date, (SS) summer studiensemester are extended by 1 month to cover the summerbreak
|
||||
based on the LVPLAN_LOAD_UEBER_SEMESTERHAELFTE constant it will load both the semester and the previous semester with the full date range
|
||||
or the semester with the full date range and the previous semester with the half date range:
|
||||
|
||||
#INPUT:
|
||||
[
|
||||
'WS2023' => ['SS2023','WS2023']
|
||||
'SS2024' => ['WS2023','SS2024']
|
||||
'WS2024' => ['SS2024','WS2024']
|
||||
]
|
||||
#OUTPUT: depends whether LVPLAN_LOAD_UEBER_SEMESTERHAELFTE is true or false
|
||||
~ if LVPLAN_LOAD_UEBER_SEMESTERHAELFTE == true
|
||||
[
|
||||
"SS2024": [
|
||||
"WS2023": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
],
|
||||
"SS2024": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
]
|
||||
]
|
||||
]
|
||||
~ if LVPLAN_LOAD_UEBER_SEMESTERHAELFTE == false
|
||||
[
|
||||
"SS2024": [
|
||||
"WS2023": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-05-17"
|
||||
],
|
||||
"SS2024": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
]
|
||||
]
|
||||
]
|
||||
*/
|
||||
$studienSemesterDateRanges=[];
|
||||
foreach($semester_collection as $semester_original => $semester_adjoint)
|
||||
{
|
||||
$semester_start_ende = $this->StudiensemesterModel->getStartEndeFromStudiensemester($semester_original);
|
||||
$semester_start_ende = current($this->getDataOrTerminateWithError($semester_start_ende));
|
||||
|
||||
// initialize empty arrays to add key value pairs
|
||||
$studienSemesterDateRanges[$semester_original] = [];
|
||||
|
||||
// check if the studiensemester is a summer semester and add 1 month to bridge the school summer break
|
||||
$match = null;
|
||||
preg_match("/^(SS)([0-9]+)/",$semester_original,$match);
|
||||
if(count($match) >0)
|
||||
{
|
||||
$one_month = new DateInterval('P1M');
|
||||
$one_day = DateInterval::createFromDateString('1 days');
|
||||
$summer_studiensemester_end_date = DateTime::createFromFormat('Y-m-d',$semester_start_ende->ende);
|
||||
$summer_studiensemester_end_date->add($one_month);
|
||||
$summer_studiensemester_end_date->sub($one_day);
|
||||
$semester_start_ende->ende = date_format($summer_studiensemester_end_date,'Y-m-d');
|
||||
}
|
||||
if (defined('LVPLAN_LOAD_UEBER_SEMESTERHAELFTE') && LVPLAN_LOAD_UEBER_SEMESTERHAELFTE === true)
|
||||
{
|
||||
foreach($semester_adjoint as $adjoint)
|
||||
{
|
||||
$studienSemesterDateRanges[$semester_original][$adjoint]=$semester_start_ende;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: half of a DateInterval might not be correctly calculated
|
||||
// calculate the half of the studiensemester
|
||||
$studiensemester_start_date = DateTime::createFromFormat('Y-m-d',$semester_start_ende->start);
|
||||
$studiensemester_end_date = DateTime::createFromFormat('Y-m-d',$semester_start_ende->ende);
|
||||
$studiensemester_time_difference = $studiensemester_start_date->diff($studiensemester_end_date);
|
||||
$half_dateNumber = ceil($studiensemester_time_difference->d/2)+ceil(($studiensemester_time_difference->m*30)/2);
|
||||
$half_dateInterval = new DateInterval('P'.strval($half_dateNumber) .'D');
|
||||
$studiensemester_half = date_format($studiensemester_start_date->add($half_dateInterval),'Y-m-d');
|
||||
|
||||
$first_half = new stdClass();
|
||||
$first_half->start = $semester_start_ende->start;
|
||||
$first_half->ende = $studiensemester_half;
|
||||
|
||||
$studienSemesterDateRanges[$semester_original][$semester_adjoint[0]] = $first_half;
|
||||
$studienSemesterDateRanges[$semester_original][$semester_adjoint[1]] = $semester_start_ende;
|
||||
}
|
||||
$semester_range = $studienSemesterDateRanges;
|
||||
}
|
||||
}
|
||||
|
||||
private function studienSemesterErmitteln($start_date,$end_date){
|
||||
|
||||
// gets all studiensemester from the student from start_date to end_date
|
||||
$semester_range = $this->StudiensemesterModel->getByDateRange($start_date,$end_date);
|
||||
$semester_range = array_map(
|
||||
function($sem)
|
||||
{
|
||||
return $sem->studiensemester_kurzbz;
|
||||
},
|
||||
$this->getDataOrTerminateWithError($semester_range)
|
||||
);
|
||||
|
||||
// if no studiensemester is found for the given timespan, get the nearest studiensemester
|
||||
if(count($semester_range) == 0)
|
||||
{
|
||||
$aktuelle_studiensemester = $this->StudiensemesterModel->getNearest();
|
||||
$aktuelle_studiensemester = $this->getDataOrTerminateWithError($aktuelle_studiensemester);
|
||||
if (count($aktuelle_studiensemester) == 0) {
|
||||
$this->terminateWithError("No aktuelles semester");
|
||||
}
|
||||
$aktuelle_studiensemester = current($aktuelle_studiensemester)->studiensemester_kurzbz;
|
||||
// push aktuelles semester in active semester array
|
||||
array_push($semester_range, $aktuelle_studiensemester);
|
||||
|
||||
}
|
||||
return $semester_range;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,7 +60,11 @@ class BetriebsmittelP extends FHCAPI_Controller
|
||||
|
||||
public function getAllBetriebsmittel($type_id, $id)
|
||||
{
|
||||
$result = $this->BetriebsmittelpersonModel->getBetriebsmittelData($id, $type_id);
|
||||
$betriebsmitteltypes = null;
|
||||
if ($this->input->get('betriebsmitteltypes') !== null && !isEmptyArray($this->input->get('betriebsmitteltypes')))
|
||||
$betriebsmitteltypes = $this->input->get('betriebsmitteltypes');
|
||||
|
||||
$result = $this->BetriebsmittelpersonModel->getBetriebsmittelData($id, $type_id, $betriebsmitteltypes);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
@@ -75,8 +79,9 @@ class BetriebsmittelP extends FHCAPI_Controller
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired')
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('kaution', 'Kaution', 'numeric|less_than_equal_to[9999.99]', [
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric')
|
||||
$this->form_validation->set_rules('kaution', 'Kaution', 'callback_valid_number|callback_not_less_than_equal', [
|
||||
'valid_number' => $this->p->t('ui', 'error_fieldNoValidNumber'),
|
||||
'not_less_than_equal' => $this->p->t('ui', 'error_fieldLessThan1000'),
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('ausgegebenam', 'Ausgegeben am', 'required|is_valid_date', [
|
||||
@@ -158,6 +163,7 @@ class BetriebsmittelP extends FHCAPI_Controller
|
||||
], [
|
||||
'uid_in_person' => $this->p->t('person', 'error_uidNotInPerson')
|
||||
]);
|
||||
|
||||
$this->validateNewOrUpdate();
|
||||
|
||||
$betriebsmitteltyp = $this->input->post('betriebsmitteltyp');
|
||||
@@ -167,6 +173,7 @@ class BetriebsmittelP extends FHCAPI_Controller
|
||||
$betriebsmittel_id = $this->input->post('betriebsmittel_id');
|
||||
$anmerkung = $this->input->post('anmerkung');
|
||||
$kaution = $this->input->post('kaution');
|
||||
if($kaution) $kaution = str_replace(',', '.', $kaution);
|
||||
$ausgegebenam = $this->input->post('ausgegebenam');
|
||||
$retouram = $this->input->post('retouram');
|
||||
$uid = $this->input->post('uid');
|
||||
@@ -250,6 +257,7 @@ class BetriebsmittelP extends FHCAPI_Controller
|
||||
$betriebsmittel_id = $this->input->post('betriebsmittel_id');
|
||||
$anmerkung = $this->input->post('anmerkung');
|
||||
$kaution = $this->input->post('kaution');
|
||||
if($kaution) $kaution = str_replace(',', '.', $kaution);
|
||||
$ausgegebenam = $this->input->post('ausgegebenam');
|
||||
$retouram = $this->input->post('retouram');
|
||||
|
||||
@@ -366,6 +374,12 @@ class BetriebsmittelP extends FHCAPI_Controller
|
||||
$this->load->model('ressource/Betriebsmitteltyp_model', 'BetriebsmitteltypModel');
|
||||
|
||||
$this->BetriebsmitteltypModel->addOrder('beschreibung', 'ASC');
|
||||
|
||||
if ($this->input->get('betriebsmitteltypes') !== null && !isEmptyArray($this->input->get('betriebsmitteltypes')))
|
||||
{
|
||||
$this->BetriebsmitteltypModel->db->where_in('betriebsmitteltyp', $this->input->get('betriebsmitteltypes'));
|
||||
}
|
||||
|
||||
$result = $this->BetriebsmitteltypModel->load(); // load All
|
||||
|
||||
if (isError($result)) {
|
||||
@@ -382,6 +396,26 @@ class BetriebsmittelP extends FHCAPI_Controller
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function valid_number($number)
|
||||
{
|
||||
if(is_null($number)) return true;
|
||||
$number = str_replace(',', '.', $number);
|
||||
if (!is_numeric($number))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function not_less_than_equal($number)
|
||||
{
|
||||
$number = str_replace(',', '.', $number);
|
||||
if ($number < 1000)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Funktionen extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//TODO(Manu) check permissions
|
||||
parent::__construct(array(
|
||||
'getAllFunctions' => ['admin:r', 'assistenz:r'],
|
||||
'getAllUserFunctions' => ['admin:r', 'assistenz:r'],
|
||||
'getOrgHeads' => ['admin:r', 'assistenz:r'],
|
||||
'getOrgetsForCompany' => ['admin:r', 'assistenz:r'],
|
||||
'getAllOrgUnits' => ['admin:r', 'assistenz:r'],
|
||||
'loadFunction' => ['admin:r', 'assistenz:r'],
|
||||
'insertFunction' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateFunction' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteFunction' => ['admin:rw', 'assistenz:rw'],
|
||||
)
|
||||
);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui',
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('extensions/FHC-Core-Personalverwaltung/Api_model', 'ApiModel');
|
||||
$this->load->model('ressource/Funktion_model', 'FunktionModel');
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
|
||||
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
|
||||
}
|
||||
|
||||
public function getAllFunctions()
|
||||
{
|
||||
$this->FunktionModel->addSelect("funktion_kurzbz");
|
||||
$this->FunktionModel->addSelect("beschreibung");
|
||||
$this->FunktionModel->addSelect("aktiv");
|
||||
$this->FunktionModel->addSelect("beschreibung AS label");
|
||||
$this->FunktionModel->addOrder("beschreibung");
|
||||
$result = $this->FunktionModel->load();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getOrgHeads()
|
||||
{
|
||||
$result = $this->OrganisationseinheitModel->getHeads();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getAllUserFunctions($uid)
|
||||
{
|
||||
if(!$uid)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'UID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
dv.dienstverhaeltnis_id,
|
||||
un.bezeichnung || ' (' || TO_CHAR(dv.von, 'DD.MM.YYYY') || CASE WHEN dv.bis IS NOT NULL THEN ' - '
|
||||
|| TO_CHAR(dv.bis, 'DD.MM.YYYY') ELSE '' END || ')' AS dienstverhaeltnis_unternehmen ,
|
||||
'[' || oet.bezeichnung || '] ' || oe.bezeichnung AS funktion_oebezeichnung,
|
||||
f.beschreibung AS funktion_beschreibung,
|
||||
bf.*,
|
||||
fb.bezeichnung AS fachbereich_bezeichnung,
|
||||
CASE
|
||||
WHEN
|
||||
bf.datum_bis IS NOT NULL AND bf.datum_bis::date < now()::date
|
||||
THEN
|
||||
false
|
||||
ELSE
|
||||
true
|
||||
END aktiv
|
||||
FROM
|
||||
public.tbl_benutzerfunktion bf
|
||||
JOIN
|
||||
public.tbl_organisationseinheit oe ON oe.oe_kurzbz = bf.oe_kurzbz
|
||||
JOIN
|
||||
public.tbl_organisationseinheittyp oet ON oe.organisationseinheittyp_kurzbz = oet.organisationseinheittyp_kurzbz
|
||||
JOIN
|
||||
public.tbl_funktion f ON f.funktion_kurzbz = bf.funktion_kurzbz
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_funktion vf ON vf.benutzerfunktion_id = bf.benutzerfunktion_id
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil v ON vf.vertragsbestandteil_id = v.vertragsbestandteil_id
|
||||
LEFT JOIN
|
||||
hr.tbl_dienstverhaeltnis dv ON v.dienstverhaeltnis_id = dv.dienstverhaeltnis_id
|
||||
LEFT JOIN
|
||||
public.tbl_organisationseinheit un ON dv.oe_kurzbz = un.oe_kurzbz
|
||||
LEFT JOIN
|
||||
public.tbl_fachbereich fb ON fb.fachbereich_kurzbz = bf.fachbereich_kurzbz
|
||||
WHERE
|
||||
bf.uid = ?
|
||||
ORDER BY
|
||||
bf.datum_von, bf.datum_von ASC";
|
||||
|
||||
$benutzerfunktionen = $this->BenutzerfunktionModel->execReadOnlyQuery($sql, array($uid));
|
||||
$data = $this->getDataOrTerminateWithError($benutzerfunktionen);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns list of all organisation units
|
||||
* as key value list to be used in select or autocomplete
|
||||
*/
|
||||
public function getAllOrgUnits()
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
oe.oe_kurzbz, oe.aktiv,
|
||||
'[' || COALESCE(oet.bezeichnung, oet.organisationseinheittyp_kurzbz) ||
|
||||
'] ' || COALESCE(oe.bezeichnung, oe.oe_kurzbz) AS label
|
||||
FROM public.tbl_organisationseinheit oe
|
||||
JOIN public.tbl_organisationseinheittyp oet ON oe.organisationseinheittyp_kurzbz = oet.organisationseinheittyp_kurzbz
|
||||
ORDER BY oet.bezeichnung ASC, oe.bezeichnung ASC";
|
||||
|
||||
$result = $this->OrganisationseinheitModel->execReadOnlyQuery($sql);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* return list of child orgets for a given company orget_kurzbz
|
||||
* as key value list to be used in select or autocomplete
|
||||
*/
|
||||
public function getOrgetsForCompany($companyOrgetkurzbz = null)
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
oe.oe_kurzbz, oe.aktiv,
|
||||
'[' || COALESCE(oet.bezeichnung, oet.organisationseinheittyp_kurzbz) ||
|
||||
'] ' || COALESCE(oe.bezeichnung, oe.oe_kurzbz) AS label
|
||||
FROM (
|
||||
WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) as
|
||||
(
|
||||
SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit
|
||||
WHERE oe_kurzbz=?
|
||||
UNION ALL
|
||||
SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes
|
||||
WHERE o.oe_parent_kurzbz=oes.oe_kurzbz
|
||||
)
|
||||
SELECT oe_kurzbz
|
||||
FROM oes
|
||||
GROUP BY oe_kurzbz
|
||||
) c
|
||||
JOIN public.tbl_organisationseinheit oe ON oe.oe_kurzbz = c.oe_kurzbz
|
||||
JOIN public.tbl_organisationseinheittyp oet ON oe.organisationseinheittyp_kurzbz = oet.organisationseinheittyp_kurzbz
|
||||
ORDER BY oet.bezeichnung ASC, oe.bezeichnung ASC";
|
||||
|
||||
$childorgets = $this->OrganisationseinheitModel->execReadOnlyQuery($sql, array($companyOrgetkurzbz));
|
||||
$data = $this->getDataOrTerminateWithError($childorgets);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function loadFunction($benutzerfunktion_id)
|
||||
{
|
||||
$this->BenutzerfunktionModel->addSelect("*");
|
||||
$result = $this->BenutzerfunktionModel->loadWhere(
|
||||
array('benutzerfunktion_id' => $benutzerfunktion_id)
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function insertFunction()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$authUID = getAuthUID();
|
||||
|
||||
$uid = $this->input->post('uid');
|
||||
|
||||
if(!$uid)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'UID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
|
||||
$datum_von = $formData['datum_von'] ?? null;
|
||||
$datum_bis = $formData['datum_bis'] ?? null;
|
||||
$formData['oe_kurzbz'] = is_array($formData['oe_kurzbz']) ? $formData['oe_kurzbz']['oe_kurzbz'] : $formData['oe_kurzbz'];
|
||||
$formData['funktion_kurzbz'] = is_array($formData['funktion_kurzbz'])
|
||||
? $formData['funktion_kurzbz']['funktion_kurzbz']
|
||||
: $formData['funktion_kurzbz'];
|
||||
$bezeichnung = $formData['bezeichnung'] ?? null;
|
||||
$wochenstunden = $formData['wochenstunden'] ?? null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
$this->form_validation->set_rules('datum_von', 'VonDatum', 'required|is_valid_date', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'VonDatum']),
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'VonDatum'])
|
||||
]);
|
||||
$this->form_validation->set_rules('datum_bis', 'BisDatum', 'is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'BisDatum'])
|
||||
]);
|
||||
$this->form_validation->set_rules('oe_kurzbz', 'Organisationseinheit', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Organisationseinheit'])
|
||||
]);
|
||||
$this->form_validation->set_rules('funktion_kurzbz', 'Funktion', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Funktion'])
|
||||
]);
|
||||
$this->form_validation->set_rules('wochenstunden', 'Wochenstunden', 'numeric', [
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Wochenstunden'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$result = $this->BenutzerfunktionModel->insert([
|
||||
'uid' => $uid,
|
||||
'datum_von' => $datum_von,
|
||||
'datum_bis' => $datum_bis ,
|
||||
'oe_kurzbz' => $formData['oe_kurzbz'],
|
||||
'funktion_kurzbz' => $formData['funktion_kurzbz'],
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'wochenstunden' => $wochenstunden,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $authUID,
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function updateFunction()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$authUID = getAuthUID();
|
||||
|
||||
$uid = $this->input->post('uid');
|
||||
|
||||
if(!$uid)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'UID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$benutzerfunktion_id = $this->input->post('benutzerfunktion_id');
|
||||
|
||||
if(!$benutzerfunktion_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Benutzerfunktion ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
|
||||
$datum_von = $formData['datum_von'] ?? null;
|
||||
$datum_bis = $formData['datum_bis'] ?? null;
|
||||
$formData['oe_kurzbz'] = is_array($formData['oe_kurzbz']) ? $formData['oe_kurzbz']['oe_kurzbz'] : $formData['oe_kurzbz'];
|
||||
$formData['funktion_kurzbz'] = is_array($formData['funktion_kurzbz'])
|
||||
? $formData['funktion_kurzbz']['funktion_kurzbz']
|
||||
: $formData['funktion_kurzbz'];
|
||||
$bezeichnung = $formData['bezeichnung'] ?? null;
|
||||
$wochenstunden = $formData['wochenstunden'] ?? null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
$this->form_validation->set_rules('datum_von', 'VonDatum', 'required|is_valid_date', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'VonDatum']),
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'VonDatum'])
|
||||
]);
|
||||
$this->form_validation->set_rules('datum_bis', 'BisDatum', 'is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'BisDatum'])
|
||||
]);
|
||||
$this->form_validation->set_rules('oe_kurzbz', 'Organisationseinheit', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Organisationseinheit'])
|
||||
]);
|
||||
$this->form_validation->set_rules('funktion_kurzbz', 'Funktion', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Funktion'])
|
||||
]);
|
||||
$this->form_validation->set_rules('wochenstunden', 'Wochenstunden', 'numeric', [
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Wochenstunden'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$result = $this->BenutzerfunktionModel->update(
|
||||
[
|
||||
'benutzerfunktion_id' => $benutzerfunktion_id,
|
||||
],
|
||||
[
|
||||
'uid' => $uid,
|
||||
'datum_von' => $datum_von,
|
||||
'datum_bis' => $datum_bis ,
|
||||
'oe_kurzbz' => $formData['oe_kurzbz'],
|
||||
'funktion_kurzbz' => $formData['funktion_kurzbz'],
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'wochenstunden' => $wochenstunden,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => $authUID,
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function deleteFunction($benutzerfunktion_id)
|
||||
{
|
||||
$result = $this->BenutzerfunktionModel->delete(
|
||||
array('benutzerfunktion_id' => $benutzerfunktion_id)
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2025 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');
|
||||
|
||||
class DirektGruppe extends FHCAPI_Controller
|
||||
{
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'add' => ['admin:rw', 'assistenz:rw'],
|
||||
'delete' => ['admin:rw', 'assistenz:rw'],
|
||||
'getByLehreinheit' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
$this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel');
|
||||
$this->_ci->load->model('education/lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$uid = $this->input->post('uid');
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
|
||||
$this->checkPermission($lehreinheit_id, $uid);
|
||||
|
||||
$result = $this->_ci->LehreinheitgruppeModel->direktUserAdd($uid, $lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$uid = $this->input->post('uid');
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
|
||||
$this->checkPermission($lehreinheit_id, $uid);
|
||||
|
||||
$result = $this->_ci->LehreinheitgruppeModel->direktUserDelete($uid, $lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getByLehreinheit($lehreinheit_id = null)
|
||||
{
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
$gruppen = $this->_ci->LehreinheitgruppeModel->getDirectGroup($lehreinheit_id);
|
||||
$this->terminateWithSuccess(hasData($gruppen) ? getData($gruppen) : array());
|
||||
}
|
||||
|
||||
private function checkPermission($lehreinheit_id, $uid = false)
|
||||
{
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id);
|
||||
|
||||
if (!hasData($lehreinheit_result) || isError($lehreinheit_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if ($uid)
|
||||
{
|
||||
$benuzuer_result = $this->_ci->BenutzerModel->load(array($uid));
|
||||
if (!hasData($benuzuer_result) || isError($benuzuer_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$oe_array = [];
|
||||
if (hasData($result))
|
||||
$oe_array = getData($result);
|
||||
|
||||
if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid'))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$result = $this->VariableModel->getVariables(getAuthUID(), ['lv_favorites']);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$data)
|
||||
$this->terminateWithSuccess(null);
|
||||
else
|
||||
$this->terminateWithSuccess(isset($data['lv_favorites']) ? $data['lv_favorites'] : null);
|
||||
}
|
||||
|
||||
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(), 'lv_favorites', $favorites);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class Gruppe extends FHCAPI_Controller
|
||||
{
|
||||
private $_uid;
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'add' => ['admin:rw', 'assistenz:rw'],
|
||||
'delete' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteFromLVPlan' => ['admin:rw', 'assistenz:rw'],
|
||||
'getBenutzer' => ['admin:r', 'assistenz:r'],
|
||||
'getAll' => ['admin:r', 'assistenz:r'],
|
||||
'getByLehreinheit' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
$this->_setAuthUID();
|
||||
$this->_ci->load->library('PhrasesLib');
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'ui'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_ci->load->model('organisation/Gruppe_model', 'GruppeModel');
|
||||
$this->_ci->load->model('organisation/Lehrverband_model', 'LehrverbandModel');
|
||||
$this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel');
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
$this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel');
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$lehreinheitgruppe_id = $this->input->post('lehreinheitgruppe_id');
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id) || is_null($lehreinheitgruppe_id) || !ctype_digit((string)$lehreinheitgruppe_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheitgruppe_result = $this->_ci->LehreinheitgruppeModel->loadWhere(array('lehreinheitgruppe_id' => $lehreinheitgruppe_id));
|
||||
if (!hasData($lehreinheitgruppe_result) || isError($lehreinheitgruppe_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
|
||||
$result = $this->_ci->LehreinheitgruppeModel->deleteGroup($lehreinheit_id, $lehreinheitgruppe_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$gid = $this->input->post('gid');
|
||||
$lehrverband = $this->input->post('lehrverband');
|
||||
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id) || is_null($gid) || !ctype_digit((string)$gid) || is_null($lehrverband))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
|
||||
$result = $this->_ci->LehreinheitgruppeModel->addGroup($lehreinheit_id, $gid, !($lehrverband === 'false'));
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getByLehreinheit($lehreinheit_id = null)
|
||||
{
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
|
||||
$gruppen = $this->_ci->LehreinheitgruppeModel->getByLehreinheit($lehreinheit_id);
|
||||
$this->terminateWithSuccess(hasData($gruppen) ? getData($gruppen) : array());
|
||||
}
|
||||
|
||||
public function deleteFromLVPlan()
|
||||
{
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$lehreinheitgruppe_id = $this->input->post('lehreinheitgruppe_id');
|
||||
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id) || is_null($lehreinheitgruppe_id) || !ctype_digit((string)$lehreinheitgruppe_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheitgruppe_result = $this->_ci->LehreinheitgruppeModel->loadWhere(array('lehreinheitgruppe_id' => $lehreinheitgruppe_id));
|
||||
if (!hasData($lehreinheitgruppe_result) || isError($lehreinheitgruppe_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->checkPermission($lehreinheit_id);
|
||||
|
||||
$result = $this->_ci->StundenplandevModel->deleteGroupPlanning($lehreinheit_id, $lehreinheitgruppe_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$this->_ci->GruppeModel->addSelect('gruppe_kurzbz,
|
||||
studiengang_kz,
|
||||
semester,
|
||||
bezeichnung,
|
||||
gid,
|
||||
\'false\' as lehrverband');
|
||||
$gruppen_result = $this->_ci->GruppeModel->loadWhere(array('sichtbar' => true, 'aktiv' => true, 'lehre' => true, 'direktinskription' => false, 'semester IS NOT NULL' => null));
|
||||
|
||||
$gruppen_array = array();
|
||||
|
||||
if (isError($gruppen_result))
|
||||
$this->terminateWithError(getError($gruppen_result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (hasData($gruppen_result))
|
||||
$gruppen_array = getData($gruppen_result);
|
||||
|
||||
$this->_ci->LehrverbandModel->addSelect('CONCAT(UPPER(CONCAT(typ, kurzbz)), \'\', semester, verband, COALESCE(gruppe,\'\')) as gruppe_kurzbz,
|
||||
studiengang_kz,
|
||||
semester,
|
||||
tbl_lehrverband.bezeichnung,
|
||||
gid,
|
||||
\'true\' as lehrverband');
|
||||
$this->_ci->LehrverbandModel->addJoin('public.tbl_studiengang', 'studiengang_kz');
|
||||
$this->_ci->LehrverbandModel->addOrder('verband');
|
||||
$this->_ci->LehrverbandModel->addOrder('gruppe');
|
||||
$lehrverband_result = $this->_ci->LehrverbandModel->loadWhere(array('tbl_lehrverband.aktiv' => true));
|
||||
|
||||
$lehrverband_array = array();
|
||||
|
||||
if (isError($lehrverband_result))
|
||||
$this->terminateWithError(getError($lehrverband_result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (hasData($lehrverband_result))
|
||||
$lehrverband_array = getData($lehrverband_result);
|
||||
|
||||
$all_gruppen = array_merge($gruppen_array, $lehrverband_array);
|
||||
|
||||
$this->terminateWithSuccess($all_gruppen);
|
||||
}
|
||||
|
||||
public function getBenutzer()
|
||||
{
|
||||
$this->_ci->PersonModel->addSelect('vorname, nachname, uid, semester, UPPER(CONCAT(tbl_studiengang.typ, tbl_studiengang.kurzbz)) as studiengang');
|
||||
$this->_ci->PersonModel->addJoin('public.tbl_benutzer', 'person_id');
|
||||
$this->_ci->PersonModel->addJoin('public.tbl_mitarbeiter', 'uid = mitarbeiter_uid', 'LEFT');
|
||||
$this->_ci->PersonModel->addJoin('public.tbl_student', 'uid = student_uid', 'LEFT');
|
||||
$this->_ci->PersonModel->addJoin('public.tbl_studiengang', 'studiengang_kz', 'LEFT');
|
||||
|
||||
$personen = $this->_ci->PersonModel->loadWhere(array('tbl_benutzer.aktiv' => true));
|
||||
$this->terminateWithSuccess(hasData($personen) ? getData($personen) : array());
|
||||
}
|
||||
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid)
|
||||
show_error('User authentification failed');
|
||||
}
|
||||
|
||||
private function checkPermission($lehreinheit_id)
|
||||
{
|
||||
$lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id);
|
||||
|
||||
if (!hasData($lehreinheit_result) || isError($lehreinheit_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$oe_array = [];
|
||||
if (hasData($result))
|
||||
$oe_array = getData($result);
|
||||
|
||||
if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid'))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,446 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class Lehreinheit extends FHCAPI_Controller
|
||||
{
|
||||
private $_uid;
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'add' => ['admin:rw', 'assistenz:rw'],
|
||||
'copy' => ['admin:rw', 'assistenz:rw'],
|
||||
'delete' => ['admin:rw', 'assistenz:rw'],
|
||||
'update' => ['admin:rw', 'assistenz:rw'],
|
||||
|
||||
'get' => ['admin:r', 'assistenz:r'],
|
||||
'getStudiensemester' => ['admin:r', 'assistenz:r'],
|
||||
'getLehrfach' => ['admin:r', 'assistenz:r'],
|
||||
'getSprache' => ['admin:r', 'assistenz:r'],
|
||||
'getRaumtyp' => ['admin:r', 'assistenz:r'],
|
||||
'getLehrform' => ['admin:r', 'assistenz:r']
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
$this->_setAuthUID();
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $this->_uid]);
|
||||
$this->_ci->load->library('PhrasesLib');
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'global',
|
||||
'ui'
|
||||
)
|
||||
);
|
||||
|
||||
$this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('education/Lehreinheitgruppe_model', 'LehreinheitgruppeModel');
|
||||
$this->_ci->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
}
|
||||
|
||||
public function get($lehreinheit_id)
|
||||
{
|
||||
$lehreinheit = $this->checkLehreinheit($lehreinheit_id);
|
||||
$lehreinheit->lehrfaecher = $this->getLehrfaecher($lehreinheit);
|
||||
$this->terminateWithSuccess($lehreinheit);
|
||||
}
|
||||
|
||||
private function getLehrfaecher($lehreinheit)
|
||||
{
|
||||
$lehrfacher_array = array($lehreinheit->lehrfach_id);
|
||||
$this->_ci->LehreinheitModel->addSelect('lehrveranstaltung_id_kompatibel');
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung_kompatibel', 'lehrveranstaltung_id');
|
||||
$lehrfaecher = $this->_ci->LehreinheitModel->loadWhere(array('lehrveranstaltung_id' => $lehreinheit->lehrveranstaltung_id));
|
||||
|
||||
|
||||
if (hasData($lehrfaecher))
|
||||
$lehrfaecher_array = array_merge($lehrfacher_array, array_column(getData($lehrfaecher), 'lehrveranstaltung_id_kompatibel'));
|
||||
|
||||
$lehrfaecher_array[] = $lehreinheit->lehrveranstaltung_id;
|
||||
|
||||
$this->_ci->LehrveranstaltungModel->addDistinct('lehrfach_id');
|
||||
$this->_ci->LehrveranstaltungModel->addSelect("tbl_lehrveranstaltung.lehrveranstaltung_id, CONCAT(tbl_lehrveranstaltung.bezeichnung || '(' || tbl_lehrveranstaltung.oe_kurzbz || ')') as lehrfach");
|
||||
$this->_ci->LehrveranstaltungModel->db->where_in('tbl_lehrveranstaltung.lehrveranstaltung_id', $lehrfaecher_array);
|
||||
$lehrfaecher_result = $this->_ci->LehrveranstaltungModel->load();
|
||||
|
||||
return hasData($lehrfaecher_result) ? getData($lehrfaecher_result) : array();
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$lehrveranstaltung_id = $this->input->post('lehrveranstaltung_id');
|
||||
|
||||
if (is_null($lehrveranstaltung_id) || !ctype_digit((string)$lehrveranstaltung_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehrveranstaltung_result = $this->_ci->LehrveranstaltungModel->loadWhere(array('lehrveranstaltung_id' => $lehrveranstaltung_id));
|
||||
|
||||
if (!hasData($lehrveranstaltung_result) || isError($lehrveranstaltung_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehrveranstaltung = getData($lehrveranstaltung_result)[0];
|
||||
|
||||
$oe_result = $this->_ci->LehrveranstaltungModel->getAllOe($lehrveranstaltung->lehrveranstaltung_id);
|
||||
$oe_array = hasData($oe_result) ? array_column(getData($oe_result), 'oe_kurzbz') : array();
|
||||
|
||||
if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid'))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
|
||||
$this->_ci->load->library('form_validation');
|
||||
|
||||
$updatableFields = array(
|
||||
'lehrveranstaltung_id',
|
||||
'studiensemester_kurzbz',
|
||||
'lehrfach_id',
|
||||
'lehrform_kurzbz',
|
||||
'stundenblockung',
|
||||
'wochenrythmus',
|
||||
'gewicht',
|
||||
'start_kw',
|
||||
'raumtyp',
|
||||
'raumtypalternativ',
|
||||
'sprache',
|
||||
'lehre',
|
||||
'anmerkung',
|
||||
'lvnr',
|
||||
'unr',
|
||||
);
|
||||
|
||||
foreach ($updatableFields as $field)
|
||||
{
|
||||
switch ($field) {
|
||||
case 'lehrveranstaltung_id':
|
||||
$this->form_validation->set_rules($field, 'Lehrveranstaltung ID', 'required|integer');
|
||||
break;
|
||||
case 'studiensemester_kurzbz':
|
||||
$this->form_validation->set_rules($field, 'Studiensemester', 'required|max_length[16]');
|
||||
break;
|
||||
case 'lehrfach_id':
|
||||
$this->form_validation->set_rules($field, 'Lehrfach ID', 'required|integer');
|
||||
break;
|
||||
case 'lehrform_kurzbz':
|
||||
$this->form_validation->set_rules($field, 'Lehrform', 'required|max_length[8]');
|
||||
break;
|
||||
case 'stundenblockung':
|
||||
$this->form_validation->set_rules($field, 'Stundenblockung', 'required|integer|greater_than_equal_to[0]');
|
||||
break;
|
||||
case 'wochenrythmus':
|
||||
$this->form_validation->set_rules($field, 'Wochenrhytmus', 'required|integer|greater_than_equal_to[0]');
|
||||
break;
|
||||
case 'start_kw':
|
||||
$this->form_validation->set_rules($field, 'Start KW', 'integer|greater_than[0]|less_than_equal_to[53]');
|
||||
break;
|
||||
case 'gewicht':
|
||||
$this->form_validation->set_rules($field, 'Gewicht', 'numeric');
|
||||
break;
|
||||
case 'raumtyp':
|
||||
$this->form_validation->set_rules($field, 'Raumtyp', 'required|max_length[16]');
|
||||
break;
|
||||
case 'raumtypalternativ':
|
||||
$this->form_validation->set_rules($field, 'Raumtyp Alternativ', 'required|max_length[16]');
|
||||
break;
|
||||
case 'sprache':
|
||||
$this->form_validation->set_rules($field, 'Sprache', 'required|max_length[16]');
|
||||
break;
|
||||
case 'lvnr':
|
||||
$this->form_validation->set_rules($field, 'LVNR', 'integer');
|
||||
break;
|
||||
case 'unr':
|
||||
$this->form_validation->set_rules($field, 'UNR', 'integer');
|
||||
break;
|
||||
case 'lehre':
|
||||
$this->form_validation->set_rules($field, 'Lehre', 'trim');
|
||||
break;
|
||||
case 'anmerkung':
|
||||
$this->form_validation->set_rules($field, 'Anmerkung', 'trim');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->form_validation->run() === false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$updateData = array();
|
||||
foreach ($updatableFields as $field)
|
||||
{
|
||||
$value = $this->input->post($field);
|
||||
|
||||
if ($value !== null)
|
||||
{
|
||||
$updateData[$field] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$updateData['insertvon'] = $this->_uid;
|
||||
$updateData['insertamum'] = date('Y-m-d H:i:s');
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->insert(
|
||||
$updateData
|
||||
);
|
||||
|
||||
if (!isset($updateData['unr']))
|
||||
{
|
||||
$unr = getData($result);
|
||||
$this->_ci->LehreinheitModel->update($unr, array('unr' => $unr));
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function copy()
|
||||
{
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$art = $this->input->post('art');
|
||||
|
||||
$lehreinheit_old = $this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_old->lehreinheit_id);
|
||||
|
||||
$lehreinheit_new = $lehreinheit_old;
|
||||
|
||||
$lehreinheit_new->unr = null;
|
||||
unset($lehreinheit_new->lehreinheit_id);
|
||||
$lehreinheit_new->updateamum = date('Y-m-d H:i:s');
|
||||
$lehreinheit_new->updatevon = $this->_uid;
|
||||
$lehreinheit_new->insertamum = date('Y-m-d H:i:s');
|
||||
$lehreinheit_new->insertvon = $this->_uid;
|
||||
|
||||
$insert_result = $this->_ci->LehreinheitModel->insert($lehreinheit_new);
|
||||
|
||||
if (isError($insert_result))
|
||||
$this->terminateWithError(getError($insert_result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheit_id_new = getData($insert_result);
|
||||
|
||||
$this->_ci->LehreinheitModel->update(array('lehreinheit_id' => $lehreinheit_id_new), array('unr' => $lehreinheit_id_new));
|
||||
if (in_array($art, array('gruppen', 'alle')))
|
||||
{
|
||||
$gruppen_result = $this->_ci->LehreinheitgruppeModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id));
|
||||
|
||||
if (isError($gruppen_result))
|
||||
$this->terminateWithError(getError($gruppen_result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (hasData($gruppen_result))
|
||||
{
|
||||
$gruppen = getData($gruppen_result);
|
||||
|
||||
foreach ($gruppen as $gruppe)
|
||||
{
|
||||
$gruppe_new = $gruppe;
|
||||
unset($gruppe_new->lehreinheitgruppe_id);
|
||||
$gruppe_new->lehreinheit_id = $lehreinheit_id_new;
|
||||
$gruppe_new->insertamum = date('Y-m-d H:i:s');
|
||||
$gruppe_new->insertvon = $this->_uid;
|
||||
$gruppe_new->updateamum = date('Y-m-d H:i:s');
|
||||
$gruppe_new->updatevon = $this->_uid;
|
||||
|
||||
$gruppe_new_result = $this->_ci->LehreinheitgruppeModel->insert($gruppe_new);
|
||||
|
||||
if (isError($gruppe_new_result))
|
||||
$this->terminateWithError(getError($gruppe_new_result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($art, array('lektoren', 'alle')))
|
||||
{
|
||||
$lektoren_result = $this->_ci->LehreinheitmitarbeiterModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id));
|
||||
|
||||
if (isError($lektoren_result))
|
||||
$this->terminateWithError(getError($lektoren_result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (hasData($lektoren_result))
|
||||
{
|
||||
$lektoren = getData($lektoren_result);
|
||||
|
||||
foreach ($lektoren as $lektor)
|
||||
{
|
||||
|
||||
$lektor_new = $lektor;
|
||||
$lektor_new->lehreinheit_id = $lehreinheit_id_new;
|
||||
$lektor_new->insertamum = date('Y-m-d H:i:s');
|
||||
$lektor_new->insertvon = $this->_uid;
|
||||
$lektor_new->updateamum = date('Y-m-d H:i:s');
|
||||
$lektor_new->updatevon = $this->_uid;
|
||||
unset($lektor_new->vertrag_id);
|
||||
|
||||
$lektor_new_result = $this->_ci->LehreinheitmitarbeiterModel->insert((array)$lektor_new);
|
||||
|
||||
if (isError($lektor_new_result))
|
||||
$this->terminateWithError(getError($lektor_new_result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess("Erfolgeich gespeichert");
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$lehreinheit = $this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit->lehreinheit_id);
|
||||
|
||||
$result = $this->_ci->LehreinheitModel->deleteLehreinheit($lehreinheit->lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithValidationErrors(getError($result));
|
||||
|
||||
$this->terminateWithSuccess('Erfolgreich geloescht');
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$lehreinheit = $this->checkLehreinheit($this->input->post('lehreinheit_id'));
|
||||
|
||||
$this->checkPermission($lehreinheit->lehreinheit_id);
|
||||
|
||||
$this->_ci->load->library('form_validation');
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
|
||||
$updatableFields = array(
|
||||
'lehrveranstaltung_id',
|
||||
'studiensemester_kurzbz',
|
||||
'lehrfach_id',
|
||||
'lehrform_kurzbz',
|
||||
'stundenblockung',
|
||||
'wochenrythmus',
|
||||
'gewicht',
|
||||
'start_kw',
|
||||
'raumtyp',
|
||||
'raumtypalternativ',
|
||||
'sprache',
|
||||
'lehre',
|
||||
'anmerkung',
|
||||
'lvnr',
|
||||
'unr',
|
||||
);
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
foreach ($updatableFields as $field)
|
||||
{
|
||||
if (array_key_exists($field, $formData))
|
||||
{
|
||||
switch ($field)
|
||||
{
|
||||
case 'lehrveranstaltung_id':
|
||||
$this->form_validation->set_rules($field, 'Lehrveranstaltung ID', 'required|integer');
|
||||
break;
|
||||
case 'studiensemester_kurzbz':
|
||||
$this->form_validation->set_rules($field, 'Studiensemester', 'required|max_length[16]');
|
||||
break;
|
||||
case 'lehrfach_id':
|
||||
$this->form_validation->set_rules($field, 'Lehrfach ID', 'required|integer');
|
||||
break;
|
||||
case 'lehrform_kurzbz':
|
||||
$this->form_validation->set_rules($field, 'Lehrform', 'required|max_length[8]');
|
||||
break;
|
||||
case 'stundenblockung':
|
||||
$this->form_validation->set_rules($field, 'Stundenblockung', 'required|integer|greater_than_equal_to[0]');
|
||||
break;
|
||||
case 'wochenrythmus':
|
||||
$this->form_validation->set_rules($field, 'Wochenrhytmus', 'required|integer|greater_than_equal_to[0]');
|
||||
break;
|
||||
case 'start_kw':
|
||||
$this->form_validation->set_rules($field, 'Start KW', 'integer|greater_than[0]|less_than_equal_to[53]');
|
||||
break;
|
||||
case 'gewicht':
|
||||
$this->form_validation->set_rules($field, 'Gewicht', 'numeric|greater_than_equal_to[0]');
|
||||
break;
|
||||
case 'raumtyp':
|
||||
$this->form_validation->set_rules($field, 'Raumtyp', 'required|max_length[16]');
|
||||
break;
|
||||
case 'raumtypalternativ':
|
||||
$this->form_validation->set_rules($field, 'Raumtyp Alternativ', 'required|max_length[16]');
|
||||
break;
|
||||
case 'sprache':
|
||||
$this->form_validation->set_rules($field, 'Sprache', 'required|max_length[16]');
|
||||
break;
|
||||
case 'lvnr':
|
||||
$this->form_validation->set_rules($field, 'LVNR', 'integer');
|
||||
break;
|
||||
case 'unr':
|
||||
$this->form_validation->set_rules($field, 'UNR', 'integer|greater_than_equal_to[0]');
|
||||
break;
|
||||
case 'lehre':
|
||||
$this->form_validation->set_rules($field, 'Lehre', 'trim');
|
||||
break;
|
||||
case 'anmerkung':
|
||||
$this->form_validation->set_rules($field, 'Anmerkung', 'trim');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->form_validation->run() === false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$updateData = [];
|
||||
foreach ($updatableFields as $field)
|
||||
{
|
||||
if (array_key_exists($field, $formData))
|
||||
{
|
||||
$updateData[$field] = $formData[$field];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$updateData['updatevon'] = $this->_uid;
|
||||
$updateData['updateamum'] = date('Y-m-d H:i:s');
|
||||
$result = $this->_ci->LehreinheitModel->update(
|
||||
[
|
||||
'lehreinheit_id' => $this->input->post('lehreinheit_id'),
|
||||
],
|
||||
$updateData
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithSuccess($this->p->t('global', 'gespeichert'));
|
||||
}
|
||||
|
||||
|
||||
private function checkPermission($lehreinheit_id)
|
||||
{
|
||||
$result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$oe_array = [];
|
||||
if (hasData($result))
|
||||
$oe_array = getData($result);
|
||||
|
||||
if (!$this->_ci->permissionlib->isBerechtigtMultipleOe('admin', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('assistenz', $oe_array, 'suid') &&
|
||||
!$this->_ci->permissionlib->isBerechtigtMultipleOe('lv-plan', $oe_array, 'suid'))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
}
|
||||
private function checkLehreinheit($lehreinheit_id)
|
||||
{
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id);
|
||||
|
||||
if (!hasData($lehreinheit_result) || isError($lehreinheit_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
return getData($lehreinheit_result)[0];
|
||||
}
|
||||
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid)
|
||||
show_error('User authentification failed');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class Lektor extends FHCAPI_Controller
|
||||
{
|
||||
private $_uid;
|
||||
private $_ci;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'add' => ['admin:rw', 'assistenz:rw'],
|
||||
'update' => ['admin:rw', 'assistenz:rw'],
|
||||
'cancelVertrag' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteLVPlan' => ['admin:rw', 'assistenz:rw'],
|
||||
'deletePerson' => ['admin:rw', 'assistenz:rw'],
|
||||
'getLehrfunktionen' => ['admin:r', 'assistenz:r'],
|
||||
'getLektoren' => ['admin:r', 'assistenz:r'],
|
||||
'getLektorenByLE' => ['admin:r', 'assistenz:r'],
|
||||
'getLektorDaten' => ['admin:r', 'assistenz:r'],
|
||||
'getLektorVertrag' => ['admin:r', 'assistenz:r'],
|
||||
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
$this->_setAuthUID();
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $this->_uid]);
|
||||
$this->_ci->load->library('PermissionLib');
|
||||
$this->_ci->load->library('LektorLib');
|
||||
$this->_ci->load->library('form_validation');
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
|
||||
$this->_ci->load->model('accounting/Vertrag_model', 'VertragModel');
|
||||
$this->_ci->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->_ci->load->model('education/lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
$this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel');
|
||||
$this->_ci->load->model('ressource/Stundensatz_model', 'StundensatzModel');
|
||||
|
||||
}
|
||||
|
||||
private function checkMitarbeiter($mitarbeiter_uid)
|
||||
{
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid);
|
||||
|
||||
if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkMitarbeiter($mitarbeiter_uid);
|
||||
$lehrfach_permission = $this->checkLehrfachPermission($lehreinheit_id, array('assistenz', 'admin'));
|
||||
$lehreinheit_permission = $this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan'));
|
||||
|
||||
if (!$lehrfach_permission && !$lehreinheit_permission)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
|
||||
$result = $this->_ci->lektorlib->addLektorToLehreinheit($lehreinheit_id, $mitarbeiter_uid);
|
||||
|
||||
if (isError($result)) $this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess("Erfolgreich gespeichert");
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$formData = $this->input->post('formData');
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkMitarbeiter($mitarbeiter_uid);
|
||||
|
||||
$updatableFields = array(
|
||||
'lehrfunktion_kurzbz',
|
||||
'planstunden',
|
||||
'stundensatz',
|
||||
'faktor',
|
||||
'anmerkung',
|
||||
'bismelden',
|
||||
'semesterstunden',
|
||||
'mitarbeiter_uid'
|
||||
);
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
foreach ($updatableFields as $field)
|
||||
{
|
||||
if (array_key_exists($field, $formData))
|
||||
{
|
||||
switch ($field)
|
||||
{
|
||||
case 'lehrfunktion_kurzbz':
|
||||
$this->form_validation->set_rules($field, 'Lehrfunktion', 'required|max_length[16]');
|
||||
break;
|
||||
case 'planstunden':
|
||||
$this->form_validation->set_rules($field, 'Planstunden', 'integer|greater_than_equal_to[0]');
|
||||
break;
|
||||
case 'stundensatz':
|
||||
$formData['stundensatz'] = str_replace(',', '.', $formData['stundensatz']);
|
||||
$this->form_validation->set_rules($field, 'Stundensatz', 'callback__check_stundensatz');
|
||||
break;
|
||||
case 'faktor':
|
||||
$this->form_validation->set_rules($field, 'Faktor', 'numeric|greater_than_equal_to[0]');
|
||||
break;
|
||||
case 'anmerkung':
|
||||
$this->form_validation->set_rules($field, 'Anmerkung', 'max_length[256]');
|
||||
break;
|
||||
case 'bismelden':
|
||||
$this->form_validation->set_rules($field, 'Bis Melden', 'trim');
|
||||
break;
|
||||
case 'semesterstunden':
|
||||
$formData['semesterstunden'] = str_replace(',', '.', $formData['semesterstunden']);
|
||||
$this->form_validation->set_rules($field, 'Semesterstunden', 'callback__check_semesterstunden');
|
||||
break;
|
||||
case 'mitarbeiter_uid':
|
||||
$this->form_validation->set_rules($field, 'Semesterstunden', 'required|max_length[32]');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$this->form_validation->run())
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
if (isset($formData['semesterstunden']) && (!is_numeric($formData['semesterstunden']) || $formData['semesterstunden'] === ''))
|
||||
{
|
||||
$formData['semesterstunden'] = null;
|
||||
}
|
||||
|
||||
$lehreinheit_permission = $this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan'));
|
||||
|
||||
if (!$lehreinheit_permission)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_fieldWriteAccess'));
|
||||
|
||||
$result = $this->_ci->lektorlib->updateLektorFromLehreinheit($lehreinheit_id, $mitarbeiter_uid, $formData);
|
||||
|
||||
if (isError($result)) $this->terminateWithError(getError($result));
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function _check_stundensatz($value)
|
||||
{
|
||||
$value = str_replace(',', '.', $value);
|
||||
|
||||
if (!is_numeric($value))
|
||||
{
|
||||
$this->form_validation->set_message('_check_decimal', 'Das Feld {field} muss eine Zahl sein.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($value < 0 || $value >= 10000) {
|
||||
$this->form_validation->set_message('_check_decimal', 'Das Feld {field} muss zwischen 0 und 10000 liegen.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public function _check_semesterstunden($value)
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!is_numeric($value))
|
||||
{
|
||||
$this->form_validation->set_message(
|
||||
'_check_semesterstunden',
|
||||
'Das Feld {field} muss eine Zahl sein.'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($value < 0)
|
||||
{
|
||||
$this->form_validation->set_message(
|
||||
'_check_semesterstunden',
|
||||
'Das Feld {field} muss eine Zahl größer oder gleich 0 sein.'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ($value > 999.99)
|
||||
{
|
||||
$this->form_validation->set_message(
|
||||
'_check_semesterstunden',
|
||||
'Das Feld {field} darf maximal 999,99 betragen.'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public function getLehrfunktionen()
|
||||
{
|
||||
$this->_ci->load->model('education/Lehrfunktion_model', 'LehrfunktionModel');
|
||||
$this->_ci->LehrfunktionModel->addOrder('lehrfunktion_kurzbz');
|
||||
$this->terminateWithSuccess(getData($this->_ci->LehrfunktionModel->load()));
|
||||
}
|
||||
|
||||
public function getLektoren()
|
||||
{
|
||||
$this->_ci->MitarbeiterModel->addSelect('uid, person_id, vorname, nachname');
|
||||
$this->_ci->MitarbeiterModel->addJoin('public.tbl_benutzer', 'uid = mitarbeiter_uid');
|
||||
$this->_ci->MitarbeiterModel->addJoin('public.tbl_person', 'person_id');
|
||||
$this->terminateWithSuccess(getData($this->_ci->MitarbeiterModel->loadWhere(array('public.tbl_benutzer.aktiv' => true))));
|
||||
}
|
||||
|
||||
private function checkLehreinheit($lehreinheit_id)
|
||||
{
|
||||
if (is_null($lehreinheit_id) || !ctype_digit((string)$lehreinheit_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehreinheit_result = $this->_ci->LehreinheitModel->load($lehreinheit_id);
|
||||
|
||||
if (!hasData($lehreinheit_result) || isError($lehreinheit_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
return getData($lehreinheit_result)[0];
|
||||
|
||||
}
|
||||
public function getLektorenByLE($lehreinheit_id = null)
|
||||
{
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$le_mitarbeiter_data = $this->_ci->LehreinheitmitarbeiterModel->getLektorenByLe($lehreinheit_id);
|
||||
$this->terminateWithSuccess(hasData($le_mitarbeiter_data) ? getData($le_mitarbeiter_data) : array());
|
||||
}
|
||||
|
||||
public function getLektorDaten($lehreinheit_id = null, $mitarbeiter_uid = null)
|
||||
{
|
||||
$lehreinheit = $this->checkLehreinheit($lehreinheit_id);
|
||||
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid);
|
||||
|
||||
if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->load->model('organisation/Studiensemester_model','StudiensemesterModel');
|
||||
$studiensemester_result = $this->_ci->StudiensemesterModel->loadWhere(array('studiensemester_kurzbz' => $lehreinheit->studiensemester_kurzbz));
|
||||
$studiensemester = getData($studiensemester_result)[0];
|
||||
|
||||
$defaultStundensatz = $this->_ci->StundensatzModel->getDefaultStundensatz($mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'lehre');
|
||||
|
||||
$le_mitarbeiter_result = $this->_ci->LehreinheitmitarbeiterModel->getByLeLektor($lehreinheit_id, $mitarbeiter_uid);
|
||||
|
||||
$le_mitarbeiter_data = array();
|
||||
if (hasData($le_mitarbeiter_result))
|
||||
{
|
||||
$le_mitarbeiter_data = getData($le_mitarbeiter_result)[0];
|
||||
$le_mitarbeiter_data->default_stundensatz = $defaultStundensatz;
|
||||
}
|
||||
$vertrag = $this->getLektorVertrag($lehreinheit_id, $mitarbeiter_uid);
|
||||
$le_mitarbeiter_data->vertrag = $vertrag;
|
||||
$this->terminateWithSuccess($le_mitarbeiter_data);
|
||||
}
|
||||
|
||||
private function getLektorVertrag($lehreinheit_id = null, $mitarbeiter_uid = null)
|
||||
{
|
||||
$this->_ci->load->model('accounting/Vertrag_model', 'VertragModel');
|
||||
$vertrag = $this->_ci->VertragModel->getVertrag($mitarbeiter_uid, $lehreinheit_id);
|
||||
return hasData($vertrag) ? getData($vertrag)[0] : null;
|
||||
}
|
||||
|
||||
private function checkLehrfachPermission($lehreinheit_id, $permissions)
|
||||
{
|
||||
$lehrfach_oe_kurzbz = $this->_ci->LehreinheitModel->getLehrfachOe($lehreinheit_id);
|
||||
|
||||
if (isError($lehrfach_oe_kurzbz))
|
||||
$this->terminateWithError(getError($lehrfach_oe_kurzbz), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$lehrfach_oe_kurzbz = array('');
|
||||
if (hasData($lehrfach_oe_kurzbz))
|
||||
$lehrfach_oe_kurzbz = array_column(getData($lehrfach_oe_kurzbz), 'oe_kurzbz');
|
||||
|
||||
|
||||
return $this->checkPermissionGenerel($permissions, $lehrfach_oe_kurzbz);
|
||||
}
|
||||
|
||||
private function checkPermissionGenerel($permissions, $oe_array)
|
||||
{
|
||||
$hasPermission = false;
|
||||
foreach ($permissions as $permission)
|
||||
{
|
||||
if ($this->_ci->permissionlib->isBerechtigtMultipleOe($permission, $oe_array, 'suid'))
|
||||
{
|
||||
$hasPermission = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $hasPermission;
|
||||
}
|
||||
|
||||
private function checkPermission($lehreinheit_id, $permissions)
|
||||
{
|
||||
$result = $this->_ci->LehreinheitModel->getOes($lehreinheit_id);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$oe_array = [];
|
||||
if (hasData($result))
|
||||
$oe_array = getData($result);
|
||||
|
||||
return $this->checkPermissionGenerel($permissions, $oe_array);
|
||||
}
|
||||
public function cancelVertrag()
|
||||
{
|
||||
$vertrag_id = $this->input->post('vertrag_id');
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, array('admin', 'lehre/lehrauftrag_bestellen'));
|
||||
|
||||
if (is_null($vertrag_id) || !ctype_digit((string)$vertrag_id))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$vertrag_result = $this->_ci->VertragModel->load($vertrag_id);
|
||||
|
||||
if (!hasData($vertrag_result) || isError($vertrag_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid);
|
||||
|
||||
if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result))
|
||||
$this->terminateWithError( $this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->_ci->VertragModel->cancelVertrag($vertrag_id, $mitarbeiter_uid);
|
||||
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function deletePerson()
|
||||
{
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, array('admin', 'assistenz', 'lv-plan'));
|
||||
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid);
|
||||
|
||||
if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$delete_result =$this->_ci->LehreinheitmitarbeiterModel->deleteLektorFromLe($lehreinheit_id, $mitarbeiter_uid);
|
||||
|
||||
if (isError($delete_result))
|
||||
$this->terminateWithError(getError($delete_result));
|
||||
|
||||
$this->terminateWithSuccess($delete_result);
|
||||
}
|
||||
|
||||
public function deleteLVPlan()
|
||||
{
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
|
||||
$this->checkLehreinheit($lehreinheit_id);
|
||||
$this->checkPermission($lehreinheit_id, array('lv-plan/lektorentfernen'));
|
||||
|
||||
if (is_null($mitarbeiter_uid))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$mitarbeiter_result = $this->_ci->MitarbeiterModel->load($mitarbeiter_uid);
|
||||
|
||||
if (!hasData($mitarbeiter_result) || isError($mitarbeiter_result))
|
||||
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
|
||||
$delete_result = $this->_ci->StundenplandevModel->deleteLektorPlanning($lehreinheit_id, $mitarbeiter_uid);
|
||||
|
||||
if (isError($delete_result))
|
||||
$this->terminateWithError(getError($delete_result));
|
||||
|
||||
$this->terminateWithSuccess($delete_result);
|
||||
}
|
||||
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid)
|
||||
show_error('User authentification failed');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2025 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');
|
||||
|
||||
class Setup extends FHCAPI_Controller
|
||||
{
|
||||
private $_ci;
|
||||
private $_uid;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getTabs' => ['admin:r', 'assistenz:r'],
|
||||
'getStudiensemester' => ['admin:r', 'assistenz:r'],
|
||||
'getSprache' => ['admin:r', 'assistenz:r'],
|
||||
'getRaumtyp' => ['admin:r', 'assistenz:r'],
|
||||
'getLehrform' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
$this->_ci = &get_instance();
|
||||
$this->_setAuthUID();
|
||||
|
||||
$this->_ci->load->model('education/Lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $this->_uid]);
|
||||
}
|
||||
|
||||
public function getTabs()
|
||||
{
|
||||
$tabs['details'] = array (
|
||||
'title' => 'Details',
|
||||
'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Details.js',
|
||||
'config' => []
|
||||
);
|
||||
$tabs['gruppen'] = array (
|
||||
'title' => 'Gruppen',
|
||||
'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Gruppen.js',
|
||||
'config' => []
|
||||
);
|
||||
$tabs['lektor'] = array (
|
||||
'title' => 'LektorInnenzuteilung',
|
||||
'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Lektor.js',
|
||||
'config' => []
|
||||
);
|
||||
$tabs['notiz'] = array (
|
||||
'title' => 'Notizen',
|
||||
'component' => APP_ROOT . 'public/js/components/LVVerwaltung/Tabs/Notiz.js',
|
||||
'config' => []
|
||||
);
|
||||
$this->terminateWithSuccess($tabs);
|
||||
}
|
||||
|
||||
public function getStudiensemester()
|
||||
{
|
||||
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->_ci->StudiensemesterModel->addOrder('start', 'DESC');
|
||||
$this->terminateWithSuccess(getData($this->_ci->StudiensemesterModel->load()));
|
||||
}
|
||||
public function getSprache()
|
||||
{
|
||||
$this->_ci->load->model('system/Sprache_model', 'SpracheModel');
|
||||
$this->terminateWithSuccess(getData($this->_ci->SpracheModel->load()));
|
||||
}
|
||||
|
||||
public function getRaumtyp()
|
||||
{
|
||||
$this->_ci->load->model('ressource/Raumtyp_model', 'RaumtypModel');
|
||||
$this->_ci->RaumtypModel->addOrder('raumtyp_kurzbz');
|
||||
$this->terminateWithSuccess(getData($this->_ci->RaumtypModel->loadWhere(array('aktiv' => true))));
|
||||
}
|
||||
|
||||
public function getLehrform()
|
||||
{
|
||||
$language = $this->_getLanguageIndex();
|
||||
|
||||
$this->_ci->load->model('codex/lehrform_model', 'LehrformModel');
|
||||
|
||||
$this->_ci->LehrformModel->addSelect(
|
||||
'*,
|
||||
bezeichnung_kurz[('.$language.')] as bez_kurz,
|
||||
bezeichnung_lang[('.$language.')] as bez
|
||||
'
|
||||
);
|
||||
$this->terminateWithSuccess(getData($this->_ci->LehrformModel->load()));
|
||||
}
|
||||
|
||||
private function _getLanguageIndex()
|
||||
{
|
||||
$this->_ci->load->model('system/Sprache_model', 'SpracheModel');
|
||||
$this->_ci->SpracheModel->addSelect('index');
|
||||
$result = $this->_ci->SpracheModel->loadWhere(array('sprache' => getUserLanguage()));
|
||||
|
||||
return hasData($result) ? getData($result)[0]->index : 1;
|
||||
}
|
||||
|
||||
private function _setAuthUID()
|
||||
{
|
||||
$this->_uid = getAuthUID();
|
||||
|
||||
if (!$this->_uid)
|
||||
show_error('User authentification failed');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class StgTree extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$permissions = [];
|
||||
$router = load_class('Router');
|
||||
$permissions[$router->method] = ['admin:r', 'assistenz:r'];
|
||||
parent::__construct($permissions);
|
||||
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
}
|
||||
|
||||
public function _remap($method, $params = [])
|
||||
{
|
||||
if ($method == '' || $method == 'index')
|
||||
return $this->getBase();
|
||||
|
||||
if (!$this->permissionlib->isBerechtigt('assistenz', 's', $method)
|
||||
&& !$this->permissionlib->isBerechtigt('admin', 's', $method)
|
||||
) {
|
||||
return $this->_outputAuthError([$method => ['admin:r', 'assistenz:r']]);
|
||||
}
|
||||
|
||||
return $this->getStudiengang($method);
|
||||
show_404();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$this->terminateWithSuccess($list);
|
||||
}
|
||||
|
||||
protected function getStudiengang($studiengang_kz)
|
||||
{
|
||||
$link = $studiengang_kz . '/';
|
||||
|
||||
$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("TRUE AS leaf", false);
|
||||
|
||||
$this->StudiengangModel->addSelect('semester');
|
||||
$this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false);
|
||||
|
||||
$this->StudiengangModel->addOrder('semester');
|
||||
|
||||
$result = $this->StudiengangModel->loadWhere([
|
||||
'v.studiengang_kz' => $studiengang_kz,
|
||||
'v.aktiv' => true
|
||||
]);
|
||||
$list = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$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->addSelect("TRUE as leaf", false);
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class Tags extends Tag_Controller
|
||||
{
|
||||
const BERECHTIGUNG_KURZBZ = ['admin:rw', 'assistenz:rw'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'getTags' => self::BERECHTIGUNG_KURZBZ,
|
||||
'addTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'updateTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'doneTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'deleteTag' => self::BERECHTIGUNG_KURZBZ,
|
||||
'updateLehre' => self::BERECHTIGUNG_KURZBZ,
|
||||
'doneLehre' => self::BERECHTIGUNG_KURZBZ,
|
||||
'deleteLehre' => self::BERECHTIGUNG_KURZBZ,
|
||||
]);
|
||||
|
||||
$this->config->load('lvverwaltung');
|
||||
}
|
||||
public function getTag($readonly_tags = null)
|
||||
{
|
||||
parent::getTag($this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function getTags($tags = null)
|
||||
{
|
||||
parent::getTags($this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function addTag($withZuordnung = true, $updatable_tags = null)
|
||||
{
|
||||
parent::addTag(true, $this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function updateTag($updatable_tags = null)
|
||||
{
|
||||
parent::updateTag($this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function deleteTag($withZuordnung = true, $updatable_tags = null)
|
||||
{
|
||||
parent::deleteTag(true, $this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
public function doneTag($updatable_tags = null)
|
||||
{
|
||||
parent::doneTag($this->config->item('lvverwaltung_tags'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
<?php
|
||||
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Messages extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getMessages' => ['admin:r', 'assistenz:r'],
|
||||
'getVorlagen' => ['admin:r', 'assistenz:r'],
|
||||
'getMessageVarsPerson' => ['admin:r', 'assistenz:r'],
|
||||
'getMsgVarsPrestudent' => ['admin:r', 'assistenz:r'],
|
||||
'getMsgVarsLoggedInUser' => ['admin:r', 'assistenz:r'],
|
||||
'getNameOfDefaultRecipient' => ['admin:r', 'assistenz:r'],
|
||||
'sendMessage' => ['admin:r', 'assistenz:r'],
|
||||
'deleteMessage' => ['admin:r', 'assistenz:r'],
|
||||
'getVorlagentext' => ['admin:r', 'assistenz:r'],
|
||||
'getPreviewText' => ['admin:r', 'assistenz:r'],
|
||||
'getReplyData' => ['admin:r', 'assistenz:r'],
|
||||
'getPersonId' => ['admin:r', 'assistenz:r'],
|
||||
'getUid' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('system/Message_model', 'MessageModel');
|
||||
$this->load->model('CL/Messages_model', 'MessagesModel');
|
||||
|
||||
// Additional Permission Checks
|
||||
//TODO(manu) check permissions
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('MessageLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getMessages($id, $type_id, $size, $page)
|
||||
{
|
||||
if($type_id != 'person_id'){
|
||||
$id = $this->_getPersonId($id, $type_id);
|
||||
}
|
||||
|
||||
$offset = $size * ($page - 1);
|
||||
$limit = $size;
|
||||
|
||||
$result = $this->MessageModel->getMessagesForTable($id, $offset, $limit);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->addMeta('count', $data['count']);
|
||||
|
||||
$this->terminateWithSuccess($data['data']);
|
||||
}
|
||||
|
||||
public function getVorlagen()
|
||||
{
|
||||
//get oe of user
|
||||
$uid = getAuthUID();
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung');
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$oe_kurzbz = current($data);
|
||||
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
|
||||
$result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
|
||||
//If admin
|
||||
$this->VorlageModel->addOrder('vorlage_kurzbz', 'ASC');
|
||||
$result = $this->VorlageModel->loadWhere(
|
||||
array(
|
||||
'mimetype' => 'text/html'
|
||||
));
|
||||
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getVorlagentext($vorlage_kurzbz)
|
||||
{
|
||||
//$this->terminateWithError("vor " . $vorlage_kurzbz, self::ERROR_TYPE_GENERAL);
|
||||
//$studiengang_kz = 227; //TODO(Manu) dynamisieren NULL
|
||||
$studiengang_kz = 0;
|
||||
$this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel');
|
||||
$this->VorlagestudiengangModel->addOrder('version', 'DESC');
|
||||
|
||||
$result = $this->VorlagestudiengangModel->loadWhere(
|
||||
[
|
||||
'vorlage_kurzbz' =>$vorlage_kurzbz,
|
||||
'studiengang_kz' => $studiengang_kz
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
//not correct with Vorlage
|
||||
$vorlage = current($data);
|
||||
|
||||
//$this->terminateWithSuccess($data);
|
||||
$this->terminateWithSuccess($vorlage->text);
|
||||
}
|
||||
|
||||
public function getMessageVarsPerson($id, $typeId)
|
||||
{
|
||||
$person_id = ($typeId == 'mitarbeiter_uid') ? $this->_getPersonId($id, $typeId) : $id;
|
||||
$result = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getMsgVarsPrestudent($id, $typeId)
|
||||
{
|
||||
$prestudent_id = ($typeId == 'uid') ? $this->_getPrestudentIdFromUid($id) : $id;
|
||||
$result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getMsgVarsLoggedInUser()
|
||||
{
|
||||
$result = $this->MessageModel->getMsgVarsLoggedInUser();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getNameOfDefaultRecipient($id, $type_id)
|
||||
{
|
||||
$id = ($type_id != 'person_id') ? $this->_getPersonId($id, $type_id) : $id;
|
||||
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
$result = $this->PersonModel->load($id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$name = current($data);
|
||||
|
||||
$this->terminateWithSuccess($name->vorname . " " . $name->nachname );
|
||||
}
|
||||
|
||||
public function sendMessage($recipient_id)
|
||||
{
|
||||
//has to be uid
|
||||
// $this->terminateWithError("uid", $recipient_id, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
//default setting
|
||||
$receiversPersonId = $this->_getPersonId($recipient_id, 'uid');
|
||||
|
||||
$uid = getAuthUID();
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['uid' => $uid]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$benutzer = current($data);
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('subject', 'Betreff', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Betreff'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('body', 'Text', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$subject = $this->input->post('subject');
|
||||
$body = $this->input->post('body');
|
||||
$relationmessage_id = $this->input->post('relationmessage_id');
|
||||
|
||||
$typeId = $this->input->post('type_id');
|
||||
$id = $this->input->post('id');
|
||||
|
||||
if($typeId == 'uid')
|
||||
{
|
||||
$prestudent_id = $this-> _getPrestudentIdFromUid($id);
|
||||
|
||||
//parseMessagetext for variables Prestudent
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
if($typeId == 'mitarbeiter_uid')
|
||||
{
|
||||
$person_id = $this->_getPersonId($id, $typeId);
|
||||
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($person_id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithError($bodyParsed, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
}
|
||||
elseif($typeId == 'person_id')
|
||||
{
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
elseif($typeId == 'prestudent_id')
|
||||
{
|
||||
// $this->terminateWithError("prestudent_id ", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError("type_id " . $typeId . " not valid", self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->messagelib->sendMessageUser($receiversPersonId, $subject, $bodyParsed, $benutzer->person_id, null, $relationmessage_id);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getPreviewText($id, $type_id)
|
||||
{
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
}
|
||||
else
|
||||
$this->terminateWithError("Textbody missing ", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
switch($type_id)
|
||||
{
|
||||
case 'uid':
|
||||
$prestudent_id = $this->_getPrestudentIdFromUid($id);
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $data);
|
||||
break;
|
||||
case 'prestudent_id':
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($id, $data);
|
||||
break;
|
||||
case 'person_id':
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($id, $data);
|
||||
break;
|
||||
case 'mitarbeiter_uid':
|
||||
{
|
||||
$person_id = $this->_getPersonId($id, $type_id);
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($person_id, $data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->terminateWithError("MESSAGES::getPreviewText logic for type_id " . $type_id . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
break;
|
||||
}
|
||||
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($bodyParsed);
|
||||
}
|
||||
|
||||
public function getReplyData($messageId)
|
||||
{
|
||||
//TODO(Manu) validation of messageId: if number
|
||||
|
||||
$this->MessageModel->addSelect('public.tbl_msg_message.*');
|
||||
$this->MessageModel->addSelect('r.*');
|
||||
$this->MessageModel->addSelect('p.nachname');
|
||||
$this->MessageModel->addSelect('p.vorname');
|
||||
$this->MessageModel->addJoin('public.tbl_msg_recipient r', 'ON (r.message_id = public.tbl_msg_message.message_id)');
|
||||
$this->MessageModel->addJoin('public.tbl_person p', 'ON (p.person_id = public.tbl_msg_message.person_id)');
|
||||
|
||||
$result = $this->MessageModel->loadWhere(
|
||||
array('r.message_id' => $messageId)
|
||||
);
|
||||
|
||||
$dataMessage = $this->getDataOrTerminateWithError($result);
|
||||
$prefix = "Re: "; // reply subject prefix
|
||||
|
||||
$subject = $dataMessage[0]->subject;
|
||||
$body = $dataMessage[0]->body;
|
||||
|
||||
|
||||
$replyBody = $this->_getReplyBody($body, $dataMessage[0]->nachname, $dataMessage[0]->vorname, $dataMessage[0]->insertamum);
|
||||
|
||||
$dataMessage[0]->replyBody = $replyBody;
|
||||
$dataMessage[0]->rest = "Help Manu";
|
||||
$dataMessage[0]->replySubject = $prefix . $subject;
|
||||
|
||||
$this->terminateWithSuccess($dataMessage);
|
||||
}
|
||||
|
||||
public function deleteMessage($messageId)
|
||||
{
|
||||
// Start DB transaction
|
||||
$this->db->trans_begin();
|
||||
|
||||
$result = $this->MessageModel->deleteMessageRecipient($messageId);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
}
|
||||
|
||||
$result = $this->MessageModel->deleteMessageStatus($messageId);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->MessageModel->deleteMessage($messageId);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getPersonId($id, $typeId)
|
||||
{
|
||||
if ($typeId == 'uid' || $typeId == 'mitarbeiter_uid')
|
||||
{
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['uid' => $id]
|
||||
);
|
||||
}
|
||||
elseif($typeId == 'prestudent_id')
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
['prestudent_id' => $id]
|
||||
);
|
||||
}
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$person = current($data);
|
||||
|
||||
$this->terminateWithSuccess($person->person_id);
|
||||
}
|
||||
|
||||
public function getUid($id, $typeId)
|
||||
{
|
||||
if (!$typeId)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Type ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
elseif ($typeId == 'person_id')
|
||||
{
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['person_id' => $id]
|
||||
);
|
||||
}
|
||||
elseif($typeId == 'prestudent_id')
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
['prestudent_id' => $id]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$person = current($data);
|
||||
$person_id = $person->person_id;
|
||||
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['person_id' => $person_id]
|
||||
);
|
||||
}
|
||||
elseif($typeId == 'uid' || $typeId == 'mitarbeiter_uid')
|
||||
{
|
||||
$this->terminateWithSuccess($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError("MESSAGES::getUID logic for type_id " . $typeId . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$benutzer = current($data);
|
||||
|
||||
$this->terminateWithSuccess($benutzer->uid);
|
||||
}
|
||||
|
||||
private function _getPersonId($id, $typeId)
|
||||
{
|
||||
if ($typeId == 'uid' || $typeId == 'mitarbeiter_uid')
|
||||
{
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['uid' => $id]
|
||||
);
|
||||
}
|
||||
elseif($typeId == 'prestudent_id')
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
['prestudent_id' => $id]
|
||||
);
|
||||
}
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
if (count($data) < 1)
|
||||
{
|
||||
$this->terminateWithError('Error: Messages API no person_id found.');
|
||||
}
|
||||
$person = current($data);
|
||||
|
||||
return $person->person_id;
|
||||
}
|
||||
|
||||
private function _getPrestudentIdFromUid($uid)
|
||||
{
|
||||
// $this->terminateWithError($uid, self::ERROR_TYPE_GENERAL);
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$result = $this->StudentModel->loadWhere(
|
||||
['student_uid' => $uid]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
if (count($data) < 1)
|
||||
{
|
||||
$this->terminateWithError('Error: Messages API no prestudent_id found.');
|
||||
}
|
||||
$student = current($data);
|
||||
|
||||
return $student->prestudent_id;
|
||||
}
|
||||
|
||||
private function _getReplyBody($body, $receiverName, $receiverSurname, $sentDate)
|
||||
{
|
||||
// To quote a reply body message
|
||||
$bodyFormat = "<br>
|
||||
<br>
|
||||
<blockquote>
|
||||
<i>
|
||||
On %s %s %s wrote:
|
||||
</i>
|
||||
</blockquote>
|
||||
<blockquote style='border-left:2px solid; padding-left: 8px'>
|
||||
%s
|
||||
</blockquote>";
|
||||
return sprintf(
|
||||
$bodyFormat,
|
||||
date_format(date_create($sentDate), 'd.m.Y H:i'), $receiverName, $receiverSurname, $body
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class NotizLehreinheit 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'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ class NotizPerson extends Notiz_Controller
|
||||
'loadDokumente' => ['admin:r', 'assistenz:r'],
|
||||
'getMitarbeiter' => ['admin:r', 'assistenz:r'],
|
||||
'isBerechtigt' => ['admin:r', 'assistenz:r'],
|
||||
'getCountNotes' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ class Abschlusspruefung extends FHCAPI_Controller
|
||||
'getBeurteilungen' => ['admin:rw', 'assistenz:rw'],
|
||||
'getAkadGrade' => ['admin:rw', 'assistenz:rw'],
|
||||
'getMitarbeiter' => ['admin:rw', 'assistenz:rw'],
|
||||
'getAllMitarbeiter' => ['admin:rw', 'assistenz:rw'],
|
||||
'getAllPersons' => ['admin:rw', 'assistenz:rw'],
|
||||
'getPruefer' => ['admin:rw', 'assistenz:rw'],
|
||||
'getTypStudiengang' => ['admin:rw', 'assistenz:rw'],
|
||||
'checkForExistingExams' => ['admin:rw', 'assistenz:rw'],
|
||||
@@ -38,6 +40,51 @@ class Abschlusspruefung extends FHCAPI_Controller
|
||||
|
||||
// Load models
|
||||
$this->load->model('education/Abschlusspruefung_model', 'AbschlusspruefungModel');
|
||||
|
||||
|
||||
//Permission checks for Studiengangsarray
|
||||
$allowedStgs = $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: [];
|
||||
|
||||
if ($this->router->method == 'insertAbschlusspruefung' || $this->router->method == 'updateAbschlusspruefung')
|
||||
{
|
||||
$student_uid = $this->input->post('uid') ?: ($this->input->post('formData')['student_uid'] ?? null);
|
||||
|
||||
if(!$student_uid)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->_checkAllowedStgsFromUid($student_uid, $allowedStgs);
|
||||
}
|
||||
|
||||
if ($this->router->method == 'deleteAbschlusspruefung')
|
||||
{
|
||||
$abschlusspruefung_id = $this->input->post('id');
|
||||
|
||||
if(!$abschlusspruefung_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Abschlusspruefung ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$result = $this->AbschlusspruefungModel->load(
|
||||
array('abschlusspruefung_id' => $abschlusspruefung_id)
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$student_uid = current($data)->student_uid;
|
||||
|
||||
$this->_checkAllowedStgsFromUid($student_uid, $allowedStgs);
|
||||
}
|
||||
}
|
||||
|
||||
private function _checkAllowedStgsFromUid($student_uid, $allowedStgs)
|
||||
{
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$result = $this->StudentModel->loadWhere(['student_uid' => $student_uid]);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$studiengang_kz = current($data)->studiengang_kz;
|
||||
|
||||
if (!in_array($studiengang_kz, $allowedStgs))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_keineBerechtigungStg'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAbschlusspruefung($student_uid)
|
||||
@@ -149,16 +196,16 @@ class Abschlusspruefung extends FHCAPI_Controller
|
||||
{
|
||||
$studiengang_kz= $this->input->post('studiengang_kz');
|
||||
|
||||
/* if (!$studiengang_kzs || !is_array($studiengang_kzs)) {
|
||||
$this->load->library('form_validation');
|
||||
/* if (!$studiengang_kzs || !is_array($studiengang_kzs)) {
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('studiengang_kzs', '', 'required|is_null', [
|
||||
'is_null' => $this->p->t('ui', 'error_fieldMustBeArray')
|
||||
]);
|
||||
$this->form_validation->set_rules('studiengang_kzs', '', 'required|is_null', [
|
||||
'is_null' => $this->p->t('ui', 'error_fieldMustBeArray')
|
||||
]);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}*/
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}*/
|
||||
|
||||
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
@@ -224,19 +271,7 @@ class Abschlusspruefung extends FHCAPI_Controller
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
|
||||
$_POST['pruefungstyp_kurzbz'] = $formData['pruefungstyp_kurzbz'];
|
||||
$_POST['akadgrad_id']= $formData['akadgrad_id'];
|
||||
$_POST['vorsitz'] = isset($formData['vorsitz']['mitarbeiter_uid']) ? $formData['vorsitz']['mitarbeiter_uid'] : $formData['vorsitz'];
|
||||
$_POST['pruefer1'] = isset($formData['pruefer1']['person_id']) ? $formData['pruefer1']['person_id'] : $formData['pruefer1'];
|
||||
$_POST['pruefer2'] = isset($formData['pruefer2']['person_id']) ? $formData['pruefer2']['person_id'] : $formData['pruefer2'];
|
||||
$_POST['pruefer3'] = isset($formData['pruefer3']['person_id']) ? $formData['pruefer3']['person_id'] : $formData['pruefer3'];
|
||||
$_POST['pruefungsantritt_kurzbz'] = $formData['pruefungsantritt_kurzbz'];
|
||||
$_POST['abschlussbeurteilung_kurzbz'] = $formData['abschlussbeurteilung_kurzbz'];
|
||||
$_POST['datum']= $formData['datum'];
|
||||
$_POST['sponsion']= $formData['sponsion'];
|
||||
$_POST['anmerkung'] = $formData['anmerkung'];
|
||||
$_POST['protokoll']= $formData['protokoll'];
|
||||
$_POST['note'] = $formData['note'];
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('pruefungstyp_kurzbz', 'Typ', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Typ'])
|
||||
@@ -261,19 +296,19 @@ class Abschlusspruefung extends FHCAPI_Controller
|
||||
|
||||
$result = $this->AbschlusspruefungModel->insert([
|
||||
'student_uid' => $student_uid,
|
||||
'pruefungstyp_kurzbz' => $this->input->post('pruefungstyp_kurzbz'),
|
||||
'akadgrad_id' => $this->input->post('akadgrad_id'),
|
||||
'vorsitz' => $this->input->post('vorsitz'),
|
||||
'pruefungsantritt_kurzbz' => $this->input->post('pruefungsantritt_kurzbz'),
|
||||
'abschlussbeurteilung_kurzbz' => $this->input->post('abschlussbeurteilung_kurzbz'),
|
||||
'datum' => $this->input->post('datum'), //TODO(Manu) check if minute format like FAS
|
||||
'sponsion' => $this->input->post('sponsion'),
|
||||
'pruefer1' => $this->input->post('pruefer1'),
|
||||
'pruefer2' => $this->input->post('pruefer2'),
|
||||
'pruefer3' => $this->input->post('pruefer3'),
|
||||
'protokoll' => $this->input->post('protokoll'),
|
||||
'note' => $this->input->post('note'),
|
||||
'anmerkung' => $this->input->post('anmerkung'),
|
||||
'pruefungstyp_kurzbz' => $formData['pruefungstyp_kurzbz'],
|
||||
'akadgrad_id' => $formData['akadgrad_id'],
|
||||
'vorsitz' => $formData['vorsitz'],
|
||||
'pruefungsantritt_kurzbz' => $formData['pruefungsantritt_kurzbz'],
|
||||
'abschlussbeurteilung_kurzbz' => $formData['abschlussbeurteilung_kurzbz'],
|
||||
'datum' => $formData['datum'], //TODO(Manu) check if minute format like FAS
|
||||
'sponsion' => $formData['sponsion'],
|
||||
'pruefer1' => $formData['pruefer1'],
|
||||
'pruefer2' => $formData['pruefer2'],
|
||||
'pruefer3' => $formData['pruefer3'],
|
||||
'protokoll' => $formData['protokoll'],
|
||||
'note' => $formData['note'],
|
||||
'anmerkung' => $formData['anmerkung'],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID()
|
||||
]);
|
||||
@@ -295,25 +330,17 @@ class Abschlusspruefung extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
$_POST['student_uid'] = $formData['student_uid'];
|
||||
$_POST['pruefungstyp_kurzbz'] = $formData['pruefungstyp_kurzbz'];
|
||||
$_POST['akadgrad_id']= $formData['akadgrad_id'];
|
||||
$_POST['vorsitz'] = isset($formData['vorsitz']['mitarbeiter_uid']) ? $formData['vorsitz']['mitarbeiter_uid'] : $formData['vorsitz'];
|
||||
$_POST['pruefer1'] = isset($formData['pruefer1']['person_id']) ? $formData['pruefer1']['person_id'] : $formData['pruefer1'];
|
||||
$_POST['pruefer2'] = isset($formData['pruefer2']['person_id']) ? $formData['pruefer2']['person_id'] : $formData['pruefer2'];
|
||||
$_POST['pruefer3'] = isset($formData['pruefer3']['person_id']) ? $formData['pruefer3']['person_id'] : $formData['pruefer3'];
|
||||
$_POST['pruefungsantritt_kurzbz'] = $formData['pruefungsantritt_kurzbz'];
|
||||
$_POST['abschlussbeurteilung_kurzbz'] = $formData['abschlussbeurteilung_kurzbz'];
|
||||
$_POST['datum']= $formData['datum'];
|
||||
$_POST['sponsion']= $formData['sponsion'];
|
||||
$_POST['anmerkung'] = $formData['anmerkung'];
|
||||
$_POST['protokoll']= $formData['protokoll'];
|
||||
$_POST['note'] = $formData['note'];
|
||||
$vorsitz = isset($formData['vorsitz']['mitarbeiter_uid']) ? $formData['vorsitz']['mitarbeiter_uid'] : $formData['vorsitz'];
|
||||
$pruefer1 = isset($formData['pruefer1']['person_id']) ? $formData['pruefer1']['person_id'] : $formData['pruefer1'];
|
||||
$pruefer2 = isset($formData['pruefer2']['person_id']) ? $formData['pruefer2']['person_id'] : $formData['pruefer2'];
|
||||
$pruefer3 = isset($formData['pruefer3']['person_id']) ? $formData['pruefer3']['person_id'] : $formData['pruefer3'];
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('pruefungstyp_kurzbz', 'Typ', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Typ'])
|
||||
]);
|
||||
|
||||
|
||||
$this->form_validation->set_rules('akadgrad_id', 'AkadGrad', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'AkadGrad'])
|
||||
]);
|
||||
@@ -334,25 +361,25 @@ class Abschlusspruefung extends FHCAPI_Controller
|
||||
|
||||
$result = $this->AbschlusspruefungModel->update(
|
||||
[
|
||||
'abschlusspruefung_id' => $abschlusspruefung_id
|
||||
'abschlusspruefung_id' => $abschlusspruefung_id
|
||||
],
|
||||
[
|
||||
'student_uid' => $this->input->post('student_uid'),
|
||||
'pruefungstyp_kurzbz' => $this->input->post('pruefungstyp_kurzbz'),
|
||||
'akadgrad_id' => $this->input->post('akadgrad_id'),
|
||||
'vorsitz' => $this->input->post('vorsitz'),
|
||||
'pruefungsantritt_kurzbz' => $this->input->post('pruefungsantritt_kurzbz'),
|
||||
'abschlussbeurteilung_kurzbz' => $this->input->post('abschlussbeurteilung_kurzbz'),
|
||||
'datum' => $this->input->post('datum'),
|
||||
'sponsion' => $this->input->post('sponsion'),
|
||||
'pruefer1' => $this->input->post('pruefer1'),
|
||||
'pruefer2' => $this->input->post('pruefer2'),
|
||||
'pruefer3' => $this->input->post('pruefer3'),
|
||||
'protokoll' => $this->input->post('protokoll'),
|
||||
'note' => $this->input->post('note'),
|
||||
'anmerkung' => $this->input->post('anmerkung'),
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID()
|
||||
'student_uid' => $formData['student_uid'],
|
||||
'pruefungstyp_kurzbz' => $formData['pruefungstyp_kurzbz'],
|
||||
'akadgrad_id' => $formData['akadgrad_id'],
|
||||
'vorsitz' => $vorsitz,
|
||||
'pruefungsantritt_kurzbz' => $formData['pruefungsantritt_kurzbz'],
|
||||
'abschlussbeurteilung_kurzbz' => $formData['abschlussbeurteilung_kurzbz'],
|
||||
'datum' => $formData['datum'],
|
||||
'sponsion' => $formData['sponsion'],
|
||||
'pruefer1' => $pruefer1,
|
||||
'pruefer2' => $pruefer2,
|
||||
'pruefer3' => $pruefer3,
|
||||
'protokoll' => $formData['protokoll'],
|
||||
'note' => $formData['note'],
|
||||
'anmerkung' => $formData['anmerkung'],
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]
|
||||
);
|
||||
|
||||
@@ -417,4 +444,58 @@ class Abschlusspruefung extends FHCAPI_Controller
|
||||
}
|
||||
$this->terminateWithSuccess('step3');
|
||||
}
|
||||
|
||||
/*
|
||||
* returns list of all Mitarbeiter
|
||||
* as key value list to be used in select or autocomplete
|
||||
*/
|
||||
public function getAllMitarbeiter()
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
ma.mitarbeiter_uid as mitarbeiter_uid,
|
||||
CONCAT(p.nachname, ' ', p.vorname, ' (', ma.mitarbeiter_uid, ')') as label
|
||||
FROM
|
||||
public.tbl_mitarbeiter ma
|
||||
JOIN public.tbl_benutzer bn ON (bn.uid = ma.mitarbeiter_uid)
|
||||
JOIN public.tbl_person p ON (p.person_id = bn.person_id)
|
||||
ORDER BY
|
||||
p.nachname ASC
|
||||
";
|
||||
|
||||
$result = $this->MitarbeiterModel->execReadOnlyQuery($sql);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns list of all Persons
|
||||
* as key value list to be used in select or autocomplete
|
||||
*/
|
||||
public function getAllPersons()
|
||||
{
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
p.vorname, p.nachname, p.person_id,
|
||||
CONCAT(p.nachname, ' ', p.vorname) as label
|
||||
FROM
|
||||
public.tbl_person p
|
||||
-- JOIN public.tbl_benutzer bn ON (p.person_id = bn.person_id)
|
||||
-- and bn.aktiv = 'true'
|
||||
ORDER BY
|
||||
p.nachname ASC
|
||||
";
|
||||
|
||||
//TODO(manu) check if filter active benutzer
|
||||
|
||||
$result = $this->PersonModel->execReadOnlyQuery($sql);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,11 @@ class Address extends FHCAPI_Controller
|
||||
'getNations' => self::PERM_LOGGED,
|
||||
'getPlaces' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getNations()
|
||||
@@ -53,7 +58,11 @@ class Address extends FHCAPI_Controller
|
||||
|
||||
$this->form_validation->set_data(['address.plz' => $plz]);
|
||||
|
||||
$this->form_validation->set_rules('address.plz', 'PLZ', 'required|numeric|less_than[10000]');
|
||||
$this->form_validation->set_rules('address.plz', 'PLZ', 'required|numeric|less_than[10000]', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'PLZ']),
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'PLZ']),
|
||||
'less_than' => $this->p->t('ui', 'error_fieldLessThan10000', ['field' => 'PLZ'])
|
||||
]);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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');
|
||||
|
||||
/**
|
||||
* Controller for downloading Akte
|
||||
*/
|
||||
class Akte extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Calls the parent's constructor and prepares libraries and phrases
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'download' => ['admin:w', 'assistenz:w'],
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('crm/Akte_model', 'AkteModel');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
*
|
||||
* Downloads an Akte
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$akte_id = $this->input->get('akte_id');
|
||||
|
||||
if (!is_numeric($akte_id)) $this->terminateWithError('akte Id missing');
|
||||
|
||||
$result = $this->AkteModel->load($akte_id);
|
||||
|
||||
if (!hasData($result)) $this->terminateWithError('Akte not found');
|
||||
|
||||
$data = getData($result)[0];
|
||||
|
||||
if (isset($data->inhalt) && $data->inhalt != '')
|
||||
{
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: '. $data->mimetype);
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Disposition: attachment; filename="'.$data->titel.'"');
|
||||
echo base64_decode($data->inhalt);
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Anrechnungen extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getAnrechnungen' => ['admin:r', 'assistenz:r'],
|
||||
'deleteAnrechnung' => ['admin:rw', 'assistenz:rw'],
|
||||
'getLehrveranstaltungen' => ['admin:r', 'assistenz:r'],
|
||||
'getBegruendungen' => ['admin:r', 'assistenz:r'],
|
||||
'getLektoren' => ['admin:r', 'assistenz:r'],
|
||||
'getLvsKompatibel' => ['admin:r', 'assistenz:r'],
|
||||
'insertAnrechnung' => ['admin:rw', 'assistenz:rw'],
|
||||
'loadAnrechnung' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateAnrechnung' => ['admin:rw', 'assistenz:rw'],
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui', 'lehre'
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('education/Anrechnung_model', 'AnrechnungsModel');
|
||||
}
|
||||
|
||||
public function getAnrechnungen($prestudent_id)
|
||||
{
|
||||
$result = $this->AnrechnungsModel->getAnrechnungsData($prestudent_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getBegruendungen()
|
||||
{
|
||||
$this->load->model('education/Anrechnungbegruendung_model', 'AnrechnungbegrueundungsModel');
|
||||
|
||||
$result = $this->AnrechnungbegrueundungsModel->load();
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getLehrveranstaltungen($prestudent_id)
|
||||
{
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$result = $this->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$studienplan_id = current($data)->studienplan_id;
|
||||
|
||||
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
$result = $this->LehrveranstaltungModel->getLvsByStudienplanId($studienplan_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getLvsKompatibel($lehrveranstaltung_id)
|
||||
{
|
||||
$this->AnrechnungsModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'ON (lv.lehrveranstaltung_id = lehre.tbl_anrechnung.lehrveranstaltung_id)');
|
||||
$result = $this->AnrechnungsModel->loadWhere(
|
||||
['lehrveranstaltung_id_kompatibel' => $lehrveranstaltung_id]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getLektoren($studiengang_kz)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
|
||||
$result = $this->MitarbeiterModel->getLektoren($studiengang_kz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function insertAnrechnung()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
|
||||
if(!$prestudent_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
$_POST['lehrveranstaltung_id'] =
|
||||
(isset($formData['lehrveranstaltung_id']) && !empty($formData['lehrveranstaltung_id']))
|
||||
? $formData['lehrveranstaltung_id']
|
||||
: null;
|
||||
$_POST['lehrveranstaltung_id_kompatibel'] =
|
||||
(isset($formData['lehrveranstaltung_id_kompatibel']) && !empty($formData['lehrveranstaltung_id_kompatibel']))
|
||||
? $formData['lehrveranstaltung_id_kompatibel']
|
||||
: null;
|
||||
$_POST['begruendung'] =
|
||||
(isset($formData['begruendung_id']) && !empty($formData['begruendung_id']))
|
||||
? $formData['begruendung_id']
|
||||
: null;
|
||||
$_POST['genehmigtVon'] = (isset($formData['genehmigt_von']) && !empty($formData['genehmigt_von']))
|
||||
? $formData['genehmigt_von']
|
||||
: null;
|
||||
|
||||
$this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrveranstaltung_id', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('begruendung', 'Begruendung', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Begruendung'])
|
||||
]);
|
||||
|
||||
if($_POST['begruendung'] == 2)
|
||||
{
|
||||
$this->form_validation->set_rules('lehrveranstaltung_id_kompatibel', 'Lehrveranstaltung_id', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung Kompatibel'])
|
||||
]);
|
||||
}
|
||||
|
||||
$this->form_validation->set_rules('genehmigtVon', 'GenehmigtVon', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'GenehmigtVon'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$result = $this->AnrechnungsModel->insert(
|
||||
[
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'lehrveranstaltung_id' => $_POST['lehrveranstaltung_id'],
|
||||
'lehrveranstaltung_id_kompatibel' => $_POST['lehrveranstaltung_id_kompatibel'],
|
||||
'begruendung_id' => $_POST['begruendung'],
|
||||
'genehmigt_von' => $_POST['genehmigtVon']
|
||||
]
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function loadAnrechnung($anrechnung_id)
|
||||
{
|
||||
$this->AnrechnungsModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'ON (lv.lehrveranstaltung_id = lehre.tbl_anrechnung.lehrveranstaltung_id)');
|
||||
$result = $this->AnrechnungsModel->loadWhere(
|
||||
array('anrechnung_id' => $anrechnung_id)
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function updateAnrechnung()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$anrechnung_id = $this->input->post('anrechnung_id');
|
||||
|
||||
if(!$anrechnung_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Anrechnung UID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
$_POST['lehrveranstaltung_id'] =
|
||||
(isset($formData['lehrveranstaltung_id']) && !empty($formData['lehrveranstaltung_id']))
|
||||
? $formData['lehrveranstaltung_id']
|
||||
: null;
|
||||
$_POST['lehrveranstaltung_id_kompatibel'] =
|
||||
(isset($formData['lehrveranstaltung_id_kompatibel']) && !empty($formData['lehrveranstaltung_id_kompatibel']))
|
||||
? $formData['lehrveranstaltung_id_kompatibel']
|
||||
: null;
|
||||
$_POST['begruendung'] = (isset($formData['begruendung_id']) && !empty($formData['begruendung_id'])) ? $formData['begruendung_id'] : null;
|
||||
$_POST['genehmigtVon'] = (isset($formData['genehmigt_von']) && !empty($formData['genehmigt_von'])) ? $formData['genehmigt_von'] : null;
|
||||
|
||||
$this->form_validation->set_rules('lehrveranstaltung_id', 'Lehrveranstaltung_id', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('begruendung', 'Begruendung', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Begruendung'])
|
||||
]);
|
||||
|
||||
if($_POST['begruendung'] == 2)
|
||||
{
|
||||
$this->form_validation->set_rules('lehrveranstaltung_id_kompatibel', 'Lehrveranstaltung_id', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Lehrveranstaltung Kompatibel'])
|
||||
]);
|
||||
}
|
||||
|
||||
$this->form_validation->set_rules('genehmigtVon', 'GenehmigtVon', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'GenehmigtVon'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$result = $this->AnrechnungsModel->update(
|
||||
[
|
||||
'anrechnung_id' => $anrechnung_id,
|
||||
],
|
||||
[
|
||||
|
||||
'lehrveranstaltung_id' => $_POST['lehrveranstaltung_id'],
|
||||
'lehrveranstaltung_id_kompatibel' => $_POST['lehrveranstaltung_id_kompatibel'],
|
||||
'begruendung_id' => $_POST['begruendung'],
|
||||
'genehmigt_von' => $_POST['genehmigtVon']
|
||||
]
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function deleteAnrechnung($anrechnung_id)
|
||||
{
|
||||
// Start DB transaction
|
||||
$this->db->trans_begin();
|
||||
|
||||
//delete anrechnung_id of table tbl_anrechnung_anrechnungstatus
|
||||
$this->load->model('education/Anrechnunganrechnungstatus_model','AnrechnungAnrechnungstatusModel');
|
||||
$result = $this->AnrechnungAnrechnungstatusModel->delete(
|
||||
array('anrechnung_id' => $anrechnung_id)
|
||||
);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
//delete anrechnung_id of table tbl_anrechnung
|
||||
$result = $this->AnrechnungsModel->delete(
|
||||
array('anrechnung_id' => $anrechnung_id)
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->db->trans_commit();
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
<?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 archive documents
|
||||
* Listens to ajax post calls to change the archive documents
|
||||
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
|
||||
*/
|
||||
class Archiv extends FHCAPI_Controller
|
||||
{
|
||||
/**
|
||||
* Calls the parent's constructor and prepares libraries and phrases
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getArchiv' => ['admin:r', 'assistenz:r'],
|
||||
'getArchivVorlagen' => ['admin:r', 'assistenz:r'],
|
||||
'archive' => ['admin:w', 'assistenz:w'],
|
||||
'download' => ['admin:w', 'assistenz:w'],
|
||||
'update' => ['admin:w'],
|
||||
'delete' => ['admin:w', 'assistenz:w']
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('crm/Akte_model', 'AkteModel');
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'archiv'
|
||||
]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Get archive documents for a person
|
||||
|
||||
* @return void
|
||||
*/
|
||||
public function getArchiv()
|
||||
{
|
||||
$person_id = $this->input->get('person_id');
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
$result = $this->AkteModel->getArchiv($person_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vorlagen for archiving documents
|
||||
* @return void
|
||||
*/
|
||||
public function getArchivVorlagen()
|
||||
{
|
||||
$result = $this->VorlageModel->getArchivVorlagen();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param
|
||||
* @return object success or error
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$akte_id = $this->input->get('akte_id');
|
||||
|
||||
if (!is_numeric($akte_id)) $this->terminateWithError('akte Id missing');
|
||||
|
||||
$result = $this->AkteModel->load($akte_id);
|
||||
|
||||
|
||||
if (!hasData($result)) $this->terminateWithError('Akte not found');
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$data = getData($result)[0];
|
||||
//$this->addMeta("daa", $data->inhalt);
|
||||
|
||||
$fileObj = new stdClass();
|
||||
if (isset($data->inhalt) && $data->inhalt != '')
|
||||
{
|
||||
// Define handle to output stream
|
||||
$tmpFilePointer = fopen("php://output", 'w');
|
||||
$meta_data = stream_get_meta_data($tmpFilePointer);
|
||||
$filename = $meta_data["uri"];
|
||||
fwrite($tmpFilePointer, $data->inhalt);
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: '. $data->mimetype);
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
//header('Content-Length: ' . filesize($fileObj->file));
|
||||
//header("Content-type: $data->mimetype");
|
||||
header('Content-Disposition: attachment; filename="'.$data->titel.'"');
|
||||
readfile($filename);
|
||||
//echo base64_decode($data->inhalt);
|
||||
die();
|
||||
//~ $fileObj->file = $data->inhalt;
|
||||
//~ $fileObj->name = $data->titel;
|
||||
//~ $fileObj->mimetype = $data->mimetype;
|
||||
//~ $fileObj->disposition = 'attachment';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->load->library('AkteLib');
|
||||
|
||||
$result = $this->aktelib->get($akte_id);
|
||||
}
|
||||
|
||||
/* $fileObj->filename
|
||||
* $fileObj->file
|
||||
* $fileObj->name
|
||||
* $fileObj->mimetype
|
||||
* $fileObj->disposition*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Updating an Akte
|
||||
* @return void
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('akte_id', 'Akte Id', 'required');
|
||||
$this->form_validation->set_rules('signiert', 'Signiert', 'is_bool');
|
||||
$this->form_validation->set_rules('stud_selfservice', 'Self-Service', 'is_bool');
|
||||
|
||||
//Events::trigger('konto_update_validation', $this->form_validation);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$id = $this->input->post('akte_id');
|
||||
|
||||
// get the akte
|
||||
$result = $this->AkteModel->load($id);
|
||||
|
||||
if (!hasData($result)) $this->terminateWithError("Akte not found!");
|
||||
|
||||
$akte = getData($result)[0];
|
||||
|
||||
$allowed = [
|
||||
'signiert',
|
||||
'stud_selfservice'
|
||||
];
|
||||
|
||||
$data = [
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
];
|
||||
|
||||
// if Akte has Inhalt directly in Akte table
|
||||
if (isset($_FILES['datei']['tmp_name']))
|
||||
{
|
||||
$this->addMeta('read', "read");
|
||||
// update inhalt directly
|
||||
|
||||
// get tmp file
|
||||
$filename = $_FILES['datei']['tmp_name'];
|
||||
// open it
|
||||
$fp = fopen($filename,'r');
|
||||
// read it
|
||||
$content = fread($fp, filesize($filename));
|
||||
fclose($fp);
|
||||
// encode it
|
||||
$data['inhalt'] = base64_encode($content);
|
||||
$this->addMeta('content', base64_encode($content));
|
||||
}
|
||||
|
||||
|
||||
foreach ($allowed as $field)
|
||||
if ($this->input->post($field) !== null)
|
||||
$data[$field] = $this->input->post($field);
|
||||
|
||||
$this->addMeta("data", $data);
|
||||
|
||||
$result = $this->AkteModel->update($id, $data);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = null;
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete archived Akte
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('akte_id', 'Akte ID', 'required');
|
||||
$this->form_validation->set_rules('studiengang_kz', 'Studiengang', 'has_permissions_for_stg[admin:rw,assistenz:rw]');
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$akte_id = $this->input->post('akte_id');
|
||||
|
||||
$result = $this->AkteModel->load($akte_id);
|
||||
|
||||
if (!hasData($result))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('archiv', 'error_missing', [
|
||||
'akte_id' => $akte_id
|
||||
]));
|
||||
}
|
||||
|
||||
$result = getData($result)[0];
|
||||
|
||||
if ($result->dokument_kurzbz == 'Ausbvert'
|
||||
&& isset($result->akzeptiertamum)
|
||||
&& !isEmptyString($result->akzeptiertamum)
|
||||
&& !has_permissions_for_stg($this->input->post('studiengang_kz'), 'admin:rw')
|
||||
)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('archiv', 'nur_admins_loschen_ausbildungsvertraege', [
|
||||
'akte_id' => $akte_id
|
||||
]));
|
||||
}
|
||||
|
||||
$result = $this->AkteModel->delete($akte_id);
|
||||
if (isError($result)) $this->terminateWithError(getError($result));
|
||||
|
||||
$this->terminateWithSuccess();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,413 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Aufnahmetermine extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getAufnahmetermine' => ['admin:r', 'assistenz:r'],
|
||||
'loadAufnahmetermin' => ['admin:r', 'assistenz:r'],
|
||||
'insertAufnahmetermin' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateAufnahmetermin' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteAufnahmetermin' => ['admin:rw', 'assistenz:rw'],
|
||||
'getListPlacementTests' => ['admin:r', 'assistenz:r'],
|
||||
'getListStudyPlans' => ['admin:r', 'assistenz:r'],
|
||||
'loadDataRtPrestudent' => ['admin:r', 'assistenz:r'],
|
||||
'insertOrUpdateDataRtPrestudent' => ['admin:r', 'assistenz:r'],
|
||||
'loadAufnahmegruppen' => ['admin:r', 'assistenz:r'],
|
||||
'getResultReihungstest' => ['admin:r', 'assistenz:r'],
|
||||
'getZukuenftigeReihungstestStg' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui',
|
||||
'admission'
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('crm/Reihungstest_model', 'ReihungstestModel');
|
||||
$this->load->model('crm/RtPerson_model', 'RtPersonModel');
|
||||
}
|
||||
|
||||
public function getAufnahmetermine($person_id)
|
||||
{
|
||||
$result = $this->ReihungstestModel->getReihungstestPerson($person_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function insertAufnahmetermin()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$authUID = getAuthUID();
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
$person_id = $this->input->post('person_id');
|
||||
|
||||
if(!$person_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
|
||||
$rt_id = (isset($formData['rt_id']) && !empty($formData['rt_id'])) ? $formData['rt_id'] : null;
|
||||
$anmeldedatum = (isset($formData['anmeldedatum']) && !empty($formData['anmeldedatum'])) ? $formData['anmeldedatum'] : null;
|
||||
$teilgenommen = (isset($formData['teilgenommen']) && !empty($formData['teilgenommen'])) ? $formData['teilgenommen'] : false;
|
||||
$studienplan_id = (isset($formData['studienplan_id']) && !empty($formData['studienplan_id'])) ? $formData['studienplan_id'] : null;
|
||||
$punkte = (isset($formData['punkte']) && !empty($formData['punkte'])) ? $formData['punkte'] : null;
|
||||
|
||||
//validation if there is already an RT with chosen data existing
|
||||
$result = $this->RtPersonModel->loadWhere(
|
||||
array(
|
||||
'rt_id' => $rt_id,
|
||||
'person_id' => $person_id,
|
||||
'studienplan_id' => $studienplan_id,
|
||||
)
|
||||
);
|
||||
$data = getData($result);
|
||||
if($data)
|
||||
return $this->terminateWithError("Error", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('punkte', 'Punkte', 'numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Punkte'])
|
||||
]);
|
||||
$this->form_validation->set_rules('studienplan_id', 'studienplan_id', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Studienplan'])
|
||||
]);
|
||||
$this->form_validation->set_rules('rt_id', 'Reihungstest_id', 'required', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Reihungstest'])
|
||||
]);
|
||||
$this->form_validation->set_rules('anmeldedatum', 'AnmeldeDatum', 'is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Anmeldedatum'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$result = $this->RtPersonModel->insert([
|
||||
'person_id' => $person_id,
|
||||
'rt_id' => $rt_id,
|
||||
'anmeldedatum' => $anmeldedatum,
|
||||
'teilgenommen' => $teilgenommen,
|
||||
'studienplan_id' => $studienplan_id,
|
||||
'punkte' => $punkte,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $authUID,
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function loadAufnahmetermin($rt_person_id)
|
||||
{
|
||||
$result = $this->RtPersonModel->loadWhere(
|
||||
array('rt_person_id' => $rt_person_id)
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function updateAufnahmetermin()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$authUID = getAuthUID();
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
$rt_person_id = $this->input->post('rt_person_id');
|
||||
$person_id = (isset($formData['person_id']) && !empty($formData['person_id'])) ? $formData['person_id'] : null;
|
||||
|
||||
|
||||
if(!$person_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if(!$rt_person_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'RT_Person ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$rt_id = (isset($formData['rt_id']) && !empty($formData['rt_id'])) ? $formData['rt_id'] : null;
|
||||
$anmeldedatum = (isset($formData['anmeldedatum']) && !empty($formData['anmeldedatum'])) ? $formData['anmeldedatum'] : null;
|
||||
$teilgenommen = (isset($formData['teilgenommen']) && !empty($formData['teilgenommen'])) ? $formData['teilgenommen'] : false;
|
||||
$studienplan_id = (isset($formData['studienplan_id']) && !empty($formData['studienplan_id'])) ? $formData['studienplan_id'] : null;
|
||||
$punkte = (isset($formData['punkte']) && !empty($formData['punkte'])) ? $formData['punkte'] : null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('punkte', 'Punkte', 'numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Punkte'])
|
||||
]);
|
||||
$this->form_validation->set_rules('studienplan_id', 'studienplan_id', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Studienplan'])
|
||||
]);
|
||||
$this->form_validation->set_rules('rt_id', 'Reihungstest_id', 'required', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Reihungstest'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('anmeldedatum', 'AnmeldeDatum', 'is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Anmeldedatum'])
|
||||
]);
|
||||
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$result = $this->RtPersonModel->update(
|
||||
[
|
||||
'rt_person_id' => $rt_person_id,
|
||||
],
|
||||
[
|
||||
'rt_id' => $rt_id,
|
||||
'anmeldedatum' => $anmeldedatum,
|
||||
'teilgenommen' => $teilgenommen,
|
||||
'studienplan_id' => $studienplan_id,
|
||||
'punkte' => $punkte,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $authUID,
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function deleteAufnahmetermin($rt_person_id)
|
||||
{
|
||||
$result = $this->RtPersonModel->delete(
|
||||
array('rt_person_id' => $rt_person_id)
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getListPlacementTests($prestudent_id)
|
||||
{
|
||||
if(!$prestudent_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//get studienplan array
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
|
||||
$this->PrestudentstatusModel->addSelect('*');
|
||||
$this->PrestudentstatusModel->addSelect('sp.studienplan_id');
|
||||
|
||||
$this->PrestudentstatusModel->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
|
||||
|
||||
$result = $this->PrestudentstatusModel->loadWhere(
|
||||
array(
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => 'Interessent'
|
||||
)
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$studienplan_arr = [];
|
||||
$include_ids = [];
|
||||
foreach ($data as $item)
|
||||
{
|
||||
if($item->studienplan_id != null)
|
||||
$studienplan_arr[] = $item->studienplan_id;
|
||||
}
|
||||
|
||||
//get Placementtests Person
|
||||
$person_id = $this->_getPersonId($prestudent_id);
|
||||
$resultRt = $this->ReihungstestModel->getReihungstestPerson($person_id);
|
||||
|
||||
$dataRt = $this->getDataOrTerminateWithError($resultRt);
|
||||
|
||||
foreach ($dataRt as $item)
|
||||
{
|
||||
if(!in_array($item->studienplan_id, $studienplan_arr))
|
||||
$studienplan_arr[] = $item->studienplan_id;
|
||||
if(!in_array($item->rt_id, $include_ids) && ($item->rt_id != null))
|
||||
$include_ids[] = $item->rt_id;
|
||||
}
|
||||
|
||||
$result = $this->ReihungstestModel->getReihungstestByStudyPlanAndIds($studienplan_arr, $include_ids);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getListStudyPlans($person_id)
|
||||
{
|
||||
$this->load->model('organisation/Studienplan_model', 'StudienplanModel');
|
||||
|
||||
$result = $this->StudienplanModel->getStudienplaeneForPerson($person_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function loadDataRtPrestudent($prestudent_id)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$this->PrestudentModel->addSelect(["reihungstestangetreten"]);
|
||||
$this->PrestudentModel->addSelect(["rt_gesamtpunkte"]);
|
||||
$this->PrestudentModel->addSelect(["aufnahmegruppe_kurzbz"]);
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
array('prestudent_id' => $prestudent_id)
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function insertOrUpdateDataRtPrestudent()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$authUID = getAuthUID();
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
|
||||
if(!$prestudent_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$rt_gesamtpunkte =
|
||||
(isset($formData['rt_gesamtpunkte']) && !empty($formData['rt_gesamtpunkte']))
|
||||
? $formData['rt_gesamtpunkte']
|
||||
: null;
|
||||
$reihungstestangetreten =
|
||||
(isset($formData['reihungstestangetreten']) && !empty($formData['reihungstestangetreten']))
|
||||
? $formData['reihungstestangetreten']
|
||||
: null;
|
||||
$aufnahmegruppe_kurzbz =
|
||||
(isset($formData['aufnahmegruppe_kurzbz']) && !empty($formData['aufnahmegruppe_kurzbz']))
|
||||
? $formData['aufnahmegruppe_kurzbz']
|
||||
: null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('rt_gesamtpunkte', 'Rt_gesamtpunkte', 'numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Rt_gesamtpunkte'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
$result = $this->PrestudentModel->update(
|
||||
[
|
||||
'prestudent_id' => $prestudent_id,
|
||||
],
|
||||
[
|
||||
'reihungstestangetreten' => $reihungstestangetreten,
|
||||
'rt_gesamtpunkte' => $rt_gesamtpunkte,
|
||||
'aufnahmegruppe_kurzbz' => $aufnahmegruppe_kurzbz,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => $authUID,
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function loadAufnahmegruppen()
|
||||
{
|
||||
$uid = $this->input->get('uid');
|
||||
$studiensemester_kurzbz = $this->input->get('studiensemester_kurzbz');
|
||||
|
||||
$this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel');
|
||||
|
||||
$result = $this->BenutzergruppeModel->loadAufnahmegruppen($uid, $studiensemester_kurzbz);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(($data));
|
||||
}
|
||||
|
||||
public function getResultReihungstest()
|
||||
{
|
||||
$person_id = $this->input->get('person_id');
|
||||
$punkte = $this->input->get('punkte');
|
||||
$reihungstest_id = $this->input->get('reihungstest_id');
|
||||
|
||||
if(!$reihungstest_id)
|
||||
{
|
||||
$this->terminateWithSuccess(null);
|
||||
}
|
||||
|
||||
//for gewichtung
|
||||
$studiengang_kz = $this->input->get('studiengang_kz');
|
||||
|
||||
$this->load->model('testtool/Ablauf_model', 'AblaufModel');
|
||||
$result = $this->AblaufModel->getAblaufGebieteAndGewichte($studiengang_kz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$weightedArray = [];
|
||||
foreach ($data as $abl)
|
||||
{
|
||||
$weightedArray[$abl->gebiet_id] = $abl->gewicht;
|
||||
}
|
||||
|
||||
$result = $this->ReihungstestModel->getReihungstestErgebnisPerson($person_id, $punkte, $reihungstest_id, $weightedArray);
|
||||
|
||||
/* if (isError($result))
|
||||
{
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}*/
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getZukuenftigeReihungstestStg()
|
||||
{
|
||||
$studiengang_kz = $this->input->get('studiengang_kz');
|
||||
if(!$studiengang_kz)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Studiengang_kz']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->ReihungstestModel->getZukuenftigeReihungstestStg($studiengang_kz);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
private function _getPersonId($prestudent_id)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
['prestudent_id' => $prestudent_id]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$person = current($data);
|
||||
|
||||
return $person->person_id;
|
||||
}
|
||||
}
|
||||
@@ -62,10 +62,15 @@ class Config extends FHCAPI_Controller
|
||||
'component' => './Stv/Studentenverwaltung/Details/Details.js',
|
||||
'config' => $config['details']
|
||||
];
|
||||
|
||||
$result['notes'] = [
|
||||
'title' => $this->p->t('stv', 'tab_notes'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Notizen.js'
|
||||
'component' => './Stv/Studentenverwaltung/Details/Notizen.js',
|
||||
'config' => $config['notes'],
|
||||
'showSuffix' => ($config['notes']['showCountNotes'] ?? false),
|
||||
'suffixhelper' => APP_ROOT . 'public/js/helpers/Stv/Studentenverwaltung/Details/Notizen/NotizenSuffixHelper.js'
|
||||
];
|
||||
|
||||
$result['contact'] = [
|
||||
'title' => $this->p->t('stv', 'tab_contact'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Kontakt.js',
|
||||
@@ -83,6 +88,10 @@ class Config extends FHCAPI_Controller
|
||||
'title' => 'Status',
|
||||
'component' => './Stv/Studentenverwaltung/Details/MultiStatus.js'
|
||||
];
|
||||
$result['documents'] = [
|
||||
'title' => $this->p->t('stv', 'tab_documents'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Dokumente.js'
|
||||
];
|
||||
$result['banking'] = [
|
||||
'title' => $this->p->t('stv', 'tab_banking'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Konto.js',
|
||||
@@ -99,6 +108,15 @@ class Config extends FHCAPI_Controller
|
||||
'title' => $this->p->t('stv', 'tab_resources'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js'
|
||||
];
|
||||
$result['groups'] = [
|
||||
'title' => $this->p->t('stv', 'tab_groups'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Gruppen.js'
|
||||
];
|
||||
$result['messages'] = [
|
||||
'title' => $this->p->t('stv', 'tab_messages'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Messages.js'
|
||||
];
|
||||
|
||||
$result['grades'] = [
|
||||
'title' => $this->p->t('stv', 'tab_grades'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Noten.js',
|
||||
@@ -117,6 +135,12 @@ class Config extends FHCAPI_Controller
|
||||
'component' => './Stv/Studentenverwaltung/Details/Pruefung.js'
|
||||
];
|
||||
|
||||
$result['exemptions'] = [
|
||||
'title' => $this->p->t('lehre', 'anrechnungen'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Anrechnungen.js',
|
||||
'config' => $config['exemptions']
|
||||
];
|
||||
|
||||
$result['finalexam'] = [
|
||||
'title' => $this->p->t('stv', 'tab_finalexam'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Abschlusspruefung.js',
|
||||
@@ -128,11 +152,41 @@ class Config extends FHCAPI_Controller
|
||||
'component' => './Stv/Studentenverwaltung/Details/Mobility.js'
|
||||
];
|
||||
|
||||
$result['archive'] = [
|
||||
'title' => $this->p->t('stv', 'tab_archive'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Archiv.js',
|
||||
'config' => [
|
||||
'showEdit' => $this->permissionlib->isBerechtigt('admin')
|
||||
]
|
||||
];
|
||||
|
||||
$result['jointstudies'] = [
|
||||
'title' => $this->p->t('stv', 'tab_jointstudies'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/JointStudies.js'
|
||||
];
|
||||
|
||||
$result['coursedates'] = [
|
||||
'title' => $this->p->t('stv', 'tab_courseDates'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Lehrveranstaltungstermine.js'
|
||||
];
|
||||
|
||||
$result['admissionDates'] = [
|
||||
'title' => $this->p->t('stv', 'tab_admissionDates'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Aufnahmetermine.js'
|
||||
];
|
||||
|
||||
$result['functions'] = [
|
||||
'title' => $this->p->t('stv', 'tab_functions'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Funktionen.js'
|
||||
];
|
||||
|
||||
Events::trigger('stv_conf_student', function & () use (&$result) {
|
||||
return $result;
|
||||
});
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
$sortConfig = $this->config->item('student_tab_order');
|
||||
|
||||
$this->terminateWithSuccess($this->sortTabList($result, $sortConfig));
|
||||
}
|
||||
|
||||
public function students()
|
||||
@@ -163,16 +217,25 @@ class Config extends FHCAPI_Controller
|
||||
]
|
||||
];
|
||||
$result['finalexam'] = [
|
||||
'title' => $this->p->t('stv', 'tab_finalexam'),
|
||||
'title' => $this->p->t('stv', 'tab_finalexam'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Abschlusspruefung.js',
|
||||
'config' => $config['finalexam']
|
||||
];
|
||||
$result['archive'] = [
|
||||
'title' => $this->p->t('stv', 'tab_archive'),
|
||||
'component' => './Stv/Studentenverwaltung/Details/Archiv.js',
|
||||
'config' => [
|
||||
'showEdit' => $this->permissionlib->isBerechtigt('admin')
|
||||
]
|
||||
];
|
||||
|
||||
Events::trigger('stv_conf_students', function & () use (&$result) {
|
||||
return $result;
|
||||
});
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
$sortConfig = $this->config->item('students_tab_order');
|
||||
|
||||
$this->terminateWithSuccess($this->sortTabList($result, $sortConfig));
|
||||
}
|
||||
|
||||
protected function kontoColumns()
|
||||
@@ -303,7 +366,7 @@ class Config extends FHCAPI_Controller
|
||||
$title_eng = $this->p->t("global", "englisch");
|
||||
$title_ff = $this->p->t("stv", "document_certificate");
|
||||
$title_lv = $this->p->t("stv", "document_coursecertificate");
|
||||
|
||||
|
||||
$link_ff = "documents/export/" .
|
||||
"zertifikat.rdf.php/" .
|
||||
"Zertifikat" .
|
||||
@@ -448,4 +511,34 @@ class Config extends FHCAPI_Controller
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort tab list
|
||||
*
|
||||
* @param array $input
|
||||
* @param array $config
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function sortTabList($input, $config)
|
||||
{
|
||||
// prepare config
|
||||
if (!$config || !is_array($config))
|
||||
$config = [];
|
||||
else
|
||||
$config = array_flip($config);
|
||||
|
||||
// fill missing items in config
|
||||
foreach (array_keys($input) as $key) {
|
||||
if (!isset($config[$key]))
|
||||
$config[$key] = count($config);
|
||||
}
|
||||
|
||||
// do the sorting
|
||||
uksort($input, function ($a, $b) use ($config) {
|
||||
return $config[$a] - $config[$b];
|
||||
});
|
||||
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,569 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Dokumente extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getDocumentsUnaccepted' => ['admin:r', 'assistenz:r'],
|
||||
'getDocumentsAccepted' => ['admin:r', 'assistenz:r'],
|
||||
'deleteZuordnung' => ['admin:rw', 'assistenz:rw'],
|
||||
'createZuordnung' => ['admin:rw', 'assistenz:rw'],
|
||||
'loadAkte' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteAkte' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateAkte' => ['admin:rw', 'assistenz:rw'],
|
||||
'getDoktypen' => ['admin:r', 'assistenz:r'],
|
||||
'uploadDokument' => ['admin:rw', 'assistenz:rw'],
|
||||
'download' => ['admin:rw', 'assistenz:rw'],
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('DmsLib', array('who' => getAuthUID()));
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui',
|
||||
'dokumente'
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('crm/Akte_model', 'AkteModel');
|
||||
$this->load->model('crm/Dokument_model', 'DokumentModel');
|
||||
$this->load->model('crm/Dokumentprestudent_model', 'DokumentprestudentModel');
|
||||
|
||||
//TODO(Manu) check additional Berechtigungen
|
||||
//TODO(Manu) check if using dokument lib instead of dokument model?
|
||||
}
|
||||
|
||||
public function getDocumentsUnaccepted($prestudent_id, $studiengang_kz)
|
||||
{
|
||||
if(!$prestudent_id)
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (!is_numeric($prestudent_id))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if(!$studiengang_kz)
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiengang_kz']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$person_id = $this->_getPersonId($prestudent_id);
|
||||
$result = $this->DokumentModel->getUnacceptedDocuments($prestudent_id, $person_id);
|
||||
|
||||
$dataAkteUnaccepted = $this->getDataOrTerminateWithError($result);
|
||||
$resultMd = $this->_getMissingDocuments($studiengang_kz, $prestudent_id);
|
||||
|
||||
$data = $this->_mergeDocuments($dataAkteUnaccepted, $resultMd);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getDocumentsAccepted($prestudent_id, $studiengang_kz)
|
||||
{
|
||||
if(!$prestudent_id)
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (!is_numeric($prestudent_id))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if(!$studiengang_kz)
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiengang_kz']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$resultPreDoc = $this->_getPrestudentDokumente($prestudent_id);
|
||||
|
||||
$arrayAccepted = [];
|
||||
$person_id = $this->_getPersonId($prestudent_id);
|
||||
|
||||
$docNames = array_map(function ($item) {
|
||||
return $item->dokument_kurzbz;
|
||||
}, $resultPreDoc);
|
||||
|
||||
foreach($docNames as $doc)
|
||||
{
|
||||
$result = $this->AkteModel->getAktenFAS($person_id, $doc, $studiengang_kz, $prestudent_id, true);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (hasData($result))
|
||||
{
|
||||
$data = getData($result);
|
||||
foreach ($data as $value)
|
||||
{
|
||||
array_push($arrayAccepted, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mapping with document_kurzbz
|
||||
$preDocMap = [];
|
||||
foreach ($resultPreDoc as $pre) {
|
||||
$preDocMap[$pre->dokument_kurzbz] = $pre;
|
||||
}
|
||||
|
||||
$mergedArray = [];
|
||||
foreach ($arrayAccepted as $doc) {
|
||||
$merged = clone $doc;
|
||||
|
||||
if (isset($preDocMap[$doc->dokument_kurzbz])) {
|
||||
$merged->docdatum = $preDocMap[$doc->dokument_kurzbz]->docdatum;
|
||||
$merged->insertvonma = $preDocMap[$doc->dokument_kurzbz]->insertvonma;
|
||||
$merged->bezeichnung = $preDocMap[$doc->dokument_kurzbz]->bezeichnung;
|
||||
} else {
|
||||
$merged->akzeptiertdatum = null;
|
||||
$merged->akzeptiertvon = null;
|
||||
}
|
||||
|
||||
$mergedArray[] = $merged;
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($mergedArray);
|
||||
}
|
||||
|
||||
public function deleteZuordnung($prestudent_id, $dokument_kurzbz)
|
||||
{
|
||||
if(!$prestudent_id)
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (!is_numeric($prestudent_id))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if(!$dokument_kurzbz)
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Dokument_kurzbz']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->DokumentprestudentModel->delete(
|
||||
[
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'dokument_kurzbz' => $dokument_kurzbz
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function loadAkte($akte_id)
|
||||
{
|
||||
if (!$akte_id)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Akte ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->AkteModel->addSelect('public.tbl_akte.*');
|
||||
$this->AkteModel->addSelect("CONCAT(public.tbl_person.vorname, ' ' , public.tbl_person.nachname) AS namePerson");
|
||||
$this->AkteModel->addJoin('public.tbl_person', 'person_id');
|
||||
$result = $this->AkteModel->loadWhere(
|
||||
[
|
||||
'akte_id' => $akte_id,
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$data = current($data);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function updateAkte()
|
||||
{
|
||||
$this->form_validation->set_rules('akte_id', 'Akte ID', 'required', [
|
||||
'required' => $this->p->t('dokumente', 'err_updateNotAllowed')
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('dokument_kurzbz', 'Dokumenttyp', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Dokumenttyp'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('nachreichung_am', 'Nachreichung am', 'is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Nachreichung am'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
$result = $this->AkteModel->update(
|
||||
[
|
||||
'akte_id' => $this->input->post('akte_id'),
|
||||
],
|
||||
[
|
||||
'dokument_kurzbz' => $this->input->post('dokument_kurzbz'),
|
||||
'anmerkung_intern' => $this->input->post('anmerkung_intern'),
|
||||
'titel_intern' => $this->input->post('titel_intern'),
|
||||
'nachgereicht_am' => $this->input->post('nachgereicht_am'),
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => $uid,
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function createZuordnung($prestudent_id, $dokument_kurzbz)
|
||||
{
|
||||
if (!$prestudent_id)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if(!$dokument_kurzbz)
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Dokument_kurzbz']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$uid = getAuthUid();
|
||||
|
||||
//check if more than 1 dokumentkurzbz
|
||||
//if()
|
||||
|
||||
$result = $this->DokumentprestudentModel->insert(
|
||||
[
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'dokument_kurzbz' => $dokument_kurzbz,
|
||||
'mitarbeiter_uid' => $uid,
|
||||
'datum' => date('c'),
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid,
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function deleteAkte($akte_id)
|
||||
{
|
||||
if (!$akte_id)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Akte ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->AkteModel->load($akte_id);
|
||||
$dataAkte = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$logdata_akte = var_export($dataAkte, true);
|
||||
|
||||
$dms_id = current($dataAkte)->dms_id;
|
||||
$nachgereicht = current($dataAkte)->nachgereicht;
|
||||
$inhalt = current($dataAkte)->inhalt;
|
||||
$inhaltVorhanden = $inhalt != '';
|
||||
$uid = getAuthUid();
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
if($dms_id)
|
||||
{
|
||||
$this->load->model('content/Dms_model', 'DmsModel');
|
||||
$result = $this->DmsModel->load($dms_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$logdata_dms = (array)$data;
|
||||
$logdata_dms = "Logdata: " . var_export($logdata_dms, true);
|
||||
|
||||
//delete from dmsLib
|
||||
$this->load->library('DmsLib');
|
||||
$person_id = current($dataAkte)->person_id;
|
||||
$result = $this->dmslib->delete($person_id, $dms_id);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
//LOGGING Dms ID
|
||||
$this->load->model('system/Log_model', 'LogModel');
|
||||
$result = $this->LogModel->insert([
|
||||
'executetime' => date('c'),
|
||||
'mitarbeiter_uid' => $uid,
|
||||
'beschreibung' => "Löschen der DMS_ID ". $dms_id,
|
||||
'sql' => $logdata_dms
|
||||
]);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
//delete akte
|
||||
$result = $this->AkteModel->delete(
|
||||
[
|
||||
'akte_id' => $akte_id
|
||||
]
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
//Logging Deletion Akte
|
||||
$result = $this->LogModel->insert([
|
||||
'executetime' => date('c'),
|
||||
'mitarbeiter_uid' => $uid,
|
||||
'beschreibung' => "Löschen der Akte ". $akte_id,
|
||||
'sql' => "DELETE FROM public.tbl_akte WHERE akte_id=" .$akte_id. " LogData: ". $logdata_akte
|
||||
]);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
$this->db->trans_complete();
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
elseif (!!$dms_id || ($nachgereicht && !$inhaltVorhanden))
|
||||
{
|
||||
$result = $this->AkteModel->delete(
|
||||
[
|
||||
'akte_id' => $akte_id
|
||||
]
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = $this->LogModel->insert([
|
||||
'executetime' => date('c'),
|
||||
'mitarbeiter_uid' => $uid,
|
||||
'beschreibung' => "Löschen der Akte ". $akte_id,
|
||||
'sql' => "DELETE FROM public.tbl_akte WHERE akte_id=" .$akte_id. " LogData: ". $logdata_akte
|
||||
]);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->db->trans_complete();
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
else
|
||||
$this->terminateWithError($this->p->t('dokumente', 'err_deleteDokHere'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
public function uploadDokument()
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
$anmerkung_intern = $this->input->post('anmerkung_intern');
|
||||
$titel_intern = $this->input->post('titel_intern');
|
||||
$dokument_kurzbz = $this->input->post('dokument_kurzbz');
|
||||
|
||||
$this->form_validation->set_rules('prestudent_id', 'Prestudent_id', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Prestudent ID'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('dokument_kurzbz', 'Dokumenttyp', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Dokumenttyp'])
|
||||
]);
|
||||
|
||||
//validation if attachment was added
|
||||
$this->form_validation->set_rules('anhang', 'Attachment', 'callback_file_check');
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->db->trans_start();
|
||||
$uid = getAuthUID();
|
||||
|
||||
$dms = array(
|
||||
'kategorie_kurzbz' => 'Akte',
|
||||
'version' => 0,
|
||||
'name' => $_FILES['anhang']['name'],
|
||||
'mimetype' => $_FILES['anhang']['type'],
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $uid
|
||||
);
|
||||
|
||||
$result = $this->dmslib->upload($dms, 'anhang', array("jpg", "png", "pdf"));
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$dms_id = $result->retval['dms_id'];
|
||||
|
||||
$person_id = $this->_getPersonId($prestudent_id);
|
||||
|
||||
$result = $this->DokumentModel->load($dokument_kurzbz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$bezeichnung = current($data)->bezeichnung;
|
||||
|
||||
//save entry in akte
|
||||
if($dms_id)
|
||||
{
|
||||
$result = $this->AkteModel->insert([
|
||||
'person_id' => $person_id,
|
||||
'dms_id' => $dms_id,
|
||||
'dokument_kurzbz' => $dokument_kurzbz,
|
||||
'mimetype' => $_FILES['anhang']['type'],
|
||||
'insertamum' => date('c'),
|
||||
'erstelltam' => date('c'),
|
||||
'insertvon' => $uid,
|
||||
'anmerkung_intern' => $anmerkung_intern,
|
||||
'titel_intern' => $titel_intern,
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'titel' => $_FILES['anhang']['name']
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->db->trans_complete();
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getDoktypen()
|
||||
{
|
||||
$this->DokumentModel->addSelect('dokument_kurzbz');
|
||||
$this->DokumentModel->addSelect('bezeichnung');
|
||||
$this->DokumentModel->addOrder('dokument_kurzbz', 'ASC');
|
||||
$result = $this->DokumentModel->load();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function download()
|
||||
{
|
||||
//TODO(Manu) check filetype, Decoding
|
||||
$akte_id = $this->input->get('akte_id');
|
||||
|
||||
if(!$akte_id)
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Akte ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (!is_numeric($akte_id))
|
||||
$this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value' => 'Akte ID']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
|
||||
$result = $this->AkteModel->load($akte_id);
|
||||
if (!hasData($result)) $this->terminateWithError('Akte not found');
|
||||
$data = getData($result)[0];
|
||||
|
||||
$mimetype = $data->mimetype;
|
||||
$filecontentbase64 = $data->inhalt;
|
||||
$filename = $data->titel;
|
||||
|
||||
if(intval($data->dms_id) > 0)
|
||||
{
|
||||
$dmsdokres = $this->dmslib->read($data->dms_id);
|
||||
if (!hasData($dmsdokres)) $this->terminateWithError('DMS File not found');
|
||||
$dmsdok = getData($dmsdokres)[0];
|
||||
|
||||
$mimetype = $dmsdok->mimetype;
|
||||
$filecontentbase64 = $dmsdok->file_content;
|
||||
$filename = $dmsdok->name;
|
||||
}
|
||||
|
||||
$filecontent = '';
|
||||
|
||||
if (!empty($filecontentbase64)) {
|
||||
$filecontent = base64_decode($filecontentbase64, true);
|
||||
|
||||
if ($filecontent === false) {
|
||||
$this->terminateWithError('Base64-Dekodierung failed.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->terminateWithFileOutput($mimetype, $filecontent, $filename);
|
||||
}
|
||||
|
||||
private function _getMissingDocuments($studiengang_kz, $prestudent_id)
|
||||
{
|
||||
$result = $this->DokumentModel->getMissingDocuments($studiengang_kz, $prestudent_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function _getUnacceptedDocuments($prestudent_id)
|
||||
{
|
||||
$person_id = $this->_getPersonId($prestudent_id);
|
||||
$result = $this->DokumentModel->getUnacceptedDocuments($prestudent_id, $person_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* helper function for merging objects
|
||||
* sorts object after merging according to dokument_kurzbz
|
||||
* @param $original object of documents of akte
|
||||
* @param object $toMerge documents to merge (of dokumentprestudent, dokumentstudiengang)
|
||||
* @return Array mergedObject
|
||||
*/
|
||||
private function _mergeDocuments($original, $toMerge)
|
||||
{
|
||||
$existingKurzbez = [];
|
||||
foreach ($original as $doc) {
|
||||
$existingKurzbez[$doc->dokument_kurzbz] = true;
|
||||
}
|
||||
|
||||
foreach ($toMerge as $doc) {
|
||||
if (!isset($existingKurzbez[$doc->dokument_kurzbz])) {
|
||||
$original[] = $doc;
|
||||
$existingKurzbez[$doc->dokument_kurzbz] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($original as $docOriginal)
|
||||
{
|
||||
if ($docOriginal->dokument_kurzbz == $doc->dokument_kurzbz)
|
||||
{
|
||||
$docOriginal->pflicht = $doc->pflicht;
|
||||
$docOriginal->onlinebewerbung = $doc->onlinebewerbung;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usort($original, function ($a, $b) {
|
||||
return strcmp($a->dokument_kurzbz, $b->dokument_kurzbz);
|
||||
});
|
||||
|
||||
return $original;
|
||||
}
|
||||
|
||||
private function _getDocumentsOfAkte($person_id)
|
||||
{
|
||||
$result = $this->AkteModel->getAktenFAS($person_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function _getPrestudentDokumente($prestudent_id)
|
||||
{
|
||||
$result = $this->DokumentprestudentModel->getPrestudentDokumente($prestudent_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function _getPersonId($prestudent_id)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
['prestudent_id' => $prestudent_id]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$person = current($data);
|
||||
|
||||
return $person->person_id;
|
||||
}
|
||||
|
||||
public function file_check($str)
|
||||
{
|
||||
if (isset($_FILES['anhang']) && $_FILES['anhang']['size'] > 0)
|
||||
{
|
||||
$allowed_mime_types = ['image/jpeg', 'image/png', 'application/pdf'];
|
||||
$mime = mime_content_type($_FILES['anhang']['tmp_name']);
|
||||
|
||||
if (in_array($mime, $allowed_mime_types))
|
||||
{
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
$this->form_validation->set_message('file_check', $this->p->t('dokumente', 'error_fileType'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form_validation->set_message('file_check', $this->p->t('dokumente', 'error_fileMissing'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,6 @@ class Favorites extends FHCAPI_Controller
|
||||
|
||||
// Load models
|
||||
$this->load->model('system/Variable_model', 'VariableModel');
|
||||
|
||||
// TODO(chris): variable table might be to small to store favorites!
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class GemeinsameStudien extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getStudien' => ['admin:r', 'assistenz:r'],
|
||||
'loadStudie' => ['admin:r', 'assistenz:r'],
|
||||
'insertStudie' => ['admin:rw', 'assistenz:rw'],
|
||||
'updateStudie' => ['admin:rw', 'assistenz:rw'],
|
||||
'deleteStudie' => ['admin:rw', 'assistenz:rw'],
|
||||
'getProgramsStudien' => ['admin:r', 'assistenz:r'],
|
||||
'getTypenMobility' => ['admin:r', 'assistenz:r'],
|
||||
'getStudiensemester' => ['admin:r', 'assistenz:r'],
|
||||
'getStudienprogramme' => ['admin:r', 'assistenz:r'],
|
||||
'getPartnerfirmen' => ['admin:r', 'assistenz:r'],
|
||||
'getStatiPrestudent' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui',
|
||||
'jointstudies'
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('codex/Mobilitaet_model', 'MobilitaetModel');
|
||||
|
||||
//TODO(check if additional Permissions necessary): 'student/stammdaten'
|
||||
}
|
||||
|
||||
public function getStudien($prestudent_id)
|
||||
{
|
||||
$this->MobilitaetModel->addSelect('mobilitaet_id');
|
||||
$this->MobilitaetModel->addSelect('mobilitaetstyp_kurzbz');
|
||||
$this->MobilitaetModel->addSelect('prestudent_id');
|
||||
$this->MobilitaetModel->addSelect('studiensemester_kurzbz');
|
||||
$this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.mobilitaetsprogramm_code');
|
||||
$this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.gsprogramm_id');
|
||||
$this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.firma_id');
|
||||
$this->MobilitaetModel->addSelect('status_kurzbz');
|
||||
$this->MobilitaetModel->addSelect('ausbildungssemester');
|
||||
$this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.insertvon');
|
||||
$this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.insertamum');
|
||||
$this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.updatevon');
|
||||
$this->MobilitaetModel->addSelect('bis.tbl_mobilitaet.updateamum');
|
||||
$this->MobilitaetModel->addSelect('mp.kurzbz');
|
||||
$this->MobilitaetModel->addSelect('gp.gsprogrammtyp_kurzbz');
|
||||
$this->MobilitaetModel->addSelect('gp.bezeichnung as studienprogramm');
|
||||
$this->MobilitaetModel->addSelect('f.name as partner');
|
||||
|
||||
$this->MobilitaetModel->addJoin('bis.tbl_mobilitaetsprogramm mp', 'ON (mp.mobilitaetsprogramm_code = bis.tbl_mobilitaet.mobilitaetsprogramm_code)', 'LEFT');
|
||||
$this->MobilitaetModel->addJoin('bis.tbl_gsprogramm gp', 'ON (gp.gsprogramm_id = bis.tbl_mobilitaet.gsprogramm_id)', 'LEFT');
|
||||
$this->MobilitaetModel->addJoin('public.tbl_firma f', 'ON (f.firma_id = bis.tbl_mobilitaet.firma_id)', 'LEFT');
|
||||
|
||||
$result = $this->MobilitaetModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getTypenMobility()
|
||||
{
|
||||
$this->load->model('codex/Mobilitaetstyp_model', 'MobilitaetstypModel');
|
||||
|
||||
$result = $this->MobilitaetstypModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getStudiensemester()
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->StudiensemesterModel->addOrder('studienjahr_kurzbz', 'DESC');
|
||||
$result = $this->StudiensemesterModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getStudienprogramme()
|
||||
{
|
||||
$this->load->model('codex/Gsprogramm_model', 'GsprogrammModel');
|
||||
|
||||
$result = $this->GsprogrammModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getPartnerfirmen()
|
||||
{
|
||||
$this->load->model('ressource/Firma_model', 'FirmaModel');
|
||||
|
||||
$result = $this->FirmaModel->loadWhere(
|
||||
['partner_code !=' => null]
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getStatiPrestudent()
|
||||
{
|
||||
$this->load->model('crm/Status_model', 'StatusModel');
|
||||
|
||||
$result = $this->StatusModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function loadStudie($mobilitaet_id)
|
||||
{
|
||||
$result = $this->MobilitaetModel->load($mobilitaet_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function insertStudie()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$authUID = getAuthUID();
|
||||
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
if(!$prestudent_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
$ausbildungssemester = (isset($formData['ausbildungssemester']) && !empty($formData['ausbildungssemester']))
|
||||
? $formData['ausbildungssemester']
|
||||
: null;
|
||||
$mobilitaetstyp_kurzbz = (isset($formData['mobilitaetstyp_kurzbz']) && !empty($formData['mobilitaetstyp_kurzbz']))
|
||||
? $formData['mobilitaetstyp_kurzbz']
|
||||
: null;
|
||||
$studiensemester_kurzbz = (isset($formData['studiensemester_kurzbz']) && !empty($formData['studiensemester_kurzbz']))
|
||||
? $formData['studiensemester_kurzbz'] : null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('mobilitaetstyp_kurzbz', 'Typ', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Typ'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Studiensemester'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'required|numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Ausbildungssemester']),
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Ausbildungssemester']),
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$status_kurzbz = (isset($formData['status_kurzbz']) && !empty($formData['status_kurzbz']))
|
||||
? $formData['status_kurzbz']
|
||||
: null;
|
||||
$mobilitaetsprogramm_code = (isset($formData['mobilitaetsprogramm_code']) && !empty($formData['mobilitaetsprogramm_code']))
|
||||
? $formData['mobilitaetsprogramm_code']
|
||||
: null;
|
||||
$gsprogramm_id = (isset($formData['gsprogramm_id']) && !empty($formData['gsprogramm_id']))
|
||||
? $formData['gsprogramm_id']
|
||||
: null;
|
||||
$firma_id= (isset($formData['firma_id']) && !empty($formData['firma_id'])) ? $formData['firma_id'] : null;
|
||||
|
||||
$result = $this->MobilitaetModel->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'mobilitaetstyp_kurzbz' =>$mobilitaetstyp_kurzbz,
|
||||
'status_kurzbz' => $status_kurzbz,
|
||||
'studiensemester_kurzbz' =>$studiensemester_kurzbz,
|
||||
'mobilitaetsprogramm_code' => $mobilitaetsprogramm_code,
|
||||
'gsprogramm_id' => $gsprogramm_id,
|
||||
'firma_id' => $firma_id,
|
||||
'ausbildungssemester' =>$ausbildungssemester,
|
||||
'insertvon' => $authUID,
|
||||
'insertamum' => date('c'),
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function updateStudie()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$authUID = getAuthUID();
|
||||
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
if(!$prestudent_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
|
||||
$mobilitaet_id = (isset($formData['mobilitaet_id']) && !empty($formData['mobilitaet_id']))
|
||||
? $formData['mobilitaet_id'] :
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Mobilitaet ID']), self::ERROR_TYPE_GENERAL);
|
||||
$ausbildungssemester = (isset($formData['ausbildungssemester']) && !empty($formData['ausbildungssemester']))
|
||||
? $formData['ausbildungssemester']
|
||||
: null;
|
||||
$mobilitaetstyp_kurzbz = (isset($formData['mobilitaetstyp_kurzbz']) && !empty($formData['mobilitaetstyp_kurzbz']))
|
||||
? $formData['mobilitaetstyp_kurzbz']
|
||||
: null;
|
||||
$studiensemester_kurzbz = (isset($formData['studiensemester_kurzbz']) && !empty($formData['studiensemester_kurzbz']))
|
||||
? $formData['studiensemester_kurzbz']
|
||||
: null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('mobilitaetstyp_kurzbz', 'Typ', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Typ'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('studiensemester_kurzbz', 'Studiensemester', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Studiensemester'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('ausbildungssemester', 'Ausbildungssemester', 'required|numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Ausbildungssemester']),
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Ausbildungssemester']),
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$status_kurzbz = (isset($formData['status_kurzbz']) && !empty($formData['status_kurzbz'])) ? $formData['status_kurzbz'] : null;
|
||||
$mobilitaetsprogramm_code = (isset($formData['mobilitaetsprogramm_code']) && !empty($formData['mobilitaetsprogramm_code']))
|
||||
? $formData['mobilitaetsprogramm_code']
|
||||
: null;
|
||||
$gsprogramm_id = (isset($formData['gsprogramm_id']) && !empty($formData['gsprogramm_id']))
|
||||
? $formData['gsprogramm_id']
|
||||
: null;
|
||||
$firma_id= (isset($formData['firma_id']) && !empty($formData['firma_id'])) ? $formData['firma_id'] : null;
|
||||
|
||||
$result = $this->MobilitaetModel->update(
|
||||
[
|
||||
'mobilitaet_id' => $mobilitaet_id,
|
||||
],
|
||||
[
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'mobilitaetstyp_kurzbz' => $mobilitaetstyp_kurzbz,
|
||||
'status_kurzbz' => $status_kurzbz,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'mobilitaetsprogramm_code' => $mobilitaetsprogramm_code,
|
||||
'gsprogramm_id' => $gsprogramm_id,
|
||||
'firma_id' => $firma_id,
|
||||
'ausbildungssemester' => $ausbildungssemester,
|
||||
'updatevon' => $authUID,
|
||||
'updateamum' => date('c'),
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function deleteStudie($mobilitaet_id)
|
||||
{
|
||||
if(!$mobilitaet_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Mobilität ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$result = $this->MobilitaetModel->delete(
|
||||
array('mobilitaet_id' => $mobilitaet_id)
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -74,14 +74,15 @@ class Grades extends FHCAPI_Controller
|
||||
* (Entries in lehre.tbl_zeugnisnote)
|
||||
*
|
||||
* @param string $prestudent_id
|
||||
* @param string|null $all (optional) If null only the current semesters grades will be loaded, otherwise all semesters grades will be loaded.
|
||||
* @param string|null $studiensemester_kurzbz If studiensemester_kurzbz only this semesters grades will be loaded, otherwise all semesters grades will be loaded.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getCertificate($prestudent_id, $all = null)
|
||||
public function getCertificate($prestudent_id, $studiensemester_kurzbz = null)
|
||||
{
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$result = $this->StudentModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id
|
||||
@@ -91,12 +92,13 @@ class Grades extends FHCAPI_Controller
|
||||
if (!$student)
|
||||
$this->terminateWithSuccess([]);
|
||||
|
||||
|
||||
$student_uid = current($student)->student_uid;
|
||||
|
||||
$studiensemester_kurzbz = ($all === null) ? $this->variablelib->getVar('semester_aktuell') : null;
|
||||
if ($studiensemester_kurzbz !== null && !$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
|
||||
$result = $this->ZeugnisnoteModel->getZeugnisnoten($student_uid, $studiensemester_kurzbz);
|
||||
|
||||
$grades = $this->getDataOrTerminateWithError($result);
|
||||
@@ -109,14 +111,15 @@ class Grades extends FHCAPI_Controller
|
||||
* (Entries in campus.tbl_lvgesamtnote)
|
||||
*
|
||||
* @param string $prestudent_id
|
||||
* @param string|null $all (optional) If null only the current semesters grades will be loaded, otherwise all semesters grades will be loaded.
|
||||
* @param string|null $studiensemester_kurzbz If studiensemester_kurzbz only this semesters grades will be loaded, otherwise all semesters grades will be loaded.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getTeacherProposal($prestudent_id, $all = null)
|
||||
public function getTeacherProposal($prestudent_id, $studiensemester_kurzbz = null)
|
||||
{
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('education/Lvgesamtnote_model', 'LvgesamtnoteModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$result = $this->StudentModel->loadWhere([
|
||||
'prestudent_id' => $prestudent_id
|
||||
@@ -129,9 +132,11 @@ class Grades extends FHCAPI_Controller
|
||||
|
||||
$student_uid = current($student)->student_uid;
|
||||
|
||||
$studiensemester_kurzbz = ($all === null) ? $this->variablelib->getVar('semester_aktuell') : null;
|
||||
if ($studiensemester_kurzbz !== null && !$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
|
||||
$result = $this->LvgesamtnoteModel->getLvGesamtNoten(null, $student_uid, $studiensemester_kurzbz);
|
||||
|
||||
$grades = $this->getDataOrTerminateWithError($result);
|
||||
@@ -144,17 +149,20 @@ class Grades extends FHCAPI_Controller
|
||||
* or as not allowed because of the repeating of a semester.
|
||||
*
|
||||
* @param string $prestudent_id
|
||||
* @param string|null $all (optional) If null only the current semesters grades will be loaded, otherwise all semesters grades will be loaded.
|
||||
* @param string|false $studiensemester_kurzbz If studiensemester_kurzbz only this semesters grades will be loaded, otherwise all semesters grades will be loaded.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getRepeaterGrades($prestudent_id, $all = null)
|
||||
public function getRepeaterGrades($prestudent_id, $studiensemester_kurzbz = false)
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->load->library('AntragLib');
|
||||
|
||||
$studiensemester_kurzbz = ($all === null) ? $this->variablelib->getVar('semester_aktuell') : false;
|
||||
if ($studiensemester_kurzbz !== false && !$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
|
||||
$result = $this->antraglib->getLvsForPrestudent($prestudent_id, $studiensemester_kurzbz);
|
||||
|
||||
$grades = $this->getDataOrTerminateWithError($result);
|
||||
@@ -456,13 +464,19 @@ class Grades extends FHCAPI_Controller
|
||||
|
||||
$this->form_validation->set_rules("lehrveranstaltung_id", $this->p->t('lehre', 'lehrveranstaltung'), "required|integer");
|
||||
$this->form_validation->set_rules("points", $this->p->t("stv", "grades_points"), "required|numeric");
|
||||
$this->form_validation->set_rules("studiensemester_kurzbz", $this->p->t("lehre", "studiensemester"), "required|regex_match[/^[WS]S[0-9]{4}$/]");
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
$this->load->model('education/Notenschluesselaufteilung_model', 'NotenschluesselaufteilungModel');
|
||||
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$studiensemester_kurzbz = $this->input->post('studiensemester_kurzbz');
|
||||
if (!$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
$this->load->model('education/Notenschluesselaufteilung_model', 'NotenschluesselaufteilungModel');
|
||||
|
||||
$result = $this->NotenschluesselaufteilungModel->getNote(
|
||||
$this->input->post('points'),
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Gruppen extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getGruppen' => ['admin:r', 'assistenz:r'],
|
||||
'deleteGruppe' => ['admin:rw', 'assistenz:rw'],
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui', 'gruppenmanagement'
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel');
|
||||
$this->load->model('organisation/Gruppe_model', 'GruppeModel');
|
||||
}
|
||||
|
||||
public function getGruppen($student_uid)
|
||||
{
|
||||
$this->BenutzergruppeModel ->addSelect('gruppe_kurzbz');
|
||||
$this->BenutzergruppeModel ->addSelect('bezeichnung');
|
||||
$this->BenutzergruppeModel ->addSelect('generiert');
|
||||
$this->BenutzergruppeModel ->addSelect('uid');
|
||||
$this->BenutzergruppeModel ->addSelect('studiensemester_kurzbz');
|
||||
$this->BenutzergruppeModel ->addJoin('public.tbl_gruppe', 'gruppe_kurzbz');
|
||||
$this->BenutzergruppeModel-> addOrder('bezeichnung', 'ASC');
|
||||
|
||||
$result = $this->BenutzergruppeModel->loadWhere(
|
||||
array(
|
||||
'uid' => $student_uid
|
||||
)
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function deleteGruppe()
|
||||
{
|
||||
$student_uid = $this->input->post('id');
|
||||
$gruppe_kurzbz = $this->input->post('gruppe_kurzbz');
|
||||
|
||||
//Validate if automatic group generation
|
||||
$result = $this->GruppeModel-> loadWhere(
|
||||
array(
|
||||
'gruppe_kurzbz' => $gruppe_kurzbz
|
||||
)
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$generation = current($data);
|
||||
|
||||
if($generation->generiert)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('gruppenmanagement', 'error_deleteGeneratedGroups'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->BenutzergruppeModel->delete(
|
||||
array(
|
||||
'gruppe_kurzbz' => $gruppe_kurzbz,
|
||||
'uid' => $student_uid
|
||||
)
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess($data);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,8 @@ class Kontakt extends FHCAPI_Controller
|
||||
'getStandorte' => ['admin:r', 'assistenz:r'],
|
||||
'getStandorteByFirma' => ['admin:r', 'assistenz:r'],
|
||||
'getKontakte' => ['admin:r', 'assistenz:r'],
|
||||
'getBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r']
|
||||
'getBankverbindung' => ['mitarbeiter/bankdaten:r', 'student/bankdaten:r'],
|
||||
'getAllFirmen' => ['admin:r', 'assistenz:r']
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
@@ -46,6 +47,7 @@ class Kontakt extends FHCAPI_Controller
|
||||
$this->load->model('organisation/standort_model', 'StandortModel');
|
||||
$this->load->model('ressource/firma_model', 'FirmaModel');
|
||||
$this->load->model('person/Kontakt_model', 'KontaktModel');
|
||||
$this->load->model('person/Kontakttyp_model', 'KontakttypModel');
|
||||
|
||||
// Extra Permissionchecks
|
||||
$permsMa = [];
|
||||
@@ -196,13 +198,7 @@ class Kontakt extends FHCAPI_Controller
|
||||
$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;
|
||||
$firma_id = isset($_POST['firma_id']) ? $_POST['firma_id'] : null;
|
||||
|
||||
$result = $this->AdresseModel->insert(
|
||||
[
|
||||
@@ -269,17 +265,6 @@ class Kontakt extends FHCAPI_Controller
|
||||
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;
|
||||
@@ -289,6 +274,7 @@ class Kontakt extends FHCAPI_Controller
|
||||
$name = isset($_POST['name']) ? $_POST['name'] : null;
|
||||
$typ = isset($_POST['typ']) ? $_POST['typ'] : null;
|
||||
$anmerkung = isset($_POST['anmerkung']) ? $_POST['anmerkung'] : null;
|
||||
$firma_id = isset($_POST['firma_id']) ? $_POST['firma_id'] : null;
|
||||
|
||||
$result = $this->AdresseModel->update(
|
||||
[
|
||||
@@ -443,10 +429,15 @@ class Kontakt extends FHCAPI_Controller
|
||||
THEN public.tbl_kontakt.updateamum
|
||||
ELSE public.tbl_kontakt.insertamum
|
||||
END) AS lastUpdate, st.bezeichnung, f.name");
|
||||
$this->KontakttypModel->addSelect("kt.beschreibung as kontakttypbeschreibung");
|
||||
$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');
|
||||
$this->KontakttypModel->addJoin('public.tbl_kontakttyp kt', 'ON (public.tbl_kontakt.kontakttyp = kt.kontakttyp)');
|
||||
$result = $this->KontaktModel->loadWhere(
|
||||
array('person_id' => $person_id)
|
||||
array(
|
||||
'person_id' => $person_id,
|
||||
'public.tbl_kontakt.kontakttyp !=' => 'hidden'
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
@@ -454,20 +445,18 @@ class Kontakt extends FHCAPI_Controller
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
|
||||
}
|
||||
|
||||
public function getKontakttypen()
|
||||
{
|
||||
$this->load->model('person/Kontakttyp_model', 'KontakttypModel');
|
||||
$this->KontakttypModel->addOrder('beschreibung', 'ASC');
|
||||
$result = $this->KontakttypModel->loadWhere(array('kontakttyp !=' => 'hidden'));
|
||||
|
||||
$result = $this->KontakttypModel->load();
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function loadContact()
|
||||
@@ -594,8 +583,8 @@ class Kontakt extends FHCAPI_Controller
|
||||
'anmerkung' => $anmerkung,
|
||||
'kontakt' => $kontakt,
|
||||
'zustellung' => $_POST['zustellung'],
|
||||
'insertvon' => $uid,
|
||||
'insertamum' => date('c'),
|
||||
'updatevon' => $uid,
|
||||
'updateamum' => date('c'),
|
||||
'standort_id' => $standort_id,
|
||||
'ext_id' => $ext_id
|
||||
]
|
||||
@@ -670,6 +659,7 @@ class Kontakt extends FHCAPI_Controller
|
||||
$iban = $this->input->post('iban');
|
||||
$typ = $this->input->post('typ');
|
||||
$verrechnung = $this->input->post('verrechnung');
|
||||
$uid = getAuthUID();
|
||||
|
||||
$result = $this->BankverbindungModel->insert(
|
||||
[
|
||||
@@ -680,7 +670,7 @@ class Kontakt extends FHCAPI_Controller
|
||||
'iban' => $iban,
|
||||
'blz' => $blz,
|
||||
'kontonr' => $kontonr,
|
||||
'insertvon' => 'uid',
|
||||
'insertvon' => $uid,
|
||||
'insertamum' => date('c'),
|
||||
'typ' => $typ,
|
||||
'verrechnung' => $verrechnung,
|
||||
@@ -797,4 +787,25 @@ class Kontakt extends FHCAPI_Controller
|
||||
|
||||
return $this->GemeindeModel->checkLocation($_POST['plz'], $_POST['gemeinde'], $_POST['ort']);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns list of all companies
|
||||
* as key value list to be used in select or autocomplete
|
||||
*/
|
||||
public function getAllFirmen()
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
f.firma_id, f.name,
|
||||
f.name AS label
|
||||
FROM public.tbl_firma f
|
||||
ORDER BY f.name ASC";
|
||||
|
||||
$result = $this->FirmaModel->execReadOnlyQuery($sql);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -116,6 +116,8 @@ class Konto extends FHCAPI_Controller
|
||||
{
|
||||
$this->load->model('crm/Buchungstyp_model', 'BuchungstypModel');
|
||||
|
||||
$this->BuchungstypModel->addOrder('beschreibung');
|
||||
|
||||
$result = $this->BuchungstypModel->load();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
@@ -350,7 +352,7 @@ class Konto extends FHCAPI_Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = $this->KontoModel->insert([
|
||||
'person_id' => $buchung['person_id'],
|
||||
'studiengang_kz' => $buchung['studiengang_kz'],
|
||||
@@ -359,7 +361,7 @@ class Konto extends FHCAPI_Controller
|
||||
'buchungstyp_kurzbz' => $buchung['buchungstyp_kurzbz'],
|
||||
'credit_points' => $buchung['credit_points'],
|
||||
'zahlungsreferenz' => $buchung['zahlungsreferenz'],
|
||||
'betrag' => $betrag,
|
||||
'betrag' => number_format($betrag, 2, '.', ''),
|
||||
'buchungsdatum' => $buchungsdatum,
|
||||
'mahnspanne' => '0',
|
||||
'buchungsnr_verweis' => $buchung['buchungsnr'],
|
||||
|
||||
@@ -0,0 +1,408 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class LvTermine extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getStundenplan' => ['admin:r', 'assistenz:r'],
|
||||
'getStudiensemester' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui',
|
||||
]);
|
||||
|
||||
// Load models
|
||||
$this->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
//query verwenden wie im Cis endpoint
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel');
|
||||
}
|
||||
|
||||
//TODO Build own lib or combine with Controller Stundenplan.php
|
||||
//here use of logic of Stundenplan.php, extended with parameters uid, grouping, and used dbTable
|
||||
public function getStundenplan($uid, $start_date = null, $end_date = null, $groupConsecutiveHours = false, $dbStundenplanTable = "stundenplan")
|
||||
{
|
||||
$student_uid = $uid;
|
||||
$semester_range = $this->studienSemesterErmitteln($start_date, $end_date);
|
||||
|
||||
$this->sortStudienSemester($semester_range);
|
||||
$this->applyLoadUeberSemesterHaelfte($semester_range);
|
||||
|
||||
$benutzer_gruppen = $this->fetchBenutzerGruppenFromStudiensemester($semester_range, $student_uid);
|
||||
$student_lehrverband = $this->fetchStudentlehrverbandFromStudiensemester($semester_range, $student_uid);
|
||||
|
||||
if(!$groupConsecutiveHours)
|
||||
$stundenplan_query = $this->StundenplanModel->getStundenplanQuery(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$semester_range,
|
||||
$benutzer_gruppen,
|
||||
$student_lehrverband
|
||||
);
|
||||
else
|
||||
$stundenplan_query = $this->StundenplanModel->getStundenplanQuery(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$semester_range,
|
||||
$benutzer_gruppen,
|
||||
$student_lehrverband,
|
||||
true,
|
||||
$dbStundenplanTable
|
||||
);
|
||||
|
||||
if(!$stundenplan_query)
|
||||
{
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
|
||||
if($groupConsecutiveHours)
|
||||
{
|
||||
$stundenplan_data = $this->StundenplanModel->stundenplanGruppierungConsecutive($stundenplan_query);
|
||||
}
|
||||
else
|
||||
{
|
||||
$stundenplan_data = $this->StundenplanModel->stundenplanGruppierung($stundenplan_query);
|
||||
}
|
||||
|
||||
$stundenplan_data = $this->getDataOrTerminateWithError($stundenplan_data) ?? [];
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
|
||||
$this->expand_object_information($stundenplan_data);
|
||||
|
||||
$this->returnObj['$stundenplan_query'] = $stundenplan_query;
|
||||
$this->returnObj['$student_lehrverband'] = $student_lehrverband;
|
||||
$this->returnObj['$benutzer_gruppen'] = $benutzer_gruppen;
|
||||
$this->terminateWithSuccess($stundenplan_data);
|
||||
}
|
||||
|
||||
public function getStudiensemester()
|
||||
{
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->StudiensemesterModel->addOrder('studienjahr_kurzbz', 'DESC');
|
||||
$result = $this->StudiensemesterModel->load();
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
//copied from Stundenplan.php
|
||||
private function studienSemesterErmitteln($start_date, $end_date)
|
||||
{
|
||||
// gets all studiensemester from the student from start_date to end_date
|
||||
$semester_range = $this->StudiensemesterModel->getByDateRange($start_date, $end_date);
|
||||
$semester_range = array_map(
|
||||
function ($sem) {
|
||||
return $sem->studiensemester_kurzbz;
|
||||
},
|
||||
$this->getDataOrTerminateWithError($semester_range)
|
||||
);
|
||||
|
||||
// if no studiensemester is found for the given timespan, get the nearest studiensemester
|
||||
if(count($semester_range) == 0)
|
||||
{
|
||||
$aktuelle_studiensemester = $this->StudiensemesterModel->getNearest();
|
||||
$aktuelle_studiensemester = $this->getDataOrTerminateWithError($aktuelle_studiensemester);
|
||||
if (count($aktuelle_studiensemester) == 0) {
|
||||
$this->terminateWithError("No aktuelles semester");
|
||||
}
|
||||
$aktuelle_studiensemester = current($aktuelle_studiensemester)->studiensemester_kurzbz;
|
||||
// push aktuelles semester in active semester array
|
||||
array_push($semester_range, $aktuelle_studiensemester);
|
||||
}
|
||||
return $semester_range;
|
||||
}
|
||||
|
||||
//copied from Stundenplan.php
|
||||
private function sortStudienSemester(&$semester_range)
|
||||
{
|
||||
usort(
|
||||
$semester_range,
|
||||
function ($first, $second) {
|
||||
$sem_first = null;
|
||||
$year_first = null;
|
||||
$match_first = null;
|
||||
|
||||
$sem_second = null;
|
||||
$year_second = null;
|
||||
$match_second = null;
|
||||
|
||||
preg_match('/([WS]+)([0-9]+)/', $first, $match_first);
|
||||
preg_match('/([WS]+)([0-9]+)/', $second, $match_second);
|
||||
|
||||
$sem_first = $match_first[1];
|
||||
$year_first = intval($match_first[2]);
|
||||
|
||||
$sem_second = $match_second[1];
|
||||
$year_second = intval($match_second[2]);
|
||||
|
||||
if($year_first < $year_second)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
elseif($year_first > $year_second)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
elseif($year_first == $year_second && $sem_first > $sem_second)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
elseif($year_first == $year_second && $sem_first < $sem_second)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//copied from Stundenplan.php
|
||||
private function applyLoadUeberSemesterHaelfte(&$semester_range)
|
||||
{
|
||||
/*
|
||||
@var($semester_collection)
|
||||
convert the array of studiensemester into an associative array with the studiensemester as the key
|
||||
and the values of each key are the studiensemester needed for the query associated to that studiensemester
|
||||
example:
|
||||
|
||||
#INPUT:
|
||||
['WS2023','SS2024','WS2024']
|
||||
#OUTPUT:
|
||||
[
|
||||
'WS2023' => ['SS2023','WS2023']
|
||||
'SS2024' => ['WS2023','SS2024']
|
||||
'WS2024' => ['SS2024','WS2024']
|
||||
]
|
||||
*/
|
||||
$semester_collection = [];
|
||||
foreach($semester_range as $studiensemester)
|
||||
{
|
||||
$previous_studiensemester = $this->StudiensemesterModel->getPreviousFrom($studiensemester);
|
||||
$previous_studiensemester = $this->getDataOrTerminateWithError($previous_studiensemester);
|
||||
if (count($previous_studiensemester) == 0) {
|
||||
$this->terminateWithError("No previous semester");
|
||||
}
|
||||
$previous_studiensemester = current($previous_studiensemester)->studiensemester_kurzbz;
|
||||
$semester_collection[$studiensemester] = [$previous_studiensemester, $studiensemester];
|
||||
}
|
||||
|
||||
/*
|
||||
@var($studienSemesterDateRanges)
|
||||
fetches for each studiensemester the start and end date, (SS) summer studiensemester are extended by 1 month to cover the summerbreak
|
||||
based on the LVPLAN_LOAD_UEBER_SEMESTERHAELFTE constant it will load both the semester and the previous semester with the full date range
|
||||
or the semester with the full date range and the previous semester with the half date range:
|
||||
|
||||
#INPUT:
|
||||
[
|
||||
'WS2023' => ['SS2023','WS2023']
|
||||
'SS2024' => ['WS2023','SS2024']
|
||||
'WS2024' => ['SS2024','WS2024']
|
||||
]
|
||||
#OUTPUT: depends whether LVPLAN_LOAD_UEBER_SEMESTERHAELFTE is true or false
|
||||
~ if LVPLAN_LOAD_UEBER_SEMESTERHAELFTE == true
|
||||
[
|
||||
"SS2024": [
|
||||
"WS2023": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
],
|
||||
"SS2024": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
]
|
||||
]
|
||||
]
|
||||
~ if LVPLAN_LOAD_UEBER_SEMESTERHAELFTE == false
|
||||
[
|
||||
"SS2024": [
|
||||
"WS2023": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-05-17"
|
||||
],
|
||||
"SS2024": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
]
|
||||
]
|
||||
]
|
||||
*/
|
||||
$studienSemesterDateRanges=[];
|
||||
foreach($semester_collection as $semester_original => $semester_adjoint)
|
||||
{
|
||||
$semester_start_ende = $this->StudiensemesterModel->getStartEndeFromStudiensemester($semester_original);
|
||||
$semester_start_ende = current($this->getDataOrTerminateWithError($semester_start_ende));
|
||||
|
||||
// initialize empty arrays to add key value pairs
|
||||
$studienSemesterDateRanges[$semester_original] = [];
|
||||
|
||||
// check if the studiensemester is a summer semester and add 1 month to bridge the school summer break
|
||||
$match = null;
|
||||
preg_match("/^(SS)([0-9]+)/", $semester_original, $match);
|
||||
if(count($match) >0)
|
||||
{
|
||||
$one_month = new DateInterval('P1M');
|
||||
$one_day = DateInterval::createFromDateString('1 days');
|
||||
$summer_studiensemester_end_date = DateTime::createFromFormat('Y-m-d', $semester_start_ende->ende);
|
||||
$summer_studiensemester_end_date->add($one_month);
|
||||
$summer_studiensemester_end_date->sub($one_day);
|
||||
$semester_start_ende->ende = date_format($summer_studiensemester_end_date, 'Y-m-d');
|
||||
}
|
||||
if (defined('LVPLAN_LOAD_UEBER_SEMESTERHAELFTE') && LVPLAN_LOAD_UEBER_SEMESTERHAELFTE === true)
|
||||
{
|
||||
foreach($semester_adjoint as $adjoint)
|
||||
{
|
||||
$studienSemesterDateRanges[$semester_original][$adjoint]=$semester_start_ende;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: half of a DateInterval might not be correctly calculated
|
||||
// calculate the half of the studiensemester
|
||||
$studiensemester_start_date = DateTime::createFromFormat('Y-m-d', $semester_start_ende->start);
|
||||
$studiensemester_end_date = DateTime::createFromFormat('Y-m-d', $semester_start_ende->ende);
|
||||
$studiensemester_time_difference = $studiensemester_start_date->diff($studiensemester_end_date);
|
||||
$half_dateNumber = ceil($studiensemester_time_difference->d/2)+ceil(($studiensemester_time_difference->m*30)/2);
|
||||
$half_dateInterval = new DateInterval('P'.strval($half_dateNumber) .'D');
|
||||
$studiensemester_half = date_format($studiensemester_start_date->add($half_dateInterval), 'Y-m-d');
|
||||
|
||||
$first_half = new stdClass();
|
||||
$first_half->start = $semester_start_ende->start;
|
||||
$first_half->ende = $studiensemester_half;
|
||||
|
||||
$studienSemesterDateRanges[$semester_original][$semester_adjoint[0]] = $first_half;
|
||||
$studienSemesterDateRanges[$semester_original][$semester_adjoint[1]] = $semester_start_ende;
|
||||
}
|
||||
$semester_range = $studienSemesterDateRanges;
|
||||
}
|
||||
}
|
||||
|
||||
//copied from Stundenplan.php, extended with $student_uid
|
||||
private function fetchBenutzerGruppenFromStudiensemester($semester_range, $student_uid)
|
||||
{
|
||||
//$student_uid = getAuthUID();
|
||||
$benutzer_gruppen = [];
|
||||
// for each studiensemester fetch the benutzer gruppen and add them to an associate $bentuzer_gruppen array
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [['gruppe1_SS2023','gruppe2_SS2023'],['gruppe1_WS2023','gruppe2_WS2023']],
|
||||
['SS2024'] => [['gruppe1_WS2023','gruppe2_WS2023'],['gruppe1_SS2024','gruppe2_SS2024']],
|
||||
['WS2024'] => [['gruppe1_SS2024','gruppe2_SS2024'],['gruppe1_WS2024','gruppe2_WS2024']],
|
||||
]
|
||||
*/
|
||||
foreach($semester_range as $semester_key => $semester_array)
|
||||
{
|
||||
$benutzer_gruppen[$semester_key] = [];
|
||||
// each semester could have ajoint semesters that need to be checked
|
||||
foreach($semester_array as $semester => $semester_date_range)
|
||||
{
|
||||
// for each active semester query the benutzer_gruppen associated to the semester
|
||||
$benutzer_query = $this->BenutzergruppeModel->execReadOnlyQuery("
|
||||
SELECT * FROM tbl_benutzergruppe where uid = ? AND studiensemester_kurzbz = ?", [$student_uid, $semester]);
|
||||
$benutzer_query_result = $this->getDataOrTerminateWithError($benutzer_query);
|
||||
array_push(
|
||||
$benutzer_gruppen[$semester_key],
|
||||
array_map(
|
||||
function ($item) {
|
||||
return "'".$item->gruppe_kurzbz. "'";
|
||||
},
|
||||
$benutzer_query_result
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// merge the gruppen of each studiensemester together for the original studiensemester
|
||||
/*
|
||||
[
|
||||
['WS2023'] => ['gruppe1_SS2023','gruppe2_SS2023','gruppe1_WS2023','gruppe2_WS2023'],
|
||||
['SS2024'] => ['gruppe1_WS2023','gruppe2_WS2023','gruppe1_SS2024','gruppe2_SS2024'],
|
||||
['WS2024'] => ['gruppe1_SS2024','gruppe2_SS2024','gruppe1_WS2024','gruppe2_WS2024'],
|
||||
]
|
||||
*/
|
||||
$benutzer_gruppen = array_map(
|
||||
function ($gruppe) {
|
||||
$merged_gruppe = [];
|
||||
foreach($gruppe as $gruppen_array)
|
||||
{
|
||||
$merged_gruppe = array_merge($merged_gruppe, $gruppen_array);
|
||||
}
|
||||
return $merged_gruppe;
|
||||
},
|
||||
$benutzer_gruppen
|
||||
);
|
||||
|
||||
return $benutzer_gruppen;
|
||||
}
|
||||
|
||||
//copied from Stundenplan.php, extended with $student_uid
|
||||
private function fetchStudentlehrverbandFromStudiensemester($semester_range, $student_uid)
|
||||
{
|
||||
//$student_uid = getAuthUID();
|
||||
$student_lehrverband = [];
|
||||
// for each studiensemester fetch the studentlehrverbaende and add them to an associate $student_lehrverband array
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [ [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
['SS2024'] => [ [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ], [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
['WS2024'] => [ [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ], [ ['stg_kz'=>298,'semester'=>3,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
]
|
||||
*/
|
||||
foreach($semester_range as $semester_key => $semester_array)
|
||||
{
|
||||
$student_lehrverband[$semester_key] = [];
|
||||
foreach($semester_array as $semester => $semester_date_range)
|
||||
{
|
||||
// for each active semester query the student_lehrverband associated to the semester
|
||||
$lehrverband_query = $this->BenutzergruppeModel->execReadOnlyQuery("
|
||||
SELECT * FROM tbl_studentlehrverband where student_uid = ? AND studiensemester_kurzbz = ?", [$student_uid, $semester]);
|
||||
$lehrverband_query_result = $this->getDataOrTerminateWithError($lehrverband_query);
|
||||
array_push($student_lehrverband[$semester_key], array_map(
|
||||
function ($item) {
|
||||
$result = new stdClass();
|
||||
$result->studiengang_kz = $item->studiengang_kz;
|
||||
$result->semester = $item->semester;
|
||||
$result->verband = $item->verband;
|
||||
$result->gruppe = $item->gruppe;
|
||||
return $result;
|
||||
},
|
||||
$lehrverband_query_result));
|
||||
}
|
||||
}
|
||||
|
||||
// merge the studentlehrverband of each studiensemester together for the original studiensemester
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ],
|
||||
['SS2024'] => [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""], ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ],
|
||||
['WS2024'] => [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""], ['stg_kz'=>298,'semester'=>3,'verband'=>"A",'gruppe'=>""] ],
|
||||
]
|
||||
*/
|
||||
$student_lehrverband = array_map(
|
||||
function ($studentlehrverband) {
|
||||
$merged_studentlehrverband = [];
|
||||
foreach($studentlehrverband as $studentlehrverband_array)
|
||||
{
|
||||
$merged_studentlehrverband = array_merge($merged_studentlehrverband, $studentlehrverband_array);
|
||||
}
|
||||
return $merged_studentlehrverband;
|
||||
},
|
||||
$student_lehrverband
|
||||
);
|
||||
|
||||
return $student_lehrverband;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
use CI3_Events as Events;
|
||||
|
||||
class Mobility extends FHCAPI_Controller
|
||||
{
|
||||
@@ -40,13 +41,54 @@ class Mobility extends FHCAPI_Controller
|
||||
|
||||
// Load models
|
||||
$this->load->model('codex/Bisio_model', 'BisioModel');
|
||||
|
||||
//Permission checks for Studiengangsarray
|
||||
$allowedStgs = $this->permissionlib->getSTG_isEntitledFor('assistenz') ?: [];
|
||||
|
||||
if ($this->router->method == 'insertMobility' || $this->router->method == 'updateMobility')
|
||||
{
|
||||
$student_uid = $this->input->post('uid');
|
||||
if(!$student_uid)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Student UID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->_checkAllowedStgsFromUid($student_uid, $allowedStgs);
|
||||
}
|
||||
|
||||
if ($this->router->method == 'deleteMobility') {
|
||||
$bisio_id = $this->input->post('bisio_id');
|
||||
if(!$bisio_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Bisio ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$result = $this->BisioModel->load(
|
||||
array('bisio_id' => $bisio_id)
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$student_uid = current($data)->student_uid;
|
||||
|
||||
$this->_checkAllowedStgsFromUid($student_uid, $allowedStgs);
|
||||
}
|
||||
}
|
||||
|
||||
private function _checkAllowedStgsFromUid($student_uid, $allowedStgs)
|
||||
{
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$result = $this->StudentModel->loadWhere(['student_uid' => $student_uid]);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$studiengang_kz = current($data)->studiengang_kz;
|
||||
|
||||
if (!in_array($studiengang_kz, $allowedStgs))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_keineBerechtigungStg'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
public function getMobilitaeten($student_uid)
|
||||
{
|
||||
$this->BisioModel->addSelect("*");
|
||||
$this->BisioModel->addJoin('bis.tbl_mobilitaetsprogramm mp', 'ON (mp.mobilitaetsprogramm_code = bis.tbl_bisio.mobilitaetsprogramm_code)', 'LEFT');
|
||||
$this->BisioModel->addJoin('lehre.tbl_lehreinheit le', 'ON (le.lehreinheit_id = bis.tbl_bisio.lehreinheit_id)','LEFT');
|
||||
$this->BisioModel->addJoin('lehre.tbl_lehreinheit le', 'ON (le.lehreinheit_id = bis.tbl_bisio.lehreinheit_id)', 'LEFT');
|
||||
$this->BisioModel->addOrder('von', 'DESC');
|
||||
$this->BisioModel->addOrder('bis', 'DESC');
|
||||
$this->BisioModel->addOrder('bisio_id', 'DESC');
|
||||
@@ -83,14 +125,20 @@ class Mobility extends FHCAPI_Controller
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
|
||||
$_POST['von'] = (isset($formData['von']) && !empty($formData['von'])) ? $formData['von'] : null;
|
||||
$_POST['bis'] = (isset($formData['bis']) && !empty($formData['bis'])) ? $formData['bis'] : null;
|
||||
$_POST['nation_code'] = (isset($formData['nation_code']) && !empty($formData['nation_code'])) ? $formData['nation_code'] : 'A';
|
||||
$_POST['mobilitaetsprogramm_code'] = (isset($formData['mobilitaetsprogramm_code']) && !empty($formData['mobilitaetsprogramm_code'])) ? $formData['mobilitaetsprogramm_code'] : null;
|
||||
$_POST['herkunftsland_code'] = (isset($formData['herkunftsland_code']) && !empty($formData['herkunftsland_code'])) ? $formData['herkunftsland_code'] : 'A';
|
||||
$_POST['ects_erworben'] = (isset($formData['ects_erworben']) && !empty($formData['ects_erworben'])) ? $formData['ects_erworben'] : null;
|
||||
$_POST['ects_angerechnet'] = (isset($formData['ects_angerechnet']) && !empty($formData['ects_angerechnet'])) ? $formData['ects_angerechnet'] : null;
|
||||
$_POST['lehreinheit_id'] = (isset($formData['lehreinheit_id']) && !empty($formData['lehreinheit_id'])) ? $formData['lehreinheit_id'] : null;
|
||||
$von = $formData['von'] ?? null;
|
||||
$bis = $formData['bis'] ?? null;
|
||||
$nation_code = $formData['nation_code'] ?? null;
|
||||
$mobilitaetsprogramm_code = $formData['mobilitaetsprogramm_code'] ?? null;
|
||||
$herkunftsland_code = $formData['herkunftsland_code'] ?? null;
|
||||
$ects_erworben = $formData['ects_erworben'] ?? null;
|
||||
$ects_angerechnet = $formData['ects_angerechnet'] ?? null;
|
||||
$lehreinheit_id = $formData['lehreinheit_id'] ?? null;
|
||||
$ort = $formData['ort'] ?? null;
|
||||
$universitaet = $formData['universitaet'] ?? null;
|
||||
$localPurposes = $formData['localPurposes'] ?? null;
|
||||
$localSupports = $formData['localSupports'] ?? null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('nation_code', 'Nation_code', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Nation_code'])
|
||||
@@ -126,23 +174,18 @@ class Mobility extends FHCAPI_Controller
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$ort = (isset($formData['ort']) && !empty($formData['ort'])) ? $formData['ort'] : null;
|
||||
$universitaet = (isset($formData['universitaet']) && !empty($formData['universitaet'])) ? $formData['universitaet'] : null;
|
||||
$localPurposes = (isset($formData['localPurposes']) && !empty($formData['localPurposes'])) ? $formData['localPurposes'] : null;
|
||||
$localSupports = (isset($formData['localSupports']) && !empty($formData['localSupports'])) ? $formData['localSupports'] : null;
|
||||
|
||||
$result = $this->BisioModel->insert([
|
||||
'student_uid' => $student_uid,
|
||||
'von' => $_POST['von'],
|
||||
'bis' => $_POST['bis'],
|
||||
'mobilitaetsprogramm_code' => $_POST['mobilitaetsprogramm_code'],
|
||||
'nation_code' => $_POST['nation_code'],
|
||||
'herkunftsland_code' => $_POST['herkunftsland_code'],
|
||||
'lehreinheit_id' => $_POST['lehreinheit_id'],
|
||||
'von' => $von,
|
||||
'bis' => $bis,
|
||||
'mobilitaetsprogramm_code' => $mobilitaetsprogramm_code,
|
||||
'nation_code' => $nation_code,
|
||||
'herkunftsland_code' => $herkunftsland_code,
|
||||
'lehreinheit_id' => $lehreinheit_id,
|
||||
'ort' => $ort,
|
||||
'universitaet' => $universitaet,
|
||||
'ects_erworben' => $_POST['ects_erworben'] ,
|
||||
'ects_angerechnet' => $_POST['ects_angerechnet'],
|
||||
'ects_erworben' => $ects_erworben ,
|
||||
'ects_angerechnet' => $ects_angerechnet,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $authUID,
|
||||
]);
|
||||
@@ -171,7 +214,7 @@ class Mobility extends FHCAPI_Controller
|
||||
{
|
||||
$this->BisioModel->addSelect("*");
|
||||
$this->BisioModel->addJoin('bis.tbl_mobilitaetsprogramm mp', 'ON (mp.mobilitaetsprogramm_code = bis.tbl_bisio.mobilitaetsprogramm_code)', 'LEFT');
|
||||
$this->BisioModel->addJoin('lehre.tbl_lehreinheit le', 'ON (le.lehreinheit_id = bis.tbl_bisio.lehreinheit_id)','LEFT');
|
||||
$this->BisioModel->addJoin('lehre.tbl_lehreinheit le', 'ON (le.lehreinheit_id = bis.tbl_bisio.lehreinheit_id)', 'LEFT');
|
||||
$result = $this->BisioModel->loadWhere(
|
||||
array('bisio_id' => $bisio_id)
|
||||
);
|
||||
@@ -194,14 +237,18 @@ class Mobility extends FHCAPI_Controller
|
||||
}
|
||||
$formData = $this->input->post('formData');
|
||||
|
||||
$_POST['von'] = (isset($formData['von']) && !empty($formData['von'])) ? $formData['von'] : null;
|
||||
$_POST['bis'] = (isset($formData['bis']) && !empty($formData['bis'])) ? $formData['bis'] : null;
|
||||
$_POST['nation_code'] = (isset($formData['nation_code']) && !empty($formData['nation_code'])) ? $formData['nation_code'] : 'A';
|
||||
$_POST['mobilitaetsprogramm_code'] = (isset($formData['mobilitaetsprogramm_code']) && !empty($formData['mobilitaetsprogramm_code'])) ? $formData['mobilitaetsprogramm_code'] : null;
|
||||
$_POST['herkunftsland_code'] = (isset($formData['herkunftsland_code']) && !empty($formData['herkunftsland_code'])) ? $formData['herkunftsland_code'] : 'A';
|
||||
$_POST['ects_erworben'] = (isset($formData['ects_erworben']) && !empty($formData['ects_erworben'])) ? $formData['ects_erworben'] : null;
|
||||
$_POST['ects_angerechnet'] = (isset($formData['ects_angerechnet']) && !empty($formData['ects_angerechnet'])) ? $formData['ects_angerechnet'] : null;
|
||||
$_POST['lehreinheit_id'] = (isset($formData['lehreinheit_id']) && !empty($formData['lehreinheit_id'])) ? $formData['lehreinheit_id'] : null;
|
||||
$von = $formData['von'] ?? null;
|
||||
$bis = $formData['bis'] ?? null;
|
||||
$nation_code = $formData['nation_code'] ?? null;
|
||||
$mobilitaetsprogramm_code = $formData['mobilitaetsprogramm_code'] ?? null;
|
||||
$herkunftsland_code = $formData['herkunftsland_code'] ?? null;
|
||||
$ects_erworben = $formData['ects_erworben'] ?? null;
|
||||
$ects_angerechnet = $formData['ects_angerechnet'] ?? null;
|
||||
$lehreinheit_id = $formData['lehreinheit_id'] ?? null;
|
||||
$ort = $formData['ort'] ?? null;
|
||||
$universitaet = $formData['universitaet'] ?? null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
|
||||
$this->form_validation->set_rules('nation_code', 'Nation_code', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Nation_code'])
|
||||
@@ -209,6 +256,7 @@ class Mobility extends FHCAPI_Controller
|
||||
$this->form_validation->set_rules('herkunftsland_code', 'Herkunftsland_code', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Herkunftsland_code'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('mobilitaetsprogramm_code', 'Mobilitaetsprogramm_code', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Mobilitaetsprogramm_code'])
|
||||
]);
|
||||
@@ -243,16 +291,17 @@ class Mobility extends FHCAPI_Controller
|
||||
],
|
||||
[
|
||||
'student_uid' => $student_uid,
|
||||
'von' => $_POST['von'],
|
||||
'bis' => $_POST['bis'],
|
||||
'mobilitaetsprogramm_code' => $_POST['mobilitaetsprogramm_code'],
|
||||
'nation_code' => $_POST['nation_code'],
|
||||
'herkunftsland_code' => $_POST['herkunftsland_code'],
|
||||
'lehreinheit_id' => $_POST['lehreinheit_id'],
|
||||
'ort' => $formData['ort'],
|
||||
'universitaet' => $formData['universitaet'],
|
||||
'ects_erworben' => $_POST['ects_erworben'] ,
|
||||
'ects_angerechnet' => $_POST['ects_angerechnet'],
|
||||
|
||||
'von' => $von,
|
||||
'bis' => $bis,
|
||||
'mobilitaetsprogramm_code' => $mobilitaetsprogramm_code,
|
||||
'nation_code' => $nation_code,
|
||||
'herkunftsland_code' => $herkunftsland_code,
|
||||
'lehreinheit_id' => $lehreinheit_id,
|
||||
'ort' => $ort,
|
||||
'universitaet' => $universitaet,
|
||||
'ects_erworben' => $ects_erworben ,
|
||||
'ects_angerechnet' => $ects_angerechnet,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => $authUID,
|
||||
]
|
||||
@@ -263,30 +312,12 @@ class Mobility extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function deleteMobility($bisio_id)
|
||||
public function deleteMobility()
|
||||
{
|
||||
//check if extension table exists
|
||||
$result = $this->BisioModel->tableExists('extension', 'tbl_mo_bisioidzuordnung');
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$bisio_id = $this->input->post('bisio_id');
|
||||
|
||||
//if table exists check if existing entry
|
||||
if(!empty($data))
|
||||
{
|
||||
$this->BisioModel->addSelect("count(*)");
|
||||
$this->BisioModel->addJoin('extension.tbl_mo_bisioidzuordnung mo', 'ON (mo.bisio_id = bis.tbl_bisio.bisio_id)', 'LEFT');
|
||||
|
||||
$resultCheckMo = $this->BisioModel->loadWhere(
|
||||
array('mo.bisio_id' => $bisio_id)
|
||||
);
|
||||
|
||||
$resultCheckMo = $this->getDataOrTerminateWithError($resultCheckMo);
|
||||
$count = current($resultCheckMo)->count;
|
||||
|
||||
$existsInExtension = $count > 0 ? true : false;
|
||||
|
||||
if($existsInExtension)
|
||||
$this->terminateWithError($this->p->t('mobility', 'error_existingEntryInExtension'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
//check if entry in MobilityOnline extension exists
|
||||
Events::trigger('mobility_delete', $bisio_id);
|
||||
|
||||
$result = $this->BisioModel->delete(
|
||||
array('bisio_id' => $bisio_id)
|
||||
@@ -294,6 +325,7 @@ class Mobility extends FHCAPI_Controller
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithSuccess($data);
|
||||
|
||||
}
|
||||
|
||||
public function getLVList($studiengang_kz)
|
||||
@@ -475,7 +507,6 @@ class Mobility extends FHCAPI_Controller
|
||||
if($local_support){
|
||||
$aufenthaltfoerderung_code = $local_support;
|
||||
}
|
||||
|
||||
$this->load->model('codex/Bisioaufenthaltfoerderung_model', 'BisioaufenthaltfoerderungModel');
|
||||
|
||||
if(!$local_support)
|
||||
|
||||
@@ -16,7 +16,8 @@ class Notiz extends Notiz_Controller
|
||||
'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']
|
||||
'getMitarbeiter' => ['admin:r', 'assistenz:r'],
|
||||
'getCountNotes' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
|
||||
@@ -136,10 +136,32 @@ class Prestudent extends FHCAPI_Controller
|
||||
$update_prestudent = array();
|
||||
foreach ($array_allowed_props_prestudent as $prop)
|
||||
{
|
||||
$val = $this->input->post($prop);
|
||||
if ($val !== null || $prop == 'foerderrelevant') {
|
||||
$val = $this->input->post($prop, true);
|
||||
|
||||
if ($val !== null) {
|
||||
if(in_array($prop, ['dual', 'bismelden', 'foerderrelevant']))
|
||||
{
|
||||
$val = boolval($val);
|
||||
}
|
||||
elseif (
|
||||
$val === ''
|
||||
&& in_array($prop, ['zgvnation', 'zgvmanation', 'zgvdoktornation', 'berufstaetigkeit_code', 'ausbildungcode'])
|
||||
)
|
||||
{
|
||||
$val = null;
|
||||
}
|
||||
$update_prestudent[$prop] = $val;
|
||||
}
|
||||
|
||||
// allowed to be null, but has to be in postparameter
|
||||
if (
|
||||
in_array($prop, ['foerderrelevant', 'zgvdatum', 'zgvmadatum', 'zgvdoktordatum', 'zgv_code', 'zgvmas_code', 'zgvdoktor_code'])
|
||||
&& !isset($update_prestudent[$prop])
|
||||
&& array_key_exists($prop, $_POST)
|
||||
)
|
||||
{
|
||||
$update_prestudent[$prop] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$update_prestudent['updateamum'] = date('c');
|
||||
@@ -174,7 +196,11 @@ class Prestudent extends FHCAPI_Controller
|
||||
{
|
||||
$this->load->model('codex/Zgv_model', 'ZgvModel');
|
||||
|
||||
$this->ZgvModel->addOrder('zgv_code');
|
||||
$this->ZgvModel->addSelect('zgv_code');
|
||||
$this->ZgvModel->addSelect('zgv_bez');
|
||||
$this->ZgvModel->addSelect('aktiv');
|
||||
$this->ZgvModel->addSelect('zgv_bez as label');
|
||||
$this->ZgvModel->addOrder('zgv_bez');
|
||||
|
||||
$result = $this->ZgvModel->load();
|
||||
if (isError($result))
|
||||
@@ -188,7 +214,11 @@ class Prestudent extends FHCAPI_Controller
|
||||
{
|
||||
$this->load->model('codex/Zgvdoktor_model', 'ZgvdoktorModel');
|
||||
|
||||
$this->ZgvdoktorModel->addOrder('zgvdoktor_code');
|
||||
$this->ZgvdoktorModel->addSelect('zgvdoktor_code');
|
||||
$this->ZgvdoktorModel->addSelect('zgvdoktor_bez');
|
||||
$this->ZgvdoktorModel->addSelect('aktiv');
|
||||
$this->ZgvdoktorModel->addSelect('zgvdoktor_bez as label');
|
||||
$this->ZgvdoktorModel->addOrder('zgvdoktor_bez');
|
||||
|
||||
$result = $this->ZgvdoktorModel->load();
|
||||
if (isError($result))
|
||||
@@ -202,7 +232,11 @@ class Prestudent extends FHCAPI_Controller
|
||||
{
|
||||
$this->load->model('codex/Zgvmaster_model', 'ZgvmasterModel');
|
||||
|
||||
$this->ZgvmasterModel->addOrder('zgvmas_code');
|
||||
$this->ZgvmasterModel->addSelect('zgvmas_code');
|
||||
$this->ZgvmasterModel->addSelect('zgvmas_bez');
|
||||
$this->ZgvmasterModel->addSelect('aktiv');
|
||||
$this->ZgvmasterModel->addSelect('zgvmas_bez as label');
|
||||
$this->ZgvmasterModel->addOrder('zgvmas_bez');
|
||||
|
||||
$result = $this->ZgvmasterModel->load();
|
||||
if (isError($result))
|
||||
|
||||
@@ -24,12 +24,12 @@ class Status extends FHCAPI_Controller
|
||||
'updateStatus' => ['admin:rw', 'assistenz:rw'],
|
||||
'advanceStatus' => ['admin:rw', 'assistenz:rw'],
|
||||
'confirmStatus' => ['admin:rw', 'assistenz:rw'],
|
||||
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
@@ -189,9 +189,13 @@ class Status extends FHCAPI_Controller
|
||||
$studiensemester_kurzbz = $lastStatusData->studiensemester_kurzbz;
|
||||
if ($status_kurzbz == Prestudentstatus_model::STATUS_ABSOLVENT
|
||||
|| $status_kurzbz == Prestudentstatus_model::STATUS_DIPLOMAND
|
||||
) {
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->input->post('currentSemester');
|
||||
if (!$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
}
|
||||
|
||||
$ausbildungssemester = $lastStatusData->ausbildungssemester;
|
||||
@@ -282,11 +286,11 @@ class Status extends FHCAPI_Controller
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('_default', '', [
|
||||
['meldestichtag_not_exceeded', function () use ($datum, $isBerechtigtNoStudstatusCheck) {
|
||||
['meldestichtag_not_exceeded', function () use ($datum_string, $isBerechtigtNoStudstatusCheck) {
|
||||
if ($isBerechtigtNoStudstatusCheck)
|
||||
return true; // Skip if access right says so
|
||||
|
||||
$result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($datum);
|
||||
$result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($datum_string);
|
||||
|
||||
return !$this->getDataOrTerminateWithError($result);
|
||||
}],
|
||||
@@ -435,9 +439,10 @@ class Status extends FHCAPI_Controller
|
||||
]);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
|
||||
$this->load->library('PrestudentLib');
|
||||
|
||||
$this->db->trans_start();
|
||||
@@ -623,8 +628,9 @@ class Status extends FHCAPI_Controller
|
||||
]);
|
||||
|
||||
if (!$this->form_validation->run())
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
|
||||
}
|
||||
|
||||
// Start DB transaction
|
||||
$this->db->trans_start();
|
||||
@@ -727,8 +733,9 @@ class Status extends FHCAPI_Controller
|
||||
);
|
||||
|
||||
$result = $this->prestudentstatuschecklib->checkIfMeldestichtagErreicht($oldstatus->datum);
|
||||
$isMeldestichtagErreicht = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$this->getDataOrTerminateWithError($result))
|
||||
if ($isMeldestichtagErreicht)
|
||||
$this->terminateWithError(
|
||||
$this->p->t('lehre', 'error_dataVorMeldestichtag'),
|
||||
self::ERROR_TYPE_GENERAL,
|
||||
@@ -739,8 +746,12 @@ class Status extends FHCAPI_Controller
|
||||
// Start DB transaction
|
||||
$this->db->trans_begin();
|
||||
|
||||
//Delete Studentlehrverband if no Status left in this semester
|
||||
$cilsresult = $this->PrestudentstatusModel->checkIfLastStatusEntry($prestudent_id, $studiensemester_kurzbz);
|
||||
$isLastPrestudentStatusForSemester = $this->getDataOrTerminateWithError($cilsresult);
|
||||
|
||||
//Delete Status
|
||||
$result = $this->PrestudentstatusModel->delete(
|
||||
$delpsresult = $this->PrestudentstatusModel->delete(
|
||||
[
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => $status_kurzbz,
|
||||
@@ -748,14 +759,9 @@ class Status extends FHCAPI_Controller
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
]
|
||||
);
|
||||
$this->getDataOrTerminateWithError($delpsresult);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
//Delete Studentlehrverband if no Status left in this semester
|
||||
$result = $this->PrestudentstatusModel->checkIfLastStatusEntry($prestudent_id, $studiensemester_kurzbz);
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
if ($result)
|
||||
if ($isLastPrestudentStatusForSemester)
|
||||
{
|
||||
//get student_uid
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
@@ -1529,9 +1535,32 @@ class Status extends FHCAPI_Controller
|
||||
$newStudentlvb['semester'] = $ausbildungssemester;
|
||||
} // If there is no lehrverband just use the same as in the previous studiensemester
|
||||
|
||||
|
||||
//add studentlehrverband
|
||||
$result = $this->StudentlehrverbandModel->insert($newStudentlvb);
|
||||
$checkres = $this->StudentlehrverbandModel->load(array(
|
||||
'student_uid' => $studentlvb->student_uid,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
));
|
||||
if(hasData($checkres))
|
||||
{
|
||||
$result = $this->StudentlehrverbandModel->update(
|
||||
array(
|
||||
'student_uid' => $studentlvb->student_uid,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
),
|
||||
array(
|
||||
'studiengang_kz' => $studentlvb->studiengang_kz,
|
||||
'semester' => $studentlvb->semester,
|
||||
'verband' => $studentlvb->verband,
|
||||
'gruppe' => $studentlvb->gruppe,
|
||||
'updateamum' => $now,
|
||||
'updatevon' => $authUID
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//add studentlehrverband
|
||||
$result = $this->StudentlehrverbandModel->insert($newStudentlvb);
|
||||
}
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
|
||||
@@ -68,13 +68,28 @@ class Student extends FHCAPI_Controller
|
||||
* @param string $prestudent_id
|
||||
* @return void
|
||||
*/
|
||||
public function get($prestudent_id)
|
||||
public function get($prestudent_id, $studiensemester_kurzbz)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
if (!$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
$this->PrestudentModel->addSelect('p.*');
|
||||
$this->PrestudentModel->addSelect('p.person_id');
|
||||
$this->PrestudentModel->addSelect('p.titelpre');
|
||||
$this->PrestudentModel->addSelect('p.nachname');
|
||||
$this->PrestudentModel->addSelect('p.vorname');
|
||||
$this->PrestudentModel->addSelect('p.wahlname');
|
||||
$this->PrestudentModel->addSelect('p.vornamen');
|
||||
$this->PrestudentModel->addSelect('p.titelpost');
|
||||
$this->PrestudentModel->addSelect('p.svnr');
|
||||
$this->PrestudentModel->addSelect('p.ersatzkennzeichen');
|
||||
$this->PrestudentModel->addSelect('p.gebdatum');
|
||||
$this->PrestudentModel->addSelect('p.geschlecht');
|
||||
$this->PrestudentModel->addSelect('p.foto');
|
||||
$this->PrestudentModel->addSelect('p.foto_sperre');
|
||||
$this->PrestudentModel->addSelect('s.student_uid');
|
||||
$this->PrestudentModel->addSelect('matrikelnr');
|
||||
$this->PrestudentModel->addSelect('b.aktiv');
|
||||
@@ -82,6 +97,16 @@ class Student extends FHCAPI_Controller
|
||||
$this->PrestudentModel->addSelect('v.verband');
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
$this->PrestudentModel->addSelect('b.alias');
|
||||
$this->PrestudentModel->addSelect('p.geburtsnation');
|
||||
$this->PrestudentModel->addSelect('p.sprache');
|
||||
$this->PrestudentModel->addSelect('p.gebort');
|
||||
$this->PrestudentModel->addSelect('p.homepage');
|
||||
$this->PrestudentModel->addSelect('p.anmerkung');
|
||||
$this->PrestudentModel->addSelect('p.familienstand');
|
||||
$this->PrestudentModel->addSelect('p.staatsbuergerschaft');
|
||||
$this->PrestudentModel->addSelect('p.matr_nr');
|
||||
$this->PrestudentModel->addSelect('p.anrede');
|
||||
$this->PrestudentModel->addSelect('p.zugangscode');
|
||||
|
||||
if (defined('ACTIVE_ADDONS') && strpos(ACTIVE_ADDONS, 'bewerbung') !== false) {
|
||||
$this->PrestudentModel->addSelect(
|
||||
@@ -97,6 +122,16 @@ class Student extends FHCAPI_Controller
|
||||
false
|
||||
);
|
||||
}
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(
|
||||
SELECT status_kurzbz
|
||||
FROM public.tbl_prestudentstatus pss
|
||||
WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id
|
||||
AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . "
|
||||
ORDER BY GREATEST(pss.datum, '0001-01-01') DESC
|
||||
LIMIT 1
|
||||
) AS statusofsemester"
|
||||
);
|
||||
|
||||
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT');
|
||||
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 'student_uid = uid', 'LEFT');
|
||||
@@ -106,43 +141,76 @@ class Student extends FHCAPI_Controller
|
||||
'LEFT'
|
||||
);
|
||||
$this->PrestudentModel->addJoin('public.tbl_person p', 'p.person_id = tbl_prestudent.person_id');
|
||||
/* $this->PrestudentModel->addJoin('public.tbl_prestudentstatus pss', 'pss.prestudent_id = tbl_prestudent.prestudent_id
|
||||
AND pss.studiensemester_kurzbz = ' . $this->PrestudentModel->escape($studiensemester_kurzbz),
|
||||
'LEFT');*/
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
$result = $this->PrestudentModel->loadWhere(['tbl_prestudent.prestudent_id' => $prestudent_id]);
|
||||
|
||||
$student = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$student)
|
||||
return show_404();
|
||||
|
||||
|
||||
$this->terminateWithSuccess(current($student));
|
||||
}
|
||||
|
||||
protected function isLaufendesSemester($selectedSemester)
|
||||
{
|
||||
$laufendesStudiensemester = '';
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$result = $this->StudiensemesterModel->getAktOrNextSemester();
|
||||
if(hasData($result)) {
|
||||
$laufendesStudiensemester = (getData($result))[0]->studiensemester_kurzbz;
|
||||
}
|
||||
|
||||
$islaufendesSemester = $selectedSemester === $laufendesStudiensemester;
|
||||
return $islaufendesSemester;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves data to a prestudent
|
||||
*
|
||||
* @param string $prestudent_id
|
||||
* @return void
|
||||
*/
|
||||
public function save($prestudent_id)
|
||||
public function save($prestudent_id, $studiensemester_kurzbz)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$this->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$this->load->model('organisation/Lehrverband_model', 'LehrverbandModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
if (!$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
$authuid = getAuthUID();
|
||||
$now = date('c');
|
||||
|
||||
$this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date');
|
||||
|
||||
$this->form_validation->set_rules('semester', 'Semester', 'integer');
|
||||
$this->form_validation->set_rules('semester', 'Semester', 'integer', [
|
||||
'integer' => $this->p->t('ui', 'error_fieldNotInteger')
|
||||
]
|
||||
);
|
||||
|
||||
$this->form_validation->set_rules('alias', 'Alias', 'regex_match[/^[-a-z0-9\_\.]*[a-z0-9]{1,}\.[-a-z0-9\_]{1,}$/]',
|
||||
[
|
||||
'regex_match' => $this->p->t('ui', 'error_fieldInvalidAlias')
|
||||
]);
|
||||
|
||||
$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);
|
||||
@@ -186,7 +254,6 @@ class Student extends FHCAPI_Controller
|
||||
'gebdatum',
|
||||
'gebort',
|
||||
'geburtsnation',
|
||||
'svnr',
|
||||
'ersatzkennzeichen',
|
||||
'staatsbuergerschaft',
|
||||
'matr_nr',
|
||||
@@ -197,7 +264,7 @@ class Student extends FHCAPI_Controller
|
||||
'anmerkung',
|
||||
'homepage'
|
||||
];
|
||||
|
||||
|
||||
// add UDFs
|
||||
$result = $this->udflib->getDefinitionForModel($this->PersonModel);
|
||||
|
||||
@@ -209,12 +276,26 @@ class Student extends FHCAPI_Controller
|
||||
$update_person = array();
|
||||
foreach ($array_allowed_props_person as $prop) {
|
||||
$val = $this->input->post($prop);
|
||||
if ($val !== null) {
|
||||
if ($val === null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if($prop == 'foto')
|
||||
{
|
||||
$fotoval = ($val == '') ? null : str_replace('data:image/jpeg;base64,', '', $val);
|
||||
$update_person[$prop] = $fotoval;
|
||||
}
|
||||
else
|
||||
{
|
||||
$update_person[$prop] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$array_allowed_props_student = ['matrikelnr'];
|
||||
if($this->isLaufendesSemester($studiensemester_kurzbz))
|
||||
{
|
||||
$array_allowed_props_student = ['matrikelnr', 'verband', 'semester', 'gruppe'];
|
||||
}
|
||||
$update_student = array();
|
||||
foreach ($array_allowed_props_student as $prop) {
|
||||
$val = $this->input->post($prop);
|
||||
@@ -223,6 +304,15 @@ class Student extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$array_allowed_props_benutzer = ['aktiv', 'alias'];
|
||||
$update_benutzer = array();
|
||||
foreach ($array_allowed_props_benutzer as $prop) {
|
||||
$val = $this->input->post($prop);
|
||||
if ($val !== null) {
|
||||
$update_benutzer[$prop] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
// Check PKs
|
||||
if (count($update_lehrverband) + count($update_student) && $uid === null) {
|
||||
$this->terminateWithValidationErrors(['' => $this->p->t('lehre', 'error_no_student')]);
|
||||
@@ -230,16 +320,47 @@ class Student extends FHCAPI_Controller
|
||||
if (count($update_person) && $person_id === null) {
|
||||
$this->terminateWithValidationErrors(['' => $this->p->t('lehre', 'error_no_person')]);
|
||||
}
|
||||
if (count($update_benutzer) && $uid === null) {
|
||||
$this->terminateWithValidationErrors(['' => $this->p->t('lehre', 'error_no_student')]);
|
||||
}
|
||||
|
||||
// Do Updates
|
||||
if (count($update_lehrverband)) {
|
||||
|
||||
$curstudlvb = $this->StudentlehrverbandModel->load([
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'student_uid' => $uid
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($curstudlvb);
|
||||
$data = current($data);
|
||||
|
||||
$verbandCurrent = $data->verband;
|
||||
$studiengang_kz = $data->studiengang_kz;
|
||||
$semesterCurrent = $data->semester;
|
||||
$gruppeCurrent = $data->gruppe;
|
||||
|
||||
$verband = isset($update_lehrverband['verband']) ? $update_lehrverband['verband'] : $verbandCurrent;
|
||||
$gruppe = isset($update_lehrverband['gruppe']) ? $update_lehrverband['gruppe'] : $gruppeCurrent;
|
||||
$semester = isset($update_lehrverband['semester']) ? $update_lehrverband['semester'] : $semesterCurrent;
|
||||
|
||||
//check if existing Lehrverband of new data to avoid Error
|
||||
$result = $this->LehrverbandModel->loadWhere([
|
||||
'verband' => $verband,
|
||||
'gruppe' => $gruppe,
|
||||
'semester' => $semester,
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
]);
|
||||
|
||||
if(!hasData($result))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('lehre', 'error_noLehrverband'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if(hasData($curstudlvb) && count(getData($curstudlvb)) > 0 )
|
||||
{
|
||||
$update_lehrverband['updatevon'] = $authuid;
|
||||
$update_lehrverband['updateamum'] = $now;
|
||||
$result = $this->StudentlehrverbandModel->update([
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'student_uid' => $uid
|
||||
@@ -247,6 +368,8 @@ class Student extends FHCAPI_Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$update_lehrverband['insertvon'] = $authuid;
|
||||
$update_lehrverband['insertamum'] = $now;
|
||||
$result = $this->StudentlehrverbandModel->insert(array_merge([
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'student_uid' => $uid,
|
||||
@@ -258,6 +381,8 @@ class Student extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
if (count($update_person)) {
|
||||
$update_person['updatevon'] = $authuid;
|
||||
$update_person['updateamum'] = $now;
|
||||
$result = $this->PersonModel->update(
|
||||
$person_id,
|
||||
$update_person
|
||||
@@ -267,6 +392,8 @@ class Student extends FHCAPI_Controller
|
||||
|
||||
|
||||
if (count($update_student)) {
|
||||
$update_student['updatevon'] = $authuid;
|
||||
$update_student['updateamum'] = $now;
|
||||
$result = $this->StudentModel->update(
|
||||
[$uid],
|
||||
$update_student
|
||||
@@ -274,10 +401,26 @@ class Student extends FHCAPI_Controller
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
if (count($update_benutzer)) {
|
||||
$update_benutzer['updatevon'] = $authuid;
|
||||
$update_benutzer['updateamum'] = $now;
|
||||
if (array_key_exists("aktiv", $update_benutzer))
|
||||
{
|
||||
$update_benutzer['updateaktivvon'] = $authuid;
|
||||
$update_benutzer['updateaktivam'] = $now;
|
||||
}
|
||||
$result = $this->BenutzerModel->update(
|
||||
[$uid],
|
||||
$update_benutzer
|
||||
);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess(array_fill_keys(array_merge(
|
||||
array_keys($update_lehrverband),
|
||||
array_keys($update_person),
|
||||
array_keys($update_student)
|
||||
array_keys($update_student),
|
||||
array_keys($update_benutzer)
|
||||
), ''));
|
||||
}
|
||||
|
||||
@@ -560,7 +703,7 @@ class Student extends FHCAPI_Controller
|
||||
return $result;
|
||||
}*/
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
public function requiredIfNotPersonId($value)
|
||||
@@ -576,4 +719,9 @@ class Student extends FHCAPI_Controller
|
||||
return true;
|
||||
return !!$value;
|
||||
}
|
||||
|
||||
public function isValidDate($value)
|
||||
{
|
||||
return isValidDate($value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,142 +45,118 @@ class Students extends FHCAPI_Controller
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('PhrasesLib');
|
||||
$this->loadPhrases(
|
||||
array(
|
||||
'lehre'
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Routing
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $params (optional)
|
||||
* /inout => index
|
||||
* /(studiensemester_kurzbz) => index
|
||||
* /(studiensemester_kurzbz)/inout => index
|
||||
*
|
||||
* /(studiensemester_kurzbz)/inout/incoming => getIncoming
|
||||
* /(studiensemester_kurzbz)/inout/outgoing => getOutgoing
|
||||
* /(studiensemester_kurzbz)/inout/gemeinsamestudien => getGemeinsamestudien
|
||||
*
|
||||
* /(studiengang_kz)/prestudent => getPrestudents
|
||||
* /(studiengang_kz)/prestudent/(studiensemester_kurzbz) => getPrestudents
|
||||
* /(studiengang_kz)/prestudent/(studiensemester_kurzbz)/(filter) => getPrestudents
|
||||
* /(studiengang_kz)/prestudent/(studiensemester_kurzbz)/(filter)/(otherfilter) => getPrestudents
|
||||
*
|
||||
* /(studiengang_kz)/(orgform)/prestudent => getPrestudentsOrgform
|
||||
* /(studiengang_kz)/(orgform)/prestudent/(studiensemester_kurzbz) => getPrestudentsOrgform
|
||||
* /(studiengang_kz)/(orgform)/prestudent/(studiensemester_kurzbz)/(filter) => getPrestudentsOrgform
|
||||
* /(studiengang_kz)/(orgform)/prestudent/(studiensemester_kurzbz)/(filter)/(otherfilter) => getPrestudentsOrgform
|
||||
*
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(semester)/grp/(gruppe) => getStudentsSpezialguppe
|
||||
*
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz) => getStudents
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(semester) => getStudents
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(semester)/(verband) => getStudents
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(semester)/(verband)/(gruppe) => getStudents
|
||||
*
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(orgform)/(semester)/grp/(gruppe) => getStudentsOrgformSpezialgruppe
|
||||
*
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(orgform) => getStudentsOrgform
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(orgform)/(semester) => getStudentsOrgform
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(orgform)/(semester)/(verband) => getStudentsOrgform
|
||||
* /(studiensemester_kurzbz)/(studiengang_kz)/(orgform)/(semester)/(verband)/(gruppe) => getStudentsOrgform
|
||||
*
|
||||
* /(studiensemester_kurzbz)/uid/(student_uid) => getStudent
|
||||
* /(studiensemester_kurzbz)/prestudent/(prestudent_id) => getPrestudent
|
||||
* /(studiensemester_kurzbz)/person/(person_id) => getPerson
|
||||
*/
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function _remap($method, $params = [])
|
||||
public function getIncoming()
|
||||
{
|
||||
if ($method == '' || $method == 'index')
|
||||
return $this->terminateWithSuccess([]);
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
// TODO(chris): IMPLEMENT!
|
||||
$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();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getOutgoing()
|
||||
{
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
// TODO(chris): IMPLEMENT!
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
|
||||
$count = count($params);
|
||||
if (!$count)
|
||||
return $this->getStudents($method);
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getGemeinsamestudien()
|
||||
{
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
// TODO(chris): IMPLEMENT!
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
public function getPrestudents($studiengang_kz,
|
||||
$studiensemester_kurzbz = null, $filter = null
|
||||
)
|
||||
{
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'filter' => $filter
|
||||
));
|
||||
|
||||
show_404();
|
||||
$this->fetchPrestudents($studiengang_kz, $studiensemester_kurzbz, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function getIncoming()
|
||||
public function getPrestudentsOrgform($studiengang_kz, $orgform_kurzbz,
|
||||
$studiensemester_kurzbz = null, $filter = null
|
||||
)
|
||||
{
|
||||
// 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([]);
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'filter' => $filter,
|
||||
'orgform_kurzbz' => $orgform_kurzbz
|
||||
));
|
||||
|
||||
$this->fetchPrestudents($studiengang_kz, $studiensemester_kurzbz, $filter, $orgform_kurzbz);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +167,7 @@ class Students extends FHCAPI_Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getPrestudents($studiengang_kz, $studiensemester_kurzbz = null, $filter = null, $orgform_kurzbz = null)
|
||||
protected function fetchPrestudents($studiengang_kz, $studiensemester_kurzbz = null, $filter = null, $orgform_kurzbz = null)
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
@@ -223,25 +199,25 @@ class Students extends FHCAPI_Controller
|
||||
break;
|
||||
case "bewerbungnichtabgeschickt":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bewerbung_abgeschicktamum'] = null;
|
||||
$where['ps.bewerbung_abgeschicktamum'] = null;
|
||||
break;
|
||||
case "bewerbungabgeschickt":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bewerbung_abgeschicktamum IS NOT NULL'] = null;
|
||||
$where['bestaetigtam'] = null;
|
||||
$where['ps.bewerbung_abgeschicktamum IS NOT NULL'] = null;
|
||||
$where['ps.bestaetigtam'] = null;
|
||||
break;
|
||||
case "statusbestaetigt":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bestaetigtam IS NOT NULL'] = null;
|
||||
$where['ps.bestaetigtam IS NOT NULL'] = null;
|
||||
break;
|
||||
case "statusbestaetigtrtnichtangemeldet":
|
||||
$where['ps.status_kurzbz'] = 'Interessent';
|
||||
$where['bestaetigtam IS NOT NULL'] = null;
|
||||
$where['ps.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;
|
||||
$where['ps.bestaetigtam IS NOT NULL'] = null;
|
||||
$this->PrestudentModel->db->where('EXISTS(' . $selectRT . ')', null, false);
|
||||
break;
|
||||
case "zgv":
|
||||
@@ -358,6 +334,18 @@ class Students extends FHCAPI_Controller
|
||||
$this->PrestudentModel->addSelect("'' AS gruppe");
|
||||
$this->addSelectPrioRel();
|
||||
|
||||
//add status per semester
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(
|
||||
SELECT status_kurzbz
|
||||
FROM public.tbl_prestudentstatus pss
|
||||
WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id
|
||||
AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . "
|
||||
ORDER BY GREATEST(pss.datum, '0001-01-01') DESC
|
||||
LIMIT 1
|
||||
) AS statusofsemester"
|
||||
);
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere($where);
|
||||
@@ -367,8 +355,73 @@ class Students extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getStudents($studiensemester_kurzbz,
|
||||
$studiengang_kz, $semester = null, $verband = null, $gruppe = null
|
||||
)
|
||||
{
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
'semester' => $semester,
|
||||
'verband' => $verband,
|
||||
'gruppe' => $gruppe
|
||||
));
|
||||
|
||||
$this->fetchStudents($studiensemester_kurzbz, $studiengang_kz, $semester, $verband, $gruppe, null, null);
|
||||
}
|
||||
|
||||
public function getStudentsOrgform($studiensemester_kurzbz,
|
||||
$studiengang_kz, $orgform_kurzbz, $semester = null, $verband = null, $gruppe = null
|
||||
)
|
||||
{
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
'orgform_kurzbz' => $orgform_kurzbz,
|
||||
'semester' => $semester,
|
||||
'verband' => $verband,
|
||||
'gruppe' => $gruppe
|
||||
));
|
||||
|
||||
$this->fetchStudents($studiensemester_kurzbz, $studiengang_kz, $semester, $verband, $gruppe, null, $orgform_kurzbz);
|
||||
}
|
||||
|
||||
public function getStudentsSpezialgruppe($studiensemester_kurzbz,
|
||||
$studiengang_kz, $semester, $gruppe_kurzbz,
|
||||
$orgform_kurzbz = null)
|
||||
{
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
'semester' => $semester,
|
||||
'gruppe_kurzbz' => $gruppe_kurzbz
|
||||
));
|
||||
|
||||
$this->fetchStudents($studiensemester_kurzbz, $studiengang_kz, $semester, null, null, $gruppe_kurzbz, null);
|
||||
}
|
||||
|
||||
public function getStudentsOrgformSpezialgruppe($studiensemester_kurzbz,
|
||||
$orgform_kurzbz, $studiengang_kz, $semester, $gruppe_kurzbz
|
||||
)
|
||||
{
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'orgform_kurzbz' => $orgform_kurzbz,
|
||||
'studiengang_kz' => $studiengang_kz,
|
||||
'semester' => $semester,
|
||||
'gruppe_kurzbz' => $gruppe_kurzbz
|
||||
));
|
||||
|
||||
$this->fetchStudents($studiensemester_kurzbz, $studiengang_kz, $semester, null, null, $gruppe_kurzbz, $orgform_kurzbz);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $studiengang_kz
|
||||
* @param string $studiensemester_kurzbz
|
||||
* @param integer $semester (optional)
|
||||
* @param string $verband (optional)
|
||||
* @param integer $gruppe (optional)
|
||||
@@ -377,12 +430,15 @@ class Students extends FHCAPI_Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getStudents($studiengang_kz, $semester = null, $verband = null, $gruppe = null, $gruppe_kurzbz = null, $orgform_kurzbz = null)
|
||||
protected function fetchStudents($studiensemester_kurzbz, $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->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
if (!$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
/*
|
||||
$this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
|
||||
@@ -406,6 +462,18 @@ class Students extends FHCAPI_Controller
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
$this->PrestudentModel->addSelect("'' AS priorisierung_relativ");
|
||||
|
||||
//add status per semester
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(
|
||||
SELECT status_kurzbz
|
||||
FROM public.tbl_prestudentstatus pss
|
||||
WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id
|
||||
AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . "
|
||||
ORDER BY GREATEST(pss.datum, '0001-01-01') DESC
|
||||
LIMIT 1
|
||||
) AS statusofsemester"
|
||||
);
|
||||
|
||||
|
||||
$where = [];
|
||||
|
||||
@@ -455,9 +523,20 @@ class Students extends FHCAPI_Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getPrestudent($prestudent_id)
|
||||
public function getPrestudent($studiensemester_kurzbz, $prestudent_id)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'prestudent_id' => $prestudent_id,
|
||||
));
|
||||
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
if (!$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
@@ -482,6 +561,19 @@ class Students extends FHCAPI_Controller
|
||||
$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');
|
||||
|
||||
//add status per semester
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(
|
||||
SELECT status_kurzbz
|
||||
FROM public.tbl_prestudentstatus pss
|
||||
WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id
|
||||
AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . "
|
||||
ORDER BY GREATEST(pss.datum, '0001-01-01') DESC
|
||||
LIMIT 1
|
||||
) AS statusofsemester"
|
||||
);
|
||||
|
||||
$this->addSelectPrioRel();
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
@@ -500,9 +592,20 @@ class Students extends FHCAPI_Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getStudent($student_uid)
|
||||
public function getStudent($studiensemester_kurzbz, $student_uid)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'student_uid' => $student_uid,
|
||||
));
|
||||
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
if (!$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
@@ -527,8 +630,23 @@ class Students extends FHCAPI_Controller
|
||||
$this->PrestudentModel->addSelect('v.semester');
|
||||
$this->PrestudentModel->addSelect('v.verband');
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
|
||||
//add status per semester
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(
|
||||
SELECT status_kurzbz
|
||||
FROM public.tbl_prestudentstatus pss
|
||||
WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id
|
||||
AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . "
|
||||
ORDER BY GREATEST(pss.datum, '0001-01-01') DESC
|
||||
LIMIT 1
|
||||
) AS statusofsemester"
|
||||
);
|
||||
|
||||
$this->addSelectPrioRel();
|
||||
|
||||
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere([
|
||||
@@ -541,13 +659,25 @@ class Students extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $studiensemester_kurzbz
|
||||
* @param integer $person_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getPerson($person_id)
|
||||
public function getPerson($studiensemester_kurzbz, $person_id)
|
||||
{
|
||||
$studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell');
|
||||
$this->addMeta('ci_method', __FUNCTION__);
|
||||
$this->addMeta('ci_params', array(
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'person_id' => $person_id,
|
||||
));
|
||||
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
if (!$this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
|
||||
{
|
||||
$this->terminateWithError($studiensemester_kurzbz . ' - ' . $this->p->t('lehre', 'error_noStudiensemester'));
|
||||
}
|
||||
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
@@ -565,6 +695,19 @@ class Students extends FHCAPI_Controller
|
||||
$this->PrestudentModel->addSelect('v.semester');
|
||||
$this->PrestudentModel->addSelect('v.verband');
|
||||
$this->PrestudentModel->addSelect('v.gruppe');
|
||||
|
||||
//add status per semester
|
||||
$this->PrestudentModel->addSelect(
|
||||
"(
|
||||
SELECT status_kurzbz
|
||||
FROM public.tbl_prestudentstatus pss
|
||||
WHERE pss.prestudent_id = public.tbl_prestudent.prestudent_id
|
||||
AND pss.studiensemester_kurzbz = " . $this->PrestudentModel->escape($studiensemester_kurzbz) . "
|
||||
ORDER BY GREATEST(pss.datum, '0001-01-01') DESC
|
||||
LIMIT 1
|
||||
) AS statusofsemester"
|
||||
);
|
||||
|
||||
$this->addSelectPrioRel();
|
||||
|
||||
$this->addFilter($studiensemester_kurzbz);
|
||||
@@ -618,10 +761,11 @@ class Students extends FHCAPI_Controller
|
||||
$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');
|
||||
$this->PrestudentModel->addSelect('foto');
|
||||
$this->PrestudentModel->addSelect('foto_sperre');
|
||||
|
||||
// semester
|
||||
// verband
|
||||
@@ -629,6 +773,7 @@ class Students extends FHCAPI_Controller
|
||||
|
||||
$this->PrestudentModel->addSelect('UPPER(stg.typ || stg.kurzbz) AS studiengang');
|
||||
$this->PrestudentModel->addSelect('tbl_prestudent.studiengang_kz');
|
||||
$this->PrestudentModel->addSelect('stg.bezeichnung AS stg_bezeichnung');
|
||||
$this->PrestudentModel->addSelect("s.matrikelnr");
|
||||
$this->PrestudentModel->addSelect('p.person_id');
|
||||
$this->PrestudentModel->addSelect('pls.status_kurzbz AS status');
|
||||
@@ -640,7 +785,7 @@ class Students extends FHCAPI_Controller
|
||||
);
|
||||
$this->PrestudentModel->addSelect("
|
||||
CASE WHEN b.uid IS NOT NULL AND b.uid<>''
|
||||
THEN b.uid || " . $this->PrestudentModel->escape(DOMAIN) . "
|
||||
THEN CONCAT(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');
|
||||
@@ -709,7 +854,12 @@ class Students extends FHCAPI_Controller
|
||||
*/
|
||||
protected function addFilter($studiensemester_kurzbz)
|
||||
{
|
||||
$filter = $this->input->get('filter');
|
||||
$filter = json_decode($this->input->get('filter'), true);
|
||||
if (!is_array($filter))
|
||||
{
|
||||
$this->addMeta('addfilter', 'invalid filter: ' . $this->input->get('filter'));
|
||||
return;
|
||||
}
|
||||
if (isset($filter['konto_count_0'])) {
|
||||
$bt = $this->PrestudentModel->escape($filter['konto_count_0']);
|
||||
$stdsem = $this->PrestudentModel->escape($studiensemester_kurzbz);
|
||||
|
||||
@@ -188,6 +188,7 @@ class Verband extends FHCAPI_Controller
|
||||
array_unshift($list, [
|
||||
'name' => 'PreStudent',
|
||||
'link' => $link . 'prestudent',
|
||||
'stg_kz' => (int)$studiengang_kz,
|
||||
'children' => $this->getStdSem($link . 'prestudent/', $studiengang_kz)
|
||||
]);
|
||||
|
||||
@@ -355,7 +356,11 @@ class Verband extends FHCAPI_Controller
|
||||
$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->load->config('stv');
|
||||
$number_displayed_past_studiensemester_default = $this->config->item('number_displayed_past_studiensemester_default');
|
||||
|
||||
$number_displayed_past_studiensemester = $data['number_displayed_past_studiensemester'] ?? $number_displayed_past_studiensemester_default;
|
||||
|
||||
$this->StudiensemesterModel->addPlusMinus(null, $number_displayed_past_studiensemester);
|
||||
$this->StudiensemesterModel->addOrder('ende');
|
||||
|
||||
@@ -0,0 +1,720 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
|
||||
class Vertraege extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getAllVertraege' => ['vertrag/mitarbeiter:r'],
|
||||
'getAllContractsNotAssigned' => ['vertrag/mitarbeiter:r'],
|
||||
'getAllContractsAssigned' => ['vertrag/mitarbeiter:r'],
|
||||
'getAllContractTypes' => ['vertrag/mitarbeiter:r'],
|
||||
'getAllContractStati' => ['vertrag/mitarbeiter:r'],
|
||||
'getStatiOfContract' => ['vertrag/mitarbeiter:r'],
|
||||
'loadContract' => ['vertrag/mitarbeiter:r'],
|
||||
'loadContractStatus' => ['vertrag/mitarbeiter:r'],
|
||||
'updateContract' =>['vertrag/mitarbeiter:w'],
|
||||
'addNewContract' =>['vertrag/mitarbeiter:w'],
|
||||
'deleteContract' =>['vertrag/mitarbeiter:w'],
|
||||
'insertContractStatus' =>['vertrag/mitarbeiter:w'],
|
||||
'deleteContractStatus' =>['vertrag/mitarbeiter:w'],
|
||||
'updateContractStatus' =>['vertrag/mitarbeiter:w'],
|
||||
'deleteLehrauftrag' =>['vertrag/mitarbeiter:w'],
|
||||
'deleteBetreuung' =>['vertrag/mitarbeiter:w'],
|
||||
'getMitarbeiter' => ['vertrag/mitarbeiter:r'],
|
||||
'getHeader' => ['vertrag/mitarbeiter:r'],
|
||||
'getPersonAbteilung' => ['vertrag/mitarbeiter:r'],
|
||||
'getLeitungOrg' => ['vertrag/mitarbeiter:r'],
|
||||
]);
|
||||
|
||||
//Load Models and Libraries
|
||||
$this->load->model('accounting/Vertrag_model', 'VertragModel');
|
||||
$this->load->model('accounting/Vertragsstatus_model', 'VertragsstatusModel');
|
||||
$this->load->model('accounting/Vertragstyp_model', 'VertragstypModel');
|
||||
$this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui',
|
||||
'vertrag'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getAllVertraege($person_id)
|
||||
{
|
||||
$result = $this->VertragModel->loadContractsOfPerson($person_id);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
public function getAllContractsNotAssigned($person_id)
|
||||
{
|
||||
$result = $this->VertragModel->loadContractsOfPersonNotAssigned($person_id);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
public function getAllContractsAssigned($person_id, $vertrag_id)
|
||||
{
|
||||
$result = $this->VertragModel->loadContractsOfPersonAssigned($person_id, $vertrag_id);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
public function getStatiOfContract($person_id, $vertrag_id)
|
||||
{
|
||||
//check if vertrag_id corresponds with person_id and return null if not
|
||||
$result = $this->VertragModel->loadWhere(
|
||||
array(
|
||||
'vertrag_id' => $vertrag_id,
|
||||
'person_id' => $person_id
|
||||
)
|
||||
);
|
||||
if(!hasData($result))
|
||||
{
|
||||
$this->terminateWithSuccess([]);
|
||||
}
|
||||
|
||||
$result = $this->VertragModel->getStatiOfContract($vertrag_id);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess((getData($result) ?: []));
|
||||
}
|
||||
|
||||
public function getAllContractTypes()
|
||||
{
|
||||
$result = $this->VertragstypModel->load();
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function getAllContractStati()
|
||||
{
|
||||
$result = $this->VertragsstatusModel->load();
|
||||
if (isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->terminateWithSuccess(getData($result) ?: []);
|
||||
}
|
||||
|
||||
public function addNewContract()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$person_id = $this->input->post('person_id');
|
||||
|
||||
if(!$person_id)
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$formData = $this->input->post('formData');
|
||||
$vertragstyp_kurzbz = $formData['vertragstyp_kurzbz'] ?? null;
|
||||
$vertragsdatum = $formData['vertragsdatum'] ?? null;
|
||||
$bezeichnung = $formData['bezeichnung'] ?? null;
|
||||
$betrag = $formData['betrag'] ?? null;
|
||||
$vertragsstunden = $formData['vertragsstunden'] ?? null;
|
||||
$vertragsstunden_studiensemester_kurzbz = $formData['vertragsstunden_studiensemester_kurzbz'] ?? null;
|
||||
$anmerkung = $formData['anmerkung'] ?? null;
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
$this->form_validation->set_rules('bezeichnung', 'Bezeichnung', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Bezeichnung'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('vertragstyp_kurzbz', 'Vertragstyp', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Vertragstyp'])
|
||||
]);
|
||||
$this->form_validation->set_rules('vertragsdatum', 'Vertragsdatum', 'required|is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Vertragsdatum']),
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Vertragsdatum'])
|
||||
]);
|
||||
$this->form_validation->set_rules('betrag', 'Betrag', 'required|numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Betrag']),
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Betrag'])
|
||||
]);
|
||||
$this->form_validation->set_rules('vertragsstunden', 'Stunden(Vertrags-Urfassung)', 'numeric', [
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Stunden(Vertrags-Urfassung)'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$lehrauftraege = $this->input->post('clickedRows');
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
$result = $this->VertragModel->insert([
|
||||
'person_id' => $person_id,
|
||||
'vertragsdatum' => $vertragsdatum,
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'vertragstyp_kurzbz' => $vertragstyp_kurzbz,
|
||||
'betrag' => $betrag,
|
||||
'vertragsstunden' => $vertragsstunden,
|
||||
'vertragsstunden_studiensemester_kurzbz' => $vertragsstunden_studiensemester_kurzbz,
|
||||
'anmerkung' => $anmerkung,
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID()
|
||||
]);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
$vertrag_id = $result->retval;
|
||||
|
||||
$status_result = $this->VertragvertragsstatusModel->insert([
|
||||
'vertrag_id' => $vertrag_id,
|
||||
'uid' => getAuthUID(),
|
||||
'vertragsstatus_kurzbz' => 'neu',
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID(),
|
||||
'datum' => date('c')
|
||||
]);
|
||||
|
||||
if (!$status_result) {
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError($this->p->t('vertrag', 'error_insertOrUpdateStatusVertrag'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//Hinzufügen der Lehraufträge
|
||||
foreach ($lehrauftraege as $row)
|
||||
{
|
||||
if ($row['type'] == 'Lehrauftrag')
|
||||
{
|
||||
$this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
|
||||
$result_lehrauftrag = $this->LehreinheitmitarbeiterModel->update(
|
||||
[
|
||||
'lehreinheit_id' => $row['lehreinheit_id'],
|
||||
'mitarbeiter_uid' => $row['mitarbeiter_uid']
|
||||
],
|
||||
[
|
||||
'vertrag_id' => $vertrag_id
|
||||
]
|
||||
);
|
||||
|
||||
if (!$result_lehrauftrag) {
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError($this->p->t('vertrag', 'error_addOrUpdateLehrauftraege'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
if ($row['type'] == 'Betreuung')
|
||||
{
|
||||
$this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel');
|
||||
|
||||
$result_projektbetreuer = $this->Projektbetreuermodel->update(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'projektarbeit_id' => $row['projektarbeit_id'],
|
||||
'betreuerart_kurzbz' => $row['betreuerart_kurzbz']
|
||||
],
|
||||
[
|
||||
'vertrag_id' => $vertrag_id
|
||||
]
|
||||
);
|
||||
|
||||
if (!$result_projektbetreuer)
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError($this->p->t('vertrag', 'error_addOrUpdateLehrauftraege'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
public function updateContract()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$vertrag_id = $this->input->post('vertrag_id');
|
||||
$person_id = $this->input->post('person_id');
|
||||
$formData = $this->input->post('formData');
|
||||
$lehrauftraege = $this->input->post('clickedRows');
|
||||
|
||||
$vertragstyp_kurzbz = $formData['vertragstyp_kurzbz'] ?? null;
|
||||
$vertragsdatum = $formData['vertragsdatum'] ?? null;
|
||||
$bezeichnung = $formData['bezeichnung'] ?? null;
|
||||
$betrag = $formData['betrag'] ?? null;
|
||||
$vertragsstunden = $formData['vertragsstunden'] ?? null;
|
||||
$vertragsstunden_studiensemester_kurzbz = $formData['vertragsstunden_studiensemester_kurzbz'] ?? null;
|
||||
$anmerkung = $formData['anmerkung'] ?? null;
|
||||
|
||||
|
||||
$this->form_validation->set_data($formData);
|
||||
$this->form_validation->set_rules('bezeichnung', 'Bezeichnung', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Bezeichnung'])
|
||||
]);
|
||||
|
||||
$this->form_validation->set_rules('vertragstyp_kurzbz', 'Vertragstyp', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Vertragstyp'])
|
||||
]);
|
||||
$this->form_validation->set_rules('vertragsdatum', 'Vertragsdatum', 'required|is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Vertragsdatum']),
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Vertragsdatum'])
|
||||
]);
|
||||
$this->form_validation->set_rules('betrag', 'Betrag', 'required|numeric', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Betrag']),
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Betrag'])
|
||||
]);
|
||||
$this->form_validation->set_rules('vertragsstunden', 'Stunden(Vertrags-Urfassung)', 'numeric', [
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Stunden(Vertrags-Urfassung)'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$this->db->trans_start();
|
||||
|
||||
$result = $this->VertragModel->update(
|
||||
$vertrag_id,
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'vertragsdatum' => $vertragsdatum,
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'vertragstyp_kurzbz' => $vertragstyp_kurzbz,
|
||||
'betrag' => $betrag,
|
||||
'vertragsstunden' => $vertragsstunden,
|
||||
'vertragsstunden_studiensemester_kurzbz' => $vertragsstunden_studiensemester_kurzbz,
|
||||
'anmerkung' => $anmerkung,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]
|
||||
);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
//Adding of Lehraufträge
|
||||
foreach ($lehrauftraege as $row)
|
||||
{
|
||||
if ($row['type'] == 'Lehrauftrag')
|
||||
{
|
||||
$this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
|
||||
$result_lehrauftrag = $this->LehreinheitmitarbeiterModel->update(
|
||||
[
|
||||
'lehreinheit_id' => $row['lehreinheit_id'],
|
||||
'mitarbeiter_uid' => $row['mitarbeiter_uid']
|
||||
],
|
||||
[
|
||||
'vertrag_id' => $vertrag_id,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]
|
||||
);
|
||||
|
||||
if (!$result_lehrauftrag) {
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError($this->p->t('vertrag', 'error_addOrUpdateLehrauftraege'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
if ($row['type'] == 'Betreuung')
|
||||
{
|
||||
$this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel');
|
||||
|
||||
$result_projektbetreuer = $this->Projektbetreuermodel->update(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'projektarbeit_id' => $row['projektarbeit_id'],
|
||||
'betreuerart_kurzbz' => $row['betreuerart_kurzbz']
|
||||
],
|
||||
[
|
||||
'vertrag_id' => $vertrag_id,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]
|
||||
);
|
||||
|
||||
if (!$result_projektbetreuer)
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError($this->p->t('vertrag', 'error_addOrUpdateLehrauftraege'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
public function loadContract($vertrag_id)
|
||||
{
|
||||
$result = $this->VertragModel->load($vertrag_id);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
if (!hasData($result)) {
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Vertrag_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function deleteContract($vertrag_id)
|
||||
{
|
||||
$this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
|
||||
//check if attached Lehrauftrag
|
||||
$resultLehrauftrag = $this->LehreinheitmitarbeiterModel->load([
|
||||
'vertrag_id' => $vertrag_id
|
||||
]);
|
||||
|
||||
if(hasData($resultLehrauftrag))
|
||||
{
|
||||
$resultLehrauftrag = getData($resultLehrauftrag);
|
||||
foreach($resultLehrauftrag as $lehrauftrag)
|
||||
{
|
||||
$result = $this->LehreinheitmitarbeiterModel->update(
|
||||
[
|
||||
'lehreinheit_id' => $lehrauftrag->lehreinheit_id,
|
||||
'mitarbeiter_uid' => $lehrauftrag->mitarbeiter_uid,
|
||||
'vertrag_id' => $vertrag_id
|
||||
],
|
||||
[
|
||||
'vertrag_id' => null,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]
|
||||
);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
//if attached Betreuung
|
||||
$this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel');
|
||||
|
||||
//if attached Betreuung
|
||||
$resultBetreuung = $this->Projektbetreuermodel->load([
|
||||
'vertrag_id' => $vertrag_id
|
||||
]);
|
||||
|
||||
if(hasData($resultBetreuung))
|
||||
{
|
||||
$resultBetreuung = getData($resultBetreuung);
|
||||
foreach($resultBetreuung as $betreuung)
|
||||
{
|
||||
$result = $this->Projektbetreuermodel->update(
|
||||
[
|
||||
'person_id' => $betreuung->person_id,
|
||||
'projektarbeit_id' => $betreuung->projektarbeit_id,
|
||||
'betreuerart_kurzbz' => $betreuung->betreuerart_kurzbz,
|
||||
'vertrag_id' => $vertrag_id
|
||||
],
|
||||
[
|
||||
'vertrag_id' => null,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
|
||||
]
|
||||
);
|
||||
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->VertragvertragsstatusModel->load([
|
||||
'vertrag_id' => $vertrag_id
|
||||
]);
|
||||
|
||||
if(hasData($result))
|
||||
{
|
||||
$data = getData($result);
|
||||
foreach ($data as $item)
|
||||
{
|
||||
//delete all entries in lehre.tbl_vertrag_vertragsstatus
|
||||
$result = $this->VertragvertragsstatusModel->delete([
|
||||
'vertrag_id' => $vertrag_id,
|
||||
'vertragsstatus_kurzbz' => $item->vertragsstatus_kurzbz,
|
||||
'uid' => $item->uid
|
||||
]);
|
||||
if(isError($result))
|
||||
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
//delete Contract
|
||||
$result = $this->VertragModel->delete(
|
||||
array('vertrag_id' => $vertrag_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' => 'Vertrag_id']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function insertContractStatus()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('vertragsstatus_kurzbz', 'vertragsstatus_kurzbz', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'vertragsstatus_kurzbz'])
|
||||
]);
|
||||
$this->form_validation->set_rules('datum', 'Datum', 'required|is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Datum']),
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Datum'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$result = $this->VertragvertragsstatusModel->loadWhere(
|
||||
array(
|
||||
'vertrag_id' => $this->input->post('vertrag_id'),
|
||||
'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz')
|
||||
)
|
||||
);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$this->terminateWithError($this->p->t('vertrag', 'error_statusVorhanden'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$status_result = $this->VertragvertragsstatusModel->insert([
|
||||
'vertrag_id' => $this->input->post('vertrag_id'),
|
||||
'uid' => getAuthUID(),
|
||||
'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz'),
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => getAuthUID(),
|
||||
'datum' => $this->input->post('datum')
|
||||
]);
|
||||
|
||||
if (!$status_result) {
|
||||
$this->terminateWithError('Fehler beim Hinzufügen des Vertragsstatus.');
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess(current(getData($status_result)));
|
||||
}
|
||||
|
||||
public function deleteContractStatus()
|
||||
{
|
||||
$status = $this->input->post('vertragsstatus_kurzbz');
|
||||
$vertrag_id = $this->input->post('vertrag_id');
|
||||
|
||||
$result = $this->VertragvertragsstatusModel->delete(
|
||||
array(
|
||||
'vertrag_id' => $vertrag_id,
|
||||
'vertragsstatus_kurzbz' => $status
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'vertragsstatus_kurzb']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function loadContractStatus()
|
||||
{
|
||||
$status = $this->input->get('vertragsstatus_kurzbz');
|
||||
$vertrag_id = $this->input->get('vertrag_id');
|
||||
|
||||
$result = $this->VertragvertragsstatusModel->loadWhere(
|
||||
array(
|
||||
'vertrag_id' => $vertrag_id,
|
||||
'vertragsstatus_kurzbz' => $status
|
||||
)
|
||||
);
|
||||
if (!$result) {
|
||||
$this->terminateWithError('Status not existing');
|
||||
}
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function updateContractStatus()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('vertragsstatus_kurzbz', 'vertragsstatus_kurzbz', 'required', [
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'vertragsstatus_kurzbz'])
|
||||
]);
|
||||
$this->form_validation->set_rules('datum', 'Datum', 'required|is_valid_date', [
|
||||
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'Datum']),
|
||||
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Datum'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
{
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$status_result = $this->VertragvertragsstatusModel->update(
|
||||
[
|
||||
'vertrag_id' => $this->input->post('vertrag_id'),
|
||||
'vertragsstatus_kurzbz' => $this->input->post('vertragsstatus_kurzbz')
|
||||
],
|
||||
[
|
||||
'uid' => getAuthUID(),
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID(),
|
||||
'datum' => $this->input->post('datum')
|
||||
]
|
||||
);
|
||||
|
||||
if (!$status_result) {
|
||||
$this->terminateWithError('Fehler beim Updaten des Vertragsstatus.');
|
||||
}
|
||||
|
||||
return $this->terminateWithSuccess(current(getData($status_result)));
|
||||
}
|
||||
|
||||
public function deleteLehrauftrag()
|
||||
{
|
||||
$lehreinheit_id = $this->input->post('lehreinheit_id');
|
||||
$mitarbeiter_uid = $this->input->post('mitarbeiter_uid');
|
||||
$vertrag_id = $this->input->post('vertrag_id');
|
||||
|
||||
$this->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
|
||||
//kein delete: ein update, bei dem die vertrag_id auf null gesetzt wird
|
||||
$result = $this->LehreinheitmitarbeiterModel->update(
|
||||
[
|
||||
'lehreinheit_id' => $lehreinheit_id,
|
||||
'mitarbeiter_uid' => $mitarbeiter_uid,
|
||||
'vertrag_id' => $vertrag_id
|
||||
],
|
||||
[
|
||||
'vertrag_id' => null,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Id_Lehrauftrag']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function deleteBetreuung()
|
||||
{
|
||||
$person_id= $this->input->post('person_id');
|
||||
$projektarbeit_id = $this->input->post('projektarbeit_id');
|
||||
$betreuerart_kurzbz = $this->input->post('betreuerart_kurzbz');
|
||||
$vertrag_id = $this->input->post('vertrag_id');
|
||||
|
||||
$this->load->model('education/Projektbetreuer_model', 'Projektbetreuermodel');
|
||||
|
||||
$result = $this->Projektbetreuermodel->update(
|
||||
[
|
||||
'person_id' => $person_id,
|
||||
'projektarbeit_id' => $projektarbeit_id,
|
||||
'betreuerart_kurzbz' => $betreuerart_kurzbz,
|
||||
'vertrag_id' => $vertrag_id
|
||||
],
|
||||
[
|
||||
'vertrag_id' => null,
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => getAuthUID()
|
||||
]
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($result))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Id_Projektbetreuung']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
return $this->terminateWithSuccess(current(getData($result)));
|
||||
}
|
||||
|
||||
public function getMitarbeiter()
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel');
|
||||
|
||||
$result = $this->Mitarbeitermodel->getPersonenWithContractDetails();
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
if (!hasData($result))
|
||||
{
|
||||
//return data before PV21 (with filter fix angestellt, active and with bisverwendung)
|
||||
$result = $this->Mitarbeitermodel->getPersonal(true, true, true);
|
||||
if (isError($result))
|
||||
{
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
return $this->terminateWithSuccess(getData($result));
|
||||
}
|
||||
|
||||
public function getPersonAbteilung($mitarbeiter_uid)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel');
|
||||
|
||||
$result = $this->Mitarbeitermodel->getPersonAbteilung($mitarbeiter_uid);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function getLeitungOrg($oekurzbz)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel');
|
||||
|
||||
$result = $this->Mitarbeitermodel->getLeitungOrg($oekurzbz);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
|
||||
public function getHeader($person_id)
|
||||
{
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'Mitarbeitermodel');
|
||||
|
||||
$result = $this->Mitarbeitermodel->getHeader($person_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(current($data));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Vorlagen extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getVorlagen' => ['admin:r', 'assistenz:r'],
|
||||
'getVorlagenByLoggedInUser' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
|
||||
// Additional Permission Checks
|
||||
//TODO(manu) check permissions
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('VorlageLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getVorlagen()
|
||||
{
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
|
||||
$this->VorlageModel->addOrder('vorlage_kurzbz', 'ASC');
|
||||
|
||||
$result = $this->VorlageModel->loadWhere(
|
||||
array(
|
||||
'mimetype' => 'text/html'
|
||||
));
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getVorlagenByLoggedInUser()
|
||||
{
|
||||
//get oe of user
|
||||
$uid = getAuthUID();
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung');
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$oe_kurzbz = current($data);
|
||||
|
||||
$result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class UHSTAT1 extends FHC_Controller
|
||||
const CODEX_UNKNOWN_YEAR = 9999;
|
||||
const CODEX_UNKNOWN_NATION = 'XXX';
|
||||
const CODEX_UNKNOWN_BILDUNGMAX = 999;
|
||||
const CODEX_EXCLUDED_NATIONS = ['ZZZ'];
|
||||
const LOWER_BOUNDARY_YEARS = 160;
|
||||
const UPPER_BOUNDARY_YEARS = 20;
|
||||
|
||||
@@ -32,8 +33,7 @@ class UHSTAT1 extends FHC_Controller
|
||||
$this->load->library('PermissionLib');
|
||||
|
||||
// load models
|
||||
$this->load->model('codex/Oehbeitrag_model', 'OehbeitragModel');
|
||||
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->load->model('system/Sprache_model', 'SpracheModel');
|
||||
$this->load->model('codex/Abschluss_model', 'AbschlussModel');
|
||||
$this->load->model('codex/Uhstat1daten_model', 'Uhstat1datenModel');
|
||||
@@ -104,7 +104,7 @@ class UHSTAT1 extends FHC_Controller
|
||||
{
|
||||
$saved = false;
|
||||
|
||||
$person_id = $this->_getValidPersonId('sui');
|
||||
$person_id = $this->_getUHSTATPersonId('sui');
|
||||
|
||||
$this->form_validation->set_error_delimiters('<span class="text-danger">', '</span>');
|
||||
|
||||
@@ -245,7 +245,7 @@ class UHSTAT1 extends FHC_Controller
|
||||
// uhstat data can only be deleted with permission
|
||||
if (!$this->_checkPermission('suid')) show_error('no permission');
|
||||
|
||||
$person_id = $this->_getValidPersonId('suid');
|
||||
$person_id = $this->_getUHSTATPersonId('suid');
|
||||
|
||||
$uhstat1datenRes = $this->Uhstat1datenModel->delete(
|
||||
array('person_id' => $person_id)
|
||||
@@ -287,13 +287,17 @@ class UHSTAT1 extends FHC_Controller
|
||||
*/
|
||||
private function _getFormMetaData()
|
||||
{
|
||||
$person_id = $this->_getValidPersonId('s');
|
||||
$person_id = $this->_getUHSTATPersonId('s');
|
||||
|
||||
// read only display param
|
||||
$readOnly = $this->input->get('readOnly');
|
||||
|
||||
// depending on permissions, editing or deleting is possible
|
||||
$editPermission = $this->_checkPermission('sui');
|
||||
// checking permissions for form
|
||||
|
||||
// saving is possible if there permission or student log in (but not from application tool)
|
||||
$savePermission = $this->_checkPermission('sui') || ($this->_getUserPersonId() && !$this->_getApplicationToolPersonId());
|
||||
|
||||
// deleting only possible with permission
|
||||
$deletePermission = $this->_checkPermission('suid');
|
||||
|
||||
$languageIdx = $this->_getLanguageIndex();
|
||||
@@ -304,7 +308,7 @@ class UHSTAT1 extends FHC_Controller
|
||||
'abschluss_nicht_oesterreich' => array(),
|
||||
'jahre' => array(),
|
||||
'person_id' => $person_id,
|
||||
'editPermission' => $editPermission,
|
||||
'savePermission' => $savePermission,
|
||||
'deletePermission' => $deletePermission,
|
||||
'readOnly' => $readOnly
|
||||
);
|
||||
@@ -336,15 +340,19 @@ class UHSTAT1 extends FHC_Controller
|
||||
|
||||
if (hasData($nationRes))
|
||||
{
|
||||
$dropdownNations = [];
|
||||
$nations = getData($nationRes);
|
||||
|
||||
// put austria in beginning of selection
|
||||
foreach ($nations as $nation)
|
||||
{
|
||||
if ($nation->nation_code == self::CODEX_OESTERREICH) array_unshift($nations, $nation);
|
||||
// put austria in beginning of selection
|
||||
if ($nation->nation_code == self::CODEX_OESTERREICH)
|
||||
array_unshift($dropdownNations, $nation);
|
||||
elseif (!in_array($nation->nation_code, self::CODEX_EXCLUDED_NATIONS)) // add nation if not excluded
|
||||
$dropdownNations[] = $nation;
|
||||
}
|
||||
|
||||
$formMetaData['nation'] = $nations;
|
||||
$formMetaData['nation'] = $dropdownNations;
|
||||
}
|
||||
|
||||
// get abschluss list
|
||||
@@ -386,7 +394,7 @@ class UHSTAT1 extends FHC_Controller
|
||||
*/
|
||||
private function _getUHSTAT1Data()
|
||||
{
|
||||
$person_id = $this->_getValidPersonId('s');
|
||||
$person_id = $this->_getUHSTATPersonId('s');
|
||||
|
||||
$this->Uhstat1datenModel->addSelect(
|
||||
implode(', ', array_keys($this->_uhstat1Fields))
|
||||
@@ -417,29 +425,70 @@ class UHSTAT1 extends FHC_Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Id of person having permissions to manage UHSTAT1 data.
|
||||
* Can be passed as parameter or be in session.
|
||||
* Gets Id of person, for which UHSTAT1 data is edited.
|
||||
* Can be passed as parameter, id of logged in person, or be in session.
|
||||
* @param berechtigungsArt type of permission (suid)
|
||||
* @return int person_id
|
||||
*/
|
||||
private function _getValidPersonId($berechtigungsArt)
|
||||
private function _getUHSTATPersonId($berechtigungsArt)
|
||||
{
|
||||
// if coming from bewerbungstool - person id is in session (person must be logged in bewerbungstool)
|
||||
$applicationToolPersonId = $this->_getApplicationToolPersonId();
|
||||
if (isset($applicationToolPersonId) && is_numeric($applicationToolPersonId)) return $applicationToolPersonId;
|
||||
|
||||
// if successfully logged in
|
||||
$loggedInPersonId = $this->_getUserPersonId();
|
||||
if (isset($loggedInPersonId) && is_numeric($loggedInPersonId))
|
||||
{
|
||||
// if person id passed directly...
|
||||
$person_id = $this->input->post('person_id');
|
||||
if (!isset($person_id)) $person_id = $this->input->get('person_id');
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
if (!is_numeric($person_id)) show_error("invalid person id");
|
||||
// ...check if there is a permission for editing UHSTAT1 data
|
||||
if ($this->_checkPermission($berechtigungsArt)) return $person_id;
|
||||
}
|
||||
|
||||
// if no id passed, use logged in person id
|
||||
return $loggedInPersonId;
|
||||
}
|
||||
|
||||
show_error("No permission");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets person Id if there is a application tool login.
|
||||
* @return person Id or null
|
||||
*/
|
||||
private function _getApplicationToolPersonId()
|
||||
{
|
||||
// if coming from aplication tool - person id is in session (person must be logged in bewerbungstool)
|
||||
if (isset($_SESSION[self::PERSON_ID_SESSION_INDEX])
|
||||
&& is_numeric($_SESSION[self::PERSON_ID_SESSION_INDEX])
|
||||
&& isset($_SESSION[self::LOGIN_SESSION_INDEX])
|
||||
)
|
||||
return $_SESSION[self::PERSON_ID_SESSION_INDEX];
|
||||
|
||||
// if person id passed directly...
|
||||
$person_id = $this->input->post('person_id');
|
||||
if (!isset($person_id)) $person_id = $this->input->get('person_id');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isset($person_id) || !is_numeric($person_id)) show_error("invalid person id");
|
||||
|
||||
// ...check if there is a permission for editing UHSTAT1 data
|
||||
if ($this->_checkPermission($berechtigungsArt)) return $person_id;
|
||||
|
||||
show_error("No permission");
|
||||
/**
|
||||
* Gets person Id if there is a user login.
|
||||
* @return person Id or null
|
||||
*/
|
||||
private function _getUserPersonId()
|
||||
{
|
||||
$loggedInPersonId = getAuthPersonId();
|
||||
if (isset($loggedInPersonId) && is_numeric($loggedInPersonId))
|
||||
{
|
||||
// check if the the user is a student and if the benutzer is active
|
||||
$this->BenutzerModel->addSelect('1');
|
||||
$res = $this->BenutzerModel->loadWhere(["public.tbl_benutzer.person_id" => $loggedInPersonId, "public.tbl_benutzer.aktiv" => TRUE]);
|
||||
if (hasData($res)) return $loggedInPersonId;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Stundenplan extends Auth_Controller
|
||||
class LvPlan extends Auth_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ class Config extends Auth_Controller
|
||||
|
||||
$preset_decoded = json_decode($preset->preset, true);
|
||||
|
||||
$this->DashboardLib->addWidgetsToWidgets($preset_decoded['widgets'], $dashboard_kurzbz, $funktion_kurzbz, $input->widgets);
|
||||
$this->DashboardLib->addWidgetsToWidgets($preset_decoded, $dashboard_kurzbz, $funktion_kurzbz, $input->widgets);
|
||||
|
||||
$preset->preset = json_encode($preset_decoded);
|
||||
|
||||
@@ -92,7 +92,7 @@ class Config extends Auth_Controller
|
||||
}
|
||||
|
||||
$preset_decoded = json_decode($preset->preset, true);
|
||||
if (!$this->DashboardLib->removeWidgetFromWidgets($preset_decoded['widgets'], $funktion_kurzbz, $widgetid))
|
||||
if (!$this->DashboardLib->removeWidgetFromWidgets($preset_decoded, $funktion_kurzbz, $widgetid))
|
||||
{
|
||||
http_response_code(404);
|
||||
$this->terminateWithJsonError('widgetid ' . $widgetid . ' not found');
|
||||
@@ -119,7 +119,7 @@ class Config extends Auth_Controller
|
||||
|
||||
$override_decoded = json_decode($override->override, true);
|
||||
|
||||
$this->DashboardLib->addWidgetsToWidgets($override_decoded['widgets'], $dashboard_kurzbz, $funktion_kurzbz, $input->widgets);
|
||||
$this->DashboardLib->addWidgetsToWidgets($override_decoded, $dashboard_kurzbz, $funktion_kurzbz, $input->widgets);
|
||||
|
||||
$override->override = json_encode($override_decoded);
|
||||
|
||||
@@ -148,7 +148,7 @@ class Config extends Auth_Controller
|
||||
|
||||
$override_decoded = json_decode($override->override, true);
|
||||
|
||||
if (!$this->DashboardLib->removeWidgetFromWidgets($override_decoded['widgets'], $funktion_kurzbz, $widgetid))
|
||||
if (!$this->DashboardLib->removeWidgetFromWidgets($override_decoded, $funktion_kurzbz, $widgetid))
|
||||
{
|
||||
http_response_code(404);
|
||||
$this->terminateWithJsonError('widgetid ' . $widgetid . ' not found');
|
||||
@@ -202,10 +202,10 @@ class Config extends Auth_Controller
|
||||
if ($conf)
|
||||
{
|
||||
$preset = json_decode($conf->preset, true);
|
||||
if (!isset($preset['widgets']) || !isset($preset['widgets'][$funktion]))
|
||||
if (!isset($preset[$funktion]) || !isset($preset[$funktion]['widgets']))
|
||||
$result[$funktion] = [];
|
||||
else
|
||||
$result[$funktion] = $preset['widgets'][$funktion];
|
||||
$result[$funktion] = $preset[$funktion]['widgets'];
|
||||
}
|
||||
else
|
||||
$result[$funktion] = [];
|
||||
|
||||
@@ -95,12 +95,15 @@ class AntragJob extends JOB_Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
$leitung = current(getData($result));
|
||||
if (!isset($stgLeitungen[$leitung->uid]))
|
||||
$leitungen = getData($result);
|
||||
foreach ($leitungen as $leitung)
|
||||
{
|
||||
$stgLeitungen[$leitung->uid] = [ 'Details' => $leitung, 'stgs' => [] ];
|
||||
if (!isset($stgLeitungen[$leitung->uid]))
|
||||
{
|
||||
$stgLeitungen[$leitung->uid] = ['Details' => $leitung, 'stgs' => []];
|
||||
}
|
||||
$stgLeitungen[$leitung->uid]['stgs'][] = $antrag->studiengang_kz;
|
||||
}
|
||||
$stgLeitungen[$leitung->uid]['stgs'][] = $antrag->studiengang_kz;
|
||||
|
||||
$result = $this->StudierendenantragModel->getStgAndSem($antrag->studierendenantrag_id);
|
||||
if (isError($result))
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class MeldezettelJob extends JOB_Controller
|
||||
{
|
||||
const INSERT_VON = 'meldezetteljob';
|
||||
const DOKUMENT_KURZBZ = 'Meldezet';
|
||||
|
||||
private $_ci; // Code igniter instance
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->model('crm/Dokumentprestudent_model', 'DokumentprestudentModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Meldezettel to "accepted" for all students with Meldeadresse.
|
||||
*/
|
||||
public function acceptMeldezettel()
|
||||
{
|
||||
$this->logInfo('Start Meldezettel Job');
|
||||
|
||||
$params = array(self::DOKUMENT_KURZBZ);
|
||||
|
||||
$qry = "
|
||||
-- get all prestudents with meldeadresse, but no accepted Meldezettel
|
||||
SELECT
|
||||
DISTINCT prestudent_id
|
||||
FROM
|
||||
public.tbl_adresse
|
||||
JOIN public.tbl_person USING (person_id)
|
||||
JOIN public.tbl_prestudent ps USING (person_id)
|
||||
WHERE
|
||||
typ = 'm'
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
public.tbl_dokumentprestudent
|
||||
WHERE
|
||||
prestudent_id = ps.prestudent_id
|
||||
AND dokument_kurzbz = ?
|
||||
)";
|
||||
|
||||
// get all prestudents with Meldeadresse and no accpeted Meldezettel
|
||||
$result = $this->_ci->DokumentprestudentModel->execReadOnlyQuery($qry, $params);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
$this->logError(getError($result));
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$prestudents = getData($result);
|
||||
|
||||
foreach ($prestudents as $prestudent)
|
||||
{
|
||||
// set Meldezettel to accepted
|
||||
$result = $this->_ci->DokumentprestudentModel->insert(
|
||||
array(
|
||||
'prestudent_id' => $prestudent->prestudent_id,
|
||||
'dokument_kurzbz' => self::DOKUMENT_KURZBZ,
|
||||
'datum' => date('Y-m-d'),
|
||||
'insertamum' => strftime('%Y-%m-%d %H:%M'),
|
||||
'insertvon' => self::INSERT_VON
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
$this->logError(getError($result));
|
||||
else
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->logInfo('End Meldezettel Job', array('Number of changes ' => $count));
|
||||
}
|
||||
}
|
||||
@@ -371,6 +371,8 @@ class InfoCenter extends Auth_Controller
|
||||
$data[self::ORIGIN_PAGE] = $origin_page;
|
||||
$data[self::PREV_FILTER_ID] = $this->input->get(self::PREV_FILTER_ID);
|
||||
|
||||
$data['studiensemester'] = $this->variablelib->getVar('infocenter_studiensemester');
|
||||
|
||||
$this->load->view('system/infocenter/infocenterDetails.php', $data);
|
||||
}
|
||||
|
||||
@@ -1284,7 +1286,6 @@ class InfoCenter extends Auth_Controller
|
||||
'nachname' => $this->input->post('nachname'),
|
||||
'titelpost' => isEmptyString($this->input->post('titelpost')) ? null : $this->input->post('titelpost'),
|
||||
'gebdatum' => isEmptyString($this->input->post('gebdatum')) ? null : date("Y-m-d", strtotime($this->input->post('gebdatum'))),
|
||||
'svnr' => isEmptyString($this->input->post('svnr')) ? null : $this->input->post('svnr'),
|
||||
'staatsbuergerschaft' => isEmptyString($this->input->post('buergerschaft')) ? null : $this->input->post('buergerschaft'),
|
||||
'geschlecht' => $this->input->post('geschlecht'),
|
||||
'geburtsnation' => isEmptyString($this->input->post('gebnation')) ? null : $this->input->post('gebnation'),
|
||||
@@ -1860,7 +1861,7 @@ class InfoCenter extends Auth_Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all necessary Person data: Stammdaten (name, svnr, contact, ...), Dokumente, Logs and Notizen
|
||||
* Loads all necessary Person data: Stammdaten (name, contact, ...), Dokumente, Logs and Notizen
|
||||
* @param $person_id
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -81,8 +81,11 @@ class FHCAPI_Controller extends Auth_Controller
|
||||
|
||||
// For JSON Requests (as opposed to multipart/form-data) get the $_POST variable from the input stream instead
|
||||
if ($this->input->get_request_header('Content-Type', true) == 'application/json')
|
||||
$_POST = json_decode($this->security->xss_clean($this->input->raw_input_stream), true);
|
||||
elseif (isset($_POST['_jsondata'])) {
|
||||
{
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
}
|
||||
elseif (isset($_POST['_jsondata']))
|
||||
{
|
||||
$_POST = array_merge($_POST, json_decode($_POST['_jsondata'], true));
|
||||
unset($_POST['_jsondata']);
|
||||
}
|
||||
@@ -106,10 +109,15 @@ class FHCAPI_Controller extends Auth_Controller
|
||||
$error = [];
|
||||
|
||||
if (is_array($data)) {
|
||||
if ($type == self::ERROR_TYPE_VALIDATION)
|
||||
if ($type == self::ERROR_TYPE_VALIDATION) {
|
||||
$error['messages'] = $data;
|
||||
else
|
||||
} elseif (array_is_list($data)) {
|
||||
foreach ($data as $d)
|
||||
$this->addError($d, $type);
|
||||
return;
|
||||
} else {
|
||||
$error = $data;
|
||||
}
|
||||
} elseif (is_object($data)) {
|
||||
$error = (array)$data;
|
||||
} else {
|
||||
@@ -223,6 +231,39 @@ class FHCAPI_Controller extends Auth_Controller
|
||||
return $result->retval;
|
||||
}
|
||||
|
||||
protected function terminateWithFileOutput($contenttype, $content, $filename=null)
|
||||
{
|
||||
$this->clearOutputBuffering();
|
||||
$this->output->set_status_header(200)
|
||||
->set_content_type($contenttype)
|
||||
->set_header('Expires: 0')
|
||||
->set_header('Cache-Control: no-store, no-cache, must-revalidate')
|
||||
->set_header('Pragma: public')
|
||||
->set_header('Content-Length: ' . strlen($content));
|
||||
|
||||
if($filename)
|
||||
{
|
||||
$cleanedfilename = preg_replace('/[^a-zA-Z0-9\-_.]/', '_', $filename);
|
||||
$this->output->set_header('Content-Disposition: attachment; filename="'
|
||||
. $cleanedfilename . '"');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->output->set_header('Content-Disposition: inline');
|
||||
}
|
||||
|
||||
$this->output->set_output($content)
|
||||
->_display();
|
||||
exit();
|
||||
}
|
||||
|
||||
private function clearOutputBuffering()
|
||||
{
|
||||
while(ob_get_level() > 0)
|
||||
{
|
||||
ob_end_clean();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Security
|
||||
|
||||
@@ -21,6 +21,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
'loadDokumente' => self::DEFAULT_PERMISSION_R,
|
||||
'getMitarbeiter' => self::DEFAULT_PERMISSION_R,
|
||||
'isBerechtigt' => self::DEFAULT_PERMISSION_R,
|
||||
'getCountNotes' => self::DEFAULT_PERMISSION_R,
|
||||
];
|
||||
|
||||
if(!is_array($permissions))
|
||||
@@ -392,10 +393,10 @@ abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
|
||||
foreach ($result as $doc) {
|
||||
$res = $this->dmslib->removeAll($doc->dms_id);
|
||||
if (isError($result))
|
||||
if (isError($res))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithError(getError($res), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,4 +460,20 @@ abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getCountNotes($person_id)
|
||||
{
|
||||
$this->NotizzuordnungModel->addSelect('COUNT(*) AS anzahl', false);
|
||||
|
||||
$result = $this->NotizzuordnungModel->loadWhere(
|
||||
array('person_id' => $person_id)
|
||||
);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$anzahl = current(getData($result));
|
||||
return $this->terminateWithSuccess($anzahl->anzahl ?: 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,13 +29,36 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
$this->load->model('person/Notiz_model', 'NotizModel');
|
||||
$this->load->model('system/Notiztyp_model', 'NotiztypModel');
|
||||
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
|
||||
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getTag()
|
||||
public function getTag($readonly_tags = null)
|
||||
{
|
||||
$language = $this->_getLanguageIndex();
|
||||
$id = $this->input->get('id');
|
||||
|
||||
if (is_array($readonly_tags) && !isEmptyArray($readonly_tags))
|
||||
{
|
||||
$readonly_tags = $this->_filterTag($readonly_tags, true);
|
||||
|
||||
foreach ($readonly_tags as $key => $tag)
|
||||
{
|
||||
$readonly_tags[$key] = $this->NotizModel->db->escape($tag);
|
||||
}
|
||||
$tags = '(' . implode(',', $readonly_tags) . ')';
|
||||
|
||||
$this->NotizModel->addSelect("
|
||||
CASE
|
||||
WHEN tbl_notiz_typ.typ_kurzbz IN $tags
|
||||
THEN TRUE
|
||||
ELSE FALSE
|
||||
END as readonly
|
||||
");
|
||||
}
|
||||
|
||||
$this->NotizModel->addSelect(
|
||||
"tbl_notiz.titel,
|
||||
tbl_notiz.text,
|
||||
@@ -54,7 +77,7 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
$this->NotizModel->addJoin('public.tbl_benutzer verfasserbenutzer', 'tbl_notiz.verfasser_uid = verfasserbenutzer.uid', 'LEFT');
|
||||
$this->NotizModel->addJoin('public.tbl_person verfasserperson', 'verfasserbenutzer.person_id = verfasserperson.person_id', 'LEFT');
|
||||
|
||||
$this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.verfasser_uid = bearbeiterbenutzer.uid', 'LEFT');
|
||||
$this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.bearbeiter_uid = bearbeiterbenutzer.uid', 'LEFT');
|
||||
$this->NotizModel->addJoin('public.tbl_person bearbeiterperson', 'bearbeiterbenutzer.person_id = bearbeiterperson.person_id', 'LEFT');
|
||||
|
||||
$notiz = $this->NotizModel->loadWhere(array('notiz_id' => $id));
|
||||
@@ -62,7 +85,7 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess(hasData($notiz) ? getData($notiz)[0] : array());
|
||||
}
|
||||
|
||||
public function getTags()
|
||||
public function getTags($tags = null)
|
||||
{
|
||||
$this->NotiztypModel->addSelect(
|
||||
'typ_kurzbz as tag_typ_kurzbz,
|
||||
@@ -73,19 +96,36 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
'
|
||||
);
|
||||
$this->NotiztypModel->addOrder('prioritaet');
|
||||
|
||||
if (is_array($tags) && !isEmptyArray($tags))
|
||||
{
|
||||
$tags = $this->_filterTag($tags, false);
|
||||
$this->NotiztypModel->db->where_in('typ_kurzbz', $tags);
|
||||
}
|
||||
|
||||
$notiztypen = $this->NotiztypModel->loadWhere(array('aktiv' => true));
|
||||
$this->terminateWithSuccess(hasData($notiztypen) ? getData($notiztypen) : array());
|
||||
}
|
||||
|
||||
public function addTag($withZuordnung = true)
|
||||
public function addTag($withZuordnung = true, $updatable_tags = null)
|
||||
{
|
||||
$postData = $this->getPostJson();
|
||||
|
||||
$checkTyp = $this->NotiztypModel->loadWhere(array('typ_kurzbz' => $postData->tag_typ_kurzbz));
|
||||
|
||||
if (!hasData($checkTyp))
|
||||
$this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL);
|
||||
if (isError($checkTyp))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (!hasData($checkTyp))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
|
||||
{
|
||||
$tags = $this->_filterTag($updatable_tags, false);
|
||||
|
||||
if (!in_array($postData->tag_typ_kurzbz, $tags))
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
|
||||
}
|
||||
|
||||
if ($withZuordnung)
|
||||
{
|
||||
@@ -125,48 +165,88 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
}
|
||||
}
|
||||
|
||||
private function addNotiz($postData)
|
||||
{
|
||||
return $this->NotizModel->insert(array(
|
||||
'titel' => 'TAG', //TODO klären
|
||||
'text' => $postData->notiz,
|
||||
'verfasser_uid' => $this->_uid,
|
||||
'erledigt' => false,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => $this->_uid,
|
||||
'typ' => $postData->tag_typ_kurzbz
|
||||
));
|
||||
|
||||
}
|
||||
public function updateTag()
|
||||
public function updateTag($updatable_tags = null)
|
||||
{
|
||||
$postData = $this->getPostJson();
|
||||
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
|
||||
|
||||
if (isError($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (!hasData($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
|
||||
{
|
||||
$tags = $this->_filterTag($updatable_tags, false);
|
||||
|
||||
$post_tag_typ = getData($post_tag)[0]->typ;
|
||||
|
||||
if (!in_array($post_tag_typ, $tags))
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
|
||||
}
|
||||
|
||||
$updateData = $this->NotizModel->update(array('notiz_id' => $postData->id),
|
||||
array('text' => $postData->notiz,
|
||||
'updateamum' => date('Y-m-d H:i:s'),
|
||||
'updatevon' => $this->_uid,
|
||||
'bearbeiter_uid' => $this->_uid,
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->terminateWithSuccess($updateData);
|
||||
}
|
||||
public function doneTag()
|
||||
public function doneTag($updatable_tags = null)
|
||||
{
|
||||
$postData = $this->getPostJson();
|
||||
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
|
||||
|
||||
if (isError($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (!hasData($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
|
||||
{
|
||||
$tags = $this->_filterTag($updatable_tags, false);
|
||||
|
||||
$post_tag_typ = getData($post_tag)[0]->typ;
|
||||
|
||||
if (!in_array($post_tag_typ, $tags))
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
|
||||
}
|
||||
|
||||
$updateData = $this->NotizModel->update(array('notiz_id' => $postData->id),
|
||||
array('erledigt' => !$postData->done,
|
||||
'text' => $postData->notiz,
|
||||
'updateamum' => date('Y-m-d H:i:s'),
|
||||
'updatevon' => $this->_uid,
|
||||
'bearbeiter_uid' => $this->_uid,
|
||||
)
|
||||
);
|
||||
|
||||
$this->terminateWithSuccess($updateData);
|
||||
}
|
||||
|
||||
public function deleteTag($withZuordnung = true)
|
||||
public function deleteTag($withZuordnung = true, $updatable_tags = null)
|
||||
{
|
||||
$postData = $this->getPostJson();
|
||||
$post_tag = $this->NotizModel->loadWhere(array('notiz_id' => $postData->id));
|
||||
|
||||
if (isError($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (!hasData($post_tag))
|
||||
$this->terminateWithError($this->p->t('ui', 'fehlerBeimLesen'));
|
||||
|
||||
if (is_array($updatable_tags) && !isEmptyArray($updatable_tags))
|
||||
{
|
||||
$tags = $this->_filterTag($updatable_tags, false);
|
||||
|
||||
$post_tag_typ = getData($post_tag)[0]->typ;
|
||||
|
||||
if (!in_array($post_tag_typ, $tags))
|
||||
$this->terminateWithError($this->p->t('ui', 'keineBerechtigung'));
|
||||
}
|
||||
|
||||
$deleteNotiz = "";
|
||||
if ($withZuordnung)
|
||||
@@ -208,5 +288,27 @@ class Tag_Controller extends FHCAPI_Controller
|
||||
return hasData($result) ? getData($result)[0]->index : 1;
|
||||
}
|
||||
|
||||
private function _filterTag($tags, $readonly = true)
|
||||
{
|
||||
$filtered_tags = array_filter($tags, function ($tag) use ($readonly)
|
||||
{
|
||||
return isset($tag['readonly']) && $tag['readonly'] === $readonly;
|
||||
});
|
||||
|
||||
return array_keys($filtered_tags);
|
||||
}
|
||||
|
||||
private function addNotiz($postData)
|
||||
{
|
||||
return $this->NotizModel->insert(array(
|
||||
'titel' => 'TAG', //TODO klären
|
||||
'text' => $postData->notiz,
|
||||
'verfasser_uid' => $this->_uid,
|
||||
'erledigt' => false,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => $this->_uid,
|
||||
'typ' => $postData->tag_typ_kurzbz
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -424,6 +424,23 @@ function isValidDate($dateString)
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// PHP functions that don't exist in older versions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the given array is sequential
|
||||
*/
|
||||
if (!function_exists('array_is_list')) {
|
||||
function array_is_list(array $arr)
|
||||
{
|
||||
if ($arr === []) {
|
||||
return true;
|
||||
}
|
||||
return array_keys($arr) === range(0, count($arr) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Collection of utility functions for form validation purposes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -88,6 +88,7 @@ function generateCSSsInclude($CSSs)
|
||||
function generateJSDataStorageObject($indexPage, $calledPath, $calledMethod)
|
||||
{
|
||||
$ci =& get_instance();
|
||||
$ci->load->config('theme');
|
||||
$ci->load->model('system/Sprache_model','SpracheModel');
|
||||
$server_language = getData($ci->SpracheModel->loadWhere(['content' => true]));
|
||||
$server_language = array_map(function($language){
|
||||
@@ -107,6 +108,10 @@ function generateJSDataStorageObject($indexPage, $calledPath, $calledMethod)
|
||||
'user_language' => $user_language,
|
||||
'timezone' => date_default_timezone_get(),
|
||||
'systemerror_mailto' => $systemerror_mailto,
|
||||
'theme' => [
|
||||
'name'=>$ci->config->item('theme_name'),
|
||||
'modes'=>$ci->config->item('theme_modes'),
|
||||
]
|
||||
);
|
||||
|
||||
$toPrint = "\n";
|
||||
@@ -231,3 +236,13 @@ function generateBackwardCompatibleJSMsIe($js)
|
||||
echo "<![endif]-->\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an accessibility skipLink https://www.w3schools.com/accessibility/accessibility_skip_links.php
|
||||
*/
|
||||
function generateSkipLink($skipID)
|
||||
{
|
||||
$toPrint = '<a id="skiplink" href="';
|
||||
$toPrint.=$skipID;
|
||||
$toPrint.='" class="fhcSkipLink" aria-label="Skip to main content"></a>';
|
||||
echo $toPrint;
|
||||
}
|
||||
|
||||
@@ -670,7 +670,7 @@ class DmsLib
|
||||
$fileObj = new stdClass();
|
||||
$fileObj->filename = getData($result)[0]->filename;
|
||||
$fileObj->file = DMS_PATH.getData($result)[0]->filename;
|
||||
$fileObj->name = DMS_PATH.getData($result)[0]->name; // original user filename
|
||||
$fileObj->name = getData($result)[0]->name; // original user filename
|
||||
$fileObj->mimetype = getData($result)[0]->mimetype;
|
||||
|
||||
return success($fileObj);
|
||||
|
||||
@@ -55,7 +55,7 @@ use SimpleXMLElement as SimpleXMLElement;
|
||||
* $doc->create($outputformat);
|
||||
* $doc->output(true);
|
||||
* $doc->close();
|
||||
*
|
||||
*
|
||||
* New:
|
||||
* $xml_data = $this->documentexportlib->getDataXML($data);
|
||||
* $images = [[
|
||||
@@ -397,20 +397,24 @@ class DocumentExportLib
|
||||
$vorlage_stg = current(getData($result));
|
||||
foreach ($vorlage_stg as $k => $v)
|
||||
$vorlage->$k = $v;
|
||||
|
||||
|
||||
if ($sign_user)
|
||||
{
|
||||
$this->addSignToData($xml_data);
|
||||
}
|
||||
|
||||
$result = $this->create($temp_folder, $outputformat, $vorlage, $xml_data, $images);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
$temp_filename = getData($result);
|
||||
|
||||
if ($sign_user) {
|
||||
$this->addSignToData($xml_data);
|
||||
|
||||
if ($sign_user)
|
||||
{
|
||||
$result = $this->sign($temp_folder, $temp_filename, $outputformat, $sign_user, $sign_profile);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
|
||||
$temp_filename = getData($result);
|
||||
}
|
||||
|
||||
@@ -445,6 +449,7 @@ class DocumentExportLib
|
||||
if ($xml_data->firstChild->tagName == 'error')
|
||||
return error($xml_data->firstChild->textContent);
|
||||
|
||||
$styles_xsl = null;
|
||||
// styles.xml erstellen
|
||||
if ($vorlage->style) {
|
||||
$styles_xsl = new DOMDocument();
|
||||
@@ -461,7 +466,7 @@ class DocumentExportLib
|
||||
// Template holen
|
||||
$vorlage_found = false;
|
||||
$vorlage_filename = $vorlage->vorlage_kurzbz . ($vorlage->mimetype == 'application/vnd.oasis.opendocument.spreadsheet' ? '.ods' : '.odt');
|
||||
|
||||
|
||||
$aktive_addons = array_filter(array_map('trim', explode(";", ACTIVE_ADDONS)));
|
||||
foreach($aktive_addons as $addon) {
|
||||
$zipfile = DOC_ROOT . 'addons/' . $addon . '/system/vorlage_zip/' . $vorlage_filename;
|
||||
@@ -652,7 +657,7 @@ class DocumentExportLib
|
||||
foreach ($files as $file)
|
||||
if (is_file($file))
|
||||
unlink($file);
|
||||
|
||||
|
||||
chdir($source_folder);
|
||||
rmdir($temp_folder);
|
||||
}
|
||||
@@ -703,12 +708,12 @@ class DocumentExportLib
|
||||
{
|
||||
if ($outputformat)
|
||||
return $outputformat;
|
||||
|
||||
|
||||
if ($mimetype == 'application/vnd.oasis.opendocument.spreadsheet')
|
||||
return 'ods';
|
||||
if ($mimetype == 'application/vnd.oasis.opendocument.text')
|
||||
return 'odt';
|
||||
|
||||
|
||||
return 'pdf';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2022 fhcomplete.org
|
||||
* Copyright (C) 2025 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
|
||||
@@ -177,7 +177,7 @@ class FilterCmptLib
|
||||
$session = $this->getSession();
|
||||
|
||||
// If session is NOT empty -> a filter was already loaded
|
||||
if ($session != null)
|
||||
if (!isError($session) && $session != null)
|
||||
{
|
||||
// Retrieve the filterId stored in the session
|
||||
$sessionFilterId = $this->_getSessionElement(FilterCmptLib::FILTER_ID);
|
||||
@@ -219,9 +219,7 @@ class FilterCmptLib
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the session is empty -> first time that this filter is loaded
|
||||
if ($session == null)
|
||||
else
|
||||
{
|
||||
// Load filter definition data from DB
|
||||
$definition = $this->_loadDefinition(
|
||||
@@ -602,7 +600,7 @@ class FilterCmptLib
|
||||
{
|
||||
$session = getSessionElement(self::SESSION_NAME, $this->_filterUniqueId);
|
||||
|
||||
if (isset($session[$name]))
|
||||
if (!isError($session) && isset($session[$name]))
|
||||
{
|
||||
return $session[$name];
|
||||
}
|
||||
@@ -623,7 +621,7 @@ class FilterCmptLib
|
||||
|
||||
if (!$this->_ci->permissionlib->hasAtLeastOne($this->_requiredPermissions, self::PERMISSION_FILTER_METHOD, self::PERMISSION_TYPE))
|
||||
{
|
||||
$this->_setSession(error('The required permission is not help by the logged user'));
|
||||
$this->_setSession(error('The required permission is not held by the logged user'));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -904,7 +902,7 @@ class FilterCmptLib
|
||||
$filterCmptsSession = getSession(self::SESSION_NAME);
|
||||
|
||||
// If something is present in session
|
||||
if ($filterCmptsSession != null)
|
||||
if (!isError($filterCmptsSession) && $filterCmptsSession != null)
|
||||
{
|
||||
// Loops in the session for all the filter components
|
||||
foreach ($filterCmptsSession as $filterCmpt => $filterCmptData)
|
||||
@@ -951,9 +949,11 @@ class FilterCmptLib
|
||||
{
|
||||
$session = getSessionElement(self::SESSION_NAME, $this->_filterUniqueId);
|
||||
|
||||
$session[$name] = $value;
|
||||
|
||||
setSessionElement(self::SESSION_NAME, $this->_filterUniqueId, $session); // stores the single value
|
||||
if (!isError($session) && $session != null)
|
||||
{
|
||||
$session[$name] = $value;
|
||||
setSessionElement(self::SESSION_NAME, $this->_filterUniqueId, $session); // stores the single value
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -965,7 +965,7 @@ class FilterCmptLib
|
||||
$filterCmptsSession = getSession(self::SESSION_NAME);
|
||||
|
||||
// If something is present in session
|
||||
if ($filterCmptsSession != null)
|
||||
if (!isError($filterCmptsSession) && $filterCmptsSession != null)
|
||||
{
|
||||
// Loops in the session for all the filter components
|
||||
foreach ($filterCmptsSession as $filterCmpt => $filterCmptData)
|
||||
@@ -1174,3 +1174,4 @@ class FilterCmptLib
|
||||
return $filterName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,342 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class LektorLib
|
||||
{
|
||||
private $_ci; // Code igniter instance
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
$this->_ci->load->model('education/lehreinheit_model', 'LehreinheitModel');
|
||||
$this->_ci->load->model('education/Lehreinheitmitarbeiter_model', 'LehreinheitmitarbeiterModel');
|
||||
$this->_ci->load->model('organisation/Studiensemester_model','StudiensemesterModel');
|
||||
$this->_ci->load->model('ressource/Stundensatz_model', 'StundensatzModel');
|
||||
$this->_ci->load->model('vertragsbestandteil/Dienstverhaeltnis_model','DienstverhaeltnisModel');
|
||||
$this->_ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
|
||||
$this->_ci->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->_ci->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
}
|
||||
|
||||
public function addLektorToLehreinheit($lehreinheit_id, $mitarbeiter_uid)
|
||||
{
|
||||
$this->_ci->LehreinheitModel->addSelect('tbl_lehreinheit.*, tbl_lehrveranstaltung.studiengang_kz, semesterstunden');
|
||||
$this->_ci->LehreinheitModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id');
|
||||
$lehreinheit_result = $this->_ci->LehreinheitModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id));
|
||||
|
||||
if (isError($lehreinheit_result)) return $lehreinheit_result;
|
||||
|
||||
if (!hasData($lehreinheit_result)) return error("Lehreinheit not found");
|
||||
|
||||
$lehreinheit = getData($lehreinheit_result)[0];
|
||||
|
||||
$already_assigned = $this->_ci->LehreinheitmitarbeiterModel->loadWhere(array('lehreinheit_id' => $lehreinheit->lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid));
|
||||
|
||||
if (isError($already_assigned)) return $already_assigned;
|
||||
|
||||
if (hasData($already_assigned)) return error('Lektor already assigned');
|
||||
|
||||
$studiensemester_result = $this->_ci->StudiensemesterModel->loadWhere(array('studiensemester_kurzbz' => $lehreinheit->studiensemester_kurzbz));
|
||||
if (isError($studiensemester_result)) return $studiensemester_result;
|
||||
$studiensemester = getData($studiensemester_result)[0];
|
||||
|
||||
$stundensatz = $this->_ci->StundensatzModel->getDefaultStundensatz($mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'lehre');
|
||||
$echter_dv_result = $this->_ci->DienstverhaeltnisModel->existsDienstverhaeltnis($mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'echterdv');
|
||||
|
||||
$echter_dv = false;
|
||||
|
||||
if (hasData($echter_dv_result))
|
||||
{
|
||||
$echter_dv = true;
|
||||
}
|
||||
|
||||
$maxstunden = $this->getMaxStunden($mitarbeiter_uid, $studiensemester->studiensemester_kurzbz, $lehreinheit->studiengang_kz, $echter_dv);
|
||||
|
||||
$newData['semesterstunden'] = 0;
|
||||
$newData['planstunden'] = 0;
|
||||
if (!is_null($lehreinheit->semesterstunden))
|
||||
{
|
||||
$newData['semesterstunden'] = min($lehreinheit->semesterstunden, $maxstunden);
|
||||
$newData['planstunden'] = min($lehreinheit->semesterstunden, $maxstunden);
|
||||
}
|
||||
|
||||
$newData['lehreinheit_id'] = $lehreinheit->lehreinheit_id;
|
||||
$newData['mitarbeiter_uid'] = $mitarbeiter_uid;
|
||||
$newData['lehrfunktion_kurzbz'] = 'Lektor';
|
||||
$newData['bismelden'] = true;
|
||||
$newData['insertvon'] = getAuthUID();
|
||||
$newData['insertamum'] = date('Y-m-d H:i:s');
|
||||
$newData['stundensatz'] = $stundensatz;
|
||||
$result = $this->_ci->LehreinheitmitarbeiterModel->insert($newData);
|
||||
|
||||
if (isError($result)) return $result;
|
||||
|
||||
return success("Lektor added successfully");
|
||||
}
|
||||
|
||||
public function updateLektorFromLehreinheit($lehreinheit_id, $mitarbeiter_uid, $new_data)
|
||||
{
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addSelect('lehre.tbl_lehreinheitmitarbeiter.*, lehre.tbl_lehreinheit.studiensemester_kurzbz, tbl_lehrveranstaltung.studiengang_kz');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehreinheit', 'lehreinheit_id');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id');
|
||||
$lehreinheit_result = $this->_ci->LehreinheitmitarbeiterModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid));
|
||||
|
||||
if (isError($lehreinheit_result)) return $lehreinheit_result;
|
||||
|
||||
if (!hasData($lehreinheit_result)) return error("Lehreinheit not found");
|
||||
|
||||
$lehreinheit = getData($lehreinheit_result)[0];
|
||||
|
||||
//TODO kollision check, wird vorerst nicht implementiert -> nur über das FAS möglich
|
||||
if (isset($new_data['mitarbeiter_uid']) && $new_data['mitarbeiter_uid'] !== $mitarbeiter_uid)
|
||||
{
|
||||
$this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel');
|
||||
$this->_ci->StundenplandevModel->addGroupBy('stundenplandev_id');
|
||||
$this->_ci->StundenplandevModel->addGroupBy('mitarbeiter_uid');
|
||||
$this->_ci->StundenplandevModel->addGroupBy('mitarbeiter_uid');
|
||||
$verplant = $this->_ci->StundenplandevModel->loadWhere(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid));
|
||||
|
||||
if (hasData($verplant))
|
||||
return error('Wechsel vom Mitarbeiter nicht möglich da er bereits verplant ist!');
|
||||
}
|
||||
$warning = '';
|
||||
if (isset($new_data['semesterstunden']))
|
||||
{
|
||||
$studiengang_result = $this->_ci->StudiengangModel->loadWhere(array('studiengang_kz' => $lehreinheit->studiengang_kz));
|
||||
if (isError($studiengang_result)) return $studiengang_result;
|
||||
if (!hasData($studiengang_result)) return error('Studiengang not found');
|
||||
$studiengang = getData($studiengang_result)[0];
|
||||
|
||||
$studiensemester_result = $this->_ci->StudiensemesterModel->loadWhere(array('studiensemester_kurzbz' => $lehreinheit->studiensemester_kurzbz));
|
||||
if (isError($studiensemester_result)) return $studiensemester_result;
|
||||
$studiensemester = getData($studiensemester_result)[0];
|
||||
|
||||
$echter_dv_result = $this->_ci->DienstverhaeltnisModel->existsDienstverhaeltnis($mitarbeiter_uid, $studiensemester->start, $studiensemester->ende, 'echterdv');
|
||||
|
||||
$echter_dv = false;
|
||||
|
||||
if (hasData($echter_dv_result))
|
||||
{
|
||||
$echter_dv = true;
|
||||
}
|
||||
|
||||
$neue_stunden_eingerechnet = isset($new_data['bismelden']) ? $new_data['bismelden'] : $lehreinheit->bismelden;
|
||||
$alte_stunden_eingerechnet = $lehreinheit->bismelden;
|
||||
|
||||
if (($new_data['semesterstunden'] > $lehreinheit->semesterstunden) || $neue_stunden_eingerechnet)
|
||||
{
|
||||
$stundengrenze_result = $this->_ci->OrganisationseinheitModel->getStundengrenze($studiengang->oe_kurzbz, $echter_dv);
|
||||
if (isError($stundengrenze_result)) return $stundengrenze_result;
|
||||
|
||||
$stundengrenze = getData($stundengrenze_result)[0];
|
||||
|
||||
$oe_result = $this->_ci->OrganisationseinheitModel->getChilds($stundengrenze->oe_kurzbz);
|
||||
$oe_array = hasData($oe_result) ? array_column(getData($oe_result), 'oe_kurzbz') : array('');
|
||||
|
||||
if ($alte_stunden_eingerechnet && $neue_stunden_eingerechnet)
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addSelect("(SUM(tbl_lehreinheitmitarbeiter.semesterstunden) - ($lehreinheit->semesterstunden) + {$this->_ci->LehreinheitmitarbeiterModel->db->escape($new_data['semesterstunden'])}) as summe");
|
||||
else if ($alte_stunden_eingerechnet && !$neue_stunden_eingerechnet)
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addSelect("(SUM(tbl_lehreinheitmitarbeiter.semesterstunden) - ($lehreinheit->semesterstunden)) as summe");
|
||||
else if (!$alte_stunden_eingerechnet && $neue_stunden_eingerechnet)
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addSelect("(SUM(tbl_lehreinheitmitarbeiter.semesterstunden) + ({$this->_ci->LehreinheitmitarbeiterModel->db->escape($new_data['semesterstunden'])})) as summe");
|
||||
else if (!$alte_stunden_eingerechnet && !$neue_stunden_eingerechnet)
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addSelect("(SUM(tbl_lehreinheitmitarbeiter.semesterstunden)) as summe");
|
||||
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehreinheit', 'lehreinheit_id');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('public.tbl_studiengang', 'studiengang_kz');
|
||||
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('mitarbeiter_uid', (isset($new_data['mitarbeiter_uid']) ? $new_data['mitarbeiter_uid'] : $mitarbeiter_uid));
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('studiensemester_kurzbz', $lehreinheit->studiensemester_kurzbz);
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('bismelden', true);
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('lower(mitarbeiter_uid) NOT LIKE', '_dummy%');
|
||||
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where_in('tbl_studiengang.oe_kurzbz', $oe_array);
|
||||
|
||||
|
||||
if(defined('FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE')
|
||||
&& is_array(FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE)
|
||||
&& count(FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE) > 0)
|
||||
{
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where_not_in('tbl_studiengang.oe_kurzbz', FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE);
|
||||
}
|
||||
|
||||
$summe_result = $this->_ci->LehreinheitmitarbeiterModel->load();
|
||||
|
||||
if (isError($summe_result)) return $summe_result;
|
||||
|
||||
if (!hasData($summe_result)) return error('Fehler beim Ermitteln der Gesamtstunden');
|
||||
|
||||
$summe = getData($summe_result)[0]->summe;
|
||||
|
||||
if ($summe > $stundengrenze->stunden)
|
||||
{
|
||||
|
||||
if (!$echter_dv && (!$this->_ci->permissionlib->isBerechtigt('admin')))
|
||||
{
|
||||
if (!$this->LehrauftragAufFirma(isset($formData['mitarbeiter_uid']) ? $formData['mitarbeiter_uid'] : $mitarbeiter_uid))
|
||||
return error("ACHTUNG: Die maximal erlaubte Semesterstundenanzahl des Lektors von $summe Stunden ($stundengrenze->stunden) wurde ueberschritten!\nDaten wurden NICHT gespeichert!\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$warning .= "ACHTUNG: Die maximal erlaubte Semesterstundenanzahl des Lektors von $summe Stunden ($stundengrenze->stunden) wurde ueberschritten!\nDaten wurden gespeichert!\n\n";
|
||||
}
|
||||
|
||||
$stunden_limit_result = $this->getStundenInstitut($mitarbeiter_uid, $lehreinheit->studiensemester_kurzbz, $oe_array);
|
||||
|
||||
if (hasData($stunden_limit_result))
|
||||
{
|
||||
$stunden_limit_array = getData($stunden_limit_result);
|
||||
foreach ($stunden_limit_array as $stunden_limit)
|
||||
{
|
||||
$warning .= $stunden_limit->summe . ' Stunden ' . $stunden_limit->bezeichnung . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$benutzer_result = $this->_ci->BenutzerModel->load(array(isset($formData['mitarbeiter_uid']) ? $formData['mitarbeiter_uid'] : $mitarbeiter_uid));
|
||||
|
||||
if (isError($benutzer_result)) return $benutzer_result;
|
||||
|
||||
if (!hasData($benutzer_result)) return error('Benutzer not found');
|
||||
|
||||
$benutzer_aktiv = getData($benutzer_result)[0]->aktiv;
|
||||
|
||||
if (!$benutzer_aktiv)
|
||||
$warning .= "Achtung: Der/Die Benutzer*in ist inaktiv!\nBitte informieren Sie die Personalbteilung.\nDaten wurden gespeichert.\n\n";
|
||||
|
||||
$updatableFields = array(
|
||||
'semesterstunden',
|
||||
'planstunden',
|
||||
'stundensatz',
|
||||
'faktor',
|
||||
'anmerkung',
|
||||
'lehrfunktion_kurzbz',
|
||||
'mitarbeiter_uid',
|
||||
'bismelden'
|
||||
);
|
||||
|
||||
$updateData = array();
|
||||
foreach ($updatableFields as $field)
|
||||
{
|
||||
$value = isset($new_data[$field]) ? $new_data[$field] : null;
|
||||
|
||||
if ($value !== null)
|
||||
{
|
||||
$updateData[$field] = $value;
|
||||
}
|
||||
}
|
||||
$updateData['updatevon'] = getAuthUID();
|
||||
$updateData['updateamum'] = date('Y-m-d H:i:s');
|
||||
|
||||
$result = $this->_ci->LehreinheitmitarbeiterModel->update(array('lehreinheit_id' => $lehreinheit_id, 'mitarbeiter_uid' => $mitarbeiter_uid), $updateData);
|
||||
|
||||
if (isError($result)) return $result;
|
||||
|
||||
if ($warning !== '') return success(['warning' => $warning]);
|
||||
|
||||
return success('Erfolgreich geupdated');
|
||||
}
|
||||
|
||||
private function getMaxStunden($mitarbeiter_uid, $studiensemester_kurzbz, $studiengang_kz, $echter_dv)
|
||||
{
|
||||
$maxstunden = 9999;
|
||||
|
||||
$studiengang_result = $this->_ci->StudiengangModel->loadWhere(array('studiengang_kz' => $studiengang_kz));
|
||||
if (isError($studiengang_result)) return $studiengang_result;
|
||||
|
||||
$studiengang = getData($studiengang_result)[0];
|
||||
|
||||
$stundengrenze_result = $this->_ci->OrganisationseinheitModel->getStundengrenze($studiengang->oe_kurzbz, $echter_dv);
|
||||
if (isError($stundengrenze_result)) return $stundengrenze_result;
|
||||
|
||||
$stundengrenze = getData($stundengrenze_result)[0];
|
||||
$maxstunden = $stundengrenze->stunden;
|
||||
|
||||
$lehrauftrag_firma = $this->LehrauftragAufFirma($mitarbeiter_uid);
|
||||
|
||||
if (!$echter_dv && !$lehrauftrag_firma)
|
||||
{
|
||||
$oe_result = $this->_ci->OrganisationseinheitModel->getChilds($stundengrenze->oe_kurzbz);
|
||||
$oe_array = hasData($oe_result) ? array_column(getData($oe_result), 'oe_kurzbz') : array('');
|
||||
|
||||
$stunden_summe_result = $this->getSumSemesterstunden($mitarbeiter_uid, $studiensemester_kurzbz, $oe_array);
|
||||
|
||||
$stunden_summe = hasData($stunden_summe_result) ? getData($stunden_summe_result)[0]->summe : 0;
|
||||
|
||||
if ($stunden_summe >= $maxstunden && (!$this->_ci->permissionlib->isBerechtigt('admin')))
|
||||
{
|
||||
$stunden_limit_result = $this->getStundenInstitut($mitarbeiter_uid, $studiensemester_kurzbz, $oe_array);
|
||||
|
||||
$error = "ACHTUNG: Die maximal erlaubte Semesterstundenanzahl des Lektors von $maxstunden Stunden ($stundengrenze->oe_kurzbz) wurde ueberschritten!\n
|
||||
Daten wurden NICHT gespeichert!\n\n";
|
||||
|
||||
if (hasData($stunden_limit_result))
|
||||
{
|
||||
$stunden_limit_array = getData($stunden_limit_result);
|
||||
|
||||
foreach ($stunden_limit_array as $stunden_limit)
|
||||
{
|
||||
$error .= $stunden_limit->summe . ' Stunden ' . $stunden_limit->bezeichnung . "\n";
|
||||
}
|
||||
}
|
||||
return error($error);
|
||||
}
|
||||
else
|
||||
$maxstunden =- $stunden_summe;
|
||||
}
|
||||
return $maxstunden;
|
||||
}
|
||||
|
||||
private function LehrauftragAufFirma($mitarbeiter_uid)
|
||||
{
|
||||
$this->_ci->MitarbeiterModel->addJoin('tbl_benutzer', 'tbl_mitarbeiter.mitarbeiter_uid = tbl_benutzer.uid');
|
||||
$this->_ci->MitarbeiterModel->addJoin('tbl_person', 'person_id');
|
||||
$this->_ci->MitarbeiterModel->addJoin('tbl_adresse', 'person_id', 'LEFT');
|
||||
$this->_ci->MitarbeiterModel->addOrder('zustelladresse', 'DESC');
|
||||
$this->_ci->MitarbeiterModel->addOrder('firma_id');
|
||||
$this->_ci->MitarbeiterModel->addLimit(1);
|
||||
$firma_result = $this->_ci->MitarbeiterModel->loadWhere(array('mitarbeiter_uid' => $mitarbeiter_uid));
|
||||
$firma = getData($firma_result)[0]->firma_id;
|
||||
return !is_null($firma);
|
||||
}
|
||||
|
||||
private function getSumSemesterstunden($mitarbeiter_uid, $studiensemester_kurzbz, $oe_array = array())
|
||||
{
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addSelect('SUM(tbl_lehreinheitmitarbeiter.semesterstunden) as summe');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehreinheit', 'lehreinheit_id');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('public.tbl_studiengang', 'studiengang_kz');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('mitarbeiter_uid', $mitarbeiter_uid);
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('studiensemester_kurzbz', $studiensemester_kurzbz);
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('bismelden', true);
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('lower(mitarbeiter_uid) NOT LIKE', '_dummy%');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where_in('tbl_studiengang.oe_kurzbz', $oe_array);
|
||||
return $this->_ci->LehreinheitmitarbeiterModel->load();
|
||||
}
|
||||
|
||||
private function getStundenInstitut($mitarbeiter_uid, $studiensemester_kurzbz, $oe_array = array())
|
||||
{
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addSelect('SUM(tbl_lehreinheitmitarbeiter.semesterstunden) as summe, tbl_studiengang.bezeichnung');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehreinheit', 'lehreinheit_id');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addJoin('public.tbl_studiengang', 'studiengang_kz');
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('mitarbeiter_uid', $mitarbeiter_uid);
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('studiensemester_kurzbz', $studiensemester_kurzbz);
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where('bismelden', true);
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where_in('tbl_studiengang.oe_kurzbz', $oe_array);
|
||||
|
||||
if(defined('FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE')
|
||||
&& is_array(FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE)
|
||||
&& count(FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE) > 0)
|
||||
{
|
||||
$this->_ci->LehreinheitmitarbeiterModel->db->where_not_in('tbl_studiengang.oe_kurzbz', FAS_LV_LEKTORINNENZUTEILUNG_STUNDEN_IGNORE_OE);
|
||||
}
|
||||
|
||||
$this->_ci->LehreinheitmitarbeiterModel->addGroupBy('tbl_studiengang.bezeichnung');
|
||||
return $this->_ci->LehreinheitmitarbeiterModel->load();
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,7 @@ class PhrasesLib
|
||||
$tmpText = substr($tmpText, 0, strlen($tmpText) - 4);
|
||||
}
|
||||
}
|
||||
$tmpText = str_replace(['<span class="caps">', '</span>'], '', $tmpText);
|
||||
|
||||
$result->retval[$i]->text = $tmpText;
|
||||
}
|
||||
|
||||
@@ -500,11 +500,6 @@ class PrestudentLib
|
||||
|
||||
$student = current(getData($result));
|
||||
|
||||
|
||||
$this->_ci->load->library('VariableLib', ['uid' => $authUID]);
|
||||
$semester_aktuell = $this->_ci->variablelib->getVar('semester_aktuell');
|
||||
|
||||
|
||||
// Update Aktionen
|
||||
|
||||
// Status updaten
|
||||
@@ -545,8 +540,8 @@ class PrestudentLib
|
||||
// Studentlehrverband updaten
|
||||
$result = $this->_ci->StudentlehrverbandModel->update([
|
||||
'student_uid' => $student->student_uid,
|
||||
'studiensemester_kurzbz' => $semester_aktuell
|
||||
], [
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
], [
|
||||
'semester' => $ausbildungssemester,
|
||||
'verband' => '',
|
||||
'gruppe' => '',
|
||||
|
||||
@@ -0,0 +1,609 @@
|
||||
<?php
|
||||
|
||||
if (! defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class ProfilLib{
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci =& get_instance();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getView($uid)
|
||||
{
|
||||
// loading required models
|
||||
$this->ci->load->model("ressource/Mitarbeiter_model","MitarbeiterModel");
|
||||
$this->ci->load->model("person/Person_model","PersonModel");
|
||||
|
||||
$res = new stdClass();
|
||||
|
||||
// checking the uid
|
||||
if ($uid == getAuthUID()) {
|
||||
$isMitarbeiter = $this->ci->MitarbeiterModel->isMitarbeiter(getAuthUID());
|
||||
if(isError($isMitarbeiter))
|
||||
{
|
||||
return error(getData($isMitarbeiter));
|
||||
}
|
||||
$isMitarbeiter = getData($isMitarbeiter);
|
||||
if ($isMitarbeiter) {
|
||||
$res->view = "MitarbeiterProfil";
|
||||
$res->data = $this->mitarbeiterProfil();
|
||||
$res->data->pid = getAuthPersonId();
|
||||
} else {
|
||||
$res->view = "StudentProfil";
|
||||
$res->data = $this->studentProfil();
|
||||
$res->data->pid = getAuthPersonId();
|
||||
}
|
||||
$res->data->fotoStatus=$this->isFotoAkzeptiert(getAuthPersonId());
|
||||
}
|
||||
// UID is availabe when accessing Profil/View/:uid
|
||||
else {
|
||||
$isMitarbeiter = $this->ci->MitarbeiterModel->isMitarbeiter($uid);
|
||||
if(isError($isMitarbeiter))
|
||||
{
|
||||
return error(getData($isMitarbeiter));
|
||||
}
|
||||
$isMitarbeiter = getData($isMitarbeiter);
|
||||
if ($isMitarbeiter) {
|
||||
$res->view = "ViewMitarbeiterProfil";
|
||||
$res->data = $this->viewMitarbeiterProfil($uid);
|
||||
|
||||
} else {
|
||||
$res->view = "ViewStudentProfil";
|
||||
$res->data = $this->viewStudentProfil($uid);
|
||||
}
|
||||
}
|
||||
|
||||
return success($res);
|
||||
}
|
||||
|
||||
//PRIVATE METHODS ###############################################
|
||||
|
||||
/**
|
||||
* function that returns the data used for the student profile
|
||||
* @access private
|
||||
* @return stdClass student data
|
||||
*/
|
||||
private function studentProfil()
|
||||
{
|
||||
$pid = getAuthPersonId();
|
||||
$uid = getAuthUID();
|
||||
$betriebsmittelperson_res = $this->getBetriebsmittelInfo($pid);
|
||||
$kontakte_res = $this->getKontaktInfo($pid);
|
||||
$zutrittskarte_ausgegebenam = $this->getZutrittskarteDatum($uid);
|
||||
$adresse_res = $this->getAdressenInfo($pid);
|
||||
$mailverteiler_res = $this->getMailverteiler($uid);
|
||||
$person_res = $this->getPersonInfo($uid, true);
|
||||
$zutrittsgruppe_res = $this->getZutrittsgruppen($uid);
|
||||
$student_res = $this->getStudentInfo($uid);
|
||||
$matr_res = $this->getMatrikelNummer($uid);
|
||||
$profilUpdates = $this->getProfilUpdates($uid);
|
||||
|
||||
$res = new stdClass();
|
||||
$res->username = $uid;
|
||||
|
||||
//? Person Information
|
||||
foreach ($person_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
//? Student Information
|
||||
foreach ($student_res as $key => $value) {
|
||||
$res->$key = trim($value);
|
||||
}
|
||||
|
||||
$intern_email = array();
|
||||
$intern_email["type"] = "intern";
|
||||
$intern_email["email"] = DOMAIN? $uid . "@" . DOMAIN :"";
|
||||
|
||||
$res->emails = [$intern_email];
|
||||
$res->adressen = $adresse_res;
|
||||
$res->zutrittsdatum = $zutrittskarte_ausgegebenam;
|
||||
$res->kontakte = $kontakte_res;
|
||||
$res->mittel = $betriebsmittelperson_res;
|
||||
$res->matrikelnummer = $matr_res->matr_nr;
|
||||
$res->zuttritsgruppen = $zutrittsgruppe_res;
|
||||
$res->mailverteiler = $mailverteiler_res;
|
||||
$res->profilUpdates = $profilUpdates;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* function that returns the data used for the mitarbeiter profile
|
||||
* @access private
|
||||
* @return stdClass mitarbeiter data
|
||||
*/
|
||||
private function mitarbeiterProfil()
|
||||
{
|
||||
$pid = getAuthPersonId();
|
||||
$uid = getAuthUID();
|
||||
$zutrittskarte_ausgegebenam = $this->getZutrittskarteDatum($uid);
|
||||
$adresse_res = $this->getAdressenInfo($pid);
|
||||
$kontakte_res = $this->getKontaktInfo($pid);
|
||||
$mailverteiler_res = $this->getMailverteiler($uid);
|
||||
$person_res = $this->getPersonInfo($uid, true);
|
||||
$benutzer_funktion_res = $this->getBenutzerFunktion($uid);
|
||||
$betriebsmittelperson_res = $this->getBetriebsmittelInfo($pid);
|
||||
$profilUpdates = $this->getProfilUpdates($uid);
|
||||
$telefon_res = $this->getTelefonInfo($uid);
|
||||
$mitarbeiter_res = $this->getMitarbeiterInfo($uid);
|
||||
|
||||
$res = new stdClass();
|
||||
$res->username = $uid;
|
||||
|
||||
//? Person Information
|
||||
foreach ($person_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
//? Mitarbeiter Information
|
||||
foreach ($mitarbeiter_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
$res->adressen = $adresse_res;
|
||||
$res->zutrittsdatum = $zutrittskarte_ausgegebenam;
|
||||
$res->kontakte = $kontakte_res;
|
||||
$res->mittel = $betriebsmittelperson_res;
|
||||
$res->mailverteiler = $mailverteiler_res;
|
||||
|
||||
$intern_email = array();
|
||||
$intern_email["type"] = "intern";
|
||||
$intern_email["email"] = DOMAIN? $uid . "@" . DOMAIN : "";
|
||||
$extern_email = array();
|
||||
$extern_email["type"] = "alias";
|
||||
|
||||
$extern_email["email"] = $mitarbeiter_res->alias? ($mitarbeiter_res->alias . "@" . DOMAIN) : null;
|
||||
$res->emails = $extern_email["email"]?[$intern_email, $extern_email]:[$intern_email];
|
||||
|
||||
$res->funktionen = $benutzer_funktion_res;
|
||||
$res->standort_telefon = $telefon_res;
|
||||
$res->profilUpdates = $profilUpdates;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the date of issue of the FH access card corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the date of issue of the FH access card
|
||||
* @return string the date of issue of the FH access card corresponding to a userID
|
||||
*/
|
||||
private function getZutrittskarteDatum($uid)
|
||||
{
|
||||
$this->ci->load->model("ressource/Betriebsmittelperson_model","BetriebsmittelpersonModel");
|
||||
$zutrittskarte_ausgegebenam = $this->ci->BetriebsmittelpersonModel->getBetriebsmittelByUid($uid, "Zutrittskarte");
|
||||
|
||||
if(isError($zutrittskarte_ausgegebenam)){
|
||||
return error(getData($zutrittskarte_ausgegebenam));
|
||||
}
|
||||
$zutrittskarte_ausgegebenam = getData($zutrittskarte_ausgegebenam);
|
||||
$zutrittskarte_ausgegebenam = $zutrittskarte_ausgegebenam ? current($zutrittskarte_ausgegebenam)->ausgegebenam : null;
|
||||
|
||||
//? formats date from 01-01-2000 to 01.01.2000
|
||||
if ($zutrittskarte_ausgegebenam !== NULL)
|
||||
{
|
||||
$zutrittskarte_ausgegebenam = (new DateTime($zutrittskarte_ausgegebenam))->format('d.m.Y');
|
||||
}
|
||||
return $zutrittskarte_ausgegebenam;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the address information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the address information
|
||||
* @return array all the address information corresponding to a userID
|
||||
*/
|
||||
private function getAdressenInfo($pid)
|
||||
{
|
||||
$this->ci->load->model("person/Adresse_model","AdresseModel");
|
||||
$adresse_res = $this->ci->AdresseModel->addSelect(["adresse_id", "strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort", "heimatadresse", "zustelladresse", "gemeinde", "nation"]);
|
||||
$adresse_res = $this->ci->AdresseModel->addOrder("zustelladresse", "DESC");
|
||||
$adresse_res = $this->ci->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz");
|
||||
|
||||
$adresse_res = $this->ci->AdresseModel->loadWhere(["person_id" => $pid]);
|
||||
if(isError($adresse_res)){
|
||||
return error(getData($adresse_res));
|
||||
}
|
||||
$adresse_res = getData($adresse_res) ?? [];
|
||||
return $adresse_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the kontakt information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the kontakt information
|
||||
* @return array all the kontakt information corresponding to a userID
|
||||
*/
|
||||
private function getKontaktInfo($pid, $includehidden=false)
|
||||
{
|
||||
$this->ci->load->model("person/Kontakt_model","KontaktModel");
|
||||
$this->ci->KontaktModel->addSelect(['kontakttyp', 'kontakt_id', 'kontakt', 'tbl_kontakt.anmerkung', 'tbl_kontakt.zustellung']);
|
||||
$this->ci->KontaktModel->addJoin('public.tbl_standort', 'standort_id', 'LEFT');
|
||||
$this->ci->KontaktModel->addJoin('public.tbl_firma', 'firma_id', 'LEFT');
|
||||
$this->ci->KontaktModel->addOrder('kontakttyp, kontakt, tbl_kontakt.updateamum, tbl_kontakt.insertamum');
|
||||
|
||||
$params = array('person_id' => $pid);
|
||||
if(!$includehidden)
|
||||
{
|
||||
$params['kontakttyp <>'] = 'hidden';
|
||||
}
|
||||
|
||||
$kontakte_res = $this->ci->KontaktModel->loadWhere($params);
|
||||
if(isError($kontakte_res)){
|
||||
return error(getData($kontakte_res));
|
||||
}
|
||||
$kontakte_res = getData($kontakte_res);
|
||||
return $kontakte_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all the mailverteiler using the tables: tbl_benutzer, tbl_benutzergruppe, tbl_gruppe
|
||||
* @access private
|
||||
* @param integer $uid the userID used to retrieve the mailverteiler
|
||||
* @return array returns the mailvertailer corresponding to a userID
|
||||
*/
|
||||
private function getMailverteiler($uid)
|
||||
{
|
||||
$this->ci->load->model("person/Person_model","PersonModel");
|
||||
$this->ci->PersonModel->addSelect('gruppe_kurzbz, beschreibung');
|
||||
$this->ci->PersonModel->addJoin('tbl_benutzer', 'person_id');
|
||||
$this->ci->PersonModel->addJoin('tbl_benutzergruppe', 'uid');
|
||||
$this->ci->PersonModel->addJoin('tbl_gruppe', 'gruppe_kurzbz');
|
||||
|
||||
$mailverteiler_res = $this->ci->PersonModel->loadWhere(array('mailgrp' => true, 'uid' => $uid));
|
||||
if(isError($mailverteiler_res)){
|
||||
return error(getData($mailverteiler_res));
|
||||
}
|
||||
$mailverteiler_res = getData($mailverteiler_res) ?? [];
|
||||
$mailverteiler_res = gettype($mailverteiler_res) === 'array' ? $mailverteiler_res : [];
|
||||
$mailverteiler_res = array_map(function ($element) {
|
||||
$element->mailto = "mailto:" . $element->gruppe_kurzbz . "@" . DOMAIN;
|
||||
return $element;
|
||||
}, $mailverteiler_res);
|
||||
return $mailverteiler_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the person information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the person information
|
||||
* @param integer $geburtsInfo flag wether to add the columns gebort, gebdatum, foto_sperre or not
|
||||
* @return array all the person informaion corresponding to a userID
|
||||
*/
|
||||
private function getPersonInfo($uid, $geburtsInfo = null)
|
||||
{
|
||||
$this->ci->load->model("person/Benutzer_model","BenutzerModel");
|
||||
$selectClause = ["foto", "foto_sperre", "anrede", "titelpost as postnomen", "titelpre as titel", "vorname", "nachname"];
|
||||
/** @param integer $geburtsInfo */
|
||||
if ($geburtsInfo) {
|
||||
array_push($selectClause, "gebort");
|
||||
array_push($selectClause, "TO_CHAR(gebdatum, 'DD.MM.YYYY') as gebdatum");
|
||||
}
|
||||
$this->ci->BenutzerModel->addSelect($selectClause);
|
||||
$this->ci->BenutzerModel->addJoin("tbl_person", "person_id");
|
||||
|
||||
$person_res = $this->ci->BenutzerModel->load([$uid]);
|
||||
if(isError($person_res)){
|
||||
return error(getData($person_res));
|
||||
}
|
||||
$person_res = getData($person_res);
|
||||
$person_res = $person_res ? current($person_res) : null;
|
||||
|
||||
if(isset($person_res)){
|
||||
if( ($person_res->foto === null) || ((getAuthUID() !== $uid) && ($person_res->foto_sperre !== false)) )
|
||||
{
|
||||
$dummy_foto = base64_encode(file_get_contents(DOC_ROOT.'skin/images/profilbild_dummy.jpg'));
|
||||
$person_res->foto = $dummy_foto;
|
||||
}
|
||||
}
|
||||
|
||||
return $person_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all the Benutzerfunktionen of a corresponding user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to retrieve the Benutzerfunktionen
|
||||
* @return array returns the Benutzerfunktionen corresponding to a userID
|
||||
*/
|
||||
private function getBenutzerFunktion($uid)
|
||||
{
|
||||
$this->ci->load->model("person/Benutzerfunktion_model","BenutzerfunktionModel");
|
||||
$this->ci->BenutzerfunktionModel->addSelect([
|
||||
"CASE WHEN (tbl_benutzerfunktion.bezeichnung IS NOT NULL AND tbl_benutzerfunktion.bezeichnung <> '' AND tbl_benutzerfunktion.bezeichnung <> tbl_funktion.beschreibung) THEN tbl_funktion.beschreibung || ' - ' || tbl_benutzerfunktion.bezeichnung ELSE tbl_funktion.beschreibung END as \"Bezeichnung\"",
|
||||
"tbl_organisationseinheit.bezeichnung as Organisationseinheit",
|
||||
"datum_von as Gültig_von",
|
||||
"datum_bis as Gültig_bis",
|
||||
"COALESCE(wochenstunden, '0'::numeric(5,2)) AS \"Wochenstunden\""
|
||||
]);
|
||||
$this->ci->BenutzerfunktionModel->addJoin("tbl_funktion", "funktion_kurzbz");
|
||||
$this->ci->BenutzerfunktionModel->addJoin("tbl_organisationseinheit", "oe_kurzbz");
|
||||
|
||||
$benutzer_funktion_res = $this->ci->BenutzerfunktionModel->loadWhere(
|
||||
array(
|
||||
'uid' => $uid,
|
||||
'NOW()::date BETWEEN COALESCE(datum_von, \'1970-01-01\'::date) AND COALESCE(datum_bis, \'2170-12-01\'::date)' => null
|
||||
)
|
||||
);
|
||||
if(isError($benutzer_funktion_res)){
|
||||
return error(getData($benutzer_funktion_res));
|
||||
}
|
||||
$benutzer_funktion_res = getData($benutzer_funktion_res);
|
||||
return $benutzer_funktion_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all the Betriebsmittel of a corresponding user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to retrieve the Betriebsmittel
|
||||
* @return array returns the Betriebsmittel corresponding to a userID
|
||||
*/
|
||||
private function getBetriebsmittelInfo($pid)
|
||||
{
|
||||
$this->ci->load->model("ressource/Betriebsmittelperson_model","BetriebsmittelpersonModel");
|
||||
$this->ci->BetriebsmittelpersonModel->addSelect(["CONCAT(betriebsmitteltyp, ' ' ,beschreibung) as Betriebsmittel", "nummer as Nummer", "ausgegebenam as Ausgegeben_am"]);
|
||||
|
||||
//? betriebsmittel are not needed in a view
|
||||
$betriebsmittelperson_res = $this->ci->BetriebsmittelpersonModel->getBetriebsmittel($pid);
|
||||
if(isError($betriebsmittelperson_res)){
|
||||
return error(getData($betriebsmittelperson_res));
|
||||
}
|
||||
$betriebsmittelperson_res = getData($betriebsmittelperson_res);
|
||||
return $betriebsmittelperson_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the profil updates corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the profil updates
|
||||
* @return array all the profil updates corresponding to a userID
|
||||
*/
|
||||
private function getProfilUpdates($uid)
|
||||
{
|
||||
$this->ci->load->model("person/Profil_update_model","ProfilUpdateModel");
|
||||
$profilUpdates = $this->ci->ProfilUpdateModel->getProfilUpdatesWhere(['uid' => $uid]);
|
||||
if(isError($profilUpdates)){
|
||||
return error(getData($profilUpdates));
|
||||
}
|
||||
$profilUpdates = getData($profilUpdates);
|
||||
return $profilUpdates;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the telefon information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the telefon information
|
||||
* @return array all the telefon informaion corresponding to a userID
|
||||
*/
|
||||
private function getTelefonInfo($uid)
|
||||
{
|
||||
$this->ci->load->model("ressource/Mitarbeiter_model","MitarbeiterModel");
|
||||
$this->ci->MitarbeiterModel->addSelect(["kontakt"]);
|
||||
$this->ci->MitarbeiterModel->addJoin("tbl_kontakt", "tbl_mitarbeiter.standort_id = tbl_kontakt.standort_id");
|
||||
$this->ci->MitarbeiterModel->addLimit(1);
|
||||
$telefon_res = $this->ci->MitarbeiterModel->loadWhere(["mitarbeiter_uid" => $uid, "kontakttyp" => "telefon"]);
|
||||
if(isError($telefon_res)){
|
||||
return error(getData($telefon_res));
|
||||
}
|
||||
$telefon_res = getData($telefon_res);
|
||||
$telefon_res = $telefon_res ? current($telefon_res) : null;
|
||||
return $telefon_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the mitarbeiter information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the mitarbeiter information
|
||||
* @return array all the mitarbeiter informaion corresponding to a userID
|
||||
*/
|
||||
private function getMitarbeiterInfo($uid)
|
||||
{
|
||||
$this->ci->load->model("ressource/Mitarbeiter_model","MitarbeiterModel");
|
||||
$this->ci->MitarbeiterModel->addSelect(["kurzbz", "telefonklappe", "alias", "ort_kurzbz"]);
|
||||
$this->ci->MitarbeiterModel->addJoin("tbl_benutzer", "tbl_benutzer.uid = tbl_mitarbeiter.mitarbeiter_uid");
|
||||
$mitarbeiter_res = $this->ci->MitarbeiterModel->load($uid);
|
||||
if(isError($mitarbeiter_res)){
|
||||
return error(getData($mitarbeiter_res));
|
||||
}
|
||||
$mitarbeiter_res = getData($mitarbeiter_res);
|
||||
$mitarbeiter_res = $mitarbeiter_res ? current($mitarbeiter_res) : null;
|
||||
|
||||
return $mitarbeiter_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the Zutrittsgruppen corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the Zutrittsgruppen
|
||||
* @return array all the Zutrittsgruppen corresponding to a userID
|
||||
*/
|
||||
private function getZutrittsgruppen($uid)
|
||||
{
|
||||
$this->ci->load->model("person/Benutzergruppe_model","BenutzergruppeModel");
|
||||
$this->ci->BenutzergruppeModel->addSelect(['bezeichnung']);
|
||||
$this->ci->BenutzergruppeModel->addJoin('tbl_gruppe', 'gruppe_kurzbz');
|
||||
|
||||
$zutrittsgruppe_res = $this->ci->BenutzergruppeModel->loadWhere(array("uid" => $uid, "zutrittssystem" => true));
|
||||
if(isError($zutrittsgruppe_res)){
|
||||
return error(getData($zutrittsgruppe_res));
|
||||
}
|
||||
$zutrittsgruppe_res = getData($zutrittsgruppe_res);
|
||||
return $zutrittsgruppe_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the student information corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the student information
|
||||
* @return array all the student informaion corresponding to a userID
|
||||
*/
|
||||
private function getStudentInfo($uid)
|
||||
{
|
||||
$this->ci->load->model("crm/Student_model","StudentModel");
|
||||
$this->ci->StudentModel->addSelect(['tbl_studiengang.bezeichnung as studiengang', 'tbl_studiengang.studiengang_kz as studiengang_kz', 'tbl_student.semester', 'tbl_student.verband', 'tbl_student.gruppe', 'tbl_student.matrikelnr as personenkennzeichen']);
|
||||
$this->ci->StudentModel->addJoin('tbl_studiengang', "tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz");
|
||||
|
||||
$student_res = $this->ci->StudentModel->load([$uid]);
|
||||
|
||||
if(isError($student_res)){
|
||||
return error(getData($student_res));
|
||||
}
|
||||
$student_res = getData($student_res);
|
||||
$student_res = $student_res ? current($student_res) : null;
|
||||
return $student_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the Matrikelnummer corresponding to a user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the Matrikelnummer
|
||||
* @return object the Matrikelnummer corresponding to a userID
|
||||
*/
|
||||
private function getMatrikelNummer($uid)
|
||||
{
|
||||
$this->ci->load->model("person/Benutzer_model","BenutzerModel");
|
||||
$this->ci->BenutzerModel->addSelect(["matr_nr"]);
|
||||
$this->ci->BenutzerModel->addJoin("tbl_person", "person_id");
|
||||
|
||||
$matr_res = $this->ci->BenutzerModel->load([$uid]);
|
||||
|
||||
if(isError($matr_res)){
|
||||
return error(getData($matr_res));
|
||||
}
|
||||
$matr_res = getData($matr_res);
|
||||
$matr_res = $matr_res ? current($matr_res) : [];
|
||||
return $matr_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks whether the foto of a user is accepted or not
|
||||
* @access private
|
||||
* @param integer $pid the personId of the student or mitarbeiter
|
||||
* @return bool whether the foto is accepted or not
|
||||
*/
|
||||
private function isFotoAkzeptiert($pid)
|
||||
{
|
||||
$this->ci->load->model('person/Fotostatusperson_model','FotostatusModel');
|
||||
$fotostatus = $this->ci->FotostatusModel->execReadOnlyQuery("
|
||||
select distinct on (person_id) person_id, insertamum, fotostatus_kurzbz
|
||||
from public.tbl_person_fotostatus
|
||||
where person_id = ?
|
||||
order by person_id, insertamum desc",[$pid]);
|
||||
if(isError($fotostatus)){
|
||||
return error(getData($fotostatus));
|
||||
}
|
||||
$fotostatus = getData($fotostatus);
|
||||
if(is_array($fotostatus) && count($fotostatus) > 0){
|
||||
$fotostatus = current($fotostatus)->fotostatus_kurzbz == 'akzeptiert';
|
||||
}
|
||||
else
|
||||
$fotostatus = false;
|
||||
return $fotostatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* function that returns the data used for viewing another mitarbeiter profile
|
||||
* @access private
|
||||
* @param integer $uid the userID to retrieve the mitarbeiter data
|
||||
* @return stdClass restricted mitarbeiter data
|
||||
*/
|
||||
private function viewMitarbeiterProfil($uid)
|
||||
{
|
||||
$mailverteiler_res = $this->getMailverteiler($uid);
|
||||
$benutzer_funktion_res = $this->getBenutzerFunktion($uid);
|
||||
$benutzer_res = $this->getBenutzerAlias($uid);
|
||||
$person_res = $this->getPersonInfo($uid);
|
||||
$mitarbeiter_res = $this->getMitarbeiterInfo($uid);
|
||||
$telefon_res = $this->getTelefonInfo($uid);
|
||||
|
||||
$res = new stdClass();
|
||||
$res->username = $uid;
|
||||
|
||||
//? Person Info
|
||||
foreach ($person_res as $key => $val) {
|
||||
$res->$key = $val;
|
||||
}
|
||||
|
||||
//? Mitarbeiter Info
|
||||
foreach ($mitarbeiter_res as $key => $val) {
|
||||
$res->$key = $val;
|
||||
|
||||
}
|
||||
|
||||
$intern_email = array();
|
||||
$intern_email["type"] = "intern";
|
||||
$intern_email["email"] = DOMAIN? $uid . "@" . DOMAIN:"";
|
||||
$extern_email = array();
|
||||
$extern_email["type"] = "alias";
|
||||
|
||||
$extern_email["email"] = $benutzer_res->alias ? ($benutzer_res->alias . "@" . DOMAIN) : null;
|
||||
$res->emails = $extern_email?[$intern_email, $extern_email]:[$intern_email];
|
||||
|
||||
$res->funktionen = $benutzer_funktion_res;
|
||||
$res->mailverteiler = $mailverteiler_res;
|
||||
$res->standort_telefon = isset($telefon_res) ? $telefon_res->kontakt : null;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the alias of a corresponding user
|
||||
* @access private
|
||||
* @param integer $uid the userID used to get the alias
|
||||
* @return string the alias of the userID
|
||||
*/
|
||||
private function getBenutzerAlias($uid)
|
||||
{
|
||||
$this->ci->load->model("person/Benutzer_model","BenutzerModel");
|
||||
$this->ci->BenutzerModel->addSelect(["alias"]);
|
||||
$benutzer_res = $this->ci->BenutzerModel->load([$uid]);
|
||||
if(isError($benutzer_res)){
|
||||
return error(getData($benutzer_res));
|
||||
}
|
||||
|
||||
$benutzer_res = getData($benutzer_res);
|
||||
$benutzer_res = $benutzer_res ? current($benutzer_res) : null;
|
||||
|
||||
return $benutzer_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* function that returns the data used for viewing another student profile
|
||||
* @access private
|
||||
* @param integer $uid the userID to retrieve the student data
|
||||
* @return stdClass restricted student data
|
||||
*/
|
||||
private function viewStudentProfil($uid)
|
||||
{
|
||||
$mailverteiler_res = $this->getMailverteiler($uid);
|
||||
$person_res = $this->getPersonInfo($uid);
|
||||
$student_res = $this->getStudentInfo($uid);
|
||||
$matr_res = $this->getMatrikelNummer($uid);
|
||||
|
||||
$res = new stdClass();
|
||||
$res->username = $uid;
|
||||
|
||||
//? Person Information
|
||||
foreach ($person_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
//? Student Information
|
||||
foreach ($student_res as $key => $value) {
|
||||
$res->$key = $value;
|
||||
}
|
||||
|
||||
$intern_email = array();
|
||||
$intern_email["type"] = "intern";
|
||||
$intern_email["email"] = DOMAIN? $uid . "@" . DOMAIN:"";
|
||||
|
||||
$res->emails = [$intern_email];
|
||||
$res->matrikelnummer = $matr_res->matr_nr;
|
||||
$res->mailverteiler = $mailverteiler_res;
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,7 @@ class SearchBarLib
|
||||
|
||||
$sql = '
|
||||
SELECT
|
||||
\'employee\' AS renderer,
|
||||
\''.$type.'\' AS type,
|
||||
b.uid AS uid,
|
||||
p.person_id AS person_id,
|
||||
@@ -205,6 +206,7 @@ EOSC;
|
||||
|
||||
$employees = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\'employee\' AS renderer,
|
||||
\''.$type.'\' AS type,
|
||||
b.uid AS uid,
|
||||
p.person_id AS person_id,
|
||||
@@ -268,6 +270,7 @@ EOSC;
|
||||
|
||||
$ous = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\'' . $type . '\' AS renderer,
|
||||
\''.$type.'\' AS type,
|
||||
o.oe_kurzbz AS oe_kurzbz,
|
||||
\'[\' || ot.bezeichnung || \'] \' || o.bezeichnung AS name,
|
||||
@@ -365,6 +368,7 @@ EOSC;
|
||||
$gesperrtes_foto = base64_encode(file_get_contents(DOC_ROOT.'skin/images/profilbild_dummy.jpg'));
|
||||
$students = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\'' . $type . '\' AS renderer,
|
||||
\''.$type.'\' AS type,
|
||||
s.student_uid AS uid,
|
||||
CONCAT(s.student_uid,\'@'.DOMAIN.'\') AS email,
|
||||
@@ -413,6 +417,7 @@ EOSC;
|
||||
|
||||
$students = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\'student\' AS renderer,
|
||||
\''.$type.'\' AS type,
|
||||
s.student_uid AS uid,
|
||||
s.matrikelnr,
|
||||
@@ -458,6 +463,7 @@ EOSC;
|
||||
|
||||
$prestudent = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\'' . $type . '\' AS renderer,
|
||||
\''.$type.'\' AS type,
|
||||
ps.prestudent_id,
|
||||
ps.studiengang_kz,
|
||||
@@ -517,6 +523,7 @@ EOSC;
|
||||
|
||||
$rooms = $dbModel->execReadOnlyQuery('
|
||||
SELECT
|
||||
\'room\' AS renderer,
|
||||
\''.$type.'\' AS type,
|
||||
COALESCE(ort.ort_kurzbz, \'N/A\') as ort_kurzbz,
|
||||
COALESCE(ort.gebteil, \'N/A\') as building,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,792 @@
|
||||
<?php
|
||||
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DateTime as DateTime;
|
||||
use \DateTimeZone as DateTimeZone;
|
||||
use \DateInterval as DateInterval;
|
||||
use \DatePeriod as DatePeriod;
|
||||
|
||||
class StundenplanLib
|
||||
{
|
||||
|
||||
private $_ci; // Code igniter instance
|
||||
|
||||
|
||||
/**
|
||||
* fetches Stundenplan events for the loggedin user between start and end
|
||||
* or for a lv
|
||||
*
|
||||
* @param string $start
|
||||
* @param string $end
|
||||
* @param string|null $lehrveranstaltung_id
|
||||
* @return stdClass
|
||||
* @access public
|
||||
*/
|
||||
public function getStundenplan($start, $end, $lehrveranstaltung_id = null)
|
||||
{
|
||||
if (!$lehrveranstaltung_id && $lehrveranstaltung_id !== 0)
|
||||
return $this->getEventsUser($start, $end);
|
||||
|
||||
return $this->getEventsLv($lehrveranstaltung_id, $start, $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches Stundenplan events for the loggedin user between start and end
|
||||
*
|
||||
* @param string $start
|
||||
* @param string $end
|
||||
* @return stdClass
|
||||
* @access public
|
||||
*/
|
||||
public function getEventsUser($start, $end)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
|
||||
$uid = getAuthUID();
|
||||
if (is_null($uid))
|
||||
return error("No UID");
|
||||
|
||||
$is_mitarbeiter = getData($this->_ci->MitarbeiterModel->isMitarbeiter($uid));
|
||||
|
||||
if ($is_mitarbeiter)
|
||||
return $this->getEventsEmployee($uid, $start, $end);
|
||||
|
||||
return $this->getEventsStudent($uid, $start, $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches Stundenplan events for a student between start and end
|
||||
*
|
||||
* @param string $student_uid
|
||||
* @param string $start
|
||||
* @param string $end
|
||||
* @return stdClass
|
||||
* @access public
|
||||
*/
|
||||
public function getEventsStudent($student_uid, $start, $end)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
$semester_range = $this->studienSemesterErmitteln($start, $end);
|
||||
if (isError($semester_range))
|
||||
return $semester_range;
|
||||
$semester_range = getData($semester_range);
|
||||
|
||||
$this->sortStudienSemester($semester_range);
|
||||
|
||||
$function_error = $this->applyLoadUeberSemesterHaelfte($semester_range);
|
||||
if ($function_error)
|
||||
return $function_error;
|
||||
|
||||
// getting the gruppen_kurzbz of the student in the different studiensemester
|
||||
$benutzer_gruppen = $this->fetchBenutzerGruppenFromStudiensemester($student_uid, $semester_range);
|
||||
if (isError($benutzer_gruppen))
|
||||
return $benutzer_gruppen;
|
||||
$benutzer_gruppen = getData($benutzer_gruppen);
|
||||
|
||||
// getting the student_lehrverbaende of the student in the different studiensemester
|
||||
$student_lehrverband = $this->fetchStudentlehrverbandFromStudiensemester($student_uid, $semester_range);
|
||||
if (isError($student_lehrverband))
|
||||
return $student_lehrverband;
|
||||
$student_lehrverband = getData($student_lehrverband);
|
||||
|
||||
$stundenplan_query = $this->_ci->StundenplanModel->getStundenplanQuery(
|
||||
$start,
|
||||
$end,
|
||||
$semester_range,
|
||||
$benutzer_gruppen,
|
||||
$student_lehrverband
|
||||
);
|
||||
if (!$stundenplan_query)
|
||||
return success([]);
|
||||
|
||||
$stundenplan_data = $this->_ci->StundenplanModel->stundenplanGruppierung($stundenplan_query);
|
||||
if (isError($stundenplan_data))
|
||||
return $stundenplan_data;
|
||||
$stundenplan_data = getData($stundenplan_data) ?? [];
|
||||
|
||||
$function_error = $this->expandObjectInformation($stundenplan_data);
|
||||
if ($function_error)
|
||||
return $function_error;
|
||||
|
||||
return success($stundenplan_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches Stundenplan events for an employee between start and end
|
||||
*
|
||||
* @param string $uid
|
||||
* @param string $start
|
||||
* @param string $end
|
||||
* @return stdClass
|
||||
* @access public
|
||||
*/
|
||||
public function getEventsEmployee($uid, $start, $end)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
$stundenplan_data = $this->_ci->StundenplanModel->getStundenplanMitarbeiter($start, $end, $uid);
|
||||
if (isError($stundenplan_data))
|
||||
return $stundenplan_data;
|
||||
$stundenplan_data = getData($stundenplan_data) ?? [];
|
||||
|
||||
$function_error = $this->expandObjectInformation($stundenplan_data);
|
||||
if ($function_error)
|
||||
return $function_error;
|
||||
|
||||
return success($stundenplan_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches Stundenplan events for a LV between start and end
|
||||
*
|
||||
* @param integer $lehrveranstaltung_id
|
||||
* @param string $start
|
||||
* @param string $end
|
||||
* @return stdClass
|
||||
* @access public
|
||||
*/
|
||||
public function getEventsLv($lehrveranstaltung_id, $start, $end)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
$stundenplan_data = $this->_ci->StundenplanModel->getStundenplanLVA($start, $end, $lehrveranstaltung_id);
|
||||
if (isError($stundenplan_data))
|
||||
return $stundenplan_data;
|
||||
$stundenplan_data = getData($stundenplan_data) ?? [];
|
||||
|
||||
$function_error = $this->expandObjectInformation($stundenplan_data);
|
||||
if ($function_error)
|
||||
return $function_error;
|
||||
|
||||
// query lv itself in case its Stundenplan is being queried and it has no entries
|
||||
$this->_ci->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
|
||||
|
||||
$lv_result = $this->_ci->LehrveranstaltungModel->load($lehrveranstaltung_id);
|
||||
if (isError($lv_result))
|
||||
return $lv_result;
|
||||
if (!hasData($lv_result))
|
||||
return error('LV not found');
|
||||
|
||||
return success($stundenplan_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stundenplan for a room
|
||||
*
|
||||
* @param string $ort_kurzbz
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getRoomplan($ort_kurzbz, $start_date, $end_date)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Load Config
|
||||
$this->_ci->load->config('calendar');
|
||||
// Load Models
|
||||
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
$query = $this->_ci->StundenplanModel->getRoomQuery($ort_kurzbz, $start_date, $end_date);
|
||||
$roomplan_data = $this->_ci->StundenplanModel->stundenplanGruppierung($query);
|
||||
|
||||
if (isError($roomplan_data))
|
||||
return $roomplan_data;
|
||||
|
||||
$this->expandObjectInformation($roomplan_data->retval);
|
||||
|
||||
return $roomplan_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get reservations (for a room or all)
|
||||
*
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
* @param string $ort_kurzbz
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getReservierungen($start_date, $end_date, $ort_kurzbz = '')
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Load Config
|
||||
$this->_ci->load->config('calendar');
|
||||
// Load Models
|
||||
$this->_ci->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->_ci->load->model('ressource/Reservierung_model', 'ReservierungModel');
|
||||
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
$is_mitarbeiter = getData($this->_ci->MitarbeiterModel->isMitarbeiter(getAuthUID()));
|
||||
|
||||
if ($is_mitarbeiter && empty($ort_kurzbz)) {
|
||||
// request for personal lvplan show only reservations of logged in user
|
||||
$reservierungen = $this->_ci->ReservierungModel->getReservierungenMitarbeiter($start_date, $end_date);
|
||||
} else {
|
||||
// querying the reservierungen
|
||||
$reservierungen = $this->_ci->ReservierungModel->getReservierungen($start_date, $end_date, $ort_kurzbz);
|
||||
}
|
||||
|
||||
if (isError($reservierungen))
|
||||
return $reservierungen;
|
||||
|
||||
$function_error = $this->expandObjectInformation($reservierungen->retval);
|
||||
|
||||
if (!is_null($function_error))
|
||||
return $function_error;
|
||||
|
||||
return $reservierungen;
|
||||
}
|
||||
|
||||
public function getLektorenFromLehrveranstaltung($lehrveranstaltung_id, $semester, $studiengang_kz, $studiensemester_kurzbz){
|
||||
$this->_ci =& get_instance();
|
||||
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
$this->_ci->load->model('organisation/Studiensemester_model','StudiensemesterModel');
|
||||
|
||||
$studiensemester = $this->_ci->StudiensemesterModel->loadWhere(["studiensemester_kurzbz"=>$studiensemester_kurzbz]);
|
||||
if(isError($studiensemester))
|
||||
{
|
||||
return error(getData($studiensemester));
|
||||
}
|
||||
$studiensemester = current(getData($studiensemester));
|
||||
$lektoren = $this->_ci->StundenplanModel->execReadOnlyQuery("
|
||||
SELECT DISTINCT uid
|
||||
FROM campus.vw_stundenplan
|
||||
WHERE lehrveranstaltung_id = ? AND
|
||||
studiengang_kz = ? AND
|
||||
semester = ? AND
|
||||
(datum BETWEEN ? AND ?)
|
||||
",[$lehrveranstaltung_id, $studiengang_kz, $semester, $studiensemester->start, $studiensemester->ende]);
|
||||
|
||||
if(isError($lektoren))
|
||||
{
|
||||
return error(getData($lektoren));
|
||||
}
|
||||
$lektoren = getData($lektoren);
|
||||
if(isset($lektoren)){
|
||||
$lektoren = array_map(function($lektor){
|
||||
return $lektor->uid;
|
||||
},$lektoren);
|
||||
|
||||
}
|
||||
return success($lektoren);
|
||||
}
|
||||
|
||||
public function expandObjectInformation($data)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Load Config
|
||||
$this->_ci->load->config('calendar');
|
||||
// Load Model
|
||||
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
$tz = new DateTimeZone($this->_ci->config->item('timezone'));
|
||||
$isostart = new DateTime($item->datum . ' ' . $item->beginn, $tz);
|
||||
$item->isostart = $isostart->format(DateTime::ATOM);
|
||||
|
||||
$isoend = new DateTime($item->datum . ' ' . $item->ende, $tz);
|
||||
$item->isoend = $isoend->format(DateTime::ATOM);
|
||||
|
||||
$lektor_obj_array = array();
|
||||
$gruppe_obj_array = array();
|
||||
|
||||
// load lektor object
|
||||
foreach ($item->lektor as $lv_lektor)
|
||||
{
|
||||
$this->_ci->StundenplanModel->addLimit(1);
|
||||
$lektor_object = $this->_ci->StundenplanModel->execReadOnlyQuery("
|
||||
SELECT mitarbeiter_uid, vorname, nachname, kurzbz
|
||||
FROM public.tbl_mitarbeiter
|
||||
JOIN public.tbl_benutzer benutzer ON benutzer.uid = mitarbeiter_uid
|
||||
JOIN public.tbl_person person ON person.person_id = benutzer.person_id
|
||||
WHERE kurzbz = ?", [$lv_lektor]);
|
||||
if (isError($lektor_object)) {
|
||||
$this->_ci->show_error(getError($lektor_object));
|
||||
}
|
||||
if(isError($lektor_object))
|
||||
{
|
||||
return error(getData($lektor_object));
|
||||
}
|
||||
$lektor_object = getData($lektor_object);
|
||||
if(count($lektor_object) == 0)
|
||||
{
|
||||
return error("No lektor object");
|
||||
}
|
||||
$lektor_object = current($lektor_object);
|
||||
// only provide needed information of the mitarbeiter object
|
||||
$lektor_obj_array[] = $lektor_object;
|
||||
}
|
||||
|
||||
// load gruppe object
|
||||
foreach ($item->gruppe as $lv_gruppe)
|
||||
{
|
||||
$lv_gruppe = strtr($lv_gruppe, ['(' => '', ')' => '', '"' => '']);
|
||||
$lv_gruppe_array = explode(",", $lv_gruppe);
|
||||
list($gruppe, $verband, $semester, $studiengang_kz, $gruppen_kuerzel) = $lv_gruppe_array;
|
||||
|
||||
$lv_gruppe_object = new stdClass();
|
||||
$lv_gruppe_object->gruppe = $gruppe;
|
||||
$lv_gruppe_object->verband = $verband;
|
||||
$lv_gruppe_object->semester = $semester;
|
||||
$lv_gruppe_object->studiengang_kz = $studiengang_kz;
|
||||
$lv_gruppe_object->kuerzel = $gruppen_kuerzel;
|
||||
|
||||
$gruppe_obj_array[] = $lv_gruppe_object;
|
||||
}
|
||||
|
||||
if($item->ort_kurzbz) {
|
||||
|
||||
$ort_content_object = $this->_ci->StundenplanModel->execReadOnlyQuery("
|
||||
SELECT content_id
|
||||
FROM public.tbl_ort
|
||||
WHERE ort_kurzbz = ?", [$item->ort_kurzbz]);
|
||||
if (isError($ort_content_object)) {
|
||||
return error(getData($ort_content_object));
|
||||
}
|
||||
$ort_content_object = getData($ort_content_object)[0];
|
||||
if($ort_content_object) {
|
||||
$item->ort_content_id = $ort_content_object->content_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$item->gruppe = $gruppe_obj_array;
|
||||
$item->lektor = $lektor_obj_array;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function fetchFerienTageEvents($start_date, $end_date, $studiengang_kz)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Load Config
|
||||
$this->_ci->load->config('calendar');
|
||||
|
||||
$this->_ci->load->model('organisation/Ferien_model', 'FerienModel');
|
||||
|
||||
$tz = new DateTimeZone($this->_ci->config->item('timezone'));
|
||||
|
||||
$ferienEvents = $this->_ci->FerienModel->execReadOnlyQuery("
|
||||
SELECT *
|
||||
FROM lehre.tbl_ferien
|
||||
WHERE (bisdatum >= ? AND vondatum < ?) AND (studiengang_kz = 0 OR studiengang_kz = ?)
|
||||
", [$start_date, $end_date, $studiengang_kz]);
|
||||
|
||||
if (isError($ferienEvents))
|
||||
return $ferienEvents;
|
||||
|
||||
$ferienEvents = getData($ferienEvents);
|
||||
|
||||
if (!$ferienEvents)
|
||||
return success([]);
|
||||
|
||||
$ferienEvents = array_map(function ($event) {
|
||||
$event_start = new DateTime($event->vondatum);
|
||||
$event_end = new DateTime($event->bisdatum);
|
||||
$event_end->modify('+1 day');
|
||||
|
||||
$interval = new DateInterval('P1D');
|
||||
$period = new DatePeriod($event_start, $interval, $event_end);
|
||||
$event->dates = iterator_to_array($period);
|
||||
return $event;
|
||||
}, $ferienEvents);
|
||||
|
||||
$start_date = new DateTime($start_date);
|
||||
$start_date->setTime(0, 0, 0);
|
||||
$end_date = new DateTime($end_date);
|
||||
$end_date->setTime(23, 59, 59);
|
||||
|
||||
$ferienEventsFlattened = [];
|
||||
foreach ($ferienEvents as $ferien_event) {
|
||||
foreach ($ferien_event->dates as $date) {
|
||||
if ($date < $start_date || $date > $end_date)
|
||||
continue;
|
||||
$event = new stdClass();
|
||||
$event->bezeichnung = $ferien_event->bezeichnung;
|
||||
$event->datum = $date->format('Y-m-d');
|
||||
$event->type = 'ferien';
|
||||
$ferienEventsFlattened[] = $event;
|
||||
}
|
||||
};
|
||||
|
||||
$today = new DateTime();
|
||||
$ferienEventsFlattened = array_map(function ($event) use ($today, $tz) {
|
||||
$ferien_event = (object)array(
|
||||
'type' => 'ferien',
|
||||
'beginn' => $today->format('H:i:s'),
|
||||
'ende' => $today->format('H:i:s'),
|
||||
'isostart' => (new DateTime($event->datum . ' 00:00:00', $tz))->format('c'),
|
||||
'isoend' => (new DateTime($event->datum . ' 23:59:59', $tz))->format('c'),
|
||||
'allDayEvent' => true,
|
||||
'datum' => $event->datum,
|
||||
'topic' => $event->bezeichnung,
|
||||
'titel' => $event->bezeichnung,
|
||||
'farbe' => '00689E'
|
||||
);
|
||||
return $ferien_event;
|
||||
}, $ferienEventsFlattened);
|
||||
|
||||
return success($ferienEventsFlattened);
|
||||
}
|
||||
|
||||
// start of the private functions ########################################################################################################
|
||||
|
||||
// function used to sort an array of studiensemester strings
|
||||
private function sortStudienSemester(&$semester_range){
|
||||
usort(
|
||||
$semester_range,
|
||||
function($first,$second)
|
||||
{
|
||||
$sem_first = null;
|
||||
$year_first = null;
|
||||
$match_first = null;
|
||||
|
||||
$sem_second = null;
|
||||
$year_second = null;
|
||||
$match_second = null;
|
||||
|
||||
preg_match('/([WS]+)([0-9]+)/',$first,$match_first);
|
||||
preg_match('/([WS]+)([0-9]+)/',$second,$match_second);
|
||||
|
||||
$sem_first = $match_first[1];
|
||||
$year_first = intval($match_first[2]);
|
||||
|
||||
$sem_second = $match_second[1];
|
||||
$year_second = intval($match_second[2]);
|
||||
|
||||
if($year_first < $year_second)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if($year_first > $year_second)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if($year_first == $year_second && $sem_first > $sem_second)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if($year_first == $year_second && $sem_first < $sem_second)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function fetchBenutzerGruppenFromStudiensemester($student_uid, $semester_range)
|
||||
{
|
||||
$this->_ci->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel');
|
||||
|
||||
$benutzer_gruppen = [];
|
||||
// for each studiensemester fetch the benutzer gruppen and add them to an associate $bentuzer_gruppen array
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [['gruppe1_SS2023','gruppe2_SS2023'],['gruppe1_WS2023','gruppe2_WS2023']],
|
||||
['SS2024'] => [['gruppe1_WS2023','gruppe2_WS2023'],['gruppe1_SS2024','gruppe2_SS2024']],
|
||||
['WS2024'] => [['gruppe1_SS2024','gruppe2_SS2024'],['gruppe1_WS2024','gruppe2_WS2024']],
|
||||
]
|
||||
*/
|
||||
foreach($semester_range as $semester_key => $semester_array)
|
||||
{
|
||||
$benutzer_gruppen[$semester_key] = [];
|
||||
// each semester could have ajoint semesters that need to be checked
|
||||
foreach($semester_array as $semester=>$semester_date_range)
|
||||
{
|
||||
// for each active semester query the benutzer_gruppen associated to the semester
|
||||
$benutzer_query = $this->_ci->BenutzergruppeModel->execReadOnlyQuery("
|
||||
SELECT * FROM tbl_benutzergruppe where uid = ? AND studiensemester_kurzbz = ?",[$student_uid, $semester]);
|
||||
if(isError($benutzer_query)){
|
||||
return error(getData($benutzer_query));
|
||||
}
|
||||
$benutzer_query_result = getData($benutzer_query)??[];
|
||||
|
||||
array_push(
|
||||
$benutzer_gruppen[$semester_key],
|
||||
array_map(
|
||||
function($item)
|
||||
{
|
||||
return "'".$item->gruppe_kurzbz. "'";
|
||||
},
|
||||
$benutzer_query_result
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// merge the gruppen of each studiensemester together for the original studiensemester
|
||||
/*
|
||||
[
|
||||
['WS2023'] => ['gruppe1_SS2023','gruppe2_SS2023','gruppe1_WS2023','gruppe2_WS2023'],
|
||||
['SS2024'] => ['gruppe1_WS2023','gruppe2_WS2023','gruppe1_SS2024','gruppe2_SS2024'],
|
||||
['WS2024'] => ['gruppe1_SS2024','gruppe2_SS2024','gruppe1_WS2024','gruppe2_WS2024'],
|
||||
]
|
||||
*/
|
||||
$benutzer_gruppen = array_map(
|
||||
function($gruppe)
|
||||
{
|
||||
$merged_gruppe = [];
|
||||
foreach($gruppe as $gruppen_array)
|
||||
{
|
||||
$merged_gruppe = array_merge($merged_gruppe, $gruppen_array);
|
||||
}
|
||||
return $merged_gruppe;
|
||||
},
|
||||
$benutzer_gruppen
|
||||
);
|
||||
|
||||
return success($benutzer_gruppen);
|
||||
}
|
||||
|
||||
private function fetchStudentlehrverbandFromStudiensemester($student_uid, $semester_range)
|
||||
{
|
||||
$this->_ci->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel');
|
||||
|
||||
$student_lehrverband = [];
|
||||
// for each studiensemester fetch the studentlehrverbaende and add them to an associate $student_lehrverband array
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [ [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
['SS2024'] => [ [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ], [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
['WS2024'] => [ [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ], [ ['stg_kz'=>298,'semester'=>3,'verband'=>"A",'gruppe'=>""] ] ],
|
||||
]
|
||||
*/
|
||||
foreach($semester_range as $semester_key => $semester_array)
|
||||
{
|
||||
$student_lehrverband[$semester_key] = [];
|
||||
foreach($semester_array as $semester=>$semester_date_range)
|
||||
{
|
||||
// for each active semester query the student_lehrverband associated to the semester
|
||||
$lehrverband_query = $this->_ci->BenutzergruppeModel->execReadOnlyQuery("
|
||||
SELECT * FROM tbl_studentlehrverband where student_uid = ? AND studiensemester_kurzbz = ?", [$student_uid, $semester]);
|
||||
if(isError($lehrverband_query)){
|
||||
return error(getData($lehrverband_query));
|
||||
}
|
||||
$lehrverband_query_result = getData($lehrverband_query)??[];
|
||||
|
||||
$converted_studentLehrverband= array_map(
|
||||
function ($item)
|
||||
{
|
||||
$result = new stdClass();
|
||||
$result->studiengang_kz = $item->studiengang_kz;
|
||||
$result->semester = $item->semester;
|
||||
$result->verband = $item->verband;
|
||||
$result->gruppe = $item->gruppe;
|
||||
return $result;
|
||||
},
|
||||
$lehrverband_query_result);
|
||||
|
||||
array_push($student_lehrverband[$semester_key], $converted_studentLehrverband);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// merge the studentlehrverband of each studiensemester together for the original studiensemester
|
||||
/*
|
||||
[
|
||||
['WS2023'] => [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""] ],
|
||||
['SS2024'] => [ ['stg_kz'=>298,'semester'=>1,'verband'=>"A",'gruppe'=>""], ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""] ],
|
||||
['WS2024'] => [ ['stg_kz'=>298,'semester'=>2,'verband'=>"A",'gruppe'=>""], ['stg_kz'=>298,'semester'=>3,'verband'=>"A",'gruppe'=>""] ],
|
||||
]
|
||||
*/
|
||||
|
||||
$student_lehrverband = array_map(
|
||||
function($studentlehrverband)
|
||||
{
|
||||
$merged_studentlehrverband = [];
|
||||
foreach($studentlehrverband as $studentlehrverband_array)
|
||||
{
|
||||
$merged_studentlehrverband = array_merge($merged_studentlehrverband, $studentlehrverband_array);
|
||||
}
|
||||
return $merged_studentlehrverband;
|
||||
},
|
||||
$student_lehrverband
|
||||
);
|
||||
|
||||
return success($student_lehrverband);
|
||||
}
|
||||
|
||||
private function applyLoadUeberSemesterHaelfte(&$semester_range)
|
||||
{
|
||||
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
/*
|
||||
@var($semester_collection)
|
||||
convert the array of studiensemester into an associative array with the studiensemester as the key
|
||||
and the values of each key are the studiensemester needed for the query associated to that studiensemester
|
||||
example:
|
||||
|
||||
#INPUT:
|
||||
['WS2023','SS2024','WS2024']
|
||||
#OUTPUT:
|
||||
[
|
||||
'WS2023' => ['SS2023','WS2023']
|
||||
'SS2024' => ['WS2023','SS2024']
|
||||
'WS2024' => ['SS2024','WS2024']
|
||||
]
|
||||
*/
|
||||
$semester_collection = [];
|
||||
foreach($semester_range as $studiensemester)
|
||||
{
|
||||
$previous_studiensemester = $this->_ci->StudiensemesterModel->getPreviousFrom($studiensemester);
|
||||
if(isError($previous_studiensemester))
|
||||
{
|
||||
return error(getData($previous_studiensemester));
|
||||
}
|
||||
$previous_studiensemester = getData($previous_studiensemester);
|
||||
if (count($previous_studiensemester) == 0) {
|
||||
return error('no previous semester');
|
||||
}
|
||||
$previous_studiensemester = current($previous_studiensemester)->studiensemester_kurzbz;
|
||||
$semester_collection[$studiensemester] = [$previous_studiensemester, $studiensemester];
|
||||
}
|
||||
|
||||
/*
|
||||
@var($studienSemesterDateRanges)
|
||||
fetches for each studiensemester the start and end date, (SS) summer studiensemester are extended by 1 month to cover the summerbreak
|
||||
based on the LVPLAN_LOAD_UEBER_SEMESTERHAELFTE constant it will load both the semester and the previous semester with the full date range
|
||||
or the semester with the full date range and the previous semester with the half date range:
|
||||
|
||||
#INPUT:
|
||||
[
|
||||
'WS2023' => ['SS2023','WS2023']
|
||||
'SS2024' => ['WS2023','SS2024']
|
||||
'WS2024' => ['SS2024','WS2024']
|
||||
]
|
||||
#OUTPUT: depends whether LVPLAN_LOAD_UEBER_SEMESTERHAELFTE is true or false
|
||||
~ if LVPLAN_LOAD_UEBER_SEMESTERHAELFTE == true
|
||||
[
|
||||
"SS2024": [
|
||||
"WS2023": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
],
|
||||
"SS2024": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
]
|
||||
]
|
||||
]
|
||||
~ if LVPLAN_LOAD_UEBER_SEMESTERHAELFTE == false
|
||||
[
|
||||
"SS2024": [
|
||||
"WS2023": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-05-17"
|
||||
],
|
||||
"SS2024": [
|
||||
"start"=> "2024-02-03",
|
||||
"ende"=> "2024-08-31"
|
||||
]
|
||||
]
|
||||
]
|
||||
*/
|
||||
$studienSemesterDateRanges=[];
|
||||
foreach($semester_collection as $semester_original => $semester_adjoint)
|
||||
{
|
||||
$semester_start_ende = $this->_ci->StudiensemesterModel->getStartEndeFromStudiensemester($semester_original);
|
||||
if(isError($semester_start_ende))
|
||||
{
|
||||
return error(getData($semester_start_ende));
|
||||
}
|
||||
$semester_start_ende = current(getData($semester_start_ende));
|
||||
|
||||
// initialize empty arrays to add key value pairs
|
||||
$studienSemesterDateRanges[$semester_original] = [];
|
||||
|
||||
// check if the studiensemester is a summer semester and add 1 month to bridge the school summer break
|
||||
$match = null;
|
||||
preg_match("/^(SS)([0-9]+)/",$semester_original,$match);
|
||||
if(count($match) >0)
|
||||
{
|
||||
$one_month = new DateInterval('P1M');
|
||||
$one_day = DateInterval::createFromDateString('1 days');
|
||||
$summer_studiensemester_end_date = DateTime::createFromFormat('Y-m-d',$semester_start_ende->ende);
|
||||
$summer_studiensemester_end_date->add($one_month);
|
||||
$summer_studiensemester_end_date->sub($one_day);
|
||||
$semester_start_ende->ende = date_format($summer_studiensemester_end_date,'Y-m-d');
|
||||
}
|
||||
if (defined('LVPLAN_LOAD_UEBER_SEMESTERHAELFTE') && LVPLAN_LOAD_UEBER_SEMESTERHAELFTE === true)
|
||||
{
|
||||
foreach($semester_adjoint as $adjoint)
|
||||
{
|
||||
$studienSemesterDateRanges[$semester_original][$adjoint]=$semester_start_ende;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: half of a DateInterval might not be correctly calculated
|
||||
// calculate the half of the studiensemester
|
||||
$studiensemester_start_date = DateTime::createFromFormat('Y-m-d',$semester_start_ende->start);
|
||||
$studiensemester_end_date = DateTime::createFromFormat('Y-m-d',$semester_start_ende->ende);
|
||||
$studiensemester_time_difference = $studiensemester_start_date->diff($studiensemester_end_date);
|
||||
$half_dateNumber = ceil($studiensemester_time_difference->d/2)+ceil(($studiensemester_time_difference->m*30)/2);
|
||||
$half_dateInterval = new DateInterval('P'.strval($half_dateNumber) .'D');
|
||||
$studiensemester_half = date_format($studiensemester_start_date->add($half_dateInterval),'Y-m-d');
|
||||
|
||||
$first_half = new stdClass();
|
||||
$first_half->start = $semester_start_ende->start;
|
||||
$first_half->ende = $studiensemester_half;
|
||||
|
||||
$studienSemesterDateRanges[$semester_original][$semester_adjoint[0]] = $first_half;
|
||||
$studienSemesterDateRanges[$semester_original][$semester_adjoint[1]] = $semester_start_ende;
|
||||
}
|
||||
$semester_range = $studienSemesterDateRanges;
|
||||
}
|
||||
}
|
||||
|
||||
private function studienSemesterErmitteln($start_date, $end_date)
|
||||
{
|
||||
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
|
||||
|
||||
// gets all studiensemester from the student from start_date to end_date
|
||||
$semester_range = $this->_ci->StudiensemesterModel->getByDateRange($start_date, $end_date);
|
||||
if (isError($semester_range))
|
||||
return $semester_range;
|
||||
|
||||
$semester_range = array_map(
|
||||
function ($sem) {
|
||||
return $sem->studiensemester_kurzbz;
|
||||
},
|
||||
getData($semester_range) ?: []
|
||||
);
|
||||
|
||||
// if no studiensemester is found for the given timespan, get the nearest studiensemester
|
||||
if (count($semester_range) == 0)
|
||||
{
|
||||
$aktuelle_studiensemester = $this->_ci->StudiensemesterModel->getNearest();
|
||||
if (isError($aktuelle_studiensemester))
|
||||
return $aktuelle_studiensemester;
|
||||
|
||||
$aktuelle_studiensemester = getData($aktuelle_studiensemester);
|
||||
if (count($aktuelle_studiensemester) == 0) {
|
||||
return error("No aktuelles semester");
|
||||
}
|
||||
$aktuelle_studiensemester = current($aktuelle_studiensemester)->studiensemester_kurzbz;
|
||||
// push aktuelles semester in active semester array
|
||||
array_push($semester_range, $aktuelle_studiensemester);
|
||||
}
|
||||
|
||||
return success($semester_range);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user