mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-12 17:49:28 +00:00
removed GUI handling and renamed Gehaltsbestandteil to make it independend from Vertragsbestandteil
This commit is contained in:
@@ -15,7 +15,7 @@ class Dienstverhaeltnis {
|
||||
/** @var integer */
|
||||
protected $dienstverhaeltnis_id;
|
||||
/** @var integer */
|
||||
protected $unternehmen; // TODO link zu orgeinheit
|
||||
protected $unternehmen;
|
||||
/** @var string */
|
||||
protected $vertragsart_kurzbz;
|
||||
protected $gueltig_ab;
|
||||
|
||||
+43
-47
@@ -1,17 +1,16 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
/**
|
||||
* Salary always depends on employment (Dienstverhältnis) and optionally on part of contract (Vetragsbestandteil)
|
||||
*/
|
||||
class VertragsbestandteilGehalt extends Vertragsbestandteil
|
||||
class Gehaltsbestandteil
|
||||
{
|
||||
protected $gehaltsbestandteil_id;
|
||||
protected $gehalt_von;
|
||||
protected $gehalt_bis;
|
||||
protected $gueltig_ab;
|
||||
protected $gueltig_bis;
|
||||
protected $anmerkung;
|
||||
protected $grundbetrag;
|
||||
protected $betrag_valorisiert;
|
||||
@@ -21,43 +20,9 @@ class VertragsbestandteilGehalt extends Vertragsbestandteil
|
||||
protected $valorisierungssperre;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_GEHALT);
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data)
|
||||
{
|
||||
parent::hydrateByStdClass($data);
|
||||
isset($data->gehalt_von) && $this->setGehaltVon($data->gehalt_von);
|
||||
isset($data->gehalt_bis) && $this->setGehaltBis($data->gehalt_bis);
|
||||
isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung);
|
||||
isset($data->gehalt_dienstverhaeltnis_id) && $this->setGehaltDienstverhaeltnisID($data->gehalt_dienstverhaeltnis_id);
|
||||
isset($data->gehaltstyp_kurzbz) && $this->setGehaltstypKurzbz($data->gehaltstyp_kurzbz);
|
||||
isset($data->valorisierungssperre) && $this->setValorisierungssperre($data->valorisierungssperre);
|
||||
}
|
||||
|
||||
public function getGehaltVon()
|
||||
{
|
||||
return $this->gehalt_von;
|
||||
}
|
||||
|
||||
public function getGehaltBis()
|
||||
{
|
||||
return $this->gehalt_bis;
|
||||
}
|
||||
|
||||
public function setGehaltVon($von)
|
||||
{
|
||||
$this->gehalt_von = $von;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setGehaltBis($bis)
|
||||
{
|
||||
$this->gehalt_bis = $bis;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of gehaltsbestandteil_id
|
||||
@@ -203,16 +168,11 @@ class VertragsbestandteilGehalt extends Vertragsbestandteil
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'von' => $this->getVon(),
|
||||
'bis' => $this->getBis(),
|
||||
'gehalt_von' => $this->getGehaltVon(),
|
||||
'gehalt_bis' => $this->getGehaltBis(),
|
||||
'gueltig_ab' => $this->getGueltigAb(),
|
||||
'gueltig_bis' => $this->getGueltigBis(),
|
||||
'gehalt_dienstverhaeltnis_id' => $this->getGehaltDienstverhaeltnisID(),
|
||||
'grundbetrag' => $this->getGrundbetrag(),
|
||||
'betrag_valorisiert' => $this->getBetragValorisiert(),
|
||||
@@ -242,4 +202,40 @@ EOTXT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of gueltig_ab
|
||||
*/
|
||||
public function getGueltigAb()
|
||||
{
|
||||
return $this->gueltig_ab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of gueltig_ab
|
||||
*/
|
||||
public function setGueltigAb($gueltig_ab): self
|
||||
{
|
||||
$this->gueltig_ab = $gueltig_ab;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of gueltig_bis
|
||||
*/
|
||||
public function getGueltigBis()
|
||||
{
|
||||
return $this->gueltig_bis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of gueltig_bis
|
||||
*/
|
||||
public function setGueltigBis($gueltig_bis): self
|
||||
{
|
||||
$this->gueltig_bis = $gueltig_bis;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/JSONData.php';
|
||||
|
||||
abstract class AbstractBestandteil {
|
||||
|
||||
use JSONData;
|
||||
|
||||
/** @var string type of vertragsbestandteil (i.e. vertragsbestandteilstunden) */
|
||||
protected $type;
|
||||
/**
|
||||
* @var object might contain id and some data needed by the GUI (Error-Messages).
|
||||
* Contents depend heavily on type of vertragsbestandteil */
|
||||
protected $guioptions;
|
||||
/** @var object container for the real data */
|
||||
protected $data;
|
||||
|
||||
abstract public function getTypeString(): string;
|
||||
abstract public function mapJSON(&$decoded);
|
||||
|
||||
/**
|
||||
* check type string ('vertragsbestandteilstunden', etc.)
|
||||
*/
|
||||
public function checkType(&$decoded)
|
||||
{
|
||||
var_dump($decoded['type']);
|
||||
if (!isset($decoded['type']) || (isset($decoded['type']) && $decoded['type'] !== $this->getTypeString()))
|
||||
{
|
||||
throw new \Exception('wrong type string: "'.$decoded['type'].'" should be "'.$this->getTypeString().'"');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of type
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of type
|
||||
*/
|
||||
public function setType($type): self
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of guioptions
|
||||
*/
|
||||
public function getGuioptions()
|
||||
{
|
||||
return $this->guioptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of guioptions
|
||||
*/
|
||||
public function setGuioptions($guioptions): self
|
||||
{
|
||||
$this->guioptions = $guioptions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of data
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of data
|
||||
*/
|
||||
public function setData($data): self
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/AbstractBestandteil.php";
|
||||
|
||||
/**
|
||||
* Wrapper for Vertragsbestandteil in JSON schema produced by the GUI.
|
||||
* Example:
|
||||
* ```{ "bb09324f-19f6-41d2-a371-388ef8fdb49e": {
|
||||
* "type": "vertragsbestandteil",
|
||||
* "guioptions": {
|
||||
* "id": "bb09324f-19f6-41d2-a371-388ef8fdb49e",
|
||||
* "infos": [
|
||||
* "test info 1",
|
||||
* "test info 2"
|
||||
* ],
|
||||
* "errors": [
|
||||
* "test error 1",
|
||||
* "test error 2"
|
||||
* ]
|
||||
* },
|
||||
* "data": {
|
||||
* "stunden": "38,5",
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "ignore"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "1.1.2011",
|
||||
* "gueltig_bis": "31.12.2014"
|
||||
* }
|
||||
* }
|
||||
* },
|
||||
* },
|
||||
* "gbs": [
|
||||
* {
|
||||
* "type": "gehaltsbestandteil",
|
||||
* "guioptions": {
|
||||
* "infos": [
|
||||
* "test info 1",
|
||||
* "test info 2"
|
||||
* ],
|
||||
* "errors": [
|
||||
* "test error 1",
|
||||
* "test error 2"
|
||||
* ]
|
||||
* },
|
||||
* "data": {
|
||||
* "gehaltstyp": "",
|
||||
* "betrag": "3333",
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "ignore"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "1.1.2011",
|
||||
* "gueltig_bis": "31.12.2014"
|
||||
* }
|
||||
* },
|
||||
* "valorisierung": ""
|
||||
* }
|
||||
* }
|
||||
* ]
|
||||
* }```
|
||||
*/
|
||||
abstract class AbstractGUIVertragsbestandteil extends AbstractBestandteil
|
||||
{
|
||||
|
||||
/** @var string hashkey */
|
||||
protected $uuid;
|
||||
|
||||
/** @var boolean does this vertragsbestandteil have a GBS array? */
|
||||
protected $hasGBS = false;
|
||||
/** @var array gehaltsbestandteile connected to current vertragsbestandteil */
|
||||
protected $gbs;
|
||||
|
||||
/** @var VertragsbestandteilLib */
|
||||
protected $vbsLib;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->vbsLib = new VertragsbestandteilLib();
|
||||
}
|
||||
|
||||
abstract public function generateVertragsbestandteil($id);
|
||||
|
||||
/**
|
||||
* Get the value of uuid
|
||||
*/
|
||||
public function getUuid()
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of uuid
|
||||
*/
|
||||
public function setUuid($uuid): self
|
||||
{
|
||||
$this->uuid = $uuid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of hasGBS
|
||||
*/
|
||||
public function getHasGBS()
|
||||
{
|
||||
return $this->hasGBS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of hasGBS
|
||||
*/
|
||||
public function setHasGBS($hasGBS): self
|
||||
{
|
||||
$this->hasGBS = $hasGBS;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of gbs
|
||||
*/
|
||||
public function getGbs()
|
||||
{
|
||||
return $this->gbs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of gbs
|
||||
*/
|
||||
public function setGbs($gbs): self
|
||||
{
|
||||
$this->gbs = $gbs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/AbstractBestandteil.php";
|
||||
require_once __DIR__ . "/GUIGueltigkeit.php";
|
||||
|
||||
class FormData extends AbstractBestandteil {
|
||||
|
||||
const TYPE_STRING = "formdata";
|
||||
|
||||
/** @var array GUI data */
|
||||
protected $children;
|
||||
/** @var array */
|
||||
protected $vbs = [];
|
||||
|
||||
public function getTypeString(): string
|
||||
{
|
||||
return FormData::TYPE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* read JSON and turn it into data structure
|
||||
*/
|
||||
public function mapJSON(&$decoded)
|
||||
{
|
||||
$this->checkType($decoded);
|
||||
// preserve gui data
|
||||
$this->mapChildren($decoded);
|
||||
// data contains DV
|
||||
$this->mapData($decoded);
|
||||
// vbs array
|
||||
$this->mapVbs($decoded);
|
||||
}
|
||||
|
||||
public function generateJSON()
|
||||
{
|
||||
$json = json_encode([
|
||||
"children" => $this->children,
|
||||
"data" => $this->generateDvJSON(),
|
||||
"vbs" => $this->generateVbsJSON()
|
||||
]);
|
||||
return $json;
|
||||
}
|
||||
|
||||
private function mapChildren(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'children'))
|
||||
{
|
||||
throw new \Exception('missing children');
|
||||
}
|
||||
$this->getJSONData($this->data['children'], $decodedData, 'children');
|
||||
}
|
||||
|
||||
private function mapData(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'data'))
|
||||
{
|
||||
throw new \Exception('missing data');
|
||||
}
|
||||
|
||||
$this->getJSONDataInt($this->data['dienstverhaeltnisid'], $decodedData, 'dienstverhaeltnisid');
|
||||
$this->getJSONData($this->data['unternehmen'], $decodedData, 'unternehmen');
|
||||
$this->getJSONData($this->data['vertragsart_kurzbz'], $decodedData, 'vertragsart_kurzbz');
|
||||
$gueltigkeit = new GUIGueltigkeit();
|
||||
$gueltigkeit->mapJSON($decodedData['gueltigkeit']);
|
||||
$this->data['gueltigkeit'] = $gueltigkeit;
|
||||
//$this->getJSONData($this->data['gueltigkeit'], $decodedData, 'gueltigkeit');
|
||||
}
|
||||
|
||||
private function generateDvJSON()
|
||||
{
|
||||
return json_encode($this->data);
|
||||
}
|
||||
|
||||
|
||||
private function mapVbs(&$decoded)
|
||||
{
|
||||
if (!$this->getJSONData($this->vbs, $decoded, 'vbs'))
|
||||
{
|
||||
throw new \Exception('missing vbs');
|
||||
}
|
||||
//$this->getJSONData($this->vbs, $decodedData, 'vbs');
|
||||
}
|
||||
|
||||
private function generateVbsJSON()
|
||||
{
|
||||
return json_encode($this->vbs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of children
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of vbs
|
||||
*/
|
||||
public function getVbs()
|
||||
{
|
||||
return $this->vbs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
require_once __DIR__ . "/AbstractBestandteil.php";
|
||||
require_once __DIR__ . "/GUIGueltigkeit.php";
|
||||
|
||||
/**
|
||||
* {
|
||||
* "type": "gehaltsbestandteil",
|
||||
* "guioptions": {
|
||||
* "id": "66246b54-9a42-43e8-b6d3-a541688ebb6e",
|
||||
* "removeable": true
|
||||
* },
|
||||
* "data": {
|
||||
* "gehaltstyp": "zulage",
|
||||
* "betrag": "100",
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "reflect"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "1.1.2011",
|
||||
* "gueltig_bis": ""
|
||||
* }
|
||||
* },
|
||||
* "valorisierung": ""
|
||||
* }
|
||||
*/
|
||||
class GUIGehaltsbestandteil extends AbstractBestandteil {
|
||||
|
||||
const TYPE_STRING = "gehaltsbestandteil";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = GUIVertragsbestandteilStunden::TYPE_STRING;
|
||||
$this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true];
|
||||
$this->data = [ "gehaltstyp" => "",
|
||||
"betrag" => "",
|
||||
"gueltigkeit" => [
|
||||
"guioptions" => ["sharedstatemode" => "reflect"],
|
||||
"data" => ["gueltig_ab" => "", "gueltig_bis" => ""]
|
||||
],
|
||||
"valorisierung" => true
|
||||
];
|
||||
}
|
||||
|
||||
public function getTypeString(): string
|
||||
{
|
||||
return GUIGehaltsbestandteil::TYPE_STRING;
|
||||
}
|
||||
|
||||
public function mapJSON(&$decoded)
|
||||
{
|
||||
//$decoded = json_decode($jsondata);
|
||||
$this->checkType($decoded);
|
||||
$this->mapGUIOptions($decoded);
|
||||
$this->mapData($decoded);
|
||||
}
|
||||
|
||||
private function mapGUIOptions(&$decoded)
|
||||
{
|
||||
$decodedGUIOptions = null;
|
||||
if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions'))
|
||||
{
|
||||
throw new \Exception('missing guioptions');
|
||||
}
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'id');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'removable');
|
||||
}
|
||||
|
||||
private function mapData(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'data'))
|
||||
{
|
||||
throw new \Exception('missing data');
|
||||
}
|
||||
$this->getJSONData($this->data['id'], $decodedData, 'id');
|
||||
$this->getJSONData($this->data['gehaltstyp'], $decodedData, 'gehaltstyp');
|
||||
$this->getJSONDataInt($this->data['betrag'], $decodedData, 'betrag');
|
||||
$gueltigkeit = new GUIGueltigkeit();
|
||||
$gueltigkeit->mapJSON($decodedData['gueltigkeit']);
|
||||
$this->data['gueltigkeit'] = $gueltigkeit;
|
||||
$this->getJSONData($this->data['valorisierung'], $decodedData, 'valorisierung');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/JSONData.php';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class GUIGueltigkeit implements JsonSerializable {
|
||||
|
||||
use JSONData;
|
||||
|
||||
/** @var array */
|
||||
protected $guioptions;
|
||||
/** @var array */
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* ```
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "reflect"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "",
|
||||
* "gueltig_bis": ""
|
||||
* }```
|
||||
*/
|
||||
public function mapJSON(&$decoded)
|
||||
{
|
||||
$this->mapGuioptions($decoded);
|
||||
$this->mapData($decoded);
|
||||
}
|
||||
|
||||
private function mapGuioptions(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'guioptions'))
|
||||
{
|
||||
throw new \Exception('missing guioptions');
|
||||
}
|
||||
$this->guioptions = $decodedData;
|
||||
}
|
||||
|
||||
private function mapData(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'data'))
|
||||
{
|
||||
throw new \Exception('missing data');
|
||||
}
|
||||
$this->getJSONData($this->data['gueltig_ab'], $decodedData, 'gueltig_ab');
|
||||
$this->getJSONData($this->data['gueltig_bis'], $decodedData, 'gueltig_bis');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of guioptions
|
||||
*/
|
||||
public function getGuioptions()
|
||||
{
|
||||
return $this->guioptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of data
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return ["guioptions" => $this->guioptions,
|
||||
"data" => $this->data];
|
||||
}
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
require_once __DIR__ . '/FormData.php';
|
||||
require_once __DIR__ . '/GUIHandlerFactory.php';
|
||||
require_once __DIR__ . '/../../../models/vertragsbestandteil/Dienstverhaeltnis_model.php';
|
||||
require_once __DIR__ . '/../VertragsbestandteilLib.php';
|
||||
require_once __DIR__ . '/util.php';
|
||||
|
||||
/**
|
||||
* GUIHandler takes JSON from GUI and manages the process of
|
||||
* storing the data to the database
|
||||
* TODO convert to controller
|
||||
*/
|
||||
class GUIHandler
|
||||
{
|
||||
|
||||
protected $employeeUID;
|
||||
protected $userUID;
|
||||
protected $CI;
|
||||
|
||||
public function __construct($employeeUID, $userUID)
|
||||
{
|
||||
$this->employeeUID = $employeeUID;
|
||||
$this->userUID = $userUID;
|
||||
$this->CI = get_instance();
|
||||
$this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model',
|
||||
'Dienstverhaeltnis_model');
|
||||
$this->CI->load->library('vertragsbestandteil/VertragsbestandteilLib',
|
||||
null, 'VertragsbestandteilLib');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* main entry (called from VetragsbestandteilLib)
|
||||
* @param string $guidata JSON submitted by editor
|
||||
* @param string $employeeUID uid of the employee
|
||||
* @param string $userUID uid of the user currently editing the employee data
|
||||
* @return string JSON for GUI client
|
||||
*/
|
||||
public function handle($guidata)
|
||||
{
|
||||
$decoded = json_decode($guidata, true);
|
||||
$formDataMapper = new FormData();
|
||||
$formDataMapper->mapJSON($decoded);
|
||||
|
||||
// DV
|
||||
$dvData = $formDataMapper->getData();
|
||||
$res = $this->handleDV($dvData);
|
||||
|
||||
if ($res === false)
|
||||
{
|
||||
// TODO write error message
|
||||
} else {
|
||||
|
||||
// VBS
|
||||
$vbsList = $formDataMapper->getVbs();
|
||||
|
||||
foreach ($vbsList as $vbsID => $vbs) {
|
||||
$this->handleVBS($dvData['dienstverhaeltnisid'] ,$vbs);
|
||||
}
|
||||
}
|
||||
|
||||
return $formDataMapper->generateJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
* dienstverhaeltnisid
|
||||
* unternehmen
|
||||
* vertragsart_kurzbz
|
||||
* gueltigkeit
|
||||
*/
|
||||
private function handleDV(&$dv)
|
||||
{
|
||||
$dienstverhaeltnisid = $dv['dienstverhaeltnisid'];
|
||||
|
||||
if (isset($dienstverhaeltnisid) && intval($dienstverhaeltnisid > 0))
|
||||
{
|
||||
// DV exists
|
||||
$res = $this->updateDV($dv);
|
||||
if (isSuccess($res))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// DV is new
|
||||
$res = $this->insertDV($dv);
|
||||
if (isSuccess($res))
|
||||
{
|
||||
// write back new id
|
||||
$dv['dienstverhaeltnisid'] = $res->retval[0]->dienstverhaeltnis_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private function handleVBS($dienstverhaeltnis_id, $vbs)
|
||||
{
|
||||
/** @var GUIVertragsbestandteilFunktion */
|
||||
$vbsMapper = GUIHandlerFactory::getGUIHandler($vbs['type']);
|
||||
$vbsMapper->mapJSON($vbs);
|
||||
$vbsData = $vbsMapper->getData();
|
||||
|
||||
// merge GUI-Data with DB-Data
|
||||
$vbsInstance = $vbsMapper->generateVertragsbestandteil(isset($vbsData['id'])?$vbsData['id']:null);
|
||||
if ($vbsInstance->getDienstverhaeltnis_id() === null)
|
||||
{
|
||||
$vbsInstance->setDienstverhaeltnis_id($dienstverhaeltnis_id);
|
||||
$vbsInstance->setInsertvon($this->userUID);
|
||||
$vbsInstance->setInsertamum((new DateTime())->format("Y-m-d h:m:s"));
|
||||
} else {
|
||||
$vbsInstance->setUpdatevon($this->userUID);
|
||||
$vbsInstance->setUpdateamum((new DateTime())->format("Y-m-d h:m:s"));
|
||||
}
|
||||
|
||||
// TODO Validate?
|
||||
|
||||
// store
|
||||
$this->CI->VertragsbestandteilLib->storeVertragsbestandteil($vbsInstance);
|
||||
|
||||
// GBS
|
||||
/*
|
||||
foreach ($vbsMapper->getGbs() as $gbs)
|
||||
{
|
||||
$gbsData = $gbs->getData();
|
||||
$this->handleGBS($gbsData);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
// GBS without connection to VBS
|
||||
private static function handleGBS($gbs)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// DV does not have a dedicated handler
|
||||
private function insertDV($dvJSON)
|
||||
{
|
||||
$dvJSON['mitarbeiter_uid'] = $this->employeeUID;
|
||||
$now = new DateTime();
|
||||
$dvJSON['von'] = string2Date($dvJSON['gueltigkeit']->getData()['gueltig_ab']);
|
||||
$dvJSON['bis'] = string2Date($dvJSON['gueltigkeit']->getData()['gueltig_bis']);
|
||||
$dvJSON['oe_kurzbz'] = $dvJSON['unternehmen'];
|
||||
$dvJSON['insertvon'] = $this->userUID;
|
||||
$dvJSON['insertamum'] = $now->format(DateTime::ATOM);
|
||||
|
||||
unset($dvJSON['dienstverhaeltnisid']);
|
||||
unset($dvJSON['children']);
|
||||
unset($dvJSON['gueltigkeit']);
|
||||
unset($dvJSON['unternehmen']);
|
||||
|
||||
$result = $this->CI->Dienstverhaeltnis_model->insert($dvJSON);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
throw Exception($result->msg);
|
||||
}
|
||||
|
||||
$record = $this->CI->Dienstverhaeltnis_model->load($result->retval);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
private function updateDV($dvJSON)
|
||||
{
|
||||
$dvJSON['mitarbeiter_uid'] = $this->employeeUID;
|
||||
$dvJSON['von'] = string2Date($dvJSON['gueltigkeit']->getData()['gueltig_ab']);
|
||||
$dvJSON['bis'] = string2Date($dvJSON['gueltigkeit']->getData()['gueltig_bis']);
|
||||
$dvJSON['oe_kurzbz'] = $dvJSON['unternehmen'];
|
||||
$now = new DateTime();
|
||||
$dvJSON['updatevon'] = $this->userUID;
|
||||
$dvJSON['updateamum'] = $now->format(DateTime::ATOM);
|
||||
$dvJSON['dienstverhaeltnis_id'] = $dvJSON['dienstverhaeltnisid'];
|
||||
|
||||
unset($dvJSON['insertamum']);
|
||||
unset($dvJSON['insertvon']);
|
||||
unset($dvJSON['dienstverhaeltnisid']);
|
||||
unset($dvJSON['children']);
|
||||
unset($dvJSON['gueltigkeit']);
|
||||
unset($dvJSON['unternehmen']);
|
||||
|
||||
$result = $this->CI->Dienstverhaeltnis_model->update($dvJSON);
|
||||
//$result = $this->CI->Dienstverhaeltnis_model->update($dvJSON['kontakt_id'], $dvJSON);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
|
||||
$record = $this->CI->Dienstverhaeltnis_model->load($result->retval);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
private function deleteDV($dv_id)
|
||||
{
|
||||
$result = $this->CI->Dienstverhaeltnis_model->delete($dv_id);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
|
||||
return success($dv_id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ .'/GUIVertragsbestandteilStunden.php';
|
||||
require_once __DIR__ .'/GUIVertragsbestandteilFunktion.php';
|
||||
require_once __DIR__ .'/GUIVertragsbestandteilKuendigungsfrist.php';
|
||||
require_once __DIR__ .'/GUIVertragsbestandteilZeitaufzeichnung.php';
|
||||
require_once __DIR__ .'/GUIVertragsbestandteilZusatzvereinbarung.php';
|
||||
|
||||
class GUIHandlerFactory {
|
||||
|
||||
public static function getGUIHandler($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case GUIVertragsbestandteilStunden::TYPE_STRING:
|
||||
return new GUIVertragsbestandteilStunden();
|
||||
break;
|
||||
case GUIVertragsbestandteilFunktion::TYPE_STRING:
|
||||
return new GUIVertragsbestandteilFunktion();
|
||||
break;
|
||||
case GUIVertragsbestandteilKuendigungsfrist::TYPE_STRING:
|
||||
return new GUIVertragsbestandteilKuendigungsfrist();
|
||||
break;
|
||||
case GUIVertragsbestandteilZeitaufzeichnung::TYPE_STRING:
|
||||
return new GUIVertragsbestandteilZeitaufzeichnung();
|
||||
break;
|
||||
case GUIVertragsbestandteilZusatzvereinbarung::TYPE_STRING:
|
||||
return new GUIVertragsbestandteilZusatzvereinbarung();
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
throw new \Exception('type not found: '.$type);
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/AbstractGUIVertragsbestandteil.php";
|
||||
require_once __DIR__ . "/GUIGehaltsbestandteil.php";
|
||||
require_once __DIR__ . "/GUIGueltigkeit.php";
|
||||
|
||||
class GUIVertragsbestandteilFunktion extends AbstractGUIVertragsbestandteil implements JsonSerializable
|
||||
{
|
||||
const TYPE_STRING = "vertragsbestandteilfunktion";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = GUIVertragsbestandteilFunktion::TYPE_STRING;
|
||||
$this->hasGBS = true;
|
||||
$this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => false];
|
||||
$this->data = ["funktion" => "Leitung",
|
||||
"orget" => "",
|
||||
"gueltigkeit" => [
|
||||
"guioptions" => ["sharedstatemode" => "reflect"],
|
||||
"data" => ["gueltig_ab" => "", "gueltig_bis" => ""]
|
||||
]
|
||||
];
|
||||
$this->gbs = [];
|
||||
}
|
||||
|
||||
public function getTypeString(): string
|
||||
{
|
||||
return GUIVertragsbestandteilFunktion::TYPE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse JSON into object
|
||||
* @param string $jsondata
|
||||
*/
|
||||
public function mapJSON(&$decoded)
|
||||
{
|
||||
$this->checkType($decoded);
|
||||
$this->mapGUIOptions($decoded);
|
||||
$this->mapData($decoded);
|
||||
$this->mapGBS($decoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* ["id" => null,
|
||||
* "infos" => [],
|
||||
* "errors" => [],
|
||||
* "removeable" => true
|
||||
* ]
|
||||
* @param mixed $decoded decoded JSON data (use associative array)
|
||||
*/
|
||||
private function mapGUIOptions(&$decoded)
|
||||
{
|
||||
$decodedGUIOptions = null;
|
||||
if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions'))
|
||||
{
|
||||
throw new \Exception('missing guioptions');
|
||||
}
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'id');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors');
|
||||
$this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable');
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "funktion": "Leitung",
|
||||
* "orget": "sdf",
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "reflect"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "",
|
||||
* "gueltig_bis": ""
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
private function mapData(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'data'))
|
||||
{
|
||||
throw new \Exception('missing data');
|
||||
}
|
||||
$this->getJSONData($this->data['funktion'], $decodedData, 'funktion');
|
||||
$this->getJSONData($this->data['orget'], $decodedData, 'orget');
|
||||
$gueltigkeit = new GUIGueltigkeit();
|
||||
$gueltigkeit->mapJSON($decodedData['gueltigkeit']);
|
||||
$this->data['gueltigkeit'] = $gueltigkeit;
|
||||
}
|
||||
|
||||
private function mapGBS(&$decoded)
|
||||
{
|
||||
//echo "gbs: ";var_dump($decoded);
|
||||
$decodedGbsList = [];
|
||||
if (!$this->getJSONData($decodedGbsList, $decoded, 'gbs'))
|
||||
{
|
||||
throw new \Exception('missing gbs');
|
||||
}
|
||||
$guiGBS = null;
|
||||
foreach ($decodedGbsList as $decodedGbs) {
|
||||
$guiGBS = new GUIGehaltsbestandteil();
|
||||
$guiGBS->mapJSON($decodedGbs);
|
||||
$this->gbs[] = $guiGBS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function generateVertragsbestandteil($id) {
|
||||
/** @var vertragsbestandteil\VertragsbestandteilFunktion */
|
||||
$vbs = null;
|
||||
if (isset($vbsData['id']) && $vbsData['id'] > 0)
|
||||
{
|
||||
// load VBS
|
||||
$vbs = $this->vbsLib->fetchVertragsbestandteil($vbsData['id']);
|
||||
} else {
|
||||
$vbs = new vertragsbestandteil\VertragsbestandteilFunktion();
|
||||
}
|
||||
// merge
|
||||
$vbs->setBenutzerfunktion_id($this->data['benutzerfunktionid']);
|
||||
$vbs->setVon(string2Date($this->data['gueltigkeit']->getData()['gueltig_ab']));
|
||||
$vbs->setBis(string2Date($this->data['gueltigkeit']->getData()['gueltig_bis']));
|
||||
return $vbs;
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
"type" => $this->type,
|
||||
"guioptions" => $this->guioptions,
|
||||
"data" => $this->data,
|
||||
"gbs" => $this->gbs];
|
||||
}
|
||||
|
||||
}
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/AbstractGUIVertragsbestandteil.php";
|
||||
|
||||
/**
|
||||
* "type": "vertragsbestandteilkuendigungsfrist",
|
||||
* "guioptions": {
|
||||
* "id": "c71a803d-b8be-4fbc-82f1-381e1d01df2e",
|
||||
* "removeable": true
|
||||
* },
|
||||
* "data": {
|
||||
* "arbeitgeber_frist": "8",
|
||||
* "arbeitnehmer_frist": "4",
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "reflect"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "1.1.2011",
|
||||
* "gueltig_bis": ""
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
class GUIVertragsbestandteilKuendigungsfrist extends AbstractGUIVertragsbestandteil implements JsonSerializable
|
||||
{
|
||||
const TYPE_STRING = "vertragsbestandteilkuendigungsfrist";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = GUIVertragsbestandteilKuendigungsfrist::TYPE_STRING;
|
||||
$this->hasGBS = false;
|
||||
$this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true];
|
||||
$this->data = ["arbeitnehmer_frist" => "",
|
||||
"arbeitgeber_frist" => "",
|
||||
"gueltigkeit" => [
|
||||
"guioptions" => ["sharedstatemode" => "reflect"],
|
||||
"data" => ["gueltig_ab" => "", "gueltig_bis" => ""]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function getTypeString(): string
|
||||
{
|
||||
return GUIVertragsbestandteilKuendigungsfrist::TYPE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse JSON into object
|
||||
* @param string $jsondata
|
||||
*/
|
||||
public function mapJSON(&$decoded)
|
||||
{
|
||||
$this->checkType($decoded);
|
||||
$this->mapGUIOptions($decoded);
|
||||
$this->mapData($decoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* ["id" => null,
|
||||
* "infos" => [],
|
||||
* "errors" => [],
|
||||
* "removeable" => true
|
||||
* ]
|
||||
* @param mixed $decoded decoded JSON data (use associative array)
|
||||
*/
|
||||
private function mapGUIOptions(&$decoded)
|
||||
{
|
||||
$decodedGUIOptions = null;
|
||||
if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions'))
|
||||
{
|
||||
throw new \Exception('missing guioptions');
|
||||
}
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'id');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors');
|
||||
$this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable');
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
private function mapData(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'data'))
|
||||
{
|
||||
throw new \Exception('missing data');
|
||||
}
|
||||
$this->getJSONDataInt($this->data['arbeitnehmer_frist'], $decodedData, 'arbeitnehmer_frist');
|
||||
$this->getJSONDataInt($this->data['arbeitgeber_frist'], $decodedData, 'arbeitgeber_frist');
|
||||
$this->getJSONData($this->data['gueltigkeit'], $decodedData, 'gueltigkeit');
|
||||
}
|
||||
|
||||
private function mapGBS()
|
||||
{
|
||||
$decodedGbsList = [];
|
||||
if (!$this->getJSONData($decodedGbsList, $decoded, 'gbs'))
|
||||
{
|
||||
throw new \Exception('missing gbs');
|
||||
}
|
||||
$guiGBS = null;
|
||||
foreach ($decodedGbsList as $decodedGbs) {
|
||||
$guiGBS = new GUIGehaltsbestandteil();
|
||||
$guiGBS->mapJSON($decodedGbs);
|
||||
}
|
||||
}
|
||||
|
||||
public function generateVertragsbestandteil($id) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
"type" => $this->type,
|
||||
"guioptions" => $this->guioptions,
|
||||
"data" => $this->data];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
require_once __DIR__ . "/AbstractGUIVertragsbestandteil.php";
|
||||
require_once __DIR__ . "/GUIGehaltsbestandteil.php";
|
||||
require_once __DIR__ . "/GUIGueltigkeit.php";
|
||||
require_once __DIR__ . "/../VertragsbestandteilFactory.php";
|
||||
require_once __DIR__ . "/../Vertragsbestandteil.php";
|
||||
require_once __DIR__ .'/../VertragsbestandteilStunden.php';
|
||||
|
||||
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
use vertragsbestandteil\VertragsbestandteilStunden;
|
||||
|
||||
|
||||
class GUIVertragsbestandteilStunden extends AbstractGUIVertragsbestandteil implements JsonSerializable
|
||||
{
|
||||
const TYPE_STRING = "vertragsbestandteilstunden";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = GUIVertragsbestandteilStunden::TYPE_STRING;
|
||||
$this->hasGBS = true;
|
||||
$this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true];
|
||||
$this->data = ["stunden" => "",
|
||||
"gueltigkeit" => [
|
||||
"guioptions" => ["sharedstatemode" => "reflect"],
|
||||
"data" => ["gueltig_ab" => "", "gueltig_bis" => ""]
|
||||
]
|
||||
];
|
||||
$this->gbs = [];
|
||||
}
|
||||
|
||||
public function getTypeString(): string
|
||||
{
|
||||
return GUIVertragsbestandteilStunden::TYPE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse JSON into object
|
||||
* @param string $jsondata
|
||||
*/
|
||||
public function mapJSON(&$decoded)
|
||||
{
|
||||
$this->checkType($decoded);
|
||||
$this->mapGUIOptions($decoded);
|
||||
$this->mapData($decoded);
|
||||
$this->mapGBS($decoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* ["id" => null,
|
||||
* "infos" => [],
|
||||
* "errors" => [],
|
||||
* "removeable" => true
|
||||
* ]
|
||||
* @param mixed $decoded decoded JSON data (use associative array)
|
||||
*/
|
||||
private function mapGUIOptions(&$decoded)
|
||||
{
|
||||
$decodedGUIOptions = null;
|
||||
if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions'))
|
||||
{
|
||||
throw new \Exception('missing guioptions');
|
||||
}
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'id');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors');
|
||||
$this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable');
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "stunden": "38,5",
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "reflect"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "1.1.2011",
|
||||
* "gueltig_bis": ""
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
private function mapData(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'data'))
|
||||
{
|
||||
throw new \Exception('missing data');
|
||||
}
|
||||
$this->getJSONDataFloat($this->data['stunden'], $decodedData, 'stunden');
|
||||
$gueltigkeit = new GUIGueltigkeit();
|
||||
$gueltigkeit->mapJSON($decodedData['gueltigkeit']);
|
||||
$this->data['gueltigkeit'] = $gueltigkeit;
|
||||
}
|
||||
|
||||
private function mapGBS(&$decoded)
|
||||
{
|
||||
$decodedGbsList = [];
|
||||
if (!$this->getJSONData($decodedGbsList, $decoded, 'gbs'))
|
||||
{
|
||||
throw new \Exception('missing gbs');
|
||||
}
|
||||
$guiGBS = null;
|
||||
foreach ($decodedGbsList as $decodedGbs) {
|
||||
$guiGBS = new GUIGehaltsbestandteil();
|
||||
$guiGBS->mapJSON($decodedGbs);
|
||||
$this->gbs[] = $guiGBS;
|
||||
}
|
||||
}
|
||||
|
||||
public function generateVertragsbestandteil($id)
|
||||
{
|
||||
$vbs = null;
|
||||
if (isset($vbsData['id']) && $vbsData['id'] > 0)
|
||||
{
|
||||
// load VBS
|
||||
$vbs = $this->vbsLib->fetchVertragsbestandteil($vbsData['id']);
|
||||
} else {
|
||||
$vbs = new vertragsbestandteil\VertragsbestandteilStunden();
|
||||
}
|
||||
// merge
|
||||
$vbs->setWochenstunden($this->data['stunden']);
|
||||
$vbs->setVon(string2Date($this->data['gueltigkeit']->getData()['gueltig_ab']));
|
||||
$vbs->setBis(string2Date($this->data['gueltigkeit']->getData()['gueltig_bis']));
|
||||
return $vbs;
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
"type" => $this->type,
|
||||
"guioptions" => $this->guioptions,
|
||||
"data" => $this->data,
|
||||
"gbs" => $this->gbs];
|
||||
}
|
||||
|
||||
}
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/AbstractGUIVertragsbestandteil.php";
|
||||
require_once __DIR__ . "/GUIGehaltsbestandteil.php";
|
||||
require_once __DIR__ . "/GUIGueltigkeit.php";
|
||||
|
||||
/**
|
||||
* ```
|
||||
* "type": "vertragsbestandteilzeitaufzeichnung",
|
||||
* "guioptions": {
|
||||
* "id": "484f7166-7792-4cc7-b906-0db09c65bbf4",
|
||||
* "removeable": true
|
||||
* },
|
||||
* "data": {
|
||||
* "zeitaufzeichnung": true,
|
||||
* "azgrelevant": false,
|
||||
* "homeoffice": true,
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "reflect"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "1.1.2010",
|
||||
* "gueltig_bis": ""
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
class GUIVertragsbestandteilZeitaufzeichnung extends AbstractGUIVertragsbestandteil implements JsonSerializable
|
||||
{
|
||||
const TYPE_STRING = "vertragsbestandteilzeitaufzeichnung";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = GUIVertragsbestandteilZeitaufzeichnung::TYPE_STRING;
|
||||
$this->hasGBS = false;
|
||||
$this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true];
|
||||
$this->data = null;
|
||||
}
|
||||
|
||||
public function getTypeString(): string
|
||||
{
|
||||
return GUIVertragsbestandteilZeitaufzeichnung::TYPE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse JSON into object
|
||||
* @param string $jsondata
|
||||
*/
|
||||
public function mapJSON(&$decoded)
|
||||
{
|
||||
$this->checkType($decoded);
|
||||
$this->mapGUIOptions($decoded);
|
||||
$this->mapData($decoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* ["id" => null,
|
||||
* "infos" => [],
|
||||
* "errors" => [],
|
||||
* "removeable" => true
|
||||
* ]
|
||||
* @param mixed $decoded decoded JSON data (use associative array)
|
||||
*/
|
||||
private function mapGUIOptions(&$decoded)
|
||||
{
|
||||
$decodedGUIOptions = null;
|
||||
if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions'))
|
||||
{
|
||||
throw new \Exception('missing guioptions');
|
||||
}
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'id');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors');
|
||||
$this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable');
|
||||
}
|
||||
|
||||
private function mapData(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'data'))
|
||||
{
|
||||
throw new \Exception('missing data');
|
||||
}
|
||||
$this->getJSONDataBool($this->data['zeitaufzeichnung'], $decodedData, 'zeitaufzeichnung');
|
||||
$this->getJSONDataBool($this->data['azgrelevant'], $decodedData, 'azgrelevant');
|
||||
$this->getJSONDataBool($this->data['homeoffice'], $decodedData, 'homeoffice');
|
||||
$gueltigkeit = new GUIGueltigkeit();
|
||||
$gueltigkeit->mapJSON($decodedData['gueltigkeit']);
|
||||
$this->data['gueltigkeit'] = $gueltigkeit;
|
||||
}
|
||||
|
||||
public function generateVertragsbestandteil($id) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
"type" => $this->type,
|
||||
"guioptions" => $this->guioptions,
|
||||
"data" => $this->data];
|
||||
}
|
||||
}
|
||||
-139
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . "/AbstractGUIVertragsbestandteil.php";
|
||||
require_once __DIR__ . "/GUIGehaltsbestandteil.php";
|
||||
require_once __DIR__ . "/GUIGueltigkeit.php";
|
||||
|
||||
/**
|
||||
* ```
|
||||
* "type": "vertragsbestandteilfreitext",
|
||||
* "guioptions": {
|
||||
* "id": "b168a3bb-d0e2-407f-8192-525a5ab59b22",
|
||||
* "removeable": true
|
||||
* },
|
||||
* "data": {
|
||||
* "freitexttyp": "allin",
|
||||
* "titel": "Lorem ipsum ",
|
||||
* "freitext": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \nAt vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. ",
|
||||
* "kuendigungsrelevant": "",
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "reflect"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "1.1.2010",
|
||||
* "gueltig_bis": ""
|
||||
* }
|
||||
* }
|
||||
* },
|
||||
* "gbs": []```
|
||||
*/
|
||||
class GUIVertragsbestandteilZusatzvereinbarung extends AbstractGUIVertragsbestandteil implements JsonSerializable
|
||||
{
|
||||
const TYPE_STRING = "vertragsbestandteilfreitext";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = GUIVertragsbestandteilZusatzvereinbarung::TYPE_STRING;
|
||||
$this->hasGBS = true;
|
||||
$this-> guioptions = ["id" => null, "infos" => [], "errors" => [], "removeable" => true];
|
||||
$this->data = null;
|
||||
$this->gbs = [];
|
||||
}
|
||||
|
||||
public function getTypeString(): string
|
||||
{
|
||||
return GUIVertragsbestandteilZusatzvereinbarung::TYPE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse JSON into object
|
||||
* @param string $jsondata
|
||||
*/
|
||||
public function mapJSON(&$decoded)
|
||||
{
|
||||
$this->checkType($decoded);
|
||||
$this->mapGUIOptions($decoded);
|
||||
$this->mapData($decoded);
|
||||
$this->mapGBS($decoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* ["id" => null,
|
||||
* "infos" => [],
|
||||
* "errors" => [],
|
||||
* "removeable" => true
|
||||
* ]
|
||||
* @param mixed $decoded decoded JSON data (use associative array)
|
||||
*/
|
||||
private function mapGUIOptions(&$decoded)
|
||||
{
|
||||
$decodedGUIOptions = null;
|
||||
if (!$this->getJSONData($decodedGUIOptions, $decoded, 'guioptions'))
|
||||
{
|
||||
throw new \Exception('missing guioptions');
|
||||
}
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'id');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'infos');
|
||||
$this->getJSONData($this->guioptions, $decodedGUIOptions, 'errors');
|
||||
$this->getJSONDataBool($this->guioptions, $decodedGUIOptions, 'removable');
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "freitexttyp": "allin",
|
||||
* "titel": "Lorem ipsum ",
|
||||
* "freitext": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \nAt vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. ",
|
||||
* "kuendigungsrelevant": "",
|
||||
* "gueltigkeit": {
|
||||
* "guioptions": {
|
||||
* "sharedstatemode": "reflect"
|
||||
* },
|
||||
* "data": {
|
||||
* "gueltig_ab": "1.1.2010",
|
||||
* "gueltig_bis": ""
|
||||
* }
|
||||
*/
|
||||
private function mapData(&$decoded)
|
||||
{
|
||||
$decodedData = null;
|
||||
if (!$this->getJSONData($decodedData, $decoded, 'data'))
|
||||
{
|
||||
throw new \Exception('missing data');
|
||||
}
|
||||
$this->getJSONDataString($this->data['freitexttyp'], $decodedData, 'freitexttyp');
|
||||
$this->getJSONDataString($this->data['titel'], $decodedData, 'titel');
|
||||
$this->getJSONDataString($this->data['freitext'], $decodedData, 'freitext');
|
||||
$gueltigkeit = new GUIGueltigkeit();
|
||||
$gueltigkeit->mapJSON($decodedData['gueltigkeit']);
|
||||
$this->data['gueltigkeit'] = $gueltigkeit;
|
||||
}
|
||||
|
||||
private function mapGBS(&$decoded)
|
||||
{
|
||||
$decodedGbsList = [];
|
||||
if (!$this->getJSONData($decodedGbsList, $decoded, 'gbs'))
|
||||
{
|
||||
throw new \Exception('missing gbs');
|
||||
}
|
||||
$guiGBS = null;
|
||||
foreach ($decodedGbsList as $decodedGbs) {
|
||||
$guiGBS = new GUIGehaltsbestandteil();
|
||||
$guiGBS->mapJSON($decodedGbs);
|
||||
$this->gbs[] = $guiGBS;
|
||||
}
|
||||
}
|
||||
|
||||
public function generateVertragsbestandteil($id) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
"type" => $this->type,
|
||||
"guioptions" => $this->guioptions,
|
||||
"data" => $this->data,
|
||||
"gbs" => $this->gbs];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
trait JSONData {
|
||||
protected function getJSONData(&$target, &$decoded, $attributeName)
|
||||
{
|
||||
if (isset($decoded[$attributeName]))
|
||||
{
|
||||
$target = $decoded[$attributeName];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getJSONDataString(&$target, &$decoded, $attributeName)
|
||||
{
|
||||
if (isset($decoded[$attributeName]))
|
||||
{
|
||||
$target = filter_var($decoded[$attributeName], FILTER_SANITIZE_STRING);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getJSONDataInt(&$target, &$decoded, $attributeName)
|
||||
{
|
||||
if (isset($decoded[$attributeName]) && filter_var($decoded[$attributeName], FILTER_VALIDATE_INT))
|
||||
{
|
||||
$target = filter_var($decoded[$attributeName], FILTER_VALIDATE_INT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getJSONDataFloat(&$target, &$decoded, $attributeName)
|
||||
{
|
||||
if (isset($decoded[$attributeName]) && filter_var($decoded[$attributeName], FILTER_VALIDATE_FLOAT))
|
||||
{
|
||||
$target = filter_var($decoded[$attributeName], FILTER_VALIDATE_FLOAT);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getJSONDataBool(&$target, &$decoded, $attributeName)
|
||||
{
|
||||
if (isset($decoded[$attributeName]) && filter_var($decoded[$attributeName], FILTER_VALIDATE_BOOL))
|
||||
{
|
||||
$target = filter_var($decoded[$attributeName], FILTER_VALIDATE_BOOL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
function string2Date($datestring)
|
||||
{
|
||||
$date = DateTimeImmutable::createFromFormat('j.m.Y', $datestring);
|
||||
if ($date === false) return null;
|
||||
return $date->format('Y-m-d');
|
||||
}
|
||||
Reference in New Issue
Block a user