mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
Merge branch 'master' into feature-33003/BIS_Meldung_Personal
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use CI3_Events as Events;
|
||||
|
||||
/**
|
||||
* NOTE(chris): example:
|
||||
Events::on('stv_conf_student', function (&$res) {
|
||||
$res['test'] = [
|
||||
'title' => 'TEST',
|
||||
'component' => './Stv/Studentenverwaltung/Details/Notizen.js'
|
||||
];
|
||||
});
|
||||
*/
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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');
|
||||
|
||||
// NOTE: if database encryption is _not_ used then leave this array empty!
|
||||
$config['encryption_passwords'] = array(
|
||||
// 'password name 1' => 'password 1'
|
||||
// 'password name 2' => 'password 2'
|
||||
// 'password name ...' => 'password ...'
|
||||
// 'password name N' => 'password N'
|
||||
);
|
||||
|
||||
@@ -126,6 +126,7 @@ $config['antrag_job_systemuser'] = '';
|
||||
* @var array Array of tbl_status.status_kurzbz's
|
||||
*/
|
||||
$config['antrag_prestudentstatus_whitelist'] = ['Student', 'Diplomand'];
|
||||
$config['antrag_prestudentstatus_whitelist_abmeldung'] = ['Student', 'Diplomand', 'Unterbrecher'];
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
if ( !defined("PHPUNIT_TEST") ) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
class Test extends CI_Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
// Yep... This is all we need.
|
||||
ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
}
|
||||
}
|
||||
@@ -33,46 +33,14 @@ class Leitung extends FHC_Controller
|
||||
|
||||
public function getActiveStgs()
|
||||
{
|
||||
$studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe');
|
||||
$stgsNeuanlage = $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag');
|
||||
|
||||
$stgs = [];
|
||||
|
||||
if ($studiengaenge) {
|
||||
$result = $this->StudierendenantragModel->loadForStudiengaenge($studiengaenge);
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJson($result);
|
||||
$antraege = getData($result) ?: [];
|
||||
|
||||
foreach ($antraege as $antrag) {
|
||||
if (!isset($stgs[$antrag->studiengang_kz])) {
|
||||
$stgs[$antrag->studiengang_kz] = new stdClass();
|
||||
$stgs[$antrag->studiengang_kz]->bezeichnung = $antrag->bezeichnung;
|
||||
$stgs[$antrag->studiengang_kz]->orgform = $antrag->orgform;
|
||||
$stgs[$antrag->studiengang_kz]->studiengang_kz = $antrag->studiengang_kz;
|
||||
}
|
||||
}
|
||||
$studiengaenge = $this->permissionlib->getSTG_isEntitledFor('student/antragfreigabe') ?: [];
|
||||
$studiengaenge = array_merge($studiengaenge, $this->permissionlib->getSTG_isEntitledFor('student/studierendenantrag') ?: []);
|
||||
|
||||
$result = $this->StudierendenantragModel->loadStgsWithAntraege($studiengaenge);
|
||||
if (isError($result)) {
|
||||
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
if ($stgsNeuanlage) {
|
||||
$result = $this->StudierendenantragModel->loadForStudiengaenge($stgsNeuanlage);
|
||||
|
||||
if (isError($result))
|
||||
return $this->outputJson($result);
|
||||
$antraege = getData($result) ?: [];
|
||||
|
||||
foreach ($antraege as $antrag) {
|
||||
if (!isset($stgs[$antrag->studiengang_kz])) {
|
||||
$stgs[$antrag->studiengang_kz] = new stdClass();
|
||||
$stgs[$antrag->studiengang_kz]->bezeichnung = $antrag->bezeichnung;
|
||||
$stgs[$antrag->studiengang_kz]->orgform = $antrag->orgform;
|
||||
$stgs[$antrag->studiengang_kz]->studiengang_kz = $antrag->studiengang_kz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->outputJsonSuccess($stgs);
|
||||
$this->outputJson($result);
|
||||
}
|
||||
|
||||
public function getAntraege($studiengang = null, $extra = null)
|
||||
|
||||
@@ -17,11 +17,17 @@ class SearchBar extends FHC_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Loads the AuthLib and starts the authentication
|
||||
$this->load->library('AuthLib');
|
||||
// Loads the AuthLib _without_ starting the authentication
|
||||
// NOTE:
|
||||
// - A user must be authenticated via another controller to access this one
|
||||
// - It is loaded to be able to call the isLogged function later
|
||||
$this->load->library('AuthLib', array(false));
|
||||
|
||||
// Load the library SearchBarLib
|
||||
$this->load->library('SearchBarLib');
|
||||
|
||||
// Checks if the user is authenticated, otherwise returns an error code in JSON format
|
||||
if (!isLogged()) $this->terminateWithJsonError(SearchBarLib::ERROR_NOT_AUTH);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -286,7 +286,6 @@ class AntragJob extends JOB_Controller
|
||||
|
||||
$result = $this->PruefungModel->getAllPrestudentsWhereCommitteeExamFailed(
|
||||
[
|
||||
null,
|
||||
Studierendenantragstatus_model::STATUS_REQUESTSENT_1,
|
||||
Studierendenantragstatus_model::STATUS_REQUESTSENT_2
|
||||
],
|
||||
@@ -346,6 +345,7 @@ class AntragJob extends JOB_Controller
|
||||
$dateDeadline = new DateTime();
|
||||
$dateDeadline->sub(DateInterval::createFromDateString($modifier_deadline));
|
||||
|
||||
$this->StudierendenantragModel->addSelect('tbl_studierendenantrag.studierendenantrag_id');
|
||||
$this->StudierendenantragModel->addSelect('prestudent_id');
|
||||
$this->StudierendenantragModel->addSelect('studiensemester_kurzbz');
|
||||
$this->StudierendenantragModel->addSelect('s.insertamum');
|
||||
@@ -370,50 +370,62 @@ class AntragJob extends JOB_Controller
|
||||
|
||||
foreach ($antraege as $antrag)
|
||||
{
|
||||
$result = $this->prestudentlib->setAbbrecher(
|
||||
$antrag->prestudent_id,
|
||||
$antrag->studiensemester_kurzbz,
|
||||
'AntragJob',
|
||||
'abbrecherStgl',
|
||||
$antrag->insertamum,
|
||||
null,
|
||||
$antrag->insertvon ?: $insertvon
|
||||
);
|
||||
$result = $this->StudierendenantragstatusModel->insert([
|
||||
'studierendenantrag_id' => $antrag->studierendenantrag_id,
|
||||
'studierendenantrag_statustyp_kurzbz' => Studierendenantragstatus_model::STATUS_DEREGISTERED,
|
||||
'insertvon' => 'AntragJob'
|
||||
]);
|
||||
if (isError($result))
|
||||
$this->logError(getError($result));
|
||||
else
|
||||
{
|
||||
$count++;
|
||||
$result = $this->PrestudentModel->load($antrag->prestudent_id);
|
||||
if(!hasData($result)) {
|
||||
$this->logWarning('No Prestudent found');
|
||||
continue;
|
||||
}
|
||||
$prestudent = current(getData($result));
|
||||
$result = $this->StudiengangModel->load($prestudent->studiengang_kz);
|
||||
if(!hasData($result)) {
|
||||
$this->logWarning('No Studiengang found');
|
||||
continue;
|
||||
}
|
||||
$studiengang = current(getData($result));
|
||||
$result = $this->PersonModel->loadPrestudent($antrag->prestudent_id);
|
||||
if(!hasData($result))
|
||||
{
|
||||
$this->logWarning('No Person found');
|
||||
continue;
|
||||
}
|
||||
$person = current(getData($result));
|
||||
$email = $studiengang->email;
|
||||
$dataMail = array(
|
||||
'prestudent' => $antrag->prestudent_id,
|
||||
'studiensemester' => $antrag->studiensemester_kurzbz,
|
||||
'name' => trim($person->vorname . ' '. $person->nachname),
|
||||
);
|
||||
else {
|
||||
$deregisterStatus = getData($result);
|
||||
|
||||
if(!sendSanchoMail('Sancho_Mail_Antrag_A_Assist', $dataMail, $email, 'Einspruchsfrist abgelaufen'))
|
||||
{
|
||||
$this->logWarning("Failed to send Notification to " . $email);
|
||||
$result = $this->prestudentlib->setAbbrecher(
|
||||
$antrag->prestudent_id,
|
||||
$antrag->studiensemester_kurzbz,
|
||||
'AntragJob',
|
||||
'abbrecherStgl',
|
||||
$antrag->insertamum,
|
||||
null,
|
||||
$antrag->insertvon ?: $insertvon
|
||||
);
|
||||
if (isError($result)) {
|
||||
$this->StudierendenantragstatusModel->delete($deregisterStatus);
|
||||
$this->logError(getError($result));
|
||||
} else {
|
||||
$count++;
|
||||
$result = $this->PrestudentModel->load($antrag->prestudent_id);
|
||||
if(!hasData($result)) {
|
||||
$this->logWarning('No Prestudent found');
|
||||
continue;
|
||||
}
|
||||
$prestudent = current(getData($result));
|
||||
$result = $this->StudiengangModel->load($prestudent->studiengang_kz);
|
||||
if(!hasData($result)) {
|
||||
$this->logWarning('No Studiengang found');
|
||||
continue;
|
||||
}
|
||||
$studiengang = current(getData($result));
|
||||
$result = $this->PersonModel->loadPrestudent($antrag->prestudent_id);
|
||||
if(!hasData($result))
|
||||
{
|
||||
$this->logWarning('No Person found');
|
||||
continue;
|
||||
}
|
||||
$person = current(getData($result));
|
||||
$email = $studiengang->email;
|
||||
$dataMail = array(
|
||||
'prestudent' => $antrag->prestudent_id,
|
||||
'studiensemester' => $antrag->studiensemester_kurzbz,
|
||||
'name' => trim($person->vorname . ' '. $person->nachname),
|
||||
);
|
||||
|
||||
if(!sendSanchoMail('Sancho_Mail_Antrag_A_Assist', $dataMail, $email, 'Einspruchsfrist abgelaufen'))
|
||||
{
|
||||
$this->logWarning("Failed to send Notification to " . $email);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$this->logInfo($count . "/" . count($antraege) . " Students set to Abbrecher");
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilTest
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilTest extends JOB_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->library('vertragsbestandteil/VertragsbestandteilLib',
|
||||
null, 'VertragsbestandteilLib');
|
||||
$this->load->library('vertragsbestandteil/GehaltsbestandteilLib',
|
||||
null, 'GehaltsbestandteilLib');
|
||||
}
|
||||
|
||||
public function testFetch()
|
||||
{
|
||||
$dienstverhaeltnis_id = 1;
|
||||
$stichtag = null;
|
||||
|
||||
foreach($this->VertragsbestandteilLib->fetchVertragsbestandteile(
|
||||
$dienstverhaeltnis_id, $stichtag) as $vertragsbestandteil)
|
||||
{
|
||||
//print_r($vertragsbestandteil);
|
||||
echo $vertragsbestandteil . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
public function testUpdate()
|
||||
{
|
||||
$now = new DateTime();
|
||||
|
||||
$data = new stdClass();
|
||||
$data->vertragsbestandteil_id = 32;
|
||||
$data->von = '2022-12-05';
|
||||
|
||||
$data->wochenstunden = 45.0;
|
||||
$data->vertragsbestandteiltyp_kurzbz = VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_STUNDEN;
|
||||
|
||||
$vb = VertragsbestandteilFactory::getVertragsbestandteil($data);
|
||||
|
||||
try
|
||||
{
|
||||
$this->VertragsbestandteilLib->storeVertragsbestandteil($vb);
|
||||
echo "Update successful.\n";
|
||||
}
|
||||
catch( Exception $ex )
|
||||
{
|
||||
echo "Update failed.\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function testInsert()
|
||||
{
|
||||
$now = new DateTime();
|
||||
|
||||
$data = new stdClass();
|
||||
$data->dienstverhaeltnis_id = 1;
|
||||
$data->von = '2022-12-01';
|
||||
$data->insertamum = $now->format(DateTime::ATOM);
|
||||
$data->insertvon = 'ma0080';
|
||||
$data->vertragsbestandteiltyp_kurzbz = VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_FUNKTION;
|
||||
|
||||
$data->benutzerfunktion_id = 112667;
|
||||
$data->anmerkung = 'test funkton';
|
||||
$data->kuendigungsrelevant = false;
|
||||
|
||||
$vb = VertragsbestandteilFactory::getVertragsbestandteil($data);
|
||||
|
||||
try
|
||||
{
|
||||
$this->VertragsbestandteilLib->storeVertragsbestandteil($vb);
|
||||
echo "Insert successful.\n";
|
||||
}
|
||||
catch( Exception $ex )
|
||||
{
|
||||
echo "Insert failed.\n";
|
||||
}
|
||||
}
|
||||
|
||||
public function testGehaltsbestandteilInsert()
|
||||
{
|
||||
$data = new stdClass();
|
||||
$data->gehaltsbestandteil_id = 2;
|
||||
/*
|
||||
$data->dienstverhaeltnis_id = 39;
|
||||
$data->vertragsbestandteil_id = 123;
|
||||
$data->gehaltstyp_kurzbz = 'zulage';
|
||||
$data->von = '2023-04-01';
|
||||
$data->bis = '2023-08-31';
|
||||
$data->anmerkung = 'test anmerkung';
|
||||
$data->grundbetrag = 100;
|
||||
$data->betrag_valorisiert = 100;
|
||||
$data->valorisierung = true;
|
||||
*/
|
||||
$data->auszahlungen = 12;
|
||||
|
||||
$gb = new \vertragsbestandteil\Gehaltsbestandteil();
|
||||
$gb->hydrateByStdClass($data);
|
||||
|
||||
print_r($gb->toStdClass());
|
||||
|
||||
$this->GehaltsbestandteilLib->storeGehaltsbestandteil($gb);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ class LehrauftragAkzeptieren extends Auth_Controller
|
||||
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->load->model('codex/Bisverwendung_model', 'BisverwendungModel');
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->load->model('vertragsbestandteil/Dienstverhaeltnis_model', 'DienstverhaeltnisModel');
|
||||
|
||||
// Load libraries
|
||||
$this->load->library('WidgetLib');
|
||||
@@ -94,9 +95,9 @@ class LehrauftragAkzeptieren extends Auth_Controller
|
||||
'lektor' => true,
|
||||
'aktiv' => true
|
||||
));
|
||||
|
||||
|
||||
$is_external_lector = hasData($result) ? true : false;
|
||||
|
||||
|
||||
$view_data = array(
|
||||
'studiensemester_selected' => $studiensemester_kurzbz,
|
||||
'is_external_lector' => $is_external_lector
|
||||
@@ -207,15 +208,41 @@ class LehrauftragAkzeptieren extends Auth_Controller
|
||||
*/
|
||||
public function checkInkludierteLehre()
|
||||
{
|
||||
$result = $this->BisverwendungModel->getLast($this->_uid, false);
|
||||
|
||||
if (hasData($result))
|
||||
if(defined('DIENSTVERHAELTNIS_SUPPORT') && DIENSTVERHAELTNIS_SUPPORT)
|
||||
{
|
||||
$this->outputJsonSuccess(!is_null($result->retval[0]->inkludierte_lehre) && $result->retval[0]->inkludierte_lehre != 0);
|
||||
// Bei neuer Vertragsstruktur wird nur anhand des echten DVs entschieden ob eine Anzeige
|
||||
// des Stundensatzes erfolgt oder nicht.
|
||||
$result = $this->DienstverhaeltnisModel->getDVByPersonUID($this->_uid, null, date('Y-m-d'));
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$data = getData($result);
|
||||
foreach($data as $row)
|
||||
{
|
||||
if($row->vertragsart_kurzbz == 'echterdv')
|
||||
$this->outputJsonSuccess(true);
|
||||
else
|
||||
$this->outputJsonSuccess(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->outputJsonError(getError($result));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->outputJsonError(getError($result));
|
||||
// DEPRECATED
|
||||
$result = $this->BisverwendungModel->getLast($this->_uid, false);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$this->outputJsonSuccess(!is_null($result->retval[0]->inkludierte_lehre) && $result->retval[0]->inkludierte_lehre != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->outputJsonError(getError($result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Components extends FHC_Controller
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function primevue(...$args)
|
||||
{
|
||||
$path = implode('/', $args);
|
||||
$target = FHCPATH . 'vendor/npm-asset/primevue/' . $path;
|
||||
if (!file_exists($target))
|
||||
return show_404();
|
||||
|
||||
$newUrl = str_repeat('../', count($args));
|
||||
|
||||
$ext = substr($path, -7) == '.min.js' ? '.esm.min.js' : '.esm.js';
|
||||
|
||||
$contents = file_get_contents($target);
|
||||
|
||||
$contents = preg_replace_callback('/import([^;]*)from\s*[\'"]vue[\'"];/i', function ($matches) {
|
||||
return 'let ' . str_replace(' as ', ': ', $matches[1]) . ' = Vue;';
|
||||
}, $contents);
|
||||
|
||||
$contents = preg_replace_callback('/(import[^;]*[\'"])(primevue[^\'"]+)([\'"])/i', function ($matches) use ($ext, $newUrl) {
|
||||
if (is_file(FHCPATH . 'vendor/npm-asset/' . $matches[2])) {
|
||||
$newUrl .= $matches[2];
|
||||
} else {
|
||||
$testfile = $matches[2] . '/index' . $ext;
|
||||
if (file_exists(FHCPATH . 'vendor/npm-asset/' . $testfile))
|
||||
$newUrl .= $testfile;
|
||||
else
|
||||
$newUrl .= $matches[2] . strrchr($matches[2], '/') . $ext;
|
||||
}
|
||||
return $matches[1] . $newUrl . $matches[3];
|
||||
}, $contents);
|
||||
|
||||
$this->output->set_content_type('text/javascript');
|
||||
$this->output->set_output($contents);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,680 @@
|
||||
<?php
|
||||
/*
|
||||
* Job zur einmaligen Migration der Mitarbeiterverträge aus der tbl_bisverwendung in die neue
|
||||
* Vertragsstruktur im HR Schema
|
||||
*
|
||||
* Aufruf pro Person
|
||||
* php index.ci.php system/MigrateContract/index/oesi
|
||||
*
|
||||
* Aufruf fuer Alle
|
||||
* php index.ci.php system/MigrateContract/index
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class MigrateContract extends CLI_Controller
|
||||
{
|
||||
|
||||
private $matching_ba1_vertragsart;
|
||||
private $OE_DEFAULT = 'gst';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('codex/bisverwendung_model', 'BisVerwendungModel');
|
||||
$this->load->model('person/benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
|
||||
$this->matching_ba1_vertragsart = array(
|
||||
'101'=>'externerlehrender',
|
||||
'102'=>'DV anderen Gebietskörperschaft',
|
||||
'103'=>'echterdv',
|
||||
'104'=>'studentischehilfskr',
|
||||
'105'=>'externerlehrender',
|
||||
'106'=>'Andere Bildungseinrichtung',
|
||||
'107'=>'werkvertrag',
|
||||
'108'=>'studentischehilfskr',
|
||||
'109'=>'ueberlassungsvertrag',
|
||||
'110'=>'echterfreier',
|
||||
'111'=>'echterdv', //All-In
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Everything has a beginning
|
||||
*/
|
||||
public function index($user = null)
|
||||
{
|
||||
if (!is_null($user))
|
||||
{
|
||||
$contracts = $this->_transformUser($user);
|
||||
|
||||
/*
|
||||
Format:
|
||||
$contracts['dv'][]['vbs'][]
|
||||
*/
|
||||
//$this->outputJson($contracts);
|
||||
var_dump($contracts);
|
||||
$this->_saveJSON($contracts);
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = "SELECT distinct mitarbeiter_uid FROM bis.tbl_bisverwendung";
|
||||
$db = new DB_Model();
|
||||
|
||||
$resultUser = $db->execReadOnlyQuery($qry);
|
||||
if (hasData($resultUser))
|
||||
{
|
||||
$users = getData($resultUser);
|
||||
foreach($users as $user)
|
||||
{
|
||||
$contracts = $this->_transformUser($user->mitarbeiter_uid);
|
||||
$this->_saveJSON($contracts);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function _saveJSON($contracts)
|
||||
{
|
||||
$this->load->model('vertragsbestandteil/Dienstverhaeltnis_model','DienstverhaeltnisModel');
|
||||
$this->load->model('vertragsbestandteil/Vertragsbestandteil_model','VertragsbestandteilModel');
|
||||
$this->load->model('vertragsbestandteil/VertragsbestandteilStunden_model','VertragsbestandteilStundenModel');
|
||||
$this->load->model('vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model','VertragsbestandteilZeitaufzeichnungModel');
|
||||
$this->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model','VertragsbestandteilFreitextModel');
|
||||
$this->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model','VertragsbestandteilFunktionModel');
|
||||
$this->load->model('vertragsbestandteil/VertragsbestandteilKarenz_model','VertragsbestandteilKarenzModel');
|
||||
|
||||
$failed = false;
|
||||
$this->db->trans_begin();
|
||||
|
||||
foreach($contracts['dv'] as $row_dv)
|
||||
{
|
||||
// Dienstvertrag erstellen
|
||||
$resultDV = $this->DienstverhaeltnisModel->insert(
|
||||
array(
|
||||
'mitarbeiter_uid' => $row_dv['mitarbeiter_uid'],
|
||||
'vertragsart_kurzbz' => $row_dv['vertragsart_kurzbz'],
|
||||
'oe_kurzbz' => $row_dv['oe_kurzbz'],
|
||||
'von' => $row_dv['von'],
|
||||
'bis' => $row_dv['bis'],
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => 'MigrateContract'
|
||||
)
|
||||
);
|
||||
|
||||
if (isSuccess($resultDV) && hasData($resultDV))
|
||||
{
|
||||
$dv_id = getData($resultDV);
|
||||
|
||||
// Vertragsbetandteile erstellen
|
||||
foreach($row_dv['vbs'] as $row_vbs)
|
||||
{
|
||||
$resultVBS = $this->VertragsbestandteilModel->insert(
|
||||
array(
|
||||
'dienstverhaeltnis_id' => $dv_id,
|
||||
'vertragsbestandteiltyp_kurzbz' => $row_vbs['vertragsbestandteiltyp_kurzbz'],
|
||||
'von' => $row_vbs['von'],
|
||||
'bis' => $row_vbs['bis'],
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => 'MigrateContract'
|
||||
)
|
||||
);
|
||||
|
||||
if (isSuccess($resultVBS) && hasData($resultVBS))
|
||||
{
|
||||
$vbs_id = getData($resultVBS);
|
||||
echo 'VBS:'.$vbs_id;
|
||||
|
||||
switch($row_vbs['vertragsbestandteiltyp_kurzbz'])
|
||||
{
|
||||
case 'stunden':
|
||||
$resultVBS = $this->_insertVBSStunden($vbs_id, $row_vbs);
|
||||
break;
|
||||
case 'zeitaufzeichnung':
|
||||
$resultVBS = $this->_insertVBSZeitaufzeichnung($vbs_id, $row_vbs);
|
||||
break;
|
||||
case 'funktion':
|
||||
$resultVBS = $this->_insertVBSFunktion($vbs_id, $row_vbs);
|
||||
break;
|
||||
case 'freitext':
|
||||
$resultVBS = $this->_insertVBSFreitext($vbs_id, $row_vbs);
|
||||
break;
|
||||
case 'karenz':
|
||||
$resultVBS = $this->_insertVBSKarenz($vbs_id, $row_vbs);
|
||||
break;
|
||||
}
|
||||
|
||||
if (isError($resultVBS))
|
||||
{
|
||||
echo "FAILED:".getError($resultVBS);
|
||||
$failed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$failed)
|
||||
{
|
||||
$this->db->trans_commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ROLLBACK";
|
||||
$this->db->trans_rollback();
|
||||
}
|
||||
}
|
||||
|
||||
private function _insertVBSKarenz($vbs_id, $row_vbs)
|
||||
{
|
||||
return $this->VertragsbestandteilKarenzModel->insert(
|
||||
array(
|
||||
'vertragsbestandteil_id' => $vbs_id,
|
||||
'karenztyp_kurzbz' => $row_vbs['karenztyp_kurzbz']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _insertVBSFreitext($vbs_id, $row_vbs)
|
||||
{
|
||||
return $this->VertragsbestandteilFreitextModel->insert(
|
||||
array(
|
||||
'vertragsbestandteil_id' => $vbs_id,
|
||||
'freitexttyp_kurzbz' => $row_vbs['freitexttyp_kurzbz'],
|
||||
'titel' => $row_vbs['titel'],
|
||||
'anmerkung' => $row_vbs['anmerkung']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _insertVBSFunktion($vbs_id, $row_vbs)
|
||||
{
|
||||
return $this->VertragsbestandteilFunktionModel->insert(
|
||||
array(
|
||||
'vertragsbestandteil_id' => $vbs_id,
|
||||
'benutzerfunktion_id' => $row_vbs['benutzerfunktion_id']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _insertVBSZeitaufzeichnung($vbs_id, $row_vbs)
|
||||
{
|
||||
return $this->VertragsbestandteilZeitaufzeichnungModel->insert(
|
||||
array(
|
||||
'vertragsbestandteil_id' => $vbs_id,
|
||||
'zeitaufzeichnung' => $row_vbs['zeitaufzeichnung'],
|
||||
'azgrelevant' => $row_vbs['azgrelevant'],
|
||||
'homeoffice' => $row_vbs['homeoffice']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _insertVBSStunden($vbs_id, $row_vbs)
|
||||
{
|
||||
return $this->VertragsbestandteilStundenModel->insert(
|
||||
array(
|
||||
'vertragsbestandteil_id' => $vbs_id,
|
||||
'wochenstunden' => $row_vbs['wochenstunden'],
|
||||
'teilzeittyp_kurzbz' => $row_vbs['teilzeittyp_kurzbz']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt die neue Vertragsstruktur fuer einen User
|
||||
*/
|
||||
private function _transformUser($user)
|
||||
{
|
||||
$contracts = array();
|
||||
$this->BisVerwendungModel->addOrder('beginn');
|
||||
$result_verwendung = $this->BisVerwendungModel->loadWhere(array("mitarbeiter_uid" => $user));
|
||||
|
||||
if (isError($result_verwendung))
|
||||
die("Failed to load Verwendung");
|
||||
|
||||
if (hasData($result_verwendung))
|
||||
{
|
||||
$verwendung = getData($result_verwendung);
|
||||
|
||||
foreach ($verwendung as $row_verwendung)
|
||||
{
|
||||
$dv = $this->_getOrCreateDV($contracts, $row_verwendung);
|
||||
|
||||
// Ende des DV aktualisieren
|
||||
if ($contracts['dv'][$dv]['bis'] < $row_verwendung->ende || $row_verwendung->ende == '')
|
||||
$contracts['dv'][$dv]['bis'] = $row_verwendung->ende;
|
||||
|
||||
// Stundenbestandteil pruefen
|
||||
$this->_addVertragsbestandteilStunden($contracts, $dv, $row_verwendung);
|
||||
|
||||
// Befristung
|
||||
$this->_addVertragsbestandteilFreitextBefristung($contracts, $dv, $row_verwendung);
|
||||
|
||||
// All-In
|
||||
$this->_addVertragsbestandteilFreitextAllIn($contracts, $dv, $row_verwendung);
|
||||
|
||||
// Zeitaufzeichnung
|
||||
$this->_addVertragsbestandteilZeitaufzeichnung($contracts, $dv, $row_verwendung);
|
||||
|
||||
// Karenz
|
||||
$this->_addVertragsbestandteilKarenz($contracts, $dv, $row_verwendung);
|
||||
|
||||
// Inkludierte Lehre
|
||||
// Kuendigungsfrist
|
||||
// Urlaubsanspruch
|
||||
}
|
||||
|
||||
// Funktion
|
||||
$this->_addVertragsbestandteilFunktion($contracts, $user);
|
||||
|
||||
}
|
||||
|
||||
return $contracts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fuegt Karenzierungseintraege zu bestehenden Dienstverhaeltnissen hinzu
|
||||
*/
|
||||
private function _addVertragsbestandteilKarenz(&$contracts, $dv, $row_verwendung)
|
||||
{
|
||||
if ($row_verwendung->beschausmasscode == 5)
|
||||
{
|
||||
$dtstart = new DateTime($row_verwendung->beginn);
|
||||
$dtende = new DateTime($row_verwendung->ende);
|
||||
$interval = $dtende->diff($dtstart);
|
||||
$dauer = $interval->format('%a');
|
||||
|
||||
// TODO: klären ob das so machbar ist
|
||||
if ($dauer < 65)
|
||||
$karenztyp = 'papamonat';
|
||||
elseif ($dauer < 120)
|
||||
$karenztyp = 'bildungskarenz';
|
||||
else
|
||||
$karenztyp = 'elternkarenz';
|
||||
|
||||
// VBS anlegen und Funktion zuweisen
|
||||
$newVBSIndex = $this->_getNewVBSIndex($contracts, $dv);
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['vertragsbestandteiltyp_kurzbz'] = 'karenz';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['von'] = $row_verwendung->beginn;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['bis'] = $row_verwendung->ende;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['karenztyp_kurzbz'] = $karenztyp;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['geplanter_geburtstermin'] = null;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['tatsaechlicher_geburtstermin'] = null;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['hint'] = 'Dauer:'.$dauer;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt die Funktionen die Vertragsrelevant sind und verknüpft diese
|
||||
*/
|
||||
private function _addVertragsbestandteilFunktion(&$contracts, $user)
|
||||
{
|
||||
// Alle Funktionen holen die Vertragsrelevant sind
|
||||
$this->BenutzerfunktionModel->addOrder('datum_von');
|
||||
$this->BenutzerfunktionModel->addJoin('public.tbl_funktion','funktion_kurzbz');
|
||||
$resultFunktionen = $this->BenutzerfunktionModel->loadWhere(array('uid' => $user, 'vertragsrelevant' => true));
|
||||
|
||||
if (isSuccess($resultFunktionen) && hasData($resultFunktionen))
|
||||
{
|
||||
$funktionen = getData($resultFunktionen);
|
||||
|
||||
foreach ($funktionen as $row_funktion)
|
||||
{
|
||||
$funktion_added = 0;
|
||||
$dv = '';
|
||||
|
||||
// Passendes DV suchen
|
||||
foreach ($contracts['dv'] as $key_dv => $row_contract)
|
||||
{
|
||||
// Eine Funktion kann zu mehreren DV zugeordnet sein
|
||||
// es werden daher alle durchsucht ob es reinfaellt und ggf mehrfach zugeordnet
|
||||
if ((isset($row_funktion->datum_von) && $row_funktion->datum_von >= $row_contract['von'])
|
||||
&& ($row_contract['bis'] == '' || $row_contract['bis'] >= $row_funktion->datum_von)
|
||||
&& (
|
||||
(
|
||||
isset($row_funktion->datum_bis) && isset($row_contract['bis'])
|
||||
&& $row_funktion->datum_bis <= $row_contract['bis']
|
||||
)
|
||||
|| $row_funktion->datum_bis == ''
|
||||
|| (isset($row_funktion->datum_bis) && !isset($row_contract['bis']))
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
$dv = $key_dv;
|
||||
|
||||
// Startdatum und Endedatum ermitteln wenn die Funktion ueber das DV hinausgeht
|
||||
// Wenn die Dauer laenger ist, wird beim Beginn/Ende des DV abgegrenzt
|
||||
$dtstart_fkt = new DateTime($row_funktion->datum_von);
|
||||
$dtstart_dv = new DateTime($row_contract['von']);
|
||||
if ($dtstart_fkt < $dtstart_dv)
|
||||
$startdatum = $row_contract['von'];
|
||||
else
|
||||
$startdatum = $row_funktion->datum_von;
|
||||
|
||||
$dtende_fkt = new DateTime($row_funktion->datum_bis);
|
||||
$dtende_dv = new DateTime($row_contract['bis']);
|
||||
if ($dtende_fkt < $dtende_dv)
|
||||
$endedatum = $row_funktion->datum_bis;
|
||||
else
|
||||
$endedatum = $row_contract['bis'];
|
||||
|
||||
// VBS anlegen und Funktion zuweisen
|
||||
$newVBSIndex = $this->_getNewVBSIndex($contracts, $dv);
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['vertragsbestandteiltyp_kurzbz'] = 'funktion';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['von'] = $startdatum;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['bis'] = $endedatum;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['benutzerfunktion_id'] = $row_funktion->benutzerfunktion_id;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['hint'] = $row_funktion->funktion_kurzbz.' '.$row_funktion->datum_von.' - '.$row_funktion->datum_bis;
|
||||
$funktion_added++;
|
||||
}
|
||||
}
|
||||
if ($funktion_added == 0)
|
||||
{
|
||||
echo "\nFunktion nicht zugeordnet: ".$row_funktion->funktion_kurzbz.' '.$row_funktion->datum_von.' - '.$row_funktion->datum_bis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob schon ein Vertragsbestandteil fuer Zeitaufzeichnung vorhanden ist das in den Zeitraum passt
|
||||
* bzw direkt anschließt. Wenn es direkt anschließend ist und die Art gleich sind wird die Laufzeit verlaengert
|
||||
* Ansonsten wird ein neuer VBS angelegt
|
||||
*/
|
||||
private function _addVertragsbestandteilZeitaufzeichnung(&$contracts, $dv, $row_verwendung)
|
||||
{
|
||||
if (isset($contracts['dv'][$dv]['vbs']))
|
||||
{
|
||||
foreach ($contracts['dv'][$dv]['vbs'] as $index_vbs=>$row_vbs)
|
||||
{
|
||||
if ($row_vbs['vertragsbestandteiltyp_kurzbz'] == 'zeitaufzeichnung')
|
||||
{
|
||||
if ($this->_isVBSAngrenzend($row_verwendung, $row_vbs)
|
||||
&& $row_vbs['zeitaufzeichnung'] == $row_verwendung->zeitaufzeichnungspflichtig
|
||||
&& $row_vbs['azgrelevant'] == $row_verwendung->azgrelevant
|
||||
&& $row_vbs['homeoffice'] == $row_verwendung->homeoffice
|
||||
)
|
||||
{
|
||||
// Zeitaufzeichnungsarten bleiben gleich - Ende des VBS verlaengern
|
||||
$contracts['dv'][$dv]['vbs'][$index_vbs]['bis'] = $row_verwendung->ende;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// kein passender VBS gefunden - neuen anlegen
|
||||
$newVBSIndex = $this->_getNewVBSIndex($contracts, $dv);
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['vertragsbestandteiltyp_kurzbz'] = 'zeitaufzeichnung';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['von'] = $row_verwendung->beginn;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['bis'] = $row_verwendung->ende;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['zeitaufzeichnung'] = $row_verwendung->zeitaufzeichnungspflichtig;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['azgrelevant'] = $row_verwendung->azgrelevant;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['homeoffice'] = $row_verwendung->homeoffice;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fueg einen Freitextbestandteil fuer All-In zum DV hinzu
|
||||
*/
|
||||
private function _addVertragsbestandteilFreitextAllIn(&$contracts, $dv, $row_verwendung)
|
||||
{
|
||||
if ($row_verwendung->ba1code == 111) // All-In
|
||||
{
|
||||
$newVBSIndex = $this->_getNewVBSIndex($contracts, $dv);
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['vertragsbestandteiltyp_kurzbz'] = 'freitext';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['von'] = $row_verwendung->beginn;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['bis'] = $row_verwendung->ende;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['freitexttyp_kurzbz'] = 'allin';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['titel'] = 'allin';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['anmerkung'] = 'allin';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fueg einen Freitextbestandteil fuer die Berfristung zum DV hinzu
|
||||
*/
|
||||
private function _addVertragsbestandteilFreitextBefristung(&$contracts, $dv, $row_verwendung)
|
||||
{
|
||||
if ($row_verwendung->ba2code == 1) // Befristung
|
||||
{
|
||||
$newVBSIndex = $this->_getNewVBSIndex($contracts, $dv);
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['vertragsbestandteiltyp_kurzbz'] = 'freitext';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['von'] = $row_verwendung->beginn;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['bis'] = $row_verwendung->ende;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['freitexttyp_kurzbz'] = 'befristung';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['titel'] = 'befristung';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['anmerkung'] = 'befristung';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob schon ein Vertragsbestandteil mit diesem Stundenausmass vorhanden ist das in den Zeitraum passt
|
||||
* bzw direkt anschließt. Wenn es direkt anschließend ist und die Stunden gleich sind wird die Laufzeit verlaengert
|
||||
* Ansonsten wird ein neuer VBS angelegt
|
||||
*/
|
||||
private function _addVertragsbestandteilStunden(&$contracts, $dv, $row_verwendung)
|
||||
{
|
||||
// Nur anlegen wenn im aktuellen Eintrag auch Stunden eingetragen sind
|
||||
if ($row_verwendung->vertragsstunden != '')
|
||||
{
|
||||
if (isset($contracts['dv'][$dv]['vbs']))
|
||||
{
|
||||
foreach ($contracts['dv'][$dv]['vbs'] as $index_vbs=>$row_vbs)
|
||||
{
|
||||
if ($row_vbs['vertragsbestandteiltyp_kurzbz'] == 'stunden' || ($row_vbs['vertragsbestandteiltyp_kurzbz'] == 'karenz' && $row_verwendung->vertragsstunden === '0.00'))
|
||||
{
|
||||
if ($this->_isVBSAngrenzend($row_verwendung, $row_vbs) && ((isset($row_vbs['wochenstunden']) && $row_vbs['wochenstunden'] == $row_verwendung->vertragsstunden) || $row_verwendung->vertragsstunden === '0.00'))
|
||||
{
|
||||
// stunden bleiben gleich - Ende des VBS verlaengern
|
||||
$contracts['dv'][$dv]['vbs'][$index_vbs]['bis'] = $row_verwendung->ende;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// kein passender VBS gefunden - neuen anlegen
|
||||
$newVBSIndex = $this->_getNewVBSIndex($contracts, $dv);
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['vertragsbestandteiltyp_kurzbz'] = 'stunden';
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['von'] = $row_verwendung->beginn;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['bis'] = $row_verwendung->ende;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['wochenstunden'] = $row_verwendung->vertragsstunden;
|
||||
$contracts['dv'][$dv]['vbs'][$newVBSIndex]['teilzeittyp_kurzbz'] = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob die Verwendung direkt an den Vertragsbestandteil angrenzt
|
||||
* @return boolean true wenn ja, sonst false
|
||||
*/
|
||||
private function _isVBSAngrenzend($verwendung, $vbs)
|
||||
{
|
||||
// Beginn Minus 1 Tag
|
||||
$dtstart = new DateTime($verwendung->beginn);
|
||||
$dtstartMinus1 = $dtstart->sub(new DateInterval('P1D'))->format('Y-m-d');
|
||||
|
||||
if ($vbs['bis'] == ''
|
||||
|| $vbs['bis'] == $dtstartMinus1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DV or Returns the Index of an existing
|
||||
*/
|
||||
private function _getOrCreateDV(&$contracts, $row_verwendung)
|
||||
{
|
||||
$unternehmen = $this->OE_DEFAULT;
|
||||
$resultUnternehmen = $this->_getUnternehmen($row_verwendung);
|
||||
if(hasData($resultUnternehmen))
|
||||
{
|
||||
$unternehmen = getData($resultUnternehmen)[0]->oe_kurzbz;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback Unternehmen wird verwendet falls keine Zuordnung ermittelt werden kann
|
||||
}
|
||||
|
||||
if (isset($contracts['dv']) && is_array($contracts['dv']))
|
||||
{
|
||||
foreach($contracts['dv'] as $indexdv => $row_dv)
|
||||
{
|
||||
// Vertragsart ist die selbe und selbes Unternehmen
|
||||
if ($row_dv['vertragsart_kurzbz'] == $this->matching_ba1_vertragsart[$row_verwendung->ba1code]
|
||||
&& $row_dv['oe_kurzbz'] == $unternehmen
|
||||
)
|
||||
{
|
||||
|
||||
$dtstart = new DateTime($row_verwendung->beginn);
|
||||
|
||||
// Zeitraum passt zur Verwendung
|
||||
if ($row_dv['von'] <= $row_verwendung->beginn // Beginn Datum Pruefen
|
||||
&& ( // Ende innerhalb des DV
|
||||
(isset($row_dv['bis']) && $row_verwendung->ende != '' && ($row_dv['bis'] == '' || $row_dv['bis'] >= $row_verwendung->ende)
|
||||
)
|
||||
|| // direkt angrenzend an dieses DV
|
||||
(isset($row_dv['bis'])
|
||||
&& ($row_dv['bis'] == ''
|
||||
|| $row_dv['bis'] == $dtstart->sub(new DateInterval('P1D'))->format('Y-m-d')
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
return $indexdv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$newDvIndex = $this->_getNewDVIndex($contracts);
|
||||
$contracts['dv'][$newDvIndex]['mitarbeiter_uid'] = $row_verwendung->mitarbeiter_uid;
|
||||
$contracts['dv'][$newDvIndex]['von'] = $row_verwendung->beginn;
|
||||
$contracts['dv'][$newDvIndex]['bis'] = $row_verwendung->ende;
|
||||
$contracts['dv'][$newDvIndex]['oe_kurzbz'] = $unternehmen;
|
||||
$contracts['dv'][$newDvIndex]['vertragsart_kurzbz'] = $this->matching_ba1_vertragsart[$row_verwendung->ba1code];
|
||||
|
||||
return $newDvIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt in welchem Unternehmen die Person zum betreffenden Zeitpunkt ist.
|
||||
*/
|
||||
private function _getUnternehmen($row_verwendung)
|
||||
{
|
||||
|
||||
$resultUnternehmen = $this->_findUnternehmen($row_verwendung->mitarbeiter_uid, "'kstzuordnung', 'oezuordnung'", $row_verwendung->beginn);
|
||||
|
||||
// Wenn zeitlich keine passende Unternehmenszuordnung vorhanden ist, dann suchen ob generell eine Zuordnung ermittelt werden kann
|
||||
if(!hasData($resultUnternehmen))
|
||||
{
|
||||
$resultUnternehmen = $this->_findUnternehmen($row_verwendung->mitarbeiter_uid, "'kstzuordnung', 'oezuordnung'");
|
||||
|
||||
// Falls nicht wird nach erweiterten Funktionen gesucht um die Zuordnung zu ermitteln.
|
||||
if(!hasData($resultUnternehmen))
|
||||
{
|
||||
$resultUnternehmen = $this->_findUnternehmen($row_verwendung->mitarbeiter_uid, "'kstzuordnung', 'oezuordnung','hilfskraft','Leitung','fbk','fbl'");
|
||||
}
|
||||
}
|
||||
|
||||
return $resultUnternehmen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detailsuche fuer die Ermittlung des Unternehmenszuordnung einer Person
|
||||
*/
|
||||
private function _findUnternehmen($uid, $fkt=null, $datum=null)
|
||||
{
|
||||
$db = new DB_Model();
|
||||
|
||||
$qry = "
|
||||
WITH RECURSIVE meine_oes(oe_kurzbz, oe_parent_kurzbz, organisationseinheittyp_kurzbz) as
|
||||
(
|
||||
SELECT
|
||||
oe_kurzbz, oe_parent_kurzbz, organisationseinheittyp_kurzbz
|
||||
FROM
|
||||
public.tbl_organisationseinheit
|
||||
WHERE
|
||||
oe_kurzbz=(SELECT
|
||||
oe_kurzbz
|
||||
FROM
|
||||
public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
uid=".$db->escape($uid);
|
||||
|
||||
if(!is_null($datum))
|
||||
$qry.=" AND ".$db->escape($datum)." BETWEEN datum_von AND COALESCE(datum_bis, '2999-12-31')";
|
||||
|
||||
if(!is_null($fkt))
|
||||
$qry.=" AND funktion_kurzbz in ($fkt)";
|
||||
|
||||
$qry.="
|
||||
ORDER BY funktion_kurzbz, datum_von LIMIT 1)
|
||||
UNION ALL
|
||||
SELECT
|
||||
o.oe_kurzbz, o.oe_parent_kurzbz, o.organisationseinheittyp_kurzbz
|
||||
FROM
|
||||
public.tbl_organisationseinheit o, meine_oes
|
||||
WHERE
|
||||
o.oe_kurzbz=meine_oes.oe_parent_kurzbz
|
||||
)
|
||||
SELECT
|
||||
oe_kurzbz
|
||||
FROM
|
||||
meine_oes
|
||||
WHERE
|
||||
oe_parent_kurzbz is null
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
$resultUnternehmen = $db->execReadOnlyQuery($qry);
|
||||
return $resultUnternehmen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt den nächsten (freien) Index für den Vertragsbetandteil
|
||||
*/
|
||||
private function _getNewVBSIndex($contracts, $dv)
|
||||
{
|
||||
if (isset($contracts['dv'][$dv]['vbs']))
|
||||
return max(array_keys($contracts['dv'][$dv]['vbs'])) + 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt den nächsten (freien) Index für das Dienstverhältnis
|
||||
*/
|
||||
private function _getNewDVIndex($contracts)
|
||||
{
|
||||
if (isset($contracts['dv']) && is_array($contracts['dv']))
|
||||
return max(array_keys($contracts['dv'])) + 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class MigrateHourlyRate extends CLI_Controller
|
||||
{
|
||||
|
||||
CONST DEFAULT_OE = 'gst';
|
||||
CONST DEFAULT_DATE = '1970-01-01';
|
||||
CONST STUNDENSTAZTYP_LEHRE = 'lehre';
|
||||
CONST STUNDENSTAZTYP_KALKULATORISCH = 'kalkulatorisch';
|
||||
|
||||
private $_ci;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->_ci = & get_instance();
|
||||
|
||||
$this->load->model('codex/Bisverwendung_model', 'BisVerwendungModel');
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$this->load->model('ressource/Stundensatz_model', 'StundensatzModel');
|
||||
}
|
||||
|
||||
public function index($user = null)
|
||||
{
|
||||
$mitarbeiterResult = $this->_getMitarbeiterStunden($user);
|
||||
if (isError($mitarbeiterResult)) return $mitarbeiterResult;
|
||||
if (!hasData($mitarbeiterResult)) return error('Keine Mitarbeiterstunden gefunden');
|
||||
|
||||
$mitarbeiterArray = getData($mitarbeiterResult);
|
||||
|
||||
foreach ($mitarbeiterArray as $mitarbeiter)
|
||||
{
|
||||
$this->_getUnternehmen($mitarbeiter);
|
||||
$insertResult = $this->_addStundensatz($mitarbeiter, self::STUNDENSTAZTYP_LEHRE, self::DEFAULT_DATE);
|
||||
if (isError($insertResult)) return $insertResult;
|
||||
}
|
||||
|
||||
$sapResult = $this->_getSapStunden($user);
|
||||
if (isError($sapResult)) return $sapResult;
|
||||
if (!hasData($sapResult)) return error('Keinen kalkulatorischen Stundensaetze gefunden');
|
||||
|
||||
$mitarbeiterArray = getData($sapResult);
|
||||
|
||||
foreach ($mitarbeiterArray as $mitarbeiter)
|
||||
{
|
||||
$this->_getUnternehmen($mitarbeiter);
|
||||
$insertResult = $this->_addStundensatz($mitarbeiter, self::STUNDENSTAZTYP_KALKULATORISCH, date_format(date_create($mitarbeiter->beginn), 'Y-m-d'));
|
||||
if (isError($insertResult)) return $insertResult;
|
||||
}
|
||||
}
|
||||
|
||||
private function _getSapStunden($user = null)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
$params = array();
|
||||
|
||||
$qry = "SELECT ss.mitarbeiter_uid as uid,
|
||||
ss.sap_kalkulatorischer_stundensatz as stundensatz,
|
||||
ss.insertamum as beginn
|
||||
FROM sync.tbl_sap_stundensatz ss
|
||||
WHERE ss.sap_kalkulatorischer_stundensatz IS NOT NULL";
|
||||
|
||||
if (!is_null($user))
|
||||
{
|
||||
$qry .= " AND ss.mitarbeiter_uid = ? ";
|
||||
$params[] = $user;
|
||||
}
|
||||
$qry .= " ORDER BY ss.mitarbeiter_uid";
|
||||
|
||||
return $dbModel->execReadOnlyQuery($qry, $params);
|
||||
}
|
||||
|
||||
private function _getMitarbeiterStunden($user = null)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
$params = array();
|
||||
|
||||
$qry = "SELECT mitarbeiter.mitarbeiter_uid as uid,
|
||||
stundensatz
|
||||
FROM public.tbl_mitarbeiter mitarbeiter
|
||||
WHERE mitarbeiter.stundensatz != 0.00
|
||||
AND mitarbeiter.stundensatz IS NOT NULL";
|
||||
|
||||
if (!is_null($user))
|
||||
{
|
||||
$qry .= " AND mitarbeiter.mitarbeiter_uid = ?";
|
||||
$params[] = $user;
|
||||
}
|
||||
|
||||
$qry .= " ORDER BY mitarbeiter.mitarbeiter_uid";
|
||||
|
||||
return $dbModel->execReadOnlyQuery($qry, $params);
|
||||
}
|
||||
|
||||
private function _addStundensatz($mitarbeiter, $stundensatztyp, $gueltig_von)
|
||||
{
|
||||
return $this->_ci->StundensatzModel->insert(
|
||||
array(
|
||||
'uid' => $mitarbeiter->uid,
|
||||
'stundensatztyp' => $stundensatztyp,
|
||||
'stundensatz' => $mitarbeiter->stundensatz,
|
||||
'oe_kurzbz' => $mitarbeiter->unternehmen,
|
||||
'gueltig_von' => $gueltig_von,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => 'MigrateHours'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _getUnternehmen(&$mitarbeiter)
|
||||
{
|
||||
$bvResult = $this->_ci->BisVerwendungModel->getLast($mitarbeiter->uid);
|
||||
|
||||
$beginn = null;
|
||||
if (hasData($bvResult))
|
||||
{
|
||||
$beginn = getData($bvResult)[0]->beginn;
|
||||
}
|
||||
|
||||
$unternehmenResult = $this->_findUnternehmen($mitarbeiter->uid, "'kstzuordnung', 'oezuordnung'", $beginn);
|
||||
|
||||
if(!hasData($unternehmenResult)) //&& hasData($bvResult)
|
||||
{
|
||||
$unternehmenResult = $this->_findUnternehmen($mitarbeiter->uid, "'kstzuordnung', 'oezuordnung'");
|
||||
}
|
||||
|
||||
$unternehmen = self::DEFAULT_OE;
|
||||
|
||||
if (hasData($unternehmenResult))
|
||||
$unternehmen = getData($unternehmenResult)[0]->oe_kurzbz;
|
||||
|
||||
$mitarbeiter->unternehmen = $unternehmen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detailsuche fuer die Ermittlung des Unternehmenszuordnung einer Person
|
||||
*/
|
||||
private function _findUnternehmen($uid, $fkt=null, $datum=null)
|
||||
{
|
||||
$dbModel = new DB_Model();
|
||||
|
||||
$qry = "
|
||||
WITH RECURSIVE meine_oes(oe_kurzbz, oe_parent_kurzbz, organisationseinheittyp_kurzbz) as
|
||||
(
|
||||
SELECT
|
||||
oe_kurzbz, oe_parent_kurzbz, organisationseinheittyp_kurzbz
|
||||
FROM
|
||||
public.tbl_organisationseinheit
|
||||
WHERE
|
||||
oe_kurzbz=(SELECT
|
||||
oe_kurzbz
|
||||
FROM
|
||||
public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
uid=".$dbModel->escape($uid);
|
||||
|
||||
if(!is_null($datum))
|
||||
$qry.=" AND ".$dbModel->escape($datum)." BETWEEN datum_von AND COALESCE(datum_bis, '2999-12-31')";
|
||||
|
||||
if(!is_null($fkt))
|
||||
$qry.=" AND funktion_kurzbz in ($fkt)";
|
||||
|
||||
$qry.="
|
||||
ORDER BY funktion_kurzbz, datum_von LIMIT 1)
|
||||
UNION ALL
|
||||
SELECT
|
||||
o.oe_kurzbz, o.oe_parent_kurzbz, o.organisationseinheittyp_kurzbz
|
||||
FROM
|
||||
public.tbl_organisationseinheit o, meine_oes
|
||||
WHERE
|
||||
o.oe_kurzbz=meine_oes.oe_parent_kurzbz
|
||||
)
|
||||
SELECT
|
||||
oe_kurzbz
|
||||
FROM
|
||||
meine_oes
|
||||
WHERE
|
||||
oe_parent_kurzbz is null
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
return $dbModel->execReadOnlyQuery($qry);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,465 @@
|
||||
<?php
|
||||
/*
|
||||
* Job zur einmaligen Import der Gehälter
|
||||
*
|
||||
* Aufruf (Encode / im Filenmae mit %2F):
|
||||
* php index.ci.php system/MigrateSalary/import filename
|
||||
*
|
||||
*/
|
||||
/*
|
||||
AUFBAU CSV:
|
||||
SVNR;Pers-Nr;Name;Dienstverhältnis;LA-Nr;Bezeichnung;2022-09-01;2022-10-01;2022-11-01;2022-12-01;2023-01-01;2023-02-01;2023-03-01
|
||||
XXXX XXXXXX;00;Name;5;1000;Gehalt;1.111,10;1.211,10;1.311,10;1.411,10;1.511,10;1.611,10;1.711,10
|
||||
*/
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class MigrateSalary extends CLI_Controller
|
||||
{
|
||||
private $OE_DEFAULT = 'gst';
|
||||
private $GEHALT_BEGINN_SPALTE = 6; // Beginnend mit 0 => G
|
||||
private $INDEX_LOHNART = 4;
|
||||
private $INDEX_BEZEICHNUNG = 5;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('vertragsbestandteil/Gehaltsbestandteil_model', 'GehaltsbestandteilModel');
|
||||
$this->load->model('vertragsbestandteil/Dienstverhaeltnis_model','DienstverhaeltnisModel');
|
||||
$this->load->model('vertragsbestandteil/Vertragsbestandteil_model','VertragsbestandteilModel');
|
||||
$this->load->model('vertragsbestandteil/VertragsbestandteilStunden_model','VertragsbestandteilStundenModel');
|
||||
$this->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model','VertragsbestandteilFreitextModel');
|
||||
$this->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model','VertragsbestandteilFunktionModel');
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Everything has a beginning
|
||||
*/
|
||||
public function import($file)
|
||||
{
|
||||
|
||||
// CSV Laden
|
||||
$file = urldecode($file);
|
||||
if($handle = fopen($file, "r"))
|
||||
{
|
||||
$csvrow = -1;
|
||||
$lastuser = '';
|
||||
$monate = array();
|
||||
$gehaltsarr = array();
|
||||
$gehaltsindex = 0;
|
||||
|
||||
while (($data = fgetcsv($handle, null, ';')) !== FALSE)
|
||||
{
|
||||
$csvrow++;
|
||||
// Kopfzeile ueberspringen
|
||||
if($csvrow == 0)
|
||||
{
|
||||
for($i = $this->GEHALT_BEGINN_SPALTE; $i < count($data); $i++)
|
||||
{
|
||||
$monate[] = $data[$i];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// User zur SVNR ermitteln
|
||||
$svnr = str_replace(' ', '',$data[0]);
|
||||
$resultuser = $this->_getUser($svnr);
|
||||
|
||||
if(!hasData($resultuser))
|
||||
{
|
||||
echo getError($resultuser);
|
||||
break;
|
||||
}
|
||||
|
||||
$user = getData($resultuser)[0]->mitarbeiter_uid;
|
||||
echo "\nUser:".$user;
|
||||
|
||||
if($user != $lastuser && $lastuser != '')
|
||||
{
|
||||
$this->_saveGehalt($lastuser, $gehaltsarr);
|
||||
$gehaltsarr = array();
|
||||
$gehaltsindex = 0;
|
||||
$lastuser = $user;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastuser = $user;
|
||||
}
|
||||
|
||||
// Gehalt Clustern
|
||||
|
||||
$monat = 0;
|
||||
for ($i = $this->GEHALT_BEGINN_SPALTE; $i < count($data); $i++)
|
||||
{
|
||||
if (count($gehaltsarr) == 0 && $data[$i] != '')
|
||||
{
|
||||
$gehaltsarr[$gehaltsindex]['betrag'] = $data[$i];
|
||||
$gehaltsarr[$gehaltsindex]['lohnart'] = $data[$this->INDEX_LOHNART];
|
||||
$gehaltsarr[$gehaltsindex]['bezeichnung'] = $data[$this->INDEX_BEZEICHNUNG];
|
||||
$gehaltsarr[$gehaltsindex]['beginn'] = $monate[$monat];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($data[$i] != ''
|
||||
&& isset($gehaltsarr[$gehaltsindex]) && isset($gehaltsarr[$gehaltsindex]['betrag'])
|
||||
&& $gehaltsarr[$gehaltsindex]['betrag'] == $data[$i])
|
||||
{
|
||||
// Gehalt bleibt gleich
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($data[$i] != '')
|
||||
{
|
||||
// Gehalt hat sich geändert
|
||||
if ($monat != 0 && isset($gehaltsarr[$gehaltsindex]))
|
||||
$gehaltsarr[$gehaltsindex]['ende'] = $monate[$monat-1];
|
||||
|
||||
$gehaltsindex++;
|
||||
|
||||
$gehaltsarr[$gehaltsindex]['betrag'] = $data[$i];
|
||||
$gehaltsarr[$gehaltsindex]['lohnart'] = $data[$this->INDEX_LOHNART];
|
||||
$gehaltsarr[$gehaltsindex]['bezeichnung'] = $data[$this->INDEX_BEZEICHNUNG];
|
||||
$gehaltsarr[$gehaltsindex]['beginn'] = $monate[$monat];
|
||||
}
|
||||
elseif(isset($gehaltsarr[$gehaltsindex]))
|
||||
{
|
||||
// Gehalt wurde beendet
|
||||
if($monat!=0)
|
||||
$gehaltsarr[$gehaltsindex]['ende'] = $monate[$monat-1];
|
||||
$gehaltsindex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$monat++;
|
||||
}
|
||||
|
||||
// Zeile zu Ende - Ende Datum setzen wenn nicht für alle Monate ein Eintrag vorhanden ist
|
||||
if($monat < count($monate) && isset($gehaltsarr[$gehaltsindex]))
|
||||
$gehaltsarr[$gehaltsindex]['ende'] == $monate[$monat-1];
|
||||
|
||||
}
|
||||
$this->_saveGehalt($lastuser, $gehaltsarr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt das passende Dienstverhaeltnis uns speichert den
|
||||
* Gehaltsbestandteil
|
||||
*/
|
||||
private function _saveGehalt($uid, $gehaltsarr)
|
||||
{
|
||||
$failed = false;
|
||||
$this->db->trans_begin();
|
||||
|
||||
foreach($gehaltsarr as $row_gehalt)
|
||||
{
|
||||
$auszahlungen = 14;
|
||||
$dvid = '';
|
||||
$vbsid = '';
|
||||
$typ = '';
|
||||
$allin = false;
|
||||
|
||||
//DV und VBS Ermitteln
|
||||
$dv = $this->DienstverhaeltnisModel->getDVByPersonUID($uid, $this->OE_DEFAULT, $row_gehalt['beginn']);
|
||||
|
||||
if (!hasData($dv))
|
||||
{
|
||||
$date = new DateTime($row_gehalt['beginn']);
|
||||
$date->modify('last day of this month');
|
||||
$last_day_this_month = $date->format('Y-m-d');
|
||||
|
||||
// Wenn mit Monatsersten kein DV gefunden wird, wird stattdessen mit Monatsletzten gesucht um DVs zu finden
|
||||
// für Personen die erst später im Monat in ihr DV einsteigen
|
||||
$dv = $this->DienstverhaeltnisModel->getDVByPersonUID($uid, $this->OE_DEFAULT, $last_day_this_month);
|
||||
|
||||
if (!hasData($dv))
|
||||
{
|
||||
echo "\nKein passendes DV gefunden für User ".$uid." und Datum ".$row_gehalt['beginn']." -> ROLLBACK\n";
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Gehaltsstart wird auf den Start des DV korrigiert wenn nicht der Monatserste
|
||||
$row_gehalt['beginn'] = getData($dv)[0]->von;
|
||||
}
|
||||
}
|
||||
|
||||
$resultdata = getData($dv);
|
||||
if (count($resultdata) !== 1)
|
||||
{
|
||||
echo "Kein oder Mehrere DVs gefunden -> ROLLBACK";
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$dvid = $resultdata[0]->dienstverhaeltnis_id;
|
||||
|
||||
$allin = $this->_isAllIn($dvid, $row_gehalt['beginn']);
|
||||
|
||||
$db = new DB_Model();
|
||||
|
||||
$resultVBS = $this->_getVBS($dvid, $row_gehalt['beginn']);
|
||||
|
||||
if (hasData($resultVBS))
|
||||
{
|
||||
$vbsid = getData($resultVBS)[0]->vertragsbestandteil_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Vertragsbestandteil wurde nicht gefunden -> ROLLBACK";
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($row_gehalt['lohnart'] == 1000)
|
||||
{
|
||||
if($allin)
|
||||
$typ = 'grundgehalt';
|
||||
else
|
||||
$typ = 'basisgehalt';
|
||||
}
|
||||
elseif ($row_gehalt['lohnart']==1041 // 14x
|
||||
|| $row_gehalt['lohnart']==1042 // 12x
|
||||
|| $row_gehalt['lohnart']==3410) // USTDPausch
|
||||
{
|
||||
$typ = 'zusatzvereinbarung';
|
||||
|
||||
// Freitextbestandteil anlegen fuer die Zulage
|
||||
// Gaehalt wird der Zuglage zugeordnet
|
||||
|
||||
$data = array(
|
||||
'dienstverhaeltnis_id' => $dvid,
|
||||
'von' => $row_gehalt['beginn'],
|
||||
'vertragsbestandteiltyp_kurzbz' => 'freitext',
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => 'MigrateSalary'
|
||||
);
|
||||
if (isset($row_gehalt['ende']) && $row_gehalt['ende']!='')
|
||||
$data['bis'] = $row_gehalt['ende'];
|
||||
|
||||
$resultVBS = $this->VertragsbestandteilModel->Insert($data);
|
||||
if(!isSuccess($resultVBS))
|
||||
{
|
||||
echo "VBS kann nicht erstellt werden -> ROLLBACK";
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
$vbsid = getData($resultVBS);
|
||||
|
||||
$data = array(
|
||||
'vertragsbestandteil_id' => $vbsid,
|
||||
'freitexttyp_kurzbz' => 'zusatzvereinbarung',
|
||||
'titel' => $row_gehalt['bezeichnung'],
|
||||
'anmerkung' => $row_gehalt['bezeichnung'],
|
||||
);
|
||||
$resultVBSFreitext = $this->VertragsbestandteilFreitextModel->Insert($data);
|
||||
if(!isSuccess($resultVBSFreitext))
|
||||
{
|
||||
echo "VBS Freitext Zusatz kann nicht erstellt werden -> ROLLBACK";
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif ($row_gehalt['lohnart']==9999) // All-In Custom Lohnart nicht per Default vorhanden
|
||||
{
|
||||
$typ = 'zulage';
|
||||
|
||||
// Freitextbestandteil anlegen fuer die Zulage
|
||||
// Gaehalt wird der Zuglage zugeordnet
|
||||
|
||||
$data = array(
|
||||
'dienstverhaeltnis_id' => $dvid,
|
||||
'von' => $row_gehalt['beginn'],
|
||||
'vertragsbestandteiltyp_kurzbz' => 'freitext',
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => 'MigrateSalary'
|
||||
);
|
||||
if (isset($row_gehalt['ende']) && $row_gehalt['ende']!='')
|
||||
$data['bis'] = $row_gehalt['ende'];
|
||||
|
||||
$resultVBS = $this->VertragsbestandteilModel->Insert($data);
|
||||
if(!isSuccess($resultVBS))
|
||||
{
|
||||
echo "VBS AllIn kann nicht erstellt werden -> ROLLBACK";
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
$vbsid = getData($resultVBS);
|
||||
|
||||
$data = array(
|
||||
'vertragsbestandteil_id' => $vbsid,
|
||||
'freitexttyp_kurzbz' => 'allin',
|
||||
'titel' => $row_gehalt['bezeichnung'],
|
||||
'anmerkung' => $row_gehalt['bezeichnung'],
|
||||
);
|
||||
$resultVBSFreitext = $this->VertragsbestandteilFreitextModel->Insert($data);
|
||||
if(!isSuccess($resultVBSFreitext))
|
||||
{
|
||||
echo "VBS Freitext AllIn Zusatz kann nicht erstellt werden -> ROLLBACK";
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif($row_gehalt['lohnart']==5500) // ATZ
|
||||
{
|
||||
$typ = 'lohnausgleichatz';
|
||||
}
|
||||
else
|
||||
{
|
||||
$typ = 'unbekannt - '.$row_gehalt['lohnart'];
|
||||
echo "\nGehaltstyp unbekannt Lohnart: ".$row_gehalt['lohnart']." -> ROLLBACK";
|
||||
$failed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Zulage 12x und Zulage 14x aus der Bezeichnung ermitteln
|
||||
if(strstr($row_gehalt['bezeichnung'], '12x'))
|
||||
{
|
||||
$auszahlungen = 12;
|
||||
}
|
||||
|
||||
// Format ist 7.777,77 und wird umformattiert in 7777.77
|
||||
$betrag = str_replace('.','', $row_gehalt['betrag']);
|
||||
$betrag = str_replace(',','.',$betrag);
|
||||
|
||||
$data = array(
|
||||
'dienstverhaeltnis_id' => $dvid,
|
||||
'vertragsbestandteil_id' => $vbsid,
|
||||
'gehaltstyp_kurzbz' => $typ,
|
||||
'von' => $row_gehalt['beginn'],
|
||||
'grundbetrag' => $betrag,
|
||||
'betrag_valorisiert' => $betrag,
|
||||
'anmerkung' => $row_gehalt['bezeichnung'],
|
||||
'valorisierung' => true,
|
||||
'auszahlungen' => $auszahlungen,
|
||||
'insertamum' => date('Y-m-d H:i:s'),
|
||||
'insertvon' => 'MigrateSalary',
|
||||
'updateamum' => date('Y-m-d H:i:s'),
|
||||
'updatevon' => 'MigrateSalary'
|
||||
);
|
||||
|
||||
if (isset($row_gehalt['ende']) && $row_gehalt['ende'] != '')
|
||||
{
|
||||
// Im Ende steht noch der Monatserste des letzten Monats
|
||||
// Das muss geaendert werden auf den Monatsletzten oder das Ende des DVs
|
||||
$date = new DateTime($row_gehalt['ende']);
|
||||
$date->modify('last day of this month');
|
||||
$last_day_this_month = $date->format('Y-m-d');
|
||||
|
||||
// TODO: wenn das Dienstverhaeltnis in diesem Monat endet und nicht der Monatsletzte ist,
|
||||
// dann muss hier das Ende Datum des DV stehen bzw das Ende
|
||||
// oder das Ende des VBS falls die Person in der Monatsmitte Stunden wechselt
|
||||
$data['bis'] = $last_day_this_month;
|
||||
}
|
||||
|
||||
$ret = $this->GehaltsbestandteilModel->insert($data,
|
||||
$this->GehaltsbestandteilModel->getEncryptedColumns()
|
||||
);
|
||||
}
|
||||
|
||||
if(!$failed)
|
||||
{
|
||||
$this->db->trans_commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ROLLBACK";
|
||||
$this->db->trans_rollback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob ein AllIn Vertrag vorhanden ist
|
||||
*/
|
||||
private function _isAllIn($dvid, $datum)
|
||||
{
|
||||
$db = new DB_Model();
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil
|
||||
JOIN hr.tbl_vertragsbestandteil_freitext USING(vertragsbestandteil_id)
|
||||
WHERE
|
||||
dienstverhaeltnis_id=".$db->escape($dvid)."
|
||||
AND vertragsbestandteiltyp_kurzbz='freitext'
|
||||
AND ".$db->escape($datum)." BETWEEN von AND COALESCE(bis, '2999-12-31')
|
||||
AND freitexttyp_kurzbz='allin'";
|
||||
|
||||
$resultAllIn = $db->execReadOnlyQuery($qry);
|
||||
|
||||
if (hasData($resultAllIn))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private function _getVBS($dvid, $datum)
|
||||
{
|
||||
$db = new DB_Model();
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil
|
||||
WHERE
|
||||
dienstverhaeltnis_id=".$db->escape($dvid)."
|
||||
AND vertragsbestandteiltyp_kurzbz='stunden'
|
||||
AND ".$db->escape($datum)." BETWEEN von AND COALESCE(bis, '2999-12-31')";
|
||||
|
||||
$resultVBS = $db->execReadOnlyQuery($qry);
|
||||
|
||||
return $resultVBS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt den User zu einer SVNR
|
||||
*/
|
||||
private function _getUser($svnr)
|
||||
{
|
||||
$db = new DB_Model();
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
mitarbeiter_uid
|
||||
FROM
|
||||
public.tbl_person
|
||||
JOIN public.tbl_benutzer using(person_id)
|
||||
JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid)
|
||||
WHERE
|
||||
tbl_person.svnr = ". $db->escape($svnr)."
|
||||
AND EXISTS(
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
hr.tbl_dienstverhaeltnis
|
||||
WHERE
|
||||
mitarbeiter_uid=tbl_mitarbeiter.mitarbeiter_uid
|
||||
AND oe_kurzbz=". $db->escape($this->OE_DEFAULT)."
|
||||
)
|
||||
ORDER BY tbl_benutzer.aktiv DESC
|
||||
LIMIT 1;
|
||||
";
|
||||
|
||||
$result = $db->execReadOnlyQuery($qry);
|
||||
|
||||
if (hasdata($result))
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
return error('Kein Benutzer mit DV und SVNR:'.$svnr.' gefunden');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Test VBform Vue Component
|
||||
*/
|
||||
class TestVBform extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'system/developer:r'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Everything has a beginning
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('system/logs/testVBform.php');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class CI3_Events
|
||||
{
|
||||
const PRIORITY_LOW = 200;
|
||||
const PRIORITY_NORMAL = 100;
|
||||
const PRIORITY_HIGH = 10;
|
||||
|
||||
private static $events = [];
|
||||
private static $eventsSorted = [];
|
||||
|
||||
public static function on($event, $function, $priority = self::PRIORITY_NORMAL)
|
||||
{
|
||||
if (!isset(self::$events[$event]))
|
||||
self::$events[$event] = [];
|
||||
|
||||
self::$events[$event][] = [$priority, $function];
|
||||
|
||||
if (!isset(self::$eventsSorted[$event]))
|
||||
self::$eventsSorted[$event] = true;
|
||||
else
|
||||
self::$eventsSorted[$event] = false;
|
||||
}
|
||||
|
||||
public static function trigger($event, ...$args)
|
||||
{
|
||||
if (!isset(self::$events[$event]))
|
||||
return;
|
||||
|
||||
if (!self::$eventsSorted[$event]) {
|
||||
usort(self::$events[$event], function ($a, $b) {
|
||||
return $a[0] - $b[0];
|
||||
});
|
||||
self::$eventsSorted[$event] = true;
|
||||
}
|
||||
|
||||
foreach (self::$events[$event] as $conf) {
|
||||
$conf[1](...$args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE(chris): Autoload Events config
|
||||
*/
|
||||
require_once(APPPATH.'config/Events.php');
|
||||
foreach (scandir(APPPATH.'config/extensions') as $dir)
|
||||
if ($dir[0] != '.' && file_exists(APPPATH.'config/extensions/'.$dir.'/Events.php'))
|
||||
require_once APPPATH.'config/extensions/'.$dir.'/Events.php';
|
||||
+297
-28
@@ -1,5 +1,24 @@
|
||||
<?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/>.
|
||||
*/
|
||||
|
||||
use \stdClass as stdClass;
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
@@ -27,6 +46,15 @@ class DB_Model extends CI_Model
|
||||
const PGSQL_INT8_TYPE = 'int8';
|
||||
const PGSQL_FLOAT4_TYPE = 'float4';
|
||||
const PGSQL_FLOAT8_TYPE = 'float8';
|
||||
const PGSQL_BYTEA_TYPE = 'bytea';
|
||||
|
||||
// Name of the config entry containing an array of password that can be used to encrypt/decrypt
|
||||
const CRYPT_CONF_PASSWORDS = 'encryption_passwords';
|
||||
const CRYPT_CAST = 'cast';
|
||||
const CRYPT_PASSWORD_NAME = 'passwordName';
|
||||
const CRYPT_SELECT_TEMPLATE = 'PGP_SYM_DECRYPT(%s, \'%s\')::%s AS %s';
|
||||
const CRYPT_WHERE_TEMPLATE = 'PGP_SYM_DECRYPT(%s, \'%s\')::%s';
|
||||
const CRYPT_WRITE_TEMPLATE = 'PGP_SYM_ENCRYPT(\'%s\', \'%s\')';
|
||||
|
||||
protected $dbTable; // Name of the DB-Table for CI-Insert, -Update, ...
|
||||
protected $pk; // Name of the PrimaryKey for DB-Update, Load, ...
|
||||
@@ -36,7 +64,7 @@ class DB_Model extends CI_Model
|
||||
private $executedQueryMetaData;
|
||||
private $executedQueryListFields;
|
||||
|
||||
private $debugMode;
|
||||
private $debugMode; // Debug mode enable (true) or disabled (false)
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -46,20 +74,23 @@ class DB_Model extends CI_Model
|
||||
// Call parent constructor
|
||||
parent::__construct();
|
||||
|
||||
// Set properties
|
||||
$this->hasSequence = true;
|
||||
|
||||
// Loads DB conns and confs
|
||||
// Loads DB connections and configs
|
||||
$this->load->database($dbtype);
|
||||
|
||||
// Loads the DB config to encrypt/decrypt data
|
||||
$this->config->load('db_crypt');
|
||||
|
||||
// Set properties
|
||||
$this->hasSequence = true;
|
||||
$this->debugMode = isset($this->db->db_debug) && $this->db->db_debug === true;
|
||||
|
||||
// Loads UDF model
|
||||
$this->load->model('system/UDF_model', 'UDFModel');
|
||||
|
||||
// Loads the UDF library
|
||||
$this->load->library('UDFLib');
|
||||
// Loads the logs library
|
||||
$this->load->library('LogLib');
|
||||
|
||||
$this->debugMode = isset($this->db->db_debug) && $this->db->db_debug === true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
@@ -85,13 +116,20 @@ class DB_Model extends CI_Model
|
||||
* @param array $data DataArray for Insert
|
||||
* @return array
|
||||
*/
|
||||
public function insert($data)
|
||||
public function insert($data, $encryptedColumns = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL);
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable))) return $validate;
|
||||
$validate = $this->_prepareUDFsWrite($data, $this->dbTable);
|
||||
if (isError($validate)) return $validate;
|
||||
|
||||
// Add the pgp_sym_eccrypt postgresql function to the set clause if needed
|
||||
$this->_addEncrypt($encryptedColumns, $data);
|
||||
|
||||
// Add the pgp_sym_eccrypt postgresql function to the set clause if needed
|
||||
if (!empty($encryptedColumns)) $this->_addEncrypt($encryptedColumns, $data);
|
||||
|
||||
// DB-INSERT
|
||||
$insert = $this->db->insert($this->dbTable, $data);
|
||||
@@ -135,14 +173,15 @@ class DB_Model extends CI_Model
|
||||
* @param array $data DataArray for Insert
|
||||
* @return array
|
||||
*/
|
||||
public function update($id, $data)
|
||||
public function update($id, $data, $encryptedColumns = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->pk)) return error('The given primary key is not valid', EXIT_MODEL);
|
||||
if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL);
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_prepareUDFsWrite($data, $this->dbTable, $id))) return $validate;
|
||||
$validate = $this->_prepareUDFsWrite($data, $this->dbTable, $id);
|
||||
if (isError($validate)) return $validate;
|
||||
|
||||
$tmpId = $id;
|
||||
|
||||
@@ -161,6 +200,9 @@ class DB_Model extends CI_Model
|
||||
|
||||
$this->db->where($tmpId);
|
||||
|
||||
// Add the pgp_sym_eccrypt postgresql function to the set clause if needed
|
||||
$this->_addEncrypt($encryptedColumns, $data);
|
||||
|
||||
// DB-UPDATE
|
||||
$update = $this->db->update($this->dbTable, $data);
|
||||
|
||||
@@ -224,7 +266,7 @@ class DB_Model extends CI_Model
|
||||
* @param string $id ID (Primary Key) for SELECT ... WHERE
|
||||
* @return array
|
||||
*/
|
||||
public function load($id = null)
|
||||
public function load($id = null, $encryptedColumns = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->pk)) return error('The given primary key is not valid', EXIT_MODEL);
|
||||
@@ -245,7 +287,7 @@ class DB_Model extends CI_Model
|
||||
$tmpId = array($this->pk => $id);
|
||||
}
|
||||
|
||||
return $this->loadWhere($tmpId);
|
||||
return $this->loadWhere($tmpId, $encryptedColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,11 +295,14 @@ class DB_Model extends CI_Model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function loadWhere($where = null)
|
||||
public function loadWhere($where = null, $encryptedColumns = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error('The given database table name is not valid', EXIT_MODEL);
|
||||
|
||||
// Add the pgp_sym_decrypt postgresql function to the select and where clause if needed
|
||||
$this->_addDecryptLoad($encryptedColumns, $where);
|
||||
|
||||
// Execute query
|
||||
$result = $this->db->get_where($this->dbTable, $where);
|
||||
|
||||
@@ -265,7 +310,7 @@ class DB_Model extends CI_Model
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return success($this->_toPhp($result));
|
||||
return success($this->_toPhp($result, $encryptedColumns));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -303,7 +348,8 @@ class DB_Model extends CI_Model
|
||||
// NOTE: $this->db->list_fields($tables[$t]) doesn't work if there are two tables with
|
||||
// the same name in two different schemas, use this workaround
|
||||
$fields = array();
|
||||
if (isSuccess($lstColumns = $this->_list_columns($schemaAndTable->schema, $schemaAndTable->table)))
|
||||
$lstColumns = $this->_list_columns($schemaAndTable->schema, $schemaAndTable->table);
|
||||
if (isSuccess($lstColumns))
|
||||
{
|
||||
$fields = $lstColumns->retval;
|
||||
}
|
||||
@@ -381,7 +427,8 @@ class DB_Model extends CI_Model
|
||||
$tmpFilteredArray = array_filter(get_object_vars($sideTableObj));
|
||||
if (isset($tmpFilteredArray) && count($tmpFilteredArray) > 0)
|
||||
{
|
||||
if (($k = $this->_findMainTable($mainTableObj, $returnArray)) === false)
|
||||
$k = $this->_findMainTable($mainTableObj, $returnArray);
|
||||
if ($k === false)
|
||||
{
|
||||
$mainTableObj->{$sideTableProperty} = array($sideTableObj);
|
||||
$returnArray[$returnArrayCounter++] = $mainTableObj;
|
||||
@@ -758,14 +805,13 @@ class DB_Model extends CI_Model
|
||||
/**
|
||||
* Like execQuery, but it allows only to perform queries to read data
|
||||
*/
|
||||
public function execReadOnlyQuery($query, $parametersArray = null)
|
||||
public function execReadOnlyQuery($query, $parametersArray = null, $encryptedColumns = null)
|
||||
{
|
||||
$result = error('You are allowed to run only query for reading data'); //
|
||||
$cleanedQuery = trim(preg_replace('/\t|\n|\r|;/', '', $query)); //
|
||||
|
||||
//
|
||||
if (
|
||||
(stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false)
|
||||
if ((stripos($cleanedQuery, 'INSERT') > 0 || stripos($cleanedQuery, 'INSERT') == false)
|
||||
&& (stripos($cleanedQuery, 'UPDATE') > 0 || stripos($cleanedQuery, 'UPDATE') == false)
|
||||
&& (stripos($cleanedQuery, 'CREATE') > 0 || stripos($cleanedQuery, 'CREATE') == false)
|
||||
&& (stripos($cleanedQuery, 'DELETE') > 0 || stripos($cleanedQuery, 'DELETE') == false)
|
||||
@@ -775,7 +821,7 @@ class DB_Model extends CI_Model
|
||||
{
|
||||
$queryToExec = str_replace(';', '', $query); //
|
||||
|
||||
$result = $this->execQuery($queryToExec, $parametersArray);
|
||||
$result = $this->execQuery($queryToExec, $parametersArray, $encryptedColumns);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -790,13 +836,16 @@ class DB_Model extends CI_Model
|
||||
* boolean if the query is of the write type (INSERT, UPDATE, DELETE...)
|
||||
* array that represents DB data
|
||||
*/
|
||||
protected function execQuery($query, $parametersArray = null)
|
||||
protected function execQuery($query, $parametersArray = null, $encryptedColumns = null)
|
||||
{
|
||||
$result = null;
|
||||
|
||||
// If the query is empty don't lose time
|
||||
if (!isEmptyString($query))
|
||||
{
|
||||
// Add the pgp_sym_decrypt postgresql function to the given query
|
||||
$this->_addDecryptQuery($encryptedColumns, $query);
|
||||
|
||||
// If there are parameters to bind to the query
|
||||
if (is_array($parametersArray) && count($parametersArray) > 0)
|
||||
{
|
||||
@@ -812,7 +861,7 @@ class DB_Model extends CI_Model
|
||||
// If no errors occurred
|
||||
if ($resultDB)
|
||||
{
|
||||
$result = success($this->_toPhp($resultDB));
|
||||
$result = success($this->_toPhp($resultDB, $encryptedColumns));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -840,7 +889,8 @@ class DB_Model extends CI_Model
|
||||
$result->schema = DB_Model::DEFAULT_SCHEMA;
|
||||
|
||||
// If a schema is specified
|
||||
if (($pos = strpos($schemaAndTable, '.')) !== false)
|
||||
$pos = strpos($schemaAndTable, '.');
|
||||
if ($pos !== false)
|
||||
{
|
||||
$result->schema = substr($schemaAndTable, 0, $pos);
|
||||
$result->table = substr($schemaAndTable, $pos + 1);
|
||||
@@ -851,6 +901,207 @@ class DB_Model extends CI_Model
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* To add the pgp_sym_encrypt function to the set clause where needed
|
||||
*/
|
||||
private function _addEncrypt($encryptedColumns, &$data)
|
||||
{
|
||||
// If encryptedColumns is not defined then exit
|
||||
if (isEmptyArray($encryptedColumns)) return;
|
||||
|
||||
$tmpData = array(); // Temporary array used to copy not encrypted columns
|
||||
|
||||
// For each column that is going to be inserted/updated
|
||||
foreach ($data as $column => $value)
|
||||
{
|
||||
// If the current column is in the list of the columns to be encrypted
|
||||
// and contains the password name element
|
||||
if (array_key_exists($column, $encryptedColumns)
|
||||
&& array_key_exists(self::CRYPT_PASSWORD_NAME, $encryptedColumns[$column]))
|
||||
{
|
||||
// Password to encrypt data
|
||||
$cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS);
|
||||
$encryptionPassword = $cryptConfPasswords[$encryptedColumns[$column][self::CRYPT_PASSWORD_NAME]];
|
||||
|
||||
// Add the encrypted column to the set clause without escaping
|
||||
$this->db->set(
|
||||
$column,
|
||||
sprintf(
|
||||
self::CRYPT_WRITE_TEMPLATE,
|
||||
$value,
|
||||
$encryptionPassword
|
||||
),
|
||||
false // no escaping
|
||||
);
|
||||
}
|
||||
else // otherwise copy this element as it is
|
||||
{
|
||||
$tmpData[$column] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$data = $tmpData; // this array does not contain encrypted columns
|
||||
}
|
||||
|
||||
/**
|
||||
* To add the pgp_sym_decrypt function to the given query
|
||||
*/
|
||||
private function _addDecryptQuery($encryptedColumns, &$query)
|
||||
{
|
||||
// If it is request to get encrypted columns
|
||||
if (!isEmptyArray($encryptedColumns))
|
||||
{
|
||||
// For each requested encrypted column
|
||||
foreach ($encryptedColumns as $encryptedColumn => $definition)
|
||||
{
|
||||
// If the requested encrypted column is well defined
|
||||
if (!isEmptyArray($definition)
|
||||
&& array_key_exists(self::CRYPT_CAST, $definition)
|
||||
&& array_key_exists(self::CRYPT_PASSWORD_NAME, $definition))
|
||||
{
|
||||
// And if exists the wanted password to decrypt in the configs
|
||||
if (array_key_exists($definition[self::CRYPT_PASSWORD_NAME], $this->config->item(self::CRYPT_CONF_PASSWORDS)))
|
||||
{
|
||||
// Password to decrypt data
|
||||
$cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS);
|
||||
$decryptionPassword = $cryptConfPasswords[$definition[self::CRYPT_PASSWORD_NAME]];
|
||||
|
||||
// Find and replace all the occurrences of the provided encrypted columns
|
||||
// with the postgresql decryption function
|
||||
$query = str_replace(
|
||||
$encryptedColumn,
|
||||
sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$encryptedColumn,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
),
|
||||
$query
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To add the pgp_sym_decrypt function to the select and where clause where needed
|
||||
*/
|
||||
private function _addDecryptLoad($encryptedColumns, &$where)
|
||||
{
|
||||
// If it is request to get encrypted columns
|
||||
if (!isEmptyArray($encryptedColumns))
|
||||
{
|
||||
// For each requested encrypted column
|
||||
foreach ($encryptedColumns as $encryptedColumn => $definition)
|
||||
{
|
||||
// If the requested encrypted column is well defined
|
||||
if (!isEmptyArray($definition)
|
||||
&& array_key_exists(self::CRYPT_CAST, $definition)
|
||||
&& array_key_exists(self::CRYPT_PASSWORD_NAME, $definition))
|
||||
{
|
||||
// And if exists the wanted password to decrypt in the configs
|
||||
if (array_key_exists($definition[self::CRYPT_PASSWORD_NAME], $this->config->item(self::CRYPT_CONF_PASSWORDS)))
|
||||
{
|
||||
// Password to decrypt data
|
||||
$cryptConfPasswords = $this->config->item(self::CRYPT_CONF_PASSWORDS);
|
||||
$decryptionPassword = $cryptConfPasswords[$definition[self::CRYPT_PASSWORD_NAME]];
|
||||
|
||||
// -----------------------------------------
|
||||
// SELECT
|
||||
|
||||
// Add to the select clause the column to be decrypted
|
||||
// NOTE: this is going to override any previously added column with the same name
|
||||
$this->addSelect(
|
||||
sprintf(
|
||||
self::CRYPT_SELECT_TEMPLATE,
|
||||
$encryptedColumn,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST],
|
||||
$encryptedColumn
|
||||
)
|
||||
);
|
||||
|
||||
// -----------------------------------------
|
||||
// WHERE
|
||||
|
||||
// If the where parameter is a valid array
|
||||
if (!isEmptyArray($where))
|
||||
{
|
||||
$tmpWhere = array();
|
||||
|
||||
// For each condition of the where clause
|
||||
foreach ($where as $column => $condition)
|
||||
{
|
||||
$operator = null; // operator not found in the column name
|
||||
|
||||
// Custom operators with 2 chars
|
||||
if (strpos($column, '>=') != false
|
||||
|| strpos($column, '<=') != false
|
||||
|| strpos($column, '!=') != false
|
||||
|| strpos($column, '<>') != false
|
||||
)
|
||||
{
|
||||
$operator = ' '.substr(trim($column), -2).' ';
|
||||
}
|
||||
// Custom operators with 1 chars
|
||||
elseif (strpos($column, '>') != false
|
||||
|| strpos($column, '<') != false
|
||||
|| strpos($column, '=') != false
|
||||
)
|
||||
{
|
||||
$operator = ' '.substr(trim($column), -1).' ';
|
||||
}
|
||||
else // default operator
|
||||
{
|
||||
$operator = ' = ';
|
||||
}
|
||||
|
||||
// If the column from the where clause is the same from the encrypted columns definition
|
||||
if (trim($column) == $encryptedColumn
|
||||
|| ($operator != null && substr(trim($column), 0, strlen(trim($column)) - 2) == $encryptedColumn)
|
||||
)
|
||||
{
|
||||
// Then rename the column using the postgresql decryption function
|
||||
$tmpWhere[sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$encryptedColumn,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
).$operator] = $condition;
|
||||
}
|
||||
else // otherwise copy the column as it is
|
||||
{
|
||||
$tmpWhere[$column] = $condition;
|
||||
}
|
||||
}
|
||||
|
||||
$where = $tmpWhere; // replace with the new where
|
||||
}
|
||||
// Otherwise if the where parameter is a valid string
|
||||
elseif (!isEmptyString($where))
|
||||
{
|
||||
// Find and replace all the occurrences of the provided encrypted columns
|
||||
// with the postgresql decryption function
|
||||
$where = str_replace(
|
||||
$encryptedColumn,
|
||||
sprintf(
|
||||
self::CRYPT_WHERE_TEMPLATE,
|
||||
$encryptedColumn,
|
||||
$decryptionPassword,
|
||||
$definition[self::CRYPT_CAST]
|
||||
),
|
||||
$where
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalid ID
|
||||
@@ -877,11 +1128,11 @@ class DB_Model extends CI_Model
|
||||
{
|
||||
if ($id != null)
|
||||
{
|
||||
$prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable, $this->_getUDFsNoPerms($id));
|
||||
$prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $schemaAndTable, $this->_getUDFsNoPerms($id));
|
||||
}
|
||||
else
|
||||
{
|
||||
$prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $this->dbTable);
|
||||
$prepareUDFsWrite = $this->udflib->prepareUDFsWrite($data, $schemaAndTable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,7 +1146,7 @@ class DB_Model extends CI_Model
|
||||
* - A FALSE value on failure
|
||||
* - Otherwise an object filled with data on success
|
||||
*/
|
||||
private function _toPhp($result)
|
||||
private function _toPhp($result, $encryptedColumns = null)
|
||||
{
|
||||
$udfs = false; // if UDFs are inside the given result set
|
||||
$toPhp = $result; // if there is nothing to convert then return the result from DB
|
||||
@@ -911,7 +1162,9 @@ class DB_Model extends CI_Model
|
||||
// Looking for booleans, arrays and UDFs
|
||||
foreach ($this->executedQueryMetaData as $eqmd)
|
||||
{
|
||||
// If array type, boolean type OR a UDF
|
||||
// If array type, boolean type, numeric type
|
||||
// Or bytea type
|
||||
// Or UDF type
|
||||
if (strpos($eqmd->type, DB_Model::PGSQL_ARRAY_TYPE) !== false
|
||||
|| $eqmd->type == DB_Model::PGSQL_BOOLEAN_TYPE
|
||||
|| $eqmd->type == DB_Model::PGSQL_INT2_TYPE
|
||||
@@ -919,6 +1172,7 @@ class DB_Model extends CI_Model
|
||||
|| $eqmd->type == DB_Model::PGSQL_INT8_TYPE
|
||||
|| $eqmd->type == DB_Model::PGSQL_FLOAT4_TYPE
|
||||
|| $eqmd->type == DB_Model::PGSQL_FLOAT8_TYPE
|
||||
|| $eqmd->type == DB_Model::PGSQL_BYTEA_TYPE
|
||||
|| $this->udflib->isUDFColumn($eqmd->name, $eqmd->type))
|
||||
{
|
||||
// If UDFs are inside this result set
|
||||
@@ -981,6 +1235,21 @@ class DB_Model extends CI_Model
|
||||
{
|
||||
$resultElement->{$toBeConverted->name} = $this->pgFloatPhp($resultElement->{$toBeConverted->name});
|
||||
}
|
||||
// Byte A type
|
||||
elseif ($toBeConverted->type == DB_Model::PGSQL_BYTEA_TYPE)
|
||||
{
|
||||
// If encrypted columns are defined
|
||||
// and if the byte a column is defined as encrypted column
|
||||
if (!isEmptyArray($encryptedColumns)
|
||||
&& array_key_exists($toBeConverted->name, $encryptedColumns))
|
||||
{
|
||||
// keep the column
|
||||
}
|
||||
else // otherwise remove the column from the result
|
||||
{
|
||||
unset($resultElement->{$toBeConverted->name});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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/>.
|
||||
*/
|
||||
|
||||
interface IEncryption
|
||||
{
|
||||
public function getEncryptedColumns(): array;
|
||||
}
|
||||
|
||||
@@ -356,7 +356,8 @@ function sanitizeProblemChars($str)
|
||||
'ss' => '/ß/'
|
||||
);
|
||||
|
||||
return preg_replace($acentos, array_keys($acentos), htmlentities($str, ENT_NOQUOTES | ENT_HTML5, $enc));
|
||||
$tmp = preg_replace($acentos, array_keys($acentos), htmlentities($str, ENT_NOQUOTES | ENT_HTML5, $enc));
|
||||
return html_entity_decode($tmp, ENT_NOQUOTES | ENT_HTML5, $enc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,7 +96,8 @@ function generateJSDataStorageObject($indexPage, $calledPath, $calledMethod)
|
||||
app_root: "'.APP_ROOT.'",
|
||||
ci_router: "'.$indexPage.'",
|
||||
called_path: "'.$calledPath.'",
|
||||
called_method: "'.$calledMethod.'"
|
||||
called_method: "'.$calledMethod.'",
|
||||
user_language: "'.$user_language.'"
|
||||
};';
|
||||
$toPrint .= "\n";
|
||||
$toPrint .= '</script>';
|
||||
|
||||
@@ -1249,7 +1249,7 @@ class AntragLib
|
||||
$result = current(getData($result));
|
||||
$datumStatus = $result->datum;
|
||||
|
||||
if (!in_array($result->status_kurzbz, $this->_ci->config->item('antrag_prestudentstatus_whitelist'))) {
|
||||
if (!in_array($result->status_kurzbz, $this->_ci->config->item('antrag_prestudentstatus_whitelist_abmeldung'))) {
|
||||
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere([
|
||||
'prestudent_id' => $prestudent_id,
|
||||
'campus.get_status_studierendenantrag(studierendenantrag_id)' => Studierendenantragstatus_model::STATUS_APPROVED
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 && !($this->vertragsart_kurzbz === 'werkvertrag')
|
||||
&& $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,452 @@
|
||||
<?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 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->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 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()
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ class Pruefung_model extends DB_Model
|
||||
$this->db->where('ps.prestudent_id', $prestudent_id);
|
||||
|
||||
if ($max_date !== null) {
|
||||
$this->db->where('p.datum <', $max_date);
|
||||
$this->db->where('p.datum <=', $max_date);
|
||||
}
|
||||
if ($studiensemester_kurzbz !== null) {
|
||||
$this->db->where('le.studiensemester_kurzbz', $studiensemester_kurzbz);
|
||||
|
||||
@@ -54,7 +54,7 @@ class Studierendenantrag_model extends DB_Model
|
||||
$this->addJoin('public.tbl_person', 'person_id');
|
||||
$this->addJoin('public.tbl_studiengang stg', 'p.studiengang_kz=stg.studiengang_kz');
|
||||
$this->addJoin('public.tbl_studiensemester ss', 'studiensemester_kurzbz');
|
||||
$this->addJoin('public.tbl_prestudentstatus ps', 'ps.prestudent_id=p.prestudent_id AND ps.studiensemester_kurzbz=ss.studiensemester_kurzbz AND ps.status_kurzbz=get_rolle_prestudent(p.prestudent_id, ss.studiensemester_kurzbz)');
|
||||
$this->addJoin('public.tbl_prestudentstatus ps', 'ps.prestudent_id=p.prestudent_id AND ps.studiensemester_kurzbz=ss.studiensemester_kurzbz AND ps.status_kurzbz=get_rolle_prestudent(p.prestudent_id, ss.studiensemester_kurzbz)', 'LEFT');
|
||||
$this->addJoin('lehre.tbl_studienplan plan', 'studienplan_id', 'LEFT');
|
||||
$this->addJoin('bis.tbl_orgform of', 'of.orgform_kurzbz=COALESCE(plan.orgform_kurzbz, ps.orgform_kurzbz, stg.orgform_kurzbz)');
|
||||
$this->addJoin(
|
||||
@@ -74,7 +74,8 @@ class Studierendenantrag_model extends DB_Model
|
||||
return $this->loadWhere($where);
|
||||
}
|
||||
|
||||
public function loadActiveForStudiengaenge($studiengaenge) {
|
||||
public function loadActiveForStudiengaenge($studiengaenge)
|
||||
{
|
||||
// NOTE(chris): get language before changing things in the global db object because getUserLanguage() might use it and it should not have been tampered with
|
||||
$sql = "SELECT index FROM public.tbl_sprache WHERE sprache='" . getUserLanguage() . "' LIMIT 1";
|
||||
|
||||
@@ -83,7 +84,8 @@ class Studierendenantrag_model extends DB_Model
|
||||
Studierendenantragstatus_model::STATUS_CANCELLED,
|
||||
Studierendenantragstatus_model::STATUS_APPROVED,
|
||||
Studierendenantragstatus_model::STATUS_REJECTED,
|
||||
Studierendenantragstatus_model::STATUS_OBJECTION_DENIED
|
||||
Studierendenantragstatus_model::STATUS_OBJECTION_DENIED,
|
||||
Studierendenantragstatus_model::STATUS_DEREGISTERED
|
||||
]);
|
||||
$this->db->or_group_start();
|
||||
$this->db->where('s.studierendenantrag_statustyp_kurzbz', Studierendenantragstatus_model::STATUS_APPROVED);
|
||||
@@ -94,6 +96,22 @@ class Studierendenantrag_model extends DB_Model
|
||||
return $this->loadForStudiengaenge($studiengaenge, null, null, $sql);
|
||||
}
|
||||
|
||||
public function loadStgsWithAntraege($studiengaenge)
|
||||
{
|
||||
$this->addDistinct();
|
||||
$this->addSelect('UPPER(stg.typ) || UPPER(stg.kurzbz) || \' \' || stg.bezeichnung AS bezeichnung');
|
||||
$this->addSelect('p.studiengang_kz');
|
||||
|
||||
$this->addJoin('public.tbl_prestudent p', 'prestudent_id');
|
||||
$this->addJoin('public.tbl_studiengang stg', 'p.studiengang_kz=stg.studiengang_kz');
|
||||
|
||||
$this->addOrder('UPPER(stg.typ) || UPPER(stg.kurzbz) || \' \' || stg.bezeichnung');
|
||||
|
||||
$this->db->where_in('p.studiengang_kz', $studiengaenge);
|
||||
|
||||
return $this->load();
|
||||
}
|
||||
|
||||
public function isInStudiengang($studierendenantrag_id, $studiengaenge)
|
||||
{
|
||||
$this->addJoin('public.tbl_prestudent', 'prestudent_id');
|
||||
|
||||
@@ -14,6 +14,7 @@ class Studierendenantragstatus_model extends DB_Model
|
||||
const STATUS_REQUESTSENT_2 = 'ZweiteAufforderungVersandt';
|
||||
const STATUS_OBJECTED = 'Beeinsprucht';
|
||||
const STATUS_OBJECTION_DENIED = 'EinspruchAbgelehnt';
|
||||
const STATUS_DEREGISTERED = 'Abgemeldet';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@@ -180,4 +180,60 @@ class Benutzerfunktion_model extends DB_Model
|
||||
|
||||
return $this->execQuery($query, $parameters_array);
|
||||
}
|
||||
|
||||
|
||||
public function insertBenutzerfunktion($Json)
|
||||
{
|
||||
unset($Json['benutzerfunktion_id']);
|
||||
unset($Json['updateamum']);
|
||||
$Json['insertvon'] = getAuthUID();
|
||||
$Json['insertamum'] = $this->escape('NOW()');
|
||||
|
||||
if ($Json['datum_bis']=='')
|
||||
{
|
||||
unset($Json['datum_bis']);
|
||||
}
|
||||
|
||||
$result = $this->insert($Json);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
|
||||
$record = $this->load($result->retval);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
function updateBenutzerfunktion($funktionJson)
|
||||
{
|
||||
$funktionJson['updatevon'] = getAuthUID();
|
||||
$funktionJson['updateamum'] = $this->escape('NOW()');
|
||||
|
||||
$result = $this->update($funktionJson['benutzerfunktion_id'], $funktionJson);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
|
||||
$result = $this->load($funktionJson['benutzerfunktion_id']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function deleteBenutzerfunktion($funktionJson)
|
||||
{
|
||||
$result = $this->delete($funktionJson);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
|
||||
return success($funktionJson);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
class Person_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
@@ -8,6 +25,7 @@ class Person_model extends DB_Model
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dbTable = 'public.tbl_person';
|
||||
$this->pk = 'person_id';
|
||||
|
||||
@@ -70,7 +88,7 @@ class Person_model extends DB_Model
|
||||
if (isset($person['svnr']) && $person['svnr'] != '')
|
||||
{
|
||||
$this->PersonModel->addOrder('svnr', 'DESC');
|
||||
$result = $this->PersonModel->loadWhere(array(
|
||||
$result = $this->PersonModel->loadWhere(array(
|
||||
'person_id != ' => $person['person_id'],
|
||||
'SUBSTRING(svnr FROM 1 FOR 10) = ' => $person['svnr'])
|
||||
);
|
||||
@@ -138,7 +156,8 @@ class Person_model extends DB_Model
|
||||
'lower(nachname) like '.$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(vorname) like ".$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(nachname || ' ' || vorname) like ".$this->db->escape('%'.$filter.'%')."
|
||||
OR lower(vorname || ' ' || nachname) like ".$this->db->escape('%'.$filter.'%'));
|
||||
OR lower(vorname || ' ' || nachname) like ".$this->db->escape('%'.$filter.'%')
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -152,8 +171,12 @@ class Person_model extends DB_Model
|
||||
*/
|
||||
public function getPersonStammdaten($person_id, $zustellung_only = false)
|
||||
{
|
||||
$this->addSelect('public.tbl_person.*, tbl_person.staatsbuergerschaft AS staatsbuergerschaft_code, tbl_person.geburtsnation AS geburtsnation_code,
|
||||
s.kurztext as staatsbuergerschaft, g.kurztext as geburtsnation');
|
||||
$this->addSelect('public.tbl_person.*,
|
||||
tbl_person.staatsbuergerschaft AS staatsbuergerschaft_code,
|
||||
tbl_person.geburtsnation AS geburtsnation_code,
|
||||
s.kurztext as staatsbuergerschaft,
|
||||
g.kurztext as geburtsnation'
|
||||
);
|
||||
$this->addJoin('bis.tbl_nation s', 'public.tbl_person.staatsbuergerschaft = s.nation_code', 'LEFT');
|
||||
$this->addJoin('bis.tbl_nation g', 'public.tbl_person.geburtsnation = g.nation_code', 'LEFT');
|
||||
|
||||
@@ -258,7 +281,8 @@ class Person_model extends DB_Model
|
||||
*/
|
||||
public function getFullName($uid)
|
||||
{
|
||||
if (!$result = getData($this->getByUid($uid))[0])
|
||||
$result = getData($this->getByUid($uid))[0];
|
||||
if (!$result)
|
||||
{
|
||||
show_error('Failed loading person');
|
||||
}
|
||||
@@ -351,3 +375,4 @@ class Person_model extends DB_Model
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,10 +144,15 @@ class Mitarbeiter_model extends DB_Model
|
||||
* Checks if alias exists
|
||||
* @param $kurzbz
|
||||
*/
|
||||
public function kurzbzExists($kurzbz)
|
||||
public function kurzbzExists($kurzbz, $uid=null)
|
||||
{
|
||||
$this->addSelect('1');
|
||||
$result = $this->loadWhere(array('kurzbz' => $kurzbz));
|
||||
$where = array('kurzbz' => $kurzbz);
|
||||
if ($uid != null)
|
||||
{
|
||||
$where['mitarbeiter_uid<>'] = $uid;
|
||||
}
|
||||
$result = $this->loadWhere($where);
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
@@ -171,7 +176,6 @@ class Mitarbeiter_model extends DB_Model
|
||||
*/
|
||||
public function generateKurzbz($uid)
|
||||
{
|
||||
$kurzbz = '';
|
||||
$this->addLimit(1);
|
||||
$this->addSelect('vorname, nachname');
|
||||
$this->addJoin('public.tbl_benutzer', 'tbl_mitarbeiter.mitarbeiter_uid = tbl_benutzer.uid');
|
||||
@@ -181,25 +185,35 @@ class Mitarbeiter_model extends DB_Model
|
||||
if (hasData($nameresult))
|
||||
{
|
||||
$kurzbzdata = getData($nameresult);
|
||||
$nachname_clean = sanitizeProblemChars($kurzbzdata[0]->nachname);
|
||||
$vorname_clean = sanitizeProblemChars($kurzbzdata[0]->vorname);
|
||||
$genKurzbz = $this->generateKurzbzHelper($kurzbzdata[0]->vorname, $kurzbzdata[0]->nachname);
|
||||
|
||||
for ($nn = 6, $vn = 2; $nn != 0; $nn--, $vn++)
|
||||
{
|
||||
$kurzbz = mb_substr($nachname_clean, 0, $nn);
|
||||
$kurzbz .= mb_substr($vorname_clean, 0, $vn);
|
||||
return $genKurzbz;
|
||||
}
|
||||
return error('No Kurzbezeichnung could be generated');
|
||||
}
|
||||
|
||||
$kurzbzexists = $this->kurzbzExists($kurzbz);
|
||||
public function generateKurzbzHelper($vorname, $nachname)
|
||||
{
|
||||
$nachname_clean = sanitizeProblemChars($nachname);
|
||||
$vorname_clean = sanitizeProblemChars($vorname);
|
||||
$kurzbz = '';
|
||||
|
||||
if (hasData($kurzbzexists) && !getData($kurzbzexists)[0])
|
||||
break;
|
||||
}
|
||||
for ($nn = 6, $vn = 2; $nn != 0; $nn--, $vn++)
|
||||
{
|
||||
$kurzbz = mb_substr($nachname_clean, 0, $nn);
|
||||
$kurzbz .= mb_substr($vorname_clean, 0, $vn);
|
||||
|
||||
$kurzbzexists = $this->kurzbzExists($kurzbz);
|
||||
|
||||
if (hasData($kurzbzexists) && getData($kurzbzexists)[0])
|
||||
return error('No Kurzbezeichnung could be generated');
|
||||
if (hasData($kurzbzexists) && !getData($kurzbzexists)[0])
|
||||
break;
|
||||
}
|
||||
|
||||
$kurzbzexists = $this->kurzbzExists($kurzbz);
|
||||
|
||||
if (hasData($kurzbzexists) && getData($kurzbzexists)[0])
|
||||
return error('No Kurzbezeichnung could be generated');
|
||||
|
||||
return success($kurzbz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class Stundensatz_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_stundensatz';
|
||||
$this->pk = 'stundensatz_id';
|
||||
$this->hasSequence = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Stundensatztyp_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_stundensatztyp';
|
||||
$this->pk = 'stundensatztyp';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
class PersonLog_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
@@ -17,7 +34,7 @@ class PersonLog_model extends DB_Model
|
||||
* @param array $data Data of Log Entry to save.
|
||||
* @return success object if true
|
||||
*/
|
||||
public function insert($data)
|
||||
public function insert($data, $encryptedColumns = null)
|
||||
{
|
||||
$result = $this->db->insert($this->dbTable, $data);
|
||||
if ($result)
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
class Dienstverhaeltnis_model extends DB_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_dienstverhaeltnis';
|
||||
$this->pk = 'dienstverhaeltnis_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of DV
|
||||
*/
|
||||
public function getDVByPersonUID($uid, $oe_kurzbz=null, $datum=null)
|
||||
{
|
||||
$result = null;
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
dv.dienstverhaeltnis_id,
|
||||
tbl_benutzer.uid,
|
||||
tbl_mitarbeiter.personalnummer,
|
||||
tbl_mitarbeiter.kurzbz,
|
||||
tbl_mitarbeiter.lektor,
|
||||
tbl_mitarbeiter.fixangestellt,
|
||||
tbl_person.person_id,
|
||||
tbl_benutzer.alias,
|
||||
org.oe_kurzbz,
|
||||
org.bezeichnung oe_bezeichnung,
|
||||
dv.von,
|
||||
dv.bis,
|
||||
dv.vertragsart_kurzbz,
|
||||
dv.updateamum,
|
||||
dv.updatevon
|
||||
FROM tbl_mitarbeiter
|
||||
JOIN tbl_benutzer ON tbl_mitarbeiter.mitarbeiter_uid::text = tbl_benutzer.uid::text
|
||||
JOIN tbl_person USING (person_id)
|
||||
JOIN hr.tbl_dienstverhaeltnis dv ON(tbl_benutzer.uid::text = dv.mitarbeiter_uid::text)
|
||||
JOIN public.tbl_organisationseinheit org USING(oe_kurzbz)
|
||||
WHERE tbl_benutzer.uid=?";
|
||||
$data = array($uid);
|
||||
|
||||
if(!is_null($oe_kurzbz))
|
||||
{
|
||||
$qry.=" AND oe_kurzbz=?";
|
||||
$data[] = $oe_kurzbz;
|
||||
}
|
||||
|
||||
if (!is_null($datum))
|
||||
{
|
||||
$qry.=" AND ? BETWEEN dv.von AND COALESCE(dv.bis, '2999-12-31')";
|
||||
$data[] = $datum;
|
||||
}
|
||||
|
||||
$qry .="
|
||||
ORDER BY dv.von desc
|
||||
";
|
||||
|
||||
return $this->execQuery($qry, $data);
|
||||
|
||||
}
|
||||
|
||||
public function getDVByID($dvid) {
|
||||
$this->addSelect('hr.tbl_dienstverhaeltnis.*, public.tbl_organisationseinheit.bezeichnung as unternehmen');
|
||||
$this->addJoin('public.tbl_organisationseinheit', 'hr.tbl_dienstverhaeltnis.oe_kurzbz = public.tbl_organisationseinheit.oe_kurzbz');
|
||||
$result = $this->load($dvid);
|
||||
|
||||
if (hasData($result)) {
|
||||
return $result;
|
||||
}
|
||||
return error('could not fetch DV by ID');
|
||||
}
|
||||
|
||||
|
||||
public function getCurrentDVByPersonUID($uid, $dateAsUnixTS)
|
||||
{
|
||||
|
||||
$date = DateTime::createFromFormat( 'U', $dateAsUnixTS );
|
||||
$datestring = $date->format("Y-m-d");
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
dv.dienstverhaeltnis_id,
|
||||
tbl_benutzer.uid,
|
||||
tbl_mitarbeiter.personalnummer,
|
||||
tbl_mitarbeiter.kurzbz,
|
||||
tbl_mitarbeiter.lektor,
|
||||
tbl_mitarbeiter.fixangestellt,
|
||||
tbl_person.person_id,
|
||||
tbl_benutzer.alias,
|
||||
dv.von,
|
||||
dv.bis,
|
||||
dv.vertragsart_kurzbz,
|
||||
dv.updateamum,
|
||||
dv.updatevon
|
||||
FROM tbl_mitarbeiter
|
||||
JOIN tbl_benutzer ON tbl_mitarbeiter.mitarbeiter_uid::text = tbl_benutzer.uid::text
|
||||
JOIN tbl_person USING (person_id)
|
||||
JOIN hr.tbl_dienstverhaeltnis dv ON(tbl_benutzer.uid::text = dv.mitarbeiter_uid::text)
|
||||
WHERE tbl_benutzer.uid=? and (dv.von<=? and (dv.bis is null OR dv.bis>=?))
|
||||
ORDER BY dv.von desc
|
||||
";
|
||||
|
||||
return $this->execQuery($qry, array($uid, $datestring, $datestring));
|
||||
}
|
||||
|
||||
public function isOverlappingExistingDV($mitarbeiter_uid, $oe_kurzbz, $von, $bis, $dvid=null)
|
||||
{
|
||||
$params = array($mitarbeiter_uid, $oe_kurzbz, $von, $bis, $von, $bis);
|
||||
$dvidclause = '';
|
||||
if (intval($dvid) > 0)
|
||||
{
|
||||
$params = array_merge($params, array($dvid, $dvid));
|
||||
$dvidclause = <<<EODVIDC
|
||||
AND (
|
||||
SELECT
|
||||
COUNT(*) AS karenzen
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil vb
|
||||
WHERE
|
||||
vb.dienstverhaeltnis_id = ?
|
||||
AND
|
||||
vb.vertragsbestandteiltyp_kurzbz = 'karenz'
|
||||
AND
|
||||
dv.von::date >= COALESCE(vb.von, '1970-01-01'::date)
|
||||
AND
|
||||
COALESCE(dv.bis::date, '2170-12-31'::date) <= COALESCE(vb.bis, '2170-12-31')
|
||||
) = 0
|
||||
AND dv.dienstverhaeltnis_id != ?
|
||||
EODVIDC;
|
||||
|
||||
}
|
||||
|
||||
$query = <<<EOSQL
|
||||
SELECT
|
||||
count(*) AS dvcount
|
||||
FROM
|
||||
hr.tbl_dienstverhaeltnis dv
|
||||
WHERE
|
||||
dv.mitarbeiter_uid = ?
|
||||
AND
|
||||
dv.oe_kurzbz = ?
|
||||
AND
|
||||
dv.vertragsart_kurzbz != 'werkvertrag'
|
||||
AND
|
||||
?::date <= COALESCE(dv.bis, '2170-12-31'::date)
|
||||
AND
|
||||
COALESCE(?::date, '2170-12-31'::date) >= dv.von
|
||||
AND (
|
||||
SELECT
|
||||
COUNT(*) AS karenzen
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil vb
|
||||
WHERE
|
||||
vb.dienstverhaeltnis_id = dv.dienstverhaeltnis_id
|
||||
AND
|
||||
vb.vertragsbestandteiltyp_kurzbz = 'karenz'
|
||||
AND
|
||||
?::date >= COALESCE(vb.von, '1970-01-01'::date)
|
||||
AND
|
||||
COALESCE(?::date, '2170-12-31'::date) <= COALESCE(vb.bis, '2170-12-31')
|
||||
) = 0
|
||||
{$dvidclause}
|
||||
EOSQL;
|
||||
|
||||
$ret = $this->execReadOnlyQuery($query, $params);
|
||||
|
||||
if( ($dvcount = getData($ret)) && ($dvcount[0]->dvcount > 0) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/IEncryption.php';
|
||||
|
||||
use vertragsbestandteil\Gehaltsbestandteil;
|
||||
|
||||
class Gehaltsbestandteil_model extends DB_Model implements IEncryption
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_gehaltsbestandteil';
|
||||
$this->pk = 'gehaltsbestandteil_id';
|
||||
}
|
||||
|
||||
public function getEncryptedColumns(): array
|
||||
{
|
||||
return array(
|
||||
'grundbetrag' => array(
|
||||
DB_Model::CRYPT_CAST => 'numeric',
|
||||
DB_Model::CRYPT_PASSWORD_NAME => 'ENCRYPTIONKEYGEHALT'
|
||||
),
|
||||
'betrag_valorisiert' => array(
|
||||
DB_Model::CRYPT_CAST => 'numeric',
|
||||
DB_Model::CRYPT_PASSWORD_NAME => 'ENCRYPTIONKEYGEHALT'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getCurrentGBTByDV($dienstverhaeltnis_id, $dateAsUnixTS)
|
||||
{
|
||||
$date = DateTime::createFromFormat( 'U', $dateAsUnixTS );
|
||||
$datestring = $date->format("Y-m-d");
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
gehaltsbestandteil_id,
|
||||
gbt.von,
|
||||
gbt.bis,
|
||||
gbt.anmerkung,
|
||||
gbt.dienstverhaeltnis_id,
|
||||
gehaltstyp_kurzbz,
|
||||
valorisierungssperre,
|
||||
gbt.valorisierung,
|
||||
grundbetrag as grund_betrag_decrypted,
|
||||
betrag_valorisiert as betrag_val_decrypted,
|
||||
gt.bezeichnung as gehaltstyp_bezeichnung,
|
||||
vb.vertragsbestandteiltyp_kurzbz,
|
||||
bf.funktion_kurzbz,
|
||||
bf.oe_kurzbz,
|
||||
fkt.beschreibung as fkt_beschreibung,
|
||||
fb.bezeichnung as fb_bezeichnung,
|
||||
org.bezeichnung as org_bezeichnung,
|
||||
freitext.freitexttyp_kurzbz,
|
||||
freitext.titel as freitext_titel
|
||||
FROM hr.tbl_gehaltsbestandteil gbt LEFT JOIN hr.tbl_gehaltstyp gt using(gehaltstyp_kurzbz)
|
||||
LEFT JOIN hr.tbl_vertragsbestandteil vb using(vertragsbestandteil_id)
|
||||
LEFT JOIN hr.tbl_vertragsbestandteil_funktion vbf using(vertragsbestandteil_id)
|
||||
LEFT JOIN public.tbl_benutzerfunktion bf using(benutzerfunktion_id)
|
||||
LEFT JOIN public.tbl_funktion fkt using(funktion_kurzbz)
|
||||
LEFT JOIN public.tbl_fachbereich fb using(fachbereich_kurzbz)
|
||||
LEFT JOIN public.tbl_organisationseinheit org on (bf.oe_kurzbz=org.oe_kurzbz)
|
||||
LEFT JOIN hr.tbl_vertragsbestandteil_freitext freitext on(vb.vertragsbestandteil_id=freitext.vertragsbestandteil_id)
|
||||
WHERE gbt.dienstverhaeltnis_id=? AND
|
||||
(gbt.von<=? and (gbt.bis is null OR gbt.bis>=?))
|
||||
ORDER BY gt.sort
|
||||
";
|
||||
|
||||
return $this->execQuery($qry,
|
||||
array($dienstverhaeltnis_id, $datestring, $datestring),
|
||||
$this->getEncryptedColumns());
|
||||
}
|
||||
|
||||
public function getGBTChartDataByDV_old($dienstverhaeltnis_id)
|
||||
{
|
||||
|
||||
$qry = "
|
||||
WITH gbt as
|
||||
(select von,bis,grundbetrag as grund_betrag_decrypted from hr.tbl_gehaltsbestandteil where dienstverhaeltnis_id=?)
|
||||
select von,bis, (select sum(gbt.grund_betrag_decrypted) as sum_betrag
|
||||
from gbt where gbt.von<=gbtmeta.von and (gbt.bis is null or gbt.bis>=gbtmeta.von)
|
||||
) as summe from gbt as gbtmeta order by von,bis
|
||||
";
|
||||
|
||||
return $this->execQuery($qry,
|
||||
array($dienstverhaeltnis_id),
|
||||
$this->getEncryptedColumns());
|
||||
}
|
||||
|
||||
|
||||
public function getGehaltsbestandteile($dienstverhaeltnis_id, $stichtag=null, $includefuture=false)
|
||||
{
|
||||
$stichtagclause = '';
|
||||
if( !is_null($stichtag) )
|
||||
{
|
||||
$date = strftime('%Y-%m-%d', strtotime($stichtag));
|
||||
$stichtagclause = 'AND (' . $this->escape($date)
|
||||
. ' BETWEEN COALESCE(von, \'1970-01-01\'::date)'
|
||||
. ' AND COALESCE(bis, \'2170-01-01\'::date)';
|
||||
if( $includefuture )
|
||||
{
|
||||
$stichtagclause .= ' OR COALESCE(von, \'1970-01-01\'::date) > '
|
||||
. $this->escape($date);
|
||||
}
|
||||
$stichtagclause .= ')';
|
||||
}
|
||||
|
||||
$this->addSelect('*');
|
||||
$where = <<<EOSQL
|
||||
dienstverhaeltnis_id = {$this->escape($dienstverhaeltnis_id)}
|
||||
{$stichtagclause}
|
||||
EOSQL;
|
||||
|
||||
$query = $this->loadWhere(
|
||||
$where,
|
||||
$this->getEncryptedColumns()
|
||||
);
|
||||
|
||||
$gehaltsbestandteile = array();
|
||||
if( null !== ($rows = getData($query)) )
|
||||
{
|
||||
foreach( $rows as $row ) {
|
||||
$tmpgb = new Gehaltsbestandteil();
|
||||
$tmpgb->hydrateByStdClass($row, true);
|
||||
$gehaltsbestandteile[] = $tmpgb;
|
||||
}
|
||||
}
|
||||
|
||||
return $gehaltsbestandteile;
|
||||
}
|
||||
|
||||
|
||||
public function getGehaltsbestandteil($id)
|
||||
{
|
||||
$this->addSelect('*');
|
||||
$query = $this->load($id, $this->getEncryptedColumns());
|
||||
$gehaltsbestandteil = null;
|
||||
|
||||
if( null !== ($row = getData($query)) )
|
||||
{
|
||||
$gehaltsbestandteil = new Gehaltsbestandteil();
|
||||
$gehaltsbestandteil->hydrateByStdClass($row[0], true);
|
||||
}
|
||||
|
||||
return $gehaltsbestandteil;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
interface IEncryption {
|
||||
|
||||
public function getEncryptedColumns(): array;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
class VertragsbestandteilFreitext_model extends DB_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil_freitext';
|
||||
$this->pk = 'vertragsbestandteil_id';
|
||||
}
|
||||
|
||||
public function countOverlappingVBFreitextsOfSameType(vertragsbestandteil\VertragsbestandteilFreitext $vbft)
|
||||
{
|
||||
$notselfclause = (intval($vbft->getVertragsbestandteil_id()) > 0)
|
||||
? 'AND v.vertragsbestandteil_id <> ' . $this->escape($vbft->getVertragsbestandteil_id())
|
||||
: '';
|
||||
$sql = <<<EOSQL
|
||||
SELECT
|
||||
count(*) AS overlappingvbs
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil v
|
||||
JOIN
|
||||
hr.tbl_vertragsbestandteil_freitext vbft USING(vertragsbestandteil_id)
|
||||
WHERE
|
||||
v.dienstverhaeltnis_id = ?
|
||||
AND
|
||||
v.vertragsbestandteiltyp_kurzbz = ?
|
||||
AND
|
||||
vbft.freitexttyp_kurzbz = ?
|
||||
AND
|
||||
COALESCE(?::date, '2170-12-31'::date) >= COALESCE(v.von, '1970-01-01'::date)
|
||||
AND
|
||||
?::date <= COALESCE(v.bis, '2170-12-31')
|
||||
{$notselfclause}
|
||||
EOSQL;
|
||||
$ret = $this->execReadOnlyQuery($sql, array(
|
||||
$vbft->getDienstverhaeltnis_id(),
|
||||
$vbft->getVertragsbestandteiltyp_kurzbz(),
|
||||
$vbft->getFreitexttypKurzbz(),
|
||||
$vbft->getBis(),
|
||||
$vbft->getVon()
|
||||
));
|
||||
|
||||
if( null === ($vbcount = getData($ret)) ) {
|
||||
throw new Exception('failed to fetch overlappingvbs count');
|
||||
}
|
||||
|
||||
return $vbcount[0]->overlappingvbs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
class VertragsbestandteilFreitexttyp_model extends DB_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil_freitexttyp';
|
||||
$this->pk = 'freitexttyp_kurzbz';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Description of VertragsbestandteilFunktion_model
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilFunktion_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil_funktion';
|
||||
$this->pk = 'vertragsbestandteil_id';
|
||||
}
|
||||
|
||||
public function isBenutzerfunktionAlreadyAttachedToAnotherVB($benutzerfunktion_id, $vertragsbestandteil_id)
|
||||
{
|
||||
$where = array('benutzerfunktion_id' => $benutzerfunktion_id);
|
||||
if( intval($vertragsbestandteil_id) > 0 )
|
||||
{
|
||||
$where['vertragsbestandteil_id != '] = $vertragsbestandteil_id;
|
||||
}
|
||||
$this->addSelect('count(*) AS vbscount');
|
||||
$res = $this->loadWhere($where);
|
||||
if(isError($res))
|
||||
{
|
||||
throw new Exception('failed to check if benutzerfunktionid is already attached to another vertragsbestanteil');
|
||||
}
|
||||
$count = (getData($res))[0]->vbscount;
|
||||
return $count > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
class VertragsbestandteilKarenz_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil_karenz';
|
||||
$this->pk = 'vertragsbestandteil_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
class VertragsbestandteilKuendigungsfrist_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil_kuendigungsfrist';
|
||||
$this->pk = 'vertragsbestandteil_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Description of VertragsbestandteilStunden_model
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilStunden_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil_stunden';
|
||||
$this->pk = 'vertragsbestandteil_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
class VertragsbestandteilTyp_model extends DB_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteiltyp';
|
||||
$this->pk = 'vertragsbestandteiltyp_kurzbz';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
class VertragsbestandteilUrlaubsanspruch_model extends DB_Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil_urlaubsanspruch';
|
||||
$this->pk = 'vertragsbestandteil_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
class VertragsbestandteilZeitaufzeichnung_model extends DB_Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil_zeitaufzeichnung';
|
||||
$this->pk = 'vertragsbestandteil_id';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
/**
|
||||
* Description of Vertragsbestandteil_model
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class Vertragsbestandteil_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'hr.tbl_vertragsbestandteil';
|
||||
$this->pk = 'vertragsbestandteil_id';
|
||||
}
|
||||
|
||||
protected function getVertragsbestandteilSQL()
|
||||
{
|
||||
$sql = <<<EOSQL
|
||||
SELECT
|
||||
v.*,
|
||||
bf.funktion_kurzbz, bf.uid AS mitarbeiter_uid,
|
||||
funktion.beschreibung AS funktion_bezeichnung,
|
||||
oe.oe_kurzbz, oe.bezeichnung AS oe_bezeichnung, sap.oe_kurzbz_sap,
|
||||
oet.organisationseinheittyp_kurzbz AS oe_typ_kurzbz, oet.bezeichnung AS oe_typ_bezeichnung,
|
||||
ft.freitexttyp_kurzbz, ft.titel, ft.anmerkung,
|
||||
f.benutzerfunktion_id,
|
||||
k.karenztyp_kurzbz, k.geplanter_geburtstermin, k.tatsaechlicher_geburtstermin,
|
||||
kf.arbeitgeber_frist, kf.arbeitnehmer_frist,
|
||||
s.wochenstunden, s.teilzeittyp_kurzbz,
|
||||
u.tage,
|
||||
z.zeitaufzeichnung, z.azgrelevant, z.homeoffice
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil v
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_freitext ft USING(vertragsbestandteil_id)
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_funktion f USING(vertragsbestandteil_id)
|
||||
LEFT JOIN
|
||||
public.tbl_benutzerfunktion bf USING(benutzerfunktion_id)
|
||||
LEFT JOIN
|
||||
public.tbl_funktion funktion USING(funktion_kurzbz)
|
||||
LEFT JOIN
|
||||
public.tbl_organisationseinheit oe USING(oe_kurzbz)
|
||||
LEFT JOIN
|
||||
public.tbl_organisationseinheittyp oet USING(organisationseinheittyp_kurzbz)
|
||||
LEFT JOIN
|
||||
sync.tbl_sap_organisationsstruktur sap USING(oe_kurzbz)
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_karenz k USING(vertragsbestandteil_id)
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_kuendigungsfrist kf USING(vertragsbestandteil_id)
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_stunden s USING(vertragsbestandteil_id)
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_urlaubsanspruch u USING(vertragsbestandteil_id)
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_zeitaufzeichnung z USING(vertragsbestandteil_id)
|
||||
EOSQL;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function getVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null, $includefuture=false)
|
||||
{
|
||||
$stichtagclause = '';
|
||||
if( !is_null($stichtag) )
|
||||
{
|
||||
$date = strftime('%Y-%m-%d', strtotime($stichtag));
|
||||
$stichtagclause = 'AND (' . $this->escape($date)
|
||||
. ' BETWEEN COALESCE(v.von, \'1970-01-01\'::date)'
|
||||
. ' AND COALESCE(v.bis, \'2170-01-01\'::date)';
|
||||
if( $includefuture )
|
||||
{
|
||||
$stichtagclause .= ' OR COALESCE(v.von, \'1970-01-01\'::date) > '
|
||||
. $this->escape($date);
|
||||
}
|
||||
$stichtagclause .= ')';
|
||||
}
|
||||
|
||||
$sql = <<<EOSQL
|
||||
{$this->getVertragsbestandteilSQL()}
|
||||
WHERE
|
||||
v.dienstverhaeltnis_id = {$this->escape($dienstverhaeltnis_id)}
|
||||
{$stichtagclause}
|
||||
;
|
||||
EOSQL;
|
||||
|
||||
// echo $sql . "\n\n";
|
||||
$query = $this->execReadOnlyQuery($sql); // TODO add decryption
|
||||
$data = getData($query);
|
||||
|
||||
if ($data == null)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$vertragsbestandteile = array();
|
||||
foreach( $data as $row ) {
|
||||
try
|
||||
{
|
||||
$vertragsbestandteile[] = VertragsbestandteilFactory::getVertragsbestandteil($row, true);
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
echo $ex->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$dummy = json_encode($vertragsbestandteile);
|
||||
return $vertragsbestandteile;
|
||||
}
|
||||
|
||||
|
||||
public function getVertragsbestandteil($id)
|
||||
{
|
||||
|
||||
$sql = <<<EOSQL
|
||||
{$this->getVertragsbestandteilSQL()}
|
||||
WHERE
|
||||
v.vertragsbestandteil_id = {$this->escape($id)}
|
||||
;
|
||||
EOSQL;
|
||||
|
||||
$query = $this->execReadOnlyQuery($sql);
|
||||
|
||||
$vertragsbestandteil = null;
|
||||
|
||||
if( hasData($query) )
|
||||
{
|
||||
$data = getData($query)[0];
|
||||
try
|
||||
{
|
||||
$vertragsbestandteil = VertragsbestandteilFactory::getVertragsbestandteil($data, true); // TODO add decryption
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
echo $ex->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $vertragsbestandteil;
|
||||
|
||||
}
|
||||
|
||||
public function countOverlappingVBsOfSameType(vertragsbestandteil\Vertragsbestandteil $vb)
|
||||
{
|
||||
$notselfclause = (intval($vb->getVertragsbestandteil_id()) > 0)
|
||||
? 'AND v.vertragsbestandteil_id <> ' . $this->escape($vb->getVertragsbestandteil_id())
|
||||
: '';
|
||||
$sql = <<<EOSQL
|
||||
SELECT
|
||||
count(*) AS overlappingvbs
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil v
|
||||
WHERE
|
||||
v.dienstverhaeltnis_id = ?
|
||||
AND
|
||||
v.vertragsbestandteiltyp_kurzbz = ?
|
||||
AND
|
||||
COALESCE(?::date, '2170-12-31'::date) >= COALESCE(v.von, '1970-01-01'::date)
|
||||
AND
|
||||
?::date <= COALESCE(v.bis, '2170-12-31')
|
||||
{$notselfclause}
|
||||
EOSQL;
|
||||
$ret = $this->execReadOnlyQuery($sql, array(
|
||||
$vb->getDienstverhaeltnis_id(),
|
||||
$vb->getVertragsbestandteiltyp_kurzbz(),
|
||||
$vb->getBis(),
|
||||
$vb->getVon()
|
||||
));
|
||||
|
||||
if( null === ($vbcount = getData($ret)) ) {
|
||||
throw new Exception('failed to fetch overlappingvbs count');
|
||||
}
|
||||
|
||||
return $vbcount[0]->overlappingvbs;
|
||||
}
|
||||
}
|
||||
@@ -142,14 +142,17 @@ $this->load->view(
|
||||
<br>
|
||||
|
||||
<!-- link for external lectors 'Informationsblatt fuer externe Lehrende'. Show only for external lecturers -->
|
||||
<?php if ($is_external_lector): ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<span class="pull-right"><?php echo $this->p->t('dms' , 'informationsblattExterneLehrende'); ?></span>
|
||||
<span class="pull-left"><?php echo $this->p->t('ui' , 'hinweistextLehrauftrag'); ?></span>
|
||||
<?php if ($is_external_lector): ?>
|
||||
<span class="pull-right"><?php echo $this->p->t('dms' , 'informationsblattExterneLehrende'); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<!-- filter buttons & PDF downloads & password field & akzeptieren-button -->
|
||||
<div class="row">
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$includesArray = array(
|
||||
'title' => 'Test VBform',
|
||||
'bootstrap5' => true,
|
||||
'fontawesome6' => true,
|
||||
'vue3' => true,
|
||||
'customJSModules' => array('public/js/apps/vbform/vbform.js')
|
||||
);
|
||||
|
||||
$this->load->view('templates/FHC-Header', $includesArray);
|
||||
?>
|
||||
|
||||
<div id="main"></div>
|
||||
|
||||
<?php $this->load->view('templates/FHC-Footer', $includesArray); ?>
|
||||
|
||||
@@ -122,7 +122,11 @@
|
||||
generateJSsInclude('vendor/npm-asset/primevue/column/column.min.js');
|
||||
generateJSsInclude('vendor/npm-asset/primevue/calendar/calendar.min.js');
|
||||
generateJSsInclude('vendor/npm-asset/primevue/skeleton/skeleton.min.js');
|
||||
generateJSsInclude('vendor/npm-asset/primevue/timeline/timeline.min.js');
|
||||
generateJSsInclude('vendor/npm-asset/primevue/multiselect/multiselect.min.js');
|
||||
generateJSsInclude('vendor/npm-asset/primevue/autocomplete/autocomplete.min.js');
|
||||
generateJSsInclude('vendor/npm-asset/primevue/overlaypanel/overlaypanel.min.js');
|
||||
generateJSsInclude('vendor/npm-asset/primevue/datatable/datatable.min.js');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* To filter data using a SQL statement
|
||||
*/
|
||||
@@ -59,6 +76,8 @@ class FilterWidget extends Widget
|
||||
|
||||
private $_sessionTimeout; // session expiring time
|
||||
|
||||
private $_encryptedColumns; // contains info about encrypted columns
|
||||
|
||||
private static $_FilterWidgetInstance; // static property that contains the instance of itself
|
||||
|
||||
/**
|
||||
@@ -195,6 +214,7 @@ class FilterWidget extends Widget
|
||||
$this->_formatRow = null;
|
||||
$this->_markRow = null;
|
||||
$this->_checkboxes = null;
|
||||
$this->_encryptedColumns = null;
|
||||
$this->_hideOptions = null;
|
||||
$this->_hideSelectFields = null;
|
||||
$this->_hideSelectFilters = null;
|
||||
@@ -252,6 +272,14 @@ class FilterWidget extends Widget
|
||||
$this->_additionalColumns = $args[FilterWidgetLib::ADDITIONAL_COLUMNS];
|
||||
}
|
||||
|
||||
// Parameter is used to define the ecrypted columns
|
||||
if (isset($args[FilterWidgetLib::ENCRYPTED_COLUMNS])
|
||||
&& is_array($args[FilterWidgetLib::ENCRYPTED_COLUMNS])
|
||||
&& count($args[FilterWidgetLib::ENCRYPTED_COLUMNS]) > 0)
|
||||
{
|
||||
$this->_encryptedColumns = $args[FilterWidgetLib::ENCRYPTED_COLUMNS];
|
||||
}
|
||||
|
||||
// Parameter is used to add use aliases for the columns fo the dataset
|
||||
if (isset($args[FilterWidgetLib::COLUMNS_ALIASES])
|
||||
&& is_array($args[FilterWidgetLib::COLUMNS_ALIASES])
|
||||
@@ -441,7 +469,7 @@ class FilterWidget extends Widget
|
||||
);
|
||||
|
||||
// Then retrieve dataset from DB
|
||||
$dataset = $this->filterwidgetlib->getDataset($datasetQuery);
|
||||
$dataset = $this->filterwidgetlib->getDataset($datasetQuery, $this->_encryptedColumns);
|
||||
|
||||
// Save changes into session if data are valid
|
||||
if (!isError($dataset))
|
||||
@@ -476,7 +504,7 @@ class FilterWidget extends Widget
|
||||
$datasetQuery = $this->filterwidgetlib->generateDatasetQuery($this->_query, $parsedFilterJson->filters);
|
||||
|
||||
// Then retrieve dataset from DB
|
||||
$dataset = $this->filterwidgetlib->getDataset($datasetQuery);
|
||||
$dataset = $this->filterwidgetlib->getDataset($datasetQuery, $this->_encryptedColumns);
|
||||
|
||||
// Try to load the name of the filter using the PhrasesLib
|
||||
$filterName = $this->filterwidgetlib->getFilterName($parsedFilterJson);
|
||||
@@ -497,6 +525,7 @@ class FilterWidget extends Widget
|
||||
FilterWidgetLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields
|
||||
FilterWidgetLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases
|
||||
FilterWidgetLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns
|
||||
FilterWidgetLib::SESSION_ENCRYPTED_COLUMNS => $this->_encryptedColumns, // encrypted columns
|
||||
FilterWidgetLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column
|
||||
FilterWidgetLib::SESSION_FILTERS => $parsedFilterJson->filters, // all the filters used to filter the dataset
|
||||
FilterWidgetLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset
|
||||
@@ -525,7 +554,7 @@ class FilterWidget extends Widget
|
||||
private function _setFilterMenu()
|
||||
{
|
||||
// Generates the filters structure array
|
||||
$filterMenu = $this->filterwidgetlib->generateFilterMenu(
|
||||
$this->filterwidgetlib->generateFilterMenu(
|
||||
$this->router->directory.$this->router->class.'/'.$this->router->method
|
||||
);
|
||||
}
|
||||
@@ -604,7 +633,7 @@ class FilterWidget extends Widget
|
||||
{
|
||||
$columnsNames = array();
|
||||
|
||||
foreach ($columns as $key => $obj)
|
||||
foreach ($columns as $obj)
|
||||
{
|
||||
if (isset($obj->name))
|
||||
{
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* To display a table that shows data retriev by a SQL statement
|
||||
*/
|
||||
@@ -40,6 +57,8 @@ class TableWidget extends Widget
|
||||
|
||||
private $_sessionTimeout; // session expiring time
|
||||
|
||||
private $_encryptedColumns; // contains info about encrypted columns
|
||||
|
||||
private static $_TableWidgetInstance; // static property that contains the instance of itself
|
||||
|
||||
/**
|
||||
@@ -127,6 +146,7 @@ class TableWidget extends Widget
|
||||
$this->_datasetRepresentationOptions = null;
|
||||
$this->_datasetRepFieldsDefs = null;
|
||||
$this->_sessionTimeout = TableWidgetLib::SESSION_DEFAULT_TIMEOUT;
|
||||
$this->_encryptedColumns = null;
|
||||
|
||||
// Retrieved the required permissions parameter if present
|
||||
if (isset($args[TableWidgetLib::REQUIRED_PERMISSIONS]))
|
||||
@@ -206,6 +226,14 @@ class TableWidget extends Widget
|
||||
{
|
||||
$this->_sessionTimeout = $args[TableWidgetLib::SESSION_TIMEOUT];
|
||||
}
|
||||
|
||||
// Parameter is used to define the ecrypted columns
|
||||
if (isset($args[TableWidgetLib::ENCRYPTED_COLUMNS])
|
||||
&& is_array($args[TableWidgetLib::ENCRYPTED_COLUMNS])
|
||||
&& count($args[TableWidgetLib::ENCRYPTED_COLUMNS]) > 0)
|
||||
{
|
||||
$this->_encryptedColumns = $args[TableWidgetLib::ENCRYPTED_COLUMNS];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,7 +316,7 @@ class TableWidget extends Widget
|
||||
$datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query);
|
||||
|
||||
// Then retrieve dataset from DB
|
||||
$dataset = $this->tablewidgetlib->getDataset($datasetQuery);
|
||||
$dataset = $this->tablewidgetlib->getDataset($datasetQuery, $this->_encryptedColumns);
|
||||
|
||||
// Save changes into session if data are valid
|
||||
if (!isError($dataset))
|
||||
@@ -310,7 +338,7 @@ class TableWidget extends Widget
|
||||
$datasetQuery = $this->tablewidgetlib->generateDatasetQuery($this->_query);
|
||||
|
||||
// Then retrieve dataset from DB
|
||||
$dataset = $this->tablewidgetlib->getDataset($datasetQuery);
|
||||
$dataset = $this->tablewidgetlib->getDataset($datasetQuery, $this->_encryptedColumns);
|
||||
|
||||
// Save changes into session if data are valid
|
||||
if (!isError($dataset))
|
||||
@@ -324,6 +352,7 @@ class TableWidget extends Widget
|
||||
TableWidgetLib::SESSION_FIELDS => $this->tablewidgetlib->getExecutedQueryListFields(), // all the fields of the dataset
|
||||
TableWidgetLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases
|
||||
TableWidgetLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns
|
||||
TableWidgetLib::SESSION_ENCRYPTED_COLUMNS => $this->_encryptedColumns, // encrypted columns
|
||||
TableWidgetLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column
|
||||
TableWidgetLib::SESSION_METADATA => $this->tablewidgetlib->getExecutedQueryMetaData(), // the metadata of the dataset
|
||||
TableWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this table
|
||||
@@ -411,24 +440,6 @@ class TableWidget extends Widget
|
||||
return !isset($class) ? '' : $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method that retrieves the name of the columns present in a table JSON definition
|
||||
*/
|
||||
private function _getColumnsNames($columns)
|
||||
{
|
||||
$columnsNames = array();
|
||||
|
||||
foreach ($columns as $key => $obj)
|
||||
{
|
||||
if (isset($obj->name))
|
||||
{
|
||||
$columnsNames[] = $obj->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $columnsNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a view using the given viewName and eventually other parameters
|
||||
*/
|
||||
@@ -438,3 +449,4 @@ class TableWidget extends Widget
|
||||
$ci->load->view($viewName, $parameters);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -215,7 +215,13 @@ function loadampel()
|
||||
</td>
|
||||
<td valign="middle" align="center">
|
||||
<form name="searchform" action="private/tools/suche.php" method="GET" target="content" style="display:inline">
|
||||
<input id="globalsearch" type="search" size="55" name="search" placeholder=" <?php echo $p->t('menu/suchePersonOrtDokumentInhalt');?> ..." title="<?php echo $p->t('menu/suchePersonOrtDokumentInhaltLang');?>"/>
|
||||
<?php
|
||||
if (defined('CIS_ALLOW_PERSON_SEARCH') && !CIS_ALLOW_PERSON_SEARCH)
|
||||
$searchText = $p->t('menu/sucheOrtDokumentInhalt');
|
||||
else
|
||||
$searchText = $p->t('menu/suchePersonOrtDokumentInhalt');
|
||||
?>
|
||||
<input id="globalsearch" type="search" size="55" name="search" placeholder=" <?php echo $searchText ;?> ..." title="<?php echo $searchText ;?>"/>
|
||||
<img src="../skin/images/search.png" onclick="document.searchform.submit()" class="suchicon"/>
|
||||
</form>
|
||||
</td>
|
||||
|
||||
@@ -276,15 +276,22 @@ if (!$ansicht)
|
||||
{
|
||||
if ($type === 'mitarbeiter')
|
||||
{
|
||||
$verwendung = new bisverwendung();
|
||||
if($verwendung->getLastVerwendung($uid))
|
||||
if(defined('DIENSTVERHAELTNIS_SUPPORT') && DIENSTVERHAELTNIS_SUPPORT)
|
||||
{
|
||||
if (!$verwendung->hauptberuflich)
|
||||
{
|
||||
echo 'Hauptberuf: '. $verwendung->hauptberuf;
|
||||
}
|
||||
// TODO Hauptberuf wieder anzeigen sobald verfuegbar
|
||||
}
|
||||
echo "<br><br>";
|
||||
else
|
||||
{
|
||||
$verwendung = new bisverwendung();
|
||||
if($verwendung->getLastVerwendung($uid))
|
||||
{
|
||||
if (!$verwendung->hauptberuflich)
|
||||
{
|
||||
echo 'Hauptberuf: '. $verwendung->hauptberuf;
|
||||
}
|
||||
}
|
||||
echo "<br><br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,9 +613,36 @@ function printFunctionsTable($query, $headingphrase, $tableid, $showVertragsstun
|
||||
if ($showVertragsstunden === true && $adminOrOwnUser)
|
||||
{
|
||||
$vertragsstunden = 0.00;
|
||||
$qry = "SELECT sum(vertragsstunden) AS vertragsstdsumme from bis.tbl_bisverwendung
|
||||
WHERE mitarbeiter_uid = ".$db->db_add_param($uid)."
|
||||
AND (ende > now() OR ende IS NULL)";
|
||||
if(defined('DIENSTVERHAELTNIS_SUPPORT') && DIENSTVERHAELTNIS_SUPPORT)
|
||||
{
|
||||
$qry = "SELECT
|
||||
sum(wochenstunden) AS vertragsstdsumme
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil_stunden vbs
|
||||
JOIN
|
||||
hr.tbl_vertragsbestandteil vb USING(vertragsbestandteil_id)
|
||||
JOIN
|
||||
hr.tbl_dienstverhaeltnis dv USING(dienstverhaeltnis_id)
|
||||
WHERE
|
||||
dv.mitarbeiter_uid = ".$db->db_add_param($uid)."
|
||||
AND NOW() BETWEEN COALESCE(vb.von, '1970-01-01'::date) AND COALESCE(vb.bis, '2170-12-31'::date)
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil
|
||||
WHERE
|
||||
dienstverhaeltnis_id = dv.dienstverhaeltnis_id
|
||||
AND vertragsbestandteiltyp_kurzbz = 'karenz'
|
||||
AND NOW() BETWEEN COALESCE(von, '1970-01-01'::date) AND COALESCE(bis, '2170-12-31'::date)
|
||||
)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = "SELECT sum(vertragsstunden) AS vertragsstdsumme from bis.tbl_bisverwendung
|
||||
WHERE mitarbeiter_uid = ".$db->db_add_param($uid)."
|
||||
AND (ende > now() OR ende IS NULL)";
|
||||
}
|
||||
|
||||
if ($result_vertragsstd = $db->db_query($qry))
|
||||
{
|
||||
|
||||
+51
-17
@@ -126,6 +126,9 @@ if (!$searchPerson && !$searchOrt && !$searchDms && !$searchContent && !$searchO
|
||||
|
||||
function searchPerson($searchItems)
|
||||
{
|
||||
if (defined('CIS_ALLOW_PERSON_SEARCH') && !CIS_ALLOW_PERSON_SEARCH)
|
||||
return false;
|
||||
|
||||
global $db, $p, $noalias, $uid;
|
||||
$bn = new benutzer();
|
||||
//search only active and Mitarbeiter with positive Personalnr
|
||||
@@ -172,9 +175,6 @@ function searchPerson($searchItems)
|
||||
';
|
||||
foreach($bn->result as $row)
|
||||
{
|
||||
$bisverwendung = new bisverwendung();
|
||||
$bisverwendung->getLastAktVerwendung($row->uid);
|
||||
|
||||
echo '<tr>';
|
||||
//echo '<td>',$row->titelpre,'</td>';
|
||||
echo '<td>',$row->anrede,'</td>';
|
||||
@@ -185,21 +185,16 @@ function searchPerson($searchItems)
|
||||
echo '<td>',$row->vorname, '</td>';
|
||||
|
||||
echo '<td>';
|
||||
if(!defined('CIS_SUCHE_PROFIL_ANZEIGEN'))
|
||||
echo '<a href="../profile/index.php?uid=',$row->uid,'" title="',$row->titelpre,' ',$row->vorname,' ',$row->wahlname, ' ',$row->nachname,' ',$row->titelpost,'">',$row->nachname,'</a>';
|
||||
else if(!CIS_SUCHE_PROFIL_ANZEIGEN)
|
||||
{
|
||||
$mitarbeiter = new Mitarbeiter($uid);
|
||||
if($mitarbeiter->errormsg === NULL)
|
||||
echo '<a href="../profile/index.php?uid=',$row->uid,'" title="',$row->titelpre,' ',$row->vorname,' ',$row->wahlname, ' ',$row->nachname,' ',$row->titelpost,'">',$row->nachname,'</a>';
|
||||
else
|
||||
|
||||
$mitarbeiter = new Mitarbeiter();
|
||||
if (defined('CIS_SUCHE_PROFIL_ANZEIGEN') && CIS_SUCHE_PROFIL_ANZEIGEN === false && !$mitarbeiter->load($uid))
|
||||
echo $row->nachname;
|
||||
}
|
||||
else
|
||||
echo '<a href="../profile/index.php?uid=',$row->uid,'" title="',$row->titelpre,' ',$row->vorname,' ',$row->wahlname,' ',$row->nachname,' ',$row->titelpost,'">',$row->nachname,'</a>';
|
||||
|
||||
if($row->aktiv==false)
|
||||
echo '<span style="color: red"> (ausgeschieden)</span>';
|
||||
elseif($bisverwendung->beschausmasscode=='5')
|
||||
elseif(isKarenziert($row->uid))
|
||||
echo '<span style="color: orange"> (karenziert)</span>';
|
||||
echo '</td>';
|
||||
//echo '<td>',$row->titelpost,'</td>';
|
||||
@@ -262,6 +257,47 @@ function searchPerson($searchItems)
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function isKarenziert($uid)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(defined('DIENSTVERHAELTNIS_SUPPORT') && DIENSTVERHAELTNIS_SUPPORT)
|
||||
{
|
||||
$qry ="
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
hr.tbl_dienstverhaeltnis
|
||||
JOIN hr.tbl_vertragsbestandteil USING(dienstverhaeltnis_id)
|
||||
JOIN hr.tbl_vertragsbestandteil_karenz USING(vertragsbestandteil_id)
|
||||
WHERE
|
||||
tbl_dienstverhaeltnis.mitarbeiter_uid=".$db->db_add_param($uid)."
|
||||
AND tbl_vertragsbestandteil.von<=now() AND tbl_vertragsbestandteil.bis>=now()
|
||||
";
|
||||
|
||||
if($result = $db->db_query($qry))
|
||||
{
|
||||
if($db->db_num_rows($result)>0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bisverwendung = new bisverwendung();
|
||||
$bisverwendung->getLastAktVerwendung($uid);
|
||||
|
||||
if($bisverwendung->beschausmasscode=='5')
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function searchOE($searchItems)
|
||||
{
|
||||
global $db, $p, $noalias;
|
||||
@@ -332,8 +368,6 @@ function searchOE($searchItems)
|
||||
$mitarbeiter->load($bf->uid);
|
||||
$kontakt = new kontakt();
|
||||
$kontakt->loadFirmaKontakttyp($mitarbeiter->standort_id,'telefon');
|
||||
$bisverwendung = new bisverwendung();
|
||||
$bisverwendung->getLastAktVerwendung($bf->uid);
|
||||
$benutzer = new benutzer($bf->uid);
|
||||
if ($benutzer->bnaktiv)
|
||||
{
|
||||
@@ -341,8 +375,8 @@ function searchOE($searchItems)
|
||||
echo '<td>'.$person->vorname.'</td>';
|
||||
echo '<td><a href="../profile/index.php?uid=',$person->uid,'" title="',$person->titelpre,' ',$person->vorname,' ',$person->nachname,' ',$person->titelpost,'">',$person->nachname,'</a></td>';
|
||||
echo '<td>'.$bf->bezeichnung;
|
||||
if($bisverwendung->beschausmasscode=='5')
|
||||
echo '<span style="color: orange"> (karenziert)</span>';
|
||||
if( isKarenziert($bf->uid))
|
||||
echo '<span style="color: orange"> (karenziert)</span>';
|
||||
echo '</td>';
|
||||
|
||||
// Display phone number
|
||||
|
||||
@@ -41,11 +41,10 @@ require_once('../../../include/service.class.php');
|
||||
require_once('../../../include/mitarbeiter.class.php');
|
||||
require_once('../../../include/betriebsmittelperson.class.php');
|
||||
require_once('../../../include/globals.inc.php');
|
||||
require_once('../../../include/bisverwendung.class.php');
|
||||
require_once('../../../include/studiensemester.class.php');
|
||||
require_once('../../../include/benutzerberechtigung.class.php');
|
||||
require_once('../../../include/zeitaufzeichnung_import_csv.class.php');
|
||||
require_once('../../../include/zeitaufzeichnung_import_post.class.php');
|
||||
require_once('../../../include/vertragsbestandteil.class.php');
|
||||
|
||||
$sprache = getSprache();
|
||||
$p=new phrasen($sprache);
|
||||
@@ -318,7 +317,7 @@ echo '
|
||||
Monat=Datum.substring(3,5);
|
||||
Jahr=Datum.substring(6,10);
|
||||
var day = Jahr + "-" + Monat + "-" + Tag;
|
||||
checkBisverwendung(day,uid);
|
||||
checkZeitaufzeichnung(day,uid);
|
||||
checkZeitsperre(day,uid);
|
||||
}
|
||||
)
|
||||
@@ -777,30 +776,31 @@ echo '
|
||||
Monat=Datum.substring(3,5);
|
||||
Jahr=Datum.substring(6,10);
|
||||
var checkedDay = Jahr + "-" + Monat + "-" + Tag;
|
||||
checkBisverwendung(checkedDay, uid);
|
||||
checkZeitaufzeichnung(checkedDay, uid);
|
||||
checkZeitsperre(checkedDay, uid);
|
||||
}
|
||||
|
||||
function checkBisverwendung(day, uid)
|
||||
function checkZeitaufzeichnung(day, uid)
|
||||
{
|
||||
/* Checkt nicht mehr Bisverwendung, sondern Vertragsbestandteil Zeitaufzeichnung */
|
||||
$.ajax({
|
||||
url: "zeitaufzeichnung_bisverwendung.php",
|
||||
data: {
|
||||
day: day,
|
||||
uid: uid
|
||||
},
|
||||
success: function (result)
|
||||
{
|
||||
if (result==\'true\')
|
||||
{
|
||||
$("#homeofficeBlock").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homeofficeBlock").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
url: "zeitaufzeichnung_bisverwendung.php",
|
||||
data: {
|
||||
day: day,
|
||||
uid: uid
|
||||
},
|
||||
success: function (result)
|
||||
{
|
||||
if (result==\'true\')
|
||||
{
|
||||
$("#homeofficeBlock").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#homeofficeBlock").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function checkZeitsperre(day, uid)
|
||||
@@ -1042,7 +1042,7 @@ if ($projekt->getProjekteMitarbeiter($user, true))
|
||||
echo "
|
||||
<hr><br>
|
||||
|
||||
<select name='mas' id='mas' onchange='location = this.options[this.selectedIndex].value;''>
|
||||
<select name='mas' id='mas' onchange='location = this.options[this.selectedIndex].value;'>
|
||||
<option>-- Timesheets Mitarbeiter*Innen --</option>";
|
||||
foreach($mitarbeiter->result as $row)
|
||||
{
|
||||
@@ -1247,9 +1247,9 @@ if ($projekt->getProjekteMitarbeiter($user, true))
|
||||
$p->t("zeitaufzeichnung/projektphase").'
|
||||
<SELECT name="projektphase" id="projektphase">
|
||||
<OPTION value="" id="projektphasekeineausw">-- '.$p->t('zeitaufzeichnung/keineAuswahl').' --</OPTION>';
|
||||
|
||||
if ($showprojphases)
|
||||
{
|
||||
|
||||
foreach ($projektphasen as $projektphase)
|
||||
{
|
||||
if (($projektphase->start != "" ) && ($projektphase->ende != " "))
|
||||
@@ -1270,13 +1270,12 @@ if ($projekt->getProjekteMitarbeiter($user, true))
|
||||
echo '<option value="'.$db->convert_html_chars($projektphase->projektphase_id).'" '.$selected.'>'.$db->convert_html_chars($projektphase->bezeichnung).
|
||||
$phasentext. '</option>';
|
||||
}
|
||||
echo '</SELECT></span>';
|
||||
|
||||
}
|
||||
echo '</SELECT></span>';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
echo "<input type ='hidden' value='$user'id=uidpass>";
|
||||
|
||||
if ($za_simple == 0)
|
||||
{
|
||||
// Service
|
||||
@@ -1370,22 +1369,19 @@ if ($projekt->getProjekteMitarbeiter($user, true))
|
||||
<td> </td>
|
||||
<td colspan="3">
|
||||
<span id="pausenblock">
|
||||
<input type="checkbox" name="genPause" id="genPause" onChange="checkPausenzeit()"> '.$p->t("zeitaufzeichnung/pauseEinfuegen").' <input type="text" name="pause_von" class="timepicker" size="4" id="pause_von"> - <input type="text" name="pause_bis" class="timepicker" size="4" id="pause_bis">
|
||||
<input type="checkbox" name="genPause" id="genPause" onChange="checkPausenzeit()"> <label for="genPause">'.$p->t("zeitaufzeichnung/pauseEinfuegen").'</label> <input type="text" name="pause_von" class="timepicker" size="4" id="pause_von"> - <input type="text" name="pause_bis" class="timepicker" size="4" id="pause_bis">
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
//Zeitsperren
|
||||
echo '<p id="outputZs"></p>';
|
||||
|
||||
//Homeoffice Checkbox
|
||||
echo '
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="1">
|
||||
<span id="homeofficeBlock">
|
||||
<input type="checkbox" name="homeoffice" id="homeoffice" '. $homeofficeChecked . '>Homeoffice</input>
|
||||
<input type="checkbox" name="homeoffice" id="homeoffice" '. $homeofficeChecked . '> <label for="homeoffice">Homeoffice</label>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1410,23 +1406,15 @@ if ($projekt->getProjekteMitarbeiter($user, true))
|
||||
echo '</table>';
|
||||
echo '</td><td valign="top"><span id="zeitsaldo"></span><br>';
|
||||
|
||||
if (defined('DEFAULT_ALLIN_DIENSTVERTRAG') && DEFAULT_ALLIN_DIENSTVERTRAG != '')
|
||||
$vbt = new vertragsbestandteil();
|
||||
$isAllin = $vbt->isAllin($user);
|
||||
|
||||
if ($isAllin)
|
||||
{
|
||||
$bisver = new bisverwendung();
|
||||
$bisver->getLastVerwendung($user);
|
||||
// $ba1code = $bisver->ba1code;
|
||||
$ba1code = null;
|
||||
|
||||
if (in_array($bisver->ba1code, DEFAULT_ALLIN_DIENSTVERTRAG))
|
||||
{
|
||||
echo '<span id="saldoAllin"></span><br><br>';
|
||||
}
|
||||
else
|
||||
echo '<br>';
|
||||
echo '<span id="saldoAllin"></span><br>';
|
||||
}
|
||||
else
|
||||
echo '<br>';
|
||||
|
||||
echo '<br>';
|
||||
|
||||
|
||||
|
||||
@@ -1437,44 +1425,10 @@ if ($projekt->getProjekteMitarbeiter($user, true))
|
||||
echo '</span></td></tr>';
|
||||
echo '<tr><td style="float:right;">';
|
||||
|
||||
// Summen Lehre anzeigen
|
||||
$bv = new bisverwendung();
|
||||
$bv->getLastAktVerwendung($user);
|
||||
$lehre_inkludiert = $bv->inkludierte_lehre;
|
||||
if (!$lehre_inkludiert)
|
||||
$lehre_inkludiert = 0;
|
||||
|
||||
$stsem = new studiensemester();
|
||||
$sem_akt = $stsem->getakt();
|
||||
$lehre = new zeitaufzeichnung();
|
||||
$l_arr = $lehre->getLehreForUser($user, $sem_akt);
|
||||
$displayLehresaldo = false;
|
||||
if ($displayLehresaldo && ($l_arr["LehreAuftraege"]>0 || $l_arr["Lehre"] > 0 || $l_arr["LehreExtern"] > 0))
|
||||
{
|
||||
if ($lehre_inkludiert == -1)
|
||||
{
|
||||
$l_extern_soll = 0;
|
||||
$lehre_inkludiert = $l_arr["LehreAuftraege"];
|
||||
}
|
||||
else
|
||||
$l_extern_soll = $l_arr["LehreAuftraege"]-$lehre_inkludiert;
|
||||
$l_extern_soll_norm = $l_extern_soll/4*3;
|
||||
$lehre_inkludiert_norm = $lehre_inkludiert/4*3;
|
||||
echo '<table style="border: 1px solid gray">';
|
||||
echo '<tr><td colspan="3" style="border: 1px solid gray"><h3>Übersicht Lehre '.$sem_akt.'</h3></tr>';
|
||||
echo '<tr><td colspan="3" style="border: 1px solid gray">(in Stunden)</tr>';
|
||||
echo '<tr><td></td><td style="border: 1px solid gray">beauftragt (LE)</td><td style="border: 1px solid gray">gebucht</td></tr>';
|
||||
if ($lehre_inkludiert > 0 || $l_arr["Lehre"] > 0)
|
||||
echo '<tr><td style="border: 1px solid gray">Lehre:</td><td align="right" style="border: 1px solid gray">'.$lehre_inkludiert_norm.' ('.$lehre_inkludiert.')</td><td align="right" style="border: 1px solid gray">'.$l_arr["Lehre"].'</td></tr>';
|
||||
if ($l_extern_soll > 0 || $l_arr["LehreExtern"] > 0)
|
||||
echo '<tr><td style="border: 1px solid gray">LehreExtern:</td><td align="right" style="border: 1px solid gray">'.$l_extern_soll_norm.' ('.$l_extern_soll.')</td><td align="right" style="border: 1px solid gray">'.$l_arr["LehreExtern"].'</td></tr>';
|
||||
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
echo '</td></tr>';
|
||||
echo '</table>';
|
||||
echo '</form>';
|
||||
echo "<input type ='hidden' value='$user' id='uidpass'>";
|
||||
echo '<hr>';
|
||||
echo '<h3>'.($alle===true?$p->t('zeitaufzeichnung/alleEintraege'):$p->t('zeitaufzeichnung/xTageAnsicht', array($angezeigte_tage))).'</h3>';
|
||||
if ($alle===true)
|
||||
@@ -1593,26 +1547,26 @@ if ($projekt->getProjekteMitarbeiter($user, true))
|
||||
$linkInformation = APP_ROOT. 'skin/images/information.png';
|
||||
|
||||
$za = new zeitaufzeichnung();
|
||||
$verwendung = new bisverwendung();
|
||||
|
||||
if ($za->checkPausenErrors($user, $tag))
|
||||
{
|
||||
$verwendung->getVerwendungDatum($user, $tag);
|
||||
foreach ($verwendung->result as $v)
|
||||
$vbt = new vertragsbestandteil();
|
||||
$isAzgrelevant = $vbt->isAzgRelevant($user, $tag);
|
||||
|
||||
if ($isAzgrelevant)
|
||||
{
|
||||
if ($v->azgrelevant)
|
||||
{
|
||||
$pausefehlt_str = '<span style="color:red; font-weight:bold;"> <img src= '. $linkExclamation. '> -- Pause fehlt oder zu kurz -- </span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$pausefehlt_str = '<span style="color:steelblue; font-weight:bold;"> <img src= '. $linkInformation. '> -- Pause fehlt --</span>';
|
||||
}
|
||||
$pausefehlt_str = '<span style="color:red; font-weight:bold;"> <img src= '. $linkExclamation. '> -- Pause fehlt oder zu kurz -- </span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$pausefehlt_str = '<span style="color:steelblue; font-weight:bold;"> <img src= '. $linkInformation. '> -- Pause fehlt --</span>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$tagessaldo = date('H:i', ($tagessaldo));
|
||||
$colspan = ($za_simple)?6:8;
|
||||
echo '<tr id="tag_row_'.$datum->formatDatum($tag,'d_m_Y').'"><td '.$style.' colspan="'.$colspan.'")>';
|
||||
echo '<tr id="tag_row_'.$datum->formatDatum($tag,'d_m_Y').'"><td '.$style.' colspan="'.$colspan.'">';
|
||||
|
||||
// Zusaetzlicher span fuer Addon Informationen
|
||||
|
||||
@@ -1669,8 +1623,8 @@ if ($projekt->getProjekteMitarbeiter($user, true))
|
||||
|
||||
<tr>
|
||||
<th colspan="'.$colspan.'" style="background-color: #8DBDD8;"></th>
|
||||
<th style="background-color: #8DBDD8;" align="right" colspan="2" style="font-weight: normal;"><b>'.$p->t("zeitaufzeichnung/wochensummeArbeitszeit").':</b></th>
|
||||
<th style="background-color: #8DBDD8;" align="right" style="font-weight: normal;"><b>'.$wochensaldo.$erstr.'</b></th>
|
||||
<th style="background-color: #8DBDD8; font-weight: normal;" align="right" colspan="2"><b>'.$p->t("zeitaufzeichnung/wochensummeArbeitszeit").':</b></th>
|
||||
<th style="background-color: #8DBDD8; font-weight: normal;" align="right"><b>'.$wochensaldo.$erstr.'</b></th>
|
||||
<th style="background-color: #8DBDD8;" colspan="3"></th>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ require_once('../../../include/benutzerberechtigung.class.php');
|
||||
require_once('../../../include/mitarbeiter.class.php');
|
||||
require_once('../../../include/zeitaufzeichnung.class.php');
|
||||
require_once('../../../include/projekt.class.php');
|
||||
require_once('../../../include/bisverwendung.class.php');
|
||||
require_once('../../../include/vertragsbestandteil.class.php');
|
||||
|
||||
if ((isset($_GET['uid'])) && (isset($_GET['day'])))
|
||||
{
|
||||
@@ -57,18 +57,8 @@ if ((isset($_GET['uid'])) && (isset($_GET['day'])))
|
||||
|
||||
$day = $_GET['day'];
|
||||
|
||||
$verwendung = new bisverwendung();
|
||||
|
||||
$verwendung->getVerwendungDatum($uid, $day);
|
||||
$homeoffice = false;
|
||||
|
||||
foreach ($verwendung->result as $v)
|
||||
{
|
||||
if ($v->homeoffice)
|
||||
{
|
||||
$homeoffice = true;
|
||||
}
|
||||
}
|
||||
$vbt = new vertragsbestandteil();
|
||||
$homeoffice = $vbt->hasHomeoffice($uid, $day);
|
||||
|
||||
echo json_encode($homeoffice);
|
||||
|
||||
|
||||
+13
-11
@@ -319,9 +319,9 @@
|
||||
"type": "package",
|
||||
"package": {
|
||||
"name": "vuejs/vuejs3",
|
||||
"version": "3.2.33",
|
||||
"version": "3.3.8",
|
||||
"dist": {
|
||||
"url": "https://unpkg.com/vue@3.2.33/dist/vue.global.prod.js",
|
||||
"url": "https://unpkg.com/vue@3.3.8/dist/vue.global.prod.js",
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
@@ -341,9 +341,9 @@
|
||||
"type": "package",
|
||||
"package": {
|
||||
"name": "vuejs/vuedatepicker_js",
|
||||
"version": "5.4.0",
|
||||
"version": "7.2.0",
|
||||
"dist": {
|
||||
"url": "https://unpkg.com/@vuepic/vue-datepicker@4.2.3/dist/vue-datepicker.iife.js",
|
||||
"url": "https://unpkg.com/@vuepic/vue-datepicker@7.2.0/dist/vue-datepicker.iife.js",
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
@@ -352,9 +352,9 @@
|
||||
"type": "package",
|
||||
"package": {
|
||||
"name": "vuejs/vuedatepicker_css",
|
||||
"version": "5.4.0",
|
||||
"version": "7.2.0",
|
||||
"dist": {
|
||||
"url": "https://unpkg.com/@vuepic/vue-datepicker@4.2.3/dist/main.css",
|
||||
"url": "https://unpkg.com/@vuepic/vue-datepicker@7.2.0/dist/main.css",
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
@@ -411,7 +411,7 @@
|
||||
"nategood/httpful": "0.2.*",
|
||||
"netcarver/textile": "3.7.*",
|
||||
"nicolaskruchten/pivottable": "2.23.0",
|
||||
"npm-asset/primevue": "3.29.*",
|
||||
"npm-asset/primevue": "3.29.1",
|
||||
"npm-asset/primeicons": "5.0.0",
|
||||
|
||||
"olifolkerd/tabulator4": "4.9.*",
|
||||
@@ -429,18 +429,20 @@
|
||||
"twbs/bootstrap3": "3.4.*",
|
||||
"twbs/bootstrap5": "5.1.*",
|
||||
|
||||
"vuejs/vuejs3": "3.2.33",
|
||||
"vuejs/vuejs3": "3.3.8",
|
||||
"vuejs/vuerouter4": "4.1.3",
|
||||
"vuejs/vuedatepicker_js": "5.4.0",
|
||||
"vuejs/vuedatepicker_css": "5.4.0"
|
||||
"vuejs/vuedatepicker_js": "7.2.0",
|
||||
"vuejs/vuedatepicker_css": "7.2.0"
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "vendor/bin"
|
||||
},
|
||||
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "3.6.*",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"phpmetrics/phpmetrics": "2.*",
|
||||
"sebastian/phpcpd": "3.*"
|
||||
"sebastian/phpcpd": "3.*",
|
||||
"phpunit/phpunit": "^6"
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+1535
-21
File diff suppressed because it is too large
Load Diff
@@ -129,6 +129,8 @@ define('MAILVERTEILER_SPERRE', true);
|
||||
// Bezeichnung des Campus
|
||||
define('CAMPUS_NAME','FH Technikum Wien');
|
||||
|
||||
define('CI_ENVIRONMENT', 'development'); // Code igniter environment variable
|
||||
|
||||
// Anzahl der Tag die eine Nachricht am Pinboard angezeigt wird.
|
||||
define("MAXNEWSALTER",60);
|
||||
// Anzahl der Newseintraege die maximal angezeigt werden
|
||||
|
||||
@@ -57,8 +57,13 @@ define('CIS_LVALISTE_NOTENEINGABE_ANZEIGEN',true);
|
||||
define('CIS_SUCHE_LVPLAN_ANZEIGEN',true);
|
||||
|
||||
// Anzeige des Links zum Profil von Personen bei globaler Suche
|
||||
// Wenn ein Mitarbeiter sucht, wird der Link IMMER angezeigt, unabhängig von der Config
|
||||
// Wenn ein Studierender sucht und die Config auf false ist, wird der Link nicht angezeigt - ansonsten schon
|
||||
define('CIS_SUCHE_PROFIL_ANZEIGEN',true);
|
||||
|
||||
// Anzeige von Personen bei globaler Suche
|
||||
define('CIS_ALLOW_PERSON_SEARCH', true);
|
||||
|
||||
// Soll geprueft werden ob das Passwort innerhalb des letzten Jahres geaendert wurde true|false
|
||||
// Wenn dies nicht geaendert wurde wird nach dem Login auf die Passwort aendern Seite umgeleitet
|
||||
define('CIS_CHECK_PASSWORD_CHANGE',false);
|
||||
@@ -322,4 +327,9 @@ define ('ZAHLUNGSBESTAETIGUNG_ZAHLUNGSREFERENZ_ANZEIGEN', false);
|
||||
|
||||
define('DOCSBOX_ENABLED', false);
|
||||
|
||||
// Aktiviert Abfragen auf die Dienstverhaeltnisse im HR Schema anstatt auf die BIS-Verwendung
|
||||
// Uebergangsphase bis zur entfernung der BIS-Verwendungen
|
||||
// (true | false)
|
||||
define('DIENSTVERHAELTNIS_SUPPORT', false);
|
||||
|
||||
?>
|
||||
|
||||
@@ -385,6 +385,7 @@ var LeLektorDDObserver=
|
||||
|
||||
req.add('lehreinheit_id', lehreinheit_id);
|
||||
req.add('mitarbeiter_uid', uid);
|
||||
req.add('studiensemester_kurzbz', getStudiensemester());
|
||||
|
||||
var response = req.executePOST();
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ require_once('../../include/datum.class.php');
|
||||
require_once('../../include/vertrag.class.php');
|
||||
require_once('../../include/benutzergruppe.class.php');
|
||||
require_once('../../include/bisverwendung.class.php');
|
||||
require_once('../../include/stundensatz.class.php');
|
||||
|
||||
$user = get_uid();
|
||||
$db = new basis_db();
|
||||
@@ -543,51 +544,61 @@ if(!$error)
|
||||
$lem->new=true;
|
||||
|
||||
$fixangestellt=false;
|
||||
//Stundensatz aus tbl_mitarbeiter holen
|
||||
$mitarbeiter = new mitarbeiter();
|
||||
if ($mitarbeiter->load($_POST['mitarbeiter_uid']))
|
||||
//"lehre" Stundensatz aus hr.tbl_stundensatz holen
|
||||
|
||||
$studiensemester = new studiensemester();
|
||||
if (!$studiensemester->load($_POST['studiensemester_kurzbz']))
|
||||
{
|
||||
$fixangestellt = $mitarbeiter->fixangestellt;
|
||||
$lem->stundensatz = $mitarbeiter->stundensatz;
|
||||
$return = false;
|
||||
$error = true;
|
||||
$errormsg = 'Fehler beim Laden des Studiensemesters';
|
||||
}
|
||||
|
||||
if (defined('FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ')
|
||||
&& !FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ)
|
||||
if (!$error)
|
||||
{
|
||||
$mitarbeiter = new mitarbeiter();
|
||||
if ($mitarbeiter->load($_POST['mitarbeiter_uid']))
|
||||
{
|
||||
$stsem = new studiensemester();
|
||||
$stsem->load($semester_aktuell);
|
||||
$bisverwendung = new bisverwendung();
|
||||
$data = $mitarbeiter->stundensatz;
|
||||
if(!$bisverwendung->getVerwendungRange($mitarbeiter->uid, $stsem->start, $stsem->ende))
|
||||
$fixangestellt = $mitarbeiter->fixangestellt;
|
||||
|
||||
$stundensatz = new stundensatz();
|
||||
$stundensatz->getStundensatzDatum($mitarbeiter->uid, $studiensemester->start, $studiensemester->ende, 'lehre');
|
||||
$lem->stundensatz = $stundensatz->stundensatz;
|
||||
|
||||
if (defined('FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ')
|
||||
&& !FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ)
|
||||
{
|
||||
$bisverwendung->getLastAktVerwendung($mitarbeiter->uid);
|
||||
$bisverwendung->result[] = $bisverwendung;
|
||||
}
|
||||
|
||||
foreach($bisverwendung->result as $row_verwendung)
|
||||
{
|
||||
// Bei echten Dienstvertraegen mit voller inkludierter Lehre wird kein Stundensatz
|
||||
// geliefert da dies im Vertrag inkludiert ist.
|
||||
|
||||
if ((in_array($row_verwendung->ba1code, $arrEchterDV)) && $row_verwendung->inkludierte_lehre == -1)
|
||||
$stsem = new studiensemester();
|
||||
$stsem->load($semester_aktuell);
|
||||
$bisverwendung = new bisverwendung();
|
||||
|
||||
if(!$bisverwendung->getVerwendungRange($mitarbeiter->uid, $stsem->start, $stsem->ende))
|
||||
{
|
||||
$fixangestellt = true;
|
||||
$lem->stundensatz = '';
|
||||
|
||||
break;
|
||||
$bisverwendung->getLastAktVerwendung($mitarbeiter->uid);
|
||||
$bisverwendung->result[] = $bisverwendung;
|
||||
}
|
||||
|
||||
foreach($bisverwendung->result as $row_verwendung)
|
||||
{
|
||||
// Bei echten Dienstvertraegen mit voller inkludierter Lehre wird kein Stundensatz
|
||||
// geliefert da dies im Vertrag inkludiert ist.
|
||||
|
||||
if ((in_array($row_verwendung->ba1code, $arrEchterDV)) && $row_verwendung->inkludierte_lehre == -1)
|
||||
{
|
||||
$fixangestellt = true;
|
||||
$lem->stundensatz = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$lem->stundensatz = $mitarbeiter->stundensatz;
|
||||
$error=true;
|
||||
$return=false;
|
||||
$errormsg='Mitarbeiter '.$db->convert_html_chars($_POST['mitarbeiter_uid']).' wurde nicht gefunden';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$return=false;
|
||||
$errormsg='Mitarbeiter '.$db->convert_html_chars($_POST['mitarbeiter_uid']).' wurde nicht gefunden';
|
||||
}
|
||||
|
||||
$maxstunden=9999;
|
||||
|
||||
@@ -1556,49 +1567,61 @@ if(!$error)
|
||||
}
|
||||
elseif(isset($_POST['type']) && $_POST['type']=='getstundensatz')
|
||||
{
|
||||
if(isset($_POST['mitarbeiter_uid']))
|
||||
if(isset($_POST['mitarbeiter_uid']) && isset($_POST['studiensemester_kurzbz']))
|
||||
{
|
||||
$mitarbeiter = new mitarbeiter();
|
||||
if($mitarbeiter->load($_POST['mitarbeiter_uid']))
|
||||
$studiensemester = new studiensemester();
|
||||
if (!$studiensemester->load($_POST['studiensemester_kurzbz']))
|
||||
{
|
||||
if (defined('FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ')
|
||||
&& !FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ)
|
||||
$return = false;
|
||||
$error = true;
|
||||
$errormsg = 'Fehler beim Laden des Studiensemesters';
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$mitarbeiter = new mitarbeiter();
|
||||
if($mitarbeiter->load($_POST['mitarbeiter_uid']))
|
||||
{
|
||||
$stsem = new studiensemester();
|
||||
$stsem->load($semester_aktuell);
|
||||
$bisverwendung = new bisverwendung();
|
||||
$data = $mitarbeiter->stundensatz;
|
||||
if(!$bisverwendung->getVerwendungRange($mitarbeiter->uid, $stsem->start, $stsem->ende))
|
||||
$stundensatz = new stundensatz();
|
||||
$stundensatz->getStundensatzDatum($mitarbeiter->uid, $studiensemester->start, $studiensemester->ende, 'lehre');
|
||||
$data = $stundensatz->stundensatz;
|
||||
|
||||
if (defined('FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ')
|
||||
&& !FAS_LV_LEKTORINNENZUTEILUNG_FIXANGESTELLT_STUNDENSATZ)
|
||||
{
|
||||
$bisverwendung->getLastAktVerwendung($mitarbeiter->uid);
|
||||
$bisverwendung->result[] = $bisverwendung;
|
||||
}
|
||||
|
||||
foreach($bisverwendung->result as $row_verwendung)
|
||||
{
|
||||
|
||||
// Bei echten Dienstvertraegen mit voller inkludierter Lehre wird kein Stundensatz
|
||||
// geliefert da dies im Vertrag inkludiert ist.
|
||||
if ((in_array($row_verwendung->ba1code, $arrEchterDV)) && $row_verwendung->inkludierte_lehre == -1)
|
||||
$stsem = new studiensemester();
|
||||
$stsem->load($semester_aktuell);
|
||||
$bisverwendung = new bisverwendung();
|
||||
if(!$bisverwendung->getVerwendungRange($mitarbeiter->uid, $stsem->start, $stsem->ende))
|
||||
{
|
||||
$data = '';
|
||||
break;
|
||||
$bisverwendung->getLastAktVerwendung($mitarbeiter->uid);
|
||||
$bisverwendung->result[] = $bisverwendung;
|
||||
}
|
||||
|
||||
foreach($bisverwendung->result as $row_verwendung)
|
||||
{
|
||||
|
||||
// Bei echten Dienstvertraegen mit voller inkludierter Lehre wird kein Stundensatz
|
||||
// geliefert da dies im Vertrag inkludiert ist.
|
||||
if ((in_array($row_verwendung->ba1code, $arrEchterDV)) && $row_verwendung->inkludierte_lehre == -1)
|
||||
{
|
||||
$data = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$return = true;
|
||||
}
|
||||
else
|
||||
$data = $mitarbeiter->stundensatz;
|
||||
$return = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$errormsg = 'Fehler beim Laden des Mitarbeitenden';
|
||||
$return = false;
|
||||
{
|
||||
$errormsg = 'Fehler beim Laden des Mitarbeitenden';
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$errormsg = 'MitarbeitendeUID muss uebergeben werden';
|
||||
$errormsg = 'MitarbeitendeUID und Studiensemester muessen uebergeben werden';
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,15 +261,25 @@ echo "<?xml-stylesheet href=\"".APP_ROOT."content/bindings.css\" type=\"text/css
|
||||
<hbox>
|
||||
<label value="Note" control="lehrveranstaltung-noten-menulist-note"/>
|
||||
<menulist id="lehrveranstaltung-noten-menulist-note" disabled="true"
|
||||
datasources="<?php echo APP_ROOT ?>rdf/note.rdf.php" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste"
|
||||
oncommand="LehrveranstaltungNoteSpeichern()">
|
||||
xmlns:NOTE="http://www.technikum-wien.at/note/rdf#"
|
||||
datasources="<?php echo APP_ROOT ?>rdf/note.rdf.php" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste"
|
||||
oncommand="LehrveranstaltungNoteSpeichern()">
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
<rule NOTE:aktiv='false'>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*" style="text-decoration:line-through;"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
</menulist>
|
||||
<label value="Punkte" control="lehrveranstaltung-noten-textbox-punkte" hidden="<?php echo $punktehidden; ?>"/>
|
||||
|
||||
@@ -1228,6 +1228,7 @@ function LeMitarbeiterLektorChange()
|
||||
|
||||
req.add('type', 'getstundensatz');
|
||||
req.add('mitarbeiter_uid', mitarbeiter_uid);
|
||||
req.add('studiensemester_kurzbz', getStudiensemester());
|
||||
|
||||
var response = req.executePOST();
|
||||
|
||||
@@ -1340,6 +1341,7 @@ function LeMitarbeiterAuswahl()
|
||||
|
||||
req_stundensatz.add('type', 'getstundensatz');
|
||||
req_stundensatz.add('mitarbeiter_uid', mitarbeiter_uid);
|
||||
req_stundensatz.add('studiensemester_kurzbz', getStudiensemester());
|
||||
|
||||
var response_stundensatz = req_stundensatz.executePOST();
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ require_once('../../include/lehreinheitmitarbeiter.class.php');
|
||||
require_once('../../include/lehreinheit.class.php');
|
||||
require_once('../../include/projektbetreuer.class.php');
|
||||
require_once('../../include/projektarbeit.class.php');
|
||||
require_once('../../include/bisverwendung.class.php');
|
||||
require_once('../../include/studiensemester.class.php');
|
||||
require_once('../../include/phrasen.class.php');
|
||||
require_once('../../include/benutzerberechtigung.class.php');
|
||||
|
||||
@@ -40,6 +40,8 @@ require_once('../../include/vertrag.class.php');
|
||||
require_once('../../include/lehreinheitmitarbeiter.class.php');
|
||||
require_once('../../include/wawi_konto.class.php');
|
||||
require_once('../../include/addon.class.php');
|
||||
require_once('../../include/stundensatz.class.php');
|
||||
|
||||
|
||||
$user = get_uid();
|
||||
|
||||
@@ -93,7 +95,6 @@ if(!$error)
|
||||
$mitarbeiter->geburtsnation = $_POST['geburtsnation'];
|
||||
$mitarbeiter->sprache = $_POST['sprache'];
|
||||
$mitarbeiter->kurzbz = $_POST['kurzbezeichnung'];
|
||||
$mitarbeiter->stundensatz = $_POST['stundensatz'];
|
||||
$mitarbeiter->telefonklappe = $_POST['telefonklappe'];
|
||||
$mitarbeiter->lektor = ($_POST['lektor']=='true'?true:false);
|
||||
$mitarbeiter->fixangestellt = ($_POST['fixangestellt']=='true'?true:false);
|
||||
@@ -808,6 +809,61 @@ if(!$error)
|
||||
$errormsg = "";
|
||||
}
|
||||
}
|
||||
else if (isset($_POST['type']) && $_POST['type'] === 'updateStundensatz')
|
||||
{
|
||||
$mitarbeiter_uid = $_POST['mitarbeiter_uid'];
|
||||
$stundenbetrag = $_POST['stundensatz'];
|
||||
$datum_von = $_POST['datum_von'];
|
||||
$datum_bis = $_POST['datum_bis'];
|
||||
$unternehmen = $_POST['unternehmen'];
|
||||
$stundensatztyp = $_POST['typ'];
|
||||
if (isset($_POST['stundensatz_id']))
|
||||
{
|
||||
$stundensatz = new stundensatz();
|
||||
$stundensatz->load($_POST['stundensatz_id']);
|
||||
$stundensatz->new = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stundensatz = new stundensatz();
|
||||
$stundensatz->new = true;
|
||||
}
|
||||
|
||||
$stundensatz->uid = $mitarbeiter_uid;
|
||||
$stundensatz->stundensatztyp = $stundensatztyp;
|
||||
$stundensatz->stundensatz = $stundenbetrag;
|
||||
$stundensatz->oe_kurzbz = $unternehmen;
|
||||
$stundensatz->gueltig_von = $datum_von;
|
||||
$stundensatz->gueltig_bis = $datum_bis;
|
||||
$stundensatz->insertvon = $user;
|
||||
$stundensatz->updatevon = $user;
|
||||
$stundensatz->insertamum = date('Y-m-d H:i:s');
|
||||
$stundensatz->updateamum = date('Y-m-d H:i:s');
|
||||
|
||||
if ($stundensatz->save())
|
||||
{
|
||||
$data = $stundensatz->stundensatz_id;
|
||||
$return = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$errormsg = $stundensatz->errormsg;
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
else if (isset($_POST['type']) && $_POST['type'] === 'deleteStundensatz')
|
||||
{
|
||||
$stundensatz = new stundensatz();
|
||||
if ($stundensatz->delete($_POST['stundensatz_id']))
|
||||
{
|
||||
$return = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = false;
|
||||
$errormsg = $stundensatz->errormsg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = false;
|
||||
|
||||
@@ -227,8 +227,6 @@ echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
|
||||
<checkbox label="Kleriker" id="mitarbeiter-detail-checkbox-kleriker" checked="false" disabled="true" hidden="true" onchange="MitarbeiterDetailValueChange()"/>
|
||||
</row>
|
||||
<row>
|
||||
<label align="end" control="mitarbeiter-detail-textbox-stundensatz" value="Stundensatz"/>
|
||||
<textbox id="mitarbeiter-detail-textbox-stundensatz" size="10" maxlength="10" disabled="true" oninput="MitarbeiterDetailValueChange()"/>
|
||||
<label align="end" control="mitarbeiter-detail-textbox-telefonklappe" value="Telefonklappe"/>
|
||||
<hbox>
|
||||
<textbox id="mitarbeiter-detail-textbox-telefonklappe" size="10" maxlength="10" disabled="true" oninput="MitarbeiterDetailValueChange()"/>
|
||||
|
||||
@@ -436,7 +436,6 @@ function MitarbeiterDetailDisableFields(val)
|
||||
//document.getElementById('mitarbeiter-detail-textbox-personalnummer').disabled=val;
|
||||
document.getElementById('mitarbeiter-detail-textbox-kurzbezeichnung').disabled=val;
|
||||
document.getElementById('mitarbeiter-detail-checkbox-lektor').disabled=val;
|
||||
document.getElementById('mitarbeiter-detail-textbox-stundensatz').disabled=val;
|
||||
document.getElementById('mitarbeiter-detail-textbox-telefonklappe').disabled=val;
|
||||
document.getElementById('mitarbeiter-detail-checkbox-fixangestellt').disabled=val;
|
||||
document.getElementById('mitarbeiter-detail-checkbox-bismelden').disabled=val;
|
||||
@@ -557,7 +556,6 @@ function MitarbeiterAuswahl()
|
||||
|
||||
personalnummer=getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#personalnummer" ));
|
||||
kurzbezeichnung=getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#kurzbz" ));
|
||||
stundensatz=getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#stundensatz" ));
|
||||
telefonklappe=getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#telefonklappe" ));
|
||||
lektor=getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#lektor" ));
|
||||
fixangestellt=getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#fixangestellt" ));
|
||||
@@ -605,7 +603,6 @@ function MitarbeiterAuswahl()
|
||||
//Mitarbeiterdaten
|
||||
document.getElementById('mitarbeiter-detail-textbox-personalnummer').value=personalnummer;
|
||||
document.getElementById('mitarbeiter-detail-textbox-kurzbezeichnung').value=kurzbezeichnung;
|
||||
document.getElementById('mitarbeiter-detail-textbox-stundensatz').value=stundensatz;
|
||||
document.getElementById('mitarbeiter-detail-textbox-telefonklappe').value=telefonklappe;
|
||||
if(lektor=='Ja')
|
||||
document.getElementById('mitarbeiter-detail-checkbox-lektor').checked=true;
|
||||
@@ -652,6 +649,8 @@ function MitarbeiterAuswahl()
|
||||
document.getElementById('mitarbeiter-udf').setAttribute('src', 'udf.xul.php?person_id='+person_id);
|
||||
}
|
||||
|
||||
document.getElementById('mitarbeiter-stundensatz').setAttribute('src','mitarbeiter/stundensatzoverlay.xul.php?mitarbeiter_uid='+uid);
|
||||
|
||||
// **** VERWENDUNG ****
|
||||
verwendungtree = document.getElementById('mitarbeiter-tree-verwendung');
|
||||
url='<?php echo APP_ROOT;?>rdf/bisverwendung.rdf.php?uid='+uid+"&"+gettimestamp();
|
||||
@@ -843,7 +842,6 @@ function MitarbeiterSave()
|
||||
//Mitarbeiterdaten
|
||||
personalnummer = document.getElementById('mitarbeiter-detail-textbox-personalnummer').value;
|
||||
kurzbezeichnung = document.getElementById('mitarbeiter-detail-textbox-kurzbezeichnung').value;
|
||||
stundensatz = document.getElementById('mitarbeiter-detail-textbox-stundensatz').value;
|
||||
telefonklappe = document.getElementById('mitarbeiter-detail-textbox-telefonklappe').value;
|
||||
lektor = document.getElementById('mitarbeiter-detail-checkbox-lektor').checked;
|
||||
fixangestellt = document.getElementById('mitarbeiter-detail-checkbox-fixangestellt').checked;
|
||||
@@ -895,7 +893,6 @@ function MitarbeiterSave()
|
||||
req.add('geburtsnation', geburtsnation);
|
||||
req.add('sprache', sprache);
|
||||
req.add('kurzbezeichnung', kurzbezeichnung);
|
||||
req.add('stundensatz', stundensatz);
|
||||
req.add('telefonklappe', telefonklappe);
|
||||
req.add('lektor', lektor);
|
||||
req.add('fixangestellt', fixangestellt);
|
||||
|
||||
@@ -268,6 +268,7 @@ echo '<?xul-overlay href="'.APP_ROOT.'content/mitarbeiter/mitarbeitervertragover
|
||||
?>
|
||||
<tab id="mitarbeiter-tab-termine" label="Termine" onclick="MitarbeiterTermineIFrameLoad()" />
|
||||
<tab id="mitarbeiter-tab-notizen" label="Notizen"/>
|
||||
<tab id="mitarbeiter-tab-stundensatz" label="Stundensätze" />
|
||||
<?php
|
||||
if (!defined('FAS_UDF') || FAS_UDF == true)
|
||||
echo '<tab id="mitarbeiter-tab-udf" label="Zusatzfelder" onclick="MitarbeiterUDFIFrameLoad()"/>';
|
||||
@@ -289,6 +290,7 @@ echo '<?xul-overlay href="'.APP_ROOT.'content/mitarbeiter/mitarbeitervertragover
|
||||
<vbox id="mitarbeiter-box-notiz">
|
||||
<box class="Notiz" flex="1" id="mitarbeiter-box-notizen"/>
|
||||
</vbox>
|
||||
<iframe id="mitarbeiter-stundensatz" src="" style="margin-top:10px;" />
|
||||
<?php
|
||||
if (!defined('FAS_UDF') || FAS_UDF == true)
|
||||
echo '<iframe id="mitarbeiter-udf" src="" style="margin-top:10px;" />';
|
||||
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
require_once('../../config/vilesci.config.inc.php');
|
||||
?>
|
||||
|
||||
var StundensaetzeTreeDatasource = ''; // Datasource des Stundensaetze Trees
|
||||
var StundensatzSelectID = null;
|
||||
var MitarbeiterUID = '';
|
||||
var StundensatzChanged = false;
|
||||
var DoubleRefresh = false
|
||||
|
||||
var StundensaetzeSinkObserver =
|
||||
{
|
||||
onBeginLoad : function(pSink) {},
|
||||
onInterrupt : function(pSink) {},
|
||||
onResume : function(pSink) {},
|
||||
onError : function(pSink, pStatus, pError) {},
|
||||
onEndLoad : function(pSink)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
document.getElementById('stundensaetze-tree').builder.rebuild();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var StundensaetzeTreeListener =
|
||||
{
|
||||
willRebuild : function(builder) { },
|
||||
didRebuild : function(builder)
|
||||
{
|
||||
if(DoubleRefresh === true)
|
||||
{
|
||||
window.setTimeout('StundensatzTreeDatasourceRefresh()',10);
|
||||
DoubleRefresh = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//timeout nur bei Mozilla notwendig da sonst die rows
|
||||
//noch keine values haben. Ab Seamonkey funktionierts auch
|
||||
//ohne dem setTimeout
|
||||
window.setTimeout(StundensaetzeTreeSelectID, 10);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function StundensatzTreeDatasourceRefresh(StundensatzSelect)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
StundensaetzeTreeDatasource.Refresh(false);
|
||||
}
|
||||
|
||||
function StundensatzDisableFields(val)
|
||||
{
|
||||
|
||||
document.getElementById('mitarbeiter-stundensatz-button-neu').disabled = val;
|
||||
document.getElementById('mitarbeiter-stundensatz-button-loeschen').disabled = val;
|
||||
}
|
||||
|
||||
function StundensatzNeu()
|
||||
{
|
||||
StundensatzDetailResetFields();
|
||||
StundensatzDetailsDisableFields(false);
|
||||
StundensatzChanged = false;
|
||||
}
|
||||
|
||||
function StundensatzDetailsDisableFields(val)
|
||||
{
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-stundensatz').disabled = val;
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-unternehmen').disabled = val;
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-typ').disabled = val;
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-von').disabled = val;
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-bis').disabled = val;
|
||||
document.getElementById('mitarbeiter-stundensatz-button-speichern').disabled = val;
|
||||
}
|
||||
|
||||
|
||||
// ****
|
||||
// * Setzt Defaultwerte fuer die Felder
|
||||
// ****
|
||||
function StundensatzDetailResetFields()
|
||||
{
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-stundensatz').value = '';
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-von').value = '';
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-bis').value = '';
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-unternehmen').value = '';
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-typ').value = '';
|
||||
|
||||
var Datum = new Date();
|
||||
var Jahr = Datum.getFullYear();
|
||||
var Tag = Datum.getDate();
|
||||
var Monat = Datum.getMonth()+1;
|
||||
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-von').value = Tag+'.'+Monat+'.'+Jahr;
|
||||
}
|
||||
|
||||
// ****
|
||||
// * Laedt die Studensätze
|
||||
// ****
|
||||
function loadStundensaetze(mitarbeiter_uid)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
MitarbeiterUID = mitarbeiter_uid;
|
||||
var url = "<?php echo APP_ROOT; ?>rdf/stundensatz.rdf.php?mitarbeiter_uid="+mitarbeiter_uid+'&'+gettimestamp();
|
||||
var tree = document.getElementById('stundensaetze-tree');
|
||||
|
||||
//Alte DS entfernen
|
||||
var oldDatasources = tree.database.GetDataSources();
|
||||
while(oldDatasources.hasMoreElements())
|
||||
{
|
||||
tree.database.RemoveDataSource(oldDatasources.getNext());
|
||||
}
|
||||
tree.builder.rebuild();
|
||||
|
||||
try
|
||||
{
|
||||
StundensaetzeTreeDatasource.removeXMLSinkObserver(StundensaetzeSinkObserver);
|
||||
tree.builder.removeListener(StundensaetzeTreeListener);
|
||||
}
|
||||
catch(e)
|
||||
{}
|
||||
|
||||
var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
StundensaetzeTreeDatasource = rdfService.GetDataSource(url);
|
||||
|
||||
StundensaetzeTreeDatasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
|
||||
StundensaetzeTreeDatasource.QueryInterface(Components.interfaces.nsIRDFXMLSink);
|
||||
tree.database.AddDataSource(StundensaetzeTreeDatasource);
|
||||
StundensaetzeTreeDatasource.addXMLSinkObserver(StundensaetzeSinkObserver);
|
||||
tree.builder.addListener(StundensaetzeTreeListener);
|
||||
|
||||
StundensatzDisableFields(false);
|
||||
}
|
||||
|
||||
|
||||
// ****
|
||||
// * Selectiert einen Stundensatz nachdem der Tree
|
||||
// * rebuildet wurde.
|
||||
// ****
|
||||
function StundensaetzeTreeSelectID()
|
||||
{
|
||||
var tree = document.getElementById('stundensaetze-tree');
|
||||
var items = tree.view.rowCount; //Anzahl der Zeilen ermitteln
|
||||
|
||||
//In der globalen Variable ist der zu selektierender Stundensatz gespeichert
|
||||
if(StundensatzSelectID != null)
|
||||
{
|
||||
for(var i = 0; i < items; i++)
|
||||
{
|
||||
//ID der row holen
|
||||
col = tree.columns ? tree.columns["stundensatz-treecol-stundensatz_id"] : "stundensatz-treecol-stundensatz_id";
|
||||
id = tree.view.getCellText(i,col);
|
||||
|
||||
if(id === StundensatzSelectID)
|
||||
{
|
||||
//Zeile markieren
|
||||
tree.view.selection.select(i);
|
||||
//Sicherstellen, dass die Zeile im sichtbaren Bereich liegt
|
||||
tree.treeBoxObject.ensureRowIsVisible(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
StundensatzSelectID = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function StundensatzDetailSpeichern()
|
||||
{
|
||||
var stundensatz = document.getElementById('mitarbeiter-stundensatz-textbox-stundensatz').value;
|
||||
var datum_von = document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-von').value;
|
||||
var datum_bis = document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-bis').value;
|
||||
var unternehmen = document.getElementById('mitarbeiter-stundensatz-textbox-unternehmen').value;
|
||||
var typ = document.getElementById('mitarbeiter-stundensatz-textbox-typ').value;
|
||||
|
||||
var url = '<?php echo APP_ROOT ?>content/mitarbeiter/mitarbeiterDBDML.php';
|
||||
var req = new phpRequest(url,'','');
|
||||
|
||||
if (StundensatzChanged !== false)
|
||||
req.add('stundensatz_id', StundensatzChanged);
|
||||
|
||||
req.add('type', 'updateStundensatz');
|
||||
req.add('mitarbeiter_uid', MitarbeiterUID);
|
||||
req.add('stundensatz', stundensatz);
|
||||
req.add('datum_von', ConvertDateToISO(datum_von));
|
||||
req.add('datum_bis', ConvertDateToISO(datum_bis));
|
||||
req.add('unternehmen', unternehmen);
|
||||
req.add('typ', typ);
|
||||
|
||||
var response = req.executePOST();
|
||||
|
||||
var val = new ParseReturnValue(response)
|
||||
|
||||
if (!val.dbdml_return)
|
||||
{
|
||||
if (val.dbdml_errormsg === '')
|
||||
alert(response)
|
||||
else
|
||||
alert(val.dbdml_errormsg)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(val.dbdml_errormsg !== '' && val.dbdml_errormsg !== 'unknown')
|
||||
alert(val.dbdml_errormsg);
|
||||
|
||||
if(document.getElementById('stundensaetze-tree').view.rowCount === 0)
|
||||
{
|
||||
DoubleRefresh = true;
|
||||
}
|
||||
StundensatzSelectID = val.dbdml_data;
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
StundensaetzeTreeDatasource.Refresh(false);
|
||||
StundensatzChanged = false;
|
||||
StundensatzDetailResetFields();
|
||||
StundensatzDetailsDisableFields(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function StundensatzBearbeiten()
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
var tree = document.getElementById('stundensaetze-tree');
|
||||
|
||||
if (tree.currentIndex === -1)
|
||||
return;
|
||||
|
||||
//Ausgewaehlten Stundensatz holen
|
||||
var col = tree.columns ? tree.columns["stundensatz-treecol-stundensatz_id"] : "stundensatz-treecol-stundensatz_id";
|
||||
var stundensatz_id = tree.view.getCellText(tree.currentIndex,col);
|
||||
|
||||
//Daten holen
|
||||
var url = "<?php echo APP_ROOT; ?>rdf/stundensatz.rdf.php?stundensatz_id="+stundensatz_id+'&'+gettimestamp();
|
||||
|
||||
var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
|
||||
var dsource = rdfService.GetDataSourceBlocking(url);
|
||||
|
||||
var subject = rdfService.GetResource("http://www.technikum-wien.at/stundensatz/"+stundensatz_id);
|
||||
|
||||
var predicateNS = "http://www.technikum-wien.at/stundensatz/rdf";
|
||||
|
||||
//Daten holen
|
||||
var stundensatz = getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#stundensatz"));
|
||||
var datum_von = getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#gueltig_von" ));
|
||||
var datum_bis = getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#gueltig_bis" ));
|
||||
var unternehmen = getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#oe_kurzbz" ));
|
||||
var typ = getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#stundensatztyp" ));
|
||||
|
||||
StundensatzChanged = getTargetHelper(dsource,subject,rdfService.GetResource( predicateNS + "#stundensatz_id" ));
|
||||
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-stundensatz').value = stundensatz;
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-von').value = datum_von;
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-gueltig-bis').value = datum_bis;
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-unternehmen').value = unternehmen;
|
||||
document.getElementById('mitarbeiter-stundensatz-textbox-typ').value = typ;
|
||||
|
||||
StundensatzDetailsDisableFields(false);
|
||||
}
|
||||
|
||||
function StundensatzDelete()
|
||||
{
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var tree = document.getElementById('stundensaetze-tree');
|
||||
|
||||
if (tree.currentIndex === -1)
|
||||
{
|
||||
alert('Bitte zuerst einen Stundensatz auswaehlen');
|
||||
return;
|
||||
}
|
||||
|
||||
StundensatzDetailsDisableFields(false);
|
||||
|
||||
//Ausgewaehlten Stundensatz holen
|
||||
var col = tree.columns ? tree.columns["stundensatz-treecol-stundensatz_id"] : "stundensatz-treecol-stundensatz_id";
|
||||
var stundensatz_id = tree.view.getCellText(tree.currentIndex,col);
|
||||
|
||||
if (confirm('Diesen Stundensatz wirklich loeschen?'))
|
||||
{
|
||||
var url = '<?php echo APP_ROOT ?>content/mitarbeiter/mitarbeiterDBDML.php';
|
||||
var req = new phpRequest(url,'','');
|
||||
|
||||
req.add('type', 'deleteStundensatz');
|
||||
req.add('stundensatz_id', stundensatz_id);
|
||||
|
||||
var response = req.executePOST();
|
||||
|
||||
var val = new ParseReturnValue(response)
|
||||
|
||||
if (!val.dbdml_return)
|
||||
{
|
||||
if (val.dbdml_errormsg === '')
|
||||
alert(response)
|
||||
else
|
||||
alert(val.dbdml_errormsg)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
StundensaetzeTreeDatasource.Refresh(false);
|
||||
StundensatzDetailResetFields();
|
||||
StundensatzDetailsDisableFields(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache");
|
||||
header("Cache-Control: post-check=0, pre-check=0",false);
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Pragma: no-cache");
|
||||
header("Content-type: application/vnd.mozilla.xul+xml");
|
||||
|
||||
include('../../config/vilesci.config.inc.php');
|
||||
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
|
||||
echo '<?xml-stylesheet href="'.APP_ROOT.'skin/tempus.css" type="text/css"?>';
|
||||
echo '<?xml-stylesheet href="'.APP_ROOT.'content/bindings.css" type="text/css"?>';
|
||||
echo '<?xml-stylesheet href="'.APP_ROOT.'content/datepicker/datepicker.css" type="text/css"?>';
|
||||
|
||||
if(isset($_GET['mitarbeiter_uid']))
|
||||
$mitarbeiter_uid = $_GET['mitarbeiter_uid'];
|
||||
else
|
||||
die('Parameter mitarbeiter_uid muss uebergeben werden');
|
||||
|
||||
?>
|
||||
|
||||
<window id="stundensaetze-window" title="Stundensaetze"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="loadStundensaetze('<?php echo $mitarbeiter_uid; ?>');"
|
||||
>
|
||||
<script type="application/x-javascript" src="<?php echo APP_ROOT; ?>content/functions.js.php" />
|
||||
<script type="application/x-javascript" src="<?php echo APP_ROOT; ?>content/mitarbeiter/stundensatzoverlay.js.php" />
|
||||
<script type="application/x-javascript" src="<?php echo APP_ROOT; ?>content/fasoverlay.js.php" />
|
||||
<script type="application/x-javascript" src="<?php echo APP_ROOT; ?>content/phpRequest.js.php" />
|
||||
|
||||
<hbox flex="1">
|
||||
<!-- STUNDENSÄTZE -->
|
||||
<vbox flex="4">
|
||||
<tree id="stundensaetze-tree" seltype="single" hidecolumnpicker="false" flex="2"
|
||||
datasources="rdf:null" ref="http://www.technikum-wien.at/stundensatz/liste"
|
||||
onselect="StundensatzBearbeiten()"
|
||||
flags="dont-build-content"
|
||||
enableColumnDrag="true"
|
||||
style="margin-left:10px;margin-right:10px;margin-bottom:5px;" height="100"
|
||||
persist="hidden, height"
|
||||
>
|
||||
<treecols>
|
||||
<treecol id="stundensatz-treecol-stundensatz_id" label="StundensatzID" flex="1" hidden="true"
|
||||
class="sortDirectionIndicator"
|
||||
sort="rdf:http://www.technikum-wien.at/stundensatz/rdf#stundensatz_id"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="stundensatz-treecol-stundensatz" label="Stundensatz" flex="1" hidden="false"
|
||||
class="sortDirectionIndicator"
|
||||
sort="rdf:http://www.technikum-wien.at/stundensatz/rdf#stundensatz"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="stundensatz-treecol-oe_kurzbz_bezeichnung" label="Unternehmen" flex="1" hidden="false"
|
||||
class="sortDirectionIndicator"
|
||||
sort="rdf:http://www.technikum-wien.at/stundensatz/rdf#oe_kurzbz_bezeichnung"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="stundensatz-treecol-stundensatz-typ" label="Stundensatztyp" flex="1" hidden="false"
|
||||
class="sortDirectionIndicator"
|
||||
sort="rdf:http://www.technikum-wien.at/stundensatz/rdf#stundensatztyp_bezeichnung"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="stundensatz-treecol-gueltig_von" label="Gültig von" flex="1" hidden="false"
|
||||
class="sortDirectionIndicator"
|
||||
sort="rdf:http://www.technikum-wien.at/stundensatz/rdf#gueltig_von"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="stundensatz-treecol-gueltig_bis" label="Gültig bis" flex="1" hidden="false"
|
||||
class="sortDirectionIndicator"
|
||||
sort="rdf:http://www.technikum-wien.at/stundensatz/rdf#gueltig_bis"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
</treecols>
|
||||
|
||||
<template>
|
||||
<rule>
|
||||
<treechildren>
|
||||
<treeitem uri="rdf:*">
|
||||
<treerow>
|
||||
<treecell label="rdf:http://www.technikum-wien.at/stundensatz/rdf#stundensatz_id" />
|
||||
<treecell label="rdf:http://www.technikum-wien.at/stundensatz/rdf#stundensatz" />
|
||||
<treecell label="rdf:http://www.technikum-wien.at/stundensatz/rdf#oe_kurzbz_bezeichnung" />
|
||||
<treecell label="rdf:http://www.technikum-wien.at/stundensatz/rdf#stundensatztyp_bezeichnung" />
|
||||
<treecell label="rdf:http://www.technikum-wien.at/stundensatz/rdf#gueltig_von" />
|
||||
<treecell label="rdf:http://www.technikum-wien.at/stundensatz/rdf#gueltig_bis" />
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</rule>
|
||||
</template>
|
||||
</tree>
|
||||
</vbox>
|
||||
<vbox flex="1">
|
||||
<hbox>
|
||||
<button id="mitarbeiter-stundensatz-button-neu" label="Neu" oncommand="StundensatzNeu();" disabled="true"/>
|
||||
<button id="mitarbeiter-stundensatz-button-loeschen" label="Loeschen" oncommand="StundensatzDelete();" disabled="true"/>
|
||||
</hbox>
|
||||
<vbox hidden="true">
|
||||
<label value="Stundensatz" control="mitarbeiter-stundensatz-textbox-stundensatz_id"/>
|
||||
<textbox id="mitarbeiter-stundensatz-textbox-stundensatz_id" disabled="true"/>
|
||||
</vbox>
|
||||
<groupbox id="mitarbeiter-stundensatz-groupbox">
|
||||
<caption label="Details"/>
|
||||
<grid id="mitarbeiter-stundensatz-grid-detail" style="overflow:auto;margin:4px;" flex="1">
|
||||
<columns >
|
||||
<column flex="1"/>
|
||||
<column flex="5"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="Stundensatz" control="mitarbeiter-stundensatz-textbox-stundensatz"/>
|
||||
<hbox>
|
||||
<textbox id="mitarbeiter-stundensatz-textbox-stundensatz" disabled="true" maxlength="9" size="9"/>
|
||||
<spacer flex="1" />
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<label value="Stundensatztyp" control="mitarbeiter-stundensatz-textbox-typ"/>
|
||||
<menulist id="mitarbeiter-stundensatz-textbox-typ"
|
||||
flex="1"
|
||||
disabled="true"
|
||||
xmlns:STUNDENSATZTYP="http://www.technikum-wien.at/stundensatztyp/rdf#"
|
||||
datasources="<?php echo APP_ROOT;?>rdf/stundensatztyp.rdf.php"
|
||||
ref="http://www.technikum-wien.at/stundensatztyp/liste" >
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/stundensatztyp/rdf#typ"
|
||||
label="rdf:http://www.technikum-wien.at/stundensatztyp/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</template>
|
||||
</menulist>
|
||||
</row>
|
||||
<row>
|
||||
<label value="Unternehmen" control="mitarbeiter-stundensatz-textbox-unternehmen"/>
|
||||
<menulist id="mitarbeiter-stundensatz-textbox-unternehmen"
|
||||
flex="1"
|
||||
disabled="true"
|
||||
xmlns:ORGANISATIONSEINHEIT="http://www.technikum-wien.at/organisationseinheit/rdf#"
|
||||
datasources="<?php echo APP_ROOT;?>rdf/organisationseinheit.rdf.php?onlyRoots=true"
|
||||
ref="http://www.technikum-wien.at/organisationseinheit/liste" >
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/organisationseinheit/rdf#oe_kurzbz"
|
||||
label="rdf:http://www.technikum-wien.at/organisationseinheit/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</template>
|
||||
</menulist>
|
||||
</row>
|
||||
<row>
|
||||
<label value="Gültig von" control="mitarbeiter-stundensatz-textbox-gueltig-von"/>
|
||||
<hbox>
|
||||
<box class="Datum" id="mitarbeiter-stundensatz-textbox-gueltig-von" disabled="true"/>
|
||||
<spacer flex="1" />
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<label value="Gültig bis" control="mitarbeiter-stundensatz-textbox-gueltig-bis"/>
|
||||
<hbox>
|
||||
<box class="Datum" id="mitarbeiter-stundensatz-textbox-gueltig-bis" disabled="true"/>
|
||||
<spacer flex="1" />
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<hbox>
|
||||
<spacer flex="1" />
|
||||
<button id="mitarbeiter-stundensatz-button-speichern" oncommand="StundensatzDetailSpeichern()" label="Speichern" disabled="true"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</window>
|
||||
@@ -4653,27 +4653,44 @@ if(!$error)
|
||||
}
|
||||
elseif(isset($_POST['type']) && $_POST['type']=='getstundensatz')
|
||||
{
|
||||
if(isset($_POST['person_id']))
|
||||
if(isset($_POST['person_id']) && isset($_POST['studiensemester_kurzbz']))
|
||||
{
|
||||
$qry = "SELECT stundensatz FROM public.tbl_mitarbeiter JOIN public.tbl_benutzer ON(uid=mitarbeiter_uid)
|
||||
WHERE person_id=".$db->db_add_param($_POST['person_id'], FHC_INTEGER);
|
||||
if($result = $db->db_query($qry))
|
||||
$studiensemester = new studiensemester();
|
||||
if ($studiensemester->load($_POST['studiensemester_kurzbz']))
|
||||
{
|
||||
if($row = $db->db_fetch_object($result))
|
||||
$qry = "SELECT ss.stundensatz
|
||||
FROM hr.tbl_stundensatz ss
|
||||
JOIN public.tbl_mitarbeiter ON ss.uid = tbl_mitarbeiter.mitarbeiter_uid
|
||||
JOIN public.tbl_benutzer ON(tbl_benutzer.uid=tbl_mitarbeiter.mitarbeiter_uid)
|
||||
WHERE person_id=".$db->db_add_param($_POST['person_id'], FHC_INTEGER) ."
|
||||
AND stundensatztyp = ". $db->db_add_param('lehre') ."
|
||||
AND gueltig_von <= ". $db->db_add_param($studiensemester->ende) ."
|
||||
AND (gueltig_bis >= ". $db->db_add_param($studiensemester->start) ." OR gueltig_bis IS NULL)
|
||||
ORDER BY gueltig_bis DESC NULLS FIRST, gueltig_von DESC NULLS LAST LIMIT 1
|
||||
";
|
||||
if($result = $db->db_query($qry))
|
||||
{
|
||||
$data = $row->stundensatz;
|
||||
$return = true;
|
||||
if($row = $db->db_fetch_object($result))
|
||||
{
|
||||
$data = $row->stundensatz;
|
||||
$return = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = '80.00';
|
||||
$return = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = '80.00';
|
||||
$return = true;
|
||||
$return = false;
|
||||
$errormsg = 'Unbekannter Fehler';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return = false;
|
||||
$errormsg = 'Unbekannter Fehler';
|
||||
$errormsg = 'Fehler beim Laden des Studiensemesters';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,17 +194,27 @@ echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
|
||||
<label value="Note komm. Pruefung" control="student-abschlusspruefung-menulist-notekommpruef" />
|
||||
<menulist id="student-abschlusspruefung-menulist-notekommpruef"
|
||||
disabled="true"
|
||||
xmlns:NOTE="http://www.technikum-wien.at/note/rdf#"
|
||||
datasources="<?php echo APP_ROOT;?>rdf/note.rdf.php?optional=true" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste"
|
||||
>
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</template>
|
||||
</menulist>
|
||||
<template>
|
||||
<rule NOTE:aktiv='false'>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*" style="text-decoration:line-through;"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
</menulist>
|
||||
</row>
|
||||
<row>
|
||||
<label value="Prüfungsantritt" control="student-abschlusspruefung-menulist-pruefungsantritt" />
|
||||
|
||||
@@ -346,15 +346,25 @@ echo "<?xml-stylesheet href=\"".APP_ROOT."content/bindings.css\" type=\"text/css
|
||||
<hbox>
|
||||
<label value="Note" control="student-noten-menulist-note"/>
|
||||
<menulist id="student-noten-menulist-note" disabled="true"
|
||||
datasources="<?php echo APP_ROOT ?>rdf/note.rdf.php" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste"
|
||||
oncommand="StudentNoteSpeichern()">
|
||||
xmlns:NOTE="http://www.technikum-wien.at/note/rdf#"
|
||||
datasources="<?php echo APP_ROOT ?>rdf/note.rdf.php" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste"
|
||||
oncommand="StudentNoteSpeichern()">
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
<rule NOTE:aktiv='false'>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*" style="text-decoration:line-through;"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
</menulist>
|
||||
<label value="Punkte" control="student-noten-textbox-punkte" hidden="<?php echo $punktehidden; ?>"/>
|
||||
|
||||
@@ -1367,6 +1367,7 @@ function StudentProjektbetreuerLoadMitarbeiterDaten()
|
||||
|
||||
req.add('type', 'getstundensatz');
|
||||
req.add('person_id', person_id);
|
||||
req.add('studiensemester_kurzbz', getStudiensemester())
|
||||
|
||||
var response = req.executePOST();
|
||||
|
||||
|
||||
@@ -279,14 +279,24 @@ $is_hidden = (!defined('FAS_STUDIERENDE_PROJEKTARBEIT_VERTRAGSDETAILS_ANZEIGEN')
|
||||
</hbox>
|
||||
<label value="Gesamtnote" control="student-projektarbeit-menulist-note"/>
|
||||
<menulist id="student-projektarbeit-menulist-note" disabled="true"
|
||||
datasources="<?php echo APP_ROOT ?>rdf/note.rdf.php?optional=true" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste" >
|
||||
xmlns:NOTE="http://www.technikum-wien.at/note/rdf#"
|
||||
datasources="<?php echo APP_ROOT ?>rdf/note.rdf.php?optional=true" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste" >
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
<rule NOTE:aktiv='false'>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*" style="text-decoration:line-through;"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
</menulist>
|
||||
</row>
|
||||
@@ -483,14 +493,24 @@ $is_hidden = (!defined('FAS_STUDIERENDE_PROJEKTARBEIT_VERTRAGSDETAILS_ANZEIGEN')
|
||||
<row>
|
||||
<label value="Note" control="student-projektbetreuer-menulist-note"/>
|
||||
<menulist id="student-projektbetreuer-menulist-note" disabled="true"
|
||||
datasources="<?php echo APP_ROOT ?>rdf/note.rdf.php?optional=true" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste" >
|
||||
xmlns:NOTE="http://www.technikum-wien.at/note/rdf#"
|
||||
datasources="<?php echo APP_ROOT ?>rdf/note.rdf.php?optional=true" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste" >
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
<rule NOTE:aktiv='false'>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*" style="text-decoration:line-through;"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
</menulist>
|
||||
</row>
|
||||
|
||||
@@ -216,14 +216,24 @@ echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
|
||||
<row>
|
||||
<label value="Note" control="student-pruefung-menulist-note"/>
|
||||
<menulist id="student-pruefung-menulist-note" disabled="true"
|
||||
datasources="<?php echo APP_ROOT; ?>rdf/note.rdf.php" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste" >
|
||||
xmlns:NOTE="http://www.technikum-wien.at/note/rdf#"
|
||||
datasources="<?php echo APP_ROOT; ?>rdf/note.rdf.php" flex="1"
|
||||
ref="http://www.technikum-wien.at/note/liste" >
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
<rule NOTE:aktiv='false'>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*" style="text-decoration:line-through;"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem value="rdf:http://www.technikum-wien.at/note/rdf#note"
|
||||
label="rdf:http://www.technikum-wien.at/note/rdf#bezeichnung"
|
||||
uri="rdf:*"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
</menulist>
|
||||
</row>
|
||||
|
||||
@@ -163,6 +163,44 @@ abstract class db extends basis
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the password names with the related passwords in a SQL string, to decrypt data from the DB
|
||||
*/
|
||||
protected function replaceSQLDecryptionPassword($sql)
|
||||
{
|
||||
$newSQL = null;
|
||||
|
||||
// If the global constant CI_ENVIRONMENT is not defined then return a failure
|
||||
if (!defined('CI_ENVIRONMENT')) return null;
|
||||
|
||||
if(!defined('BASEPATH'))
|
||||
define('BASEPATH', 'LEGACY_WORKAROUND'); // little trick to load a CI config file
|
||||
|
||||
// Tries to include the CI config file that contains password for the database encryption
|
||||
// If the include fails then return a failure
|
||||
if (!include(dirname(__FILE__).'/../application/config/'.CI_ENVIRONMENT.'/db_crypt.php')) return null;
|
||||
|
||||
// Array that will contains all the DB decryption password
|
||||
$decryptionPasswordsArray = array();
|
||||
// Array that will contains all the DB decryption password names
|
||||
$decryptionPasswordNamesArray = array();
|
||||
|
||||
// For each password found in the config array
|
||||
foreach ($config['encryption_passwords'] as $name => $password)
|
||||
{
|
||||
// Copy the password name using this template: '{$'<password name>'}'
|
||||
$decryptionPasswordArray[] = $password;
|
||||
$decryptionPasswordNamesArray[] = '${'.$name.'}';
|
||||
}
|
||||
|
||||
// Replace the password names with the password values
|
||||
$newSQL = str_replace($decryptionPasswordNamesArray, $decryptionPasswordArray, $sql);
|
||||
|
||||
// In case the replacement is a failure
|
||||
if ($newSQL == '' || $newSQL == null) return null;
|
||||
|
||||
return $newSQL; // OK
|
||||
}
|
||||
}
|
||||
require_once(dirname(__FILE__).'/'.DB_SYSTEM.'.class.php');
|
||||
|
||||
|
||||
@@ -230,9 +230,11 @@ class filter extends basis_db
|
||||
*/
|
||||
public function loadValues($sql, $valuename, $showvalue)
|
||||
{
|
||||
|
||||
$this->values = array();
|
||||
|
||||
// In case a decryption function is used then perform password substitution
|
||||
$sql = $this->replaceSQLDecryptionPassword($sql);
|
||||
|
||||
if($this->db_query($sql))
|
||||
{
|
||||
while($row = $this->db_fetch_row())
|
||||
|
||||
@@ -1197,6 +1197,26 @@ function anzahlTage($date1, $date2)
|
||||
return round($diff / 86400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided SQL string contains PostgreSQL functions to decrypt data, returns a boolean
|
||||
*/
|
||||
function hasSQLDecryption($sql)
|
||||
{
|
||||
return stripos($sql, 'PGP_SYM_DECRYPT') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided SQL string contains PostgreSQL functions to decrypt data,
|
||||
* and if it is used a variable instead of a readable password. Returns a boolean
|
||||
*/
|
||||
function isSQLDecryptionValid($sql)
|
||||
{
|
||||
// If the SQL string contains decryption functions and there are _no_ password variables
|
||||
if (hasSQLDecryption($sql) && strpos($sql, '${') === false) return false; // then return false
|
||||
|
||||
return true; // in any other case return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt zurück, ob ein String ausschließlich erlaubte Zeichen enthält
|
||||
* erlaubt: Buchstaben a-z, A-Z, 0-9, -, _
|
||||
@@ -1205,10 +1225,10 @@ function anzahlTage($date1, $date2)
|
||||
*/
|
||||
function hasOnlyAllowedChars($stringToCheck)
|
||||
{
|
||||
if (!preg_match("#^[a-zA-Z0-9_-]+$#", $stringToCheck))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
if (!preg_match("#^[a-zA-Z0-9_-]+$#", $stringToCheck))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+219
-48
@@ -1067,10 +1067,12 @@ class mitarbeiter extends benutzer
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt ein Array mit den UIDs der Vorgesetzten zurück
|
||||
* Gibt ein Array mit den UIDs der aktuellen Vorgesetzten zurück
|
||||
* @param null $uid
|
||||
* @param null $limit LIMIT = 1 liefert bei mehreren Vorgesetzten den letzten (aktuellsten) zurück.
|
||||
* @return uid
|
||||
*/
|
||||
public function getVorgesetzte($uid=null)
|
||||
public function getVorgesetzte($uid=null, $limit = null)
|
||||
{
|
||||
$return=false;
|
||||
if (is_null($uid))
|
||||
@@ -1084,14 +1086,40 @@ class mitarbeiter extends benutzer
|
||||
funktion_kurzbz='Leitung' AND
|
||||
(datum_von is null OR datum_von<=now()) AND
|
||||
(datum_bis is null OR datum_bis>=now()) AND
|
||||
oe_kurzbz in (SELECT oe_kurzbz
|
||||
FROM public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
oe_kurzbz in (
|
||||
SELECT
|
||||
oe_kurzbz
|
||||
FROM
|
||||
public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
funktion_kurzbz='oezuordnung' AND uid=".$this->db_add_param($uid)." AND
|
||||
(datum_von is null OR datum_von<=now()) AND
|
||||
(datum_bis is null OR datum_bis>=now())
|
||||
);";
|
||||
ORDER BY
|
||||
(
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil_funktion
|
||||
JOIN hr.tbl_vertragsbestandteil vbsfkt USING(vertragsbestandteil_id)
|
||||
JOIN hr.tbl_vertragsbestandteil vbskarenz USING(dienstverhaeltnis_id)
|
||||
WHERE
|
||||
tbl_vertragsbestandteil_funktion.benutzerfunktion_id=tbl_benutzerfunktion.benutzerfunktion_id
|
||||
AND vbskarenz.vertragsbestandteiltyp_kurzbz='karenz'
|
||||
AND
|
||||
(
|
||||
now()::date BETWEEN COALESCE(vbskarenz.von, '1970-01-01') AND COALESCE(vbskarenz.bis, '2170-12-31')
|
||||
OR
|
||||
now()::date BETWEEN COALESCE(vbskarenz.von, '1970-01-01') AND COALESCE(vbskarenz.bis, '2170-12-31')
|
||||
)
|
||||
) NULLS FIRST LIMIT 1
|
||||
)
|
||||
ORDER BY datum_von DESC ";
|
||||
|
||||
if (is_numeric($limit))
|
||||
{
|
||||
$qry .= 'LIMIT '. $this->db_add_param($limit, FHC_INTEGER);
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
@@ -1113,11 +1141,146 @@ class mitarbeiter extends benutzer
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft ob eine Person im angegebenen Zeitraum Vorgesetzter von einem Mitarbeiter ist
|
||||
* @param $leiter UID der zu pruefenden Leitungsposition
|
||||
* @param $mitarbeiter UID der zu pruefenden Leitungsposition
|
||||
* @param $datumvon Von Datum des zu pruefenden Zeitraums
|
||||
* @param $datumbis BIS Datum des zu pruefenden Zeitraums
|
||||
*/
|
||||
public function isVorgesetzterByDate($leiter, $mitarbeiter, $datumvon, $datumbis)
|
||||
{
|
||||
// Alle OEs der zu pruefenden Leitungsposition holen (oes_leitung)
|
||||
// Alle OEs des zu pruefenden Mitarbeiters holen (oes_mitarbeiter)
|
||||
// OE-Ueberschneidungen pruefen
|
||||
|
||||
$qry = "
|
||||
WITH RECURSIVE
|
||||
oes_leitung (oe_kurzbz, oe_parent_kurzbz, level) AS
|
||||
(
|
||||
SELECT
|
||||
oe_kurzbz,
|
||||
oe_parent_kurzbz,
|
||||
1 as level
|
||||
FROM
|
||||
public.tbl_organisationseinheit
|
||||
WHERE
|
||||
oe_kurzbz IN (
|
||||
|
||||
-- Leitung im Zeitraum X
|
||||
SELECT oe_kurzbz FROM public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
funktion_kurzbz='Leitung'
|
||||
AND uid=".$this->db_add_param($leiter)."
|
||||
AND
|
||||
(
|
||||
".$this->db_add_param($datumvon)." BETWEEN COALESCE(tbl_benutzerfunktion.datum_von, '1970-01-01') AND COALESCE(tbl_benutzerfunktion.datum_bis, '2170-12-31')
|
||||
OR
|
||||
".$this->db_add_param($datumbis)." BETWEEN COALESCE(tbl_benutzerfunktion.datum_von, '1970-01-01') AND COALESCE(tbl_benutzerfunktion.datum_bis, '2170-12-31')
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
o.oe_kurzbz,
|
||||
o.oe_parent_kurzbz,
|
||||
oes_leitung.level + 1 as level
|
||||
FROM
|
||||
public.tbl_organisationseinheit o, oes_leitung
|
||||
WHERE
|
||||
o.oe_parent_kurzbz = oes_leitung.oe_kurzbz
|
||||
),
|
||||
oes_mitarbeiter (oe_kurzbz, oe_parent_kurzbz, level) AS
|
||||
(
|
||||
SELECT
|
||||
oe_kurzbz,
|
||||
oe_parent_kurzbz,
|
||||
1 as level
|
||||
FROM
|
||||
public.tbl_organisationseinheit
|
||||
WHERE
|
||||
oe_kurzbz IN (
|
||||
|
||||
-- OEZuordnung im Zeitraum X - bevorzugt nicht karenziert
|
||||
SELECT oe_kurzbz FROM public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
funktion_kurzbz='oezuordnung'
|
||||
AND uid=".$this->db_add_param($mitarbeiter)."
|
||||
AND (
|
||||
".$this->db_add_param($datumvon)." BETWEEN COALESCE(tbl_benutzerfunktion.datum_von, '1970-01-01') AND COALESCE(tbl_benutzerfunktion.datum_bis, '2170-12-31')
|
||||
OR
|
||||
".$this->db_add_param($datumbis)." BETWEEN COALESCE(tbl_benutzerfunktion.datum_von, '1970-01-01') AND COALESCE(tbl_benutzerfunktion.datum_bis, '2170-12-31')
|
||||
)
|
||||
ORDER BY
|
||||
(
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil_funktion
|
||||
JOIN hr.tbl_vertragsbestandteil vbsfkt USING(vertragsbestandteil_id)
|
||||
JOIN hr.tbl_vertragsbestandteil vbskarenz USING(dienstverhaeltnis_id)
|
||||
WHERE
|
||||
tbl_vertragsbestandteil_funktion.benutzerfunktion_id=tbl_benutzerfunktion.benutzerfunktion_id
|
||||
AND vbskarenz.vertragsbestandteiltyp_kurzbz='karenz'
|
||||
AND
|
||||
(
|
||||
".$this->db_add_param($datumvon)." BETWEEN COALESCE(vbskarenz.von, '1970-01-01') AND COALESCE(vbskarenz.bis, '2170-12-31')
|
||||
OR
|
||||
".$this->db_add_param($datumbis)." BETWEEN COALESCE(vbskarenz.von, '1970-01-01') AND COALESCE(vbskarenz.bis, '2170-12-31')
|
||||
)
|
||||
) NULLS FIRST LIMIT 1
|
||||
|
||||
)
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
o.oe_kurzbz,
|
||||
o.oe_parent_kurzbz,
|
||||
oes_mitarbeiter.level + 1 as level
|
||||
FROM
|
||||
public.tbl_organisationseinheit o, oes_mitarbeiter
|
||||
WHERE
|
||||
o.oe_kurzbz = oes_mitarbeiter.oe_parent_kurzbz
|
||||
)
|
||||
SELECT
|
||||
oe_kurzbz, level
|
||||
FROM
|
||||
oes_leitung
|
||||
WHERE
|
||||
oe_kurzbz in (SELECT oe_kurzbz FROM oes_mitarbeiter)
|
||||
ORDER BY
|
||||
oe_kurzbz, level
|
||||
";
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
if($this->db_num_rows($result) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt ein Array mit den UIDs der Vorgesetzten zum Zeitpunkt des korrespondierenden Timesheets zurück
|
||||
* @param $uid
|
||||
* @param $date
|
||||
* @param null $limit LIMIT = 1 liefert bei mehreren Vorgesetzten den letzten (aktuellsten) zurück.
|
||||
* @return uid
|
||||
*/
|
||||
public function getVorgesetzteMonatTimesheet($uid, $timesheetDate)
|
||||
public function getVorgesetzteByDate($uid, $date, $limit = null)
|
||||
{
|
||||
$return=false;
|
||||
|
||||
@@ -1127,15 +1290,38 @@ class mitarbeiter extends benutzer
|
||||
public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
funktion_kurzbz='Leitung' AND
|
||||
(datum_von is null OR datum_von<=".$this->db_add_param($timesheetDate).") AND
|
||||
(datum_bis is null OR datum_bis>=".$this->db_add_param($timesheetDate).") AND
|
||||
oe_kurzbz in (SELECT oe_kurzbz
|
||||
FROM public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
funktion_kurzbz='oezuordnung' AND uid=".$this->db_add_param($uid)." AND
|
||||
(datum_von is null OR (datum_von<= ".$this->db_add_param($timesheetDate).")) AND
|
||||
(datum_bis is null OR (datum_bis>=".$this->db_add_param($timesheetDate)."))
|
||||
);";
|
||||
(datum_von is null OR datum_von<=".$this->db_add_param($date).") AND
|
||||
(datum_bis is null OR datum_bis>=".$this->db_add_param($date).") AND
|
||||
oe_kurzbz in (
|
||||
SELECT
|
||||
oe_kurzbz
|
||||
FROM
|
||||
public.tbl_benutzerfunktion
|
||||
WHERE
|
||||
funktion_kurzbz='oezuordnung' AND uid=".$this->db_add_param($uid)." AND
|
||||
(datum_von is null OR (datum_von<= ".$this->db_add_param($date).")) AND
|
||||
(datum_bis is null OR (datum_bis>=".$this->db_add_param($date)."))
|
||||
ORDER BY
|
||||
(
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil_funktion
|
||||
JOIN hr.tbl_vertragsbestandteil vbsfkt USING(vertragsbestandteil_id)
|
||||
JOIN hr.tbl_vertragsbestandteil vbskarenz USING(dienstverhaeltnis_id)
|
||||
WHERE
|
||||
tbl_vertragsbestandteil_funktion.benutzerfunktion_id=tbl_benutzerfunktion.benutzerfunktion_id
|
||||
AND vbskarenz.vertragsbestandteiltyp_kurzbz='karenz'
|
||||
AND (vbskarenz.von <= ".$this->db_add_param($date)." OR vbskarenz.von is null)
|
||||
AND (vbskarenz.bis >= ".$this->db_add_param($date)." OR vbskarenz.bis is null)
|
||||
) NULLS FIRST LIMIT 1
|
||||
)
|
||||
ORDER BY datum_von DESC ";
|
||||
|
||||
if (is_numeric($limit))
|
||||
{
|
||||
$qry .= 'LIMIT '. $this->db_add_param($limit);
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
@@ -1204,16 +1390,16 @@ class mitarbeiter extends benutzer
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gibt ein Array mit den UIDs der aktiv beschäftigten Untergebenen zurueck
|
||||
* @param string $uid UID.
|
||||
* @param boolean $include_OE_childs Wenn true, dann werden auch alle aktiv
|
||||
* beschäftigten Untergebenen der Kind-OEs des Leiters zurückgegeben.
|
||||
* @param bool $fixangestellte_only
|
||||
* @param bool $include_ImLetztenMonatBeendete Inkludiert Mitarbeiter, deren Benutzerfunktion im letzten Monat bereits endete
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUntergebene($uid=null, $include_OE_childs = false, $fixangestellte_only = true)
|
||||
public function getUntergebene($uid=null, $include_OE_childs = false, $fixangestellte_only = true, $include_ImLetztenMonatBeendete = false)
|
||||
{
|
||||
if (is_null($uid))
|
||||
$uid=$this->uid;
|
||||
@@ -1320,11 +1506,18 @@ class mitarbeiter extends benutzer
|
||||
|
||||
$qry.= ")
|
||||
AND
|
||||
(tbl_benutzerfunktion.datum_von is null OR tbl_benutzerfunktion.datum_von<=now())
|
||||
AND
|
||||
(tbl_benutzerfunktion.datum_bis is null OR tbl_benutzerfunktion.datum_bis>=now())
|
||||
AND
|
||||
tbl_benutzer.aktiv = 'true'";
|
||||
(tbl_benutzerfunktion.datum_von is null OR tbl_benutzerfunktion.datum_von<=now())";
|
||||
if ($include_ImLetztenMonatBeendete)
|
||||
{
|
||||
// hier kein check auf aktiv = 'true', da hier auch DV abgefragt werden, die im letzten Monat beendet wurden
|
||||
$qry .= " AND (tbl_benutzerfunktion.datum_bis is null OR tbl_benutzerfunktion.datum_bis >= (DATE_TRUNC('MONTH', NOW()) - INTERVAL '1 month'))";
|
||||
}
|
||||
else {
|
||||
|
||||
$qry .= " AND (tbl_benutzerfunktion.datum_bis is null OR tbl_benutzerfunktion.datum_bis >= now())";
|
||||
$qry .= " AND tbl_benutzer.aktiv = 'true'";
|
||||
}
|
||||
|
||||
if ($fixangestellte_only)
|
||||
$qry .= " AND tbl_mitarbeiter.fixangestellt";
|
||||
$qry .= ";";
|
||||
@@ -1617,28 +1810,6 @@ class mitarbeiter extends benutzer
|
||||
}
|
||||
}
|
||||
|
||||
/** Check if uid is a supervisor
|
||||
*
|
||||
* @param string $uid
|
||||
* @param string $employee_uid
|
||||
* @return boolean True if $uid is direct leader of $employee_uid.
|
||||
*/
|
||||
function check_isVorgesetzter($uid, $employee_uid)
|
||||
{
|
||||
$this->getUntergebene($uid);
|
||||
$untergebenen_arr = $this->untergebene;
|
||||
|
||||
// Check, if uid is an employee of supervisor
|
||||
if (!empty($untergebenen_arr) &&
|
||||
in_array($employee_uid, $untergebenen_arr))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Check if uid is a supervisor on higher oe level
|
||||
*
|
||||
* @param string $uid
|
||||
@@ -1753,7 +1924,7 @@ class mitarbeiter extends benutzer
|
||||
{
|
||||
if (is_null($uid))
|
||||
$uid = $this->uid;
|
||||
|
||||
|
||||
$qry = "
|
||||
SELECT o.oe_kurzbz AS standardkostenstelle, o.bezeichnung
|
||||
FROM public.tbl_benutzerfunktion bf
|
||||
@@ -1770,7 +1941,7 @@ class mitarbeiter extends benutzer
|
||||
$obj = new StdClass();
|
||||
$obj->oekurzbz = $row->standardkostenstelle;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
|
||||
|
||||
$this->result []= $obj;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -977,6 +977,36 @@ class organisationseinheit extends basis_db
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getRoots()
|
||||
{
|
||||
$qry = "SELECT *
|
||||
FROM public.tbl_organisationseinheit
|
||||
WHERE oe_parent_kurzbz IS NULL AND aktiv
|
||||
ORDER BY organisationseinheittyp_kurzbz, bezeichnung";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
$obj = new organisationseinheit();
|
||||
|
||||
$obj->oe_kurzbz = $row->oe_kurzbz;
|
||||
$obj->oe_parent_kurzbz = $row->oe_parent_kurzbz;
|
||||
$obj->bezeichnung = $row->bezeichnung;
|
||||
$obj->organisationseinheittyp_kurzbz = $row->organisationseinheittyp_kurzbz;
|
||||
$obj->aktiv = $this->db_parse_bool($row->aktiv);
|
||||
$obj->mailverteiler = $this->db_parse_bool($row->mailverteiler);
|
||||
$obj->lehre = $this->db_parse_bool($row->lehre);
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Organisationseinheiten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -512,7 +512,10 @@ class statistik extends basis_db
|
||||
$this->csv='';
|
||||
$this->json=array();
|
||||
$this->countRows=0;
|
||||
set_time_limit(120);
|
||||
set_time_limit(600);
|
||||
|
||||
// In case a decryption function is used then perform password substitution
|
||||
$this->sql = $this->replaceSQLDecryptionPassword($this->sql);
|
||||
|
||||
if($this->sql!='')
|
||||
{
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class stundensatz extends basis_db
|
||||
{
|
||||
public $new;
|
||||
public $result = array();
|
||||
|
||||
//Tabellenspalten
|
||||
public $stundensatz_id; // serial
|
||||
public $uid; // varchar(32)
|
||||
public $stundensatztyp; // varchar(32)
|
||||
public $stundensatz; // numeric
|
||||
public $oe_kurzbz; // varchar(32)
|
||||
public $gueltig_von; // date
|
||||
public $gueltig_bis; // date
|
||||
public $insertamum; // timestamp
|
||||
public $insertvon; // varchar(16)
|
||||
public $updateamum; // timestamp
|
||||
public $updatevon; // varchar(16)
|
||||
|
||||
public $oe_bezeichnung;
|
||||
public $stundensatztyp_bezeichnung;
|
||||
|
||||
public function __construct($stundensatz_id = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (!is_null($stundensatz_id))
|
||||
$this->load($stundensatz_id);
|
||||
}
|
||||
|
||||
public function getStundensatzDatum($uid, $beginn, $ende = null, $typ = null)
|
||||
{
|
||||
|
||||
$qry = "SELECT
|
||||
*
|
||||
FROM
|
||||
hr.tbl_stundensatz
|
||||
WHERE
|
||||
uid = ". $this->db_add_param($uid) ."
|
||||
AND (gueltig_bis >= ". $this->db_add_param($beginn) ." OR gueltig_bis is null)";
|
||||
|
||||
if (!is_null($ende))
|
||||
{
|
||||
$qry .= " AND (gueltig_von <= ". $this->db_add_param($ende) .")";
|
||||
}
|
||||
|
||||
if (!is_null($typ))
|
||||
{
|
||||
$qry .= " AND stundensatztyp = ". $this->db_add_param($typ);
|
||||
}
|
||||
|
||||
$qry .= " ORDER BY gueltig_bis DESC NULLS FIRST, gueltig_von DESC NULLS LAST LIMIT 1;";
|
||||
|
||||
if ($this->db_query($qry))
|
||||
{
|
||||
if ($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->stundensatz_id = $row->stundensatz_id;
|
||||
$this->uid = $row->uid;
|
||||
$this->stundensatztyp = $row->stundensatztyp;
|
||||
$this->stundensatz = $row->stundensatz;
|
||||
$this->oe_kurzbz = $row->oe_kurzbz;
|
||||
$this->gueltig_von = $row->gueltig_von;
|
||||
$this->gueltig_bis = $row->gueltig_bis;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllStundensaetze($uid)
|
||||
{
|
||||
$qry = "SELECT
|
||||
tbl_stundensatz.*,
|
||||
tbl_organisationseinheit.bezeichnung AS oe_bezeichnung,
|
||||
hr.tbl_stundensatztyp.bezeichnung AS stundensatztyp_bezeichnung,
|
||||
tbl_organisationseinheit.oe_kurzbz
|
||||
FROM
|
||||
hr.tbl_stundensatz
|
||||
LEFT JOIN
|
||||
public.tbl_organisationseinheit ON tbl_stundensatz.oe_kurzbz = tbl_organisationseinheit.oe_kurzbz
|
||||
JOIN hr.tbl_stundensatztyp USING(stundensatztyp)
|
||||
WHERE
|
||||
uid = ". $this->db_add_param($uid);
|
||||
|
||||
if ($result = $this->db_query($qry))
|
||||
{
|
||||
while ($row = $this->db_fetch_object($result))
|
||||
{
|
||||
$obj = new stundensatz();
|
||||
$obj->stundensatz_id = $row->stundensatz_id;
|
||||
$obj->uid = $row->uid;
|
||||
$obj->stundensatztyp = $row->stundensatztyp;
|
||||
$obj->stundensatz = $row->stundensatz;
|
||||
$obj->oe_kurzbz = $row->oe_kurzbz;
|
||||
$obj->gueltig_von = $row->gueltig_von;
|
||||
$obj->gueltig_bis = $row->gueltig_bis;
|
||||
$obj->insertamum = $row->insertamum;
|
||||
$obj->insertvon = $row->insertvon;
|
||||
$obj->updateamum = $row->updateamum;
|
||||
$obj->updatevon = $row->updatevon;
|
||||
$obj->oe_bezeichnung = $row->oe_bezeichnung;
|
||||
$obj->stundensatztyp_bezeichnung = $row->stundensatztyp_bezeichnung;
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Daten';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function load($stundensatz_id)
|
||||
{
|
||||
$qry = "SELECT
|
||||
tbl_stundensatz.*,
|
||||
tbl_organisationseinheit.bezeichnung AS oe_bezeichnung,
|
||||
hr.tbl_stundensatztyp.bezeichnung AS stundensatztyp_bezeichnung,
|
||||
tbl_organisationseinheit.oe_kurzbz
|
||||
FROM
|
||||
hr.tbl_stundensatz
|
||||
LEFT JOIN public.tbl_organisationseinheit ON tbl_stundensatz.oe_kurzbz = tbl_organisationseinheit.oe_kurzbz
|
||||
JOIN hr.tbl_stundensatztyp USING(stundensatztyp)
|
||||
WHERE
|
||||
stundensatz_id = ".$this->db_add_param($stundensatz_id).";";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if ($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->stundensatz_id = $row->stundensatz_id;
|
||||
$this->uid = $row->uid;
|
||||
$this->stundensatztyp = $row->stundensatztyp;
|
||||
$this->stundensatz = $row->stundensatz;
|
||||
$this->oe_kurzbz = $row->oe_kurzbz;
|
||||
$this->gueltig_von = $row->gueltig_von;
|
||||
$this->gueltig_bis = $row->gueltig_bis;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
$this->oe_bezeichnung = $row->oe_bezeichnung;
|
||||
$this->stundensatztyp_bezeichnung = $row->stundensatztyp_bezeichnung;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function save($new = null)
|
||||
{
|
||||
if (!$this->validate())
|
||||
return false;
|
||||
|
||||
if(is_null($new))
|
||||
$new = $this->new;
|
||||
|
||||
if ($new)
|
||||
{
|
||||
|
||||
$qry = "BEGIN;INSERT INTO hr.tbl_stundensatz
|
||||
(
|
||||
uid,
|
||||
stundensatz,
|
||||
gueltig_von,
|
||||
gueltig_bis,
|
||||
oe_kurzbz,
|
||||
stundensatztyp,
|
||||
insertamum,
|
||||
insertvon
|
||||
)
|
||||
VALUES
|
||||
(" .
|
||||
$this->db_add_param($this->uid) . "," .
|
||||
$this->db_add_param($this->stundensatz, FHC_INTEGER) . "," .
|
||||
$this->db_add_param($this->gueltig_von) . "," .
|
||||
$this->db_add_param($this->gueltig_bis) . "," .
|
||||
$this->db_add_param($this->oe_kurzbz) . "," .
|
||||
$this->db_add_param($this->stundensatztyp) . "," .
|
||||
$this->db_add_param($this->insertamum) . "," .
|
||||
$this->db_add_param($this->insertvon) .
|
||||
");";
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = "UPDATE hr.tbl_stundensatz SET " .
|
||||
"stundensatz = " . $this->db_add_param($this->stundensatz, FHC_INTEGER) .",".
|
||||
"oe_kurzbz = " . $this->db_add_param($this->oe_kurzbz) .",".
|
||||
"stundensatztyp = " . $this->db_add_param($this->stundensatztyp) .",".
|
||||
"gueltig_von = " . $this->db_add_param($this->gueltig_von) .",".
|
||||
"gueltig_bis = " . $this->db_add_param($this->gueltig_bis) .",".
|
||||
"updatevon = " . $this->db_add_param($this->updatevon) .",".
|
||||
"updateamum = " . $this->db_add_param($this->updateamum).
|
||||
" WHERE stundensatz_id = " . $this->db_add_param($this->stundensatz_id, FHC_INTEGER).';';
|
||||
}
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
if ($new)
|
||||
{
|
||||
$qry = "SELECT currval('hr.tbl_stundensatz_stundensatz_id_seq') as id;";
|
||||
if ($this->db_query($qry))
|
||||
{
|
||||
if ($row = $this->db_fetch_object())
|
||||
{
|
||||
$this->stundensatz_id = $row->id;
|
||||
$this->db_query('COMMIT');
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
$this->db_query('ROLLBACK');
|
||||
$this->errormsg = "Fehler beim Auslesen der Sequence";
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
$this->db_query('ROLLBACK');
|
||||
$this->errormsg = 'Fehler beim Auslesen der Sequence';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Zuteilen des Eintrages';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($stundensatz_id)
|
||||
{
|
||||
$qry = "DELETE FROM hr.tbl_stundensatz WHERE stundensatz_id = ".$this->db_add_param($stundensatz_id, FHC_INTEGER);
|
||||
|
||||
if($this->db_query($qry))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Löschen des Stundensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if (!is_numeric($this->stundensatz))
|
||||
{
|
||||
$this->errormsg = "Stundensatz ungueltig";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_null($this->oe_kurzbz))
|
||||
{
|
||||
$this->errormsg = "Unternehmen ungueltig";
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->insertamum === '')
|
||||
{
|
||||
$this->errormsg = "Datum ungueltig";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user