mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
first guess vertragsbestandteil library
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
/**
|
||||
* Description of Vertragsbestandteil
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
abstract class Vertragsbestandteil
|
||||
{
|
||||
protected $vertragsbestandteil_id;
|
||||
protected $dienstverhaeltnis_id;
|
||||
protected $von;
|
||||
protected $bis;
|
||||
protected $vertragsbestandteiltyp_kurzbz;
|
||||
protected $insertamum;
|
||||
protected $insertvon;
|
||||
protected $updateamum;
|
||||
protected $updatevon;
|
||||
|
||||
public function hydrateByStdClass($data)
|
||||
{
|
||||
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->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);
|
||||
}
|
||||
|
||||
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 setVertragsbestandteil_id($vertragsbestandteil_id)
|
||||
{
|
||||
$this->vertragsbestandteil_id = $vertragsbestandteil_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDienstverhaeltnis_id($dienstverhaeltnis_id)
|
||||
{
|
||||
$this->dienstverhaeltnis_id = $dienstverhaeltnis_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVon($von)
|
||||
{
|
||||
$this->von = $von;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setBis($bis)
|
||||
{
|
||||
$this->bis = $bis;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setVertragsbestandteiltyp_kurzbz($vertragsbestandteiltyp_kurzbz)
|
||||
{
|
||||
$this->vertragsbestandteiltyp_kurzbz = $vertragsbestandteiltyp_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInsertamum($insertamum)
|
||||
{
|
||||
$this->insertamum = $insertamum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInsertvon($insertvon)
|
||||
{
|
||||
$this->insertvon = $insertvon;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdateamum($updateamum)
|
||||
{
|
||||
$this->updateamum = $updateamum;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatevon($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($v) {
|
||||
return !is_null($v);
|
||||
});
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
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 abstract function toStdClass();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use Exception;
|
||||
use vertragsbestandteil\VertragsbestandteilStunden;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilFactory
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilFactory
|
||||
{
|
||||
const VERTRAGSBESTANDTEIL_STUNDEN = 'stunden';
|
||||
const VERTRAGSBESTANDTEIL_FUNKTION = 'funktion';
|
||||
|
||||
public static function getVertragsbestandteil($data)
|
||||
{
|
||||
$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_STUNDEN:
|
||||
$vertragsbestandteil = new VertragsbestandteilStunden();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FUNKTION:
|
||||
$vertragsbestandteil = new VertragsbestandteilFunktion();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown vertragsbestandteiltyp_kurzbz '
|
||||
. $vertragsbestandteiltyp_kurzbz);
|
||||
}
|
||||
|
||||
return $vertragsbestandteil;
|
||||
}
|
||||
|
||||
public static function getVertragsbestandteilDBModel($vertragsbestandteil_kurzbz)
|
||||
{
|
||||
$CI = get_instance();
|
||||
|
||||
$vertragsbestandteildbmodel = null;
|
||||
switch ($vertragsbestandteil_kurzbz)
|
||||
{
|
||||
case self::VERTRAGSBESTANDTEIL_STUNDEN:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilStunden_model',
|
||||
'VertragsbestandteilStunden_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilStunden_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FUNKTION:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model',
|
||||
'VertragsbestandteilFunktion_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilFunktion_model;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown vertragsbestandteil_kurzbz '
|
||||
. $vertragsbestandteil_kurzbz);
|
||||
}
|
||||
|
||||
return $vertragsbestandteildbmodel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilFunktion
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilFunktion extends Vertragsbestandteil
|
||||
{
|
||||
protected $benutzerfunktion_id;
|
||||
protected $anmerkung;
|
||||
protected $kuendigungsrelevant;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_FUNKTION);
|
||||
}
|
||||
|
||||
public function toStdClass()
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'benutzerfunktion_id' => $this->getBenutzerfunktion_id(),
|
||||
'anmerkung' => $this->getAnmerkung(),
|
||||
'kuendigungsrelevant' => $this->getKuendigungsrelevant()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($v) {
|
||||
return !is_null($v);
|
||||
});
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
benutzerfunktion_id: {$this->getBenutzerfunktion_id()}
|
||||
anmerkung: {$this->getAnmerkung()}
|
||||
kuendigungsrelevant: {$this->getKuendigungsrelevant()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data)
|
||||
{
|
||||
parent::hydrateByStdClass($data);
|
||||
isset($data->benutzerfunktion_id) && $this->setBenutzerfunktion_id($data->benutzerfunktion_id);
|
||||
isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung);
|
||||
isset($data->kuendigungsrelevant) && $this->setKuendigungsrelevant($data->kuendigungsrelevant);
|
||||
}
|
||||
|
||||
public function getBenutzerfunktion_id()
|
||||
{
|
||||
return $this->benutzerfunktion_id;
|
||||
}
|
||||
|
||||
public function getAnmerkung()
|
||||
{
|
||||
return $this->anmerkung;
|
||||
}
|
||||
|
||||
public function getKuendigungsrelevant()
|
||||
{
|
||||
return $this->kuendigungsrelevant;
|
||||
}
|
||||
|
||||
public function setBenutzerfunktion_id($benutzerfunktion_id)
|
||||
{
|
||||
$this->benutzerfunktion_id = $benutzerfunktion_id;
|
||||
return $this;
|
||||
}
|
||||
public function setAnmerkung($anmerkung)
|
||||
{
|
||||
$this->anmerkung = $anmerkung;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setKuendigungsrelevant($kuendigungsrelevant)
|
||||
{
|
||||
$this->kuendigungsrelevant = $kuendigungsrelevant;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Vertragsbestandteil.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilStunden.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilFunktion.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilFactory.php';
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilLib
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilLib
|
||||
{
|
||||
protected $CI;
|
||||
protected $VertragsbestandteilModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->CI = get_instance();
|
||||
$this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model',
|
||||
'VertragsbestandteilModel');
|
||||
$this->VertragsbestandteilModel = $this->CI->VertragsbestandteilModel;
|
||||
}
|
||||
|
||||
public function fetchVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null)
|
||||
{
|
||||
return $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag);
|
||||
}
|
||||
|
||||
public function storeVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil)
|
||||
{
|
||||
$this->CI->db->trans_begin();
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
protected function insertVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil)
|
||||
{
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
||||
protected function updateVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil)
|
||||
{
|
||||
$vertragsbestandteil->setUpdateamum(strftime('%Y-%m-%d %H:%M'))
|
||||
->setUpdatevon('ma0080');
|
||||
$ret = $this->VertragsbestandteilModel->update($vertragsbestandteil->getVertragsbestandteil_id(),
|
||||
$vertragsbestandteil->baseToStdClass());
|
||||
|
||||
if(isError($ret) )
|
||||
{
|
||||
throw new Exception('error updating vertragsbestandteil');
|
||||
}
|
||||
|
||||
$specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel(
|
||||
$vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
|
||||
$retspecial = $specialisedModel->update($vertragsbestandteil->getVertragsbestandteil_id(),
|
||||
$vertragsbestandteil->toStdClass());
|
||||
|
||||
if(isError($retspecial) )
|
||||
{
|
||||
throw new Exception('error updating vertragsbestandteil '
|
||||
. $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilStunden
|
||||
*
|
||||
* @author bambi
|
||||
*/
|
||||
class VertragsbestandteilStunden extends Vertragsbestandteil
|
||||
{
|
||||
protected $wochenstunden;
|
||||
protected $karenz;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_STUNDEN);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data)
|
||||
{
|
||||
parent::hydrateByStdClass($data);
|
||||
isset($data->wochenstunden) && $this->setWochenstunden($data->wochenstunden);
|
||||
isset($data->karenz) && $this->setKarenz($data->karenz);
|
||||
}
|
||||
|
||||
public function getWochenstunden()
|
||||
{
|
||||
return $this->wochenstunden;
|
||||
}
|
||||
|
||||
public function getKarenz()
|
||||
{
|
||||
return $this->karenz;
|
||||
}
|
||||
|
||||
public function setWochenstunden($wochenstunden)
|
||||
{
|
||||
$this->wochenstunden = $wochenstunden;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setKarenz($karenz)
|
||||
{
|
||||
$this->karenz = $karenz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'wochenstunden' => $this->getWochenstunden(),
|
||||
'karenz' => $this->getKarenz()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($v) {
|
||||
return !is_null($v);
|
||||
});
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
wochenstunden: {$this->getWochenstunden()}
|
||||
karenz: {$this->getKarenz()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
||||
@@ -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,63 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
public function getVertragsbestandteile($dienstverhaeltnis_id=1, $stichtag=null)
|
||||
{
|
||||
$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)';
|
||||
}
|
||||
|
||||
$sql = <<<EOSQL
|
||||
SELECT
|
||||
v.*, s.wochenstunden, s.karenz, f.benutzerfunktion_id, f.anmerkung, f. kuendigungsrelevant
|
||||
FROM
|
||||
hr.tbl_vertragsbestandteil v
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_stunden s USING(vertragsbestandteil_id)
|
||||
LEFT JOIN
|
||||
hr.tbl_vertragsbestandteil_funktion f USING(vertragsbestandteil_id)
|
||||
WHERE
|
||||
v.dienstverhaeltnis_id = {$this->escape($dienstverhaeltnis_id)}
|
||||
{$stichtagclause}
|
||||
;
|
||||
EOSQL;
|
||||
|
||||
echo $sql . "\n\n";
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$vertragsbestandteile = array();
|
||||
foreach( $query->result() as $row ) {
|
||||
try
|
||||
{
|
||||
$vertragsbestandteile[] = VertragsbestandteilFactory::getVertragsbestandteil($row);
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
echo $ex->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $vertragsbestandteile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user