mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Issues: added possibility to display issues only when user is hauptzustaendig
This commit is contained in:
@@ -23,7 +23,7 @@ class IssueChecker extends FHCAPI_Controller
|
||||
|
||||
if(!is_array($permissions))
|
||||
{
|
||||
$this->terminateWithError("Issue Checker: permissions must be an array");
|
||||
$this->terminateWithError("Issue Checker: permissions must be an array");
|
||||
}
|
||||
|
||||
$merged_permissions = array_merge($default_permissions, $permissions);
|
||||
@@ -37,10 +37,12 @@ class IssueChecker extends FHCAPI_Controller
|
||||
public function checkPerson()
|
||||
{
|
||||
$person_id = $this->input->post('person_id', true);
|
||||
$hauptzustaendig = filter_var($this->input->post('hauptzustaendig', true), FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
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);
|
||||
$this->hauptzustaendig = $hauptzustaendig;
|
||||
|
||||
$persRes = $this->PersonModel->load($this->person_id);
|
||||
if (!hasData($persRes)) $this->terminateWithError('Person with id ' . $this->person_id . ' not found.', self::ERROR_TYPE_GENERAL);
|
||||
@@ -66,11 +68,11 @@ class IssueChecker extends FHCAPI_Controller
|
||||
'PlausicheckResolverLib'
|
||||
);
|
||||
|
||||
$this->produceIssues();
|
||||
$this->resolveIssues();
|
||||
$this->produceIssues();
|
||||
$this->_produceIssues();
|
||||
$this->_resolveIssues();
|
||||
$this->_produceIssues();
|
||||
|
||||
$openIssueCountRes = $this->countOpenIssues(array_keys($allCodeLibMappings));
|
||||
$openIssueCountRes = $this->_countOpenIssues(array_keys($allCodeLibMappings));
|
||||
if (isError($openIssueCountRes)) $this->terminateWithError(getError($openIssueCountRes), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$data = array(
|
||||
@@ -87,16 +89,18 @@ class IssueChecker extends FHCAPI_Controller
|
||||
public function countPersonOpenIssues()
|
||||
{
|
||||
$person_id = $this->input->get('person_id', true);
|
||||
$hauptzustaendig = filter_var($this->input->get('hauptzustaendig', true), FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
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);
|
||||
$this->hauptzustaendig = $hauptzustaendig;
|
||||
|
||||
$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)));
|
||||
$openIssueCountRes = $this->_countOpenIssues(array_keys(array_merge($this->_codeLibMappings, $this->_codeProducerLibMappings)));
|
||||
if (isError($openIssueCountRes)) $this->terminateWithError(getError($openIssueCountRes), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$data = array(
|
||||
@@ -110,14 +114,17 @@ class IssueChecker extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
protected function countOpenIssues($fehlercodes)
|
||||
protected function _countOpenIssues($fehlercodes)
|
||||
{
|
||||
if (isEmptyArray($fehlercodes)) return success([]);
|
||||
|
||||
// load open issues with given errorcodes
|
||||
$openIssuesRes = $this->IssueModel->getOpenIssues(
|
||||
$fehlercodes,
|
||||
$this->person_id
|
||||
$this->person_id,
|
||||
$oe_kurzbz = null,
|
||||
$fehlercode_extern = null,
|
||||
$this->hauptzustaendig
|
||||
);
|
||||
|
||||
// log error if occured
|
||||
@@ -129,7 +136,7 @@ class IssueChecker extends FHCAPI_Controller
|
||||
return success($issuescount);
|
||||
}
|
||||
|
||||
protected function produceIssues()
|
||||
protected function _produceIssues()
|
||||
{
|
||||
if (isEmptyArray($this->_codeLibMappings) && isEmptyArray($this->_codeProducerLibMappings)) return success([]);
|
||||
|
||||
@@ -146,7 +153,7 @@ class IssueChecker extends FHCAPI_Controller
|
||||
$this->infos = array_merge($this->infos, $result->infos);
|
||||
}
|
||||
|
||||
protected function resolveIssues()
|
||||
protected function _resolveIssues()
|
||||
{
|
||||
// load open issues with given errorcodes
|
||||
$openIssuesRes = $this->IssueModel->getOpenIssues(
|
||||
|
||||
@@ -37,6 +37,7 @@ class Issues extends FHCAPI_Controller
|
||||
$fehlertyp_kurzbz = $this->input->get('fehlertyp_kurzbz', true);
|
||||
$apps = $this->input->get('apps', true);
|
||||
$behebung_parameter = $this->input->get('behebung_parameter', true);
|
||||
$hauptzustaendig = filter_var($this->input->get('hauptzustaendig', true), FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
if (isset($person_id) && !is_numeric($person_id))
|
||||
$this->terminateWithError('person id is not numeric!');
|
||||
@@ -44,7 +45,16 @@ class Issues extends FHCAPI_Controller
|
||||
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);
|
||||
$this->addMeta("vorher", $hauptzustaendig);
|
||||
|
||||
$issueRes = $this->IssueModel->getOpenIssuesByProperties(
|
||||
$person_id,
|
||||
$oe_kurzbz,
|
||||
$fehlertyp_kurzbz,
|
||||
$apps,
|
||||
$behebung_parameter,
|
||||
$hauptzustaendig
|
||||
);
|
||||
|
||||
if (isError($issueRes))
|
||||
{
|
||||
|
||||
@@ -12,6 +12,67 @@ class Fehlerzustaendigkeiten_model extends DB_Model
|
||||
$this->pk = 'fehlerzustaendigkeiten_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Fehler for which user is hauptzuständig (is in charge).
|
||||
* @return object success or error
|
||||
*/
|
||||
public function getFehlerForUserHauptzustaendig()
|
||||
{
|
||||
$params = [getAuthPersonId()];
|
||||
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
|
||||
// get oes of uid for which there is a current funktion
|
||||
$all_funktionen_oe_kurzbz = array();
|
||||
$benutzerfunktionRes = $this->BenutzerfunktionModel->getBenutzerFunktionByUid(getAuthUID(), null, date('Y-m-d'), date('Y-m-d'));
|
||||
|
||||
if (isError($benutzerfunktionRes)) return $benutzerfunktionRes;
|
||||
|
||||
if (hasData($benutzerfunktionRes))
|
||||
{
|
||||
foreach (getData($benutzerfunktionRes) as $benutzerfunktion)
|
||||
{
|
||||
$all_funktionen_oe_kurzbz[$benutzerfunktion->oe_kurzbz][] = $benutzerfunktion->funktion_kurzbz;
|
||||
}
|
||||
}
|
||||
|
||||
$query = "WITH zustaendigkeiten AS (
|
||||
SELECT fehlercode,
|
||||
CASE
|
||||
WHEN zst.person_id = ?";
|
||||
|
||||
if (!isEmptyArray($all_funktionen_oe_kurzbz))
|
||||
{
|
||||
$params[] = array_keys($all_funktionen_oe_kurzbz);
|
||||
$query .= " OR (zst.oe_kurzbz IN ? AND zst.funktion_kurzbz IS NULL) /* if oe is specified in fehler_zustaendigkeiten */";
|
||||
|
||||
// check for each oe for each function if zustaendig
|
||||
foreach ($all_funktionen_oe_kurzbz as $oe_kurzbz => $funktionen_kurzbz)
|
||||
{
|
||||
foreach ($funktionen_kurzbz as $funktion_kurzbz)
|
||||
{
|
||||
$query .= " OR (zst.oe_kurzbz = '$oe_kurzbz' AND zst.funktion_kurzbz = '$funktion_kurzbz')";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query .= " THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS \"zustaendig\"
|
||||
FROM system.tbl_fehler_zustaendigkeiten zst
|
||||
)
|
||||
SELECT
|
||||
fehler.fehler_kurzbz, fehler.fehlercode
|
||||
FROM
|
||||
system.tbl_fehler fehler
|
||||
LEFT JOIN zustaendigkeiten USING(fehlercode)
|
||||
WHERE
|
||||
zustaendigkeiten.fehlercode IS NULL
|
||||
OR zustaendigkeiten.zustaendig = TRUE";
|
||||
|
||||
return $this->execReadOnlyQuery($query, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets active Mitarbeiter not assigned to a Fehler.
|
||||
* @param $fehlercode
|
||||
|
||||
@@ -20,7 +20,7 @@ class Issue_model extends DB_Model
|
||||
* @param string $fehlercode_extern
|
||||
* @return object success with issues or error
|
||||
*/
|
||||
public function getOpenIssues($fehlercodes, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null)
|
||||
public function getOpenIssues($fehlercodes, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null, $hauptzustaendig = false)
|
||||
{
|
||||
// issue exists for a fehlercode (or fehlercode_extern), person_id, oe_kurzbz, if not verarbeitet yet
|
||||
return $this->_getIssues(
|
||||
@@ -31,7 +31,8 @@ class Issue_model extends DB_Model
|
||||
$ist_verarbeitet = false,
|
||||
$behebung_parameter = null,
|
||||
$fehlercodes,
|
||||
$fehlercode_extern
|
||||
$fehlercode_extern,
|
||||
$hauptzustaendig
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,8 +44,14 @@ class Issue_model extends DB_Model
|
||||
* @param string $fehlercode_extern if provided, only issues with this external fehlercode are counted (for identifying issues from external systems).
|
||||
* @return Object success with number of issues or error
|
||||
*/
|
||||
public function getOpenIssueCount($fehlercode, $person_id = null, $oe_kurzbz = null, $fehlercode_extern = null, $behebung_parameter = null)
|
||||
{
|
||||
public function getOpenIssueCount(
|
||||
$fehlercode,
|
||||
$person_id = null,
|
||||
$oe_kurzbz = null,
|
||||
$fehlercode_extern = null,
|
||||
$behebung_parameter = null,
|
||||
$hauptzustaendig = false
|
||||
) {
|
||||
$params = array($fehlercode);
|
||||
// issue exists for a fehlercode (or fehlercode_extern), person_id, oe_kurzbz, if not verarbeitet yet
|
||||
$qry = 'SELECT count(*) as anzahl_open_issues FROM system.tbl_issue
|
||||
@@ -100,9 +107,20 @@ class Issue_model extends DB_Model
|
||||
$oe_kurzbz = null,
|
||||
$fehlertyp_kurzbz = null,
|
||||
$apps = null,
|
||||
$behebung_parameter = null
|
||||
$behebung_parameter = null,
|
||||
$hauptzustaendig = false
|
||||
) {
|
||||
return $this->_getIssues($person_id, $oe_kurzbz, $fehlertyp_kurzbz, $apps, $ist_verarbeitet = false, $behebung_parameter);
|
||||
return $this->_getIssues(
|
||||
$person_id,
|
||||
$oe_kurzbz,
|
||||
$fehlertyp_kurzbz,
|
||||
$apps,
|
||||
$ist_verarbeitet = false,
|
||||
$behebung_parameter,
|
||||
$fehlercodes = null,
|
||||
$fehlercode_extern = null,
|
||||
$hauptzustaendig
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +143,8 @@ class Issue_model extends DB_Model
|
||||
$ist_verarbeitet = null,
|
||||
$behebung_parameter = null,
|
||||
$fehlercodes = null,
|
||||
$fehlercode_extern = null
|
||||
$fehlercode_extern = null,
|
||||
$hauptzustaendig = false
|
||||
) {
|
||||
$params = array();
|
||||
|
||||
@@ -186,6 +205,23 @@ class Issue_model extends DB_Model
|
||||
}
|
||||
}
|
||||
|
||||
// retrieving only fehler for which user is hauptzuständig
|
||||
if ($hauptzustaendig === true)
|
||||
{
|
||||
$this->load->model('system/Fehlerzustaendigkeiten_model', 'FehlerzustaendigkeitenModel');
|
||||
|
||||
$result = $this->FehlerzustaendigkeitenModel->getFehlerForUserHauptzustaendig();
|
||||
|
||||
|
||||
if (isError($result)) return $result;
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$fehlercodesZust = array_column(getData($result), 'fehlercode');
|
||||
$fehlercodes = isEmptyArray($fehlercodes) ? $fehlercodesZust : array_intersect($fehlercodes, $fehlercodesZust);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isEmptyArray($fehlercodes))
|
||||
{
|
||||
$qry .= ' AND fehlercode IN ?';
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
export default {
|
||||
|
||||
getOpenIssuesByProperties(person_id, oe_kurzbz, fehlertyp_kurzbz, apps, behebung_parameter)
|
||||
getOpenIssuesByProperties(person_id, oe_kurzbz, fehlertyp_kurzbz, apps, behebung_parameter, hauptzustaendig)
|
||||
{
|
||||
return {
|
||||
method: 'get',
|
||||
url: '/api/frontend/v1/issues/Issues/getOpenIssuesByProperties',
|
||||
params: { person_id, oe_kurzbz, fehlertyp_kurzbz, apps, behebung_parameter }
|
||||
params: { person_id, oe_kurzbz, fehlertyp_kurzbz, apps, behebung_parameter, hauptzustaendig }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ export default {
|
||||
person_id: Number,
|
||||
//oe_kurzbz: String,
|
||||
apps: [String, Array],
|
||||
hauptzustaendig: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
endpoint: {
|
||||
type: Object,
|
||||
required: true
|
||||
@@ -26,14 +30,14 @@ export default {
|
||||
watch: {
|
||||
},
|
||||
mounted() {
|
||||
this.getOpenIssuesCount();
|
||||
this.countPersonOpenIssues();
|
||||
},
|
||||
methods: {
|
||||
|
||||
getOpenIssuesCount() {
|
||||
countPersonOpenIssues() {
|
||||
this.isFetching = true;
|
||||
this.$api.call(
|
||||
this.endpoint.countPersonOpenIssues(this.person_id)
|
||||
this.endpoint.countPersonOpenIssues(this.person_id, this.hauptzustaendig)
|
||||
)
|
||||
.then(result => {
|
||||
//this.$emit('issuesLoaded', this.issues);
|
||||
@@ -45,7 +49,7 @@ export default {
|
||||
checkPerson() {
|
||||
this.isFetching = true;
|
||||
this.$api.call(
|
||||
this.endpoint.checkPerson(this.person_id)
|
||||
this.endpoint.checkPerson(this.person_id, this.hauptzustaendig)
|
||||
)
|
||||
.then(result => {
|
||||
//this.$emit('issuesLoaded', this.issues);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ApiIssues from '../../api/factory/issues.js';
|
||||
import ApiIssueList from '../../api/factory/issueList.js';
|
||||
|
||||
export default {
|
||||
name: 'IssueList',
|
||||
@@ -11,10 +11,14 @@ export default {
|
||||
fehlertyp_kurzbz: String,
|
||||
apps: [String, Array],
|
||||
behebung_parameter: Array,
|
||||
hauptzustaendig: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
date: null,
|
||||
endpoint: {
|
||||
type: Object,
|
||||
default: ApiIssues
|
||||
default: ApiIssueList
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -45,7 +49,14 @@ export default {
|
||||
fetchIssues() {
|
||||
this.isFetching = true;
|
||||
this.$api.call(
|
||||
this.endpoint.getOpenIssuesByProperties(this.person_id, this.oe_kurzbz, this.fehlertyp_kurzbz, this.apps, this.behebung_parameter)
|
||||
this.endpoint.getOpenIssuesByProperties(
|
||||
this.person_id,
|
||||
this.oe_kurzbz,
|
||||
this.fehlertyp_kurzbz,
|
||||
this.apps,
|
||||
this.behebung_parameter,
|
||||
this.hauptzustaendig
|
||||
)
|
||||
)
|
||||
.then(result => {
|
||||
this.issues = result.data;
|
||||
|
||||
Reference in New Issue
Block a user