changes for aenderung and korrektur

This commit is contained in:
Harald Bamberger
2023-05-30 19:13:27 +02:00
parent a47a746940
commit ec000fbf83
5 changed files with 80 additions and 20 deletions
@@ -26,9 +26,9 @@ class GehaltsbestandteilLib
$this->GehaltsbestandteilModel = $this->CI->GehaltsbestandteilModel; $this->GehaltsbestandteilModel = $this->CI->GehaltsbestandteilModel;
} }
public function fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag=null) public function fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag=null, $includefuture=false)
{ {
return $this->GehaltsbestandteilModel->getGehaltsbestandteile($dienstverhaeltnis_id, $stichtag); return $this->GehaltsbestandteilModel->getGehaltsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture);
} }
public function fetchGehaltsbestandteil($gehaltsbestandteil_id) public function fetchGehaltsbestandteil($gehaltsbestandteil_id)
@@ -93,4 +93,13 @@ class GehaltsbestandteilLib
throw new Exception('error updating gehaltsbestandteil'); throw new Exception('error updating gehaltsbestandteil');
} }
} }
public function deleteGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil)
{
$ret = $this->GehaltsbestandteilModel->delete($gehaltsbestandteil->getGehaltsbestandteil_id());
if(isError($ret) )
{
throw new Exception('error deleting gehaltsbestandteil');
}
}
} }
@@ -31,6 +31,31 @@ class VertragsbestandteilFunktion extends Vertragsbestandteil
public function beforePersist() public function beforePersist()
{ {
if( isset($this->benutzerfunktion_id) && intval($this->benutzerfunktion_id) > 0 )
{
$this->beforePersitExisting();
}
else
{
$this->beforePersitNew();
}
}
protected function beforePersitExisting() {
$data = (object) array(
'datum_bis' => $this->getBis(),
'updateamum' => strftime('%Y-%m-%d %H:%M:%S'),
'updatevon' => getAuthUID()
);
$ret = $this->CI->BenutzerfunktionModel->update($this->getBenutzerfunktion_id(), $data);
if(isError($ret) )
{
throw new Exception('failed to update Benutzerfunktion');
}
}
protected function beforePersitNew() {
if( $this->benutzerfunktiondata === null) if( $this->benutzerfunktiondata === null)
{ {
return; return;
@@ -43,9 +68,9 @@ class VertragsbestandteilFunktion extends Vertragsbestandteil
throw new Exception('failed to create Benutzerfunktion'); throw new Exception('failed to create Benutzerfunktion');
} }
$this->setBenutzerfunktion_id(getData($ret)); $this->setBenutzerfunktion_id(getData($ret));
} }
public function toStdClass() public function toStdClass()
{ {
$tmp = array( $tmp = array(
@@ -21,7 +21,10 @@ use vertragsbestandteil\VertragsbestandteilFactory;
* @author bambi * @author bambi
*/ */
class VertragsbestandteilLib class VertragsbestandteilLib
{ {
const INCLUDE_FUTURE = true;
const DO_NOT_INCLUDE_FUTURE = false;
protected $CI; protected $CI;
/** @var Dienstverhaeltnis_model */ /** @var Dienstverhaeltnis_model */
protected $DienstverhaeltnisModel; protected $DienstverhaeltnisModel;
@@ -75,10 +78,10 @@ class VertragsbestandteilLib
return $dv; return $dv;
} }
public function fetchVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null) public function fetchVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null, $includefuture=false)
{ {
$vbs = $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag); $vbs = $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture);
$gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag); $gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture);
$gbsByVBid = array(); $gbsByVBid = array();
foreach( $gbs as $gb ) foreach( $gbs as $gb )
@@ -259,4 +262,22 @@ class VertragsbestandteilLib
$dv->getDienstverhaeltnis_id() $dv->getDienstverhaeltnis_id()
); );
} }
public function deleteVertragsbestandteil(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());
}
$ret = $this->VertragsbestandteilModel->delete($vertragsbestandteil->getVertragsbestandteil_id());
if(isError($ret) )
{
throw new Exception('error deleting vertragsbestandteil');
}
}
} }
@@ -80,7 +80,7 @@ class Gehaltsbestandteil_model extends DB_Model implements IEncryption
. ' AND COALESCE(bis, \'2170-01-01\'::date)'; . ' AND COALESCE(bis, \'2170-01-01\'::date)';
if( $includefuture ) if( $includefuture )
{ {
$stichtagclause .= ' OR COALESCE(v.von, \'1970-01-01\'::date) > ' $stichtagclause .= ' OR COALESCE(von, \'1970-01-01\'::date) > '
. $this->escape($date); . $this->escape($date);
} }
$stichtagclause .= ')'; $stichtagclause .= ')';
@@ -113,6 +113,7 @@ EOSQL;
public function getGehaltsbestandteil($id) public function getGehaltsbestandteil($id)
{ {
$this->addSelect('*');
$query = $this->load($id, $this->getEncryptedColumns()); $query = $this->load($id, $this->getEncryptedColumns());
$gehaltsbestandteil = null; $gehaltsbestandteil = null;
@@ -120,19 +120,23 @@ EOSQL;
; ;
EOSQL; EOSQL;
// echo $sql . "\n\n"; $query = $this->execReadOnlyQuery($sql);
$query = $this->db->query($sql);
$vertragsbestandteil = null;
$vertragsbestandteil = array();
try if( hasData($query) )
{ {
$vertragsbestandteile = VertragsbestandteilFactory::getVertragsbestandteil($row); // TODO add decryption $data = getData($query)[0];
try
{
$vertragsbestandteil = VertragsbestandteilFactory::getVertragsbestandteil($data); // TODO add decryption
}
catch (Exception $ex)
{
echo $ex->getMessage() . "\n";
}
} }
catch (Exception $ex)
{
echo $ex->getMessage() . "\n";
}
return $vertragsbestandteil; return $vertragsbestandteil;
} }