mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 08:52:21 +00:00
Merge branch 'master' into feature-25999/C4_TEST
This commit is contained in:
@@ -174,6 +174,8 @@ class AnrechnungLib
|
||||
$anrechnung_data->insertvon = '';
|
||||
$anrechnung_data->studiensemester_kurzbz = '';
|
||||
$anrechnung_data->empfehlung = '';
|
||||
$anrechnung_data->begruendung_ects = '';
|
||||
$anrechnung_data->begruendung_lvinhalt = '';
|
||||
$anrechnung_data->status_kurzbz = '';
|
||||
$anrechnung_data->status = getUserLanguage() == 'German' ? 'neu' : 'new';
|
||||
$anrechnung_data->dokumentname = '';
|
||||
@@ -894,6 +896,8 @@ class AnrechnungLib
|
||||
$anrechnung_data->insertvon= $anrechnung->insertvon;
|
||||
$anrechnung_data->studiensemester_kurzbz= $anrechnung->studiensemester_kurzbz;
|
||||
$anrechnung_data->empfehlung= $anrechnung->empfehlung_anrechnung;
|
||||
$anrechnung_data->begruendung_ects = $anrechnung->begruendung_ects;
|
||||
$anrechnung_data->begruendung_lvinhalt = $anrechnung->begruendung_lvinhalt;
|
||||
|
||||
// Get last status_kurzbz
|
||||
$result = $this->ci->AnrechnungModel->getLastAnrechnungstatus($anrechnung->anrechnung_id);
|
||||
|
||||
+627
-166
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2022 fhcomplete.org
|
||||
*
|
||||
@@ -36,6 +37,7 @@ class FilterCmptLib
|
||||
const SESSION_METADATA = 'datasetMetadata';
|
||||
const SESSION_ROW_NUMBER = 'rowNumber';
|
||||
const SESSION_TIMEOUT = 'sessionTimeout';
|
||||
const SESSION_ENCRYPTED_COLUMNS = 'encryptedColumns';
|
||||
|
||||
// Session dataset elements
|
||||
const SESSION_DATASET = 'dataset';
|
||||
@@ -62,6 +64,7 @@ class FilterCmptLib
|
||||
|
||||
// ...to specify permissions that are needed to use this FilterCmpt
|
||||
const REQUIRED_PERMISSIONS = 'requiredPermissions';
|
||||
const ENCRYPTED_COLUMNS = 'encryptedColumns';
|
||||
|
||||
// ...stament to retrieve the dataset
|
||||
const QUERY = 'query';
|
||||
@@ -102,6 +105,7 @@ class FilterCmptLib
|
||||
private $_filterKurzbz;
|
||||
private $_query;
|
||||
private $_requiredPermissions;
|
||||
private $_encryptedColumns;
|
||||
private $_reloadDataset;
|
||||
private $_sessionTimeout;
|
||||
|
||||
@@ -504,10 +508,12 @@ class FilterCmptLib
|
||||
$saveCustomFilter = true;
|
||||
}
|
||||
|
||||
if ($saveCustomFilter === true)
|
||||
if ($saveCustomFilter === true)
|
||||
{
|
||||
$this->_setSessionElement(FilterCmptLib::SESSION_SIDE_MENU,
|
||||
$this->_generateFilterMenu($this->_app, $this->_datasetName));
|
||||
$this->_setSessionElement(
|
||||
FilterCmptLib::SESSION_SIDE_MENU,
|
||||
$this->_generateFilterMenu($this->_app, $this->_datasetName)
|
||||
);
|
||||
}
|
||||
|
||||
return $saveCustomFilter;
|
||||
@@ -717,6 +723,7 @@ class FilterCmptLib
|
||||
$this->_filterKurzbz = null;
|
||||
$this->_query = null;
|
||||
$this->_requiredPermissions = null;
|
||||
$this->_encryptedColumns = null;
|
||||
|
||||
$this->_reloadDataset = true; // by default the dataset is NOT cached in session
|
||||
$this->_sessionTimeout = FilterCmptLib::SESSION_DEFAULT_TIMEOUT;
|
||||
@@ -727,6 +734,12 @@ class FilterCmptLib
|
||||
$this->_requiredPermissions = $filterCmptArray[FilterCmptLib::REQUIRED_PERMISSIONS];
|
||||
}
|
||||
|
||||
// Retrieved the encrypted columns parameter if present
|
||||
if (isset($filterCmptArray[FilterCmptLib::ENCRYPTED_COLUMNS]))
|
||||
{
|
||||
$this->_encryptedColumns = $filterCmptArray[FilterCmptLib::ENCRYPTED_COLUMNS];
|
||||
}
|
||||
|
||||
// Parameters needed to retrieve univocally a filter from DB
|
||||
if (isset($filterCmptArray[FilterCmptLib::APP]))
|
||||
{
|
||||
@@ -1129,7 +1142,7 @@ class FilterCmptLib
|
||||
$this->_ci->load->model('system/Filters_model', 'FiltersModel');
|
||||
|
||||
// Execute the given SQL statement suppressing error messages
|
||||
$dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery);
|
||||
$dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery, null, $this->_encryptedColumns);
|
||||
}
|
||||
|
||||
return $dataset;
|
||||
|
||||
@@ -1,7 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2023 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 \stdClass as stdClass;
|
||||
|
||||
/**
|
||||
* FilterWidget logic
|
||||
*/
|
||||
@@ -16,6 +35,7 @@ class FilterWidgetLib
|
||||
const SESSION_SELECTED_FIELDS = 'selectedFields';
|
||||
const SESSION_COLUMNS_ALIASES = 'columnsAliases';
|
||||
const SESSION_ADDITIONAL_COLUMNS = 'additionalColumns';
|
||||
const SESSION_ENCRYPTED_COLUMNS = 'encryptedColumns';
|
||||
const SESSION_CHECKBOXES = 'checkboxes';
|
||||
const SESSION_FILTERS = 'filters';
|
||||
const SESSION_METADATA = 'datasetMetadata';
|
||||
@@ -56,6 +76,7 @@ class FilterWidgetLib
|
||||
const ADDITIONAL_COLUMNS = 'additionalColumns';
|
||||
const CHECKBOXES = 'checkboxes';
|
||||
const COLUMNS_ALIASES = 'columnsAliases';
|
||||
const ENCRYPTED_COLUMNS = 'encryptedColumns';
|
||||
|
||||
// ...to format/mark records of a dataset
|
||||
const FORMAT_ROW = 'formatRow';
|
||||
@@ -120,7 +141,7 @@ class FilterWidgetLib
|
||||
/**
|
||||
* Gets the CI instance and loads message helper
|
||||
*/
|
||||
public function __construct($params = null)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
}
|
||||
@@ -367,7 +388,7 @@ class FilterWidgetLib
|
||||
/**
|
||||
* Retrieves the dataset from the DB
|
||||
*/
|
||||
public function getDataset($datasetQuery)
|
||||
public function getDataset($datasetQuery, $encryptedColumns)
|
||||
{
|
||||
$dataset = null;
|
||||
|
||||
@@ -376,7 +397,7 @@ class FilterWidgetLib
|
||||
$this->_ci->load->model('system/Filters_model', 'FiltersModel');
|
||||
|
||||
// Execute the given SQL statement suppressing error messages
|
||||
$dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery);
|
||||
$dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery, null, $encryptedColumns);
|
||||
}
|
||||
|
||||
return $dataset;
|
||||
@@ -390,7 +411,7 @@ class FilterWidgetLib
|
||||
public function getFilterName($filterJson)
|
||||
{
|
||||
$filterName = $filterJson->name; // always present, used as default
|
||||
$trimedname = (isset($filterJson->namePhrase)?trim($filterJson->namePhrase):'');
|
||||
|
||||
// Filter name from phrases system
|
||||
if (isset($filterJson->namePhrase) && !isEmptyString($filterJson->namePhrase))
|
||||
{
|
||||
@@ -451,7 +472,8 @@ class FilterWidgetLib
|
||||
if (in_array($selectedField, $fields))
|
||||
{
|
||||
// If the selected field is present in the list of the selected fields by the current filter
|
||||
if (($pos = array_search($selectedField, $selectedFields)) !== false)
|
||||
$pos = array_search($selectedField, $selectedFields);
|
||||
if ($pos !== false)
|
||||
{
|
||||
// Then remove it and shift the rest of elements by one if needed
|
||||
array_splice($selectedFields, $pos, 1);
|
||||
@@ -750,7 +772,6 @@ class FilterWidgetLib
|
||||
$this->_ci->load->library('NavigationLib', array(self::NAVIGATION_PAGE => $navigationPage));
|
||||
|
||||
$filterMenu = null;
|
||||
$currentMenu = $this->_ci->navigationlib->getSessionMenu(); // The navigation menu currently stored in session
|
||||
|
||||
$session = $this->getSession(); // The filter currently stored in session (the one that is currently used)
|
||||
if ($session != null)
|
||||
|
||||
@@ -182,6 +182,7 @@ class MailLib
|
||||
{
|
||||
if ($this->sended == $this->email_number_per_time_range)
|
||||
{
|
||||
$this->sended = 0;
|
||||
sleep($this->email_time_range); // Wait!!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ require_once(FHCPATH.'include/functions.inc.php');
|
||||
require_once(FHCPATH.'include/wawi_kostenstelle.class.php');
|
||||
require_once(FHCPATH.'include/benutzerberechtigung.class.php');
|
||||
|
||||
use \benutzerberechtigung as benutzerberechtigung;
|
||||
|
||||
class PermissionLib
|
||||
{
|
||||
// Available rights in the DB
|
||||
@@ -65,8 +67,10 @@ class PermissionLib
|
||||
if (!is_cli())
|
||||
{
|
||||
// API Caller rights initialization
|
||||
$authObj = $this->_ci->authlib->getAuthObj();
|
||||
self::$bb = new benutzerberechtigung();
|
||||
self::$bb->getBerechtigungen(($this->_ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME});
|
||||
if ($authObj)
|
||||
self::$bb->getBerechtigungen($authObj->{AuthLib::AO_USERNAME});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +170,16 @@ class PermissionLib
|
||||
if ($checkPermissions === true) break;
|
||||
}
|
||||
}
|
||||
elseif ($permissions[$pCounter] == Auth_Controller::PERM_ANONYMOUS)
|
||||
{
|
||||
$checkPermissions = true;
|
||||
break;
|
||||
}
|
||||
elseif ($permissions[$pCounter] == Auth_Controller::PERM_LOGGED)
|
||||
{
|
||||
$checkPermissions = isLogged();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('The given permission does not use the correct format');
|
||||
|
||||
@@ -32,12 +32,15 @@ class PrestudentLib
|
||||
$this->_ci->load->model('organisation/Lehrverband_model', 'LehrverbandModel');
|
||||
$this->_ci->load->model('education/Studentlehrverband_model', 'StudentlehrverbandModel');
|
||||
$this->_ci->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
}
|
||||
|
||||
public function setAbbrecher($prestudent_id, $studiensemester_kurzbz, $insertvon = null, $statusgrund_kurzbz = null, $datum = null, $bestaetigtam = null)
|
||||
public function setAbbrecher($prestudent_id, $studiensemester_kurzbz, $insertvon = null, $statusgrund_kurzbz = null, $datum = null, $bestaetigtam = null, $bestaetigtvon = null)
|
||||
{
|
||||
if (!$insertvon)
|
||||
$insertvon = getAuthUID();
|
||||
if (!$bestaetigtvon)
|
||||
$bestaetigtvon = $insertvon;
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
@@ -71,14 +74,14 @@ class PrestudentLib
|
||||
$result = $this->_ci->PrestudentstatusModel->withGrund($statusgrund_kurzbz)->insert([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_ABBRECHER,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'studiensemester_kurzbz' => $prestudent_status->studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $prestudent_status->ausbildungssemester,
|
||||
'datum' => $datum,
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
'orgform_kurzbz'=> $prestudent_status->orgform_kurzbz,
|
||||
'studienplan_id'=> $prestudent_status->studienplan_id,
|
||||
'bestaetigtvon' => $insertvon,
|
||||
'bestaetigtvon' => $bestaetigtvon,
|
||||
'bestaetigtam' => $bestaetigtam
|
||||
]);
|
||||
|
||||
@@ -132,7 +135,7 @@ class PrestudentLib
|
||||
}
|
||||
|
||||
//noch nicht eingetragene Zeugnisnoten auf 9 setzen
|
||||
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $studiensemester_kurzbz);
|
||||
$result = $this->_ci->ZeugnisnoteModel->getZeugnisnoten($student->student_uid, $prestudent_status->studiensemester_kurzbz);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result) ?: [];
|
||||
@@ -178,7 +181,7 @@ class PrestudentLib
|
||||
|
||||
//Studentlehrverband setzen
|
||||
$this->_ci->StudentlehrverbandModel->update([
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'studiensemester_kurzbz' => $prestudent_status->studiensemester_kurzbz,
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
'studiengang_kz' => $student->studiengang_kz,
|
||||
@@ -205,6 +208,7 @@ class PrestudentLib
|
||||
|
||||
public function setUnterbrecher($prestudent_id, $studiensemester_kurzbz, $studierendenantrag_id, $insertvon = null)
|
||||
{
|
||||
$ausbildungssemester_plus = 0;
|
||||
if (!$insertvon)
|
||||
$insertvon = getAuthUID();
|
||||
|
||||
@@ -213,14 +217,38 @@ class PrestudentLib
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
if (!$result) {
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudent_in_sem', [
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
]));
|
||||
//NOTE(manu): only valid if nextSemester focus max
|
||||
|
||||
$result = $this->_ci->PrestudentstatusModel->getLastStatus($prestudent_id);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$result = getData($result);
|
||||
|
||||
//check if ausbildungssemester is last
|
||||
$this->_ci->StudiengangModel->addJoin('public.tbl_prestudent p', 'studiengang_kz');
|
||||
$res = $this->_ci->StudiengangModel->loadWhere(['p.prestudent_id' => $prestudent_id]);
|
||||
if(isError($res))
|
||||
return $res;
|
||||
if(!hasData($res))
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_stg_for_prestudent', [
|
||||
'prestudent_id' => $prestudent_id
|
||||
]));
|
||||
|
||||
$studiengang = current(getData($res));
|
||||
$prestudent_status = current($result);
|
||||
if($prestudent_status->ausbildungssemester + 1 < $studiengang->max_semester)
|
||||
$ausbildungssemester_plus = 1;
|
||||
|
||||
if(!$result)
|
||||
{
|
||||
return error($this->_ci->p->t('studierendenantrag', 'error_no_prestudent_in_sem', [
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
$prestudent_status = current($result);
|
||||
|
||||
$result = $this->_ci->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
if (isError($result))
|
||||
@@ -245,7 +273,7 @@ class PrestudentLib
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'status_kurzbz' => Prestudentstatus_model::STATUS_UNTERBRECHER,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'ausbildungssemester' => $prestudent_status->ausbildungssemester,
|
||||
'ausbildungssemester' => $prestudent_status->ausbildungssemester + $ausbildungssemester_plus,
|
||||
'datum' => date('c'),
|
||||
'insertvon' => $insertvon,
|
||||
'insertamum' => date('c'),
|
||||
@@ -256,7 +284,6 @@ class PrestudentLib
|
||||
'anmerkung'=> 'Wiedereinstieg ' . $antrag->datum_wiedereinstieg
|
||||
]);
|
||||
|
||||
//error try manu
|
||||
if (isError($result))
|
||||
return $result;
|
||||
|
||||
@@ -351,17 +378,34 @@ class PrestudentLib
|
||||
]);
|
||||
|
||||
//Studentlehrverband setzen
|
||||
$this->_ci->StudentlehrverbandModel->update([
|
||||
$result = $this->_ci->StudentlehrverbandModel->loadWhere([
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
'studiengang_kz' => $student->studiengang_kz,
|
||||
'semester' => 0,
|
||||
'verband' => 'B',
|
||||
'gruppe' => '',
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => $insertvon
|
||||
]);
|
||||
if (hasData($result)) {
|
||||
$this->_ci->StudentlehrverbandModel->update([
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'student_uid' => $student->student_uid
|
||||
], [
|
||||
'studiengang_kz' => $student->studiengang_kz,
|
||||
'semester' => 0,
|
||||
'verband' => 'B',
|
||||
'gruppe' => '',
|
||||
'updateamum' => date('c'),
|
||||
'updatevon' => $insertvon
|
||||
]);
|
||||
} else {
|
||||
$this->_ci->StudentlehrverbandModel->insert([
|
||||
'student_uid' => $student->student_uid,
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'studiengang_kz' => $student->studiengang_kz,
|
||||
'semester' => 0,
|
||||
'verband' => 'B',
|
||||
'gruppe' => '',
|
||||
'insertamum' => date('c'),
|
||||
'insertvon' => $insertvon
|
||||
]);
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
@@ -30,9 +30,10 @@ class SearchBarLib
|
||||
const ERROR_WRONG_SEARCHSTR = 'ERR002';
|
||||
const ERROR_NO_TYPES = 'ERR003';
|
||||
const ERROR_WRONG_TYPES = 'ERR004';
|
||||
const ERROR_NOT_AUTH = 'ERR005';
|
||||
|
||||
// List of allowed types of search
|
||||
const ALLOWED_TYPES = ['mitarbeiter', 'organisationunit', 'raum', 'person', 'student', 'prestudent', 'document', 'cms'];
|
||||
const ALLOWED_TYPES = ['mitarbeiter', 'mitarbeiter_ohne_zuordnung', 'organisationunit', 'raum', 'person', 'student', 'prestudent', 'document', 'cms'];
|
||||
|
||||
const PHOTO_IMG_URL = '/cis/public/bild.php?src=person&person_id=';
|
||||
|
||||
@@ -108,6 +109,92 @@ class SearchBarLib
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function _mitarbeiter_ohne_zuordnung($searchstr, $type)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
|
||||
$sql = '
|
||||
SELECT
|
||||
\''.$type.'\' AS type,
|
||||
b.uid AS uid,
|
||||
p.person_id AS person_id,
|
||||
p.vorname || \' \' || p.nachname AS name,
|
||||
ARRAY_AGG(DISTINCT(org.bezeichnung)) AS organisationunit_name,
|
||||
COALESCE(b.alias, b.uid) || \''.'@'.DOMAIN.'\' AS email,
|
||||
TRIM(COALESCE(k.kontakt, \'\') || \' \' || COALESCE(m.telefonklappe, \'\')) AS phone,
|
||||
\''.base_url(self::PHOTO_IMG_URL).'\' || p.person_id AS photo_url,
|
||||
ARRAY_AGG(DISTINCT(stdkst.bezeichnung)) AS standardkostenstelle
|
||||
FROM public.tbl_mitarbeiter m
|
||||
JOIN public.tbl_benutzer b ON(b.uid = m.mitarbeiter_uid)
|
||||
LEFT JOIN (
|
||||
SELECT \'[\' || ot.bezeichnung || \'] \' || o.bezeichnung AS bezeichnung, bf.uid
|
||||
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())
|
||||
GROUP BY o.bezeichnung, ot.bezeichnung, bf.uid
|
||||
) stdkst ON stdkst.uid = b.uid
|
||||
JOIN public.tbl_person p USING(person_id)
|
||||
LEFT JOIN (
|
||||
SELECT \'[\' || ot.bezeichnung || \'] \' || o.bezeichnung AS bezeichnung, bf.uid
|
||||
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())
|
||||
GROUP BY o.bezeichnung, ot.bezeichnung, bf.uid
|
||||
) org ON org.uid = b.uid
|
||||
LEFT JOIN (
|
||||
SELECT kontakt, standort_id
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = \'telefon\'
|
||||
) k ON(k.standort_id = m.standort_id)
|
||||
WHERE
|
||||
(stdkst.bezeichnung IS NULL
|
||||
OR org.bezeichnung IS NULL)
|
||||
AND (
|
||||
' .
|
||||
$this->buildSearchClause(
|
||||
$dbModel,
|
||||
array('b.uid', 'p.vorname', 'p.nachname'),
|
||||
$searchstr
|
||||
) .
|
||||
'
|
||||
)
|
||||
GROUP BY type, b.uid, p.person_id, name, email, m.telefonklappe, phone
|
||||
';
|
||||
|
||||
$employees = $dbModel->execReadOnlyQuery($sql);
|
||||
|
||||
// If something has been found then return it
|
||||
if (hasData($employees)) return getData($employees);
|
||||
|
||||
// Otherwise return an empty array
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function buildSearchClause(DB_Model $dbModel, array $columns, $searchstr)
|
||||
{
|
||||
$document = implode(' || \' \' || ', $columns);
|
||||
$query = '\'' . implode(':* & ', explode(' ', trim($searchstr))) . ':*\'';
|
||||
$reversequery = '\'*:' . implode(' & *:', explode(' ', trim($searchstr))) . '\'';
|
||||
$nospacequery = '\'' . implode('', explode(' ', trim($searchstr))) . ':*\'';
|
||||
|
||||
$searchclause = <<<EOSC
|
||||
to_tsvector(lower(regexp_replace({$document}, '[[:punct:]]', ' ', 'g'))) @@ to_tsquery(lower({$query}))
|
||||
OR
|
||||
to_tsvector(reverse(lower(regexp_replace({$document}, '[[:punct:]]', ' ', 'g')))) @@ to_tsquery(reverse(lower({$reversequery})))
|
||||
OR
|
||||
to_tsvector(lower(regexp_replace({$document}, '[[:punct:]]', ' ', 'g'))) @@ to_tsquery(lower({$nospacequery}))
|
||||
|
||||
EOSC;
|
||||
|
||||
return $searchclause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for employees
|
||||
*/
|
||||
@@ -129,34 +216,38 @@ class SearchBarLib
|
||||
FROM public.tbl_mitarbeiter m
|
||||
JOIN public.tbl_benutzer b ON(b.uid = m.mitarbeiter_uid)
|
||||
JOIN (
|
||||
SELECT o.bezeichnung, bf.uid
|
||||
SELECT \'[\' || ot.bezeichnung || \'] \' || o.bezeichnung AS bezeichnung, bf.uid
|
||||
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())
|
||||
GROUP BY o.bezeichnung, bf.uid
|
||||
GROUP BY o.bezeichnung, ot.bezeichnung, bf.uid
|
||||
) stdkst ON stdkst.uid = b.uid
|
||||
JOIN public.tbl_person p USING(person_id)
|
||||
JOIN (
|
||||
SELECT o.bezeichnung, bf.uid
|
||||
SELECT \'[\' || ot.bezeichnung || \'] \' || o.bezeichnung AS bezeichnung, bf.uid
|
||||
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())
|
||||
GROUP BY o.bezeichnung, bf.uid
|
||||
GROUP BY o.bezeichnung, ot.bezeichnung, bf.uid
|
||||
) org ON org.uid = b.uid
|
||||
LEFT JOIN (
|
||||
SELECT kontakt, standort_id
|
||||
FROM public.tbl_kontakt
|
||||
WHERE kontakttyp = \'telefon\'
|
||||
) k ON(k.standort_id = m.standort_id)
|
||||
WHERE b.uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.vorname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR p.nachname ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR org.bezeichnung ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR stdkst.bezeichnung ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
WHERE ' .
|
||||
$this->buildSearchClause(
|
||||
$dbModel,
|
||||
array('b.uid', 'p.vorname', 'p.nachname', 'org.bezeichnung', 'stdkst.bezeichnung'),
|
||||
$searchstr
|
||||
) .
|
||||
'
|
||||
GROUP BY type, b.uid, p.person_id, name, email, m.telefonklappe, phone
|
||||
');
|
||||
|
||||
@@ -178,15 +269,17 @@ class SearchBarLib
|
||||
SELECT
|
||||
\''.$type.'\' AS type,
|
||||
o.oe_kurzbz AS oe_kurzbz,
|
||||
o.bezeichnung AS name,
|
||||
\'[\' || ot.bezeichnung || \'] \' || o.bezeichnung AS name,
|
||||
oParent.oe_kurzbz AS parentoe_kurzbz,
|
||||
oParent.bezeichnung AS parentoe_name,
|
||||
(CASE WHEN oParent.bezeichnung IS NOT NULL THEN \'[\' || otParent.bezeichnung || \'] \' || oParent.bezeichnung END) AS parentoe_name,
|
||||
ARRAY_AGG(DISTINCT(bfLeader.uid)) AS leader_uid,
|
||||
ARRAY_AGG(DISTINCT(bfLeader.vorname || \' \' || bfLeader.nachname)) AS leader_name,
|
||||
COUNT(bfCount.benutzerfunktion_id) AS number_of_people,
|
||||
(CASE WHEN o.mailverteiler = TRUE THEN o.oe_kurzbz || \''.'@'.DOMAIN.'\' END) AS mailgroup
|
||||
FROM public.tbl_organisationseinheit o
|
||||
JOIN public.tbl_organisationseinheittyp ot USING(organisationseinheittyp_kurzbz)
|
||||
LEFT JOIN public.tbl_organisationseinheit oParent ON(oParent.oe_kurzbz = o.oe_parent_kurzbz)
|
||||
LEFT JOIN public.tbl_organisationseinheittyp otParent ON(oParent.organisationseinheittyp_kurzbz = otParent.organisationseinheittyp_kurzbz)
|
||||
LEFT JOIN (
|
||||
SELECT benutzerfunktion_id, oe_kurzbz
|
||||
FROM public.tbl_benutzerfunktion
|
||||
@@ -204,9 +297,14 @@ class SearchBarLib
|
||||
AND (datum_bis IS NULL OR datum_bis >= NOW())
|
||||
AND b.aktiv = TRUE
|
||||
) bfLeader ON(bfLeader.oe_kurzbz = o.oe_kurzbz)
|
||||
WHERE o.oe_kurzbz ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
OR o.bezeichnung ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\'
|
||||
GROUP BY type, o.oe_kurzbz, o.bezeichnung, oParent.oe_kurzbz, oParent.bezeichnung
|
||||
WHERE ' .
|
||||
$this->buildSearchClause(
|
||||
$dbModel,
|
||||
array('o.oe_kurzbz', 'o.bezeichnung', 'ot.bezeichnung'),
|
||||
$searchstr
|
||||
) .
|
||||
'
|
||||
GROUP BY type, o.oe_kurzbz, o.bezeichnung, ot.bezeichnung, oParent.oe_kurzbz, oParent.bezeichnung, otParent.bezeichnung
|
||||
');
|
||||
|
||||
// If something has been found
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2023 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');
|
||||
|
||||
/**
|
||||
@@ -16,6 +33,7 @@ class TableWidgetLib
|
||||
const SESSION_FIELDS = 'fields';
|
||||
const SESSION_COLUMNS_ALIASES = 'columnsAliases';
|
||||
const SESSION_ADDITIONAL_COLUMNS = 'additionalColumns';
|
||||
const SESSION_ENCRYPTED_COLUMNS = 'encryptedColumns';
|
||||
const SESSION_CHECKBOXES = 'checkboxes';
|
||||
const SESSION_METADATA = 'datasetMetadata';
|
||||
const SESSION_ROW_NUMBER = 'rowNumber';
|
||||
@@ -49,6 +67,7 @@ class TableWidgetLib
|
||||
const ADDITIONAL_COLUMNS = 'additionalColumns';
|
||||
const CHECKBOXES = 'checkboxes';
|
||||
const COLUMNS_ALIASES = 'columnsAliases';
|
||||
const ENCRYPTED_COLUMNS = 'encryptedColumns';
|
||||
|
||||
// ...to format/mark records of a dataset
|
||||
const FORMAT_ROW = 'formatRow';
|
||||
@@ -74,7 +93,7 @@ class TableWidgetLib
|
||||
/**
|
||||
* Gets the CI instance and loads message helper
|
||||
*/
|
||||
public function __construct($params = null)
|
||||
public function __construct()
|
||||
{
|
||||
$this->_ci =& get_instance(); // get code igniter instance
|
||||
}
|
||||
@@ -177,7 +196,7 @@ class TableWidgetLib
|
||||
/**
|
||||
* Retrieves the dataset from the DB
|
||||
*/
|
||||
public function getDataset($datasetQuery)
|
||||
public function getDataset($datasetQuery, $encryptedColumns)
|
||||
{
|
||||
$dataset = null;
|
||||
|
||||
@@ -186,7 +205,7 @@ class TableWidgetLib
|
||||
$this->_ci->load->model('system/Filters_model', 'FiltersModel');
|
||||
|
||||
// Execute the given SQL statement suppressing error messages
|
||||
$dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery);
|
||||
$dataset = @$this->_ci->FiltersModel->execReadOnlyQuery($datasetQuery, null, $encryptedColumns);
|
||||
}
|
||||
|
||||
return $dataset;
|
||||
|
||||
@@ -85,6 +85,12 @@ class GbDatumWeitZurueck extends PlausiChecker
|
||||
$params[] = $studiengang_kz;
|
||||
}
|
||||
|
||||
if (isset($exkludierte_studiengang_kz) && !isEmptyArray($exkludierte_studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz NOT IN ?";
|
||||
$params[] = $exkludierte_studiengang_kz;
|
||||
}
|
||||
|
||||
$qry .= ")";
|
||||
|
||||
if (isset($person_id))
|
||||
@@ -93,12 +99,6 @@ class GbDatumWeitZurueck extends PlausiChecker
|
||||
$params[] = $person_id;
|
||||
}
|
||||
|
||||
if (isset($exkludierte_studiengang_kz) && !isEmptyArray($exkludierte_studiengang_kz))
|
||||
{
|
||||
$qry .= " AND stg.studiengang_kz NOT IN ?";
|
||||
$params[] = $exkludierte_studiengang_kz;
|
||||
}
|
||||
|
||||
return $this->_db->execReadOnlyQuery($qry, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\IValidation;
|
||||
|
||||
/**
|
||||
* Description of AbstractBestandteil
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
abstract class AbstractBestandteil implements IValidation
|
||||
{
|
||||
protected $isvalid;
|
||||
protected $validationerrors;
|
||||
|
||||
protected $modifiedcolumns;
|
||||
protected $fromdb;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->isvalid = false;
|
||||
$this->validationerrors = array();
|
||||
|
||||
$this->modifiedcolumns = array();
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
public function isDirty() {
|
||||
return count($this->modifiedcolumns) > 0;
|
||||
}
|
||||
|
||||
protected function markDirty($columnname, $old_value, $new_value) {
|
||||
if( $this->fromdb ) {
|
||||
// data comes from db dont check for changes
|
||||
if( isset($this->modifiedcolumns[$columnname]) ) {
|
||||
unset($this->modifiedcolumns[$columnname]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if( is_bool($new_value) && ($old_value !== $new_value) ) {
|
||||
$this->modifiedcolumns[$columnname] = $columnname;
|
||||
} else if($old_value != $new_value) {
|
||||
$this->modifiedcolumns[$columnname] = $columnname;
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid()
|
||||
{
|
||||
return $this->isvalid;
|
||||
}
|
||||
|
||||
public function getValidationErrors()
|
||||
{
|
||||
return $this->validationerrors;
|
||||
}
|
||||
|
||||
|
||||
public function addValidationError($errormsg)
|
||||
{
|
||||
if( !in_array($errormsg, $this->validationerrors, true) )
|
||||
{
|
||||
$this->validationerrors[] = $errormsg;
|
||||
}
|
||||
$this->isvalid = false;
|
||||
}
|
||||
|
||||
abstract public function hydrateByStdClass($data, $fromdb=false);
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
require_once __DIR__ . '/IValidation.php';
|
||||
require_once __DIR__ . '/AbstractBestandteil.php';
|
||||
|
||||
use vertragsbestandteil\AbstractBestandteil;
|
||||
use vertragsbestandteil\IValidation;
|
||||
|
||||
const TYPE_ECHT = 'echterdv';
|
||||
const TYPE_STUDENTISCHE_HILFSKRAFT = 'studentischehilfskr';
|
||||
const TYPE_FREI = 'freierdv';
|
||||
const TYPE_EXTERN = 'externerlehrender';
|
||||
const TYPE_GAST = 'gastlektor';
|
||||
const TYPE_ECHT_FREI = 'echterfreier';
|
||||
const TYPE_WERKVERTRAG = 'werkvertrag';
|
||||
const TYPE_UEBERLASSUNG = 'ueberlassungsvertrag';
|
||||
|
||||
class Dienstverhaeltnis extends AbstractBestandteil {
|
||||
protected $dienstverhaeltnis_id;
|
||||
protected $mitarbeiter_uid;
|
||||
protected $vertragsart_kurzbz;
|
||||
protected $oe_kurzbz;
|
||||
protected $checkoverlap;
|
||||
protected $von;
|
||||
protected $bis;
|
||||
protected $insertamum;
|
||||
protected $insertvon;
|
||||
protected $updateamum;
|
||||
protected $updatevon;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->checkoverlap = true;
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->dienstverhaeltnis_id) && $this->setDienstverhaeltnis_id($data->dienstverhaeltnis_id);
|
||||
isset($data->mitarbeiter_uid) && $this->setMitarbeiter_uid($data->mitarbeiter_uid);
|
||||
isset($data->vertragsart_kurzbz) && $this->setVertragsart_kurzbz($data->vertragsart_kurzbz);
|
||||
isset($data->checkoverlap) && $this->setCheckoverlap($data->checkoverlap);
|
||||
isset($data->oe_kurzbz) && $this->setOe_kurzbz($data->oe_kurzbz);
|
||||
isset($data->von) && $this->setVon($data->von);
|
||||
isset($data->bis) && $this->setBis($data->bis);
|
||||
isset($data->insertamum) && $this->setInsertamum($data->insertamum);
|
||||
isset($data->insertvon) && $this->setInsertvon($data->insertvon);
|
||||
isset($data->updateamum) && $this->setUpdateamum($data->updateamum);
|
||||
isset($data->updatevon) && $this->setUpdatevon($data->updatevon);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'dienstverhaeltnis_id' => $this->getDienstverhaeltnis_id(),
|
||||
'mitarbeiter_uid' => $this->getMitarbeiter_uid(),
|
||||
'vertragsart_kurzbz' => $this->getVertragsart_kurzbz(),
|
||||
'oe_kurzbz' => $this->getOe_kurzbz(),
|
||||
'von' => $this->getVon(),
|
||||
'bis' => $this->getBis(),
|
||||
'insertamum' => $this->getInsertamum(),
|
||||
'insertvon' => $this->getInsertvon(),
|
||||
'updateamum' => $this->getUpdateamum(),
|
||||
'updatevon' => $this->getUpdatevon()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
dienstverhaeltnis_id: {$this->getDienstverhaeltnis_id()}
|
||||
mitarbeiter_uid: {$this->getMitarbeiter_uid()}
|
||||
vertragsart_kurzbz: {$this->getVertragsart_kurzbz()}
|
||||
oe_kurzbz: {$this->getOe_kurzbz()}
|
||||
von: {$this->getVon()}
|
||||
bis: {$this->getBis()}
|
||||
|
||||
EOTXT;
|
||||
return $txt;
|
||||
}
|
||||
|
||||
public function getDienstverhaeltnis_id()
|
||||
{
|
||||
return $this->dienstverhaeltnis_id;
|
||||
}
|
||||
|
||||
public function getMitarbeiter_uid()
|
||||
{
|
||||
return $this->mitarbeiter_uid;
|
||||
}
|
||||
|
||||
public function getVertragsart_kurzbz()
|
||||
{
|
||||
return $this->vertragsart_kurzbz;
|
||||
}
|
||||
|
||||
public function getOe_kurzbz()
|
||||
{
|
||||
return $this->oe_kurzbz;
|
||||
}
|
||||
|
||||
public function getVon()
|
||||
{
|
||||
return $this->von;
|
||||
}
|
||||
|
||||
public function getBis()
|
||||
{
|
||||
return $this->bis;
|
||||
}
|
||||
|
||||
public function getInsertamum()
|
||||
{
|
||||
return $this->insertamum;
|
||||
}
|
||||
|
||||
public function getInsertvon()
|
||||
{
|
||||
return $this->insertvon;
|
||||
}
|
||||
|
||||
public function getUpdateamum()
|
||||
{
|
||||
return $this->updateamum;
|
||||
}
|
||||
|
||||
public function getUpdatevon()
|
||||
{
|
||||
return $this->updatevon;
|
||||
}
|
||||
|
||||
public function setDienstverhaeltnis_id($dienstverhaeltnis_id)
|
||||
{
|
||||
$this->markDirty('dienstverhaeltnis_id', $this->dienstverhaeltnis_id, $dienstverhaeltnis_id);
|
||||
$this->dienstverhaeltnis_id = $dienstverhaeltnis_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMitarbeiter_uid($mitarbeiter_uid)
|
||||
{
|
||||
$this->markDirty('mitarbeiter_uid', $this->mitarbeiter_uid, $mitarbeiter_uid);
|
||||
$this->mitarbeiter_uid = $mitarbeiter_uid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVertragsart_kurzbz($vertragsart_kurzbz)
|
||||
{
|
||||
$this->markDirty('vertragsart_kurzbz', $this->vertragsart_kurzbz, $vertragsart_kurzbz);
|
||||
$this->vertragsart_kurzbz = $vertragsart_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCheckoverlap(bool $checkoverlap)
|
||||
{
|
||||
$this->checkoverlap = $checkoverlap;
|
||||
}
|
||||
|
||||
public function setOe_kurzbz($oe_kurzbz)
|
||||
{
|
||||
$this->markDirty('oe_kurzbz', $this->oe_kurzbz, $oe_kurzbz);
|
||||
$this->oe_kurzbz = $oe_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVon($von)
|
||||
{
|
||||
$this->markDirty('von', $this->von, $von);
|
||||
$this->von = $von;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setBis($bis)
|
||||
{
|
||||
$this->markDirty('bis', $this->bis, $bis);
|
||||
$this->bis = $bis;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInsertamum($insertamum)
|
||||
{
|
||||
$this->markDirty('insertamum', $this->insertamum, $insertamum);
|
||||
$this->insertamum = $insertamum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInsertvon($insertvon)
|
||||
{
|
||||
$this->markDirty('insertvon', $this->insertvon, $insertvon);
|
||||
$this->insertvon = $insertvon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdateamum($updateamum)
|
||||
{
|
||||
$this->markDirty('updateamum', $this->updateamum, $updateamum);
|
||||
$this->updateamum = $updateamum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatevon($updatevon)
|
||||
{
|
||||
$this->markDirty('updatevon', $this->updatevon, $updatevon);
|
||||
$this->updatevon = $updatevon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function validate() {
|
||||
//do Validation here
|
||||
$ci = get_instance();
|
||||
$ci->load->library('vertragsbestandteil/VertragsbestandteilLib',
|
||||
null, 'VertragsbestandteilLib');
|
||||
|
||||
if( empty($this->mitarbeiter_uid) ) {
|
||||
$this->validationerrors[] = 'Mitarbeiter_UID fehlt.';
|
||||
}
|
||||
|
||||
if( empty($this->oe_kurzbz) ) {
|
||||
$this->validationerrors[] = 'Unternehmen fehlt.';
|
||||
}
|
||||
|
||||
if( empty($this->vertragsart_kurzbz) ) {
|
||||
$this->validationerrors[] = 'Vertragsart fehlt.';
|
||||
}
|
||||
|
||||
$von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von);
|
||||
$bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis);
|
||||
|
||||
if( false === $von ) {
|
||||
$this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.';
|
||||
}
|
||||
|
||||
if( $this->bis !== null && $bis === false ) {
|
||||
$this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.';
|
||||
}
|
||||
|
||||
if( $this-> bis !== null && $von && $bis && $von > $bis ) {
|
||||
$this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.';
|
||||
}
|
||||
|
||||
if( $this->checkoverlap && !(in_array($this->vertragsart_kurzbz, array('werkvertrag', 'studentischehilfskr')) )
|
||||
&& $ci->VertragsbestandteilLib->isOverlappingExistingDV($this) )
|
||||
{
|
||||
$this->validationerrors[] = 'Es existiert bereits ein überlappendes Dienstverhältnis';
|
||||
}
|
||||
|
||||
// return status after Validation
|
||||
if( count($this->validationerrors) > 0 ) {
|
||||
$this->isvalid = false;
|
||||
} else {
|
||||
$this->isvalid = true;
|
||||
}
|
||||
|
||||
return $this->isvalid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\AbstractBestandteil;
|
||||
use DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* Salary always depends on employment (Dienstverhältnis) and optionally on part of contract (Vetragsbestandteil)
|
||||
*/
|
||||
class Gehaltsbestandteil extends AbstractBestandteil implements \JsonSerializable
|
||||
{
|
||||
protected $gehaltsbestandteil_id;
|
||||
protected $dienstverhaeltnis_id;
|
||||
protected $vertragsbestandteil_id;
|
||||
protected $gehaltstyp_kurzbz;
|
||||
protected $von;
|
||||
protected $bis;
|
||||
protected $anmerkung;
|
||||
protected $grundbetrag;
|
||||
protected $betrag_valorisiert;
|
||||
protected $valorisierungssperre;
|
||||
protected $valorisierung;
|
||||
protected $auszahlungen;
|
||||
|
||||
protected $insertamum;
|
||||
protected $insertvon;
|
||||
protected $updateamum;
|
||||
protected $updatevon;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->gehaltsbestandteil_id) && $this->setGehaltsbestandteil_id($data->gehaltsbestandteil_id);
|
||||
isset($data->dienstverhaeltnis_id) && $this->setDienstverhaeltnis_id($data->dienstverhaeltnis_id);
|
||||
isset($data->vertragsbestandteil_id) && $this->setVertragsbestandteil_id($data->vertragsbestandteil_id);
|
||||
isset($data->gehaltstyp_kurzbz) && $this->setGehaltstyp_kurzbz($data->gehaltstyp_kurzbz);
|
||||
isset($data->von) && $this->setVon($data->von);
|
||||
isset($data->bis) && $this->setBis($data->bis);
|
||||
isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung);
|
||||
isset($data->grundbetrag) && $this->setGrundbetrag($data->grundbetrag);
|
||||
isset($data->betrag_valorisiert) && $this->setBetrag_valorisiert($data->betrag_valorisiert);
|
||||
isset($data->valorisierungssperre) && $this->setValorisierungssperre($data->valorisierungssperre);
|
||||
isset($data->valorisierung) && $this->setValorisierung($data->valorisierung);
|
||||
isset($data->auszahlungen) && $this->setAuszahlungen($data->auszahlungen);
|
||||
|
||||
isset($data->insertamum) && $this->setInsertamum($data->insertamum);
|
||||
isset($data->insertvon) && $this->setInsertvon($data->insertvon);
|
||||
isset($data->updateamum) && $this->setUpdateamum($data->updateamum);
|
||||
isset($data->updatevon) && $this->setUpdatevon($data->updatevon);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
public function getGehaltsbestandteil_id()
|
||||
{
|
||||
return $this->gehaltsbestandteil_id;
|
||||
}
|
||||
|
||||
public function getDienstverhaeltnis_id()
|
||||
{
|
||||
return $this->dienstverhaeltnis_id;
|
||||
}
|
||||
|
||||
public function getVertragsbestandteil_id()
|
||||
{
|
||||
return $this->vertragsbestandteil_id;
|
||||
}
|
||||
|
||||
public function getGehaltstyp_kurzbz()
|
||||
{
|
||||
return $this->gehaltstyp_kurzbz;
|
||||
}
|
||||
|
||||
public function getVon()
|
||||
{
|
||||
return $this->von;
|
||||
}
|
||||
|
||||
public function getBis()
|
||||
{
|
||||
return $this->bis;
|
||||
}
|
||||
|
||||
public function getVonDateTime()
|
||||
{
|
||||
return $this->toDateTime($this->von);
|
||||
}
|
||||
|
||||
public function getBisDateTime()
|
||||
{
|
||||
return $this->toDateTime($this->bis);
|
||||
}
|
||||
|
||||
protected function toDateTime($d) {
|
||||
if ($d == null) return null;
|
||||
return new DateTimeImmutable($d);
|
||||
}
|
||||
|
||||
public function getAnmerkung()
|
||||
{
|
||||
return $this->anmerkung;
|
||||
}
|
||||
|
||||
public function getGrundbetrag()
|
||||
{
|
||||
return $this->grundbetrag;
|
||||
}
|
||||
|
||||
public function getBetrag_valorisiert()
|
||||
{
|
||||
return $this->betrag_valorisiert;
|
||||
}
|
||||
|
||||
public function getValorisierungssperre()
|
||||
{
|
||||
return $this->valorisierungssperre;
|
||||
}
|
||||
|
||||
public function getValorisierung()
|
||||
{
|
||||
return $this->valorisierung;
|
||||
}
|
||||
|
||||
public function getAuszahlungen()
|
||||
{
|
||||
return $this->auszahlungen;
|
||||
}
|
||||
|
||||
public function getInsertamum()
|
||||
{
|
||||
return $this->insertamum;
|
||||
}
|
||||
|
||||
public function getInsertvon()
|
||||
{
|
||||
return $this->insertvon;
|
||||
}
|
||||
|
||||
public function getUpdateamum()
|
||||
{
|
||||
return $this->updateamum;
|
||||
}
|
||||
|
||||
public function getUpdatevon()
|
||||
{
|
||||
return $this->updatevon;
|
||||
}
|
||||
|
||||
public function setGehaltsbestandteil_id($gehaltsbestandteil_id)
|
||||
{
|
||||
$this->markDirty('gehaltsbestandteil_id', $this->gehaltsbestandteil_id, $gehaltsbestandteil_id);
|
||||
$this->gehaltsbestandteil_id = $gehaltsbestandteil_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDienstverhaeltnis_id($dienstverhaeltnis_id)
|
||||
{
|
||||
$this->markDirty('dienstverhaeltnis_id', $this->dienstverhaeltnis_id, $dienstverhaeltnis_id);
|
||||
$this->dienstverhaeltnis_id = $dienstverhaeltnis_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVertragsbestandteil_id($vertragsbestandteil_id)
|
||||
{
|
||||
$this->markDirty('vertragsbestandteil_id', $this->vertragsbestandteil_id, $vertragsbestandteil_id);
|
||||
$this->vertragsbestandteil_id = $vertragsbestandteil_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setGehaltstyp_kurzbz($gehaltstyp_kurzbz)
|
||||
{
|
||||
$this->markDirty('gehaltstyp_kurzbz', $this->gehaltstyp_kurzbz, $gehaltstyp_kurzbz);
|
||||
$this->gehaltstyp_kurzbz = $gehaltstyp_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVon($von)
|
||||
{
|
||||
$this->markDirty('von', $this->von, $von);
|
||||
$this->von = $von;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setBis($bis)
|
||||
{
|
||||
$this->markDirty('bis', $this->bis, $bis);
|
||||
$this->bis = $bis;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAnmerkung($anmerkung)
|
||||
{
|
||||
$this->markDirty('anmerkung', $this->anmerkung, $anmerkung);
|
||||
$this->anmerkung = $anmerkung;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setGrundbetrag($grundbetrag)
|
||||
{
|
||||
$this->markDirty('grundbetrag', $this->grundbetrag, $grundbetrag);
|
||||
$this->grundbetrag = $grundbetrag;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setBetrag_valorisiert($betrag_valorisiert)
|
||||
{
|
||||
$this->markDirty('betrag_valorisiert', $this->betrag_valorisiert, $betrag_valorisiert);
|
||||
$this->betrag_valorisiert = $betrag_valorisiert;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setValorisierungssperre($valorisierungssperre)
|
||||
{
|
||||
$this->markDirty('valorisierungssperre', $this->valorisierungssperre, $valorisierungssperre);
|
||||
$this->valorisierungssperre = $valorisierungssperre;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setValorisierung($valorisierung)
|
||||
{
|
||||
$this->markDirty('valorisierung', $this->valorisierung, $valorisierung);
|
||||
$this->valorisierung = $valorisierung;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAuszahlungen($auszahlungen)
|
||||
{
|
||||
$this->markDirty('auszahlungen', $this->auszahlungen, $auszahlungen);
|
||||
$this->auszahlungen = $auszahlungen;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInsertamum($insertamum)
|
||||
{
|
||||
$this->markDirty('insertamum', $this->insertamum, $insertamum);
|
||||
$this->insertamum = $insertamum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInsertvon($insertvon)
|
||||
{
|
||||
$this->markDirty('insertvon', $this->insertvon, $insertvon);
|
||||
$this->insertvon = $insertvon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdateamum($updateamum)
|
||||
{
|
||||
$this->markDirty('updateamum', $this->updateamum, $updateamum);
|
||||
$this->updateamum = $updateamum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatevon($updatevon)
|
||||
{
|
||||
$this->markDirty('updatevon', $this->updatevon, $updatevon);
|
||||
$this->updatevon = $updatevon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
unset($vars['CI']);
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'gehaltsbestandteil_id' => $this->getGehaltsbestandteil_id(),
|
||||
'dienstverhaeltnis_id' => $this->getDienstverhaeltnis_id(),
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'gehaltstyp_kurzbz' => $this->getGehaltstyp_kurzbz(),
|
||||
'von' => $this->getVon(),
|
||||
'bis' => $this->getBis(),
|
||||
'anmerkung' => $this->getAnmerkung(),
|
||||
'grundbetrag' => $this->getGrundbetrag(),
|
||||
'betrag_valorisiert' => $this->getBetrag_valorisiert(),
|
||||
'valorisierungssperre' => $this->getValorisierungssperre(),
|
||||
'valorisierung' => $this->getValorisierung(),
|
||||
'auszahlungen' => $this->getAuszahlungen(),
|
||||
'insertamum' => $this->getInsertamum(),
|
||||
'insertvon' => $this->getInsertvon(),
|
||||
'updateamum' => $this->getUpdateamum(),
|
||||
'updatevon' => $this->getUpdatevon()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
gehaltsbestandteil_id: {$this->getGehaltsbestandteil_id()}
|
||||
dienstverhaeltnis_id: {$this->getDienstverhaeltnis_id()}
|
||||
vertragsbestandteil_id: {$this->getVertragsbestandteil_id()}
|
||||
gehaltstyp_kurzbz: {$this->getGehaltstyp_kurzbz()}
|
||||
von: {$this->getVon()}
|
||||
bis: {$this->getBis()}
|
||||
anmerkung: {$this->getAnmerkung()}
|
||||
grundbetrag: {$this->getGrundbetrag()}
|
||||
betrag_valorisiert: {$this->getBetrag_valorisiert()}
|
||||
valorisierungssperre: {$this->getValorisierungssperre()}
|
||||
valorisierung: {$this->getValorisierung()}
|
||||
auszahlungen: {$this->getAuszahlungen()}
|
||||
insertamum: {$this->getInsertamum()}
|
||||
insertvon: {$this->getInsertvon()}
|
||||
updateamum: {$this->getUpdateamum()}
|
||||
updatevon: {$this->getUpdatevon()}
|
||||
|
||||
EOTXT;
|
||||
return $txt;
|
||||
}
|
||||
|
||||
public function validate() {
|
||||
//do Validation here
|
||||
if( empty($this->gehaltstyp_kurzbz) )
|
||||
{
|
||||
$this->validationerrors[] = "Ein Gehaltstyp muss ausgewählt sein.";
|
||||
}
|
||||
|
||||
if( empty($this->grundbetrag) )
|
||||
{
|
||||
$this->validationerrors[] = "Betrag fehlt.";
|
||||
}
|
||||
|
||||
$von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von);
|
||||
$bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis);
|
||||
|
||||
if( false === $von ) {
|
||||
$this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.';
|
||||
}
|
||||
|
||||
if( $this->bis !== null && $bis === false ) {
|
||||
$this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.';
|
||||
}
|
||||
|
||||
if( $this-> bis !== null && $von && $bis && $von > $bis ) {
|
||||
$this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.';
|
||||
}
|
||||
|
||||
// return status after Validation
|
||||
if( count($this->validationerrors) > 0 ) {
|
||||
$this->isvalid = false;
|
||||
} else {
|
||||
$this->isvalid = true;
|
||||
}
|
||||
|
||||
return $this->isvalid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/IValidation.php';
|
||||
require_once __DIR__ . '/AbstractBestandteil.php';
|
||||
require_once __DIR__ . '/Gehaltsbestandteil.php';
|
||||
|
||||
use vertragsbestandteil\Gehaltsbestandteil;
|
||||
|
||||
/**
|
||||
* Description of GehaltsbestandteilLib
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class GehaltsbestandteilLib
|
||||
{
|
||||
protected $CI;
|
||||
/** @var Gehaltsbestandteil_model */
|
||||
protected $GehaltsbestandteilModel;
|
||||
|
||||
protected $loggedInUser;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->loggedInUser = getAuthUID();
|
||||
$this->CI = get_instance();
|
||||
$this->CI->load->model('vertragsbestandteil/Gehaltsbestandteil_model',
|
||||
'GehaltsbestandteilModel');
|
||||
$this->CI->load->library('extensions/FHC-Core-Personalverwaltung/abrechnung/GehaltsLib');
|
||||
$this->GehaltsbestandteilModel = $this->CI->GehaltsbestandteilModel;
|
||||
}
|
||||
|
||||
public function fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag=null, $includefuture=false)
|
||||
{
|
||||
return $this->GehaltsbestandteilModel->getGehaltsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture);
|
||||
}
|
||||
|
||||
public function fetchGehaltsbestandteil($gehaltsbestandteil_id)
|
||||
{
|
||||
return $this->GehaltsbestandteilModel->getGehaltsbestandteil($gehaltsbestandteil_id);
|
||||
}
|
||||
|
||||
public function storeGehaltsbestandteile($gehaltsbestandteile)
|
||||
{
|
||||
foreach( $gehaltsbestandteile as $gehaltsbestandteil )
|
||||
{
|
||||
$this->storeGehaltsbestandteil($gehaltsbestandteil);
|
||||
}
|
||||
}
|
||||
|
||||
public function storeGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->setUIDtoPGSQL();
|
||||
if( intval($gehaltsbestandteil->getGehaltsbestandteil_id()) > 0 )
|
||||
{
|
||||
$this->updateGehaltsbestandteil($gehaltsbestandteil);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->insertGehaltsbestandteil($gehaltsbestandteil);
|
||||
}
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
log_message('debug', "Storing Gehaltsbestandteil failed. " . $ex->getMessage());
|
||||
throw new Exception('Storing Gehaltsbestandteil failed.');
|
||||
}
|
||||
}
|
||||
|
||||
protected function insertGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil)
|
||||
{
|
||||
$gehaltsbestandteil->setInsertvon($this->loggedInUser)
|
||||
->setInsertamum(strftime('%Y-%m-%d %H:%M:%S'));
|
||||
$ret = $this->GehaltsbestandteilModel->insert($gehaltsbestandteil->toStdClass(),
|
||||
$this->GehaltsbestandteilModel->getEncryptedColumns());
|
||||
if( hasData($ret) )
|
||||
{
|
||||
$gehaltsbestandteil->setGehaltsbestandteil_id(getData($ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception('error inserting gehaltsbestandteil');
|
||||
}
|
||||
}
|
||||
|
||||
protected function updateGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil)
|
||||
{
|
||||
if(!$gehaltsbestandteil->isDirty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$gehaltsbestandteil->setUpdatevon($this->loggedInUser)
|
||||
->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S'));
|
||||
$ret = $this->GehaltsbestandteilModel->update($gehaltsbestandteil->getGehaltsbestandteil_id(),
|
||||
$gehaltsbestandteil->toStdClass(),
|
||||
$this->GehaltsbestandteilModel->getEncryptedColumns());
|
||||
|
||||
if(isError($ret) )
|
||||
{
|
||||
throw new Exception('error updating gehaltsbestandteil');
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteGehaltsbestandteile($gehaltsbestandteile)
|
||||
{
|
||||
foreach( $gehaltsbestandteile as $gehaltsbestandteil )
|
||||
{
|
||||
$this->deleteGehaltsbestandteil($gehaltsbestandteil);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil)
|
||||
{
|
||||
$this->setUIDtoPGSQL();
|
||||
|
||||
// delete Gehaltsabrechnung
|
||||
$ret = $this->CI->gehaltslib->deleteAbrechnung($gehaltsbestandteil);
|
||||
|
||||
//
|
||||
$ret = $this->GehaltsbestandteilModel->delete($gehaltsbestandteil->getGehaltsbestandteil_id());
|
||||
|
||||
if (isError($ret))
|
||||
{
|
||||
throw new Exception('error deleting gehaltsbestandteil');
|
||||
}
|
||||
}
|
||||
|
||||
public function endGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil, $enddate)
|
||||
{
|
||||
$this->setUIDtoPGSQL();
|
||||
if( $gehaltsbestandteil->getBis() !== null && $gehaltsbestandteil->getBis() < $enddate )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$gehaltsbestandteil->setBis($enddate);
|
||||
$this->updateGehaltsbestandteil($gehaltsbestandteil);
|
||||
}
|
||||
|
||||
protected function setUIDtoPGSQL() {
|
||||
$ret = $this->GehaltsbestandteilModel
|
||||
->execReadOnlyQuery('SET LOCAL pv21.uid TO \''
|
||||
. $this->loggedInUser . '\'');
|
||||
if(isError($ret))
|
||||
{
|
||||
throw new Exception('error setting uid to pgsql');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
/**
|
||||
* Description of IValidation
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
interface IValidation
|
||||
{
|
||||
public function isValid();
|
||||
|
||||
public function getValidationErrors();
|
||||
|
||||
public function validate();
|
||||
|
||||
public function addValidationError($errormsg);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFreitext;
|
||||
|
||||
/**
|
||||
* Description of OverlapChecker
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class OverlapChecker
|
||||
{
|
||||
protected $CI;
|
||||
/**
|
||||
* @var Vertragsbestandteil_model
|
||||
*/
|
||||
protected $VertragsbestandteilModel;
|
||||
/**
|
||||
* @var VertragsbestandteilFreitext_model
|
||||
*/
|
||||
protected $VertragsbestandteilFreitextModel;
|
||||
/**
|
||||
* @var VertragsbestandteilTyp_model
|
||||
*/
|
||||
protected $VertragsbestandteilTypModel;
|
||||
/**
|
||||
* @var VertragsbestandteilFreitexttyp_model
|
||||
*/
|
||||
protected $VertragsbestandteilFreitexttypModel;
|
||||
|
||||
protected static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
if( null === self::$instance )
|
||||
{
|
||||
self::$instance = new OverlapChecker();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$this->CI = get_instance();
|
||||
$this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model',
|
||||
'VertragsbestandteilModel');
|
||||
$this->VertragsbestandteilModel = $this->CI->VertragsbestandteilModel;
|
||||
$this->CI->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model',
|
||||
'VertragsbestandteilFreitextModel');
|
||||
$this->VertragsbestandteilFreitextModel = $this->CI->VertragsbestandteilFreitextModel;
|
||||
$this->CI->load->model('vertragsbestandteil/Vertragsbestandteiltyp_model',
|
||||
'VertragsbestandteilTypModel');
|
||||
$this->VertragsbestandteilTypModel = $this->CI->VertragsbestandteilTypModel;
|
||||
$this->CI->load->model('vertragsbestandteil/VertragsbestandteilFreitexttyp_model',
|
||||
'VertragsbestandteilFreitexttypModel');
|
||||
$this->VertragsbestandteilFreitexttypModel = $this->CI->VertragsbestandteilFreitexttypModel;
|
||||
}
|
||||
|
||||
public function overlapsVB(Vertragsbestandteil $vb)
|
||||
{
|
||||
$result = $this->VertragsbestandteilTypModel->load($vb->getVertragsbestandteiltyp_kurzbz());
|
||||
if( null === ($vertragsbestandteiltyp = getData($result)) )
|
||||
{
|
||||
throw new Exception('vertragsbestandteiltyp: '
|
||||
. $vb->getVertragsbestandteiltyp_kurzbz() . ' not found.');
|
||||
}
|
||||
|
||||
if( true === $vertragsbestandteiltyp[0]->ueberlappend )
|
||||
{
|
||||
// vertragsbestandteiltyp can overlap
|
||||
return false;
|
||||
}
|
||||
|
||||
if( $this->VertragsbestandteilModel->countOverlappingVBsOfSameType($vb) === 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function overlapsFreitext(VertragsbestandteilFreitext $vbft)
|
||||
{
|
||||
$result = $this->VertragsbestandteilFreitexttypModel->load($vbft->getFreitexttypKurzbz());
|
||||
if( null === ($vertragsbestandteilfreitexttyp = getData($result)) )
|
||||
{
|
||||
throw new Exception('vertragsbestandteilfreitexttyp: '
|
||||
. $vbft->getFreitexttypKurzbz() . ' not found.');
|
||||
}
|
||||
|
||||
if( true === $vertragsbestandteilfreitexttyp[0]->ueberlappend )
|
||||
{
|
||||
// freitexttyp can overlap
|
||||
return false;
|
||||
}
|
||||
|
||||
if( $this->VertragsbestandteilFreitextModel->countOverlappingVBFreitextsOfSameType($vbft) === 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private function __clone() {}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\AbstractBestandteil;
|
||||
|
||||
/**
|
||||
* Description of Vertragsbestandteil
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
abstract class Vertragsbestandteil extends AbstractBestandteil implements \JsonSerializable
|
||||
{
|
||||
protected $vertragsbestandteil_id;
|
||||
protected $dienstverhaeltnis_id;
|
||||
protected $von;
|
||||
protected $bis;
|
||||
protected $vertragsbestandteiltyp_kurzbz;
|
||||
protected $insertamum;
|
||||
protected $insertvon;
|
||||
protected $updateamum;
|
||||
protected $updatevon;
|
||||
|
||||
protected $gehaltsbestandteile;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->gehaltsbestandteile = array();
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->vertragsbestandteil_id) && $this->setVertragsbestandteil_id($data->vertragsbestandteil_id);
|
||||
isset($data->dienstverhaeltnis_id) && $this->setDienstverhaeltnis_id($data->dienstverhaeltnis_id);
|
||||
isset($data->von) && $this->setVon($data->von);
|
||||
isset($data->bis) && $this->setBis($data->bis);
|
||||
isset($data->vertragsbestandteiltyp_kurzbz) && $this->setVertragsbestandteiltyp_kurzbz($data->vertragsbestandteiltyp_kurzbz);
|
||||
isset($data->insertamum) && $this->setInsertamum($data->insertamum);
|
||||
isset($data->insertvon) && $this->setInsertvon($data->insertvon);
|
||||
isset($data->updateamum) && $this->setUpdateamum($data->updateamum);
|
||||
isset($data->updatevon) && $this->setUpdatevon($data->updatevon);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
public function addGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil)
|
||||
{
|
||||
$gehaltsbestandteil->setDienstverhaeltnis_id($this->getDienstverhaeltnis_id());
|
||||
$gehaltsbestandteil->setVertragsbestandteil_id($this->getVertragsbestandteil_id());
|
||||
$this->gehaltsbestandteile[] = $gehaltsbestandteil;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGehaltsbestandteile()
|
||||
{
|
||||
return $this->gehaltsbestandteile;
|
||||
}
|
||||
|
||||
public function getVertragsbestandteil_id()
|
||||
{
|
||||
return $this->vertragsbestandteil_id;
|
||||
}
|
||||
|
||||
public function getDienstverhaeltnis_id()
|
||||
{
|
||||
return $this->dienstverhaeltnis_id;
|
||||
}
|
||||
|
||||
public function getVon()
|
||||
{
|
||||
return $this->von;
|
||||
}
|
||||
|
||||
public function getBis()
|
||||
{
|
||||
return $this->bis;
|
||||
}
|
||||
|
||||
public function getVertragsbestandteiltyp_kurzbz()
|
||||
{
|
||||
return $this->vertragsbestandteiltyp_kurzbz;
|
||||
}
|
||||
|
||||
public function getInsertamum()
|
||||
{
|
||||
return $this->insertamum;
|
||||
}
|
||||
|
||||
public function getInsertvon()
|
||||
{
|
||||
return $this->insertvon;
|
||||
}
|
||||
|
||||
public function getUpdateamum()
|
||||
{
|
||||
return $this->updateamum;
|
||||
}
|
||||
|
||||
public function getUpdatevon()
|
||||
{
|
||||
return $this->updatevon;
|
||||
}
|
||||
|
||||
public function setGehaltsbestandteile($gehaltsbestandteile)
|
||||
{
|
||||
$this->gehaltsbestandteile = $gehaltsbestandteile;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVertragsbestandteil_id($vertragsbestandteil_id)
|
||||
{
|
||||
$this->markDirty('vertragsbestandteil_id', $this->vertragsbestandteil_id, $vertragsbestandteil_id);
|
||||
$this->vertragsbestandteil_id = $vertragsbestandteil_id;
|
||||
foreach ($this->gehaltsbestandteile as $gehaltsbestandteil)
|
||||
{
|
||||
$gehaltsbestandteil->setVertragsbestandteil_id($vertragsbestandteil_id);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDienstverhaeltnis_id($dienstverhaeltnis_id)
|
||||
{
|
||||
$this->markDirty('dienstverhaeltnis_id', $this->dienstverhaeltnis_id, $dienstverhaeltnis_id);
|
||||
$this->dienstverhaeltnis_id = $dienstverhaeltnis_id;
|
||||
foreach ($this->gehaltsbestandteile as $gehaltsbestandteil)
|
||||
{
|
||||
$gehaltsbestandteil->setDienstverhaeltnis_id($dienstverhaeltnis_id);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVon($von)
|
||||
{
|
||||
$this->markDirty('von', $this->von, $von);
|
||||
$this->von = $von;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setBis($bis)
|
||||
{
|
||||
$this->markDirty('bis', $this->bis, $bis);
|
||||
$this->bis = $bis;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVertragsbestandteiltyp_kurzbz($vertragsbestandteiltyp_kurzbz)
|
||||
{
|
||||
$this->markDirty('vertragsbestandteiltyp_kurzbz', $this->vertragsbestandteiltyp_kurzbz, $vertragsbestandteiltyp_kurzbz);
|
||||
$this->vertragsbestandteiltyp_kurzbz = $vertragsbestandteiltyp_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInsertamum($insertamum)
|
||||
{
|
||||
$this->markDirty('insertamum', $this->insertamum, $insertamum);
|
||||
$this->insertamum = $insertamum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInsertvon($insertvon)
|
||||
{
|
||||
$this->markDirty('insertvon', $this->insertvon, $insertvon);
|
||||
$this->insertvon = $insertvon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdateamum($updateamum)
|
||||
{
|
||||
$this->markDirty('updateamum', $this->updateamum, $updateamum);
|
||||
$this->updateamum = $updateamum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatevon($updatevon)
|
||||
{
|
||||
$this->markDirty('updatevon', $this->updatevon, $updatevon);
|
||||
$this->updatevon = $updatevon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function baseToStdClass() {
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'dienstverhaeltnis_id' => $this->getDienstverhaeltnis_id(),
|
||||
'von' => $this->getVon(),
|
||||
'bis' => $this->getBis(),
|
||||
'vertragsbestandteiltyp_kurzbz' => $this->getVertragsbestandteiltyp_kurzbz(),
|
||||
'insertamum' => $this->getInsertamum(),
|
||||
'insertvon' => $this->getInsertvon(),
|
||||
'updateamum' => $this->getUpdateamum(),
|
||||
'updatevon' => $this->getUpdatevon(),
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
unset($vars['CI']);
|
||||
|
||||
// TODO cleanup workaroung for vb freitext where db column is anmerkung and formfield is freitext
|
||||
if( isset($vars['anmerkung']) ) {
|
||||
$vars['freitext'] = $vars['anmerkung'];
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return <<<EOTXT
|
||||
vertragsbestandteil_id: {$this->getVertragsbestandteil_id()}
|
||||
dienstverhaeltnis_id: {$this->getDienstverhaeltnis_id()}
|
||||
von: {$this->getVon()}
|
||||
bis: {$this->getBis()}
|
||||
vertragsbestandteiltyp_kurzbz: {$this->getVertragsbestandteiltyp_kurzbz()}
|
||||
insertamum: {$this->getInsertamum()}
|
||||
insertvon: {$this->getInsertvon()}
|
||||
updateamum: {$this->getUpdateamum()}
|
||||
updatevon: {$this->getUpdatevon()}
|
||||
|
||||
EOTXT;
|
||||
|
||||
}
|
||||
|
||||
public function beforePersist() {
|
||||
// can be overridden in childs
|
||||
}
|
||||
|
||||
public function afterDelete() {
|
||||
// can be overridden in childs
|
||||
}
|
||||
|
||||
public function validate() {
|
||||
$von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von);
|
||||
$bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis);
|
||||
|
||||
if( false === $von ) {
|
||||
$this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.';
|
||||
}
|
||||
|
||||
if( $this->bis !== null && $bis === false ) {
|
||||
$this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.';
|
||||
}
|
||||
|
||||
if( $this-> bis !== null && $von && $bis && $von > $bis ) {
|
||||
$this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.';
|
||||
}
|
||||
|
||||
if( count($this->validationerrors) > 0 ) {
|
||||
$this->isvalid = false;
|
||||
} else {
|
||||
$this->isvalid = true;
|
||||
}
|
||||
|
||||
return $this->isvalid;
|
||||
}
|
||||
|
||||
public abstract function toStdClass();
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use Exception;
|
||||
use vertragsbestandteil\VertragsbestandteilStunden;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilFactory
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilFactory
|
||||
{
|
||||
const VERTRAGSBESTANDTEIL_STUNDEN = 'stunden';
|
||||
const VERTRAGSBESTANDTEIL_FUNKTION = 'funktion';
|
||||
const VERTRAGSBESTANDTEIL_GEHALT = 'gehalt';
|
||||
const VERTRAGSBESTANDTEIL_FREITEXT = 'freitext';
|
||||
const VERTRAGSBESTANDTEIL_KARENZ = 'karenz';
|
||||
const VERTRAGSBESTANDTEIL_BEFRISTUNG = 'befristung';
|
||||
const VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST = 'kuendigungsfrist';
|
||||
const VERTRAGSBESTANDTEIL_KV = 'kv';
|
||||
const VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH = 'urlaubsanspruch';
|
||||
const VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG = 'zeitaufzeichnung';
|
||||
const VERTRAGSBESTANDTEIL_LEHRE = 'lehre';
|
||||
|
||||
public static function getVertragsbestandteil($data, $fromdb=false)
|
||||
{
|
||||
$vertragsbestandteiltyp_kurzbz = isset($data->vertragsbestandteiltyp_kurzbz)
|
||||
? $data->vertragsbestandteiltyp_kurzbz : false;
|
||||
if( false === $vertragsbestandteiltyp_kurzbz )
|
||||
{
|
||||
throw new Exception('Missing Parameter vertragsbestandteiltyp_kurzbz');
|
||||
}
|
||||
|
||||
$vertragsbestandteil = null;
|
||||
switch ($vertragsbestandteiltyp_kurzbz)
|
||||
{
|
||||
case self::VERTRAGSBESTANDTEIL_FREITEXT:
|
||||
$vertragsbestandteil = new VertragsbestandteilFreitext();
|
||||
$vertragsbestandteil->hydrateByStdClass($data, $fromdb);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FUNKTION:
|
||||
$vertragsbestandteil = new VertragsbestandteilFunktion();
|
||||
$vertragsbestandteil->hydrateByStdClass($data, $fromdb);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KARENZ:
|
||||
$vertragsbestandteil = new VertragsbestandteilKarenz();
|
||||
$vertragsbestandteil->hydrateByStdClass($data, $fromdb);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST:
|
||||
$vertragsbestandteil = new VertragsbestandteilKuendigungsfrist();
|
||||
$vertragsbestandteil->hydrateByStdClass($data, $fromdb);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_STUNDEN:
|
||||
$vertragsbestandteil = new VertragsbestandteilStunden();
|
||||
$vertragsbestandteil->hydrateByStdClass($data, $fromdb);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH:
|
||||
$vertragsbestandteil = new VertragsbestandteilUrlaubsanspruch();
|
||||
$vertragsbestandteil->hydrateByStdClass($data, $fromdb);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG:
|
||||
$vertragsbestandteil = new VertragsbestandteilZeitaufzeichnung();
|
||||
$vertragsbestandteil->hydrateByStdClass($data, $fromdb);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown vertragsbestandteiltyp_kurzbz '
|
||||
. $vertragsbestandteiltyp_kurzbz);
|
||||
}
|
||||
|
||||
return $vertragsbestandteil;
|
||||
}
|
||||
|
||||
public static function getVertragsbestandteilDBModel($vertragsbestandteil_kurzbz): \DB_model
|
||||
{
|
||||
$CI = get_instance();
|
||||
|
||||
$vertragsbestandteildbmodel = null;
|
||||
switch ($vertragsbestandteil_kurzbz)
|
||||
{
|
||||
case self::VERTRAGSBESTANDTEIL_FREITEXT:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model',
|
||||
'VertragsbestandteilFreitext_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilFreitext_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FUNKTION:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model',
|
||||
'VertragsbestandteilFunktion_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilFunktion_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KARENZ:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilKarenz_model',
|
||||
'VertragsbestandteilKarenz_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilKarenz_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilKuendigungsfrist_model',
|
||||
'VertragsbestandteilKuendigungsfrist_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilKuendigungsfrist_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_STUNDEN:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilStunden_model',
|
||||
'VertragsbestandteilStunden_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilStunden_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilUrlaubsanspruch_model',
|
||||
'VertragsbestandteilUrlaubsanspruch_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilUrlaubsanspruch_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model',
|
||||
'VertragsbestandteilZeitaufzeichnung_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilZeitaufzeichnung_model;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown vertragsbestandteil_kurzbz '
|
||||
. $vertragsbestandteil_kurzbz);
|
||||
}
|
||||
|
||||
return $vertragsbestandteildbmodel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
class VertragsbestandteilFreitext extends Vertragsbestandteil
|
||||
{
|
||||
protected $freitexttyp_kurzbz;
|
||||
protected $titel;
|
||||
protected $anmerkung;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_FREITEXT);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
parent::hydrateByStdClass($data, $fromdb);
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->freitexttyp) && $this->setFreitexttypKurzbz($data->freitexttyp);
|
||||
isset($data->freitexttyp_kurzbz) && $this->setFreitexttypKurzbz($data->freitexttyp_kurzbz);
|
||||
isset($data->titel) && $this->setTitel($data->titel);
|
||||
isset($data->freitext) && $this->setAnmerkung($data->freitext);
|
||||
isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'freitexttyp_kurzbz' => $this->getFreitexttypKurzbz(),
|
||||
'titel' => $this->getTitel(),
|
||||
'anmerkung' => $this->getAnmerkung()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
anmerkung: {$this->getAnmerkung()}
|
||||
titel: {$this->getTitel()}
|
||||
freitexttyp_kurzbz: {$this->getFreitexttypKurzbz()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of anmerkung
|
||||
*/
|
||||
public function getAnmerkung()
|
||||
{
|
||||
return $this->anmerkung;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of anmerkung
|
||||
*/
|
||||
public function setAnmerkung($anmerkung): self
|
||||
{
|
||||
$this->markDirty('anmerkung', $this->anmerkung, $anmerkung);
|
||||
$this->anmerkung = $anmerkung;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of titel
|
||||
*/
|
||||
public function getTitel()
|
||||
{
|
||||
return $this->titel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of titel
|
||||
*/
|
||||
public function setTitel($titel): self
|
||||
{
|
||||
$this->markDirty('titel', $this->titel, $titel);
|
||||
$this->titel = $titel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of freitexttyp_kurzbz
|
||||
*/
|
||||
public function getFreitexttypKurzbz()
|
||||
{
|
||||
return $this->freitexttyp_kurzbz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of freitexttyp_kurzbz
|
||||
*/
|
||||
public function setFreitexttypKurzbz($freitexttyp_kurzbz): self
|
||||
{
|
||||
$this->markDirty('freitexttyp_kurzbz', $this->freitexttyp_kurzbz, $freitexttyp_kurzbz);
|
||||
$this->freitexttyp_kurzbz = $freitexttyp_kurzbz;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if( empty($this->freitexttyp_kurzbz) ) {
|
||||
$this->validationerrors[] = 'Bitte einen gültigen Freitexttyp auswählen.';
|
||||
}
|
||||
|
||||
if( empty($this->titel) ) {
|
||||
$this->validationerrors[] = 'Bitte einen Titel angeben.';
|
||||
}
|
||||
|
||||
if( empty($this->anmerkung) ) {
|
||||
$this->validationerrors[] = 'Bitte eine Beschreibung eingeben.';
|
||||
}
|
||||
|
||||
return parent::validate();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,369 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use Exception;
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilFunktion
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilFunktion extends Vertragsbestandteil
|
||||
{
|
||||
protected $benutzerfunktion_id;
|
||||
protected $benutzerfunktiondata;
|
||||
|
||||
protected $CI;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->benutzerfunktiondata = null;
|
||||
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_FUNKTION);
|
||||
|
||||
$this->CI = get_instance();
|
||||
$this->CI->load->model('person/Benutzerfunktion_model',
|
||||
'BenutzerfunktionModel');
|
||||
$this->CI->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model',
|
||||
'VertragsbestandteilFunktionModel');
|
||||
$this->CI->load->library('vertragsbestandteil/VertragsbestandteilLib',
|
||||
null, 'VertragsbestandteilLib');
|
||||
}
|
||||
|
||||
public function isDirty()
|
||||
{
|
||||
$isdirty = parent::isDirty();
|
||||
if( !$isdirty ) {
|
||||
$bf = $this->loadBenutzerfunktion($this->getBenutzerfunktion_id());
|
||||
if( !$this->areVbAndBfInSync($bf) )
|
||||
{
|
||||
$isdirty = true;
|
||||
}
|
||||
}
|
||||
return $isdirty;
|
||||
}
|
||||
|
||||
public function beforePersist()
|
||||
{
|
||||
if( isset($this->benutzerfunktion_id) && intval($this->benutzerfunktion_id) > 0 )
|
||||
{
|
||||
$this->beforePersitExisting();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->beforePersitNew();
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadBenutzerfunktion($bfid)
|
||||
{
|
||||
$bfres = $this->CI->BenutzerfunktionModel->load($bfid);
|
||||
if(!hasData($bfres))
|
||||
{
|
||||
throw new Exception('failed to load existing Benutzerfunktion');
|
||||
}
|
||||
return (getData($bfres))[0];
|
||||
}
|
||||
|
||||
protected function loadPersitedVB($vbid)
|
||||
{
|
||||
$vb = $this->CI->VertragsbestandteilLib->fetchVertragsbestandteil($vbid);
|
||||
if( $vb === null )
|
||||
{
|
||||
throw new Exception('failed to load persited Vertragsbestandteil');
|
||||
}
|
||||
return $vb;
|
||||
}
|
||||
|
||||
protected function areVbAndBfInSync($bf)
|
||||
{
|
||||
$vbvon = $this->getVon();
|
||||
$vbbis = $this->getBis();
|
||||
if( intval($this->getVertragsbestandteil_id()) > 0 )
|
||||
{
|
||||
$vb = $this->loadPersitedVB($this->getVertragsbestandteil_id());
|
||||
$vbvon = $vb->getVon();
|
||||
$vbbis = $vb->getBis();
|
||||
}
|
||||
|
||||
if( ($bf->datum_von === $vbvon) && ($bf->datum_bis === $vbbis) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function isBefore($a, $b)
|
||||
{
|
||||
if($a === null) {
|
||||
return false;
|
||||
}
|
||||
elseif($b === null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return $a < $b;
|
||||
}
|
||||
}
|
||||
|
||||
protected function isAfter($a, $b)
|
||||
{
|
||||
if($b === null) {
|
||||
return false;
|
||||
}
|
||||
elseif($a === null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return $a > $b;
|
||||
}
|
||||
}
|
||||
|
||||
protected function beforePersitExisting()
|
||||
{
|
||||
$bf = $this->loadBenutzerfunktion($this->getBenutzerfunktion_id());
|
||||
if( $this->areVbAndBfInSync($bf) )
|
||||
{
|
||||
// vb or stored vb von bis is in sync so update benutzerfunktion
|
||||
$this->updateBenutzerfunktion($bf, $this->getVon(), $this->getBis());
|
||||
}
|
||||
else
|
||||
{
|
||||
$daybeforevon = \DateTime::createFromFormat('Y-m-d', $this->getVon(),
|
||||
new \DateTimeZone('Europe/Vienna'));
|
||||
$daybeforevon->sub(new \DateInterval('P1D'));
|
||||
|
||||
if( $this->isBefore($bf->datum_von, $this->getVon()) &&
|
||||
$this->isBefore($bf->datum_von, $this->getBis()) )
|
||||
{
|
||||
$data = (object) array(
|
||||
'mitarbeiter_uid' => $bf->uid,
|
||||
'funktion' => $bf->funktion_kurzbz,
|
||||
'orget' => $bf->oe_kurzbz
|
||||
);
|
||||
$this->createBenutzerfunktionData($data);
|
||||
$bfid = $this->insertBenutzerfunktion($this->getBenutzerfunktionData4Insert());
|
||||
$this->setBenutzerfunktion_id($bfid);
|
||||
}
|
||||
elseif( $this->isBefore($bf->datum_von, $this->getVon()) &&
|
||||
$this->isAfter($this->getBis(), $bf->datum_von) )
|
||||
{
|
||||
$this->updateBenutzerfunktion($bf, $bf->datum_von, $daybeforevon->format('Y-m-d'));
|
||||
$data = (object) array(
|
||||
'mitarbeiter_uid' => $bf->uid,
|
||||
'funktion' => $bf->funktion_kurzbz,
|
||||
'orget' => $bf->oe_kurzbz
|
||||
);
|
||||
$this->createBenutzerfunktionData($data);
|
||||
$bfid = $this->insertBenutzerfunktion($this->getBenutzerfunktionData4Insert());
|
||||
$this->setBenutzerfunktion_id($bfid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->updateBenutzerfunktion($bf, $this->getVon(), $this->getBis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function updateBenutzerfunktion($bf, $von, $bis)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
if($von !== $bf->datum_von)
|
||||
{
|
||||
$data['datum_von'] = $von;
|
||||
}
|
||||
if($bis !== $bf->datum_bis)
|
||||
{
|
||||
$data['datum_bis'] = $bis;
|
||||
}
|
||||
|
||||
if( count($data) === 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$data['updateamum'] = strftime('%Y-%m-%d %H:%M:%S');
|
||||
$data['updatevon'] = getAuthUID();
|
||||
|
||||
$ret = $this->CI->BenutzerfunktionModel->update($bf->benutzerfunktion_id, $data);
|
||||
|
||||
if(isError($ret) )
|
||||
{
|
||||
throw new Exception('failed to update Benutzerfunktion');
|
||||
}
|
||||
}
|
||||
|
||||
protected function insertBenutzerfunktion($benutzerfunktiondata)
|
||||
{
|
||||
$ret = $this->CI->BenutzerfunktionModel->insert($benutzerfunktiondata);
|
||||
|
||||
if(isError($ret) )
|
||||
{
|
||||
throw new Exception('failed to create Benutzerfunktion');
|
||||
}
|
||||
|
||||
return getData($ret);
|
||||
}
|
||||
|
||||
protected function deleteBenutzerfunktion($benutzerfunktion_id)
|
||||
{
|
||||
$ret = $this->CI->BenutzerfunktionModel->delete($benutzerfunktion_id);
|
||||
|
||||
if(isError($ret) )
|
||||
{
|
||||
throw new Exception('failed to delete Benutzerfunktion');
|
||||
}
|
||||
}
|
||||
|
||||
protected function beforePersitNew() {
|
||||
if( $this->benutzerfunktiondata === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$bfid = $this->insertBenutzerfunktion($this->getBenutzerfunktionData4Insert());
|
||||
|
||||
$this->setBenutzerfunktion_id($bfid);
|
||||
}
|
||||
|
||||
public function afterDelete()
|
||||
{
|
||||
if( !(intval($this->getBenutzerfunktion_id()) > 0) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->deleteBenutzerfunktion($this->getBenutzerfunktion_id());
|
||||
}
|
||||
|
||||
public function toStdClass()
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'benutzerfunktion_id' => $this->getBenutzerfunktion_id()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
benutzerfunktion_id: {$this->getBenutzerfunktion_id()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
parent::hydrateByStdClass($data, $fromdb);
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->benutzerfunktionid) && $this->setBenutzerfunktion_id($data->benutzerfunktionid);
|
||||
isset($data->benutzerfunktion_id) && $this->setBenutzerfunktion_id($data->benutzerfunktion_id);
|
||||
isset($data->funktion) && isset($data->orget)
|
||||
&& isset($data->mitarbeiter_uid) && $this->createBenutzerfunktionData($data);
|
||||
isset($data->funktion_bezeichnung) && isset($data->oe_bezeichnung)
|
||||
&& $this->createBenutzerfunktionData4Display($data);
|
||||
$this->fromdb = false;
|
||||
|
||||
}
|
||||
|
||||
public function getBenutzerfunktion_id()
|
||||
{
|
||||
return $this->benutzerfunktion_id;
|
||||
}
|
||||
|
||||
public function setBenutzerfunktion_id($benutzerfunktion_id)
|
||||
{
|
||||
$this->markDirty('benutzerfunktion_id', $this->benutzerfunktion_id, $benutzerfunktion_id);
|
||||
$this->benutzerfunktion_id = $benutzerfunktion_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getBenutzerfunktionData4Insert()
|
||||
{
|
||||
if( null === $this->benutzerfunktiondata ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$benutzerfunktiondata = (object) array(
|
||||
'funktion_kurzbz' => $this->benutzerfunktiondata->funktion_kurzbz,
|
||||
'oe_kurzbz' => $this->benutzerfunktiondata->oe_kurzbz,
|
||||
'uid' => $this->benutzerfunktiondata->uid,
|
||||
'datum_von' => $this->getVon(),
|
||||
'datum_bis' => $this->getBis(),
|
||||
'insertamum' => strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'insertvon' => getAuthUID()
|
||||
);
|
||||
|
||||
return $benutzerfunktiondata;
|
||||
}
|
||||
|
||||
protected function createBenutzerfunktionData($data)
|
||||
{
|
||||
if( empty($data->funktion) || empty($data->orget) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->benutzerfunktiondata = (object) array(
|
||||
'funktion_kurzbz' => $data->funktion,
|
||||
'oe_kurzbz' => $data->orget,
|
||||
'uid' => $data->mitarbeiter_uid
|
||||
);
|
||||
}
|
||||
|
||||
protected function createBenutzerfunktionData4Display($data)
|
||||
{
|
||||
if( empty($data->funktion_bezeichnung) || empty($data->oe_bezeichnung) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->benutzerfunktiondata = (object) array(
|
||||
'funktion_kurzbz' => $data->funktion_kurzbz,
|
||||
'funktion_bezeichnung' => $data->funktion_bezeichnung,
|
||||
'oe_kurzbz' => $data->oe_kurzbz,
|
||||
'oe_bezeichnung' => $data->oe_bezeichnung,
|
||||
'oe_kurzbz_sap' => $data->oe_kurzbz_sap,
|
||||
'oe_typ_kurzbz' => $data->oe_typ_kurzbz,
|
||||
'oe_typ_bezeichnung' => $data->oe_typ_bezeichnung,
|
||||
'uid' => $data->mitarbeiter_uid
|
||||
);
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if( (intval($this->benutzerfunktion_id) < 1)
|
||||
&& ($this->benutzerfunktiondata === NULL) ) {
|
||||
$this->validationerrors[] = 'Eine bestehende Funktion oder eine '
|
||||
. 'Funktion und eine Organisationseinheit müssen ausgewählt sein.';
|
||||
}
|
||||
|
||||
// TODO check if Benutzerfunktion is assigned to another vb
|
||||
if( intval($this->benutzerfunktion_id) > 0 )
|
||||
{
|
||||
if ( $this->CI->VertragsbestandteilFunktionModel
|
||||
->isBenutzerfunktionAlreadyAttachedToAnotherVB(
|
||||
$this->benutzerfunktion_id,
|
||||
$this->getVertragsbestandteil_id()) )
|
||||
{
|
||||
$this->validationerrors[] = 'Die Benutzerfunktion ist bereits '
|
||||
. 'mit einem anderen Vertragsbestandteil verknüpft und kann '
|
||||
. 'nicht mehrfach verknüft werden.';
|
||||
}
|
||||
}
|
||||
|
||||
return parent::validate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
class VertragsbestandteilKarenz extends Vertragsbestandteil
|
||||
{
|
||||
protected $karenztyp_kurzbz;
|
||||
protected $tatsaechlicher_geburtstermin;
|
||||
protected $geplanter_geburtstermin;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_KARENZ);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
parent::hydrateByStdClass($data, $fromdb);
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->karenztyp_kurzbz) && $this->setKarenztypKurzbz($data->karenztyp_kurzbz);
|
||||
isset($data->geplanter_geburtstermin) && $this->setGeplanterGeburtstermin($data->geplanter_geburtstermin);
|
||||
isset($data->tatsaechlicher_geburtstermin) && $this->setTatsaechlicherGeburtstermin($data->tatsaechlicher_geburtstermin);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of karenztyp_kurzbz
|
||||
*/
|
||||
public function getKarenztypKurzbz()
|
||||
{
|
||||
return $this->karenztyp_kurzbz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of karenztyp_kurzbz
|
||||
*/
|
||||
public function setKarenztypKurzbz($karenztyp_kurzbz): self
|
||||
{
|
||||
$this->markDirty('karenztyp_kurzbz', $this->karenztyp_kurzbz, $karenztyp_kurzbz);
|
||||
$this->karenztyp_kurzbz = $karenztyp_kurzbz;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of tatsaechlicher_geburtstermin
|
||||
*/
|
||||
public function getTatsaechlicherGeburtstermin()
|
||||
{
|
||||
return $this->tatsaechlicher_geburtstermin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of tatsaechlicher_geburtstermin
|
||||
*/
|
||||
public function setTatsaechlicherGeburtstermin($tatsaechlicher_geburtstermin): self
|
||||
{
|
||||
$this->markDirty('tatsaechlicher_geburtstermin', $this->tatsaechlicher_geburtstermin, $tatsaechlicher_geburtstermin);
|
||||
$this->tatsaechlicher_geburtstermin = $tatsaechlicher_geburtstermin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of geplanter_geburtstermin
|
||||
*/
|
||||
public function getGeplanterGeburtstermin()
|
||||
{
|
||||
return $this->geplanter_geburtstermin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of geplanter_geburtstermin
|
||||
*/
|
||||
public function setGeplanterGeburtstermin($geplanter_geburtstermin): self
|
||||
{
|
||||
$this->markDirty('geplanter_geburtstermin', $this->geplanter_geburtstermin, $geplanter_geburtstermin);
|
||||
$this->geplanter_geburtstermin = $geplanter_geburtstermin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'karenztyp_kurzbz' => $this->getKarenztypKurzbz(),
|
||||
'tatsaechlicher_geburtstermin' => $this->getTatsaechlicherGeburtstermin(),
|
||||
'geplanter_geburtstermin' => $this->getGeplanterGeburtstermin()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
karenztyp_kurzbz: {$this->getKarenztypKurzbz()}
|
||||
tatsaechlicher_geburtstermin: {$this->getTatsaechlicherGeburtstermin()}
|
||||
geplanter_geburtstermin: {$this->getGeplanterGeburtstermin()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if( empty($this->karenztyp_kurzbz) ) {
|
||||
$this->validationerrors[] = 'Ein Karenztyp muss ausgewählt sein.';
|
||||
}
|
||||
|
||||
if( $this->karenztyp_kurzbz === 'elternkarenz' ) {
|
||||
$geplant = \DateTimeImmutable::createFromFormat('Y-m-d', $this->geplanter_geburtstermin);
|
||||
$tatsaechlich = \DateTimeImmutable::createFromFormat('Y-m-d', $this->tatsaechlicher_geburtstermin);
|
||||
|
||||
if( false === $geplant ) {
|
||||
$this->validationerrors[] = 'Bei Elternkarenz muss der geplanter Geburtstermin ein gültiges Datum sein.';
|
||||
}
|
||||
|
||||
if( !empty($this->tatsaechlicher_geburtstermin) && $tatsaechlich === false ) {
|
||||
$this->validationerrors[] = 'Bei Elternkarenz muss der tatsaechliche Geburtstermin leer oder ein gültiges Datum sein.';
|
||||
}
|
||||
}
|
||||
|
||||
$bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis);
|
||||
|
||||
if( false === $bis ) {
|
||||
$this->validationerrors[] = 'Bei einer Karenz muss ein gültiges Ende-Datum angegeben werden.';
|
||||
}
|
||||
|
||||
return parent::validate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
class VertragsbestandteilKuendigungsfrist extends Vertragsbestandteil
|
||||
{
|
||||
protected $arbeitgeber_frist;
|
||||
protected $arbeitnehmer_frist;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
parent::hydrateByStdClass($data, $fromdb);
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->arbeitgeber_frist) && $this->setArbeitgeberFrist($data->arbeitgeber_frist);
|
||||
isset($data->arbeitnehmer_frist) && $this->setArbeitnehmerFrist($data->arbeitnehmer_frist);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of arbeitgeber_frist
|
||||
*/
|
||||
public function getArbeitgeberFrist()
|
||||
{
|
||||
return $this->arbeitgeber_frist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of arbeitgeber_frist
|
||||
*/
|
||||
public function setArbeitgeberFrist($arbeitgeber_frist): self
|
||||
{
|
||||
$this->markDirty('arbeitgeber_frist', $this->arbeitgeber_frist, $arbeitgeber_frist);
|
||||
$this->arbeitgeber_frist = $arbeitgeber_frist;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of arbeitnehmer_frist
|
||||
*/
|
||||
public function getArbeitnehmerFrist()
|
||||
{
|
||||
return $this->arbeitnehmer_frist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of arbeitnehmer_frist
|
||||
*/
|
||||
public function setArbeitnehmerFrist($arbeitnehmer_frist): self
|
||||
{
|
||||
$this->markDirty('arbeitnehmer_frist', $this->arbeitnehmer_frist, $arbeitnehmer_frist);
|
||||
$this->arbeitnehmer_frist = $arbeitnehmer_frist;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'arbeitgeber_frist' => $this->getArbeitgeberFrist(),
|
||||
'arbeitnehmer_frist' => $this->getArbeitnehmerFrist()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
arbeitgeber_frist: {$this->getArbeitgeberFrist()}
|
||||
arbeitnehmer_frist: {$this->getArbeitnehmerFrist()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if( !(filter_var($this->arbeitgeber_frist, FILTER_VALIDATE_INT,
|
||||
array(
|
||||
'options' => array(
|
||||
'min_range' => 0,
|
||||
'max_range' => 52
|
||||
)
|
||||
)
|
||||
)) ) {
|
||||
$this->validationerrors[] = 'Arbeitgeberfrist muss eine Wochenanzahl im Bereich 1 bis 52 sein.';
|
||||
}
|
||||
|
||||
if( !(filter_var($this->arbeitnehmer_frist, FILTER_VALIDATE_INT,
|
||||
array(
|
||||
'options' => array(
|
||||
'min_range' => 1,
|
||||
'max_range' => 52
|
||||
)
|
||||
)
|
||||
)) ) {
|
||||
$this->validationerrors[] = 'Arbeitnehmerfrist muss eine Wochenanzahl im Bereich 1 bis 52 sein.';
|
||||
}
|
||||
|
||||
return parent::validate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,504 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/IValidation.php';
|
||||
require_once __DIR__ . '/AbstractBestandteil.php';
|
||||
require_once __DIR__ . '/Dienstverhaeltnis.php';
|
||||
require_once __DIR__ . '/Vertragsbestandteil.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilStunden.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilFunktion.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilZeitaufzeichnung.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilKuendigungsfrist.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilUrlaubsanspruch.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilFreitext.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilKarenz.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilFactory.php';
|
||||
require_once __DIR__ . '/OverlapChecker.php';
|
||||
|
||||
use vertragsbestandteil\Dienstverhaeltnis;
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilLib
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilLib
|
||||
{
|
||||
const INCLUDE_FUTURE = true;
|
||||
const DO_NOT_INCLUDE_FUTURE = false;
|
||||
|
||||
protected $CI;
|
||||
/** @var Dienstverhaeltnis_model */
|
||||
protected $DienstverhaeltnisModel;
|
||||
/** @var Vertragsbestandteil_model */
|
||||
protected $VertragsbestandteilModel;
|
||||
/** @var Benutzer_model */
|
||||
protected $BenutzerModel;
|
||||
/**
|
||||
* @var GehaltsbestandteilLib
|
||||
*/
|
||||
protected $GehaltsbestandteilLib;
|
||||
|
||||
protected $loggedInUser;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->loggedInUser = getAuthUID();
|
||||
$this->CI = get_instance();
|
||||
$this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model',
|
||||
'DienstverhaeltnisModel');
|
||||
$this->DienstverhaeltnisModel = $this->CI->DienstverhaeltnisModel;
|
||||
$this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model',
|
||||
'VertragsbestandteilModel');
|
||||
$this->VertragsbestandteilModel = $this->CI->VertragsbestandteilModel;
|
||||
$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;
|
||||
}
|
||||
|
||||
public function handleGUIData($guidata, $employeeUID, $userUID)
|
||||
{
|
||||
$guiHandler = new GUIHandler($employeeUID, $userUID);
|
||||
$ret = false;
|
||||
try {
|
||||
$ret = $guiHandler->handle($guidata, $employeeUID, $userUID);
|
||||
} catch (Exception $ex)
|
||||
{
|
||||
log_message('debug', "Error handling json data from GUI. " . $ex->getMessage());
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function fetchDienstverhaeltnisse($unternehmen, $stichtag=null, $mitarbeiteruid=null) {
|
||||
$dvs = $this->DienstverhaeltnisModel->fetchDienstverhaeltnisse($unternehmen, $stichtag, $mitarbeiteruid);
|
||||
return $dvs;
|
||||
}
|
||||
|
||||
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 fetchVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null, $includefuture=false)
|
||||
{
|
||||
$vbs = $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture);
|
||||
$gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture);
|
||||
|
||||
$gbsByVBid = array();
|
||||
foreach( $gbs as $gb )
|
||||
{
|
||||
if( intval($gb->getVertragsbestandteil_id()) > 0 )
|
||||
{
|
||||
if( !isset($gbsByVBid[$gb->getVertragsbestandteil_id()])
|
||||
|| !is_array($gbsByVBid[$gb->getVertragsbestandteil_id()]) ) {
|
||||
$gbsByVBid[$gb->getVertragsbestandteil_id()] = array();
|
||||
}
|
||||
$gbsByVBid[$gb->getVertragsbestandteil_id()][] = $gb;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($vbs as $vb)
|
||||
{
|
||||
if( isset($gbsByVBid[$vb->getVertragsbestandteil_id()]) )
|
||||
{
|
||||
$vb->setGehaltsbestandteile($gbsByVBid[$vb->getVertragsbestandteil_id()]);
|
||||
}
|
||||
}
|
||||
|
||||
return $vbs;
|
||||
}
|
||||
|
||||
public function fetchVertragsbestandteil($vertragsbestandteil_id)
|
||||
{
|
||||
return $this->VertragsbestandteilModel->getVertragsbestandteil($vertragsbestandteil_id);
|
||||
}
|
||||
|
||||
public function storeDienstverhaeltnis(Dienstverhaeltnis $dv)
|
||||
{
|
||||
if( intval($dv->getDienstverhaeltnis_id()) > 0 )
|
||||
{
|
||||
$this->updateDienstverhaeltnis($dv);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->insertDienstverhaeltnis($dv);
|
||||
}
|
||||
}
|
||||
|
||||
public function storeVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil)
|
||||
{
|
||||
$this->CI->db->trans_begin();
|
||||
try
|
||||
{
|
||||
$this->setUIDtoPGSQL();
|
||||
if( intval($vertragsbestandteil->getVertragsbestandteil_id()) > 0 )
|
||||
{
|
||||
$this->updateVertragsbestandteil($vertragsbestandteil);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->insertVertragsbestandteil($vertragsbestandteil);
|
||||
}
|
||||
if( $this->CI->db->trans_status() === false )
|
||||
{
|
||||
log_message('debug', "Transaction failed");
|
||||
throw new Exception("Transaction failed");
|
||||
}
|
||||
$this->CI->db->trans_commit();
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
log_message('debug', "Transaction rolled back. " . $ex->getMessage());
|
||||
$this->CI->db->trans_rollback();
|
||||
throw new Exception('Storing Vertragsbestandteil failed.');
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteDienstverhaeltnis(Dienstverhaeltnis $dv)
|
||||
{
|
||||
$this->CI->db->trans_begin();
|
||||
try
|
||||
{
|
||||
$this->setUIDtoPGSQL();
|
||||
if( intval($dv->getDienstverhaeltnis_id()) > 0 )
|
||||
{
|
||||
$vbs = $this->fetchVertragsbestandteile($dv->getDienstverhaeltnis_id());
|
||||
foreach ($vbs as $vb)
|
||||
{
|
||||
$this->deleteVertragsbestandteil($vb);
|
||||
}
|
||||
|
||||
$ret = $this->DienstverhaeltnisModel->delete($dv->getDienstverhaeltnis_id());
|
||||
if(isError($ret) )
|
||||
{
|
||||
log_message('debug', "Delete DV failed");
|
||||
throw new Exception('error deleting dienstverhaeltnis '
|
||||
. $dv->getDienstverhaeltnis_id());
|
||||
}
|
||||
|
||||
if( $this->CI->db->trans_status() === false )
|
||||
{
|
||||
log_message('debug', "Transaction failed");
|
||||
throw new Exception("Transaction failed");
|
||||
}
|
||||
$this->CI->db->trans_commit();
|
||||
}
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
log_message('debug', "Transaction rolled back. " . $ex->getMessage());
|
||||
$this->CI->db->trans_rollback();
|
||||
return $ex->getMessage();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public function deleteVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil)
|
||||
{
|
||||
$this->CI->db->trans_begin();
|
||||
try
|
||||
{
|
||||
$this->setUIDtoPGSQL();
|
||||
if( intval($vertragsbestandteil->getVertragsbestandteil_id()) > 0 )
|
||||
{
|
||||
$this->deleteVertragsbestandteilHelper($vertragsbestandteil);
|
||||
}
|
||||
if( $this->CI->db->trans_status() === false )
|
||||
{
|
||||
log_message('debug', "Transaction failed");
|
||||
throw new Exception("Transaction failed");
|
||||
}
|
||||
$this->CI->db->trans_commit();
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
log_message('debug', "Transaction rolled back. " . $ex->getMessage());
|
||||
$this->CI->db->trans_rollback();
|
||||
throw new Exception('Delete Vertragsbestandteil failed.');
|
||||
}
|
||||
}
|
||||
|
||||
protected function insertDienstverhaeltnis(Dienstverhaeltnis $dv)
|
||||
{
|
||||
$dv->setInsertvon($this->loggedInUser)
|
||||
->setInsertamum(strftime('%Y-%m-%d %H:%M:%S'));
|
||||
$ret = $this->DienstverhaeltnisModel->insert($dv->toStdClass());
|
||||
if( hasData($ret) )
|
||||
{
|
||||
$dv->setDienstverhaeltnis_id(getData($ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception('error inserting dienstverhaeltnis');
|
||||
}
|
||||
}
|
||||
|
||||
protected function insertVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil)
|
||||
{
|
||||
$vertragsbestandteil->setInsertvon($this->loggedInUser)
|
||||
->setInsertamum(strftime('%Y-%m-%d %H:%M:%S'));
|
||||
$vertragsbestandteil->beforePersist();
|
||||
$ret = $this->VertragsbestandteilModel->insert($vertragsbestandteil->baseToStdClass());
|
||||
if( hasData($ret) )
|
||||
{
|
||||
$vertragsbestandteil->setVertragsbestandteil_id(getData($ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception('error inserting vertragsbestandteil');
|
||||
}
|
||||
|
||||
$specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel(
|
||||
$vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
|
||||
$retspecial = $specialisedModel->insert($vertragsbestandteil->toStdClass());
|
||||
|
||||
if(isError($retspecial) )
|
||||
{
|
||||
throw new Exception('error updating vertragsbestandteil '
|
||||
. $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile();
|
||||
$this->GehaltsbestandteilLib->storeGehaltsbestandteile($gehaltsbestandteile);
|
||||
}
|
||||
catch(Exception $ex)
|
||||
{
|
||||
throw new Exception('VertragsbestandteilLib insertVertragsbestandteil '
|
||||
. 'failed to store Gehaltsbestandteile. ' . $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function updateDienstverhaeltnis(Dienstverhaeltnis $dv)
|
||||
{
|
||||
if(!$dv->isDirty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dv->setUpdatevon($this->loggedInUser)
|
||||
->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S'));
|
||||
$ret = $this->DienstverhaeltnisModel->update($dv->getDienstverhaeltnis_id(),
|
||||
$dv->toStdClass());
|
||||
if(isError($ret) )
|
||||
{
|
||||
throw new Exception('error updating dienstverhaeltnis');
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteVertragsbestandteilHelper(Vertragsbestandteil $vertragsbestandteil)
|
||||
{
|
||||
|
||||
$specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel(
|
||||
$vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
|
||||
$retspecial = $specialisedModel->delete($vertragsbestandteil->getVertragsbestandteil_id());
|
||||
|
||||
if(isError($retspecial) )
|
||||
{
|
||||
throw new Exception('error deleting vertragsbestandteil '
|
||||
. $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile();
|
||||
$this->GehaltsbestandteilLib->deleteGehaltsbestandteile($gehaltsbestandteile);
|
||||
}
|
||||
catch(Exception $ex)
|
||||
{
|
||||
throw new Exception('VertragsbestandteilLib deleteVertragsbestandteil '
|
||||
. 'failed to delete Gehaltsbestandteile. ' . $ex->getMessage());
|
||||
}
|
||||
|
||||
|
||||
$ret = $this->VertragsbestandteilModel->delete($vertragsbestandteil->getVertragsbestandteil_id());
|
||||
|
||||
if(isError($ret) )
|
||||
{
|
||||
throw new Exception('error deleting vertragsbestandteil');
|
||||
}
|
||||
|
||||
$vertragsbestandteil->afterDelete();
|
||||
}
|
||||
|
||||
protected function updateVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil)
|
||||
{
|
||||
if($vertragsbestandteil->isDirty()) {
|
||||
$vertragsbestandteil->setUpdatevon($this->loggedInUser)
|
||||
->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S'));
|
||||
$vertragsbestandteil->beforePersist();
|
||||
$basedata = $vertragsbestandteil->baseToStdClass();
|
||||
if( count((array) $basedata) > 0 )
|
||||
{
|
||||
$ret = $this->VertragsbestandteilModel->update(
|
||||
$vertragsbestandteil->getVertragsbestandteil_id(),
|
||||
$basedata);
|
||||
|
||||
if(isError($ret) )
|
||||
{
|
||||
throw new Exception('error updating vertragsbestandteil');
|
||||
}
|
||||
}
|
||||
|
||||
$specialisedData = $vertragsbestandteil->toStdClass();
|
||||
if( count((array) $specialisedData) > 0 )
|
||||
{
|
||||
$specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel(
|
||||
$vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
|
||||
$retspecial = $specialisedModel->update(
|
||||
$vertragsbestandteil->getVertragsbestandteil_id(),
|
||||
$specialisedData);
|
||||
|
||||
if(isError($retspecial) )
|
||||
{
|
||||
throw new Exception('error updating vertragsbestandteil '
|
||||
. $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile();
|
||||
$this->GehaltsbestandteilLib->storeGehaltsbestandteile($gehaltsbestandteile);
|
||||
}
|
||||
catch(Exception $ex)
|
||||
{
|
||||
throw new Exception('VertragsbestandteilLib updateVertragsbestandteil '
|
||||
. 'failed to store Gehaltsbestandteile. ' . $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function isOverlappingExistingDV(Dienstverhaeltnis $dv)
|
||||
{
|
||||
return $this->DienstverhaeltnisModel->isOverlappingExistingDV(
|
||||
$dv->getMitarbeiter_uid(),
|
||||
$dv->getOe_kurzbz(),
|
||||
$dv->getVon(),
|
||||
$dv->getBis(),
|
||||
$dv->getDienstverhaeltnis_id()
|
||||
);
|
||||
}
|
||||
|
||||
protected function hasOtherActiveDV(Dienstverhaeltnis $dv, $duedate)
|
||||
{
|
||||
$hasotheractivedv = false;
|
||||
$result = $this->DienstverhaeltnisModel->getDVByPersonUID($dv->getMitarbeiter_uid(), null, $duedate);
|
||||
$dvs = getData($result);
|
||||
foreach ($dvs as $tmpdv)
|
||||
{
|
||||
if(intval($tmpdv->dienstverhaeltnis_id) !== intval($dv->getDienstverhaeltnis_id()))
|
||||
{
|
||||
$hasotheractivedv = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $hasotheractivedv;
|
||||
}
|
||||
|
||||
/**
|
||||
* like endDienstverhaeltnis, but also sets aktiv flag to false
|
||||
*/
|
||||
public function deactivateDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate, $deactivate)
|
||||
{
|
||||
$result = $this->endDienstverhaeltnis($dv, $enddate);
|
||||
if ( $result === true)
|
||||
{
|
||||
if (!$deactivate) return $result;
|
||||
|
||||
if(!$this->hasOtherActiveDV($dv, $enddate))
|
||||
{
|
||||
$result = $this->BenutzerModel->update(
|
||||
array('uid' => $dv->getMitarbeiter_uid()),
|
||||
array(
|
||||
'aktiv' => false,
|
||||
'updateaktivam' => date('Y-m-d'),
|
||||
'updateaktivvon' => $this->loggedInUser
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate)
|
||||
{
|
||||
if( $dv->getBis() !== null && $dv->getBis() < $enddate )
|
||||
{
|
||||
return 'Dienstverhältnis ist bereits beendet.';
|
||||
}
|
||||
|
||||
$this->CI->db->trans_begin();
|
||||
try
|
||||
{
|
||||
$this->setUIDtoPGSQL();
|
||||
if( intval($dv->getDienstverhaeltnis_id()) > 0 )
|
||||
{
|
||||
$gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile($dv->getDienstverhaeltnis_id());
|
||||
foreach ($gbs as $gb)
|
||||
{
|
||||
$this->GehaltsbestandteilLib->endGehaltsbestandteil($gb, $enddate);
|
||||
}
|
||||
|
||||
$vbs = $this->fetchVertragsbestandteile($dv->getDienstverhaeltnis_id());
|
||||
foreach ($vbs as $vb)
|
||||
{
|
||||
$this->endVertragsbestandteil($vb, $enddate);
|
||||
}
|
||||
|
||||
$dv->setBis($enddate);
|
||||
$this->updateDienstverhaeltnis($dv);
|
||||
|
||||
if( $this->CI->db->trans_status() === false )
|
||||
{
|
||||
log_message('debug', "Transaction failed");
|
||||
throw new Exception("Transaction failed");
|
||||
}
|
||||
$this->CI->db->trans_commit();
|
||||
}
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
log_message('debug', "end DV failed " . $dv->getDienstverhaeltnis_id());
|
||||
log_message('debug', "Transaction rolled back. " . $ex->getMessage());
|
||||
$this->CI->db->trans_rollback();
|
||||
return $ex->getMessage();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function endVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil, $enddate)
|
||||
{
|
||||
if( $vertragsbestandteil->getBis() !== null && $vertragsbestandteil->getBis() < $enddate )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$vertragsbestandteil->setBis($enddate);
|
||||
$this->updateVertragsbestandteil($vertragsbestandteil);
|
||||
}
|
||||
|
||||
protected function setUIDtoPGSQL() {
|
||||
$ret = $this->VertragsbestandteilModel
|
||||
->execReadOnlyQuery('SET LOCAL pv21.uid TO \''
|
||||
. $this->loggedInUser . '\'');
|
||||
if(isError($ret))
|
||||
{
|
||||
throw new Exception('error setting uid to pgsql');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilStunden
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilStunden extends Vertragsbestandteil
|
||||
{
|
||||
protected $wochenstunden;
|
||||
protected $teilzeittyp_kurzbz;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_STUNDEN);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
parent::hydrateByStdClass($data, $fromdb);
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->wochenstunden) && $this->setWochenstunden($data->wochenstunden);
|
||||
isset($data->teilzeittyp_kurzbz) && $this->setTeilzeittyp_kurzbz($data->teilzeittyp_kurzbz);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
public function getWochenstunden()
|
||||
{
|
||||
return $this->wochenstunden;
|
||||
}
|
||||
|
||||
public function getTeilzeittyp_kurzbz()
|
||||
{
|
||||
return $this->teilzeittyp_kurzbz;
|
||||
}
|
||||
|
||||
public function setWochenstunden($wochenstunden)
|
||||
{
|
||||
$this->markDirty('wochenstunden', $this->wochenstunden, $wochenstunden);
|
||||
$this->wochenstunden = $wochenstunden;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTeilzeittyp_kurzbz($teilzeittyp_kurzbz)
|
||||
{
|
||||
$teilzeittyp_kurzbz = ($teilzeittyp_kurzbz !== '')
|
||||
? $teilzeittyp_kurzbz : null;
|
||||
$this->markDirty('teilzeittyp_kurzbz', $this->teilzeittyp_kurzbz, $teilzeittyp_kurzbz);
|
||||
$this->teilzeittyp_kurzbz = $teilzeittyp_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'wochenstunden' => $this->getWochenstunden(),
|
||||
'teilzeittyp_kurzbz' => $this->getTeilzeittyp_kurzbz()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
wochenstunden: {$this->getWochenstunden()}
|
||||
teilzeittyp_kurzbz: {$this->getTeilzeittyp_kurzbz()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if( false === filter_var($this->wochenstunden, FILTER_VALIDATE_FLOAT,
|
||||
array(
|
||||
'options' => array(
|
||||
'min_range' => 0,
|
||||
'max_range' => 100
|
||||
)
|
||||
)
|
||||
) ) {
|
||||
$this->validationerrors[] = 'Stunden muss eine Kommazahl im Bereich 0 bis 100 sein.';
|
||||
}
|
||||
else
|
||||
{
|
||||
if( floatval($this->wochenstunden) < floatval('0.01') &&
|
||||
$this->teilzeittyp_kurzbz !== 'altersteilzeit' )
|
||||
{
|
||||
$this->validationerrors[] = '0 Wochenstunden ist nur in Kombination mit Altersteilzeit zulässig.';
|
||||
}
|
||||
}
|
||||
|
||||
return parent::validate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
class VertragsbestandteilUrlaubsanspruch extends Vertragsbestandteil
|
||||
{
|
||||
protected $tage;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
parent::hydrateByStdClass($data, $fromdb);
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->tage) && $this->setTage($data->tage);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of tage
|
||||
*/
|
||||
public function getTage()
|
||||
{
|
||||
return $this->tage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of tage
|
||||
*/
|
||||
public function setTage($tage): self
|
||||
{
|
||||
$this->markDirty('tage', $this->tage, $tage);
|
||||
$this->tage = $tage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'tage' => $this->getTage(),
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
tage: {$this->getTage()}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil
|
||||
{
|
||||
protected $zeitaufzeichnung;
|
||||
protected $azgrelevant;
|
||||
protected $homeoffice;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data, $fromdb=false)
|
||||
{
|
||||
parent::hydrateByStdClass($data, $fromdb);
|
||||
$this->fromdb = $fromdb;
|
||||
isset($data->zeitaufzeichnung) && $this->setZeitaufzeichnung($data->zeitaufzeichnung);
|
||||
isset($data->azgrelevant) && $this->setAzgrelevant($data->azgrelevant);
|
||||
isset($data->homeoffice) && $this->setHomeoffice($data->homeoffice);
|
||||
$this->fromdb = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of zeitaufzeichnung
|
||||
*/
|
||||
public function getZeitaufzeichnung()
|
||||
{
|
||||
return $this->zeitaufzeichnung;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of zeitaufzeichnung
|
||||
*/
|
||||
public function setZeitaufzeichnung($zeitaufzeichnung): self
|
||||
{
|
||||
$this->markDirty('zeitaufzeichnung', $this->zeitaufzeichnung, $zeitaufzeichnung);
|
||||
$this->zeitaufzeichnung = $zeitaufzeichnung;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of azgrelevant
|
||||
*/
|
||||
public function getAzgrelevant()
|
||||
{
|
||||
return $this->azgrelevant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of azgrelevant
|
||||
*/
|
||||
public function setAzgrelevant($azgrelevant): self
|
||||
{
|
||||
$this->markDirty('azgrelevant', $this->azgrelevant, $azgrelevant);
|
||||
$this->azgrelevant = $azgrelevant;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of homeoffice
|
||||
*/
|
||||
public function getHomeoffice()
|
||||
{
|
||||
return $this->homeoffice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of homeoffice
|
||||
*/
|
||||
public function setHomeoffice($homeoffice): self
|
||||
{
|
||||
$this->markDirty('homeoffice', $this->homeoffice, $homeoffice);
|
||||
$this->homeoffice = $homeoffice;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'zeitaufzeichnung' => $this->getZeitaufzeichnung(),
|
||||
'azgrelevant' => $this->getAzgrelevant(),
|
||||
'homeoffice' => $this->getHomeoffice()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($k) {
|
||||
return in_array($k, $this->modifiedcolumns);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
zeitaufzeichnung: {$this->getZeitaufzeichnung()}
|
||||
azgrelevant: {$this->getAzgrelevant()}
|
||||
homeoffice: {$this->getHomeoffice()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
return parent::validate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user