mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 16:44:28 +00:00
add Interface IValidation, implement validate stub in all Vertragsbestandteile and Gehaltsbestandteil and DV
This commit is contained in:
@@ -11,7 +11,7 @@ const TYPE_ECHT_FREI = 'echterfreier';
|
|||||||
const TYPE_WERKVERTRAG = 'werkvertrag';
|
const TYPE_WERKVERTRAG = 'werkvertrag';
|
||||||
const TYPE_UEBERLASSUNG = 'ueberlassungsvertrag';
|
const TYPE_UEBERLASSUNG = 'ueberlassungsvertrag';
|
||||||
|
|
||||||
class Dienstverhaeltnis {
|
class Dienstverhaeltnis implements IValidation {
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
protected $dienstverhaeltnis_id;
|
protected $dienstverhaeltnis_id;
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
@@ -20,7 +20,16 @@ class Dienstverhaeltnis {
|
|||||||
protected $vertragsart_kurzbz;
|
protected $vertragsart_kurzbz;
|
||||||
protected $gueltig_ab;
|
protected $gueltig_ab;
|
||||||
protected $gueltig_bis;
|
protected $gueltig_bis;
|
||||||
|
|
||||||
|
protected $isvalid;
|
||||||
|
protected $validationerrors;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->isvalid = false;
|
||||||
|
$this->validationerrors = array();
|
||||||
|
}
|
||||||
|
|
||||||
public function toStdClass(): \stdClass
|
public function toStdClass(): \stdClass
|
||||||
{
|
{
|
||||||
$tmp = array(
|
$tmp = array(
|
||||||
@@ -141,4 +150,27 @@ EOTXT;
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isValid()
|
||||||
|
{
|
||||||
|
return $this->isvalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValidationErrors()
|
||||||
|
{
|
||||||
|
return $this->validationerrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validate() {
|
||||||
|
//do Validation here
|
||||||
|
|
||||||
|
// return status after Validation
|
||||||
|
if( count($this->validationerrors) > 0 ) {
|
||||||
|
$this->isvalid = false;
|
||||||
|
} else {
|
||||||
|
$this->isvalid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->isvalid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ namespace vertragsbestandteil;
|
|||||||
/**
|
/**
|
||||||
* Salary always depends on employment (Dienstverhältnis) and optionally on part of contract (Vetragsbestandteil)
|
* Salary always depends on employment (Dienstverhältnis) and optionally on part of contract (Vetragsbestandteil)
|
||||||
*/
|
*/
|
||||||
class Gehaltsbestandteil
|
class Gehaltsbestandteil implements IValidation
|
||||||
{
|
{
|
||||||
protected $gehaltsbestandteil_id;
|
protected $gehaltsbestandteil_id;
|
||||||
protected $dienstverhaeltnis_id;
|
protected $dienstverhaeltnis_id;
|
||||||
@@ -23,7 +23,16 @@ class Gehaltsbestandteil
|
|||||||
protected $insertvon;
|
protected $insertvon;
|
||||||
protected $updateamum;
|
protected $updateamum;
|
||||||
protected $updatevon;
|
protected $updatevon;
|
||||||
|
|
||||||
|
protected $isvalid;
|
||||||
|
protected $validationerrors;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->isvalid = false;
|
||||||
|
$this->validationerrors = array();
|
||||||
|
}
|
||||||
|
|
||||||
public function hydrateByStdClass($data)
|
public function hydrateByStdClass($data)
|
||||||
{
|
{
|
||||||
isset($data->gehaltsbestandteil_id) && $this->setGehaltsbestandteil_id($data->gehaltsbestandteil_id);
|
isset($data->gehaltsbestandteil_id) && $this->setGehaltsbestandteil_id($data->gehaltsbestandteil_id);
|
||||||
@@ -272,4 +281,27 @@ class Gehaltsbestandteil
|
|||||||
EOTXT;
|
EOTXT;
|
||||||
return $txt;
|
return $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isValid()
|
||||||
|
{
|
||||||
|
return $this->isvalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValidationErrors()
|
||||||
|
{
|
||||||
|
return $this->validationerrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validate() {
|
||||||
|
//do Validation here
|
||||||
|
|
||||||
|
// return status after Validation
|
||||||
|
if( count($this->validationerrors) > 0 ) {
|
||||||
|
$this->isvalid = false;
|
||||||
|
} else {
|
||||||
|
$this->isvalid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->isvalid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace vertragsbestandteil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of IValidation
|
||||||
|
*
|
||||||
|
* @author bambi
|
||||||
|
*/
|
||||||
|
interface IValidation
|
||||||
|
{
|
||||||
|
public function isValid();
|
||||||
|
|
||||||
|
public function getValidationErrors();
|
||||||
|
|
||||||
|
public function validate();
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ namespace vertragsbestandteil;
|
|||||||
*
|
*
|
||||||
* @author bambi
|
* @author bambi
|
||||||
*/
|
*/
|
||||||
abstract class Vertragsbestandteil implements \JsonSerializable
|
abstract class Vertragsbestandteil implements \JsonSerializable, IValidation
|
||||||
{
|
{
|
||||||
protected $vertragsbestandteil_id;
|
protected $vertragsbestandteil_id;
|
||||||
protected $dienstverhaeltnis_id;
|
protected $dienstverhaeltnis_id;
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ EOTXT;
|
|||||||
return parent::__toString() . $txt;
|
return parent::__toString() . $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
return parent::validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,4 +105,9 @@ EOTXT;
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
return parent::validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,5 +105,8 @@ EOTXT;
|
|||||||
return parent::__toString() . $txt;
|
return parent::__toString() . $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
return parent::validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,5 +84,8 @@ EOTXT;
|
|||||||
return parent::__toString() . $txt;
|
return parent::__toString() . $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
return parent::validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,5 +62,8 @@ EOTXT;
|
|||||||
return parent::__toString() . $txt;
|
return parent::__toString() . $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
return parent::validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,4 +77,9 @@ class VertragsbestandteilStunden extends Vertragsbestandteil
|
|||||||
EOTXT;
|
EOTXT;
|
||||||
return parent::__toString() . $txt;
|
return parent::__toString() . $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
return parent::validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,5 +62,8 @@ EOTXT;
|
|||||||
return parent::__toString() . $txt;
|
return parent::__toString() . $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
return parent::validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil
|
|||||||
EOTXT;
|
EOTXT;
|
||||||
return parent::__toString() . $txt;
|
return parent::__toString() . $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function validate()
|
||||||
|
{
|
||||||
|
return parent::validate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once __DIR__ . '/IEncryption.php';
|
require_once __DIR__ . '/IEncryption.php';
|
||||||
|
|
||||||
|
use vertragsbestandteil\Gehaltsbestandteil;
|
||||||
|
|
||||||
class Gehaltsbestandteil_model extends DB_Model implements IEncryption
|
class Gehaltsbestandteil_model extends DB_Model implements IEncryption
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -48,7 +49,61 @@ class Gehaltsbestandteil_model extends DB_Model implements IEncryption
|
|||||||
";
|
";
|
||||||
|
|
||||||
return $this->execQuery($qry, array($dienstverhaeltnis_id), $this->getEncryptedColumns());
|
return $this->execQuery($qry, array($dienstverhaeltnis_id), $this->getEncryptedColumns());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGehaltsbestandteile($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
|
||||||
|
g.*
|
||||||
|
FROM
|
||||||
|
hr.tbl_gehaltsbestandteil g
|
||||||
|
WHERE
|
||||||
|
g.dienstverhaeltnis_id = ?
|
||||||
|
{$stichtagclause}
|
||||||
|
;
|
||||||
|
EOSQL;
|
||||||
|
|
||||||
|
$query = $this->execReadOnlyQuery(
|
||||||
|
$query,
|
||||||
|
array($dienstverhaeltnis_id),
|
||||||
|
$this->getEncryptedColumns()
|
||||||
|
);
|
||||||
|
|
||||||
|
$gehaltsbestandteile = array();
|
||||||
|
if( null !== ($rows = getData($query)) )
|
||||||
|
{
|
||||||
|
foreach( $rows as $row ) {
|
||||||
|
$tmpgb = new Gehaltsbestandteil();
|
||||||
|
$tmpgb->hydrateByStdClass($row);
|
||||||
|
$gehaltsbestandteile[] = $tmpgb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $gehaltsbestandteile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getGehaltsbestandteil($id)
|
||||||
|
{
|
||||||
|
$query = $this->load($id, $this->getEncryptedColumns());
|
||||||
|
$gehaltsbestandteil = null;
|
||||||
|
|
||||||
|
if( null !== ($row = getData($query)) )
|
||||||
|
{
|
||||||
|
$gehaltsbestandteil = new Gehaltsbestandteil();
|
||||||
|
$gehaltsbestandteil->hydrateByStdClass($row[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $gehaltsbestandteil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user