mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-16 19:49:28 +00:00
Issue system: adapted to work with multiple apps per fehler
This commit is contained in:
@@ -88,9 +88,11 @@ class IssuesKonfiguration extends Auth_Controller
|
||||
|
||||
// get all Fehler, optionally filtered by app
|
||||
$params = array('fehlercode_extern' => null);
|
||||
$this->FehlerModel->addDistinct();
|
||||
$this->FehlerModel->addSelect('fehlercode, fehler_kurzbz, fehlertyp_kurzbz, fehlertext');
|
||||
$this->FehlerModel->addJoin('system.tbl_fehler_app', 'fehlercode');
|
||||
$this->FehlerModel->addOrder('fehlercode');
|
||||
if (!isEmptyString($app)) $params['app'] = $app;
|
||||
if (!isEmptyString($app)) $params['tbl_fehler_app.app'] = $app;
|
||||
$fehlerRes = $this->FehlerModel->loadWhere($params);
|
||||
|
||||
if (isError($fehlerRes)) $this->terminateWithJsonError($this->p->t('fehlermonitoring', 'fehlerFehlerLaden'));
|
||||
|
||||
@@ -69,10 +69,7 @@ class IssuesZustaendigkeiten extends Auth_Controller
|
||||
{
|
||||
$app = $this->input->get('app');
|
||||
|
||||
$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();
|
||||
$fehlerRes = $this->FehlerModel->getByApps($app);
|
||||
|
||||
$this->outputJson($fehlerRes);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class FehlerUpdateLib
|
||||
];
|
||||
|
||||
private $_ci; // Code igniter instance
|
||||
private $_updateHistory = [];
|
||||
|
||||
/**
|
||||
* Loads parser library
|
||||
@@ -74,9 +75,7 @@ class FehlerUpdateLib
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param
|
||||
* @return object success or error
|
||||
* Install all possible fehler, from core and extensions
|
||||
*/
|
||||
public function installAll()
|
||||
{
|
||||
@@ -121,7 +120,6 @@ class FehlerUpdateLib
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
@@ -190,22 +188,29 @@ class FehlerUpdateLib
|
||||
*/
|
||||
private function _updateFehler($fehler)
|
||||
{
|
||||
$fehlerReferences = $fehler['references'];
|
||||
$fehler = $fehler['fehler'];
|
||||
|
||||
// Checks if the fehler already exists in the database
|
||||
$this->_ci->FehlerModel->db->where(self::FEHLERCODE.' = ', $fehler[self::FEHLERCODE]);
|
||||
if ($fehler[self::FEHLER_KURZBZ] != null) $this->_ci->FehlerModel->db->or_where(self::FEHLER_KURZBZ.' = ', $fehler[self::FEHLER_KURZBZ]);
|
||||
if (isset($fehler[self::FEHLER_KURZBZ]) && !isEmptyString($fehler[self::FEHLER_KURZBZ]))
|
||||
$this->_ci->FehlerModel->db->or_where(self::FEHLER_KURZBZ.' = ', $fehler[self::FEHLER_KURZBZ]);
|
||||
$fehlerResult = $this->_ci->FehlerModel->load();
|
||||
|
||||
// If an error occurred then return the error itself
|
||||
if (isError($fehlerResult)) return $fehlerResult;
|
||||
|
||||
$updateRes = null;
|
||||
|
||||
// if fehler has been found
|
||||
if (hasData($fehlerResult))
|
||||
{
|
||||
$foundFehler = getData($fehlerResult)[0];
|
||||
|
||||
// check if fehlercode - fehler kurzbz combination is correct
|
||||
if ($foundFehler->{self::FEHLERCODE} != $fehler[self::FEHLERCODE] || $foundFehler->{self::FEHLER_KURZBZ} != $fehler[self::FEHLER_KURZBZ])
|
||||
{
|
||||
if ($foundFehler->{self::FEHLERCODE} != $fehler[self::FEHLERCODE]
|
||||
|| $foundFehler->{self::FEHLER_KURZBZ} != ($fehler[self::FEHLER_KURZBZ] ?? null)
|
||||
) {
|
||||
return error("Wrong fehlercode - fehler kurzbz combination: ".$fehler[self::FEHLERCODE].", ".$fehler[self::FEHLER_KURZBZ]);
|
||||
}
|
||||
|
||||
@@ -224,6 +229,13 @@ class FehlerUpdateLib
|
||||
if (isset($attributeInfo['updateable']) && $attributeInfo['updateable'] && $foundFehler->{$attributeName} != $fehler[$attributeName])
|
||||
{
|
||||
$updateArr[$attributeName] = $fehler[$attributeName];
|
||||
|
||||
if (isset($this->_updateHistory[$foundFehler->{self::FEHLERCODE}][$attributeName])
|
||||
&& $this->_updateHistory[$foundFehler->{self::FEHLERCODE}][$attributeName] != $fehler[$attributeName]
|
||||
) {
|
||||
return error("Conflicting update values for attribute ".$attributeName.", fehler ".$foundFehler->{self::FEHLERCODE});
|
||||
}
|
||||
$this->_updateHistory[$foundFehler->{self::FEHLERCODE}][$attributeName] = $fehler[$attributeName];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,50 +251,60 @@ class FehlerUpdateLib
|
||||
"Fehler ".$fehler[self::FEHLERCODE].(isset($fehler[self::FEHLER_KURZBZ]) ? " (".$fehler[self::FEHLER_KURZBZ].")" : "")." updated"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no fehler has been found
|
||||
|
||||
return success($fehler[self::FEHLERCODE]);
|
||||
// then add the fehler to the database
|
||||
$updateRes = $this->_ci->FehlerModel->insert(
|
||||
array_merge($fehler, ['insertamum' => 'NOW()', 'insertvon' => self::UPSERT_BY])
|
||||
);
|
||||
|
||||
// If an error occurred then return the error itself
|
||||
if (isError($updateRes)) return $updateRes;
|
||||
|
||||
// Prints info about the new added fehler
|
||||
$this->_ci->eprintflib->printMessage(
|
||||
sprintf(
|
||||
'A new fehler has been added into the database: '.
|
||||
'fehlercode => %s | fehler_kurzbz => %s | fehlertyp => %s',
|
||||
$fehler[self::FEHLERCODE],
|
||||
$fehler[self::FEHLER_KURZBZ],
|
||||
$fehler[self::FEHLERTYP_KURZBZ]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// no fehler has been found
|
||||
|
||||
// handle apps
|
||||
if (isset($fehler[self::APP]))
|
||||
// handle references
|
||||
if (isset($fehlerReferences[self::APP]))
|
||||
{
|
||||
$apps = $fehler[self::APP];
|
||||
if (is_string($apps)) $apps = [$apps];
|
||||
$this->_ci->load->model('system/FehlerApp_model', 'FehlerAppModel');
|
||||
$apps = $fehlerReferences[self::APP];
|
||||
|
||||
foreach ($apps as $app)
|
||||
// load all assigned apps
|
||||
$this->_ci->FehlerAppModel->addSelect(self::APP);
|
||||
$fehlerAppRes = $this->_ci->FehlerAppModel->loadWhere([self::FEHLERCODE => $fehler[self::FEHLERCODE]]);
|
||||
|
||||
$fehlerApps = hasData($fehlerAppRes) ? array_column(getData($fehlerAppRes), self::APP) : [];
|
||||
|
||||
$appsToInsert = array_diff($apps, $fehlerApps);
|
||||
|
||||
foreach ($appsToInsert as $app)
|
||||
{
|
||||
// check if app exists in db
|
||||
$this->_ci->AppModel->addSelect('1');
|
||||
$appRes = $this->_ci->AppModel->loadWhere(['app' => $app]);
|
||||
$fehlerAppsInsertRes = $this->_ci->FehlerAppModel->insert(
|
||||
[self::FEHLERCODE => $fehler[self::FEHLERCODE], self::APP => $app, 'insertamum' => 'NOW()', 'insertvon' => self::UPSERT_BY]
|
||||
);
|
||||
|
||||
if (!hasData($appRes)) return error("App ".$app." does not exist");
|
||||
// TODO add entry for each app
|
||||
if (isError($fehlerAppsInsertRes)) return $fehlerAppsInsertRes;
|
||||
|
||||
$this->_ci->eprintflib->printMessage(
|
||||
"Added app ".$app." to fehler ".$fehler[self::FEHLERCODE]
|
||||
);
|
||||
}
|
||||
|
||||
$fehler[self::APP] = $apps[0];
|
||||
}
|
||||
|
||||
// Then add the fehler to the database
|
||||
$fehlerInsertResult = $this->_ci->FehlerModel->insert(
|
||||
array_merge($fehler, ['insertamum' => 'NOW()', 'insertvon' => self::UPSERT_BY])
|
||||
);
|
||||
|
||||
// If an error occurred then return the error itself
|
||||
if (isError($fehlerInsertResult)) return $fehlerInsertResult;
|
||||
|
||||
// Prints info about the new added fehler
|
||||
$this->_ci->eprintflib->printMessage(
|
||||
sprintf(
|
||||
'A new fehler has been added into the database: '.
|
||||
'fehlercode => %s | fehler_kurzbz => %s | fehlertyp => %s',
|
||||
$fehler[self::FEHLERCODE],
|
||||
$fehler[self::FEHLER_KURZBZ],
|
||||
$fehler[self::FEHLERTYP_KURZBZ]
|
||||
)
|
||||
);
|
||||
|
||||
// If here then no blocking errors occurred
|
||||
return success();
|
||||
}
|
||||
@@ -292,13 +314,14 @@ class FehlerUpdateLib
|
||||
*/
|
||||
private function _createFehlerFromEntry($configEntry)
|
||||
{
|
||||
$fehler = [];
|
||||
$fehler = ['fehler' => [], 'references' => []];
|
||||
foreach (self::FEHLER_ATTRIBUTES as $attributeName => $attributeInfo)
|
||||
{
|
||||
$required = isset($attributeInfo['required']) && $attributeInfo['required'];
|
||||
if ($required && !isset($configEntry[$attributeName]))
|
||||
if (!isset($configEntry[$attributeName]))
|
||||
{
|
||||
return error('attribute'.$attributeName.' is missing');
|
||||
if ($required) return error('attribute'.$attributeName.' is missing');
|
||||
continue;
|
||||
}
|
||||
|
||||
$attributeValue = $configEntry[$attributeName];
|
||||
@@ -330,7 +353,29 @@ class FehlerUpdateLib
|
||||
return error('attribute'.$attributeName.' has invalid type');
|
||||
}
|
||||
|
||||
$fehler[$attributeName] = $configEntry[$attributeName];
|
||||
if ($attributeName == self::APP)
|
||||
{
|
||||
if (is_string($attributeValue)) $attributeValue = [$attributeValue];
|
||||
|
||||
foreach ($attributeValue as $app)
|
||||
{
|
||||
// check if app exists in db
|
||||
$this->_ci->AppModel->addSelect('1');
|
||||
$appRes = $this->_ci->AppModel->loadWhere(['app' => $app]);
|
||||
|
||||
if (!hasData($appRes)) return error("App ".$app." does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($attributeInfo['types']) && is_array($attributeInfo['types']) && in_array(self::TYPE_ARRAY, $attributeInfo['types']))
|
||||
{
|
||||
$fehler['references'][$attributeName] = $attributeValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$fehler['fehler'][$attributeName] = $attributeValue;
|
||||
}
|
||||
|
||||
}
|
||||
return success($fehler);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@ class IssuesLib
|
||||
const ERRORTYPE_CODE = 'error';
|
||||
const WARNINGTYPE_CODE = 'warning';
|
||||
|
||||
const STATUS_KURZBZ = 'status_kurzbz';
|
||||
const VERARBEITET_AMUM = 'verarbeitetamum';
|
||||
const VERARBEITET_VON = 'verarbeitetvon';
|
||||
|
||||
public function __construct($params = null)
|
||||
{
|
||||
$this->_ci =& get_instance();
|
||||
@@ -91,12 +95,16 @@ class IssuesLib
|
||||
return error("fehlercode_extern missing");
|
||||
|
||||
// get external fehlercode (unique for each app)
|
||||
$this->_ci->FehlerModel->addSelect('fehlercode');
|
||||
$fehlerRes = $this->_ci->FehlerModel->loadWhere(
|
||||
array(
|
||||
'fehlercode_extern' => $fehlercode_extern,
|
||||
'app' => $this->_app
|
||||
)
|
||||
$fehlerRes = $this->_ci->FehlerModel->execReadOnlyQuery(
|
||||
'
|
||||
SELECT
|
||||
fehlercode
|
||||
FROM
|
||||
system.tbl_fehler fe
|
||||
WHERE
|
||||
fehlercode_extern = ?
|
||||
AND EXISTS (SELECT 1 FROM system.tbl_fehler_app WHERE fehlercode = fe.fehlercode AND app = ?)',
|
||||
[$fehlercode_extern, $this->_app]
|
||||
);
|
||||
|
||||
if (isError($fehlerRes))
|
||||
@@ -105,8 +113,10 @@ class IssuesLib
|
||||
// check if there is a predefined custom error for the external issue
|
||||
if (hasData($fehlerRes))
|
||||
{
|
||||
$fehlerData = getData($fehlerRes)[0];
|
||||
// if found, use the code
|
||||
$fehlerData = getData($fehlerRes);
|
||||
if (count($fehlerData) > 1) return error("Multiple fehlercode_extern ".$fehlercode_extern. " for app ".$this->_app);
|
||||
$fehlerData = getData($fehlerRes)[0];
|
||||
$fehlercode = $fehlerData->fehlercode;
|
||||
}
|
||||
else
|
||||
@@ -128,9 +138,9 @@ class IssuesLib
|
||||
public function setBehoben($issue_id, $user)
|
||||
{
|
||||
$data = array(
|
||||
'status_kurzbz' => self::STATUS_BEHOBEN,
|
||||
'verarbeitetvon' => $user,
|
||||
'verarbeitetamum' => date('Y-m-d H:i:s')
|
||||
self::STATUS_KURZBZ => self::STATUS_BEHOBEN,
|
||||
self::VERARBEITET_VON => $user,
|
||||
self::VERARBEITET_AMUM => date('Y-m-d H:i:s')
|
||||
);
|
||||
|
||||
return $this->_changeIssueStatus($issue_id, $data, $user);
|
||||
@@ -145,8 +155,8 @@ class IssuesLib
|
||||
public function setInBearbeitung($issue_id, $user)
|
||||
{
|
||||
$data = array(
|
||||
'status_kurzbz' => self::STATUS_IN_BEARBEITUNG,
|
||||
'verarbeitetvon' => $user
|
||||
self::STATUS_KURZBZ => self::STATUS_IN_BEARBEITUNG,
|
||||
self::VERARBEITET_VON => $user
|
||||
);
|
||||
|
||||
return $this->_changeIssueStatus($issue_id, $data, $user);
|
||||
@@ -161,9 +171,9 @@ class IssuesLib
|
||||
public function setNeu($issue_id, $user)
|
||||
{
|
||||
$data = array(
|
||||
'status_kurzbz' => self::STATUS_NEU,
|
||||
'verarbeitetvon' => null,
|
||||
'verarbeitetamum' => null
|
||||
self::STATUS_KURZBZ => self::STATUS_NEU,
|
||||
self::VERARBEITET_VON => null,
|
||||
self::VERARBEITET_AMUM => null
|
||||
);
|
||||
|
||||
return $this->_changeIssueStatus($issue_id, $data, $user);
|
||||
@@ -185,13 +195,18 @@ class IssuesLib
|
||||
return error("Issue Id must be set correctly.");
|
||||
|
||||
// check if given status is same as existing
|
||||
$this->_ci->IssueModel->addSelect('status_kurzbz');
|
||||
$this->_ci->IssueModel->addSelect(self::STATUS_KURZBZ.', '.self::VERARBEITET_AMUM);
|
||||
$currStatus = $this->_ci->IssueModel->load($issue_id);
|
||||
|
||||
if (hasData($currStatus))
|
||||
{
|
||||
if (getData($currStatus)[0]->status_kurzbz == $data['status_kurzbz'])
|
||||
$currStatusData = getData($currStatus)[0];
|
||||
// if same status set, and verarbeitet amum is not being newly set
|
||||
if ($currStatusData->{self::STATUS_KURZBZ} == $data[self::STATUS_KURZBZ]
|
||||
&& !(isset($data[self::VERARBEITET_AMUM]) && !isset($currStatusData->{self::VERARBEITET_AMUM}))
|
||||
) {
|
||||
return success("Same status already set");
|
||||
}
|
||||
}
|
||||
else
|
||||
return error("Error when getting status");
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
class FehlerApp_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_fehler_app';
|
||||
$this->pk = array('fehlercode', 'app');
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,41 @@ class Fehler_model extends DB_Model
|
||||
$this->pk = array('fehlercode');
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all fehler for particular apps.
|
||||
* @param $apps string of one app or array with multiple
|
||||
* @return object success or error
|
||||
*/
|
||||
public function getByApps($apps)
|
||||
{
|
||||
if (is_string($apps)) $apps = [$apps];
|
||||
|
||||
$params = [];
|
||||
|
||||
$qry = "
|
||||
SELECT
|
||||
fehlercode, fehler_kurzbz, fehlercode_extern, fehlertext, fehlertyp_kurzbz
|
||||
FROM
|
||||
system.tbl_fehler fe";
|
||||
|
||||
if (!isEmptyArray($apps))
|
||||
{
|
||||
$qry .= "
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM
|
||||
system.tbl_fehler_app
|
||||
WHERE
|
||||
fehlercode = fe.fehlercode
|
||||
AND app IN ?
|
||||
)";
|
||||
|
||||
$params[] = $apps;
|
||||
}
|
||||
|
||||
$qry .= " ORDER BY fehlercode;";
|
||||
|
||||
return $this->execReadOnlyQuery($qry, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,20 @@ class Fehlerkonfiguration_model extends DB_Model
|
||||
|
||||
/**
|
||||
* Retrieve all set configuration parameters, optionally filtered by app.
|
||||
* @param string $app
|
||||
* @param string $apps
|
||||
* @return object success or error
|
||||
*/
|
||||
public function getKonfiguration($apps = null)
|
||||
{
|
||||
if (is_string($apps)) $apps = [$apps];
|
||||
$fehlerkonfiguration = array();
|
||||
$apps = is_string($apps) ? [$apps] : $apps;
|
||||
|
||||
$this->addSelect('fehlercode, konfigurationstyp_kurzbz, konfiguration, fehler_kurzbz');
|
||||
$this->addDistinct();
|
||||
$this->addSelect('fehler.fehlercode, konftyp.konfigurationstyp_kurzbz, tbl_fehler_konfiguration.konfiguration, fehler.fehler_kurzbz');
|
||||
$this->addJoin('system.tbl_fehler_konfigurationstyp konftyp', 'konfigurationstyp_kurzbz');
|
||||
$this->addJoin('system.tbl_fehler fehler', 'fehlercode');
|
||||
if (is_array($apps) && !isEmptyArray($apps)) $this->db->where_in('fehler.app', $apps);
|
||||
$this->addJoin('system.tbl_fehler_app fe_app', 'fehlercode');
|
||||
if (isset($apps) && !isEmptyArray($apps)) $this->db->where_in('fe_app.app', $apps);
|
||||
$fehlerkonfigurationRes = $this->load();
|
||||
|
||||
if (isError($fehlerkonfigurationRes)) return $fehlerkonfigurationRes;
|
||||
|
||||
@@ -11,37 +11,4 @@ class Fehlerkonfigurationstyp_model extends DB_Model
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ class Issue_model extends DB_Model
|
||||
|
||||
if (is_array($apps))
|
||||
{
|
||||
$qry .= ' AND app IN ?';
|
||||
$qry .= ' AND EXISTS (SELECT 1 FROM system.tbl_fehler_app WHERE fehlercode = fe.fehlercode AND app IN ?)';
|
||||
$params[] = $apps;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ $query .= "
|
||||
inhalt AS \"Inhalt\", inhalt_extern AS \"Inhalt extern\", iss.person_id AS \"PersonId\", iss.oe_kurzbz AS \"OE\",
|
||||
ftyp.bezeichnung_mehrsprachig[".$this->db->escape($language_index)."] AS \"Fehlertyp\",
|
||||
stat.bezeichnung_mehrsprachig[".$this->db->escape($language_index)."] AS \"Fehlerstatus\",
|
||||
verarbeitetvon AS \"Verarbeitet von\",verarbeitetamum AS \"Verarbeitet am\", fr.app AS \"Applikation\",
|
||||
verarbeitetvon AS \"Verarbeitet von\",verarbeitetamum AS \"Verarbeitet am\",
|
||||
(SELECT STRING_AGG(app, ', ') FROM system.tbl_fehler_app WHERE fehlercode = fr.fehlercode GROUP BY fehlercode) AS \"Applikation\",
|
||||
fr.fehlertyp_kurzbz AS \"Fehlertypcode\", iss.status_kurzbz AS \"Statuscode\",
|
||||
pers.vorname AS \"Vorname\", pers.nachname AS \"Nachname\",
|
||||
(
|
||||
@@ -168,7 +169,7 @@ $query .= ")
|
||||
|
||||
$query .= ") ";
|
||||
|
||||
if (!isEmptyString($APPS)) $query .= " AND fr.app IN ".$APPS;
|
||||
if (!isEmptyString($APPS)) $query .= " AND EXISTS (SELECT 1 FROM system.tbl_fehler_app WHERE fehlercode = fr.fehlercode AND app IN ".$APPS.")";
|
||||
|
||||
$query .= " ORDER BY
|
||||
CASE
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
// get assigned Konfiguration
|
||||
$query = "SELECT
|
||||
konftyp.konfigurationstyp_kurzbz, fe.fehlercode, fe.fehler_kurzbz, konf.konfiguration, fe.app,
|
||||
konftyp.konfigurationstyp_kurzbz, fe.fehlercode, fe.fehler_kurzbz, konf.konfiguration,
|
||||
(SELECT STRING_AGG(app, ', ') FROM system.tbl_fehler_app WHERE fehlercode = fe.fehlercode GROUP BY fehlercode) AS app,
|
||||
konftyp.beschreibung AS konfigurationsbeschreibung, konftyp.konfigurationsdatentyp, fe.fehlertext
|
||||
FROM
|
||||
system.tbl_fehler_konfiguration konf
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
// get assigned Zustaendigkeiten
|
||||
$query = "SELECT fehlerzustaendigkeiten_id, fe.fehlercode, fe.fehlercode_extern, fehler_kurzbz, fehlertext, fehlertyp_kurzbz, fe.app,
|
||||
$query = "SELECT fehlerzustaendigkeiten_id, fe.fehlercode, fe.fehlercode_extern, fehler_kurzbz, fehlertext, fehlertyp_kurzbz,
|
||||
(SELECT STRING_AGG(app, ', ') FROM system.tbl_fehler_app WHERE fehlercode = fe.fehlercode GROUP BY fehlercode) AS app,
|
||||
pers.person_id, pers.vorname, pers.nachname,
|
||||
oe.oe_kurzbz, oe.bezeichnung AS oe_bezeichnung, funk.funktion_kurzbz, funk.beschreibung AS funktion_beschreibung
|
||||
FROM system.tbl_fehler_zustaendigkeiten zst
|
||||
|
||||
@@ -13,4 +13,39 @@ if(!$result = @$db->db_query("SELECT insertamum FROM system.tbl_fehler LIMIT 1")
|
||||
echo '<strong>system.tbl_fehler '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Spalten insertamum, insertvon, updateamum, updatevon in system.tbl_fehler hinzugefügt';
|
||||
}
|
||||
|
||||
if (!$result = @$db->db_query('SELECT 1 FROM system.tbl_fehler_app LIMIT 1'))
|
||||
{
|
||||
$qry = 'CREATE TABLE system.tbl_fehler_app
|
||||
(
|
||||
fehlercode varchar(64),
|
||||
app varchar(32) NOT NULL,
|
||||
insertamum timestamp DEFAULT now(),
|
||||
insertvon varchar(32)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE system.tbl_fehler_app IS \'Fehler app Zuordnungen\';
|
||||
COMMENT ON COLUMN system.tbl_fehler_app.fehlercode IS \'Fehler\';
|
||||
COMMENT ON COLUMN system.tbl_fehler_app.app IS \'dem Fehler zugeweisene App\';
|
||||
|
||||
ALTER TABLE system.tbl_fehler_app ADD CONSTRAINT pk_fehler_app PRIMARY KEY (fehlercode, app);
|
||||
ALTER TABLE system.tbl_fehler_app ADD CONSTRAINT fk_fehler_app_app FOREIGN KEY (app) REFERENCES system.tbl_app(app) ON UPDATE CASCADE ON DELETE RESTRICT;
|
||||
ALTER TABLE system.tbl_fehler_app ADD CONSTRAINT fk_fehler_app_fehlercode FOREIGN KEY (fehlercode) REFERENCES system.tbl_fehler(fehlercode) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
GRANT SELECT, UPDATE, INSERT, DELETE ON system.tbl_fehler_app TO web;
|
||||
GRANT SELECT, UPDATE, INSERT, DELETE ON system.tbl_fehler_app TO vilesci;
|
||||
|
||||
-- prefill values
|
||||
INSERT INTO system.tbl_fehler_app(fehlercode, app, insertvon)
|
||||
SELECT fehlercode, app, \'dbupdate\' FROM system.tbl_fehler;
|
||||
|
||||
-- remove not null constraint from old table
|
||||
ALTER TABLE system.tbl_fehler ALTER COLUMN app DROP NOT NULL;
|
||||
';
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_fehler_app: '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo ' system.tbl_fehler_app: Tabelle hinzugefuegt<br>';
|
||||
}
|
||||
Reference in New Issue
Block a user