GRIS_HISTORY
extends GRIS_CLASS_TEMPLATE
in package
Basic abstract class
With this class all mandatory methods and attributes are defined
PHP version 7
Copyright (c) 2017, Holger Heuser Sportplatzweg 7 56357 Oelsberg, Germany
Table of Contents
- dbtable = 'gris_history'
- The constant for the database table
- settings_group = "history"
- The constant for the settings group
- $classname : object
- The name of the class
- $dbconnection : object
- The database object for managing the connection
- $full_data : array<string|int, mixed>
- The dataset of the resource information
- $history_types : array<string|int, mixed>
- The complete history type table
- $i18n : object
- The object for translations
- $id : object
- The current object ID
- $settings : object
- The object for settings
- $state : object
- The object for state
- $xml_data : string
- The data as xml string
- __construct() : mixed
- The class constructor
- autoCreate_historyOrgaEventStatus() : bool
- Creates a History Event when a Organigramm entry of a person is changed
- autoSave_historyOrgaEvent() : mixed
- Creates a new History Event when the Organigramm of a person is changed
- check_history() : array<string|int, mixed>
- Checks if the events in this series are valid (comparing the follow-up states)
- check_state() : array<string|int, mixed>
- Checks if an event is valid at the current position inside the series
- copy_event() : array<string|int, mixed>
- Copies all data from the previous event
- count_history_series() : int
- Create a new history event entry
- debug() : bool
- Output the full dataset without object data (all subobjects are parsed recursively)
- delete_history_event() : bool
- Delete a history entry
- delete_history_series() : bool
- Delete a history series
- get() : array<string|int, mixed>|object|string
- Returns an array of the full data or (if given) only certain attributes (separated by "|" for a subattribute)
- get_flat_data() : array<string|int, mixed>
- Get the data in a flat format. From subarrays only the first entry is merged
- get_flat_data_old() : array<string|int, mixed>
- Get the data in a flat format. From subarrays only the first entry is merged
- get_history_event() : array<string|int, mixed>
- Returns a single history event
- get_history_events() : array<string|int, mixed>
- Returns a list of history events of a history_serie
- get_history_fields() : array<string|int, mixed>
- Returns an array with field information for a history type
- get_history_next_states() : array<string|int, mixed>
- Returns all follow-up states for a given history state
- get_history_series() : array<string|int, mixed>
- Returns all history series for a given person ID, series ID oder history type
- get_history_series_range() : array<string|int, mixed>
- Returns start date, last date and current state of a given history series
- get_history_states() : array<string|int, mixed>
- Returns all states
- get_history_types() : array<string|int, mixed>
- Returns all history types (or only the ones related to a given person_id)
- get_series_id_by_event() : int
- Undocumented function
- get_validity() : int
- Gets the validity (NULL = undefined, 0 = invalid, 1 = valid) of a history series
- id() : int
- Set a new ID or return the current ID if $id is NULL. The numeric value 0 is also set to NULL.
- pull_json() : string
- Returns the object data as JSON
- pull_xml() : string
- Returns the object data as XML
- push_xml() : bool
- Push an xml into the object (experimental, not finished yet)
- rename_history_series() : int
- Rename a history series
- reset() : bool
- Reset the whole object (ID = NULL, full_data is empty)
- set_history_event() : int
- Create a new history event entry
- set_history_series() : int
- Create a new history series and history entry
- set_validity() : bool
- Sets the validity (NULL = undefined, 0 = invalid, 1 = valid) of a history series
- unset_attribute() : bool
- Unsets an attribute
- update_history_event() : int
- Update a history event entry
- initialize() : bool
- Initializes the object by filling the array with data
- array_to_xml() : bool
- Convert an array into an xml representation
- find_previous_event() : array<string|int, mixed>
- Finds the previous event in a series
- load_history_types() : array<string|int, mixed>
- Returns all history types
- out() : bool
- Preformatted output of the variable (for development)
Constants
dbtable
The constant for the database table
public
mixed
dbtable
= 'gris_history'
settings_group
The constant for the settings group
public
mixed
settings_group
= "history"
Properties
$classname
The name of the class
protected
object
$classname
= NULL
Tags
$dbconnection
The database object for managing the connection
protected
object
$dbconnection
= NULL
Tags
$full_data
The dataset of the resource information
protected
array<string|int, mixed>
$full_data
= array()
Tags
$history_types
The complete history type table
protected
array<string|int, mixed>
$history_types
= NULL
Tags
$i18n
The object for translations
protected
object
$i18n
Tags
$id
The current object ID
protected
object
$id
Tags
$settings
The object for settings
protected
object
$settings
= null
Tags
$state
The object for state
protected
object
$state
Tags
$xml_data
The data as xml string
protected
string
$xml_data
= NULL
Tags
Methods
__construct()
The class constructor
public
__construct() : mixed
Initializes the objects
Return values
mixed —autoCreate_historyOrgaEventStatus()
Creates a History Event when a Organigramm entry of a person is changed
public
autoCreate_historyOrgaEventStatus(string $personID, string $unitID, string $state[, string $role = NULL ][, mixed $date = NULL ]) : bool
Parameters
- $personID : string
-
ID of the person
- $unitID : string
-
ID of the unit
- $state : string
-
State of the new history event
- $role : string = NULL
-
Role of the new history event or NULL for finished
- $date : mixed = NULL
Return values
bool —returns false if the History could not be changed
autoSave_historyOrgaEvent()
Creates a new History Event when the Organigramm of a person is changed
public
autoSave_historyOrgaEvent(array<string|int, mixed> $orgaData) : mixed
Parameters
- $orgaData : array<string|int, mixed>
-
- Array of organigram data
Return values
mixed —check_history()
Checks if the events in this series are valid (comparing the follow-up states)
public
check_history(array<string|int, mixed> $history_events) : array<string|int, mixed>
Parameters
- $history_events : array<string|int, mixed>
-
Alle events of the series
Return values
array<string|int, mixed> —Returns an array with the numbers of invalid events (starting with 1)
check_state()
Checks if an event is valid at the current position inside the series
public
check_state(string $date, int $state, array<string|int, mixed> $series_id, int $ignore) : array<string|int, mixed>
Parameters
- $date : string
-
The date of the new event
- $state : int
-
The state of the new event
- $series_id : array<string|int, mixed>
-
The series ID
- $ignore : int
-
Ignore warnings with override = 1
Return values
array<string|int, mixed> —Returns an array with the error and the possibility to override it oder an empty array for success
copy_event()
Copies all data from the previous event
public
copy_event(int $series_id, int $target_id) : array<string|int, mixed>
Parameters
- $series_id : int
-
The ID of the series
- $target_id : int
-
The ID of the target event
Return values
array<string|int, mixed> —Returns true for success and false for errors
count_history_series()
Create a new history event entry
public
count_history_series(array<string|int, mixed> $series_id, array<string|int, mixed> $count) : int
Parameters
- $series_id : array<string|int, mixed>
-
The data for the history entry
- $count : array<string|int, mixed>
-
The data for the history entry
Return values
int —The ID of the history entry
debug()
Output the full dataset without object data (all subobjects are parsed recursively)
public
debug() : bool
Return values
bool —true
delete_history_event()
Delete a history entry
public
delete_history_event(int $id) : bool
Parameters
- $id : int
-
The gris_history_id
Return values
bool —true if the entry was deleted, otherwise false
delete_history_series()
Delete a history series
public
delete_history_series(int $id) : bool
Parameters
- $id : int
-
The gris_history_series_id
Return values
bool —true if the entry was deleted, otherwise false
get()
Returns an array of the full data or (if given) only certain attributes (separated by "|" for a subattribute)
public
get([string $attribute = NULL ]) : array<string|int, mixed>|object|string
Parameters
- $attribute : string = NULL
-
The attributes separated by [parent|child]
Return values
array<string|int, mixed>|object|string —The dataset or NULL
get_flat_data()
Get the data in a flat format. From subarrays only the first entry is merged
public
get_flat_data([bool $hierarchy = false ][, mixed $data = NULL ]) : array<string|int, mixed>
Parameters
- $hierarchy : bool = false
-
Return full flat (standard) or array hierarchy (if true)
- $data : mixed = NULL
-
Use other data than $this->full_data
Return values
array<string|int, mixed> —The flat data
get_flat_data_old()
Get the data in a flat format. From subarrays only the first entry is merged
public
get_flat_data_old([bool $hierarchy = false ][, mixed $data = NULL ]) : array<string|int, mixed>
Parameters
- $hierarchy : bool = false
-
Return full flat (standard) or array hierarchy (if true)
- $data : mixed = NULL
-
Use other data than $this->full_data
Return values
array<string|int, mixed> —The flat data
get_history_event()
Returns a single history event
public
get_history_event(int $event_id) : array<string|int, mixed>
Parameters
- $event_id : int
-
The ID of history event
Return values
array<string|int, mixed> —The array with the data of the history event or NULL (gris_history_date is not converted)
get_history_events()
Returns a list of history events of a history_serie
public
get_history_events(int $series_id) : array<string|int, mixed>
Parameters
- $series_id : int
-
The ID of history series
Return values
array<string|int, mixed> —The array with all history events of the series
get_history_fields()
Returns an array with field information for a history type
public
get_history_fields(int $type_id) : array<string|int, mixed>
Parameters
- $type_id : int
-
The ID of history type
Return values
array<string|int, mixed> —The array with type name as key and ID as value (or field name as key and a list if comma separated type IDs as JSON value)
get_history_next_states()
Returns all follow-up states for a given history state
public
get_history_next_states(string $current_state) : array<string|int, mixed>
Parameters
- $current_state : string
-
The current state
Return values
array<string|int, mixed> —An array with possible follow-up states
get_history_series()
Returns all history series for a given person ID, series ID oder history type
public
get_history_series([int $person_id = NULL ][, mixed $series_id = NULL ][, mixed $history_type = NULL ]) : array<string|int, mixed>
Parameters
- $person_id : int = NULL
-
The ID of the person
- $series_id : mixed = NULL
- $history_type : mixed = NULL
Return values
array<string|int, mixed> —The array with the history series
get_history_series_range()
Returns start date, last date and current state of a given history series
public
get_history_series_range(int $series_id) : array<string|int, mixed>
Parameters
- $series_id : int
-
The ID of the series
Return values
array<string|int, mixed> —The array with start date, last date and current state
get_history_states()
Returns all states
public
get_history_states([string $filter = NULL ][, string $history_type = NULL ]) : array<string|int, mixed>
Parameters
- $filter : string = NULL
-
Set "b" to return only begin state and "e" for all end states or "a" for all states (Default ist NULL to return all states without begin)
- $history_type : string = NULL
-
If a history type is given, the states will be filtered according to the table gris_history_type
Return values
array<string|int, mixed> —An array with states (begin state will be returned as a string)
get_history_types()
Returns all history types (or only the ones related to a given person_id)
public
get_history_types([int $person_id = NULL ][, bool $active = false ][, bool $filter_auto = false ]) : array<string|int, mixed>
Parameters
- $person_id : int = NULL
-
The ID of the person
- $active : bool = false
-
Get only active entries
- $filter_auto : bool = false
-
Filter aut generated entries
Return values
array<string|int, mixed> —The array with the history types
get_series_id_by_event()
Undocumented function
public
get_series_id_by_event(int $id) : int
Parameters
- $id : int
-
The event ID
Return values
int —Returns the series ID or NULL if not found
get_validity()
Gets the validity (NULL = undefined, 0 = invalid, 1 = valid) of a history series
public
get_validity(int $history_series_id) : int
Parameters
- $history_series_id : int
-
The series ID
Return values
int —Returns NULL for undefined, 0 for invalid or 1 for valid
id()
Set a new ID or return the current ID if $id is NULL. The numeric value 0 is also set to NULL.
public
id([string $id = NULL ]) : int
Parameters
- $id : string = NULL
-
The current ID
Return values
int —The ID
pull_json()
Returns the object data as JSON
public
pull_json() : string
Return values
string —The json string
pull_xml()
Returns the object data as XML
public
pull_xml([bool $head = false ]) : string
Parameters
- $head : bool = false
-
Return XML with head (as default, just a node is returned)
Return values
string —The xml string
push_xml()
Push an xml into the object (experimental, not finished yet)
public
push_xml(string $xml) : bool
Parameters
- $xml : string
-
The xml with the object data
Return values
bool —true (or false on error)
rename_history_series()
Rename a history series
public
rename_history_series(array<string|int, mixed> $history_series_id, array<string|int, mixed> $history_series_name) : int
Parameters
- $history_series_id : array<string|int, mixed>
-
The series ID
- $history_series_name : array<string|int, mixed>
-
The name of the series
Return values
int —The ID of the history entry
reset()
Reset the whole object (ID = NULL, full_data is empty)
public
reset() : bool
Return values
bool —Returns true
set_history_event()
Create a new history event entry
public
set_history_event(array<string|int, mixed> $data) : int
Parameters
- $data : array<string|int, mixed>
-
The data for the history entry
Return values
int —The ID of the history entry
set_history_series()
Create a new history series and history entry
public
set_history_series(array<string|int, mixed> $data) : int
Parameters
- $data : array<string|int, mixed>
-
The data for the history entry
Return values
int —The ID of the history entry or null
set_validity()
Sets the validity (NULL = undefined, 0 = invalid, 1 = valid) of a history series
public
set_validity(int $history_series_id, bool $valid) : bool
Parameters
- $history_series_id : int
-
The series ID
- $valid : bool
-
The value for the validity (Null, 0, 1)
Return values
bool —Returns true on success and false on error
unset_attribute()
Unsets an attribute
public
unset_attribute(string $attribute) : bool
Parameters
- $attribute : string
-
The attributes
Return values
bool —Returns true
update_history_event()
Update a history event entry
public
update_history_event(int $id, array<string|int, mixed> $data) : int
Parameters
- $id : int
-
The event ID
- $data : array<string|int, mixed>
-
The data for the history entry
Return values
int —The ID of the history entry
initialize()
Initializes the object by filling the array with data
protected
initialize() : bool
Return values
bool —true (or false on error)
array_to_xml()
Convert an array into an xml representation
private
array_to_xml(array<string|int, mixed> $data, Pointer &$xml) : bool
Parameters
- $data : array<string|int, mixed>
-
The array with the data
- $xml : Pointer
-
A pointer to the xml
Return values
bool —true (or NULL if empty)
find_previous_event()
Finds the previous event in a series
private
find_previous_event(int $series_id, int $target_id) : array<string|int, mixed>
Parameters
- $series_id : int
-
The ID of the series
- $target_id : int
-
The ID of the target event
Return values
array<string|int, mixed> —Returns the ID of the previous event for success or 0 (int) if it does not exist
load_history_types()
Returns all history types
private
load_history_types() : array<string|int, mixed>
Return values
array<string|int, mixed> —The array with the history types
out()
Preformatted output of the variable (for development)
private
out([mixed $mixed = NULL ]) : bool
Parameters
- $mixed : mixed = NULL
-
The variable
Return values
bool —true