issues: added issue controller for displaying issues, added issuechecker controller and component

This commit is contained in:
Alexei Karpenko
2025-12-15 17:20:56 +01:00
parent 733a6a8c15
commit 9c37215e62
6 changed files with 356 additions and 2 deletions
@@ -0,0 +1,170 @@
<?php
defined('BASEPATH') || exit('No direct script access allowed');
class IssueChecker extends FHCAPI_Controller
{
const DEFAULT_PERMISSION = 'system/issues_verwalten:r';
protected $person_id;
protected $_extensionName = null;
protected $_codeLibMappings = [];
protected $_codeProducerLibMappings = [];
protected $_app = null;
protected $errors = [];
protected $infos = [];
public function __construct($permissions)
{
$default_permissions = [
'checkPerson' => 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);
}
}
}
@@ -0,0 +1,100 @@
<?php
defined('BASEPATH') || exit('No direct script access allowed');
class Issues extends FHCAPI_Controller
{
const DEFAULT_PERMISSION = 'system/issues_verwalten:r';
// code igniter
protected $CI;
public function __construct() {
parent::__construct(
array(
'getOpenIssuesByProperties' => 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 = <<<EOSQL
SELECT
person_id, uid, vorname, nachname, count(*) AS openissues ,
(select count(*) anz_aktiv
from hr.tbl_dienstverhaeltnis dv
where dv.mitarbeiter_uid=uid and dv.von<=now() and
(dv.bis is null OR dv.bis>=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());
}
}
}
@@ -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
+1 -1
View File
@@ -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 }
};
}
@@ -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: `
<div class="px-2">
<h4 class="mb-1">Issues<a class="refresh-issues" title="erneut prüfen" href="javascript:void(0);" @click="checkPerson"><i class="fas fa-sync"></i></a></h4>
<h6 v-if="!isFetching" class="text-muted">{{ openissuescount }}</h6>
<h6 v-else class="mb-2"><p-skeleton v-if="isFetching" style="width:45%"></p-skeleton></h6>
</div>
`
}
+19
View File
@@ -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'
)
)
);