diff --git a/application/config/navigation.php b/application/config/navigation.php index c70aba57c..4d4dcc22a 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -208,7 +208,14 @@ $config['navigation_header'] = array( 'expand' => true, 'sort' => 30, 'requiredPermissions' => 'lehre/anrechnungszeitfenster:rw' - ) + ), + 'dashboardadmin' => array( + 'link' => site_url('dashboard/Admin'), + 'description' => 'Dashboard Admin', + 'expand' => true, + 'sort' => 40, + 'requiredPermissions' => 'dashboard/admin:r' + ) ) ) ) diff --git a/application/controllers/api/frontend/v1/Documents.php b/application/controllers/api/frontend/v1/Documents.php index dcc0bb9ac..13c0a2eba 100644 --- a/application/controllers/api/frontend/v1/Documents.php +++ b/application/controllers/api/frontend/v1/Documents.php @@ -220,7 +220,7 @@ class Documents extends FHCAPI_Controller 'gedruckt' => true, 'insertamum' => date('c'), 'insertvon' => getAuthUID(), - 'uid' => $this->input->post_get('uid') ?: '', + 'uid' => $this->input->post_get('uid') ?: null, 'archiv' => true, 'signiert' => !!$sign_user, 'stud_selfservice' => $vorlage->stud_selfservice @@ -334,6 +334,7 @@ class Documents extends FHCAPI_Controller if ($prestudent_id) { $this->load->model('crm/prestudent_model', 'PrestudentModel'); $this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz', 'LEFT'); + $this->PrestudentModel->addSelect('tbl_prestudent.*, UPPER(typ || kurzbz) AS kuerzel'); $result = $this->PrestudentModel->load($prestudent_id); $prestudent = current($this->getDataOrTerminateWithError($result)); diff --git a/application/controllers/api/frontend/v1/dashboard/Board.php b/application/controllers/api/frontend/v1/dashboard/Board.php new file mode 100644 index 000000000..c50fec128 --- /dev/null +++ b/application/controllers/api/frontend/v1/dashboard/Board.php @@ -0,0 +1,121 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about addresses + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Board extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'list' => 'dashboard/admin:r', + 'create' => 'dashboard/admin:rw', + 'update' => 'dashboard/admin:rw', + 'delete' => 'dashboard/admin:rw' + ]); + + // Models + $this->load->model('dashboard/Dashboard_model', 'DashboardModel'); + } + + public function list() + { + $result = $this->DashboardModel->load(); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($result); + } + + public function create() + { + $dashboard_kurzbz = $this->input->post('dashboard_kurzbz'); + + $result = $this->DashboardModel->insert([ + 'dashboard_kurzbz' => $dashboard_kurzbz + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } + + public function update() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('dashboard_id', 'Dashboard ID', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $dashboard_id = $this->input->post('dashboard_id'); + $dashboard_kurzbz = $this->input->post('dashboard_kurzbz'); + $beschreibung = $this->input->post('beschreibung'); + + $result = $this->DashboardModel->update([ + 'dashboard_id' => $dashboard_id + ], [ + 'dashboard_kurzbz' => $dashboard_kurzbz, + 'beschreibung' => $beschreibung + ]); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($result); + } + + public function delete() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('dashboard_id', 'Dashboard ID', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $dashboard_id = $this->input->post('dashboard_id'); + + //delete all presets + $this->load->model('dashboard/Dashboard_Preset_model', 'DashboardPresetModel'); + + $result = $this->DashboardPresetModel->delete([ + 'dashboard_id' => $dashboard_id + ]); + $this->getDataOrTerminateWithError($result); + + //delete all widgets + $this->load->model('dashboard/Dashboard_Widget_model', 'DashboardWidgetModel'); + + $result = $this->DashboardWidgetModel->delete([ + 'dashboard_id' => $dashboard_id + ]); + $this->getDataOrTerminateWithError($result); + + $result = $this->DashboardModel->delete($dashboard_id); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($result); + } +} diff --git a/application/controllers/api/frontend/v1/dashboard/Preset.php b/application/controllers/api/frontend/v1/dashboard/Preset.php new file mode 100644 index 000000000..5983d9660 --- /dev/null +++ b/application/controllers/api/frontend/v1/dashboard/Preset.php @@ -0,0 +1,200 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about addresses + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Preset extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'list' => 'dashboard/admin:r', + 'getBatch' => 'dashboard/admin:r', + 'addWidget' => 'dashboard/admin:rw', + 'removeWidget' => 'dashboard/admin:rw' + ]); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + + // Libraries + $this->load->library('dashboard/DashboardLib'); + + // Models + $this->load->model('ressource/Funktion_model', 'FunktionModel'); + } + + public function list($dashboard_kurzbz) + { + $sql = " + WITH + dashboard_presets AS ( + SELECT + * + FROM + dashboard.tbl_dashboard_preset dp + JOIN + dashboard.tbl_dashboard d ON d.dashboard_id = dp.dashboard_id + WHERE + d.dashboard_kurzbz = {$this->db->escape($dashboard_kurzbz)} + ), + general AS ( + SELECT + 'general' AS funktion_kurzbz, + 'Allgemein' AS beschreibung + ) + + ( + SELECT + f.funktion_kurzbz, + f.beschreibung, + COUNT(p.preset_id) AS has_preset + FROM + general f + LEFT JOIN + dashboard_presets p ON p.funktion_kurzbz IS NULL + GROUP BY + f.funktion_kurzbz, f.beschreibung + ) + UNION ALL + ( + SELECT + f.funktion_kurzbz, + f.beschreibung, + COUNT(p.preset_id) AS has_preset + FROM + public.tbl_funktion f + LEFT JOIN + dashboard_presets p ON p.funktion_kurzbz = f.funktion_kurzbz + GROUP BY + f.funktion_kurzbz, f.beschreibung + ORDER BY + f.beschreibung ASC + ) + "; + + $result = $this->FunktionModel->execReadOnlyQuery($sql); + + $funktionen = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($funktionen); + } + + public function getBatch() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('db', 'Dashboard', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $db = $this->input->post('db'); + $funktionen = $this->input->post('funktionen') ?: []; + + $result = []; + + foreach ($funktionen as $funktion) { + $conf = $this->dashboardlib->getPreset($db, $funktion); + if ($conf) { + $preset = json_decode($conf->preset, true); + if (!isset($preset[$funktion]) || !isset($preset[$funktion]['widgets'])) + $result[$funktion] = []; + else + $result[$funktion] = $preset[$funktion]['widgets']; + } else { + $result[$funktion] = []; + } + } + + return $this->terminateWithSuccess($result); + } + + public function addWidget() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('dashboard', 'Dashboard', 'required'); + $this->form_validation->set_rules('funktion_kurzbz', 'Funktion', 'required'); + $this->form_validation->set_rules('widget[widget]', 'Widget', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $dashboard_kurzbz = $this->input->post('dashboard'); + $funktion_kurzbz = $this->input->post('funktion_kurzbz'); + $widget = $this->input->post('widget'); + + if (!isset($widget['widgetid'])) + $widget['widgetid'] = $this->dashboardlib->generateWidgetId($dashboard_kurzbz); + + $preset = $this->dashboardlib->getPresetOrCreateEmptyPreset($dashboard_kurzbz, $funktion_kurzbz); + + $preset_decoded = json_decode($preset->preset, true); + + $this->dashboardlib->addWidgetsToWidgets($preset_decoded, $dashboard_kurzbz, $funktion_kurzbz, [$widget]); + + $preset->preset = json_encode($preset_decoded); + + $result = $this->dashboardlib->insertOrUpdatePreset($preset); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($widget['widgetid']); + } + + public function removeWidget() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('db', 'Dashboard', 'required'); + $this->form_validation->set_rules('funktion_kurzbz', 'Funktion', 'required'); + $this->form_validation->set_rules('widgetid', 'Widget', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $dashboard_kurzbz = $this->input->post('db'); + $funktion_kurzbz = $this->input->post('funktion_kurzbz'); + $widgetid = $this->input->post('widgetid'); + + $preset = $this->dashboardlib->getPreset($dashboard_kurzbz, $funktion_kurzbz); + if (!$preset) + show_404(); + + $preset_decoded = json_decode($preset->preset, true); + + if (!$this->dashboardlib->removeWidgetFromWidgets($preset_decoded, $funktion_kurzbz, $widgetid)) + show_404(); + + $preset->preset = json_encode($preset_decoded); + + $result = $this->dashboardlib->insertOrUpdatePreset($preset); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(array('msg' => $this->p->t('dashboard', 'success_savePreset'))); + } +} diff --git a/application/controllers/api/frontend/v1/dashboard/User.php b/application/controllers/api/frontend/v1/dashboard/User.php new file mode 100644 index 000000000..9d020649e --- /dev/null +++ b/application/controllers/api/frontend/v1/dashboard/User.php @@ -0,0 +1,159 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about the users dashboard + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class User extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'get' => 'dashboard/benutzer:r', + 'addWidget' => 'dashboard/benutzer:rw', + 'removeWidget' => 'dashboard/benutzer:rw' + ]); + + // Libraries + $this->load->library('dashboard/DashboardLib'); + + // Models + $this->load->model('ressource/Funktion_model', 'FunktionModel'); + } + + public function get($dashboard_kurzbz) + { + $dashboard = $this->dashboardlib->getDashboardByKurzbz($dashboard_kurzbz); + if (!$dashboard) + show_404(); + + $uid = $this->authlib->getAuthObj()->username; + + /*$mergedconfig = $this->dashboardlib->getMergedConfig($dashboard->dashboard_id, $uid); + + $this->terminateWithSuccess([ + 'general' => call_user_func_array( + 'array_merge_recursive', + $mergedconfig + ) + ]);*/ + $defaultconfig = $this->dashboardlib->getDefaultConfig($dashboard->dashboard_id); + $userconfig = $this->dashboardlib->getUserConfig($dashboard->dashboard_id, $uid); + + $defaultconfig_squashed = $defaultconfig ? call_user_func_array('array_replace_recursive', $defaultconfig) : []; + $userconfig_squashed = $userconfig ? call_user_func_array('array_replace_recursive', $userconfig) : []; + + $mergedconfig = array_replace_recursive($defaultconfig_squashed, $userconfig_squashed); + + $this->terminateWithSuccess([ + DashboardLib::SECTION_IF_FUNKTION_KURZBZ_IS_NULL => $mergedconfig + ]); + } + + public function addWidget() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('dashboard', 'Dashboard', 'required'); + $this->form_validation->set_rules('widget[widget]', 'Widget', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $widget = $this->input->post('widget'); + $dashboard_kurzbz = $this->input->post('dashboard'); + $uid = $this->authlib->getAuthObj()->username; + + if (!isset($widget['widgetid'])) + $widget['widgetid'] = $this->dashboardlib->generateWidgetId($dashboard_kurzbz); + + $override = $this->dashboardlib->getOverrideOrCreateEmptyOverride($dashboard_kurzbz, $uid); + + $override_decoded = json_decode($override->override, true); + + if (!isset($override_decoded['general']) || !is_array($override_decoded['general'])) + $override_decoded['general'] = []; + + if (!isset($override_decoded['general']['widgets'])) + $override_decoded['general']['widgets'] = []; + + $override_decoded['general']['widgets'][$widget['widgetid']] = $widget; + + // NOTE(chris): remove doubles in other funktionen + foreach ($override_decoded as $funktion => $array) { + if ($funktion == 'general') + continue; + if (isset($array['widgets']) && isset($array['widgets'][$widget['widgetid']])) + unset($override_decoded[$funktion]['widgets'][$widget['widgetid']]); + } + + $override->override = json_encode($override_decoded); + + $result = $this->dashboardlib->insertOrUpdateOverride($override); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($widget['widgetid']); + } + + public function removeWidget() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('dashboard', 'Dashboard', 'required'); + $this->form_validation->set_rules('widget', 'Widget', 'required'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $widget_id = $this->input->post('widget'); + $dashboard_kurzbz = $this->input->post('dashboard'); + $uid = $this->authlib->getAuthObj()->username; + + $override = $this->dashboardlib->getOverride($dashboard_kurzbz, $uid); + if (!$override) + show_404(); + + $override_decoded = json_decode($override->override, true); + + foreach (array_keys($override_decoded) as $k) { + if (!isset($override_decoded[$k]["widgets"])) { + unset($override_decoded[$k]); + continue; + } + if (isset($override_decoded[$k]["widgets"][$widget_id])) { + unset($override_decoded[$k]["widgets"][$widget_id]); + } + if (!$override_decoded[$k]["widgets"]) { + unset($override_decoded[$k]); + } + } + + $override->override = json_encode($override_decoded); + + $result = $this->dashboardlib->insertOrUpdateOverride($override); + + $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess(); + } +} diff --git a/application/controllers/api/frontend/v1/dashboard/Widget.php b/application/controllers/api/frontend/v1/dashboard/Widget.php new file mode 100644 index 000000000..ac8c682e8 --- /dev/null +++ b/application/controllers/api/frontend/v1/dashboard/Widget.php @@ -0,0 +1,137 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the back-end + * Provides data to the ajax get calls about the users dashboard + * This controller works with JSON calls on the HTTP GET or POST and the output is always JSON + */ +class Widget extends FHCAPI_Controller +{ + public function __construct() + { + parent::__construct([ + 'get' => ['dashboard/benutzer:r', 'dashboard/admin:r'], + 'list' => 'dashboard/admin:r', + 'listAllowed' => ['dashboard/benutzer:rw', 'dashboard/admin:r'], + 'setAllowed' => 'dashboard/admin:rw' + ]); + + // Libraries + $this->load->library('dashboard/DashboardLib'); + + // Models + $this->load->model('dashboard/Widget_model', 'WidgetModel'); + } + + public function get($id) + { + $result = $this->WidgetModel->load($id); + + $widget = $this->getDataOrTerminateWithError($result); + + if (!$widget) + return $this->terminateWithSuccess([ + "widget_id" => 0, + "widget_kurzbz" => "notfound", + "arguments" => [ + "className" => 'alert-danger', + "title" => 'Widget Not Found', + "msg" => 'The widget with the id ' . $id . ' could not be found' + ], + "setup" => [ + "name" => 'Widget Not Found', + "file" => absoluteJsImportUrl('public/js/components/DashboardWidget/Default.js'), + "width" => 1, + "height" => 1 + ] + ]); + + $widget = current($widget); + $widget->arguments = json_decode($widget->arguments); + $tmpsetup = json_decode($widget->setup); + $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); + $widget->setup = $tmpsetup; + + $this->terminateWithSuccess($widget); + } + + public function list($dashboard) + { + $result = $this->WidgetModel->getWithAllowedForDashboard($dashboard); + + $widgets = $this->getDataOrTerminateWithError($result); + + $widgets = array_map(function ($widget) { + $widget->arguments = json_decode($widget->arguments); + $tmpsetup = json_decode($widget->setup); + $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); + $widget->setup = $tmpsetup; + return $widget; + }, $widgets); + + $this->terminateWithSuccess($widgets); + } + + public function listAllowed($dashboard) + { + $result = $this->WidgetModel->getForDashboard($dashboard); + + $widgets = $this->getDataOrTerminateWithError($result); + + $widgets = array_map(function ($widget) { + $widget->arguments = json_decode($widget->arguments); + $tmpsetup = json_decode($widget->setup); + $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); + $widget->setup = $tmpsetup; + return $widget; + }, $widgets); + + $this->terminateWithSuccess($widgets); + } + + public function setAllowed() + { + $this->load->library('form_validation'); + + $this->form_validation->set_rules('dashboard_id', 'Dashboard', 'required'); + $this->form_validation->set_rules('widget_id', 'Widget', 'required'); + $this->form_validation->set_rules('allowed', 'Allowed', 'is_bool'); + + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); + + $data = [ + 'dashboard_id' => $this->input->post('dashboard_id'), + 'widget_id' => $this->input->post('widget_id') + ]; + + $this->load->model('dashboard/Dashboard_Widget_model', 'DashboardWidgetModel'); + + if ($this->input->post('allowed')) + $result = $this->DashboardWidgetModel->insert($data); + else + $result = $this->DashboardWidgetModel->delete($data); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + } +} diff --git a/application/controllers/api/frontend/v1/messages/Messages.php b/application/controllers/api/frontend/v1/messages/Messages.php index 3035e532d..77b46f97b 100644 --- a/application/controllers/api/frontend/v1/messages/Messages.php +++ b/application/controllers/api/frontend/v1/messages/Messages.php @@ -42,14 +42,22 @@ class Messages extends FHCAPI_Controller ]); } - public function getMessages($id, $type_id, $size, $page) + public function getMessages($id, $type_id, $size=null, $page=null) { if($type_id != 'person_id'){ $id = $this->_getPersonId($id, $type_id); } - $offset = $size * ($page - 1); - $limit = $size; + if(!(is_null($size) && is_null($page))) + { + $offset = $size * ($page - 1); + $limit = $size; + } + else + { + $offset = null; + $limit = null; + } $result = $this->MessageModel->getMessagesForTable($id, $offset, $limit); diff --git a/application/controllers/api/frontend/v1/stv/Students.php b/application/controllers/api/frontend/v1/stv/Students.php index 55f4b8976..f87e527e0 100644 --- a/application/controllers/api/frontend/v1/stv/Students.php +++ b/application/controllers/api/frontend/v1/stv/Students.php @@ -626,7 +626,7 @@ class Students extends FHCAPI_Controller $this->addFilter($studiensemester_kurzbz); $result = $this->PrestudentModel->loadWhere($where); - + $data = $this->getDataOrTerminateWithError($result); $this->terminateWithSuccess($data); @@ -851,40 +851,44 @@ class Students extends FHCAPI_Controller $stdsemEsc = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL'; $this->load->config('stv'); - $tags = $this->config->item('stv_prestudent_tags'); - $whereTags = ''; - if (is_array($tags) && !isEmptyArray($tags)) { - $tags = array_keys($tags); + if(defined('STV_TAGS_ENABLED') && STV_TAGS_ENABLED) + { + $tags = $this->config->item('stv_prestudent_tags'); - foreach ($tags as $key => $tag) { - $tags[$key] = $this->db->escape($tag); + $whereTags = ''; + if (is_array($tags) && !isEmptyArray($tags)) { + $tags = array_keys($tags); + + foreach ($tags as $key => $tag) { + $tags[$key] = $this->db->escape($tag); + } + $whereTags = " AND nt.typ_kurzbz IN (" . implode(",", $tags) . ")"; } - $whereTags = " AND nt.typ_kurzbz IN (" . implode(",", $tags) . ")"; + $subQueryTag = " + ( + SELECT + tag.prestudent_id, + COALESCE(json_agg(tag ORDER BY tag.done), '[]'::json) AS tags + FROM ( + SELECT DISTINCT ON (n.notiz_id) + n.notiz_id AS id, + nt.typ_kurzbz, + array_to_json(nt.bezeichnung_mehrsprachig)->>0 AS beschreibung, + n.text AS notiz, + nt.style, + n.erledigt AS done, + nz.prestudent_id + FROM public.tbl_notizzuordnung AS nz + JOIN public.tbl_notiz AS n ON nz.notiz_id = n.notiz_id + JOIN public.tbl_notiz_typ AS nt ON n.typ = nt.typ_kurzbz " + . $whereTags . + " + ) AS tag + GROUP BY tag.prestudent_id + ) AS tag_data_agg + "; } - $subQueryTag = " - ( - SELECT - tag.prestudent_id, - COALESCE(json_agg(tag ORDER BY tag.done), '[]'::json) AS tags - FROM ( - SELECT DISTINCT ON (n.notiz_id) - n.notiz_id AS id, - nt.typ_kurzbz, - array_to_json(nt.bezeichnung_mehrsprachig)->>0 AS beschreibung, - n.text AS notiz, - nt.style, - n.erledigt AS done, - nz.prestudent_id - FROM public.tbl_notizzuordnung AS nz - JOIN public.tbl_notiz AS n ON nz.notiz_id = n.notiz_id - JOIN public.tbl_notiz_typ AS nt ON n.typ = nt.typ_kurzbz " - . $whereTags . - " - ) AS tag - GROUP BY tag.prestudent_id - ) AS tag_data_agg - "; $this->PrestudentModel->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT'); $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); @@ -907,11 +911,17 @@ class Students extends FHCAPI_Controller AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT'); - $this->PrestudentModel->addJoin($subQueryTag, 'tag_data_agg.prestudent_id = tbl_prestudent.prestudent_id', 'LEFT'); + if(defined('STV_TAGS_ENABLED') && STV_TAGS_ENABLED) + { + $this->PrestudentModel->addJoin($subQueryTag, 'tag_data_agg.prestudent_id = tbl_prestudent.prestudent_id', 'LEFT'); + } $this->PrestudentModel->addSelect("b.uid"); - $this->PrestudentModel->addSelect('tag_data_agg.tags'); + if(defined('STV_TAGS_ENABLED') && STV_TAGS_ENABLED) + { + $this->PrestudentModel->addSelect('tag_data_agg.tags'); + } $this->PrestudentModel->addSelect('titelpre'); $this->PrestudentModel->addSelect('nachname'); $this->PrestudentModel->addSelect('vorname'); diff --git a/application/controllers/dashboard/Admin.php b/application/controllers/dashboard/Admin.php new file mode 100644 index 000000000..702c04bab --- /dev/null +++ b/application/controllers/dashboard/Admin.php @@ -0,0 +1,52 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + */ +class Admin extends Auth_Controller +{ + /** + * Constructor + */ + public function __construct() + { + // Set required permissions + parent::__construct( + array( + 'index' => 'dashboard/admin:rw', + 'preview' => 'dashboard/admin:r', + ) + ); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + public function index() + { + $this->load->view('dashboard/admin.php', []); + } + + public function preview($dashboard_kurzbz = 'CIS') + { + $this->load->view('dashboard/preview.php', [ + 'dashboard_kurzbz' => $dashboard_kurzbz + ]); + } +} diff --git a/application/controllers/dashboard/Api.php b/application/controllers/dashboard/Api.php deleted file mode 100644 index 422bf0675..000000000 --- a/application/controllers/dashboard/Api.php +++ /dev/null @@ -1,76 +0,0 @@ - 'dashboard/admin:rw', - 'getNews' => 'dashboard/benutzer:r', - 'getAmpeln' => 'dashboard/benutzer:r', - ) - ); - - $this->load->library('AuthLib', null, 'AuthLib'); - - $this->_setAuthUID(); - } - - public function index() - { - echo 'Dashboard API Controller'; - } - - /** - * Get News. - */ - public function getNews() - { - $limit = $this->input->get('limit'); - - $this->load->model('content/News_model', 'NewsModel'); - - $result = $this->NewsModel->getAll($limit); - - if (hasData($result)) - { - $this->outputJson(getData($result), REST_Controller::HTTP_OK); - } - else - { - $this->terminateWithJsonError('fehler entdeckt'); - } - } - - - /** - * Get Ampeln. - */ - public function getAmpeln() - { - - $this->load->model('content/Ampel_model', 'AmpelModel'); - $result = $this->AmpelModel->getByUser($this->_uid); - - if (hasData($result)) - { - $this->outputJson(getData($result), REST_Controller::HTTP_OK); - } - else - { - $this->terminateWithJsonError('fehler entdeckt'); - } - } - - /** - * Retrieve the UID of the logged user and checks if it is valid - */ - private function _setAuthUID() - { - $this->_uid = getAuthUID(); - - if (!$this->_uid) show_error('User authentification failed'); - } -} diff --git a/application/controllers/dashboard/Config.php b/application/controllers/dashboard/Config.php deleted file mode 100644 index f6db9509f..000000000 --- a/application/controllers/dashboard/Config.php +++ /dev/null @@ -1,216 +0,0 @@ - 'dashboard/benutzer:r', - 'dummy' => 'dashboard/benutzer:r', - 'genWidgetId' => 'dashboard/benutzer:rw', - 'addWidgetsToPreset' => 'dashboard/admin:rw', - 'removeWidgetFromPreset' => 'dashboard/admin:rw', - 'addWidgetsToUserOverride' => 'dashboard/benutzer:rw', - 'removeWidgetFromUserOverride' => 'dashboard/benutzer:rw', - 'funktionen' => 'dashboard/admin:r', - 'preset' => 'dashboard/admin:r', - 'presetBatch' => 'dashboard/admin:r' - ) - ); - - $this->load->library('dashboard/DashboardLib', null, 'DashboardLib'); - $this->load->library('AuthLib', null, 'AuthLib'); - $this->load->model('ressource/Funktion_model', 'FunktionModel'); - } - - public function index() - { - $dashboard_kurzbz = $this->input->get('db'); - $uid = $this->AuthLib->getAuthObj()->username; - - $dashboard = $this->DashboardLib->getDashboardByKurzbz($dashboard_kurzbz); - if(!$dashboard) { - http_response_code(404); - $this->terminateWithJsonError(array( - 'error' => 'Dashboard ' . $dashboard_kurzbz . ' not found.' - )); - } - - $mergedconfig = $this->DashboardLib->getMergedConfig($dashboard->dashboard_id, $uid); - $this->outputJsonSuccess($mergedconfig); - } - - public function genWidgetId() - { - $dashboard_kurzbz = $this->input->get('db'); - $widgetid = $this->DashboardLib->generateWidgetId($dashboard_kurzbz); - $this->outputJsonSuccess(array( - 'widgetid' => $widgetid - )); - } - - public function addWidgetsToPreset() - { - $input = json_decode($this->input->raw_input_stream); - $dashboard_kurzbz = $input->db; - $funktion_kurzbz = $input->funktion_kurzbz; - - $preset = $this->DashboardLib->getPresetOrCreateEmptyPreset($dashboard_kurzbz, $funktion_kurzbz); - - $preset_decoded = json_decode($preset->preset, true); - - $this->DashboardLib->addWidgetsToWidgets($preset_decoded, $dashboard_kurzbz, $funktion_kurzbz, $input->widgets); - - $preset->preset = json_encode($preset_decoded); - - $result = $this->DashboardLib->insertOrUpdatePreset($preset); - if (isError($result)) { - http_response_code(500); - $this->terminateWithJsonError('preset could not be saved'); - } - - $this->outputJsonSuccess(array('msg' => 'preset successfully stored.', 'data' => $preset_decoded)); - } - - public function removeWidgetFromPreset() - { - $input = json_decode($this->input->raw_input_stream); - $dashboard_kurzbz = $input->db; - $funktion_kurzbz = $input->funktion_kurzbz; - $widgetid = $input->widgetid; - - $preset = $this->DashboardLib->getPreset($dashboard_kurzbz, $funktion_kurzbz); - if ($preset === null) { - http_response_code(404); - $this->terminateWithJsonError('preset for dashboard ' . $dashboard_kurzbz . ' and funktion ' . $funktion_kurzbz . ' not found.'); - } - - $preset_decoded = json_decode($preset->preset, true); - if (!$this->DashboardLib->removeWidgetFromWidgets($preset_decoded, $funktion_kurzbz, $widgetid)) - { - http_response_code(404); - $this->terminateWithJsonError('widgetid ' . $widgetid . ' not found'); - } - - $preset->preset = json_encode($preset_decoded); - $result = $this->DashboardLib->insertOrUpdatePreset($preset); - if (isError($result)) - { - http_response_code(500); - $this->terminateWithJsonError('failed to remove widget'); - } - $this->outputJsonSuccess(array('msg' => 'preset successfully updated.')); - } - - public function addWidgetsToUserOverride() - { - $input = json_decode($this->input->raw_input_stream); - $dashboard_kurzbz = $input->db; - $funktion_kurzbz = $input->funktion_kurzbz; - $uid = $this->AuthLib->getAuthObj()->username; - - $override = $this->DashboardLib->getOverrideOrCreateEmptyOverride($dashboard_kurzbz, $uid); - - $override_decoded = json_decode($override->override, true); - - $this->DashboardLib->addWidgetsToWidgets($override_decoded, $dashboard_kurzbz, $funktion_kurzbz, $input->widgets); - - $override->override = json_encode($override_decoded); - - $result = $this->DashboardLib->insertOrUpdateOverride($override); - if (isError($result)) { - http_response_code(500); - $this->terminateWithJsonError('override could not be saved'); - } - - $this->outputJsonSuccess(array('msg' => 'override successfully stored.', 'data' => $override_decoded)); - } - - public function removeWidgetFromUserOverride() - { - $input = json_decode($this->input->raw_input_stream); - $dashboard_kurzbz = $input->db; - $funktion_kurzbz = $input->funktion_kurzbz; - $uid = $this->AuthLib->getAuthObj()->username; - $widgetid = $input->widgetid; - - $override = $this->DashboardLib->getOverride($dashboard_kurzbz, $uid); - if (empty($override)) { - http_response_code(404); - $this->terminateWithJsonError('userconfig for dashboard ' . $dashboard_kurzbz . ' not found.'); - } - - $override_decoded = json_decode($override->override, true); - - if (!$this->DashboardLib->removeWidgetFromWidgets($override_decoded, $funktion_kurzbz, $widgetid)) - { - http_response_code(404); - $this->terminateWithJsonError('widgetid ' . $widgetid . ' not found'); - } - - $override->override = json_encode($override_decoded); - $result = $this->DashboardLib->insertOrUpdateOverride($override, $uid); - if (isError($result)) - { - http_response_code(500); - $this->terminateWithJsonError('failed to remove widget'); - } - $this->outputJsonSuccess(array('msg' => 'override successfully updated.')); - } - - public function funktionen() - { - $funktionen = $this->FunktionModel->load(); - - if (isError($funktionen)) { - http_response_code(404); - $this->terminateWithJsonError([ - 'error' => getError($funktionen) - ]); - } - - return $this->outputJsonSuccess(getData($funktionen) ?: []); - } - - public function preset() - { - $db = $this->input->get('db'); - $funktion = $this->input->get('funktion'); - - $conf = $this->DashboardLib->getPreset($db, $funktion); - - if (!$conf) - return $this->outputJsonSuccess(['widgets' => [$funktion => []]]); - - return $this->outputJsonSuccess(json_decode($conf->preset, true)); - } - - public function presetBatch() - { - $db = $this->input->get('db'); - $funktionen = $this->input->get('funktionen'); - $result = []; - - foreach ($funktionen as $funktion) { - $conf = $this->DashboardLib->getPreset($db, $funktion); - if ($conf) - { - $preset = json_decode($conf->preset, true); - if (!isset($preset[$funktion]) || !isset($preset[$funktion]['widgets'])) - $result[$funktion] = []; - else - $result[$funktion] = $preset[$funktion]['widgets']; - } - else - $result[$funktion] = []; - } - - return $this->outputJsonSuccess($result); - } -} diff --git a/application/controllers/dashboard/Dashboard.php b/application/controllers/dashboard/Dashboard.php deleted file mode 100644 index 3773a6d73..000000000 --- a/application/controllers/dashboard/Dashboard.php +++ /dev/null @@ -1,86 +0,0 @@ - 'dashboard/admin:r', - 'create' => 'dashboard/admin:rw', - 'update' => 'dashboard/admin:rw', - 'delete' => 'dashboard/admin:rw' - ) - ); - - $this->load->library('dashboard/DashboardLib', null, 'DashboardLib'); - $this->load->model('dashboard/Dashboard_model', 'DashboardModel'); - } - - public function index() - { - $result = $this->DashboardModel->load(); - - if (isError($result)) { - http_response_code(404); - $this->terminateWithJsonError([ - 'error' => getError($result) - ]); - } - - return $this->outputJsonSuccess(getData($result) ?: []); - } - - public function create() - { - $input = $this->getPostJSON(); - - $result = $this->DashboardModel->insert($input); - - if (isError($result)) { - http_response_code(404); - $this->terminateWithJsonError([ - 'error' => getError($result) - ]); - } - - return $this->outputJsonSuccess(getData($result) ?: []); - } - - public function update() - { - $input = $this->getPostJSON(); - - $result = $this->DashboardModel->update($input->dashboard_id, $input); - - if (isError($result)) { - http_response_code(404); - $this->terminateWithJsonError([ - 'error' => getError($result) - ]); - } - - return $this->outputJsonSuccess(getData($result) ?: []); - } - - public function delete() - { - $input = $this->getPostJSON(); - - $result = $this->DashboardModel->delete($input->dashboard_id); - - if (isError($result)) { - http_response_code(404); - $this->terminateWithJsonError([ - 'error' => getError($result) - ]); - } - - return $this->outputJsonSuccess(getData($result) ?: []); - } -} diff --git a/application/controllers/dashboard/DashboardDemo.php b/application/controllers/dashboard/DashboardDemo.php deleted file mode 100644 index 35d530384..000000000 --- a/application/controllers/dashboard/DashboardDemo.php +++ /dev/null @@ -1,58 +0,0 @@ - 'dashboard/benutzer:r', - 'admin' => 'dashboard/admin:rw' - ) - ); - - $this->load->library('AuthLib'); - $this->load->library('WidgetLib'); - - $this->_setAuthUID(); // sets property uid - - $this->setControllerId(); // sets the controller id - } - - // ----------------------------------------------------------------------------------------------------------------- - // Public methods - public function index() - { - $this->load->view('dashboard/dashboard_demo.php', []); - } - - // ----------------------------------------------------------------------------------------------------------------- - // Public methods - public function admin() - { - $this->load->view('dashboard/dashboard_demo_admin.php', []); - } - - // ----------------------------------------------------------------------------------------------------------------- - // Private methods - - /** - * Retrieve the UID of the logged user and checks if it is valid - */ - private function _setAuthUID() - { - $this->_uid = getAuthUID(); - - if (!$this->_uid) show_error('User authentification failed'); - } -} diff --git a/application/controllers/dashboard/Widget.php b/application/controllers/dashboard/Widget.php deleted file mode 100644 index 9966ddc12..000000000 --- a/application/controllers/dashboard/Widget.php +++ /dev/null @@ -1,134 +0,0 @@ - ['dashboard/benutzer:r', 'dashboard/admin:r'], - 'getAll' => 'dashboard/admin:r', - 'getWidgetsForDashboard' => ['dashboard/benutzer:rw', 'dashboard/admin:r'], - 'setAllowed' => 'dashboard/admin:rw' - ) - ); - - $this->load->library('dashboard/DashboardLib', null, 'DashboardLib'); - $this->load->model('dashboard/Widget_model', 'WidgetModel'); - $this->load->model('dashboard/Dashboard_Widget_model', 'DashboardWidgetModel'); - } - - public function index() - { - $widget_id = $this->input->get('id'); - - $widget = $this->WidgetModel->load($widget_id); - - if (isError($widget) || !getData($widget)) - return $this->outputJsonSuccess([ - "widget_id" => 0, - "widget_kurzbz" => "notfound", - "arguments" => [ - "className" => 'alert-danger', - "title" => 'Widget Not Found', - "msg" => 'The widget with the id ' . $widget_id . ' could not be found' - ], - "setup" => [ - "name" => 'Widget Not Found', - "file" => absoluteJsImportUrl('public/js/components/DashboardWidget/Default.js'), - "width" => 1, - "height" => 1 - ] - ]); - - $widget = current(getData($widget)); - $widget->arguments = json_decode($widget->arguments); - $tmpsetup = json_decode($widget->setup); - $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); - $widget->setup = $tmpsetup; - - return $this->outputJsonSuccess($widget); - } - - public function getAll() - { - $dashboard_id = $this->input->get('dashboard_id'); - $result = $this->WidgetModel->getWithAllowedForDashboard($dashboard_id); - - if (isError($result)) - return $this->outputJsonError(getError($result)); - - $tmpwidgets = getData($result) ?: []; - $widgets = array_map(function($widget) { - $widget->arguments = json_decode($widget->arguments); - $tmpsetup = json_decode($widget->setup); - $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); - $widget->setup = $tmpsetup; - return $widget; - }, $tmpwidgets); - - $this->outputJsonSuccess($widgets); - } - - public function getWidgetsForDashboard() - { - $db = $this->input->get('db'); - $result = $this->WidgetModel->getForDashboard($db); - - if (isError($result)) { - http_response_code(404); - $this->terminateWithJsonError([ - 'error' => getError($result) - ]); - } - - $tmpwidgets = getData($result) ?: []; - $widgets = array_map(function($widget) { - $widget->arguments = json_decode($widget->arguments); - $tmpsetup = json_decode($widget->setup); - $tmpsetup->file = absoluteJsImportUrl($tmpsetup->file); - $widget->setup = $tmpsetup; - return $widget; - }, $tmpwidgets); - - $this->outputJsonSuccess($widgets); - } - - public function setAllowed() - { - $input = $this->getPostJSON(); - - $dashboard_id = $input->dashboard_id; - $widget_id = $input->widget_id; - $action = $input->action; - - if ($action == 'add') { - $result = $this->DashboardWidgetModel->insert([ - 'dashboard_id' => $dashboard_id, - 'widget_id' => $widget_id - ]); - } elseif ($action == 'delete') { - $result = $this->DashboardWidgetModel->delete([ - 'dashboard_id' => $dashboard_id, - 'widget_id' => $widget_id - ]); - } else { - http_response_code(404); // TODO(chris): 400? - $this->terminateWithJsonError([ - 'error' => 'action value invalid' - ]); - } - if (isError($result)) { - http_response_code(404); - $this->terminateWithJsonError([ - 'error' => getError($result) - ]); - } - return $this->outputJsonSuccess(getData($result)); - } -} diff --git a/application/libraries/PermissionLib.php b/application/libraries/PermissionLib.php index 42502f999..d3fdc6642 100644 --- a/application/libraries/PermissionLib.php +++ b/application/libraries/PermissionLib.php @@ -50,6 +50,7 @@ class PermissionLib const LOGINAS_PERSONIDS_BLACKLIST = 'permission_loginas_personids_blacklist'; private $_ci; // CI instance + private $access_rights; // current users access rights private static $bb; // benutzerberechtigung /** @@ -61,6 +62,8 @@ class PermissionLib // Loads CI instance $this->_ci =& get_instance(); + $this->access_rights = null; + $this->_ci->config->load('permission'); // Loads permission configuration // If it's NOT called from command line @@ -69,8 +72,10 @@ class PermissionLib // API Caller rights initialization $authObj = $this->_ci->authlib->getAuthObj(); self::$bb = new benutzerberechtigung(); - if ($authObj) + if ($authObj) { self::$bb->getBerechtigungen($authObj->{AuthLib::AO_USERNAME}); + $this->access_rights = self::$bb->berechtigungen; + } } } @@ -340,6 +345,16 @@ class PermissionLib } } + /** + * Returns the access rights for the current user + * + * @return array|null + */ + public function getAccessRights() + { + return $this->access_rights; + } + //------------------------------------------------------------------------------------------------------------------ // Private methods diff --git a/application/libraries/dashboard/DashboardLib.php b/application/libraries/dashboard/DashboardLib.php index f6d7d6599..1c3983108 100644 --- a/application/libraries/dashboard/DashboardLib.php +++ b/application/libraries/dashboard/DashboardLib.php @@ -49,7 +49,7 @@ class DashboardLib public function getMergedConfig($dashboard_id, $uid) { - $defaultconfig = $this->getDefaultConfig($dashboard_id, $uid); + $defaultconfig = $this->getDefaultConfig($dashboard_id); $userconfig = $this->getUserConfig($dashboard_id, $uid); $mergedconfig = array_replace_recursive($defaultconfig, $userconfig); @@ -57,14 +57,31 @@ class DashboardLib return $mergedconfig; } - public function getDefaultConfig($dashboard_id, $uid) + public function getDefaultConfig($dashboard_id) { - $res_presets = $this->_ci->DashboardPresetModel->getPresets($dashboard_id, $uid); + $funktion_kurzbzs = []; + $rights = $this->_ci->permissionlib->getAccessRights(); + if ($rights) + $funktion_kurzbzs = array_unique(array_map(function ($right) { + return $right->funktion_kurzbz; + }, $rights)); + + $this->_ci->DashboardPresetModel->db + ->group_start() + ->where_in('funktion_kurzbz', $funktion_kurzbzs) + ->or_where('funktion_kurzbz IS NULL') + ->group_end(); + + $this->_ci->DashboardPresetModel->addOrder('funktion_kurzbz', 'DESC'); + + $result = $this->_ci->DashboardPresetModel->loadWhere([ + 'dashboard_id' => $dashboard_id + ]); $defaultconfig = array(); - if (hasData($res_presets)) + if (hasData($result)) { - $presets = getData($res_presets); + $presets = getData($result); foreach ($presets as $presetobj) { $preset = json_decode($presetobj->preset, true); @@ -137,8 +154,10 @@ class DashboardLib $dashboard = $this->getDashboardByKurzbz($dashboard_kurzbz); $funktion_kurzbz = ($section === self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL) ? null : $section; - $result = $this->_ci->DashboardPresetModel - ->getPresetByDashboardAndFunktion($dashboard->dashboard_id, $funktion_kurzbz); + $result = $this->_ci->DashboardPresetModel->loadWhere([ + 'dashboard_id' => $dashboard->dashboard_id, + 'funktion_kurzbz' => $funktion_kurzbz + ]); if (hasData($result)) { @@ -195,11 +214,11 @@ class DashboardLib { foreach ($addwigets as $widget) { - if(!isset($widget->widgetid)) + if(!isset($widget['widgetid'])) { - $widget->widgetid = $this->generateWidgetId($dashboard_kurzbz); + $widget['widgetid'] = $this->generateWidgetId($dashboard_kurzbz); } - $this->addWidgetToWidgets($widgets, $section, $widget, $widget->widgetid); + $this->addWidgetToWidgets($widgets, $section, $widget, $widget['widgetid']); } } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php b/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php index 6e7b0af06..50504099a 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php @@ -3,6 +3,7 @@ namespace vertragsbestandteil; use Exception; use vertragsbestandteil\VertragsbestandteilStunden; +use vertragsbestandteil\VertragsbestandteilLohnguide; /** * Description of VertragsbestandteilFactory @@ -22,6 +23,7 @@ class VertragsbestandteilFactory const VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH = 'urlaubsanspruch'; const VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG = 'zeitaufzeichnung'; const VERTRAGSBESTANDTEIL_LEHRE = 'lehre'; + const VERTRAGSBESTANDTEIL_LOHNGUIDE = 'lohnguide'; public static function getVertragsbestandteil($data, $fromdb=false) { @@ -69,6 +71,11 @@ class VertragsbestandteilFactory $vertragsbestandteil = new VertragsbestandteilZeitaufzeichnung(); $vertragsbestandteil->hydrateByStdClass($data, $fromdb); break; + + case self::VERTRAGSBESTANDTEIL_LOHNGUIDE: + $vertragsbestandteil = new VertragsbestandteilLohnguide(); + $vertragsbestandteil->hydrateByStdClass($data, $fromdb); + break; default: throw new Exception('Unknown vertragsbestandteiltyp_kurzbz ' @@ -127,6 +134,12 @@ class VertragsbestandteilFactory $vertragsbestandteildbmodel = $CI->VertragsbestandteilZeitaufzeichnung_model; break; + case self::VERTRAGSBESTANDTEIL_LOHNGUIDE: + $CI->load->model('vertragsbestandteil/VertragsbestandteilLohnguide_model', + 'VertragsbestandteilLohnguide_model'); + $vertragsbestandteildbmodel = $CI->VertragsbestandteilLohnguide_model; + break; + default: throw new Exception('Unknown vertragsbestandteil_kurzbz ' . $vertragsbestandteil_kurzbz); diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php index 1ecb9ac60..61208eda0 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php @@ -10,6 +10,7 @@ require_once __DIR__ . '/VertragsbestandteilKuendigungsfrist.php'; require_once __DIR__ . '/VertragsbestandteilUrlaubsanspruch.php'; require_once __DIR__ . '/VertragsbestandteilFreitext.php'; require_once __DIR__ . '/VertragsbestandteilKarenz.php'; +require_once __DIR__ . '/VertragsbestandteilLohnguide.php'; require_once __DIR__ . '/VertragsbestandteilFactory.php'; require_once __DIR__ . '/OverlapChecker.php'; diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLohnguide.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLohnguide.php new file mode 100644 index 000000000..0e071f36b --- /dev/null +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilLohnguide.php @@ -0,0 +1,155 @@ +setVertragsbestandteiltyp_kurzbz( + VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_LOHNGUIDE); + } + + public function getStellenbezeichnung() + { + return $this->stellenbezeichnung; + } + + public function setStellenbezeichnung($stellenbezeichnung): self + { + $this->markDirty('stellenbezeichnung', $this->stellenbezeichnung, $stellenbezeichnung); + $this->stellenbezeichnung = $stellenbezeichnung; + return $this; + } + + public function getVordienstzeit() + { + return $this->vordienstzeit; + } + + public function setVordienstzeit($vordienstzeit): self + { + $this->markDirty('vordienstzeit', $this->vordienstzeit, $vordienstzeit); + $this->vordienstzeit = $vordienstzeit; + return $this; + } + + public function getFachrichtung_kurzbz() + { + return $this->fachrichtung_kurzbz; + } + + public function setFachrichtung_kurzbz($fachrichtung_kurzbz): self + { + $this->markDirty('fachrichtung_kurzbz', $this->fachrichtung_kurzbz, $fachrichtung_kurzbz); + $this->fachrichtung_kurzbz = $fachrichtung_kurzbz; + return $this; + } + + public function getModellstelle_kurzbz() + { + return $this->modellstelle_kurzbz; + } + + public function setModellstelle_kurzbz($modellstelle_kurzbz): self + { + $this->markDirty('modellstelle_kurzbz', $this->modellstelle_kurzbz, $modellstelle_kurzbz); + $this->modellstelle_kurzbz = $modellstelle_kurzbz; + return $this; + } + + public function getKommentar_person() + { + return $this->kommentar_person; + } + + public function setKommentar_person($kommentar_person): self + { + $this->markDirty('kommentar_person', $this->kommentar_person, $kommentar_person); + $this->kommentar_person = $kommentar_person; + return $this; + } + + public function getKommentar_modellstelle() + { + return $this->kommentar_modellstelle; + } + + public function setKommentar_modellstelle($kommentar_modellstelle): self + { + $this->markDirty('kommentar_modellstelle', $this->kommentar_modellstelle, $kommentar_modellstelle); + $this->kommentar_modellstelle = $kommentar_modellstelle; + return $this; + } + + + + + public function hydrateByStdClass($data, $fromdb=false) + { + parent::hydrateByStdClass($data, $fromdb); + $this->fromdb = $fromdb; + isset($data->fachrichtung_kurzbz) && $this->setFachrichtung_kurzbz($data->fachrichtung_kurzbz); + isset($data->stellenbezeichnung) && $this->setStellenbezeichnung($data->stellenbezeichnung); + isset($data->vordienstzeit) && $this->setVordienstzeit($data->vordienstzeit); + isset($data->modellstelle_kurzbz) && $this->setModellstelle_kurzbz($data->modellstelle_kurzbz); + isset($data->kommentar_person) && $this->setKommentar_person($data->kommentar_person); + isset($data->kommentar_modellstelle) && $this->setKommentar_modellstelle($data->kommentar_modellstelle); + $this->fromdb = false; + } + + public function toStdClass(): \stdClass + { + $tmp = array( + 'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(), + 'stellenbezeichnung' => $this->getStellenbezeichnung(), + 'vordienstzeit' => $this->getVordienstzeit(), + 'fachrichtung_kurzbz' => $this->getFachrichtung_kurzbz(), + 'modellstelle_kurzbz' => $this->getModellstelle_kurzbz(), + 'kommentar_person' => $this->getKommentar_person(), + 'kommentar_modellstelle' => $this->getKommentar_modellstelle(), + ); + + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); + + return (object) $tmp; + } + + public function __toString() + { + $txt = <<getModellstelle_kurzbz()} + +EOTXT; + return parent::__toString() . $txt; + } + + /* public function validate() + { + if( !(filter_var($this->tage, FILTER_VALIDATE_INT, + array( + 'options' => array( + 'min_range' => 1, + 'max_range' => 50 + ) + ) + )) ) { + $this->validationerrors[] = 'Urlaubsanspruch muss eine Tagesanzahl im Bereich 1 bis 50 sein.'; + } + + return parent::validate(); + } */ +} diff --git a/application/models/dashboard/Dashboard_Preset_model.php b/application/models/dashboard/Dashboard_Preset_model.php index ca10ce98a..42570d091 100644 --- a/application/models/dashboard/Dashboard_Preset_model.php +++ b/application/models/dashboard/Dashboard_Preset_model.php @@ -11,57 +11,4 @@ class Dashboard_Preset_model extends DB_Model $this->dbTable = 'dashboard.tbl_dashboard_preset'; $this->pk = 'preset_id'; } - - /** - * Get Presets of given uid. - * @param integer dashboard_id - * @param string $uid - * @return array - */ - public function getPresets($dashboard_id, $uid) - { - // TODO: get Funktionen for uid and load all preset for all funktionen for uid - //return $this->loadWhere(array('dashboard_id' => $dashboard_id, 'funktion_kurzbz'=> null)); - $sql = <<execQuery($sql, array($dashboard_id, $uid)); - } - - /** - * Get Preset by Dashboard and Funktion - * @param integer dashboard_id - * @param string funktion_kurzbz - * @return array - */ - public function getPresetByDashboardAndFunktion($dashboard_id, $funktion_kurzbz) - { - return $this->loadWhere(array('dashboard_id' => $dashboard_id, 'funktion_kurzbz' => $funktion_kurzbz)); - } } diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index ccac33bc7..5422c290e 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -402,14 +402,17 @@ class Lehrveranstaltung_model extends DB_Model SELECT vorname, nachname, mitarbeiter_uid, lehrfunktion_kurzbz FROM - lehre.tbl_lehreinheit + lehre.tbl_lehreinheit le JOIN lehre.tbl_lehreinheitmitarbeiter lema USING (lehreinheit_id) JOIN public.tbl_benutzer b ON b.uid = lema.mitarbeiter_uid JOIN public.tbl_person p using (person_id) WHERE - tbl_lehreinheit.lehrveranstaltung_id= ? - AND tbl_lehreinheit.studiensemester_kurzbz = ? + le.lehrveranstaltung_id= ? + AND le.studiensemester_kurzbz = ? AND lehrfunktion_kurzbz = 'LV-Leitung' + AND lema.mitarbeiter_uid NOT like '_Dummy%' + AND b.aktiv = TRUE + AND p.aktiv = TRUE ORDER BY lema.insertamum DESC LIMIT 1 diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index 131e1deb5..1db658596 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -594,7 +594,10 @@ class Studiengang_model extends DB_Model $this->addSelect('p.prestudent_id'); $this->addSelect('pers.vorname'); $this->addSelect('pers.nachname'); - $this->addSelect("CONCAT(UPPER(pers.nachname), ' ', pers.vorname, ' (', " . $this->dbTable . ".bezeichnung, ')') AS name"); + $this->addSelect("CONCAT(UPPER(pers.nachname), ' ', pers.vorname, ' (', " + . $this->dbTable . ".bezeichnung, ', ', " + . "UPPER(" . $this->dbTable . ".typ), " + . "UPPER(" . $this->dbTable . ".kurzbz),')') AS name"); $this->addJoin('public.tbl_prestudent p', 'studiengang_kz'); $this->addJoin( diff --git a/application/models/person/Benutzerfunktion_model.php b/application/models/person/Benutzerfunktion_model.php index 8c43e4f84..dff422b7d 100644 --- a/application/models/person/Benutzerfunktion_model.php +++ b/application/models/person/Benutzerfunktion_model.php @@ -261,6 +261,42 @@ class Benutzerfunktion_model extends DB_Model } + /** + * Get active Kompetenzfeldleitung bei UID. + * + * @param $uid + * @return array|stdClass|null + */ + public function getKFLByUID($uid) + { + $query = ' + SELECT + bf.uid, + bf.oe_kurzbz, + oe.organisationseinheittyp_kurzbz + FROM + public.tbl_benutzerfunktion bf + JOIN public.tbl_organisationseinheit oe USING (oe_kurzbz) + JOIN public.tbl_benutzer b USING (uid) + WHERE + b.uid = ? + AND b.aktiv = TRUE + AND funktion_kurzbz = \'Leitung\' + AND organisationseinheittyp_kurzbz = \'Kompetenzfeld\' + AND (datum_von IS NULL OR datum_von <= now()) + AND (datum_bis IS NULL OR datum_bis >= now()) + '; + + $parameters_array = array(); + if (is_string($uid)) + { + $parameters_array[] = $uid; + } + + return $this->execQuery($query, $parameters_array); + } + + public function insertBenutzerfunktion($Json) { unset($Json['benutzerfunktion_id']); diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index 3e59d7250..ba51e514e 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -242,6 +242,7 @@ class Message_model extends DB_Model */ public function getMessagesForTable($person_id, $offset, $limit) { + $limitoffset = (!is_null($offset) && !is_null($limit)) ? 'limit ? offset ?' : ''; $sql = <<execQuery($sql, $parametersArray); @@ -325,7 +327,7 @@ EOSQL; $data = getData($data); if($data) { - $count = ceil($data[0]->total_msgs / $limit); + $count = is_null($limit) ? 1 : ceil($data[0]->total_msgs / $limit); } return success(['data' => $data, 'count' => $count]); diff --git a/application/models/vertragsbestandteil/VertragsbestandteilLohnguide_model.php b/application/models/vertragsbestandteil/VertragsbestandteilLohnguide_model.php new file mode 100644 index 000000000..6f3f8e47a --- /dev/null +++ b/application/models/vertragsbestandteil/VertragsbestandteilLohnguide_model.php @@ -0,0 +1,11 @@ +dbTable = 'hr.tbl_vertragsbestandteil_lohnguide'; + $this->pk = 'vertragsbestandteil_id'; + } +} diff --git a/application/models/vertragsbestandteil/Vertragsbestandteil_model.php b/application/models/vertragsbestandteil/Vertragsbestandteil_model.php index ce741268d..334a29dfd 100644 --- a/application/models/vertragsbestandteil/Vertragsbestandteil_model.php +++ b/application/models/vertragsbestandteil/Vertragsbestandteil_model.php @@ -37,7 +37,8 @@ class Vertragsbestandteil_model extends DB_Model kf.arbeitgeber_frist, kf.arbeitnehmer_frist, s.wochenstunden, s.teilzeittyp_kurzbz, u.tage, - z.zeitaufzeichnung, z.azgrelevant, z.homeoffice + z.zeitaufzeichnung, z.azgrelevant, z.homeoffice, + lg.stellenbezeichnung, lg.vordienstzeit, lg.fachrichtung_kurzbz, lg.modellstelle_kurzbz, lg.kommentar_person, lg.kommentar_modellstelle FROM hr.tbl_vertragsbestandteil v LEFT JOIN @@ -63,6 +64,8 @@ class Vertragsbestandteil_model extends DB_Model hr.tbl_vertragsbestandteil_urlaubsanspruch u USING(vertragsbestandteil_id) LEFT JOIN hr.tbl_vertragsbestandteil_zeitaufzeichnung z USING(vertragsbestandteil_id) + LEFT JOIN + hr.tbl_vertragsbestandteil_lohnguide lg USING(vertragsbestandteil_id) EOSQL; return $sql; } diff --git a/application/views/dashboard/dashboard_demo.php b/application/views/dashboard/admin.php similarity index 67% rename from application/views/dashboard/dashboard_demo.php rename to application/views/dashboard/admin.php index 8efc230b7..1e338e125 100644 --- a/application/views/dashboard/dashboard_demo.php +++ b/application/views/dashboard/admin.php @@ -8,9 +8,15 @@ $this->load->view( 'axios027' => true, 'restclient' => true, 'vue3' => true, - 'customJSModules' => ['public/js/apps/Dashboard.js'], + 'primevue3' => true, + 'vuedatepicker11' => true, + 'customJSs' => [ + 'vendor/moment/luxonjs/luxon.min.js' + ], + 'customJSModules' => ['public/js/apps/Dashboard/Admin.js'], 'customCSSs' => [ - 'public/css/components/dashboard.css' + 'public/css/components/dashboard.css', + 'public/css/components/primevue.css', ], 'navigationcomponent' => true ) @@ -25,7 +31,7 @@ $this->load->view(

Dashboard

- + diff --git a/application/views/dashboard/dashboard_demo_admin.php b/application/views/dashboard/preview.php similarity index 67% rename from application/views/dashboard/dashboard_demo_admin.php rename to application/views/dashboard/preview.php index 0d92146a8..f8c37c0c8 100644 --- a/application/views/dashboard/dashboard_demo_admin.php +++ b/application/views/dashboard/preview.php @@ -8,7 +8,12 @@ $this->load->view( 'axios027' => true, 'restclient' => true, 'vue3' => true, - 'customJSModules' => ['public/js/apps/DashboardAdmin.js'], + 'vuedatepicker11' => true, + 'primevue3' => true, + 'customJSs' => [ + 'vendor/moment/luxonjs/luxon.min.js' + ], + 'customJSModules' => ['public/js/apps/Dashboard/Preview.js'], 'customCSSs' => [ 'public/css/components/dashboard.css' ], @@ -23,9 +28,9 @@ $this->load->view(
-

Dashboard

+

Dashboard

- +
diff --git a/cis/private/info/service_uebersicht.php b/cis/private/info/service_uebersicht.php index 348a82b0d..ef2516bf7 100644 --- a/cis/private/info/service_uebersicht.php +++ b/cis/private/info/service_uebersicht.php @@ -46,12 +46,13 @@ echo ' - - '; + include('../../../include/meta/jquery.php'); + include('../../../include/meta/jquery-tablesorter.php'); + const MOODLE_ADDON_KURZBZ = 'moodle'; // Load Addons to get Moodle_Path @@ -71,7 +72,7 @@ echo ' $("#myTable").tablesorter( { sortList: [[0,0],[1,0]], - widgets: [\'zebra\'] + widgets: [\'zebra\',\'filter\'] }); } ); @@ -151,8 +152,9 @@ foreach($service->result as $row) $person = new person(); $person->getPersonFromBenutzer($row->operativ_uid); $operativ = $person->nachname.' '.$person->vorname; + $oeBez = new organisationseinheit($row->oe_kurzbz); echo ''; - echo '',$row->oe_kurzbz,''; + echo '',$oeBez->bezeichnung,''; echo ''.$row->bezeichnung.''; echo '',$row->beschreibung,''; echo '',$design,''; diff --git a/content/student/studentdetailoverlay.xul.php b/content/student/studentdetailoverlay.xul.php index c3bf8c191..63e26d011 100644 --- a/content/student/studentdetailoverlay.xul.php +++ b/content/student/studentdetailoverlay.xul.php @@ -802,6 +802,10 @@ echo ''; class="sortDirectionIndicator" sort="rdf:http://www.technikum-wien.at/prestudentrolle/rdf#fgm" /> +