diff --git a/application/config/navigation.php b/application/config/navigation.php index 928f5bae3..56d142d08 100644 --- a/application/config/navigation.php +++ b/application/config/navigation.php @@ -283,10 +283,18 @@ $config['navigation_menu']['system/issues/Issues/*'] = array( 'fehlerzustaendigkeiten' => array( 'link' => site_url('system/issues/IssuesZustaendigkeiten'), 'description' => 'Fehler Zuständigkeiten', - 'icon' => 'cogs', + 'icon' => 'users', 'sort' => 100, 'target' => '_blank', 'requiredPermissions' => array('admin:rw') - ) + ), + 'fehlerkonfiguration' => array( + 'link' => site_url('system/issues/IssuesKonfiguration'), + 'description' => 'Fehler Konfiguration', + 'icon' => 'cogs', + 'sort' => 200, + 'target' => '_blank', + 'requiredPermissions' => array('admin:rw') + ), ); diff --git a/application/controllers/system/issues/IssuesKonfiguration.php b/application/controllers/system/issues/IssuesKonfiguration.php new file mode 100644 index 000000000..fdc309798 --- /dev/null +++ b/application/controllers/system/issues/IssuesKonfiguration.php @@ -0,0 +1,239 @@ + 'admin:r', + 'getApps' => 'admin:r', + 'getFehlerKonfigurationByApp' => 'admin:r', + 'saveFehlerKonfiguration' => 'admin:rw', + 'deleteKonfiguration' => 'admin:rw' + ) + ); + + // Load libraries + $this->load->library('IssuesLib'); + $this->load->library('WidgetLib'); + + // Load models + $this->load->model('system/Fehlerkonfigurationstyp_model', 'FehlerkonfigurationstypModel'); + $this->load->model('system/Fehlerkonfiguration_model', 'FehlerkonfigurationModel'); + + $this->loadPhrases( + array( + //~ 'global', + 'ui', + 'filter', + //~ 'lehre', + //~ 'person', + 'fehlermonitoring' + ) + ); + + $this->_setAuthUID(); // sets property uid + $this->setControllerId(); // sets the controller id + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * Load initial view. + */ + public function index() + { + $this->load->view("system/issues/issuesKonfiguration.php"); + } + + /** + * Loads all Apps to which Fehler exist. + */ + public function getApps() + { + $this->FehlerModel->addDistinct(); + $this->FehlerModel->addSelect('app'); + $this->FehlerModel->addJoin('system.tbl_fehler_konfigurationstyp', 'app'); + $this->FehlerModel->addOrder('app'); + + $appRes = $this->FehlerModel->load(); + + $this->outputJson($appRes); + } + + /** + * Gets all fehlercodes, optionally by app. + */ + public function getFehlerKonfigurationByApp() + { + $app = $this->input->get('app'); + + // get all Konfiguration types, optionally filtered by app + $this->FehlerkonfigurationstypModel->addSelect('konfigurationstyp_kurzbz, konfigurationsdatentyp, beschreibung'); + $this->FehlerkonfigurationstypModel->addOrder('konfigurationstyp_kurzbz'); + $konfRes = isEmptyString($app) + ? $this->FehlerkonfigurationstypModel->load() + : $this->FehlerkonfigurationstypModel->loadWhere(array('app' => $app)); + + if (isError($konfRes)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerKonfigurationstypenLaden')); + + // get all Fehler, optionally filtered by app + $params = array('fehlercode_extern' => null); + $this->FehlerModel->addSelect('fehlercode, fehler_kurzbz, fehlertyp_kurzbz, fehlertext'); + $this->FehlerModel->addOrder('fehlercode'); + if (isEmptyString($app)) $params['app'] = $app; + $fehlerRes = $this->FehlerModel->loadWhere($params); + + if (isError($fehlerRes)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerFehlerLaden')); + + // return object with retrieved data + $konfObj = new StdClass(); + $konfObj->konfigurationstypen = array(); + $konfObj->fehler = array(); + + if (hasData($konfRes)) $konfObj->konfigurationstypen = getData($konfRes); + if (hasData($fehlerRes)) $konfObj->fehler = getData($fehlerRes); + + $this->outputJsonSuccess($konfObj); + } + + /** + * Saves a Fehler configuration, inserts new configuration or updates existing. + * Checks if datatype of passed configuration is correct. + */ + public function saveFehlerKonfiguration() + { + $result = null; + $konfigurationstyp_kurzbz = $this->input->post('konfigurationstyp_kurzbz'); + $fehlercode = $this->input->post('fehlercode'); + $konfigurationsWert = $this->input->post('konfigurationsWert'); + + // check if all params passed + if (isEmptyString($konfigurationstyp_kurzbz)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'ungueltigerKonfigurationstyp')); + + if (isEmptyString($fehlercode)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'ungueltigerFehlercode')); + + // separate by semicolon if multiple values passed + $konfigurationsWert = explode(';', $konfigurationsWert); + + // check konfigurationswert + + // get the expected data type + $dataType = self::STRING_DATA_TYPE; + $this->FehlerkonfigurationstypModel->addSelect('konfigurationsdatentyp'); + $konfigtypRes = $this->FehlerkonfigurationstypModel->loadWhere(array('konfigurationstyp_kurzbz' => $konfigurationstyp_kurzbz)); + + if (hasData($konfigtypRes)) + { + $konfigurationsdatentyp = getData($konfigtypRes)[0]->konfigurationsdatentyp; + foreach ($konfigurationsWert as $idx => $konfWert) + { + // check if data type correct + $valid = false; + switch ($konfigurationsdatentyp) + { + case self::INTEGER_DATA_TYPE: + $valid = (string)(int)$konfWert == $konfWert; + $konfigurationsWert[$idx] = (int) $konfWert; + break; + case self::FLOAT_DATA_TYPE: + $valid = (string)(float)$konfWert == $konfWert; + $konfigurationsWert[$idx] = (float) $konfWert; + break; + default: + $valid = is_string($konfWert) && preg_match('/^[A-Za-z0-9_]+$/', $konfWert); + } + if (!$valid) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'ungueltigerKonfigurationswert', $konfigurationsdatentyp)); + } + } + + // check if konfiguration already set for the fehlercode + $this->FehlerkonfigurationModel->addSelect('konfiguration'); + $fehlerkonfigurationRes = $this->FehlerkonfigurationModel->loadWhere( + array( + 'konfigurationstyp_kurzbz' => $konfigurationstyp_kurzbz, + 'fehlercode' => $fehlercode + ) + ); + + if (isError($fehlerkonfigurationRes)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerFehlerKonfigurationLaden')); + + // if konfiguration exists, update by add konfiguration values to existing + if (hasData($fehlerkonfigurationRes)) + { + $fehlerkonfiguration = getData($fehlerkonfigurationRes); + + $existingKonf = json_decode($fehlerkonfiguration[0]->konfiguration); + + if (!$existingKonf) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerJsonDekodierung')); + + if (!is_array($existingKonf)) $existingKonf = array($existingKonf); + + $newKonf = json_encode(array_values(array_unique(array_merge($existingKonf, $konfigurationsWert)))); + if (!$newKonf) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerJsonKodierung')); + + $result = $this->FehlerkonfigurationModel->update( + array('konfigurationstyp_kurzbz' => $konfigurationstyp_kurzbz, 'fehlercode' => $fehlercode), + array('konfiguration' => $newKonf, 'updateamum' => 'NOW()', 'updatevon' => $this->_uid) + ); + } + else // if no konfiguration exists, add new konfiguration entry + { + $newKonf = json_encode($konfigurationsWert); + if (!$newKonf) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerJsonKodierung')); + + $result = $this->FehlerkonfigurationModel->insert( + array( + 'konfigurationstyp_kurzbz' => $konfigurationstyp_kurzbz, + 'fehlercode' => $fehlercode, + 'konfiguration' => $newKonf, + 'insertvon' => $this->_uid + ) + ); + } + + // output result (insert or update) + $this->outputJson($result); + } + + /** + * Deletes a Konfiguration. + */ + public function deleteKonfiguration() + { + $konfigurationstyp_kurzbz = $this->input->post('konfigurationstyp_kurzbz'); + $fehlercode = $this->input->post('fehlercode'); + + // check if Konfigurationstyp correctly passed + if (isEmptyString($konfigurationstyp_kurzbz)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'ungueltigerKonfigurationstyp')); + + // check if fehlercode correctly passed + if (isEmptyString($fehlercode)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'ungueltigerFehlercode')); + + $this->outputJson( + $this->FehlerkonfigurationModel->delete( + array('konfigurationstyp_kurzbz' => $konfigurationstyp_kurzbz, 'fehlercode' => $fehlercode) + ) + ); + } + + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) show_error('User authentification failed'); + } +} diff --git a/application/controllers/system/issues/IssuesZustaendigkeiten.php b/application/controllers/system/issues/IssuesZustaendigkeiten.php index fd3e6192a..d7bf9836e 100644 --- a/application/controllers/system/issues/IssuesZustaendigkeiten.php +++ b/application/controllers/system/issues/IssuesZustaendigkeiten.php @@ -26,7 +26,6 @@ class IssuesZustaendigkeiten extends Auth_Controller // Load models $this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel'); $this->load->model('system/Fehler_model', 'FehlerModel'); - $this->load->model('system/Fehler_model', 'FehlerModel'); $this->load->model('system/Fehlerzustaendigkeiten_model', 'FehlerzustaendigkeitenModel'); $this->loadPhrases( @@ -70,7 +69,7 @@ class IssuesZustaendigkeiten extends Auth_Controller { $app = $this->input->get('app'); - //$this->FehlerModel->addSelect('fehlercode, fehler_kurzbz, fehlertext, fehlertyp_kurzbz'); + $this->FehlerModel->addSelect('fehlercode, fehler_kurzbz, fehlertext, fehlertyp_kurzbz, app'); $this->FehlerModel->addOrder('fehlercode'); $fehlerRes = isset($app) ? $this->FehlerModel->loadWhere(array('app' => $app)) : $this->FehlerModel->load(); diff --git a/application/core/PlausiIssueProducer_Controller.php b/application/core/PlausiIssueProducer_Controller.php index 2e066c7e6..0dce7a487 100644 --- a/application/core/PlausiIssueProducer_Controller.php +++ b/application/core/PlausiIssueProducer_Controller.php @@ -14,7 +14,6 @@ abstract class PlausiIssueProducer_Controller extends JOB_Controller // pass extension name if calling from extension $extensionName = isset($this->_extensionName) ? $this->_extensionName : null; - //$app = isset($this->_app) ? $this->_app : null; // load libraries $this->load->library('issues/PlausicheckProducerLib', array('extensionName' => $extensionName, 'app' => $this->_app)); diff --git a/application/libraries/issues/PlausicheckProducerLib.php b/application/libraries/issues/PlausicheckProducerLib.php index c92c38e1f..c32f1f863 100644 --- a/application/libraries/issues/PlausicheckProducerLib.php +++ b/application/libraries/issues/PlausicheckProducerLib.php @@ -26,7 +26,7 @@ class PlausicheckProducerLib $this->_ci =& get_instance(); // get ci instance // load models - $this->_ci->load->model('system/fehlerkonfiguration_model', 'FehlerkonfigurationModel'); + $this->_ci->load->model('system/Fehlerkonfiguration_model', 'FehlerkonfigurationModel'); // get all configuration parameters for the application $fehlerkonfigurationRes = $this->_ci->FehlerkonfigurationModel->getKonfiguration($app); diff --git a/application/models/system/Fehlerkonfiguration_model.php b/application/models/system/Fehlerkonfiguration_model.php index 729709e92..bf8de4cde 100644 --- a/application/models/system/Fehlerkonfiguration_model.php +++ b/application/models/system/Fehlerkonfiguration_model.php @@ -10,10 +10,11 @@ class Fehlerkonfiguration_model extends DB_Model parent::__construct(); $this->dbTable = 'system.tbl_fehler_konfiguration'; $this->pk = array('konfigurationstyp_kurzbz', 'fehlercode'); + $this->hasSequence = false; } /** - * Retrieve all configuration parameters (e.g. excluding certain values), optionally filtered by app. + * Retrieve all set configuration parameters, optionally filtered by app. * @param string $app * @return object success or error */ diff --git a/application/models/system/Fehlerkonfigurationstyp_model.php b/application/models/system/Fehlerkonfigurationstyp_model.php new file mode 100644 index 000000000..dc1c7957f --- /dev/null +++ b/application/models/system/Fehlerkonfigurationstyp_model.php @@ -0,0 +1,47 @@ +dbTable = 'system.tbl_fehler_konfigurationstyp'; + $this->pk = array('konfigurationstyp_kurzbz'); + } + + /** + * Retrieve all set configuration parameters, optionally filtered by app. + * @param string $app + * @return object success or error + */ + public function getKonfiguration($app = null) + { + $fehlerkonfiguration = array(); + + $this->addSelect('fehlercode, konfigurationstyp_kurzbz, konfiguration, fehler_kurzbz'); + $this->addJoin('system.tbl_fehler_konfigurationstyp konftyp', 'konfigurationstyp_kurzbz'); + $this->addJoin('system.tbl_fehler fehler', 'fehlercode'); + $fehlerkonfigurationRes = isset($app) ? $this->loadWhere(array('fehler.app' => $app)) : $this->load(); + + if (isError($fehlerkonfigurationRes)) return $fehlerkonfigurationRes; + + if (hasData($fehlerkonfigurationRes)) + { + $fehlerkonfigurationData = getData($fehlerkonfigurationRes); + foreach ($fehlerkonfigurationData as $fk) + { + $konf = json_decode($fk->konfiguration); + if (is_array($konf)) + { + $fk->konfiguration = $konf; + $fehlerkonfiguration[] = $fk; + } + } + } + + return success($fehlerkonfiguration); + } +} diff --git a/application/views/system/issues/issuesKonfiguration.php b/application/views/system/issues/issuesKonfiguration.php new file mode 100644 index 000000000..8b07157d2 --- /dev/null +++ b/application/views/system/issues/issuesKonfiguration.php @@ -0,0 +1,197 @@ +load->view( + 'templates/FHC-Header', + array( + 'title' => 'Fehler Konfiguration', + 'jquery3' => true, + 'jqueryui1' => true, + 'jquerycheckboxes1' => true, + 'bootstrap3' => true, + 'fontawesome4' => true, + 'sbadmintemplate3' => true, + 'tablesorter2' => true, + 'ajaxlib' => true, + 'filterwidget' => true, + 'navigationwidget' => true, + 'dialoglib' => true, + 'phrases' => array( + 'ui', + 'fehlermonitoring' + ), + 'customCSSs' => array('public/css/issues/issuesKonfiguration.css', 'public/css/sbadmin2/tablesort_bootstrap.css'), + 'customJSs' => array('public/js/issues/issuesKonfiguration.js', 'public/js/bootstrapper.js') + ) +); +?> + + +
+ + widgetlib->widget('NavigationWidget'); ?> + +
+
+
+
+ +
+
+
+
+
+ + + + +
+ + +
+
+
+
+
+ + + + + +
+ + + + + + + +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ load->view('system/issues/issuesKonfigurationData.php'); ?> +
+ + +
+
+ +
+ + +load->view('templates/FHC-Footer'); ?> diff --git a/application/views/system/issues/issuesKonfigurationData.php b/application/views/system/issues/issuesKonfigurationData.php new file mode 100644 index 000000000..fa4e1e49d --- /dev/null +++ b/application/views/system/issues/issuesKonfigurationData.php @@ -0,0 +1,56 @@ + $query, + 'app' => 'core', + 'datasetName' => 'fehlerKonfiguration', + 'filter_id' => $this->input->get('filter_id'), + 'tableUniqueId' => 'issuesKonfiguration', + 'requiredPermissions' => 'admin', + 'datasetRepresentation' => 'tablesorter', + 'additionalColumns' => array('Delete'), + 'columnsAliases' => array( + ucfirst($this->p->t('fehlermonitoring', 'konfigurationstyp')), + ucfirst($this->p->t('fehlermonitoring', 'fehlercode')), + ucfirst($this->p->t('fehlermonitoring', 'fehlerkurzbz')), + ucfirst($this->p->t('fehlermonitoring', 'konfigurationswert')), + 'application', + ucfirst($this->p->t('fehlermonitoring', 'konfigurationsbeschreibung')), + ucfirst($this->p->t('fehlermonitoring', 'konfigurationsdatentyp')), + ucfirst($this->p->t('fehlermonitoring', 'fehlertext')), + ), + 'formatRow' => function($datasetRaw) { + + $datasetRaw->{'Delete'} = + ""; + + if ($datasetRaw->{'konfigurationsbeschreibung'} == null) + { + $datasetRaw->{'konfigurationsbeschreibung'} = '-'; + } + + if ($datasetRaw->{'fehlertext'} == null) + { + $datasetRaw->{'fehlertext'} = '-'; + } + + return $datasetRaw; + } +); + +echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray); diff --git a/public/css/issues/issuesKonfiguration.css b/public/css/issues/issuesKonfiguration.css new file mode 100644 index 000000000..4d582e9e1 --- /dev/null +++ b/public/css/issues/issuesKonfiguration.css @@ -0,0 +1,7 @@ +#konfigSelect, #fehlercodeSelect { + float: left; +} + +#konfigurationstypInfoIcon,#fehlercodeInfoIcon { + cursor: pointer; +} diff --git a/public/js/issues/issuesKonfiguration.js b/public/js/issues/issuesKonfiguration.js new file mode 100644 index 000000000..9e0ebaf4d --- /dev/null +++ b/public/js/issues/issuesKonfiguration.js @@ -0,0 +1,305 @@ +/** + * Javascript file for Issues Zuständigkeiten assignment page + */ + +const FEHLERAPP_DROPDOWN_ID = "fehlerappSelect"; +const FEHLERCODE_DROPDOWN_ID = "fehlercodeSelect"; +const FEHLERKONFIGURATIONSTYP_DROPDOWN_ID = "konfigSelect"; + +var IssuesKonfiguration = { + + fehlerkonfigArr: [], // for saving received fehlerkonfigs + fehlercodesArr: [], // for saving received fehlercodes + + getApps: function() + { + FHC_AjaxClient.ajaxCallGet( + 'system/issues/IssuesKonfiguration/getApps', + null, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) + { + // save loaded apps + let apps = FHC_AjaxClient.getData(data); + + // fill dropdown with apps + IssuesKonfiguration._fillDropdown( + FEHLERAPP_DROPDOWN_ID, + "app", + apps, + null, + false, + "core" + ); + + // Initiate getting of fehlercodes with apps + IssuesKonfiguration.getFehlerKonfigurationByApp($("#"+FEHLERAPP_DROPDOWN_ID).val()); + } + }, + errorCallback: function(jqXHR, textStatus, errorThrown) { + FHC_DialogLib.alertError(textStatus); + } + } + ); + }, + getFehlerKonfigurationByApp: function(app) + { + FHC_AjaxClient.ajaxCallGet( + 'system/issues/IssuesKonfiguration/getFehlerKonfigurationByApp', + { + app: app + }, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) + { + let fehlerKonfigurationData = FHC_AjaxClient.getData(data); + + // save konfig and fehler data for displaying info later + IssuesKonfiguration.fehlerkonfigArr = fehlerKonfigurationData.konfigurationstypen; + IssuesKonfiguration.fehlercodesArr = fehlerKonfigurationData.fehler; + + // display fehlercodes in dropdown + let fehlerCodes = []; + + for (let i = 0; i < fehlerKonfigurationData.fehler.length; i++) + { + let fe = fehlerKonfigurationData.fehler[i]; + + fehlerCodes.push( + { + fehlercode: fe.fehlercode, + fullFehlerBezeichnung: fe.fehlercode + (!fe.fehler_kurzbz ? '' : ' - ' + fe.fehler_kurzbz) + } + ); + } + + IssuesKonfiguration._fillDropdown( + FEHLERCODE_DROPDOWN_ID, + "fehlercode", + fehlerCodes, + "fullFehlerBezeichnung" + ); + + // display fehlerkonfiguration in dropdown + let konfigurationstypen = []; + + for (let i = 0; i < fehlerKonfigurationData.konfigurationstypen.length; i++) + { + let konf = fehlerKonfigurationData.konfigurationstypen[i]; + + konfigurationstypen.push( + { + konfigurationstyp_kurzbz: konf.konfigurationstyp_kurzbz + } + ); + } + + IssuesKonfiguration._fillDropdown( + FEHLERKONFIGURATIONSTYP_DROPDOWN_ID, + "konfigurationstyp_kurzbz", + konfigurationstypen + ); + + // set delete event on buttons + IssuesKonfiguration._setDeleteEvents(); + } + }, + errorCallback: function(jqXHR, textStatus, errorThrown) { + FHC_DialogLib.alertError(textStatus); + } + } + ); + }, + saveFehlerKonfiguration: function(konfigurationstyp_kurzbz, fehlercode, konfigurationsWert) + { + FHC_AjaxClient.ajaxCallPost( + 'system/issues/IssuesKonfiguration/saveFehlerKonfiguration', + { + konfigurationstyp_kurzbz: konfigurationstyp_kurzbz, + fehlercode: fehlercode, + konfigurationsWert: konfigurationsWert + }, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) + { + // show message, reset input fields and reload data after Zuständigkeit added + FHC_DialogLib.alertSuccess(FHC_PhrasesLib.t('fehlermonitoring', 'konfigurationGespeichert')) + IssuesKonfiguration._reloadKonfigurationOverview(); + } + else + { + // show error if no data + let errorMsg = FHC_PhrasesLib.t('fehlermonitoring', 'konfigurationGespeichertFehler'); + if (FHC_AjaxClient.isError(data)) + errorMsg += ": "+FHC_AjaxClient.getError(data); + FHC_DialogLib.alertError(errorMsg); + } + }, + errorCallback: function(jqXHR, textStatus, errorThrown) { + FHC_DialogLib.alertError(textStatus); + } + } + ); + }, + deleteKonfiguration: function(konfigurationstyp_kurzbz, fehlercode) + { + FHC_AjaxClient.ajaxCallPost( + 'system/issues/IssuesKonfiguration/deleteKonfiguration', + { + konfigurationstyp_kurzbz: konfigurationstyp_kurzbz, + fehlercode: fehlercode + }, + { + successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) + { + FHC_DialogLib.alertSuccess(FHC_PhrasesLib.t('fehlermonitoring', 'konfigurationGeloescht')) + // reload dataset to see change + IssuesKonfiguration._reloadKonfigurationOverview(); + } + else + { + FHC_DialogLib.alertError(FHC_PhrasesLib.t('fehlermonitoring', 'konfigurationGeloeschtFehler')); + } + }, + errorCallback: function(jqXHR, textStatus, errorThrown) { + FHC_DialogLib.alertError(textStatus); + } + } + ); + }, + _reloadKonfigurationOverview: function() + { + FHC_FilterWidget.reloadDataset(); + IssuesKonfiguration._setDeleteEvents(); + }, + _setDeleteEvents: function() + { + // set events on delete buttons + $(".deleteBtn").click( + function() + { + IssuesKonfiguration.deleteKonfiguration($(this).attr("data-konfigurationstyp-kurzbz"), $(this).attr("data-fehlercode")); + } + ) + }, + _fillDropdown: function(dropdownId, valueName, data, textName, includeNoSelectionOption, defaultValue) + { + // by default, displayed text in dropdown is the value + if (!textName) + textName = valueName; + + // clear dropdown + $("#"+dropdownId).empty(); + + // optionally include default "no selection" value + if (includeNoSelectionOption === true) + $("#"+dropdownId).append(""); + + // fill dropdown with values + for (let i = 0; i < data.length; i++) + { + let val = data[i]; + + // the value selected by default + let selected = val[valueName] === defaultValue ? " selected" : ""; + + // append option + $("#"+dropdownId).append(""); + } + } +}; + +/** + * When JQuery is up + */ +$(document).ready(function() { + + // initiate cascade of getting data, first apps + IssuesKonfiguration.getApps(); + + // get new fehlercodes each time app is changed + $("#"+FEHLERAPP_DROPDOWN_ID).change( + function() + { + IssuesKonfiguration.getFehlerKonfigurationByApp($(this).val()); + } + ); + + // get new fehlercodes each time app is changed + $("#assignKonfiguration").click( + function() + { + IssuesKonfiguration.saveFehlerKonfiguration( + $("#"+FEHLERKONFIGURATIONSTYP_DROPDOWN_ID).val(), + $("#"+FEHLERCODE_DROPDOWN_ID).val(), + $("#konfigurationsWert").val() + ); + } + ); + + // set events for showing info modals + $("#fehlercodeInfoIcon").click( + function() + { + let fehlercode = $("#"+FEHLERCODE_DROPDOWN_ID).val(); + let fehlercodeData = {}; + + for (let i = 0; i < IssuesKonfiguration.fehlercodesArr.length; i++) + { + let fc = IssuesKonfiguration.fehlercodesArr[i]; + console.log(fc); + + if (fc.fehlercode === fehlercode) + { + fehlercodeData = fc; + break; + } + } + + if (!fehlercodeData) + return; + + $("#fehlerInfoLabel").text(fehlercodeData.fehlercode + " - " + fehlercodeData.fehler_kurzbz); + $("#fehlercodeInfo").text(fehlercodeData.fehlercode); + $("#fehlerkurzbzInfo").text(fehlercodeData.fehler_kurzbz); + $("#fehlertypInfo").text(fehlercodeData.fehlertyp_kurzbz); + $("#fehlertextInfo").text(fehlercodeData.fehlertext); + + $("#fehlerInfo").modal("show"); + } + ); + + $("#konfigurationstypInfoIcon").click( + function() + { + let konfigurationstyp_kurzbz = $("#"+FEHLERKONFIGURATIONSTYP_DROPDOWN_ID).val(); + let konfigurationstypData = {}; + + for (let i = 0; i < IssuesKonfiguration.fehlerkonfigArr.length; i++) + { + let konf = IssuesKonfiguration.fehlerkonfigArr[i]; + console.log(konf); + + if (konf.konfigurationstyp_kurzbz === konfigurationstyp_kurzbz) + { + konfigurationstypData = konf; + break; + } + } + + if (!konfigurationstypData) + return; + + $("#konfigurationstypInfo").text(konfigurationstypData.konfigurationstyp_kurzbz); + $("#konfigurationsbeschreibungInfo").text(konfigurationstypData.beschreibung); + $("#konfigurationsdatentypInfo").text(konfigurationstypData.konfigurationsdatentyp); + + $("#konfigurationsInfo").modal("show"); + } + ); + +}); diff --git a/public/js/issues/issuesZustaendigkeiten.js b/public/js/issues/issuesZustaendigkeiten.js index 605868295..2c56fd2da 100644 --- a/public/js/issues/issuesZustaendigkeiten.js +++ b/public/js/issues/issuesZustaendigkeiten.js @@ -289,7 +289,7 @@ var IssuesZustaendigkeiten = { let val = data[i]; // the value selected by default - let selected = val === defaultValue ? " selected" : ""; + let selected = val[valueName] === defaultValue ? " selected" : ""; // append option $("#"+dropdownId).append(""); diff --git a/system/filtersupdate.php b/system/filtersupdate.php index 126ed7116..3ff74e3ae 100644 --- a/system/filtersupdate.php +++ b/system/filtersupdate.php @@ -1211,6 +1211,28 @@ $filters = array( ', 'oe_kurzbz' => null ), + array( + 'app' => 'core', + 'dataset_name' => 'fehlerKonfiguration', + 'filter_kurzbz' => 'fehlerKonfiguration', + 'description' => '{Fehler Konfiguration}', + 'sort' => 1, + 'default_filter' => true, + 'filter' => ' + { + "name": "Fehler Konfiguration", + "columns": [ + {"name": "konfigurationstyp_kurzbz"}, + {"name": "fehlercode"}, + {"name": "fehler_kurzbz"}, + {"name": "konfiguration"}, + {"name": "app"} + ], + "filters": [] + } + ', + 'oe_kurzbz' => null + ), array( 'app' => 'core', 'dataset_name' => 'gruppenmanagement',