mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 18:02:18 +00:00
Vertragsbestandteil Model: check if sap sync table present before executing select for sap organisationseinheit
This commit is contained in:
@@ -19,12 +19,17 @@ class Vertragsbestandteil_model extends DB_Model
|
|||||||
|
|
||||||
protected function getVertragsbestandteilSQL()
|
protected function getVertragsbestandteilSQL()
|
||||||
{
|
{
|
||||||
|
$sapInstalled = $this->_checkIfSAPSyncTableExists();
|
||||||
|
|
||||||
|
$oe_kurzbz_sap = $sapInstalled ? 'sap.oe_kurzbz_sap' : 'NULL AS oe_kurzbz_sap';
|
||||||
|
$sap_join = $sapInstalled ? 'LEFT JOIN sync.tbl_sap_organisationsstruktur sap USING(oe_kurzbz)' : '';
|
||||||
|
|
||||||
$sql = <<<EOSQL
|
$sql = <<<EOSQL
|
||||||
SELECT
|
SELECT
|
||||||
v.*,
|
v.*,
|
||||||
bf.funktion_kurzbz, bf.uid AS mitarbeiter_uid,
|
bf.funktion_kurzbz, bf.uid AS mitarbeiter_uid,
|
||||||
funktion.beschreibung AS funktion_bezeichnung,
|
funktion.beschreibung AS funktion_bezeichnung,
|
||||||
oe.oe_kurzbz, oe.bezeichnung AS oe_bezeichnung, sap.oe_kurzbz_sap,
|
oe.oe_kurzbz, oe.bezeichnung AS oe_bezeichnung, {$oe_kurzbz_sap},
|
||||||
oet.organisationseinheittyp_kurzbz AS oe_typ_kurzbz, oet.bezeichnung AS oe_typ_bezeichnung,
|
oet.organisationseinheittyp_kurzbz AS oe_typ_kurzbz, oet.bezeichnung AS oe_typ_bezeichnung,
|
||||||
ft.freitexttyp_kurzbz, ft.titel, ft.anmerkung,
|
ft.freitexttyp_kurzbz, ft.titel, ft.anmerkung,
|
||||||
f.benutzerfunktion_id,
|
f.benutzerfunktion_id,
|
||||||
@@ -39,7 +44,7 @@ class Vertragsbestandteil_model extends DB_Model
|
|||||||
hr.tbl_vertragsbestandteil_freitext ft USING(vertragsbestandteil_id)
|
hr.tbl_vertragsbestandteil_freitext ft USING(vertragsbestandteil_id)
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
hr.tbl_vertragsbestandteil_funktion f USING(vertragsbestandteil_id)
|
hr.tbl_vertragsbestandteil_funktion f USING(vertragsbestandteil_id)
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
public.tbl_benutzerfunktion bf USING(benutzerfunktion_id)
|
public.tbl_benutzerfunktion bf USING(benutzerfunktion_id)
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
public.tbl_funktion funktion USING(funktion_kurzbz)
|
public.tbl_funktion funktion USING(funktion_kurzbz)
|
||||||
@@ -47,8 +52,7 @@ class Vertragsbestandteil_model extends DB_Model
|
|||||||
public.tbl_organisationseinheit oe USING(oe_kurzbz)
|
public.tbl_organisationseinheit oe USING(oe_kurzbz)
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
public.tbl_organisationseinheittyp oet USING(organisationseinheittyp_kurzbz)
|
public.tbl_organisationseinheittyp oet USING(organisationseinheittyp_kurzbz)
|
||||||
LEFT JOIN
|
{$sap_join}
|
||||||
sync.tbl_sap_organisationsstruktur sap USING(oe_kurzbz)
|
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
hr.tbl_vertragsbestandteil_karenz k USING(vertragsbestandteil_id)
|
hr.tbl_vertragsbestandteil_karenz k USING(vertragsbestandteil_id)
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
@@ -178,4 +182,30 @@ EOSQL;
|
|||||||
|
|
||||||
return $vbcount[0]->overlappingvbs;
|
return $vbcount[0]->overlappingvbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if sap sync table exists.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function _checkIfSAPSyncTableExists()
|
||||||
|
{
|
||||||
|
$params = array(
|
||||||
|
DB_NAME,
|
||||||
|
'sync',
|
||||||
|
'tbl_sap_organisationsstruktur'
|
||||||
|
);
|
||||||
|
|
||||||
|
$sql = "SELECT
|
||||||
|
1 AS exists
|
||||||
|
FROM
|
||||||
|
information_schema.tables
|
||||||
|
WHERE
|
||||||
|
table_catalog = ? AND
|
||||||
|
table_schema = ? AND
|
||||||
|
table_name = ?";
|
||||||
|
|
||||||
|
$res = $this->execReadOnlyQuery($sql, $params);
|
||||||
|
|
||||||
|
return hasData($res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user