diff --git a/application/controllers/api/frontend/v1/funktionen/Funktionen.php b/application/controllers/api/frontend/v1/funktionen/Funktionen.php
index 030994736..b2787072b 100644
--- a/application/controllers/api/frontend/v1/funktionen/Funktionen.php
+++ b/application/controllers/api/frontend/v1/funktionen/Funktionen.php
@@ -11,14 +11,10 @@ class Funktionen extends FHCAPI_Controller
//TODO(Manu) check permissions
parent::__construct(array(
'getAllFunctions' => ['admin:r', 'assistenz:r'],
- 'getContractFunctions' => ['admin:r', 'assistenz:r'],
- 'getCurrentFunctions' => ['admin:r', 'assistenz:r'],
'getAllUserFunctions' => ['admin:r', 'assistenz:r'],
'getOrgHeads' => ['admin:r', 'assistenz:r'],
'getOrgetsForCompany' => ['admin:r', 'assistenz:r'],
- 'loadAllOes' => ['admin:r', 'assistenz:r'],
- 'searchOes' => ['admin:r', 'assistenz:r'],
- 'searchFunctions' => ['admin:r', 'assistenz:r'],
+ 'getAllOrgUnits' => ['admin:r', 'assistenz:r'],
'loadFunction' => ['admin:r', 'assistenz:r'],
'insertFunction' => ['admin:rw', 'assistenz:rw'],
'updateFunction' => ['admin:rw', 'assistenz:rw'],
@@ -43,6 +39,20 @@ class Funktionen extends FHCAPI_Controller
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
}
+ public function getAllFunctions()
+ {
+ $this->FunktionModel->addSelect("funktion_kurzbz");
+ $this->FunktionModel->addSelect("beschreibung");
+ $this->FunktionModel->addSelect("aktiv");
+ $this->FunktionModel->addSelect("beschreibung AS label");
+ $this->FunktionModel->addOrder("beschreibung");
+ $result = $this->FunktionModel->load();
+
+ $data = $this->getDataOrTerminateWithError($result);
+
+ $this->terminateWithSuccess($data);
+ }
+
public function getOrgHeads()
{
$result = $this->OrganisationseinheitModel->getHeads();
@@ -97,7 +107,7 @@ class Funktionen extends FHCAPI_Controller
WHERE
bf.uid = ?
ORDER BY
- f.beschreibung, bf.datum_von ASC";
+ bf.datum_von, bf.datum_von ASC";
$benutzerfunktionen = $this->BenutzerfunktionModel->execReadOnlyQuery($sql, array($uid));
$data = $this->getDataOrTerminateWithError($benutzerfunktionen);
@@ -106,14 +116,35 @@ class Funktionen extends FHCAPI_Controller
}
/*
- * return list of child orgets for a given company orget_kurzbz
+ * returns list of all organisation units
* as key value list to be used in select or autocomplete
*/
- public function getOrgetsForCompany($companyOrgetkurzbz=null)
+ public function getAllOrgUnits()
{
$sql = "
SELECT
- oe.oe_kurzbz,
+ oe.oe_kurzbz, oe.aktiv,
+ '[' || COALESCE(oet.bezeichnung, oet.organisationseinheittyp_kurzbz) ||
+ '] ' || COALESCE(oe.bezeichnung, oe.oe_kurzbz) AS label
+ FROM public.tbl_organisationseinheit oe
+ JOIN public.tbl_organisationseinheittyp oet ON oe.organisationseinheittyp_kurzbz = oet.organisationseinheittyp_kurzbz
+ ORDER BY oet.bezeichnung ASC, oe.bezeichnung ASC";
+
+ $result = $this->OrganisationseinheitModel->execReadOnlyQuery($sql);
+ $data = $this->getDataOrTerminateWithError($result);
+
+ $this->terminateWithSuccess($data);
+ }
+
+ /*
+ * return list of child orgets for a given company orget_kurzbz
+ * as key value list to be used in select or autocomplete
+ */
+ public function getOrgetsForCompany($companyOrgetkurzbz = null)
+ {
+ $sql = "
+ SELECT
+ oe.oe_kurzbz, oe.aktiv,
'[' || COALESCE(oet.bezeichnung, oet.organisationseinheittyp_kurzbz) ||
'] ' || COALESCE(oe.bezeichnung, oe.oe_kurzbz) AS label
FROM (
@@ -139,25 +170,6 @@ class Funktionen extends FHCAPI_Controller
$this->terminateWithSuccess($data);
}
- public function searchOes($companyOrgetKurzbz, $searchString = null)
- {
- $result = $this->OrganisationseinheitModel->getAutocompleteSuggestionsWithCompany($companyOrgetKurzbz, $searchString);
- if (isError($result)) {
- $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
- }
- $this->terminateWithSuccess($result ?: []);
- }
-
- public function searchFunctions($searchString = null)
- {
-
- $result = $this->FunktionModel->getAutocompleteSuggestions($searchString);
- if (isError($result)) {
- $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
- }
- $this->terminateWithSuccess($result ?: []);
- }
-
public function loadFunction($benutzerfunktion_id)
{
$this->BenutzerfunktionModel->addSelect("*");
diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php
index b146ee7e5..ba91964f6 100644
--- a/application/models/organisation/Organisationseinheit_model.php
+++ b/application/models/organisation/Organisationseinheit_model.php
@@ -191,7 +191,7 @@ class Organisationseinheit_model extends DB_Model
/**
* @param string $oe_kurzbz
- *
+ *
* @return stdClass
*/
public function getWithType($oe_kurzbz)
@@ -202,78 +202,6 @@ class Organisationseinheit_model extends DB_Model
return $this->load($oe_kurzbz);
}
- /**
- * Get OEs by eventQuery string. Use with autocomplete event queries.
- * @param $eventQuery String
- * @return array
- */
- public function getAutocompleteSuggestions($eventQuery)
- {
- $this->addSelect('oe_kurzbz');
- $this->addSelect('organisationseinheittyp_kurzbz, oe_kurzbz, bezeichnung, aktiv, lehre');
- $this->addOrder('organisationseinheittyp_kurzbz, bezeichnung');
-
- return $this->loadWhere("
- oe_kurzbz ILIKE '%". $this->escapeLike($eventQuery). "%'
- ");
- }
-
- /**
- * Get OEs by eventQuery string and companyOrgetKurzbz
- * Use with autocomplete event queries in Function Component
- * @param $searchString String
- * @param $companyOrgetKurzbz String oe_kurzbz of the company (gst vs gmbh)
- * @return array
- */
- public function getAutocompleteSuggestionsWithCompany($companyOrgetKurzbz, $searchString)
- {
- $sql = "
- WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) AS (
- SELECT oe_kurzbz, oe_parent_kurzbz
- FROM public.tbl_organisationseinheit
- WHERE oe_kurzbz = ?
- UNION ALL
- SELECT o.oe_kurzbz, o.oe_parent_kurzbz
- FROM public.tbl_organisationseinheit o
- INNER JOIN oes ON o.oe_parent_kurzbz = oes.oe_kurzbz
- )
- SELECT
- oe.oe_kurzbz, oe.aktiv,
- '[' || COALESCE(oet.bezeichnung, oet.organisationseinheittyp_kurzbz) ||
- '] ' || COALESCE(oe.bezeichnung, oe.oe_kurzbz) AS label
- FROM (
- SELECT oe_kurzbz FROM oes GROUP BY oe_kurzbz
- ) c
- JOIN public.tbl_organisationseinheit oe ON oe.oe_kurzbz = c.oe_kurzbz
- JOIN public.tbl_organisationseinheittyp oet ON oe.organisationseinheittyp_kurzbz = oet.organisationseinheittyp_kurzbz
- ";
-
- $params = [$companyOrgetKurzbz];
-
- if (!empty($searchString)) {
- $escaped = $this->escapeLike($searchString);
- $ilike = '%' . $escaped . '%';
-
- $sql .= "
- WHERE
- oe.oe_kurzbz ILIKE ? OR
- oe.bezeichnung ILIKE ? OR
- oe.organisationseinheittyp_kurzbz ILIKE ?
- ";
-
- $params[] = $ilike;
- $params[] = $ilike;
- $params[] = $ilike;
- }
-
- $sql .= " ORDER BY oet.bezeichnung ASC, oe.bezeichnung ASC";
-
- $result = $this->execQuery($sql, $params);
-
- return $result;
- }
-
-
/**
* get highest organisation units
*/
diff --git a/application/models/ressource/Funktion_model.php b/application/models/ressource/Funktion_model.php
index 60965b438..43908167c 100644
--- a/application/models/ressource/Funktion_model.php
+++ b/application/models/ressource/Funktion_model.php
@@ -11,26 +11,4 @@ class Funktion_model extends DB_Model
$this->dbTable = 'public.tbl_funktion';
$this->pk = 'funktion_kurzbz';
}
-
- /**
- * Get Functions by eventQuery string. Use with autocomplete event queries in Function Component
- * @param $eventQuery String
- * @return array
- */
- public function getAutocompleteSuggestions($eventQuery)
- {
- $this->addSelect('funktion_kurzbz, beschreibung, aktiv');
- $this->addSelect("beschreibung AS label");
- $this->addOrder('beschreibung', 'ASC');
-
- if($eventQuery === null)
- {
- return $this->load();
- }
-
- return $this->loadWhere("
- funktion_kurzbz ILIKE '%". $this->escapeLike($eventQuery). "%'
- OR beschreibung ILIKE '%". $this->escapeLike($eventQuery). "%'
- ");
- }
}
diff --git a/public/js/api/factory/functions.js b/public/js/api/factory/functions.js
index ac717050a..ef0be43cb 100644
--- a/public/js/api/factory/functions.js
+++ b/public/js/api/factory/functions.js
@@ -15,17 +15,6 @@
* along with this program. If not, see