diff --git a/application/controllers/components/SearchBar.php b/application/controllers/components/SearchBar.php new file mode 100644 index 000000000..41cadbe8e --- /dev/null +++ b/application/controllers/components/SearchBar.php @@ -0,0 +1,43 @@ +load->library('SearchBarLib'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + public function index() + { + $this->load->view('test'); + } + + /** + * + */ + public function search() + { + $searchstr = $this->input->post(self::SEARCHSTR_PARAM); + $types = $this->input->post(self::TYPES_PARAM); + + $this->outputJson($this->searchbarlib->search($searchstr, $types)); + } +} + diff --git a/application/libraries/SearchBarLib.php b/application/libraries/SearchBarLib.php new file mode 100644 index 000000000..d72aa750f --- /dev/null +++ b/application/libraries/SearchBarLib.php @@ -0,0 +1,199 @@ +_ci =& get_instance(); // get code igniter instance + + // + $this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * + */ + public function search($searchstr, $types) + { + // + $search = $this->_checkParameters($searchstr, $types); + // + if (isSuccess($search)) $search = $this->_search($searchstr, $types); + + return $search; // + } + + //------------------------------------------------------------------------------------------------------------------ + // Private methods + + /** + * + */ + private function _checkParameters($searchstr, $types) + { + // + if (isEmptyString($searchstr)) + { + return error(self::ERROR_WRONG_SEARCHSTR); + } + + // + if (isEmptyArray($types)) + { + return error(self::ERROR_NO_TYPES); + } + else + { + // + if (!isEmptyArray(array_diff($types, self::ALLOWED_TYPES))) + { + return error(self::ERROR_WRONG_TYPES); + } + } + + return success(); // + } + + /** + * + */ + private function _search($searchstr, $types) + { + $data = array(); // + + // + foreach ($types as $type) + { + // + $data = array_merge($data, $this->{'_'.$type}($searchstr, $type)); + } + + $result = new stdClass(); + $result->data = $data; + + return $result; + } + + /** + * + */ + private function _mitarbeiter($searchstr, $type) + { + $dbModel = new DB_Model(); + + $employees = $dbModel->execReadOnlyQuery(' + SELECT + \''.$type.'\' AS type, + b.uid, + p.person_id, + p.vorname || \' \' || p.nachname AS name, + b.uid AS email, + m.telefonklappe AS phone + FROM public.tbl_mitarbeiter m + JOIN public.tbl_benutzer b ON(b.uid = m.mitarbeiter_uid) + JOIN public.tbl_person p USING(person_id) + WHERE m.mitarbeiter_uid ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\' + '); + + // + if (hasData($employees)) return getData($employees); + + // + return array(); + } + + /** + * + */ + private function _organisationunit($searchstr, $type) + { + $dbModel = new DB_Model(); + + $ous = $dbModel->execReadOnlyQuery(' + SELECT + \''.$type.'\' AS type, + o.oe_kurzbz, + o.bezeichnung AS name, + o.oe_parent_kurzbz AS parentoe_kurzbz, + o.oe_parent_kurzbz AS parentoe_name + FROM public.tbl_organisationseinheit o + WHERE o.oe_kurzbz ILIKE \'%'.$dbModel->escapeLike($searchstr).'%\' + '); + + // + if (hasData($ous)) return getData($ous); + + // + return array(); + } + + /** + * + */ + private function _person($searchstr, $type) + { + return array(); + } + + /** + * + */ + private function _student($searchstr, $type) + { + return array(); + } + + /** + * + */ + private function _prestudent($searchstr, $type) + { + return array(); + } + + /** + * + */ + private function _document($searchstr, $type) + { + return array(); + } + + /** + * + */ + private function _cms($searchstr, $type) + { + return array(); + } + + /** + * + */ + private function raum($searchstr, $type) + { + return array(); + } +} + diff --git a/application/views/system/logs/logsViewerData.php b/application/views/system/logs/logsViewerData.php deleted file mode 100644 index f8476df6a..000000000 --- a/application/views/system/logs/logsViewerData.php +++ /dev/null @@ -1,66 +0,0 @@ - ' - SELECT wsl.webservicelog_id AS "LogId", - wsl.request_id AS "RequestId", - wsl.execute_time AS "ExecutionTime", - wsl.execute_user AS "ExecutedBy", - wsl.beschreibung AS "Description", - wsl.request_data AS "Data", - wsl.webservicetyp_kurzbz AS "WebserviceType" - FROM system.tbl_webservicelog wsl - ORDER BY wsl.execute_time DESC - ', - 'requiredPermissions' => 'admin', - 'datasetRepresentation' => 'tablesorter', - 'columnsAliases' => array( - 'Log id', - 'Request id', - 'Execution time', - 'Executed by', - 'Producer', - 'Data', - 'Webservice type' - ), - 'formatRow' => function($datasetRaw) { - - $datasetRaw->ExecutionTime = date_format(date_create($datasetRaw->ExecutionTime), 'd.m.Y H:i:s:u'); - - return $datasetRaw; - }, - 'markRow' => function($datasetRaw) { - - $mark = ''; - - if (strpos($datasetRaw->RequestId, 'error') != false) - { - $mark = 'text-red'; - } - - if (strpos($datasetRaw->RequestId, 'info') != false) - { - $mark = 'text-green'; - } - - if (strpos($datasetRaw->RequestId, 'warning') != false) - { - $mark = 'text-orange'; - } - - if (strpos($datasetRaw->RequestId, 'debug') != false) - { - $mark = 'text-info'; - } - - return $mark; - } - ); - - $filterWidgetArray['app'] = 'core'; - $filterWidgetArray['datasetName'] = 'logs'; - $filterWidgetArray['filter_id'] = $this->input->get('filter_id'); - - echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); -?> -