mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 18:02:18 +00:00
Issue system: adapted to work with multiple apps per fehler
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user