Compare commits

..

4 Commits

Author SHA1 Message Date
Harald Bamberger d1ef2e4f74 refactor 2026-06-22 09:52:08 +02:00
Harald Bamberger b0fea017f2 further progress on rendering partMenu 2026-05-29 08:42:02 +02:00
Harald Bamberger 861623750d Merge branch 'master' of github.com:FH-Complete/FHC-Core into bhdev_treemenu 2026-05-13 21:14:35 +02:00
Harald Bamberger 51d73c862b treemenu trial 2026-05-11 16:42:48 +02:00
17 changed files with 462 additions and 251 deletions
+47
View File
@@ -0,0 +1,47 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
$config['stv_menu'] = array(
'library' => 'treemenu/TreeMenuLib',
'children' => array(
'stg' => array(
'library' => 'treemenu/StgLib',
'children' => array(
/*
'pre' => array(
'library' => 'treemenu/PrestudentLib'
),
'sem' => array(
'library' => 'treemenu/AusbSemesterLib',
'children' => array(
'vbd' => array(
'library' => 'treemenu/VerbandLib'
)
)
),
*/
'orgform' => array(
'library' => 'treemenu/OrgFormLib',
'children' => array(
/*
'pre' => array(
'library' => 'treemenu/PrestudentLib'
),
'sem' => array(
'library' => 'treemenu/AusbSemesterLib',
'children' => array(
'vbd' => array(
'library' => 'treemenu/VerbandLib'
)
)
)
*/
)
)
)
),
'inout' => array(
'library' => 'treemenu/InOutLib'
),
)
);
@@ -1,50 +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 Permission extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'isBerechtigt' => self::PERM_LOGGED
]);
// Load the library SearchBarLib
$this->load->library('PermissionLib');
}
public function isBerechtigt()
{
$payload = json_decode($this->input->raw_input_stream, TRUE);
if( !isset($payload['berechtigung_kurzbz']) || empty($payload['berechtigung_kurzbz']) )
{
$this->terminateWithError('Missing Parameter "berechtigung_kurzbz"');
}
$berechtigung_kurzbz = $payload['berechtigung_kurzbz'];
$art = isset($payload['art']) ? $payload['art'] : null;
$oe_kurzbz = isset($payload['oe_kurzbz']) ? $payload['oe_kurzbz'] : null;
$kostenstelle_id = isset($payload['kostenstelle_id']) ? $payload['kostenstelle_id'] : null;
$payload['isBerechtigt'] = $this->permissionlib->isBerechtigt(
$berechtigung_kurzbz, $art, $oe_kurzbz, $kostenstelle_id
);
$this->terminateWithSuccess($payload);
}
}
@@ -0,0 +1,103 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the back-end
* Provides data to the ajax get calls about verbände
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class TreeMenu extends FHCAPI_Controller
{
protected $treemenuconfig;
public function __construct()
{
parent::__construct([
'fullMenu' => ['admin:r', 'assistenz:r'],
'partMenu' => ['admin:r', 'assistenz:r'],
]);
}
public function fullMenu($treemenu=null)
{
$includeSubMenu = true;
$this->getMenu($treemenu, $includeSubMenu);
}
public function partMenu($treemenu=null)
{
$includeSubMenu = false;
$this->getMenu($treemenu, $includeSubMenu);
}
protected function getMenu($treemenu=null, $includeSubMenu=false)
{
if(is_null($treemenu))
{
$this->terminateWithError('missing parameter treemenu.');
}
$this->loadMenuConfig($treemenu);
$uri = $this->uri->uri_to_assoc(7);
$startconfig = $this->findStartLib($this->treemenuconfig, array_keys($uri));
$libpath = $startconfig['library'];
$children = isset($startconfig['children']) ? $startconfig['children'] : array();
$libname = basename($startconfig['library']);
$this->load->library(
$libpath,
$children,
$libname
);
$bhdebug = (object) array(
'treemenu' => $treemenu,
'treemenuconfig' => $this->treemenuconfig,
'uri' => $uri,
'libpath' => $libpath,
'libname' => $libname,
'children' => $children,
'startconfig' => $startconfig
);
$this->addMeta('bhdebug', $bhdebug);
//$this->addMeta('bhci', $this);
$this->$libname->init($uri, $includeSubMenu);
$data = $this->$libname->getSubMenu();
$this->terminateWithSuccess($data);
}
protected function findStartLib($config, $uri)
{
$level = array_shift($uri);
if(is_null($level)) {
return $config;
}
return $this->findStartLib($config['children'][$level], $uri);
}
protected function loadMenuConfig($treemenu)
{
$this->config->load('treemenu/' . $treemenu . '.php');
$this->treemenuconfig = $this->config->item($treemenu);
}
}
@@ -0,0 +1,37 @@
<?php
require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
/**
* Description of InOutLib
*
* @author bambi
*/
class InOutLib extends TreeMenuLib
{
public function getNodes($params=array(), $includeSubMenu=false)
{
return [
[
'name' => 'International',
'link' => 'inout',
'children' => [
[
'name' => 'Incoming',
'link' => 'inout/incoming',
'leaf' => true
],
[
'name' => 'Outgoing',
'link' => 'inout/outgoing',
'leaf' => true
],
[
'name' => 'Gemeinsame Studien',
'link' => 'inout/gemeinsamestudien',
'leaf' => true
]
]
]
];
}
}
@@ -0,0 +1,64 @@
<?php
require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
/**
* Description of OrgFormLib
*
* @author bambi
*/
class OrgFormLib extends TreeMenuLib
{
public function getData()
{
if(!isset($this->params['stg']))
{
throw new Exception(self::class . ' Missing Parameter stg.');
}
$this->ci->load->model('codex/Orgform_model', 'OrgFormModel');
$sql = <<<EOSQL
select
o.*
from
bis.tbl_orgform o
join (
SELECT
tl.orgform_kurzbz
FROM
public.tbl_lehrverband AS tl
WHERE
studiengang_kz = {$this->ci->OrgFormModel->escape($this->params['stg'])}
and
orgform_kurzbz IS NOT null
group by
orgform_kurzbz
) v on o.orgform_kurzbz = v.orgform_kurzbz
order by
o.orgform_kurzbz
EOSQL;
$res = $this->ci->OrgFormModel->execReadonlyQuery($sql);
$orgforms = hasData($res) ? getData($res) : array();
$this->ci->addMeta('bhorgform_' . $this->params['stg'] , $orgforms);
return $orgforms;
}
protected function getParamsForNextLevel($element=null)
{
if($element)
{
$paramsstg = array_merge($this->params, array('orgform' => $element->orgform_kurzbz));
return $paramsstg;
}
return $this->params;
}
protected function getName($element)
{
$name = $element->orgform_kurzbz . ' ' . $element->bezeichnung;
return $name;
}
}
@@ -0,0 +1,37 @@
<?php
require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
/**
* Description of PreStudentLib
*
* @author bambi
*/
class PreStudentLib extends TreeMenuLib
{
public function getNodes($params=array())
{
return [
[
'name' => 'International',
'link' => 'inout',
'children' => [
[
'name' => 'Incoming',
'link' => 'inout/incoming',
'leaf' => true
],
[
'name' => 'Outgoing',
'link' => 'inout/outgoing',
'leaf' => true
],
[
'name' => 'Gemeinsame Studien',
'link' => 'inout/gemeinsamestudien',
'leaf' => true
]
]
]
];
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
/**
* Description of InOutLib
*
* @author bambi
*/
class StgLib extends TreeMenuLib
{
protected function getData()
{
$this->ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->ci->StudiengangModel->addOrder('typ');
$this->ci->StudiengangModel->addOrder('kurzbz');
$res = $this->ci->StudiengangModel->loadWhere(array('aktiv' => true));
$stgs = hasData($res) ? getData($res) : array();
$this->ci->addMeta('bhstg', $stgs);
return $stgs;
}
protected function getParamsForNextLevel($element=null)
{
if($element)
{
$paramsstg = array_merge($this->params, array('stg' => $element->studiengang_kz));
return $paramsstg;
}
return $this->params;
}
protected function getName($element)
{
$name = strtoupper($element->typ . $element->kurzbz) . ' ' . $element->bezeichnung;
return $name;
}
}
@@ -0,0 +1,14 @@
<?php
require_once APPPATH . 'libraries/treemenu/TreeMenuLib.php';
/**
* Description of StvMenuLib
*
* @author bambi
*/
class StvMenuLib extends TreeMenuLib
{
public function getNodes($params=array(), $includeSubMenu=false)
{
return [];
}
}
@@ -0,0 +1,108 @@
<?php
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
*/
/**
* Description of InOutLib
*
* @author bambi
*/
class TreeMenuLib
{
protected $ci;
protected $children_config;
protected $params;
protected $includeSubMenu;
public function __construct($children_config)
{
$this->ci =& get_instance();
$this->children_config = $children_config;
$this->params = array();
$this->includeSubMenu = false;
foreach($this->children_config as $child_config)
{
$grandchildren_config = isset($child_config['children']) ? $child_config['children'] : [];
$this->ci->load->library($child_config['library'], $grandchildren_config, basename($child_config['library']));
}
}
public function init($params=array(), $includeSubMenu=false)
{
$this->params = $params;
$this->includeSubMenu = $includeSubMenu;
}
public function getNodes()
{
$data = $this->getData();
$nodes = array();
foreach($data as $element)
{
$node = array(
'name' => $this->getName($element),
'link' => $this->getLink($element),
'leaf' => $this->isLeaf()
);
if($this->includeSubMenu)
{
$node['children'] = $this->getSubMenu($element);
}
$nodes[] = $node;
};
return $nodes;
}
public function getSubMenu($element=null)
{
$nodes = array();
foreach($this->children_config as $childconfig)
{
$childlib = basename($childconfig['library']);
$this->ci->$childlib->init(
$this->getParamsForNextLevel($element),
$this->includeSubMenu
);
$childnodes = $this->ci->$childlib->getNodes();
$nodes = array_merge($nodes, $childnodes);
}
return $nodes;
}
protected function getData()
{
return array();
}
protected function getParamsForNextLevel($element=null)
{
return $this->params;
}
protected function getName($element)
{
return __METHOD__ . 'NOT IMPLEMENTED';
}
protected function getLink($element)
{
$link = $this->ci->uri->assoc_to_uri($this->getParamsForNextLevel($element));
return $link;
}
protected function isLeaf()
{
if(count($this->children_config) === 0) {
return true;
}
return false;
}
}
@@ -15,13 +15,6 @@ class GehaltsbestandteilLib
protected $CI;
/** @var Gehaltsbestandteil_model */
protected $GehaltsbestandteilModel;
/** @var Dienstverhaeltnis_model */
protected $DienstverhaeltnisModel;
/**
* @var PermissionLib
*/
protected $PermissionLib;
protected $loggedInUser;
@@ -31,25 +24,7 @@ class GehaltsbestandteilLib
$this->CI = get_instance();
$this->CI->load->model('vertragsbestandteil/Gehaltsbestandteil_model',
'GehaltsbestandteilModel');
$this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model',
'DienstverhaeltnisModel');
$this->DienstverhaeltnisModel = $this->CI->DienstverhaeltnisModel;
$this->CI->load->library('extensions/FHC-Core-Personalverwaltung/abrechnung/GehaltsLib');
$this->GehaltsbestandteilModel = $this->CI->GehaltsbestandteilModel;
$this->CI->load->library('PermissionLib', null, 'PermissionLib');
$this->PermissionLib = $this->CI->PermissionLib;
}
public function fetchDienstverhaeltnis($dienstverhaeltnis_id)
{
$result = $this->DienstverhaeltnisModel->load($dienstverhaeltnis_id);
$dv = null;
if(null !== ($row = getData($result)))
{
$dv = new Dienstverhaeltnis();
$dv->hydrateByStdClass($row[0], true);
}
return $dv;
}
public function fetchGehaltsbestandteileValorisiertForChart($dienstverhaeltnis_id, $stichtag=null, $includefuture=false)
@@ -145,29 +120,12 @@ class GehaltsbestandteilLib
{
$this->setUIDtoPGSQL();
$dv = $this->fetchDienstverhaeltnis($gehaltsbestandteil->getDienstverhaeltnis_id());
if($dv && $this->PermissionLib->isberechtigt('basis/gehaelter', 'd', $dv->getOe_kurzbz()))
$ret = $this->GehaltsbestandteilModel->delete($gehaltsbestandteil->getGehaltsbestandteil_id());
if (isError($ret))
{
$ret = $this->GehaltsbestandteilModel->delete($gehaltsbestandteil->getGehaltsbestandteil_id());
if (isError($ret))
{
// delete Gehaltsabrechnung
$ret = $this->CI->gehaltslib->deleteAbrechnung($gehaltsbestandteil);
//
$ret = $this->GehaltsbestandteilModel->delete($gehaltsbestandteil->getGehaltsbestandteil_id());
if (isError($ret))
{
throw new Exception('error deleting gehaltsbestandteil');
}
}
} else {
throw new Exception('permission denied for deleting gehaltsbestandteil');
throw new Exception('error deleting gehaltsbestandteil');
}
}
public function endGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil, $enddate)
@@ -1,19 +0,0 @@
<?php
namespace vertragsbestandteil;
class NoPermissionException extends \Exception
{
// Redefine the exception so message isn't optional
public function __construct($message, $code = 0, ?\Throwable $previous = null) {
// make sure everything is assigned properly
parent::__construct($message, $code, $previous);
}
// custom string representation of object
public function __toString() {
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}
@@ -13,12 +13,10 @@ require_once __DIR__ . '/VertragsbestandteilKarenz.php';
require_once __DIR__ . '/VertragsbestandteilLohnguide.php';
require_once __DIR__ . '/VertragsbestandteilFactory.php';
require_once __DIR__ . '/OverlapChecker.php';
require_once __DIR__ . '/NoPermissionException.php';
use vertragsbestandteil\Dienstverhaeltnis;
use vertragsbestandteil\Vertragsbestandteil;
use vertragsbestandteil\VertragsbestandteilFactory;
use vertragsbestandteil\NoPermissionException;
/**
* Description of VertragsbestandteilLib
@@ -37,8 +35,6 @@ class VertragsbestandteilLib
protected $DienstverhaeltnisModel;
/** @var Vertragsbestandteil_model */
protected $VertragsbestandteilModel;
/** @var GehaltsbestandeilModel */
protected $GehaltbestandteilModel;
/** @var Benutzer_model */
protected $BenutzerModel;
/**
@@ -48,11 +44,6 @@ class VertragsbestandteilLib
protected $loggedInUser;
/**
* @var PermissionLib
*/
protected $PermissionLib;
public function __construct()
{
$this->loggedInUser = getAuthUID();
@@ -63,17 +54,12 @@ class VertragsbestandteilLib
$this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model',
'VertragsbestandteilModel');
$this->VertragsbestandteilModel = $this->CI->VertragsbestandteilModel;
$this->CI->load->model('vertragsbestandteil/Gehaltsbestandteil_model',
'GehaltbestandteilModel');
$this->GehaltbestandteilModel = $this->CI->GehaltbestandteilModel;
$this->CI->load->model('person/benutzer_model',
'BenutzerModel');
$this->BenutzerModel = $this->CI->BenutzerModel;
$this->CI->load->library('vertragsbestandteil/GehaltsbestandteilLib',
null, 'GehaltsbestandteilLib');
$this->GehaltsbestandteilLib = $this->CI->GehaltsbestandteilLib;
$this->CI->load->library('PermissionLib', null, 'PermissionLib');
$this->PermissionLib = $this->CI->PermissionLib;
}
public function handleGUIData($guidata, $employeeUID, $userUID)
@@ -113,14 +99,9 @@ class VertragsbestandteilLib
$vbs = $this->VertragsbestandteilModel->getVertragsbestandteile(
$dienstverhaeltnis_id, $stichtag, $includefuture
);
$dv = $this->fetchDienstverhaeltnis($dienstverhaeltnis_id);
$gbs = array();
if($dv && $this->PermissionLib->isberechtigt('basis/gehaelter', 's', $dv->getOe_kurzbz()))
{
$gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile(
$dienstverhaeltnis_id, $stichtag, $includefuture, $withvalorisationhistory
);
}
$gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile(
$dienstverhaeltnis_id, $stichtag, $includefuture, $withvalorisationhistory
);
$gbsByVBid = array();
foreach( $gbs as $gb )
@@ -254,12 +235,8 @@ class VertragsbestandteilLib
throw new Exception("Transaction failed");
}
$this->CI->db->trans_commit();
} catch (NoPermissionException $e) {
log_message('debug', "Transaction rolled back. " . $e->getMessage());
$this->CI->db->trans_rollback();
// rethrow and let GUIHandler catch it to display error message
throw $e;
} catch (Exception $ex)
}
catch (Exception $ex)
{
log_message('debug', "Transaction rolled back. " . $ex->getMessage());
$this->CI->db->trans_rollback();
@@ -337,15 +314,6 @@ class VertragsbestandteilLib
private function deleteVertragsbestandteilHelper(Vertragsbestandteil $vertragsbestandteil)
{
$dv = $this->fetchDienstverhaeltnis($vertragsbestandteil->getDienstverhaeltnis_id());
$hasGehaltsPermission = $this->PermissionLib->isberechtigt('basis/gehaelter', 's', $dv->getOe_kurzbz());
$vbHasGehaltsbestandteile = $this->GehaltbestandteilModel->existsGehaltsbestandteil($vertragsbestandteil->getVertragsbestandteil_id());
if (!$hasGehaltsPermission && $vbHasGehaltsbestandteile)
{
throw new NoPermissionException('delete Gehaltsbestandteil permission denied');
}
$specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel(
$vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
@@ -129,15 +129,6 @@ LEFT JOIN
array($dienstverhaeltnis_id),
$this->getEncryptedColumns());
}
public function existsGehaltsbestandteil($vertragsbestandteil_id)
{
$qry = "select count(*) from hr.tbl_gehaltsbestandteil where vertragsbestandteil_id=?";
$ret = $this->execQuery($qry,
array($vertragsbestandteil_id));
$d = getData($ret);
return $d !== null && $d > 0;
}
public function getGehaltsbestandteile($dienstverhaeltnis_id, $stichtag=null,
$includefuture=false, $withvalorisationhistory=true)
-27
View File
@@ -1,27 +0,0 @@
/**
* 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/>.
*/
export default {
isBerechtigt(berechtigung_kurzbz, art, oe_kurzbz, kostenstelle_id) {
return {
method: 'post',
url: '/api/frontend/v1/Permission/isBerechtigt',
params: { berechtigung_kurzbz, art, oe_kurzbz, kostenstelle_id }
};
},
};
+4 -5
View File
@@ -39,7 +39,6 @@ import studiengang from "./studiengang.js";
import menu from "./menu.js";
import dashboard from "./dashboard.js";
import authinfo from "./authinfo.js";
import permission from "./permission.js";
import vertraege from "./vertraege.js";
import studium from "./studium.js";
import language from "./language.js";
@@ -64,12 +63,12 @@ export default {
cms,
lehre,
addons,
studiengang,
menu,
authinfo,
messages,
vorlagen,
permission,
addons,
studiengang,
menu,
authinfo,
vertraege,
studium,
language
-17
View File
@@ -1,17 +0,0 @@
export default {
isBerechtigt: function(berechtigung_kurzbz, art, oe_kurzbz, kostenstelle_id) {
var url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router
+ '/api/frontend/v1/Permission/isBerechtigt';
var payload = {
"berechtigung_kurzbz": berechtigung_kurzbz,
"art": art,
"oe_kurzbz": oe_kurzbz,
"kostenstelle_id": kostenstelle_id
};
return axios.post(url, payload, {
headers: {
'Content-Type': 'application/json'
}
});
}
}
@@ -1,41 +0,0 @@
<?php
/* Copyright (C) 2017 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Authors: Harald Bamberger <harald.bamberger@technikum-wien.at>,
*
* Beschreibung:
* Permissions f. DV erstellen und bearbeiten bzw. korrigieren, Gehaelter
*/
if (! defined('DB_NAME')) exit('No direct script access allowed');
// Add permission: basis/gehaelter
if($result = @$db->db_query("SELECT 1 FROM system.tbl_berechtigung WHERE berechtigung_kurzbz = 'basis/gehaelter';"))
{
if($db->db_num_rows($result) == 0)
{
$qry = "INSERT INTO system.tbl_berechtigung(berechtigung_kurzbz, beschreibung) VALUES('basis/gehaelter', 'Zugriff auf gehaelter');";
if(!$db->db_query($qry))
{
echo '<strong>system.tbl_berechtigung '.$db->db_last_error().'</strong><br>';
}
else
{
echo 'system.tbl_berechtigung: Added permission "basis/gehaelter"<br>';
}
}
}