mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 08:22:17 +00:00
prepare list of vbs with gbs
This commit is contained in:
@@ -4,7 +4,7 @@ namespace vertragsbestandteil;
|
||||
/**
|
||||
* Salary always depends on employment (Dienstverhältnis) and optionally on part of contract (Vetragsbestandteil)
|
||||
*/
|
||||
class Gehaltsbestandteil implements IValidation
|
||||
class Gehaltsbestandteil implements IValidation, \JsonSerializable
|
||||
{
|
||||
protected $gehaltsbestandteil_id;
|
||||
protected $dienstverhaeltnis_id;
|
||||
@@ -230,6 +230,13 @@ class Gehaltsbestandteil implements IValidation
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
unset($vars['CI']);
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
|
||||
@@ -100,6 +100,12 @@ abstract class Vertragsbestandteil implements \JsonSerializable, IValidation
|
||||
return $this->updatevon;
|
||||
}
|
||||
|
||||
public function setGehaltsbestandteile($gehaltsbestandteile)
|
||||
{
|
||||
$this->gehaltsbestandteile = $gehaltsbestandteile;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVertragsbestandteil_id($vertragsbestandteil_id)
|
||||
{
|
||||
$this->vertragsbestandteil_id = $vertragsbestandteil_id;
|
||||
|
||||
@@ -76,7 +76,31 @@ class VertragsbestandteilLib
|
||||
|
||||
public function fetchVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null)
|
||||
{
|
||||
return $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag);
|
||||
$vbs = $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag);
|
||||
$gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag);
|
||||
|
||||
$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)
|
||||
|
||||
@@ -69,31 +69,31 @@ class Gehaltsbestandteil_model extends DB_Model implements IEncryption
|
||||
return $this->execQuery($qry, array($dienstverhaeltnis_id), $this->getEncryptedColumns());
|
||||
}
|
||||
|
||||
public function getGehaltsbestandteile($dienstverhaeltnis_id=1, $stichtag=null)
|
||||
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(v.von, \'1970-01-01\'::date)'
|
||||
. ' AND COALESCE(v.bis, \'2170-01-01\'::date)';
|
||||
$stichtagclause = 'AND (' . $this->escape($date)
|
||||
. ' BETWEEN COALESCE(von, \'1970-01-01\'::date)'
|
||||
. ' AND COALESCE(bis, \'2170-01-01\'::date)';
|
||||
if( $includefuture )
|
||||
{
|
||||
$stichtagclause .= ' OR COALESCE(v.von, \'1970-01-01\'::date) > '
|
||||
. $this->escape($date);
|
||||
}
|
||||
$stichtagclause .= ')';
|
||||
}
|
||||
|
||||
$sql = <<<EOSQL
|
||||
SELECT
|
||||
g.*
|
||||
FROM
|
||||
hr.tbl_gehaltsbestandteil g
|
||||
WHERE
|
||||
g.dienstverhaeltnis_id = ?
|
||||
$this->addSelect('*');
|
||||
$where = <<<EOSQL
|
||||
dienstverhaeltnis_id = {$this->escape($dienstverhaeltnis_id)}
|
||||
{$stichtagclause}
|
||||
;
|
||||
EOSQL;
|
||||
|
||||
$query = $this->execReadOnlyQuery(
|
||||
$query,
|
||||
array($dienstverhaeltnis_id),
|
||||
$query = $this->loadWhere(
|
||||
$where,
|
||||
$this->getEncryptedColumns()
|
||||
);
|
||||
|
||||
|
||||
@@ -59,15 +59,21 @@ EOSQL;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function getVertragsbestandteile($dienstverhaeltnis_id=1, $stichtag=null)
|
||||
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)
|
||||
$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
|
||||
|
||||
Reference in New Issue
Block a user