mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 00:24:35 +00:00
first guess vertragsbestandteil library
This commit is contained in:
@@ -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