diff --git a/application/controllers/api/frontend/v1/issues/IssueChecker.php b/application/controllers/api/frontend/v1/issues/IssueChecker.php new file mode 100644 index 000000000..4ed957dba --- /dev/null +++ b/application/controllers/api/frontend/v1/issues/IssueChecker.php @@ -0,0 +1,170 @@ + self::DEFAULT_PERMISSION, + 'countPersonOpenIssues' => self::DEFAULT_PERMISSION + ]; + + if(!is_array($permissions)) + { + $this->terminateWithError("Issue Checker: permissions must be an array"); + } + + $merged_permissions = array_merge($default_permissions, $permissions); + + parent::__construct($merged_permissions); + + $this->load->model('system/Issue_model', 'IssueModel'); + $this->load->model('person/Person_model', 'PersonModel'); + } + + public function checkPerson() + { + $person_id = $this->input->post('person_id', true); + + if (!is_numeric($person_id)) $this->terminateWithError($this->p->t('ui', 'error_invalidId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL); + + $this->person_id = intval($person_id); + + $persRes = $this->PersonModel->load($this->person_id); + if (!hasData($persRes)) $this->terminateWithError('Person with id ' . $this->person_id . ' not found.', self::ERROR_TYPE_GENERAL); + + $allCodeLibMappings = array_merge($this->_codeLibMappings, $this->_codeProducerLibMappings); + + $this->load->library( + 'issues/PlausicheckProducerLib', + array( + 'extensionName' => $this->_extensionName, + 'codeLibMappings' => $allCodeLibMappings + ), + 'PlausicheckProducerLib' + ); + + $this->load->library( + 'issues/PlausicheckResolverLib', + array( + 'extensionName' => $this->_extensionName, + 'codeLibMappings' => $this->_codeLibMappings, + 'codeProducerLibMappings' => $this->_codeProducerLibMappings + ), + 'PlausicheckResolverLib' + ); + + $this->produceIssues(); + $this->resolveIssues(); + $this->produceIssues(); + + $openIssueCountRes = $this->countOpenIssues(array_keys($allCodeLibMappings)); + if (isError($openIssueCountRes)) $this->terminateWithError(getError($openIssueCountRes), self::ERROR_TYPE_GENERAL); + + $data = array( + 'person_id' => $this->person_id, + 'openissues' => hasData($openIssueCountRes) ? getData($openIssueCountRes) : 0 + ); + + $this->addMeta('errors', $this->errors); + $this->addMeta('infos', $this->infos); + + $this->terminateWithSuccess($data); + } + + public function countPersonOpenIssues() + { + $person_id = $this->input->get('person_id', true); + + if (!is_numeric($person_id)) $this->terminateWithError($this->p->t('ui', 'error_invalidId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL); + + $this->person_id = intval($person_id); + + $persRes = $this->PersonModel->load($this->person_id); + + if (!hasData($persRes)) $this->terminateWithError('Person with id ' . $this->person_id . ' not found.', self::ERROR_TYPE_GENERAL); + + $openIssueCountRes = $this->countOpenIssues(array_keys(array_merge($this->_codeLibMappings, $this->_codeProducerLibMappings))); + if (isError($openIssueCountRes)) $this->terminateWithError(getError($openIssueCountRes), self::ERROR_TYPE_GENERAL); + + $data = array( + 'person_id' => $this->person_id, + 'openissues' => hasData($openIssueCountRes) ? getData($openIssueCountRes) : 0 + ); + + $this->addMeta('errors', $this->errors); + $this->addMeta('infos', $this->infos); + + $this->terminateWithSuccess($data); + } + + protected function countOpenIssues($fehlercodes) + { + if (isEmptyArray($fehlercodes)) return success([]); + + // load open issues with given errorcodes + $openIssuesRes = $this->IssueModel->getOpenIssues( + $fehlercodes, + $this->person_id + ); + + // log error if occured + if (isError($openIssuesRes)) return $openIssuesRes; + + $issues = hasData($openIssuesRes) ? getData($openIssuesRes) : []; + $issuescount = is_array($issues) || $issues instanceof Countable ? count($issues) : 0; + + return success($issuescount); + } + + protected function produceIssues() + { + if (isEmptyArray($this->_codeLibMappings) && isEmptyArray($this->_codeProducerLibMappings)) return success([]); + + $allCodeLibMappings = array_merge($this->_codeLibMappings, $this->_codeProducerLibMappings); + + $result = $this->PlausicheckProducerLib->producePlausicheckIssues( + array('person_id' => $this->person_id) + ); + + // log if error, or log info if inserted new issue + if (isset($result->errors)) + $this->errors = array_merge($this->errors, $result->errors); + if (isset($result->infos)) + $this->infos = array_merge($this->infos, $result->infos); + } + + protected function resolveIssues() + { + // load open issues with given errorcodes + $openIssuesRes = $this->IssueModel->getOpenIssues( + array_keys(array_merge($this->_codeLibMappings, $this->_codeProducerLibMappings)), + $this->person_id + ); + + if (hasData($openIssuesRes)) + { + $openIssues = getData($openIssuesRes); + + $result = $this->PlausicheckResolverLib->resolvePlausicheckIssues($openIssues); + + // log if error, or log info if inserted new issue + if (isset($result->errors)) + $this->errors = array_merge($this->errors, $result->errors); + if (isset($result->infos)) + $this->infos = array_merge($this->infos, $result->infos); + } + } +} diff --git a/application/controllers/api/frontend/v1/issues/Issues.php b/application/controllers/api/frontend/v1/issues/Issues.php new file mode 100644 index 000000000..6ae268a53 --- /dev/null +++ b/application/controllers/api/frontend/v1/issues/Issues.php @@ -0,0 +1,100 @@ + Self::DEFAULT_PERMISSION + ) + ); + + // Loads authentication library and starts authenticationfetc + $this->load->library('AuthLib'); + + $this->load->model('extensions/FHC-Core-Personalverwaltung/Api_model','ApiModel'); + $this->load->model('person/Person_model','PersonModel'); + $this->load->model('system/Fehler_model','FehlerModel'); + $this->load->model('system/Issue_model', 'IssueModel'); + $this->load->model('person/Benutzer_model', 'BenutzerModel'); + + // get CI for transaction management + $this->CI = &get_instance(); + } + + public function getOpenIssuesByProperties() + { + $person_id = $this->input->get('person_id', true); + $oe_kurzbz = $this->input->get('oe_kurzbz', true); + $fehlertyp_kurzbz = $this->input->get('fehlertyp_kurzbz', true); + $apps = $this->input->get('apps', true); + $behebung_parameter = $this->input->get('behebung_parameter', true); + + if (isset($person_id) && !is_numeric($person_id)) + $this->terminateWithError('person id is not numeric!'); + + if (isset($behebung_parameter) && !is_array($behebung_parameter)) + $this->terminateWithError('Behebung parameter invalid'); + + $issueRes = $this->IssueModel->getOpenIssuesByProperties($person_id, $oe_kurzbz, $fehlertyp_kurzbz, $apps, $behebung_parameter); + + if (isError($issueRes)) + { + $this->terminateWithError(getError($issueRes)); + } + + $this->terminateWithSuccess(hasData($issueRes) ? getData($issueRes) : []); + } + + public function PersonenMitOffenenIssues() + { + + $sql = <<=now()) + ) aktiv +FROM + system.tbl_issue +JOIN + system.tbl_fehler USING (fehlercode) +JOIN + public.tbl_person USING (person_id) +JOIN + public.tbl_benutzer USING (person_id) +JOIN + public.tbl_mitarbeiter ON uid = mitarbeiter_uid +WHERE + app = 'personalverwaltung' AND verarbeitetamum IS NULL +GROUP BY + person_id, uid, vorname, nachname +HAVING + count(*) > 0 +ORDER BY + count(*) DESC; + +EOSQL; + + $personenmitissues = $this->IssueModel->execReadOnlyQuery($sql); + if( hasData($personenmitissues) ) + { + $this->terminateWithSuccess(getData($personenmitissues)); + } + else + { + $this->terminateWithSuccess(array()); + } + } +} \ No newline at end of file diff --git a/application/controllers/jobs/PlausiIssueProducer.php b/application/controllers/jobs/PlausiIssueProducer.php index 356895a76..77d4518ff 100644 --- a/application/controllers/jobs/PlausiIssueProducer.php +++ b/application/controllers/jobs/PlausiIssueProducer.php @@ -18,7 +18,7 @@ class PlausiIssueProducer extends PlausiIssueProducer_Controller $this->load->model('organisation/studiensemester_model', 'StudiensemesterModel'); // get current Studiensemester - $studiensemesterRes = $this->StudiensemesterModel->getAktOrNextSemester(); + $studiensemesterRes = $this->StudiensemesterModel->getAktOrNextSemester(62); if (hasData($studiensemesterRes)) $this->_currentStudiensemester = getData($studiensemesterRes)[0]->studiensemester_kurzbz; // set fehler which can be produced by the job diff --git a/public/js/api/factory/issues.js b/public/js/api/factory/issues.js index 376845897..1279cc232 100644 --- a/public/js/api/factory/issues.js +++ b/public/js/api/factory/issues.js @@ -4,7 +4,7 @@ export default { { return { method: 'get', - url: '/api/frontend/v1/Issues/getOpenIssuesByProperties', + url: '/api/frontend/v1/issues/getOpenIssuesByProperties', params: { person_id, oe_kurzbz, fehlertyp_kurzbz, apps, behebung_parameter } }; } diff --git a/public/js/components/Issues/IssueChecker.js b/public/js/components/Issues/IssueChecker.js new file mode 100644 index 000000000..f698faa64 --- /dev/null +++ b/public/js/components/Issues/IssueChecker.js @@ -0,0 +1,65 @@ +export default { + name: 'IssueChecker', + //emits: ['issuesLoaded'], + components: { + "p-skeleton": primevue.skeleton, + }, + props: { + person_id: Number, + //oe_kurzbz: String, + apps: [String, Array], + endpoint: { + type: Object, + required: true + } + }, + data() { + return { + title: "IssueChecker", + currentDate: null, + isFetching: false, + openissuescount: null + } + }, + computed: { + }, + watch: { + }, + mounted() { + this.getOpenIssuesCount(); + }, + methods: { + + getOpenIssuesCount() { + this.isFetching = true; + this.$api.call( + this.endpoint.countPersonOpenIssues(this.person_id) + ) + .then(result => { + //this.$emit('issuesLoaded', this.issues); + this.openissuescount = result.data.openissues; + this.isFetching = false; + }) + .catch(this.$fhcAlert.handleSystemError); + }, + checkPerson() { + this.isFetching = true; + this.$api.call( + this.endpoint.checkPerson(this.person_id) + ) + .then(result => { + //this.$emit('issuesLoaded', this.issues); + this.openissuescount = result.data.openissues; + this.isFetching = false; + }) + .catch(this.$fhcAlert.handleSystemError); + }, + }, + template: ` +
+

Issues

+
{{ openissuescount }}
+
+
+ ` +} diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index e1568b97e..2b8bc28b6 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -52310,6 +52310,25 @@ I have been informed that I am under no obligation to consent to the transmissio ) ), // ### Personen zusammenlegen Phrasen END + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'error_invalidId', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Id {id} ungültig', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Invalid Id {id}', + 'description' => '', + 'insertvon' => 'system' + ) + ) );